@web-ppt/edit-core 0.5.0-beta.1 → 0.5.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/dist/collaboration-identity.d.ts +3 -0
  4. package/dist/commands/add-slide-identity.d.ts +2 -0
  5. package/dist/commands/convert-to-custom-geometry.d.ts +4 -0
  6. package/dist/commands/element-geometry.d.ts +6 -0
  7. package/dist/commands/element-hierarchy.d.ts +6 -0
  8. package/dist/commands/element-table-style.d.ts +5 -0
  9. package/dist/commands/frame-decomposition.d.ts +10 -0
  10. package/dist/commands/generated-creation-defaults.d.ts +4 -0
  11. package/dist/commands/geometry-types.d.ts +22 -0
  12. package/dist/commands/group-types.d.ts +24 -0
  13. package/dist/commands/group.d.ts +4 -0
  14. package/dist/commands/insertion-host.d.ts +3 -0
  15. package/dist/commands/insertion-rect.d.ts +2 -0
  16. package/dist/commands/patch-invalidation.d.ts +4 -0
  17. package/dist/commands/patch.d.ts +4 -0
  18. package/dist/commands/record-clone.d.ts +3 -0
  19. package/dist/commands/set-geometry.d.ts +4 -0
  20. package/dist/commands/set-table-style.d.ts +3 -0
  21. package/dist/commands/spid.d.ts +1 -0
  22. package/dist/commands/table-style-types.d.ts +28 -0
  23. package/dist/commands/text-target.d.ts +1 -0
  24. package/dist/commands/types.d.ts +29 -4
  25. package/dist/commands/ungroup.d.ts +4 -0
  26. package/dist/custom-geometry-path.d.ts +3 -0
  27. package/dist/custom-geometry.d.ts +12 -0
  28. package/dist/document-B1jjN-QB.js +274 -0
  29. package/dist/edit-core.js +3597 -2639
  30. package/dist/editor.d.ts +6 -1
  31. package/dist/generate/custom-geometry.d.ts +2 -0
  32. package/dist/generate/index.d.ts +12 -0
  33. package/dist/generate/links.d.ts +3 -0
  34. package/dist/generate/materialize.d.ts +2 -0
  35. package/dist/generate/media.d.ts +13 -0
  36. package/dist/generate/table.d.ts +4 -0
  37. package/dist/generate/template.d.ts +3 -0
  38. package/dist/generate.js +744 -0
  39. package/dist/hyperlink.d.ts +2 -0
  40. package/dist/identity-allocation.d.ts +12 -0
  41. package/dist/identity-watermark.d.ts +4 -0
  42. package/dist/image-resource-DbgJS9n-.js +24 -0
  43. package/dist/{index-D4ZTaYOa.js → index-D2JizcOQ.js} +7 -7
  44. package/dist/index.d.ts +11 -3
  45. package/dist/insertion-CGpb504L.js +6152 -0
  46. package/dist/layout-projection.d.ts +2 -0
  47. package/dist/opc/patch.d.ts +2 -0
  48. package/dist/opc.js +1 -1
  49. package/dist/paragraph-level.d.ts +11 -0
  50. package/dist/paragraph-property-schema.d.ts +1 -1
  51. package/dist/{patch-DO8497wO.js → patch-D7lZelRa.js} +111 -94
  52. package/dist/patch-change.d.ts +4 -0
  53. package/dist/patch-events.d.ts +12 -0
  54. package/dist/recovery-identity.d.ts +2 -1
  55. package/dist/run-property-schema.d.ts +1 -1
  56. package/dist/save/geometry.d.ts +5 -0
  57. package/dist/save/insertion.d.ts +3 -0
  58. package/dist/save/notes.d.ts +2 -0
  59. package/dist/save/run-overrides.d.ts +10 -0
  60. package/dist/save/shape-format.d.ts +3 -0
  61. package/dist/save/table-style-part.d.ts +11 -0
  62. package/dist/save/table.d.ts +3 -0
  63. package/dist/save/text-source-less.d.ts +6 -0
  64. package/dist/save.js +468 -1441
  65. package/dist/table-direct-markup.d.ts +7 -1
  66. package/dist/table-style-part-DBtpxmuo.js +1042 -0
  67. package/dist/table-style.d.ts +20 -0
  68. package/dist/text-model.d.ts +1 -1
  69. package/dist/types.d.ts +44 -1
  70. package/dist/xml.js +1 -1
  71. package/package.json +6 -2
  72. package/dist/insertion-DabLme_U.js +0 -5471
@@ -0,0 +1,1042 @@
1
+ import { P as be, k as ne, Q as Se, l as A, R as U, g as j, n as w, S as we, T as Pe, U as Ee, V as Ue, W as xe, X as ke, Y as Ce, Z as Me } from "./insertion-CGpb504L.js";
2
+ import { p as b, x as p, f as S, i as y, c as x, a as O, b as v, s as N, r as Q, h as ge, d as k, m as ie, g as ae, P as f, D as L, n as B, k as X, l as D, j as I, M as C, e as Ie, o as Re, X as Le, q as Ae } from "./index-D2JizcOQ.js";
3
+ const Oe = "http://schemas.openxmlformats.org/package/2006/relationships", $e = "http://schemas.openxmlformats.org/package/2006/content-types";
4
+ function _t(e) {
5
+ var o, r, i;
6
+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), a = (s, c, l) => {
7
+ const u = (c.relationships ?? []).filter((m) => m.targetId !== l), d = t.get(s) ?? [];
8
+ d.push(...u), t.set(s, d);
9
+ for (const m of c.resources ?? []) {
10
+ if (!u.some(($) => !$.targetMode && ne(s, $.target) === m.targetPart)) continue;
11
+ const T = n.get(m.targetPart);
12
+ if (T && (T.hash !== m.hash || T.bytes !== m.bytes))
13
+ throw new Error(`多个媒体资源争用目标 part:${m.targetPart}`);
14
+ n.set(m.targetPart, m);
15
+ }
16
+ };
17
+ for (const s of Object.values(e.elements)) {
18
+ const c = (o = s.meta.origin) == null ? void 0 : o.part;
19
+ if (!c) continue;
20
+ const l = s.meta.imageReplacement, u = [s.meta.insertion, l ? {
21
+ relationships: l.relationships,
22
+ resources: [e.imageResources[l.resourceHash]]
23
+ } : void 0];
24
+ for (const d of u)
25
+ d && a(c, d, (r = s.meta.imageReplacement) == null ? void 0 : r.suppressedRelationshipId);
26
+ }
27
+ for (const s of Object.values(e.slides)) {
28
+ const c = (i = s.origin) == null ? void 0 : i.part, l = s.backgroundImage;
29
+ if (!c || !l) continue;
30
+ const u = l.resourceHashes.map((d) => e.imageResources[d]);
31
+ if (u.some((d) => !d))
32
+ throw new Error(`幻灯片 ${s.id} 的图片背景资源不存在`);
33
+ a(c, { relationships: l.relationships, resources: u });
34
+ }
35
+ return { relationships: t, resources: n };
36
+ }
37
+ function z(e, t) {
38
+ const n = e ? b(e) : b(`<Relationships xmlns="${Oe}"/>`), a = new Map(p(n.root, { localName: "Relationship" }).flatMap((o) => {
39
+ var l, u, d, m;
40
+ const r = (l = S(o, { localName: "Id", namespaceUri: null })) == null ? void 0 : l.value, i = (u = S(o, { localName: "Type", namespaceUri: null })) == null ? void 0 : u.value, s = (d = S(o, { localName: "Target", namespaceUri: null })) == null ? void 0 : d.value, c = (m = S(o, { localName: "TargetMode", namespaceUri: null })) == null ? void 0 : m.value;
41
+ return r && i && s ? [[r, { type: i, target: s, mode: c }]] : [];
42
+ }));
43
+ for (const o of t) {
44
+ const r = a.get(o.targetId);
45
+ if (r) {
46
+ if (r.type === o.type && r.target === o.target && r.mode === o.targetMode) continue;
47
+ throw new Error(`目标关系 id 冲突:${o.targetId}`);
48
+ }
49
+ a.set(o.targetId, {
50
+ type: o.type,
51
+ target: o.target,
52
+ mode: o.targetMode
53
+ }), y(n.root, x("Relationship", {
54
+ attributes: [
55
+ ["Id", o.targetId],
56
+ ["Type", o.type],
57
+ ["Target", o.target],
58
+ ...o.targetMode ? [["TargetMode", o.targetMode]] : []
59
+ ]
60
+ }));
61
+ }
62
+ return O(n);
63
+ }
64
+ function Be(e, t) {
65
+ var r, i;
66
+ const n = e ? b(e) : b(`<Types xmlns="${$e}"/>`), a = p(n.root, { localName: "Default" }), o = p(n.root, { localName: "Override" });
67
+ for (const s of t) {
68
+ const c = a.find((h) => {
69
+ var T;
70
+ return ((T = S(h, { localName: "Extension", namespaceUri: null })) == null ? void 0 : T.value.toLowerCase()) === s.extension.toLowerCase();
71
+ });
72
+ if ((c && ((r = S(c, { localName: "ContentType", namespaceUri: null })) == null ? void 0 : r.value)) === s.mime) continue;
73
+ const u = `/${s.targetPart}`, d = o.find((h) => {
74
+ var T;
75
+ return ((T = S(h, { localName: "PartName", namespaceUri: null })) == null ? void 0 : T.value) === u;
76
+ });
77
+ if (d) {
78
+ if (((i = S(d, {
79
+ localName: "ContentType",
80
+ namespaceUri: null
81
+ })) == null ? void 0 : i.value) !== s.mime)
82
+ throw new Error(`媒体资源与既有 Content-Type Override 冲突:${s.targetPart}`);
83
+ continue;
84
+ }
85
+ const m = x(c ? "Override" : "Default", {
86
+ attributes: c ? [["PartName", u], ["ContentType", s.mime]] : [["Extension", s.extension], ["ContentType", s.mime]]
87
+ });
88
+ y(n.root, m), c ? o.push(m) : a.push(m);
89
+ }
90
+ return O(n);
91
+ }
92
+ function Ft(e) {
93
+ return be(e.bytes);
94
+ }
95
+ const se = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide", q = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide";
96
+ function _e(e) {
97
+ var n;
98
+ const t = ge(e, {
99
+ localName: "spTree",
100
+ namespaceUri: f
101
+ });
102
+ for (const a of t ? p(t, {
103
+ localName: "sp",
104
+ namespaceUri: f
105
+ }) : []) {
106
+ const o = k(a, {
107
+ localName: "nvSpPr",
108
+ namespaceUri: f
109
+ }), r = o && k(o, {
110
+ localName: "nvPr",
111
+ namespaceUri: f
112
+ }), i = r && k(r, {
113
+ localName: "ph",
114
+ namespaceUri: f
115
+ }), s = (n = i == null ? void 0 : i.attributes.find((l) => l.namespaceUri === null && l.localName === "type")) == null ? void 0 : n.value, c = k(a, {
116
+ localName: "txBody",
117
+ namespaceUri: f
118
+ });
119
+ if (s === "body" && c) return c;
120
+ }
121
+ throw new Error("notesSlide 缺少可编辑的 body 占位符");
122
+ }
123
+ function ce(e, t) {
124
+ for (const n of [...e.children]) v(e, n);
125
+ y(e, ae(t));
126
+ }
127
+ function Fe(e, t) {
128
+ const n = e ? ie(e) : x("a:p", { selfClosing: !1 });
129
+ let a = ge(n, { localName: "t" });
130
+ if (!a) {
131
+ const i = n.prefix ? `${n.prefix}:` : "", s = x(`${i}r`, { selfClosing: !1 }), c = p(n).find((l) => l.localName === "endParaRPr");
132
+ if (c) {
133
+ const l = x(`${i}rPr`);
134
+ for (const u of c.attributes)
135
+ N(l, u.name, u.value, u.quote);
136
+ for (const u of c.children)
137
+ y(l, ie(u));
138
+ y(s, l);
139
+ }
140
+ a = x(`${i}t`, { selfClosing: !1 }), y(s, a), y(n, s, c ?? null);
141
+ }
142
+ ce(a, t);
143
+ let o = !1;
144
+ const r = (i) => {
145
+ for (const s of p(i))
146
+ s.localName === "t" ? o ? ce(s, "") : o = !0 : r(s);
147
+ };
148
+ return r(n), n;
149
+ }
150
+ function ee(e, t) {
151
+ const n = b(e), a = _e(n.root), o = p(a, {
152
+ localName: "p",
153
+ namespaceUri: L
154
+ });
155
+ for (const r of o) v(a, r);
156
+ for (const [r, i] of t.split(`
157
+ `).entries()) {
158
+ const s = o[r] ?? o[o.length - 1] ?? null;
159
+ y(a, Fe(s, i));
160
+ }
161
+ return O(n);
162
+ }
163
+ function he() {
164
+ return new TextEncoder().encode(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
165
+ <p:notes xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
166
+ <p:cSld><p:spTree>
167
+ <p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>
168
+ <p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>
169
+ <p:sp><p:nvSpPr><p:cNvPr id="2" name="备注正文"/><p:cNvSpPr/><p:nvPr><p:ph type="body" idx="1"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:r><a:t></a:t></a:r></a:p></p:txBody></p:sp>
170
+ </p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>
171
+ </p:notes>`);
172
+ }
173
+ function Xt(e) {
174
+ return ee(he(), e);
175
+ }
176
+ const E = (e, t) => {
177
+ var n;
178
+ return (n = e.attributes.find((a) => a.localName === t && a.namespaceUri === null)) == null ? void 0 : n.value;
179
+ };
180
+ function Xe(e, t, n) {
181
+ const a = b(e);
182
+ let o = !1;
183
+ for (const r of p(a.root, { localName: "Relationship" }))
184
+ E(r, "Type") !== t || E(r, "TargetMode") === "External" || (N(r, "Target", n), Q(r, "TargetMode"), o = !0);
185
+ return { bytes: o ? O(a) : e, found: o };
186
+ }
187
+ function De(e) {
188
+ const t = new Set(e ? p(
189
+ b(e).root,
190
+ { localName: "Relationship" }
191
+ ).flatMap((n) => E(n, "Id") ?? []) : []);
192
+ for (let n = 1; Number.isSafeInteger(n); n++) {
193
+ const a = `rId${n}`;
194
+ if (!t.has(a)) return a;
195
+ }
196
+ throw new Error("备注页的页面回指关系身份已耗尽");
197
+ }
198
+ function qe(e, t, n) {
199
+ const a = j(t, n);
200
+ if (e) {
201
+ const r = Xe(e, se, a);
202
+ if (r.found) return r.bytes;
203
+ }
204
+ const o = De(e);
205
+ return z(e, [{
206
+ sourceId: o,
207
+ targetId: o,
208
+ type: se,
209
+ target: a
210
+ }]);
211
+ }
212
+ function Dt(e, t) {
213
+ if (!e.origin) throw new Error(`页面 ${e.id} 缺少 notes 关系宿主`);
214
+ if (!t)
215
+ return e.notes ? z(void 0, [{
216
+ sourceId: e.notes.relationshipId,
217
+ targetId: e.notes.relationshipId,
218
+ type: q,
219
+ target: j(e.origin.part, e.notes.targetPart)
220
+ }]) : z(void 0, []);
221
+ const n = b(t), a = p(n.root, { localName: "Relationship" });
222
+ if (!e.notes) {
223
+ let i = !1;
224
+ for (const s of a)
225
+ E(s, "Type") === q && E(s, "TargetMode") !== "External" && (v(n.root, s), i = !0);
226
+ return i ? O(n) : t;
227
+ }
228
+ const o = a.find((i) => E(i, "Id") === e.notes.relationshipId);
229
+ if (!o) return z(t, [{
230
+ sourceId: e.notes.relationshipId,
231
+ targetId: e.notes.relationshipId,
232
+ type: q,
233
+ target: j(e.origin.part, e.notes.targetPart)
234
+ }]);
235
+ if (E(o, "Type") !== q)
236
+ throw new Error(`页面 ${e.id} 的 notes 关系 id 与其它关系冲突`);
237
+ const r = j(e.origin.part, e.notes.targetPart);
238
+ return E(o, "Target") === r && E(o, "TargetMode") === void 0 ? t : (N(o, "Target", r), Q(o, "TargetMode"), O(n));
239
+ }
240
+ function je(e, t, n) {
241
+ var r;
242
+ const a = t.origin && A(t.origin.part), o = a && ((r = e.package) == null ? void 0 : r.parts[a]);
243
+ return !o || !t.origin ? !1 : p(b(o).root, { localName: "Relationship" }).some((i) => {
244
+ const s = E(i, "Target");
245
+ return E(i, "Type") === q && E(i, "TargetMode") !== "External" && !!s && n.has(ne(t.origin.part, s));
246
+ });
247
+ }
248
+ function qt(e, t, n) {
249
+ var r, i, s;
250
+ const a = new Set([...n].filter(Se));
251
+ for (const c of Object.values(e.slides)) {
252
+ const l = c.notes;
253
+ if (l) {
254
+ if (a.has(l.targetPart) || !((r = e.package) != null && r.parts[l.targetPart]) && !t[l.targetPart])
255
+ a.add(l.targetPart), n.add(l.targetPart), n.add(A(l.targetPart));
256
+ else if (U(c.ovr, "notes") && !t[l.targetPart]) {
257
+ const u = l.sourcePart ?? l.targetPart, d = (i = e.package) == null ? void 0 : i.parts[u];
258
+ if (!d) throw new Error(`找不到备注保存基线:${u}`);
259
+ t[l.targetPart] = d.slice();
260
+ }
261
+ }
262
+ }
263
+ const o = /* @__PURE__ */ new Map();
264
+ for (const c of Object.values(e.slides)) {
265
+ if (!c.origin || !(!!c.notes && a.has(c.notes.targetPart) || je(e, c, a)) || (o.set(c.origin.part, c), c.creation)) continue;
266
+ const u = A(c.origin.part);
267
+ if (t[u] || n.has(u)) continue;
268
+ const d = (s = e.package) == null ? void 0 : s.parts[u];
269
+ d ? t[u] = d.slice() : n.add(u);
270
+ }
271
+ return { relationshipSlides: o, trackedParts: a };
272
+ }
273
+ function jt(e, t, n, a) {
274
+ var o, r, i;
275
+ for (const s of Object.values(e.slides)) {
276
+ const c = s.notes;
277
+ if (!c) continue;
278
+ if (n.trackedParts.has(c.targetPart)) {
279
+ const m = c.sourcePart ? t[c.sourcePart] ?? ((o = e.package) == null ? void 0 : o.parts[c.sourcePart]) : void 0;
280
+ if (c.sourcePart && !m) throw new Error(`找不到备注克隆来源:${c.sourcePart}`);
281
+ const h = U(s.ovr, "notes") ? s.ovr.notes : s.src.notes ?? "";
282
+ a[c.targetPart] = ee(m ?? he(), h);
283
+ const T = c.sourcePart ? t[A(c.sourcePart)] ?? ((r = e.package) == null ? void 0 : r.parts[A(c.sourcePart)]) : void 0;
284
+ a[A(c.targetPart)] = qe(
285
+ T,
286
+ c.targetPart,
287
+ s.origin.part
288
+ );
289
+ continue;
290
+ }
291
+ const l = t[c.targetPart];
292
+ if (!l) continue;
293
+ const u = (i = e.package) == null ? void 0 : i.parts[c.targetPart];
294
+ (U(s.ovr, "notes") || u && (u.length !== l.length || u.some((m, h) => m !== l[h]))) && (a[c.targetPart] = U(s.ovr, "notes") ? ee(l, s.ovr.notes) : l);
295
+ }
296
+ }
297
+ const Y = "http://schemas.microsoft.com/office/powerpoint/2015/09/main", oe = /* @__PURE__ */ new Set([
298
+ "vortex",
299
+ "switch",
300
+ "flip",
301
+ "ripple",
302
+ "honeycomb",
303
+ "glitter",
304
+ "warp",
305
+ "flythrough",
306
+ "flash",
307
+ "shred",
308
+ "reveal",
309
+ "wheelReverse",
310
+ "ferris",
311
+ "gallery",
312
+ "conveyor",
313
+ "pan",
314
+ "doors",
315
+ "window",
316
+ "prism"
317
+ ]), ze = /* @__PURE__ */ new Set([
318
+ "fade",
319
+ "cut",
320
+ "push",
321
+ "pull",
322
+ "cover",
323
+ "wipe",
324
+ "split",
325
+ "zoom",
326
+ "dissolve",
327
+ "checker",
328
+ "blinds",
329
+ "comb",
330
+ "wheel",
331
+ "circle",
332
+ "diamond",
333
+ "plus",
334
+ "wedge",
335
+ "newsflash",
336
+ "randomBar",
337
+ "strips",
338
+ "random",
339
+ "fadeThroughBlack"
340
+ ]), Ve = /* @__PURE__ */ new Set([I, Y]);
341
+ function Ge(e) {
342
+ return e <= 625 ? "fast" : e <= 875 ? "med" : "slow";
343
+ }
344
+ function W(e, t) {
345
+ for (const n of [...e.attributes])
346
+ t(n) && Q(e, n.name);
347
+ }
348
+ function Ne(e) {
349
+ return e === "p" ? f : e === "p14" ? I : Y;
350
+ }
351
+ function Ye(e, t, n) {
352
+ const a = Ne(n);
353
+ return e && p(e).find((o) => o.namespaceUri === a && ye(o) === t);
354
+ }
355
+ function ye(e) {
356
+ if (e.namespaceUri === f)
357
+ return e.localName === "random" ? "dissolve" : e.localName === "fadeThroughBlack" ? "fade" : ze.has(e.localName) ? e.localName : void 0;
358
+ if (e.namespaceUri === I && oe.has(e.localName)) return e.localName;
359
+ if (e.namespaceUri === Y && e.localName === "morph") return "morph";
360
+ }
361
+ function ve(e) {
362
+ return ye(e) !== void 0;
363
+ }
364
+ function He(e, t, n, a) {
365
+ const o = Ye(a, e.type, t), r = o ? D(o) : w(n, Ne(t), e.type);
366
+ if (W(r, (i) => i.namespaceUri === null && ["dir", "orient", "option"].includes(i.localName)), e.type === "split" && e.dir) {
367
+ const [i, s] = e.dir.split("-");
368
+ N(r, "orient", i), N(r, "dir", s);
369
+ } else e.dir && N(r, "dir", e.dir);
370
+ return e.type === "morph" && N(r, "option", e.morphBy ?? "byObject"), r;
371
+ }
372
+ function le(e, t, n, a, o) {
373
+ const r = o ? D(o) : w(a, f, "transition"), i = p(r).filter(ve);
374
+ for (const c of i.slice(1)) v(r, c);
375
+ W(r, (c) => c.namespaceUri === null && ["spd", "advTm", "dur"].includes(c.localName) || c.namespaceUri === I && c.localName === "dur"), n || W(r, (c) => c.namespaceUri === I || c.namespaceUri === Y), N(r, "spd", Ge(e.durationMs)), n && (N(r, "xmlns:p14", I), N(r, "p14:dur", String(e.durationMs))), e.advanceAfterMs !== void 0 && N(r, "advTm", String(e.advanceAfterMs));
376
+ const s = He(e, t, r, o);
377
+ if (i[0]) B(r, i[0], [s]);
378
+ else {
379
+ const c = r.children.find((l) => l.type === "element") ?? null;
380
+ y(r, s, c);
381
+ }
382
+ return r;
383
+ }
384
+ function We(e) {
385
+ if (!oe.has(e.type) && e.type !== "morph") return e;
386
+ const t = ["gallery", "conveyor", "pan", "reveal"].includes(e.type) ? "push" : "fade";
387
+ return {
388
+ type: t,
389
+ durationMs: e.durationMs,
390
+ ...t === "push" && e.dir && ["l", "r", "u", "d"].includes(e.dir) ? { dir: e.dir } : {},
391
+ ...e.advanceAfterMs !== void 0 ? { advanceAfterMs: e.advanceAfterMs } : {}
392
+ };
393
+ }
394
+ function M(e) {
395
+ return e && p(e).find((t) => t.namespaceUri === f && t.localName === "transition");
396
+ }
397
+ function Ke(e) {
398
+ var a;
399
+ const t = ((a = e.attributes.find((o) => o.namespaceUri === null && o.localName === "Requires")) == null ? void 0 : a.value.trim().split(/\s+/).filter(Boolean)) ?? [], n = Re(e).namespaces;
400
+ return t.length > 0 && t.every((o) => Ve.has(n.get(o) ?? ""));
401
+ }
402
+ function te(e) {
403
+ const t = p(e);
404
+ return {
405
+ choice: t.find((n) => n.namespaceUri === C && n.localName === "Choice" && Ke(n)),
406
+ fallback: t.find((n) => n.namespaceUri === C && n.localName === "Fallback")
407
+ };
408
+ }
409
+ function V(e, t) {
410
+ const n = M(e);
411
+ if (n) B(e, n, [t]);
412
+ else {
413
+ const a = e.children.find((o) => o.type === "element") ?? null;
414
+ y(e, t, a);
415
+ }
416
+ }
417
+ function Te(e, t) {
418
+ const n = p(e), a = n.findIndex((i) => i.namespaceUri === C && i.localName === "Choice"), o = n.indexOf(t);
419
+ if (a < 0 || o <= a) return;
420
+ const r = [...n];
421
+ r.splice(o, 1), r.splice(a, 0, t), Ie(e, r);
422
+ }
423
+ function Qe(e, t) {
424
+ const n = (t == null ? void 0 : t.namespaceUri) === f ? t : void 0, a = (t == null ? void 0 : t.namespaceUri) === C ? D(t) : x("mc:AlternateContent", { selfClosing: !1 });
425
+ N(a, "xmlns:mc", C);
426
+ const o = e.type === "morph";
427
+ let { choice: r, fallback: i } = te(a);
428
+ if (!r || !M(r)) {
429
+ r = x("mc:Choice", { selfClosing: !1 });
430
+ const u = a.children.find((d) => d.type === "element") ?? null;
431
+ y(a, r, u);
432
+ }
433
+ const s = M(r) ?? n;
434
+ N(r, "xmlns:p14", I), o && N(r, "xmlns:p159", Y), N(r, "Requires", o ? "p159" : "p14"), Te(a, r), V(r, le(
435
+ e,
436
+ o ? "p159" : oe.has(e.type) ? "p14" : "p",
437
+ !0,
438
+ r,
439
+ s
440
+ )), i || (i = x("mc:Fallback", { selfClosing: !1 }), y(a, i));
441
+ const c = M(i) ?? n, l = We(e);
442
+ return V(i, le(
443
+ l,
444
+ "p",
445
+ !1,
446
+ i,
447
+ c
448
+ )), a;
449
+ }
450
+ function Ze(e) {
451
+ return e.namespaceUri !== C || e.localName !== "AlternateContent" ? !1 : p(e).some((t) => t.namespaceUri === C && (t.localName === "Choice" || t.localName === "Fallback") && M(t) !== void 0);
452
+ }
453
+ function Je(e) {
454
+ return p(e).filter((t) => t.namespaceUri === f && t.localName === "transition" || Ze(t));
455
+ }
456
+ function J(e, t) {
457
+ const n = D(e);
458
+ for (const a of p(n).filter(ve))
459
+ v(n, a);
460
+ return W(n, (a) => a.namespaceUri === null && ["spd", "dur", "advTm"].includes(a.localName) || a.namespaceUri === I && a.localName === "dur"), t.advanceAfterMs !== void 0 && N(n, "advTm", String(t.advanceAfterMs)), n;
461
+ }
462
+ function et(e, t) {
463
+ if (e.namespaceUri === f) return J(e, t);
464
+ const n = D(e);
465
+ let a = te(n), o = a.choice;
466
+ if (!o || !M(o)) {
467
+ o = x("mc:Choice", { selfClosing: !1 });
468
+ const c = n.children.find((l) => l.type === "element") ?? null;
469
+ y(n, o, c);
470
+ }
471
+ N(o, "xmlns:p14", I), N(o, "Requires", "p14");
472
+ const r = M(o), i = M(a.fallback), s = r ?? i;
473
+ if (s ? V(o, J(s, t)) : V(o, w(o, f, "transition")), Te(n, o), a = te(n), a.fallback) {
474
+ const c = M(a.fallback);
475
+ c ? B(a.fallback, c, [J(c, t)]) : V(
476
+ a.fallback,
477
+ w(a.fallback, f, "transition")
478
+ );
479
+ } else {
480
+ const c = x("mc:Fallback", { selfClosing: !1 });
481
+ y(n, c), y(c, w(c, f, "transition"));
482
+ }
483
+ return n;
484
+ }
485
+ function tt(e) {
486
+ const t = (a, o = []) => a.attributes.some((r) => r.name !== "xmlns" && r.prefix !== "xmlns" && !(r.namespaceUri === null && o.includes(r.localName))), n = (a) => t(a) || a.children.some((o) => o.type === "element" || o.type === "text" && o.value.trim() || o.type !== "text");
487
+ return e.namespaceUri === f ? n(e) : t(e) || p(e).some((a) => t(a, ["Requires"]) || a.children.some((o) => o.type !== "element" ? o.type !== "text" || !!o.value.trim() : o.namespaceUri === f && o.localName === "transition" ? n(o) : !0));
488
+ }
489
+ function nt(e, t, n = !1) {
490
+ const a = Je(e.root);
491
+ if (t.type === "none") {
492
+ if (a[0]) {
493
+ const i = et(a[0], t), s = n || t.advanceAfterMs !== void 0 || tt(i) ? [i] : [];
494
+ B(e.root, a[0], s);
495
+ for (const c of a.slice(1)) v(e.root, c);
496
+ } else if (n || t.advanceAfterMs !== void 0) {
497
+ const i = w(e.root, f, "transition");
498
+ t.advanceAfterMs !== void 0 && N(i, "advTm", String(t.advanceAfterMs)), X(e.root, i);
499
+ }
500
+ return;
501
+ }
502
+ const o = Qe(t, a[0]);
503
+ if (a[0]) {
504
+ B(e.root, a[0], [o]);
505
+ for (const i of a.slice(1)) v(e.root, i);
506
+ return;
507
+ }
508
+ const r = w(e.root, f, "transition");
509
+ X(e.root, r), B(e.root, r, [o]);
510
+ }
511
+ const at = Object.freeze({
512
+ u: 1,
513
+ r: 2,
514
+ d: 4,
515
+ l: 8,
516
+ rd: 3,
517
+ ru: 6,
518
+ lu: 9,
519
+ ld: 12,
520
+ horz: 5,
521
+ vert: 10,
522
+ in: 16,
523
+ out: 32
524
+ });
525
+ function g(e, t, n = {}) {
526
+ const a = w(e, f, t);
527
+ for (const [o, r] of Object.entries(n)) N(a, o, String(r));
528
+ return y(e, a), a;
529
+ }
530
+ function _(e, t, n = {}) {
531
+ return g(e, "cTn", { id: t(), ...n });
532
+ }
533
+ function re(e, t) {
534
+ const n = g(e, "stCondLst");
535
+ g(n, "cond", { delay: t });
536
+ }
537
+ function H(e, t, n, a, o = []) {
538
+ const r = g(e, "cBhvr");
539
+ _(r, a, { dur: n, fill: "hold" });
540
+ const i = g(r, "tgtEl");
541
+ if (g(i, "spTgt", { spid: t }), o.length) {
542
+ const s = g(r, "attrNameLst");
543
+ for (const c of o) {
544
+ const l = g(s, "attrName");
545
+ y(l, ae(c));
546
+ }
547
+ }
548
+ }
549
+ function fe(e, t, n, a, o) {
550
+ const r = g(e, "set"), i = g(r, "cBhvr"), s = _(i, o, { dur: 1, fill: "hold" });
551
+ re(s, a);
552
+ const c = g(i, "tgtEl");
553
+ g(c, "spTgt", { spid: t });
554
+ const l = g(i, "attrNameLst"), u = g(l, "attrName");
555
+ y(u, ae("style.visibility"));
556
+ const d = g(r, "to");
557
+ g(d, "strVal", { val: n });
558
+ }
559
+ function ot(e, t, n, a) {
560
+ if (t.kind === "emphasis" && t.effect === "spin") {
561
+ const i = g(e, "animRot", { by: 216e5 });
562
+ H(i, n, t.durationMs, a, ["r"]);
563
+ return;
564
+ }
565
+ if (t.kind === "emphasis" && t.effect === "grow") {
566
+ const i = g(e, "animScale");
567
+ H(i, n, t.durationMs, a, ["ppt_w", "ppt_h"]), g(i, "by", { x: 125e3, y: 125e3 });
568
+ return;
569
+ }
570
+ if (t.effect === "appear") return;
571
+ const o = Pe(t.effect, t.dir);
572
+ if (!o) throw new Error(`动画 ${t.effect} 缺少可保存 filter`);
573
+ const r = g(e, "animEffect", {
574
+ transition: t.kind === "exit" ? "out" : "in",
575
+ filter: o
576
+ });
577
+ H(r, n, t.durationMs, a);
578
+ }
579
+ function pe(e) {
580
+ const t = Math.abs(e) < 5e-10 ? 0 : Math.round(e * 1e9) / 1e9;
581
+ return String(t);
582
+ }
583
+ function rt(e, t, n, a, o) {
584
+ const r = t.motionPath.map(([s, c], l) => `${l ? "L" : "M"} ${pe(s / a.meta.width)} ${pe(c / a.meta.height)}`).join(" "), i = g(e, "animMotion", {
585
+ origin: "layout",
586
+ path: `${r} E`,
587
+ pathEditMode: "relative"
588
+ });
589
+ H(i, n, t.durationMs, o, ["ppt_x", "ppt_y"]);
590
+ }
591
+ function it(e, t, n, a) {
592
+ var l;
593
+ const o = n.elements[t.target], r = ((l = o == null ? void 0 : o.meta.origin) == null ? void 0 : l.spid) ?? (o == null ? void 0 : o.src.id);
594
+ if (r === void 0) throw new Error(`动画目标缺少 OOXML spid:${t.target}`);
595
+ const i = g(e, "par"), s = _(i, a, {
596
+ presetID: t.kind === "motion" ? 0 : we(t.effect).preset,
597
+ presetClass: t.kind === "motion" ? "path" : t.kind === "entrance" ? "entr" : t.kind === "exit" ? "exit" : "emph",
598
+ ...t.kind !== "motion" && t.dir !== void 0 ? { presetSubtype: at[t.dir] ?? 0 } : {},
599
+ dur: t.durationMs,
600
+ fill: "hold",
601
+ nodeType: t.trigger === "click" ? "clickEffect" : t.trigger === "withPrev" ? "withEffect" : "afterEffect"
602
+ });
603
+ re(s, t.delayMs);
604
+ const c = g(s, "childTnLst");
605
+ t.kind === "entrance" && fe(c, r, "visible", 0, a), t.kind === "motion" ? rt(c, t, r, n, a) : ot(c, t, r, a), t.kind === "exit" && fe(c, r, "hidden", t.durationMs, a);
606
+ }
607
+ function st(e, t, n) {
608
+ let a = 0;
609
+ const o = () => ++a, r = g(e, "par"), i = _(r, o, {
610
+ dur: "indefinite",
611
+ restart: "never",
612
+ nodeType: "tmRoot"
613
+ }), s = g(i, "childTnLst"), c = g(s, "seq", { concurrent: 1, nextAc: "seek" }), l = _(c, o, { dur: "indefinite", nodeType: "mainSeq" }), u = g(l, "childTnLst");
614
+ let d = null;
615
+ for (const m of t) {
616
+ if (!d || m.trigger === "click") {
617
+ const h = g(u, "par"), T = _(h, o, { fill: "hold", nodeType: "clickEffect" });
618
+ re(T, "indefinite"), d = g(T, "childTnLst");
619
+ }
620
+ it(d, m, n, o);
621
+ }
622
+ }
623
+ function Z(e) {
624
+ return e.attributes.some((t) => t.namespaceUri !== Le);
625
+ }
626
+ function K(e) {
627
+ return p(e).filter((t) => t.namespaceUri === f && t.localName === "timing");
628
+ }
629
+ function ct(e) {
630
+ if (e.namespaceUri !== C || e.localName !== "AlternateContent") return [];
631
+ const n = p(e).filter((a) => a.namespaceUri === C && (a.localName === "Choice" || a.localName === "Fallback")).map((a) => ({ parent: a, timings: K(a) }));
632
+ if (n.some(({ timings: a }) => a.length > 1))
633
+ throw new Error("mc:AlternateContent 分支包含多个 p:timing");
634
+ return n.some(({ timings: a }) => a.length) ? n.map(({ parent: a, timings: o }) => ({ parent: a, timing: o[0] })) : [];
635
+ }
636
+ function lt(e) {
637
+ const t = K(e), n = p(e).map(ct).filter((a) => a.length);
638
+ if (t.length > 1 || n.length > 1 || t.length && n.length)
639
+ throw new Error("幻灯片包含多个 p:timing 载体");
640
+ return t.length ? [{ parent: e, timing: t[0] }] : n[0] ?? [];
641
+ }
642
+ const ft = /* @__PURE__ */ new Set([
643
+ "set",
644
+ "anim",
645
+ "animClr",
646
+ "animEffect",
647
+ "animMotion",
648
+ "animRot",
649
+ "animScale",
650
+ "audio",
651
+ "video",
652
+ "cmd"
653
+ ]);
654
+ function P(e) {
655
+ const t = Ae(e).parent;
656
+ return (t == null ? void 0 : t.type) === "element" ? t : null;
657
+ }
658
+ function F(e, t) {
659
+ var n;
660
+ return (n = e.attributes.find((a) => a.namespaceUri === null && a.localName === t)) == null ? void 0 : n.value;
661
+ }
662
+ function R(e) {
663
+ const t = [], n = [e];
664
+ for (; n.length; ) {
665
+ const a = n.pop();
666
+ if (t.push(a), t.length > 1e5) throw new Error("动画时间树节点超过保存安全上限");
667
+ const o = p(a);
668
+ for (let r = o.length - 1; r >= 0; r--) n.push(o[r]);
669
+ }
670
+ return t;
671
+ }
672
+ function pt(e, t) {
673
+ return R(e).some((n) => {
674
+ const a = F(n, "spid");
675
+ return a !== void 0 && t.has(Number(a));
676
+ });
677
+ }
678
+ function mt(e) {
679
+ let t = P(e), n = (t == null ? void 0 : t.localName) === "tgtEl" ? t : e;
680
+ for (; t; ) {
681
+ if (t.namespaceUri === f && (t.localName === "cBhvr" || t.localName === "cond") || ft.has(t.localName)) return t;
682
+ t = P(t);
683
+ }
684
+ return n;
685
+ }
686
+ function G(e) {
687
+ if (!(e.namespaceUri !== f || e.localName !== "par"))
688
+ return p(e).find((t) => t.namespaceUri === f && t.localName === "cTn" && !!F(t, "presetClass"));
689
+ }
690
+ function ut(e, t) {
691
+ const n = R(e).filter((o) => !!G(o));
692
+ let a = null;
693
+ for (let o = n.length - 1; o >= 0; o--) {
694
+ const r = n[o], i = G(r);
695
+ if (!t.has(r)) {
696
+ a = r;
697
+ continue;
698
+ }
699
+ F(i, "nodeType") === "clickEffect" && a && N(G(a), "nodeType", "clickEffect");
700
+ }
701
+ }
702
+ function dt(e) {
703
+ for (let t = 0; t < 64; t++) {
704
+ let n = !1;
705
+ const a = R(e).reverse();
706
+ for (const o of a) {
707
+ if (o.namespaceUri !== f || o.localName !== "par" && o.localName !== "seq") continue;
708
+ const r = p(o).find((c) => c.namespaceUri === f && c.localName === "cTn"), i = r && p(r).find((c) => c.namespaceUri === f && c.localName === "childTnLst"), s = P(o);
709
+ i && p(i).length === 0 && s && (v(s, o), n = !0);
710
+ }
711
+ if (!n) break;
712
+ }
713
+ for (const t of R(e).reverse()) {
714
+ if (t.namespaceUri !== f || t.localName !== "tnLst" && t.localName !== "bldLst" || p(t).length !== 0 || Z(t)) continue;
715
+ const n = P(t);
716
+ n && v(n, t);
717
+ }
718
+ }
719
+ function me(e) {
720
+ return R(e).filter((t) => t.namespaceUri === f && t.localName === "spTgt");
721
+ }
722
+ function gt(e) {
723
+ const t = P(e);
724
+ if (t && (v(t, e), t.localName === "tgtEl" && p(t).length === 0 && !Z(t))) {
725
+ const n = P(t);
726
+ n && v(n, t);
727
+ }
728
+ }
729
+ const ht = /* @__PURE__ */ new Set([
730
+ "timing",
731
+ "tnLst",
732
+ "childTnLst",
733
+ "subTnLst",
734
+ "par",
735
+ "seq",
736
+ "cTn"
737
+ ]);
738
+ function Nt(e) {
739
+ const t = /* @__PURE__ */ new Set();
740
+ for (const a of e) {
741
+ if (a.namespaceUri !== f || a.localName !== "cBhvr") continue;
742
+ const o = P(a);
743
+ o && !ht.has(o.localName) && t.add(o);
744
+ }
745
+ const n = /* @__PURE__ */ new Set();
746
+ for (const a of t) {
747
+ const o = p(a).filter((r) => r.namespaceUri === f && r.localName === "cBhvr");
748
+ o.length && o.every((r) => e.has(r)) && n.add(a);
749
+ }
750
+ return n;
751
+ }
752
+ function yt(e) {
753
+ const t = /* @__PURE__ */ new Set();
754
+ for (const a of e) {
755
+ if (a.namespaceUri !== f || a.localName !== "cond") continue;
756
+ const o = P(a);
757
+ o && (o.localName === "stCondLst" || o.localName === "endCondLst") && t.add(o);
758
+ }
759
+ const n = /* @__PURE__ */ new Set();
760
+ for (const a of t) {
761
+ const o = p(a).filter((s) => s.namespaceUri === f && s.localName === "cond");
762
+ if (!o.length || !o.every((s) => e.has(s))) continue;
763
+ const r = P(a), i = r && P(r);
764
+ i && i.namespaceUri === f && (i.localName === "par" || i.localName === "seq") && n.add(i);
765
+ }
766
+ return n;
767
+ }
768
+ function vt(e, t) {
769
+ for (let n = P(e); n; n = P(n))
770
+ if (t.has(n)) return !0;
771
+ return !1;
772
+ }
773
+ function Tt(e) {
774
+ return R(e).filter((t) => {
775
+ const n = G(t), a = n && p(n).find((o) => o.namespaceUri === f && o.localName === "childTnLst");
776
+ return !!a && p(a).length === 0;
777
+ });
778
+ }
779
+ function ue(e) {
780
+ for (const t of e) {
781
+ const n = P(t);
782
+ n && v(n, t);
783
+ }
784
+ }
785
+ function bt(e) {
786
+ const t = K(e).map((n) => ({ parent: e, timing: n }));
787
+ for (const n of p(e))
788
+ if (!(n.namespaceUri !== C || n.localName !== "AlternateContent")) {
789
+ for (const a of p(n))
790
+ if (!(a.namespaceUri !== C || a.localName !== "Choice" && a.localName !== "Fallback"))
791
+ for (const o of K(a)) t.push({ parent: a, timing: o });
792
+ }
793
+ return t;
794
+ }
795
+ function zt(e, t) {
796
+ if (!t.length) return;
797
+ const n = new Set(t);
798
+ for (const a of bt(e.root)) {
799
+ const o = a.timing, r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
800
+ for (const m of R(o))
801
+ if (m.namespaceUri === f && m.localName === "spTgt" && n.has(Number(F(m, "spid")))) {
802
+ const h = mt(m);
803
+ h && s.set(h, [...s.get(h) ?? [], m]);
804
+ }
805
+ for (const [m, h] of s)
806
+ me(m).some(($) => !n.has(Number(F($, "spid")))) ? h.forEach(($) => i.add($)) : r.add(m);
807
+ i.forEach(gt);
808
+ const c = Nt(r), l = yt(r);
809
+ c.forEach((m) => r.add(m));
810
+ const u = new Set([...r].filter((m) => !l.has(m)));
811
+ ue(u);
812
+ const d = new Set(Tt(o));
813
+ for (const m of R(o).filter((h) => !!G(h)))
814
+ (l.has(m) || vt(m, l)) && d.add(m);
815
+ ut(o, d), ue(l);
816
+ for (const m of R(o).filter((h) => h.namespaceUri === f && h.localName === "bldLst"))
817
+ for (const h of [...p(m)])
818
+ pt(h, n) && v(m, h);
819
+ if (dt(o), me(o).some((m) => n.has(Number(F(m, "spid")))))
820
+ throw new Error("删除动画目标后仍存在悬空 spTgt");
821
+ !Z(o) && p(o).length === 0 && v(a.parent, o);
822
+ }
823
+ }
824
+ function St(e, t, n, a) {
825
+ for (const o of [...p(t)])
826
+ o.namespaceUri === f && o.localName === "tnLst" && v(t, o);
827
+ if (n.length) {
828
+ const o = w(t, f, "tnLst"), r = p(t).find((i) => i.namespaceUri === f && (i.localName === "bldLst" || i.localName === "extLst")) ?? null;
829
+ y(t, o, r), st(o, n, a);
830
+ } else !Z(t) && p(t).length === 0 && v(e, t);
831
+ }
832
+ function wt(e, t, n, a) {
833
+ let o = lt(e.root);
834
+ if (!o.length && a.length) {
835
+ const r = w(e.root, f, "timing");
836
+ X(e.root, r), o = [{ parent: e.root, timing: r }];
837
+ }
838
+ for (const r of o) {
839
+ let i = r.timing;
840
+ !i && a.length && (i = w(r.parent, f, "timing"), X(r.parent, i)), i && St(r.parent, i, a, t);
841
+ }
842
+ }
843
+ const Pt = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
844
+ function Et(e, t) {
845
+ var o;
846
+ const n = new Map(((o = t.backgroundImage) == null ? void 0 : o.relationships.map((r) => [r.sourceId, r.targetId])) ?? []), a = (r) => {
847
+ for (const i of r.attributes) {
848
+ const s = i.namespaceUri === Pt ? n.get(i.value) : null;
849
+ s && N(r, i.name, s, i.quote);
850
+ }
851
+ for (const i of p(r)) a(i);
852
+ };
853
+ a(e);
854
+ }
855
+ function Ut(e) {
856
+ return U(e.ovr, "background") || U(e.ovr, "hidden") || U(e.ovr, "transition") || U(e.ovr, "animations");
857
+ }
858
+ function xt(e, t) {
859
+ const n = k(e.root, {
860
+ localName: "cSld",
861
+ namespaceUri: f
862
+ });
863
+ if (!n) throw new Error(`幻灯片 ${t.id} 缺少 p:cSld`);
864
+ return n;
865
+ }
866
+ function kt(e, t, n) {
867
+ var i, s;
868
+ const a = (i = e.package) == null ? void 0 : i.parts[A(t)];
869
+ if (!a) return null;
870
+ const o = p(b(a).root, { localName: "Relationship" }).find((c) => {
871
+ var l;
872
+ return (l = S(c, { localName: "Type", namespaceUri: null })) == null ? void 0 : l.value.endsWith(n);
873
+ }), r = o && ((s = S(o, { localName: "Target", namespaceUri: null })) == null ? void 0 : s.value);
874
+ return r ? ne(t, r) : null;
875
+ }
876
+ function Ct(e, t) {
877
+ var s;
878
+ const n = (s = e.package) == null ? void 0 : s.parts[t];
879
+ if (!n) return { found: !1, image: null };
880
+ const a = k(b(n).root, {
881
+ localName: "cSld",
882
+ namespaceUri: f
883
+ }), o = a && k(a, {
884
+ localName: "bg",
885
+ namespaceUri: f
886
+ });
887
+ if (!o) return { found: !1, image: null };
888
+ const r = k(o, {
889
+ localName: "bgPr",
890
+ namespaceUri: f
891
+ });
892
+ return { found: !0, image: r && k(r, {
893
+ localName: "blipFill",
894
+ namespaceUri: L
895
+ }) ? o : null };
896
+ }
897
+ function Mt(e, t) {
898
+ var a;
899
+ if (((a = t.src.background) == null ? void 0 : a.type) !== "image" || !t.layoutId) return null;
900
+ const n = kt(e, t.layoutId, "/slideMaster");
901
+ for (const o of [t.layoutId, n]) {
902
+ if (!o) continue;
903
+ const r = Ct(e, o);
904
+ if (r.found) return r.image;
905
+ }
906
+ return null;
907
+ }
908
+ function It(e, t, n) {
909
+ if (!U(n.ovr, "background")) return;
910
+ const a = n.ovr.background;
911
+ (a == null ? void 0 : a.type) === "image" ? Ee(a, `幻灯片 ${n.id} 的背景覆盖`) : Ue(a, `幻灯片 ${n.id} 的背景覆盖`);
912
+ const o = xt(e, n);
913
+ let r = k(o, {
914
+ localName: "bg",
915
+ namespaceUri: f
916
+ });
917
+ if (!r) {
918
+ const s = a.type === "image" ? Mt(t, n) : null;
919
+ r = s ? D(s) : w(o, f, "bg"), s && Et(r, n), X(o, r);
920
+ }
921
+ let i = k(r, {
922
+ localName: "bgPr",
923
+ namespaceUri: f
924
+ });
925
+ for (const s of [...p(r)])
926
+ s.namespaceUri === f && s.localName === "bgRef" && v(r, s);
927
+ if (i || (i = w(r, f, "bgPr"), X(r, i)), a.type === "image") {
928
+ const s = n.backgroundImage;
929
+ if (!s) throw new Error(`幻灯片 ${n.id} 的图片背景缺少关系`);
930
+ xe(
931
+ i,
932
+ a,
933
+ s.imageRelationshipId,
934
+ s.sourcePart !== void 0
935
+ );
936
+ } else
937
+ ke(i), Ce(i, a);
938
+ }
939
+ function Vt(e, t, n) {
940
+ var a;
941
+ if (Ut(n)) {
942
+ if (U(n.ovr, "hidden") && (n.ovr.hidden ? N(e.root, "show", "0") : Q(e.root, "show")), U(n.ovr, "transition")) {
943
+ const o = n.layoutId ? (a = t.layouts[n.layoutId]) == null ? void 0 : a.transition : void 0;
944
+ nt(
945
+ e,
946
+ n.ovr.transition,
947
+ o !== void 0
948
+ );
949
+ }
950
+ U(n.ovr, "animations") && wt(e, t, n, n.ovr.animations), It(e, t, n);
951
+ }
952
+ }
953
+ const Rt = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', Lt = "application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml", de = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles";
954
+ function Gt(e) {
955
+ const t = /* @__PURE__ */ new Map();
956
+ for (const a of Object.values(e.elements)) {
957
+ const o = a.ovr.tableStyle;
958
+ if (!o) continue;
959
+ const r = Me(e, a.id, o.styleId);
960
+ if (!r) throw new Error(`表格 ${a.id} 的样式定义不存在:${o.styleId}`);
961
+ t.set(r.styleId.toUpperCase(), r);
962
+ }
963
+ const n = e.meta.tableStylesPart ?? e.saveState.createdParts.find((a) => /(?:^|\/)tableStyles\.xml$/.test(a));
964
+ return !t.size && !n ? null : { part: n ?? "ppt/tableStyles.xml", definitions: [...t.values()] };
965
+ }
966
+ function Yt(e, t) {
967
+ return Be(e, [{
968
+ targetPart: t,
969
+ hash: "table-style-part",
970
+ mime: Lt,
971
+ extension: "xml",
972
+ bytes: "",
973
+ created: !0
974
+ }]);
975
+ }
976
+ function Ht(e, t) {
977
+ const n = b(e), a = p(n.root, { localName: "Relationship" });
978
+ if (a.find((c) => {
979
+ var l;
980
+ return ((l = S(c, { localName: "Type", namespaceUri: null })) == null ? void 0 : l.value) === de;
981
+ })) return e;
982
+ const r = new Set(a.flatMap((c) => {
983
+ var u;
984
+ const l = (u = S(c, { localName: "Id", namespaceUri: null })) == null ? void 0 : u.value;
985
+ return l ? [l] : [];
986
+ }));
987
+ let i = 1;
988
+ for (; r.has(`rId${i}`); ) i++;
989
+ const s = `rId${i}`;
990
+ return z(e, [{
991
+ sourceId: s,
992
+ targetId: s,
993
+ type: de,
994
+ target: j("ppt/presentation.xml", t)
995
+ }]);
996
+ }
997
+ function At(e) {
998
+ const t = b(e);
999
+ if (t.root.localName !== "tblStyleLst" || t.root.namespaceUri !== L)
1000
+ throw new Error("tableStyles.xml 根节点不是 a:tblStyleLst");
1001
+ return new Set(p(t.root, { localName: "tblStyle", namespaceUri: L }).flatMap((n) => {
1002
+ var o;
1003
+ const a = (o = S(n, { localName: "styleId", namespaceUri: null })) == null ? void 0 : o.value;
1004
+ return a ? [a.toUpperCase()] : [];
1005
+ }));
1006
+ }
1007
+ function Ot(e, t) {
1008
+ const n = e ? At(e) : /* @__PURE__ */ new Set();
1009
+ return t.filter((a) => !n.has(a.styleId.toUpperCase()));
1010
+ }
1011
+ function Wt(e, t) {
1012
+ var i;
1013
+ const n = Ot(e, t);
1014
+ if (e && !n.length) return e;
1015
+ const a = e ?? new TextEncoder().encode(
1016
+ `${Rt}<a:tblStyleLst xmlns:a="${L}" def="${((i = t[0]) == null ? void 0 : i.styleId) ?? ""}"></a:tblStyleLst>`
1017
+ ), o = b(a), r = p(o.root, { localName: "extLst", namespaceUri: L })[0] ?? null;
1018
+ for (const s of n) {
1019
+ const c = b(`<root xmlns:a="${L}">${s.markup}</root>`), l = p(c.root, { localName: "tblStyle", namespaceUri: L })[0];
1020
+ if (!l || !v(c.root, l))
1021
+ throw new Error(`无法物化表样式:${s.styleId}`);
1022
+ y(o.root, l, r);
1023
+ }
1024
+ return O(o);
1025
+ }
1026
+ export {
1027
+ qt as a,
1028
+ Vt as b,
1029
+ Dt as c,
1030
+ Ft as d,
1031
+ jt as e,
1032
+ Be as f,
1033
+ Yt as g,
1034
+ Ht as h,
1035
+ Wt as i,
1036
+ Ut as j,
1037
+ Xt as k,
1038
+ _t as m,
1039
+ z as p,
1040
+ zt as r,
1041
+ Gt as t
1042
+ };