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