kordoc 4.22.0 → 4.22.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 (129) hide show
  1. package/README.md +18 -9
  2. package/dist/{-KRYEEYOX.js → -C437ZARA.js} +11 -11
  3. package/dist/{chunk-HIM23MJP.js → chunk-2X64TI7I.js} +2 -2
  4. package/dist/{chunk-SP3DBTDN.js → chunk-3LJ6QO53.js} +28 -6
  5. package/dist/chunk-3LJ6QO53.js.map +1 -0
  6. package/dist/{chunk-PPYQUI3X.js → chunk-4BJZGXNM.js} +2 -2
  7. package/dist/{chunk-NKWY4UJ4.js → chunk-4GCS7WJJ.js} +2 -2
  8. package/dist/{chunk-BKEDPKXS.js → chunk-56GBOIOE.js} +2 -2
  9. package/dist/{chunk-GQJ4MFLT.cjs → chunk-AUWO57ED.cjs} +2 -2
  10. package/dist/{chunk-GQJ4MFLT.cjs.map → chunk-AUWO57ED.cjs.map} +1 -1
  11. package/dist/{chunk-2ZRU6WJQ.js → chunk-AXR7OKQY.js} +2 -2
  12. package/dist/{chunk-HI45PG3J.js → chunk-CNMUT5YW.js} +2 -2
  13. package/dist/{chunk-B4IKM3CG.js → chunk-DQXP3ELP.js} +2 -2
  14. package/dist/{chunk-EFO7H2D4.cjs → chunk-EKKZNKJD.cjs} +3 -3
  15. package/dist/{chunk-EFO7H2D4.cjs.map → chunk-EKKZNKJD.cjs.map} +1 -1
  16. package/dist/{chunk-LJSZ3HCI.cjs → chunk-ENV25MPM.cjs} +27 -26
  17. package/dist/chunk-ENV25MPM.cjs.map +1 -0
  18. package/dist/{chunk-7BJDDE7V.js → chunk-FPUBEM3F.js} +11 -11
  19. package/dist/{chunk-4W7GCW3Z.js → chunk-GFQIKYBV.js} +3 -3
  20. package/dist/{chunk-BXBOFBHR.js → chunk-GVBQVXXB.js} +2 -2
  21. package/dist/{chunk-BXBOFBHR.js.map → chunk-GVBQVXXB.js.map} +1 -1
  22. package/dist/{chunk-EXKBLZUH.cjs → chunk-I4BS4BXE.cjs} +188 -166
  23. package/dist/{chunk-EXKBLZUH.cjs.map → chunk-I4BS4BXE.cjs.map} +1 -1
  24. package/dist/{chunk-72DOHOTQ.js → chunk-IRP6QS3K.js} +3 -3
  25. package/dist/{chunk-VHDD33Q4.js → chunk-L6N4OMKR.js} +60 -28
  26. package/dist/chunk-L6N4OMKR.js.map +1 -0
  27. package/dist/{chunk-GWJV3FYA.js → chunk-L6PFPBTK.js} +2 -2
  28. package/dist/{chunk-DKSQ22RU.cjs → chunk-MED2MR6O.cjs} +6 -6
  29. package/dist/{chunk-DKSQ22RU.cjs.map → chunk-MED2MR6O.cjs.map} +1 -1
  30. package/dist/{chunk-7YVDZCHF.js → chunk-NGDMJICC.js} +29 -7
  31. package/dist/{chunk-SP3DBTDN.js.map → chunk-NGDMJICC.js.map} +1 -1
  32. package/dist/{chunk-PMVM7BS6.js → chunk-QFJCEHY7.js} +2 -2
  33. package/dist/{chunk-PMVM7BS6.js.map → chunk-QFJCEHY7.js.map} +1 -1
  34. package/dist/{chunk-DCXK7PYL.js → chunk-S4KQUVBV.js} +6 -5
  35. package/dist/{chunk-POPIFZOT.js.map → chunk-S4KQUVBV.js.map} +1 -1
  36. package/dist/{chunk-PWCVNTMX.js → chunk-U3TZVR7A.js} +2 -2
  37. package/dist/{chunk-POPIFZOT.js → chunk-UMNKY2EZ.js} +6 -5
  38. package/dist/{chunk-DCXK7PYL.js.map → chunk-UMNKY2EZ.js.map} +1 -1
  39. package/dist/{chunk-NNGZXPPA.js → chunk-UV2G6XFA.js} +2 -2
  40. package/dist/{chunk-746T2J3U.js → chunk-VUC4JJUM.js} +2 -2
  41. package/dist/{chunk-D5DRW3S5.js → chunk-YOFKJ7IM.js} +2 -2
  42. package/dist/{chunk-DZFGZBMV.js → chunk-YTEMFVZB.js} +2 -2
  43. package/dist/{chunk-GBQXV6MI.cjs → chunk-ZLFUZM7H.cjs} +3 -3
  44. package/dist/{chunk-GBQXV6MI.cjs.map → chunk-ZLFUZM7H.cjs.map} +1 -1
  45. package/dist/chunks-MPOOHZVO.js +10 -0
  46. package/dist/cli.js +30 -30
  47. package/dist/{formula-QPKCUYLS.cjs → formula-3TVRNJ66.cjs} +9 -9
  48. package/dist/{formula-QPKCUYLS.cjs.map → formula-3TVRNJ66.cjs.map} +1 -1
  49. package/dist/{formula-XSXXXRA6.js → formula-43QBPAL5.js} +4 -4
  50. package/dist/{formula-2G43QHEV.js → formula-HUENRCPJ.js} +3 -3
  51. package/dist/{image-ocr-XY3TUBYK.js → image-ocr-BAHDLDV5.js} +6 -6
  52. package/dist/{image-ocr-L46V4HIX.js → image-ocr-HYAKWJGE.js} +9 -9
  53. package/dist/{image-ocr-ZQMWJHKE.cjs → image-ocr-OC3TCXMV.cjs} +17 -17
  54. package/dist/{image-ocr-ZQMWJHKE.cjs.map → image-ocr-OC3TCXMV.cjs.map} +1 -1
  55. package/dist/index.cjs +356 -324
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.cts +1 -1
  58. package/dist/index.d.ts +1 -1
  59. package/dist/index.js +60 -28
  60. package/dist/index.js.map +1 -1
  61. package/dist/mcp.js +22 -22
  62. package/dist/{model-bundle-QFDCCCI2.js → model-bundle-23WBSECG.js} +5 -5
  63. package/dist/{models-T2QBJSY5.js → models-NRZQY45P.js} +5 -5
  64. package/dist/{parse-worker-v2-PT6LULNS.js → parse-worker-v2-DPNXGJ73.js} +12 -12
  65. package/dist/{parser-2EIOJGOS.js → parser-FNUQW2F3.js} +73 -27
  66. package/dist/parser-FNUQW2F3.js.map +1 -0
  67. package/dist/{parser-BGSWEVUB.cjs → parser-OKAQRZKM.cjs} +318 -272
  68. package/dist/parser-OKAQRZKM.cjs.map +1 -0
  69. package/dist/{parser-LM6FNKVB.js → parser-XNOLC3MZ.js} +70 -24
  70. package/dist/parser-XNOLC3MZ.js.map +1 -0
  71. package/dist/pdf-ocr-6UXBIQE6.cjs +31 -0
  72. package/dist/pdf-ocr-6UXBIQE6.cjs.map +1 -0
  73. package/dist/{pdf-ocr-GSELGUFG.js → pdf-ocr-FAGA3O6B.js} +8 -6
  74. package/dist/{pdf-ocr-C5OFY2RY.js → pdf-ocr-N5LYC5LA.js} +11 -9
  75. package/dist/{profile-io-Y2TLZ62F.js → profile-io-HC6FMYX4.js} +3 -3
  76. package/dist/{rasterize-FB6MFPS3.js → rasterize-QLTROEV2.js} +3 -3
  77. package/dist/{redact-doc-AV2EOKPP.js → redact-doc-V4KMM2QV.js} +11 -11
  78. package/dist/{render-M5BW4TLH.js → render-V4S3QLTR.js} +7 -7
  79. package/dist/seal-MQ5TB5YZ.js +10 -0
  80. package/dist/{setup-DVKUFC73.js → setup-HU7ZOQNM.js} +3 -3
  81. package/dist/visual-RLIFC4XC.js +21 -0
  82. package/dist/{watch-S35AWINM.js → watch-NPIZ6DSJ.js} +12 -12
  83. package/package.json +1 -1
  84. package/dist/chunk-7YVDZCHF.js.map +0 -1
  85. package/dist/chunk-LJSZ3HCI.cjs.map +0 -1
  86. package/dist/chunk-VHDD33Q4.js.map +0 -1
  87. package/dist/chunks-5AVQEPIH.js +0 -10
  88. package/dist/parser-2EIOJGOS.js.map +0 -1
  89. package/dist/parser-BGSWEVUB.cjs.map +0 -1
  90. package/dist/parser-LM6FNKVB.js.map +0 -1
  91. package/dist/pdf-ocr-A2UWUATF.cjs +0 -29
  92. package/dist/pdf-ocr-A2UWUATF.cjs.map +0 -1
  93. package/dist/seal-JXYWI5CN.js +0 -10
  94. package/dist/visual-DBVBTOAV.js +0 -21
  95. /package/dist/{-KRYEEYOX.js.map → -C437ZARA.js.map} +0 -0
  96. /package/dist/{chunk-HIM23MJP.js.map → chunk-2X64TI7I.js.map} +0 -0
  97. /package/dist/{chunk-PPYQUI3X.js.map → chunk-4BJZGXNM.js.map} +0 -0
  98. /package/dist/{chunk-NKWY4UJ4.js.map → chunk-4GCS7WJJ.js.map} +0 -0
  99. /package/dist/{chunk-BKEDPKXS.js.map → chunk-56GBOIOE.js.map} +0 -0
  100. /package/dist/{chunk-2ZRU6WJQ.js.map → chunk-AXR7OKQY.js.map} +0 -0
  101. /package/dist/{chunk-HI45PG3J.js.map → chunk-CNMUT5YW.js.map} +0 -0
  102. /package/dist/{chunk-B4IKM3CG.js.map → chunk-DQXP3ELP.js.map} +0 -0
  103. /package/dist/{chunk-7BJDDE7V.js.map → chunk-FPUBEM3F.js.map} +0 -0
  104. /package/dist/{chunk-4W7GCW3Z.js.map → chunk-GFQIKYBV.js.map} +0 -0
  105. /package/dist/{chunk-72DOHOTQ.js.map → chunk-IRP6QS3K.js.map} +0 -0
  106. /package/dist/{chunk-GWJV3FYA.js.map → chunk-L6PFPBTK.js.map} +0 -0
  107. /package/dist/{chunk-PWCVNTMX.js.map → chunk-U3TZVR7A.js.map} +0 -0
  108. /package/dist/{chunk-NNGZXPPA.js.map → chunk-UV2G6XFA.js.map} +0 -0
  109. /package/dist/{chunk-746T2J3U.js.map → chunk-VUC4JJUM.js.map} +0 -0
  110. /package/dist/{chunk-D5DRW3S5.js.map → chunk-YOFKJ7IM.js.map} +0 -0
  111. /package/dist/{chunk-DZFGZBMV.js.map → chunk-YTEMFVZB.js.map} +0 -0
  112. /package/dist/{chunks-5AVQEPIH.js.map → chunks-MPOOHZVO.js.map} +0 -0
  113. /package/dist/{formula-XSXXXRA6.js.map → formula-43QBPAL5.js.map} +0 -0
  114. /package/dist/{formula-2G43QHEV.js.map → formula-HUENRCPJ.js.map} +0 -0
  115. /package/dist/{image-ocr-XY3TUBYK.js.map → image-ocr-BAHDLDV5.js.map} +0 -0
  116. /package/dist/{image-ocr-L46V4HIX.js.map → image-ocr-HYAKWJGE.js.map} +0 -0
  117. /package/dist/{model-bundle-QFDCCCI2.js.map → model-bundle-23WBSECG.js.map} +0 -0
  118. /package/dist/{models-T2QBJSY5.js.map → models-NRZQY45P.js.map} +0 -0
  119. /package/dist/{parse-worker-v2-PT6LULNS.js.map → parse-worker-v2-DPNXGJ73.js.map} +0 -0
  120. /package/dist/{pdf-ocr-C5OFY2RY.js.map → pdf-ocr-FAGA3O6B.js.map} +0 -0
  121. /package/dist/{pdf-ocr-GSELGUFG.js.map → pdf-ocr-N5LYC5LA.js.map} +0 -0
  122. /package/dist/{profile-io-Y2TLZ62F.js.map → profile-io-HC6FMYX4.js.map} +0 -0
  123. /package/dist/{rasterize-FB6MFPS3.js.map → rasterize-QLTROEV2.js.map} +0 -0
  124. /package/dist/{redact-doc-AV2EOKPP.js.map → redact-doc-V4KMM2QV.js.map} +0 -0
  125. /package/dist/{render-M5BW4TLH.js.map → render-V4S3QLTR.js.map} +0 -0
  126. /package/dist/{seal-JXYWI5CN.js.map → seal-MQ5TB5YZ.js.map} +0 -0
  127. /package/dist/{setup-DVKUFC73.js.map → setup-HU7ZOQNM.js.map} +0 -0
  128. /package/dist/{visual-DBVBTOAV.js.map → visual-RLIFC4XC.js.map} +0 -0
  129. /package/dist/{watch-S35AWINM.js.map → watch-NPIZ6DSJ.js.map} +0 -0
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  parse
4
- } from "./chunk-7BJDDE7V.js";
4
+ } from "./chunk-FPUBEM3F.js";
5
5
  import {
6
6
  classifyError,
7
7
  sanitizeError,
8
8
  toArrayBuffer
9
- } from "./chunk-PPYQUI3X.js";
9
+ } from "./chunk-4BJZGXNM.js";
10
10
 
11
11
  // src/cli/worker-parse.ts
12
12
  import { readFileSync, statSync } from "fs";
@@ -26,4 +26,4 @@ async function parseWorkerFile(absPath, options) {
26
26
  export {
27
27
  parseWorkerFile
28
28
  };
29
- //# sourceMappingURL=chunk-72DOHOTQ.js.map
29
+ //# sourceMappingURL=chunk-IRP6QS3K.js.map
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  loadSharp,
4
4
  rasterizePageSvg
5
- } from "./chunk-HIM23MJP.js";
5
+ } from "./chunk-2X64TI7I.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-BXBOFBHR.js";
19
+ } from "./chunk-GVBQVXXB.js";
20
20
  import {
21
21
  MAX_COLS,
22
22
  MAX_ROWS,
@@ -27,7 +27,7 @@ import {
27
27
  flattenLayoutTables,
28
28
  mapPuaText,
29
29
  markNonLayoutTable
30
- } from "./chunk-PWCVNTMX.js";
30
+ } from "./chunk-U3TZVR7A.js";
31
31
  import {
32
32
  DEFAULT_CHAR,
33
33
  DEFAULT_PARA_GEOM,
@@ -41,7 +41,7 @@ import {
41
41
  hwpxAppMajor,
42
42
  parseRenderStyles,
43
43
  readZipEntry
44
- } from "./chunk-746T2J3U.js";
44
+ } from "./chunk-VUC4JJUM.js";
45
45
  import {
46
46
  KordocError,
47
47
  compareSectionPaths,
@@ -49,7 +49,7 @@ import {
49
49
  precheckZipSize,
50
50
  sanitizeHref,
51
51
  toArrayBuffer
52
- } from "./chunk-PPYQUI3X.js";
52
+ } from "./chunk-4BJZGXNM.js";
53
53
 
54
54
  // src/render/svg-render.ts
55
55
  import JSZip from "jszip";
@@ -10714,21 +10714,22 @@ var FORBID_START = /* @__PURE__ */ new Set([..."!%),.:;?]}\xA2\xB0\u2032\u2033\u
10714
10714
  var FORBID_END = /* @__PURE__ */ new Set([..."$([{\xA3\xA5\u3008\u300A\u300C\u300E\u3010\u3014$([{\u20A9"]);
10715
10715
  var HANCOM_FORBID_START = /* @__PURE__ */ new Set([..."!%),.:;>?]^`}~\xB0\xB7\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u3019\u301B\u30FB\uFF01\uFF05\uFF09\uFF0C\uFF0E\uFF1A\uFF1B\uFF1E\uFF1F\uFF3D\uFF3E\uFF40\uFF5D\uFF5E\uFF65\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u308E\u30A1\u30A3\u30A5\u30A7\u30A9\u30C3\u30E3\u30E5\u30E7\u30EE\u30F5\u30F6\u3001\u3002\u3003\u3005\u30FC\u309B\u309C\u309D\u309E\u30FD\u30FE\u2019\u201D\u2024\u2025\u2026\u2030\u2031\u2032\u2033\u2034\u2035\u2036\u2037\u2103\u2109"]);
10716
10716
  var HANCOM_FORBID_END = /* @__PURE__ */ new Set([..."(<[\\{\xA7\u2018\u201C\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\uFF04\uFF08\uFF1C\uFF3B\uFF3C\uFF5B\uFFE0\uFFE1\uFFE5\uFFE6$\xA2\xA3\xA4\xA5\u09F2\u09F3\u0E3F", ...Array.from({ length: 13 }, (_, i) => String.fromCharCode(8352 + i))]);
10717
+ var isWrapSpace = (ch) => ch === " " || ch === "\u2005";
10717
10718
  function prepareWrap(text, mode, opts) {
10718
10719
  const widthEm = widthFnOf(opts?.faceClass), spaceEm = opts?.spaceEm ?? SPACE_EM_FIXED;
10719
10720
  const advances = [], steps = [];
10720
10721
  let i = 0;
10721
10722
  for (const ch of text) {
10722
10723
  const cp = ch.codePointAt(0);
10723
- advances[i] = isSpaceCp(cp) ? spaceEm : widthEm(cp);
10724
+ advances[i] = cp === 8197 ? 250 : isSpaceCp(cp) ? spaceEm : widthEm(cp);
10724
10725
  steps[i] = ch.length;
10725
10726
  i += ch.length;
10726
10727
  }
10727
10728
  return { units: splitWrapUnits(text, mode), advances, steps };
10728
10729
  }
10729
10730
  function splitWrapUnits(text, mode, latinBreak = false) {
10730
- if (latinBreak) return text.match(mode === "keep" ? / +|[\x21-\x7e]|[^ \x21-\x7e]+/gu : / +|[^ ](?:\u00a0[^ \u00a0]?)*/gu) ?? [];
10731
- return text.match(mode === "keep" ? / +|\ufdd0+(?=[^ \ufdd0])|[^ ]+/gu : / +|\u2060*(?:[\x21-\x7e\u00a1-\u024f\u2018-\u201f]+|[^ ])(?:\u00a0(?:[\x21-\x7e\u00a1-\u024f\u2018-\u201f]+|[^ \u00a0])?)*/gu) ?? [];
10731
+ if (latinBreak) return text.match(mode === "keep" ? /[ \u2005]+|[\x21-\x7e]|[^ \u2005\x21-\x7e]+/gu : /[ \u2005]+|[^ \u2005](?:\u00a0[^ \u2005\u00a0]?)*/gu) ?? [];
10732
+ return text.match(mode === "keep" ? /[ \u2005]+|\ufdd0+(?=[^ \u2005\ufdd0])|[^ \u2005]+/gu : /[ \u2005]+|\u2060*(?:[\x21-\x7e\u00a1-\u024f\u2018-\u201f]+|[^ \u2005])(?:\u00a0(?:[\x21-\x7e\u00a1-\u024f\u2018-\u201f]+|[^ \u2005\u00a0])?)*/gu) ?? [];
10732
10733
  }
10733
10734
  function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "keep", opts) {
10734
10735
  if (!opts?.prepared && text.includes("\n")) {
@@ -10775,7 +10776,7 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
10775
10776
  if (unitW) return (unitW[i] ?? 0) + (ch.length === 2 ? unitW[i + 1] ?? 0 : 0);
10776
10777
  if (prepared) return prepared.advances[i] * (1 + spacing / 100) * k;
10777
10778
  const cp = ch.codePointAt(0);
10778
- return (isSpaceCp(cp) ? spaceEm : widthEm(cp)) * (1 + spacing / 100) * k;
10779
+ return (cp === 8197 ? 250 : isSpaceCp(cp) ? spaceEm : widthEm(cp)) * (1 + spacing / 100) * k;
10779
10780
  };
10780
10781
  const rangeW = (from, to) => {
10781
10782
  let w = 0;
@@ -10808,11 +10809,11 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
10808
10809
  const u = text[unitPos];
10809
10810
  const prevStart = (end) => end - (end >= 2 && /[\uDC00-\uDFFF]/.test(text[end - 1]) && /[\uD800-\uDBFF]/.test(text[end - 2]) ? 2 : 1);
10810
10811
  const old = opts?.before2024;
10811
- const splitIn = opts?.kinsoku === "hancom" && split && u !== void 0 && u !== " " && text[bp - 1] !== " ";
10812
+ const splitIn = opts?.kinsoku === "hancom" && split && u !== void 0 && !isWrapSpace(u) && !isWrapSpace(text[bp - 1]);
10812
10813
  const inWord = old && splitIn;
10813
- if (!splitIn && u !== void 0 && forbidStart.has(u) && prevStart(bp) > lineStart() && text[bp - 1] !== " ") {
10814
+ if (!splitIn && u !== void 0 && forbidStart.has(u) && prevStart(bp) > lineStart() && !isWrapSpace(text[bp - 1])) {
10814
10815
  bp = prevStart(bp);
10815
- if (old && forbidStart.has(text[bp]) && prevStart(bp) > lineStart() && text[bp - 1] !== " ") bp = prevStart(bp);
10816
+ if (old && forbidStart.has(text[bp]) && prevStart(bp) > lineStart() && !isWrapSpace(text[bp - 1])) bp = prevStart(bp);
10816
10817
  }
10817
10818
  while (!inWord && bp - 1 >= lineStart() && forbidEnd.has(text[bp - 1])) bp--;
10818
10819
  if (bp <= lineStart()) bp = unitPos;
@@ -10823,8 +10824,8 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
10823
10824
  lineEnded = false;
10824
10825
  placed = unitPos > bp ? 1 : 0;
10825
10826
  for (let i = bp; i < unitPos; i++) {
10826
- if (text[i] !== " ") realSeen = true;
10827
- else if (condense > 0 && (realSeen || !hancom)) spaceW += rangeW(i, i + 1) - (spAt?.[i] ?? 0);
10827
+ if (!isWrapSpace(text[i])) realSeen = true;
10828
+ else if (text[i] === " " && condense > 0 && (realSeen || !hancom)) spaceW += rangeW(i, i + 1) - (spAt?.[i] ?? 0);
10828
10829
  }
10829
10830
  lineW = rangeW(bp, unitPos) + w;
10830
10831
  };
@@ -10838,16 +10839,16 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
10838
10839
  lineW = leadW;
10839
10840
  };
10840
10841
  for (const u of units) {
10841
- if (u[0] === " ") {
10842
+ if (isWrapSpace(u[0])) {
10842
10843
  if (hancom) {
10843
10844
  let k2 = 0;
10844
10845
  for (; k2 < u.length; k2++) {
10845
10846
  if (!lineEnded && lineW >= avail) lineEnded = true;
10846
- if (lineEnded && k2 >= 2 && pos + k2 > lineStart()) break;
10847
+ if (lineEnded && (k2 >= 2 || u[k2] === "\u2005") && pos + k2 > lineStart()) break;
10847
10848
  if (!lineEnded) {
10848
10849
  const sw2 = rangeW(pos + k2, pos + k2 + 1);
10849
10850
  lineW += sw2;
10850
- if (realSeen) spaceW += sw2 - (spAt?.[pos + k2] ?? 0);
10851
+ if (realSeen && u[k2] === " ") spaceW += sw2 - (spAt?.[pos + k2] ?? 0);
10851
10852
  }
10852
10853
  }
10853
10854
  if (k2 < u.length) breakAt(pos + k2, rangeW(pos + k2, pos + u.length));
@@ -10856,7 +10857,7 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
10856
10857
  }
10857
10858
  const sw = rangeW(pos, pos + u.length);
10858
10859
  lineW += sw;
10859
- spaceW += sw;
10860
+ for (let k2 = 0; k2 < u.length; k2++) if (u[k2] === " ") spaceW += rangeW(pos + k2, pos + k2 + 1);
10860
10861
  pos += u.length;
10861
10862
  continue;
10862
10863
  }
@@ -11877,6 +11878,21 @@ function nextParaNumber(counters, geom) {
11877
11878
  });
11878
11879
  }
11879
11880
 
11881
+ // src/render/reflow-cache.ts
11882
+ function cachedParagraphBottom(lsa, bodyFlow) {
11883
+ let bottom = Number.NEGATIVE_INFINITY, previousV = Number.NEGATIVE_INFINITY;
11884
+ for (let i = 0; i < lsa.childNodes.length; i++) {
11885
+ const seg = lsa.childNodes[i];
11886
+ if (seg.nodeType !== 1 || seg.localName !== "lineseg") continue;
11887
+ const num3 = (name, fallback = 0) => toInt32(seg.getAttribute(name) ?? void 0, fallback);
11888
+ const v = num3("vertpos");
11889
+ if (bodyFlow && v < previousV) bottom = Number.NEGATIVE_INFINITY;
11890
+ bottom = Math.max(bottom, v + Math.max(num3("vertsize", 1e3), num3("textheight", 1e3)) + num3("spacing"));
11891
+ previousV = v;
11892
+ }
11893
+ return bottom;
11894
+ }
11895
+
11880
11896
  // src/render/reflow.ts
11881
11897
  var geomMemo = (styles) => ({ cell: /* @__PURE__ */ new WeakMap(), table: /* @__PURE__ */ new WeakMap(), paraGeom: styles.paraGeom });
11882
11898
  var LINESEG_FLAGS = "393216";
@@ -12198,10 +12214,11 @@ function reflowPara(p, doc, styles, areaW, startV, mode, zones = [], nums = /* @
12198
12214
  }
12199
12215
  const lineBox = [];
12200
12216
  const lineParts = [];
12217
+ const collisionHeights = [];
12201
12218
  const boxAt = (i) => {
12202
12219
  if (!zones.length) return void 0;
12203
12220
  if (i in lineBox) return lineBox[i];
12204
- const y0 = textStartV + i * pitch, y1 = y0 + height;
12221
+ const y0 = textStartV + i * pitch, y1 = y0 + Math.max(height, collisionHeights[i] ?? 0);
12205
12222
  let free = [[marginL, marginL + avail]], hit = false, flow = "BOTH_SIDES";
12206
12223
  for (const z of zones) {
12207
12224
  if (!(y1 > z.top && y0 < z.bottom)) continue;
@@ -12261,7 +12278,26 @@ function reflowPara(p, doc, styles, areaW, startV, mode, zones = [], nums = /* @
12261
12278
  lineParts.length = 0;
12262
12279
  }
12263
12280
  }
12264
- const wrap = text.length === 0 ? { lines: 1, starts: [0], lastLineWidth: 0 } : simulateWrap(text, firstWrapWidth, contWidth, height, 100, paraMode, { widths, spacings, condensePct: condenseUse, kinsoku: "hancom", before2024: styles.before2024, lineWidth, latinBreak: geom.latinBreak, rightTabs });
12281
+ const wrapLines = () => text.length === 0 ? { lines: 1, starts: [0], lastLineWidth: 0 } : simulateWrap(text, firstWrapWidth, contWidth, height, 100, paraMode, { widths, spacings, condensePct: condenseUse, kinsoku: "hancom", before2024: styles.before2024, lineWidth, latinBreak: geom.latinBreak, rightTabs });
12282
+ let wrap = wrapLines();
12283
+ if (zones.length) for (let pass = 0; pass < text.length; pass++) {
12284
+ let changed = false;
12285
+ for (const o of m.objs) if (o.inline) {
12286
+ const k = realIdx.indexOf(o.index), om = findChildByLocalName(o.el, "outMargin");
12287
+ if (k < 0) continue;
12288
+ let li = 0;
12289
+ for (let j = 1; j < wrap.starts.length; j++) if (wrap.starts[j] <= k) li = j;
12290
+ const h = num2(om, "top") + effHOf(o) + num2(om, "bottom");
12291
+ if (h > Math.max(height, collisionHeights[li] ?? 0)) {
12292
+ collisionHeights[li] = h;
12293
+ changed = true;
12294
+ }
12295
+ }
12296
+ if (!changed) break;
12297
+ lineBox.length = 0;
12298
+ lineParts.length = 0;
12299
+ wrap = wrapLines();
12300
+ }
12265
12301
  const lineObjH = new Array(wrap.starts.length).fill(0);
12266
12302
  const lineObjAsc = new Array(wrap.starts.length).fill(0);
12267
12303
  const lineObjLs = new Array(wrap.starts.length).fill(false);
@@ -12352,12 +12388,13 @@ function reflowPara(p, doc, styles, areaW, startV, mode, zones = [], nums = /* @
12352
12388
  }
12353
12389
  }
12354
12390
  const vertpos = v;
12391
+ const occupiedH = Math.max(lineH, collisionHeights[li] ?? 0);
12355
12392
  v += lineH + spacing;
12356
12393
  const isFirst = li === 0;
12357
12394
  const seg = doc.createElement("hp:lineseg");
12358
12395
  seg.setAttribute("textpos", String(textpos));
12359
12396
  seg.setAttribute("vertpos", String(vertpos));
12360
- seg.setAttribute("vertsize", String(lineH === textH && boxAll > textH0 ? Math.max(textH0, boxTop) : lineH));
12397
+ seg.setAttribute("vertsize", String(occupiedH === textH && boxAll > textH0 ? Math.max(textH0, boxTop) : occupiedH));
12361
12398
  seg.setAttribute("textheight", String(lineH));
12362
12399
  seg.setAttribute("baseline", String(geom.vertAlign === "TOP" ? 0 : geom.vertAlign === "CENTER" ? Math.floor(lineH / 2) : geom.vertAlign === "BOTTOM" ? lineH : Math.max(fl ? fl[1] : Math.round(textH0 * BASELINE_RATIO), lineObjAsc[li])));
12363
12400
  seg.setAttribute("spacing", String(spacing));
@@ -12540,12 +12577,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
12540
12577
  if (!res) {
12541
12578
  const lsa = findChildByLocalName(p, "linesegarray");
12542
12579
  if (lsa) {
12543
- let bottom = Number.NEGATIVE_INFINITY;
12544
- for (const seg of elements2(lsa)) {
12545
- if (ln2(seg) !== "lineseg") continue;
12546
- const th = Math.max(num2(seg, "vertsize", 1e3), num2(seg, "textheight", 1e3));
12547
- bottom = Math.max(bottom, num2(seg, "vertpos") + th + num2(seg, "spacing"));
12548
- }
12580
+ const bottom = cachedParagraphBottom(lsa, bodyFlow);
12549
12581
  if (Number.isFinite(bottom)) {
12550
12582
  cursorV = bottom;
12551
12583
  prevSpaceAfter = g?.spaceAfter ?? 0;
@@ -19593,4 +19625,4 @@ export {
19593
19625
  cropRect,
19594
19626
  extractRenderedRegions
19595
19627
  };
19596
- //# sourceMappingURL=chunk-VHDD33Q4.js.map
19628
+ //# sourceMappingURL=chunk-L6N4OMKR.js.map