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

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 (337) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/README.md +164 -21
  3. package/dist/alt-text.d.ts +5 -0
  4. package/dist/appearance/index.d.ts +12 -0
  5. package/dist/appearance/materialize.d.ts +4 -0
  6. package/dist/appearance/types.d.ts +26 -0
  7. package/dist/appearance/values.d.ts +9 -0
  8. package/dist/appearance.js +301 -0
  9. package/dist/cfb/index.d.ts +5 -0
  10. package/dist/cfb/read.d.ts +16 -0
  11. package/dist/cfb/write.d.ts +3 -0
  12. package/dist/cfb.js +208 -0
  13. package/dist/change-classification.d.ts +3 -3
  14. package/dist/chart/category-binding.d.ts +4 -0
  15. package/dist/chart/category-commands.d.ts +23 -0
  16. package/dist/chart/category-levels.d.ts +14 -0
  17. package/dist/chart/category-matrix.d.ts +2 -0
  18. package/dist/chart/category-value.d.ts +2 -0
  19. package/dist/chart/category-workbook.d.ts +13 -0
  20. package/dist/chart/commands.d.ts +28 -0
  21. package/dist/chart/context.d.ts +12 -0
  22. package/dist/chart/dataset-merge.d.ts +5 -0
  23. package/dist/chart/formula.d.ts +13 -0
  24. package/dist/chart/identity-frames.d.ts +4 -0
  25. package/dist/chart/identity-scopes.d.ts +6 -0
  26. package/dist/chart/identity.d.ts +24 -0
  27. package/dist/chart/index.d.ts +8 -0
  28. package/dist/chart/limits.d.ts +6 -0
  29. package/dist/chart/locator.d.ts +4 -0
  30. package/dist/chart/materialize.d.ts +7 -0
  31. package/dist/chart/ordering.d.ts +9 -0
  32. package/dist/chart/part-graph.d.ts +5 -0
  33. package/dist/chart/patch-validation.d.ts +3 -0
  34. package/dist/chart/plot-kinds.d.ts +2 -0
  35. package/dist/chart/projection.d.ts +8 -0
  36. package/dist/chart/save.d.ts +4 -0
  37. package/dist/chart/shared-added-plan.d.ts +19 -0
  38. package/dist/chart/shared-added-records.d.ts +8 -0
  39. package/dist/chart/shared-address.d.ts +5 -0
  40. package/dist/chart/shared-allocate.d.ts +7 -0
  41. package/dist/chart/shared-cache-codec.d.ts +5 -0
  42. package/dist/chart/shared-cache-identities.d.ts +3 -0
  43. package/dist/chart/shared-cache-migration.d.ts +7 -0
  44. package/dist/chart/shared-cache-save.d.ts +3 -0
  45. package/dist/chart/shared-cache-scopes.d.ts +13 -0
  46. package/dist/chart/shared-cache.d.ts +11 -0
  47. package/dist/chart/shared-category.d.ts +4 -0
  48. package/dist/chart/shared-cell.d.ts +9 -0
  49. package/dist/chart/shared-family.d.ts +26 -0
  50. package/dist/chart/shared-fields.d.ts +18 -0
  51. package/dist/chart/shared-graph.d.ts +19 -0
  52. package/dist/chart/shared-growth-space.d.ts +5 -0
  53. package/dist/chart/shared-inserted-cells.d.ts +14 -0
  54. package/dist/chart/shared-inserted-command.d.ts +7 -0
  55. package/dist/chart/shared-inserted-layout.d.ts +16 -0
  56. package/dist/chart/shared-inserted-project.d.ts +14 -0
  57. package/dist/chart/shared-inserted-records.d.ts +16 -0
  58. package/dist/chart/shared-inserted-save.d.ts +6 -0
  59. package/dist/chart/shared-joint-command.d.ts +9 -0
  60. package/dist/chart/shared-joint-records.d.ts +9 -0
  61. package/dist/chart/shared-record-axis.d.ts +25 -0
  62. package/dist/chart/shared-record-remove.d.ts +13 -0
  63. package/dist/chart/shared-record-stage.d.ts +2 -0
  64. package/dist/chart/shared-records.d.ts +2 -0
  65. package/dist/chart/shared-rows.d.ts +17 -0
  66. package/dist/chart/shared-runtime.d.ts +19 -0
  67. package/dist/chart/shared-save-plan.d.ts +4 -0
  68. package/dist/chart/shared-save.d.ts +3 -0
  69. package/dist/chart/shared-series.d.ts +6 -0
  70. package/dist/chart/shared-source-cache.d.ts +4 -0
  71. package/dist/chart/shared-topology.d.ts +9 -0
  72. package/dist/chart/shared-unresolved.d.ts +3 -0
  73. package/dist/chart/shared-validation.d.ts +6 -0
  74. package/dist/chart/shared-workbook-source.d.ts +6 -0
  75. package/dist/chart/shared-xy-command.d.ts +7 -0
  76. package/dist/chart/shared-xy-family.d.ts +16 -0
  77. package/dist/chart/shared-xy-project.d.ts +6 -0
  78. package/dist/chart/shared-xy-records.d.ts +23 -0
  79. package/dist/chart/shared-xy-save.d.ts +5 -0
  80. package/dist/chart/shared-xy-source.d.ts +39 -0
  81. package/dist/chart/shared.d.ts +13 -0
  82. package/dist/chart/source.d.ts +11 -0
  83. package/dist/chart/types.d.ts +86 -0
  84. package/dist/chart/validation.d.ts +24 -0
  85. package/dist/chart/workbook-range.d.ts +16 -0
  86. package/dist/chart/workbook-read.d.ts +7 -0
  87. package/dist/chart/workbook-write.d.ts +9 -0
  88. package/dist/chart/workbook.d.ts +25 -0
  89. package/dist/chart/xml-data.d.ts +14 -0
  90. package/dist/chart/xml-namespaces.d.ts +16 -0
  91. package/dist/chart-design/index.d.ts +10 -0
  92. package/dist/chart-design/types.d.ts +11 -0
  93. package/dist/chart-design/xml.d.ts +2 -0
  94. package/dist/chart-design.js +361 -0
  95. package/dist/chart-ex/index.d.ts +15 -0
  96. package/dist/chart-ex/workbook.d.ts +6 -0
  97. package/dist/chart-ex/xml.d.ts +14 -0
  98. package/dist/chart-ex.js +457 -0
  99. package/dist/chart-shared/index.d.ts +12 -0
  100. package/dist/chart-shared.js +1 -0
  101. package/dist/chart.js +1 -0
  102. package/dist/clipboard-links-GuPtqr1z.js +778 -0
  103. package/dist/clipboard-package.d.ts +4 -0
  104. package/dist/clipboard-source.d.ts +6 -2
  105. package/dist/clipboard-trees.d.ts +9 -0
  106. package/dist/commands/add-slide-identity.d.ts +2 -0
  107. package/dist/commands/bullet-image-resource.d.ts +11 -0
  108. package/dist/commands/clear-format.d.ts +4 -0
  109. package/dist/commands/common-object-slide-patch.d.ts +4 -0
  110. package/dist/commands/common-object-slide-types.d.ts +68 -0
  111. package/dist/commands/direct-format-patches.d.ts +11 -5
  112. package/dist/commands/distribute-elements.d.ts +4 -0
  113. package/dist/commands/edit-table-grid.d.ts +10 -0
  114. package/dist/commands/element-alt-text.d.ts +8 -0
  115. package/dist/commands/element-arrangement.d.ts +17 -0
  116. package/dist/commands/element-effects.d.ts +1 -1
  117. package/dist/commands/element-fill.d.ts +1 -1
  118. package/dist/commands/element-geometry.d.ts +5 -2
  119. package/dist/commands/element-image-content.d.ts +2 -2
  120. package/dist/commands/element-link.d.ts +1 -1
  121. package/dist/commands/element-name.d.ts +1 -1
  122. package/dist/commands/element-stroke.d.ts +1 -1
  123. package/dist/commands/element-text.d.ts +1 -1
  124. package/dist/commands/element-transform.d.ts +2 -2
  125. package/dist/commands/geometry-types.d.ts +23 -1
  126. package/dist/commands/hierarchy-record.d.ts +5 -0
  127. package/dist/commands/image-resource.d.ts +8 -1
  128. package/dist/commands/insertion-host.d.ts +14 -1
  129. package/dist/commands/layout-property.d.ts +7 -0
  130. package/dist/commands/master-property.d.ts +5 -0
  131. package/dist/commands/master-text-style-types.d.ts +27 -0
  132. package/dist/commands/master-text-style.d.ts +7 -0
  133. package/dist/commands/paste-resources.d.ts +9 -5
  134. package/dist/commands/patch-apply.d.ts +3 -0
  135. package/dist/commands/patch-count.d.ts +1 -0
  136. package/dist/commands/patch-invalidation.d.ts +1 -1
  137. package/dist/commands/patch-stage.d.ts +4 -0
  138. package/dist/commands/record-override.d.ts +5 -0
  139. package/dist/commands/replace-image.d.ts +6 -1
  140. package/dist/commands/sections.d.ts +10 -0
  141. package/dist/commands/set-preset.d.ts +5 -0
  142. package/dist/commands/slide-property-types.d.ts +55 -5
  143. package/dist/commands/slide-size.d.ts +7 -0
  144. package/dist/commands/spid.d.ts +1 -1
  145. package/dist/commands/table-grid-patch.d.ts +12 -0
  146. package/dist/commands/text-target.d.ts +2 -2
  147. package/dist/commands/theme-types.d.ts +47 -0
  148. package/dist/commands/theme.d.ts +9 -0
  149. package/dist/commands/types.d.ts +194 -17
  150. package/dist/commands/ungroup-source.d.ts +3 -0
  151. package/dist/comments/index.d.ts +35 -0
  152. package/dist/comments/save.d.ts +3 -0
  153. package/dist/comments/state.d.ts +10 -0
  154. package/dist/comments/xml.d.ts +12 -0
  155. package/dist/comments.js +782 -0
  156. package/dist/common-object-slide-types.d.ts +34 -0
  157. package/dist/data-validation.d.ts +1 -1
  158. package/dist/describe/budget.d.ts +3 -0
  159. package/dist/describe/index.d.ts +5 -0
  160. package/dist/describe/read.d.ts +4 -0
  161. package/dist/describe/types.d.ts +103 -0
  162. package/dist/describe.js +192 -0
  163. package/dist/design-dependencies.d.ts +8 -0
  164. package/dist/design-projection-package.d.ts +10 -0
  165. package/dist/design-target.d.ts +10 -0
  166. package/dist/design.d.ts +3 -0
  167. package/dist/document-extensions.d.ts +9 -0
  168. package/dist/document.d.ts +1 -1
  169. package/dist/dynamic-projection.d.ts +6 -0
  170. package/dist/edit-core.js +5420 -4111
  171. package/dist/editor.d.ts +15 -3
  172. package/dist/element-source.d.ts +11 -0
  173. package/dist/element-spids.d.ts +4 -0
  174. package/dist/extension-address-journal.d.ts +9 -0
  175. package/dist/extension-address-remap.d.ts +14 -0
  176. package/dist/extension-addresses.d.ts +20 -0
  177. package/dist/extension-copy-history.d.ts +7 -0
  178. package/dist/extension-copy.d.ts +16 -0
  179. package/dist/extension-migration-receipt.d.ts +34 -0
  180. package/dist/extension-recovery-context.d.ts +5 -0
  181. package/dist/extension-runtime.d.ts +64 -0
  182. package/dist/generate/comments.d.ts +3 -0
  183. package/dist/generate/compatibility-parts.d.ts +14 -0
  184. package/dist/generate/compatibility-references.d.ts +3 -0
  185. package/dist/generate/compatibility.d.ts +4 -0
  186. package/dist/generate/index.d.ts +1 -0
  187. package/dist/generate/master-defaults.d.ts +4 -0
  188. package/dist/generate/materialize.d.ts +2 -2
  189. package/dist/generate/math.d.ts +3 -0
  190. package/dist/generate/portable-clipboard.d.ts +4 -0
  191. package/dist/generate/projection-tree.d.ts +8 -0
  192. package/dist/generate/template.d.ts +68 -1
  193. package/dist/generate/text-body.d.ts +2 -0
  194. package/dist/generate/text-effects.d.ts +5 -0
  195. package/dist/generate/text-override.d.ts +8 -0
  196. package/dist/generate/validation.d.ts +3 -0
  197. package/dist/generate/warp.d.ts +2 -0
  198. package/dist/generate.js +1232 -512
  199. package/dist/history.d.ts +11 -1
  200. package/dist/identities.d.ts +4 -0
  201. package/dist/image-content.d.ts +5 -2
  202. package/dist/image-resource-history.d.ts +2 -0
  203. package/dist/index-C2r7c6G6.js +714 -0
  204. package/dist/index-CYDvbiwF.js +1 -0
  205. package/dist/index.d.ts +35 -7
  206. package/dist/ink/index.d.ts +27 -0
  207. package/dist/ink/model.d.ts +4 -0
  208. package/dist/ink/save.d.ts +3 -0
  209. package/dist/ink/source.d.ts +7 -0
  210. package/dist/ink.js +324 -0
  211. package/dist/layout-assets.d.ts +3 -1
  212. package/dist/layout-projection.d.ts +17 -5
  213. package/dist/layout-state.d.ts +2 -0
  214. package/dist/layout-types.d.ts +42 -0
  215. package/dist/layout.d.ts +5 -0
  216. package/dist/lint/color.d.ts +5 -0
  217. package/dist/lint/index.d.ts +7 -0
  218. package/dist/lint/prompts.d.ts +3 -0
  219. package/dist/lint/report.d.ts +21 -0
  220. package/dist/lint/sampler-batch.d.ts +4 -0
  221. package/dist/lint/sampler-images.d.ts +2 -0
  222. package/dist/lint/sampler.d.ts +9 -0
  223. package/dist/lint/snapshot.d.ts +34 -0
  224. package/dist/lint/types.d.ts +67 -0
  225. package/dist/lint-sampler.js +187 -0
  226. package/dist/lint.js +659 -0
  227. package/dist/master-state.d.ts +3 -0
  228. package/dist/master-text-style-state.d.ts +3 -0
  229. package/dist/master-types.d.ts +55 -0
  230. package/dist/master.d.ts +5 -0
  231. package/dist/media/audio-icon.d.ts +2 -0
  232. package/dist/media/commands.d.ts +3 -0
  233. package/dist/media/index.d.ts +10 -0
  234. package/dist/media/markup.d.ts +10 -0
  235. package/dist/media/mp4-boxes.d.ts +12 -0
  236. package/dist/media/mp4-fragments.d.ts +8 -0
  237. package/dist/media/mp4-samples.d.ts +4 -0
  238. package/dist/media/mp4.d.ts +2 -0
  239. package/dist/media/poster.d.ts +2 -0
  240. package/dist/media/replace-poster.d.ts +3 -0
  241. package/dist/media/resource.d.ts +4 -0
  242. package/dist/media/source.d.ts +14 -0
  243. package/dist/media/types.d.ts +33 -0
  244. package/dist/media-properties.d.ts +4 -0
  245. package/dist/media.js +1630 -0
  246. package/dist/model-invariants-BM19JVxy.js +8980 -0
  247. package/dist/object-source.d.ts +11 -0
  248. package/dist/ole/container.d.ts +14 -0
  249. package/dist/ole/content.d.ts +94 -0
  250. package/dist/ole/index.d.ts +20 -0
  251. package/dist/ole/preview.d.ts +3 -0
  252. package/dist/ole/save.d.ts +2 -0
  253. package/dist/ole/state.d.ts +16 -0
  254. package/dist/ole.js +870 -0
  255. package/dist/opc.js +1 -1
  256. package/dist/paragraph-level.d.ts +2 -2
  257. package/dist/paragraph-property-schema.d.ts +4 -1
  258. package/dist/{patch-D7lZelRa.js → patch-BwhfBbYE.js} +10 -10
  259. package/dist/patch-events.d.ts +5 -1
  260. package/dist/ppt/appearance.d.ts +11 -0
  261. package/dist/ppt/binary.d.ts +20 -0
  262. package/dist/ppt/drawing.d.ts +18 -0
  263. package/dist/ppt/geometry.d.ts +4 -0
  264. package/dist/ppt/index.d.ts +12 -0
  265. package/dist/ppt/pictures.d.ts +11 -0
  266. package/dist/ppt/text.d.ts +9 -0
  267. package/dist/ppt.js +774 -0
  268. package/dist/preset-geometry.d.ts +6 -0
  269. package/dist/projection.d.ts +2 -0
  270. package/dist/query-BHLjWjnu.js +903 -0
  271. package/dist/recovery-identity.d.ts +1 -0
  272. package/dist/recovery-migrations.d.ts +3 -0
  273. package/dist/recovery.d.ts +3 -0
  274. package/dist/resize/index.d.ts +6 -0
  275. package/dist/resize/text.d.ts +4 -0
  276. package/dist/resize.js +5090 -0
  277. package/dist/retained-element-origins.d.ts +6 -0
  278. package/dist/run-property-fields.d.ts +12 -0
  279. package/dist/run-property-schema.d.ts +3 -1
  280. package/dist/run-style.d.ts +15 -0
  281. package/dist/save/alt-text.d.ts +4 -0
  282. package/dist/save/comments.d.ts +3 -0
  283. package/dist/save/effects.d.ts +2 -1
  284. package/dist/save/extension-availability.d.ts +3 -0
  285. package/dist/save/extension-elements.d.ts +26 -0
  286. package/dist/save/index.d.ts +6 -1
  287. package/dist/save/insertion.d.ts +6 -5
  288. package/dist/save/layout-properties.d.ts +4 -0
  289. package/dist/save/master-properties.d.ts +5 -0
  290. package/dist/save/paragraph-overrides.d.ts +3 -0
  291. package/dist/save/slide-parts.d.ts +1 -0
  292. package/dist/save/table.d.ts +2 -0
  293. package/dist/save/xfrm.d.ts +8 -2
  294. package/dist/save.js +493 -498
  295. package/dist/sections.d.ts +8 -0
  296. package/dist/session-assets.d.ts +4 -0
  297. package/dist/slide-parts-D0o_DDhi.js +1331 -0
  298. package/dist/slide-size.d.ts +6 -0
  299. package/dist/smartart/drawing.d.ts +3 -0
  300. package/dist/smartart/index.d.ts +16 -0
  301. package/dist/smartart/model.d.ts +18 -0
  302. package/dist/smartart/save.d.ts +3 -0
  303. package/dist/smartart.js +604 -0
  304. package/dist/source-retention.d.ts +7 -0
  305. package/dist/space.d.ts +37 -0
  306. package/dist/table-cell.d.ts +7 -1
  307. package/dist/table-grid-projection.d.ts +6 -0
  308. package/dist/table-grid.d.ts +45 -0
  309. package/dist/table-invariants.d.ts +4 -0
  310. package/dist/table-rows.d.ts +2 -1
  311. package/dist/table-scale.d.ts +4 -0
  312. package/dist/table-style.d.ts +5 -4
  313. package/dist/templates/index.d.ts +4 -0
  314. package/dist/templates/recipes.d.ts +5 -0
  315. package/dist/templates/types.d.ts +17 -0
  316. package/dist/templates.js +543 -0
  317. package/dist/text-flatten.d.ts +6 -0
  318. package/dist/text-fragment.d.ts +5 -0
  319. package/dist/text-model.d.ts +8 -8
  320. package/dist/text-override-validation.d.ts +6 -2
  321. package/dist/text-selection.d.ts +4 -0
  322. package/dist/theme-projection.d.ts +8 -0
  323. package/dist/theme-xml.d.ts +3 -0
  324. package/dist/theme.d.ts +14 -0
  325. package/dist/types.d.ts +174 -8
  326. package/dist/xml/index.d.ts +1 -1
  327. package/dist/xml/nodes.d.ts +2 -2
  328. package/dist/xml/shape-ids.d.ts +3 -0
  329. package/dist/xml.js +19 -16
  330. package/package.json +79 -5
  331. package/schemas/describe.schema.json +479 -0
  332. package/schemas/lint.schema.json +145 -0
  333. package/dist/document-B1jjN-QB.js +0 -274
  334. package/dist/image-resource-DbgJS9n-.js +0 -24
  335. package/dist/index-D2JizcOQ.js +0 -706
  336. package/dist/insertion-CGpb504L.js +0 -6152
  337. package/dist/table-style-part-DBtpxmuo.js +0 -1042
package/dist/ole.js ADDED
@@ -0,0 +1,870 @@
1
+ import { sourcePartBytes as k } from "@web-ppt/edit-core";
2
+ import { xmlElementChildren as M, parseXmlTree as y, findXmlAttribute as at, serializeXmlTreeBytes as j, createXmlElement as A, insertXmlChildUnchecked as R, removeXmlAttribute as rt, setXmlAttribute as P, removeXmlChild as q, createXmlText as yt, cloneXmlNode as te } from "@web-ppt/edit-core/xml";
3
+ import { isCompoundFile as ee, readCompoundFile as re, patchCompoundFile as ne } from "@web-ppt/edit-core/cfb";
4
+ import { unzipSync as oe } from "fflate";
5
+ import { patchOpcPackage as se, disposeOpcPackage as ie } from "@web-ppt/edit-core/opc";
6
+ import { sha256 as le } from "@web-ppt/core";
7
+ function It(t) {
8
+ return [...le(t)].map((e) => e.toString(16).padStart(2, "0")).join("");
9
+ }
10
+ const wt = Symbol.for("@web-ppt/edit-core/extensions/v1"), Rt = Symbol.for("@web-ppt/edit-core/extensions-generation/v1"), bt = Symbol.for("@web-ppt/edit-core/extensions-listeners/v1"), ae = /^[a-z][a-z0-9-]{0,63}$/;
11
+ function vt() {
12
+ const t = globalThis;
13
+ return t[bt] ?? (t[bt] = { documents: /* @__PURE__ */ new WeakMap(), pending: /* @__PURE__ */ new Map(), active: /* @__PURE__ */ new Set(), resolvers: /* @__PURE__ */ new WeakMap() });
14
+ }
15
+ function ce(t) {
16
+ if (!ae.test(t))
17
+ throw new Error(`编辑扩展命名空间无效:${t}`);
18
+ }
19
+ function fe() {
20
+ const t = globalThis;
21
+ return t[wt] ?? (t[wt] = /* @__PURE__ */ new Map());
22
+ }
23
+ function ue(t, e) {
24
+ var l;
25
+ ce(t), fe().set(t, e);
26
+ const n = globalThis;
27
+ n[Rt] = (n[Rt] ?? 0) + 1;
28
+ const r = new Set(vt().pending.get(t));
29
+ if (e.migrate) for (const o of vt().active) r.add(o);
30
+ vt().pending.delete(t);
31
+ for (const o of r ?? [])
32
+ try {
33
+ o(t);
34
+ } catch (s) {
35
+ (l = globalThis.reportError) == null || l.call(globalThis, s);
36
+ }
37
+ }
38
+ const pe = "http://schemas.openxmlformats.org/presentationml/2006/main", de = "http://schemas.openxmlformats.org/package/2006/relationships", me = "http://purl.oclc.org/ooxml", he = `${me}/presentationml/main`, ge = (t, e, n) => t === e || t === n, xe = (t) => ge(t, pe, he), Mt = k, jt = /* @__PURE__ */ new WeakMap(), we = {
39
+ bg1: "lt1",
40
+ tx1: "dk1",
41
+ bg2: "lt2",
42
+ tx2: "dk2",
43
+ accent1: "accent1",
44
+ accent2: "accent2",
45
+ accent3: "accent3",
46
+ accent4: "accent4",
47
+ accent5: "accent5",
48
+ accent6: "accent6",
49
+ hlink: "hlink",
50
+ folHlink: "folHlink"
51
+ };
52
+ function be(t) {
53
+ const e = t.lastIndexOf("/");
54
+ return `${t.slice(0, e + 1)}_rels/${t.slice(e + 1)}.rels`;
55
+ }
56
+ function ve(t, e) {
57
+ if (e.startsWith("/")) return e.slice(1);
58
+ const n = t.slice(0, t.lastIndexOf("/") + 1).split("/").filter(Boolean);
59
+ for (const r of e.split("/"))
60
+ r === ".." ? n.pop() : r && r !== "." && n.push(r);
61
+ return n.join("/");
62
+ }
63
+ function _t(t, e) {
64
+ var s, i, a, f;
65
+ const n = Mt(t, be(e));
66
+ if (!n) return {};
67
+ let r = jt.get(n);
68
+ r || (r = /* @__PURE__ */ new Map(), jt.set(n, r));
69
+ const l = r.get(e);
70
+ if (l) return l;
71
+ const o = /* @__PURE__ */ Object.create(null);
72
+ for (const c of M(y(n).root, {
73
+ localName: "Relationship",
74
+ namespaceUri: de
75
+ })) {
76
+ const h = (s = at(c, { localName: "Id", namespaceUri: null })) == null ? void 0 : s.value, d = (i = at(c, { localName: "Type", namespaceUri: null })) == null ? void 0 : i.value, u = (a = at(c, { localName: "Target", namespaceUri: null })) == null ? void 0 : a.value, E = ((f = at(c, {
77
+ localName: "TargetMode",
78
+ namespaceUri: null
79
+ })) == null ? void 0 : f.value) === "External";
80
+ h && d && u && (o[h] = { type: d, target: E ? u : ve(e, u), ...E ? { external: !0 } : {} });
81
+ }
82
+ return r.set(e, o), o;
83
+ }
84
+ function ye(t, e) {
85
+ var r;
86
+ let n = (r = t.elements[e]) == null ? void 0 : r.parent;
87
+ for (; n && t.elements[n]; ) n = t.elements[n].parent;
88
+ return n ? t.slides[n] : void 0;
89
+ }
90
+ const Ee = (t) => {
91
+ var n;
92
+ const e = (n = t.match(/rgba?\(([^)]+)\)/)) == null ? void 0 : n[1].split(",").slice(0, 3).map((r) => Math.max(0, Math.min(255, Math.round(Number(r.trim())))));
93
+ return (e == null ? void 0 : e.length) === 3 && e.every(Number.isFinite) ? e.map((r) => r.toString(16).padStart(2, "0")).join("").toUpperCase() : t.replace("#", "");
94
+ };
95
+ function Te(t, e, n) {
96
+ var E;
97
+ const r = ye(t, e), l = r != null && r.layoutId ? t.layouts[r.layoutId] : void 0, o = l ? t.masters[l.origin.masterPart] : void 0, s = (l == null ? void 0 : l.themeId) ?? (o == null ? void 0 : o.themeId), i = s ? t.themes[s] : void 0, a = { ...i == null ? void 0 : i.src.colors, ...i == null ? void 0 : i.ovr.colors }, f = structuredClone((i == null ? void 0 : i.src.fonts) ?? {
98
+ major: { latin: "", ea: "", cs: "", scripts: {} },
99
+ minor: { latin: "", ea: "", cs: "", scripts: {} }
100
+ });
101
+ for (const m of ["major", "minor"])
102
+ Object.assign(f[m], (E = i == null ? void 0 : i.ovr.fonts) == null ? void 0 : E[m]);
103
+ const c = { ...we }, h = o && Mt(t, o.id), d = h ? y(h).root : null, u = d && xe(d.namespaceUri) ? M(d).find((m) => m.localName === "clrMap" && m.namespaceUri === d.namespaceUri) : null;
104
+ for (const m of (u == null ? void 0 : u.attributes) ?? []) c[m.localName] = m.value;
105
+ return {
106
+ ctx: { theme: Object.fromEntries(Object.entries(a).map(([m, N]) => [m, Ee(N)])), clrMap: c },
107
+ fonts: f,
108
+ rels: structuredClone(_t(t, n))
109
+ };
110
+ }
111
+ function Et(t, e, n, r = "id") {
112
+ var u, E, m, N;
113
+ const l = t.elements[e], o = l == null ? void 0 : l.meta.origin;
114
+ if (!o || l.meta.editable !== "frame") return null;
115
+ let s = l.parent;
116
+ for (; t.elements[s]; ) s = t.elements[s].parent;
117
+ const i = ((E = (u = t.slides[s]) == null ? void 0 : u.creation) == null ? void 0 : E.duplicateSourcePart) ?? o.part, a = k(t, i);
118
+ if (!a) return null;
119
+ const f = y(a).root, c = [f], h = f.namespaceUri, d = _t(t, i);
120
+ for (; c.length; ) {
121
+ const b = c.pop(), S = M(b);
122
+ if (b.localName !== "graphicFrame" || b.namespaceUri !== h) {
123
+ c.push(...S);
124
+ continue;
125
+ }
126
+ const $ = S.find((T) => T.localName === "nvGraphicFramePr" && T.namespaceUri === h), C = $ && M($).find((T) => T.localName === "cNvPr" && T.namespaceUri === h);
127
+ if (Number((m = C == null ? void 0 : C.attributes.find((T) => T.localName === "id" && !T.namespaceUri)) == null ? void 0 : m.value) !== o.spid) continue;
128
+ const F = [...S];
129
+ for (; F.length; ) {
130
+ const T = F.pop();
131
+ if (T.localName === "graphicData" && T.attributes.some((z) => z.localName === "uri" && !z.namespaceUri && z.value === n)) {
132
+ const z = M(T).find((I) => I.namespaceUri === n || n.endsWith("/ole") && I.namespaceUri === h && I.localName === "oleObj"), st = Object.fromEntries(((z == null ? void 0 : z.attributes) ?? []).filter((I) => {
133
+ var Z;
134
+ return ((Z = I.namespaceUri) == null ? void 0 : Z.endsWith("/relationships")) && d[I.value];
135
+ }).map((I) => [I.localName, d[I.value].target])), _ = (N = z == null ? void 0 : z.attributes.find((I) => {
136
+ var Z;
137
+ return I.localName === r && ((Z = I.namespaceUri) == null ? void 0 : Z.endsWith("/relationships"));
138
+ })) == null ? void 0 : N.value, J = _ && d[_], U = J && J.target, it = U && k(t, U);
139
+ if (U && it) return {
140
+ part: U,
141
+ hostPart: i,
142
+ references: st,
143
+ xml: new TextDecoder().decode(it),
144
+ context: { ...Te(t, e, U), readPart: (I) => k(t, I) }
145
+ };
146
+ }
147
+ F.push(...M(T));
148
+ }
149
+ }
150
+ return null;
151
+ }
152
+ const L = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", p = (t, e) => {
153
+ var n;
154
+ return (n = t.attributes.find((r) => r.localName === e)) == null ? void 0 : n.value;
155
+ }, g = (t, e) => t ? M(t).filter((n) => n.localName === e) : [], x = (t, e) => g(t, e)[0], B = (t) => t.replace(/([^/]+)$/, "_rels/$1.rels");
156
+ function D(t, e) {
157
+ if (/[:\\?#]/.test(e)) throw new Error("嵌入文档关系必须指向包内文件");
158
+ const n = e.startsWith("/") ? [] : t.split("/").slice(0, -1);
159
+ for (const r of e.split("/"))
160
+ if (r === "..") {
161
+ if (!n.length) throw new Error("嵌入文档关系越界");
162
+ n.pop();
163
+ } else r && r !== "." && n.push(r);
164
+ return n.join("/");
165
+ }
166
+ const nt = (t) => t[0] === 80 && t[1] === 75;
167
+ function Oe(t) {
168
+ if (t.length < 6) return null;
169
+ const e = new DataView(t.buffer, t.byteOffset, t.byteLength), n = e.getUint32(0, !0);
170
+ if (n + 4 > t.length) return null;
171
+ let r = 4, l;
172
+ if (!nt(t.subarray(r))) {
173
+ if (e.getUint16(4, !0) !== 2) return null;
174
+ if (r = 6, !nt(t.subarray(r))) {
175
+ for (let i = 0; i < 2; i++) {
176
+ let a = r;
177
+ for (; a < t.length && t[a]; ) a++;
178
+ if (a - r > 4096 || a === t.length) return null;
179
+ r = a + 1;
180
+ }
181
+ if (r += 4, r + 4 > t.length) return null;
182
+ const s = e.getUint32(r, !0);
183
+ if (s > 4096 || (r += 4 + s, r + 4 > t.length)) return null;
184
+ l = r, r += 4;
185
+ }
186
+ }
187
+ const o = l === void 0 ? n + 4 - r : e.getUint32(l, !0);
188
+ return o < 0 || r + o > n + 4 || !nt(t.subarray(r)) ? null : { bytes: t.slice(r, r + o), wrap(s) {
189
+ const i = new Uint8Array(t.length - o + s.length), a = new DataView(i.buffer);
190
+ return i.set(t.subarray(0, r)), i.set(s, r), i.set(t.subarray(r + o), r + s.length), a.setUint32(0, n - o + s.length, !0), l !== void 0 && a.setUint32(l, s.length, !0), i;
191
+ } };
192
+ }
193
+ function Ne(t) {
194
+ let e = t, n = (c) => c;
195
+ if (ee(t)) {
196
+ const c = re(t), h = [];
197
+ for (const u of c.entries) if (u.type === 2 && u.bytes && !u.path.includes("/") && (u.name.toLowerCase() === "package" && nt(u.bytes) && h.push({ path: u.path, bytes: u.bytes, wrap: (E) => E }), u.name.toLowerCase() === "ole10native")) {
198
+ const E = Oe(u.bytes);
199
+ E && h.push({ path: u.path, ...E });
200
+ }
201
+ if (h.length !== 1) return null;
202
+ const d = h[0];
203
+ e = d.bytes, n = (u) => ne(t, { [d.path]: d.wrap(u) });
204
+ }
205
+ if (!nt(e)) return null;
206
+ let r = 0, l = 0;
207
+ if (e.length > 32 * 1024 * 1024) throw new Error("嵌入文档超限");
208
+ const o = oe(e, { filter(c) {
209
+ if ((r += c.originalSize) > 64 * 1024 * 1024 || ++l > 2048) throw new Error("嵌入文档解压超限");
210
+ return !0;
211
+ } });
212
+ if (!o["_rels/.rels"]) return null;
213
+ const s = g(y(o["_rels/.rels"]).root, "Relationship").filter((c) => p(c, "Type") === `${L}/officeDocument` && p(c, "TargetMode") !== "External");
214
+ if (s.length !== 1) return null;
215
+ const i = D("", p(s[0], "Target") ?? "");
216
+ if (!o[i]) return null;
217
+ const a = y(o[i]).root, f = a.localName === "workbook" ? "xlsx" : a.localName === "document" ? "docx" : null;
218
+ return f ? { parts: o, main: i, kind: f, wrap(c) {
219
+ const h = { format: "pptx", parts: o, bytes: e, disposed: !1 }, d = se(h, c), u = d.bytes.slice();
220
+ return d.package !== h && ie(d.package), n(u);
221
+ } } : null;
222
+ }
223
+ const w = "http://schemas.openxmlformats.org/spreadsheetml/2006/main", X = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", H = (t) => (t == null ? void 0 : t.children.map((e) => e.type === "text" || e.type === "cdata" ? e.value : e.type === "element" ? H(e) : "").join("")) ?? "", W = (t, e, n = t.namespaceUri) => {
224
+ const r = [], l = [t];
225
+ for (; l.length; ) {
226
+ const o = l.pop();
227
+ o.localName === e && o.namespaceUri === n && r.push(o), l.push(...M(o).reverse());
228
+ }
229
+ return r;
230
+ }, Y = (t, e = "val") => t ? p(t, e) ?? void 0 : void 0, tt = (t, e) => {
231
+ const n = x(t, e);
232
+ if (!n) return;
233
+ const r = p(n, "val");
234
+ return r === void 0 || r === "true" || r === "1" || r === "on";
235
+ }, kt = (t) => {
236
+ const e = x(t, "u");
237
+ return !!e && p(e, "val") !== "none";
238
+ }, ot = (t) => {
239
+ const e = Y(t, "rgb") ?? Y(t);
240
+ return e && /^(?:[0-9A-Fa-f]{2})?[0-9A-Fa-f]{6}$/.test(e) ? e.slice(-6).toUpperCase() : void 0;
241
+ }, ct = (t) => `FF${t.toUpperCase()}`;
242
+ function Xt(t) {
243
+ const e = y(t.parts[t.main]).root, n = g(y(t.parts[B(t.main)]).root, "Relationship");
244
+ return g(x(e, "sheets"), "sheet").map((r) => {
245
+ var s;
246
+ const l = (s = r.attributes.find((i) => i.localName === "id" && i.namespaceUri === L)) == null ? void 0 : s.value, o = n.find((i) => p(i, "Id") === l && p(i, "Type") === `${L}/worksheet` && p(i, "TargetMode") !== "External");
247
+ return o ? { id: p(r, "sheetId"), name: p(r, "name"), part: D(t.main, p(o, "Target")) } : null;
248
+ }).filter((r) => r !== null);
249
+ }
250
+ function G(t) {
251
+ if (!/^[A-Z]{1,3}[1-9]\d{0,6}$/.test(t)) throw new Error("单元格地址无效");
252
+ const [, e, n] = /^([A-Z]+)(\d+)$/.exec(t), r = [...e].reduce((o, s) => o * 26 + s.charCodeAt(0) - 64, 0), l = Number(n);
253
+ if (r > 16384 || l > 1048576) throw new Error("单元格地址越界");
254
+ return [l, r];
255
+ }
256
+ function Tt(t) {
257
+ return W(t, "t", w).map(H).join("");
258
+ }
259
+ const Se = ["fldChar", "instrText", "del", "ins", "sdt", "pict", "drawing", "object", "br", "tab"];
260
+ function Pe(t) {
261
+ if (!t) return {};
262
+ const e = {};
263
+ tt(t, "b") && (e.bold = !0), tt(t, "i") && (e.italic = !0), kt(t) && (e.underline = !0);
264
+ const n = Y(x(t, "sz"));
265
+ n && Number.isFinite(Number(n)) && (e.size = Number(n));
266
+ const r = ot(x(t, "color"));
267
+ return r && (e.color = r), e;
268
+ }
269
+ function Dt(t) {
270
+ return !Se.some((e) => W(t, e, X).length);
271
+ }
272
+ function $e(t) {
273
+ const e = /* @__PURE__ */ new Map();
274
+ for (const n of W(t, "tbl", X))
275
+ g(n, "tr").forEach((r, l) => {
276
+ g(r, "tc").forEach((o, s) => {
277
+ for (const i of W(o, "p", X)) e.set(i, { row: l, col: s });
278
+ });
279
+ });
280
+ return e;
281
+ }
282
+ function Ce(t) {
283
+ return g(t, "r").map((e, n) => ({
284
+ index: n,
285
+ text: W(e, "t", X).map(H).join(""),
286
+ format: Pe(x(e, "rPr"))
287
+ }));
288
+ }
289
+ function Bt(t) {
290
+ const e = g(t, "r");
291
+ if (!e.length) return { text: Tt(t) };
292
+ const n = e.map((r) => {
293
+ const l = x(r, "rPr"), o = { text: H(x(r, "t")) };
294
+ tt(l, "b") && (o.bold = !0), tt(l, "i") && (o.italic = !0), kt(l) && (o.underline = !0);
295
+ const s = Y(x(l, "sz"));
296
+ s && Number.isFinite(Number(s)) && (o.size = Number(s));
297
+ const i = ot(x(l, "color"));
298
+ return i && (o.color = i), o;
299
+ });
300
+ return { text: n.map((r) => r.text).join(""), richText: n.length > 1 || n.some((r) => r.bold || r.italic || r.underline || r.size || r.color) ? n : void 0 };
301
+ }
302
+ function Wt(t) {
303
+ if (!t) return null;
304
+ const e = y(t).root, n = g(x(e, "fonts"), "font").map((s) => {
305
+ const i = {}, a = Y(x(s, "name"));
306
+ a && (i.name = a);
307
+ const f = Y(x(s, "sz"));
308
+ f && Number.isFinite(Number(f)) && (i.size = Number(f)), tt(s, "b") && (i.bold = !0), tt(s, "i") && (i.italic = !0);
309
+ const c = ot(x(s, "color"));
310
+ return c && (i.color = c), i;
311
+ }), r = g(x(e, "fills"), "fill").map((s) => {
312
+ const i = ot(x(x(s, "patternFill"), "fgColor"));
313
+ return i ? { color: i } : {};
314
+ }), l = g(x(e, "borders"), "border").map((s) => {
315
+ const i = x(s, "left") ?? x(s, "right") ?? x(s, "top") ?? x(s, "bottom");
316
+ if (!i) return {};
317
+ const a = p(i, "style") ?? void 0, f = ot(x(i, "color")), c = {};
318
+ return a && (c.style = a), f && (c.color = f), c;
319
+ }), o = g(x(e, "cellXfs"), "xf").map((s) => ({
320
+ fontId: Number(p(s, "fontId") ?? 0),
321
+ fillId: Number(p(s, "fillId") ?? 0),
322
+ borderId: Number(p(s, "borderId") ?? 0)
323
+ }));
324
+ return { fonts: n, fills: r, borders: l, xfs: o };
325
+ }
326
+ function ft(t, e) {
327
+ if (!t || e === void 0 || !Number.isInteger(e) || e < 0 || e >= t.xfs.length) return;
328
+ const n = t.xfs[e], r = {}, l = t.fonts[n.fontId];
329
+ l && Object.keys(l).length && (r.font = { ...l });
330
+ const o = t.fills[n.fillId];
331
+ o && Object.keys(o).length && (r.fill = { ...o });
332
+ const s = t.borders[n.borderId];
333
+ return s && Object.keys(s).length && (r.border = { ...s }), Object.keys(r).length ? r : void 0;
334
+ }
335
+ function Q(t) {
336
+ if (t.kind === "docx") {
337
+ const c = y(t.parts[t.main]).root, h = x(c, "body") ?? c, d = $e(h);
338
+ return { kind: "docx", paragraphs: W(c, "p", X).map((u, E) => {
339
+ const m = Ce(u), N = d.get(u);
340
+ return {
341
+ index: E,
342
+ // 超链接、智能标记里的 run 不是段落的直接子级,段落文字必须按全部 w:t 拼。
343
+ text: W(u, "t", X).map(H).join(""),
344
+ editable: Dt(u),
345
+ runs: m,
346
+ ...N ? { table: N } : {}
347
+ };
348
+ }) };
349
+ }
350
+ const e = g(y(t.parts[B(t.main)]).root, "Relationship"), n = e.find((c) => p(c, "Type") === `${L}/sharedStrings` && p(c, "TargetMode") !== "External"), r = n && D(t.main, p(n, "Target")), l = r ? t.parts[r] : void 0, o = l ? g(y(l).root, "si").map(Bt) : [], s = e.find((c) => p(c, "Type") === `${L}/styles` && p(c, "TargetMode") !== "External"), i = s && D(t.main, p(s, "Target")), a = Wt(i ? t.parts[i] : void 0);
351
+ let f = 0;
352
+ return { kind: "xlsx", sheets: Xt(t).map(({ id: c, name: h, part: d }) => ({
353
+ id: c,
354
+ name: h,
355
+ cells: W(y(t.parts[d]).root, "c", w).map((u) => {
356
+ if (++f > 1e5) throw new Error("嵌入表格单元格超限");
357
+ const E = p(u, "r");
358
+ G(E);
359
+ const m = p(u, "t"), N = H(x(u, "v")), b = x(u, "f"), S = p(u, "s") !== void 0 ? Number(p(u, "s")) : void 0;
360
+ let $, C;
361
+ if (m === "inlineStr") $ = Tt(u);
362
+ else if (m === "s") {
363
+ const T = o[Number(N)];
364
+ $ = (T == null ? void 0 : T.text) ?? "", C = T == null ? void 0 : T.richText;
365
+ } else m === "b" ? $ = N === "1" : m === "str" || m === "e" ? $ = N : $ = N === "" ? null : Number(N);
366
+ const F = ft(a, S);
367
+ return {
368
+ ref: E,
369
+ value: $,
370
+ ...b ? { formula: H(b) } : {},
371
+ ...S !== void 0 && Number.isFinite(S) ? { styleIndex: S } : {},
372
+ ...F ? { style: F } : {},
373
+ ...C ? { richText: C } : {}
374
+ };
375
+ })
376
+ })) };
377
+ }
378
+ const ut = (t) => typeof t == "string" && t.length <= 32767 && !/[\u0000-\u0008\u000b\u000c\u000e-\u001f\ufffe\uffff]/u.test(t), Ie = (t) => Array.isArray(t) && t.length > 0 && t.length <= 100 && t.every((e) => e && ut(e.text) && (e.bold === void 0 || typeof e.bold == "boolean") && (e.italic === void 0 || typeof e.italic == "boolean") && (e.underline === void 0 || typeof e.underline == "boolean") && (e.size === void 0 || typeof e.size == "number" && Number.isFinite(e.size)) && (e.color === void 0 || typeof e.color == "string" && /^[0-9A-Fa-f]{6}$/.test(e.color))), Re = (t) => {
379
+ if (!t || typeof t != "object") return !1;
380
+ const e = t, n = !e.font || typeof e.font == "object" && (e.font.name === void 0 || typeof e.font.name == "string") && (e.font.size === void 0 || typeof e.font.size == "number") && (e.font.bold === void 0 || typeof e.font.bold == "boolean") && (e.font.italic === void 0 || typeof e.font.italic == "boolean") && (e.font.color === void 0 || typeof e.font.color == "string" && /^[0-9A-Fa-f]{6}$/.test(e.font.color)), r = !e.fill || typeof e.fill == "object" && (e.fill.color === void 0 || typeof e.fill.color == "string" && /^[0-9A-Fa-f]{6}$/.test(e.fill.color)), l = !e.border || typeof e.border == "object" && (e.border.color === void 0 || typeof e.border.color == "string" && /^[0-9A-Fa-f]{6}$/.test(e.border.color)) && (e.border.style === void 0 || typeof e.border.style == "string");
381
+ return !!(n && r && l && (e.font || e.fill || e.border));
382
+ };
383
+ function qt(t) {
384
+ if (!t || typeof t != "object") throw new Error("OLE 编辑数据无效");
385
+ const e = t;
386
+ if (!Array.isArray(e.cells) || !Array.isArray(e.paragraphs) || e.cells.length + e.paragraphs.length > 1e4) throw new Error("OLE 编辑数据超限");
387
+ const n = /* @__PURE__ */ new Set(), r = e.cells.map((o) => {
388
+ if (!o || typeof o.sheet != "string" || !/^\d+$/.test(o.sheet) || typeof o.ref != "string") throw new Error("OLE 单元格无效");
389
+ G(o.ref);
390
+ const s = "value" in o, i = "style" in o, a = "richText" in o;
391
+ if (!s && !i && !a) throw new Error("OLE 单元格缺少变更");
392
+ if (s && !(o.value === null || typeof o.value == "boolean" || typeof o.value == "number" && Number.isFinite(o.value) || ut(o.value))) throw new Error("OLE 单元格值无效");
393
+ if (i && o.style !== null && !Re(o.style)) throw new Error("OLE 单元格样式无效");
394
+ if (a && o.richText !== null && !Ie(o.richText)) throw new Error("OLE 富文本无效");
395
+ const f = o.sheet + ":" + o.ref;
396
+ if (n.has(f)) throw new Error("OLE 单元格重复");
397
+ return n.add(f), {
398
+ sheet: o.sheet,
399
+ ref: o.ref,
400
+ ...s ? { value: o.value } : {},
401
+ ...i ? { style: o.style } : {},
402
+ ...a ? { richText: o.richText } : {}
403
+ };
404
+ }).sort((o, s) => o.sheet.localeCompare(s.sheet) || G(o.ref)[0] - G(s.ref)[0] || G(o.ref)[1] - G(s.ref)[1]), l = e.paragraphs.map((o) => {
405
+ if (!o || !Number.isInteger(o.index) || o.index < 0) throw new Error("OLE 段落无效");
406
+ const s = typeof o.text == "string", i = Array.isArray(o.runs);
407
+ if (!s && !i) throw new Error("OLE 段落缺少变更");
408
+ if (s && !ut(o.text)) throw new Error("OLE 段落无效");
409
+ if (i) {
410
+ if (!o.runs.length || o.runs.length > 100) throw new Error("OLE 段落 run 超限");
411
+ const f = /* @__PURE__ */ new Set();
412
+ for (const c of o.runs) {
413
+ if (!c || !Number.isInteger(c.index) || c.index < 0 || !ut(c.text)) throw new Error("OLE 段落 run 无效");
414
+ if (f.has(c.index)) throw new Error("OLE 段落 run 重复");
415
+ f.add(c.index);
416
+ }
417
+ }
418
+ const a = "p" + o.index;
419
+ if (n.has(a)) throw new Error("OLE 段落重复");
420
+ return n.add(a), {
421
+ index: o.index,
422
+ ...s ? { text: o.text } : {},
423
+ ...i ? { runs: [...o.runs].sort((f, c) => f.index - c.index) } : {}
424
+ };
425
+ }).sort((o, s) => o.index - s.index);
426
+ return { cells: r, paragraphs: l };
427
+ }
428
+ function v(t, e, n) {
429
+ const r = A(e, { attributes: [["xmlns", n]] });
430
+ return R(t, r), r;
431
+ }
432
+ function pt(t, e) {
433
+ for (const n of [...t.children]) q(t, n);
434
+ R(t, yt(e)), P(t, "xml:space", "preserve");
435
+ }
436
+ function je(t, e) {
437
+ if (!Dt(t)) throw new Error("段落含域、图形或修订,不能直接替换文字");
438
+ if (e.runs) {
439
+ const r = g(t, "r");
440
+ for (const l of e.runs) {
441
+ const o = r[l.index];
442
+ if (!o) throw new Error("段落 run 不存在");
443
+ let s = x(o, "t");
444
+ s || (s = v(o, "t", X)), pt(s, l.text);
445
+ }
446
+ return;
447
+ }
448
+ const n = W(t, "t", X);
449
+ n.length || n.push(v(v(t, "r", X), "t", X)), n.forEach((r, l) => pt(r, l ? "" : e.text ?? ""));
450
+ }
451
+ function zt(t, e) {
452
+ return ((t == null ? void 0 : t.name) ?? "") === ((e == null ? void 0 : e.name) ?? "") && ((t == null ? void 0 : t.size) ?? 0) === ((e == null ? void 0 : e.size) ?? 0) && !!(t != null && t.bold) == !!(e != null && e.bold) && !!(t != null && t.italic) == !!(e != null && e.italic) && ((t == null ? void 0 : t.color) ?? "") === ((e == null ? void 0 : e.color) ?? "");
453
+ }
454
+ function Ut(t, e) {
455
+ return ((t == null ? void 0 : t.color) ?? "") === ((e == null ? void 0 : e.color) ?? "");
456
+ }
457
+ function Lt(t, e) {
458
+ return ((t == null ? void 0 : t.color) ?? "") === ((e == null ? void 0 : e.color) ?? "") && ((t == null ? void 0 : t.style) ?? "") === ((e == null ? void 0 : e.style) ?? "");
459
+ }
460
+ function Gt(t, e) {
461
+ const n = new Set(g(t, "Relationship").map((l) => p(l, "Id")));
462
+ let r = e;
463
+ for (let l = 2; n.has(r); l++) r = `${e}${l}`;
464
+ return r;
465
+ }
466
+ function ze(t, e) {
467
+ const n = B(t.main), r = y(e[n] ?? t.parts[n]), l = y(e["[Content_Types].xml"] ?? t.parts["[Content_Types].xml"]);
468
+ let o = g(r.root, "Relationship").find((f) => p(f, "Type") === `${L}/styles` && p(f, "TargetMode") !== "External"), s = o ? D(t.main, p(o, "Target")) : D(t.main, "styles.xml");
469
+ o || (o = A("Relationship", { attributes: [["xmlns", "http://schemas.openxmlformats.org/package/2006/relationships"], ["Id", Gt(r.root, "styles")], ["Type", `${L}/styles`], ["Target", "styles.xml"]] }), R(r.root, o), e[n] = j(r)), g(l.root, "Override").some((f) => p(f, "PartName") === "/" + s) || (R(l.root, A("Override", { attributes: [["xmlns", "http://schemas.openxmlformats.org/package/2006/content-types"], ["PartName", "/" + s], ["ContentType", "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"]] })), e["[Content_Types].xml"] = j(l));
470
+ const i = e[s] ?? t.parts[s];
471
+ if (i) return { part: s, tree: y(i) };
472
+ const a = y(new TextEncoder().encode(
473
+ `<styleSheet xmlns="${w}"><fonts count="1"><font><sz val="11"/><name val="Calibri"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border/></borders><cellStyleXfs count="1"><xf/></cellStyleXfs><cellXfs count="1"><xf/></cellXfs></styleSheet>`
474
+ ));
475
+ return { part: s, tree: a };
476
+ }
477
+ function Ue(t, e, n) {
478
+ var N;
479
+ const { part: r, tree: l } = ze(t, e), o = l.root, s = x(o, "fonts") ?? v(o, "fonts", w), i = x(o, "fills") ?? v(o, "fills", w), a = x(o, "borders") ?? v(o, "borders", w), f = x(o, "cellXfs") ?? v(o, "cellXfs", w), c = Wt(j(l));
480
+ let h = c.fonts.findIndex((b) => zt(b, n.font));
481
+ if (h < 0 && n.font) {
482
+ h = g(s, "font").length;
483
+ const b = v(s, "font", w);
484
+ if (n.font.size !== void 0) {
485
+ const S = v(b, "sz", w);
486
+ P(S, "val", String(n.font.size));
487
+ }
488
+ if (n.font.name) {
489
+ const S = v(b, "name", w);
490
+ P(S, "val", n.font.name);
491
+ }
492
+ if (n.font.bold && v(b, "b", w), n.font.italic && v(b, "i", w), n.font.color) {
493
+ const S = v(b, "color", w);
494
+ P(S, "rgb", ct(n.font.color));
495
+ }
496
+ P(s, "count", String(h + 1));
497
+ } else h < 0 && (h = 0);
498
+ let d = c.fills.findIndex((b) => Ut(b, n.fill));
499
+ if (d < 0 && ((N = n.fill) != null && N.color)) {
500
+ d = g(i, "fill").length;
501
+ const b = v(i, "fill", w), S = v(b, "patternFill", w);
502
+ P(S, "patternType", "solid");
503
+ const $ = v(S, "fgColor", w);
504
+ P($, "rgb", ct(n.fill.color)), P(i, "count", String(d + 1));
505
+ } else d < 0 && (d = 0);
506
+ let u = c.borders.findIndex((b) => Lt(b, n.border));
507
+ if (u < 0 && n.border) {
508
+ u = g(a, "border").length;
509
+ const b = v(a, "border", w);
510
+ for (const S of ["left", "right", "top", "bottom"]) {
511
+ const $ = v(b, S, w);
512
+ if (n.border.style && P($, "style", n.border.style), n.border.color) {
513
+ const C = v($, "color", w);
514
+ P(C, "rgb", ct(n.border.color));
515
+ }
516
+ }
517
+ P(a, "count", String(u + 1));
518
+ } else u < 0 && (u = 0);
519
+ const E = c.xfs.findIndex((b, S) => {
520
+ var $, C, F;
521
+ return b.fontId !== h || b.fillId !== d || b.borderId !== u ? !1 : zt(($ = ft(c, S)) == null ? void 0 : $.font, n.font) && Ut((C = ft(c, S)) == null ? void 0 : C.fill, n.fill) && Lt((F = ft(c, S)) == null ? void 0 : F.border, n.border);
522
+ });
523
+ if (E >= 0)
524
+ return e[r] = j(l), E;
525
+ const m = A("xf", { attributes: [
526
+ ["xmlns", w],
527
+ ["fontId", String(h)],
528
+ ["fillId", String(d)],
529
+ ["borderId", String(u)],
530
+ ["applyFont", n.font ? "1" : "0"],
531
+ ["applyFill", n.fill ? "1" : "0"],
532
+ ["applyBorder", n.border ? "1" : "0"]
533
+ ] });
534
+ return R(f, m), P(f, "count", String(g(f, "xf").length)), e[r] = j(l), g(f, "xf").length - 1;
535
+ }
536
+ function Le(t, e) {
537
+ const n = B(t.main), r = y(e[n] ?? t.parts[n]), l = y(e["[Content_Types].xml"] ?? t.parts["[Content_Types].xml"]);
538
+ let o = g(r.root, "Relationship").find((a) => p(a, "Type") === `${L}/sharedStrings` && p(a, "TargetMode") !== "External"), s = o ? D(t.main, p(o, "Target")) : D(t.main, "sharedStrings.xml");
539
+ o || (o = A("Relationship", { attributes: [["xmlns", "http://schemas.openxmlformats.org/package/2006/relationships"], ["Id", Gt(r.root, "strings")], ["Type", `${L}/sharedStrings`], ["Target", "sharedStrings.xml"]] }), R(r.root, o), e[n] = j(r)), g(l.root, "Override").some((a) => p(a, "PartName") === "/" + s) || (R(l.root, A("Override", { attributes: [["xmlns", "http://schemas.openxmlformats.org/package/2006/content-types"], ["PartName", "/" + s], ["ContentType", "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"]] })), e["[Content_Types].xml"] = j(l));
540
+ const i = e[s] ?? t.parts[s];
541
+ return i ? { part: s, tree: y(i) } : { part: s, tree: y(new TextEncoder().encode(`<sst xmlns="${w}" count="0" uniqueCount="0"/>`)) };
542
+ }
543
+ function Fe(t, e, n) {
544
+ const r = H(x(n, "v")), l = p(n, "t");
545
+ if (l === "inlineStr") return Tt(x(n, "is") ?? n);
546
+ if (l !== "s") return r;
547
+ const o = g(y(e[B(t.main)] ?? t.parts[B(t.main)]).root, "Relationship").find((a) => p(a, "Type") === `${L}/sharedStrings` && p(a, "TargetMode") !== "External");
548
+ if (!o) throw new Error("共享字符串单元格缺少 sharedStrings 部件");
549
+ const s = D(t.main, p(o, "Target")), i = g(y(e[s] ?? t.parts[s]).root, "si")[Number(r)];
550
+ if (!i) throw new Error(`共享字符串索引 ${r} 不存在`);
551
+ return Bt(i).text;
552
+ }
553
+ function Ae(t, e, n) {
554
+ const { part: r, tree: l } = Le(t, e), o = v(l.root, "si", w);
555
+ for (const i of n) {
556
+ const a = v(o, "r", w);
557
+ if (i.bold || i.italic || i.underline || i.size !== void 0 || i.color) {
558
+ const f = v(a, "rPr", w);
559
+ if (i.bold && v(f, "b", w), i.italic && v(f, "i", w), i.underline && v(f, "u", w), i.size !== void 0) {
560
+ const c = v(f, "sz", w);
561
+ P(c, "val", String(i.size));
562
+ }
563
+ if (i.color) {
564
+ const c = v(f, "color", w);
565
+ P(c, "rgb", ct(i.color));
566
+ }
567
+ }
568
+ pt(v(a, "t", w), i.text);
569
+ }
570
+ const s = g(l.root, "si").length;
571
+ return P(l.root, "count", String(s)), P(l.root, "uniqueCount", String(s)), e[r] = j(l), s - 1;
572
+ }
573
+ function Vt(t, e) {
574
+ const n = /* @__PURE__ */ Object.create(null);
575
+ if (t.kind === "docx") {
576
+ if (e.cells.length) throw new Error("文档不支持单元格编辑");
577
+ const s = y(t.parts[t.main]), i = W(s.root, "p", X);
578
+ for (const a of e.paragraphs) {
579
+ const f = i[a.index];
580
+ if (!f) throw new Error("段落不存在");
581
+ je(f, a);
582
+ }
583
+ return e.paragraphs.length && (n[t.main] = j(s)), n;
584
+ }
585
+ if (e.paragraphs.length) throw new Error("表格不支持文档段落编辑");
586
+ const r = Xt(t), l = /* @__PURE__ */ new Map();
587
+ let o = !1;
588
+ for (const s of e.cells) {
589
+ const i = r.find((m) => m.id === s.sheet);
590
+ if (!i) throw new Error("工作表不存在");
591
+ const a = l.get(i.part) ?? y(t.parts[i.part]);
592
+ if (l.set(i.part, a), x(a.root, "sheetProtection")) throw new Error("工作表受保护");
593
+ const f = x(a.root, "sheetData");
594
+ if (!f) throw new Error("工作表缺少 sheetData");
595
+ const [c, h] = G(s.ref);
596
+ let d = g(f, "row").find((m) => Number(p(m, "r")) === c);
597
+ d || (d = A("row", { attributes: [["xmlns", w], ["r", String(c)]] }), R(f, d, g(f, "row").find((m) => Number(p(m, "r")) > c) ?? null));
598
+ let u = g(d, "c").find((m) => p(m, "r") === s.ref);
599
+ if (u && x(u, "f") && ["array", "dataTable", "shared"].includes(p(x(u, "f"), "t") ?? "")) throw new Error("数组或共享公式不能单独替换");
600
+ if (u || (u = A("c", { attributes: [["xmlns", w], ["r", s.ref]] }), R(d, u, g(d, "c").find((m) => G(p(m, "r"))[1] > h) ?? null)), "style" in s && (s.style === null ? rt(u, "s") : P(u, "s", String(Ue(t, n, s.style)))), "richText" in s) {
601
+ const m = s.richText === null ? typeof s.value == "string" ? s.value : Fe(t, n, u) : "";
602
+ for (const N of M(u)) ["f", "v", "is"].includes(N.localName) && q(u, N);
603
+ if (rt(u, "t"), s.richText === null)
604
+ P(u, "t", "inlineStr"), pt(v(v(u, "is", w), "t", w), m);
605
+ else {
606
+ const N = Ae(t, n, s.richText);
607
+ P(u, "t", "s"), R(v(u, "v", w), yt(String(N)));
608
+ }
609
+ o = !0;
610
+ } else if ("value" in s) {
611
+ for (const m of M(u)) ["f", "v", "is"].includes(m.localName) && q(u, m);
612
+ if (rt(u, "t"), s.value !== null && s.value !== void 0) {
613
+ P(u, "t", typeof s.value == "string" ? "inlineStr" : typeof s.value == "boolean" ? "b" : "n");
614
+ const m = typeof s.value == "string" ? v(v(u, "is", w), "t", w) : v(u, "v", w);
615
+ R(m, yt(typeof s.value == "boolean" ? s.value ? "1" : "0" : String(s.value))), typeof s.value == "string" && P(m, "xml:space", "preserve");
616
+ }
617
+ o = !0;
618
+ }
619
+ const E = x(a.root, "dimension");
620
+ E && q(a.root, E), rt(d, "spans");
621
+ }
622
+ for (const [s, i] of l) n[s] = j(i);
623
+ if (o) {
624
+ const s = y(n[t.main] ?? t.parts[t.main]);
625
+ let i = x(s.root, "calcPr");
626
+ if (!i) {
627
+ i = A("calcPr", { attributes: [["xmlns", w]] });
628
+ const c = ["oleSize", "customWorkbookViews", "pivotCaches", "smartTagPr", "smartTagTypes", "webPublishing", "fileRecoveryPr", "webPublishObjects", "extLst"];
629
+ R(s.root, i, M(s.root).find((h) => c.includes(h.localName)) ?? null);
630
+ }
631
+ P(i, "fullCalcOnLoad", "1"), P(i, "forceFullCalc", "1"), P(i, "calcMode", "auto"), n[t.main] = j(s);
632
+ const a = y(n[B(t.main)] ?? t.parts[B(t.main)]), f = y(n["[Content_Types].xml"] ?? t.parts["[Content_Types].xml"]);
633
+ for (const c of g(a.root, "Relationship")) if (p(c, "Type") === `${L}/calcChain`) {
634
+ const h = D(t.main, p(c, "Target"));
635
+ n[h] = null, q(a.root, c);
636
+ for (const d of g(f.root, "Override")) p(d, "PartName") === "/" + h && q(f.root, d);
637
+ }
638
+ n[B(t.main)] = j(a), n["[Content_Types].xml"] = j(f);
639
+ }
640
+ return n;
641
+ }
642
+ const Ot = "http://schemas.openxmlformats.org/presentationml/2006/ole", mt = (t, e) => {
643
+ var n, r, l;
644
+ return (l = (r = (n = t.elements[e]) == null ? void 0 : n.ovr.extensions) == null ? void 0 : r.ole) == null ? void 0 : l.value;
645
+ };
646
+ function V(t, e) {
647
+ const n = Et(t, e, Ot);
648
+ if (!n) throw new Error("对象不是 OLE 嵌入内容");
649
+ const r = k(t, n.part);
650
+ if (!r) throw new Error("OLE 原始字节已丢失");
651
+ const l = Ne(r);
652
+ if (!l) throw new Error("此 OLE 类型不支持内容编辑");
653
+ return { source: n, bytes: r, pkg: l };
654
+ }
655
+ function dt(t, e) {
656
+ const n = V(t, e), r = mt(t, e), l = r ? qt(JSON.parse(r)) : { cells: [], paragraphs: [] }, o = Vt(n.pkg, l), s = { ...n.pkg.parts };
657
+ for (const [i, a] of Object.entries(o))
658
+ a ? s[i] = a : delete s[i];
659
+ return { ...n, edits: l, changes: o, content: Q({ ...n.pkg, parts: s }) };
660
+ }
661
+ const Me = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
662
+ function Ht(t) {
663
+ const r = '<rect width="800" height="500" fill="#fff"/>';
664
+ let l = "";
665
+ const o = (s, i, a, f = 20) => `<text x="${s}" y="${i}" font-family="Arial,sans-serif" font-size="${f}" fill="#172033">${Me(a)}</text>`;
666
+ if (t.kind === "docx") {
667
+ let s = 0;
668
+ for (const i of t.paragraphs) {
669
+ const a = [...i.text];
670
+ for (let f = 0; f < Math.max(a.length, 1) && s < 15; f += 38) l += o(24, 36 + s++ * 30, a.slice(f, f + 38).join(""));
671
+ if (s >= 15) break;
672
+ }
673
+ } else {
674
+ const s = t.sheets[0];
675
+ l += o(20, 30, (s == null ? void 0 : s.name) ?? "");
676
+ for (let i = 0; i < 12; i++) l += `<path d="M20 ${50 + i * 36}H780" stroke="#cbd5e1"/>`;
677
+ for (let i = 0; i < 6; i++) l += `<path d="M${20 + i * 152} 50V446" stroke="#cbd5e1"/>`;
678
+ for (const i of (s == null ? void 0 : s.cells) ?? []) {
679
+ const [a, f] = G(i.ref);
680
+ if (a > 11 || f > 5) continue;
681
+ const c = i.formula !== void 0 ? "=" + i.formula : i.value === null ? "" : String(i.value);
682
+ l += o(26 + (f - 1) * 152, 75 + (a - 1) * 36, [...c].slice(0, 11).join(""), 17);
683
+ }
684
+ }
685
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="800" height="500" viewBox="0 0 800 500">${r}${l}</svg>`;
686
+ }
687
+ const Ft = "http://schemas.openxmlformats.org/presentationml/2006/main", _e = "http://schemas.openxmlformats.org/drawingml/2006/main";
688
+ function At(t, e, n, r, l = !1) {
689
+ const o = new Set([...n].filter((f) => f.startsWith("ppt/media/web-ppt-ole-") || f.startsWith("ppt/embeddings/web-ppt-ole-")));
690
+ for (const f of o)
691
+ r[f] = null, n.delete(f);
692
+ const s = "[Content_Types].xml";
693
+ let i;
694
+ const a = () => {
695
+ if (!i) {
696
+ i = y(r[s] ?? k(t, s));
697
+ for (const f of g(i.root, "Override")) o.has((p(f, "PartName") ?? "").slice(1)) && q(i.root, f);
698
+ }
699
+ return i;
700
+ };
701
+ for (const f of Object.values(t.elements)) {
702
+ const c = Et(t, f.id, Ot);
703
+ if (!c || !mt(t, f.id)) continue;
704
+ const d = dt(t, f.id), u = Ht(d.content), E = new TextEncoder().encode(u), m = It(new TextEncoder().encode(f.id)).slice(0, 16), N = c.part.split(".").pop();
705
+ let b = `ppt/embeddings/web-ppt-ole-${m}.${N}`, S = 1;
706
+ for (; k(t, b) && !o.has(b); ) b = `ppt/embeddings/web-ppt-ole-${m}-${S++}.${N}`;
707
+ r[b] = d.pkg.wrap(d.changes), n.add(b);
708
+ let $ = f.parent;
709
+ for (; t.elements[$]; ) $ = t.elements[$].parent;
710
+ const C = l ? `ppt/slides/slide${t.slideOrder.indexOf($) + 1}.xml` : c.hostPart, F = k(t, C), T = B(C), z = k(t, T);
711
+ l || (F && (e[C] ?? (e[C] = F)), z && (e[T] ?? (e[T] = z)));
712
+ const st = y(r[C] ?? F), _ = y(r[T] ?? z);
713
+ for (const O of g(_.root, "Relationship"))
714
+ p(O, "TargetMode") !== "External" && o.has(D(C, p(O, "Target") ?? "")) && q(_.root, O);
715
+ const J = It(E).slice(0, 16);
716
+ let U = `ppt/media/web-ppt-ole-${J}.svg`, it = 1;
717
+ for (; k(t, U) && !o.has(U); ) U = `ppt/media/web-ppt-ole-${J}-${it++}.svg`;
718
+ let I = `webPptOle${J}`, Z = 1;
719
+ for (; g(_.root, "Relationship").some((O) => p(O, "Id") === I); ) I = `webPptOle${J}_${Z++}`;
720
+ R(_.root, A("Relationship", { attributes: [["Id", I], ["Type", `${L}/image`], ["Target", "../media/" + U.split("/").pop()]] }));
721
+ const ht = [st.root], gt = [];
722
+ let xt = 1;
723
+ for (; ht.length; ) {
724
+ const O = ht.pop();
725
+ ht.push(...M(O)), O.localName === "cNvPr" && (xt = Math.max(xt, Number(p(O, "id")) || 1)), O.namespaceUri === Ft && O.localName === "oleObj" && p(O, "webPptOleEdit") === f.id && gt.push(O);
726
+ }
727
+ if (!gt.length) throw new Error("保存找不到 OLE 原生对象");
728
+ const Nt = y(k(t, s)), St = g(Nt.root, "Override").find((O) => p(O, "PartName") === "/" + c.part) ?? g(Nt.root, "Default").find((O) => p(O, "Extension") === N);
729
+ if (!St) throw new Error("OLE 原生类型声明不存在");
730
+ R(a().root, A("Override", { attributes: [["PartName", "/" + b], ["ContentType", p(St, "ContentType")]] }));
731
+ for (const O of gt) {
732
+ const et = O.attributes.find((K) => K.namespaceUri === L && K.localName === "id"), $t = g(_.root, "Relationship").find((K) => p(K, "Id") === (et == null ? void 0 : et.value));
733
+ if (!$t || !et) throw new Error("OLE 原生关系不存在");
734
+ let lt = `webPptOleData${m}`, Kt = 1;
735
+ for (; g(_.root, "Relationship").some((K) => p(K, "Id") === lt); ) lt = `webPptOleData${m}_${Kt++}`;
736
+ R(_.root, A("Relationship", { attributes: [["Id", lt], ["Type", p($t, "Type")], ["Target", "../embeddings/" + b.split("/").pop()]] })), P(O, et.name, lt), rt(O, "webPptOleEdit");
737
+ const Ct = x(O, "pic");
738
+ Ct && q(O, Ct);
739
+ const Qt = `<p:pic xmlns:p="${Ft}" xmlns:a="${_e}" xmlns:r="${L}"><p:nvPicPr><p:cNvPr id="${++xt}" name="OLE 内容预览"/><p:cNvPicPr/><p:nvPr/></p:nvPicPr><p:blipFill><a:blip r:embed="${I}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill><p:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${Math.round(f.src.w * 9525)}" cy="${Math.round(f.src.h * 9525)}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr></p:pic>`, Yt = y(Qt).root;
740
+ R(O, te(Yt));
741
+ }
742
+ r[C] = j(st), r[T] = j(_), r[U] = E, n.add(U);
743
+ const Pt = a();
744
+ g(Pt.root, "Override").some((O) => p(O, "PartName") === "/" + U) || R(Pt.root, A("Override", { attributes: [["PartName", "/" + U], ["ContentType", "image/svg+xml"]] }));
745
+ }
746
+ o.size && a(), i && (r[s] = j(i));
747
+ }
748
+ function Jt(t, e) {
749
+ return dt(t, e).content;
750
+ }
751
+ function Ve(t) {
752
+ return Object.values(t.elements).filter((e) => Et(t, e.id, Ot)).flatMap((e) => {
753
+ try {
754
+ const { pkg: n } = V(t, e.id);
755
+ return [{ id: e.id, name: e.src.name ?? "OLE", kind: n.kind }];
756
+ } catch {
757
+ return [];
758
+ }
759
+ });
760
+ }
761
+ function Zt(t, e, n) {
762
+ const r = qt(n);
763
+ return Vt(V(t, e).pkg, r), r;
764
+ }
765
+ function ke(t, e, n) {
766
+ if (t.meta.readonly) throw new Error("文稿只读");
767
+ const r = mt(t, e.id), l = e.payload === null ? void 0 : Zt(t, e.id, e.payload), o = l && (l.cells.length || l.paragraphs.length) ? JSON.stringify(l) : void 0, s = ["elements", e.id, "ovr", "extensions", "ole", "value"], i = (a) => a === void 0 ? { op: "del", path: s, origin: n } : { op: "set", path: s, origin: n, value: a };
768
+ return r === o ? { forward: [], inverse: [] } : { forward: [i(o)], inverse: [i(r)] };
769
+ }
770
+ ue("ole", {
771
+ command: ke,
772
+ validatePatch(t, e) {
773
+ if (e.path[0] !== "elements" || e.path.length !== 6 || e.path[5] !== "value") throw new Error("OLE 补丁路径无效");
774
+ if (e.op === "set") {
775
+ if (typeof e.value != "string") throw new Error("OLE 补丁值无效");
776
+ Zt(t, e.path[1], JSON.parse(e.value));
777
+ }
778
+ },
779
+ project(t, e, n) {
780
+ return mt(t, e) ? { ...n, kind: "image", src: "data:image/svg+xml," + encodeURIComponent(Ht(Jt(t, e))), crop: null } : n;
781
+ },
782
+ materialize(t, e, n, r) {
783
+ var o, s;
784
+ if (!((s = (o = e.ovr.extensions) == null ? void 0 : o.ole) != null && s.value)) return;
785
+ const l = [r.locateElementHost(t, e).host];
786
+ for (; l.length; ) {
787
+ const i = l.pop();
788
+ i.localName === "oleObj" && r.setXmlAttribute(i, "webPptOleEdit", e.id), l.push(...r.xmlElementChildren(i));
789
+ }
790
+ },
791
+ materializePackage: At,
792
+ generateParts(t, e) {
793
+ const n = { ...e };
794
+ At(t, {}, /* @__PURE__ */ new Set(), n, !0);
795
+ for (const [r, l] of Object.entries(n))
796
+ l ? e[r] = l : delete e[r];
797
+ }
798
+ });
799
+ function He(t) {
800
+ const e = (r, l) => {
801
+ const { edits: o } = dt(t.doc, r);
802
+ l(o), t.exec({ type: "Extension", namespace: "ole", id: r, payload: o });
803
+ }, n = (r, l, o, s) => {
804
+ const i = r.cells.find((a) => a.sheet === l && a.ref === o);
805
+ r.cells = r.cells.filter((a) => a.sheet !== l || a.ref !== o), r.cells.push({ ...i, ...s, sheet: l, ref: o });
806
+ };
807
+ return {
808
+ query: (r) => Jt(t.doc, r),
809
+ setCell(r, l, o, s) {
810
+ e(r, (i) => {
811
+ var d;
812
+ const a = Q(V(t.doc, r).pkg);
813
+ if (a.kind !== "xlsx") throw new Error("对象不是工作簿");
814
+ const f = (d = a.sheets.find((u) => u.id === l)) == null ? void 0 : d.cells.find((u) => u.ref === o), c = i.cells.find((u) => u.sheet === l && u.ref === o);
815
+ i.cells = i.cells.filter((u) => u.sheet !== l || u.ref !== o), ((f == null ? void 0 : f.formula) !== void 0 || ((f == null ? void 0 : f.value) ?? null) !== s || (c == null ? void 0 : c.style) !== void 0 || (c == null ? void 0 : c.richText) !== void 0) && i.cells.push({
816
+ sheet: l,
817
+ ref: o,
818
+ value: s,
819
+ ...(c == null ? void 0 : c.style) !== void 0 ? { style: c.style } : {},
820
+ ...(c == null ? void 0 : c.richText) !== void 0 ? { richText: c.richText } : {}
821
+ });
822
+ });
823
+ },
824
+ setCellStyle(r, l, o, s) {
825
+ e(r, (i) => {
826
+ if (Q(V(t.doc, r).pkg).kind !== "xlsx") throw new Error("对象不是工作簿");
827
+ n(i, l, o, { sheet: l, ref: o, style: s });
828
+ });
829
+ },
830
+ setCellRichText(r, l, o, s) {
831
+ e(r, (i) => {
832
+ if (Q(V(t.doc, r).pkg).kind !== "xlsx") throw new Error("对象不是工作簿");
833
+ n(i, l, o, { sheet: l, ref: o, richText: s, ...s ? { value: s.map((a) => a.text).join("") } : {} });
834
+ });
835
+ },
836
+ setParagraph(r, l, o) {
837
+ e(r, (s) => {
838
+ var a;
839
+ const i = Q(V(t.doc, r).pkg);
840
+ if (i.kind !== "docx") throw new Error("对象不是文档");
841
+ s.paragraphs = s.paragraphs.filter((f) => f.index !== l), ((a = i.paragraphs[l]) == null ? void 0 : a.text) !== o && s.paragraphs.push({ index: l, text: o });
842
+ });
843
+ },
844
+ setRun(r, l, o, s) {
845
+ e(r, (i) => {
846
+ var d;
847
+ const a = Q(V(t.doc, r).pkg);
848
+ if (a.kind !== "docx") throw new Error("对象不是文档");
849
+ const f = (d = a.paragraphs[l]) == null ? void 0 : d.runs[o];
850
+ let c = i.paragraphs.find((u) => u.index === l);
851
+ i.paragraphs = i.paragraphs.filter((u) => u.index !== l), c || (c = { index: l, runs: [] });
852
+ const h = [...c.runs ?? []].filter((u) => u.index !== o);
853
+ (f == null ? void 0 : f.text) !== s && h.push({ index: o, text: s }), (h.length || c.text !== void 0) && i.paragraphs.push({ ...c, runs: h.length ? h : void 0 });
854
+ });
855
+ },
856
+ exportContent(r) {
857
+ const l = dt(t.doc, r);
858
+ return l.pkg.wrap(l.changes);
859
+ },
860
+ reset(r) {
861
+ t.exec({ type: "Extension", namespace: "ole", id: r, payload: null });
862
+ }
863
+ };
864
+ }
865
+ export {
866
+ G as cellPosition,
867
+ He as createOleEditor,
868
+ Ve as listEditableOle,
869
+ Jt as queryOleContent
870
+ };