@web-ppt/edit-core 0.5.0-beta.2 → 0.5.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +171 -0
- package/README.md +164 -21
- package/dist/alt-text.d.ts +5 -0
- package/dist/appearance/index.d.ts +12 -0
- package/dist/appearance/materialize.d.ts +4 -0
- package/dist/appearance/types.d.ts +26 -0
- package/dist/appearance/values.d.ts +9 -0
- package/dist/appearance.js +301 -0
- package/dist/cfb/index.d.ts +5 -0
- package/dist/cfb/read.d.ts +16 -0
- package/dist/cfb/write.d.ts +3 -0
- package/dist/cfb.js +208 -0
- package/dist/change-classification.d.ts +3 -3
- package/dist/chart/category-binding.d.ts +4 -0
- package/dist/chart/category-commands.d.ts +23 -0
- package/dist/chart/category-levels.d.ts +14 -0
- package/dist/chart/category-matrix.d.ts +2 -0
- package/dist/chart/category-value.d.ts +2 -0
- package/dist/chart/category-workbook.d.ts +13 -0
- package/dist/chart/commands.d.ts +28 -0
- package/dist/chart/context.d.ts +12 -0
- package/dist/chart/dataset-merge.d.ts +5 -0
- package/dist/chart/formula.d.ts +13 -0
- package/dist/chart/identity-frames.d.ts +4 -0
- package/dist/chart/identity-scopes.d.ts +6 -0
- package/dist/chart/identity.d.ts +24 -0
- package/dist/chart/index.d.ts +8 -0
- package/dist/chart/limits.d.ts +6 -0
- package/dist/chart/locator.d.ts +4 -0
- package/dist/chart/materialize.d.ts +7 -0
- package/dist/chart/ordering.d.ts +9 -0
- package/dist/chart/part-graph.d.ts +5 -0
- package/dist/chart/patch-validation.d.ts +3 -0
- package/dist/chart/plot-kinds.d.ts +2 -0
- package/dist/chart/projection.d.ts +8 -0
- package/dist/chart/save.d.ts +4 -0
- package/dist/chart/shared-added-plan.d.ts +19 -0
- package/dist/chart/shared-added-records.d.ts +8 -0
- package/dist/chart/shared-address.d.ts +5 -0
- package/dist/chart/shared-allocate.d.ts +7 -0
- package/dist/chart/shared-cache-codec.d.ts +5 -0
- package/dist/chart/shared-cache-identities.d.ts +3 -0
- package/dist/chart/shared-cache-migration.d.ts +7 -0
- package/dist/chart/shared-cache-save.d.ts +3 -0
- package/dist/chart/shared-cache-scopes.d.ts +13 -0
- package/dist/chart/shared-cache.d.ts +11 -0
- package/dist/chart/shared-category.d.ts +4 -0
- package/dist/chart/shared-cell.d.ts +9 -0
- package/dist/chart/shared-family.d.ts +26 -0
- package/dist/chart/shared-fields.d.ts +18 -0
- package/dist/chart/shared-graph.d.ts +19 -0
- package/dist/chart/shared-growth-space.d.ts +5 -0
- package/dist/chart/shared-inserted-cells.d.ts +14 -0
- package/dist/chart/shared-inserted-command.d.ts +7 -0
- package/dist/chart/shared-inserted-layout.d.ts +16 -0
- package/dist/chart/shared-inserted-project.d.ts +14 -0
- package/dist/chart/shared-inserted-records.d.ts +16 -0
- package/dist/chart/shared-inserted-save.d.ts +6 -0
- package/dist/chart/shared-joint-command.d.ts +9 -0
- package/dist/chart/shared-joint-records.d.ts +9 -0
- package/dist/chart/shared-record-axis.d.ts +25 -0
- package/dist/chart/shared-record-remove.d.ts +13 -0
- package/dist/chart/shared-record-stage.d.ts +2 -0
- package/dist/chart/shared-records.d.ts +2 -0
- package/dist/chart/shared-rows.d.ts +17 -0
- package/dist/chart/shared-runtime.d.ts +19 -0
- package/dist/chart/shared-save-plan.d.ts +4 -0
- package/dist/chart/shared-save.d.ts +3 -0
- package/dist/chart/shared-series.d.ts +6 -0
- package/dist/chart/shared-source-cache.d.ts +4 -0
- package/dist/chart/shared-topology.d.ts +9 -0
- package/dist/chart/shared-unresolved.d.ts +3 -0
- package/dist/chart/shared-validation.d.ts +6 -0
- package/dist/chart/shared-workbook-source.d.ts +6 -0
- package/dist/chart/shared-xy-command.d.ts +7 -0
- package/dist/chart/shared-xy-family.d.ts +16 -0
- package/dist/chart/shared-xy-project.d.ts +6 -0
- package/dist/chart/shared-xy-records.d.ts +23 -0
- package/dist/chart/shared-xy-save.d.ts +5 -0
- package/dist/chart/shared-xy-source.d.ts +39 -0
- package/dist/chart/shared.d.ts +13 -0
- package/dist/chart/source.d.ts +11 -0
- package/dist/chart/types.d.ts +86 -0
- package/dist/chart/validation.d.ts +24 -0
- package/dist/chart/workbook-range.d.ts +16 -0
- package/dist/chart/workbook-read.d.ts +7 -0
- package/dist/chart/workbook-write.d.ts +9 -0
- package/dist/chart/workbook.d.ts +25 -0
- package/dist/chart/xml-data.d.ts +14 -0
- package/dist/chart/xml-namespaces.d.ts +16 -0
- package/dist/chart-design/index.d.ts +10 -0
- package/dist/chart-design/types.d.ts +11 -0
- package/dist/chart-design/xml.d.ts +2 -0
- package/dist/chart-design.js +361 -0
- package/dist/chart-ex/index.d.ts +15 -0
- package/dist/chart-ex/workbook.d.ts +6 -0
- package/dist/chart-ex/xml.d.ts +14 -0
- package/dist/chart-ex.js +457 -0
- package/dist/chart-shared/index.d.ts +12 -0
- package/dist/chart-shared.js +1 -0
- package/dist/chart.js +1 -0
- package/dist/clipboard-links-GuPtqr1z.js +778 -0
- package/dist/clipboard-package.d.ts +4 -0
- package/dist/clipboard-source.d.ts +6 -2
- package/dist/clipboard-trees.d.ts +9 -0
- package/dist/commands/add-slide-identity.d.ts +2 -0
- package/dist/commands/bullet-image-resource.d.ts +11 -0
- package/dist/commands/clear-format.d.ts +4 -0
- package/dist/commands/common-object-slide-patch.d.ts +4 -0
- package/dist/commands/common-object-slide-types.d.ts +68 -0
- package/dist/commands/direct-format-patches.d.ts +11 -5
- package/dist/commands/distribute-elements.d.ts +4 -0
- package/dist/commands/edit-table-grid.d.ts +10 -0
- package/dist/commands/element-alt-text.d.ts +8 -0
- package/dist/commands/element-arrangement.d.ts +17 -0
- package/dist/commands/element-effects.d.ts +1 -1
- package/dist/commands/element-fill.d.ts +1 -1
- package/dist/commands/element-geometry.d.ts +5 -2
- package/dist/commands/element-image-content.d.ts +2 -2
- package/dist/commands/element-link.d.ts +1 -1
- package/dist/commands/element-name.d.ts +1 -1
- package/dist/commands/element-stroke.d.ts +1 -1
- package/dist/commands/element-text.d.ts +1 -1
- package/dist/commands/element-transform.d.ts +2 -2
- package/dist/commands/geometry-types.d.ts +23 -1
- package/dist/commands/hierarchy-record.d.ts +5 -0
- package/dist/commands/image-resource.d.ts +8 -1
- package/dist/commands/insertion-host.d.ts +14 -1
- package/dist/commands/layout-property.d.ts +7 -0
- package/dist/commands/master-property.d.ts +5 -0
- package/dist/commands/master-text-style-types.d.ts +27 -0
- package/dist/commands/master-text-style.d.ts +7 -0
- package/dist/commands/paste-resources.d.ts +9 -5
- package/dist/commands/patch-apply.d.ts +3 -0
- package/dist/commands/patch-count.d.ts +1 -0
- package/dist/commands/patch-invalidation.d.ts +1 -1
- package/dist/commands/patch-stage.d.ts +4 -0
- package/dist/commands/record-override.d.ts +5 -0
- package/dist/commands/replace-image.d.ts +6 -1
- package/dist/commands/sections.d.ts +10 -0
- package/dist/commands/set-preset.d.ts +5 -0
- package/dist/commands/slide-property-types.d.ts +55 -5
- package/dist/commands/slide-size.d.ts +7 -0
- package/dist/commands/spid.d.ts +1 -1
- package/dist/commands/table-grid-patch.d.ts +12 -0
- package/dist/commands/text-target.d.ts +2 -2
- package/dist/commands/theme-types.d.ts +47 -0
- package/dist/commands/theme.d.ts +9 -0
- package/dist/commands/types.d.ts +194 -17
- package/dist/commands/ungroup-source.d.ts +3 -0
- package/dist/comments/index.d.ts +35 -0
- package/dist/comments/save.d.ts +3 -0
- package/dist/comments/state.d.ts +10 -0
- package/dist/comments/xml.d.ts +12 -0
- package/dist/comments.js +782 -0
- package/dist/common-object-slide-types.d.ts +34 -0
- package/dist/data-validation.d.ts +1 -1
- package/dist/describe/budget.d.ts +3 -0
- package/dist/describe/index.d.ts +5 -0
- package/dist/describe/read.d.ts +4 -0
- package/dist/describe/types.d.ts +103 -0
- package/dist/describe.js +192 -0
- package/dist/design-dependencies.d.ts +8 -0
- package/dist/design-projection-package.d.ts +10 -0
- package/dist/design-target.d.ts +10 -0
- package/dist/design.d.ts +3 -0
- package/dist/document-extensions.d.ts +9 -0
- package/dist/document.d.ts +1 -1
- package/dist/dynamic-projection.d.ts +6 -0
- package/dist/edit-core.js +5420 -4111
- package/dist/editor.d.ts +15 -3
- package/dist/element-source.d.ts +11 -0
- package/dist/element-spids.d.ts +4 -0
- package/dist/extension-address-journal.d.ts +9 -0
- package/dist/extension-address-remap.d.ts +14 -0
- package/dist/extension-addresses.d.ts +20 -0
- package/dist/extension-copy-history.d.ts +7 -0
- package/dist/extension-copy.d.ts +16 -0
- package/dist/extension-migration-receipt.d.ts +34 -0
- package/dist/extension-recovery-context.d.ts +5 -0
- package/dist/extension-runtime.d.ts +64 -0
- package/dist/generate/comments.d.ts +3 -0
- package/dist/generate/compatibility-parts.d.ts +14 -0
- package/dist/generate/compatibility-references.d.ts +3 -0
- package/dist/generate/compatibility.d.ts +4 -0
- package/dist/generate/index.d.ts +1 -0
- package/dist/generate/master-defaults.d.ts +4 -0
- package/dist/generate/materialize.d.ts +2 -2
- package/dist/generate/math.d.ts +3 -0
- package/dist/generate/portable-clipboard.d.ts +4 -0
- package/dist/generate/projection-tree.d.ts +8 -0
- package/dist/generate/template.d.ts +68 -1
- package/dist/generate/text-body.d.ts +2 -0
- package/dist/generate/text-effects.d.ts +5 -0
- package/dist/generate/text-override.d.ts +8 -0
- package/dist/generate/validation.d.ts +3 -0
- package/dist/generate/warp.d.ts +2 -0
- package/dist/generate.js +1232 -512
- package/dist/history.d.ts +11 -1
- package/dist/identities.d.ts +4 -0
- package/dist/image-content.d.ts +5 -2
- package/dist/image-resource-history.d.ts +2 -0
- package/dist/index-C2r7c6G6.js +714 -0
- package/dist/index-CYDvbiwF.js +1 -0
- package/dist/index.d.ts +35 -7
- package/dist/ink/index.d.ts +27 -0
- package/dist/ink/model.d.ts +4 -0
- package/dist/ink/save.d.ts +3 -0
- package/dist/ink/source.d.ts +7 -0
- package/dist/ink.js +324 -0
- package/dist/layout-assets.d.ts +3 -1
- package/dist/layout-projection.d.ts +17 -5
- package/dist/layout-state.d.ts +2 -0
- package/dist/layout-types.d.ts +42 -0
- package/dist/layout.d.ts +5 -0
- package/dist/lint/color.d.ts +5 -0
- package/dist/lint/index.d.ts +7 -0
- package/dist/lint/prompts.d.ts +3 -0
- package/dist/lint/report.d.ts +21 -0
- package/dist/lint/sampler-batch.d.ts +4 -0
- package/dist/lint/sampler-images.d.ts +2 -0
- package/dist/lint/sampler.d.ts +9 -0
- package/dist/lint/snapshot.d.ts +34 -0
- package/dist/lint/types.d.ts +67 -0
- package/dist/lint-sampler.js +187 -0
- package/dist/lint.js +659 -0
- package/dist/master-state.d.ts +3 -0
- package/dist/master-text-style-state.d.ts +3 -0
- package/dist/master-types.d.ts +55 -0
- package/dist/master.d.ts +5 -0
- package/dist/media/audio-icon.d.ts +2 -0
- package/dist/media/commands.d.ts +3 -0
- package/dist/media/index.d.ts +10 -0
- package/dist/media/markup.d.ts +10 -0
- package/dist/media/mp4-boxes.d.ts +12 -0
- package/dist/media/mp4-fragments.d.ts +8 -0
- package/dist/media/mp4-samples.d.ts +4 -0
- package/dist/media/mp4.d.ts +2 -0
- package/dist/media/poster.d.ts +2 -0
- package/dist/media/replace-poster.d.ts +3 -0
- package/dist/media/resource.d.ts +4 -0
- package/dist/media/source.d.ts +14 -0
- package/dist/media/types.d.ts +33 -0
- package/dist/media-properties.d.ts +4 -0
- package/dist/media.js +1630 -0
- package/dist/model-invariants-BM19JVxy.js +8980 -0
- package/dist/object-source.d.ts +11 -0
- package/dist/ole/container.d.ts +14 -0
- package/dist/ole/content.d.ts +94 -0
- package/dist/ole/index.d.ts +20 -0
- package/dist/ole/preview.d.ts +3 -0
- package/dist/ole/save.d.ts +2 -0
- package/dist/ole/state.d.ts +16 -0
- package/dist/ole.js +870 -0
- package/dist/opc.js +1 -1
- package/dist/paragraph-level.d.ts +2 -2
- package/dist/paragraph-property-schema.d.ts +4 -1
- package/dist/{patch-D7lZelRa.js → patch-BwhfBbYE.js} +10 -10
- package/dist/patch-events.d.ts +5 -1
- package/dist/ppt/appearance.d.ts +11 -0
- package/dist/ppt/binary.d.ts +20 -0
- package/dist/ppt/drawing.d.ts +18 -0
- package/dist/ppt/geometry.d.ts +4 -0
- package/dist/ppt/index.d.ts +12 -0
- package/dist/ppt/pictures.d.ts +11 -0
- package/dist/ppt/text.d.ts +9 -0
- package/dist/ppt.js +774 -0
- package/dist/preset-geometry.d.ts +6 -0
- package/dist/projection.d.ts +2 -0
- package/dist/query-BHLjWjnu.js +903 -0
- package/dist/recovery-identity.d.ts +1 -0
- package/dist/recovery-migrations.d.ts +3 -0
- package/dist/recovery.d.ts +3 -0
- package/dist/resize/index.d.ts +6 -0
- package/dist/resize/text.d.ts +4 -0
- package/dist/resize.js +5090 -0
- package/dist/retained-element-origins.d.ts +6 -0
- package/dist/run-property-fields.d.ts +12 -0
- package/dist/run-property-schema.d.ts +3 -1
- package/dist/run-style.d.ts +15 -0
- package/dist/save/alt-text.d.ts +4 -0
- package/dist/save/comments.d.ts +3 -0
- package/dist/save/effects.d.ts +2 -1
- package/dist/save/extension-availability.d.ts +3 -0
- package/dist/save/extension-elements.d.ts +26 -0
- package/dist/save/index.d.ts +6 -1
- package/dist/save/insertion.d.ts +6 -5
- package/dist/save/layout-properties.d.ts +4 -0
- package/dist/save/master-properties.d.ts +5 -0
- package/dist/save/paragraph-overrides.d.ts +3 -0
- package/dist/save/slide-parts.d.ts +1 -0
- package/dist/save/table.d.ts +2 -0
- package/dist/save/xfrm.d.ts +8 -2
- package/dist/save.js +493 -498
- package/dist/sections.d.ts +8 -0
- package/dist/session-assets.d.ts +4 -0
- package/dist/slide-parts-D0o_DDhi.js +1331 -0
- package/dist/slide-size.d.ts +6 -0
- package/dist/smartart/drawing.d.ts +3 -0
- package/dist/smartart/index.d.ts +16 -0
- package/dist/smartart/model.d.ts +18 -0
- package/dist/smartart/save.d.ts +3 -0
- package/dist/smartart.js +604 -0
- package/dist/source-retention.d.ts +7 -0
- package/dist/space.d.ts +37 -0
- package/dist/table-cell.d.ts +7 -1
- package/dist/table-grid-projection.d.ts +6 -0
- package/dist/table-grid.d.ts +45 -0
- package/dist/table-invariants.d.ts +4 -0
- package/dist/table-rows.d.ts +2 -1
- package/dist/table-scale.d.ts +4 -0
- package/dist/table-style.d.ts +5 -4
- package/dist/templates/index.d.ts +4 -0
- package/dist/templates/recipes.d.ts +5 -0
- package/dist/templates/types.d.ts +17 -0
- package/dist/templates.js +543 -0
- package/dist/text-flatten.d.ts +6 -0
- package/dist/text-fragment.d.ts +5 -0
- package/dist/text-model.d.ts +8 -8
- package/dist/text-override-validation.d.ts +6 -2
- package/dist/text-selection.d.ts +4 -0
- package/dist/theme-projection.d.ts +8 -0
- package/dist/theme-xml.d.ts +3 -0
- package/dist/theme.d.ts +14 -0
- package/dist/types.d.ts +174 -8
- package/dist/xml/index.d.ts +1 -1
- package/dist/xml/nodes.d.ts +2 -2
- package/dist/xml/shape-ids.d.ts +3 -0
- package/dist/xml.js +19 -16
- package/package.json +73 -5
- package/schemas/describe.schema.json +479 -0
- package/schemas/lint.schema.json +145 -0
- package/dist/document-B1jjN-QB.js +0 -274
- package/dist/image-resource-DbgJS9n-.js +0 -24
- package/dist/index-D2JizcOQ.js +0 -706
- package/dist/insertion-CGpb504L.js +0 -6152
- package/dist/table-style-part-DBtpxmuo.js +0 -1042
package/dist/media.js
ADDED
|
@@ -0,0 +1,1630 @@
|
|
|
1
|
+
import { sha256 as Mt } from "@web-ppt/core";
|
|
2
|
+
function B(e) {
|
|
3
|
+
return [...Mt(e)].map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
4
|
+
}
|
|
5
|
+
function qe(e) {
|
|
6
|
+
const t = [];
|
|
7
|
+
for (let n = 0; n < e.length; n += 32768)
|
|
8
|
+
t.push(String.fromCharCode(...e.subarray(n, n + 32768)));
|
|
9
|
+
return btoa(t.join(""));
|
|
10
|
+
}
|
|
11
|
+
function Qe(e) {
|
|
12
|
+
const t = atob(e);
|
|
13
|
+
return Uint8Array.from(t, (n) => n.charCodeAt(0));
|
|
14
|
+
}
|
|
15
|
+
const St = "web-ppt-resource:", Ze = (e) => `${St}${e}`, Ye = (e, t) => Object.prototype.hasOwnProperty.call(e, t);
|
|
16
|
+
function D(e, t, n) {
|
|
17
|
+
if (!e || typeof e != "object" || Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null)
|
|
18
|
+
throw new Error(`${n} 必须是纯数据对象`);
|
|
19
|
+
const r = Array.isArray(t) ? new Set(t) : t;
|
|
20
|
+
for (const s of Reflect.ownKeys(e)) {
|
|
21
|
+
const i = Object.getOwnPropertyDescriptor(e, s);
|
|
22
|
+
if (typeof s != "string" || !r.has(s) || !(i != null && i.enumerable) || !("value" in i))
|
|
23
|
+
throw new Error(`${n} 包含不可序列化或未知字段:${String(s)}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", X = _.length, Ot = 8, $t = BigInt(X);
|
|
27
|
+
$t ** BigInt(Ot);
|
|
28
|
+
function et(e) {
|
|
29
|
+
const t = _.indexOf(e);
|
|
30
|
+
if (t < 0) throw new Error(`非法分数序字符:${JSON.stringify(e)}`);
|
|
31
|
+
return t;
|
|
32
|
+
}
|
|
33
|
+
function Nt(e) {
|
|
34
|
+
if (!e) throw new Error("分数序不能为空");
|
|
35
|
+
for (const t of e) et(t);
|
|
36
|
+
if (e.endsWith(_[0])) throw new Error("分数序不能以最小字符结尾");
|
|
37
|
+
}
|
|
38
|
+
function Pt(e) {
|
|
39
|
+
let t = "z";
|
|
40
|
+
for (let n = 0; n < e.length; n++) {
|
|
41
|
+
const r = e.charCodeAt(n);
|
|
42
|
+
t += _[Math.floor(r / (X * X))] + _[Math.floor(r / X) % X] + _[r % X];
|
|
43
|
+
}
|
|
44
|
+
return `${t}V`;
|
|
45
|
+
}
|
|
46
|
+
function Ee(e, t) {
|
|
47
|
+
if (e !== null && Nt(e), e !== null && t !== null && e >= t)
|
|
48
|
+
throw new Error(`分数序边界无效:${e} >= ${t}`);
|
|
49
|
+
let n = "", r = 0;
|
|
50
|
+
for (; ; ) {
|
|
51
|
+
const s = e === null || r >= e.length ? -1 : et(e[r]), i = X;
|
|
52
|
+
if (s === i) {
|
|
53
|
+
n += _[s], r++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (s + 1 < i) {
|
|
57
|
+
const a = Math.floor((s + i) / 2);
|
|
58
|
+
return s === -1 && a === 0 ? n + _[0] + Ee(null, null) : n + _[a];
|
|
59
|
+
}
|
|
60
|
+
if (s === -1)
|
|
61
|
+
throw new Error("上界不是本模块生成的合法分数序");
|
|
62
|
+
const o = e && r + 1 < e.length ? e.slice(r + 1) : null;
|
|
63
|
+
return n + _[s] + Ee(o, null);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function kt(e, t, n) {
|
|
67
|
+
const r = Ee(e, t);
|
|
68
|
+
return n === void 0 ? r : r + Pt(n);
|
|
69
|
+
}
|
|
70
|
+
const F = /* @__PURE__ */ new WeakMap(), jt = /* @__PURE__ */ new WeakMap(), Ct = /* @__PURE__ */ new WeakMap(), tt = "http://www.w3.org/XML/1998/namespace", Rt = "http://www.w3.org/2000/xmlns/", Tt = "http://schemas.openxmlformats.org/drawingml/2006/main", bt = "http://schemas.openxmlformats.org/presentationml/2006/main", _t = /^[A-Za-z_][A-Za-z0-9_.-]*$/, Wt = /^[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{N}\p{M}\p{Pc}_.\-\u00B7\u203F-\u2040]*$/u, he = (e) => _t.test(e) || Wt.test(e);
|
|
71
|
+
function ke(e) {
|
|
72
|
+
const t = e.indexOf(":");
|
|
73
|
+
return t < 0 ? he(e) : t === e.lastIndexOf(":") && he(e.slice(0, t)) && he(e.slice(t + 1));
|
|
74
|
+
}
|
|
75
|
+
const xe = (e) => {
|
|
76
|
+
const t = e.indexOf(":");
|
|
77
|
+
return t < 0 ? { prefix: null, localName: e } : { prefix: e.slice(0, t), localName: e.slice(t + 1) };
|
|
78
|
+
};
|
|
79
|
+
function je(e, t, n) {
|
|
80
|
+
const r = xe(e);
|
|
81
|
+
return n && (e === "xmlns" || r.prefix === "xmlns") ? Rt : r.prefix === "xml" ? tt : r.prefix ? t.get(r.prefix) || null : n ? null : t.get("") || null;
|
|
82
|
+
}
|
|
83
|
+
const Bt = /* @__PURE__ */ new WeakMap(), Dt = {
|
|
84
|
+
amp: "&",
|
|
85
|
+
lt: "<",
|
|
86
|
+
gt: ">",
|
|
87
|
+
quot: '"',
|
|
88
|
+
apos: "'"
|
|
89
|
+
}, K = (e) => e === " " || e === " " || e === "\r" || e === `
|
|
90
|
+
`, Ce = (e) => K(e) || e === "=" || e === "/" || e === ">";
|
|
91
|
+
function Ht(e) {
|
|
92
|
+
let t = e.length - 2;
|
|
93
|
+
for (; K(e[t]); ) t--;
|
|
94
|
+
return e[t] === "/";
|
|
95
|
+
}
|
|
96
|
+
function Q(e) {
|
|
97
|
+
return e.includes("&") ? e.replace(/&(#x[0-9a-f]+|#[0-9]+|[A-Za-z][\w.-]*);/gi, (t, n) => {
|
|
98
|
+
if (n[0] !== "#") return Dt[n] ?? t;
|
|
99
|
+
const r = n[1].toLowerCase() === "x", s = Number.parseInt(n.slice(r ? 2 : 1), r ? 16 : 10);
|
|
100
|
+
return Number.isFinite(s) && s >= 0 && s <= 1114111 ? String.fromCodePoint(s) : t;
|
|
101
|
+
}) : e;
|
|
102
|
+
}
|
|
103
|
+
function zt(e) {
|
|
104
|
+
let t = "utf-8", n = !1, r = 0;
|
|
105
|
+
return e[0] === 239 && e[1] === 187 && e[2] === 191 ? (n = !0, r = 3) : e[0] === 255 && e[1] === 254 ? (t = "utf-16le", n = !0, r = 2) : e[0] === 254 && e[1] === 255 ? (t = "utf-16be", n = !0, r = 2) : e[0] === 60 && e[1] === 0 ? t = "utf-16le" : e[0] === 0 && e[1] === 60 && (t = "utf-16be"), { text: new TextDecoder(t, { fatal: !0 }).decode(e.subarray(r)), encoding: t, bom: n };
|
|
106
|
+
}
|
|
107
|
+
class Re {
|
|
108
|
+
constructor(t) {
|
|
109
|
+
this.source = t, this.offset = 0;
|
|
110
|
+
}
|
|
111
|
+
parse() {
|
|
112
|
+
const t = [], n = { type: "document", children: t, root: null };
|
|
113
|
+
let r = null;
|
|
114
|
+
for (; this.offset < this.source.length; ) {
|
|
115
|
+
const s = this.source[this.offset] === "<" ? this.parseMarkup(n, /* @__PURE__ */ new Map()) : this.parseText(n);
|
|
116
|
+
t.push(s), s.type === "element" ? (r && this.fail("XML 只能有一个根元素"), r = s) : s.type === "text" && s.value.replace(/^\uFEFF/, "").trim() && this.fail("根元素外不能出现文本");
|
|
117
|
+
}
|
|
118
|
+
return r || this.fail("未找到根元素"), Object.defineProperty(n, "root", { value: r, enumerable: !0 }), F.set(n, { raw: this.source, parent: null, dirty: !1 }), n;
|
|
119
|
+
}
|
|
120
|
+
parseText(t) {
|
|
121
|
+
const n = this.offset, r = this.source.indexOf("<", n);
|
|
122
|
+
this.offset = r < 0 ? this.source.length : r;
|
|
123
|
+
const s = this.source.slice(n, this.offset), i = { type: "text", value: Q(s) };
|
|
124
|
+
return F.set(i, { raw: s, parent: t, dirty: !1 }), i;
|
|
125
|
+
}
|
|
126
|
+
parseMarkup(t, n) {
|
|
127
|
+
const r = this.offset;
|
|
128
|
+
if (this.source.startsWith("<!--", r)) {
|
|
129
|
+
const s = this.source.indexOf("-->", r + 4);
|
|
130
|
+
s < 0 && this.fail("注释未闭合"), this.offset = s + 3;
|
|
131
|
+
const i = this.source.slice(r, this.offset), o = { type: "comment", value: i.slice(4, -3) };
|
|
132
|
+
return F.set(o, { raw: i, parent: t, dirty: !1 }), o;
|
|
133
|
+
}
|
|
134
|
+
if (this.source.startsWith("<![CDATA[", r)) {
|
|
135
|
+
const s = this.source.indexOf("]]>", r + 9);
|
|
136
|
+
s < 0 && this.fail("CDATA 未闭合"), this.offset = s + 3;
|
|
137
|
+
const i = this.source.slice(r, this.offset), o = { type: "cdata", value: i.slice(9, -3) };
|
|
138
|
+
return F.set(o, { raw: i, parent: t, dirty: !1 }), o;
|
|
139
|
+
}
|
|
140
|
+
return this.source.startsWith("<?", r) ? this.parseInstruction(t) : this.source.startsWith("<!", r) ? this.parseDeclaration(t) : (this.source.startsWith("</", r) && this.fail("遇到意外的闭合标签"), this.parseElement(t, n));
|
|
141
|
+
}
|
|
142
|
+
parseInstruction(t) {
|
|
143
|
+
const n = this.offset, r = this.source.indexOf("?>", n + 2);
|
|
144
|
+
r < 0 && this.fail("处理指令未闭合"), this.offset = r + 2;
|
|
145
|
+
const s = this.source.slice(n, this.offset), i = s.slice(2, -2), o = i.search(/\s/), a = {
|
|
146
|
+
type: "processing-instruction",
|
|
147
|
+
target: o < 0 ? i : i.slice(0, o),
|
|
148
|
+
value: o < 0 ? "" : i.slice(o).trimStart()
|
|
149
|
+
};
|
|
150
|
+
return F.set(a, { raw: s, parent: t, dirty: !1 }), a;
|
|
151
|
+
}
|
|
152
|
+
parseDeclaration(t) {
|
|
153
|
+
const n = this.offset;
|
|
154
|
+
let r = "", s = 0;
|
|
155
|
+
for (this.offset += 2; this.offset < this.source.length; ) {
|
|
156
|
+
const a = this.source[this.offset++];
|
|
157
|
+
if (r)
|
|
158
|
+
a === r && (r = "");
|
|
159
|
+
else if (a === '"' || a === "'") r = a;
|
|
160
|
+
else if (a === "[") s++;
|
|
161
|
+
else if (a === "]") s = Math.max(0, s - 1);
|
|
162
|
+
else if (a === ">" && s === 0) break;
|
|
163
|
+
}
|
|
164
|
+
this.source[this.offset - 1] !== ">" && this.fail("声明未闭合");
|
|
165
|
+
const i = this.source.slice(n, this.offset), o = { type: "declaration", value: i.slice(2, -1) };
|
|
166
|
+
return F.set(o, { raw: i, parent: t, dirty: !1 }), o;
|
|
167
|
+
}
|
|
168
|
+
parseElement(t, n) {
|
|
169
|
+
const r = this.offset, s = this.scanOpenEnd(r), i = this.source.slice(r, s + 1), o = this.scanNameEnd(r + 1, s), a = this.source.slice(r + 1, o);
|
|
170
|
+
ke(a) || this.fail(`非法元素名 ${a || "(空)"}`);
|
|
171
|
+
const c = this.parseAttributes(i, a.length + 1), f = new Map(n);
|
|
172
|
+
f.set("xml", tt);
|
|
173
|
+
for (const m of c)
|
|
174
|
+
m.name === "xmlns" ? f.set("", Q(m.value)) : m.name.startsWith("xmlns:") && f.set(m.name.slice(6), Q(m.value));
|
|
175
|
+
const u = c.map((m) => {
|
|
176
|
+
const h = xe(m.name), E = {
|
|
177
|
+
name: m.name,
|
|
178
|
+
prefix: h.prefix,
|
|
179
|
+
localName: h.localName,
|
|
180
|
+
namespaceUri: je(m.name, f, !0),
|
|
181
|
+
value: Q(m.value),
|
|
182
|
+
quote: m.quote
|
|
183
|
+
};
|
|
184
|
+
return Ct.set(E, m.state), E;
|
|
185
|
+
}), d = xe(a), l = Ht(i), p = [], g = {
|
|
186
|
+
type: "element",
|
|
187
|
+
name: a,
|
|
188
|
+
prefix: d.prefix,
|
|
189
|
+
localName: d.localName,
|
|
190
|
+
namespaceUri: je(a, f, !1),
|
|
191
|
+
attributes: u,
|
|
192
|
+
children: p,
|
|
193
|
+
selfClosing: l
|
|
194
|
+
};
|
|
195
|
+
this.offset = s + 1;
|
|
196
|
+
let v = "";
|
|
197
|
+
if (!l) {
|
|
198
|
+
for (; this.offset < this.source.length && !this.source.startsWith("</", this.offset); ) {
|
|
199
|
+
const y = this.source[this.offset] === "<" ? this.parseMarkup(g, f) : this.parseText(g);
|
|
200
|
+
p.push(y);
|
|
201
|
+
}
|
|
202
|
+
this.source.startsWith("</", this.offset) || this.fail(`元素 <${a}> 未闭合`);
|
|
203
|
+
const m = this.offset, h = this.source.indexOf(">", m + 2);
|
|
204
|
+
h < 0 && this.fail(`元素 <${a}> 未闭合`);
|
|
205
|
+
const E = this.source.slice(m + 2, h).trim();
|
|
206
|
+
E !== a && this.fail(`闭合标签 </${E}> 与 <${a}> 不匹配`), this.offset = h + 1, v = this.source.slice(m, this.offset);
|
|
207
|
+
}
|
|
208
|
+
const x = {
|
|
209
|
+
raw: this.source.slice(r, this.offset),
|
|
210
|
+
parent: t,
|
|
211
|
+
dirty: !1,
|
|
212
|
+
openRaw: i,
|
|
213
|
+
closeRaw: v,
|
|
214
|
+
sourceSelfClosing: l,
|
|
215
|
+
// 源属性表必须与公开的当前属性表分离;删除/新增只改当前表,序列化仍靠源表定位原始字节。
|
|
216
|
+
sourceAttributes: [...u],
|
|
217
|
+
namespaces: f
|
|
218
|
+
};
|
|
219
|
+
return F.set(g, x), jt.set(g, x), g;
|
|
220
|
+
}
|
|
221
|
+
scanOpenEnd(t) {
|
|
222
|
+
let n = "";
|
|
223
|
+
for (let r = t + 1; r < this.source.length; r++) {
|
|
224
|
+
const s = this.source[r];
|
|
225
|
+
if (n)
|
|
226
|
+
s === n && (n = "");
|
|
227
|
+
else if (s === '"' || s === "'") n = s;
|
|
228
|
+
else if (s === ">") return r;
|
|
229
|
+
}
|
|
230
|
+
this.fail("开始标签未闭合");
|
|
231
|
+
}
|
|
232
|
+
scanNameEnd(t, n) {
|
|
233
|
+
let r = t;
|
|
234
|
+
for (; r < n && !Ce(this.source[r]); ) r++;
|
|
235
|
+
return r;
|
|
236
|
+
}
|
|
237
|
+
parseAttributes(t, n) {
|
|
238
|
+
const r = [], s = /* @__PURE__ */ new Set();
|
|
239
|
+
let i = n;
|
|
240
|
+
for (; i < t.length - 1; ) {
|
|
241
|
+
const o = i;
|
|
242
|
+
for (; K(t[i]); ) i++;
|
|
243
|
+
if (t[i] === "/" || t[i] === ">" || i >= t.length - 1) break;
|
|
244
|
+
i === o && this.fail("属性前缺少空白");
|
|
245
|
+
const a = i;
|
|
246
|
+
for (; i < t.length && !Ce(t[i]); ) i++;
|
|
247
|
+
const c = t.slice(a, i);
|
|
248
|
+
for (ke(c) || this.fail(`非法属性名 ${c || "(空)"}`), s.has(c) && this.fail(`属性 ${c} 重复`), s.add(c); K(t[i]); ) i++;
|
|
249
|
+
for (t[i++] !== "=" && this.fail(`属性 ${c} 缺少等号`); K(t[i]); ) i++;
|
|
250
|
+
const f = t[i++];
|
|
251
|
+
f !== '"' && f !== "'" && this.fail(`属性 ${c} 必须使用引号`);
|
|
252
|
+
const u = i, d = t.indexOf(f, u);
|
|
253
|
+
d < 0 && this.fail(`属性 ${c} 未闭合`), i = d + 1, r.push({
|
|
254
|
+
name: c,
|
|
255
|
+
value: t.slice(u, d),
|
|
256
|
+
quote: f,
|
|
257
|
+
state: {
|
|
258
|
+
source: !0,
|
|
259
|
+
present: !0,
|
|
260
|
+
changed: !1,
|
|
261
|
+
start: o,
|
|
262
|
+
nameStart: a,
|
|
263
|
+
valueStart: u,
|
|
264
|
+
valueEnd: d,
|
|
265
|
+
end: i
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
return r;
|
|
270
|
+
}
|
|
271
|
+
fail(t) {
|
|
272
|
+
throw new Error(`XML 解析失败(偏移 ${this.offset}):${t}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function fe(e) {
|
|
276
|
+
if (typeof e == "string") return new Re(e).parse();
|
|
277
|
+
const t = zt(e), n = new Re(t.text).parse();
|
|
278
|
+
return Bt.set(n, { encoding: t.encoding, bom: t.bom, source: e }), n;
|
|
279
|
+
}
|
|
280
|
+
const nt = (e, t) => e.localName === t.localName && (!Object.prototype.hasOwnProperty.call(t, "namespaceUri") || e.namespaceUri === t.namespaceUri);
|
|
281
|
+
function ie(e, t) {
|
|
282
|
+
const n = e.children.filter((r) => r.type === "element");
|
|
283
|
+
return t ? n.filter((r) => nt(r, t)) : n;
|
|
284
|
+
}
|
|
285
|
+
function W(e, t) {
|
|
286
|
+
return e.attributes.find((n) => nt(n, t)) ?? null;
|
|
287
|
+
}
|
|
288
|
+
function Ut(e) {
|
|
289
|
+
return Ye(e, "order") ? e.order : e.z;
|
|
290
|
+
}
|
|
291
|
+
function ye(e) {
|
|
292
|
+
const t = e.lastIndexOf("/"), n = t < 0 ? "" : e.slice(0, t + 1), r = t < 0 ? e : e.slice(t + 1);
|
|
293
|
+
return `${n}_rels/${r}.rels`;
|
|
294
|
+
}
|
|
295
|
+
function Ie(e, t) {
|
|
296
|
+
const n = e.split("/").slice(0, -1), r = t.split("/");
|
|
297
|
+
let s = 0;
|
|
298
|
+
for (; s < n.length && s < r.length && n[s] === r[s]; ) s++;
|
|
299
|
+
return `${"../".repeat(n.length - s)}${r.slice(s).join("/")}`;
|
|
300
|
+
}
|
|
301
|
+
function rt(e, t) {
|
|
302
|
+
const n = t.split("#", 1)[0], r = [
|
|
303
|
+
...n.startsWith("/") ? [] : e.split("/").slice(0, -1),
|
|
304
|
+
...n.replace(/^\//, "").split("/")
|
|
305
|
+
], s = [];
|
|
306
|
+
for (const i of r)
|
|
307
|
+
if (!(!i || i === "."))
|
|
308
|
+
if (i === "..") {
|
|
309
|
+
if (!s.length) throw new Error(`OPC 关系越出包根:${t}`);
|
|
310
|
+
s.pop();
|
|
311
|
+
} else s.push(i);
|
|
312
|
+
return s.join("/");
|
|
313
|
+
}
|
|
314
|
+
const Te = /* @__PURE__ */ new WeakMap(), be = /* @__PURE__ */ new WeakMap(), Lt = /* @__PURE__ */ new WeakMap();
|
|
315
|
+
function te(e, t) {
|
|
316
|
+
let n = be.get(e);
|
|
317
|
+
n || (n = /* @__PURE__ */ new Map(), be.set(e, n));
|
|
318
|
+
const r = n.get(t);
|
|
319
|
+
if (r) return r;
|
|
320
|
+
const s = e.parts[t];
|
|
321
|
+
if (!s) throw new Error(`复杂对象关系目标不存在:${t}`);
|
|
322
|
+
const i = B(s);
|
|
323
|
+
return n.set(t, i), i;
|
|
324
|
+
}
|
|
325
|
+
function Ft(e, t) {
|
|
326
|
+
let n = Te.get(e);
|
|
327
|
+
n || (n = /* @__PURE__ */ new Map(), Te.set(e, n));
|
|
328
|
+
const r = n.get(t);
|
|
329
|
+
if (r) return r;
|
|
330
|
+
const s = [], i = /* @__PURE__ */ new Set(), o = (c) => {
|
|
331
|
+
var p, g, v, x;
|
|
332
|
+
if (i.has(c)) return;
|
|
333
|
+
i.add(c);
|
|
334
|
+
const f = te(e, c), u = ye(c), d = e.parts[u], l = [];
|
|
335
|
+
for (const m of d ? ie(fe(d).root, { localName: "Relationship" }) : []) {
|
|
336
|
+
const h = (p = W(m, { localName: "Id", namespaceUri: null })) == null ? void 0 : p.value, E = (g = W(m, { localName: "Type", namespaceUri: null })) == null ? void 0 : g.value, y = (v = W(m, { localName: "TargetMode", namespaceUri: null })) == null ? void 0 : v.value, I = (x = W(m, { localName: "Target", namespaceUri: null })) == null ? void 0 : x.value;
|
|
337
|
+
if (!h || !E || !I) throw new Error(`复杂对象关系缺少 Id、Type 或 Target:${c}`);
|
|
338
|
+
if (y === "External") l.push(JSON.stringify([h, E, "External", I]));
|
|
339
|
+
else {
|
|
340
|
+
const $ = rt(c, I);
|
|
341
|
+
l.push(JSON.stringify([h, E, "Internal", te(e, $)])), o($);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
s.push(JSON.stringify({ content: f, relationships: l.sort() }));
|
|
345
|
+
};
|
|
346
|
+
o(t);
|
|
347
|
+
const a = {
|
|
348
|
+
rootHash: te(e, t),
|
|
349
|
+
closureHash: B(new TextEncoder().encode(JSON.stringify(s.sort())))
|
|
350
|
+
};
|
|
351
|
+
return n.set(t, a), Lt.set(a, [...i].flatMap((c) => [c, ye(c)])), a;
|
|
352
|
+
}
|
|
353
|
+
function Xt(e, t) {
|
|
354
|
+
return !t || !/^[0-9a-f]{64}$/.test(t.rootHash) || !/^[0-9a-f]{64}$/.test(t.closureHash) ? null : Object.keys(e.parts).filter((r) => r !== "[Content_Types].xml" && !r.includes("/_rels/") && !r.startsWith("_rels/") && te(e, r) === t.rootHash).sort().find((r) => Ft(e, r).closureHash === t.closureHash) ?? null;
|
|
355
|
+
}
|
|
356
|
+
const _e = /* @__PURE__ */ new WeakMap();
|
|
357
|
+
function st(e) {
|
|
358
|
+
var a, c, f, u;
|
|
359
|
+
const t = _e.get(e);
|
|
360
|
+
if (t) return t;
|
|
361
|
+
const n = e.parts["[Content_Types].xml"];
|
|
362
|
+
if (!n) throw new Error("PPTX 缺少 [Content_Types].xml");
|
|
363
|
+
const r = fe(n).root, s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
364
|
+
for (const d of ie(r, { localName: "Override" })) {
|
|
365
|
+
const l = (a = W(d, { localName: "PartName", namespaceUri: null })) == null ? void 0 : a.value, p = (c = W(d, { localName: "ContentType", namespaceUri: null })) == null ? void 0 : c.value;
|
|
366
|
+
l && p && s.set(l, p);
|
|
367
|
+
}
|
|
368
|
+
for (const d of ie(r, { localName: "Default" })) {
|
|
369
|
+
const l = (f = W(d, { localName: "Extension", namespaceUri: null })) == null ? void 0 : f.value, p = (u = W(d, { localName: "ContentType", namespaceUri: null })) == null ? void 0 : u.value;
|
|
370
|
+
l && p && i.set(l.toLowerCase(), p);
|
|
371
|
+
}
|
|
372
|
+
const o = { overrides: s, defaults: i };
|
|
373
|
+
return _e.set(e, o), o;
|
|
374
|
+
}
|
|
375
|
+
function We(e, t, n) {
|
|
376
|
+
const r = st(e), s = r.overrides.get(`/${t}`);
|
|
377
|
+
if (s) return s;
|
|
378
|
+
const i = r.defaults.get(n.toLowerCase());
|
|
379
|
+
if (!i) throw new Error(`资源缺少 Content-Type:${t}`);
|
|
380
|
+
return i;
|
|
381
|
+
}
|
|
382
|
+
function Jt(e, t) {
|
|
383
|
+
return st(e).overrides.get(`/${t}`);
|
|
384
|
+
}
|
|
385
|
+
function Vt(e, t) {
|
|
386
|
+
if (!t || typeof t != "object" || Object.getPrototypeOf(t) !== Object.prototype || typeof t.id != "string" || !t.id || t.kind === "layout" && !e.layouts[t.id] || t.kind === "master" && !e.masters[t.id] || t.kind !== "layout" && t.kind !== "master")
|
|
387
|
+
throw new Error(`找不到设计目标:${String(t == null ? void 0 : t.id)}`);
|
|
388
|
+
}
|
|
389
|
+
const pe = Symbol.for("@web-ppt/edit-core/extensions/v1"), Be = Symbol.for("@web-ppt/edit-core/extensions-generation/v1"), me = Symbol.for("@web-ppt/edit-core/extensions-listeners/v1"), Gt = /^[a-z][a-z0-9-]{0,63}$/, Kt = 1e6;
|
|
390
|
+
function ge() {
|
|
391
|
+
const e = globalThis;
|
|
392
|
+
return e[me] ?? (e[me] = { documents: /* @__PURE__ */ new WeakMap(), pending: /* @__PURE__ */ new Map(), active: /* @__PURE__ */ new Set(), resolvers: /* @__PURE__ */ new WeakMap() });
|
|
393
|
+
}
|
|
394
|
+
function it(e) {
|
|
395
|
+
if (!e || !Gt.test(e))
|
|
396
|
+
throw new Error(`编辑扩展命名空间无效:${e}`);
|
|
397
|
+
}
|
|
398
|
+
function ot(e) {
|
|
399
|
+
if (!(e === null || typeof e == "boolean") && !(typeof e == "number" && Number.isFinite(e)) && !(typeof e == "string" && e.length <= Kt))
|
|
400
|
+
throw new Error("编辑扩展值必须是有界的纯数据标量");
|
|
401
|
+
}
|
|
402
|
+
function at() {
|
|
403
|
+
const e = globalThis;
|
|
404
|
+
return e[pe] ?? (e[pe] = /* @__PURE__ */ new Map());
|
|
405
|
+
}
|
|
406
|
+
function qt(e, t) {
|
|
407
|
+
var s;
|
|
408
|
+
it(e), at().set(e, t);
|
|
409
|
+
const n = globalThis;
|
|
410
|
+
n[Be] = (n[Be] ?? 0) + 1;
|
|
411
|
+
const r = new Set(ge().pending.get(e));
|
|
412
|
+
if (t.migrate) for (const i of ge().active) r.add(i);
|
|
413
|
+
ge().pending.delete(e);
|
|
414
|
+
for (const i of r ?? [])
|
|
415
|
+
try {
|
|
416
|
+
i(e);
|
|
417
|
+
} catch (o) {
|
|
418
|
+
(s = globalThis.reportError) == null || s.call(globalThis, o);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function ct() {
|
|
422
|
+
return at();
|
|
423
|
+
}
|
|
424
|
+
function Qt(e, t = !1) {
|
|
425
|
+
var n;
|
|
426
|
+
return e.src.kind === "image" && !((n = e.src.editInfo) != null && n.requiresOriginal) && e.meta.editable === (e.src.media ? t ? "frame" : null : "full");
|
|
427
|
+
}
|
|
428
|
+
const ne = 4294967295, Zt = (e) => e.startsWith("spid:") || e.startsWith("relationship:");
|
|
429
|
+
function Yt(e, t, n, r = ne) {
|
|
430
|
+
const s = e.allocation;
|
|
431
|
+
if (!s) return null;
|
|
432
|
+
const i = s.ranges[t];
|
|
433
|
+
if (i) {
|
|
434
|
+
if (Zt(t)) {
|
|
435
|
+
if (i.base !== s.slot + 1 || i.maximum !== ne || i.step !== s.count || i.end !== ne + 1 || (i.next - i.base) % s.count !== 0)
|
|
436
|
+
throw new Error(`身份范围 ${t} 与当前副本分区不匹配`);
|
|
437
|
+
return i;
|
|
438
|
+
}
|
|
439
|
+
const f = Math.floor((r - i.base + 1) / s.count), u = i.base + s.slot * f, d = s.slot === s.count - 1 ? r + 1 : u + f;
|
|
440
|
+
if (i.maximum !== r || i.step !== 1 || i.end !== d || i.next < u || i.next > d)
|
|
441
|
+
throw new Error(`身份范围 ${t} 与当前副本分区不匹配`);
|
|
442
|
+
return i;
|
|
443
|
+
}
|
|
444
|
+
if (!Number.isSafeInteger(n) || n <= 0 || n > r)
|
|
445
|
+
throw new Error(`身份范围 ${t} 已耗尽`);
|
|
446
|
+
const o = Math.floor((r - n + 1) / s.count);
|
|
447
|
+
if (o < 1) throw new Error(`身份范围 ${t} 无法容纳协同副本`);
|
|
448
|
+
const a = n + s.slot * o, c = s.slot === s.count - 1 ? r + 1 : a + o;
|
|
449
|
+
return s.ranges[t] = { base: n, maximum: r, next: a, end: c, step: 1 };
|
|
450
|
+
}
|
|
451
|
+
function lt(e, t, n, r = ne) {
|
|
452
|
+
const s = Yt(e, t, n, r);
|
|
453
|
+
if (!s) return null;
|
|
454
|
+
if (s.next >= s.end) throw new Error(`身份范围 ${t} 已耗尽`);
|
|
455
|
+
const i = s.next;
|
|
456
|
+
return s.next += s.step, i;
|
|
457
|
+
}
|
|
458
|
+
const ft = (e) => {
|
|
459
|
+
var t;
|
|
460
|
+
return ((t = e.allocation) == null ? void 0 : t.prefix) ?? e.prefix;
|
|
461
|
+
}, re = (e) => typeof e == "string" && !!e && e.length <= 1024 && !["__proto__", "constructor", "prototype"].includes(e);
|
|
462
|
+
function en(e) {
|
|
463
|
+
if (e === void 0) return;
|
|
464
|
+
const t = e;
|
|
465
|
+
if (!t || typeof t != "object" || Array.isArray(t) || Object.keys(t).some((n) => !["ids", "paths", "values", "prefix"].includes(n)) || !t.ids || typeof t.ids != "object" || Array.isArray(t.ids) || Object.entries(t.ids).some(([n, r]) => !re(n) || !re(r)) || typeof t.prefix != "string" || t.prefix.length > 64 || [t.paths, t.values].some((n) => !Array.isArray(n) || n.length > 32 || n.some((r) => !Array.isArray(r) || !r.length || r.length > 16 || !r.every(re))))
|
|
466
|
+
throw new Error("扩展身份映射无效");
|
|
467
|
+
}
|
|
468
|
+
const De = (e, t) => t.length <= e.length && t.every((n, r) => n === "*" || n === e[r]);
|
|
469
|
+
function He(e, t) {
|
|
470
|
+
return Object.prototype.hasOwnProperty.call(e.ids, t) ? e.ids[t] : `${e.prefix}${t}`;
|
|
471
|
+
}
|
|
472
|
+
function Ne(e, t, n) {
|
|
473
|
+
if (!e) return { path: t, value: n };
|
|
474
|
+
const r = [...t];
|
|
475
|
+
for (const s of e.paths) if (De(t, s)) {
|
|
476
|
+
const i = s.length - 1;
|
|
477
|
+
if (r[i] = He(e, t[i]), !re(r[i])) throw new Error("扩展迁移后的身份路径无效");
|
|
478
|
+
}
|
|
479
|
+
return { path: r, value: typeof n == "string" && e.values.some((s) => s.length === t.length && De(t, s)) ? He(e, n) : n };
|
|
480
|
+
}
|
|
481
|
+
function tn(e, t, n) {
|
|
482
|
+
const r = e === void 0 ? /* @__PURE__ */ Object.create(null) : structuredClone(e);
|
|
483
|
+
if (!r || typeof r != "object" || Array.isArray(r)) throw new Error("扩展迁移目标不是容器");
|
|
484
|
+
const s = (i, o) => {
|
|
485
|
+
if (!i || typeof i != "object" || Array.isArray(i)) throw new Error("扩展迁移来源不是容器");
|
|
486
|
+
for (const [a, c] of Object.entries(i)) {
|
|
487
|
+
if (c && typeof c == "object") {
|
|
488
|
+
s(c, [...o, a]);
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
const f = Ne(n, [...o, a], c);
|
|
492
|
+
let u = r;
|
|
493
|
+
for (const l of f.path.slice(0, -1)) {
|
|
494
|
+
if (u[l] ?? (u[l] = /* @__PURE__ */ Object.create(null)), !u[l] || typeof u[l] != "object" || Array.isArray(u[l])) throw new Error("扩展迁移字段冲突");
|
|
495
|
+
u = u[l];
|
|
496
|
+
}
|
|
497
|
+
const d = f.path[f.path.length - 1];
|
|
498
|
+
if (u[d] !== void 0 && u[d] !== f.value) throw new Error("扩展迁移字段冲突");
|
|
499
|
+
u[d] = f.value;
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
return t !== void 0 && s(t, []), r;
|
|
503
|
+
}
|
|
504
|
+
const J = "edit-addresses", we = (e) => typeof e == "string" && !!e && e.length <= 1024 && !["__proto__", "prototype", "constructor"].includes(e), ut = /^[a-z][a-z0-9-]{0,63}$/, ue = (e) => {
|
|
505
|
+
var t;
|
|
506
|
+
return (t = e.extensions) == null ? void 0 : t[J];
|
|
507
|
+
};
|
|
508
|
+
function G(e) {
|
|
509
|
+
if (typeof e != "string") throw new Error("扩展地址必须是序列化的纯数据");
|
|
510
|
+
const t = JSON.parse(e);
|
|
511
|
+
if (!t || typeof t != "object" || Array.isArray(t) || Object.keys(t).some((n) => !["target", "identities", "remap", "merge"].includes(n)) || !Array.isArray(t.target) || t.target.length < 4 || t.target.length > 12 || t.target[0] !== "document" || t.target[1] !== "extensions" || t.target[2] === J || t.target[2] === "edit-migrations" || !ut.test(t.target[2]) || t.target.some((n) => !we(n)) || !t.identities || typeof t.identities != "object" || Array.isArray(t.identities) || Object.entries(t.identities).some(([n, r]) => !we(n) || !we(r)) || t.merge !== void 0 && t.merge !== "equal")
|
|
512
|
+
throw new Error("扩展地址映射无效");
|
|
513
|
+
return en(t.remap), t;
|
|
514
|
+
}
|
|
515
|
+
function nn(e, t) {
|
|
516
|
+
return Object.entries(ue(e) ?? {}).flatMap(([n, r]) => {
|
|
517
|
+
if (!r || typeof r != "object" || Array.isArray(r))
|
|
518
|
+
throw new Error("扩展地址来源必须是命名空间容器");
|
|
519
|
+
return Object.entries(r).map(([s, i]) => ({
|
|
520
|
+
op: "set",
|
|
521
|
+
origin: t,
|
|
522
|
+
path: ["document", "extensions", J, n, s],
|
|
523
|
+
value: i
|
|
524
|
+
}));
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function rn(e, t) {
|
|
528
|
+
var s, i;
|
|
529
|
+
if (t[0] !== "elements" || t[2] !== "ovr" || t[3] !== "extensions") return t;
|
|
530
|
+
const n = (i = (s = ue(e)) == null ? void 0 : s[t[1]]) == null ? void 0 : i[t[4]];
|
|
531
|
+
if (n === void 0) return t;
|
|
532
|
+
const r = G(n);
|
|
533
|
+
return [...r.target, ...Ne(r.remap, t.slice(5)).path];
|
|
534
|
+
}
|
|
535
|
+
function sn(e, t) {
|
|
536
|
+
const n = rn(e, t.path);
|
|
537
|
+
if (n === t.path) return t;
|
|
538
|
+
const r = G(ue(e)[t.path[1]][t.path[4]]), s = Ne(r.remap, t.path.slice(5), t.op === "set" ? t.value : void 0);
|
|
539
|
+
return { ...t, path: n, ...t.op === "set" ? { value: s.value } : {} };
|
|
540
|
+
}
|
|
541
|
+
function on(e, t) {
|
|
542
|
+
var n, r;
|
|
543
|
+
return (e.merge === "equal" || t.merge === "equal") && e.target.length === t.target.length && e.target.every((s, i) => s === t.target[i]) && (((n = e.remap) == null ? void 0 : n.prefix) ?? "") === (((r = t.remap) == null ? void 0 : r.prefix) ?? "") && Object.keys(e.identities).length === Object.keys(t.identities).length && Object.entries(e.identities).every(([s, i]) => t.identities[s] === i);
|
|
544
|
+
}
|
|
545
|
+
function ze(e, t) {
|
|
546
|
+
let n = e.extensions;
|
|
547
|
+
for (const r of t.target.slice(2)) {
|
|
548
|
+
if (n === void 0) return;
|
|
549
|
+
if (!n || typeof n != "object") throw new Error("扩展迁移目标的父路径不是容器");
|
|
550
|
+
n = n[r];
|
|
551
|
+
}
|
|
552
|
+
return n;
|
|
553
|
+
}
|
|
554
|
+
function an(e, t) {
|
|
555
|
+
var s, i, o, a;
|
|
556
|
+
if (t.op !== "set" || t.path.length !== 5 || !ut.test(t.path[4]))
|
|
557
|
+
throw new Error("扩展地址只接受不可变的映射声明");
|
|
558
|
+
const n = G(t.value), r = (i = (s = ue(e)) == null ? void 0 : s[t.path[3]]) == null ? void 0 : i[t.path[4]];
|
|
559
|
+
if (r !== void 0 && r !== t.value) throw new Error("扩展地址不能重新指向其他数据");
|
|
560
|
+
if (r === void 0) {
|
|
561
|
+
if (n.merge === "equal")
|
|
562
|
+
tn(ze(e, n), (a = (o = e.elements[t.path[3]]) == null ? void 0 : o.ovr.extensions) == null ? void 0 : a[t.path[4]], n.remap);
|
|
563
|
+
else if (ze(e, n) !== void 0)
|
|
564
|
+
throw new Error("扩展迁移目标已存在,不能覆盖其字段与时钟");
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
function cn(e) {
|
|
568
|
+
const t = { children: /* @__PURE__ */ new Map() };
|
|
569
|
+
for (const n of nn(e, "validate")) {
|
|
570
|
+
an(e, n);
|
|
571
|
+
const r = G(n.op === "set" ? n.value : void 0);
|
|
572
|
+
let s = t;
|
|
573
|
+
for (const i of r.target) {
|
|
574
|
+
if (s.terminal) throw new Error("扩展迁移目标不能重叠");
|
|
575
|
+
let o = s.children.get(i);
|
|
576
|
+
o || s.children.set(i, o = { children: /* @__PURE__ */ new Map() }), s = o;
|
|
577
|
+
}
|
|
578
|
+
if (s.terminal && !on(s.terminal, r) || s.children.size) throw new Error("扩展迁移目标不能重叠");
|
|
579
|
+
s.terminal = r;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
const Ue = 1e4;
|
|
583
|
+
function ln(e) {
|
|
584
|
+
if (e > Ue)
|
|
585
|
+
throw new Error(`单个编辑事务不能超过 ${Ue} 个补丁`);
|
|
586
|
+
}
|
|
587
|
+
const oe = "edit-migrations", Me = (e) => typeof e == "string" && !!e && e.length <= 1024 && !["__proto__", "prototype", "constructor"].includes(e), Z = (e, t) => !!e && typeof e == "object" && !Array.isArray(e) && Object.keys(e).every((n) => t.includes(n)), O = () => {
|
|
588
|
+
throw new Error("扩展迁移凭据无效");
|
|
589
|
+
};
|
|
590
|
+
function fn(e) {
|
|
591
|
+
(typeof e != "string" || e.length > 1e6) && O();
|
|
592
|
+
const t = JSON.parse(e);
|
|
593
|
+
(!Z(t, ["version", "routes", "inputs", "winners"]) || t.version !== 1 || !Array.isArray(t.routes) || !t.routes.length || !Array.isArray(t.inputs) || !Array.isArray(t.winners)) && O(), ln(t.routes.length + t.inputs.length + 1);
|
|
594
|
+
const n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
595
|
+
let s;
|
|
596
|
+
for (const i of t.routes) {
|
|
597
|
+
(!Z(i, ["source", "address"]) || !Array.isArray(i.source) || i.source.length !== 2 || !i.source.every(Me) || !/^[a-z][a-z0-9-]{0,63}$/.test(i.source[1])) && O();
|
|
598
|
+
const o = JSON.stringify(i.source);
|
|
599
|
+
n.has(o) && O(), n.add(o);
|
|
600
|
+
const a = G(i.address), c = JSON.stringify(a.target);
|
|
601
|
+
(a.target[2] === oe || s !== void 0 && s !== c) && O(), s = c;
|
|
602
|
+
}
|
|
603
|
+
for (const i of t.inputs) {
|
|
604
|
+
(!Z(i, ["path", "op", "value", "stamp"]) || !Array.isArray(i.path) || i.path.length > 21 || !i.path.every(Me) || !(i.path[0] === "elements" && i.path[2] === "ovr" && i.path[3] === "extensions" && i.path.length >= 6 && n.has(JSON.stringify([i.path[1], i.path[4]])) || i.path[0] === "document" && i.path[1] === "extensions" && i.path.length >= 4)) && O();
|
|
605
|
+
const o = JSON.stringify(i.path);
|
|
606
|
+
r.has(o) && O(), r.add(o), i.op === "set" ? ot(i.value) : (i.op !== "del" || Object.prototype.hasOwnProperty.call(i, "value")) && O(), i.stamp !== void 0 && (!Z(i.stamp, ["clock", "replicaId"]) || !Number.isSafeInteger(i.stamp.clock) || i.stamp.clock <= 0 || typeof i.stamp.replicaId != "string" || !i.stamp.replicaId || i.stamp.replicaId.length > 128 || /[\0-\x1f\x7f]/.test(i.stamp.replicaId)) && O();
|
|
607
|
+
}
|
|
608
|
+
return (t.winners.some((i) => !Number.isSafeInteger(i) || i < 0 || i >= t.inputs.length) || new Set(t.winners).size !== t.winners.length) && O(), t;
|
|
609
|
+
}
|
|
610
|
+
function un(e, t) {
|
|
611
|
+
var s;
|
|
612
|
+
const n = /* @__PURE__ */ Object.create(null);
|
|
613
|
+
for (const i of t.routes) {
|
|
614
|
+
const o = n[s = i.source[0]] ?? (n[s] = /* @__PURE__ */ Object.create(null));
|
|
615
|
+
o[i.source[1]] = i.address;
|
|
616
|
+
}
|
|
617
|
+
const r = { ...e, extensions: { ...e.extensions, [J]: n } };
|
|
618
|
+
return t.inputs.map((i) => {
|
|
619
|
+
const o = sn(r, { ...i, origin: "migration" });
|
|
620
|
+
return {
|
|
621
|
+
path: o.path,
|
|
622
|
+
...o.op === "set" ? { op: "set", value: o.value } : { op: "del" },
|
|
623
|
+
...i.stamp ? { stamp: i.stamp } : {}
|
|
624
|
+
};
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
function dn(e, t, n) {
|
|
628
|
+
var d, l;
|
|
629
|
+
const r = n.routes.map((p) => ({
|
|
630
|
+
op: "set",
|
|
631
|
+
origin: t.origin,
|
|
632
|
+
path: ["document", "extensions", J, ...p.source],
|
|
633
|
+
value: p.address
|
|
634
|
+
})), s = G(n.routes[0].address).target;
|
|
635
|
+
(t.op !== "set" || t.path.length !== 4 || t.path[3] !== JSON.stringify(s)) && O();
|
|
636
|
+
const i = un(e, n).map(({ stamp: p, ...g }) => ({ ...g, origin: t.origin }));
|
|
637
|
+
i.some((p) => p.path.length <= s.length || s.some((g, v) => p.path[v] !== g)) && O();
|
|
638
|
+
const o = n.winners.map((p) => i[p]), a = new Set(i.map((p) => JSON.stringify(p.path)));
|
|
639
|
+
(o.length !== a.size || new Set(o.map((p) => JSON.stringify(p.path))).size !== a.size) && O();
|
|
640
|
+
for (const p of o)
|
|
641
|
+
for (let g = s.length + 1; g < p.path.length; g++)
|
|
642
|
+
if (a.has(JSON.stringify(p.path.slice(0, g)))) throw new Error("扩展迁移赢家路径冲突");
|
|
643
|
+
const c = new Set(n.inputs.map((p) => JSON.stringify(p.path))), f = /* @__PURE__ */ new Set(), u = (p, g) => {
|
|
644
|
+
if (p && typeof p == "object") {
|
|
645
|
+
(Array.isArray(p) || f.has(p) || g.length > 21) && O(), f.add(p);
|
|
646
|
+
for (const [v, x] of Object.entries(p))
|
|
647
|
+
Me(v) || O(), u(x, [...g, v]);
|
|
648
|
+
} else if (!c.has(JSON.stringify(g))) throw new Error("扩展迁移凭据缺少参与来源字段");
|
|
649
|
+
};
|
|
650
|
+
for (const { source: [p, g] } of n.routes) {
|
|
651
|
+
const v = (l = (d = e.elements[p]) == null ? void 0 : d.ovr.extensions) == null ? void 0 : l[g];
|
|
652
|
+
v !== void 0 && u(v, ["elements", p, "ovr", "extensions", g]);
|
|
653
|
+
}
|
|
654
|
+
return { routes: r, fields: o };
|
|
655
|
+
}
|
|
656
|
+
function hn(e, t) {
|
|
657
|
+
var n;
|
|
658
|
+
return Object.entries(((n = e.extensions) == null ? void 0 : n[oe]) ?? {}).map(([r, s]) => ({
|
|
659
|
+
op: "set",
|
|
660
|
+
path: ["document", "extensions", oe, r],
|
|
661
|
+
origin: t,
|
|
662
|
+
value: s
|
|
663
|
+
}));
|
|
664
|
+
}
|
|
665
|
+
function pn(e) {
|
|
666
|
+
var t, n;
|
|
667
|
+
for (const r of hn(e, "validate")) {
|
|
668
|
+
const s = fn(r.op === "set" ? r.value : void 0);
|
|
669
|
+
dn(e, r, s);
|
|
670
|
+
const i = (t = e.extensions) == null ? void 0 : t[J];
|
|
671
|
+
for (const o of s.routes)
|
|
672
|
+
((n = i == null ? void 0 : i[o.source[0]]) == null ? void 0 : n[o.source[1]]) !== o.address && O();
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
const Le = (e) => !!e && e.length <= 1024 && e !== "__proto__" && e !== "prototype" && e !== "constructor";
|
|
676
|
+
function mn(e) {
|
|
677
|
+
if (e === void 0) return;
|
|
678
|
+
const t = /* @__PURE__ */ new WeakSet(), n = (s) => {
|
|
679
|
+
if (D(s, new Set(s && typeof s == "object" ? Reflect.ownKeys(s) : []), "文档扩展容器"), t.has(s)) throw new Error("文档扩展不能包含循环或共用可变容器");
|
|
680
|
+
return t.add(s), s;
|
|
681
|
+
}, r = (s, i) => {
|
|
682
|
+
for (const [o, a] of Object.entries(n(s))) {
|
|
683
|
+
if (i >= 16 || !Le(o)) throw new Error("文档扩展路径无效");
|
|
684
|
+
if (a && typeof a == "object") r(a, i + 1);
|
|
685
|
+
else
|
|
686
|
+
try {
|
|
687
|
+
ot(a);
|
|
688
|
+
} catch {
|
|
689
|
+
throw new Error("文档扩展值必须是有界的纯数据标量");
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
for (const [s, i] of Object.entries(n(e))) {
|
|
694
|
+
if (!Le(s)) throw new Error("文档扩展命名空间无效");
|
|
695
|
+
try {
|
|
696
|
+
it(s);
|
|
697
|
+
} catch {
|
|
698
|
+
throw new Error("文档扩展命名空间无效");
|
|
699
|
+
}
|
|
700
|
+
r(i, 0);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function gn(e) {
|
|
704
|
+
mn(e.extensions), cn(e), pn(e);
|
|
705
|
+
const t = ct(), n = /* @__PURE__ */ new Set();
|
|
706
|
+
for (const r of Object.keys(e.extensions ?? {})) {
|
|
707
|
+
if (r === J || r === oe) continue;
|
|
708
|
+
const s = t.get(r);
|
|
709
|
+
if (!s) n.add(r);
|
|
710
|
+
else if (!s.validateDocumentPatch) throw new Error("保存扩展不支持文档级状态");
|
|
711
|
+
}
|
|
712
|
+
for (const r of ["elements", "slides"]) for (const s of Object.values(e[r]))
|
|
713
|
+
for (const i of Object.keys(s.ovr.extensions ?? {})) {
|
|
714
|
+
const o = t.get(i);
|
|
715
|
+
if (!o) n.add(i);
|
|
716
|
+
else if ((o.scope === "slide" ? "slides" : "elements") !== r) throw new Error("保存扩展 scope 与注册不符");
|
|
717
|
+
}
|
|
718
|
+
if (n.size) throw new Error(`保存前必须加载编辑扩展:${[...n].join("、")}`);
|
|
719
|
+
}
|
|
720
|
+
function wn(e) {
|
|
721
|
+
var r;
|
|
722
|
+
const t = e.package;
|
|
723
|
+
if (!t) throw new Error("复制资源缺少 OPC 包");
|
|
724
|
+
gn(e);
|
|
725
|
+
const n = { ...t.parts };
|
|
726
|
+
for (const s of ct().values()) (r = s.copyParts) == null || r.call(s, e, n);
|
|
727
|
+
return { ...t, parts: n };
|
|
728
|
+
}
|
|
729
|
+
const Fe = /* @__PURE__ */ new WeakMap();
|
|
730
|
+
function An(e) {
|
|
731
|
+
const t = e.package, n = Fe.get(t);
|
|
732
|
+
if (n) return new Map(n);
|
|
733
|
+
const r = /* @__PURE__ */ new Map();
|
|
734
|
+
for (const [s, i] of Object.entries(t.parts))
|
|
735
|
+
s.startsWith("ppt/media/") && r.set(B(i), s);
|
|
736
|
+
return Fe.set(t, r), new Map(r);
|
|
737
|
+
}
|
|
738
|
+
function dt(e, t) {
|
|
739
|
+
const n = Object.values(e.elements).flatMap((s) => {
|
|
740
|
+
var u;
|
|
741
|
+
if (t !== void 0 && ((u = s.meta.origin) == null ? void 0 : u.part) !== t) return [];
|
|
742
|
+
const i = s.meta.insertion ? [s.meta.insertion] : [], o = s.meta.imageReplacement, a = o && e.imageResources[o.resourceHash], f = [
|
|
743
|
+
s.ovr.text,
|
|
744
|
+
...Object.values(s.ovr.tableCells ?? {}).map((d) => d.text)
|
|
745
|
+
].flatMap((d) => (d == null ? void 0 : d.kind) === "flat" ? d.paragraphs.flatMap((l) => {
|
|
746
|
+
const p = l.bulletImageOverride, g = p && e.imageResources[p.resourceHash];
|
|
747
|
+
return p && g ? [{
|
|
748
|
+
relationships: p.relationships,
|
|
749
|
+
resources: [g]
|
|
750
|
+
}] : [];
|
|
751
|
+
}) : []);
|
|
752
|
+
return [...i, ...o && a ? [{
|
|
753
|
+
relationships: o.relationships,
|
|
754
|
+
resources: [a]
|
|
755
|
+
}] : [], ...f];
|
|
756
|
+
}), r = Object.values(e.slides).flatMap((s) => {
|
|
757
|
+
var a;
|
|
758
|
+
if (t !== void 0 && ((a = s.origin) == null ? void 0 : a.part) !== t) return [];
|
|
759
|
+
const i = s.backgroundImage, o = (i == null ? void 0 : i.resourceHashes.map((c) => e.imageResources[c]).filter(Boolean)) ?? [];
|
|
760
|
+
return i && o.length === i.resourceHashes.length ? [{ relationships: i.relationships, resources: o }] : [];
|
|
761
|
+
});
|
|
762
|
+
return [...n, ...r];
|
|
763
|
+
}
|
|
764
|
+
function vn(e, t) {
|
|
765
|
+
var i;
|
|
766
|
+
const n = /* @__PURE__ */ new Set(), r = e.package.parts[ye(t)];
|
|
767
|
+
if (r)
|
|
768
|
+
for (const o of ie(fe(r).root, { localName: "Relationship" })) {
|
|
769
|
+
const a = (i = W(o, { localName: "Id", namespaceUri: null })) == null ? void 0 : i.value;
|
|
770
|
+
a && n.add(a);
|
|
771
|
+
}
|
|
772
|
+
for (const o of dt(e, t))
|
|
773
|
+
for (const a of o.relationships ?? []) n.add(a.targetId);
|
|
774
|
+
const s = Object.values(e.slides).find((o) => {
|
|
775
|
+
var a;
|
|
776
|
+
return ((a = o.origin) == null ? void 0 : a.part) === t && o.creation;
|
|
777
|
+
});
|
|
778
|
+
return s != null && s.creation && n.add(s.creation.layoutRelationshipId), n;
|
|
779
|
+
}
|
|
780
|
+
function En(e) {
|
|
781
|
+
return e.startsWith("image/") ? "image" : e.startsWith("audio/") ? "audio" : e.startsWith("video/") ? "video" : "media";
|
|
782
|
+
}
|
|
783
|
+
function xn(e) {
|
|
784
|
+
const t = /* @__PURE__ */ new Map();
|
|
785
|
+
for (const n of e) {
|
|
786
|
+
const r = /^ppt\/media\/(image|audio|video|media)(\d+)\.([a-z0-9]+)$/.exec(n);
|
|
787
|
+
if (!r) continue;
|
|
788
|
+
const s = `${r[1]}|${r[3]}`;
|
|
789
|
+
t.set(s, Math.max(t.get(s) ?? 1, Number(r[2]) + 1));
|
|
790
|
+
}
|
|
791
|
+
return (n, r) => {
|
|
792
|
+
const s = `${n}|${r}`;
|
|
793
|
+
let i = t.get(s) ?? 1, o = `ppt/media/${n}${i}.${r}`;
|
|
794
|
+
for (; e.has(o); ) o = `ppt/media/${n}${++i}.${r}`;
|
|
795
|
+
return t.set(s, i + 1), e.add(o), o;
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function yn(e) {
|
|
799
|
+
const t = [
|
|
800
|
+
...dt(e).flatMap((s) => s.resources ?? []),
|
|
801
|
+
...Object.values(e.imageResources)
|
|
802
|
+
], n = An(e), r = new Set(Object.keys(e.package.parts));
|
|
803
|
+
for (const s of t)
|
|
804
|
+
n.set(s.hash, s.targetPart), r.add(s.targetPart);
|
|
805
|
+
return { targetByHash: n, allocateMediaPart: xn(r) };
|
|
806
|
+
}
|
|
807
|
+
function ht(e, t) {
|
|
808
|
+
const n = vn(e, t), r = e.identity.allocation;
|
|
809
|
+
if (r) {
|
|
810
|
+
const i = `relationship:${t}`;
|
|
811
|
+
if (!r.ranges[i]) {
|
|
812
|
+
const o = Math.max(0, ...[...n].flatMap((f) => {
|
|
813
|
+
const u = /^rId(\d+)$/.exec(f), d = Number(u == null ? void 0 : u[1]);
|
|
814
|
+
return Number.isSafeInteger(d) && d > 0 && d <= 4294967295 ? [d] : [];
|
|
815
|
+
})), a = r.slot + 1, c = o < a ? 0 : Math.floor((o - a) / r.count) + 1;
|
|
816
|
+
r.ranges[i] = {
|
|
817
|
+
base: a,
|
|
818
|
+
maximum: 4294967295,
|
|
819
|
+
next: a + c * r.count,
|
|
820
|
+
end: 4294967296,
|
|
821
|
+
step: r.count
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
return () => {
|
|
825
|
+
let o;
|
|
826
|
+
do
|
|
827
|
+
o = `rId${lt(e.identity, i, 1)}`;
|
|
828
|
+
while (n.has(o));
|
|
829
|
+
return n.add(o), o;
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
let s = 1;
|
|
833
|
+
return () => {
|
|
834
|
+
for (; n.has(`rId${s}`); ) s++;
|
|
835
|
+
const i = `rId${s++}`;
|
|
836
|
+
return n.add(i), i;
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
function pt(e, t) {
|
|
840
|
+
const n = e.imageResources[t.hash];
|
|
841
|
+
if (n) return n.targetPart;
|
|
842
|
+
const r = e.package;
|
|
843
|
+
if (t.sourcePart) {
|
|
844
|
+
const o = r.parts[t.sourcePart], a = t.sourcePart.split(".").pop() ?? t.extension;
|
|
845
|
+
if (o && B(o) === t.hash && We(r, t.sourcePart, a) === t.mime)
|
|
846
|
+
return t.sourcePart;
|
|
847
|
+
}
|
|
848
|
+
const s = `web-ppt-${t.hash}`, i = B(new TextEncoder().encode(ft(e.identity))).slice(0, 10);
|
|
849
|
+
for (let o = 0; ; o++) {
|
|
850
|
+
const a = o === 0 ? "" : o === 1 ? `-${i}` : `-${i}-${o}`, c = `ppt/media/${s}${a}.${t.extension}`, f = Jt(r, c);
|
|
851
|
+
if (f && f !== t.mime) continue;
|
|
852
|
+
const u = r.parts[c];
|
|
853
|
+
if (!u) return c;
|
|
854
|
+
try {
|
|
855
|
+
if (B(u) === t.hash && We(r, c, t.extension) === t.mime) return c;
|
|
856
|
+
} catch {
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
function In(e, t, n, r, s) {
|
|
861
|
+
if (!e.package) throw new Error("媒体关系资源需要可写 OPC 包");
|
|
862
|
+
const i = pt(e, s), { sourcePart: o, ...a } = s, c = { ...a, targetPart: i, created: !e.package.parts[i] };
|
|
863
|
+
return {
|
|
864
|
+
relationships: [{
|
|
865
|
+
sourceId: n,
|
|
866
|
+
targetId: ht(e, t)(),
|
|
867
|
+
type: r,
|
|
868
|
+
target: Ie(t, i)
|
|
869
|
+
}],
|
|
870
|
+
resources: [c]
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
function Mn(e, t, n, r, s = {}) {
|
|
874
|
+
var d;
|
|
875
|
+
if (!e.package) throw new Error("粘贴关系资源需要可写 OPC 包");
|
|
876
|
+
const i = /* @__PURE__ */ new Map();
|
|
877
|
+
for (const l of t.resources) {
|
|
878
|
+
if (!l || !/^[0-9a-f]{64}$/.test(l.hash) || typeof l.mime != "string" || !l.mime || !/^[a-z0-9]+$/.test(l.extension) || typeof l.bytes != "string")
|
|
879
|
+
throw new Error("剪贴板资源描述无效");
|
|
880
|
+
if (i.has(l.hash)) throw new Error(`剪贴板资源哈希重复:${l.hash}`);
|
|
881
|
+
if (!((d = s.preverifiedResourceHashes) != null && d.has(l.hash))) {
|
|
882
|
+
let p;
|
|
883
|
+
try {
|
|
884
|
+
p = Qe(l.bytes);
|
|
885
|
+
} catch {
|
|
886
|
+
throw new Error("剪贴板资源不是有效 Base64");
|
|
887
|
+
}
|
|
888
|
+
if (B(p) !== l.hash) throw new Error(`剪贴板资源哈希不匹配:${l.hash}`);
|
|
889
|
+
}
|
|
890
|
+
i.set(l.hash, {
|
|
891
|
+
...l,
|
|
892
|
+
targetPart: "",
|
|
893
|
+
created: !1
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
const { targetByHash: o, allocateMediaPart: a } = yn(e), c = ht(e, r), f = /* @__PURE__ */ new Map();
|
|
897
|
+
let u;
|
|
898
|
+
for (const l of n) {
|
|
899
|
+
const p = t.ooxml.roots[l].relationships ?? [], g = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), x = [], m = [];
|
|
900
|
+
for (const h of p) {
|
|
901
|
+
if (!h || typeof h.sourceId != "string" || !h.sourceId || typeof h.type != "string" || !h.type || g.has(h.sourceId))
|
|
902
|
+
throw new Error(`剪贴板根 ${l} 的关系描述无效`);
|
|
903
|
+
g.add(h.sourceId);
|
|
904
|
+
const E = c();
|
|
905
|
+
if (h.targetMode === "External") {
|
|
906
|
+
if (typeof h.target != "string" || !h.target || h.resourceHash || h.packageTarget)
|
|
907
|
+
throw new Error(`剪贴板外部关系无效:${h.sourceId}`);
|
|
908
|
+
m.push({
|
|
909
|
+
sourceId: h.sourceId,
|
|
910
|
+
targetId: E,
|
|
911
|
+
type: h.type,
|
|
912
|
+
target: h.target,
|
|
913
|
+
targetMode: "External"
|
|
914
|
+
});
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
if (h.packageTarget) {
|
|
918
|
+
const C = h.packageTarget;
|
|
919
|
+
if (h.resourceHash || h.target || h.targetMode || !/^[0-9a-f]{64}$/.test(C.rootHash) || !/^[0-9a-f]{64}$/.test(C.closureHash))
|
|
920
|
+
throw new Error(`剪贴板同包关系无效:${h.sourceId}`);
|
|
921
|
+
const T = Xt(s.sourceOnly ? e.package : u ?? (u = wn(e)), C);
|
|
922
|
+
if (!T) throw new Error(`复杂对象只能粘贴到拥有相同 OPC 闭包的文档:${h.sourceId}`);
|
|
923
|
+
m.push({
|
|
924
|
+
sourceId: h.sourceId,
|
|
925
|
+
targetId: E,
|
|
926
|
+
type: h.type,
|
|
927
|
+
target: Ie(r, T)
|
|
928
|
+
});
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
if (!h.resourceHash || h.target || h.targetMode)
|
|
932
|
+
throw new Error(`剪贴板内部关系无效:${h.sourceId}`);
|
|
933
|
+
const y = i.get(h.resourceHash);
|
|
934
|
+
if (!y) throw new Error(`剪贴板关系缺少资源:${h.resourceHash}`);
|
|
935
|
+
let I = o.get(y.hash);
|
|
936
|
+
I || (I = e.identity.allocation ? pt(e, y) : a(En(y.mime), y.extension), o.set(y.hash, I));
|
|
937
|
+
const $ = {
|
|
938
|
+
...y,
|
|
939
|
+
targetPart: I,
|
|
940
|
+
created: !e.package.parts[I]
|
|
941
|
+
};
|
|
942
|
+
v.has($.hash) || (v.add($.hash), x.push($)), m.push({
|
|
943
|
+
sourceId: h.sourceId,
|
|
944
|
+
targetId: E,
|
|
945
|
+
type: h.type,
|
|
946
|
+
target: Ie(r, I)
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
f.set(l, { relationships: m, resources: x });
|
|
950
|
+
}
|
|
951
|
+
return f;
|
|
952
|
+
}
|
|
953
|
+
const ae = (e, t, n) => n.every((r, s) => e[t + s] === r), R = (e, t, n) => [...n].every((r, s) => e[t + s] === r.charCodeAt(0)), Y = (e, t) => e[t] * 256 + e[t + 1], ce = (e, t) => e[t] + e[t + 1] * 256, Ae = (e, t) => e[t] * 16777216 + e[t + 1] * 65536 + e[t + 2] * 256 + e[t + 3], le = (e, t) => e[t] + e[t + 1] * 256 + e[t + 2] * 65536 + e[t + 3] * 16777216;
|
|
954
|
+
function Sn(e) {
|
|
955
|
+
if (e.length < 45 || !ae(e, 0, [137, 80, 78, 71, 13, 10, 26, 10])) return !1;
|
|
956
|
+
let t = 8, n = !0, r = !1;
|
|
957
|
+
for (; t + 12 <= e.length; ) {
|
|
958
|
+
const s = Ae(e, t);
|
|
959
|
+
if (s > e.length - t - 12 || n && (s !== 13 || !R(e, t + 4, "IHDR") || Ae(e, t + 8) === 0 || Ae(e, t + 12) === 0)) return !1;
|
|
960
|
+
const i = t + s + 12;
|
|
961
|
+
if (R(e, t + 4, "IDAT") && (r || (r = s > 0)), R(e, t + 4, "IEND"))
|
|
962
|
+
return r && s === 0 && i === e.length;
|
|
963
|
+
t = i, n = !1;
|
|
964
|
+
}
|
|
965
|
+
return !1;
|
|
966
|
+
}
|
|
967
|
+
function Xe(e, t) {
|
|
968
|
+
let n = t;
|
|
969
|
+
for (; n < e.length; ) {
|
|
970
|
+
const r = e[n++];
|
|
971
|
+
if (r === 0) return n;
|
|
972
|
+
if (r > e.length - n) return -1;
|
|
973
|
+
n += r;
|
|
974
|
+
}
|
|
975
|
+
return -1;
|
|
976
|
+
}
|
|
977
|
+
function On(e) {
|
|
978
|
+
if (e.length < 14 || !R(e, 0, "GIF87a") && !R(e, 0, "GIF89a") || ce(e, 6) === 0 || ce(e, 8) === 0) return !1;
|
|
979
|
+
const t = e[10];
|
|
980
|
+
let n = 13 + (t & 128 ? 3 * 2 ** ((t & 7) + 1) : 0), r = !1;
|
|
981
|
+
for (; n < e.length; ) {
|
|
982
|
+
const s = e[n++];
|
|
983
|
+
if (s === 59) return r && n === e.length;
|
|
984
|
+
if (s === 33) {
|
|
985
|
+
if (n >= e.length) return !1;
|
|
986
|
+
n = Xe(e, n + 1);
|
|
987
|
+
} else if (s === 44) {
|
|
988
|
+
if (r = !0, n + 9 > e.length) return !1;
|
|
989
|
+
const i = e[n + 8];
|
|
990
|
+
if (n += 9 + (i & 128 ? 3 * 2 ** ((i & 7) + 1) : 0), n >= e.length) return !1;
|
|
991
|
+
n = Xe(e, n + 1);
|
|
992
|
+
} else return !1;
|
|
993
|
+
if (n < 0) return !1;
|
|
994
|
+
}
|
|
995
|
+
return !1;
|
|
996
|
+
}
|
|
997
|
+
const $n = /* @__PURE__ */ new Set([
|
|
998
|
+
192,
|
|
999
|
+
193,
|
|
1000
|
+
194,
|
|
1001
|
+
195,
|
|
1002
|
+
197,
|
|
1003
|
+
198,
|
|
1004
|
+
199,
|
|
1005
|
+
201,
|
|
1006
|
+
202,
|
|
1007
|
+
203,
|
|
1008
|
+
205,
|
|
1009
|
+
206,
|
|
1010
|
+
207
|
|
1011
|
+
]);
|
|
1012
|
+
function Nn(e) {
|
|
1013
|
+
if (e.length < 12 || !ae(e, 0, [255, 216]) || !ae(e, e.length - 2, [255, 217])) return !1;
|
|
1014
|
+
let t = 2, n = !1;
|
|
1015
|
+
for (; t < e.length - 2; ) {
|
|
1016
|
+
if (e[t++] !== 255) continue;
|
|
1017
|
+
for (; e[t] === 255; ) t++;
|
|
1018
|
+
const r = e[t++];
|
|
1019
|
+
if (r === 217) break;
|
|
1020
|
+
if (r === 218) {
|
|
1021
|
+
if (t + 2 > e.length) return !1;
|
|
1022
|
+
const i = Y(e, t);
|
|
1023
|
+
return n && i >= 6 && t + i < e.length - 2;
|
|
1024
|
+
}
|
|
1025
|
+
if (r === 1 || r >= 208 && r <= 215) continue;
|
|
1026
|
+
if (t + 2 > e.length) return !1;
|
|
1027
|
+
const s = Y(e, t);
|
|
1028
|
+
if (s < 2 || t + s > e.length) return !1;
|
|
1029
|
+
if ($n.has(r)) {
|
|
1030
|
+
if (s < 7 || Y(e, t + 3) === 0 || Y(e, t + 5) === 0) return !1;
|
|
1031
|
+
n = !0;
|
|
1032
|
+
}
|
|
1033
|
+
t += s;
|
|
1034
|
+
}
|
|
1035
|
+
return n;
|
|
1036
|
+
}
|
|
1037
|
+
function mt(e, t, n, r) {
|
|
1038
|
+
return R(e, t, "VP8L") ? r < 5 || e[n] !== 47 ? !1 : le(e, n + 1) >>> 0 >>> 29 === 0 : R(e, t, "VP8 ") && r >= 10 && ae(e, n + 3, [157, 1, 42]) && (ce(e, n + 6) & 16383) > 0 && (ce(e, n + 8) & 16383) > 0;
|
|
1039
|
+
}
|
|
1040
|
+
function Pn(e, t, n) {
|
|
1041
|
+
let r = t;
|
|
1042
|
+
for (; r + 8 <= n; ) {
|
|
1043
|
+
const s = le(e, r + 4), i = r + 8 + s + (s & 1);
|
|
1044
|
+
if (i > n) return !1;
|
|
1045
|
+
if (mt(e, r, r + 8, s)) return !0;
|
|
1046
|
+
r = i;
|
|
1047
|
+
}
|
|
1048
|
+
return !1;
|
|
1049
|
+
}
|
|
1050
|
+
function kn(e) {
|
|
1051
|
+
if (e.length < 26 || !R(e, 0, "RIFF") || !R(e, 8, "WEBP") || le(e, 4) + 8 !== e.length) return !1;
|
|
1052
|
+
let t = 12, n = !1;
|
|
1053
|
+
for (; t + 8 <= e.length; ) {
|
|
1054
|
+
const r = le(e, t + 4), s = t + 8, i = s + r + (r & 1);
|
|
1055
|
+
if (i > e.length || R(e, t, "VP8X") && (t !== 12 || r !== 10)) return !1;
|
|
1056
|
+
n || (n = mt(e, t, s, r)), R(e, t, "ANMF") && (n || (n = r >= 16 && Pn(e, s + 16, s + r))), t = i;
|
|
1057
|
+
}
|
|
1058
|
+
return t === e.length && n;
|
|
1059
|
+
}
|
|
1060
|
+
const Se = {
|
|
1061
|
+
"image/png": { extension: "png", validate: Sn },
|
|
1062
|
+
"image/jpeg": { extension: "jpg", validate: Nn },
|
|
1063
|
+
"image/gif": { extension: "gif", validate: On },
|
|
1064
|
+
"image/webp": { extension: "webp", validate: kn }
|
|
1065
|
+
};
|
|
1066
|
+
function jn(e) {
|
|
1067
|
+
for (const [t, n] of Object.entries(Se))
|
|
1068
|
+
if (n.validate(e)) return t;
|
|
1069
|
+
return null;
|
|
1070
|
+
}
|
|
1071
|
+
function Cn(e, t, n = "AddImage") {
|
|
1072
|
+
if (typeof t != "string" || !Ye(Se, t))
|
|
1073
|
+
throw new Error(`${n}.mime 不支持:${String(t)}`);
|
|
1074
|
+
const r = Se[t];
|
|
1075
|
+
if (jn(e) !== t)
|
|
1076
|
+
throw new Error(`${n}.bytes 与声明格式 ${t} 不一致或容器不完整`);
|
|
1077
|
+
return { extension: r.extension };
|
|
1078
|
+
}
|
|
1079
|
+
const Rn = 5 * 1024 * 1024;
|
|
1080
|
+
function Tn(e) {
|
|
1081
|
+
return { ...e, targetPart: `ppt/media/web-ppt-${e.hash}.${e.extension}`, created: !0 };
|
|
1082
|
+
}
|
|
1083
|
+
function bn(e, t, n) {
|
|
1084
|
+
const r = t.filter((s) => !e.imageResources[s.hash]);
|
|
1085
|
+
return {
|
|
1086
|
+
forward: r.map((s) => ({ op: "set", path: ["imageResources", s.hash], value: s, origin: n })),
|
|
1087
|
+
inverse: r.map((s) => ({ op: "del", path: ["imageResources", s.hash], origin: n }))
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
function gt(e, t, n) {
|
|
1091
|
+
if (!ArrayBuffer.isView(e) || Object.prototype.toString.call(e) !== "[object Uint8Array]")
|
|
1092
|
+
throw new Error(`${t} 必须是 Uint8Array`);
|
|
1093
|
+
const r = e;
|
|
1094
|
+
if (!r.byteLength) throw new Error(`${t} 不能为空`);
|
|
1095
|
+
if (n !== void 0 && r.byteLength > n)
|
|
1096
|
+
throw new Error(`${t} 不能超过 ${n} 字节`);
|
|
1097
|
+
return new Uint8Array(r.buffer.slice(r.byteOffset, r.byteOffset + r.byteLength));
|
|
1098
|
+
}
|
|
1099
|
+
function _n(e, t, n, r) {
|
|
1100
|
+
const s = gt(e, `${n}.bytes`, r), i = Cn(s, t, n);
|
|
1101
|
+
return {
|
|
1102
|
+
hash: B(s),
|
|
1103
|
+
mime: t,
|
|
1104
|
+
extension: i.extension,
|
|
1105
|
+
bytes: qe(s)
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
const wt = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", Wn = "rIdImageReplacement";
|
|
1109
|
+
function At(e) {
|
|
1110
|
+
var t, n;
|
|
1111
|
+
return (n = (t = e.meta.insertion) == null ? void 0 : t.resources) == null ? void 0 : n.find((r) => e.src.src === `web-ppt-resource:${r.hash}` || e.src.src === `data:${r.mime};base64,${r.bytes}`);
|
|
1112
|
+
}
|
|
1113
|
+
function Bn(e, t) {
|
|
1114
|
+
var i, o;
|
|
1115
|
+
const { src: n } = t.src;
|
|
1116
|
+
if (n.startsWith("web-ppt-resource:")) return n.slice(17);
|
|
1117
|
+
const r = At(t);
|
|
1118
|
+
if (r) return r.hash;
|
|
1119
|
+
const s = (o = (i = e.package) == null ? void 0 : i.assets) == null ? void 0 : o[n];
|
|
1120
|
+
return s ? B(s.bytes) : null;
|
|
1121
|
+
}
|
|
1122
|
+
function Dn(e) {
|
|
1123
|
+
var n, r, s;
|
|
1124
|
+
if (!e.meta.insertion || !e.meta.origin) return;
|
|
1125
|
+
const t = (n = At(e)) == null ? void 0 : n.targetPart;
|
|
1126
|
+
if (t)
|
|
1127
|
+
return (s = (r = e.meta.insertion.relationships) == null ? void 0 : r.find((i) => i.type === wt && rt(e.meta.origin.part, i.target) === t)) == null ? void 0 : s.targetId;
|
|
1128
|
+
}
|
|
1129
|
+
function Hn(e, t, n, r) {
|
|
1130
|
+
var p, g, v;
|
|
1131
|
+
const s = (p = t.meta.origin) == null ? void 0 : p.part;
|
|
1132
|
+
if ((((g = t.meta.imageReplacement) == null ? void 0 : g.resourceHash) ?? Bn(e, t)) === n.hash) return { forward: [], inverse: [] };
|
|
1133
|
+
const o = s ? In(e, s, Wn, wt, n) : {
|
|
1134
|
+
relationships: [],
|
|
1135
|
+
resources: [Tn(n)]
|
|
1136
|
+
}, a = ((v = t.meta.imageReplacement) == null ? void 0 : v.suppressedRelationshipId) ?? Dn(t), c = {
|
|
1137
|
+
src: Ze(n.hash),
|
|
1138
|
+
relationships: o.relationships,
|
|
1139
|
+
resourceHash: n.hash,
|
|
1140
|
+
...a ? { suppressedRelationshipId: a } : {}
|
|
1141
|
+
}, f = ["elements", t.id, "meta", "imageReplacement"], u = {
|
|
1142
|
+
op: "set",
|
|
1143
|
+
path: f,
|
|
1144
|
+
value: structuredClone(c),
|
|
1145
|
+
origin: r
|
|
1146
|
+
}, d = t.meta.imageReplacement ? { op: "set", path: f, value: structuredClone(t.meta.imageReplacement), origin: r } : { op: "del", path: f, origin: r }, l = bn(e, o.resources, r);
|
|
1147
|
+
return {
|
|
1148
|
+
forward: [...l.forward, u],
|
|
1149
|
+
inverse: [d, ...l.inverse]
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
function zn(e) {
|
|
1153
|
+
for (; ; ) {
|
|
1154
|
+
const t = `${ft(e.identity)}e${(e.identity.nextElement++).toString(36)}`;
|
|
1155
|
+
if (!e.elements[t] && !e.slides[t]) return t;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
const Un = 9525, Ln = -2147483648, vt = 2147483647, V = (e) => Math.round(e * Un), Je = (e) => {
|
|
1159
|
+
const t = V(e);
|
|
1160
|
+
return Number.isSafeInteger(t) && t >= Ln && t <= vt;
|
|
1161
|
+
}, Ve = (e) => {
|
|
1162
|
+
const t = V(e);
|
|
1163
|
+
return Number.isSafeInteger(t) && t > 0 && t <= vt;
|
|
1164
|
+
};
|
|
1165
|
+
function Fn(e, t) {
|
|
1166
|
+
D(e, ["x", "y", "w", "h"], t);
|
|
1167
|
+
const n = e;
|
|
1168
|
+
if (!Number.isFinite(n.x) || !Number.isFinite(n.y) || !Je(n.x) || !Je(n.y) || !Number.isFinite(n.w) || n.w <= 0 || !Ve(n.w) || !Number.isFinite(n.h) || n.h <= 0 || !Ve(n.h))
|
|
1169
|
+
throw new Error(`${t} 必须是 PowerPoint 可表示的有限坐标与有限正尺寸`);
|
|
1170
|
+
}
|
|
1171
|
+
function Xn(e, t) {
|
|
1172
|
+
var r;
|
|
1173
|
+
if (e.meta.source !== "pptx" || !e.package || e.package.disposed) return null;
|
|
1174
|
+
const n = (r = t.origin) == null ? void 0 : r.part;
|
|
1175
|
+
if (!n || !e.package.parts[n] && !t.creation)
|
|
1176
|
+
throw new Error(`幻灯片 ${t.id} 缺少可写 OOXML 宿主`);
|
|
1177
|
+
return n;
|
|
1178
|
+
}
|
|
1179
|
+
function Jn(e, t) {
|
|
1180
|
+
if (e.meta.source !== "pptx" || !e.package || e.package.disposed) return null;
|
|
1181
|
+
const n = t.origin.part;
|
|
1182
|
+
if (!e.package.parts[n]) throw new Error(`版式 ${t.id} 缺少可写 OOXML 宿主`);
|
|
1183
|
+
return n;
|
|
1184
|
+
}
|
|
1185
|
+
function Vn(e, t) {
|
|
1186
|
+
if (e.meta.source !== "pptx" || !e.package || e.package.disposed) return null;
|
|
1187
|
+
const n = t.id;
|
|
1188
|
+
if (!e.package.parts[n]) throw new Error(`母版 ${t.id} 缺少可写 OOXML 宿主`);
|
|
1189
|
+
return n;
|
|
1190
|
+
}
|
|
1191
|
+
function Gn(e, t, n) {
|
|
1192
|
+
const r = t.target !== void 0, s = t.slideId !== void 0;
|
|
1193
|
+
if (r === s) throw new Error(`${n} 必须且只能指定一个画布目标`);
|
|
1194
|
+
if (t.target) {
|
|
1195
|
+
if (Vt(e, t.target), t.target.kind === "master") {
|
|
1196
|
+
const a = e.masters[t.target.id];
|
|
1197
|
+
return {
|
|
1198
|
+
kind: "master",
|
|
1199
|
+
id: a.id,
|
|
1200
|
+
children: a.children,
|
|
1201
|
+
part: Vn(e, a)
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
const o = e.layouts[t.target.id];
|
|
1205
|
+
return {
|
|
1206
|
+
kind: "layout",
|
|
1207
|
+
id: o.id,
|
|
1208
|
+
children: o.children,
|
|
1209
|
+
part: Jn(e, o)
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
const i = e.slides[t.slideId];
|
|
1213
|
+
if (!i) throw new Error(`找不到${n}目标页:${String(t.slideId)}`);
|
|
1214
|
+
return {
|
|
1215
|
+
kind: "slide",
|
|
1216
|
+
id: i.id,
|
|
1217
|
+
children: i.children,
|
|
1218
|
+
part: Xn(e, i)
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
function Kn(e) {
|
|
1222
|
+
const t = /* @__PURE__ */ new Set(), n = (r) => {
|
|
1223
|
+
if (r.localName === "cNvPr") {
|
|
1224
|
+
const s = W(r, { localName: "id", namespaceUri: null });
|
|
1225
|
+
s && t.add(s.value);
|
|
1226
|
+
}
|
|
1227
|
+
for (const s of r.children) s.type === "element" && n(s);
|
|
1228
|
+
};
|
|
1229
|
+
return n(e), [...t];
|
|
1230
|
+
}
|
|
1231
|
+
function qn(e) {
|
|
1232
|
+
var n, r;
|
|
1233
|
+
let t = ((n = e.meta.origin) == null ? void 0 : n.spid) ?? 0;
|
|
1234
|
+
for (const s of Object.values(((r = e.meta.insertion) == null ? void 0 : r.spids) ?? {})) t = Math.max(t, s);
|
|
1235
|
+
return t;
|
|
1236
|
+
}
|
|
1237
|
+
const ee = 4294967295;
|
|
1238
|
+
function Qn(e, t) {
|
|
1239
|
+
var o, a, c;
|
|
1240
|
+
const n = (o = Object.values(e.slides).find((f) => {
|
|
1241
|
+
var u;
|
|
1242
|
+
return ((u = f.origin) == null ? void 0 : u.part) === t;
|
|
1243
|
+
})) == null ? void 0 : o.creation, r = (n == null ? void 0 : n.duplicateSourcePart) ?? t, s = e.saveState.baselines[t] ?? ((a = e.package) == null ? void 0 : a.parts[t]) ?? e.saveState.baselines[r] ?? ((c = e.package) == null ? void 0 : c.parts[r]);
|
|
1244
|
+
if (!s) {
|
|
1245
|
+
if (n && !n.duplicateSourcePart) return 0;
|
|
1246
|
+
throw new Error(`无法读取元素目标 part:${t}`);
|
|
1247
|
+
}
|
|
1248
|
+
let i = 0;
|
|
1249
|
+
for (const f of Kn(fe(s).root)) {
|
|
1250
|
+
const u = Number(f);
|
|
1251
|
+
Number.isSafeInteger(u) && u >= 0 && (i = Math.max(i, u));
|
|
1252
|
+
}
|
|
1253
|
+
return i;
|
|
1254
|
+
}
|
|
1255
|
+
function Zn(e, t) {
|
|
1256
|
+
return Math.max(0, ...[...Object.values(e.elements), ...Object.values(e.removedElements)].map((n) => {
|
|
1257
|
+
var r;
|
|
1258
|
+
return ((r = n.meta.origin) == null ? void 0 : r.part) === t ? qn(n) : 0;
|
|
1259
|
+
}));
|
|
1260
|
+
}
|
|
1261
|
+
function Et(e, t) {
|
|
1262
|
+
return Math.max(Qn(e, t), Zn(e, t));
|
|
1263
|
+
}
|
|
1264
|
+
function Yn(e, t) {
|
|
1265
|
+
const n = e.identity.allocation;
|
|
1266
|
+
if (!n) return;
|
|
1267
|
+
const r = `spid:${t}`, s = n.ranges[r];
|
|
1268
|
+
if (s) {
|
|
1269
|
+
if (s.step !== n.count || s.end !== ee + 1 || (s.next - (n.slot + 1)) % n.count !== 0)
|
|
1270
|
+
throw new Error(`目标 part 的 spid 分区无效:${t}`);
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
const i = n.slot + 1, o = Et(e, t), a = o < i ? 0 : Math.floor((o - i) / n.count) + 1, c = i + a * n.count;
|
|
1274
|
+
if (!Number.isSafeInteger(c) || c > ee) throw new Error(`目标 part 的 spid 已耗尽:${t}`);
|
|
1275
|
+
n.ranges[r] = {
|
|
1276
|
+
base: i,
|
|
1277
|
+
maximum: ee,
|
|
1278
|
+
next: c,
|
|
1279
|
+
end: ee + 1,
|
|
1280
|
+
step: n.count
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
function er(e, t) {
|
|
1284
|
+
if (e.identity.allocation) {
|
|
1285
|
+
e.identity.allocation.ranges[`spid:${t}`] || Yn(e, t);
|
|
1286
|
+
const s = lt(e.identity, `spid:${t}`, 1);
|
|
1287
|
+
return e.identity.nextSpid[t] = Math.max(e.identity.nextSpid[t] ?? 1, s + 1), s;
|
|
1288
|
+
}
|
|
1289
|
+
const r = e.identity.nextSpid[t] ?? Et(e, t) + 1;
|
|
1290
|
+
if (!Number.isSafeInteger(r) || r <= 0) throw new Error(`目标 part 的 spid 已耗尽:${t}`);
|
|
1291
|
+
return e.identity.nextSpid[t] = r + 1, r;
|
|
1292
|
+
}
|
|
1293
|
+
const w = () => {
|
|
1294
|
+
throw new Error("视频不是完整的自包含 MP4 文件");
|
|
1295
|
+
}, se = (e, t) => String.fromCharCode(...e.subarray(t, t + 4));
|
|
1296
|
+
function A(e, t, n, r = 4) {
|
|
1297
|
+
const s = t.data + n;
|
|
1298
|
+
(n < 0 || s + r > t.end) && w();
|
|
1299
|
+
let i = 0;
|
|
1300
|
+
for (let o = s; o < s + r; o++) i = i * 256 + e[o];
|
|
1301
|
+
return Number.isSafeInteger(i) || w(), i;
|
|
1302
|
+
}
|
|
1303
|
+
function k(e, t = 0, n = e.length) {
|
|
1304
|
+
const r = new DataView(e.buffer, e.byteOffset, e.byteLength), s = [];
|
|
1305
|
+
for (; t < n; ) {
|
|
1306
|
+
(n - t < 8 || s.length >= 1e5) && w();
|
|
1307
|
+
let i = r.getUint32(t), o = 8;
|
|
1308
|
+
i === 1 ? (n - t < 16 && w(), i = r.getUint32(t + 8) * 2 ** 32 + r.getUint32(t + 12), o = 16) : i || (i = n - t), (!Number.isSafeInteger(i) || i < o || i > n - t) && w(), s.push({ type: se(e, t + 4), start: t, data: t + o, end: t + i }), t += i;
|
|
1309
|
+
}
|
|
1310
|
+
return s;
|
|
1311
|
+
}
|
|
1312
|
+
function S(e, t) {
|
|
1313
|
+
const n = e.filter((r) => r.type === t);
|
|
1314
|
+
return n.length !== 1 && w(), n[0];
|
|
1315
|
+
}
|
|
1316
|
+
function xt(e, t, n) {
|
|
1317
|
+
let r = 0, s = n.length;
|
|
1318
|
+
for (; r < s; ) {
|
|
1319
|
+
const o = r + s >>> 1;
|
|
1320
|
+
n[o].data <= e ? r = o + 1 : s = o;
|
|
1321
|
+
}
|
|
1322
|
+
const i = n[r - 1];
|
|
1323
|
+
(t <= 0 || !i || e + t > i.end) && w();
|
|
1324
|
+
}
|
|
1325
|
+
function tr(e, t) {
|
|
1326
|
+
const n = t.filter((a) => a.type === "stsz" || a.type === "stz2");
|
|
1327
|
+
n.length !== 1 && w();
|
|
1328
|
+
const r = n[0], s = A(e, r, 8);
|
|
1329
|
+
(A(e, r, 0) || s > e.length) && w();
|
|
1330
|
+
const i = r.type === "stsz" ? A(e, r, 4) : 0, o = r.type === "stsz" ? 32 : A(e, r, 7, 1);
|
|
1331
|
+
return (!(r.type === "stsz" ? [32] : [4, 8, 16]).includes(o) || r.end - r.data !== 12 + (i ? 0 : Math.ceil(s * o / 8))) && w(), { count: s, fixed: i, size: (a) => (a >= s && w(), i || (o === 4 ? A(e, r, 12 + Math.floor(a / 2), 1) >> (a % 2 ? 0 : 4) & 15 : A(e, r, 12 + a * o / 8, o / 8))) };
|
|
1332
|
+
}
|
|
1333
|
+
function nr(e, t, n, r) {
|
|
1334
|
+
const s = tr(e, t), i = S(t, "stts"), o = A(e, i, 4);
|
|
1335
|
+
(A(e, i, 0) || i.end - i.data !== 8 + o * 8) && w();
|
|
1336
|
+
let a = 0;
|
|
1337
|
+
for (let m = 0; m < o; m++) {
|
|
1338
|
+
const h = A(e, i, 8 + m * 8);
|
|
1339
|
+
h || w(), a += h;
|
|
1340
|
+
}
|
|
1341
|
+
a !== s.count && w();
|
|
1342
|
+
const c = t.filter((m) => m.type === "stco" || m.type === "co64");
|
|
1343
|
+
c.length !== 1 && w();
|
|
1344
|
+
const f = c[0], u = f.type === "co64" ? 8 : 4, d = A(e, f, 4);
|
|
1345
|
+
(A(e, f, 0) || f.end - f.data !== 8 + d * u) && w();
|
|
1346
|
+
const l = S(t, "stsc"), p = A(e, l, 4);
|
|
1347
|
+
if ((A(e, l, 0) || l.end - l.data !== 8 + p * 12) && w(), !s.count)
|
|
1348
|
+
return (d || p) && w(), 0;
|
|
1349
|
+
(!d || !p) && w();
|
|
1350
|
+
let g = 0, v = 0;
|
|
1351
|
+
const x = (m) => A(e, l, 8 + m * 12);
|
|
1352
|
+
for (let m = 0; m < p; m++) {
|
|
1353
|
+
const h = x(m), E = A(e, l, 16 + m * 12);
|
|
1354
|
+
((m === 0 ? h !== 1 : h <= x(m - 1)) || h > d || !E || E > r || !A(e, l, 12 + m * 12)) && w();
|
|
1355
|
+
}
|
|
1356
|
+
for (let m = 1; m <= d; m++) {
|
|
1357
|
+
g + 1 < p && m === x(g + 1) && g++;
|
|
1358
|
+
const h = A(e, l, 12 + g * 12);
|
|
1359
|
+
h > s.count - v && w();
|
|
1360
|
+
let E = h * s.fixed;
|
|
1361
|
+
s.fixed && (v += h);
|
|
1362
|
+
for (let y = 0; !s.fixed && y < h; y++) {
|
|
1363
|
+
const I = s.size(v++);
|
|
1364
|
+
I || w(), E += I;
|
|
1365
|
+
}
|
|
1366
|
+
xt(A(e, f, 8 + (m - 1) * u, u), E, n);
|
|
1367
|
+
}
|
|
1368
|
+
return v !== s.count && w(), v;
|
|
1369
|
+
}
|
|
1370
|
+
function rr(e, t, n, r) {
|
|
1371
|
+
const s = t.filter((c) => c.type === "moof");
|
|
1372
|
+
if (!s.length) return;
|
|
1373
|
+
const i = S(n, "mvex"), o = /* @__PURE__ */ new Map();
|
|
1374
|
+
for (const c of k(e, i.data, i.end).filter((f) => f.type === "trex")) {
|
|
1375
|
+
const f = A(e, c, 4), u = A(e, c, 8);
|
|
1376
|
+
(c.end - c.data !== 24 || A(e, c, 0) || o.has(f) || !r.has(f) || !u || u > r.get(f).descriptions) && w(), o.set(f, { description: u, size: A(e, c, 16) });
|
|
1377
|
+
}
|
|
1378
|
+
const a = t.filter((c) => c.type === "mdat");
|
|
1379
|
+
for (const c of s) {
|
|
1380
|
+
let f = c.start;
|
|
1381
|
+
const u = k(e, c.data, c.end).filter((d) => d.type === "traf");
|
|
1382
|
+
u.length || w();
|
|
1383
|
+
for (const d of u) {
|
|
1384
|
+
const l = k(e, d.data, d.end), p = S(l, "tfhd"), g = A(e, p, 0), v = A(e, p, 4);
|
|
1385
|
+
(g & -196668 || !r.has(v) || !o.has(v)) && w();
|
|
1386
|
+
const x = r.get(v), m = o.get(v);
|
|
1387
|
+
let h = 8;
|
|
1388
|
+
const E = (N = 4) => {
|
|
1389
|
+
const U = A(e, p, h, N);
|
|
1390
|
+
return h += N, U;
|
|
1391
|
+
}, y = g & 1 ? E(8) : g & 131072 ? c.start : f, I = g & 2 ? E() : m.description;
|
|
1392
|
+
g & 8 && E();
|
|
1393
|
+
const $ = g & 16 ? E() : m.size;
|
|
1394
|
+
g & 32 && E(), (p.end - p.data !== h || !I || I > x.descriptions) && w();
|
|
1395
|
+
const C = l.filter((N) => N.type === "trun");
|
|
1396
|
+
let T = y, z = 0;
|
|
1397
|
+
for (const N of C) {
|
|
1398
|
+
const U = A(e, N, 0), q = U >>> 24, P = U & 16777215, j = A(e, N, 4);
|
|
1399
|
+
(q > 1 || P & -3846 || j > e.length || P & 4 && P & 1024) && w();
|
|
1400
|
+
let H = 8;
|
|
1401
|
+
const M = () => {
|
|
1402
|
+
const b = A(e, N, H);
|
|
1403
|
+
return H += 4, b;
|
|
1404
|
+
};
|
|
1405
|
+
if (P & 1) {
|
|
1406
|
+
const b = M();
|
|
1407
|
+
T = y + (b > 2147483647 ? b - 2 ** 32 : b);
|
|
1408
|
+
}
|
|
1409
|
+
P & 4 && M();
|
|
1410
|
+
const L = [256, 512, 1024, 2048].filter((b) => P & b).length * 4;
|
|
1411
|
+
N.end - N.data !== H + j * L && w();
|
|
1412
|
+
let de = L ? 0 : j * $;
|
|
1413
|
+
!L && j && !$ && w();
|
|
1414
|
+
for (let b = 0; L && b < j; b++) {
|
|
1415
|
+
P & 256 && M();
|
|
1416
|
+
const Pe = P & 512 ? M() : $;
|
|
1417
|
+
Pe || w(), P & 1024 && M(), P & 2048 && M(), de += Pe;
|
|
1418
|
+
}
|
|
1419
|
+
j && xt(T, de, a), T += de, z += j;
|
|
1420
|
+
}
|
|
1421
|
+
(!C.length && !(g & 65536) || z && g & 65536) && w(), x.samples += z, f = T;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
function sr(e) {
|
|
1426
|
+
const t = k(e), n = S(t, "ftyp");
|
|
1427
|
+
(n.end - n.data < 8 || (n.end - n.data) % 4) && w();
|
|
1428
|
+
const r = /* @__PURE__ */ new Set([
|
|
1429
|
+
"isom",
|
|
1430
|
+
"iso2",
|
|
1431
|
+
"iso3",
|
|
1432
|
+
"iso4",
|
|
1433
|
+
"iso5",
|
|
1434
|
+
"iso6",
|
|
1435
|
+
"iso7",
|
|
1436
|
+
"iso8",
|
|
1437
|
+
"iso9",
|
|
1438
|
+
"mp41",
|
|
1439
|
+
"mp42",
|
|
1440
|
+
"avc1",
|
|
1441
|
+
"dash",
|
|
1442
|
+
"M4V "
|
|
1443
|
+
]);
|
|
1444
|
+
let s = r.has(se(e, n.data));
|
|
1445
|
+
for (let l = n.data + 8; l < n.end; l += 4) s || (s = r.has(se(e, l)));
|
|
1446
|
+
s || w();
|
|
1447
|
+
const i = S(t, "moov"), o = t.filter((l) => l.type === "mdat");
|
|
1448
|
+
o.some((l) => l.end > l.data) || w();
|
|
1449
|
+
const a = k(e, i.data, i.end), c = S(a, "mvhd"), f = A(e, c, 0, 1);
|
|
1450
|
+
(f > 1 || c.end - c.data < (f ? 112 : 100) || !A(e, c, f ? 20 : 12)) && w();
|
|
1451
|
+
const u = a.filter((l) => l.type === "trak");
|
|
1452
|
+
u.length || w();
|
|
1453
|
+
const d = /* @__PURE__ */ new Map();
|
|
1454
|
+
for (const l of u) {
|
|
1455
|
+
const p = k(e, l.data, l.end), g = S(p, "tkhd"), v = A(e, g, 0, 1), x = A(e, g, v === 1 ? 20 : 12);
|
|
1456
|
+
(v > 1 || g.end - g.data < (v ? 96 : 84) || !x || d.has(x)) && w();
|
|
1457
|
+
const m = S(p, "mdia"), h = k(e, m.data, m.end), E = S(h, "mdhd"), y = A(e, E, 0, 1);
|
|
1458
|
+
(y > 1 || E.end - E.data < (y ? 36 : 24) || !A(e, E, y ? 20 : 12)) && w();
|
|
1459
|
+
const I = S(h, "hdlr");
|
|
1460
|
+
I.end - I.data < 12 && w();
|
|
1461
|
+
const $ = se(e, I.data + 8) === "vide", C = S(h, "minf"), T = S(k(e, C.data, C.end), "dinf"), z = S(k(e, T.data, T.end), "dref"), N = A(e, z, 4), U = k(e, z.data + 8, z.end);
|
|
1462
|
+
(!N || N !== U.length || U.some((M) => M.type !== "url " || A(e, M, 0) !== 1 || M.end - M.data !== 4)) && w();
|
|
1463
|
+
const q = S(k(e, C.data, C.end), "stbl"), P = k(e, q.data, q.end), j = S(P, "stsd"), H = k(e, j.data + 8, j.end);
|
|
1464
|
+
(A(e, j, 0) || !H.length || H.length !== A(e, j, 4)) && w();
|
|
1465
|
+
for (const M of H) {
|
|
1466
|
+
const L = A(e, M, 6, 2);
|
|
1467
|
+
(!L || L > N || ["encv", "enca"].includes(M.type)) && w(), $ && (M.end - M.data < 78 || !A(e, M, 24, 2) || !A(e, M, 26, 2)) && w();
|
|
1468
|
+
}
|
|
1469
|
+
d.set(x, {
|
|
1470
|
+
video: $,
|
|
1471
|
+
descriptions: H.length,
|
|
1472
|
+
samples: nr(e, P, o, H.length)
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1475
|
+
rr(e, t, a, d), [...d.values()].some((l) => l.video && l.samples > 0) || w();
|
|
1476
|
+
}
|
|
1477
|
+
const Oe = 25 * 1024 * 1024, ve = (e, t, n) => String.fromCharCode(...e.subarray(t, t + n));
|
|
1478
|
+
function ir(e) {
|
|
1479
|
+
const t = () => {
|
|
1480
|
+
throw new Error("音频不是完整的 PCM WAV 文件");
|
|
1481
|
+
};
|
|
1482
|
+
(e.length < 44 || ve(e, 0, 4) !== "RIFF" || ve(e, 8, 4) !== "WAVE") && t();
|
|
1483
|
+
const n = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
1484
|
+
n.getUint32(4, !0) !== e.length - 8 && t();
|
|
1485
|
+
let r = 0, s = 0, i = 12;
|
|
1486
|
+
for (; i + 8 <= e.length; ) {
|
|
1487
|
+
const o = ve(e, i, 4), a = n.getUint32(i + 4, !0), c = i + 8, f = c + a;
|
|
1488
|
+
if (f > e.length && t(), o === "fmt ") {
|
|
1489
|
+
(r || a < 16 || n.getUint16(c, !0) !== 1) && t();
|
|
1490
|
+
const u = n.getUint16(c + 2, !0), d = n.getUint32(c + 4, !0), l = n.getUint16(c + 14, !0);
|
|
1491
|
+
r = n.getUint16(c + 12, !0), (u < 1 || u > 8 || !d || d > 192e3 || ![8, 16, 24, 32].includes(l) || r !== u * l / 8 || n.getUint32(c + 8, !0) !== d * r) && t();
|
|
1492
|
+
}
|
|
1493
|
+
o === "data" && ((s || !a) && t(), s = a), i = f + a % 2;
|
|
1494
|
+
}
|
|
1495
|
+
(i !== e.length || !r || !s || s % r) && t();
|
|
1496
|
+
}
|
|
1497
|
+
function yt(e, t) {
|
|
1498
|
+
const n = e.mime === "audio/wav" && e.extension === "wav", r = e.mime === "video/mp4" && e.extension === "mp4";
|
|
1499
|
+
if (!n && !r) return !1;
|
|
1500
|
+
if (t.length > Oe) throw new Error(`媒体不能超过 ${Oe} 字节`);
|
|
1501
|
+
return n ? ir(t) : sr(t), !0;
|
|
1502
|
+
}
|
|
1503
|
+
function or(e, t) {
|
|
1504
|
+
const n = gt(e, "AddMedia.source.bytes", Oe), r = { mime: typeof t == "string" ? t : "", extension: t === "video/mp4" ? "mp4" : "wav" };
|
|
1505
|
+
if (!yt(r, n)) throw new Error("不支持的媒体 MIME");
|
|
1506
|
+
return { ...r, bytes: qe(n), hash: B(n) };
|
|
1507
|
+
}
|
|
1508
|
+
function ar(e) {
|
|
1509
|
+
if (D(e, ["kind", "bytes", "mime", "mediaKind", "url"], "AddMedia.source"), e.kind === "embedded") {
|
|
1510
|
+
D(e, ["kind", "bytes", "mime"], "AddMedia.source");
|
|
1511
|
+
const r = or(e.bytes, e.mime);
|
|
1512
|
+
return { kind: r.mime === "video/mp4" ? "video" : "audio", resource: r };
|
|
1513
|
+
}
|
|
1514
|
+
if (D(e, ["kind", "mediaKind", "url"], "AddMedia.source"), e.kind !== "external" || !["audio", "video"].includes(e.mediaKind)) throw new Error("媒体来源无效");
|
|
1515
|
+
const t = e.url;
|
|
1516
|
+
if (typeof t != "string" || t.length > 8192 || t !== t.trim() || !/^https?:\/\//i.test(t) || /[\\\u0000-\u001f\u007f]/.test(t)) throw new Error("媒体外链 URL 无效");
|
|
1517
|
+
let n;
|
|
1518
|
+
try {
|
|
1519
|
+
n = new URL(t);
|
|
1520
|
+
} catch {
|
|
1521
|
+
throw new Error("媒体外链 URL 无效");
|
|
1522
|
+
}
|
|
1523
|
+
if (!n.hostname || n.username || n.password) throw new Error("媒体外链不能包含凭据或缺少主机");
|
|
1524
|
+
return { kind: e.mediaKind, resource: null, url: n.href };
|
|
1525
|
+
}
|
|
1526
|
+
const cr = "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAIAAABMXPacAAAC/0lEQVR42u3du24TQRQGYF6GJ+AFeAKegI6KgjotBRUlokZ0VBTUqSloKBE1oiMCIgjiIi5HGFmHSXzZmVl7nf2iv3FhW5lvZ+bMXsZXrt56J3sMAAAABAAAAQBAAAAQAAAEAAABAEAAABAAAAQAAAEAQAAAEAAABMDouXbnBMDecvTo0+nZrxt3PwDYT+v//vu3GwMA/+X60ftF6y8Nxh6LAJS59+RzNnj15seoBgAuyNPnX7NBvASwuWjp20zHL79lg5gYAKxMTJVvT35GM/UVjcEnTwYxPQDYMGR3d412X374i9ffAZQHaTRKHijGnpDjJYB/uXn/Yz48RwKIZOMxqtKDBHh8/KVo+vEAYujP0vHVswaI5shz4w4AIg+eneVv6TsbHxLA4hTNqtbfEuD2w9OKr15UWWMsCw4DYFHmr2n6LQEW53kqWnB5gqh7JzgAgGWZ3wiQG7HCYKROMHWAohBsASgmj6GL26IT9CqHpgtwvsxvBIgPzEdxxeI2v73XmmCiABeW+e1zQOPiNnfHwLi0AKvK/HaA8yPJoAM5+lB+b5fLNdMCWF/mdwEoznQOXdzm93ZZlE0IYGOZ3wsgWjx/Uayz6qbiLqNQN4CWhuv1V7e4HdQJilGofUEwU4CiEwyaCXJt1l4LzRSg6ASDBpNcC8WUAKASoLqkiRK54zQwX4Di4vugkqbjknjWAHFmtO5YztNAdAgAlQDVJU3uOoOqWADrjuXtLxXkCRxAE0BdU+axq/FuibkD5JXt9k2ZCyEATQB1TZnv4W2sROcOkOfhWBvX/b8Amhqi7hMAAAAAAIBJGIAy1EIMgFMRTsYBcDraBRkALkm6KA/AbSluzAIwx1sT3Zzr9nS3p3tAwyNKHlHykJ7HVD2m6kFtWxXYqsBmHbarsV2NDZtsWdYcW5bZtM+2lbattHGrrYttXbzD2Lzb9vVzjR9w8BMm4kd8/IyV7C4AAAAQAAAEAAABAEAAABAAAAQAAAEAQAAAEAAABAAAAQBAAACQjvkDJvM8rvLczI4AAAAASUVORK5CYII=";
|
|
1527
|
+
function It(e, t) {
|
|
1528
|
+
const n = e === void 0 && t === "audio" ? { bytes: Qe(cr), mime: "image/png" } : e;
|
|
1529
|
+
return D(n, ["bytes", "mime"], "媒体海报"), _n(n.bytes, n.mime, "媒体海报", Rn);
|
|
1530
|
+
}
|
|
1531
|
+
const lr = "http://schemas.microsoft.com/office/2007/relationships/media", fr = "http://schemas.microsoft.com/office/powerpoint/2010/main";
|
|
1532
|
+
function ur(e, t, n, r = !1) {
|
|
1533
|
+
return `<a:${e}File${` r:link="${t}"`}/><p:extLst><p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}"><p14:media r:${r ? "link" : "embed"}="${n}"/></p:ext></p:extLst>`;
|
|
1534
|
+
}
|
|
1535
|
+
const $e = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", dr = lr, Ge = {
|
|
1536
|
+
"xmlns:a": Tt,
|
|
1537
|
+
"xmlns:p": bt,
|
|
1538
|
+
"xmlns:r": $e,
|
|
1539
|
+
"xmlns:p14": fr
|
|
1540
|
+
};
|
|
1541
|
+
function hr(e, t, n, r = !1) {
|
|
1542
|
+
return `<p:pic><p:nvPicPr><p:cNvPr id="${e}" name="${n === "audio" ? "音频" : "视频"}"/><p:cNvPicPr/>
|
|
1543
|
+
<p:nvPr>${ur(n, "rIdSource", "rIdMedia", r)}</p:nvPr></p:nvPicPr>
|
|
1544
|
+
<p:blipFill><a:blip r:embed="rIdPoster"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>
|
|
1545
|
+
<p:spPr><a:xfrm><a:off x="${V(t.x)}" y="${V(t.y)}"/><a:ext cx="${V(t.w)}" cy="${V(t.h)}"/></a:xfrm>
|
|
1546
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr></p:pic>`;
|
|
1547
|
+
}
|
|
1548
|
+
function pr(e, t, n) {
|
|
1549
|
+
if (e.meta.readonly) throw new Error("只读编辑文档不能新增媒体");
|
|
1550
|
+
D(t.payload, ["type", "slideId", "rect", "source", "poster"], "媒体命令");
|
|
1551
|
+
const r = t.payload;
|
|
1552
|
+
if (r.type !== "AddMedia") throw new Error("不支持的媒体命令");
|
|
1553
|
+
if (t.id !== r.slideId) throw new Error("媒体命令的画布身份不一致");
|
|
1554
|
+
Fn(r.rect, "AddMedia.rect");
|
|
1555
|
+
const s = Gn(e, r, "新增媒体"), i = ar(r.source), { kind: o } = i, a = It(r.poster, o), c = [a, ...i.resource ? [i.resource] : []], f = zn(e), u = s.part, d = u ? er(e, u) : void 0;
|
|
1556
|
+
let l;
|
|
1557
|
+
if (u && d !== void 0) {
|
|
1558
|
+
const h = hr(d, r.rect, o, !i.resource), E = i.resource ? { resourceHash: i.resource.hash } : { target: i.url, targetMode: "External" }, y = { markup: h, namespaces: Ge, hostSpids: [String(d)], relationships: [
|
|
1559
|
+
{ sourceId: "rIdPoster", type: `${$e}/image`, resourceHash: a.hash },
|
|
1560
|
+
{ sourceId: "rIdSource", type: `${$e}/${o}`, ...E },
|
|
1561
|
+
{ sourceId: "rIdMedia", type: dr, ...E }
|
|
1562
|
+
] }, I = Mn(
|
|
1563
|
+
e,
|
|
1564
|
+
{ ooxml: { roots: { media: y } }, resources: c },
|
|
1565
|
+
["media"],
|
|
1566
|
+
u,
|
|
1567
|
+
{ preverifiedResourceHashes: new Set(c.map(($) => $.hash)) }
|
|
1568
|
+
).get("media");
|
|
1569
|
+
l = { markup: h, namespaces: Ge, spids: { [String(d)]: d }, ...I };
|
|
1570
|
+
}
|
|
1571
|
+
const p = (h) => l ? Ze(h.hash) : `data:${h.mime};base64,${h.bytes}`, g = s.children, v = g.length ? Ut(e.elements[g[g.length - 1]]) : null, x = {
|
|
1572
|
+
id: f,
|
|
1573
|
+
parent: s.id,
|
|
1574
|
+
z: kt(v, null, f),
|
|
1575
|
+
ovr: {},
|
|
1576
|
+
src: {
|
|
1577
|
+
kind: "image",
|
|
1578
|
+
...d === void 0 ? {} : { id: d },
|
|
1579
|
+
name: o === "audio" ? "音频" : "视频",
|
|
1580
|
+
...r.rect,
|
|
1581
|
+
rot: 0,
|
|
1582
|
+
flipH: !1,
|
|
1583
|
+
flipV: !1,
|
|
1584
|
+
src: p(a),
|
|
1585
|
+
crop: null,
|
|
1586
|
+
stroke: null,
|
|
1587
|
+
media: i.resource ? { kind: o, src: p(i.resource), mime: i.resource.mime } : { kind: o, src: i.url, external: !0 }
|
|
1588
|
+
},
|
|
1589
|
+
meta: { editable: "frame", created: !0, ...u && d !== void 0 ? { origin: { part: u, spid: d }, insertion: l } : {} }
|
|
1590
|
+
}, m = { root: x.id, parent: s.id, records: { [x.id]: x } };
|
|
1591
|
+
return {
|
|
1592
|
+
selection: { kind: "elements", ids: [f], enteredGroup: null },
|
|
1593
|
+
forward: [{ op: "insert", path: ["elements", x.id], value: m, origin: n }],
|
|
1594
|
+
inverse: [{ op: "remove", path: ["elements", x.id], value: m, origin: n }]
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
function mr(e, t, n) {
|
|
1598
|
+
D(t.payload, ["type", "id", "slideId", "rect", "source", "poster"], "媒体命令");
|
|
1599
|
+
const r = t.payload;
|
|
1600
|
+
if (r.type === "AddMedia") return pr(e, t, n);
|
|
1601
|
+
if (D(r, ["type", "id", "poster"], "海报替换命令"), r.type !== "ReplaceMediaPoster" || t.id !== r.id) throw new Error("海报替换命令身份无效");
|
|
1602
|
+
if (e.meta.readonly) throw new Error("只读编辑文档不能替换海报");
|
|
1603
|
+
const s = e.elements[r.id];
|
|
1604
|
+
if (!s || !Qt(s, !0) || !s.src.media)
|
|
1605
|
+
throw new Error("海报替换必须指向可编辑的媒体对象");
|
|
1606
|
+
if (s.meta.locked) throw new Error("已锁定的媒体不能替换海报");
|
|
1607
|
+
return D(r.poster, ["bytes", "mime"], "媒体海报"), Hn(
|
|
1608
|
+
e,
|
|
1609
|
+
s,
|
|
1610
|
+
It(r.poster, s.src.media.kind),
|
|
1611
|
+
n
|
|
1612
|
+
);
|
|
1613
|
+
}
|
|
1614
|
+
let Ke = !1;
|
|
1615
|
+
function gr() {
|
|
1616
|
+
Ke || (qt("media", { command: mr, validateResource: yt }), Ke = !0);
|
|
1617
|
+
}
|
|
1618
|
+
function Ar(e) {
|
|
1619
|
+
return gr(), {
|
|
1620
|
+
exec(t) {
|
|
1621
|
+
const n = t.type === "AddMedia" ? t.slideId : t.id, r = e.exec({ type: "Extension", namespace: "media", id: n, payload: t });
|
|
1622
|
+
return t.type === "AddMedia" ? r.forward.find((s) => s.op === "insert" && s.path[0] === "elements").path[1] : n;
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
export {
|
|
1627
|
+
Oe as MAX_MEDIA_BYTES,
|
|
1628
|
+
Ar as createMediaEditor,
|
|
1629
|
+
gr as registerMediaEditing
|
|
1630
|
+
};
|