kordoc 4.21.20 → 4.21.21

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 (124) hide show
  1. package/README.md +6 -5
  2. package/dist/{-QHQ2QKM7.js → -ZYF6HX4M.js} +11 -11
  3. package/dist/{chunk-FU3SCGE7.js → chunk-2ZGP7A5T.js} +2 -2
  4. package/dist/{chunk-TYYKK5DX.js → chunk-3TCF5HPP.js} +2 -2
  5. package/dist/{chunk-WWMHVDRG.cjs → chunk-57VNFMMS.cjs} +3 -3
  6. package/dist/{chunk-WWMHVDRG.cjs.map → chunk-57VNFMMS.cjs.map} +1 -1
  7. package/dist/{chunk-75INFYVC.js → chunk-5HTFWUJE.js} +2 -2
  8. package/dist/{chunk-G6G25HUO.js → chunk-7YAJCXCD.js} +2 -2
  9. package/dist/{chunk-DBFAQJCX.js → chunk-BC54LBST.js} +3 -3
  10. package/dist/{chunk-PALYDA3M.js → chunk-BG6LUCQL.js} +2 -2
  11. package/dist/{chunk-42XYVZ2B.js → chunk-CY4QM2KQ.js} +2 -2
  12. package/dist/{chunk-2FALZL3E.cjs → chunk-DTZIZ5PP.cjs} +13 -13
  13. package/dist/{chunk-2FALZL3E.cjs.map → chunk-DTZIZ5PP.cjs.map} +1 -1
  14. package/dist/{chunk-AINZICPE.js → chunk-FBJVDBMO.js} +2 -2
  15. package/dist/{chunk-7ITWGPNB.js → chunk-FZMGF6XU.js} +2 -2
  16. package/dist/{chunk-CKEO54YN.cjs → chunk-H2MS4VG3.cjs} +3 -3
  17. package/dist/{chunk-CKEO54YN.cjs.map → chunk-H2MS4VG3.cjs.map} +1 -1
  18. package/dist/{chunk-KBL24ZCP.js → chunk-HWIW3WK2.js} +3 -3
  19. package/dist/{chunk-E5L6DUOE.js → chunk-J5PBI3ZC.js} +3 -3
  20. package/dist/{chunk-LY4ITNAL.js → chunk-KBV4WFZ6.js} +80 -5
  21. package/dist/chunk-KBV4WFZ6.js.map +1 -0
  22. package/dist/{chunk-JDVOYDIA.js → chunk-KTLHADU4.js} +2 -2
  23. package/dist/{chunk-M37GOXT5.cjs → chunk-MCUX2Y2C.cjs} +2 -2
  24. package/dist/{chunk-M37GOXT5.cjs.map → chunk-MCUX2Y2C.cjs.map} +1 -1
  25. package/dist/{chunk-ZMGWKGSC.js → chunk-PTF4NCFM.js} +2 -2
  26. package/dist/{chunk-N47I6OS7.js → chunk-QHNVH4TC.js} +6 -6
  27. package/dist/{chunk-LO5A36FU.js → chunk-RBRHO7WL.js} +2 -2
  28. package/dist/{chunk-6HIDMA5O.js → chunk-T3DTTK23.js} +2 -2
  29. package/dist/{chunk-KS2SASZH.cjs → chunk-T7PN5D4D.cjs} +6 -6
  30. package/dist/{chunk-KS2SASZH.cjs.map → chunk-T7PN5D4D.cjs.map} +1 -1
  31. package/dist/{chunk-MOT7WOP5.cjs → chunk-TMUUDMDH.cjs} +100 -25
  32. package/dist/chunk-TMUUDMDH.cjs.map +1 -0
  33. package/dist/{chunk-I4HF4UCA.js → chunk-TRO4CQHJ.js} +4 -4
  34. package/dist/{chunk-WINHSKFD.js → chunk-WGMYVRSA.js} +2 -2
  35. package/dist/{chunk-LQSF4JSV.js → chunk-YHPJTLCA.js} +2 -2
  36. package/dist/{chunk-BLKAJD2G.js → chunk-YM3K3LCD.js} +10 -10
  37. package/dist/{chunk-F5KWC7I3.js → chunk-YQZOPT3A.js} +81 -6
  38. package/dist/chunk-YQZOPT3A.js.map +1 -0
  39. package/dist/{chunk-F5PISJEI.js → chunk-ZZIQWSGC.js} +2 -2
  40. package/dist/chunks-MDMJRCJ7.js +10 -0
  41. package/dist/cli.js +30 -30
  42. package/dist/{formula-XAPMN6HX.js → formula-6XNIXZ5L.js} +3 -3
  43. package/dist/{formula-G5LTBMGC.cjs → formula-A3I5VAP7.cjs} +9 -9
  44. package/dist/{formula-G5LTBMGC.cjs.map → formula-A3I5VAP7.cjs.map} +1 -1
  45. package/dist/{formula-KHPAZKOK.js → formula-P7M7IH2L.js} +4 -4
  46. package/dist/{image-ocr-RNPHQ4C2.js → image-ocr-3C6W3KZO.js} +6 -6
  47. package/dist/{image-ocr-N5LAIHRV.js → image-ocr-ITNY454I.js} +9 -9
  48. package/dist/{image-ocr-MHPVAYOB.cjs → image-ocr-UJRSQ2T3.cjs} +15 -15
  49. package/dist/{image-ocr-MHPVAYOB.cjs.map → image-ocr-UJRSQ2T3.cjs.map} +1 -1
  50. package/dist/index.cjs +276 -276
  51. package/dist/index.js +5 -5
  52. package/dist/mcp.js +22 -22
  53. package/dist/{model-bundle-XP4AHFLT.js → model-bundle-LAWQH75O.js} +5 -5
  54. package/dist/{models-AD2KAUNC.js → models-6QTD2CFM.js} +5 -5
  55. package/dist/{parse-worker-v2-7UHOQ2TK.js → parse-worker-v2-FEPJG3ER.js} +12 -12
  56. package/dist/{parser-5WGRQKPI.js → parser-56I364YM.js} +16 -8
  57. package/dist/{parser-2RN5WNPJ.js.map → parser-56I364YM.js.map} +1 -1
  58. package/dist/{parser-2RN5WNPJ.js → parser-KFCY3NIN.js} +19 -11
  59. package/dist/{parser-5WGRQKPI.js.map → parser-KFCY3NIN.js.map} +1 -1
  60. package/dist/{parser-ZPCCXCVO.cjs → parser-VKWUMUML.cjs} +142 -134
  61. package/dist/parser-VKWUMUML.cjs.map +1 -0
  62. package/dist/pdf-ocr-MME37BL4.js +18 -0
  63. package/dist/pdf-ocr-OKAHNEJA.cjs +19 -0
  64. package/dist/{pdf-ocr-SFIWMJQL.cjs.map → pdf-ocr-OKAHNEJA.cjs.map} +1 -1
  65. package/dist/pdf-ocr-ZZ6AJL6Z.js +22 -0
  66. package/dist/{profile-io-UP7H2J6I.js → profile-io-OCITHUQF.js} +3 -3
  67. package/dist/{rasterize-XBCDG4MD.js → rasterize-SFCG4YOI.js} +3 -3
  68. package/dist/{redact-doc-CJ6W6YNR.js → redact-doc-5SMPXIGG.js} +11 -11
  69. package/dist/{render-K5UDHXRI.js → render-FGPG5A2N.js} +7 -7
  70. package/dist/seal-GA7NZDTG.js +10 -0
  71. package/dist/{setup-S66RLBBM.js → setup-JQVYZO7I.js} +3 -3
  72. package/dist/visual-YMG644YW.js +20 -0
  73. package/dist/{watch-PB7IOD73.js → watch-C77BUSP7.js} +12 -12
  74. package/package.json +1 -1
  75. package/dist/chunk-F5KWC7I3.js.map +0 -1
  76. package/dist/chunk-LY4ITNAL.js.map +0 -1
  77. package/dist/chunk-MOT7WOP5.cjs.map +0 -1
  78. package/dist/chunks-BJRBKGKZ.js +0 -10
  79. package/dist/parser-ZPCCXCVO.cjs.map +0 -1
  80. package/dist/pdf-ocr-KHY3P4EP.js +0 -18
  81. package/dist/pdf-ocr-LFDH6DFD.js +0 -22
  82. package/dist/pdf-ocr-SFIWMJQL.cjs +0 -19
  83. package/dist/seal-YCK6TM5I.js +0 -10
  84. package/dist/visual-S5ZNFWFH.js +0 -20
  85. /package/dist/{-QHQ2QKM7.js.map → -ZYF6HX4M.js.map} +0 -0
  86. /package/dist/{chunk-FU3SCGE7.js.map → chunk-2ZGP7A5T.js.map} +0 -0
  87. /package/dist/{chunk-TYYKK5DX.js.map → chunk-3TCF5HPP.js.map} +0 -0
  88. /package/dist/{chunk-75INFYVC.js.map → chunk-5HTFWUJE.js.map} +0 -0
  89. /package/dist/{chunk-G6G25HUO.js.map → chunk-7YAJCXCD.js.map} +0 -0
  90. /package/dist/{chunk-DBFAQJCX.js.map → chunk-BC54LBST.js.map} +0 -0
  91. /package/dist/{chunk-PALYDA3M.js.map → chunk-BG6LUCQL.js.map} +0 -0
  92. /package/dist/{chunk-42XYVZ2B.js.map → chunk-CY4QM2KQ.js.map} +0 -0
  93. /package/dist/{chunk-AINZICPE.js.map → chunk-FBJVDBMO.js.map} +0 -0
  94. /package/dist/{chunk-7ITWGPNB.js.map → chunk-FZMGF6XU.js.map} +0 -0
  95. /package/dist/{chunk-KBL24ZCP.js.map → chunk-HWIW3WK2.js.map} +0 -0
  96. /package/dist/{chunk-E5L6DUOE.js.map → chunk-J5PBI3ZC.js.map} +0 -0
  97. /package/dist/{chunk-JDVOYDIA.js.map → chunk-KTLHADU4.js.map} +0 -0
  98. /package/dist/{chunk-ZMGWKGSC.js.map → chunk-PTF4NCFM.js.map} +0 -0
  99. /package/dist/{chunk-N47I6OS7.js.map → chunk-QHNVH4TC.js.map} +0 -0
  100. /package/dist/{chunk-LO5A36FU.js.map → chunk-RBRHO7WL.js.map} +0 -0
  101. /package/dist/{chunk-6HIDMA5O.js.map → chunk-T3DTTK23.js.map} +0 -0
  102. /package/dist/{chunk-I4HF4UCA.js.map → chunk-TRO4CQHJ.js.map} +0 -0
  103. /package/dist/{chunk-WINHSKFD.js.map → chunk-WGMYVRSA.js.map} +0 -0
  104. /package/dist/{chunk-LQSF4JSV.js.map → chunk-YHPJTLCA.js.map} +0 -0
  105. /package/dist/{chunk-BLKAJD2G.js.map → chunk-YM3K3LCD.js.map} +0 -0
  106. /package/dist/{chunk-F5PISJEI.js.map → chunk-ZZIQWSGC.js.map} +0 -0
  107. /package/dist/{chunks-BJRBKGKZ.js.map → chunks-MDMJRCJ7.js.map} +0 -0
  108. /package/dist/{formula-XAPMN6HX.js.map → formula-6XNIXZ5L.js.map} +0 -0
  109. /package/dist/{formula-KHPAZKOK.js.map → formula-P7M7IH2L.js.map} +0 -0
  110. /package/dist/{image-ocr-RNPHQ4C2.js.map → image-ocr-3C6W3KZO.js.map} +0 -0
  111. /package/dist/{image-ocr-N5LAIHRV.js.map → image-ocr-ITNY454I.js.map} +0 -0
  112. /package/dist/{model-bundle-XP4AHFLT.js.map → model-bundle-LAWQH75O.js.map} +0 -0
  113. /package/dist/{models-AD2KAUNC.js.map → models-6QTD2CFM.js.map} +0 -0
  114. /package/dist/{parse-worker-v2-7UHOQ2TK.js.map → parse-worker-v2-FEPJG3ER.js.map} +0 -0
  115. /package/dist/{pdf-ocr-KHY3P4EP.js.map → pdf-ocr-MME37BL4.js.map} +0 -0
  116. /package/dist/{pdf-ocr-LFDH6DFD.js.map → pdf-ocr-ZZ6AJL6Z.js.map} +0 -0
  117. /package/dist/{profile-io-UP7H2J6I.js.map → profile-io-OCITHUQF.js.map} +0 -0
  118. /package/dist/{rasterize-XBCDG4MD.js.map → rasterize-SFCG4YOI.js.map} +0 -0
  119. /package/dist/{redact-doc-CJ6W6YNR.js.map → redact-doc-5SMPXIGG.js.map} +0 -0
  120. /package/dist/{render-K5UDHXRI.js.map → render-FGPG5A2N.js.map} +0 -0
  121. /package/dist/{seal-YCK6TM5I.js.map → seal-GA7NZDTG.js.map} +0 -0
  122. /package/dist/{setup-S66RLBBM.js.map → setup-JQVYZO7I.js.map} +0 -0
  123. /package/dist/{visual-S5ZNFWFH.js.map → visual-YMG644YW.js.map} +0 -0
  124. /package/dist/{watch-PB7IOD73.js.map → watch-C77BUSP7.js.map} +0 -0
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  UNRULED_REGION_TABLES,
7
7
  extractPageBlocksWithLines
8
- } from "./chunk-LY4ITNAL.js";
8
+ } from "./chunk-KBV4WFZ6.js";
9
9
  import {
10
10
  OCR_DET_MODEL,
11
11
  OCR_REC_DICT,
@@ -13,10 +13,10 @@ import {
13
13
  ensureOcrModels,
14
14
  getOcrModelsDir,
15
15
  parseCharacterDict
16
- } from "./chunk-WINHSKFD.js";
16
+ } from "./chunk-WGMYVRSA.js";
17
17
  import {
18
18
  OPTIONAL_DEP_INSTALL_HINT
19
- } from "./chunk-7ITWGPNB.js";
19
+ } from "./chunk-FZMGF6XU.js";
20
20
 
21
21
  // src/ocr/ruling-lines.ts
22
22
  var INK_LUMA_MAX = 205;
@@ -2133,4 +2133,4 @@ export {
2133
2133
  groupOcrLines,
2134
2134
  ocrItemsToBlocks
2135
2135
  };
2136
- //# sourceMappingURL=chunk-I4HF4UCA.js.map
2136
+ //# sourceMappingURL=chunk-TRO4CQHJ.js.map
@@ -3,7 +3,7 @@ import {
3
3
  ensureModelsIn,
4
4
  getModelStatusIn,
5
5
  getModelsDir
6
- } from "./chunk-TYYKK5DX.js";
6
+ } from "./chunk-3TCF5HPP.js";
7
7
 
8
8
  // src/ocr/models.ts
9
9
  import { join } from "path";
@@ -93,4 +93,4 @@ export {
93
93
  parseCharacterDict,
94
94
  ocrModelPath
95
95
  };
96
- //# sourceMappingURL=chunk-WINHSKFD.js.map
96
+ //# sourceMappingURL=chunk-WGMYVRSA.js.map
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  KordocError,
4
4
  OPTIONAL_DEP_INSTALL_HINT
5
- } from "./chunk-7ITWGPNB.js";
5
+ } from "./chunk-FZMGF6XU.js";
6
6
 
7
7
  // src/render/rasterize.ts
8
8
  var densityExponent = null;
@@ -88,4 +88,4 @@ export {
88
88
  rasterizeSvg,
89
89
  rasterizePageSvg
90
90
  };
91
- //# sourceMappingURL=chunk-LQSF4JSV.js.map
91
+ //# sourceMappingURL=chunk-YHPJTLCA.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  blocksToPages
4
- } from "./chunk-FU3SCGE7.js";
4
+ } from "./chunk-2ZGP7A5T.js";
5
5
  import {
6
6
  allLinesegRemovalSplices,
7
7
  applySplices,
@@ -17,7 +17,7 @@ import {
17
17
  patchZipEntries,
18
18
  readZipEntries,
19
19
  scanSectionXml
20
- } from "./chunk-KBL24ZCP.js";
20
+ } from "./chunk-HWIW3WK2.js";
21
21
  import {
22
22
  CONVERT_MAP,
23
23
  FLAG_COMPRESSED,
@@ -68,7 +68,7 @@ import {
68
68
  romanNumeral,
69
69
  simulateWrap,
70
70
  takeTocLeaders
71
- } from "./chunk-N47I6OS7.js";
71
+ } from "./chunk-QHNVH4TC.js";
72
72
  import {
73
73
  inlineImagesIntoMarkdown
74
74
  } from "./chunk-7FCNOKOR.js";
@@ -83,7 +83,7 @@ import {
83
83
  tidyScriptTags,
84
84
  unframeLayoutTables,
85
85
  wrapScript
86
- } from "./chunk-ZMGWKGSC.js";
86
+ } from "./chunk-PTF4NCFM.js";
87
87
  import {
88
88
  parsePageRange
89
89
  } from "./chunk-VQFA55IC.js";
@@ -103,7 +103,7 @@ import {
103
103
  localName,
104
104
  rawTextContent,
105
105
  readZipEntry
106
- } from "./chunk-PALYDA3M.js";
106
+ } from "./chunk-BG6LUCQL.js";
107
107
  import {
108
108
  MAX_COLS,
109
109
  MAX_ROWS,
@@ -118,7 +118,7 @@ import {
118
118
  hasStructuredCellContent,
119
119
  mapPuaText,
120
120
  noteSuffix
121
- } from "./chunk-LO5A36FU.js";
121
+ } from "./chunk-RBRHO7WL.js";
122
122
  import {
123
123
  KordocError,
124
124
  classifyError,
@@ -134,7 +134,7 @@ import {
134
134
  toArrayBuffer,
135
135
  unescapeHtml,
136
136
  unzipLimitBytes
137
- } from "./chunk-7ITWGPNB.js";
137
+ } from "./chunk-FZMGF6XU.js";
138
138
 
139
139
  // src/table/visual.ts
140
140
  import { readFile as readFile2 } from "fs/promises";
@@ -31099,7 +31099,7 @@ function scriptsOff(r, off) {
31099
31099
  }
31100
31100
  async function parseImage(buffer, options) {
31101
31101
  try {
31102
- const { parseImageDocument } = await import("./image-ocr-N5LAIHRV.js");
31102
+ const { parseImageDocument } = await import("./image-ocr-ITNY454I.js");
31103
31103
  const { blocks, warnings } = await parseImageDocument(buffer, options);
31104
31104
  stripScriptTags({ blocks });
31105
31105
  return {
@@ -31159,7 +31159,7 @@ async function parseHwp(buffer, options) {
31159
31159
  async function parsePdf(buffer, options) {
31160
31160
  let parsePdfDocument;
31161
31161
  try {
31162
- const mod = await import("./parser-2RN5WNPJ.js");
31162
+ const mod = await import("./parser-KFCY3NIN.js");
31163
31163
  parsePdfDocument = mod.parsePdfDocument;
31164
31164
  } catch {
31165
31165
  return {
@@ -31389,4 +31389,4 @@ export {
31389
31389
  parseHwpml,
31390
31390
  fillForm
31391
31391
  };
31392
- //# sourceMappingURL=chunk-BLKAJD2G.js.map
31392
+ //# sourceMappingURL=chunk-YM3K3LCD.js.map
@@ -4,15 +4,15 @@ import {
4
4
  HEADING_RATIO_H2,
5
5
  HEADING_RATIO_H3,
6
6
  tidyScriptTags
7
- } from "./chunk-JDVOYDIA.js";
7
+ } from "./chunk-KTLHADU4.js";
8
8
  import {
9
9
  ensureModelsIn,
10
10
  getModelsDir
11
- } from "./chunk-AINZICPE.js";
11
+ } from "./chunk-FBJVDBMO.js";
12
12
  import {
13
13
  safeMax,
14
14
  safeMin
15
- } from "./chunk-F5PISJEI.js";
15
+ } from "./chunk-ZZIQWSGC.js";
16
16
 
17
17
  // src/ocr/models.ts
18
18
  import { join } from "path";
@@ -5744,6 +5744,20 @@ function detectSpecialKoreanTables(blocks) {
5744
5744
  flushKvTable();
5745
5745
  return result;
5746
5746
  }
5747
+ function tracksPages(occ) {
5748
+ const nums = occ.map((o) => [...o.text.matchAll(/\d+/g)].map((m) => +m[0]));
5749
+ if (!nums.length || nums.some((n) => n.length !== nums[0].length)) return false;
5750
+ return nums[0].some((_, j) => new Set(occ.map((o, k) => o.page - nums[k][j])).size === 1);
5751
+ }
5752
+ function looseVaryingNumber(occ) {
5753
+ const nums = occ.map((o) => [...o.text.matchAll(/\d+/g)]);
5754
+ if (!nums.length || nums.some((n) => n.length !== nums[0].length)) return false;
5755
+ const loose = (text, m) => !/\p{L}/u.test(text[m.index - 1] ?? " ") && !/\p{L}/u.test(text[m.index + m[0].length] ?? " ");
5756
+ for (let j = 0; j < nums[0].length; j++) {
5757
+ if (new Set(nums.map((n) => n[j][0])).size > 1 && occ.every((o, k) => loose(o.text, nums[k][j]))) return true;
5758
+ }
5759
+ return false;
5760
+ }
5747
5761
  function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables = false, context = []) {
5748
5762
  if (context.length && !tables) {
5749
5763
  const removed = removeHeaderFooterBlocks([...blocks, ...context], pageHeights, [], notes).filter((index) => index < blocks.length);
@@ -5773,6 +5787,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
5773
5787
  const patternCount = /* @__PURE__ */ new Map();
5774
5788
  const patternPages = /* @__PURE__ */ new Map();
5775
5789
  const patternNumbers = /* @__PURE__ */ new Map();
5790
+ const patternOcc = /* @__PURE__ */ new Map();
5776
5791
  for (const e of entries) {
5777
5792
  const norm = e.text.replace(/\d+/g, "#");
5778
5793
  patternCount.set(norm, (patternCount.get(norm) || 0) + 1);
@@ -5782,13 +5797,18 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
5782
5797
  const pages = patternPages.get(norm) || /* @__PURE__ */ new Set();
5783
5798
  pages.add(e.page);
5784
5799
  patternPages.set(norm, pages);
5800
+ patternOcc.set(norm, [...patternOcc.get(norm) ?? [], e]);
5785
5801
  }
5786
5802
  const repeatedPatterns = /* @__PURE__ */ new Set();
5787
5803
  for (const [p, count] of patternCount) {
5788
5804
  const pages = [...patternPages.get(p) ?? []];
5789
5805
  const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
5790
- const pageNumbered = !tables && (patternNumbers.get(p)?.size ?? 0) > 1;
5791
- if (count >= MIN_REPEAT2 && pages.length >= MIN_REPEAT2 && (pages.length >= span2 * 0.4 || pageNumbered)) {
5806
+ const varying = !tables && (patternNumbers.get(p)?.size ?? 0) > 1;
5807
+ const occ = patternOcc.get(p) ?? [];
5808
+ const dense = pages.length >= span2 * 0.4;
5809
+ const loose = looseVaryingNumber(occ) && (entries === bottomEntries || dense || tracksPages(occ));
5810
+ const pageNumbered = varying && (loose || dense && new Set(occ.map((o) => o.text)).size * 2 <= occ.length);
5811
+ if (count >= MIN_REPEAT2 && pages.length >= MIN_REPEAT2 && (varying ? pageNumbered : dense)) {
5792
5812
  repeatedPatterns.add(p);
5793
5813
  }
5794
5814
  }
@@ -5826,6 +5846,59 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
5826
5846
  }
5827
5847
  return [...removeSet].sort((a, b) => a - b);
5828
5848
  }
5849
+ function runningLinePatterns(removed, pageHeights) {
5850
+ const occ = /* @__PURE__ */ new Map();
5851
+ for (const b of removed) {
5852
+ const ph = b.bbox && b.pageNumber ? pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber) : void 0;
5853
+ const key = b.text ? runningKey(b.text) : "";
5854
+ if (!ph || !b.bbox || !b.pageNumber || !/\p{L}/u.test(key) || ph - b.bbox.y <= ph * 0.5) continue;
5855
+ (occ.get(key) ?? occ.set(key, []).get(key)).push({ page: b.pageNumber, nums: (b.text.match(/\d+/g) ?? []).join(",") });
5856
+ }
5857
+ const out = /* @__PURE__ */ new Map();
5858
+ for (const [key, list] of occ) {
5859
+ if (!pageNumberAtEnd(key)) continue;
5860
+ const offsets = new Set(list.map((o) => o.page - +o.nums));
5861
+ if (offsets.size === 1) out.set(key, [...offsets][0]);
5862
+ }
5863
+ return out;
5864
+ }
5865
+ var runningKey = (s) => s.replace(/\d+/g, "#").replace(/\s+/g, " ").trim();
5866
+ var pageNumberAtEnd = (key) => (key.match(/#/g) ?? []).length === 1 && /#\s*[)\]]?$/.test(key);
5867
+ function stripAbsorbedRunningLines(blocks, pageHeights, running) {
5868
+ if (!running.size) return blocks;
5869
+ const matches = (line, page) => {
5870
+ const offset = running.get(runningKey(line));
5871
+ return offset !== void 0 && page - +(line.match(/\d+/g) ?? []).pop() === offset;
5872
+ };
5873
+ const out = [];
5874
+ for (const b of blocks) {
5875
+ const ph = b.bbox && b.pageNumber ? pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber) : void 0;
5876
+ if (!ph || !b.bbox || !b.pageNumber || b.bbox.y > ph * 0.12) {
5877
+ out.push(b);
5878
+ continue;
5879
+ }
5880
+ if (b.type === "paragraph" && b.text) {
5881
+ const lines = b.text.split("\n");
5882
+ let hi = lines.length;
5883
+ while (hi > 0 && !lines[hi - 1].trim()) hi--;
5884
+ if (hi > 0 && matches(lines[hi - 1], b.pageNumber)) {
5885
+ const text = lines.slice(0, hi - 1).join("\n").trim();
5886
+ if (!text) continue;
5887
+ b.text = text;
5888
+ }
5889
+ } else if (b.type === "table" && b.table && b.table.cells.length) {
5890
+ const t = b.table, last = t.cells.length - 1;
5891
+ if (matches(t.cells[last].map((c) => c.text.trim()).filter(Boolean).join(" "), b.pageNumber) && !t.cells.slice(0, last).some((row, i) => row.some((c) => i + (c.rowSpan || 1) - 1 >= last))) {
5892
+ t.cells.pop();
5893
+ if (!t.cells.length) continue;
5894
+ t.rows = t.cells.length;
5895
+ t.hasHeader = t.hasHeader && t.rows > 1;
5896
+ }
5897
+ }
5898
+ out.push(b);
5899
+ }
5900
+ return out;
5901
+ }
5829
5902
 
5830
5903
  // src/pdf/table-meta.ts
5831
5904
  var CLIP_TABLES = /* @__PURE__ */ new WeakSet();
@@ -8874,6 +8947,8 @@ export {
8874
8947
  detectTableCaptions,
8875
8948
  detectKoreanListBlocks,
8876
8949
  removeHeaderFooterBlocks,
8950
+ runningLinePatterns,
8951
+ stripAbsorbedRunningLines,
8877
8952
  CLIP_TABLES,
8878
8953
  FRAME_TITLE_BLOCKS,
8879
8954
  TABLE_COLXS,
@@ -8896,4 +8971,4 @@ export {
8896
8971
  UNRULED_REGION_TABLES,
8897
8972
  mergeOcrImageRegions
8898
8973
  };
8899
- //# sourceMappingURL=chunk-F5KWC7I3.js.map
8974
+ //# sourceMappingURL=chunk-YQZOPT3A.js.map