@forevka/wordcanvas 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist-lib/assets/{worker-BFAbWoje.js → worker-VdvO3cMW.js} +1198 -1182
  2. package/dist-lib/builder.js +5 -5
  3. package/dist-lib/{editorApp-CQn18PAu.js → editorApp-BGyP48-P.js} +37 -36
  4. package/dist-lib/{recalcToc-Dzz8cQho.js → engine-Chvebzwr.js} +525 -548
  5. package/dist-lib/export.js +8 -7
  6. package/dist-lib/generate-toc.js +7 -6
  7. package/dist-lib/import.js +2 -2
  8. package/dist-lib/{lists-DpmgbDyt.js → lists-BVCy5dMa.js} +2 -2
  9. package/dist-lib/{parse-CIuWi88O.js → parse-PD2rg4oO.js} +28 -28
  10. package/dist-lib/{pipeline-DQil8qUX.js → pipeline-r7GVSMFb.js} +60 -60
  11. package/dist-lib/query.js +977 -0
  12. package/dist-lib/recalc-docx.js +22 -21
  13. package/dist-lib/recalcToc-CAeOzLr3.js +37 -0
  14. package/dist-lib/{stylesheet-BeM16Mvj.js → stylesheet-IH4Hyc8o.js} +3 -3
  15. package/dist-lib/{toc-C-JErW1U.js → toc-B-TzD-Mr.js} +102 -86
  16. package/dist-lib/{webmcp-B9Q6w0Vl.js → webmcp-CDpzmTtU.js} +2 -2
  17. package/dist-lib/{wordcanvas-Cla5Ys8Y.js → wordcanvas-CIqBAV2w.js} +3 -3
  18. package/dist-lib/wordcanvas.js +1 -1
  19. package/dist-node/{chunk-JVSPB6WM.js → chunk-A53KB3BE.js} +2 -2
  20. package/dist-node/{chunk-HMBQQDXD.js → chunk-TLGEFCLV.js} +64 -1
  21. package/dist-node/chunk-TLGEFCLV.js.map +7 -0
  22. package/dist-node/{chunk-KZHUXFDE.js → chunk-VNDCELYX.js} +5 -45
  23. package/dist-node/chunk-VNDCELYX.js.map +7 -0
  24. package/dist-node/{engine-46GL2RKU.js → engine-QKH45ZHY.js} +5 -4
  25. package/dist-node/export.js +3 -3
  26. package/dist-node/generate-toc.js +3 -3
  27. package/dist-node/import.js +2 -2
  28. package/dist-node/recalc-docx.js +2 -2
  29. package/package.json +6 -2
  30. package/types/builder.d.ts +47 -2
  31. package/types/model.d.ts +34 -0
  32. package/types/query.d.ts +416 -0
  33. package/dist-node/chunk-HMBQQDXD.js.map +0 -7
  34. package/dist-node/chunk-KZHUXFDE.js.map +0 -7
  35. /package/dist-node/{chunk-JVSPB6WM.js.map → chunk-A53KB3BE.js.map} +0 -0
  36. /package/dist-node/{engine-46GL2RKU.js.map → engine-QKH45ZHY.js.map} +0 -0
@@ -1,21 +1,22 @@
1
1
  import { u, a as f, s as m, z as g } from "./browser-BUrsjziD.js";
2
2
  import { f as h } from "./contentTypes-BwUSSoXc.js";
3
- import { p as b, c as k } from "./recalcToc-Dzz8cQho.js";
4
- function w(s, r) {
5
- const n = b(r), a = {};
6
- for (const [o, i] of Object.entries(s.bookmarks ?? {})) {
3
+ import { c as b } from "./engine-Chvebzwr.js";
4
+ import { p as k } from "./recalcToc-CAeOzLr3.js";
5
+ function w(r, a) {
6
+ const n = k(a), s = {};
7
+ for (const [o, i] of Object.entries(r.bookmarks ?? {})) {
7
8
  const c = n.get(i.start.blockId);
8
- c !== void 0 && (a[o] = String(c));
9
+ c !== void 0 && (s[o] = String(c));
9
10
  }
10
- return a;
11
+ return s;
11
12
  }
12
13
  const y = /\bPAGEREF\s+("[^"]+"|\S+)/, d = /<w:fldChar\b[^>]*?w:fldCharType="(begin|separate|end)"[^>]*?\/?>|<w:instrText\b[^>]*?>([\s\S]*?)<\/w:instrText>|(<w:t\b[^>]*?>)([\s\S]*?)(<\/w:t>)/g;
13
- function S(s, r) {
14
+ function S(r, a) {
14
15
  const n = [];
15
- let a = "", o = 0, i = 0, c = 0;
16
+ let s = "", o = 0, i = 0, c = 0;
16
17
  d.lastIndex = 0;
17
18
  let e;
18
- for (; (e = d.exec(s)) !== null; ) {
19
+ for (; (e = d.exec(r)) !== null; ) {
19
20
  const t = n[n.length - 1];
20
21
  let p = null;
21
22
  if (e[1] !== void 0)
@@ -31,25 +32,25 @@ function S(s, r) {
31
32
  t.replaced && e[4] !== "" && (p = e[3] + e[5]);
32
33
  else {
33
34
  t.done = !0;
34
- const l = r[t.anchor];
35
+ const l = a[t.anchor];
35
36
  l !== void 0 && /^\d+$/.test(e[4]) ? e[4] !== l && (p = e[3] + l + e[5], i++, t.replaced = !0) : l !== void 0 && !/^\d+$/.test(e[4].trim()) && e[4].trim().length > 0 && c++;
36
37
  }
37
- p !== null && (a += s.slice(o, e.index) + p, o = e.index + e[0].length);
38
+ p !== null && (s += r.slice(o, e.index) + p, o = e.index + e[0].length);
38
39
  }
39
- return a += s.slice(o), { xml: a, changed: i, skipped: c };
40
+ return s += r.slice(o), { xml: s, changed: i, skipped: c };
40
41
  }
41
- function E(s, r) {
42
- const n = u(s), a = n["[Content_Types].xml"], o = (a ? h(f(a)) : void 0) ?? "word/document.xml", i = n[o];
43
- if (!i) return { bytes: s, changed: 0, skipped: 0 };
44
- const { xml: c, changed: e, skipped: t } = S(f(i), r);
45
- return e === 0 ? { bytes: s, changed: 0, skipped: t } : (n[o] = m(c), { bytes: g(n), changed: e, skipped: t });
42
+ function E(r, a) {
43
+ const n = u(r), s = n["[Content_Types].xml"], o = (s ? h(f(s)) : void 0) ?? "word/document.xml", i = n[o];
44
+ if (!i) return { bytes: r, changed: 0, skipped: 0 };
45
+ const { xml: c, changed: e, skipped: t } = S(f(i), a);
46
+ return e === 0 ? { bytes: r, changed: 0, skipped: t } : (n[o] = m(c), { bytes: g(n), changed: e, skipped: t });
46
47
  }
47
- function P(s, r) {
48
- const n = k().layout(r);
49
- return E(s, w(r, n));
48
+ function F(r, a) {
49
+ const n = b().layout(a);
50
+ return E(r, w(a, n));
50
51
  }
51
52
  export {
52
53
  w as pageByBookmark,
53
- P as patchTocFromLayout,
54
+ F as patchTocFromLayout,
54
55
  E as patchTocPageNumbers
55
56
  };
@@ -0,0 +1,37 @@
1
+ import { t as k, x as p } from "./toc-B-TzD-Mr.js";
2
+ import "./engine-Chvebzwr.js";
3
+ function b(r) {
4
+ const s = /* @__PURE__ */ new Map(), i = (n, t) => {
5
+ for (const o of n)
6
+ if (s.has(o.blockId) || s.set(o.blockId, t), o.table) for (const l of o.table.rows) for (const c of l.cells) i(c.blocks, t);
7
+ };
8
+ for (const n of r.pages) i(n.blocks, n.number);
9
+ return s;
10
+ }
11
+ function h(r, s) {
12
+ const i = b(s), n = [];
13
+ for (const t of r.blocks) {
14
+ if (t.kind !== "paragraph") continue;
15
+ const o = t.runs.find((u) => u.style.link?.startsWith("#"))?.style.link?.slice(1);
16
+ if (!o) continue;
17
+ const l = r.bookmarks?.[o]?.start.blockId;
18
+ if (!l) continue;
19
+ const c = i.get(l);
20
+ if (c === void 0) continue;
21
+ const a = k(t.runs), e = a.match(/\t(\d+)(\s*)$/);
22
+ if (!e || e[1] === String(c)) continue;
23
+ const f = a.length - e[2].length - e[1].length;
24
+ n.push({
25
+ blockId: t.id,
26
+ start: f,
27
+ end: f + e[1].length,
28
+ text: String(c),
29
+ style: p(t.runs, f) ?? t.runs[0]?.style
30
+ });
31
+ }
32
+ return n;
33
+ }
34
+ export {
35
+ h as c,
36
+ b as p
37
+ };
@@ -1,4 +1,4 @@
1
- import { c as u } from "./toc-C-JErW1U.js";
1
+ import { o as u } from "./toc-B-TzD-Mr.js";
2
2
  function p(e) {
3
3
  return e.type ?? "paragraph";
4
4
  }
@@ -134,13 +134,13 @@ function v() {
134
134
  }
135
135
  export {
136
136
  p as a,
137
- g as b,
137
+ O as b,
138
138
  x as c,
139
139
  v as d,
140
140
  y as e,
141
141
  b as m,
142
142
  P as p,
143
- O as r,
143
+ g as r,
144
144
  c as s,
145
145
  S as w
146
146
  };
@@ -54,14 +54,14 @@ const S = [
54
54
  n || (n = /* @__PURE__ */ new Map(), Y.set(t, n));
55
55
  let s = n.get(e);
56
56
  return s || (s = q(t, e).filter((o) => !ne(o)), n.set(e, s)), s;
57
- }, D = (t, e) => {
57
+ }, $ = (t, e) => {
58
58
  for (const n of t)
59
59
  if (e.add(n.id), n.kind === "table")
60
- for (const s of n.rows) for (const o of s.cells) D(o.blocks, e);
60
+ for (const s of n.rows) for (const o of s.cells) $(o.blocks, e);
61
61
  }, We = (t, e) => {
62
62
  const n = /* @__PURE__ */ new Set();
63
- D(t.blocks, n);
64
- for (const s of S) D(t.section[s] ?? [], n);
63
+ $(t.blocks, n);
64
+ for (const s of S) $(t.section[s] ?? [], n);
65
65
  for (const s of Object.values(t.footnotes ?? {})) for (const o of s) n.add(o.id);
66
66
  for (const s of Object.values(t.endnotes ?? {})) for (const o of s) n.add(o.id);
67
67
  return n.has(e);
@@ -127,9 +127,9 @@ function R(t, e, n) {
127
127
  const s = se(t, e.where).slice(), o = s[e.bi], i = o.rows.slice(), r = { cells: i[e.ri].cells.slice() }, c = { ...r.cells[e.ci], blocks: r.cells[e.ci].blocks.slice() };
128
128
  return c.blocks[e.pi] = n, r.cells[e.ci] = c, i[e.ri] = r, s[e.bi] = { ...o, rows: i, revision: o.revision + 1 }, e.where === "body" ? { ...t, blocks: s } : { ...t, section: { ...t.section, [e.where]: s } };
129
129
  }
130
- const $e = (t, e) => M(t, e)?.kind === "cell", F = (t) => t.map((e) => e.text).join(""), De = (t, e) => {
130
+ const De = (t, e) => M(t, e)?.kind === "cell", C = (t) => t.map((e) => e.text).join(""), $e = (t, e) => {
131
131
  const n = de(t, e);
132
- return n ? F(n.runs) : "";
132
+ return n ? C(n.runs) : "";
133
133
  };
134
134
  function He(t, e) {
135
135
  let n = 0;
@@ -204,24 +204,31 @@ function Ue(t) {
204
204
  const e = t.sdtPath;
205
205
  return e && e.length > 0 ? e[e.length - 1] : void 0;
206
206
  }
207
+ function Ye(t, e) {
208
+ const n = t?.sdtPath ?? [], s = e.sdtPath ?? [];
209
+ return n.length === 0 ? s.slice() : n.concat(s);
210
+ }
207
211
  function ke(t, e) {
208
212
  const n = t?.length ?? 0, s = e?.length ?? 0;
209
213
  if (n !== s) return !1;
210
214
  for (let o = 0; o < n; o++) if (t[o] !== e[o]) return !1;
211
215
  return !0;
212
216
  }
213
- function Ye(t, e) {
217
+ function Ve(t, e) {
214
218
  return t.sdtPath?.includes(e) ?? !1;
215
219
  }
216
- function Ve(t, e) {
220
+ function Xe(t) {
221
+ return t && t.length > 0 ? t.slice() : void 0;
222
+ }
223
+ function Je(t, e) {
217
224
  return t && t.length > 0 ? [...t, e] : [e];
218
225
  }
219
- function Xe(t, e) {
226
+ function Qe(t, e) {
220
227
  if (!t) return;
221
228
  const n = t.filter((s) => s !== e);
222
229
  return n.length > 0 ? n : void 0;
223
230
  }
224
- function Je(t, e) {
231
+ function Ze(t, e) {
225
232
  if (!t) return;
226
233
  const n = t.indexOf(e);
227
234
  return n < 0 ? void 0 : t.slice(0, n + 1);
@@ -294,11 +301,11 @@ function pe(t, e, n) {
294
301
  const [s, o] = y(t, e), [, i] = y(o, n - e);
295
302
  return x([...s, ...i], p(t, e));
296
303
  }
297
- function Qe(t, e, n, s) {
304
+ function Ke(t, e, n, s) {
298
305
  const [o, i] = y(t, e), [r, c] = y(i, n - e), l = r.map((a) => ({ text: a.text, style: { ...a.style, ...s } }));
299
306
  return x([...o, ...l, ...c], p(t, e));
300
307
  }
301
- function Ze(t, e, n, s) {
308
+ function et(t, e, n, s) {
302
309
  const [o, i] = y(t, e), [r, c] = y(i, n - e), l = r.map((h) => h.text).join(""), a = s(l);
303
310
  let d = 0;
304
311
  const f = a.length === l.length ? r.map((h) => {
@@ -419,14 +426,14 @@ function Se(t) {
419
426
  }
420
427
  return e;
421
428
  }
422
- function $(t) {
429
+ function D(t) {
423
430
  const e = Se(t);
424
431
  return t.colFractions && t.colFractions.length === e ? t.colFractions : Array.from({ length: e }, () => 1 / e);
425
432
  }
426
433
  function v(t, e) {
427
434
  return { ...t, runs: e, revision: t.revision + 1 };
428
435
  }
429
- function Ke(t, e) {
436
+ function tt(t, e) {
430
437
  switch (e.type) {
431
438
  case "insertText": {
432
439
  const { loc: n, block: s } = E(t, e.at.blockId), o = we(s.runs, e.at.offset, e.text, e.style), i = e.text.length;
@@ -438,7 +445,7 @@ function Ke(t, e) {
438
445
  };
439
446
  }
440
447
  case "insertRuns": {
441
- const { loc: n, block: s } = E(t, e.at.blockId), o = F(e.runs).length, i = xe(s.runs, e.at.offset, e.runs);
448
+ const { loc: n, block: s } = E(t, e.at.blockId), o = C(e.runs).length, i = xe(s.runs, e.at.offset, e.runs);
442
449
  return {
443
450
  doc: R(t, n, v(s, i)),
444
451
  inverse: { type: "deleteRange", blockId: s.id, start: e.at.offset, end: e.at.offset + o },
@@ -540,7 +547,7 @@ function Ke(t, e) {
540
547
  throw new Error("mergeParagraphs: no next paragraph");
541
548
  o = a;
542
549
  }
543
- const i = F(s.runs).length, r = v(
550
+ const i = C(s.runs).length, r = v(
544
551
  s,
545
552
  x([...s.runs, ...o.runs], p(s.runs, i))
546
553
  );
@@ -639,7 +646,7 @@ function Ke(t, e) {
639
646
  };
640
647
  }
641
648
  case "setTableColFractions": {
642
- const { where: n, bi: s, block: o } = g(t, e.blockId), i = $(o);
649
+ const { where: n, bi: s, block: o } = g(t, e.blockId), i = D(o);
643
650
  return {
644
651
  doc: m(t, n, s, { ...o, colFractions: e.fractions }),
645
652
  inverse: { type: "setTableColFractions", blockId: e.blockId, fractions: i },
@@ -787,7 +794,7 @@ function Ke(t, e) {
787
794
  });
788
795
  let c = e.fractions;
789
796
  if (!c) {
790
- const l = $(o), a = 1 / (l.length + 1);
797
+ const l = D(o), a = 1 / (l.length + 1);
791
798
  c = l.map((d) => d * (1 - a)), c.splice(e.colIndex, 0, a);
792
799
  }
793
800
  return {
@@ -914,6 +921,13 @@ function Ke(t, e) {
914
921
  dirtyBlockIds: []
915
922
  };
916
923
  }
924
+ case "setDocument":
925
+ return {
926
+ doc: e.doc,
927
+ inverse: { type: "setDocument", doc: t },
928
+ mapPosition: b,
929
+ dirtyBlockIds: []
930
+ };
917
931
  case "setSectionBand": {
918
932
  const n = t.section[e.band] ?? null, s = { ...t.section };
919
933
  e.blocks ? s[e.band] = e.blocks : delete s[e.band];
@@ -930,19 +944,19 @@ function Ke(t, e) {
930
944
  case "removeTableColumn": {
931
945
  const { where: n, bi: s, block: o } = g(t, e.tableId), i = { type: "setTableStructure", tableId: e.tableId, rows: o.rows };
932
946
  o.colFractions && (i.colFractions = o.colFractions);
933
- const r = $(o), c = /* @__PURE__ */ new Set(), l = o.rows.map((u) => {
947
+ const r = D(o), c = /* @__PURE__ */ new Set(), l = o.rows.map((u) => {
934
948
  const I = [];
935
949
  let P = 0;
936
- for (const C of u.cells) {
937
- const B = C.colSpan ?? 1;
950
+ for (const F of u.cells) {
951
+ const B = F.colSpan ?? 1;
938
952
  if (e.colIndex >= P && e.colIndex < P + B)
939
953
  if (B > 1) {
940
- const T = { ...C };
954
+ const T = { ...F };
941
955
  B - 1 > 1 ? T.colSpan = B - 1 : delete T.colSpan, I.push(T);
942
956
  } else
943
- for (const T of C.blocks) c.add(T.id);
957
+ for (const T of F.blocks) c.add(T.id);
944
958
  else
945
- I.push(C);
959
+ I.push(F);
946
960
  P += B;
947
961
  }
948
962
  return { cells: I };
@@ -965,13 +979,13 @@ function ie(t, e = 0) {
965
979
  };
966
980
  }
967
981
  let _ = ie("local");
968
- function et(t, e = 0) {
982
+ function nt(t, e = 0) {
969
983
  _ = ie(t, e);
970
984
  }
971
985
  function Q() {
972
986
  return _.next();
973
987
  }
974
- function tt() {
988
+ function st() {
975
989
  return _.siteId;
976
990
  }
977
991
  const Z = (t) => {
@@ -1003,7 +1017,7 @@ function Be(t) {
1003
1017
  }
1004
1018
  return e;
1005
1019
  }
1006
- function nt(t) {
1020
+ function ot(t) {
1007
1021
  const e = ["TOC"];
1008
1022
  if (t.outlineRange && e.push(`\\o "${t.outlineRange.from}-${t.outlineRange.to}"`), t.useOutlineLevels && e.push("\\u"), t.customStyles && Object.keys(t.customStyles).length > 0) {
1009
1023
  const n = Object.entries(t.customStyles).map(([s, o]) => `${s},${o}`).join(",");
@@ -1011,7 +1025,7 @@ function nt(t) {
1011
1025
  }
1012
1026
  return t.hyperlinks && e.push("\\h"), t.hidePageNumberRange && e.push(`\\n "${t.hidePageNumberRange.from}-${t.hidePageNumberRange.to}"`), t.separator !== void 0 && e.push(`\\p "${t.separator}"`), t.hideInWeb && e.push("\\z"), ` ${e.join(" ")} `;
1013
1027
  }
1014
- const st = (t, e) => !!t && e >= t.from && e <= t.to;
1028
+ const rt = (t, e) => !!t && e >= t.from && e <= t.to;
1015
1029
  function K(t, e) {
1016
1030
  if (!e || !t.stylesheet) return;
1017
1031
  const n = new Map(t.stylesheet.styles.map((i) => [i.id, i]));
@@ -1043,7 +1057,7 @@ function Re(t, e, n = 3) {
1043
1057
  }
1044
1058
  return o;
1045
1059
  }
1046
- function ot(t, e = 20) {
1060
+ function it(t, e = 20) {
1047
1061
  if (!t.bookmarks) return 0;
1048
1062
  const n = t.section.pageWidthPx - t.section.marginPx.left - t.section.marginPx.right;
1049
1063
  let s = 0;
@@ -1053,7 +1067,7 @@ function ot(t, e = 20) {
1053
1067
  if (!i) continue;
1054
1068
  const r = t.bookmarks[i]?.start.blockId;
1055
1069
  if (!r) continue;
1056
- const c = F(o.runs), l = c.match(/\t\d+\s*$/);
1070
+ const c = C(o.runs), l = c.match(/\t\d+\s*$/);
1057
1071
  if (!l) continue;
1058
1072
  o.runs = re(o.runs, 0, c.length - l[0].length), o.runs.length === 0 && (o.runs = [{ text: "", style: { ...A } }]);
1059
1073
  const a = Math.min(9, Math.max(1, Math.round((o.style.indentLeftPx || 0) / e) + 1));
@@ -1062,7 +1076,7 @@ function ot(t, e = 20) {
1062
1076
  return s;
1063
1077
  }
1064
1078
  const A = { ...oe, fontSizePx: 13 }, Ee = 20;
1065
- function Fe(t, e, n, s) {
1079
+ function Ce(t, e, n, s) {
1066
1080
  const o = t.indentStepPx ?? Ee, i = t.leader ?? "dot", r = { align: "left", lineHeight: 1.5, spaceBeforePx: 0, spaceAfterPx: 2, indentFirstLinePx: 0 };
1067
1081
  let c, l;
1068
1082
  if (s && (s.char || s.para)) {
@@ -1082,7 +1096,7 @@ function Fe(t, e, n, s) {
1082
1096
  };
1083
1097
  return i !== "none" && n > 0 ? l.tabStops = [{ posPx: n, align: "right", leader: i }] : delete l.tabStops, { char: c, para: l };
1084
1098
  }
1085
- function Ce(t) {
1099
+ function Fe(t) {
1086
1100
  if (t.title === null) return null;
1087
1101
  const e = t.title ?? {}, n = { ...A, ...t.baseChar };
1088
1102
  return {
@@ -1104,7 +1118,7 @@ const Oe = 3;
1104
1118
  function Ne(t, e = {}) {
1105
1119
  const n = t.tocInstruction ? Be(t.tocInstruction) : void 0, s = e.maxLevel ?? n?.outlineRange?.to ?? Oe, o = t.section.pageWidthPx - t.section.marginPx.left - t.section.marginPx.right, i = t.tocAnchorBlockId ? t.blocks.find((a) => a.kind === "paragraph" && a.id === t.tocAnchorBlockId) : void 0, r = i ? { char: i.runs[0]?.style, para: i.style } : void 0, c = [];
1106
1120
  if (e.title !== void 0 ? e.title !== null : i === void 0) {
1107
- const a = Ce(e);
1121
+ const a = Fe(e);
1108
1122
  a && c.push({
1109
1123
  kind: "paragraph",
1110
1124
  id: Q(),
@@ -1114,9 +1128,9 @@ function Ne(t, e = {}) {
1114
1128
  });
1115
1129
  }
1116
1130
  for (const { block: a, level: d } of Re(t, n, s)) {
1117
- const f = F(a.runs).replace(/\v/g, " ").trim();
1131
+ const f = C(a.runs).replace(/\v/g, " ").trim();
1118
1132
  if (f.length === 0) continue;
1119
- const { char: h, para: u } = Fe(e, d, o, r);
1133
+ const { char: h, para: u } = Ce(e, d, o, r);
1120
1134
  c.push({
1121
1135
  kind: "paragraph",
1122
1136
  id: Q(),
@@ -1127,7 +1141,7 @@ function Ne(t, e = {}) {
1127
1141
  }
1128
1142
  return c;
1129
1143
  }
1130
- function rt(t, e = {}) {
1144
+ function lt(t, e = {}) {
1131
1145
  if (t.blocks.some((r) => r.kind === "paragraph" && r.style.tocEntry))
1132
1146
  return { doc: t, generated: 0, headings: 0 };
1133
1147
  if (t.tocAnchorBlockId === void 0) return { doc: t, generated: 0, headings: 0 };
@@ -1139,58 +1153,60 @@ function rt(t, e = {}) {
1139
1153
  return i.splice(n, 1, ...s), { doc: { ...t, blocks: i }, generated: o, headings: o };
1140
1154
  }
1141
1155
  export {
1142
- ot as $,
1143
- De as A,
1156
+ nt as $,
1157
+ k as A,
1144
1158
  S as B,
1145
- X as C,
1159
+ se as C,
1146
1160
  oe as D,
1147
- Pe as E,
1148
- Je as F,
1149
- Ve as G,
1150
- ne as H,
1151
- y as I,
1152
- x as J,
1153
- re as K,
1154
- qe as L,
1155
- ze as M,
1156
- Xe as N,
1157
- Ne as O,
1158
- le as P,
1159
- Ge as Q,
1160
- Le as R,
1161
- Ae as S,
1162
- je as T,
1163
- _e as U,
1164
- q as V,
1165
- H as W,
1166
- $ as X,
1167
- et as Y,
1168
- Se as Z,
1169
- ie as _,
1170
- Fe as a,
1171
- nt as b,
1172
- ae as c,
1161
+ Ue as E,
1162
+ Ve as F,
1163
+ De as G,
1164
+ He as H,
1165
+ $e as I,
1166
+ X as J,
1167
+ Pe as K,
1168
+ Je as L,
1169
+ ne as M,
1170
+ y as N,
1171
+ x as O,
1172
+ re as P,
1173
+ qe as Q,
1174
+ ze as R,
1175
+ Ne as S,
1176
+ le as T,
1177
+ Le as U,
1178
+ Ae as V,
1179
+ je as W,
1180
+ _e as X,
1181
+ q as Y,
1182
+ H as Z,
1183
+ D as _,
1184
+ Ge as a,
1185
+ ie as a0,
1186
+ it as a1,
1187
+ ot as b,
1188
+ Q as c,
1173
1189
  Re as d,
1174
- Ke as e,
1175
- We as f,
1176
- rt as g,
1177
- de as h,
1178
- st as i,
1179
- Qe as j,
1180
- Me as k,
1181
- W as l,
1182
- tt as m,
1183
- Q as n,
1184
- Ze as o,
1190
+ W as e,
1191
+ Ye as f,
1192
+ lt as g,
1193
+ Ze as h,
1194
+ rt as i,
1195
+ Ke as j,
1196
+ Se as k,
1197
+ tt as l,
1198
+ Ce as m,
1199
+ Xe as n,
1200
+ ae as o,
1185
1201
  Be as p,
1186
- M as q,
1187
- k as r,
1188
- ue as s,
1189
- F as t,
1190
- se as u,
1191
- Ue as v,
1192
- te as w,
1193
- Ye as x,
1194
- $e as y,
1195
- He as z
1202
+ We as q,
1203
+ Qe as r,
1204
+ de as s,
1205
+ C as t,
1206
+ Me as u,
1207
+ st as v,
1208
+ et as w,
1209
+ ue as x,
1210
+ te as y,
1211
+ M as z
1196
1212
  };
@@ -1,4 +1,4 @@
1
- import { c as j, h as _, A as F, t as k, D as L } from "./toc-C-JErW1U.js";
1
+ import { o as j, s as _, I as F, t as k, D as L } from "./toc-B-TzD-Mr.js";
2
2
  const s = (e) => Math.round(e * 100) / 100;
3
3
  function A(e) {
4
4
  const o = { font: e.fontFamily, sizePx: e.fontSizePx };
@@ -332,7 +332,7 @@ function H(e, o = {}, r = {}) {
332
332
  if (i && e.search(i).total === 0)
333
333
  return e.searchClear(), f(`text not found: ${i}`);
334
334
  if (!e.getSelection()) return f("no selection (pass 'find' or select_range first)");
335
- const { insertText: d } = await import("./editorApp-CQn18PAu.js").then((m) => m.c);
335
+ const { insertText: d } = await import("./editorApp-BGyP48-P.js").then((m) => m.c);
336
336
  return e.dispatch(d(t)), i && e.searchClear(), g("inserted");
337
337
  }
338
338
  }), a({
@@ -1,5 +1,5 @@
1
- import "./toc-C-JErW1U.js";
2
- import { m as h } from "./stylesheet-BeM16Mvj.js";
1
+ import "./toc-B-TzD-Mr.js";
2
+ import { m as h } from "./stylesheet-IH4Hyc8o.js";
3
3
  import { H as u, A as w, y as m, C as y, I as v, a as k, P as z, F as S, Q as E, R as L, D as O } from "./paintStyle-OSXohdGT.js";
4
4
  const R = 1.1, C = 0.25, A = 5, T = 36, s = {
5
5
  canvasBackground: "#e8eaed",
@@ -626,7 +626,7 @@ class X {
626
626
  },
627
627
  onEvent: (r) => this.emit(r)
628
628
  };
629
- e.onLoadProgress?.({ phase: "bundle", percent: 0, loaded: 0, total: 0 }), import("./editorApp-CQn18PAu.js").then((r) => r.e).then((r) => (e.onLoadProgress?.({ phase: "bundle", percent: p, loaded: 0, total: 0 }), r.mountEditorApp(i)));
629
+ e.onLoadProgress?.({ phase: "bundle", percent: 0, loaded: 0, total: 0 }), import("./editorApp-BGyP48-P.js").then((r) => r.e).then((r) => (e.onLoadProgress?.({ phase: "bundle", percent: p, loaded: 0, total: 0 }), r.mountEditorApp(i)));
630
630
  });
631
631
  }
632
632
  /** Subscribe to a collaboration event. Returns an unsubscribe function. */
@@ -1,4 +1,4 @@
1
- import { W as s, d as e, m } from "./wordcanvas-Cla5Ys8Y.js";
1
+ import { W as s, d as e, m } from "./wordcanvas-CIqBAV2w.js";
2
2
  export {
3
3
  s as WordCanvas,
4
4
  e as darkCanvasTheme,
@@ -32,7 +32,7 @@ import {
32
32
  normalizeRuns,
33
33
  parseFieldInstruction,
34
34
  parseFieldSpec
35
- } from "./chunk-HMBQQDXD.js";
35
+ } from "./chunk-TLGEFCLV.js";
36
36
 
37
37
  // src/import/docx/units.ts
38
38
  var twipsToPx = (tw) => tw / 15;
@@ -3251,4 +3251,4 @@ function partNameByRelType(rels, kind) {
3251
3251
  export {
3252
3252
  runImport
3253
3253
  };
3254
- //# sourceMappingURL=chunk-JVSPB6WM.js.map
3254
+ //# sourceMappingURL=chunk-A53KB3BE.js.map
@@ -5,6 +5,16 @@ const require = __createRequire(import.meta.url);
5
5
  const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __pathDirname(__filename);
7
7
 
8
+ // ../shared/src/model/document.ts
9
+ var BAND_CONTAINERS = [
10
+ "header",
11
+ "footer",
12
+ "headerFirst",
13
+ "headerEven",
14
+ "footerFirst",
15
+ "footerEven"
16
+ ];
17
+
8
18
  // ../shared/src/model/text.ts
9
19
  var graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
10
20
  var words = new Intl.Segmenter(void 0, { granularity: "word" });
@@ -201,6 +211,57 @@ function effectiveFractions(t) {
201
211
  return Array.from({ length: n }, () => 1 / n);
202
212
  }
203
213
 
214
+ // ../shared/src/model/sections.ts
215
+ function effectiveSection(base, patch) {
216
+ const out = {
217
+ pageWidthPx: patch.pageWidthPx ?? base.pageWidthPx,
218
+ pageHeightPx: patch.pageHeightPx ?? base.pageHeightPx,
219
+ marginPx: patch.marginPx ?? base.marginPx
220
+ };
221
+ const columns = patch.columns === void 0 ? base.columns : patch.columns ?? void 0;
222
+ if (columns) out.columns = columns;
223
+ if (patch.pageNumberStart !== void 0) out.pageNumberStart = patch.pageNumberStart;
224
+ const headerDist = patch.headerDistancePx ?? base.headerDistancePx;
225
+ if (headerDist !== void 0) out.headerDistancePx = headerDist;
226
+ const footerDist = patch.footerDistancePx ?? base.footerDistancePx;
227
+ if (footerDist !== void 0) out.footerDistancePx = footerDist;
228
+ const pageColorHex = patch.pageColorHex ?? base.pageColorHex;
229
+ if (pageColorHex !== void 0) out.pageColorHex = pageColorHex;
230
+ const pageBorders = patch.pageBorders ?? base.pageBorders;
231
+ if (pageBorders !== void 0) out.pageBorders = pageBorders;
232
+ if (patch.lineNumbering !== void 0) out.lineNumbering = patch.lineNumbering;
233
+ for (const key of BAND_CONTAINERS) {
234
+ const blocks = patch[key] ?? base[key];
235
+ if (blocks) out[key] = blocks;
236
+ }
237
+ return out;
238
+ }
239
+ function resolveSections(doc) {
240
+ const out = [];
241
+ let startBlock = 0;
242
+ for (let i = 0; i < doc.blocks.length; i++) {
243
+ const b = doc.blocks[i];
244
+ if (b.kind === "paragraph" && b.style.sectionBreak) {
245
+ out.push({
246
+ index: out.length,
247
+ props: effectiveSection(doc.section, b.style.sectionBreak.props),
248
+ startBlock,
249
+ endBlock: i,
250
+ breakType: b.style.sectionBreak.type
251
+ });
252
+ startBlock = i + 1;
253
+ }
254
+ }
255
+ out.push({
256
+ index: out.length,
257
+ props: doc.section,
258
+ startBlock,
259
+ endBlock: doc.blocks.length - 1,
260
+ breakType: doc.section.breakType ?? "nextPage"
261
+ });
262
+ return out;
263
+ }
264
+
204
265
  // ../shared/src/ids.ts
205
266
  function createIdGenerator(siteId, start = 0) {
206
267
  let n = start;
@@ -480,6 +541,8 @@ export {
480
541
  markerText,
481
542
  normalizeRuns,
482
543
  effectiveFractions,
544
+ effectiveSection,
545
+ resolveSections,
483
546
  emptyMathRow,
484
547
  parseTocInstruction,
485
548
  inRange,
@@ -490,4 +553,4 @@ export {
490
553
  isCustomFieldInstruction,
491
554
  parseFieldSpec
492
555
  };
493
- //# sourceMappingURL=chunk-HMBQQDXD.js.map
556
+ //# sourceMappingURL=chunk-TLGEFCLV.js.map