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