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

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 (179) hide show
  1. package/CHANGELOG.md +274 -0
  2. package/LICENSE +21 -0
  3. package/README.md +474 -0
  4. package/dist/animation-catalog.d.ts +21 -0
  5. package/dist/body-properties.d.ts +8 -0
  6. package/dist/body-property-schema.d.ts +3 -0
  7. package/dist/change-classification.d.ts +10 -0
  8. package/dist/clipboard-binary.d.ts +4 -0
  9. package/dist/clipboard-links.d.ts +11 -0
  10. package/dist/clipboard-source.d.ts +23 -0
  11. package/dist/clipboard.d.ts +4 -0
  12. package/dist/commands/add-image.d.ts +4 -0
  13. package/dist/commands/add-shape.d.ts +4 -0
  14. package/dist/commands/add-slide-identity.d.ts +8 -0
  15. package/dist/commands/add-slide-template.d.ts +9 -0
  16. package/dist/commands/add-slide.d.ts +3 -0
  17. package/dist/commands/add-table.d.ts +4 -0
  18. package/dist/commands/align-elements.d.ts +4 -0
  19. package/dist/commands/apply-format.d.ts +4 -0
  20. package/dist/commands/clipboard-types.d.ts +91 -0
  21. package/dist/commands/direct-format-patches.d.ts +8 -0
  22. package/dist/commands/dispatch.d.ts +7 -0
  23. package/dist/commands/duplicate-slide.d.ts +3 -0
  24. package/dist/commands/edit-text.d.ts +3 -0
  25. package/dist/commands/element-effects.d.ts +5 -0
  26. package/dist/commands/element-fill.d.ts +5 -0
  27. package/dist/commands/element-image-content.d.ts +17 -0
  28. package/dist/commands/element-interaction.d.ts +11 -0
  29. package/dist/commands/element-link.d.ts +5 -0
  30. package/dist/commands/element-name.d.ts +8 -0
  31. package/dist/commands/element-order.d.ts +7 -0
  32. package/dist/commands/element-stroke.d.ts +5 -0
  33. package/dist/commands/element-text.d.ts +6 -0
  34. package/dist/commands/element-transform.d.ts +5 -0
  35. package/dist/commands/element-tree.d.ts +8 -0
  36. package/dist/commands/fit-text-shape.d.ts +3 -0
  37. package/dist/commands/format-painter-types.d.ts +17 -0
  38. package/dist/commands/image-format.d.ts +7 -0
  39. package/dist/commands/image-resource.d.ts +4 -0
  40. package/dist/commands/insert-row.d.ts +3 -0
  41. package/dist/commands/insertion-rect.d.ts +9 -0
  42. package/dist/commands/paste-elements.d.ts +4 -0
  43. package/dist/commands/paste-resources.d.ts +18 -0
  44. package/dist/commands/patch.d.ts +6 -0
  45. package/dist/commands/remove-slide.d.ts +3 -0
  46. package/dist/commands/replace-image.d.ts +3 -0
  47. package/dist/commands/replace-text.d.ts +5 -0
  48. package/dist/commands/set-animations.d.ts +3 -0
  49. package/dist/commands/set-body-props.d.ts +3 -0
  50. package/dist/commands/set-crop.d.ts +3 -0
  51. package/dist/commands/set-effects.d.ts +3 -0
  52. package/dist/commands/set-fill.d.ts +3 -0
  53. package/dist/commands/set-flip.d.ts +4 -0
  54. package/dist/commands/set-link.d.ts +3 -0
  55. package/dist/commands/set-para-props.d.ts +3 -0
  56. package/dist/commands/set-run-props.d.ts +3 -0
  57. package/dist/commands/set-slide-properties.d.ts +7 -0
  58. package/dist/commands/set-stroke.d.ts +3 -0
  59. package/dist/commands/set-xfrm.d.ts +3 -0
  60. package/dist/commands/set-z.d.ts +5 -0
  61. package/dist/commands/slide-image.d.ts +4 -0
  62. package/dist/commands/slide-layout.d.ts +8 -0
  63. package/dist/commands/slide-notes.d.ts +8 -0
  64. package/dist/commands/slide-order.d.ts +7 -0
  65. package/dist/commands/slide-property-types.d.ts +135 -0
  66. package/dist/commands/slide-property.d.ts +20 -0
  67. package/dist/commands/slide-tree.d.ts +6 -0
  68. package/dist/commands/spid.d.ts +4 -0
  69. package/dist/commands/table-row.d.ts +5 -0
  70. package/dist/commands/text-target.d.ts +25 -0
  71. package/dist/commands/types.d.ts +509 -0
  72. package/dist/commands/xfrm.d.ts +8 -0
  73. package/dist/data-validation.d.ts +7 -0
  74. package/dist/document.d.ts +17 -0
  75. package/dist/dynamic-slide-fields.d.ts +6 -0
  76. package/dist/edit-core.js +5321 -0
  77. package/dist/editor.d.ts +38 -0
  78. package/dist/element-ancestry.d.ts +3 -0
  79. package/dist/element-name.d.ts +4 -0
  80. package/dist/element-order.d.ts +7 -0
  81. package/dist/field-text.d.ts +3 -0
  82. package/dist/fractional-index.d.ts +10 -0
  83. package/dist/history.d.ts +50 -0
  84. package/dist/hyperlink.d.ts +10 -0
  85. package/dist/image-content.d.ts +7 -0
  86. package/dist/image-resource-history.d.ts +6 -0
  87. package/dist/index-D4ZTaYOa.js +706 -0
  88. package/dist/index.d.ts +46 -0
  89. package/dist/insertion-DabLme_U.js +5471 -0
  90. package/dist/insertion-invariants.d.ts +5 -0
  91. package/dist/layout-assets.d.ts +10 -0
  92. package/dist/layout-projection.d.ts +24 -0
  93. package/dist/layout-text-rebase.d.ts +3 -0
  94. package/dist/model-invariants.d.ts +5 -0
  95. package/dist/notes-part.d.ts +2 -0
  96. package/dist/opc/bytes.d.ts +1 -0
  97. package/dist/opc/crc32.d.ts +1 -0
  98. package/dist/opc/index.d.ts +3 -0
  99. package/dist/opc/package-owner.d.ts +4 -0
  100. package/dist/opc/patch.d.ts +6 -0
  101. package/dist/opc/types.d.ts +12 -0
  102. package/dist/opc/zip.d.ts +28 -0
  103. package/dist/opc-owner-protocol.d.ts +5 -0
  104. package/dist/opc.js +5 -0
  105. package/dist/paragraph-properties.d.ts +4 -0
  106. package/dist/paragraph-property-schema.d.ts +4 -0
  107. package/dist/patch-DO8497wO.js +322 -0
  108. package/dist/projection.d.ts +19 -0
  109. package/dist/recovery-identity.d.ts +35 -0
  110. package/dist/recovery-types.d.ts +30 -0
  111. package/dist/recovery.d.ts +28 -0
  112. package/dist/run-links.d.ts +3 -0
  113. package/dist/run-properties.d.ts +4 -0
  114. package/dist/run-property-schema.d.ts +3 -0
  115. package/dist/save/animation.d.ts +6 -0
  116. package/dist/save/background-image.d.ts +8 -0
  117. package/dist/save/clipboard-parts.d.ts +11 -0
  118. package/dist/save/drawing-color.d.ts +2 -0
  119. package/dist/save/duplicate-slide-parts.d.ts +15 -0
  120. package/dist/save/effects.d.ts +6 -0
  121. package/dist/save/hyperlink.d.ts +18 -0
  122. package/dist/save/image-content.d.ts +4 -0
  123. package/dist/save/index.d.ts +5 -0
  124. package/dist/save/insertion.d.ts +14 -0
  125. package/dist/save/layout-fallback-source.d.ts +4 -0
  126. package/dist/save/layout-fallback.d.ts +7 -0
  127. package/dist/save/materialize.d.ts +5 -0
  128. package/dist/save/name.d.ts +5 -0
  129. package/dist/save/notes.d.ts +12 -0
  130. package/dist/save/order.d.ts +5 -0
  131. package/dist/save/remove-element.d.ts +4 -0
  132. package/dist/save/remove-slide-parts.d.ts +11 -0
  133. package/dist/save/shape-format.d.ts +14 -0
  134. package/dist/save/slide-parts.d.ts +11 -0
  135. package/dist/save/slide-properties.d.ts +4 -0
  136. package/dist/save/table.d.ts +7 -0
  137. package/dist/save/text-body.d.ts +4 -0
  138. package/dist/save/text.d.ts +6 -0
  139. package/dist/save/transition.d.ts +4 -0
  140. package/dist/save/xfrm.d.ts +22 -0
  141. package/dist/save/xml-element.d.ts +3 -0
  142. package/dist/save.js +1559 -0
  143. package/dist/selection-pane.d.ts +18 -0
  144. package/dist/selection.d.ts +11 -0
  145. package/dist/session-assets.d.ts +20 -0
  146. package/dist/shape-effects.d.ts +6 -0
  147. package/dist/shape-fill.d.ts +12 -0
  148. package/dist/shape-stroke.d.ts +9 -0
  149. package/dist/slide-animation.d.ts +15 -0
  150. package/dist/slide-background-source.d.ts +13 -0
  151. package/dist/slide-notes.d.ts +2 -0
  152. package/dist/slide-properties.d.ts +4 -0
  153. package/dist/slide-transition.d.ts +19 -0
  154. package/dist/space.d.ts +47 -0
  155. package/dist/table-cell.d.ts +10 -0
  156. package/dist/table-direct-markup.d.ts +3 -0
  157. package/dist/table-insertion-policy.d.ts +5 -0
  158. package/dist/table-row-append-validation.d.ts +3 -0
  159. package/dist/table-rows.d.ts +12 -0
  160. package/dist/text-model.d.ts +28 -0
  161. package/dist/text-override-projection.d.ts +8 -0
  162. package/dist/text-override-validation.d.ts +7 -0
  163. package/dist/text-position.d.ts +8 -0
  164. package/dist/text-search-types.d.ts +46 -0
  165. package/dist/text-search.d.ts +5 -0
  166. package/dist/transaction-validation.d.ts +5 -0
  167. package/dist/types.d.ts +519 -0
  168. package/dist/xml/index.d.ts +9 -0
  169. package/dist/xml/mutate.d.ts +7 -0
  170. package/dist/xml/namespace.d.ts +5 -0
  171. package/dist/xml/nodes.d.ts +22 -0
  172. package/dist/xml/order.d.ts +15 -0
  173. package/dist/xml/qname.d.ts +15 -0
  174. package/dist/xml/query.d.ts +10 -0
  175. package/dist/xml/state.d.ts +30 -0
  176. package/dist/xml/tree.d.ts +8 -0
  177. package/dist/xml/types.d.ts +46 -0
  178. package/dist/xml.js +19 -0
  179. package/package.json +67 -0
@@ -0,0 +1,706 @@
1
+ const k = (t, e) => t.localName === e.localName && (!Object.prototype.hasOwnProperty.call(e, "namespaceUri") || t.namespaceUri === e.namespaceUri);
2
+ function J(t, e) {
3
+ const n = t.children.filter((s) => s.type === "element");
4
+ return e ? n.filter((s) => k(s, e)) : n;
5
+ }
6
+ function Ut(t, e) {
7
+ return J(t).find((n) => k(n, e)) ?? null;
8
+ }
9
+ function ht(t, e) {
10
+ for (const n of J(t)) {
11
+ if (k(n, e)) return n;
12
+ const s = ht(n, e);
13
+ if (s) return s;
14
+ }
15
+ return null;
16
+ }
17
+ function Wt(t, e) {
18
+ return t.attributes.find((n) => k(n, e)) ?? null;
19
+ }
20
+ const g = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap();
21
+ function m(t) {
22
+ const e = g.get(t);
23
+ if (!e) throw new Error("XML 节点不属于保留型 XML 树");
24
+ return e;
25
+ }
26
+ function y(t) {
27
+ const e = E.get(t);
28
+ if (!e) throw new Error("XML 元素不属于保留型 XML 树");
29
+ return e;
30
+ }
31
+ function S(t) {
32
+ let e = t;
33
+ for (; e; ) {
34
+ const n = m(e);
35
+ if (n.dirty) break;
36
+ n.dirty = !0, e = n.parent;
37
+ }
38
+ }
39
+ const tt = "http://www.w3.org/XML/1998/namespace", pt = "http://www.w3.org/2000/xmlns/", x = "http://schemas.openxmlformats.org/drawingml/2006/main", d = "http://schemas.openxmlformats.org/presentationml/2006/main", q = "http://schemas.microsoft.com/office/powerpoint/2010/main", et = "http://schemas.openxmlformats.org/markup-compatibility/2006", mt = "http://schemas.openxmlformats.org/officeDocument/2006/math", Dt = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", dt = /^[A-Za-z_][A-Za-z0-9_.-]*$/, gt = /^[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{N}\p{M}\p{Pc}_.\-\u00B7\u203F-\u2040]*$/u, D = (t) => dt.test(t) || gt.test(t);
40
+ function B(t) {
41
+ const e = t.indexOf(":");
42
+ return e < 0 ? D(t) : e === t.lastIndexOf(":") && D(t.slice(0, e)) && D(t.slice(e + 1));
43
+ }
44
+ function st(t, e) {
45
+ if (!B(t)) throw new Error(`非法 XML ${e}名:${t}`);
46
+ }
47
+ const A = (t) => {
48
+ const e = t.indexOf(":");
49
+ return e < 0 ? { prefix: null, localName: t } : { prefix: t.slice(0, e), localName: t.slice(e + 1) };
50
+ };
51
+ function L(t, e, n) {
52
+ const s = A(t);
53
+ return n && (t === "xmlns" || s.prefix === "xmlns") ? pt : s.prefix === "xml" ? tt : s.prefix ? e.get(s.prefix) || null : n ? null : e.get("") || null;
54
+ }
55
+ function nt(t, e) {
56
+ const n = new Map(t);
57
+ for (const s of e.attributes)
58
+ s.name === "xmlns" ? n.set("", s.value) : s.name.startsWith("xmlns:") && n.set(s.name.slice(6), s.value);
59
+ return n;
60
+ }
61
+ function xt(t) {
62
+ const e = y(t).parent;
63
+ return (e == null ? void 0 : e.type) === "element" ? y(e).namespaces : /* @__PURE__ */ new Map();
64
+ }
65
+ function wt(t, e) {
66
+ return L(e.name, nt(y(t).namespaces, e), !1);
67
+ }
68
+ function P(t, e = xt(t)) {
69
+ const n = y(t), s = nt(e, t);
70
+ n.namespaces = s, t.namespaceUri = L(t.name, s, !1);
71
+ for (const i of t.attributes)
72
+ i.namespaceUri = L(i.name, s, !0);
73
+ for (const i of t.children)
74
+ i.type === "element" && P(i, s);
75
+ }
76
+ const C = (t) => t.attributes, bt = (t, e) => {
77
+ t.value = e;
78
+ };
79
+ function yt(t, e) {
80
+ return L(e, y(t).namespaces, !0);
81
+ }
82
+ function Nt(t, e) {
83
+ const n = y(t), s = n.sourceAttributes.indexOf(e);
84
+ if (s < 0) return C(t).length;
85
+ const i = C(t);
86
+ for (let r = 0; r < i.length; r++) {
87
+ const o = n.sourceAttributes.indexOf(i[r]);
88
+ if (o >= 0 && o > s) return r;
89
+ }
90
+ return i.findIndex((r) => {
91
+ var o;
92
+ return !((o = b.get(r)) != null && o.source);
93
+ }) >= 0 ? i.findIndex((r) => {
94
+ var o;
95
+ return !((o = b.get(r)) != null && o.source);
96
+ }) : i.length;
97
+ }
98
+ function rt(t, e, n, s = '"') {
99
+ st(e, "属性");
100
+ let r = y(t).sourceAttributes.find((a) => a.name === e) ?? C(t).find((a) => a.name === e);
101
+ if (r) {
102
+ const a = b.get(r);
103
+ let h = !1;
104
+ return a.present || (a.present = !0, C(t).splice(Nt(t, r), 0, r), h = !0), r.value !== n && (bt(r, n), a.changed = !0, h = !0), h && ((e === "xmlns" || e.startsWith("xmlns:")) && P(t), S(t)), r;
105
+ }
106
+ const o = A(e);
107
+ r = {
108
+ name: e,
109
+ prefix: o.prefix,
110
+ localName: o.localName,
111
+ namespaceUri: yt(t, e),
112
+ value: n,
113
+ quote: s
114
+ };
115
+ const c = {
116
+ source: !1,
117
+ present: !0,
118
+ changed: !0,
119
+ start: -1,
120
+ nameStart: -1,
121
+ valueStart: -1,
122
+ valueEnd: -1,
123
+ end: -1
124
+ };
125
+ return b.set(r, c), C(t).push(r), (e === "xmlns" || e.startsWith("xmlns:")) && P(t), S(t), r;
126
+ }
127
+ function _t(t, e) {
128
+ const n = C(t), s = n.findIndex((r) => r.name === e);
129
+ if (s < 0) return !1;
130
+ const [i] = n.splice(s, 1);
131
+ return b.get(i).present = !1, (e === "xmlns" || e.startsWith("xmlns:")) && P(t), S(t), !0;
132
+ }
133
+ function H(t, e) {
134
+ let n = t.replace(/&/g, "&amp;").replace(/</g, "&lt;");
135
+ return n = e === '"' ? n.replace(/"/g, "&quot;") : n.replace(/'/g, "&apos;"), n;
136
+ }
137
+ function St(t) {
138
+ let e = t.length - 1;
139
+ for (; e > 0 && /\s/.test(t[e - 1]); ) e--;
140
+ if (t[e - 1] === "/")
141
+ for (e--; e > 0 && /\s/.test(t[e - 1]); ) e--;
142
+ return e;
143
+ }
144
+ function Et(t) {
145
+ const e = y(t), n = [];
146
+ for (const r of e.sourceAttributes) {
147
+ const o = b.get(r);
148
+ o.present ? o.changed && n.push({
149
+ start: o.valueStart,
150
+ end: o.valueEnd,
151
+ value: H(r.value, r.quote)
152
+ }) : n.push({ start: o.start, end: o.end, value: "" });
153
+ }
154
+ n.sort((r, o) => o.start - r.start);
155
+ let s = e.openRaw;
156
+ for (const r of n) s = s.slice(0, r.start) + r.value + s.slice(r.end);
157
+ const i = t.attributes.filter((r) => !b.get(r).source);
158
+ if (i.length) {
159
+ const r = St(s), o = i.map((c) => ` ${c.name}=${c.quote}${H(c.value, c.quote)}${c.quote}`).join("");
160
+ s = s.slice(0, r) + o + s.slice(r);
161
+ }
162
+ return e.sourceSelfClosing && t.children.length && (s = s.replace(/\s*\/\s*>$/, ">")), s;
163
+ }
164
+ const it = /* @__PURE__ */ new WeakMap(), vt = {
165
+ amp: "&",
166
+ lt: "<",
167
+ gt: ">",
168
+ quot: '"',
169
+ apos: "'"
170
+ }, O = (t) => t === " " || t === " " || t === "\r" || t === `
171
+ `, Z = (t) => O(t) || t === "=" || t === "/" || t === ">";
172
+ function Ct(t) {
173
+ let e = t.length - 2;
174
+ for (; O(t[e]); ) e--;
175
+ return t[e] === "/";
176
+ }
177
+ function F(t) {
178
+ return t.includes("&") ? t.replace(/&(#x[0-9a-f]+|#[0-9]+|[A-Za-z][\w.-]*);/gi, (e, n) => {
179
+ if (n[0] !== "#") return vt[n] ?? e;
180
+ const s = n[1].toLowerCase() === "x", i = Number.parseInt(n.slice(s ? 2 : 1), s ? 16 : 10);
181
+ return Number.isFinite(i) && i >= 0 && i <= 1114111 ? String.fromCodePoint(i) : e;
182
+ }) : t;
183
+ }
184
+ function Lt(t) {
185
+ let e = "utf-8", n = !1, s = 0;
186
+ return t[0] === 239 && t[1] === 187 && t[2] === 191 ? (n = !0, s = 3) : t[0] === 255 && t[1] === 254 ? (e = "utf-16le", n = !0, s = 2) : t[0] === 254 && t[1] === 255 ? (e = "utf-16be", n = !0, s = 2) : t[0] === 60 && t[1] === 0 ? e = "utf-16le" : t[0] === 0 && t[1] === 60 && (e = "utf-16be"), { text: new TextDecoder(e, { fatal: !0 }).decode(t.subarray(s)), encoding: e, bom: n };
187
+ }
188
+ function Mt(t, e, n) {
189
+ if (e === "utf-8") {
190
+ const r = new TextEncoder().encode(t);
191
+ if (!n) return r;
192
+ const o = new Uint8Array(r.length + 3);
193
+ return o.set([239, 187, 191]), o.set(r, 3), o;
194
+ }
195
+ const s = new Uint8Array(t.length * 2 + (n ? 2 : 0));
196
+ let i = 0;
197
+ n && (s.set(e === "utf-16le" ? [255, 254] : [254, 255]), i = 2);
198
+ for (let r = 0; r < t.length; r++) {
199
+ const o = t.charCodeAt(r);
200
+ e === "utf-16le" ? (s[i++] = o & 255, s[i++] = o >>> 8) : (s[i++] = o >>> 8, s[i++] = o & 255);
201
+ }
202
+ return s;
203
+ }
204
+ function Xt(t) {
205
+ const e = t.children.find((r) => r.type === "processing-instruction" && r.target.toLowerCase() === "xml"), n = e == null ? void 0 : e.value.match(/\bencoding\s*=\s*(['"])([^'"]+)\1/i), s = (n == null ? void 0 : n[2].toLowerCase()) ?? "utf-8", i = m(t).raw.startsWith("\uFEFF");
206
+ if (s === "utf-8" || s === "utf8") return { encoding: "utf-8", bom: i };
207
+ if (s === "utf-16") return { encoding: "utf-16le", bom: !0 };
208
+ if (s === "utf-16le") return { encoding: "utf-16le", bom: i };
209
+ if (s === "utf-16be") return { encoding: "utf-16be", bom: i };
210
+ throw new Error(`无法按 XML 声明输出 ${n == null ? void 0 : n[2]} 字节;仅支持 UTF-8 与 UTF-16`);
211
+ }
212
+ class K {
213
+ constructor(e) {
214
+ this.source = e, this.offset = 0;
215
+ }
216
+ parse() {
217
+ const e = [], n = { type: "document", children: e, root: null };
218
+ let s = null;
219
+ for (; this.offset < this.source.length; ) {
220
+ const i = this.source[this.offset] === "<" ? this.parseMarkup(n, /* @__PURE__ */ new Map()) : this.parseText(n);
221
+ e.push(i), i.type === "element" ? (s && this.fail("XML 只能有一个根元素"), s = i) : i.type === "text" && i.value.replace(/^\uFEFF/, "").trim() && this.fail("根元素外不能出现文本");
222
+ }
223
+ return s || this.fail("未找到根元素"), Object.defineProperty(n, "root", { value: s, enumerable: !0 }), g.set(n, { raw: this.source, parent: null, dirty: !1 }), n;
224
+ }
225
+ parseText(e) {
226
+ const n = this.offset, s = this.source.indexOf("<", n);
227
+ this.offset = s < 0 ? this.source.length : s;
228
+ const i = this.source.slice(n, this.offset), r = { type: "text", value: F(i) };
229
+ return g.set(r, { raw: i, parent: e, dirty: !1 }), r;
230
+ }
231
+ parseMarkup(e, n) {
232
+ const s = this.offset;
233
+ if (this.source.startsWith("<!--", s)) {
234
+ const i = this.source.indexOf("-->", s + 4);
235
+ i < 0 && this.fail("注释未闭合"), this.offset = i + 3;
236
+ const r = this.source.slice(s, this.offset), o = { type: "comment", value: r.slice(4, -3) };
237
+ return g.set(o, { raw: r, parent: e, dirty: !1 }), o;
238
+ }
239
+ if (this.source.startsWith("<![CDATA[", s)) {
240
+ const i = this.source.indexOf("]]>", s + 9);
241
+ i < 0 && this.fail("CDATA 未闭合"), this.offset = i + 3;
242
+ const r = this.source.slice(s, this.offset), o = { type: "cdata", value: r.slice(9, -3) };
243
+ return g.set(o, { raw: r, parent: e, dirty: !1 }), o;
244
+ }
245
+ return this.source.startsWith("<?", s) ? this.parseInstruction(e) : this.source.startsWith("<!", s) ? this.parseDeclaration(e) : (this.source.startsWith("</", s) && this.fail("遇到意外的闭合标签"), this.parseElement(e, n));
246
+ }
247
+ parseInstruction(e) {
248
+ const n = this.offset, s = this.source.indexOf("?>", n + 2);
249
+ s < 0 && this.fail("处理指令未闭合"), this.offset = s + 2;
250
+ const i = this.source.slice(n, this.offset), r = i.slice(2, -2), o = r.search(/\s/), c = {
251
+ type: "processing-instruction",
252
+ target: o < 0 ? r : r.slice(0, o),
253
+ value: o < 0 ? "" : r.slice(o).trimStart()
254
+ };
255
+ return g.set(c, { raw: i, parent: e, dirty: !1 }), c;
256
+ }
257
+ parseDeclaration(e) {
258
+ const n = this.offset;
259
+ let s = "", i = 0;
260
+ for (this.offset += 2; this.offset < this.source.length; ) {
261
+ const c = this.source[this.offset++];
262
+ if (s)
263
+ c === s && (s = "");
264
+ else if (c === '"' || c === "'") s = c;
265
+ else if (c === "[") i++;
266
+ else if (c === "]") i = Math.max(0, i - 1);
267
+ else if (c === ">" && i === 0) break;
268
+ }
269
+ this.source[this.offset - 1] !== ">" && this.fail("声明未闭合");
270
+ const r = this.source.slice(n, this.offset), o = { type: "declaration", value: r.slice(2, -1) };
271
+ return g.set(o, { raw: r, parent: e, dirty: !1 }), o;
272
+ }
273
+ parseElement(e, n) {
274
+ const s = this.offset, i = this.scanOpenEnd(s), r = this.source.slice(s, i + 1), o = this.scanNameEnd(s + 1, i), c = this.source.slice(s + 1, o);
275
+ B(c) || this.fail(`非法元素名 ${c || "(空)"}`);
276
+ const a = this.parseAttributes(r, c.length + 1), h = new Map(n);
277
+ h.set("xml", tt);
278
+ for (const p of a)
279
+ p.name === "xmlns" ? h.set("", F(p.value)) : p.name.startsWith("xmlns:") && h.set(p.name.slice(6), F(p.value));
280
+ const w = a.map((p) => {
281
+ const v = A(p.name), X = {
282
+ name: p.name,
283
+ prefix: v.prefix,
284
+ localName: v.localName,
285
+ namespaceUri: L(p.name, h, !0),
286
+ value: F(p.value),
287
+ quote: p.quote
288
+ };
289
+ return b.set(X, p.state), X;
290
+ }), N = A(c), W = Ct(r), G = [], M = {
291
+ type: "element",
292
+ name: c,
293
+ prefix: N.prefix,
294
+ localName: N.localName,
295
+ namespaceUri: L(c, h, !1),
296
+ attributes: w,
297
+ children: G,
298
+ selfClosing: W
299
+ };
300
+ this.offset = i + 1;
301
+ let Q = "";
302
+ if (!W) {
303
+ for (; this.offset < this.source.length && !this.source.startsWith("</", this.offset); ) {
304
+ const ut = this.source[this.offset] === "<" ? this.parseMarkup(M, h) : this.parseText(M);
305
+ G.push(ut);
306
+ }
307
+ this.source.startsWith("</", this.offset) || this.fail(`元素 <${c}> 未闭合`);
308
+ const p = this.offset, v = this.source.indexOf(">", p + 2);
309
+ v < 0 && this.fail(`元素 <${c}> 未闭合`);
310
+ const X = this.source.slice(p + 2, v).trim();
311
+ X !== c && this.fail(`闭合标签 </${X}> 与 <${c}> 不匹配`), this.offset = v + 1, Q = this.source.slice(p, this.offset);
312
+ }
313
+ const R = {
314
+ raw: this.source.slice(s, this.offset),
315
+ parent: e,
316
+ dirty: !1,
317
+ openRaw: r,
318
+ closeRaw: Q,
319
+ sourceSelfClosing: W,
320
+ // 源属性表必须与公开的当前属性表分离;删除/新增只改当前表,序列化仍靠源表定位原始字节。
321
+ sourceAttributes: [...w],
322
+ namespaces: h
323
+ };
324
+ return g.set(M, R), E.set(M, R), M;
325
+ }
326
+ scanOpenEnd(e) {
327
+ let n = "";
328
+ for (let s = e + 1; s < this.source.length; s++) {
329
+ const i = this.source[s];
330
+ if (n)
331
+ i === n && (n = "");
332
+ else if (i === '"' || i === "'") n = i;
333
+ else if (i === ">") return s;
334
+ }
335
+ this.fail("开始标签未闭合");
336
+ }
337
+ scanNameEnd(e, n) {
338
+ let s = e;
339
+ for (; s < n && !Z(this.source[s]); ) s++;
340
+ return s;
341
+ }
342
+ parseAttributes(e, n) {
343
+ const s = [], i = /* @__PURE__ */ new Set();
344
+ let r = n;
345
+ for (; r < e.length - 1; ) {
346
+ const o = r;
347
+ for (; O(e[r]); ) r++;
348
+ if (e[r] === "/" || e[r] === ">" || r >= e.length - 1) break;
349
+ r === o && this.fail("属性前缺少空白");
350
+ const c = r;
351
+ for (; r < e.length && !Z(e[r]); ) r++;
352
+ const a = e.slice(c, r);
353
+ for (B(a) || this.fail(`非法属性名 ${a || "(空)"}`), i.has(a) && this.fail(`属性 ${a} 重复`), i.add(a); O(e[r]); ) r++;
354
+ for (e[r++] !== "=" && this.fail(`属性 ${a} 缺少等号`); O(e[r]); ) r++;
355
+ const h = e[r++];
356
+ h !== '"' && h !== "'" && this.fail(`属性 ${a} 必须使用引号`);
357
+ const w = r, N = e.indexOf(h, w);
358
+ N < 0 && this.fail(`属性 ${a} 未闭合`), r = N + 1, s.push({
359
+ name: a,
360
+ value: e.slice(w, N),
361
+ quote: h,
362
+ state: {
363
+ source: !0,
364
+ present: !0,
365
+ changed: !1,
366
+ start: o,
367
+ nameStart: c,
368
+ valueStart: w,
369
+ valueEnd: N,
370
+ end: r
371
+ }
372
+ });
373
+ }
374
+ return s;
375
+ }
376
+ fail(e) {
377
+ throw new Error(`XML 解析失败(偏移 ${this.offset}):${e}`);
378
+ }
379
+ }
380
+ function ot(t) {
381
+ const e = m(t);
382
+ if (!e.dirty || t.type !== "element") return e.raw;
383
+ const n = E.get(t), s = n.sourceSelfClosing && t.children.length ? `</${t.name}>` : n.closeRaw;
384
+ return Et(t) + t.children.map(ot).join("") + s;
385
+ }
386
+ function qt(t) {
387
+ if (typeof t == "string") return new K(t).parse();
388
+ const e = Lt(t), n = new K(e.text).parse();
389
+ return it.set(n, { encoding: e.encoding, bom: e.bom, source: t }), n;
390
+ }
391
+ function Ot(t) {
392
+ const e = m(t);
393
+ return e.dirty ? t.children.map(ot).join("") : e.raw;
394
+ }
395
+ function Bt(t) {
396
+ const e = it.get(t);
397
+ if (e && !m(t).dirty) return e.source.slice();
398
+ const n = e ?? Xt(t), s = Ot(t).replace(/^\uFEFF/, "");
399
+ return Mt(s, n.encoding, n.bom);
400
+ }
401
+ function At(t, e = {}) {
402
+ if ("namespaceUri" in e)
403
+ throw new Error("namespaceUri 由 QName 与 xmlns 声明决定,不能脱离序列化文本覆盖");
404
+ st(t, "元素");
405
+ const n = A(t), s = e.selfClosing !== !1, i = [], r = [], o = {
406
+ type: "element",
407
+ name: t,
408
+ prefix: n.prefix,
409
+ localName: n.localName,
410
+ namespaceUri: null,
411
+ attributes: i,
412
+ children: r,
413
+ selfClosing: s
414
+ }, c = {
415
+ raw: s ? `<${t}/>` : `<${t}></${t}>`,
416
+ parent: null,
417
+ dirty: !0,
418
+ openRaw: s ? `<${t}/>` : `<${t}>`,
419
+ closeRaw: s ? "" : `</${t}>`,
420
+ sourceSelfClosing: s,
421
+ sourceAttributes: [],
422
+ namespaces: /* @__PURE__ */ new Map()
423
+ };
424
+ g.set(o, c), E.set(o, c);
425
+ for (const [a, h, w] of e.attributes ?? [])
426
+ rt(o, a, h, w);
427
+ return o;
428
+ }
429
+ function lt(t) {
430
+ if (t.type !== "element") {
431
+ const n = { ...t };
432
+ return g.set(n, { raw: m(t).raw, parent: null, dirty: !1 }), n;
433
+ }
434
+ const e = At(t.name, {
435
+ selfClosing: t.selfClosing,
436
+ attributes: t.attributes.map((n) => [n.name, n.value, n.quote])
437
+ });
438
+ for (const n of t.children) T(e, lt(n));
439
+ return e;
440
+ }
441
+ function zt(t) {
442
+ const e = lt(t), n = new Set(e.attributes.filter((s) => s.name === "xmlns" || s.name.startsWith("xmlns:")).map((s) => s.name === "xmlns" ? "" : s.name.slice(6)));
443
+ for (const [s, i] of E.get(t).namespaces)
444
+ s === "xml" || n.has(s) || rt(e, s ? `xmlns:${s}` : "xmlns", i);
445
+ return e;
446
+ }
447
+ function ct(t, e) {
448
+ if (m(e).parent) throw new Error("XML 节点已经属于另一棵树;请先显式移除");
449
+ let s = t;
450
+ for (; s; ) {
451
+ if (s === e) throw new Error("不能把 XML 节点插入自身后代");
452
+ s = m(s).parent;
453
+ }
454
+ }
455
+ function at(t, e) {
456
+ e.type === "element" && P(e, E.get(t).namespaces);
457
+ }
458
+ function T(t, e, n = null) {
459
+ ct(t, e);
460
+ const s = t.children;
461
+ let i = n === null ? s.length : s.indexOf(n);
462
+ if (i < 0) throw new Error("before 不是该父元素的子节点");
463
+ let r = n !== null && i > 0 ? s[i - 1] : null, o = (r == null ? void 0 : r.type) === "text" && !r.value.trim() ? V(r.value) : null;
464
+ if (n === null && i > 0) {
465
+ const c = s[i - 1];
466
+ if (c.type === "text" && !c.value.trim()) {
467
+ r = [...s.slice(0, -1)].reverse().find((h) => h.type === "text" && !h.value.trim()) ?? null;
468
+ const a = (r == null ? void 0 : r.type) === "text" ? r.value : c.value.replace(/([^\r\n])?$/, " $&");
469
+ o = V(a), i--, s.splice(i, 0, o, e), i++;
470
+ } else
471
+ s.splice(i, 0, e);
472
+ } else
473
+ s.splice(i, 0, e, ...o ? [o] : []);
474
+ return at(t, e), m(e).parent = t, o && (m(o).parent = t), t.selfClosing = !1, S(t), i;
475
+ }
476
+ function jt(t, e) {
477
+ const n = t.children, s = n.indexOf(e);
478
+ if (s < 0) return !1;
479
+ const i = n[s - 1], r = n[s + 1];
480
+ return e.type === "element" && (i == null ? void 0 : i.type) === "text" && !i.value.trim() && /[\r\n]/.test(i.value) && (r == null ? void 0 : r.type) === "text" && !r.value.trim() ? (n.splice(s - 1, 2), m(i).parent = null) : n.splice(s, 1), m(e).parent = null, t.selfClosing = E.get(t).sourceSelfClosing && n.length === 0, S(t), !0;
481
+ }
482
+ function Gt(t, e, n) {
483
+ if (new Set(n).size !== n.length) throw new Error("XML 替换不能包含重复节点");
484
+ const s = t.children, i = s.indexOf(e);
485
+ if (i < 0 || m(e).parent !== t) throw new Error("XML 替换目标不是父元素的直属子节点");
486
+ for (const r of n) ct(t, r);
487
+ s.splice(i, 1, ...n), m(e).parent = null;
488
+ for (const r of n)
489
+ at(t, r), m(r).parent = t;
490
+ S(t);
491
+ }
492
+ function Qt(t, e) {
493
+ if (new Set(e).size !== e.length) throw new Error("XML 重排不能包含重复节点");
494
+ const n = t.children, s = new Set(e);
495
+ for (const o of e)
496
+ if (m(o).parent !== t) throw new Error("XML 重排节点不是目标父元素的直属子节点");
497
+ const i = [], r = [];
498
+ if (n.forEach((o, c) => {
499
+ s.has(o) && (i.push(c), r.push(o));
500
+ }), r.length !== e.length) throw new Error("XML 重排节点集合与父元素不一致");
501
+ return r.every((o, c) => o === e[c]) ? !1 : (i.forEach((o, c) => {
502
+ n[o] = e[c];
503
+ }), S(t), !0);
504
+ }
505
+ function V(t) {
506
+ const e = { type: "text", value: t }, n = t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
507
+ return g.set(e, { raw: n, parent: null, dirty: !0 }), e;
508
+ }
509
+ const f = (t, e) => `{${t}}${e}`, U = (t, ...e) => e.map((n) => f(t, n)), l = (...t) => U(x, ...t), u = (...t) => U(d, ...t), $ = (...t) => U(q, ...t), Pt = (...t) => U(mt, ...t), I = l("noFill", "solidFill", "gradFill", "blipFill", "pattFill", "grpFill"), z = l("effectLst", "effectDag"), _ = [
510
+ l("xfrm"),
511
+ l("custGeom", "prstGeom"),
512
+ I,
513
+ l("ln"),
514
+ z,
515
+ l("scene3d"),
516
+ l("sp3d"),
517
+ l("extLst")
518
+ ], Y = [l("bodyPr"), l("lstStyle"), l("p")], Ft = [
519
+ l("prstTxWarp"),
520
+ l("noAutofit", "normAutofit", "spAutoFit"),
521
+ l("scene3d"),
522
+ l("sp3d"),
523
+ l("flatTx"),
524
+ l("extLst")
525
+ ], $t = {
526
+ [f(x, "spPr")]: { groups: _ },
527
+ [f(d, "spPr")]: { groups: _ },
528
+ [f(d, "grpSpPr")]: { groups: _ },
529
+ [f(x, "xfrm")]: { groups: [l("off"), l("ext"), l("chOff"), l("chExt")] },
530
+ [f(d, "xfrm")]: { groups: [l("off"), l("ext")] },
531
+ [f(q, "xfrm")]: { groups: [l("off"), l("ext")] },
532
+ [f(x, "ln")]: {
533
+ groups: [
534
+ I,
535
+ l("prstDash", "custDash"),
536
+ l("round", "bevel", "miter"),
537
+ l("headEnd"),
538
+ l("tailEnd"),
539
+ l("extLst")
540
+ ]
541
+ },
542
+ [f(x, "effectLst")]: {
543
+ groups: [
544
+ l("blur"),
545
+ l("fillOverlay"),
546
+ l("glow"),
547
+ l("innerShdw"),
548
+ l("outerShdw"),
549
+ l("prstShdw"),
550
+ l("reflection"),
551
+ l("softEdge")
552
+ ]
553
+ },
554
+ [f(x, "rPr")]: {
555
+ groups: [
556
+ l("ln"),
557
+ I,
558
+ z,
559
+ l("highlight"),
560
+ l("uLnTx", "uLn"),
561
+ l("uFillTx", "uFill"),
562
+ l("latin"),
563
+ l("ea"),
564
+ l("cs"),
565
+ l("sym"),
566
+ l("hlinkClick"),
567
+ l("hlinkMouseOver"),
568
+ l("rtl"),
569
+ l("extLst")
570
+ ]
571
+ },
572
+ [f(d, "cNvPr")]: {
573
+ groups: [l("hlinkClick"), l("hlinkMouseOver"), l("extLst")]
574
+ },
575
+ [f(x, "pPr")]: {
576
+ groups: [
577
+ l("lnSpc"),
578
+ l("spcBef"),
579
+ l("spcAft"),
580
+ l("buClrTx", "buClr"),
581
+ l("buSzTx", "buSzPct", "buSzPts"),
582
+ l("buFontTx", "buFont"),
583
+ l("buNone", "buAutoNum", "buChar", "buBlip"),
584
+ l("tabLst"),
585
+ l("defRPr"),
586
+ l("extLst")
587
+ ]
588
+ },
589
+ [f(x, "p")]: {
590
+ groups: [l("pPr"), [...l("r", "br", "fld"), ...Pt("oMath", "oMathPara")], l("endParaRPr")]
591
+ },
592
+ [f(x, "bodyPr")]: { groups: Ft },
593
+ [f(x, "txBody")]: { groups: Y },
594
+ [f(d, "txBody")]: { groups: Y },
595
+ [f(d, "sp")]: {
596
+ groups: [u("nvSpPr"), u("spPr"), u("style"), u("txBody")]
597
+ },
598
+ [f(d, "spTree")]: {
599
+ groups: [
600
+ u("nvGrpSpPr"),
601
+ u("grpSpPr"),
602
+ [...u("sp", "grpSp", "graphicFrame", "cxnSp", "pic"), ...$("contentPart")],
603
+ u("extLst")
604
+ ]
605
+ },
606
+ [f(d, "graphicFrame")]: {
607
+ groups: [u("nvGraphicFramePr"), u("xfrm"), l("graphic"), u("extLst")]
608
+ },
609
+ [f(q, "contentPart")]: {
610
+ groups: [$("nvContentPartPr"), $("xfrm"), $("extLst")]
611
+ },
612
+ [f(d, "cSld")]: {
613
+ groups: [u("bg"), u("spTree"), u("custDataLst"), u("controls"), u("extLst")]
614
+ },
615
+ [f(d, "bg")]: {
616
+ groups: [u("bgPr", "bgRef")]
617
+ },
618
+ [f(d, "bgPr")]: {
619
+ groups: [I, z, l("extLst")]
620
+ },
621
+ [f(d, "sld")]: {
622
+ groups: [u("cSld"), u("clrMapOvr"), u("transition"), u("timing"), u("extLst")]
623
+ }
624
+ };
625
+ function j(t, e, n) {
626
+ return e === null ? -1 : t.findIndex((s) => s.includes(f(e, n)));
627
+ }
628
+ function ft(t) {
629
+ return t.namespaceUri ? $t[f(t.namespaceUri, t.localName)] : void 0;
630
+ }
631
+ function It(t, e, n) {
632
+ const s = t.children.filter((r) => r.type === "element" && r.namespaceUri === et && (r.localName === "Choice" || r.localName === "Fallback"));
633
+ if (!s.length) throw new Error("mc:AlternateContent 没有可判断序位的 Choice/Fallback");
634
+ const i = [];
635
+ for (const r of s) {
636
+ const o = r.children.filter((c) => c.type === "element");
637
+ if (!o.length) throw new Error(`mc:${r.localName} 没有可判断序位的元素`);
638
+ for (const c of o) {
639
+ const a = j(e.groups, c.namespaceUri, c.localName);
640
+ if (a < 0)
641
+ throw new Error(`无法判断 mc:${r.localName}/${c.name} 的 OOXML 序位`);
642
+ i.push(a);
643
+ }
644
+ }
645
+ if (i.every((r) => r > n)) return "after";
646
+ if (i.every((r) => r <= n)) return "before";
647
+ throw new Error("mc:AlternateContent 各分支横跨插入位置,拒绝猜测");
648
+ }
649
+ function Tt(t, e, n) {
650
+ if (t.namespaceUri === et && t.localName === "AlternateContent")
651
+ return It(t, e, n);
652
+ const s = j(e.groups, t.namespaceUri, t.localName);
653
+ return s < 0 ? "ignore" : s > n ? "after" : "before";
654
+ }
655
+ function kt(t, e) {
656
+ const n = ft(t);
657
+ if (!n) return T(t, e);
658
+ const s = wt(t, e), i = j(n.groups, s, e.localName);
659
+ if (i < 0)
660
+ throw new Error(`OOXML 顺序表缺少 ${t.name}/${e.name},拒绝无依据追加`);
661
+ let r = null;
662
+ for (const o of t.children)
663
+ if (o.type === "element" && Tt(o, n, i) === "after") {
664
+ r = o;
665
+ break;
666
+ }
667
+ return T(t, e, r);
668
+ }
669
+ function Rt(t, e, n = null) {
670
+ if (e.type !== "element" || !ft(t))
671
+ return T(t, e, n);
672
+ if (n !== null) throw new Error("已知 OOXML 容器不接受手工 before;请使用 schema 有序插入");
673
+ return kt(t, e);
674
+ }
675
+ export {
676
+ x as D,
677
+ et as M,
678
+ Dt as O,
679
+ d as P,
680
+ pt as X,
681
+ rt as a,
682
+ jt as b,
683
+ At as c,
684
+ Ut as d,
685
+ Qt as e,
686
+ Wt as f,
687
+ V as g,
688
+ ht as h,
689
+ T as i,
690
+ q as j,
691
+ kt as k,
692
+ Gt as l,
693
+ zt as m,
694
+ y as n,
695
+ m as o,
696
+ qt as p,
697
+ lt as q,
698
+ _t as r,
699
+ Bt as s,
700
+ mt as t,
701
+ Rt as u,
702
+ ot as v,
703
+ $t as w,
704
+ J as x,
705
+ Ot as y
706
+ };