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