@silurus/ooxml 0.88.0 → 0.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +118 -23
  2. package/THIRD_PARTY_NOTICES.md +7 -6
  3. package/dist/abort-VrnK7mdP.js +10 -0
  4. package/dist/assets/render-worker-CUOU6mL2.js +16 -0
  5. package/dist/assets/render-worker-DOqrFhSU.js +15 -0
  6. package/dist/assets/render-worker-DvWUdZUN.js +35 -0
  7. package/dist/bounded-raw-part-cache-B7JoC1CD.js +64586 -0
  8. package/dist/bundled-asset-url-E2nXURF9.js +15 -0
  9. package/dist/canvas-viewer-mechanics-DfQqRKkD.js +675 -0
  10. package/dist/cfb-guard-9QTRTg7f.js +528 -0
  11. package/dist/chart-ex.mjs +692 -688
  12. package/dist/comment-overlay-controller-B5_zGgG5.js +994 -0
  13. package/dist/comment-ui-runtime-B7ZvovcS.js +2 -0
  14. package/dist/{comment-ui-runtime-DcJOYlw-.js → comment-ui-runtime-D_sb2K6s.js} +5 -5
  15. package/dist/{comment-ui-runtime-CWGqn5Vr.js → comment-ui-runtime-Jy-3goA9.js} +5 -5
  16. package/dist/delimited-text-worker-host-CikWU6_m.js +27 -0
  17. package/dist/document-model-source-BKNrXjAL.js +249 -0
  18. package/dist/document-pull-client-CxONDGbk.js +37833 -0
  19. package/dist/document-pull-worker-AMyXYpPq.js +104 -0
  20. package/dist/docx-D91ER1_S.js +495 -0
  21. package/dist/docx-DhDnKEI6.js +3563 -0
  22. package/dist/docx-model-source-CdrSt3hF.js +98 -0
  23. package/dist/docx-source-worker.mjs +455 -0
  24. package/dist/docx.mjs +7 -7
  25. package/dist/docx_parser_bg.wasm +0 -0
  26. package/dist/drawingml-shape-ChcGZNd8.js +310 -0
  27. package/dist/duotone-ekYik4ix.js +126 -0
  28. package/dist/emf-UT6I8rVi.js +1790 -0
  29. package/dist/font-preload-demand-CdJZUMCT.js +2058 -0
  30. package/dist/grid-geometry-uQOgViJU.js +384 -0
  31. package/dist/host-layout-DVMw8hDY.js +56 -0
  32. package/dist/host-layout-measure-CCEgaC_v.js +7 -0
  33. package/dist/in-process-pull-transport-DuXcPZng.js +29 -0
  34. package/dist/index.mjs +4 -4
  35. package/dist/internal-companion.mjs +12 -0
  36. package/dist/line-distribute-CPOV6csk.js +2716 -0
  37. package/dist/math.mjs +2 -2
  38. package/dist/mathjax-stix2.js +10 -10
  39. package/dist/model-source-DJGzDtGb.js +61 -0
  40. package/dist/model-source-kz_NkZqT.js +179 -0
  41. package/dist/model-source-session-Bu9CHFHc.js +71 -0
  42. package/dist/model-source-session-CDuijwv1.js +85 -0
  43. package/dist/model-source-session-sKpNiIJI.js +58 -0
  44. package/dist/node.mjs +7 -1327
  45. package/dist/{pixel-budget-9P63Bsk5.js → pixel-budget-BpTYrepD.js} +13 -10
  46. package/dist/plot-area-frame-CaJFvZ7p.js +8502 -0
  47. package/dist/pptx-CDP9dZHe.js +2936 -0
  48. package/dist/pptx-C_uxLVKB.js +183 -0
  49. package/dist/pptx-model-source-O7LhpOjz.js +37 -0
  50. package/dist/pptx-source-worker.mjs +446 -0
  51. package/dist/pptx.mjs +8 -7
  52. package/dist/pptx_parser_bg.wasm +0 -0
  53. package/dist/presentation-model-source-tmROzteR.js +77 -0
  54. package/dist/raster-target-YQ4G6rxo.js +42 -0
  55. package/dist/region-map.mjs +114 -150
  56. package/dist/{render-D3iqVKCo.js → render-CJVglUHl.js} +3 -3
  57. package/dist/{render-worker-host-B5wQfB7U.js → render-worker-host-BseIaVvm.js} +1 -1
  58. package/dist/{render-worker-host-D4123J27.js → render-worker-host-CyxPU4JU.js} +1 -1
  59. package/dist/{render-worker-host-Di3LxLc0.js → render-worker-host-aF6aWkC0.js} +1 -1
  60. package/dist/renderer-CkGLj0CC.js +5170 -0
  61. package/dist/renderer-Czw1cCC7.js +5823 -0
  62. package/dist/resource-measurement-mXw-WjMF.js +771 -0
  63. package/dist/session-Csv9maad.js +656 -0
  64. package/dist/slide-pull-client-DRZYwBTu.js +6515 -0
  65. package/dist/three-d-BK5siJgJ.js +878 -0
  66. package/dist/three-d.mjs +960 -945
  67. package/dist/{raster-target-ojDdQizC.js → tiff-contract-C6M3QcPp.js} +1 -42
  68. package/dist/tiff.mjs +401 -248
  69. package/dist/types/chart-ex.d.ts +149 -2
  70. package/dist/types/docx.d.ts +333 -96
  71. package/dist/types/index.d.ts +566 -301
  72. package/dist/types/internal-companion.d.ts +11 -0
  73. package/dist/types/math.d.ts +1 -1
  74. package/dist/types/node.d.ts +422 -9
  75. package/dist/types/pptx.d.ts +302 -95
  76. package/dist/types/region-map.d.ts +149 -2
  77. package/dist/types/three-d.d.ts +149 -2
  78. package/dist/types/tiff.d.ts +1 -1
  79. package/dist/types/xlsx.d.ts +343 -132
  80. package/dist/wasm-loader-rlgHmcSv.js +35 -0
  81. package/dist/wasm-runtime-generation-DX4y0Ecl.js +97 -0
  82. package/dist/workbook-model-source-BTC4ISTS.js +94 -0
  83. package/dist/worker-source-I1cIYBel.js +22 -0
  84. package/dist/worker-source-SbudzjYL.js +22 -0
  85. package/dist/worker-source-UAi3GNcM.js +22 -0
  86. package/dist/worksheet-pull-client-CkHgbtyM.js +579 -0
  87. package/dist/xlsx-CpSDPAEU.js +5809 -0
  88. package/dist/xlsx-D5569TPf.js +534 -0
  89. package/dist/xlsx-model-source-DPSkjFic.js +309 -0
  90. package/dist/xlsx-source-worker.mjs +525 -0
  91. package/dist/xlsx.mjs +8 -7
  92. package/dist/xlsx_parser_bg.wasm +0 -0
  93. package/package.json +42 -16
  94. package/dist/assets/render-worker-1uPAxMZr.js +0 -31
  95. package/dist/assets/render-worker-BlvJybji.js +0 -10
  96. package/dist/assets/render-worker-CzmiJfFL.js +0 -11
  97. package/dist/bounded-raw-part-cache-Cg1BsSZQ.js +0 -119
  98. package/dist/canvas-viewer-mechanics-DbLz0rYW.js +0 -1384
  99. package/dist/cjk-fallback-bLI3z70h.js +0 -46
  100. package/dist/comment-occurrence-C8Y2uoVr.js +0 -6
  101. package/dist/comment-ui-runtime-BsK8pmUT.js +0 -2
  102. package/dist/comments-Diid5ujN.js +0 -246
  103. package/dist/delimited-text-worker-host-BVY-Ecni.js +0 -27
  104. package/dist/document-pull-client-B9PTM-pL.js +0 -27280
  105. package/dist/docx-BF9WXrYH.js +0 -3103
  106. package/dist/dom-interaction-boundary-Cnm8DSBN.js +0 -223
  107. package/dist/highlight-rect-C5hkRqUr.js +0 -13
  108. package/dist/hyperlink-Cxzhet30.js +0 -36446
  109. package/dist/line-distribute-D1WNHKz_.js +0 -1023
  110. package/dist/line-metrics-B60C86uh.js +0 -60
  111. package/dist/plot-area-frame-DLTYKHNP.js +0 -4354
  112. package/dist/pptx-DkyYBYoL.js +0 -3065
  113. package/dist/renderer-B4GZb5We.js +0 -6492
  114. package/dist/resource-measurement-SHQCbkh2.js +0 -150
  115. package/dist/session-BGq81gRQ.js +0 -743
  116. package/dist/slide-pull-client-DiPnm240.js +0 -6253
  117. package/dist/source-key-DIJG8BA0.js +0 -42
  118. package/dist/three-d-DJBl8g8M.js +0 -1162
  119. package/dist/transfer-p6iCC2R7.js +0 -6
  120. package/dist/units-BzZ0gAxs.js +0 -4
  121. package/dist/worksheet-pull-client-BM8ywvbu.js +0 -458
  122. package/dist/xlsx-C9NVjgaV.js +0 -8484
  123. /package/dist/{chunk-DmhlhrBa.js → chunk-Dy4uBu1J.js} +0 -0
  124. /package/dist/{mathjax-DoyWZbSp.js → mathjax-BhwN6ilc.js} +0 -0
  125. /package/dist/{read-only-comment-decoration-Dz7eTQ4d.js → read-only-comment-decoration-PidH0wnP.js} +0 -0
  126. /package/dist/{read-only-comment-margin-DkgzASAl.js → read-only-comment-margin-B52rDVKo.js} +0 -0
  127. /package/dist/{renderer-module-contract-D91rkYHH.js → renderer-module-contract-CWM7jv6d.js} +0 -0
  128. /package/dist/{visible-index-BgiHEc1z.js → visible-index-FeVA0mGE.js} +0 -0
@@ -0,0 +1,528 @@
1
+ import { $a as e } from "./plot-area-frame-CaJFvZ7p.js";
2
+ //#region packages/core/src/errors/cfb-read.ts
3
+ var t = [
4
+ 208,
5
+ 207,
6
+ 17,
7
+ 224,
8
+ 161,
9
+ 177,
10
+ 26,
11
+ 225
12
+ ], n = 4294967290, r = 4294967294, i = 512, a = 128, o = 4e6, s = 8e6, c = 65536, l = 1e6;
13
+ function u(e, n) {
14
+ if (e.length < i) return null;
15
+ for (let n = 0; n < t.length; n++) if (e[n] !== t[n]) return null;
16
+ let r = new DataView(e.buffer, e.byteOffset, e.byteLength), a = d(r);
17
+ if (a === null) return null;
18
+ let o = m(r, e.length, a);
19
+ if (o === null) return null;
20
+ let s = g(r, e.length, a, o, n);
21
+ if (s === null || s.target === null) return null;
22
+ let { target: c, root: l } = s;
23
+ return c.size === 0 ? new Uint8Array() : c.size < a.miniStreamCutoff ? l === null ? null : y(r, e.length, a, o, l, c) : v(r, e.length, a, o, c.startSector, c.size);
24
+ }
25
+ function d(e) {
26
+ let t = e.getUint16(30, !0);
27
+ if (t !== 9 && t !== 12) return null;
28
+ let n = e.getUint16(32, !0);
29
+ if (n !== 6) return null;
30
+ let r = 1 << t, i = 1 << n, a = e.getUint32(56, !0);
31
+ return {
32
+ sectorSize: r,
33
+ numFatSectors: e.getUint32(44, !0),
34
+ miniSectorSize: i,
35
+ miniStreamCutoff: a,
36
+ firstDirSector: e.getUint32(48, !0),
37
+ firstMiniFatSector: e.getUint32(60, !0),
38
+ firstDifatSector: e.getUint32(68, !0),
39
+ numDifatSectors: e.getUint32(72, !0)
40
+ };
41
+ }
42
+ function f(e, t) {
43
+ return (e + 1) * t;
44
+ }
45
+ function p(e) {
46
+ return e >= 0 && e <= n;
47
+ }
48
+ function m(e, t, n) {
49
+ let { sectorSize: r } = n, i = [], a = /* @__PURE__ */ new Set(), o = Math.max(0, Math.floor(t / r) - 1);
50
+ if (n.numFatSectors > o || n.numDifatSectors > o || n.numDifatSectors > l) return null;
51
+ let s = 0, c = (e) => s++ >= n.numFatSectors ? !p(e) : !p(e) || e >= o || a.has(e) ? !1 : (a.add(e), i.push(e), !0);
52
+ for (let t = 0; t < 109; t++) if (!c(e.getUint32(76 + t * 4, !0))) return null;
53
+ let u = r / 4 - 1, d = n.firstDifatSector, m = /* @__PURE__ */ new Set(), h = 0;
54
+ for (; p(d) && h < n.numDifatSectors && (h++, !m.has(d));) {
55
+ m.add(d);
56
+ let n = f(d, r);
57
+ if (n < 0 || n + r > t) return null;
58
+ for (let t = 0; t < u; t++) if (!c(e.getUint32(n + t * 4, !0))) return null;
59
+ d = e.getUint32(n + u * 4, !0);
60
+ }
61
+ return h !== n.numDifatSectors || p(d) || i.length !== n.numFatSectors ? null : i;
62
+ }
63
+ function h(e, t, n, r, i) {
64
+ let a = n / 4, o = Math.floor(i / a), s = i % a;
65
+ if (o >= r.length) return null;
66
+ let c = r[o];
67
+ if (!p(c)) return null;
68
+ let l = f(c, n) + s * 4;
69
+ return l < 0 || l + 4 > t ? null : e.getUint32(l, !0);
70
+ }
71
+ function g(e, t, n, r, i) {
72
+ let { sectorSize: s } = n, l = Math.floor(s / a);
73
+ if (l < 1) return null;
74
+ let u = null, d = null, m = /* @__PURE__ */ new Set(), g = n.firstDirSector, v = 0, y = 0;
75
+ for (; p(g);) {
76
+ if (v++ > o) return null;
77
+ if (m.has(g)) break;
78
+ m.add(g);
79
+ let n = f(g, s);
80
+ if (n < 0 || n + s > t) return null;
81
+ for (let t = 0; t < l; t++) {
82
+ if (y++ > c) return {
83
+ target: u,
84
+ root: d
85
+ };
86
+ let r = n + t * a, o = e.getUint8(r + 66);
87
+ if (o === 0) continue;
88
+ let s = e.getUint32(r + 116, !0), l = e.getUint32(r + 120, !0);
89
+ if (o === 5) {
90
+ d = {
91
+ startSector: s,
92
+ size: l
93
+ };
94
+ continue;
95
+ }
96
+ _(e, r) === i && (u = {
97
+ startSector: s,
98
+ size: l
99
+ });
100
+ }
101
+ let p = h(e, t, s, r, g);
102
+ if (p === null) break;
103
+ g = p;
104
+ }
105
+ return {
106
+ target: u,
107
+ root: d
108
+ };
109
+ }
110
+ function _(e, t) {
111
+ let n = e.getUint16(t + 64, !0);
112
+ if (n < 2 || n > 64) return "";
113
+ let r = n / 2 - 1, i = "";
114
+ for (let n = 0; n < r; n++) {
115
+ let r = e.getUint16(t + n * 2, !0);
116
+ if (r === 0) break;
117
+ i += String.fromCharCode(r);
118
+ }
119
+ return i;
120
+ }
121
+ function v(e, t, n, r, i, a) {
122
+ let { sectorSize: s } = n, c = new Uint8Array(a), l = 0, u = i, d = /* @__PURE__ */ new Set(), m = 0;
123
+ for (; p(u) && l < a;) {
124
+ if (m++ > o || d.has(u)) return null;
125
+ d.add(u);
126
+ let n = f(u, s);
127
+ if (n < 0 || n + s > t) return null;
128
+ let i = Math.min(s, a - l);
129
+ c.set(new Uint8Array(e.buffer, e.byteOffset + n, i), l), l += i;
130
+ let p = h(e, t, s, r, u);
131
+ if (p === null) return null;
132
+ u = p;
133
+ }
134
+ return l === a ? c : null;
135
+ }
136
+ function y(e, t, n, r, i, a) {
137
+ let { sectorSize: o, miniSectorSize: c } = n, l = v(e, t, n, r, i.startSector, i.size);
138
+ if (l === null) return null;
139
+ let u = new Uint8Array(a.size), d = 0, f = a.startSector, m = /* @__PURE__ */ new Set(), h = 0, g = o / 4;
140
+ for (; p(f) && d < a.size;) {
141
+ if (h++ > s || m.has(f)) return null;
142
+ m.add(f);
143
+ let i = f * c;
144
+ if (i < 0 || i + c > l.length) return null;
145
+ let o = Math.min(c, a.size - d);
146
+ u.set(l.subarray(i, i + o), d), d += o;
147
+ let p = b(e, t, n, r, g, f);
148
+ if (p === null) return null;
149
+ f = p;
150
+ }
151
+ return d === a.size ? u : null;
152
+ }
153
+ function b(e, t, n, i, a, o) {
154
+ let { sectorSize: s } = n, c = Math.floor(o / a), l = o % a, u = n.firstMiniFatSector, d = /* @__PURE__ */ new Set();
155
+ for (let n = 0; n < c; n++) {
156
+ if (!p(u) || d.has(u)) return null;
157
+ d.add(u);
158
+ let n = h(e, t, s, i, u);
159
+ if (n === null) return null;
160
+ u = n;
161
+ }
162
+ if (!p(u)) return null;
163
+ let m = f(u, s) + l * 4;
164
+ if (m < 0 || m + 4 > t) return null;
165
+ let g = e.getUint32(m, !0);
166
+ return g === r ? r : g;
167
+ }
168
+ //#endregion
169
+ //#region packages/core/src/errors/cfb-sniff.ts
170
+ var x = [
171
+ 208,
172
+ 207,
173
+ 17,
174
+ 224,
175
+ 161,
176
+ 177,
177
+ 26,
178
+ 225
179
+ ], S = 4294967290, C = 512, w = 128, T = 4096, E = 8192, ee = new Set([
180
+ "WordDocument",
181
+ "Workbook",
182
+ "Book",
183
+ "PowerPoint Document"
184
+ ]), D = "EncryptionInfo";
185
+ function O(e) {
186
+ if (e.length < C) return null;
187
+ for (let t = 0; t < x.length; t++) if (e[t] !== x[t]) return null;
188
+ let t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = t.getUint16(30, !0);
189
+ if (n !== 9 && n !== 12) return "cfb-unknown";
190
+ let r = 1 << n, i = t.getUint32(48, !0), a = {
191
+ sectorSize: r,
192
+ numFatSectors: t.getUint32(44, !0),
193
+ firstDifatSector: t.getUint32(68, !0),
194
+ numDifatSectors: t.getUint32(72, !0)
195
+ }, o = m(t, e.length, a);
196
+ if (o === null) return "cfb-unknown";
197
+ let s = k(t, e.length, r, i, o);
198
+ if (s === null) return "cfb-unknown";
199
+ if (s.has(D)) return "encrypted";
200
+ for (let e of s) if (ee.has(e)) return "legacy-binary-format";
201
+ return "cfb-unknown";
202
+ }
203
+ function k(e, t, n, r, i) {
204
+ if (!M(r)) return null;
205
+ let a = /* @__PURE__ */ new Set(), o = Math.floor(n / w);
206
+ if (o < 1) return null;
207
+ let s = /* @__PURE__ */ new Set(), c = r, l = 0, u = 0;
208
+ for (; M(c) && !(l++ > E || s.has(c));) {
209
+ s.add(c);
210
+ let r = j(c, n);
211
+ if (r < 0 || r + n > t) return null;
212
+ for (let t = 0; t < o; t++) {
213
+ if (u++ > T) return a;
214
+ let n = A(e, r + t * w);
215
+ n && a.add(n);
216
+ }
217
+ let l = h(e, t, n, i, c);
218
+ if (l === null) break;
219
+ c = l;
220
+ }
221
+ return a;
222
+ }
223
+ function A(e, t) {
224
+ let n = e.getUint16(t + 64, !0);
225
+ if (n < 2 || n > 64) return "";
226
+ let r = n / 2 - 1, i = "";
227
+ for (let n = 0; n < r; n++) {
228
+ let r = e.getUint16(t + n * 2, !0);
229
+ if (r === 0) break;
230
+ i += String.fromCharCode(r);
231
+ }
232
+ return i;
233
+ }
234
+ function j(e, t) {
235
+ return (e + 1) * t;
236
+ }
237
+ function M(e) {
238
+ return e >= 0 && e <= S;
239
+ }
240
+ //#endregion
241
+ //#region packages/core/src/crypto/encryption-info.ts
242
+ function N(e) {
243
+ if (typeof atob == "function") {
244
+ let t = atob(e), n = new Uint8Array(t.length);
245
+ for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
246
+ return n;
247
+ }
248
+ let t = globalThis.Buffer;
249
+ if (t) return new Uint8Array(t.from(e, "base64"));
250
+ throw Error("no base64 decoder available");
251
+ }
252
+ function P(e, t, n) {
253
+ let r = RegExp(`<(?:[\\w]+:)?${t}\\b[^>]*>`).exec(e);
254
+ if (!r) return null;
255
+ let i = r[0], a = RegExp(`\\b${n}\\s*=\\s*"([^"]*)"`).exec(i);
256
+ return a ? a[1] : null;
257
+ }
258
+ function F(e) {
259
+ if (e === null) return null;
260
+ let t = Number(e);
261
+ return Number.isFinite(t) ? t : null;
262
+ }
263
+ function I(e, t) {
264
+ let n = F(P(e, t, "saltSize")), r = F(P(e, t, "blockSize")), i = F(P(e, t, "keyBits")), a = F(P(e, t, "hashSize")), o = P(e, t, "cipherAlgorithm"), s = P(e, t, "cipherChaining"), c = P(e, t, "hashAlgorithm"), l = P(e, t, "saltValue");
265
+ return n === null || r === null || i === null || a === null || !o || !s || !c || l === null ? null : {
266
+ saltSize: n,
267
+ blockSize: r,
268
+ keyBits: i,
269
+ hashSize: a,
270
+ cipherAlgorithm: o,
271
+ cipherChaining: s,
272
+ hashAlgorithm: c,
273
+ saltValue: N(l)
274
+ };
275
+ }
276
+ function L(e) {
277
+ if (e.length < 8) return { kind: "unknown" };
278
+ let t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = t.getUint16(0, !0), r = t.getUint16(2, !0);
279
+ if (n === 4 && r === 4) {
280
+ let t = te(e.subarray(8));
281
+ return t ? {
282
+ kind: "agile",
283
+ descriptor: t
284
+ } : { kind: "unknown" };
285
+ }
286
+ return r === 16 && (n === 3 || n === 4) ? { kind: "extensible" } : r === 2 && (n === 2 || n === 3 || n === 4) ? { kind: "standard" } : { kind: "unknown" };
287
+ }
288
+ function te(e) {
289
+ let t = new TextDecoder("utf-8").decode(e), n = I(t, "keyData"), r = I(t, "encryptedKey");
290
+ if (!n || !r) return null;
291
+ let i = F(P(t, "encryptedKey", "spinCount")), a = P(t, "encryptedKey", "encryptedVerifierHashInput"), o = P(t, "encryptedKey", "encryptedVerifierHashValue"), s = P(t, "encryptedKey", "encryptedKeyValue");
292
+ if (i === null || a === null || o === null || s === null) return null;
293
+ let c = {
294
+ ...r,
295
+ spinCount: i,
296
+ encryptedVerifierHashInput: N(a),
297
+ encryptedVerifierHashValue: N(o),
298
+ encryptedKeyValue: N(s)
299
+ }, l = null, u = P(t, "dataIntegrity", "encryptedHmacKey"), d = P(t, "dataIntegrity", "encryptedHmacValue");
300
+ return u !== null && d !== null && (l = {
301
+ encryptedHmacKey: N(u),
302
+ encryptedHmacValue: N(d)
303
+ }), {
304
+ keyData: n,
305
+ passwordKeyEncryptor: c,
306
+ dataIntegrity: l
307
+ };
308
+ }
309
+ //#endregion
310
+ //#region packages/core/src/crypto/agile.ts
311
+ var R = {
312
+ verifierHashInput: new Uint8Array([
313
+ 254,
314
+ 167,
315
+ 210,
316
+ 118,
317
+ 59,
318
+ 75,
319
+ 158,
320
+ 121
321
+ ]),
322
+ verifierHashValue: new Uint8Array([
323
+ 215,
324
+ 170,
325
+ 15,
326
+ 109,
327
+ 48,
328
+ 97,
329
+ 52,
330
+ 78
331
+ ]),
332
+ keyValue: new Uint8Array([
333
+ 20,
334
+ 110,
335
+ 11,
336
+ 231,
337
+ 171,
338
+ 172,
339
+ 208,
340
+ 214
341
+ ]),
342
+ hmacKey: new Uint8Array([
343
+ 95,
344
+ 178,
345
+ 173,
346
+ 1,
347
+ 12,
348
+ 185,
349
+ 225,
350
+ 246
351
+ ]),
352
+ hmacValue: new Uint8Array([
353
+ 160,
354
+ 103,
355
+ 127,
356
+ 2,
357
+ 178,
358
+ 44,
359
+ 132,
360
+ 51
361
+ ])
362
+ }, z = 54, B = 4096, V = class extends Error {
363
+ reason;
364
+ constructor(e, t) {
365
+ super(t), this.name = "AgileDecryptError", this.reason = e;
366
+ }
367
+ };
368
+ function H() {
369
+ let e = globalThis.crypto;
370
+ if (!e || !e.subtle) throw new V("unsupported-encryption", "WebCrypto (globalThis.crypto.subtle) is unavailable; cannot decrypt.");
371
+ return e.subtle;
372
+ }
373
+ function U(e) {
374
+ switch (e.toUpperCase().replace(/[-_]/g, "")) {
375
+ case "SHA512": return "SHA-512";
376
+ case "SHA384": return "SHA-384";
377
+ case "SHA256": return "SHA-256";
378
+ case "SHA1": return "SHA-1";
379
+ default: throw new V("unsupported-encryption", `Unsupported hashAlgorithm "${e}" (only SHA-1/256/384/512).`);
380
+ }
381
+ }
382
+ function W(e) {
383
+ if (e.cipherAlgorithm.toUpperCase() !== "AES") throw new V("unsupported-encryption", `Unsupported cipherAlgorithm "${e.cipherAlgorithm}" (only AES).`);
384
+ if (e.cipherChaining.toLowerCase() !== "chainingmodecbc") throw new V("unsupported-encryption", `Unsupported cipherChaining "${e.cipherChaining}" (only ChainingModeCBC).`);
385
+ if (e.keyBits !== 128 && e.keyBits !== 192 && e.keyBits !== 256) throw new V("unsupported-encryption", `Unsupported keyBits ${e.keyBits} (only 128/192/256).`);
386
+ }
387
+ function G(...e) {
388
+ let t = e.reduce((e, t) => e + t.length, 0), n = new Uint8Array(t), r = 0;
389
+ for (let t of e) n.set(t, r), r += t.length;
390
+ return n;
391
+ }
392
+ function K(e) {
393
+ let t = new Uint8Array(4);
394
+ return new DataView(t.buffer).setUint32(0, e >>> 0, !0), t;
395
+ }
396
+ function q(e) {
397
+ let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
398
+ for (let t = 0; t < e.length; t++) n.setUint16(t * 2, e.charCodeAt(t), !0);
399
+ return t;
400
+ }
401
+ async function J(e, t) {
402
+ return new Uint8Array(await H().digest(e, t));
403
+ }
404
+ function Y(e, t) {
405
+ if (e.length > t) return e.slice(0, t);
406
+ let n = new Uint8Array(t);
407
+ return n.set(e), e.length < t && n.fill(z, e.length), n;
408
+ }
409
+ async function X(e, t, n, r) {
410
+ let i = U(t.hashAlgorithm), a = await J(i, G(t.saltValue, q(e)));
411
+ for (let e = 0; e < n; e++) a = await J(i, G(K(e), a));
412
+ return Y(await J(i, G(a, r)), t.keyBits / 8);
413
+ }
414
+ async function Z(e, t, n) {
415
+ return Y(n ? await J(U(e.hashAlgorithm), G(t, n)) : t, e.blockSize);
416
+ }
417
+ async function Q(e, t, n) {
418
+ let r = t.length;
419
+ if (n.length === 0) return new Uint8Array();
420
+ if (n.length % r !== 0) throw new V("corrupt", "ciphertext length is not a multiple of the block size");
421
+ let i = await H().importKey("raw", e, { name: "AES-CBC" }, !1, ["decrypt"]), a = await H().importKey("raw", e, { name: "AES-CBC" }, !1, ["encrypt"]), o = n.subarray(n.length - r), s = ne(new Uint8Array(r).fill(r), o), c = G(n, new Uint8Array(await H().encrypt({
422
+ name: "AES-CBC",
423
+ iv: new Uint8Array(r)
424
+ }, a, s)).subarray(0, r)), l = new Uint8Array(await H().decrypt({
425
+ name: "AES-CBC",
426
+ iv: t
427
+ }, i, c));
428
+ return l.length >= n.length ? l.subarray(0, n.length) : l;
429
+ }
430
+ function ne(e, t) {
431
+ let n = new Uint8Array(e.length);
432
+ for (let r = 0; r < e.length; r++) n[r] = e[r] ^ t[r];
433
+ return n;
434
+ }
435
+ async function re(e, t) {
436
+ W(t);
437
+ let n = U(t.hashAlgorithm), r = await Q(await X(e, t, t.spinCount, R.verifierHashInput), await Z(t, t.saltValue, null), t.encryptedVerifierHashInput), i = await Q(await X(e, t, t.spinCount, R.verifierHashValue), await Z(t, t.saltValue, null), t.encryptedVerifierHashValue);
438
+ return ie((await J(n, r)).subarray(0, t.hashSize), i.subarray(0, t.hashSize));
439
+ }
440
+ function ie(e, t) {
441
+ if (e.length !== t.length) return !1;
442
+ let n = 0;
443
+ for (let r = 0; r < e.length; r++) n |= e[r] ^ t[r];
444
+ return n === 0;
445
+ }
446
+ async function ae(e, t) {
447
+ return await Q(await X(e, t, t.spinCount, R.keyValue), await Z(t, t.saltValue, null), t.encryptedKeyValue);
448
+ }
449
+ async function oe(e, t, n) {
450
+ if (W(t), e.length < 8) throw new V("corrupt", "EncryptedPackage is shorter than its size prefix");
451
+ let r = new DataView(e.buffer, e.byteOffset, e.byteLength), i = Number(r.getBigUint64(0, !0)), a = e.subarray(8);
452
+ if (i > a.length) throw new V("corrupt", "EncryptedPackage size prefix exceeds the ciphertext");
453
+ let o = n.slice(0, t.keyBits / 8), s = new Uint8Array(i), c = 0, l = 0;
454
+ for (let e = 0; e < a.length; e += B) {
455
+ let n = a.subarray(e, e + B), r = await Q(o, await Z(t, t.saltValue, K(l)), n), u = Math.min(r.length, i - c);
456
+ if (s.set(r.subarray(0, u), c), c += u, l++, c >= i) break;
457
+ }
458
+ if (c !== i) throw new V("corrupt", "decrypted output is shorter than the declared size");
459
+ return s;
460
+ }
461
+ async function $(e, t, n) {
462
+ let { keyData: r, passwordKeyEncryptor: i } = e;
463
+ if (W(r), W(i), !await re(n, i)) throw new V("invalid-password", "The supplied password is incorrect.");
464
+ return oe(t, r, await ae(n, i));
465
+ }
466
+ //#endregion
467
+ //#region packages/core/src/crypto/decrypt-ooxml.ts
468
+ var se = "EncryptionInfo", ce = "EncryptedPackage";
469
+ async function le(e, t) {
470
+ let n = u(e, se), r = u(e, ce);
471
+ if (n === null || r === null) return {
472
+ ok: !1,
473
+ reason: "corrupt"
474
+ };
475
+ let i = L(n);
476
+ if (i.kind !== "agile") return {
477
+ ok: !1,
478
+ reason: "unsupported-encryption"
479
+ };
480
+ try {
481
+ return {
482
+ ok: !0,
483
+ data: await $(i.descriptor, r, t)
484
+ };
485
+ } catch (e) {
486
+ return e instanceof V ? {
487
+ ok: !1,
488
+ reason: e.reason
489
+ } : {
490
+ ok: !1,
491
+ reason: "corrupt"
492
+ };
493
+ }
494
+ }
495
+ //#endregion
496
+ //#region packages/core/src/errors/cfb-guard.ts
497
+ function ue(t) {
498
+ let n = O(t instanceof Uint8Array ? t : new Uint8Array(t));
499
+ if (n !== null) switch (n) {
500
+ case "encrypted": throw new e("encrypted", "This file is password-protected (MS-OFFCRYPTO). Pass LoadOptions.password to decrypt it.");
501
+ case "legacy-binary-format": throw new e("legacy-binary-format", "This is a legacy binary Office file (.doc/.xls/.ppt), not OOXML.");
502
+ case "cfb-unknown": throw new e("not-ooxml", "This file is an OLE2/Compound File container, not an OOXML (ZIP) document.");
503
+ default: throw new e("not-ooxml", "This file is an OLE2/Compound File container of an unrecognised kind, not an OOXML (ZIP) document.");
504
+ }
505
+ }
506
+ async function de(t, n) {
507
+ let r = t instanceof Uint8Array ? t : new Uint8Array(t), i = O(r);
508
+ if (i === null) return r;
509
+ if (i === "encrypted") {
510
+ if (n === void 0) throw new e("encrypted", "This file is password-protected (MS-OFFCRYPTO). Pass LoadOptions.password to decrypt it.");
511
+ let t = await le(r, n);
512
+ if (t.ok) return t.data;
513
+ switch (t.reason) {
514
+ case "invalid-password": throw new e("invalid-password", "The supplied password is incorrect.");
515
+ case "unsupported-encryption": throw new e("unsupported-encryption", "This file uses an encryption scheme other than Agile ([MS-OFFCRYPTO]) that is not supported (Standard / Extensible / legacy binary encryption).");
516
+ case "corrupt": throw new e("not-ooxml", "This file is an encrypted OLE2/Compound File container but its structure could not be read.");
517
+ default: throw t.reason, new e("not-ooxml", "This encrypted file could not be decrypted.");
518
+ }
519
+ }
520
+ return ue(r), r;
521
+ }
522
+ function fe(e) {
523
+ if (e.byteOffset === 0 && e.byteLength === e.buffer.byteLength && e.buffer instanceof ArrayBuffer) return e.buffer;
524
+ let t = new Uint8Array(e.byteLength);
525
+ return t.set(e), t.buffer;
526
+ }
527
+ //#endregion
528
+ export { fe as n, de as t };