kordoc 4.12.1 → 4.12.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 (111) hide show
  1. package/README.md +11 -0
  2. package/dist/{-BUYIUNW3.js → -EZH6NKTE.js} +8 -8
  3. package/dist/{chunk-WGUVKNBX.js → chunk-2B7OIEJJ.js} +6 -3
  4. package/dist/chunk-2B7OIEJJ.js.map +1 -0
  5. package/dist/{chunk-CJPVVR2Y.js → chunk-2HBYWA5X.js} +2 -2
  6. package/dist/{chunk-EOGPRO3U.cjs → chunk-2LKYJ4G3.cjs} +6 -6
  7. package/dist/{chunk-EOGPRO3U.cjs.map → chunk-2LKYJ4G3.cjs.map} +1 -1
  8. package/dist/{chunk-FNCBOTM5.js → chunk-2LO525TL.js} +2 -2
  9. package/dist/{chunk-WJOWM27X.cjs → chunk-2LPBIW2B.cjs} +3 -3
  10. package/dist/{chunk-WJOWM27X.cjs.map → chunk-2LPBIW2B.cjs.map} +1 -1
  11. package/dist/{chunk-6MF7JRG3.cjs → chunk-62IU4NV3.cjs} +2 -2
  12. package/dist/{chunk-6MF7JRG3.cjs.map → chunk-62IU4NV3.cjs.map} +1 -1
  13. package/dist/{chunk-BPKJTQAW.js → chunk-7XUXSDH5.js} +89 -25
  14. package/dist/chunk-7XUXSDH5.js.map +1 -0
  15. package/dist/{chunk-ST3JBCIL.js → chunk-DBGEUDBY.js} +2 -2
  16. package/dist/{chunk-E37VAV46.js → chunk-FBLMVHDK.js} +2 -2
  17. package/dist/{chunk-EWSH6O6S.js → chunk-FVBR7SC3.js} +2 -2
  18. package/dist/{chunk-F2KL5Z5T.js → chunk-IOJX4Q63.js} +3 -3
  19. package/dist/{chunk-L5DNHSX4.js → chunk-JCMBQC5N.js} +2 -2
  20. package/dist/{chunk-JD4H6Y33.js → chunk-KX7IYCCZ.js} +3 -3
  21. package/dist/{chunk-VO37BVAH.js → chunk-LD2K4K5V.js} +40 -19
  22. package/dist/chunk-LD2K4K5V.js.map +1 -0
  23. package/dist/{chunk-D2XNLIFU.js → chunk-MUYU4JI5.js} +2 -2
  24. package/dist/{chunk-OS2IOI3W.js → chunk-OEYECZGV.js} +89 -25
  25. package/dist/chunk-OEYECZGV.js.map +1 -0
  26. package/dist/{chunk-MXZXZTKW.cjs → chunk-ONNAHSPV.cjs} +104 -40
  27. package/dist/chunk-ONNAHSPV.cjs.map +1 -0
  28. package/dist/{chunk-JQBF4PSF.js → chunk-Q6ETEJFK.js} +6 -3
  29. package/dist/chunk-Q6ETEJFK.js.map +1 -0
  30. package/dist/{chunk-ELCPCTJ6.js → chunk-QBCMFNHS.js} +2 -2
  31. package/dist/{chunk-DXKNPBXX.js → chunk-QM2RSJ2S.js} +3 -3
  32. package/dist/{chunk-L6FIUSD2.js → chunk-UL2MDA5C.js} +3 -3
  33. package/dist/{chunk-CBPO5IZZ.cjs → chunk-V5BUPZ6I.cjs} +20 -17
  34. package/dist/chunk-V5BUPZ6I.cjs.map +1 -0
  35. package/dist/{chunk-7U34YNFR.js → chunk-XXDZ2KTW.js} +2 -2
  36. package/dist/chunks-TT7ZE5QQ.js +10 -0
  37. package/dist/cli.js +20 -20
  38. package/dist/{formula-7TN26AKF.js → formula-6RQX4NMJ.js} +4 -4
  39. package/dist/{formula-XKRMKGAW.cjs → formula-NBEO6CFC.cjs} +9 -9
  40. package/dist/{formula-XKRMKGAW.cjs.map → formula-NBEO6CFC.cjs.map} +1 -1
  41. package/dist/{formula-RZNSECGO.js → formula-NW33S4TA.js} +3 -3
  42. package/dist/{image-ocr-3O34O7XS.js → image-ocr-CAVU2TNZ.js} +5 -5
  43. package/dist/{image-ocr-TNU4ILLU.js → image-ocr-SO56VETS.js} +7 -7
  44. package/dist/{image-ocr-XDZONLD6.cjs → image-ocr-V4KY373B.cjs} +11 -11
  45. package/dist/{image-ocr-XDZONLD6.cjs.map → image-ocr-V4KY373B.cjs.map} +1 -1
  46. package/dist/index.cjs +419 -398
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.js +36 -15
  49. package/dist/index.js.map +1 -1
  50. package/dist/mcp.js +15 -15
  51. package/dist/{model-bundle-NCYN375I.js → model-bundle-EIJF34DR.js} +5 -5
  52. package/dist/{models-J4G4VZMU.js → models-6V4CPQXC.js} +5 -5
  53. package/dist/{parser-6IH62P6U.js → parser-GIREMEPD.js} +6 -6
  54. package/dist/{parser-5WZBCP7H.js → parser-OBHNXEQM.js} +6 -6
  55. package/dist/{parser-LVMTVO2N.cjs → parser-OMT25WH2.cjs} +26 -26
  56. package/dist/{parser-LVMTVO2N.cjs.map → parser-OMT25WH2.cjs.map} +1 -1
  57. package/dist/pdf-ocr-IRXQ5GBM.js +13 -0
  58. package/dist/pdf-ocr-SL4GCOGS.js +16 -0
  59. package/dist/pdf-ocr-TFYVK4FI.cjs +14 -0
  60. package/dist/{pdf-ocr-IAO273AQ.cjs.map → pdf-ocr-TFYVK4FI.cjs.map} +1 -1
  61. package/dist/{profile-io-ANPS7DTT.js → profile-io-PZVMM66V.js} +3 -3
  62. package/dist/{rasterize-FKXCEFHV.js → rasterize-NRWP2C6L.js} +2 -2
  63. package/dist/render-V5ZPTZQ7.js +10 -0
  64. package/dist/seal-LVG2DGAB.js +10 -0
  65. package/dist/{setup-DEAFODGI.js → setup-V55AJP6H.js} +3 -3
  66. package/dist/{watch-B5X7IAMK.js → watch-7CQSMDDP.js} +9 -9
  67. package/package.json +1 -1
  68. package/dist/chunk-BPKJTQAW.js.map +0 -1
  69. package/dist/chunk-CBPO5IZZ.cjs.map +0 -1
  70. package/dist/chunk-JQBF4PSF.js.map +0 -1
  71. package/dist/chunk-MXZXZTKW.cjs.map +0 -1
  72. package/dist/chunk-OS2IOI3W.js.map +0 -1
  73. package/dist/chunk-VO37BVAH.js.map +0 -1
  74. package/dist/chunk-WGUVKNBX.js.map +0 -1
  75. package/dist/chunks-G2U2XUZU.js +0 -10
  76. package/dist/pdf-ocr-5PLJOKGI.js +0 -13
  77. package/dist/pdf-ocr-7FPCZCV7.js +0 -16
  78. package/dist/pdf-ocr-IAO273AQ.cjs +0 -14
  79. package/dist/render-NWQI3AXU.js +0 -10
  80. package/dist/seal-N3GCBTVA.js +0 -10
  81. /package/dist/{-BUYIUNW3.js.map → -EZH6NKTE.js.map} +0 -0
  82. /package/dist/{chunk-CJPVVR2Y.js.map → chunk-2HBYWA5X.js.map} +0 -0
  83. /package/dist/{chunk-FNCBOTM5.js.map → chunk-2LO525TL.js.map} +0 -0
  84. /package/dist/{chunk-ST3JBCIL.js.map → chunk-DBGEUDBY.js.map} +0 -0
  85. /package/dist/{chunk-E37VAV46.js.map → chunk-FBLMVHDK.js.map} +0 -0
  86. /package/dist/{chunk-EWSH6O6S.js.map → chunk-FVBR7SC3.js.map} +0 -0
  87. /package/dist/{chunk-F2KL5Z5T.js.map → chunk-IOJX4Q63.js.map} +0 -0
  88. /package/dist/{chunk-L5DNHSX4.js.map → chunk-JCMBQC5N.js.map} +0 -0
  89. /package/dist/{chunk-JD4H6Y33.js.map → chunk-KX7IYCCZ.js.map} +0 -0
  90. /package/dist/{chunk-D2XNLIFU.js.map → chunk-MUYU4JI5.js.map} +0 -0
  91. /package/dist/{chunk-ELCPCTJ6.js.map → chunk-QBCMFNHS.js.map} +0 -0
  92. /package/dist/{chunk-DXKNPBXX.js.map → chunk-QM2RSJ2S.js.map} +0 -0
  93. /package/dist/{chunk-L6FIUSD2.js.map → chunk-UL2MDA5C.js.map} +0 -0
  94. /package/dist/{chunk-7U34YNFR.js.map → chunk-XXDZ2KTW.js.map} +0 -0
  95. /package/dist/{chunks-G2U2XUZU.js.map → chunks-TT7ZE5QQ.js.map} +0 -0
  96. /package/dist/{formula-7TN26AKF.js.map → formula-6RQX4NMJ.js.map} +0 -0
  97. /package/dist/{formula-RZNSECGO.js.map → formula-NW33S4TA.js.map} +0 -0
  98. /package/dist/{image-ocr-3O34O7XS.js.map → image-ocr-CAVU2TNZ.js.map} +0 -0
  99. /package/dist/{image-ocr-TNU4ILLU.js.map → image-ocr-SO56VETS.js.map} +0 -0
  100. /package/dist/{model-bundle-NCYN375I.js.map → model-bundle-EIJF34DR.js.map} +0 -0
  101. /package/dist/{models-J4G4VZMU.js.map → models-6V4CPQXC.js.map} +0 -0
  102. /package/dist/{parser-6IH62P6U.js.map → parser-GIREMEPD.js.map} +0 -0
  103. /package/dist/{parser-5WZBCP7H.js.map → parser-OBHNXEQM.js.map} +0 -0
  104. /package/dist/{pdf-ocr-5PLJOKGI.js.map → pdf-ocr-IRXQ5GBM.js.map} +0 -0
  105. /package/dist/{pdf-ocr-7FPCZCV7.js.map → pdf-ocr-SL4GCOGS.js.map} +0 -0
  106. /package/dist/{profile-io-ANPS7DTT.js.map → profile-io-PZVMM66V.js.map} +0 -0
  107. /package/dist/{rasterize-FKXCEFHV.js.map → rasterize-NRWP2C6L.js.map} +0 -0
  108. /package/dist/{render-NWQI3AXU.js.map → render-V5ZPTZQ7.js.map} +0 -0
  109. /package/dist/{seal-N3GCBTVA.js.map → seal-LVG2DGAB.js.map} +0 -0
  110. /package/dist/{setup-DEAFODGI.js.map → setup-V55AJP6H.js.map} +0 -0
  111. /package/dist/{watch-B5X7IAMK.js.map → watch-7CQSMDDP.js.map} +0 -0
@@ -6,7 +6,7 @@ var _chunkT7GRHAIWcjs = require('./chunk-T7GRHAIW.cjs');
6
6
 
7
7
 
8
8
 
9
- var _chunk6MF7JRG3cjs = require('./chunk-6MF7JRG3.cjs');
9
+ var _chunk62IU4NV3cjs = require('./chunk-62IU4NV3.cjs');
10
10
 
11
11
  // src/pdf/image-regions.ts
12
12
  var _pdfmjs = require('pdfjs-dist/legacy/build/pdf.mjs');
@@ -1009,8 +1009,14 @@ function edgeStroked(lines, dir, pos, a1, a2) {
1009
1009
  }
1010
1010
  function buildClipCellGrids(rects, strokedH, strokedV, pageWidth, pageHeight) {
1011
1011
  const pageArea = pageWidth * pageHeight;
1012
- const cells = rects.filter((r) => r.x2 - r.x1 >= CLIP_MIN_W2 && r.y2 - r.y1 >= CLIP_MIN_H2 && (pageArea <= 0 || (r.x2 - r.x1) * (r.y2 - r.y1) < pageArea * CLIP_MAX_PAGE_FRAC));
1013
- if (cells.length < CLIP_MIN_GROUP) return { grids: [], containers: [] };
1012
+ const sameRect = (a, b) => Math.abs(a.x1 - b.x1) <= CLIP_EDGE_TOL && Math.abs(a.x2 - b.x2) <= CLIP_EDGE_TOL && Math.abs(a.y1 - b.y1) <= CLIP_EDGE_TOL && Math.abs(a.y2 - b.y2) <= CLIP_EDGE_TOL;
1013
+ const cells = [];
1014
+ for (const r of rects) {
1015
+ if (r.x2 - r.x1 < CLIP_MIN_W2 || r.y2 - r.y1 < CLIP_MIN_H2) continue;
1016
+ if (pageArea > 0 && (r.x2 - r.x1) * (r.y2 - r.y1) >= pageArea * CLIP_MAX_PAGE_FRAC) continue;
1017
+ if (!cells.some((c) => sameRect(c, r))) cells.push(r);
1018
+ }
1019
+ if (cells.length < 1) return { grids: [], containers: [] };
1014
1020
  const parent = new Array(cells.length).fill(-1);
1015
1021
  for (let i = 0; i < cells.length; i++) {
1016
1022
  for (let j = 0; j < cells.length; j++) {
@@ -1045,15 +1051,30 @@ function buildClipCellGrids(rects, strokedH, strokedV, pageWidth, pageHeight) {
1045
1051
  if (g) g.push(i);
1046
1052
  else groups.set(r, [i]);
1047
1053
  }
1048
- const containers = [];
1049
- for (let i = 0; i < cells.length; i++) {
1050
- if (!isContainer[i]) continue;
1051
- const r = cells[i];
1052
- if (!containers.some((c) => Math.abs(c.x1 - r.x1) <= CLIP_EDGE_TOL && Math.abs(c.x2 - r.x2) <= CLIP_EDGE_TOL && Math.abs(c.y1 - r.y1) <= CLIP_EDGE_TOL && Math.abs(c.y2 - r.y2) <= CLIP_EDGE_TOL)) containers.push(r);
1053
- }
1054
+ const containers = cells.filter((_, i) => isContainer[i]);
1055
+ const groupSize = (i) => _nullishCoalesce(_optionalChain([groups, 'access', _4 => _4.get, 'call', _5 => _5(find(i)), 'optionalAccess', _6 => _6.length]), () => ( 0));
1056
+ const isGridMember = (i) => groupSize(i) >= CLIP_MIN_GROUP;
1057
+ const framed = (r) => edgeStroked(strokedH, "h", r.y1, r.x1, r.x2) && edgeStroked(strokedH, "h", r.y2, r.x1, r.x2) && edgeStroked(strokedV, "v", r.x1, r.y1, r.y2) && edgeStroked(strokedV, "v", r.x2, r.y1, r.y2);
1058
+ const loneFrame = (i) => isContainer[i] && !isGridMember(i) && framed(cells[i]);
1059
+ const parentAttachable = (i) => parent[i] >= 0 && (isGridMember(parent[i]) || loneFrame(parent[i]));
1060
+ const onlyChild = (i) => parent[i] >= 0 && parent.filter((p) => p === parent[i]).length === 1;
1054
1061
  const grids = [];
1055
1062
  for (const idxs of groups.values()) {
1056
- if (idxs.length < CLIP_MIN_GROUP) continue;
1063
+ const first = idxs[0];
1064
+ const parentRect = parentAttachable(first) ? cells[parent[first]] : void 0;
1065
+ if (idxs.length < CLIP_MIN_GROUP) {
1066
+ if (!loneFrame(first) && !((parentRect || onlyChild(first)) && framed(cells[first]))) continue;
1067
+ const r = cells[first];
1068
+ grids.push({
1069
+ rowYs: [r.y2, r.y1],
1070
+ colXs: [r.x1, r.x2],
1071
+ bbox: { x1: r.x1, y1: r.y1, x2: r.x2, y2: r.y2 },
1072
+ vertexRadius: 1,
1073
+ cells: [{ row: 0, col: 0, rowSpan: 1, colSpan: 1, bbox: { x1: r.x1, y1: r.y1, x2: r.x2, y2: r.y2 } }],
1074
+ ...parentRect ? { clipParent: parentRect } : {}
1075
+ });
1076
+ continue;
1077
+ }
1057
1078
  const members = idxs.map((i) => cells[i]);
1058
1079
  let edges = 0, invisible = 0;
1059
1080
  for (const r of members) {
@@ -1094,7 +1115,8 @@ function buildClipCellGrids(rects, strokedH, strokedV, pageWidth, pageHeight) {
1094
1115
  colXs,
1095
1116
  bbox: { x1: colXs[0], y1: rowYs[numRows], x2: colXs[numCols], y2: rowYs[0] },
1096
1117
  vertexRadius: 1,
1097
- cells: out
1118
+ cells: out,
1119
+ ...parentRect ? { clipParent: parentRect } : {}
1098
1120
  });
1099
1121
  }
1100
1122
  return { grids, containers };
@@ -1573,7 +1595,7 @@ function dominantStyle(items) {
1573
1595
  }
1574
1596
  }
1575
1597
  if (dominantSize === 0) return void 0;
1576
- const fontName = _optionalChain([items, 'access', _4 => _4.find, 'call', _5 => _5((i) => i.fontSize === dominantSize), 'optionalAccess', _6 => _6.fontName]) || void 0;
1598
+ const fontName = _optionalChain([items, 'access', _7 => _7.find, 'call', _8 => _8((i) => i.fontSize === dominantSize), 'optionalAccess', _9 => _9.fontName]) || void 0;
1577
1599
  return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
1578
1600
  }
1579
1601
  function normalizeItems(rawItems) {
@@ -1700,7 +1722,7 @@ function mergeSuperscriptLines(lines) {
1700
1722
  return result;
1701
1723
  }
1702
1724
  function mergeLineSimple(items) {
1703
- if (items.length <= 1) return _optionalChain([items, 'access', _7 => _7[0], 'optionalAccess', _8 => _8.text]) || "";
1725
+ if (items.length <= 1) return _optionalChain([items, 'access', _10 => _10[0], 'optionalAccess', _11 => _11.text]) || "";
1704
1726
  const sorted = [...items].sort((a, b) => a.x - b.x);
1705
1727
  const isEvenSpaced = detectEvenSpacedItems(sorted);
1706
1728
  let result = sorted[0].text;
@@ -1749,7 +1771,7 @@ function computeMedianFontSizeFromFreq(freq) {
1749
1771
  }
1750
1772
  function detectHeadings(blocks, medianFontSize) {
1751
1773
  for (const block of blocks) {
1752
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _9 => _9.style, 'optionalAccess', _10 => _10.fontSize])) continue;
1774
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _12 => _12.style, 'optionalAccess', _13 => _13.fontSize])) continue;
1753
1775
  const text = block.text.trim();
1754
1776
  if (text.length === 0 || text.length > 200) continue;
1755
1777
  if (/^\d+$/.test(text)) continue;
@@ -1810,7 +1832,7 @@ function detectMarkerHeadings(blocks) {
1810
1832
  block.level = 4;
1811
1833
  continue;
1812
1834
  }
1813
- if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
1835
+ if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _14 => _14.style, 'optionalAccess', _15 => _15.fontSize])) {
1814
1836
  const prev = blocks[i - 1];
1815
1837
  const next = blocks[i + 1];
1816
1838
  const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
@@ -2065,7 +2087,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings) {
2065
2087
  const bottomEntries = [];
2066
2088
  for (let bi = 0; bi < blocks.length; bi++) {
2067
2089
  const b = blocks[bi];
2068
- if (!b.bbox || !b.pageNumber || !_optionalChain([b, 'access', _13 => _13.text, 'optionalAccess', _14 => _14.trim, 'call', _15 => _15()])) continue;
2090
+ if (!b.bbox || !b.pageNumber || !_optionalChain([b, 'access', _16 => _16.text, 'optionalAccess', _17 => _17.trim, 'call', _18 => _18()])) continue;
2069
2091
  const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
2070
2092
  if (!ph) continue;
2071
2093
  const blockTop = ph - (b.bbox.y + b.bbox.height);
@@ -2088,7 +2110,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings) {
2088
2110
  }
2089
2111
  const repeatedPatterns = /* @__PURE__ */ new Set();
2090
2112
  for (const [p, count] of patternCount) {
2091
- if (count >= MIN_REPEAT && (_nullishCoalesce(_optionalChain([patternPages, 'access', _16 => _16.get, 'call', _17 => _17(p), 'optionalAccess', _18 => _18.size]), () => ( 0))) >= MIN_REPEAT) {
2113
+ if (count >= MIN_REPEAT && (_nullishCoalesce(_optionalChain([patternPages, 'access', _19 => _19.get, 'call', _20 => _20(p), 'optionalAccess', _21 => _21.size]), () => ( 0))) >= MIN_REPEAT) {
2092
2114
  repeatedPatterns.add(p);
2093
2115
  }
2094
2116
  }
@@ -2102,7 +2124,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings) {
2102
2124
  if (bi === e.blockIdx) continue;
2103
2125
  const o = blocks[bi];
2104
2126
  if (!o.bbox || o.bbox.page !== cb.page) continue;
2105
- const oNorm = _optionalChain([o, 'access', _19 => _19.text, 'optionalAccess', _20 => _20.trim, 'call', _21 => _21(), 'access', _22 => _22.replace, 'call', _23 => _23(/\d+/g, "#")]);
2127
+ const oNorm = _optionalChain([o, 'access', _22 => _22.text, 'optionalAccess', _23 => _23.trim, 'call', _24 => _24(), 'access', _25 => _25.replace, 'call', _26 => _26(/\d+/g, "#")]);
2106
2128
  if (oNorm && repeatedPatterns.has(oNorm)) continue;
2107
2129
  const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
2108
2130
  if (overlap2 >= cb.height * 0.5) {
@@ -2173,12 +2195,12 @@ function isTwoColumnProse(r) {
2173
2195
  if (t.rows < 8) return false;
2174
2196
  const dense = [];
2175
2197
  for (let c = 0; c < t.cols; c++) {
2176
- const filled = t.cells.filter((row) => _optionalChain([row, 'access', _24 => _24[c], 'optionalAccess', _25 => _25.text, 'access', _26 => _26.trim, 'call', _27 => _27()])).length;
2198
+ const filled = t.cells.filter((row) => _optionalChain([row, 'access', _27 => _27[c], 'optionalAccess', _28 => _28.text, 'access', _29 => _29.trim, 'call', _30 => _30()])).length;
2177
2199
  if (filled / t.rows >= 0.3) dense.push(c);
2178
2200
  }
2179
2201
  if (dense.length !== 2) return false;
2180
2202
  for (const c of dense) {
2181
- const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _28 => _28[c], 'optionalAccess', _29 => _29.text, 'access', _30 => _30.replace, 'call', _31 => _31(/\s+/g, ""), 'access', _32 => _32.length]), () => ( 0))).filter((n) => n > 0);
2203
+ const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _31 => _31[c], 'optionalAccess', _32 => _32.text, 'access', _33 => _33.replace, 'call', _34 => _34(/\s+/g, ""), 'access', _35 => _35.length]), () => ( 0))).filter((n) => n > 0);
2182
2204
  const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
2183
2205
  if (avg < 12) return false;
2184
2206
  }
@@ -2655,7 +2677,7 @@ function buildClusterTable(rows, columns, pageNum) {
2655
2677
  const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
2656
2678
  if (nonEmptyCols !== 1) continue;
2657
2679
  if (cells[r][0].text.trim() !== "") continue;
2658
- const contentText = _optionalChain([cells, 'access', _33 => _33[r], 'access', _34 => _34.find, 'call', _35 => _35((c) => c.text.trim()), 'optionalAccess', _36 => _36.text, 'access', _37 => _37.trim, 'call', _38 => _38()]) || "";
2680
+ const contentText = _optionalChain([cells, 'access', _36 => _36[r], 'access', _37 => _37.find, 'call', _38 => _38((c) => c.text.trim()), 'optionalAccess', _39 => _39.text, 'access', _40 => _40.trim, 'call', _41 => _41()]) || "";
2659
2681
  if (/^[○●▶\-·]/.test(contentText)) continue;
2660
2682
  for (let pr = r - 1; pr >= 0; pr--) {
2661
2683
  if (cells[pr].some((c) => c.text.trim())) {
@@ -3020,14 +3042,14 @@ function isProseSpread(items) {
3020
3042
  for (let i = 1; i < sorted.length; i++) {
3021
3043
  gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
3022
3044
  }
3023
- const maxGap = _chunk6MF7JRG3cjs.safeMax.call(void 0, gaps);
3045
+ const maxGap = _chunk62IU4NV3cjs.safeMax.call(void 0, gaps);
3024
3046
  const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
3025
3047
  return maxGap < 40 && avgLen < 5;
3026
3048
  }
3027
3049
  function detectColumns(yLines) {
3028
3050
  const allItems = yLines.flat();
3029
3051
  if (allItems.length === 0) return null;
3030
- const pageWidth = _chunk6MF7JRG3cjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunk6MF7JRG3cjs.safeMin.call(void 0, allItems.map((i) => i.x));
3052
+ const pageWidth = _chunk62IU4NV3cjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunk62IU4NV3cjs.safeMin.call(void 0, allItems.map((i) => i.x));
3031
3053
  if (pageWidth < 100) return null;
3032
3054
  let bigoLineIdx = -1;
3033
3055
  for (let i = 0; i < yLines.length; i++) {
@@ -3463,9 +3485,47 @@ function isProseBoxGrid(grid, verticals, table) {
3463
3485
  if (longCells < PROSEBOX_LONG_CELL_MIN || longCells < texts.length * PROSEBOX_LONG_CELL_RATIO) return false;
3464
3486
  return true;
3465
3487
  }
3488
+ function cleanCellText(text) {
3489
+ const stripped = text.replace(/^[\s]*[-–—]\s*\d+\s*[-–—][\s]*$/gm, "").trim();
3490
+ return stripped.split("\n").map((line) => collapseEvenSpacing(line)).join("\n");
3491
+ }
3492
+ var FRAME_RECT_TOL = 1.5;
3493
+ function takePendingNested(pending, cellBox) {
3494
+ const out = [];
3495
+ for (let i = pending.length - 1; i >= 0; i--) {
3496
+ const p = pending[i].parent;
3497
+ if (Math.abs(p.x1 - cellBox.x1) <= FRAME_RECT_TOL && Math.abs(p.x2 - cellBox.x2) <= FRAME_RECT_TOL && Math.abs(p.y1 - cellBox.y1) <= FRAME_RECT_TOL && Math.abs(p.y2 - cellBox.y2) <= FRAME_RECT_TOL) {
3498
+ out.push(pending[i].block);
3499
+ pending.splice(i, 1);
3500
+ }
3501
+ }
3502
+ return out;
3503
+ }
3504
+ function buildFrameCellBlocks(cellItems, nested, pageNum) {
3505
+ const tables = [...nested].sort((a, b) => b.bbox.y + b.bbox.height - (a.bbox.y + a.bbox.height));
3506
+ const blocks = [];
3507
+ let rest = [...cellItems];
3508
+ const pushParagraphs = (items) => {
3509
+ if (items.length === 0) return;
3510
+ for (const line of cleanCellText(cellTextToString(items)).split("\n")) {
3511
+ const t = line.trim();
3512
+ if (t) blocks.push({ type: "paragraph", text: t, pageNumber: pageNum });
3513
+ }
3514
+ };
3515
+ for (const tb of tables) {
3516
+ const bottom = tb.bbox.y;
3517
+ pushParagraphs(rest.filter((it) => it.y >= bottom));
3518
+ rest = rest.filter((it) => it.y < bottom);
3519
+ blocks.push(tb);
3520
+ }
3521
+ pushParagraphs(rest);
3522
+ const text = blocks.map((b) => b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text).filter(Boolean).join("\n") : _nullishCoalesce(b.text, () => ( ""))).filter(Boolean).join("\n");
3523
+ return { blocks, text };
3524
+ }
3466
3525
  function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
3467
3526
  const blocks = [];
3468
3527
  const usedItems = /* @__PURE__ */ new Set();
3528
+ const pendingNested = [];
3469
3529
  const gridArea = (g) => (g.bbox.x2 - g.bbox.x1) * (g.bbox.y2 - g.bbox.y1);
3470
3530
  const sortedGrids = [...grids].sort((a, b) => (b.cells ? 1 : 0) - (a.cells ? 1 : 0) || (a.cells && b.cells ? gridArea(a) - gridArea(b) : 0) || b.bbox.y2 - a.bbox.y2);
3471
3531
  for (const grid of sortedGrids) {
@@ -3505,13 +3565,18 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
3505
3565
  { length: numRows },
3506
3566
  () => Array.from({ length: numCols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }))
3507
3567
  );
3568
+ let nestedAttached = false;
3508
3569
  for (const cell of cells) {
3509
3570
  const cellItems = cellTextMap.get(cell) || [];
3510
- let text = cellTextToString(cellItems);
3511
- text = text.replace(/^[\s]*[-–—]\s*\d+\s*[-–—][\s]*$/gm, "").trim();
3512
- text = text.split("\n").map((line) => collapseEvenSpacing(line)).join("\n");
3571
+ const nested = grid.cells ? takePendingNested(pendingNested, cell.bbox) : [];
3572
+ if (nested.length > 0) {
3573
+ nestedAttached = true;
3574
+ const built = buildFrameCellBlocks(cellItems, nested, pageNum);
3575
+ irGrid[cell.row][cell.col] = { text: built.text, colSpan: cell.colSpan, rowSpan: cell.rowSpan, blocks: built.blocks };
3576
+ continue;
3577
+ }
3513
3578
  irGrid[cell.row][cell.col] = {
3514
- text,
3579
+ text: cleanCellText(cellTextToString(cellItems)),
3515
3580
  colSpan: cell.colSpan,
3516
3581
  rowSpan: cell.rowSpan
3517
3582
  };
@@ -3519,18 +3584,11 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
3519
3584
  let finalGrid = irGrid;
3520
3585
  let finalRows = numRows;
3521
3586
  let rebuiltUsed = false;
3522
- if (numRows <= 2 && numCols >= 3) {
3587
+ if (numRows <= 2 && numCols >= 3 && !nestedAttached) {
3523
3588
  const rebuilt = normalizeUndersegmentedTable(irGrid, grid.colXs, textItems);
3524
3589
  if (rebuilt) {
3525
3590
  rebuiltUsed = true;
3526
- finalGrid = rebuilt.map((row) => row.map((rawText) => {
3527
- const cleaned = rawText.replace(/^[\s]*[-–—]\s*\d+\s*[-–—][\s]*$/gm, "").trim();
3528
- return {
3529
- text: cleaned.split("\n").map((line) => collapseEvenSpacing(line)).join("\n"),
3530
- colSpan: 1,
3531
- rowSpan: 1
3532
- };
3533
- }));
3591
+ finalGrid = rebuilt.map((row) => row.map((rawText) => ({ text: cleanCellText(rawText), colSpan: 1, rowSpan: 1 })));
3534
3592
  finalRows = finalGrid.length;
3535
3593
  }
3536
3594
  }
@@ -3547,6 +3605,11 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
3547
3605
  };
3548
3606
  const hasContent = finalGrid.some((row) => row.some((cell) => cell.text.trim() !== ""));
3549
3607
  if (!hasContent) continue;
3608
+ if (grid.clipParent) {
3609
+ const nb = { page: pageNum, x: grid.bbox.x1, y: grid.bbox.y1, width: grid.bbox.x2 - grid.bbox.x1, height: grid.bbox.y2 - grid.bbox.y1 };
3610
+ pendingNested.push({ parent: grid.clipParent, block: { type: "table", table: irTable, pageNumber: pageNum, bbox: nb } });
3611
+ continue;
3612
+ }
3550
3613
  if (!grid.cells && isProseBoxGrid(grid, verticals, irTable)) {
3551
3614
  for (const it of tableItems) usedItems.delete(it);
3552
3615
  continue;
@@ -3568,6 +3631,7 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
3568
3631
  }
3569
3632
  blocks.push({ type: "table", table: irTable, pageNumber: pageNum, bbox: tableBbox });
3570
3633
  }
3634
+ for (const p of pendingNested) blocks.push(p.block);
3571
3635
  let remaining = items.filter((i) => !usedItems.has(i));
3572
3636
  const groupSizes = [];
3573
3637
  let finalTextBlocks = [];
@@ -3610,7 +3674,7 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
3610
3674
  if (gutterX !== null) {
3611
3675
  const gx = gutterX;
3612
3676
  const allY = remaining.map((i) => i.y);
3613
- const pageH = _chunk6MF7JRG3cjs.safeMax.call(void 0, allY) - _chunk6MF7JRG3cjs.safeMin.call(void 0, allY);
3677
+ const pageH = _chunk62IU4NV3cjs.safeMax.call(void 0, allY) - _chunk62IU4NV3cjs.safeMin.call(void 0, allY);
3614
3678
  const gapThreshold = Math.max(15, pageH * 0.03);
3615
3679
  const sides = [
3616
3680
  remaining.filter((i) => i.x + i.w <= gx),
@@ -3630,7 +3694,7 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
3630
3694
  finalTextBlocks = detectListBlocks(textBlocks);
3631
3695
  } else {
3632
3696
  const allY = remaining.map((i) => i.y);
3633
- const pageH = _chunk6MF7JRG3cjs.safeMax.call(void 0, allY) - _chunk6MF7JRG3cjs.safeMin.call(void 0, allY);
3697
+ const pageH = _chunk62IU4NV3cjs.safeMax.call(void 0, allY) - _chunk62IU4NV3cjs.safeMin.call(void 0, allY);
3634
3698
  const groups = xyCutOrder(remaining, Math.max(15, pageH * 0.03));
3635
3699
  const textBlocks = [];
3636
3700
  for (const group of groups) {
@@ -3838,7 +3902,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
3838
3902
  blocks.push({ type: "paragraph", text: tableText, pageNumber: pageNum, bbox, style: dominantStyle(items) });
3839
3903
  } else {
3840
3904
  const allY = items.map((i) => i.y);
3841
- const pageHeight = _chunk6MF7JRG3cjs.safeMax.call(void 0, allY) - _chunk6MF7JRG3cjs.safeMin.call(void 0, allY);
3905
+ const pageHeight = _chunk62IU4NV3cjs.safeMax.call(void 0, allY) - _chunk62IU4NV3cjs.safeMin.call(void 0, allY);
3842
3906
  const gapThreshold = Math.max(15, pageHeight * 0.03);
3843
3907
  const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold);
3844
3908
  for (const group of orderedGroups) {
@@ -3877,4 +3941,4 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
3877
3941
 
3878
3942
 
3879
3943
  exports.extractImageRegions = extractImageRegions; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.normalizeItems = normalizeItems; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.mergeCrossPageTables = mergeCrossPageTables;
3880
- //# sourceMappingURL=chunk-MXZXZTKW.cjs.map
3944
+ //# sourceMappingURL=chunk-ONNAHSPV.cjs.map