@forevka/wordcanvas 0.7.1 → 0.7.3

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 (64) hide show
  1. package/dist-lib/assets/{worker-D8rUOKfg.js → worker-CqU4Popa.js} +10903 -10736
  2. package/dist-lib/assets/worker-Cw5cYW5z.js +2418 -0
  3. package/dist-lib/blockFactory-DDCRWDnA.js +91 -0
  4. package/dist-lib/browser-BUrsjziD.js +612 -0
  5. package/dist-lib/builder.js +13 -13
  6. package/dist-lib/editorApp-CB_ZArIF.js +9566 -0
  7. package/dist-lib/export.js +4507 -4456
  8. package/dist-lib/generate-toc.js +7 -7
  9. package/dist-lib/import.js +2 -2
  10. package/dist-lib/lists-DpmgbDyt.js +110 -0
  11. package/dist-lib/measure.js +2 -2
  12. package/dist-lib/{measureHost-CMiJKdlk.js → measureHost-BlukHGwx.js} +1 -1
  13. package/dist-lib/metrics-bvGO8KDK.js +96 -0
  14. package/dist-lib/paintStyle-vT6jtWbH.js +74 -0
  15. package/dist-lib/pipeline-UryP-u7Z.js +1850 -0
  16. package/dist-lib/recalc-docx.js +2 -2
  17. package/dist-lib/recalcToc-BfXlXZik.js +3985 -0
  18. package/dist-lib/styleProps-DhqDEfvc.js +149 -0
  19. package/dist-lib/stylesheet-LTBEGkvG.js +146 -0
  20. package/dist-lib/toc-D09f4PrI.js +939 -0
  21. package/dist-lib/{webmcp-6WxRNKCc.js → webmcp-K6UZgQJ0.js} +60 -68
  22. package/dist-lib/wordcanvas-DBx2ana_.js +734 -0
  23. package/dist-lib/wordcanvas.js +4 -2
  24. package/dist-node/{chunk-CDN6WU2P.js → chunk-373K2XRY.js} +40 -22
  25. package/dist-node/chunk-373K2XRY.js.map +7 -0
  26. package/dist-node/{chunk-22JHAERT.js → chunk-3PUV3BG6.js} +235 -39
  27. package/dist-node/chunk-3PUV3BG6.js.map +7 -0
  28. package/dist-node/{chunk-4ICCHZX4.js → chunk-5RX3IHWE.js} +39 -3
  29. package/dist-node/chunk-5RX3IHWE.js.map +7 -0
  30. package/dist-node/{chunk-4PDVRJF6.js → chunk-EMY2P524.js} +32 -2
  31. package/dist-node/chunk-EMY2P524.js.map +7 -0
  32. package/dist-node/{chunk-BRAPV465.js → chunk-HWQKGDS2.js} +2 -2
  33. package/dist-node/{chunk-6AJJMHKY.js → chunk-KJV7GJ3H.js} +1 -1
  34. package/dist-node/chunk-KJV7GJ3H.js.map +7 -0
  35. package/dist-node/{chunk-RNB336F3.js → chunk-ZLLSXOO2.js} +92 -14
  36. package/dist-node/{chunk-RNB336F3.js.map → chunk-ZLLSXOO2.js.map} +2 -2
  37. package/dist-node/{engine-5FGDJD2H.js → engine-LLA6PCS5.js} +4 -4
  38. package/dist-node/export.js +89 -24
  39. package/dist-node/export.js.map +2 -2
  40. package/dist-node/generate-toc.js +6 -6
  41. package/dist-node/import.js +3 -3
  42. package/dist-node/measure.js +2 -2
  43. package/dist-node/recalc-docx.js +4 -4
  44. package/package.json +1 -1
  45. package/types/model.d.ts +46 -0
  46. package/types/wordcanvas.d.ts +493 -1
  47. package/dist-lib/assets/worker-wXuuyshQ.js +0 -2258
  48. package/dist-lib/blockFactory-CUI4Rqiq.js +0 -186
  49. package/dist-lib/browser-DkKxreJM.js +0 -1305
  50. package/dist-lib/editorApp-DLXMmtu5.js +0 -8023
  51. package/dist-lib/lists-Sc5I40JO.js +0 -110
  52. package/dist-lib/metrics-CkAo4zh8.js +0 -143
  53. package/dist-lib/pipeline-CbxmCE84.js +0 -1705
  54. package/dist-lib/recalcToc-g1hFKSNs.js +0 -3935
  55. package/dist-lib/styleProps-Db5pEkG8.js +0 -127
  56. package/dist-lib/toc-B6VpkJge.js +0 -213
  57. package/dist-lib/wordcanvas-CFqpDK0k.js +0 -125
  58. package/dist-node/chunk-22JHAERT.js.map +0 -7
  59. package/dist-node/chunk-4ICCHZX4.js.map +0 -7
  60. package/dist-node/chunk-4PDVRJF6.js.map +0 -7
  61. package/dist-node/chunk-6AJJMHKY.js.map +0 -7
  62. package/dist-node/chunk-CDN6WU2P.js.map +0 -7
  63. /package/dist-node/{chunk-BRAPV465.js.map → chunk-HWQKGDS2.js.map} +0 -0
  64. /package/dist-node/{engine-5FGDJD2H.js.map → engine-LLA6PCS5.js.map} +0 -0
@@ -1,2258 +0,0 @@
1
- const Et = (e) => e.map((n) => n.text).join("");
2
- function Ct(e, n) {
3
- return e.fontFamily === n.fontFamily && e.fontSizePx === n.fontSizePx && e.bold === n.bold && e.italic === n.italic && e.underline === n.underline && e.strikethrough === n.strikethrough && e.color === n.color && !!e.hidden == !!n.hidden && // hidden runs must never merge with visible ones
4
- (e.letterSpacingPx ?? 0) === (n.letterSpacingPx ?? 0) && e.highlightColor === n.highlightColor && e.verticalAlign === n.verticalAlign && e.link === n.link && e.footnoteRef === n.footnoteRef && // adjacent refs must never merge into one run
5
- e.sdtId === n.sdtId && // content-control boundaries survive normalization
6
- e.fieldId === n.fieldId;
7
- }
8
- function Mt(e, n) {
9
- const t = e.filter((r) => r.text.length > 0);
10
- if (t.length === 0) return [{ text: "", style: e[0]?.style ?? n }];
11
- const o = [{ ...t[0] }];
12
- for (let r = 1; r < t.length; r++) {
13
- const i = t[r], s = o[o.length - 1];
14
- Ct(s.style, i.style) ? s.text += i.text : o.push({ ...i });
15
- }
16
- return o;
17
- }
18
- function qe(e, n) {
19
- const t = [], o = [];
20
- let r = 0;
21
- for (const i of e) {
22
- const s = r + i.text.length;
23
- s <= n ? t.push(i) : r >= n ? o.push(i) : (t.push({ text: i.text.slice(0, n - r), style: i.style }), o.push({ text: i.text.slice(n - r), style: i.style })), r = s;
24
- }
25
- return [t, o];
26
- }
27
- function Ft(e, n, t) {
28
- const [, o] = qe(e, n), [r] = qe(o, t - n);
29
- return r;
30
- }
31
- function Rt(e, n = 20) {
32
- if (!e.bookmarks) return 0;
33
- const t = e.section.pageWidthPx - e.section.marginPx.left - e.section.marginPx.right;
34
- let o = 0;
35
- for (const r of e.blocks) {
36
- if (r.kind !== "paragraph" || r.style.tocEntry) continue;
37
- const i = r.runs.find((d) => d.style.link?.startsWith("#"))?.style.link?.slice(1);
38
- if (!i) continue;
39
- const s = e.bookmarks[i]?.start.blockId;
40
- if (!s) continue;
41
- const a = Et(r.runs), f = a.match(/\t\d+\s*$/);
42
- if (!f) continue;
43
- r.runs = Ft(r.runs, 0, a.length - f[0].length), r.runs.length === 0 && (r.runs = [{ text: "", style: { ...Lt } }]);
44
- const p = Math.min(9, Math.max(1, Math.round((r.style.indentLeftPx || 0) / n) + 1));
45
- r.style.tocEntry = { targetId: s, level: p }, !r.style.tabStops?.length && t > 0 && (r.style.tabStops = [{ posPx: t, align: "right", leader: "dot" }]), r.revision++, o++;
46
- }
47
- return o;
48
- }
49
- const Lt = {
50
- fontFamily: "Georgia, serif",
51
- fontSizePx: 13,
52
- bold: !1,
53
- italic: !1,
54
- underline: !1,
55
- strikethrough: !1,
56
- color: "#202124"
57
- }, Ot = /* @__PURE__ */ new Set([
58
- "TOC",
59
- "PAGE",
60
- "NUMPAGES",
61
- "PAGEREF",
62
- "HYPERLINK",
63
- "REF",
64
- "SEQ",
65
- "STYLEREF",
66
- "DATE",
67
- "TIME",
68
- "CREATEDATE",
69
- "SAVEDATE",
70
- "PRINTDATE",
71
- "EDITTIME",
72
- "FILENAME",
73
- "FILESIZE",
74
- "AUTHOR",
75
- "LASTSAVEDBY",
76
- "TITLE",
77
- "SUBJECT",
78
- "KEYWORDS",
79
- "COMMENTS",
80
- "NUMWORDS",
81
- "NUMCHARS",
82
- "TOA",
83
- "INDEX",
84
- "XE",
85
- "TC",
86
- "TA",
87
- "RD",
88
- "FORMTEXT",
89
- "FORMCHECKBOX",
90
- "FORMDROPDOWN",
91
- "SYMBOL",
92
- "QUOTE",
93
- "IF",
94
- "DOCPROPERTY",
95
- "DOCVARIABLE",
96
- "MERGEFIELD",
97
- "ADDRESSBLOCK",
98
- "GREETINGLINE",
99
- "FILLIN",
100
- "ASK",
101
- "SET",
102
- "GOTOBUTTON",
103
- "MACROBUTTON",
104
- "EQ",
105
- "LISTNUM",
106
- "BIBLIOGRAPHY",
107
- "CITATION",
108
- "SECTION",
109
- "SECTIONPAGES",
110
- "AUTONUM",
111
- "AUTONUMLGL",
112
- "AUTONUMOUT",
113
- "INCLUDETEXT",
114
- "INCLUDEPICTURE",
115
- "LINK",
116
- "NOTEREF"
117
- ]);
118
- function Nt(e) {
119
- return Ot.has(e.trim().toUpperCase());
120
- }
121
- function Bt(e) {
122
- const n = [], t = /"([^"]*)"|(\S+)/g;
123
- let o;
124
- for (; (o = t.exec(e)) !== null; ) n.push(o[1] !== void 0 ? o[1] : o[2]);
125
- return n;
126
- }
127
- function $e(e) {
128
- const n = Bt(e);
129
- return { name: n.length > 0 ? n[0].toUpperCase() : "", args: n.slice(1), raw: e };
130
- }
131
- function Dt(e) {
132
- const n = $e(e).name;
133
- return n.length > 0 && !Nt(n);
134
- }
135
- const Ht = /* @__PURE__ */ new Set(["=", "<>", "<", ">", "<=", ">="]);
136
- function Ze(e) {
137
- if (/\\\*\s*ROMAN\b/.test(e)) return "Roman";
138
- if (/\\\*\s*roman\b/.test(e)) return "roman";
139
- if (/\\\*\s*ALPHABETIC\b/.test(e)) return "Alpha";
140
- if (/\\\*\s*alphabetic\b/.test(e)) return "alpha";
141
- }
142
- function Qe(e) {
143
- return e.match(/\\@\s*"([^"]*)"/)?.[1] ?? e.match(/\\@\s*(\S+)/)?.[1];
144
- }
145
- function Ut(e, n) {
146
- switch (e.name) {
147
- case "PAGE": {
148
- const t = Ze(e.raw);
149
- return t ? { type: "PAGE", numFmt: t } : { type: "PAGE" };
150
- }
151
- case "NUMPAGES": {
152
- const t = Ze(e.raw);
153
- return t ? { type: "NUMPAGES", numFmt: t } : { type: "NUMPAGES" };
154
- }
155
- case "DATE":
156
- return { type: "DATE", format: Qe(e.raw) ?? "M/d/yyyy" };
157
- case "TIME":
158
- return { type: "TIME", format: Qe(e.raw) ?? "h:mm AM/PM" };
159
- case "IF": {
160
- const [t, o, r, i, s] = e.args;
161
- return t === void 0 || o === void 0 || r === void 0 || !Ht.has(o) ? void 0 : {
162
- type: "IF",
163
- operandA: t,
164
- op: o,
165
- operandB: r,
166
- trueRuns: [{ text: i ?? "", style: { ...n } }],
167
- falseRuns: [{ text: s ?? "", style: { ...n } }]
168
- };
169
- }
170
- default:
171
- return;
172
- }
173
- }
174
- function Re(e) {
175
- return e.replace(/&(#x[0-9a-fA-F]+|#\d+|amp|lt|gt|quot|apos);/g, function(n, t) {
176
- if (t === "amp") return "&";
177
- if (t === "lt") return "<";
178
- if (t === "gt") return ">";
179
- if (t === "quot") return '"';
180
- if (t === "apos") return "'";
181
- if (t[0] === "#") {
182
- var o = t[1] === "x" || t[1] === "X", r = parseInt(t.slice(o ? 2 : 1), o ? 16 : 10);
183
- if (!Number.isNaN(r) && r >= 0 && r <= 1114111) try {
184
- return String.fromCodePoint(r);
185
- } catch {
186
- return n;
187
- }
188
- }
189
- return n;
190
- });
191
- }
192
- function ct(e, n) {
193
- var t = (n = n || {}).pos || 0, o = !!n.keepComments, r = !!n.keepWhitespace, i = !!n.decodeEntities, s = 60, a = 62, f = 45, p = 47, d = 33, c = 63, u = 39, m = 34, S = 61, x = 91, b = 93, R = 63;
194
- function M(C) {
195
- for (var W = []; e[t]; ) if (e.charCodeAt(t) == s) {
196
- if (e.charCodeAt(t + 1) === p) {
197
- var re = t + 2;
198
- if (t = e.indexOf(">", t), e.substring(re, t).indexOf(C) == -1) {
199
- var Z = e.substring(0, t).split(`
200
- `);
201
- throw new Error(`Unexpected close tag
202
- Line: ` + (Z.length - 1) + `
203
- Column: ` + (Z[Z.length - 1].length + 1) + `
204
- Char: ` + e[t]);
205
- }
206
- return t + 1 && (t += 1), W;
207
- }
208
- if (e.charCodeAt(t + 1) === d) {
209
- if (e.charCodeAt(t + 2) == f) {
210
- const k = t;
211
- for (; t !== -1 && (e.charCodeAt(t) !== a || e.charCodeAt(t - 1) != f || e.charCodeAt(t - 2) != f || t == -1); ) t = e.indexOf(">", t + 1);
212
- t === -1 && (t = e.length), o && W.push(e.substring(k, t + 1));
213
- } else {
214
- if (e.charCodeAt(t + 2) === x && e.charCodeAt(t + 8) === x && e.substr(t + 3, 5).toLowerCase() === "cdata") {
215
- var _ = e.indexOf("]]>", t);
216
- _ == -1 ? (W.push(e.substr(t + 9)), t = e.length) : (W.push(e.substring(t + 9, _)), t = _ + 3);
217
- continue;
218
- }
219
- {
220
- const k = t + 1;
221
- t += 2;
222
- for (var l = !1; (e.charCodeAt(t) !== a || l === !0) && e[t]; ) e.charCodeAt(t) === x ? l = !0 : l === !0 && e.charCodeAt(t) === b && (l = !1), t++;
223
- W.push(e.substring(k, t));
224
- }
225
- }
226
- t++;
227
- continue;
228
- }
229
- var g = ee();
230
- W.push(g);
231
- } else {
232
- var I = N();
233
- if (r) I.length > 0 && W.push(I);
234
- else {
235
- var P = I.trim();
236
- P.length > 0 && W.push(P);
237
- }
238
- t++;
239
- }
240
- return W;
241
- }
242
- function N() {
243
- var C = t;
244
- (t = e.indexOf("<", t) - 1) === -2 && (t = e.length);
245
- var W = e.slice(C, t + 1);
246
- return i ? Re(W) : W;
247
- }
248
- var j = `\r
249
- >/= `;
250
- function K() {
251
- for (var C = t; j.indexOf(e[t]) === -1 && e[t]; ) t++;
252
- return e.slice(C, t);
253
- }
254
- var G, q = n.selfClosingTags || n.noChildNodes || ["img", "br", "input", "meta", "link", "hr"];
255
- function ee() {
256
- t++;
257
- const C = K(), W = C[0] === "?", re = t, Z = {};
258
- let _ = [];
259
- for (; e[t] && e.charCodeAt(t) !== a && (!W || e.charCodeAt(t) !== c || e.charCodeAt(t + 1) !== a); ) {
260
- var l = e.charCodeAt(t);
261
- if (l > 64 && l < 91 || l > 96 && l < 123) {
262
- for (var g = K(), I = null; e.charCodeAt(t) === 32 || e.charCodeAt(t) === 9 || e.charCodeAt(t) === 10 || e.charCodeAt(t) === 13; ) t++;
263
- if (e.charCodeAt(t) === S) {
264
- for (t++; e.charCodeAt(t) === 32 || e.charCodeAt(t) === 9 || e.charCodeAt(t) === 10 || e.charCodeAt(t) === 13; ) t++;
265
- var P = e.charCodeAt(t);
266
- if (P === u || P === m) {
267
- if (I = te(), t === -1) return { tagName: C, attributes: Z, children: _ };
268
- } else if (P && P !== a) {
269
- for (var k = t; e[t] && j.indexOf(e[t]) === -1; ) t++;
270
- I = e.slice(k, t), i && (I = Re(I));
271
- }
272
- }
273
- Z[g] = I;
274
- } else t++;
275
- }
276
- if (W) {
277
- var y = e.slice(re, t).trim();
278
- return y.length > 0 && Object.keys(Z).length === 0 && (_ = [y]), e.charCodeAt(t) === c && e.charCodeAt(t + 1) === a ? t += 2 : e.charCodeAt(t) === a && (t += 1), { tagName: C, attributes: Z, children: _ };
279
- }
280
- if (e.charCodeAt(t - 1) !== p && e.charCodeAt(t - 1) !== R) if (C == "script") {
281
- var E = t + 1;
282
- t = e.indexOf("<\/script>", t), _ = [e.slice(E, t)], t += 9;
283
- } else C == "style" ? (E = t + 1, t = e.indexOf("</style>", t), _ = [e.slice(E, t)], t += 8) : q.indexOf(C) === -1 ? (t++, _ = M(C)) : t++;
284
- else t++;
285
- return { tagName: C, attributes: Z, children: _ };
286
- }
287
- function te() {
288
- var C = e[t], W = t + 1;
289
- t = e.indexOf(C, W);
290
- var re = e.slice(W, t);
291
- return i ? Re(re) : re;
292
- }
293
- function oe() {
294
- if (!n || !n.attrName || !n.attrValue) return -1;
295
- var C = new RegExp("\\s" + n.attrName + `\\s*=['"]` + n.attrValue + `['"]`).exec(e);
296
- return C ? C.index : -1;
297
- }
298
- if (n.attrValue !== void 0) for (n.attrName = n.attrName || "id", G = []; (t = oe()) !== -1; ) (t = e.lastIndexOf("<", t)) !== -1 && G.push(ee()), e = e.substr(t), t = 0;
299
- else G = n.parseNode ? ee() : M("");
300
- return n.filter && Array.isArray(G) && (G = lt(G, n.filter)), n.simplify ? He(Array.isArray(G) ? G : [G]) : (n.setPos && typeof G == "object" && !Array.isArray(G) && (G.pos = t), G);
301
- }
302
- function He(e) {
303
- if (typeof e == "string") return He(ct(e));
304
- if (!Array.isArray(e)) throw new TypeError("simplify() expects parsed node array or XML string");
305
- var n = {};
306
- if (!e.length) return "";
307
- if (e.length === 1 && typeof e[0] == "string") return e[0];
308
- for (var t in e.forEach(function(o) {
309
- if (typeof o == "object") {
310
- n[o.tagName] || (n[o.tagName] = []);
311
- var r = He(o.children);
312
- n[o.tagName].push(r), Object.keys(o.attributes).length && typeof r == "object" && !Array.isArray(r) && (r._attributes = o.attributes);
313
- }
314
- }), n) n[t].length == 1 && (n[t] = n[t][0]);
315
- return n;
316
- }
317
- function lt(e, n, t = 0, o = "") {
318
- var r = [];
319
- return e.forEach(function(i, s) {
320
- if (typeof i == "object" && n(i, s, t, o) && r.push(i), typeof i == "object" && i.children) {
321
- var a = lt(i.children, n, t + 1, (o ? o + "." : "") + s + "." + i.tagName);
322
- r = r.concat(a);
323
- }
324
- }), r;
325
- }
326
- function Ie(e) {
327
- return typeof e == "object" && e !== null && "tagName" in e;
328
- }
329
- class pe extends Error {
330
- code;
331
- constructor(n, t) {
332
- super(t), this.name = "ImportError", this.code = n;
333
- }
334
- }
335
- class zt {
336
- list = [];
337
- seen = /* @__PURE__ */ new Set();
338
- add(n, t) {
339
- this.seen.has(n) || (this.seen.add(n), this.list.push({ code: n, message: t }));
340
- }
341
- }
342
- function ue(e, n) {
343
- try {
344
- return ct(e, { keepWhitespace: !0, decodeEntities: !0 }).filter(Ie);
345
- } catch (t) {
346
- throw new pe(
347
- "MALFORMED_XML",
348
- `Failed to parse ${n}: ${t instanceof Error ? t.message : String(t)}`
349
- );
350
- }
351
- }
352
- function de(e, n) {
353
- return e.find((t) => t.tagName === n);
354
- }
355
- function J(e) {
356
- return e.children.filter(Ie);
357
- }
358
- function h(e, n) {
359
- return e.children.find((t) => Ie(t) && t.tagName === n);
360
- }
361
- function ne(e, n) {
362
- return e.children.filter((t) => Ie(t) && t.tagName === n);
363
- }
364
- function v(e, n) {
365
- const t = e.attributes[n];
366
- return t === void 0 ? void 0 : t ?? "";
367
- }
368
- function ke(e, n) {
369
- for (const t of e.children) {
370
- if (!Ie(t)) continue;
371
- if (t.tagName === n) return t;
372
- const o = ke(t, n);
373
- if (o) return o;
374
- }
375
- }
376
- function we(e) {
377
- let n = "";
378
- for (const t of e.children) typeof t == "string" && (n += t);
379
- return n;
380
- }
381
- function se(e, n) {
382
- const t = h(e, n);
383
- return t ? v(t, "w:val") : void 0;
384
- }
385
- function ge(e) {
386
- if (!e) return;
387
- const n = v(e, "w:val");
388
- return n === void 0 ? !0 : !["0", "false", "none", "off"].includes(n);
389
- }
390
- function A(e, n) {
391
- if (!e) return;
392
- const t = v(e, n);
393
- if (t === void 0) return;
394
- const o = Number(t);
395
- return Number.isFinite(o) ? o : void 0;
396
- }
397
- const Gt = /* @__PURE__ */ new Set([
398
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",
399
- "application/vnd.ms-word.document.macroEnabled.main+xml"
400
- ]);
401
- function _t(e) {
402
- const n = de(ue(e, "[Content_Types].xml"), "Types");
403
- if (n)
404
- for (const t of J(n)) {
405
- if (t.tagName !== "Override") continue;
406
- const o = v(t, "ContentType"), r = v(t, "PartName");
407
- if (o && r && Gt.has(o))
408
- return r.replace(/^\//, "");
409
- }
410
- }
411
- const X = (e) => e / 15, jt = (e) => e * 2 / 3, Se = (e) => e / 9525, Wt = (e) => e / 240, O = (e) => Math.round(e * 100) / 100, Le = (e) => ({
412
- top: O(X(e.top)),
413
- right: O(X(e.right)),
414
- bottom: O(X(e.bottom)),
415
- left: O(X(e.left))
416
- }), $t = [
417
- ["top", "w:top"],
418
- ["left", "w:left"],
419
- ["bottom", "w:bottom"],
420
- ["right", "w:right"],
421
- ["insideH", "w:insideH"],
422
- ["insideV", "w:insideV"]
423
- ];
424
- function Xe(e) {
425
- if (!e) return;
426
- const n = {};
427
- for (const [t, o] of $t) {
428
- const r = h(e, o);
429
- if (!r) continue;
430
- const i = { val: v(r, "w:val") ?? "single" }, s = A(r, "w:sz");
431
- s !== void 0 && (i.sizeEighthPt = s);
432
- const a = v(r, "w:color");
433
- a && (i.color = a), n[t] = i;
434
- }
435
- return Object.keys(n).length > 0 ? n : void 0;
436
- }
437
- function Ve(e) {
438
- if (!e) return;
439
- const n = v(e, "w:fill");
440
- if (n && n !== "auto") return `#${n.toLowerCase()}`;
441
- const t = v(e, "w:val"), o = v(e, "w:color");
442
- if (t && t !== "clear" && t !== "nil" && o && o !== "auto")
443
- return `#${o.toLowerCase()}`;
444
- }
445
- function Xt(e, n) {
446
- return e ? n ? { ...e, ...n } : e : n;
447
- }
448
- function Vt(e, n) {
449
- const t = (f, p, d) => (
450
- // Cell edges are named directly; the table/style layers use the named edge
451
- // on the boundary and the inside edge between cells.
452
- e.cell?.[f] ?? e.table?.[d ? f : p] ?? e.style?.[d ? f : p]
453
- ), o = {}, r = Ee(t("top", "insideH", n.top));
454
- r && (o.top = r);
455
- const i = Ee(t("bottom", "insideH", n.bottom));
456
- i && (o.bottom = i);
457
- const s = Ee(t("left", "insideV", n.left));
458
- s && (o.left = s);
459
- const a = Ee(t("right", "insideV", n.right));
460
- return a && (o.right = a), o;
461
- }
462
- function Ee(e) {
463
- if (!e || e.val === "nil" || e.val === "none") return;
464
- const n = O(Math.max(0.5, (e.sizeEighthPt ?? 4) / 6)), o = { color: !e.color || e.color === "auto" ? "#000000" : `#${e.color.toLowerCase()}`, widthPx: n }, r = Yt(e.val);
465
- return r !== "single" && (o.style = r), o;
466
- }
467
- function Yt(e) {
468
- return e === "double" ? "double" : /dash/i.test(e) ? "dashed" : /dot/i.test(e) ? "dotted" : "single";
469
- }
470
- function be(e) {
471
- const n = {}, t = se(e, "w:rStyle");
472
- t && (n.styleId = t);
473
- const o = ge(h(e, "w:b"));
474
- o !== void 0 && (n.bold = o);
475
- const r = ge(h(e, "w:i"));
476
- r !== void 0 && (n.italic = r);
477
- const i = ge(h(e, "w:strike"));
478
- i !== void 0 && (n.strikethrough = i);
479
- const s = h(e, "w:u");
480
- s && (n.underline = v(s, "w:val") !== "none");
481
- const a = h(e, "w:color");
482
- if (a) {
483
- const m = v(a, "w:val");
484
- m && (n.color = m);
485
- const S = v(a, "w:themeColor");
486
- S && (n.colorTheme = S);
487
- }
488
- const f = A(h(e, "w:sz"), "w:val");
489
- f !== void 0 && (n.sizeHalfPoints = f);
490
- const p = h(e, "w:rFonts");
491
- if (p) {
492
- const m = v(p, "w:ascii");
493
- m && (n.fontAscii = m);
494
- const S = v(p, "w:asciiTheme");
495
- S && (n.fontThemeAscii = S);
496
- }
497
- const d = se(e, "w:highlight");
498
- d && d !== "none" && (n.highlight = d);
499
- const c = se(e, "w:vertAlign");
500
- c && (n.vertAlign = c);
501
- const u = ge(h(e, "w:vanish"));
502
- return u !== void 0 && (n.vanish = u), n;
503
- }
504
- const Kt = {
505
- left: "left",
506
- start: "left",
507
- center: "center",
508
- right: "right",
509
- end: "right",
510
- both: "justify",
511
- distribute: "justify"
512
- };
513
- function Ue(e, n) {
514
- const t = {}, o = se(e, "w:pStyle");
515
- o && (t.styleId = o);
516
- const r = se(e, "w:jc"), i = r !== void 0 ? Kt[r] : void 0;
517
- i && (t.align = i);
518
- const s = h(e, "w:spacing");
519
- if (s) {
520
- const b = A(s, "w:before");
521
- b !== void 0 && (t.spaceBeforeTwips = b);
522
- const R = A(s, "w:after");
523
- R !== void 0 && (t.spaceAfterTwips = R);
524
- const M = A(s, "w:line"), N = v(s, "w:lineRule") ?? "auto";
525
- M !== void 0 && (N === "auto" ? t.lineHeight = Wt(M) : n.add("line-rule-exact", "Exact/atLeast line spacing was ignored (model is multiplier-only)."));
526
- }
527
- const a = h(e, "w:ind");
528
- if (a) {
529
- const b = A(a, "w:left") ?? A(a, "w:start");
530
- b !== void 0 && (t.indentLeftTwips = b);
531
- const R = A(a, "w:right") ?? A(a, "w:end");
532
- R !== void 0 && (t.indentRightTwips = R);
533
- const M = A(a, "w:firstLine"), N = A(a, "w:hanging");
534
- M !== void 0 ? t.indentFirstLineTwips = M : N !== void 0 && (t.indentFirstLineTwips = -N);
535
- }
536
- const f = ge(h(e, "w:keepNext"));
537
- f !== void 0 && (t.keepWithNext = f);
538
- const p = ge(h(e, "w:keepLines"));
539
- p !== void 0 && (t.keepLinesTogether = p);
540
- const d = h(e, "w:tabs");
541
- if (d) {
542
- const b = [];
543
- for (const R of ne(d, "w:tab")) {
544
- const M = A(R, "w:pos"), N = v(R, "w:val");
545
- if (M === void 0 || N === "clear" || N === "bar") continue;
546
- const j = { posTwips: M };
547
- N && (j.val = N);
548
- const K = v(R, "w:leader");
549
- K && (j.leader = K), b.push(j);
550
- }
551
- b.length > 0 && (t.tabStops = b);
552
- }
553
- const c = ge(h(e, "w:pageBreakBefore"));
554
- c !== void 0 && (t.pageBreakBefore = c);
555
- const u = se(e, "w:outlineLvl");
556
- if (u !== void 0) {
557
- const b = Number(u);
558
- Number.isFinite(b) && b >= 0 && b <= 8 && (t.outlineLevel = b);
559
- }
560
- const m = h(e, "w:numPr");
561
- if (m) {
562
- const b = se(m, "w:numId");
563
- b !== void 0 && (t.list = b === "0" ? null : { numId: b, level: A(h(m, "w:ilvl"), "w:val") ?? 0 });
564
- }
565
- const S = h(e, "w:rPr");
566
- S && (t.markRunProps = be(S));
567
- const x = h(e, "w:sectPr");
568
- if (x) {
569
- t.sectionBreak = se(x, "w:type") === "continuous" ? "continuous" : "page";
570
- const b = h(x, "w:pgSz"), R = A(b, "w:w"), M = A(b, "w:h");
571
- R !== void 0 && M !== void 0 && (t.sectionPgSize = { w: R, h: M });
572
- const N = h(x, "w:pgMar");
573
- if (N) {
574
- const q = A(N, "w:top"), ee = A(N, "w:right"), te = A(N, "w:bottom"), oe = A(N, "w:left");
575
- q !== void 0 && ee !== void 0 && te !== void 0 && oe !== void 0 && (t.sectionMarginTwips = { top: q, right: ee, bottom: te, left: oe });
576
- }
577
- const j = h(x, "w:cols"), K = A(j, "w:num");
578
- if (K !== void 0 && K > 1) {
579
- t.sectionColumns = { count: K };
580
- const q = A(j, "w:space");
581
- q !== void 0 && (t.sectionColumns.spaceTwips = q);
582
- }
583
- const G = A(h(x, "w:pgNumType"), "w:start");
584
- G !== void 0 && (t.sectionPageNumberStart = G), (ne(x, "w:headerReference").length > 0 || ne(x, "w:footerReference").length > 0) && (t.sectionHasBands = !0);
585
- }
586
- return t;
587
- }
588
- const Ye = () => ({ depth: 0, topInstr: "", openId: null, markBlock: null, next: { n: 0 }, registry: {} });
589
- function Je(e) {
590
- const n = e.fieldTrack;
591
- if (n.openId !== null || !Dt(n.topInstr)) return;
592
- const t = `field${n.next.n++}`;
593
- n.registry[t] = { id: t, instruction: n.topInstr, name: $e(n.topInstr).name, kind: "custom" }, n.openId = t, n.markBlock = t;
594
- }
595
- function et(e) {
596
- let n = 0;
597
- for (const t of e)
598
- t.kind === "run" ? n += t.text.length : t.kind === "break" && (n += 1);
599
- return n;
600
- }
601
- function qt(e, n, t) {
602
- const o = de(ue(e, n), "w:document"), r = o && h(o, "w:body");
603
- if (!r)
604
- throw new pe("MALFORMED_XML", `${n} has no w:document/w:body root.`);
605
- const i = {}, s = { warnings: t, fieldTokens: !1, sdts: i, nextSdt: { n: 0 }, pendingBookmarks: [], currentBookmarks: null, pendingMarkers: [], currentMarkers: null, trackFields: !0, fieldTrack: Ye() }, a = [];
606
- ye(J(r), a, s);
607
- const f = h(r, "w:sectPr"), p = f ? mn(f) : null, d = s.fieldTrack.registry;
608
- return Object.keys(d).length > 0 ? { blocks: a, section: p, sdts: i, fields: d } : { blocks: a, section: p, sdts: i };
609
- }
610
- function Zt(e, n, t, o = {}) {
611
- const r = ue(e, n), i = de(r, "w:hdr") ?? de(r, "w:ftr");
612
- if (!i)
613
- throw new pe("MALFORMED_XML", `${n} has no w:hdr/w:ftr root.`);
614
- const s = { warnings: t, fieldTokens: !0, sdts: o, nextSdt: { n: Object.keys(o).length }, pendingBookmarks: [], currentBookmarks: null, pendingMarkers: [], currentMarkers: null, trackFields: !1, fieldTrack: Ye() }, a = [];
615
- return ye(J(i), a, s), a;
616
- }
617
- const Qt = /* @__PURE__ */ new Set(["_GoBack", "_Toc_Placeholder"]);
618
- function ft(e) {
619
- const n = v(e, "w:name");
620
- return n && !Qt.has(n) ? n : null;
621
- }
622
- function ye(e, n, t) {
623
- for (const o of e)
624
- switch (t.trackFields && (t.fieldTrack.markBlock = t.fieldTrack.openId), o.tagName) {
625
- case "w:p": {
626
- const r = Jt(o, t);
627
- t.trackFields && t.fieldTrack.markBlock && (r.fieldId = t.fieldTrack.markBlock), n.push(r);
628
- break;
629
- }
630
- case "w:tbl": {
631
- const r = pn(o, t);
632
- t.trackFields && t.fieldTrack.markBlock && (r.fieldId = t.fieldTrack.markBlock), n.push(r);
633
- break;
634
- }
635
- case "w:sdt": {
636
- const r = h(o, "w:sdtContent");
637
- if (!r) break;
638
- const i = ut(h(o, "w:sdtPr"));
639
- if (!i) {
640
- t.warnings.add("sdt-unwrapped", "Content controls were unwrapped to their content."), ye(J(r), n, t);
641
- break;
642
- }
643
- const s = `sdt${t.nextSdt.n++}`;
644
- t.sdts[s] = i;
645
- const a = [];
646
- ye(J(r), a, t);
647
- for (const f of a) ht(f, s);
648
- n.push(...a);
649
- break;
650
- }
651
- case "w:bookmarkStart": {
652
- const r = ft(o), i = v(o, "w:id");
653
- r && (t.pendingBookmarks.push(r), i && t.pendingMarkers.push({ id: i, name: r, kind: "start", offset: 0 }));
654
- break;
655
- }
656
- case "w:bookmarkEnd": {
657
- const r = v(o, "w:id");
658
- r && t.pendingMarkers.push({ id: r, kind: "end", offset: 0 });
659
- break;
660
- }
661
- }
662
- }
663
- function Jt(e, n) {
664
- const t = h(e, "w:pPr"), o = t ? Ue(t, n.warnings) : {}, r = [], i = n.pendingBookmarks;
665
- n.pendingBookmarks = [], n.currentBookmarks = i;
666
- const s = n.pendingMarkers;
667
- n.pendingMarkers = [], n.currentMarkers = s;
668
- const a = { depth: 0, instr: "", suppressResult: !1 };
669
- me(J(e), r, n, a), n.currentBookmarks = null, n.currentMarkers = null;
670
- const f = { kind: "paragraph", props: o, inlines: r };
671
- return i.length > 0 && (f.bookmarks = i), s.length > 0 && (f.bookmarkMarkers = s), a.tocInstr !== void 0 && (f.tocField = a.tocInstr), f;
672
- }
673
- const en = /* @__PURE__ */ new Set(["PAGE", "NUMPAGES", "DATE", "TIME", "IF"]), tn = { fontFamily: "", fontSizePx: 16, bold: !1, italic: !1, underline: !1, strikethrough: !1, color: "#000000" };
674
- function nn(e) {
675
- return e.type === "NUMPAGES" ? "{pages}" : e.type === "PAGE" ? `{page${e.numFmt && e.numFmt !== "arabic" ? `:${e.numFmt}` : ""}}` : "";
676
- }
677
- function ze(e) {
678
- if (/\bNUMPAGES\b/.test(e)) return "{pages}";
679
- if (/\bPAGE\b/.test(e)) return "{page}";
680
- }
681
- function on(e) {
682
- const n = e.match(/\bPAGEREF\s+("[^"]+"|\S+)/) ?? e.match(/\bHYPERLINK\s+\\l\s+("[^"]+"|\S+)/);
683
- return n ? n[1].replace(/^"|"$/g, "") : void 0;
684
- }
685
- function me(e, n, t, o) {
686
- for (const r of e)
687
- switch (r.tagName) {
688
- case "w:r":
689
- sn(r, n, t, o);
690
- break;
691
- case "w:hyperlink": {
692
- const i = v(r, "r:id"), s = v(r, "w:anchor"), a = n.length;
693
- if (me(J(r), n, t, o), i || s)
694
- for (let f = a; f < n.length; f++) {
695
- const p = n[f];
696
- p.kind === "run" && (i ? p.props.linkRelId = i : s && (p.props.linkAnchor = s));
697
- }
698
- break;
699
- }
700
- case "w:sdt": {
701
- const i = h(r, "w:sdtContent");
702
- if (!i) break;
703
- const s = ut(h(r, "w:sdtPr"));
704
- if (!s) {
705
- t.warnings.add("sdt-unwrapped", "Content controls were unwrapped to their content."), me(J(i), n, t, o);
706
- break;
707
- }
708
- const a = `sdt${t.nextSdt.n++}`;
709
- t.sdts[a] = s;
710
- const f = [];
711
- me(J(i), f, t, o);
712
- for (const p of f)
713
- p.kind === "run" && (p.sdtId = a);
714
- n.push(...f);
715
- break;
716
- }
717
- case "w:fldSimple": {
718
- const i = v(r, "w:instr") ?? "", s = t.fieldTokens ? ze(i) : void 0;
719
- s ? n.push({ kind: "run", text: s, props: rn(r) }) : me(J(r), n, t, o);
720
- break;
721
- }
722
- case "w:smartTag":
723
- case "w:ins":
724
- me(J(r), n, t, o);
725
- break;
726
- case "w:del":
727
- break;
728
- case "w:bookmarkStart": {
729
- const i = ft(r), s = v(r, "w:id");
730
- i && t.currentBookmarks && t.currentBookmarks.push(i), i && s && t.currentMarkers && t.currentMarkers.push({ id: s, name: i, kind: "start", offset: et(n) });
731
- break;
732
- }
733
- case "w:bookmarkEnd": {
734
- const i = v(r, "w:id");
735
- i && t.currentMarkers && t.currentMarkers.push({ id: i, kind: "end", offset: et(n) });
736
- break;
737
- }
738
- }
739
- }
740
- function rn(e) {
741
- const n = ke(e, "w:r"), t = n && h(n, "w:rPr");
742
- return t ? be(t) : {};
743
- }
744
- function sn(e, n, t, o) {
745
- const r = h(e, "w:rPr"), i = r ? be(r) : {};
746
- let s = "";
747
- const a = () => {
748
- s.length > 0 && (o.pagerefAnchor && i.linkAnchor === void 0 && i.linkRelId === void 0 && (i.linkAnchor = o.pagerefAnchor), n.push({ kind: "run", text: s, props: i, ...o.resultFieldId ? { fieldId: o.resultFieldId } : {} })), s = "";
749
- }, f = (p) => {
750
- for (const d of p)
751
- switch (d.tagName) {
752
- case "w:t":
753
- o.suppressResult || (s += we(d));
754
- break;
755
- case "w:tab":
756
- o.suppressResult || (s += " ");
757
- break;
758
- case "w:br": {
759
- a();
760
- const c = v(d, "w:type");
761
- c === "page" ? n.push({ kind: "break", page: !0 }) : c === "column" ? n.push({ kind: "break", column: !0 }) : n.push({ kind: "break" });
762
- break;
763
- }
764
- case "w:cr":
765
- a(), n.push({ kind: "break" });
766
- break;
767
- case "w:noBreakHyphen":
768
- s += "‑";
769
- break;
770
- case "w:drawing": {
771
- a();
772
- const c = cn(d, t);
773
- c && n.push(c);
774
- break;
775
- }
776
- case "w:pict": {
777
- a();
778
- const c = hn(d, t);
779
- c && n.push(c);
780
- break;
781
- }
782
- case "w:object":
783
- t.warnings.add("objects-skipped", "Embedded OLE objects are not imported.");
784
- break;
785
- case "w:instrText":
786
- if (o.depth > 0) {
787
- o.instr += we(d);
788
- const c = on(o.instr);
789
- c && (o.pagerefAnchor = c);
790
- const u = we(d);
791
- o.tocInstr === void 0 && /\bTOC\b/.test(u) && (o.tocInstr = u);
792
- }
793
- t.trackFields && t.fieldTrack.depth === 1 && (t.fieldTrack.topInstr += we(d));
794
- break;
795
- case "w:fldChar":
796
- an(d, i, n, t, o);
797
- break;
798
- case "mc:AlternateContent": {
799
- const c = h(d, "mc:Choice") ?? h(d, "mc:Fallback");
800
- c && f(J(c));
801
- break;
802
- }
803
- case "w:footnoteReference": {
804
- const c = v(d, "w:id");
805
- c !== void 0 && (a(), n.push({ kind: "run", text: "", props: { ...i, footnoteId: c } }));
806
- break;
807
- }
808
- }
809
- };
810
- f(J(e)), a();
811
- }
812
- function an(e, n, t, o, r) {
813
- const i = o.fieldTrack;
814
- switch (v(e, "w:fldCharType")) {
815
- case "begin":
816
- r.depth++, r.depth === 1 && (r.instr = "", r.suppressResult = !1, r.pagerefAnchor = void 0, r.resultFieldId = void 0), o.trackFields && (i.depth++, i.depth === 1 && (i.topInstr = "", i.openId = null));
817
- break;
818
- case "separate": {
819
- if (o.trackFields && i.depth === 1 && Je(o), r.depth !== 1) break;
820
- if (o.trackFields) {
821
- const a = $e(r.instr);
822
- if (en.has(a.name)) {
823
- const f = Ut(a, tn);
824
- if (f) {
825
- const p = `field${i.next.n++}`;
826
- i.registry[p] = { id: p, instruction: r.instr, name: a.name, kind: "builtin", spec: f }, f.type === "PAGE" || f.type === "NUMPAGES" ? (t.push({ kind: "run", text: nn(f), props: n, fieldId: p }), r.suppressResult = !0) : r.resultFieldId = p;
827
- break;
828
- }
829
- }
830
- }
831
- const s = o.fieldTokens ? ze(r.instr) : void 0;
832
- s && (t.push({ kind: "run", text: s, props: n }), r.suppressResult = !0);
833
- break;
834
- }
835
- case "end":
836
- if (o.trackFields && i.depth > 0 && (i.depth === 1 && (Je(o), i.openId = null, i.topInstr = ""), i.depth--), r.depth > 0 && r.depth--, r.depth === 0) {
837
- if (!r.suppressResult) {
838
- const s = o.fieldTokens ? ze(r.instr) : void 0;
839
- s && t.push({ kind: "run", text: s, props: n });
840
- }
841
- r.instr = "", r.suppressResult = !1, r.pagerefAnchor = void 0, r.resultFieldId = void 0;
842
- }
843
- break;
844
- }
845
- }
846
- function cn(e, n) {
847
- const t = h(e, "wp:anchor"), o = h(e, "wp:inline") ?? t;
848
- if (!o) return;
849
- const r = ke(o, "a:blip"), i = r && v(r, "r:embed");
850
- if (!i) {
851
- n.warnings.add("images-skipped", "A drawing without an embedded image reference was skipped.");
852
- return;
853
- }
854
- const s = h(o, "wp:extent"), a = { kind: "image", relId: i, anchored: !!t }, f = A(s, "cx");
855
- f !== void 0 && (a.widthEmu = f);
856
- const p = A(s, "cy");
857
- if (p !== void 0 && (a.heightEmu = p), t) {
858
- const d = h(t, "wp:wrapSquare") ?? h(t, "wp:wrapTight") ?? h(t, "wp:wrapThrough"), c = h(t, "wp:wrapNone");
859
- a.anchorWrap = d ? "square" : "block";
860
- const u = h(t, "wp:positionH"), m = h(t, "wp:positionV"), S = u && h(u, "wp:align"), x = S && we(S);
861
- if ((x === "left" || x === "right" || x === "center") && (a.anchorAlign = x), c) {
862
- const b = ke(t, "adec:decorative"), R = A(t, "relativeHeight");
863
- a.anchorFloat = {
864
- behind: v(t, "behindDoc") === "1",
865
- offsetXEmu: tt(u),
866
- offsetYEmu: tt(m),
867
- relFromH: dn(u),
868
- relFromV: un(m),
869
- decorative: !!b && v(b, "val") !== "0",
870
- ...R !== void 0 ? { z: R } : {}
871
- };
872
- } else d || n.warnings.add(
873
- "images-anchored",
874
- "Some floating images (overlapping or top-and-bottom wrap) were placed in the text flow."
875
- );
876
- }
877
- return a;
878
- }
879
- function tt(e) {
880
- const n = e && h(e, "wp:posOffset"), t = n ? Number(we(n).trim()) : NaN;
881
- return Number.isFinite(t) ? t : 0;
882
- }
883
- const ln = /* @__PURE__ */ new Set(["page", "margin", "column", "leftMargin", "rightMargin", "character"]), fn = /* @__PURE__ */ new Set(["page", "margin", "paragraph", "line", "topMargin", "bottomMargin"]);
884
- function dn(e) {
885
- const n = e && v(e, "relativeFrom");
886
- return n && ln.has(n) ? n : "column";
887
- }
888
- function un(e) {
889
- const n = e && v(e, "relativeFrom");
890
- return n && fn.has(n) ? n : "paragraph";
891
- }
892
- function hn(e, n) {
893
- const t = ke(e, "v:imagedata"), o = t && v(t, "r:id");
894
- if (!o) {
895
- n.warnings.add("images-skipped", "A legacy picture without an image reference was skipped.");
896
- return;
897
- }
898
- const r = { kind: "image", relId: o, anchored: !1 }, i = ke(e, "v:shape"), s = (i && v(i, "style")) ?? "", a = (d) => {
899
- const c = s.match(new RegExp(`(?:^|;)\\s*${d}:([\\d.]+)pt`));
900
- return c ? Number(c[1]) * 12700 : void 0;
901
- }, f = a("width");
902
- f !== void 0 && (r.widthEmu = f);
903
- const p = a("height");
904
- return p !== void 0 && (r.heightEmu = p), r;
905
- }
906
- function dt(e) {
907
- if (!e) return;
908
- const n = (a) => A(h(e, a), "w:w"), t = {}, o = n("w:top");
909
- o !== void 0 && (t.top = o);
910
- const r = n("w:right");
911
- r !== void 0 && (t.right = r);
912
- const i = n("w:bottom");
913
- i !== void 0 && (t.bottom = i);
914
- const s = n("w:left");
915
- return s !== void 0 && (t.left = s), Object.keys(t).length > 0 ? t : void 0;
916
- }
917
- function pn(e, n) {
918
- const t = [];
919
- for (const s of ne(e, "w:tr")) {
920
- const a = [];
921
- for (const f of ne(s, "w:tc"))
922
- a.push(gn(f, n));
923
- t.push({ cells: a });
924
- }
925
- const o = { kind: "table", rows: t }, r = h(e, "w:tblGrid");
926
- if (r) {
927
- const s = ne(r, "w:gridCol").map((a) => A(a, "w:w")).filter((a) => a !== void 0 && a > 0);
928
- s.length > 0 && (o.colWidthsTwips = s);
929
- }
930
- const i = h(e, "w:tblPr");
931
- if (i) {
932
- const s = se(i, "w:tblStyle");
933
- s && (o.styleId = s), h(i, "w:tblBorders") && (o.bordersSpecified = !0);
934
- const a = Xe(h(i, "w:tblBorders"));
935
- a && (o.borders = a);
936
- const f = Ve(h(i, "w:shd"));
937
- f && (o.shd = f);
938
- const p = dt(h(i, "w:tblCellMar"));
939
- p && (o.cellMarginTwips = p);
940
- }
941
- return o;
942
- }
943
- function gn(e, n) {
944
- const t = h(e, "w:tcPr"), o = (t && A(h(t, "w:gridSpan"), "w:val")) ?? 1, r = t && h(t, "w:vMerge"), i = !!r && (v(r, "w:val") ?? "continue") === "continue", s = [];
945
- ye(J(e), s, n);
946
- const a = { blocks: s, gridSpan: o, vMergeContinue: i };
947
- if (t) {
948
- h(t, "w:tcBorders") && (a.bordersSpecified = !0);
949
- const f = Xe(h(t, "w:tcBorders"));
950
- f && (a.borders = f);
951
- const p = Ve(h(t, "w:shd"));
952
- p && (a.shd = p);
953
- const d = dt(h(t, "w:tcMar"));
954
- d && (a.marginTwips = d);
955
- }
956
- return a;
957
- }
958
- function ut(e) {
959
- if (!e) return null;
960
- const n = { type: "richText" }, t = h(e, "w:alias"), o = t && v(t, "w:val");
961
- o && (n.alias = o);
962
- const r = h(e, "w:tag"), i = r && v(r, "w:val");
963
- i && (n.tag = i), h(e, "w:text") && (n.type = "plainText");
964
- const s = h(e, "w:dropDownList") ?? h(e, "w:comboBox");
965
- s && (n.type = s.tagName === "w:dropDownList" ? "dropDown" : "comboBox", n.listItems = ne(s, "w:listItem").map((c) => ({
966
- display: v(c, "w:displayText") ?? v(c, "w:value") ?? "",
967
- value: v(c, "w:value") ?? v(c, "w:displayText") ?? ""
968
- })));
969
- const a = h(e, "w:date");
970
- if (a) {
971
- n.type = "date";
972
- const c = h(a, "w:dateFormat"), u = c && v(c, "w:val");
973
- u && (n.dateFormat = u);
974
- }
975
- const f = h(e, "w14:checkbox");
976
- if (f) {
977
- n.type = "checkbox";
978
- const c = h(f, "w14:checked"), u = c && v(c, "w14:val");
979
- n.checked = u === "1" || u === "true";
980
- }
981
- h(e, "w:showingPlcHdr") && (n.placeholder = !0);
982
- const p = h(e, "w:lock"), d = p && v(p, "w:val");
983
- return (d === "contentLocked" || d === "sdtContentLocked") && (n.lockContent = !0), (d === "sdtLocked" || d === "sdtContentLocked") && (n.lockControl = !0), n;
984
- }
985
- function ht(e, n) {
986
- if (e.kind === "paragraph") {
987
- for (const t of e.inlines)
988
- t.kind === "run" && t.sdtId === void 0 && (t.sdtId = n);
989
- return;
990
- }
991
- for (const t of e.rows)
992
- for (const o of t.cells) for (const r of o.blocks) ht(r, n);
993
- }
994
- function mn(e, n) {
995
- const t = {}, o = h(e, "w:pgSz"), r = A(o, "w:w");
996
- r !== void 0 && (t.pageWidthTwips = r);
997
- const i = A(o, "w:h");
998
- i !== void 0 && (t.pageHeightTwips = i);
999
- const s = h(e, "w:pgMar");
1000
- if (s) {
1001
- const c = A(s, "w:top"), u = A(s, "w:right"), m = A(s, "w:bottom"), S = A(s, "w:left");
1002
- c !== void 0 && u !== void 0 && m !== void 0 && S !== void 0 && (t.marginTwips = { top: c, right: u, bottom: m, left: S });
1003
- const x = A(s, "w:header");
1004
- x !== void 0 && (t.headerDistTwips = x);
1005
- const b = A(s, "w:footer");
1006
- b !== void 0 && (t.footerDistTwips = b);
1007
- }
1008
- const a = nt(ne(e, "w:headerReference"));
1009
- a && (t.headerRefs = a);
1010
- const f = nt(ne(e, "w:footerReference"));
1011
- f && (t.footerRefs = f), h(e, "w:titlePg") && (t.titlePg = !0);
1012
- const p = h(e, "w:cols");
1013
- if (p) {
1014
- const c = A(p, "w:num") ?? 1;
1015
- if (c > 1) {
1016
- t.columns = { count: c };
1017
- const u = A(p, "w:space");
1018
- u !== void 0 && (t.columns.spaceTwips = u);
1019
- }
1020
- }
1021
- const d = A(h(e, "w:pgNumType"), "w:start");
1022
- return d !== void 0 && (t.pageNumberStart = d), t;
1023
- }
1024
- function nt(e) {
1025
- if (e.length === 0) return;
1026
- const n = {};
1027
- for (const t of e) {
1028
- const o = v(t, "r:id");
1029
- if (!o) continue;
1030
- const r = v(t, "w:type") ?? "default";
1031
- r === "first" ? n.first = o : r === "even" ? n.even = o : n.default = o;
1032
- }
1033
- return Object.keys(n).length > 0 ? n : void 0;
1034
- }
1035
- function wn(e, n, t, o = {}) {
1036
- const r = /* @__PURE__ */ new Map(), i = de(ue(e, n), "w:footnotes");
1037
- if (!i) return r;
1038
- const s = {
1039
- warnings: t,
1040
- fieldTokens: !1,
1041
- sdts: o,
1042
- nextSdt: { n: Object.keys(o).length },
1043
- pendingBookmarks: [],
1044
- currentBookmarks: null,
1045
- pendingMarkers: [],
1046
- currentMarkers: null,
1047
- trackFields: !1,
1048
- fieldTrack: Ye()
1049
- };
1050
- for (const a of ne(i, "w:footnote")) {
1051
- const f = v(a, "w:id");
1052
- if (f === void 0 || v(a, "w:type")) continue;
1053
- const d = [];
1054
- ye(J(a), d, s), r.set(f, d);
1055
- }
1056
- return r;
1057
- }
1058
- const vn = () => {
1059
- }, pt = {
1060
- fontFamily: "Times New Roman, serif",
1061
- fontSizePx: 16,
1062
- // 12pt
1063
- bold: !1,
1064
- italic: !1,
1065
- underline: !1,
1066
- strikethrough: !1,
1067
- color: "#000000"
1068
- }, kn = {
1069
- align: "left",
1070
- lineHeight: 1,
1071
- spaceBeforePx: 0,
1072
- spaceAfterPx: 0,
1073
- indentFirstLinePx: 0,
1074
- indentLeftPx: 0
1075
- }, bn = { top: 0, right: 108, bottom: 0, left: 108 }, Te = {
1076
- pageWidthPx: 816,
1077
- pageHeightPx: 1056,
1078
- marginPx: { top: 96, right: 96, bottom: 96, left: 96 }
1079
- };
1080
- function yn(e, n, t = {}, o = /* @__PURE__ */ new Map(), r = () => ({}), i) {
1081
- let s = 0;
1082
- const a = () => `i${s++}`, f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), c = [], u = (l) => {
1083
- let g = d.get(l);
1084
- return g === void 0 && (g = String(d.size + 1), d.set(l, g), c.push(l)), g;
1085
- }, m = /* @__PURE__ */ new Map(), S = (l) => {
1086
- const g = m.get(l);
1087
- if (g) return g;
1088
- const I = o.get(l);
1089
- if (!I) return;
1090
- const P = Pn(I);
1091
- return m.set(l, P), P;
1092
- }, x = Oe(n.run(void 0, {})), b = ot(n.para({})), R = () => ({
1093
- kind: "paragraph",
1094
- id: a(),
1095
- revision: 0,
1096
- runs: [{ text: "", style: { ...x } }],
1097
- style: { ...b }
1098
- }), M = (l, g) => {
1099
- if (!g) return 0;
1100
- const I = S(g.numId);
1101
- if (!I)
1102
- return e.add("list-missing", "A list reference had no matching definition — markers were dropped."), 0;
1103
- l.list = { listId: g.numId, level: g.level };
1104
- const P = I.levels[Math.min(g.level, I.levels.length - 1)], k = P ? P.indentLeftPx : 0;
1105
- return l.indentLeftPx = Math.max(0, O(l.indentLeftPx - k)), l.indentFirstLinePx = 0, k;
1106
- }, N = (l) => {
1107
- const g = l.sectionPgSize;
1108
- return !!g && !!i && (g.w !== i.w || g.h !== i.h);
1109
- }, j = (l) => N(l) || !!l.sectionColumns || l.sectionPageNumberStart !== void 0, K = (l) => {
1110
- const g = {};
1111
- return l.sectionPgSize && (g.pageWidthPx = O(X(l.sectionPgSize.w)), g.pageHeightPx = O(X(l.sectionPgSize.h))), l.sectionMarginTwips && (g.marginPx = Le(l.sectionMarginTwips)), l.sectionColumns && (g.columns = { count: l.sectionColumns.count, gapPx: O(X(l.sectionColumns.spaceTwips ?? 720)) }), l.sectionPageNumberStart !== void 0 && (g.pageNumberStart = l.sectionPageNumberStart), g;
1112
- }, G = (l) => {
1113
- for (let g = l.length - 1; g >= 0; g--) if (l[g].kind === "paragraph") return l[g];
1114
- };
1115
- let q;
1116
- const ee = (l, g, I = vn) => {
1117
- const P = [];
1118
- let k = !1, y = !1, E = !1, L = !1;
1119
- const Y = (D) => D.some((T) => T.kind !== "paragraph" || T.runs.some((w) => w.text.trim().length > 0 && !w.style.hidden));
1120
- let U = 0, $ = null;
1121
- const z = (D) => {
1122
- for (const T of D)
1123
- if (T.kind === "paragraph" && T.runs.some((w) => w.text.trim().length > 0 && !w.style.hidden)) return T;
1124
- }, B = (D) => {
1125
- for (let T = D + 1; T < l.length; T++) {
1126
- const w = l[T];
1127
- if (w.kind !== "paragraph") return !1;
1128
- if (w.inlines.some(
1129
- (H) => H.kind === "run" && H.text.trim().length > 0 && !H.props.vanish
1130
- ))
1131
- return n.isHeading(w.props.styleId) ? !0 : (w.bookmarks ?? []).some((H) => /toc/i.test(H));
1132
- }
1133
- return !1;
1134
- };
1135
- for (let D = 0; D < l.length; D++) {
1136
- const T = l[D], w = T.kind === "paragraph" ? oe(T, g, I) : [Z(T, g, I)];
1137
- if (T.fieldId) for (const F of w) F.fieldId = T.fieldId;
1138
- if (T.kind === "paragraph" && T.tocField !== void 0 && q === void 0) {
1139
- const F = w.find((H) => H.kind === "paragraph") ?? w[0];
1140
- F && (q = { blockId: F.id, instruction: T.tocField });
1141
- }
1142
- if (k && w.length > 0) {
1143
- const F = w[0];
1144
- F.kind === "paragraph" && F.runs.every((Q) => Q.text.length === 0 || Q.style.hidden) || ((T.kind === "paragraph" && n.isHeading(T.props.styleId) || y) && (F.kind === "paragraph" ? F.style.pageBreakBefore = !0 : w.unshift({ ...R(), style: { ...b, pageBreakBefore: !0 } })), k = !1, y = !1);
1145
- }
1146
- if (T.kind === "paragraph" && T.props.sectionBreak === "page") {
1147
- const F = T.props;
1148
- if (j(F)) {
1149
- let H = G(w);
1150
- H || (H = R(), w.push(H)), H.style.sectionBreak = { type: "nextPage", props: K(F) }, k = !1;
1151
- } else
1152
- F.sectionHasBands && e.add(
1153
- "section-bands-flattened",
1154
- "Per-section headers/footers on geometry-preserving section breaks were not applied (the document section's are used)."
1155
- ), k = !0, y = !E && L || B(D), U > 0 && $ && B(U - 1) && ($.style.pageBreakBefore = !0);
1156
- E = !0;
1157
- }
1158
- T.kind === "paragraph" && T.props.sectionBreak !== void 0 ? (U = D + 1, $ = null) : $ || ($ = z(w) ?? null), P.push(...w), E || (L ||= Y(w));
1159
- }
1160
- return te(P), P;
1161
- }, te = (l) => {
1162
- const g = (k) => k.kind === "image" || k.kind === "table", I = (k) => k.kind === "paragraph" && k.runs.every((y) => y.text.trim().length === 0 || y.style.hidden), P = (k) => k.kind === "paragraph" ? k.runs.reduce((y, E) => y + E.text.length, 0) : 0;
1163
- for (let k = 0; k < l.length; k++) {
1164
- const y = l[k];
1165
- if (y.kind !== "paragraph" || !y.style.namedStyle || !n.isHeading(y.style.namedStyle)) continue;
1166
- const E = [];
1167
- let L = 0, Y = -1;
1168
- for (let U = k + 1; U < l.length && U <= k + 6; U++) {
1169
- const $ = l[U];
1170
- if (g($)) {
1171
- Y = U;
1172
- break;
1173
- }
1174
- if ($.kind !== "paragraph") break;
1175
- if (!I($)) {
1176
- if (L >= 2 || P($) > 300) break;
1177
- L++, E.push($);
1178
- }
1179
- }
1180
- if (!(Y < 0)) {
1181
- y.style.keepWithNext = !0;
1182
- for (const U of E) U.style.keepWithNext = !0;
1183
- }
1184
- }
1185
- };
1186
- function oe(l, g, I) {
1187
- const P = n.para(l.props), k = ot(P), y = M(k, P.list), E = Oe(n.run(l.props.styleId, l.props.markRunProps ?? {})), L = [];
1188
- let Y = [], U = !1, $ = !1, z = !1;
1189
- const B = (w) => {
1190
- const F = { ...k };
1191
- return $ && (F.pageBreakBefore = !0, $ = !1), z && (F.columnBreakBefore = !0, z = !1), {
1192
- kind: "paragraph",
1193
- id: a(),
1194
- revision: 0,
1195
- runs: Mt(w, E),
1196
- style: F
1197
- };
1198
- }, D = () => {
1199
- Y.length !== 0 && (L.push(B(Y)), Y = []);
1200
- };
1201
- for (const w of l.inlines)
1202
- switch (w.kind) {
1203
- case "break":
1204
- !w.page && !w.column ? (e.add("soft-breaks", "Soft line breaks (Shift+Enter) became paragraph breaks."), Y.length > 0 ? D() : L.push(B([]))) : (Y.length > 0 && D(), w.page && ($ = !0), w.column && (z = !0)), U = !0;
1205
- break;
1206
- case "image": {
1207
- const F = C(w, g, k.align);
1208
- F && (D(), ($ || z) && L.push(B([])), L.push(F), U = !1);
1209
- break;
1210
- }
1211
- case "run": {
1212
- const F = n.run(l.props.styleId, w.props);
1213
- Y.push(W(w.text, F, I, w.sdtId, w.fieldId)), U = !1;
1214
- break;
1215
- }
1216
- }
1217
- D(), (U || L.length === 0) && L.push(B([]));
1218
- const T = L.filter((w) => w.kind === "paragraph");
1219
- if (T.forEach((w, F) => {
1220
- F > 0 && (w.style.spaceBeforePx = 0), F < T.length - 1 && (w.style.spaceAfterPx = 0), F > 0 && w.style.list && (delete w.style.list, w.style.indentLeftPx = O(w.style.indentLeftPx + y));
1221
- }), l.bookmarkMarkers && l.bookmarkMarkers.length > 0 && L[0]) {
1222
- const w = L[0], F = w.kind === "paragraph" ? w.runs.reduce((H, Q) => H + Q.text.length, 0) : 0;
1223
- for (const H of l.bookmarkMarkers) {
1224
- const Q = { blockId: w.id, offset: Math.min(H.offset, F) };
1225
- H.kind === "start" && H.name ? f.set(H.id, { name: H.name, pos: Q }) : H.kind === "end" && p.set(H.id, Q);
1226
- }
1227
- }
1228
- return L;
1229
- }
1230
- function C(l, g, I) {
1231
- const P = g.resolve(l.relId);
1232
- if (!P) return;
1233
- if (l.widthEmu === void 0 || l.heightEmu === void 0) {
1234
- e.add("images-unsized", "An image without explicit dimensions was skipped.");
1235
- return;
1236
- }
1237
- const k = {
1238
- kind: "image",
1239
- id: a(),
1240
- revision: 0,
1241
- src: P,
1242
- widthPx: O(Se(l.widthEmu)),
1243
- heightPx: O(Se(l.heightEmu)),
1244
- align: l.anchorAlign ?? (I === "justify" ? "left" : I)
1245
- };
1246
- if (l.anchored && l.anchorWrap === "square" && (k.wrap = "square"), l.anchorFloat) {
1247
- const y = l.anchorFloat;
1248
- k.anchor = {
1249
- behind: y.behind,
1250
- offsetXPx: O(Se(y.offsetXEmu)),
1251
- offsetYPx: O(Se(y.offsetYEmu)),
1252
- relFromH: y.relFromH,
1253
- relFromV: y.relFromV,
1254
- ...y.decorative ? { decorative: !0 } : {},
1255
- ...y.z !== void 0 ? { z: y.z } : {}
1256
- };
1257
- }
1258
- return k;
1259
- }
1260
- function W(l, g, I, P, k) {
1261
- let y = l;
1262
- const E = Oe(g);
1263
- if (g.linkRelId) {
1264
- const L = I(g.linkRelId);
1265
- L ? E.link = L : e.add("links-unresolved", "A hyperlink target could not be resolved and was dropped.");
1266
- } else g.linkAnchor && (E.link = `#${g.linkAnchor}`);
1267
- if (g.footnoteId !== void 0 && (y = u(g.footnoteId), E.footnoteRef = `fn${g.footnoteId}`, E.verticalAlign = "super"), P) {
1268
- E.sdtId = P;
1269
- const L = t[P];
1270
- L?.type === "checkbox" && y.length > 0 && (y = L.checked ? "☒" : "☐", E.fontFamily = pt.fontFamily);
1271
- }
1272
- return k && (E.fieldId = k), { text: y, style: E };
1273
- }
1274
- function re(l, g, I, P, k, y) {
1275
- const E = l.cell.rowSpan ?? 1, L = {
1276
- top: l.startRow === 0,
1277
- bottom: l.startRow + E - 1 === y - 1,
1278
- left: l.startCol === 0,
1279
- right: l.startCol + l.colSpan - 1 === k - 1
1280
- }, Y = l.ir?.shd ?? g.shd ?? I.shd;
1281
- if (Y && (l.cell.shading = Y), P) {
1282
- const U = { cell: l.ir?.borders, table: g.borders, style: I.borders };
1283
- l.cell.borders = Vt(U, L);
1284
- }
1285
- }
1286
- function Z(l, g, I) {
1287
- const P = (z) => {
1288
- const B = [];
1289
- for (const w of z.blocks)
1290
- w.kind === "paragraph" ? B.push(...oe(w, g, I)) : B.push(Z(w, g, I));
1291
- const D = { id: a(), blocks: B.length > 0 ? B : [R()] };
1292
- z.gridSpan > 1 && (D.colSpan = z.gridSpan);
1293
- const T = (w) => z.marginTwips?.[w] ?? l.cellMarginTwips?.[w] ?? bn[w];
1294
- return D.margin = Le({ top: T("top"), right: T("right"), bottom: T("bottom"), left: T("left") }), D;
1295
- }, k = Math.max(1, ...l.rows.map((z) => z.cells.reduce((B, D) => B + Math.max(1, D.gridSpan), 0))), y = new Array(k), E = l.rows.map((z, B) => {
1296
- const D = [];
1297
- let T = 0;
1298
- for (const w of z.cells) {
1299
- if (T >= k) break;
1300
- const F = Math.max(1, Math.min(w.gridSpan, k - T));
1301
- if (w.vMergeContinue) {
1302
- const Q = y[T];
1303
- Q ? Q.rowSpan = (Q.rowSpan ?? 1) + 1 : e.add("cell-vmerge-orphan", "A merged-cell continuation had no cell above to extend."), T += F;
1304
- continue;
1305
- }
1306
- const H = P(w);
1307
- D.push({ cell: H, ir: w, startRow: B, startCol: T, colSpan: F });
1308
- for (let Q = 0; Q < F && T + Q < k; Q++) y[T + Q] = H;
1309
- T += F;
1310
- }
1311
- for (; T < k; ) {
1312
- const w = { id: a(), blocks: [R()] };
1313
- D.push({ cell: w, ir: null, startRow: B, startCol: T, colSpan: 1 }), y[T] = w, T += 1;
1314
- }
1315
- return D;
1316
- }), L = l.styleId ? r(l.styleId) : {}, Y = !!L.borders || !!l.borders || !!l.bordersSpecified || l.rows.some((z) => z.cells.some((B) => B.borders || B.bordersSpecified));
1317
- for (const z of E) for (const B of z) re(B, l, L, Y, k, l.rows.length);
1318
- const U = E.map((z) => ({ cells: z.map((B) => B.cell) })), $ = { kind: "table", id: a(), revision: 0, rows: U };
1319
- return $.colFractions = En(l.colWidthsTwips, k), $;
1320
- }
1321
- function _(l) {
1322
- if (!l) return { ...Te, marginPx: { ...Te.marginPx } };
1323
- const g = {
1324
- pageWidthPx: l.pageWidthTwips !== void 0 ? O(X(l.pageWidthTwips)) : Te.pageWidthPx,
1325
- pageHeightPx: l.pageHeightTwips !== void 0 ? O(X(l.pageHeightTwips)) : Te.pageHeightPx,
1326
- marginPx: l.marginTwips ? Le(l.marginTwips) : { ...Te.marginPx }
1327
- };
1328
- return l.columns && (g.columns = { count: l.columns.count, gapPx: O(X(l.columns.spaceTwips ?? 720)) }), l.pageNumberStart !== void 0 && (g.pageNumberStart = l.pageNumberStart), l.headerDistTwips !== void 0 && (g.headerDistancePx = O(X(l.headerDistTwips))), l.footerDistTwips !== void 0 && (g.footerDistancePx = O(X(l.footerDistTwips))), g;
1329
- }
1330
- return {
1331
- mapBlocks: ee,
1332
- mapSection: _,
1333
- emptyParagraph: R,
1334
- lists: () => Object.fromEntries(m),
1335
- bookmarks: () => {
1336
- const l = {};
1337
- for (const [g, I] of f)
1338
- l[I.name] = { start: I.pos, end: p.get(g) ?? I.pos };
1339
- return l;
1340
- },
1341
- footnoteRefs: () => c.map((l) => ({ docxId: l, noteId: `fn${l}` })),
1342
- tocField: () => q
1343
- };
1344
- }
1345
- const Tn = {
1346
- decimal: "decimal",
1347
- decimalZero: "decimal",
1348
- lowerLetter: "lowerLetter",
1349
- upperLetter: "upperLetter",
1350
- lowerRoman: "lowerRoman",
1351
- upperRoman: "upperRoman",
1352
- bullet: "bullet"
1353
- };
1354
- function An(e) {
1355
- if (e.length !== 1) return e;
1356
- switch (e.charCodeAt(0)) {
1357
- case 61623:
1358
- // Symbol (filled round bullet)
1359
- case 183:
1360
- return "•";
1361
- // •
1362
- case 61607:
1363
- // Wingdings (filled square)
1364
- case 167:
1365
- return "▪";
1366
- // ▪
1367
- case 61551:
1368
- return "▫";
1369
- // ▫
1370
- case 61656:
1371
- return "‣";
1372
- // ‣
1373
- case 61692:
1374
- return "✔";
1375
- // ✔
1376
- default:
1377
- return e;
1378
- }
1379
- }
1380
- function Pn(e) {
1381
- const n = [];
1382
- for (let t = 0; t < 9; t++)
1383
- n.push(In(e.levels[t], t));
1384
- return { id: e.id, levels: n };
1385
- }
1386
- function In(e, n) {
1387
- if (!e)
1388
- return { format: "decimal", text: `%${n + 1}.`, indentLeftPx: 24 + n * 24, hangingPx: 18, start: 1 };
1389
- const t = Tn[e.format] ?? (e.format === "none" ? "bullet" : "decimal"), o = {
1390
- format: t,
1391
- text: t === "bullet" ? "" : e.lvlText,
1392
- indentLeftPx: e.indentLeftTwips !== void 0 ? O(X(e.indentLeftTwips)) : 24 + n * 24,
1393
- hangingPx: e.hangingTwips !== void 0 ? O(X(e.hangingTwips)) : 18,
1394
- start: e.start
1395
- };
1396
- if (t === "bullet" && (o.bulletChar = e.format === "none" ? "" : An(e.lvlText)), e.markerRunProps) {
1397
- const r = vt(e.markerRunProps);
1398
- Object.keys(r).length > 0 && (o.markerStyle = r);
1399
- }
1400
- return o;
1401
- }
1402
- const xn = {
1403
- left: "left",
1404
- start: "left",
1405
- num: "left",
1406
- center: "center",
1407
- right: "right",
1408
- end: "right",
1409
- decimal: "decimal"
1410
- }, Sn = {
1411
- dot: "dot",
1412
- middleDot: "dot",
1413
- hyphen: "dash",
1414
- underscore: "underscore"
1415
- };
1416
- function gt(e) {
1417
- const n = e.map((t) => {
1418
- const o = { posPx: O(X(t.posTwips)) }, r = t.val ? xn[t.val] : void 0;
1419
- r && r !== "left" && (o.align = r);
1420
- const i = t.leader ? Sn[t.leader] : void 0;
1421
- return i && (o.leader = i), o;
1422
- });
1423
- return n.sort((t, o) => t.posPx - o.posPx), n;
1424
- }
1425
- function En(e, n) {
1426
- const t = e && e.length === n && e.reduce((o, r) => o + r, 0) > 0 ? e.map((o) => Math.round(o / e.reduce((r, i) => r + i, 0) * 1e4) / 1e4) : Array.from({ length: n }, () => Math.round(1 / n * 1e4) / 1e4);
1427
- return t[t.length - 1] = Math.round((1 - t.slice(0, -1).reduce((o, r) => o + r, 0)) * 1e4) / 1e4, t;
1428
- }
1429
- const Cn = {
1430
- yellow: "#ffff00",
1431
- green: "#00ff00",
1432
- cyan: "#00ffff",
1433
- magenta: "#ff00ff",
1434
- blue: "#0000ff",
1435
- red: "#ff0000",
1436
- darkBlue: "#000080",
1437
- darkCyan: "#008080",
1438
- darkGreen: "#008000",
1439
- darkMagenta: "#800080",
1440
- darkRed: "#800000",
1441
- darkYellow: "#808000",
1442
- darkGray: "#808080",
1443
- lightGray: "#c0c0c0",
1444
- black: "#000000",
1445
- white: "#ffffff"
1446
- };
1447
- function Oe(e) {
1448
- const n = { ...pt };
1449
- return mt(n, e), n;
1450
- }
1451
- function mt(e, n) {
1452
- if (n.fontAscii && (e.fontFamily = `${n.fontAscii}, serif`), n.sizeHalfPoints !== void 0 && (e.fontSizePx = O(jt(n.sizeHalfPoints))), n.bold !== void 0 && (e.bold = n.bold), n.italic !== void 0 && (e.italic = n.italic), n.underline !== void 0 && (e.underline = n.underline), n.strikethrough !== void 0 && (e.strikethrough = n.strikethrough), n.color && n.color !== "auto" && (e.color = `#${n.color.toLowerCase()}`), n.highlight) {
1453
- const t = Cn[n.highlight];
1454
- t && (e.highlightColor = t);
1455
- }
1456
- n.vertAlign === "superscript" ? e.verticalAlign = "super" : n.vertAlign === "subscript" && (e.verticalAlign = "sub"), n.vanish && (e.hidden = !0);
1457
- }
1458
- function Mn(e) {
1459
- const n = {};
1460
- for (const [t, o] of Object.entries(e)) {
1461
- const r = { type: o.type };
1462
- o.alias !== void 0 && (r.alias = o.alias), o.tag !== void 0 && (r.tag = o.tag), o.placeholder && (r.placeholder = !0), o.listItems !== void 0 && (r.listItems = o.listItems), o.dateFormat !== void 0 && (r.dateFormat = o.dateFormat), o.checked !== void 0 && (r.checked = o.checked), o.lockContent && (r.lockContent = !0), o.lockControl && (r.lockControl = !0), n[t] = r;
1463
- }
1464
- return n;
1465
- }
1466
- function wt(e, n = /* @__PURE__ */ new Set()) {
1467
- for (const t of e)
1468
- if (t.kind === "paragraph")
1469
- t.props.styleId && n.add(t.props.styleId);
1470
- else
1471
- for (const o of t.rows) for (const r of o.cells) wt(r.blocks, n);
1472
- return n;
1473
- }
1474
- function vt(e) {
1475
- const n = {};
1476
- return mt(n, e), n;
1477
- }
1478
- function Fn(e) {
1479
- const n = {};
1480
- return e.align && (n.align = e.align), e.lineHeight !== void 0 && (n.lineHeight = O(e.lineHeight)), e.spaceBeforeTwips !== void 0 && (n.spaceBeforePx = O(X(e.spaceBeforeTwips))), e.spaceAfterTwips !== void 0 && (n.spaceAfterPx = O(X(e.spaceAfterTwips))), e.indentLeftTwips !== void 0 && (n.indentLeftPx = O(X(e.indentLeftTwips))), e.indentRightTwips !== void 0 && (n.indentRightPx = O(X(e.indentRightTwips))), e.indentFirstLineTwips !== void 0 && (n.indentFirstLinePx = O(X(e.indentFirstLineTwips))), e.keepWithNext && (n.keepWithNext = !0), e.keepLinesTogether && (n.keepLinesTogether = !0), e.tabStops && (n.tabStops = gt(e.tabStops)), n;
1481
- }
1482
- function Rn(e, n) {
1483
- if (e.styles.size === 0) return;
1484
- const t = /* @__PURE__ */ new Set(), o = (i) => {
1485
- for (let s = e.styles.get(i); s && !t.has(s.id); s = s.basedOnId ? e.styles.get(s.basedOnId) : void 0)
1486
- s.type === "paragraph" && t.add(s.id);
1487
- };
1488
- for (const i of n) o(i);
1489
- if (e.defaultParaStyleId && o(e.defaultParaStyleId), t.size === 0) return;
1490
- const r = [];
1491
- for (const i of t) {
1492
- const s = e.styles.get(i), a = {
1493
- id: i,
1494
- name: s.name ?? i,
1495
- char: vt(s.rPr),
1496
- para: Fn(s.pPr)
1497
- };
1498
- s.basedOnId && t.has(s.basedOnId) && (a.basedOn = s.basedOnId), r.push(a);
1499
- }
1500
- return r.sort(
1501
- (i, s) => i.id === e.defaultParaStyleId ? -1 : s.id === e.defaultParaStyleId ? 1 : i.name.localeCompare(s.name)
1502
- ), { styles: r, defaultStyleId: e.defaultParaStyleId ?? r[0].id };
1503
- }
1504
- function ot(e) {
1505
- const n = { ...kn };
1506
- return e.align && (n.align = e.align), e.lineHeight !== void 0 && (n.lineHeight = O(e.lineHeight)), e.spaceBeforeTwips !== void 0 && (n.spaceBeforePx = O(X(e.spaceBeforeTwips))), e.spaceAfterTwips !== void 0 && (n.spaceAfterPx = O(X(e.spaceAfterTwips))), e.indentLeftTwips !== void 0 && (n.indentLeftPx = O(X(e.indentLeftTwips))), e.indentRightTwips !== void 0 && (n.indentRightPx = O(X(e.indentRightTwips))), e.indentFirstLineTwips !== void 0 && (n.indentFirstLinePx = O(X(e.indentFirstLineTwips))), e.keepWithNext && (n.keepWithNext = !0), e.keepLinesTogether && (n.keepLinesTogether = !0), e.tabStops && (n.tabStops = gt(e.tabStops)), e.pageBreakBefore && (n.pageBreakBefore = !0), e.outlineLevel !== void 0 && (n.outlineLevel = e.outlineLevel), e.styleId && (n.namedStyle = e.styleId), n;
1507
- }
1508
- const Ln = {
1509
- png: "image/png",
1510
- jpg: "image/jpeg",
1511
- jpeg: "image/jpeg",
1512
- gif: "image/gif",
1513
- bmp: "image/bmp",
1514
- webp: "image/webp",
1515
- svg: "image/svg+xml"
1516
- };
1517
- function On(e, n, t, o) {
1518
- const r = /* @__PURE__ */ new Map(), i = [];
1519
- return {
1520
- resolve(s) {
1521
- const a = n.get(s);
1522
- if (!a) {
1523
- t.add("media-missing", "An image reference had no matching relationship — skipped.");
1524
- return;
1525
- }
1526
- if (r.has(a.target)) return r.get(a.target);
1527
- if (a.external) {
1528
- const c = /^https?:\/\//i.test(a.target);
1529
- c ? t.add("media-external", "Linked (external) images load from their original URL.") : t.add(
1530
- "media-external-unreachable",
1531
- "Linked images pointing at local files can't be loaded in the browser — skipped."
1532
- );
1533
- const u = c ? a.target : void 0;
1534
- return r.set(a.target, u), u;
1535
- }
1536
- let f;
1537
- const p = a.target.slice(a.target.lastIndexOf(".") + 1).toLowerCase(), d = Ln[p];
1538
- if (!d)
1539
- t.add(
1540
- "media-unsupported",
1541
- `Some images use formats browsers can't display (.${p}, typically metafiles) — skipped.`
1542
- );
1543
- else {
1544
- const c = e.part(a.target);
1545
- if (!c)
1546
- t.add("media-missing", "An image reference had no matching relationship — skipped.");
1547
- else {
1548
- const u = new Uint8Array(c);
1549
- f = URL.createObjectURL(new Blob([u], { type: d })), i.push(f);
1550
- }
1551
- }
1552
- return r.set(a.target, f), f;
1553
- },
1554
- urls: () => [...i]
1555
- };
1556
- }
1557
- const Nn = /* @__PURE__ */ new Map();
1558
- function Bn(e) {
1559
- const n = /* @__PURE__ */ new Map(), t = de(ue(e, "numbering.xml"), "w:numbering");
1560
- if (!t) return n;
1561
- const o = /* @__PURE__ */ new Map();
1562
- for (const r of ne(t, "w:abstractNum")) {
1563
- const i = v(r, "w:abstractNumId");
1564
- i !== void 0 && o.set(i, Dn(r));
1565
- }
1566
- for (const r of ne(t, "w:num")) {
1567
- const i = v(r, "w:numId");
1568
- if (i === void 0) continue;
1569
- const s = se(r, "w:abstractNumId"), a = s !== void 0 ? o.get(s) : void 0;
1570
- if (!a) continue;
1571
- const f = a.map((p) => ({ ...p }));
1572
- for (const p of ne(r, "w:lvlOverride")) {
1573
- const d = A(p, "w:ilvl") ?? 0, c = A(h(p, "w:startOverride"), "w:val"), u = h(p, "w:lvl");
1574
- u && f[d] && (f[d] = kt(u, d)), c !== void 0 && f[d] && (f[d].start = c);
1575
- }
1576
- n.set(i, { id: i, levels: f });
1577
- }
1578
- return n;
1579
- }
1580
- function Dn(e) {
1581
- const n = [];
1582
- for (const t of ne(e, "w:lvl")) {
1583
- const o = A(t, "w:ilvl") ?? n.length;
1584
- n[o] = kt(t, o);
1585
- }
1586
- return n;
1587
- }
1588
- function kt(e, n) {
1589
- const t = h(e, "w:lvlText"), o = {
1590
- format: se(e, "w:numFmt") ?? "decimal",
1591
- lvlText: t ? v(t, "w:val") ?? "" : `%${n + 1}.`,
1592
- start: A(h(e, "w:start"), "w:val") ?? 1
1593
- }, r = h(e, "w:pPr"), i = r && h(r, "w:ind");
1594
- if (i) {
1595
- const a = A(i, "w:left") ?? A(i, "w:start");
1596
- a !== void 0 && (o.indentLeftTwips = a);
1597
- const f = A(i, "w:hanging");
1598
- f !== void 0 && (o.hangingTwips = f);
1599
- }
1600
- const s = h(e, "w:rPr");
1601
- return s && (o.markerRunProps = be(s)), o;
1602
- }
1603
- function Hn(e, n) {
1604
- const t = n.includes("/") ? n.slice(0, n.lastIndexOf("/")) : "", o = /* @__PURE__ */ new Map(), r = de(ue(e, `${n} rels`), "Relationships");
1605
- if (!r) return o;
1606
- for (const i of J(r)) {
1607
- if (i.tagName !== "Relationship") continue;
1608
- const s = v(i, "Id"), a = v(i, "Type"), f = v(i, "Target");
1609
- if (!s || !a || !f) continue;
1610
- const p = v(i, "TargetMode") === "External";
1611
- o.set(s, { id: s, type: a, target: p ? f : Un(t, f), external: p });
1612
- }
1613
- return o;
1614
- }
1615
- function Un(e, n) {
1616
- if (n.startsWith("/")) return n.slice(1);
1617
- const t = e === "" ? [] : e.split("/");
1618
- for (const o of n.split("/"))
1619
- o === ".." ? t.pop() : o !== "." && o !== "" && t.push(o);
1620
- return t.join("/");
1621
- }
1622
- function bt(e, n) {
1623
- for (const t of e.values())
1624
- if (t.type.endsWith(`/${n}`)) return t;
1625
- }
1626
- function zn(e) {
1627
- const n = e.lastIndexOf("/"), t = n >= 0 ? e.slice(0, n + 1) : "", o = n >= 0 ? e.slice(n + 1) : e;
1628
- return `${t}_rels/${o}.rels`;
1629
- }
1630
- const Gn = { colors: /* @__PURE__ */ new Map() }, _n = {
1631
- dark1: "dk1",
1632
- light1: "lt1",
1633
- dark2: "dk2",
1634
- light2: "lt2",
1635
- text1: "dk1",
1636
- background1: "lt1",
1637
- text2: "dk2",
1638
- background2: "lt2",
1639
- hyperlink: "hlink",
1640
- followedHyperlink: "folHlink"
1641
- };
1642
- function jn(e, n) {
1643
- return e.colors.get(_n[n] ?? n);
1644
- }
1645
- function Wn(e, n) {
1646
- if (n.startsWith("major")) return e.majorLatin;
1647
- if (n.startsWith("minor")) return e.minorLatin;
1648
- }
1649
- function $n(e) {
1650
- const n = { colors: /* @__PURE__ */ new Map() }, t = de(ue(e, "theme"), "a:theme"), o = t && h(t, "a:themeElements");
1651
- if (!o) return n;
1652
- const r = h(o, "a:fontScheme");
1653
- if (r) {
1654
- const s = rt(h(r, "a:majorFont"));
1655
- s && (n.majorLatin = s);
1656
- const a = rt(h(r, "a:minorFont"));
1657
- a && (n.minorLatin = a);
1658
- }
1659
- const i = h(o, "a:clrScheme");
1660
- if (i)
1661
- for (const s of J(i)) {
1662
- const a = s.tagName.replace(/^a:/, ""), f = h(s, "a:srgbClr"), p = h(s, "a:sysClr"), d = (f && v(f, "val")) ?? (p && v(p, "lastClr"));
1663
- d && n.colors.set(a, d);
1664
- }
1665
- return n;
1666
- }
1667
- function rt(e) {
1668
- const n = e && h(e, "a:latin");
1669
- return n && v(n, "typeface") || void 0;
1670
- }
1671
- const Xn = { docDefaultsRun: {}, docDefaultsPara: {}, styles: /* @__PURE__ */ new Map() };
1672
- function Vn(e, n) {
1673
- const t = { docDefaultsRun: {}, docDefaultsPara: {}, styles: /* @__PURE__ */ new Map() }, o = de(ue(e, "styles.xml"), "w:styles");
1674
- if (!o) return t;
1675
- const r = h(o, "w:docDefaults");
1676
- if (r) {
1677
- const i = h(r, "w:rPrDefault"), s = i && h(i, "w:rPr");
1678
- s && (t.docDefaultsRun = be(s));
1679
- const a = h(r, "w:pPrDefault"), f = a && h(a, "w:pPr");
1680
- f && (t.docDefaultsPara = Ue(f, n));
1681
- }
1682
- for (const i of ne(o, "w:style")) {
1683
- const s = v(i, "w:styleId"), a = v(i, "w:type");
1684
- if (!s || !a) continue;
1685
- const f = h(i, "w:rPr"), p = h(i, "w:pPr"), d = {
1686
- id: s,
1687
- type: a,
1688
- rPr: f ? be(f) : {},
1689
- pPr: p ? Ue(p, n) : {}
1690
- }, c = se(i, "w:name");
1691
- c && (d.name = c);
1692
- const u = se(i, "w:basedOn");
1693
- if (u && (d.basedOnId = u), a === "table") {
1694
- const S = h(i, "w:tblPr");
1695
- if (S) {
1696
- const x = Xe(h(S, "w:tblBorders"));
1697
- x && (d.tblBorders = x);
1698
- const b = Ve(h(S, "w:shd"));
1699
- b && (d.tblShd = b);
1700
- }
1701
- }
1702
- t.styles.set(s, d);
1703
- const m = v(i, "w:default");
1704
- a === "paragraph" && (m === "1" || m === "true") && (t.defaultParaStyleId = s);
1705
- }
1706
- return t;
1707
- }
1708
- function Yn(e, n) {
1709
- let t, o;
1710
- const r = /* @__PURE__ */ new Set(), i = [];
1711
- for (let a = e.styles.get(n); a && !r.has(a.id); a = a.basedOnId ? e.styles.get(a.basedOnId) : void 0)
1712
- r.add(a.id), i.unshift(a);
1713
- for (const a of i)
1714
- t = Xt(t, a.tblBorders), a.tblShd !== void 0 && (o = a.tblShd);
1715
- const s = {};
1716
- return t && (s.borders = t), o !== void 0 && (s.shd = o), s;
1717
- }
1718
- const Kn = ["bold", "italic", "strikethrough", "vanish"];
1719
- function qn(e, n) {
1720
- const t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), r = (d) => {
1721
- const c = [], u = /* @__PURE__ */ new Set();
1722
- for (let m = e.styles.get(d); m && !u.has(m.id); m = m.basedOnId ? e.styles.get(m.basedOnId) : void 0)
1723
- u.add(m.id), c.unshift(m);
1724
- return c;
1725
- }, i = (d) => {
1726
- let c = t.get(d);
1727
- return c || (c = r(d).reduce((u, m) => Ce(u, m.rPr), {}), t.set(d, c)), c;
1728
- }, s = (d) => {
1729
- let c = o.get(d);
1730
- return c || (c = r(d).reduce((u, m) => Fe(u, m.pPr), {}), o.set(d, c)), c;
1731
- }, a = /* @__PURE__ */ new Map(), f = (d, c) => {
1732
- const u = `${d ?? ""}|${c ?? ""}`;
1733
- let m = a.get(u);
1734
- if (m) return m;
1735
- const S = d ? i(d) : {}, x = c ? i(c) : {};
1736
- m = Ce(Ce(e.docDefaultsRun, S), x);
1737
- for (const b of Kn) {
1738
- if (e.docDefaultsRun[b] === void 0 && S[b] === void 0 && x[b] === void 0) continue;
1739
- const R = e.docDefaultsRun[b] ?? !1;
1740
- m[b] = R !== (S[b] === !0) != (x[b] === !0);
1741
- }
1742
- return a.set(u, m), m;
1743
- };
1744
- return {
1745
- run(d, c) {
1746
- const u = d ?? e.defaultParaStyleId, m = f(u, c.styleId);
1747
- return p(Ce(m, c));
1748
- },
1749
- para(d) {
1750
- const c = d.styleId ?? e.defaultParaStyleId, u = c ? s(c) : {}, m = Fe(Fe(e.docDefaultsPara, u), d);
1751
- return d.styleId ? m.styleId = d.styleId : delete m.styleId, m;
1752
- },
1753
- isHeading(d) {
1754
- if (!d) return !1;
1755
- const c = (u) => u !== void 0 && /(^|\s)heading(\s|\d|$)/i.test(u);
1756
- return r(d).some((u) => c(u.name) || c(u.id));
1757
- }
1758
- };
1759
- function p(d) {
1760
- const c = { ...d };
1761
- if (!c.fontAscii && c.fontThemeAscii) {
1762
- const u = Wn(n, c.fontThemeAscii);
1763
- u && (c.fontAscii = u);
1764
- }
1765
- if ((c.color === void 0 || c.color === "auto") && c.colorTheme) {
1766
- const u = jn(n, c.colorTheme);
1767
- u && (c.color = u);
1768
- }
1769
- return c;
1770
- }
1771
- }
1772
- function Ce(e, n) {
1773
- const t = { ...e };
1774
- return (n.fontAscii !== void 0 || n.fontThemeAscii !== void 0) && (delete t.fontAscii, delete t.fontThemeAscii), (n.color !== void 0 || n.colorTheme !== void 0) && (delete t.color, delete t.colorTheme), Fe(t, n);
1775
- }
1776
- function Fe(e, n) {
1777
- const t = { ...e };
1778
- for (const [o, r] of Object.entries(n))
1779
- r !== void 0 && (t[o] = r);
1780
- return t;
1781
- }
1782
- var ae = Uint8Array, ve = Uint16Array, Zn = Int32Array, yt = new ae([
1783
- 0,
1784
- 0,
1785
- 0,
1786
- 0,
1787
- 0,
1788
- 0,
1789
- 0,
1790
- 0,
1791
- 1,
1792
- 1,
1793
- 1,
1794
- 1,
1795
- 2,
1796
- 2,
1797
- 2,
1798
- 2,
1799
- 3,
1800
- 3,
1801
- 3,
1802
- 3,
1803
- 4,
1804
- 4,
1805
- 4,
1806
- 4,
1807
- 5,
1808
- 5,
1809
- 5,
1810
- 5,
1811
- 0,
1812
- /* unused */
1813
- 0,
1814
- 0,
1815
- /* impossible */
1816
- 0
1817
- ]), Tt = new ae([
1818
- 0,
1819
- 0,
1820
- 0,
1821
- 0,
1822
- 1,
1823
- 1,
1824
- 2,
1825
- 2,
1826
- 3,
1827
- 3,
1828
- 4,
1829
- 4,
1830
- 5,
1831
- 5,
1832
- 6,
1833
- 6,
1834
- 7,
1835
- 7,
1836
- 8,
1837
- 8,
1838
- 9,
1839
- 9,
1840
- 10,
1841
- 10,
1842
- 11,
1843
- 11,
1844
- 12,
1845
- 12,
1846
- 13,
1847
- 13,
1848
- /* unused */
1849
- 0,
1850
- 0
1851
- ]), Qn = new ae([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), At = function(e, n) {
1852
- for (var t = new ve(31), o = 0; o < 31; ++o)
1853
- t[o] = n += 1 << e[o - 1];
1854
- for (var r = new Zn(t[30]), o = 1; o < 30; ++o)
1855
- for (var i = t[o]; i < t[o + 1]; ++i)
1856
- r[i] = i - t[o] << 5 | o;
1857
- return { b: t, r };
1858
- }, Pt = At(yt, 2), It = Pt.b, Jn = Pt.r;
1859
- It[28] = 258, Jn[258] = 28;
1860
- var eo = At(Tt, 0), to = eo.b, Ge = new ve(32768);
1861
- for (var V = 0; V < 32768; ++V) {
1862
- var he = (V & 43690) >> 1 | (V & 21845) << 1;
1863
- he = (he & 52428) >> 2 | (he & 13107) << 2, he = (he & 61680) >> 4 | (he & 3855) << 4, Ge[V] = ((he & 65280) >> 8 | (he & 255) << 8) >> 1;
1864
- }
1865
- var Pe = (function(e, n, t) {
1866
- for (var o = e.length, r = 0, i = new ve(n); r < o; ++r)
1867
- e[r] && ++i[e[r] - 1];
1868
- var s = new ve(n);
1869
- for (r = 1; r < n; ++r)
1870
- s[r] = s[r - 1] + i[r - 1] << 1;
1871
- var a;
1872
- if (t) {
1873
- a = new ve(1 << n);
1874
- var f = 15 - n;
1875
- for (r = 0; r < o; ++r)
1876
- if (e[r])
1877
- for (var p = r << 4 | e[r], d = n - e[r], c = s[e[r] - 1]++ << d, u = c | (1 << d) - 1; c <= u; ++c)
1878
- a[Ge[c] >> f] = p;
1879
- } else
1880
- for (a = new ve(o), r = 0; r < o; ++r)
1881
- e[r] && (a[r] = Ge[s[e[r] - 1]++] >> 15 - e[r]);
1882
- return a;
1883
- }), xe = new ae(288);
1884
- for (var V = 0; V < 144; ++V)
1885
- xe[V] = 8;
1886
- for (var V = 144; V < 256; ++V)
1887
- xe[V] = 9;
1888
- for (var V = 256; V < 280; ++V)
1889
- xe[V] = 7;
1890
- for (var V = 280; V < 288; ++V)
1891
- xe[V] = 8;
1892
- var xt = new ae(32);
1893
- for (var V = 0; V < 32; ++V)
1894
- xt[V] = 5;
1895
- var no = /* @__PURE__ */ Pe(xe, 9, 1), oo = /* @__PURE__ */ Pe(xt, 5, 1), Ne = function(e) {
1896
- for (var n = e[0], t = 1; t < e.length; ++t)
1897
- e[t] > n && (n = e[t]);
1898
- return n;
1899
- }, le = function(e, n, t) {
1900
- var o = n / 8 | 0;
1901
- return (e[o] | e[o + 1] << 8) >> (n & 7) & t;
1902
- }, Be = function(e, n) {
1903
- var t = n / 8 | 0;
1904
- return (e[t] | e[t + 1] << 8 | e[t + 2] << 16) >> (n & 7);
1905
- }, ro = function(e) {
1906
- return (e + 7) / 8 | 0;
1907
- }, Ke = function(e, n, t) {
1908
- return (n == null || n < 0) && (n = 0), (t == null || t > e.length) && (t = e.length), new ae(e.subarray(n, t));
1909
- }, io = [
1910
- "unexpected EOF",
1911
- "invalid block type",
1912
- "invalid length/literal",
1913
- "invalid distance",
1914
- "stream finished",
1915
- "no stream handler",
1916
- ,
1917
- // determined by compression function
1918
- "no callback",
1919
- "invalid UTF-8 data",
1920
- "extra field too long",
1921
- "date not in range 1980-2099",
1922
- "filename too long",
1923
- "stream finishing",
1924
- "invalid zip data"
1925
- // determined by unknown compression method
1926
- ], ie = function(e, n, t) {
1927
- var o = new Error(n || io[e]);
1928
- if (o.code = e, Error.captureStackTrace && Error.captureStackTrace(o, ie), !t)
1929
- throw o;
1930
- return o;
1931
- }, so = function(e, n, t, o) {
1932
- var r = e.length, i = o ? o.length : 0;
1933
- if (!r || n.f && !n.l)
1934
- return t || new ae(0);
1935
- var s = !t, a = s || n.i != 2, f = n.i;
1936
- s && (t = new ae(r * 3));
1937
- var p = function(w) {
1938
- var F = t.length;
1939
- if (w > F) {
1940
- var H = new ae(Math.max(F * 2, w));
1941
- H.set(t), t = H;
1942
- }
1943
- }, d = n.f || 0, c = n.p || 0, u = n.b || 0, m = n.l, S = n.d, x = n.m, b = n.n, R = r * 8;
1944
- do {
1945
- if (!m) {
1946
- d = le(e, c, 1);
1947
- var M = le(e, c + 1, 3);
1948
- if (c += 3, M)
1949
- if (M == 1)
1950
- m = no, S = oo, x = 9, b = 5;
1951
- else if (M == 2) {
1952
- var G = le(e, c, 31) + 257, q = le(e, c + 10, 15) + 4, ee = G + le(e, c + 5, 31) + 1;
1953
- c += 14;
1954
- for (var te = new ae(ee), oe = new ae(19), C = 0; C < q; ++C)
1955
- oe[Qn[C]] = le(e, c + C * 3, 7);
1956
- c += q * 3;
1957
- for (var W = Ne(oe), re = (1 << W) - 1, Z = Pe(oe, W, 1), C = 0; C < ee; ) {
1958
- var _ = Z[le(e, c, re)];
1959
- c += _ & 15;
1960
- var N = _ >> 4;
1961
- if (N < 16)
1962
- te[C++] = N;
1963
- else {
1964
- var l = 0, g = 0;
1965
- for (N == 16 ? (g = 3 + le(e, c, 3), c += 2, l = te[C - 1]) : N == 17 ? (g = 3 + le(e, c, 7), c += 3) : N == 18 && (g = 11 + le(e, c, 127), c += 7); g--; )
1966
- te[C++] = l;
1967
- }
1968
- }
1969
- var I = te.subarray(0, G), P = te.subarray(G);
1970
- x = Ne(I), b = Ne(P), m = Pe(I, x, 1), S = Pe(P, b, 1);
1971
- } else
1972
- ie(1);
1973
- else {
1974
- var N = ro(c) + 4, j = e[N - 4] | e[N - 3] << 8, K = N + j;
1975
- if (K > r) {
1976
- f && ie(0);
1977
- break;
1978
- }
1979
- a && p(u + j), t.set(e.subarray(N, K), u), n.b = u += j, n.p = c = K * 8, n.f = d;
1980
- continue;
1981
- }
1982
- if (c > R) {
1983
- f && ie(0);
1984
- break;
1985
- }
1986
- }
1987
- a && p(u + 131072);
1988
- for (var k = (1 << x) - 1, y = (1 << b) - 1, E = c; ; E = c) {
1989
- var l = m[Be(e, c) & k], L = l >> 4;
1990
- if (c += l & 15, c > R) {
1991
- f && ie(0);
1992
- break;
1993
- }
1994
- if (l || ie(2), L < 256)
1995
- t[u++] = L;
1996
- else if (L == 256) {
1997
- E = c, m = null;
1998
- break;
1999
- } else {
2000
- var Y = L - 254;
2001
- if (L > 264) {
2002
- var C = L - 257, U = yt[C];
2003
- Y = le(e, c, (1 << U) - 1) + It[C], c += U;
2004
- }
2005
- var $ = S[Be(e, c) & y], z = $ >> 4;
2006
- $ || ie(3), c += $ & 15;
2007
- var P = to[z];
2008
- if (z > 3) {
2009
- var U = Tt[z];
2010
- P += Be(e, c) & (1 << U) - 1, c += U;
2011
- }
2012
- if (c > R) {
2013
- f && ie(0);
2014
- break;
2015
- }
2016
- a && p(u + 131072);
2017
- var B = u + Y;
2018
- if (u < P) {
2019
- var D = i - P, T = Math.min(P, B);
2020
- for (D + u < 0 && ie(3); u < T; ++u)
2021
- t[u] = o[D + u];
2022
- }
2023
- for (; u < B; ++u)
2024
- t[u] = t[u - P];
2025
- }
2026
- }
2027
- n.l = m, n.p = E, n.b = u, n.f = d, m && (d = 1, n.m = x, n.d = S, n.n = b);
2028
- } while (!d);
2029
- return u != t.length && s ? Ke(t, 0, u) : t.subarray(0, u);
2030
- }, ao = /* @__PURE__ */ new ae(0), fe = function(e, n) {
2031
- return e[n] | e[n + 1] << 8;
2032
- }, ce = function(e, n) {
2033
- return (e[n] | e[n + 1] << 8 | e[n + 2] << 16 | e[n + 3] << 24) >>> 0;
2034
- }, De = function(e, n) {
2035
- return ce(e, n) + ce(e, n + 4) * 4294967296;
2036
- };
2037
- function co(e, n) {
2038
- return so(e, { i: 2 }, n && n.out, n && n.dictionary);
2039
- }
2040
- var _e = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), lo = 0;
2041
- try {
2042
- _e.decode(ao, { stream: !0 }), lo = 1;
2043
- } catch {
2044
- }
2045
- var fo = function(e) {
2046
- for (var n = "", t = 0; ; ) {
2047
- var o = e[t++], r = (o > 127) + (o > 223) + (o > 239);
2048
- if (t + r > e.length)
2049
- return { s: n, r: Ke(e, t - 1) };
2050
- r ? r == 3 ? (o = ((o & 15) << 18 | (e[t++] & 63) << 12 | (e[t++] & 63) << 6 | e[t++] & 63) - 65536, n += String.fromCharCode(55296 | o >> 10, 56320 | o & 1023)) : r & 1 ? n += String.fromCharCode((o & 31) << 6 | e[t++] & 63) : n += String.fromCharCode((o & 15) << 12 | (e[t++] & 63) << 6 | e[t++] & 63) : n += String.fromCharCode(o);
2051
- }
2052
- };
2053
- function St(e, n) {
2054
- if (n) {
2055
- for (var t = "", o = 0; o < e.length; o += 16384)
2056
- t += String.fromCharCode.apply(null, e.subarray(o, o + 16384));
2057
- return t;
2058
- } else {
2059
- if (_e)
2060
- return _e.decode(e);
2061
- var r = fo(e), i = r.s, t = r.r;
2062
- return t.length && ie(8), i;
2063
- }
2064
- }
2065
- var uo = function(e, n) {
2066
- return n + 30 + fe(e, n + 26) + fe(e, n + 28);
2067
- }, ho = function(e, n, t) {
2068
- var o = fe(e, n + 28), r = fe(e, n + 30), i = St(e.subarray(n + 46, n + 46 + o), !(fe(e, n + 8) & 2048)), s = n + 46 + o, a = po(e, s, r, t, ce(e, n + 20), ce(e, n + 24), ce(e, n + 42)), f = a[0], p = a[1], d = a[2];
2069
- return [fe(e, n + 10), f, p, i, s + r + fe(e, n + 32), d];
2070
- }, po = function(e, n, t, o, r, i, s) {
2071
- var a = r == 4294967295, f = i == 4294967295, p = s == 4294967295, d = n + t, c = a + f + p;
2072
- if (o && c) {
2073
- for (; n + 4 < d; n += 4 + fe(e, n + 2))
2074
- if (fe(e, n) == 1)
2075
- return [
2076
- a ? De(e, n + 4 + 8 * f) : r,
2077
- f ? De(e, n + 4) : i,
2078
- p ? De(e, n + 4 + 8 * (f + a)) : s,
2079
- 1
2080
- ];
2081
- o < 2 && ie(13);
2082
- }
2083
- return [r, i, s, 0];
2084
- };
2085
- function it(e, n) {
2086
- for (var t = {}, o = e.length - 22; ce(e, o) != 101010256; --o)
2087
- (!o || e.length - o > 65558) && ie(13);
2088
- var r = fe(e, o + 8);
2089
- if (!r)
2090
- return {};
2091
- var i = ce(e, o + 16), s = ce(e, o - 20) == 117853008;
2092
- if (s) {
2093
- var a = ce(e, o - 12);
2094
- s = ce(e, a) == 101075792, s && (r = ce(e, a + 32), i = ce(e, a + 48));
2095
- }
2096
- for (var f = n && n.filter, p = 0; p < r; ++p) {
2097
- var d = ho(e, i, s), c = d[0], u = d[1], m = d[2], S = d[3], x = d[4], b = d[5], R = uo(e, b);
2098
- i = x, (!f || f({
2099
- name: S,
2100
- size: u,
2101
- originalSize: m,
2102
- compression: c
2103
- })) && (c ? c == 8 ? t[S] = co(e.subarray(R, R + u), { out: new ae(m) }) : ie(14, "unknown compression type " + c) : t[S] = Ke(e, R, R + u));
2104
- }
2105
- return t;
2106
- }
2107
- const go = [80, 75], mo = [208, 207, 17, 224], st = (e, n) => n.every((t, o) => e[o] === t);
2108
- function wo(e) {
2109
- if (st(e, mo))
2110
- throw new pe("ENCRYPTED", "Password-protected documents are not supported.");
2111
- if (!st(e, go))
2112
- throw new pe("NOT_ZIP", "Not a .docx file (zip container signature missing).");
2113
- const n = (s) => /^word\/media\//.test(s);
2114
- let t, o;
2115
- try {
2116
- o = [], t = it(e, {
2117
- filter: (s) => n(s.name) ? (o.push(s.name), !1) : !0
2118
- });
2119
- } catch (s) {
2120
- throw new pe("NOT_ZIP", `Corrupt zip container: ${s instanceof Error ? s.message : String(s)}`);
2121
- }
2122
- const r = /* @__PURE__ */ new Map(), i = (s) => {
2123
- const a = it(e, { filter: (f) => f.name === s })[s];
2124
- return a && (t[s] = a), a;
2125
- };
2126
- return {
2127
- part: (s) => t[s] ?? (n(s) ? i(s) : void 0),
2128
- text(s) {
2129
- const a = r.get(s);
2130
- if (a !== void 0) return a;
2131
- const f = t[s];
2132
- if (!f) return;
2133
- const p = St(f);
2134
- return r.set(s, p), p;
2135
- },
2136
- names: () => [...Object.keys(t), ...o.filter((s) => !(s in t))]
2137
- };
2138
- }
2139
- function vo(e, n, t) {
2140
- const o = (y, E) => n?.(y, E), r = new zt(), i = [];
2141
- o("unzip", 0);
2142
- const s = wo(e);
2143
- o("unzip", 1);
2144
- const a = s.text("[Content_Types].xml"), f = (a !== void 0 ? _t(a) : void 0) ?? "word/document.xml", p = s.text(f);
2145
- if (p === void 0)
2146
- throw new pe("NO_DOCUMENT_PART", `Main document part "${f}" not found in the archive.`);
2147
- const d = je(s, f);
2148
- o("styles", 0);
2149
- const c = Me(s, d, "styles") ?? s.text("word/styles.xml"), u = c !== void 0 ? Vn(c, r) : Xn, m = Me(s, d, "theme") ?? s.text("word/theme/theme1.xml"), S = m !== void 0 ? $n(m) : Gn, x = qn(u, S), b = Me(s, d, "numbering") ?? s.text("word/numbering.xml"), R = b !== void 0 ? Bn(b) : Nn;
2150
- o("styles", 1), o("parse", 0);
2151
- const M = qt(p, f, r);
2152
- o("parse", 1), o("map", 0);
2153
- const N = {
2154
- w: M.section?.pageWidthTwips ?? 12240,
2155
- h: M.section?.pageHeightTwips ?? 15840
2156
- }, j = yn(
2157
- r,
2158
- x,
2159
- M.sdts,
2160
- R,
2161
- (y) => Yn(u, y),
2162
- N
2163
- ), K = [], G = (y) => {
2164
- const E = On(s, y, r);
2165
- return K.push(E), E;
2166
- }, q = j.mapBlocks(M.blocks, G(d), We(d));
2167
- q.length === 0 && q.push(j.emptyParagraph());
2168
- const ee = j.mapSection(M.section), te = Me(s, d, "settings") ?? s.text("word/settings.xml"), oe = te !== void 0 && bo(te);
2169
- at(ee, "header", M.section?.headerRefs, M.section?.titlePg ?? !1, oe, s, d, j, G, r, M.sdts), at(ee, "footer", M.section?.footerRefs, M.section?.titlePg ?? !1, oe, s, d, j, G, r, M.sdts);
2170
- const C = yo(d, "footnotes") ?? "word/footnotes.xml", W = s.text(C), re = W !== void 0 ? wn(W, C, r, M.sdts) : /* @__PURE__ */ new Map(), Z = {};
2171
- if (re.size > 0) {
2172
- const y = je(s, C), E = G(y), L = We(y);
2173
- for (const { docxId: Y, noteId: U } of j.footnoteRefs()) {
2174
- const $ = re.get(Y);
2175
- if (!$) {
2176
- r.add("footnote-missing", "A footnote reference had no matching note body.");
2177
- continue;
2178
- }
2179
- const z = j.mapBlocks($, E, L), B = z.filter((D) => D.kind === "paragraph");
2180
- B.length < z.length && r.add("footnote-tables", "Tables inside footnotes were dropped (footnotes hold paragraphs only)."), B.length > 0 && (Z[U] = B);
2181
- }
2182
- }
2183
- o("map", 1);
2184
- const _ = { section: ee, blocks: q };
2185
- Object.keys(Z).length > 0 && (_.footnotes = Z);
2186
- const l = Mn(M.sdts);
2187
- Object.keys(l).length > 0 && (_.sdts = l);
2188
- const g = j.lists();
2189
- Object.keys(g).length > 0 && (_.lists = g);
2190
- const I = j.bookmarks();
2191
- Object.keys(I).length > 0 && (_.bookmarks = I);
2192
- const P = Rn(u, wt(M.blocks));
2193
- P && (_.stylesheet = P);
2194
- const k = j.tocField();
2195
- return k && (_.tocInstruction = k.instruction, Rt(_) === 0 && (_.tocAnchorBlockId = k.blockId)), M.fields && (_.fields = M.fields), {
2196
- doc: _,
2197
- warnings: r.list,
2198
- mediaUrls: K.flatMap((y) => y.urls()),
2199
- media: i
2200
- };
2201
- }
2202
- function ko(e, n, t, o, r, i, s) {
2203
- if (!t) return;
2204
- const a = n.get(t), f = a && !a.external ? e.text(a.target) : void 0;
2205
- if (a === void 0 || f === void 0) {
2206
- i.add("header-missing", "A referenced header/footer part was missing from the archive.");
2207
- return;
2208
- }
2209
- const p = je(e, a.target), d = Zt(f, a.target, i, s), c = o.mapBlocks(d, r(p), We(p));
2210
- return c.length > 0 ? c : void 0;
2211
- }
2212
- function at(e, n, t, o, r, i, s, a, f, p, d) {
2213
- if (!t) return;
2214
- const c = (m) => `${n}${m}`, u = (m, S) => {
2215
- const x = ko(i, s, S, a, f, p, d);
2216
- x && (e[m] = x);
2217
- };
2218
- u(c(""), t.default), o && u(c("First"), t.first), r && u(c("Even"), t.even);
2219
- }
2220
- function bo(e) {
2221
- const n = de(ue(e, "settings.xml"), "w:settings");
2222
- return !!n && !!h(n, "w:evenAndOddHeadersAndFooters");
2223
- }
2224
- function je(e, n) {
2225
- const t = e.text(zn(n));
2226
- return t !== void 0 ? Hn(t, n) : /* @__PURE__ */ new Map();
2227
- }
2228
- function We(e) {
2229
- return (n) => {
2230
- const t = e.get(n);
2231
- return t?.external ? t.target : void 0;
2232
- };
2233
- }
2234
- function Me(e, n, t) {
2235
- const o = bt(n, t);
2236
- return o && !o.external ? e.text(o.target) : void 0;
2237
- }
2238
- function yo(e, n) {
2239
- const t = bt(e, n);
2240
- return t && !t.external ? t.target : void 0;
2241
- }
2242
- const Ae = self;
2243
- Ae.onmessage = (e) => {
2244
- const { id: n, buf: t } = e.data;
2245
- try {
2246
- const o = vo(new Uint8Array(t), (r, i) => {
2247
- Ae.postMessage({ id: n, type: "progress", phase: r, pct: i });
2248
- });
2249
- Ae.postMessage({ id: n, type: "done", result: o });
2250
- } catch (o) {
2251
- o instanceof pe ? Ae.postMessage({ id: n, type: "error", code: o.code, message: o.message }) : Ae.postMessage({
2252
- id: n,
2253
- type: "error",
2254
- code: "MALFORMED_XML",
2255
- message: o instanceof Error ? o.message : String(o)
2256
- });
2257
- }
2258
- };