kordoc 4.22.8 → 4.22.10

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 (122) hide show
  1. package/README.md +7 -5
  2. package/dist/{-V3MHVWUQ.js → -K6ZEUCPU.js} +11 -11
  3. package/dist/{chunk-JNHUOGGQ.js → chunk-3HEWZNSJ.js} +2 -2
  4. package/dist/{chunk-JA4IIIEU.js → chunk-4OZKQ4ET.js} +2 -2
  5. package/dist/{chunk-TDCHLOY6.cjs → chunk-55JC3WIX.cjs} +3 -3
  6. package/dist/{chunk-TDCHLOY6.cjs.map → chunk-55JC3WIX.cjs.map} +1 -1
  7. package/dist/{chunk-GVRCO3KT.js → chunk-5QEVIUXM.js} +2 -2
  8. package/dist/{chunk-RNBU6S2X.js → chunk-5RBT7L72.js} +2 -2
  9. package/dist/{chunk-P53VOW4B.js → chunk-5TVTSRHH.js} +3 -3
  10. package/dist/{chunk-VGRTUHAU.js → chunk-6ZQ47CXH.js} +3 -3
  11. package/dist/{chunk-YSTWJWOY.js → chunk-7YDXV44H.js} +4 -4
  12. package/dist/{chunk-ORFDIAP3.js → chunk-A65TQXWP.js} +4 -4
  13. package/dist/{chunk-XZZ7WOCP.js → chunk-APEYJ6G5.js} +2 -2
  14. package/dist/{chunk-XZZ7WOCP.js.map → chunk-APEYJ6G5.js.map} +1 -1
  15. package/dist/{chunk-YBD5XGFC.js → chunk-ATSTJQMI.js} +84 -21
  16. package/dist/chunk-ATSTJQMI.js.map +1 -0
  17. package/dist/{chunk-K5UU73BA.js → chunk-AXOFVPF2.js} +2 -2
  18. package/dist/{chunk-UDB4YKOP.cjs → chunk-D7FPRPEZ.cjs} +2 -2
  19. package/dist/{chunk-UDB4YKOP.cjs.map → chunk-D7FPRPEZ.cjs.map} +1 -1
  20. package/dist/{chunk-P7UB5SMI.js → chunk-FMVSQED7.js} +2 -2
  21. package/dist/{chunk-KZSDBXWS.js → chunk-GWYFJQL7.js} +11 -11
  22. package/dist/{chunk-LSOFR4R2.cjs → chunk-HRFGBMVO.cjs} +6 -6
  23. package/dist/{chunk-LSOFR4R2.cjs.map → chunk-HRFGBMVO.cjs.map} +1 -1
  24. package/dist/{chunk-TVCGPOCE.js → chunk-HTPPDXDH.js} +2 -2
  25. package/dist/{chunk-YDAGUSKH.js → chunk-JJSSXV55.js} +2 -2
  26. package/dist/{chunk-DUQJ7EBY.js → chunk-K65R6PB4.js} +2 -2
  27. package/dist/{chunk-4OMXOT6T.js → chunk-LAZZEGT4.js} +3 -3
  28. package/dist/{chunk-V7BK7IKP.js → chunk-M4P52HHG.js} +2 -2
  29. package/dist/{chunk-Z5Z7HOER.js → chunk-M7AXOSY5.js} +4 -4
  30. package/dist/{chunk-5TYEUZGN.cjs → chunk-MILWFVER.cjs} +3 -3
  31. package/dist/{chunk-5TYEUZGN.cjs.map → chunk-MILWFVER.cjs.map} +1 -1
  32. package/dist/{chunk-I6XE7VJQ.js → chunk-NU4IFUHW.js} +2 -2
  33. package/dist/{chunk-OXVNNCQQ.js → chunk-TUEX7M4N.js} +2 -2
  34. package/dist/{chunk-LM3PI43Q.js → chunk-VLAYMRFS.js} +2 -2
  35. package/dist/{chunk-RAZJF5QW.cjs → chunk-WCXPF7PT.cjs} +24 -24
  36. package/dist/{chunk-RAZJF5QW.cjs.map → chunk-WCXPF7PT.cjs.map} +1 -1
  37. package/dist/{chunk-5YXW5RLC.cjs → chunk-ZN4BGNYO.cjs} +23 -23
  38. package/dist/{chunk-5YXW5RLC.cjs.map → chunk-ZN4BGNYO.cjs.map} +1 -1
  39. package/dist/{chunk-D7A5NKP3.js → chunk-ZWBFTG3T.js} +2 -2
  40. package/dist/{chunk-D7A5NKP3.js.map → chunk-ZWBFTG3T.js.map} +1 -1
  41. package/dist/chunks-A4DKG5YP.js +10 -0
  42. package/dist/cli.js +30 -30
  43. package/dist/{formula-SPMFPBGU.js → formula-J5DTOYGK.js} +4 -4
  44. package/dist/{formula-246A2T5B.cjs → formula-SOILYG2T.cjs} +9 -9
  45. package/dist/{formula-246A2T5B.cjs.map → formula-SOILYG2T.cjs.map} +1 -1
  46. package/dist/{formula-HO2NNWVN.js → formula-YYMYI32F.js} +3 -3
  47. package/dist/{image-ocr-YRACG6TO.cjs → image-ocr-2FQTSQAQ.cjs} +17 -17
  48. package/dist/{image-ocr-YRACG6TO.cjs.map → image-ocr-2FQTSQAQ.cjs.map} +1 -1
  49. package/dist/{image-ocr-G2UUJPBI.js → image-ocr-EXZCN2Q5.js} +9 -9
  50. package/dist/{image-ocr-WSRZMXYM.js → image-ocr-HXLPIDJH.js} +6 -6
  51. package/dist/index.cjs +473 -410
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.js +84 -21
  54. package/dist/index.js.map +1 -1
  55. package/dist/mcp.js +30 -23
  56. package/dist/mcp.js.map +1 -1
  57. package/dist/{model-bundle-CJACYVVC.js → model-bundle-L2OLSYAW.js} +5 -5
  58. package/dist/{models-HGIMOYGX.js → models-A4JR64CR.js} +5 -5
  59. package/dist/{parse-worker-v2-7GQJ5IGY.js → parse-worker-v2-YCNMSEIB.js} +12 -12
  60. package/dist/{parser-TW2QXVZR.js → parser-2QCANHDO.js} +9 -9
  61. package/dist/{parser-Q3W25PYR.cjs → parser-S3IJOFFP.cjs} +157 -157
  62. package/dist/{parser-Q3W25PYR.cjs.map → parser-S3IJOFFP.cjs.map} +1 -1
  63. package/dist/{parser-23M44GFD.js → parser-WFLZFNN4.js} +12 -12
  64. package/dist/pdf-ocr-6S4U4T56.cjs +31 -0
  65. package/dist/{pdf-ocr-RAJ33NDH.cjs.map → pdf-ocr-6S4U4T56.cjs.map} +1 -1
  66. package/dist/{pdf-ocr-RZR2VPQD.js → pdf-ocr-MXOMLVFC.js} +6 -6
  67. package/dist/{pdf-ocr-DHVUQ4H2.js → pdf-ocr-UBQ4K63F.js} +9 -9
  68. package/dist/{profile-io-TP5LYMSB.js → profile-io-PIHSFGQ6.js} +3 -3
  69. package/dist/{rasterize-RENNLGB3.js → rasterize-7GBVLJG4.js} +3 -3
  70. package/dist/{redact-doc-TRBUJ3EL.js → redact-doc-CVJWVNKE.js} +11 -11
  71. package/dist/{render-3X6FI2WM.js → render-FQN7Y52S.js} +7 -7
  72. package/dist/seal-FZGFDRBC.js +10 -0
  73. package/dist/{setup-F7JGWFDW.js → setup-JTVGMAJB.js} +3 -3
  74. package/dist/visual-SNHWQXSM.js +21 -0
  75. package/dist/{watch-QYVW2AG6.js → watch-5MU2GVS4.js} +12 -12
  76. package/package.json +1 -1
  77. package/dist/chunk-YBD5XGFC.js.map +0 -1
  78. package/dist/chunks-OV75DVHD.js +0 -10
  79. package/dist/pdf-ocr-RAJ33NDH.cjs +0 -31
  80. package/dist/seal-M5GYTAPE.js +0 -10
  81. package/dist/visual-PZRC23GE.js +0 -21
  82. /package/dist/{-V3MHVWUQ.js.map → -K6ZEUCPU.js.map} +0 -0
  83. /package/dist/{chunk-JNHUOGGQ.js.map → chunk-3HEWZNSJ.js.map} +0 -0
  84. /package/dist/{chunk-JA4IIIEU.js.map → chunk-4OZKQ4ET.js.map} +0 -0
  85. /package/dist/{chunk-GVRCO3KT.js.map → chunk-5QEVIUXM.js.map} +0 -0
  86. /package/dist/{chunk-RNBU6S2X.js.map → chunk-5RBT7L72.js.map} +0 -0
  87. /package/dist/{chunk-P53VOW4B.js.map → chunk-5TVTSRHH.js.map} +0 -0
  88. /package/dist/{chunk-VGRTUHAU.js.map → chunk-6ZQ47CXH.js.map} +0 -0
  89. /package/dist/{chunk-YSTWJWOY.js.map → chunk-7YDXV44H.js.map} +0 -0
  90. /package/dist/{chunk-ORFDIAP3.js.map → chunk-A65TQXWP.js.map} +0 -0
  91. /package/dist/{chunk-K5UU73BA.js.map → chunk-AXOFVPF2.js.map} +0 -0
  92. /package/dist/{chunk-P7UB5SMI.js.map → chunk-FMVSQED7.js.map} +0 -0
  93. /package/dist/{chunk-KZSDBXWS.js.map → chunk-GWYFJQL7.js.map} +0 -0
  94. /package/dist/{chunk-TVCGPOCE.js.map → chunk-HTPPDXDH.js.map} +0 -0
  95. /package/dist/{chunk-YDAGUSKH.js.map → chunk-JJSSXV55.js.map} +0 -0
  96. /package/dist/{chunk-DUQJ7EBY.js.map → chunk-K65R6PB4.js.map} +0 -0
  97. /package/dist/{chunk-4OMXOT6T.js.map → chunk-LAZZEGT4.js.map} +0 -0
  98. /package/dist/{chunk-V7BK7IKP.js.map → chunk-M4P52HHG.js.map} +0 -0
  99. /package/dist/{chunk-Z5Z7HOER.js.map → chunk-M7AXOSY5.js.map} +0 -0
  100. /package/dist/{chunk-I6XE7VJQ.js.map → chunk-NU4IFUHW.js.map} +0 -0
  101. /package/dist/{chunk-OXVNNCQQ.js.map → chunk-TUEX7M4N.js.map} +0 -0
  102. /package/dist/{chunk-LM3PI43Q.js.map → chunk-VLAYMRFS.js.map} +0 -0
  103. /package/dist/{chunks-OV75DVHD.js.map → chunks-A4DKG5YP.js.map} +0 -0
  104. /package/dist/{formula-SPMFPBGU.js.map → formula-J5DTOYGK.js.map} +0 -0
  105. /package/dist/{formula-HO2NNWVN.js.map → formula-YYMYI32F.js.map} +0 -0
  106. /package/dist/{image-ocr-G2UUJPBI.js.map → image-ocr-EXZCN2Q5.js.map} +0 -0
  107. /package/dist/{image-ocr-WSRZMXYM.js.map → image-ocr-HXLPIDJH.js.map} +0 -0
  108. /package/dist/{model-bundle-CJACYVVC.js.map → model-bundle-L2OLSYAW.js.map} +0 -0
  109. /package/dist/{models-HGIMOYGX.js.map → models-A4JR64CR.js.map} +0 -0
  110. /package/dist/{parse-worker-v2-7GQJ5IGY.js.map → parse-worker-v2-YCNMSEIB.js.map} +0 -0
  111. /package/dist/{parser-TW2QXVZR.js.map → parser-2QCANHDO.js.map} +0 -0
  112. /package/dist/{parser-23M44GFD.js.map → parser-WFLZFNN4.js.map} +0 -0
  113. /package/dist/{pdf-ocr-DHVUQ4H2.js.map → pdf-ocr-MXOMLVFC.js.map} +0 -0
  114. /package/dist/{pdf-ocr-RZR2VPQD.js.map → pdf-ocr-UBQ4K63F.js.map} +0 -0
  115. /package/dist/{profile-io-TP5LYMSB.js.map → profile-io-PIHSFGQ6.js.map} +0 -0
  116. /package/dist/{rasterize-RENNLGB3.js.map → rasterize-7GBVLJG4.js.map} +0 -0
  117. /package/dist/{redact-doc-TRBUJ3EL.js.map → redact-doc-CVJWVNKE.js.map} +0 -0
  118. /package/dist/{render-3X6FI2WM.js.map → render-FQN7Y52S.js.map} +0 -0
  119. /package/dist/{seal-M5GYTAPE.js.map → seal-FZGFDRBC.js.map} +0 -0
  120. /package/dist/{setup-F7JGWFDW.js.map → setup-JTVGMAJB.js.map} +0 -0
  121. /package/dist/{visual-PZRC23GE.js.map → visual-SNHWQXSM.js.map} +0 -0
  122. /package/dist/{watch-QYVW2AG6.js.map → watch-5MU2GVS4.js.map} +0 -0
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  loadSharp,
4
4
  rasterizePageSvg
5
- } from "./chunk-TVCGPOCE.js";
5
+ } from "./chunk-HTPPDXDH.js";
6
6
  import {
7
7
  inlineImagesIntoMarkdown
8
8
  } from "./chunk-VKVDMH7X.js";
@@ -16,7 +16,7 @@ import {
16
16
  HEADING_RATIO_H3,
17
17
  tidyScriptTags,
18
18
  unframeLayoutTables
19
- } from "./chunk-DUQJ7EBY.js";
19
+ } from "./chunk-K65R6PB4.js";
20
20
  import {
21
21
  MAX_COLS,
22
22
  MAX_ROWS,
@@ -32,7 +32,7 @@ import {
32
32
  mapPuaText,
33
33
  markNonLayoutTable,
34
34
  romanNumeral
35
- } from "./chunk-JNHUOGGQ.js";
35
+ } from "./chunk-3HEWZNSJ.js";
36
36
  import {
37
37
  DEFAULT_CHAR,
38
38
  DEFAULT_PARA_GEOM,
@@ -46,7 +46,7 @@ import {
46
46
  hwpxAppMajor,
47
47
  parseRenderStyles,
48
48
  readZipEntry
49
- } from "./chunk-GVRCO3KT.js";
49
+ } from "./chunk-5QEVIUXM.js";
50
50
  import {
51
51
  KordocError,
52
52
  compareSectionPaths,
@@ -54,7 +54,7 @@ import {
54
54
  precheckZipSize,
55
55
  sanitizeHref,
56
56
  toArrayBuffer
57
- } from "./chunk-D7A5NKP3.js";
57
+ } from "./chunk-ZWBFTG3T.js";
58
58
 
59
59
  // src/render/svg-render.ts
60
60
  import JSZip from "jszip";
@@ -107,7 +107,30 @@ function solveBoundaries(constraints, count, total) {
107
107
  for (let k = 1; k <= count; k++) if (out[k] < out[k - 1]) out[k] = out[k - 1];
108
108
  return out;
109
109
  }
110
- function solveRowHeights(cells, rowCount) {
110
+ function longestPathBoundaries(constraints, count) {
111
+ const inner = constraints.filter((c) => c.a >= 0 && c.b <= count && c.a < c.b && !(c.a === 0 && c.b === count));
112
+ const x = new Array(count + 1).fill(Number.NEGATIVE_INFINITY);
113
+ x[0] = 0;
114
+ for (let k = 1; k <= count; k++) {
115
+ for (const c of inner) if (c.b === k && x[c.a] > Number.NEGATIVE_INFINITY) x[k] = Math.max(x[k], x[c.a] + c.size);
116
+ if (x[k] === Number.NEGATIVE_INFINITY) return null;
117
+ x[k] = Math.max(x[k], x[k - 1]);
118
+ }
119
+ const y = new Array(count + 1).fill(Number.NEGATIVE_INFINITY);
120
+ y[count] = 0;
121
+ for (let k = count - 1; k >= 0; k--) {
122
+ y[k] = y[k + 1];
123
+ for (const c of inner) if (c.a === k && y[c.b] > Number.NEGATIVE_INFINITY) y[k] = Math.max(y[k], c.size + y[c.b]);
124
+ }
125
+ return { x, tight: x.map((v, k) => Math.abs(v + y[k] - x[count]) <= 2) };
126
+ }
127
+ function tableColumnBoundaries(constraints, count, total) {
128
+ const prop = solveBoundaries(constraints, count, total);
129
+ if (!total || total <= 0) return prop;
130
+ const lp = longestPathBoundaries(constraints, count);
131
+ return lp && Math.abs(lp.x[count] - total) <= 2 && lp.x.every((v, k) => Math.abs(v - prop[k]) <= 2 || lp.tight[k]) ? lp.x : prop;
132
+ }
133
+ function solveRowHeights(cells, rowCount, maxTotal = Number.POSITIVE_INFINITY) {
111
134
  const h = new Array(rowCount).fill(0);
112
135
  for (const c of cells) {
113
136
  if (c.rowSpan === 1 && c.rowAddr >= 0 && c.rowAddr < rowCount) {
@@ -145,6 +168,15 @@ function solveRowHeights(cells, rowCount) {
145
168
  for (let k = 0; k < spans.length; k++) if (!done.has(k) && solve(k, true)) again = true;
146
169
  }
147
170
  for (let k = 0; k < spans.length; k++) if (!done.has(k)) solve(k, false);
171
+ let total = h.reduce((s, x) => s + x, 0);
172
+ for (const { c, rows } of [...spans].sort((a, b) => a.rows[a.rows.length - 1] - b.rows[b.rows.length - 1] || b.rows[0] - a.rows[0])) {
173
+ const known = rows.reduce((s, r) => s + h[r], 0);
174
+ const add = Math.min(c.height - known, maxTotal - total);
175
+ if (rows.length && add > 0) {
176
+ h[rows[rows.length - 1]] += add;
177
+ total += add;
178
+ }
179
+ }
148
180
  return h;
149
181
  }
150
182
 
@@ -10412,6 +10444,13 @@ for (const [face, fix] of Object.entries(FACE_WIDTH_FIX)) {
10412
10444
  }
10413
10445
  FONTS[face] = { ...m, ascii, ex };
10414
10446
  }
10447
+ var CHE_HALF = "0-1f 7f a0 a2-a3 a5-a6 a9 ab-ac af b5 bb c0-c5 c7-cf d1-d6 d9-dd e0-e5 e7-ef f1-f6 f9-fd ff-110 112-125 128-130 134-137 139-13e 143-148 14c-151 154-165 168-17f 192 1fa-1ff 2c6 2c9 2dc 37e 384-38a 38c 38e-390 3aa-3b0 3c2 3ca-3ce 402-40c 40e-40f 452-45c 45e-45f 490-491 1e80-1e85 1ef2-1ef3 2013-2014 2017 201a-201b 201e 2022 2039-203a 203c 203e 2044 20a3-20a4 20a7 20a9 2105 212e 21a8 2206 2212 2215 2219 221f 2248 2302 2310 2320-2321 2550-256c 2580 2584 2588 258c 2590-2591 2593 25aa-25ac 25ba 25c4 25ca 25d8-25d9 25e6 263a-263c 2666 266b fb01-fb02";
10448
+ var cheEx = { ...FONTS["\uAD74\uB9BC\uCCB4"].ex };
10449
+ for (const r of CHE_HALF.split(" ")) {
10450
+ const [a, b] = r.split("-").map((x) => parseInt(x, 16));
10451
+ for (let c = a; c <= (b ?? a); c++) cheEx[c] = 500;
10452
+ }
10453
+ FONTS["\uAD74\uB9BC\uCCB4"] = FONTS["\uB3CB\uC6C0\uCCB4"] = { ...FONTS["\uAD74\uB9BC\uCCB4"], ex: cheEx };
10415
10454
  for (const [face, wm] of Object.entries(seoulFontWidths())) {
10416
10455
  const m = FONTS[face], ascii = m ? [...m.ascii] : new Array(95).fill(500), ex = m ? { ...m.ex } : {};
10417
10456
  for (const [cp, w] of wm) {
@@ -10522,7 +10561,7 @@ function isHanja(cp) {
10522
10561
  function fontWidthFn(face, fallback = true) {
10523
10562
  if (!hasFontMetrics(face)) return null;
10524
10563
  const m = FONTS[face.trim()];
10525
- return (cp) => cp >= 32 && cp <= 126 ? m.ascii[cp - 32] : m.ex[cp] ?? ((fallback ? HANCOM_FALLBACK_W[cp] : void 0) ?? (isHalfwidthForm(cp) ? 500 : m.han !== void 0 && isHanja(cp) ? m.han : m.cjk));
10564
+ return (cp) => cp >= 32 && cp <= 126 ? m.ascii[cp - 32] : (fallback ? m.ex[cp] ?? HANCOM_FALLBACK_W[cp] : void 0) ?? (isHalfwidthForm(cp) ? 500 : m.han !== void 0 && isHanja(cp) ? m.han : m.cjk);
10526
10565
  }
10527
10566
  function isHalfwidthForm(cp) {
10528
10567
  return cp >= 65377 && cp <= 65500 || cp >= 65512 && cp <= 65518;
@@ -11366,17 +11405,18 @@ function cellContentExtent(cell, memo) {
11366
11405
  if (hit !== void 0) return hit;
11367
11406
  const cols = cellColumns(cell.sub);
11368
11407
  let ext = 0;
11369
- let shift = 0, prevV = Number.NEGATIVE_INFINITY, prevEnd = 0;
11408
+ let shift = 0, prevV = Number.NEGATIVE_INFINITY, prevH = 0, prevEnd = 0;
11370
11409
  for (const p of elements(cell.sub)) {
11371
11410
  if (ln(p) !== "p") continue;
11372
11411
  const m = buildPara(p);
11373
11412
  let firstShift = shift;
11374
11413
  const lineTops = [];
11375
11414
  m.segs.forEach((s, k) => {
11376
- if (s.vertpos < prevV && !cols) shift = prevEnd - s.vertpos;
11415
+ if ((s.vertpos < prevV || s.vertpos === prevV && s.horzpos <= prevH && prevEnd - shift > s.vertpos) && !cols) shift = prevEnd - s.vertpos;
11377
11416
  if (k === 0) firstShift = shift;
11378
11417
  lineTops.push(s.vertpos + shift);
11379
11418
  prevV = s.vertpos;
11419
+ prevH = s.horzpos;
11380
11420
  prevEnd = s.vertpos + shift + s.textheight + (s.spacing ?? 0);
11381
11421
  ext = Math.max(ext, s.vertpos + s.textheight + shift);
11382
11422
  });
@@ -11446,7 +11486,8 @@ function measureTableRowHeights(tbl, memo) {
11446
11486
  const sp = num(tbl, "cellSpacing");
11447
11487
  const rows = solveRowHeights(
11448
11488
  cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h - sp * (c.rs - 1), contentH: c.rs === 1 ? cellContentExtent(c, memo) + c.marginT + c.marginB : void 0 })),
11449
- nRows
11489
+ nRows,
11490
+ num(findChildByLocalName(tbl, "sz"), "height") - (sp > 0 ? sp * (nRows + 1) : 0) || Number.POSITIVE_INFINITY
11450
11491
  );
11451
11492
  if (sp > 0) {
11452
11493
  for (let r = 0; r < rows.length; r++) rows[r] += sp;
@@ -12813,7 +12854,14 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
12813
12854
  const split3 = splitFloatTableRemainder(p, startV, lim, bodyH, styles, true);
12814
12855
  const lsa = findChildByLocalName(p, "linesegarray");
12815
12856
  const own = lsa ? elements2(lsa).filter((e) => ln2(e) === "lineseg") : [];
12816
- if (split3 !== void 0 && own.length) {
12857
+ const sq = m0Objs(p), sqPos = sq ? findChildByLocalName(sq, "pos") : null;
12858
+ const sqVo = num2(sqPos, "vertOffset"), sqTop = startV + Math.max(0, sqVo >= 2 ** 31 ? sqVo - 2 ** 32 : sqVo) + num2(sq ? findChildByLocalName(sq, "outMargin") : null, "top");
12859
+ if (split3 !== void 0 && sq && own.length && own.every((sg) => num2(sg, "vertpos") + num2(sg, "vertsize") <= sqTop)) {
12860
+ cursorV = 0;
12861
+ floatFloor = split3;
12862
+ zones.length = 0;
12863
+ splitPage = true;
12864
+ } else if (split3 !== void 0 && own.length) {
12817
12865
  const d = split3 - num2(own[0], "vertpos");
12818
12866
  for (const sg of own) sg.setAttribute("vertpos", String(num2(sg, "vertpos") + d));
12819
12867
  cursorV = res.textBottom + d;
@@ -13175,17 +13223,19 @@ function stackedFloats(c) {
13175
13223
  }
13176
13224
  function cellLineBoxes(c) {
13177
13225
  const out = [];
13178
- let shift = 0, prevV = Number.NEGATIVE_INFINITY, prevEnd = 0, part = 0;
13226
+ let shift = 0, prevV = Number.NEGATIVE_INFINITY, prevH = 0, prevSavedEnd = 0, prevEnd = 0, part = 0;
13179
13227
  const cols = cellColumns(c.sub);
13180
13228
  for (const p of c.sub ? elements(c.sub) : []) if (ln(p) === "p") {
13181
13229
  const lsa = findChildByLocalName(p, "linesegarray");
13182
13230
  for (const sg of lsa ? elements(lsa) : []) if (ln(sg) === "lineseg") {
13183
- const v = num(sg, "vertpos");
13184
- if (v < prevV && !cols) {
13231
+ const v = num(sg, "vertpos"), hz = num(sg, "horzpos");
13232
+ if ((v < prevV || v === prevV && hz <= prevH && prevSavedEnd > v) && !cols) {
13185
13233
  shift = prevEnd - v;
13186
13234
  part++;
13187
13235
  }
13188
13236
  prevV = v;
13237
+ prevH = hz;
13238
+ prevSavedEnd = v + num(sg, "vertsize") + num(sg, "spacing");
13189
13239
  const top = v + shift, bottom = top + num(sg, "vertsize");
13190
13240
  prevEnd = bottom + num(sg, "spacing");
13191
13241
  out.push({ seg: sg, top, bottom, part, origin: shift });
@@ -13218,9 +13268,11 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13218
13268
  let hdrRows = 0;
13219
13269
  if (tbl.getAttribute("repeatHeader") === "1") while (hdrRows < nRows && cells.some((c) => c.ra === hdrRows) && cells.filter((c) => c.ra === hdrRows).every((c) => c.el.getAttribute("header") === "1")) hdrRows++;
13220
13270
  const contTop = MT + num(findChildByLocalName(tbl, "outMargin"), "top") + rowY[hdrRows];
13271
+ const outB = num(findChildByLocalName(tbl, "outMargin"), "bottom");
13221
13272
  const cellSplit = tbl.getAttribute("pageBreak") === "CELL";
13222
13273
  const out = [];
13223
- let page = 0, y = ty, first = true;
13274
+ const flows = (findChildByLocalName(tbl, "pos")?.getAttribute("vertRelTo") ?? "PARA") === "PARA";
13275
+ let page = 0, y = ty, first = !flows || ty - MT < 2e3;
13224
13276
  for (let r = 0; r < nRows; r++) {
13225
13277
  let h = rowH[r];
13226
13278
  const pieces = [];
@@ -13259,6 +13311,7 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13259
13311
  if (boxes && hParts > 0) {
13260
13312
  const declared = num(findChildByLocalName(tbl, "sz"), "height");
13261
13313
  const led = /* @__PURE__ */ new Set();
13314
+ let firstPh = 0;
13262
13315
  for (let k = 0; k <= hParts; k++) {
13263
13316
  if (k > 0 && floatSpan) {
13264
13317
  let lead = 0, place;
@@ -13289,8 +13342,11 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13289
13342
  if (inK.length && next) toNext = Math.max(toNext, next.top - from + c.marginT + c.marginB);
13290
13343
  }
13291
13344
  const last = k === hParts;
13292
- const firstH = declared > 0 && ty + declared - y >= ext ? Math.min(pageBottom - y, ty + declared - y) : pageBottom - y;
13293
- const ph = last ? ext : k === 0 ? firstH : toNext > 0 ? Math.min(pageBottom - contTop, toNext) : pageBottom - contTop;
13345
+ const cellH = Math.max(0, ...rowCells.map((c) => num(findChildByLocalName(c.el, "cellSz"), "height")));
13346
+ const firstH = Math.min(declared > 0 && ty + declared - y >= ext ? Math.min(pageBottom - y, ty + declared - y) : pageBottom - y, Math.max(ext, cellH));
13347
+ const share = last && k === 1 ? Math.max(0, ...rowCells.filter((c) => tbl.getAttribute("noAdjust") === "1" || /^(CENTER|BOTTOM)$/.test(c.sub?.getAttribute("vertAlign") ?? "")).map((c) => c.h - firstPh)) : 0;
13348
+ const ph = last ? Math.max(ext, share) : k === 0 ? firstH : toNext > 0 ? Math.min(pageBottom - contTop, toNext) : pageBottom - contTop;
13349
+ if (k === 0) firstPh = ph;
13294
13350
  pieces.push({ page, y, h: ph, range });
13295
13351
  if (!last) {
13296
13352
  let span = 0, spanEnd = 0;
@@ -13394,7 +13450,7 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13394
13450
  first = false;
13395
13451
  continue;
13396
13452
  }
13397
- if (!first && y + h > pageBottom && r >= hdrRows) {
13453
+ if (!first && y + h + (cellSplit ? 0 : outB) > pageBottom && r >= hdrRows) {
13398
13454
  page++;
13399
13455
  y = contTop;
13400
13456
  first = true;
@@ -14376,6 +14432,8 @@ function planLines(m, styles, numText = "") {
14376
14432
  const headW = bu?.useInstWidth === false ? [...bu.ch].reduce((w, ch) => w + glyphWidth(ch, bst, false).w, 0) : bu ? measureTextWidth(bu.ch, bst.height, bst.ratio, { spacingPct: bst.spacing, faceClass: faceClassOf(bst.face) }) : 0;
14377
14433
  const bulletW = bu ? paraHeadAdvance(bu, bst.height, headW) : 0;
14378
14434
  const plans = [];
14435
+ const inlineW = /* @__PURE__ */ new Map();
14436
+ for (const o of m.objs) if (o.inline) inlineW.set(o.index, o.omL + o.width + o.omR);
14379
14437
  for (let i = 0; i < m.segs.length; i++) {
14380
14438
  const seg = m.segs[i];
14381
14439
  const start = seg.textpos;
@@ -14387,6 +14445,11 @@ function planLines(m, styles, numText = "") {
14387
14445
  let fixedW = 0;
14388
14446
  for (let k = start; k < end && k < m.chars.length; k++) {
14389
14447
  const c = m.chars[k];
14448
+ const ow = inlineW.get(k);
14449
+ if (ow !== void 0) {
14450
+ x += ow;
14451
+ continue;
14452
+ }
14390
14453
  if (!c.tab) {
14391
14454
  x += charW(c, styles);
14392
14455
  continue;
@@ -14857,7 +14920,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
14857
14920
  const nCols = Math.max(...cells.map((c) => c.ca + c.cs));
14858
14921
  const nRows = Math.max(...cells.map((c) => c.ra + c.rs));
14859
14922
  const colCons = cells.map((c) => ({ a: c.ca, b: c.ca + c.cs, size: c.w }));
14860
- const colX = solveBoundaries(colCons, nCols, num(tblSz, "width") || void 0);
14923
+ const colX = tableColumnBoundaries(colCons, nCols, num(tblSz, "width") || void 0);
14861
14924
  const rowH = measureTableRowHeights(tbl, ctx.extentMemo);
14862
14925
  const rowY = [0];
14863
14926
  for (let r = 0; r < nRows; r++) rowY.push(rowY[r] + rowH[r]);
@@ -14908,7 +14971,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
14908
14971
  }));
14909
14972
  const va2 = c.sub.getAttribute("vertAlign") ?? "TOP";
14910
14973
  const pieceOff = g.pieces.map((pc, k) => {
14911
- if (va2 === "TOP") return 0;
14974
+ if (va2 === "TOP" || k > 0) return 0;
14912
14975
  const from = pc.range?.get(c.el)?.[0] ?? 0;
14913
14976
  const bottoms = boxes.filter((b) => pieceOf(b.top) === k).map((b) => b.bottom - from);
14914
14977
  if (!bottoms.length) return 0;
@@ -19736,4 +19799,4 @@ export {
19736
19799
  cropRect,
19737
19800
  extractRenderedRegions
19738
19801
  };
19739
- //# sourceMappingURL=chunk-YBD5XGFC.js.map
19802
+ //# sourceMappingURL=chunk-ATSTJQMI.js.map