kordoc 4.24.21 → 4.24.23

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 (127) hide show
  1. package/README.md +7 -7
  2. package/dist/{-IS4RXPEZ.js → -POV3PVKW.js} +11 -11
  3. package/dist/{chunk-3RVASM4C.js → chunk-2NINEUJ5.js} +4 -4
  4. package/dist/{chunk-MMZUWRH6.js → chunk-2Q4ZLQQJ.js} +11 -11
  5. package/dist/{chunk-BV2YG7M6.js → chunk-2S4WERRK.js} +2 -2
  6. package/dist/{chunk-PDOWSDNM.js → chunk-2UNY7AKC.js} +2 -2
  7. package/dist/{chunk-F4GZFIUJ.js → chunk-3QWZCQI6.js} +2 -2
  8. package/dist/{chunk-E6G4B457.js → chunk-5L32QFLQ.js} +2 -2
  9. package/dist/{chunk-MYDHNNPA.js → chunk-6OG6WPA3.js} +43 -8
  10. package/dist/chunk-6OG6WPA3.js.map +1 -0
  11. package/dist/{chunk-NRCG3ASU.js → chunk-7JFJPFME.js} +2 -2
  12. package/dist/{chunk-WVZSTMCZ.cjs → chunk-7OZLM5MR.cjs} +3 -3
  13. package/dist/{chunk-WVZSTMCZ.cjs.map → chunk-7OZLM5MR.cjs.map} +1 -1
  14. package/dist/{chunk-V7S36XCU.cjs → chunk-AABI2ELF.cjs} +3 -3
  15. package/dist/{chunk-V7S36XCU.cjs.map → chunk-AABI2ELF.cjs.map} +1 -1
  16. package/dist/{chunk-O5ZCJEZ4.js → chunk-AXBEO5NB.js} +2 -2
  17. package/dist/{chunk-L556KKBU.cjs → chunk-HJ5YI5E6.cjs} +79 -79
  18. package/dist/{chunk-L556KKBU.cjs.map → chunk-HJ5YI5E6.cjs.map} +1 -1
  19. package/dist/{chunk-B3POEH7X.js → chunk-JDDKQD7W.js} +2 -2
  20. package/dist/{chunk-IZN5BTCW.js → chunk-NBETHWJH.js} +2 -2
  21. package/dist/{chunk-4OF7DHIT.js → chunk-NRPLZ4NO.js} +4 -4
  22. package/dist/{chunk-F6OHQLN7.js → chunk-NWNL5YYK.js} +38 -7
  23. package/dist/chunk-NWNL5YYK.js.map +1 -0
  24. package/dist/{chunk-NE75RO62.js → chunk-PG7OI72B.js} +2 -2
  25. package/dist/{chunk-BNEKESI4.js → chunk-QMAWEM4N.js} +2 -2
  26. package/dist/{chunk-MGCIQ43Y.js → chunk-SLS65M44.js} +3 -3
  27. package/dist/{chunk-BTBFKDPH.js → chunk-SYJZYHBB.js} +2 -2
  28. package/dist/{chunk-B5M676H3.cjs → chunk-T7Z554HT.cjs} +6 -6
  29. package/dist/{chunk-B5M676H3.cjs.map → chunk-T7Z554HT.cjs.map} +1 -1
  30. package/dist/{chunk-BUFGW3UJ.cjs → chunk-TBGNGQ2O.cjs} +213 -182
  31. package/dist/chunk-TBGNGQ2O.cjs.map +1 -0
  32. package/dist/{chunk-CPVXUEKF.js → chunk-VK3ZZLT7.js} +2 -2
  33. package/dist/{chunk-N45RCYBL.js → chunk-VK6S3WGD.js} +3 -3
  34. package/dist/{chunk-Z6ONQ63K.js → chunk-VOLDBZDF.js} +2 -2
  35. package/dist/{chunk-WQC4XWVT.js → chunk-WTFXQGND.js} +2 -2
  36. package/dist/{chunk-BMXWY36E.js → chunk-XEYTPWCF.js} +39 -8
  37. package/dist/chunk-XEYTPWCF.js.map +1 -0
  38. package/dist/{chunk-UNYH6MTO.js → chunk-XLVQUVL4.js} +2 -2
  39. package/dist/{chunk-OMGCVZ4W.cjs → chunk-YOLFNCQQ.cjs} +2 -2
  40. package/dist/{chunk-OMGCVZ4W.cjs.map → chunk-YOLFNCQQ.cjs.map} +1 -1
  41. package/dist/chunks-SGEDTBKI.js +10 -0
  42. package/dist/cli.js +30 -30
  43. package/dist/{formula-DHBBWQLC.js → formula-7YKP7MFB.js} +3 -3
  44. package/dist/{formula-G3FQTUOY.cjs → formula-IIPZAHPY.cjs} +9 -9
  45. package/dist/{formula-G3FQTUOY.cjs.map → formula-IIPZAHPY.cjs.map} +1 -1
  46. package/dist/{formula-I4EA7ULD.js → formula-TI6JRF6D.js} +4 -4
  47. package/dist/{image-ocr-THUO6YRG.cjs → image-ocr-4FIFSQ5E.cjs} +17 -17
  48. package/dist/{image-ocr-THUO6YRG.cjs.map → image-ocr-4FIFSQ5E.cjs.map} +1 -1
  49. package/dist/{image-ocr-QUVBGNWD.js → image-ocr-JQ65V7NG.js} +9 -9
  50. package/dist/{image-ocr-5YWVBRY6.js → image-ocr-Q7ZPUDKM.js} +6 -6
  51. package/dist/index.cjs +463 -428
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.js +43 -8
  54. package/dist/index.js.map +1 -1
  55. package/dist/mcp.js +23 -23
  56. package/dist/{model-bundle-6RG5PO3R.js → model-bundle-RHZIWRK3.js} +5 -5
  57. package/dist/{models-CGYIGN6D.js → models-IX2U5E2X.js} +5 -5
  58. package/dist/{parse-worker-v2-F5NXYBU6.js → parse-worker-v2-WH2ZU73A.js} +12 -12
  59. package/dist/{parser-GJ4PKW7I.cjs → parser-HZI6SSX5.cjs} +172 -161
  60. package/dist/parser-HZI6SSX5.cjs.map +1 -0
  61. package/dist/{parser-G5QTRKII.js → parser-OSH4JPYU.js} +22 -11
  62. package/dist/parser-OSH4JPYU.js.map +1 -0
  63. package/dist/{parser-I2C5DUXC.js → parser-U2WRX53G.js} +25 -14
  64. package/dist/parser-U2WRX53G.js.map +1 -0
  65. package/dist/{pdf-ocr-U3I74Q4O.js → pdf-ocr-HUQ2RFMY.js} +9 -9
  66. package/dist/{pdf-ocr-TNW6YOPX.js → pdf-ocr-NPFRBGWJ.js} +6 -6
  67. package/dist/pdf-ocr-OA57HOVS.cjs +35 -0
  68. package/dist/{pdf-ocr-LJKCUXTE.cjs.map → pdf-ocr-OA57HOVS.cjs.map} +1 -1
  69. package/dist/{profile-io-5YZCFK7B.js → profile-io-MVJHVB5K.js} +3 -3
  70. package/dist/{rasterize-7VRHPOQX.js → rasterize-MBQRUDTT.js} +3 -3
  71. package/dist/{redact-doc-VK6VGBK3.js → redact-doc-Y6DPTTVM.js} +11 -11
  72. package/dist/{render-Y7J6DPRL.js → render-CSVVMX6Y.js} +7 -7
  73. package/dist/seal-Y7I5CXGZ.js +10 -0
  74. package/dist/{setup-4XTUDU4X.js → setup-BU2VPWG4.js} +3 -3
  75. package/dist/visual-OAJU373I.js +21 -0
  76. package/dist/{watch-SPZRLTKG.js → watch-RLLW3NTH.js} +12 -12
  77. package/package.json +1 -1
  78. package/dist/chunk-BMXWY36E.js.map +0 -1
  79. package/dist/chunk-BUFGW3UJ.cjs.map +0 -1
  80. package/dist/chunk-F6OHQLN7.js.map +0 -1
  81. package/dist/chunk-MYDHNNPA.js.map +0 -1
  82. package/dist/chunks-FYCQOIWO.js +0 -10
  83. package/dist/parser-G5QTRKII.js.map +0 -1
  84. package/dist/parser-GJ4PKW7I.cjs.map +0 -1
  85. package/dist/parser-I2C5DUXC.js.map +0 -1
  86. package/dist/pdf-ocr-LJKCUXTE.cjs +0 -35
  87. package/dist/seal-4QIZ3ZNI.js +0 -10
  88. package/dist/visual-VEMQJ52W.js +0 -21
  89. /package/dist/{-IS4RXPEZ.js.map → -POV3PVKW.js.map} +0 -0
  90. /package/dist/{chunk-3RVASM4C.js.map → chunk-2NINEUJ5.js.map} +0 -0
  91. /package/dist/{chunk-MMZUWRH6.js.map → chunk-2Q4ZLQQJ.js.map} +0 -0
  92. /package/dist/{chunk-BV2YG7M6.js.map → chunk-2S4WERRK.js.map} +0 -0
  93. /package/dist/{chunk-PDOWSDNM.js.map → chunk-2UNY7AKC.js.map} +0 -0
  94. /package/dist/{chunk-F4GZFIUJ.js.map → chunk-3QWZCQI6.js.map} +0 -0
  95. /package/dist/{chunk-E6G4B457.js.map → chunk-5L32QFLQ.js.map} +0 -0
  96. /package/dist/{chunk-NRCG3ASU.js.map → chunk-7JFJPFME.js.map} +0 -0
  97. /package/dist/{chunk-O5ZCJEZ4.js.map → chunk-AXBEO5NB.js.map} +0 -0
  98. /package/dist/{chunk-B3POEH7X.js.map → chunk-JDDKQD7W.js.map} +0 -0
  99. /package/dist/{chunk-IZN5BTCW.js.map → chunk-NBETHWJH.js.map} +0 -0
  100. /package/dist/{chunk-4OF7DHIT.js.map → chunk-NRPLZ4NO.js.map} +0 -0
  101. /package/dist/{chunk-NE75RO62.js.map → chunk-PG7OI72B.js.map} +0 -0
  102. /package/dist/{chunk-BNEKESI4.js.map → chunk-QMAWEM4N.js.map} +0 -0
  103. /package/dist/{chunk-MGCIQ43Y.js.map → chunk-SLS65M44.js.map} +0 -0
  104. /package/dist/{chunk-BTBFKDPH.js.map → chunk-SYJZYHBB.js.map} +0 -0
  105. /package/dist/{chunk-CPVXUEKF.js.map → chunk-VK3ZZLT7.js.map} +0 -0
  106. /package/dist/{chunk-N45RCYBL.js.map → chunk-VK6S3WGD.js.map} +0 -0
  107. /package/dist/{chunk-Z6ONQ63K.js.map → chunk-VOLDBZDF.js.map} +0 -0
  108. /package/dist/{chunk-WQC4XWVT.js.map → chunk-WTFXQGND.js.map} +0 -0
  109. /package/dist/{chunk-UNYH6MTO.js.map → chunk-XLVQUVL4.js.map} +0 -0
  110. /package/dist/{chunks-FYCQOIWO.js.map → chunks-SGEDTBKI.js.map} +0 -0
  111. /package/dist/{formula-DHBBWQLC.js.map → formula-7YKP7MFB.js.map} +0 -0
  112. /package/dist/{formula-I4EA7ULD.js.map → formula-TI6JRF6D.js.map} +0 -0
  113. /package/dist/{image-ocr-QUVBGNWD.js.map → image-ocr-JQ65V7NG.js.map} +0 -0
  114. /package/dist/{image-ocr-5YWVBRY6.js.map → image-ocr-Q7ZPUDKM.js.map} +0 -0
  115. /package/dist/{model-bundle-6RG5PO3R.js.map → model-bundle-RHZIWRK3.js.map} +0 -0
  116. /package/dist/{models-CGYIGN6D.js.map → models-IX2U5E2X.js.map} +0 -0
  117. /package/dist/{parse-worker-v2-F5NXYBU6.js.map → parse-worker-v2-WH2ZU73A.js.map} +0 -0
  118. /package/dist/{pdf-ocr-TNW6YOPX.js.map → pdf-ocr-HUQ2RFMY.js.map} +0 -0
  119. /package/dist/{pdf-ocr-U3I74Q4O.js.map → pdf-ocr-NPFRBGWJ.js.map} +0 -0
  120. /package/dist/{profile-io-5YZCFK7B.js.map → profile-io-MVJHVB5K.js.map} +0 -0
  121. /package/dist/{rasterize-7VRHPOQX.js.map → rasterize-MBQRUDTT.js.map} +0 -0
  122. /package/dist/{redact-doc-VK6VGBK3.js.map → redact-doc-Y6DPTTVM.js.map} +0 -0
  123. /package/dist/{render-Y7J6DPRL.js.map → render-CSVVMX6Y.js.map} +0 -0
  124. /package/dist/{seal-4QIZ3ZNI.js.map → seal-Y7I5CXGZ.js.map} +0 -0
  125. /package/dist/{setup-4XTUDU4X.js.map → setup-BU2VPWG4.js.map} +0 -0
  126. /package/dist/{visual-VEMQJ52W.js.map → visual-OAJU373I.js.map} +0 -0
  127. /package/dist/{watch-SPZRLTKG.js.map → watch-RLLW3NTH.js.map} +0 -0
@@ -5,15 +5,15 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkB5M676H3cjs = require('./chunk-B5M676H3.cjs');
8
+ var _chunkT7Z554HTcjs = require('./chunk-T7Z554HT.cjs');
9
9
 
10
10
 
11
11
 
12
- var _chunkV7S36XCUcjs = require('./chunk-V7S36XCU.cjs');
12
+ var _chunkAABI2ELFcjs = require('./chunk-AABI2ELF.cjs');
13
13
 
14
14
 
15
15
 
16
- var _chunkOMGCVZ4Wcjs = require('./chunk-OMGCVZ4W.cjs');
16
+ var _chunkYOLFNCQQcjs = require('./chunk-YOLFNCQQ.cjs');
17
17
 
18
18
  // src/ocr/models.ts
19
19
  var _path = require('path');
@@ -65,7 +65,7 @@ var OCR_REC_DICT = {
65
65
  sizeMb: 1
66
66
  };
67
67
  function getOcrModelsDir() {
68
- return _chunkV7S36XCUcjs.getModelsDir.call(void 0, "ppocr");
68
+ return _chunkAABI2ELFcjs.getModelsDir.call(void 0, "ppocr");
69
69
  }
70
70
  var DEFAULT_OCR_MODELS = Object.freeze({
71
71
  det: { spec: OCR_DET_MODEL },
@@ -107,7 +107,7 @@ async function ensureOcrModelsFor(sel, onProgress) {
107
107
  if (!stamp || verifiedInProcess.get(path) !== stamp) todo.push(s.spec);
108
108
  }
109
109
  if (!todo.length) return;
110
- await _chunkV7S36XCUcjs.ensureModelsIn.call(void 0, dir, todo, onProgress);
110
+ await _chunkAABI2ELFcjs.ensureModelsIn.call(void 0, dir, todo, onProgress);
111
111
  for (const spec of todo) {
112
112
  const path = _path.join.call(void 0, dir, spec.filename), stamp = await fileStamp(path);
113
113
  if (stamp) verifiedInProcess.set(path, stamp);
@@ -1216,7 +1216,10 @@ function extractLines(fnArray, argsArray) {
1216
1216
  classifyAndAdd(seg, effWidth, horizontals, verticals, fromFill, fromFill ? void 0 : { h: shortH, v: shortV });
1217
1217
  });
1218
1218
  if (from) outs.forEach((o, k) => {
1219
- for (let n = from[k]; n < o.length; n++) if (white || k < 2 && !thinFill.has(o[n])) nonRules.add(o[n]);
1219
+ for (let n = from[k]; n < o.length; n++) if (white || k < 2 && !thinFill.has(o[n])) {
1220
+ nonRules.add(o[n]);
1221
+ if (white) WHITE_EDGES.add(o[n]);
1222
+ }
1220
1223
  });
1221
1224
  currentPath = [];
1222
1225
  }
@@ -1543,8 +1546,15 @@ function preprocessLines(horizontals, verticals, nonRules) {
1543
1546
  let v = verticals.filter((l) => l.lineWidth <= MAX_LINE_WIDTH);
1544
1547
  h = dropShadingStacks(h, "h");
1545
1548
  v = dropShadingStacks(v, "v");
1546
- h = mergeParallelLines(h, "h", nonRules);
1549
+ h = mergeParallelLines(h, "h", nonRules, v);
1547
1550
  v = mergeParallelLines(v, "v", nonRules);
1551
+ if (nonRules) {
1552
+ const visH = h.filter((l) => !nonRules.has(l)), visV = v.filter((l) => !nonRules.has(l));
1553
+ const crossH = (w) => visV.filter((c) => c.x1 > w.x1 + 1 && c.x1 < w.x2 - 1 && Math.min(c.y1, c.y2) < w.y1 - 2 && Math.max(c.y1, c.y2) > w.y1 + 2).length;
1554
+ const crossV = (w) => visH.filter((c) => c.y1 > Math.min(w.y1, w.y2) + 1 && c.y1 < Math.max(w.y1, w.y2) - 1 && Math.min(c.x1, c.x2) < w.x1 - 2 && Math.max(c.x1, c.x2) > w.x1 + 2).length;
1555
+ h = h.filter((l) => !(WHITE_EDGES.has(l) && nonRules.has(l) && crossH(l) >= 2));
1556
+ v = v.filter((l) => !(WHITE_EDGES.has(l) && nonRules.has(l) && crossV(l) >= 2));
1557
+ }
1548
1558
  return { horizontals: h, verticals: v };
1549
1559
  }
1550
1560
  var STACK_GAP = 2;
@@ -1712,7 +1722,8 @@ function closeOpenTableEdges(horizontals, verticals) {
1712
1722
  }
1713
1723
  return synthesized.length ? [...verticals, ...synthesized] : verticals;
1714
1724
  }
1715
- function mergeParallelLines(lines, dir, nonRules) {
1725
+ var WHITE_EDGES = /* @__PURE__ */ new WeakSet();
1726
+ function mergeParallelLines(lines, dir, nonRules, perp) {
1716
1727
  if (lines.length <= 1) return lines;
1717
1728
  const sorted = [...lines].sort((a, b) => {
1718
1729
  const posA = dir === "h" ? a.y1 : a.x1;
@@ -1735,7 +1746,26 @@ function mergeParallelLines(lines, dir, nonRules) {
1735
1746
  const overlap2 = Math.min(prevEnd, currEnd) - Math.max(prevStart, currStart);
1736
1747
  const minLen = Math.min(prevEnd - prevStart, currEnd - currStart);
1737
1748
  if (overlap2 > minLen * 0.3) {
1738
- if (_optionalChain([nonRules, 'optionalAccess', _13 => _13.has, 'call', _14 => _14(prev)]) && !nonRules.has(curr)) nonRules.delete(prev);
1749
+ const bgPrev = !!_optionalChain([nonRules, 'optionalAccess', _13 => _13.has, 'call', _14 => _14(prev)]) && !nonRules.has(curr), bgCurr = !!_optionalChain([nonRules, 'optionalAccess', _15 => _15.has, 'call', _16 => _16(curr)]) && !nonRules.has(prev);
1750
+ const whPrev = bgPrev && WHITE_EDGES.has(prev), whCurr = bgCurr && WHITE_EDGES.has(curr);
1751
+ if (bgPrev) nonRules.delete(prev);
1752
+ const clip = (w, o) => {
1753
+ if (dir !== "h" || !perp) return false;
1754
+ let n = 0;
1755
+ for (const c of perp) {
1756
+ if (nonRules.has(c) || Math.min(c.y1, c.y2) >= w.y1 - 2 || Math.max(c.y1, c.y2) <= w.y1 + 2) continue;
1757
+ if (c.x1 > w.x1 + 1 && c.x1 < o.x1 - 1 || c.x1 > o.x2 + 1 && c.x1 < w.x2 - 1) n++;
1758
+ }
1759
+ return n >= 2;
1760
+ };
1761
+ if (whPrev && clip(prev, curr)) {
1762
+ prev.x1 = curr.x1;
1763
+ prev.x2 = curr.x2;
1764
+ prev.y1 = prev.y2 = curr.y1;
1765
+ prev.lineWidth = curr.lineWidth;
1766
+ continue;
1767
+ }
1768
+ if (whCurr && clip(curr, prev)) continue;
1739
1769
  if (dir === "h") {
1740
1770
  prev.x1 = Math.min(prev.x1, curr.x1);
1741
1771
  prev.x2 = Math.max(prev.x2, curr.x2);
@@ -1803,8 +1833,8 @@ function extractImageRegions(fnArray, argsArray, respectClip = false) {
1803
1833
  break;
1804
1834
  case _pdfmjs.OPS.restore: {
1805
1835
  const state = stack.pop();
1806
- ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _15 => _15.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
1807
- clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _16 => _16.clip]), () => ( null));
1836
+ ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _17 => _17.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
1837
+ clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _18 => _18.clip]), () => ( null));
1808
1838
  break;
1809
1839
  }
1810
1840
  case _pdfmjs.OPS.transform: {
@@ -1815,19 +1845,19 @@ function extractImageRegions(fnArray, argsArray, respectClip = false) {
1815
1845
  // Form XObject 는 /Matrix 공간에서 그린다 — pdfjs 인자 [matrix, bbox], End 에서 복원 (line-extract.ts 와 같음)
1816
1846
  case _pdfmjs.OPS.paintFormXObjectBegin: {
1817
1847
  stack.push({ ctm, clip });
1818
- const m = _optionalChain([argsArray, 'access', _17 => _17[i], 'optionalAccess', _18 => _18[0]]);
1848
+ const m = _optionalChain([argsArray, 'access', _19 => _19[i], 'optionalAccess', _20 => _20[0]]);
1819
1849
  if (Array.isArray(m) && m.length >= 6) ctm = multiplyTransform(ctm, m);
1820
1850
  break;
1821
1851
  }
1822
1852
  case _pdfmjs.OPS.paintFormXObjectEnd: {
1823
1853
  const state = stack.pop();
1824
- ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _19 => _19.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
1825
- clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _20 => _20.clip]), () => ( null));
1854
+ ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _21 => _21.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
1855
+ clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _22 => _22.clip]), () => ( null));
1826
1856
  break;
1827
1857
  }
1828
1858
  case _pdfmjs.OPS.constructPath: {
1829
1859
  const [ops, coords] = argsArray[i];
1830
- pathRect = pathRect === void 0 && _optionalChain([ops, 'optionalAccess', _21 => _21.length]) === 1 && ops[0] === _pdfmjs.OPS.rectangle && _optionalChain([coords, 'optionalAccess', _22 => _22.length]) >= 4 ? transformedRect(ctm, coords[0], coords[1], coords[2], coords[3]) : null;
1860
+ pathRect = pathRect === void 0 && _optionalChain([ops, 'optionalAccess', _23 => _23.length]) === 1 && ops[0] === _pdfmjs.OPS.rectangle && _optionalChain([coords, 'optionalAccess', _24 => _24.length]) >= 4 ? transformedRect(ctm, coords[0], coords[1], coords[2], coords[3]) : null;
1831
1861
  break;
1832
1862
  }
1833
1863
  case _pdfmjs.OPS.clip:
@@ -1980,7 +2010,7 @@ function hasShadedRowBands(host, clips, fills, verticals, horizontals) {
1980
2010
  if (!host.colXs.slice(1, -1).every((x) => verticals.some((v) => !v.fromFill && near2(v.x1, x) && v.y1 <= host.bbox.y1 + tol && v.y2 >= host.bbox.y2 - tol))) return false;
1981
2011
  const covered = /* @__PURE__ */ new Set();
1982
2012
  for (const band of bands) {
1983
- if (band.clipParent || !_optionalChain([band, 'access', _23 => _23.cells, 'optionalAccess', _24 => _24.length]) || band.colXs.length !== host.colXs.length || !band.colXs.every((x, i) => near2(x, host.colXs[i]))) return false;
2013
+ if (band.clipParent || !_optionalChain([band, 'access', _25 => _25.cells, 'optionalAccess', _26 => _26.length]) || band.colXs.length !== host.colXs.length || !band.colXs.every((x, i) => near2(x, host.colXs[i]))) return false;
1984
2014
  const start = host.rowYs.findIndex((y) => near2(y, band.rowYs[0]));
1985
2015
  if (start < 0 || !band.rowYs.every((y, i) => near2(y, host.rowYs[start + i]))) return false;
1986
2016
  if (!band.rowYs.every((y) => horizontals.some((h) => !h.fromFill && near2(h.y1, y) && h.x1 <= host.bbox.x1 + tol && h.x2 >= host.bbox.x2 - tol))) return false;
@@ -2082,7 +2112,7 @@ function mergeVertices(vertices) {
2082
2112
  const candidates = [];
2083
2113
  for (let dx = -1; dx <= 1; dx++) {
2084
2114
  for (let dy = -1; dy <= 1; dy++) {
2085
- const arr = _optionalChain([buckets, 'access', _25 => _25.get, 'call', _26 => _26(cx + dx), 'optionalAccess', _27 => _27.get, 'call', _28 => _28(cy + dy)]);
2115
+ const arr = _optionalChain([buckets, 'access', _27 => _27.get, 'call', _28 => _28(cx + dx), 'optionalAccess', _29 => _29.get, 'call', _30 => _30(cy + dy)]);
2086
2116
  if (!arr) continue;
2087
2117
  for (const j of arr) {
2088
2118
  if (j > i && !used[j]) candidates.push(j);
@@ -2209,7 +2239,7 @@ function dropShadingClipGrids(clipGrids, lineGrids, fillRects, verticals = [], h
2209
2239
  const area = (b) => Math.max(0, b.x2 - b.x1) * Math.max(0, b.y2 - b.y1);
2210
2240
  const inter = (a, b) => area({ x1: Math.max(a.x1, b.x1), y1: Math.max(a.y1, b.y1), x2: Math.min(a.x2, b.x2), y2: Math.min(a.y2, b.y2) });
2211
2241
  return clipGrids.filter((c) => {
2212
- if (!_optionalChain([c, 'access', _29 => _29.cells, 'optionalAccess', _30 => _30.length]) || c.clipParent) return true;
2242
+ if (!_optionalChain([c, 'access', _31 => _31.cells, 'optionalAccess', _32 => _32.length]) || c.clipParent) return true;
2213
2243
  const sourceCells = c.cells.filter((cell) => !cell.filler);
2214
2244
  if (sourceCells.length === 0) return true;
2215
2245
  const shaded = sourceCells.every((cell) => fillRects.some((f) => near2(f.x1, cell.bbox.x1) && near2(f.x2, cell.bbox.x2) && near2(f.y1, cell.bbox.y1) && near2(f.y2, cell.bbox.y2)));
@@ -2219,7 +2249,7 @@ function dropShadingClipGrids(clipGrids, lineGrids, fillRects, verticals = [], h
2219
2249
  const host = lineGrids.find((l) => (
2220
2250
  // Inferred filler cells carry no boundary evidence. Replace their frame only
2221
2251
  // with a finer ruled grid of the same extent, never a larger surrounding form.
2222
- (!c.cells.some((cell) => cell.filler) || near2(c.bbox.x1, l.bbox.x1) && near2(c.bbox.x2, l.bbox.x2) && near2(c.bbox.y1, l.bbox.y1) && near2(c.bbox.y2, l.bbox.y2) && l.rowYs.length > c.rowYs.length && sourceCells.every((cell) => [cell.bbox.y1, cell.bbox.y2].every((y) => l.rowYs.some((ly) => near2(y, ly))))) && c.bbox.x1 >= l.bbox.x1 - SHADE_CLIP_TOL && c.bbox.x2 <= l.bbox.x2 + SHADE_CLIP_TOL && c.bbox.y1 >= l.bbox.y1 - SHADE_CLIP_TOL && c.bbox.y2 <= l.bbox.y2 + SHADE_CLIP_TOL && c.colXs.every((x) => l.colXs.some((lx) => near2(lx, x))) && (clipGrids.reduce((s, o) => s + (_optionalChain([o, 'access', _31 => _31.cells, 'optionalAccess', _32 => _32.some, 'call', _33 => _33((cell) => cell.filler)]) ? o.cells.filter((cell) => !cell.filler).reduce((a, cell) => a + inter(cell.bbox, l.bbox), 0) : inter(o.bbox, l.bbox)), 0) <= area(l.bbox) * SHADE_CLIP_MAX_AREA || l.rowYs.length === c.rowYs.length + 1 && c.rowYs.every((y, i) => near2(y, l.rowYs[i])) && l.colXs.length === c.colXs.length && c.colXs.every((x, i) => near2(x, l.colXs[i])) && !clipGrids.some((o) => o !== c && inter(o.bbox, l.bbox) > 0) || hasShadedRowBands(l, clipGrids, fillRects, verticals, horizontals))
2252
+ (!c.cells.some((cell) => cell.filler) || near2(c.bbox.x1, l.bbox.x1) && near2(c.bbox.x2, l.bbox.x2) && near2(c.bbox.y1, l.bbox.y1) && near2(c.bbox.y2, l.bbox.y2) && l.rowYs.length > c.rowYs.length && sourceCells.every((cell) => [cell.bbox.y1, cell.bbox.y2].every((y) => l.rowYs.some((ly) => near2(y, ly))))) && c.bbox.x1 >= l.bbox.x1 - SHADE_CLIP_TOL && c.bbox.x2 <= l.bbox.x2 + SHADE_CLIP_TOL && c.bbox.y1 >= l.bbox.y1 - SHADE_CLIP_TOL && c.bbox.y2 <= l.bbox.y2 + SHADE_CLIP_TOL && c.colXs.every((x) => l.colXs.some((lx) => near2(lx, x))) && (clipGrids.reduce((s, o) => s + (_optionalChain([o, 'access', _33 => _33.cells, 'optionalAccess', _34 => _34.some, 'call', _35 => _35((cell) => cell.filler)]) ? o.cells.filter((cell) => !cell.filler).reduce((a, cell) => a + inter(cell.bbox, l.bbox), 0) : inter(o.bbox, l.bbox)), 0) <= area(l.bbox) * SHADE_CLIP_MAX_AREA || l.rowYs.length === c.rowYs.length + 1 && c.rowYs.every((y, i) => near2(y, l.rowYs[i])) && l.colXs.length === c.colXs.length && c.colXs.every((x, i) => near2(x, l.colXs[i])) && !clipGrids.some((o) => o !== c && inter(o.bbox, l.bbox) > 0) || hasShadedRowBands(l, clipGrids, fillRects, verticals, horizontals))
2223
2253
  ));
2224
2254
  return !host;
2225
2255
  });
@@ -2234,12 +2264,12 @@ function dropHeadBandClipGrids(clipGrids, lineGrids) {
2234
2264
  if (clipGrids.length === 0 || lineGrids.length === 0) return clipGrids;
2235
2265
  const near2 = (a, b) => Math.abs(a - b) <= SHADE_CLIP_TOL;
2236
2266
  const overlaps = (a, b) => Math.min(a.x2, b.x2) > Math.max(a.x1, b.x1) && Math.min(a.y2, b.y2) > Math.max(a.y1, b.y1);
2237
- const kept = clipGrids.filter((c) => c.clipParent || !_optionalChain([c, 'access', _34 => _34.cells, 'optionalAccess', _35 => _35.length]) || !lineGrids.some((l) => l.rowYs.length > c.rowYs.length && l.colXs.length === c.colXs.length && c.colXs.every((x, k) => near2(x, l.colXs[k])) && c.rowYs.every((y, k) => near2(y, l.rowYs[k])) && !clipGrids.some((o) => o !== c && overlaps(o.bbox, l.bbox))));
2267
+ const kept = clipGrids.filter((c) => c.clipParent || !_optionalChain([c, 'access', _36 => _36.cells, 'optionalAccess', _37 => _37.length]) || !lineGrids.some((l) => l.rowYs.length > c.rowYs.length && l.colXs.length === c.colXs.length && c.colXs.every((x, k) => near2(x, l.colXs[k])) && c.rowYs.every((y, k) => near2(y, l.rowYs[k])) && !clipGrids.some((o) => o !== c && overlaps(o.bbox, l.bbox))));
2238
2268
  return kept.filter((c) => !lineGrids.some((l) => headBandTiles(kept, l, near2, overlaps).includes(c)));
2239
2269
  }
2240
2270
  function headBandTiles(clips, l, near2, overlaps) {
2241
2271
  const onRow = (y) => l.rowYs.some((r) => near2(r, y));
2242
- const band = clips.filter((c) => !c.clipParent && _optionalChain([c, 'access', _36 => _36.cells, 'optionalAccess', _37 => _37.length]) && near2(c.bbox.y2, l.bbox.y2) && c.bbox.y1 > l.bbox.y1 + SHADE_CLIP_TOL && c.bbox.x1 >= l.bbox.x1 - SHADE_CLIP_TOL && c.bbox.x2 <= l.bbox.x2 + SHADE_CLIP_TOL && c.rowYs.every(onRow)).sort((a, b) => a.bbox.x1 - b.bbox.x1);
2272
+ const band = clips.filter((c) => !c.clipParent && _optionalChain([c, 'access', _38 => _38.cells, 'optionalAccess', _39 => _39.length]) && near2(c.bbox.y2, l.bbox.y2) && c.bbox.y1 > l.bbox.y1 + SHADE_CLIP_TOL && c.bbox.x1 >= l.bbox.x1 - SHADE_CLIP_TOL && c.bbox.x2 <= l.bbox.x2 + SHADE_CLIP_TOL && c.rowYs.every(onRow)).sort((a, b) => a.bbox.x1 - b.bbox.x1);
2243
2273
  if (band.length < 2 || !near2(band[0].bbox.x1, l.bbox.x1) || !near2(band[band.length - 1].bbox.x2, l.bbox.x2)) return [];
2244
2274
  if (band.some((c, k) => k > 0 && c.bbox.x1 > band[k - 1].bbox.x2 + SHADE_CLIP_TOL)) return [];
2245
2275
  const bottom = Math.min(...band.map((c) => c.bbox.y1));
@@ -2595,7 +2625,7 @@ function buildClipCellGrids(rects, strokedH, strokedV, pageWidth, pageHeight, te
2595
2625
  for (let dx = -1; dx <= 1 && !duplicate; dx++) {
2596
2626
  const ys2 = buckets.get(bx + dx);
2597
2627
  for (let dy = -1; dy <= 1 && !duplicate; dy++) {
2598
- duplicate = _nullishCoalesce(_optionalChain([ys2, 'optionalAccess', _38 => _38.get, 'call', _39 => _39(by + dy), 'optionalAccess', _40 => _40.some, 'call', _41 => _41((c) => sameRect(c, r))]), () => ( false));
2628
+ duplicate = _nullishCoalesce(_optionalChain([ys2, 'optionalAccess', _40 => _40.get, 'call', _41 => _41(by + dy), 'optionalAccess', _42 => _42.some, 'call', _43 => _43((c) => sameRect(c, r))]), () => ( false));
2599
2629
  }
2600
2630
  }
2601
2631
  if (duplicate) continue;
@@ -2743,7 +2773,7 @@ function buildClipCellGrids(rects, strokedH, strokedV, pageWidth, pageHeight, te
2743
2773
  else groups.set(r, [i]);
2744
2774
  }
2745
2775
  const containers = cells.filter((_, i) => isContainer[i]);
2746
- const groupSize = (i) => _nullishCoalesce(_optionalChain([groups, 'access', _42 => _42.get, 'call', _43 => _43(find(i)), 'optionalAccess', _44 => _44.length]), () => ( 0));
2776
+ const groupSize = (i) => _nullishCoalesce(_optionalChain([groups, 'access', _44 => _44.get, 'call', _45 => _45(find(i)), 'optionalAccess', _46 => _46.length]), () => ( 0));
2747
2777
  const isGridMember = (i) => groupSize(i) >= CLIP_MIN_GROUP;
2748
2778
  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);
2749
2779
  const titledFrame = (r) => r.y1 >= pageHeight * TITLED_FRAME_MIN_TOP && r.x2 - r.x1 >= pageWidth * TITLED_FRAME_MIN_WIDTH && textPoints.some((p) => p.y < r.y1 && p.y > pageHeight * HEADER_BAND && p.x >= r.x1 - CLIP_EDGE_TOL && p.x <= r.x2 + CLIP_EDGE_TOL) && textPoints.some((p) => p.x > r.x1 && p.x < r.x2 && p.y > r.y1 && p.y < r.y2);
@@ -3124,8 +3154,8 @@ function childRules(r, grid) {
3124
3154
  }
3125
3155
  function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
3126
3156
  if (!grids.some((g) => g.cells)) return;
3127
- const h = rules(_optionalChain([nonRules, 'optionalAccess', _45 => _45.size]) ? horizontals.filter((l) => !nonRules.has(l)) : horizontals, "h");
3128
- const v = rules(_optionalChain([nonRules, 'optionalAccess', _46 => _46.size]) ? verticals.filter((l) => !nonRules.has(l)) : verticals, "v");
3157
+ const h = rules(_optionalChain([nonRules, 'optionalAccess', _47 => _47.size]) ? horizontals.filter((l) => !nonRules.has(l)) : horizontals, "h");
3158
+ const v = rules(_optionalChain([nonRules, 'optionalAccess', _48 => _48.size]) ? verticals.filter((l) => !nonRules.has(l)) : verticals, "v");
3129
3159
  for (const g of grids) {
3130
3160
  if (!g.cells) continue;
3131
3161
  const ownH = childRules(h, g), ownV = childRules(v, g);
@@ -3141,9 +3171,9 @@ function recordOpenEndCellEdges(grid, cells, horizontals) {
3141
3171
  const end = horizontals.find((l) => OPEN_END_RULES.has(l) && Math.abs(l.y1 - b.y1) <= EDGE_NEAR2 && Math.abs(l.x1 - b.x1) <= EDGE_NEAR2 && Math.abs(l.x2 - b.x2) <= EDGE_NEAR2);
3142
3172
  const raw = end && OPEN_END_RULES.get(end);
3143
3173
  if (!raw) return;
3144
- const hs = raw.horizontals.filter((l) => !_optionalChain([raw, 'access', _47 => _47.nonRules, 'optionalAccess', _48 => _48.has, 'call', _49 => _49(l)]));
3174
+ const hs = raw.horizontals.filter((l) => !_optionalChain([raw, 'access', _49 => _49.nonRules, 'optionalAccess', _50 => _50.has, 'call', _51 => _51(l)]));
3145
3175
  if (hs.some((l) => Math.abs(l.y1 - b.y1) <= EDGE_NEAR2 && Math.min(l.x2, b.x2) - Math.max(l.x1, b.x1) > TIP_MAX)) return;
3146
- const h = rules(hs, "h"), v = rules(raw.verticals.filter((l) => !_optionalChain([raw, 'access', _50 => _50.nonRules, 'optionalAccess', _51 => _51.has, 'call', _52 => _52(l)])), "v");
3176
+ const h = rules(hs, "h"), v = rules(raw.verticals.filter((l) => !_optionalChain([raw, 'access', _52 => _52.nonRules, 'optionalAccess', _53 => _53.has, 'call', _54 => _54(l)])), "v");
3147
3177
  const edges = cells.map((c) => edgesOf(c.bbox, h, v));
3148
3178
  const last = grid.rowYs.length - 2;
3149
3179
  if (!cells.every((c, i) => {
@@ -3154,16 +3184,16 @@ function recordOpenEndCellEdges(grid, cells, horizontals) {
3154
3184
  }
3155
3185
  function takeClipCellEdges(from, to) {
3156
3186
  const e = CLIP_CELL_EDGES.get(from);
3157
- if (e) _chunkB5M676H3cjs.CELL_EDGES.set(to, e);
3187
+ if (e) _chunkT7Z554HTcjs.CELL_EDGES.set(to, e);
3158
3188
  }
3159
3189
  function hasOpenCellSeam(a, b) {
3160
- const u = _chunkB5M676H3cjs.CELL_EDGES.get(a), d = _chunkB5M676H3cjs.CELL_EDGES.get(b);
3190
+ const u = _chunkT7Z554HTcjs.CELL_EDGES.get(a), d = _chunkT7Z554HTcjs.CELL_EDGES.get(b);
3161
3191
  return !!u && !!d && u.t && !u.b && !d.t && d.b && u.l && u.r && d.l && d.r;
3162
3192
  }
3163
3193
  function joinCellEdges(a, b) {
3164
- const u = _chunkB5M676H3cjs.CELL_EDGES.get(a), d = _chunkB5M676H3cjs.CELL_EDGES.get(b);
3194
+ const u = _chunkT7Z554HTcjs.CELL_EDGES.get(a), d = _chunkT7Z554HTcjs.CELL_EDGES.get(b);
3165
3195
  if (!u || !d) return;
3166
- _chunkB5M676H3cjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
3196
+ _chunkT7Z554HTcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
3167
3197
  }
3168
3198
 
3169
3199
  // src/pdf/cell-extract.ts
@@ -3339,7 +3369,7 @@ function tagScripts(text, lines) {
3339
3369
  const [s, e, kind] = marks[m];
3340
3370
  out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
3341
3371
  }
3342
- return _chunkB5M676H3cjs.tidyScriptTags.call(void 0, out);
3372
+ return _chunkT7Z554HTcjs.tidyScriptTags.call(void 0, out);
3343
3373
  }
3344
3374
 
3345
3375
  // src/pdf/line-wrap.ts
@@ -3386,12 +3416,12 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
3386
3416
  const t = toks[i], n = t.length;
3387
3417
  if (i > 0 && i < toks.length - 1) {
3388
3418
  bump(this.words, t);
3389
- const run = _nullishCoalesce(_optionalChain([t, 'access', _53 => _53.match, 'call', _54 => _54(/^[가-힣]+/), 'optionalAccess', _55 => _55[0]]), () => ( ""));
3419
+ const run = _nullishCoalesce(_optionalChain([t, 'access', _55 => _55.match, 'call', _56 => _56(/^[가-힣]+/), 'optionalAccess', _57 => _57[0]]), () => ( ""));
3390
3420
  for (let j = 2; j <= Math.min(run.length, 6); j++) this.heads.add(run.slice(0, j));
3391
3421
  }
3392
3422
  if (i + 1 < toks.length) {
3393
3423
  this.pairs.add(t + " " + toks[i + 1]);
3394
- const tail = _optionalChain([t, 'access', _56 => _56.match, 'call', _57 => _57(/[가-힣]+$/), 'optionalAccess', _58 => _58[0]]);
3424
+ const tail = _optionalChain([t, 'access', _58 => _58.match, 'call', _59 => _59(/[가-힣]+$/), 'optionalAccess', _60 => _60[0]]);
3395
3425
  if (tail) this.spacedHeads.add(tail + " " + toks[i + 1].charAt(0));
3396
3426
  }
3397
3427
  for (let a = 0; a + 1 < n; a++) {
@@ -3428,14 +3458,14 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
3428
3458
  const n = left.length;
3429
3459
  if (n < 2 || right.length < 2) return null;
3430
3460
  const k1 = pairKey(left.charCodeAt(n - 2), left.charCodeAt(n - 1)), k2 = pairKey(right.charCodeAt(0), right.charCodeAt(1));
3431
- return decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _59 => _59.joined2, 'access', _60 => _60.get, 'call', _61 => _61(k1), 'optionalAccess', _62 => _62.get, 'call', _63 => _63(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _64 => _64.spaced2, 'access', _65 => _65.get, 'call', _66 => _66(k1), 'optionalAccess', _67 => _67.get, 'call', _68 => _68(k2)]), () => ( 0)));
3461
+ return decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _61 => _61.joined2, 'access', _62 => _62.get, 'call', _63 => _63(k1), 'optionalAccess', _64 => _64.get, 'call', _65 => _65(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _66 => _66.spaced2, 'access', _67 => _67.get, 'call', _68 => _68(k1), 'optionalAccess', _69 => _69.get, 'call', _70 => _70(k2)]), () => ( 0)));
3432
3462
  }
3433
3463
  /** 꺾인 자리 증거: "" 붙음 · " " 띄움 · null 모름 (두 글자 증거가 갈리거나 없으면 한 글자) */
3434
3464
  evidence(left, right) {
3435
3465
  const n = left.length;
3436
3466
  if (n >= 2 && right.length >= 2) {
3437
3467
  const k1 = pairKey(left.charCodeAt(n - 2), left.charCodeAt(n - 1)), k2 = pairKey(right.charCodeAt(0), right.charCodeAt(1));
3438
- const v = decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _69 => _69.joined2, 'access', _70 => _70.get, 'call', _71 => _71(k1), 'optionalAccess', _72 => _72.get, 'call', _73 => _73(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _74 => _74.spaced2, 'access', _75 => _75.get, 'call', _76 => _76(k1), 'optionalAccess', _77 => _77.get, 'call', _78 => _78(k2)]), () => ( 0)));
3468
+ const v = decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _71 => _71.joined2, 'access', _72 => _72.get, 'call', _73 => _73(k1), 'optionalAccess', _74 => _74.get, 'call', _75 => _75(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _76 => _76.spaced2, 'access', _77 => _77.get, 'call', _78 => _78(k1), 'optionalAccess', _79 => _79.get, 'call', _80 => _80(k2)]), () => ( 0)));
3439
3469
  if (v !== null) return v;
3440
3470
  }
3441
3471
  if (n && right.length) {
@@ -3510,11 +3540,11 @@ function wrapJoiner(prevText, nextText, lex, heads = true) {
3510
3540
  if (particleContinues(left, right)) return "";
3511
3541
  if (endsAsWord(left)) return " ";
3512
3542
  if (/[A-Za-z]-$/.test(left) && /^[A-Za-z]/.test(right) && !/[가-힣]/.test(prev + next)) {
3513
- return _optionalChain([lex, 'optionalAccess', _79 => _79.joinedWord, 'call', _80 => _80(left, right.replace(/[.,;:!?)]*$/, ""))]) ? "" : " ";
3543
+ return _optionalChain([lex, 'optionalAccess', _81 => _81.joinedWord, 'call', _82 => _82(left, right.replace(/[.,;:!?)]*$/, ""))]) ? "" : " ";
3514
3544
  }
3515
3545
  if (/[·ㆍ‧-]/.test(a) && !/[·ㆍ‧…]{2}$/.test(prev) && /[가-힣A-Za-z0-9]/.test(b)) return "";
3516
3546
  if (/[A-Za-z]/.test(a) && /[A-Za-z]/.test(b) || /\d/.test(a) && /\d/.test(b)) return " ";
3517
- const ev = _optionalChain([lex, 'optionalAccess', _81 => _81.evidence, 'call', _82 => _82(left, right)]);
3547
+ const ev = _optionalChain([lex, 'optionalAccess', _83 => _83.evidence, 'call', _84 => _84(left, right)]);
3518
3548
  if (ev != null) return ev;
3519
3549
  if (lex && /[가-힣A-Za-z0-9]$/.test(left) && /^[가-힣A-Za-z0-9]/.test(right) && lex.joinedWord(left, right.replace(/[.,)」』’”;:]+$/, ""))) return "";
3520
3550
  if (/\d$/.test(left) && COUNTER.test(right)) return "";
@@ -3522,7 +3552,7 @@ function wrapJoiner(prevText, nextText, lex, heads = true) {
3522
3552
  const r1 = right.replace(/[.,)」』’”]+$/, "");
3523
3553
  if (lex && /[가-힣]$/.test(left) && /^[가-힣]$/.test(r1) && !STANDALONE_SYLLABLE.test(r1) && !lex.isWord(r1) && !lex.isWord(right)) return "";
3524
3554
  if (lex && heads) {
3525
- const tail = _optionalChain([left, 'access', _83 => _83.match, 'call', _84 => _84(/[가-힣]+$/), 'optionalAccess', _85 => _85[0]]), run = _optionalChain([right, 'access', _86 => _86.match, 'call', _87 => _87(/^[가-힣]+/), 'optionalAccess', _88 => _88[0]]);
3555
+ const tail = _optionalChain([left, 'access', _85 => _85.match, 'call', _86 => _86(/[가-힣]+$/), 'optionalAccess', _87 => _87[0]]), run = _optionalChain([right, 'access', _88 => _88.match, 'call', _89 => _89(/^[가-힣]+/), 'optionalAccess', _90 => _90[0]]);
3526
3556
  if (tail && run && !STANDALONE_SYLLABLE.test(tail) && lex.startsWord(tail + run.slice(0, 2)) && !lex.spacedHead(tail, run[0])) return "";
3527
3557
  if (/[가-힣]{2}$/.test(left) && /^\([^()\s]*\)/.test(right) && !endsAsWord(left) && !/(?:함|음|됨|임|다)$/.test(left) && !BARE_UNIT_PAREN.test(right) && !/^\(\d/.test(right)) return "";
3528
3558
  }
@@ -3557,14 +3587,14 @@ function joinPageBreakWraps(blocks, lex) {
3557
3587
  if (a.type !== "paragraph" && a.type !== "list" || b.type !== "paragraph") continue;
3558
3588
  const last = a.bbox && PARA_LAST_LINE.get(a.bbox), fs = last ? last.fontSize : 0;
3559
3589
  if (!last || fs <= 0 || (_nullishCoalesce(pageRight.get(a.pageNumber), () => ( Infinity))) - last.right >= BODY_FULL_TOL * fs) continue;
3560
- if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _89 => _89.style, 'optionalAccess', _90 => _90.fontSize]), () => ( 0))) - fs) > 0.15 * fs) continue;
3590
+ if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _91 => _91.style, 'optionalAccess', _92 => _92.fontSize]), () => ( 0))) - fs) > 0.15 * fs) continue;
3561
3591
  const bt = b.text.replace(MARKUP, "");
3562
3592
  if (startsNewItem(a.text, b.text) || PAGE_REF_TAIL.test(a.text) || PAGE_ITEM_HEAD.test(bt)) continue;
3563
3593
  if (PAGE_HEAD_MARK.test(bt) && !(/^[\u25a0-\u25ff]/.test(bt) && a.text.includes(bt[0]))) continue;
3564
3594
  const firstLeft = b.bbox && PARA_FIRST_LEFT.get(b.bbox);
3565
3595
  const indented = firstLeft === void 0 || firstLeft - (_nullishCoalesce(pageLeft.get(b.pageNumber), () => ( firstLeft))) >= 0.3 * fs;
3566
3596
  if (indented && SENTENCE_END.test(a.text.replace(MARKUP, "").trimEnd())) continue;
3567
- if (Math.round(_nullishCoalesce(_optionalChain([b, 'access', _91 => _91.style, 'optionalAccess', _92 => _92.fontSize]), () => ( 0))) !== Math.round(fs) && titleLike(b.text)) continue;
3597
+ if (Math.round(_nullishCoalesce(_optionalChain([b, 'access', _93 => _93.style, 'optionalAccess', _94 => _94.fontSize]), () => ( 0))) !== Math.round(fs) && titleLike(b.text)) continue;
3568
3598
  if (/\t/.test(a.text.slice(a.text.lastIndexOf("\n") + 1).replace(/^\S{1,8}\t/, "")) && titleLike(bt.trim().split("\n")[0])) continue;
3569
3599
  const joined = wrapJoiner(a.text, b.text, lex);
3570
3600
  const head = a.text, joiner = joined === "" && last.spaceAfter ? " " : joined;
@@ -3613,7 +3643,7 @@ function bodyLineJoins(lines, lex) {
3613
3643
  for (const l of lines) if (!HANGING.test(l.text) && l.right > inner) inner = l.right;
3614
3644
  const full = (l) => right - l.right < BODY_FULL_TOL * l.fontSize || right - inner <= 1.2 * l.fontSize && inner - l.right < BODY_FULL_TOL * l.fontSize;
3615
3645
  const nextWordNoRoom = (a, b) => {
3616
- const w = _optionalChain([b, 'access', _93 => _93.text, 'access', _94 => _94.trim, 'call', _95 => _95(), 'access', _96 => _96.match, 'call', _97 => _97(/^\S+/), 'optionalAccess', _98 => _98[0]]);
3646
+ const w = _optionalChain([b, 'access', _95 => _95.text, 'access', _96 => _96.trim, 'call', _97 => _97(), 'access', _98 => _98.match, 'call', _99 => _99(/^\S+/), 'optionalAccess', _100 => _100[0]]);
3617
3647
  const n = [...b.text.trim()].length;
3618
3648
  if (!w || n === 0) return false;
3619
3649
  const em = (b.right - b.left) / n;
@@ -3639,7 +3669,7 @@ function bodyLineJoins(lines, lex) {
3639
3669
  const a = lines[i], b = lines[i + 1];
3640
3670
  const fs = a.fontSize;
3641
3671
  const own = i === i1 ? p2 : p1;
3642
- const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess', _99 => _99.bodyPitch, 'call', _100 => _100(fs)]), () => ( Infinity));
3672
+ const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess', _101 => _101.bodyPitch, 'call', _102 => _102(fs)]), () => ( Infinity));
3643
3673
  const maxPitch = Number.isFinite(others) ? Math.min(BODY_MAX_PITCH_ABS_EM * fs, Math.max(BODY_MAX_PITCH_EM * fs, others * BODY_PITCH_REL)) : BODY_MAX_PITCH_EM * fs;
3644
3674
  const wordWrap = ragged && !full(a) && nextWordNoRoom(a, b) && !MULTI_LEVEL_NUMBER.test(b.text.trimStart());
3645
3675
  const wraps = fs > 0 && (full(a) || wordWrap) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && a.y - b.y < maxPitch && Math.abs(b.fontSize - fs) <= 0.15 * fs && !startsNewItem(a.text, b.text);
@@ -3810,7 +3840,7 @@ function cellTextToString(items, wrap) {
3810
3840
  const merged = mergeSuperscriptRows(lines).map((line) => sortLineByX(line));
3811
3841
  const textLines = merged.map((s) => {
3812
3842
  if (s.length === 1) return s[0].text;
3813
- if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _101 => _101.lex]) && (wrap.lex.isWord(s[0].text + s[1].text) || wrap.lex.evidence(s[0].text, s[1].text) === "" || REGION_LABELS.has(s[0].text + s[1].text)) && s[1].x - (s[0].x + s[0].w) >= Math.max(s[0].fontSize, s[1].fontSize) * 1.5 && s[1].x + s[1].w - s[0].x >= wrap.box.x2 - wrap.box.x1 - Math.max(s[0].fontSize, s[1].fontSize) * 2) return s[0].text + s[1].text;
3843
+ if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _103 => _103.lex]) && (wrap.lex.isWord(s[0].text + s[1].text) || wrap.lex.evidence(s[0].text, s[1].text) === "" || REGION_LABELS.has(s[0].text + s[1].text)) && s[1].x - (s[0].x + s[0].w) >= Math.max(s[0].fontSize, s[1].fontSize) * 1.5 && s[1].x + s[1].w - s[0].x >= wrap.box.x2 - wrap.box.x1 - Math.max(s[0].fontSize, s[1].fontSize) * 2) return s[0].text + s[1].text;
3814
3844
  const evenSpaced = detectEvenSpacedItems(s, true);
3815
3845
  const hangulLine = s.some((it) => /[가-힣]/.test(it.text));
3816
3846
  let result = s[0].text;
@@ -3957,12 +3987,12 @@ function markEvenRun(items, visible, result, start, end) {
3957
3987
  }
3958
3988
  function mergeCellTextLines(textLines, wrap) {
3959
3989
  if (textLines.length <= 1) return textLines[0] || "";
3960
- const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess', _102 => _102.wraps, 'access', _103 => _103[k]]) && (_nullishCoalesce(_optionalChain([wrap, 'access', _104 => _104.wide, 'optionalAccess', _105 => _105[k]]), () => ( true)));
3990
+ const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess', _104 => _104.wraps, 'access', _105 => _105[k]]) && (_nullishCoalesce(_optionalChain([wrap, 'access', _106 => _106.wide, 'optionalAccess', _107 => _107[k]]), () => ( true)));
3961
3991
  const merged = [textLines[0]];
3962
3992
  for (let i = 1; i < textLines.length; i++) {
3963
3993
  const prev = merged[merged.length - 1];
3964
3994
  const curr = textLines[i];
3965
- if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access', _106 => _106.spaced, 'optionalAccess', _107 => _107[i - 1]]) && !startsNewItem(prev, curr) && wrapJoiner(prev, curr, wrap.lex, false) === "" : /[가-힣]$/.test(prev) && /^[가-힣]+$/.test(curr) && curr.length <= 8 && !curr.includes(" ")) {
3995
+ if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access', _108 => _108.spaced, 'optionalAccess', _109 => _109[i - 1]]) && !startsNewItem(prev, curr) && wrapJoiner(prev, curr, wrap.lex, false) === "" : /[가-힣]$/.test(prev) && /^[가-힣]+$/.test(curr) && curr.length <= 8 && !curr.includes(" ")) {
3966
3996
  merged[merged.length - 1] = prev + curr;
3967
3997
  } else if (curr.trim().length <= 3 && /^[)\]%}]/.test(curr.trim())) {
3968
3998
  merged[merged.length - 1] = prev + curr.trim();
@@ -4057,7 +4087,7 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs) {
4057
4087
  if (numRows > MAX_UNDERSEGMENTED_ROWS || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
4058
4088
  if (items.length === 0) return null;
4059
4089
  if (numRows >= 3) {
4060
- if (_optionalChain([rowYs, 'optionalAccess', _108 => _108.length]) !== numRows + 1) return null;
4090
+ if (_optionalChain([rowYs, 'optionalAccess', _110 => _110.length]) !== numRows + 1) return null;
4061
4091
  const rebuilt2 = [];
4062
4092
  let expanded = 0;
4063
4093
  for (let r = 0; r < numRows; r++) {
@@ -4151,7 +4181,7 @@ function sortLineByX(items) {
4151
4181
  e++;
4152
4182
  }
4153
4183
  const run = items.slice(s, e), seqs = run.map((i) => i.seq);
4154
- const ok = !wide ? !run.some((i) => _optionalChain([i, 'access', _109 => _109.text, 'optionalAccess', _110 => _110.startsWith, 'call', _111 => _111("$")])) : Math.max(...seqs) - Math.min(...seqs) <= 2 * (e - s - 1) && run.every((i) => Math.abs((_nullishCoalesce(i.fontSize, () => ( 0))) - (_nullishCoalesce(run[0].fontSize, () => ( 0)))) <= 0.5);
4184
+ const ok = !wide ? !run.some((i) => _optionalChain([i, 'access', _111 => _111.text, 'optionalAccess', _112 => _112.startsWith, 'call', _113 => _113("$")])) : Math.max(...seqs) - Math.min(...seqs) <= 2 * (e - s - 1) && run.every((i) => Math.abs((_nullishCoalesce(i.fontSize, () => ( 0))) - (_nullishCoalesce(run[0].fontSize, () => ( 0)))) <= 0.5);
4155
4185
  if (e - s > 1 && seqs.every((q) => q !== void 0) && ok) {
4156
4186
  run.sort((a, b) => a.seq - b.seq);
4157
4187
  for (let k = 0; k < run.length; k++) items[s + k] = run[k];
@@ -4221,7 +4251,7 @@ function dominantStyle(items) {
4221
4251
  let maxCount = 0, dominantSize = 0;
4222
4252
  for (const i of items) {
4223
4253
  if (i.fontSize <= 0) continue;
4224
- const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _112 => _112.text, 'access', _113 => _113.match, 'call', _114 => _114(/[\p{L}\p{N}]/gu), 'optionalAccess', _115 => _115.length]), () => ( 0)));
4254
+ const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _114 => _114.text, 'access', _115 => _115.match, 'call', _116 => _116(/[\p{L}\p{N}]/gu), 'optionalAccess', _117 => _117.length]), () => ( 0)));
4225
4255
  freq.set(i.fontSize, count);
4226
4256
  if (count > maxCount) {
4227
4257
  maxCount = count;
@@ -4229,7 +4259,7 @@ function dominantStyle(items) {
4229
4259
  }
4230
4260
  }
4231
4261
  if (dominantSize === 0) return void 0;
4232
- const fontName = _optionalChain([items, 'access', _116 => _116.find, 'call', _117 => _117((i) => i.fontSize === dominantSize), 'optionalAccess', _118 => _118.fontName]) || void 0;
4262
+ const fontName = _optionalChain([items, 'access', _118 => _118.find, 'call', _119 => _119((i) => i.fontSize === dominantSize), 'optionalAccess', _120 => _120.fontName]) || void 0;
4233
4263
  return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
4234
4264
  }
4235
4265
  function normalizeItems(rawItems) {
@@ -4374,7 +4404,7 @@ function splitAroundOverlays(c, overlays) {
4374
4404
  const ov = overlays.filter((o) => {
4375
4405
  for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
4376
4406
  const prefix = c.text.slice(0, at);
4377
- const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _119 => _119.match, 'call', _120 => _120(/\s+/g), 'optionalAccess', _121 => _121.length]), () => ( 0))) * ws;
4407
+ const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _121 => _121.match, 'call', _122 => _122(/\s+/g), 'optionalAccess', _123 => _123.length]), () => ( 0))) * ws;
4378
4408
  if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
4379
4409
  }
4380
4410
  return true;
@@ -4499,7 +4529,7 @@ function mergeSuperscriptLines(lines) {
4499
4529
  return result;
4500
4530
  }
4501
4531
  function mergeLineSimple(items) {
4502
- if (items.length <= 1) return _optionalChain([items, 'access', _122 => _122[0], 'optionalAccess', _123 => _123.text]) || "";
4532
+ if (items.length <= 1) return _optionalChain([items, 'access', _124 => _124[0], 'optionalAccess', _125 => _125.text]) || "";
4503
4533
  const sorted = sortLineByX([...items]);
4504
4534
  const isEvenSpaced = detectEvenSpacedItems(sorted);
4505
4535
  const hangulLine = sorted.some((it) => /[가-힣]/.test(it.text));
@@ -4588,7 +4618,7 @@ function isProseTable(table) {
4588
4618
  if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
4589
4619
  for (let c = 0; c < table.cols; c++) {
4590
4620
  const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
4591
- if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _124 => _124.match, 'call', _125 => _125(/\p{L}/gu), 'optionalAccess', _126 => _126.length]), () => ( 0))) >= 2)) return false;
4621
+ if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _126 => _126.match, 'call', _127 => _127(/\p{L}/gu), 'optionalAccess', _128 => _128.length]), () => ( 0))) >= 2)) return false;
4592
4622
  }
4593
4623
  return true;
4594
4624
  }
@@ -4617,7 +4647,7 @@ var TICK = /^-?[\d,]+(?:\.\d+)?%?$/;
4617
4647
  var QUANTITY = /^[-−–]?[\d,]*\.?\d+%?$/;
4618
4648
  var quantity = (token) => Number(token.replace(/^[−–]/, "-").replace(/[,%]/g, ""));
4619
4649
  function isValueAxisColumn(table, c) {
4620
- const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _127 => _127[c], 'optionalAccess', _128 => _128.text]), () => ( ""))).split("\n").map((line) => line.trim().split(/\s+/)));
4650
+ const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _129 => _129[c], 'optionalAccess', _130 => _130.text]), () => ( ""))).split("\n").map((line) => line.trim().split(/\s+/)));
4621
4651
  const others = table.cells.flatMap((row) => row.filter((_, k) => k !== c).map((cell) => cell.text.trim().split(/\s+/))).filter((tokens) => tokens.every((token) => QUANTITY.test(token))).flat().map(quantity).filter((v) => !(Number.isInteger(v) && v >= 1900 && v <= 2100));
4622
4652
  for (const ticks of [lines.flat().filter((t) => TICK.test(t)).map(quantity), lines.map((tokens) => tokens[0]).filter((t) => TICK.test(t)).map(quantity)]) {
4623
4653
  const run = fallingRun(ticks);
@@ -4649,7 +4679,7 @@ function isChartTable(table, ocr = false) {
4649
4679
  const numeric = texts.filter((text) => NUMERIC_CELL.test(text)).length;
4650
4680
  if (numeric < texts.length * 0.5) return false;
4651
4681
  for (let c = 0; c < table.cols; c++) {
4652
- if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _129 => _129[c], 'optionalAccess', _130 => _130.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
4682
+ if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _131 => _131[c], 'optionalAccess', _132 => _132.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
4653
4683
  }
4654
4684
  const values = texts.filter((text) => text.split(/\s+/).every((token) => QUANTITY.test(token))).length;
4655
4685
  const cells = table.rows * table.cols;
@@ -4703,7 +4733,7 @@ function clusterCellLines(items) {
4703
4733
  }
4704
4734
  var WRAP_INDENT_MAX = 3;
4705
4735
  function joinClusterCellLines(lines, box, lex) {
4706
- let out = _nullishCoalesce(_optionalChain([lines, 'access', _131 => _131[0], 'optionalAccess', _132 => _132.text]), () => ( ""));
4736
+ let out = _nullishCoalesce(_optionalChain([lines, 'access', _133 => _133[0], 'optionalAccess', _134 => _134.text]), () => ( ""));
4707
4737
  for (let i = 1; i < lines.length; i++) {
4708
4738
  const a = lines[i - 1], b = lines[i];
4709
4739
  const join2 = !a.spaceAfter && cellLineWraps(box, box.x1, a.right, a.fontSize, b.firstCharW) && a.left - box.x1 <= WRAP_INDENT_MAX * a.fontSize && b.left - box.x1 <= WRAP_INDENT_MAX * b.fontSize && /<\/u>$/.test(a.text) === /^<u>/.test(b.text) && !startsNewItem(out, b.text) && wrapJoiner(out, b.text, lex, false) === "";
@@ -4975,7 +5005,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
4975
5005
  continue;
4976
5006
  }
4977
5007
  const top = rows[i - 1];
4978
- const title = _optionalChain([top, 'optionalAccess', _133 => _133.items, 'access', _134 => _134.length]) === 1 && Math.abs(top.items[0].x - first[0].x) <= 5 && top.items[0].text.length <= 65 && top.y - first[0].y <= Math.max(24, first[0].fontSize * 2.8) ? top : void 0;
5008
+ const title = _optionalChain([top, 'optionalAccess', _135 => _135.items, 'access', _136 => _136.length]) === 1 && Math.abs(top.items[0].x - first[0].x) <= 5 && top.items[0].text.length <= 65 && top.y - first[0].y <= Math.max(24, first[0].fontSize * 2.8) ? top : void 0;
4979
5009
  const tableRows = title ? [title, ...body] : body;
4980
5010
  const cells = tableRows.map((row, idx) => {
4981
5011
  if (title && idx === 0) return [{ text: row.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }];
@@ -5031,12 +5061,12 @@ function isTwoColumnProse(r) {
5031
5061
  if (t.rows < 8) return false;
5032
5062
  const dense = [];
5033
5063
  for (let c = 0; c < t.cols; c++) {
5034
- const filled = t.cells.filter((row) => _optionalChain([row, 'access', _135 => _135[c], 'optionalAccess', _136 => _136.text, 'access', _137 => _137.trim, 'call', _138 => _138()])).length;
5064
+ const filled = t.cells.filter((row) => _optionalChain([row, 'access', _137 => _137[c], 'optionalAccess', _138 => _138.text, 'access', _139 => _139.trim, 'call', _140 => _140()])).length;
5035
5065
  if (filled / t.rows >= 0.3) dense.push(c);
5036
5066
  }
5037
5067
  if (dense.length !== 2) return false;
5038
5068
  for (const c of dense) {
5039
- const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _139 => _139[c], 'optionalAccess', _140 => _140.text, 'access', _141 => _141.replace, 'call', _142 => _142(/\s+/g, ""), 'access', _143 => _143.length]), () => ( 0))).filter((n) => n > 0);
5069
+ const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _141 => _141[c], 'optionalAccess', _142 => _142.text, 'access', _143 => _143.replace, 'call', _144 => _144(/\s+/g, ""), 'access', _145 => _145.length]), () => ( 0))).filter((n) => n > 0);
5040
5070
  const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
5041
5071
  if (avg < 12) return false;
5042
5072
  }
@@ -5495,7 +5525,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
5495
5525
  const runs = [];
5496
5526
  for (const it of sorted) {
5497
5527
  const last = runs[runs.length - 1];
5498
- const prev = _optionalChain([last, 'optionalAccess', _144 => _144[last.length - 1]]);
5528
+ const prev = _optionalChain([last, 'optionalAccess', _146 => _146[last.length - 1]]);
5499
5529
  if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
5500
5530
  else runs.push([it]);
5501
5531
  }
@@ -5546,7 +5576,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
5546
5576
  assignedGroups.add(gi);
5547
5577
  usedCols.add(ci);
5548
5578
  }
5549
- const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _145 => _145.find, 'call', _146 => _146((a) => a.items === g), 'optionalAccess', _147 => _147.col]), () => ( -1)));
5579
+ const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _147 => _147.find, 'call', _148 => _148((a) => a.items === g), 'optionalAccess', _149 => _149.col]), () => ( -1)));
5550
5580
  if (groups.length <= numCols && colOf.some((c, g) => g > 0 && c < colOf[g - 1])) {
5551
5581
  const G = groups.length, cost = (g, c2) => Math.abs(groupCenters[g] - colCenters[c2]);
5552
5582
  const best = groups.map(() => new Array(numCols).fill(Infinity)), from = groups.map(() => new Array(numCols).fill(-1));
@@ -5583,7 +5613,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
5583
5613
  function buildClusterTable(rows, columns, pageNum, lex) {
5584
5614
  const numRows = rows.length;
5585
5615
  if (numRows < MIN_ROWS || columns.length < MIN_COLS) return null;
5586
- const headFaces = new Set(_optionalChain([rows, 'access', _148 => _148[0], 'optionalAccess', _149 => _149.items, 'access', _150 => _150.map, 'call', _151 => _151((i) => i.fontName)]));
5616
+ const headFaces = new Set(_optionalChain([rows, 'access', _150 => _150[0], 'optionalAccess', _151 => _151.items, 'access', _152 => _152.map, 'call', _153 => _153((i) => i.fontName)]));
5587
5617
  const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
5588
5618
  const assigned = rows.map((row, r) => assignRowItems(row.items, columns, columns.length, r === 0 ? headerFace : void 0));
5589
5619
  const cuts = supportedOcrColumnCuts(assigned);
@@ -5654,7 +5684,7 @@ function buildClusterTable(rows, columns, pageNum, lex) {
5654
5684
  const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
5655
5685
  if (nonEmptyCols !== 1) continue;
5656
5686
  if (cells[r][0].text.trim() !== "") continue;
5657
- const contentText = _optionalChain([cells, 'access', _152 => _152[r], 'access', _153 => _153.find, 'call', _154 => _154((c) => c.text.trim()), 'optionalAccess', _155 => _155.text, 'access', _156 => _156.trim, 'call', _157 => _157()]) || "";
5687
+ const contentText = _optionalChain([cells, 'access', _154 => _154[r], 'access', _155 => _155.find, 'call', _156 => _156((c) => c.text.trim()), 'optionalAccess', _157 => _157.text, 'access', _158 => _158.trim, 'call', _159 => _159()]) || "";
5658
5688
  if (/^[○●▶\-·]/.test(contentText)) continue;
5659
5689
  for (let pr = r - 1; pr >= 0; pr--) {
5660
5690
  if (cells[pr].some((c) => c.text.trim())) {
@@ -5887,7 +5917,7 @@ function stackedTableBands(items) {
5887
5917
  const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
5888
5918
  while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
5889
5919
  if (runs.length < 2) return null;
5890
- if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _158 => _158[i + 1], 'optionalAccess', _159 => _159.start]), () => ( lines.length))))) return null;
5920
+ if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _160 => _160[i + 1], 'optionalAccess', _161 => _161.start]), () => ( lines.length))))) return null;
5891
5921
  const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
5892
5922
  const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
5893
5923
  const tail = lines.slice(runs[runs.length - 1].end);
@@ -6155,7 +6185,7 @@ function splitTrailingColumnRegion(items) {
6155
6185
  }
6156
6186
  function panelBlocks(items, panel, pageNum) {
6157
6187
  const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
6158
- const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _160 => _160(line), 'optionalAccess', _161 => _161.fontName]), () => ( ""));
6188
+ const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _162 => _162(line), 'optionalAccess', _163 => _163.fontName]), () => ( ""));
6159
6189
  const runs = [];
6160
6190
  for (const line of lines) {
6161
6191
  const last = runs[runs.length - 1];
@@ -6337,7 +6367,7 @@ function validWrapBands(items, bands) {
6337
6367
  }
6338
6368
  function inheritedWrapBands(items) {
6339
6369
  const source = XY_WRAP_ITEMS.get(items[0]);
6340
- const present = _optionalChain([source, 'optionalAccess', _162 => _162.length]) === items.length ? new Set(items) : null;
6370
+ const present = _optionalChain([source, 'optionalAccess', _164 => _164.length]) === items.length ? new Set(items) : null;
6341
6371
  const sameLeaf = present && source.every((item) => present.has(item));
6342
6372
  return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
6343
6373
  }
@@ -6376,7 +6406,7 @@ function wrappedLineBands(items, inherited) {
6376
6406
  left: box.x,
6377
6407
  right: box.x + box.width,
6378
6408
  y: row.reduce((n, i) => n + i.y, 0) / row.length,
6379
- fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _163 => _163(row), 'optionalAccess', _164 => _164.fontSize]), () => ( 0)),
6409
+ fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _165 => _165(row), 'optionalAccess', _166 => _166.fontSize]), () => ( 0)),
6380
6410
  sources: row.map((item) => ({ item, state: { ...item } }))
6381
6411
  };
6382
6412
  });
@@ -6512,10 +6542,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
6512
6542
  const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
6513
6543
  const geo = lines.map((l) => {
6514
6544
  const b = computeBBox(l.items, pageNum);
6515
- return { text: l.text, left: b.x, right: b.x + b.width, y: l.items.reduce((s, i) => s + i.y, 0) / l.items.length, fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _165 => _165(l.items), 'optionalAccess', _166 => _166.fontSize]), () => ( 0)) };
6545
+ return { text: l.text, left: b.x, right: b.x + b.width, y: l.items.reduce((s, i) => s + i.y, 0) / l.items.length, fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _167 => _167(l.items), 'optionalAccess', _168 => _168.fontSize]), () => ( 0)) };
6516
6546
  });
6517
6547
  const joins = bodyLineJoins(geo, lex);
6518
- const first = _optionalChain([lines, 'access', _167 => _167[0], 'optionalAccess', _168 => _168.items, 'access', _169 => _169[0]]);
6548
+ const first = _optionalChain([lines, 'access', _169 => _169[0], 'optionalAccess', _170 => _170.items, 'access', _171 => _171[0]]);
6519
6549
  const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
6520
6550
  const hasBand = (top, bottom) => {
6521
6551
  let lo = 0, hi = bands.length;
@@ -6592,15 +6622,15 @@ function computeMedianFontSizeFromFreq(freq) {
6592
6622
  function detectHeadings(blocks, medianFontSize) {
6593
6623
  for (let bi = 0; bi < blocks.length; bi++) {
6594
6624
  const block = blocks[bi];
6595
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _170 => _170.style, 'optionalAccess', _171 => _171.fontSize])) continue;
6625
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _172 => _172.style, 'optionalAccess', _173 => _173.fontSize])) continue;
6596
6626
  const text = block.text.trim();
6597
6627
  if (text.length === 0 || text.length > 200) continue;
6598
6628
  if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
6599
6629
  const ratio = block.style.fontSize / medianFontSize;
6600
6630
  let level = 0;
6601
- if (ratio >= _chunkB5M676H3cjs.HEADING_RATIO_H1) level = 1;
6602
- else if (ratio >= _chunkB5M676H3cjs.HEADING_RATIO_H2) level = 2;
6603
- else if (ratio >= _chunkB5M676H3cjs.HEADING_RATIO_H3) level = 3;
6631
+ if (ratio >= _chunkT7Z554HTcjs.HEADING_RATIO_H1) level = 1;
6632
+ else if (ratio >= _chunkT7Z554HTcjs.HEADING_RATIO_H2) level = 2;
6633
+ else if (ratio >= _chunkT7Z554HTcjs.HEADING_RATIO_H3) level = 3;
6604
6634
  if (level > 0) {
6605
6635
  block.type = "heading";
6606
6636
  block.level = level;
@@ -6609,21 +6639,21 @@ function detectHeadings(blocks, medianFontSize) {
6609
6639
  }
6610
6640
  }
6611
6641
  function isChapterNumber(block, next, medianFontSize) {
6612
- const size = _nullishCoalesce(_optionalChain([block, 'access', _172 => _172.style, 'optionalAccess', _173 => _173.fontSize]), () => ( 0));
6613
- const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _174 => _174.style, 'optionalAccess', _175 => _175.fontSize]), () => ( 0));
6614
- const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _176 => _176.text, 'optionalAccess', _177 => _177.trim, 'call', _178 => _178()]), () => ( ""));
6615
- const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _179 => _179.bbox]);
6616
- return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _180 => _180.text, 'optionalAccess', _181 => _181.trim, 'call', _182 => _182()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkB5M676H3cjs.HEADING_RATIO_H1 && text.length > 0 && text.length <= 80 && !/^[\d\s.]+$/.test(text) && !!a && !!b && a.y > b.y && a.y - (b.y + b.height) <= size * 2;
6642
+ const size = _nullishCoalesce(_optionalChain([block, 'access', _174 => _174.style, 'optionalAccess', _175 => _175.fontSize]), () => ( 0));
6643
+ const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _176 => _176.style, 'optionalAccess', _177 => _177.fontSize]), () => ( 0));
6644
+ const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _178 => _178.text, 'optionalAccess', _179 => _179.trim, 'call', _180 => _180()]), () => ( ""));
6645
+ const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _181 => _181.bbox]);
6646
+ return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _182 => _182.text, 'optionalAccess', _183 => _183.trim, 'call', _184 => _184()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkT7Z554HTcjs.HEADING_RATIO_H1 && text.length > 0 && text.length <= 80 && !/^[\d\s.]+$/.test(text) && !!a && !!b && a.y > b.y && a.y - (b.y + b.height) <= size * 2;
6617
6647
  }
6618
6648
  function mergeStackedHeadingLines(blocks, medianFontSize) {
6619
6649
  for (let i = 0; i < blocks.length - 1; ) {
6620
6650
  const a = blocks[i], b = blocks[i + 1];
6621
6651
  const ab = a.bbox, bb = b.bbox;
6622
- const af = _nullishCoalesce(_optionalChain([a, 'access', _183 => _183.style, 'optionalAccess', _184 => _184.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _185 => _185.style, 'optionalAccess', _186 => _186.fontSize]), () => ( 0));
6652
+ const af = _nullishCoalesce(_optionalChain([a, 'access', _185 => _185.style, 'optionalAccess', _186 => _186.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _187 => _187.style, 'optionalAccess', _188 => _188.fontSize]), () => ( 0));
6623
6653
  const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
6624
- const centered = ab && bb && _optionalChain([a, 'access', _187 => _187.style, 'optionalAccess', _188 => _188.fontName]) === _optionalChain([b, 'access', _189 => _189.style, 'optionalAccess', _190 => _190.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
6654
+ const centered = ab && bb && _optionalChain([a, 'access', _189 => _189.style, 'optionalAccess', _190 => _190.fontName]) === _optionalChain([b, 'access', _191 => _191.style, 'optionalAccess', _192 => _192.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
6625
6655
  const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
6626
- const wrapped = sameAnchor && _optionalChain([a, 'access', _191 => _191.style, 'optionalAccess', _192 => _192.fontName]) === _optionalChain([b, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _195 => _195.text, 'optionalAccess', _196 => _196.trim, 'call', _197 => _197(), 'access', _198 => _198.split, 'call', _199 => _199(/\s+/), 'access', _200 => _200.length]), () => ( 0))) >= 3;
6656
+ const wrapped = sameAnchor && _optionalChain([a, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontName]) === _optionalChain([b, 'access', _195 => _195.style, 'optionalAccess', _196 => _196.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _197 => _197.text, 'optionalAccess', _198 => _198.trim, 'call', _199 => _199(), 'access', _200 => _200.split, 'call', _201 => _201(/\s+/), 'access', _202 => _202.length]), () => ( 0))) >= 3;
6627
6657
  const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
6628
6658
  if (a.type !== "heading" || b.type !== "heading" || !a.text || !b.text || /^\d+$/.test(a.text.trim()) || !ab || !bb || ab.page !== bb.page || !(sameAnchor && af >= medianFontSize * 2 && bf >= medianFontSize * 2) && !wrapped && !(centered && af >= medianFontSize * 1.25 && bf >= medianFontSize * 1.25) || Math.abs(af - bf) > Math.max(af, bf) * 0.15 && !displayStack || gap < -2 || gap > Math.max(af, bf) * 0.45 || a.text.length > (centered ? 120 : 50) || b.text.length > (centered ? 120 : 50)) {
6629
6659
  i++;
@@ -6652,25 +6682,25 @@ function detectTypographyHeadings(blocks) {
6652
6682
  if (page.some((block) => block.type === "heading")) continue;
6653
6683
  const faceWeight = /* @__PURE__ */ new Map();
6654
6684
  for (const block of page) {
6655
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _201 => _201.style, 'optionalAccess', _202 => _202.fontName])) continue;
6685
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _203 => _203.style, 'optionalAccess', _204 => _204.fontName])) continue;
6656
6686
  const faces = FACE_CHARS.get(block);
6657
6687
  if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
6658
6688
  else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
6659
6689
  }
6660
- const bodyFace = _optionalChain([[...faceWeight], 'access', _203 => _203.sort, 'call', _204 => _204((a, b) => b[1] - a[1]), 'access', _205 => _205[0], 'optionalAccess', _206 => _206[0]]);
6690
+ const bodyFace = _optionalChain([[...faceWeight], 'access', _205 => _205.sort, 'call', _206 => _206((a, b) => b[1] - a[1]), 'access', _207 => _207[0], 'optionalAccess', _208 => _208[0]]);
6661
6691
  if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
6662
6692
  const sizeWeight = /* @__PURE__ */ new Map();
6663
6693
  for (const block of page) {
6664
- if (block.type !== "paragraph" || !_optionalChain([block, 'access', _207 => _207.style, 'optionalAccess', _208 => _208.fontSize])) continue;
6694
+ if (block.type !== "paragraph" || !_optionalChain([block, 'access', _209 => _209.style, 'optionalAccess', _210 => _210.fontSize])) continue;
6665
6695
  const faces = FACE_CHARS.get(block);
6666
- const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _209 => _209.text, 'optionalAccess', _210 => _210.length]), () => ( 0)) : 0;
6696
+ const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _211 => _211.text, 'optionalAccess', _212 => _212.length]), () => ( 0)) : 0;
6667
6697
  if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
6668
6698
  }
6669
- const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _211 => _211.sort, 'call', _212 => _212((a, b) => b[1] - a[1]), 'access', _213 => _213[0], 'optionalAccess', _214 => _214[0]]), () => ( 0));
6699
+ const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _213 => _213.sort, 'call', _214 => _214((a, b) => b[1] - a[1]), 'access', _215 => _215[0], 'optionalAccess', _216 => _216[0]]), () => ( 0));
6670
6700
  for (let i = 0; i < page.length; i++) {
6671
6701
  const block = page[i];
6672
6702
  const { text, bbox, style } = block;
6673
- if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _215 => _215.fontName]) || !style.fontSize) continue;
6703
+ if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _217 => _217.fontName]) || !style.fontSize) continue;
6674
6704
  const title = text.trim();
6675
6705
  const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
6676
6706
  const faces = FACE_CHARS.get(block);
@@ -6700,16 +6730,16 @@ function detectDocumentStyleHeadings(blocks) {
6700
6730
  for (const page of byPage.values()) {
6701
6731
  const faceChars = /* @__PURE__ */ new Map();
6702
6732
  for (const block of page) {
6703
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _216 => _216.style, 'optionalAccess', _217 => _217.fontName])) continue;
6733
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _218 => _218.style, 'optionalAccess', _219 => _219.fontName])) continue;
6704
6734
  faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
6705
6735
  }
6706
- const bodyFace = _optionalChain([[...faceChars], 'access', _218 => _218.sort, 'call', _219 => _219((a, b) => b[1] - a[1]), 'access', _220 => _220[0], 'optionalAccess', _221 => _221[0]]);
6736
+ const bodyFace = _optionalChain([[...faceChars], 'access', _220 => _220.sort, 'call', _221 => _221((a, b) => b[1] - a[1]), 'access', _222 => _222[0], 'optionalAccess', _223 => _223[0]]);
6707
6737
  if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
6708
- const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _222 => _222.style, 'optionalAccess', _223 => _223.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
6738
+ const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _224 => _224.style, 'optionalAccess', _225 => _225.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
6709
6739
  for (const label of labels) {
6710
- const peers = labels.filter((b) => _optionalChain([b, 'access', _224 => _224.style, 'optionalAccess', _225 => _225.fontName]) === _optionalChain([label, 'access', _226 => _226.style, 'optionalAccess', _227 => _227.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
6740
+ const peers = labels.filter((b) => _optionalChain([b, 'access', _226 => _226.style, 'optionalAccess', _227 => _227.fontName]) === _optionalChain([label, 'access', _228 => _228.style, 'optionalAccess', _229 => _229.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
6711
6741
  if (peers.length < 2) continue;
6712
- const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _228 => _228.style, 'optionalAccess', _229 => _229.fontName]) !== _optionalChain([label, 'access', _230 => _230.style, 'optionalAccess', _231 => _231.fontName]) && b.bbox.x >= label.bbox.x - 5 && b.bbox.x <= label.bbox.x + 20 && b.bbox.y < label.bbox.y && label.bbox.y - (b.bbox.y + b.bbox.height) <= 60);
6742
+ const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _230 => _230.style, 'optionalAccess', _231 => _231.fontName]) !== _optionalChain([label, 'access', _232 => _232.style, 'optionalAccess', _233 => _233.fontName]) && b.bbox.x >= label.bbox.x - 5 && b.bbox.x <= label.bbox.x + 20 && b.bbox.y < label.bbox.y && label.bbox.y - (b.bbox.y + b.bbox.height) <= 60);
6713
6743
  if (value) {
6714
6744
  label.type = "heading";
6715
6745
  label.level = 2;
@@ -6718,7 +6748,7 @@ function detectDocumentStyleHeadings(blocks) {
6718
6748
  const first = page.find((b) => b.type !== "image" && b.type !== "separator");
6719
6749
  const second = page[page.indexOf(first) + 1];
6720
6750
  const third = page[page.indexOf(first) + 2];
6721
- if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _232 => _232.style, 'optionalAccess', _233 => _233.fontName]) || !_optionalChain([second, 'access', _234 => _234.style, 'optionalAccess', _235 => _235.fontName]) || !/^\d+(?:\.\d+)*\.\s+/.test(first.text.trim()) || first.style.fontName === bodyFace || second.style.fontName === bodyFace || first.text.length + second.text.length > 140 || Math.abs(first.bbox.x - second.bbox.x) > 30 || first.bbox.y - (second.bbox.y + second.bbox.height) > (_nullishCoalesce(first.style.fontSize, () => ( 0))) * 1.5 || _optionalChain([third, 'access', _236 => _236.style, 'optionalAccess', _237 => _237.fontName]) !== bodyFace) continue;
6751
+ if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _234 => _234.style, 'optionalAccess', _235 => _235.fontName]) || !_optionalChain([second, 'access', _236 => _236.style, 'optionalAccess', _237 => _237.fontName]) || !/^\d+(?:\.\d+)*\.\s+/.test(first.text.trim()) || first.style.fontName === bodyFace || second.style.fontName === bodyFace || first.text.length + second.text.length > 140 || Math.abs(first.bbox.x - second.bbox.x) > 30 || first.bbox.y - (second.bbox.y + second.bbox.height) > (_nullishCoalesce(first.style.fontSize, () => ( 0))) * 1.5 || _optionalChain([third, 'access', _238 => _238.style, 'optionalAccess', _239 => _239.fontName]) !== bodyFace) continue;
6722
6752
  first.type = "heading";
6723
6753
  first.level = 1;
6724
6754
  first.text = `${first.text.trim()} ${second.text.trim()}`;
@@ -6742,18 +6772,18 @@ function detectSiblingStyleHeadings(blocks) {
6742
6772
  for (const page of byPage.values()) {
6743
6773
  const bodyChars = /* @__PURE__ */ new Map();
6744
6774
  for (const block of page) {
6745
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _238 => _238.style, 'optionalAccess', _239 => _239.fontName])) continue;
6775
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _240 => _240.style, 'optionalAccess', _241 => _241.fontName])) continue;
6746
6776
  const face = block.style.fontName;
6747
6777
  bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
6748
6778
  }
6749
- const bodyFace = _optionalChain([[...bodyChars], 'access', _240 => _240.sort, 'call', _241 => _241((a, b) => b[1] - a[1]), 'access', _242 => _242[0], 'optionalAccess', _243 => _243[0]]);
6750
- const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _244 => _244.style, 'optionalAccess', _245 => _245.fontName]) && b.style.fontName !== bodyFace);
6779
+ const bodyFace = _optionalChain([[...bodyChars], 'access', _242 => _242.sort, 'call', _243 => _243((a, b) => b[1] - a[1]), 'access', _244 => _244[0], 'optionalAccess', _245 => _245[0]]);
6780
+ const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _246 => _246.style, 'optionalAccess', _247 => _247.fontName]) && b.style.fontName !== bodyFace);
6751
6781
  for (const anchor of anchors) {
6752
6782
  const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
6753
6783
  const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
6754
- const peers = anchors.filter((b) => _optionalChain([b, 'access', _246 => _246.style, 'optionalAccess', _247 => _247.fontName]) === _optionalChain([anchor, 'access', _248 => _248.style, 'optionalAccess', _249 => _249.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _250 => _250.style, 'optionalAccess', _251 => _251.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _252 => _252.style, 'optionalAccess', _253 => _253.fontSize]), () => ( 0)))) < 0.5);
6784
+ const peers = anchors.filter((b) => _optionalChain([b, 'access', _248 => _248.style, 'optionalAccess', _249 => _249.fontName]) === _optionalChain([anchor, 'access', _250 => _250.style, 'optionalAccess', _251 => _251.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _252 => _252.style, 'optionalAccess', _253 => _253.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _254 => _254.style, 'optionalAccess', _255 => _255.fontSize]), () => ( 0)))) < 0.5);
6755
6785
  if (peers.length < 2 && !numbered && !lettered) continue;
6756
- const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _254 => _254.style, 'optionalAccess', _255 => _255.fontName]) === _optionalChain([anchor, 'access', _256 => _256.style, 'optionalAccess', _257 => _257.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _258 => _258.style, 'optionalAccess', _259 => _259.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _260 => _260.style, 'optionalAccess', _261 => _261.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _262 => _262.style, 'optionalAccess', _263 => _263.fontSize]), () => ( 0))) * 1.6 && /^[A-Z]/.test(b.text.trim()) && !/[.!?:;,]$/.test(b.text.trim()) && !/^(?:Table|Figure|Fig\.?|Appendix)\s+\d/i.test(b.text.trim()));
6786
+ const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _256 => _256.style, 'optionalAccess', _257 => _257.fontName]) === _optionalChain([anchor, 'access', _258 => _258.style, 'optionalAccess', _259 => _259.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _260 => _260.style, 'optionalAccess', _261 => _261.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _262 => _262.style, 'optionalAccess', _263 => _263.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _264 => _264.style, 'optionalAccess', _265 => _265.fontSize]), () => ( 0))) * 1.6 && /^[A-Z]/.test(b.text.trim()) && !/[.!?:;,]$/.test(b.text.trim()) && !/^(?:Table|Figure|Fig\.?|Appendix)\s+\d/i.test(b.text.trim()));
6757
6787
  const siblings = candidates.filter((b) => numbered ? new RegExp(`^${numbered[1]}\\.\\d+\\s+`).test(b.text.trim()) : lettered ? /^[A-Z]\s+/.test(b.text.trim()) && Math.abs(anchor.bbox.x - b.bbox.x) < 8 : peers.some((h) => h.bbox && Math.abs(h.bbox.x - b.bbox.x) < 8));
6758
6788
  if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
6759
6789
  for (const sibling of siblings) {
@@ -6772,13 +6802,13 @@ function detectRepeatedPageLabels(blocks) {
6772
6802
  }
6773
6803
  for (const page of byPage.values()) {
6774
6804
  const bodyChars = /* @__PURE__ */ new Map();
6775
- for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _264 => _264.style, 'optionalAccess', _265 => _265.fontName])) {
6805
+ for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _266 => _266.style, 'optionalAccess', _267 => _267.fontName])) {
6776
6806
  const faces = FACE_CHARS.get(b);
6777
6807
  if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
6778
6808
  else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
6779
6809
  }
6780
- const bodyFace = _optionalChain([[...bodyChars], 'access', _266 => _266.sort, 'call', _267 => _267((a, b) => b[1] - a[1]), 'access', _268 => _268[0], 'optionalAccess', _269 => _269[0]]);
6781
- const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) && b.style.fontName !== bodyFace && b.bbox.height <= (_nullishCoalesce(b.style.fontSize, () => ( 0))) * 1.6 && b.text.trim().length >= 5 && b.text.trim().length <= 80);
6810
+ const bodyFace = _optionalChain([[...bodyChars], 'access', _268 => _268.sort, 'call', _269 => _269((a, b) => b[1] - a[1]), 'access', _270 => _270[0], 'optionalAccess', _271 => _271[0]]);
6811
+ const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _272 => _272.style, 'optionalAccess', _273 => _273.fontName]) && b.style.fontName !== bodyFace && b.bbox.height <= (_nullishCoalesce(b.style.fontSize, () => ( 0))) * 1.6 && b.text.trim().length >= 5 && b.text.trim().length <= 80);
6782
6812
  const groups = /* @__PURE__ */ new Map();
6783
6813
  for (const b of candidates) {
6784
6814
  const key = `${b.style.fontName}:${b.style.fontSize}`;
@@ -6814,19 +6844,19 @@ function detectPageLeadHeadings(blocks) {
6814
6844
  for (const page of byPage.values()) {
6815
6845
  const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
6816
6846
  const [first, second, third] = content;
6817
- if (!_optionalChain([first, 'optionalAccess', _272 => _272.bbox]) || !first.text || !_optionalChain([first, 'access', _273 => _273.style, 'optionalAccess', _274 => _274.fontSize]) || !second) continue;
6847
+ if (!_optionalChain([first, 'optionalAccess', _274 => _274.bbox]) || !first.text || !_optionalChain([first, 'access', _275 => _275.style, 'optionalAccess', _276 => _276.fontSize]) || !second) continue;
6818
6848
  const firstText = first.text.trim();
6819
6849
  const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
6820
6850
  const hasImage = page.some((b) => b.type === "image");
6821
- const firstIsTitle = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 1.6 && (/^(?:CONTENTS|Table of Contents)$/i.test(firstText) || hasImage && /^[A-Z]/.test(firstText) && !captionLike.test(firstText) && second.type === "paragraph" && /^[A-Z]/.test(_nullishCoalesce(_optionalChain([second, 'access', _275 => _275.text, 'optionalAccess', _276 => _276.trim, 'call', _277 => _277()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _278 => _278.text, 'optionalAccess', _279 => _279.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
6851
+ const firstIsTitle = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 1.6 && (/^(?:CONTENTS|Table of Contents)$/i.test(firstText) || hasImage && /^[A-Z]/.test(firstText) && !captionLike.test(firstText) && second.type === "paragraph" && /^[A-Z]/.test(_nullishCoalesce(_optionalChain([second, 'access', _277 => _277.text, 'optionalAccess', _278 => _278.trim, 'call', _279 => _279()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _280 => _280.text, 'optionalAccess', _281 => _281.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
6822
6852
  const firstAboveProse = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 2 && second.type === "paragraph" && second.bbox && second.bbox.height >= first.style.fontSize * 4 && Math.abs(first.bbox.x - second.bbox.x) <= first.style.fontSize * 2 && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize * 2 && !captionLike.test(firstText) && !/^(?:doi:|https?:|www\.)/i.test(firstText);
6823
- const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _280 => _280.text, 'optionalAccess', _281 => _281.length]), () => ( 0))) >= 100;
6853
+ const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _282 => _282.text, 'optionalAccess', _283 => _283.length]), () => ( 0))) >= 100;
6824
6854
  if (firstIsTitle || firstAboveProse || firstIsSection) {
6825
6855
  first.type = "heading";
6826
6856
  first.level = 1;
6827
6857
  }
6828
- if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _282 => _282.style, 'optionalAccess', _283 => _283.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _284 => _284.text]) || !third.bbox || second.text.trim().length < 5 || second.text.trim().length > 80 || captionLike.test(second.text.trim()) || /^(?:doi:|https?:)/i.test(second.text.trim()) || second.bbox.height > second.style.fontSize * 1.6 || Math.abs(second.bbox.x - third.bbox.x) > 30) continue;
6829
- const distinctFace = _optionalChain([third, 'access', _285 => _285.style, 'optionalAccess', _286 => _286.fontName]) !== second.style.fontName;
6858
+ if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _284 => _284.style, 'optionalAccess', _285 => _285.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _286 => _286.text]) || !third.bbox || second.text.trim().length < 5 || second.text.trim().length > 80 || captionLike.test(second.text.trim()) || /^(?:doi:|https?:)/i.test(second.text.trim()) || second.bbox.height > second.style.fontSize * 1.6 || Math.abs(second.bbox.x - third.bbox.x) > 30) continue;
6859
+ const distinctFace = _optionalChain([third, 'access', _287 => _287.style, 'optionalAccess', _288 => _288.fontName]) !== second.style.fontName;
6830
6860
  const namedContents = /^Table of Contents$/i.test(second.text.trim());
6831
6861
  if (distinctFace && third.text.length >= 60 || namedContents) {
6832
6862
  second.type = "heading";
@@ -6837,24 +6867,24 @@ function detectPageLeadHeadings(blocks) {
6837
6867
  function refineDocumentStyleHeadings(blocks) {
6838
6868
  const faceChars = /* @__PURE__ */ new Map();
6839
6869
  for (const block of blocks) {
6840
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _287 => _287.style, 'optionalAccess', _288 => _288.fontName])) continue;
6870
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _289 => _289.style, 'optionalAccess', _290 => _290.fontName])) continue;
6841
6871
  faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
6842
6872
  }
6843
6873
  const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
6844
6874
  if (!bodyFace || !bodyChars || bodyChars < 300) return;
6845
6875
  for (let i = 0; i < blocks.length; i++) {
6846
6876
  const block = blocks[i];
6847
- const text = _nullishCoalesce(_optionalChain([block, 'access', _289 => _289.text, 'optionalAccess', _290 => _290.trim, 'call', _291 => _291()]), () => ( ""));
6877
+ const text = _nullishCoalesce(_optionalChain([block, 'access', _291 => _291.text, 'optionalAccess', _292 => _292.trim, 'call', _293 => _293()]), () => ( ""));
6848
6878
  if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
6849
6879
  block.type = "paragraph";
6850
6880
  block.level = void 0;
6851
6881
  continue;
6852
6882
  }
6853
6883
  const box = block.bbox, style = block.style;
6854
- if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _292 => _292.fontName]) || !style.fontSize || style.fontName === bodyFace || (_nullishCoalesce(faceChars.get(style.fontName), () => ( 0))) > bodyChars * 0.25 || text.length < 3 || text.length > 70 || text.includes("\n") || box.height > style.fontSize * 1.6 || /^(?:table|figure|fig\.?|source|doi:|arxiv:|https?:|www\.|[•●○▪▫⮚*∗†])/i.test(text) || /(?:https?:\/\/|www\.|@|[=¼≪þ])/i.test(text) || /^definition\s+\d+[.:]?\s+.*\b(?:is|are|means)\b/i.test(text) || /^[\d\s.,:%+\-–]+$/.test(text)) continue;
6884
+ if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _294 => _294.fontName]) || !style.fontSize || style.fontName === bodyFace || (_nullishCoalesce(faceChars.get(style.fontName), () => ( 0))) > bodyChars * 0.25 || text.length < 3 || text.length > 70 || text.includes("\n") || box.height > style.fontSize * 1.6 || /^(?:table|figure|fig\.?|source|doi:|arxiv:|https?:|www\.|[•●○▪▫⮚*∗†])/i.test(text) || /(?:https?:\/\/|www\.|@|[=¼≪þ])/i.test(text) || /^definition\s+\d+[.:]?\s+.*\b(?:is|are|means)\b/i.test(text) || /^[\d\s.,:%+\-–]+$/.test(text)) continue;
6855
6885
  const previous = blocks[i - 1], next = blocks[i + 1];
6856
- const pb = _optionalChain([previous, 'optionalAccess', _293 => _293.bbox]), nb = _optionalChain([next, 'optionalAccess', _294 => _294.bbox]);
6857
- if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _295 => _295.style, 'optionalAccess', _296 => _296.fontName]) !== bodyFace || !next.text || next.text.length < 40 || style.fontSize < (_nullishCoalesce(next.style.fontSize, () => ( 0))) * 0.95 || pb.y - (box.y + box.height) < style.fontSize * 0.5 || box.y - (nb.y + nb.height) < 0 || box.y - (nb.y + nb.height) > style.fontSize * 2 || box.x + box.width / 2 < nb.x - 10 || box.x + box.width / 2 > nb.x + nb.width + 10) continue;
6886
+ const pb = _optionalChain([previous, 'optionalAccess', _295 => _295.bbox]), nb = _optionalChain([next, 'optionalAccess', _296 => _296.bbox]);
6887
+ if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _297 => _297.style, 'optionalAccess', _298 => _298.fontName]) !== bodyFace || !next.text || next.text.length < 40 || style.fontSize < (_nullishCoalesce(next.style.fontSize, () => ( 0))) * 0.95 || pb.y - (box.y + box.height) < style.fontSize * 0.5 || box.y - (nb.y + nb.height) < 0 || box.y - (nb.y + nb.height) > style.fontSize * 2 || box.x + box.width / 2 < nb.x - 10 || box.x + box.width / 2 > nb.x + nb.width + 10) continue;
6858
6888
  block.type = "heading";
6859
6889
  block.level = 2;
6860
6890
  }
@@ -6904,7 +6934,7 @@ function detectMarkerHeadings(blocks) {
6904
6934
  block.level = 4;
6905
6935
  continue;
6906
6936
  }
6907
- if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _297 => _297.style, 'optionalAccess', _298 => _298.fontSize])) {
6937
+ if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _299 => _299.style, 'optionalAccess', _300 => _300.fontSize])) {
6908
6938
  const prev = blocks[i - 1];
6909
6939
  const next = blocks[i + 1];
6910
6940
  const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
@@ -6945,7 +6975,7 @@ function detectTableCaptions(blocks) {
6945
6975
  block.table.caption = blocks[i - 1].text.trim();
6946
6976
  blocks.splice(i - 1, 1);
6947
6977
  i--;
6948
- } else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _299 => _299[i + 2], 'optionalAccess', _300 => _300.type]) !== "table") {
6978
+ } else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _301 => _301[i + 2], 'optionalAccess', _302 => _302.type]) !== "table") {
6949
6979
  const cap = blocks[i + 1].bbox, tbl = block.bbox;
6950
6980
  block.table.caption = blocks[i + 1].text.trim();
6951
6981
  if (cap && tbl && cap.y + cap.height <= tbl.y + 1) block.table.captionBelow = true;
@@ -7183,7 +7213,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
7183
7213
  const bottomEntries = [];
7184
7214
  for (let bi = 0; bi < blocks.length; bi++) {
7185
7215
  const b = blocks[bi];
7186
- const text = !tables ? _optionalChain([b, 'access', _301 => _301.text, 'optionalAccess', _302 => _302.trim, 'call', _303 => _303()]) : b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean).join(" | ") : void 0;
7216
+ const text = !tables ? _optionalChain([b, 'access', _303 => _303.text, 'optionalAccess', _304 => _304.trim, 'call', _305 => _305()]) : b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean).join(" | ") : void 0;
7187
7217
  if (!b.bbox || !b.pageNumber || !text) continue;
7188
7218
  const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
7189
7219
  if (!ph) continue;
@@ -7216,7 +7246,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
7216
7246
  for (const [p, count] of patternCount) {
7217
7247
  const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
7218
7248
  const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
7219
- const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _304 => _304.get, 'call', _305 => _305(p), 'optionalAccess', _306 => _306.size]), () => ( 0))) > 1;
7249
+ const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _306 => _306.get, 'call', _307 => _307(p), 'optionalAccess', _308 => _308.size]), () => ( 0))) > 1;
7220
7250
  const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
7221
7251
  const dense = pages.length >= span2 * 0.4;
7222
7252
  const loose = looseVaryingNumber(occ, entries === topEntries) && (entries === bottomEntries || dense || tracksPages(occ));
@@ -7228,8 +7258,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
7228
7258
  for (const e of entries) {
7229
7259
  const norm = e.text.replace(/\d+/g, "#");
7230
7260
  if (!repeatedPatterns.has(norm)) continue;
7231
- const noteMark = _optionalChain([e, 'access', _307 => _307.text, 'access', _308 => _308.match, 'call', _309 => _309(/^\d{1,3}\)/), 'optionalAccess', _310 => _310[0]]);
7232
- if (noteMark && _optionalChain([notes, 'optionalAccess', _311 => _311.get, 'call', _312 => _312(e.page), 'optionalAccess', _313 => _313.marks, 'access', _314 => _314.some, 'call', _315 => _315((m) => m.mark === noteMark)])) continue;
7261
+ const noteMark = _optionalChain([e, 'access', _309 => _309.text, 'access', _310 => _310.match, 'call', _311 => _311(/^\d{1,3}\)/), 'optionalAccess', _312 => _312[0]]);
7262
+ if (noteMark && _optionalChain([notes, 'optionalAccess', _313 => _313.get, 'call', _314 => _314(e.page), 'optionalAccess', _315 => _315.marks, 'access', _316 => _316.some, 'call', _317 => _317((m) => m.mark === noteMark)])) continue;
7233
7263
  const cand = blocks[e.blockIdx];
7234
7264
  const cb = cand.bbox;
7235
7265
  const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::]|\*\s+\S)/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
@@ -7243,7 +7273,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
7243
7273
  if (bi === e.blockIdx) continue;
7244
7274
  const o = blocks[bi];
7245
7275
  if (!o.bbox || o.bbox.page !== cb.page) continue;
7246
- const oNorm = _optionalChain([o, 'access', _316 => _316.text, 'optionalAccess', _317 => _317.trim, 'call', _318 => _318(), 'access', _319 => _319.replace, 'call', _320 => _320(/\d+/g, "#")]);
7276
+ const oNorm = _optionalChain([o, 'access', _318 => _318.text, 'optionalAccess', _319 => _319.trim, 'call', _320 => _320(), 'access', _321 => _321.replace, 'call', _322 => _322(/\d+/g, "#")]);
7247
7277
  if (oNorm && repeatedPatterns.has(oNorm)) continue;
7248
7278
  const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
7249
7279
  if (overlap2 >= cb.height * 0.5) {
@@ -7371,7 +7401,7 @@ function recordRowRules(table, cells, bbox, hs) {
7371
7401
  function markImageCell(cell) {
7372
7402
  IMAGE_CELLS.add(cell);
7373
7403
  }
7374
- var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _321 => _321.text, 'optionalAccess', _322 => _322.trim, 'call', _323 => _323()]) && !_optionalChain([cell, 'access', _324 => _324.blocks, 'optionalAccess', _325 => _325.length]) && !IMAGE_CELLS.has(cell);
7404
+ var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _323 => _323.text, 'optionalAccess', _324 => _324.trim, 'call', _325 => _325()]) && !_optionalChain([cell, 'access', _326 => _326.blocks, 'optionalAccess', _327 => _327.length]) && !IMAGE_CELLS.has(cell);
7375
7405
  function trimTable(table) {
7376
7406
  let cols = table.cols;
7377
7407
  while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
@@ -7387,7 +7417,7 @@ function trimTable(table) {
7387
7417
  function trimTrailingEmptyTableCols(blocks) {
7388
7418
  for (const b of blocks) {
7389
7419
  if (b.type !== "table" || !b.table) continue;
7390
- for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _326 => _326.blocks, 'optionalAccess', _327 => _327.length])) trimTrailingEmptyTableCols(cell.blocks);
7420
+ for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _328 => _328.blocks, 'optionalAccess', _329 => _329.length])) trimTrailingEmptyTableCols(cell.blocks);
7391
7421
  trimTable(b.table);
7392
7422
  }
7393
7423
  }
@@ -7407,7 +7437,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
7407
7437
  }
7408
7438
  const ok = owner.every((row) => {
7409
7439
  const o = row[c];
7410
- return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _328 => _328.blocks, 'optionalAccess', _329 => _329.length]));
7440
+ return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _330 => _330.blocks, 'optionalAccess', _331 => _331.length]));
7411
7441
  });
7412
7442
  if (!ok) continue;
7413
7443
  const spanning = /* @__PURE__ */ new Set();
@@ -7434,7 +7464,7 @@ var multiply = (m, t) => [
7434
7464
  m[1] * t[4] + m[3] * t[5] + m[5]
7435
7465
  ];
7436
7466
  function hollowCircle(image) {
7437
- if (!_optionalChain([image, 'optionalAccess', _330 => _330.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128 || Math.abs(image.width - image.height) > Math.min(image.width, image.height) * 0.1) return false;
7467
+ if (!_optionalChain([image, 'optionalAccess', _332 => _332.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128 || Math.abs(image.width - image.height) > Math.min(image.width, image.height) * 0.1) return false;
7438
7468
  const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
7439
7469
  const { width, height, data } = image;
7440
7470
  if (!stride || data.length < width * height * stride) return false;
@@ -7499,9 +7529,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
7499
7529
  const op = fnArray[i], args = argsArray[i];
7500
7530
  if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
7501
7531
  stack.push({ ctm, alpha, clip, unknownClip });
7502
- const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _331 => _331[0]]) : void 0;
7532
+ const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _333 => _333[0]]) : void 0;
7503
7533
  if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
7504
- const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _332 => _332[1]]) : void 0;
7534
+ const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _334 => _334[1]]) : void 0;
7505
7535
  if (Array.isArray(bounds) && bounds.length === 4) {
7506
7536
  const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
7507
7537
  if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
@@ -7509,17 +7539,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
7509
7539
  }
7510
7540
  } else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
7511
7541
  const state = stack.pop();
7512
- ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _333 => _333.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
7513
- alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _334 => _334.alpha]), () => ( 1));
7514
- clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _335 => _335.clip]), () => ( null));
7515
- unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _336 => _336.unknownClip]), () => ( false));
7542
+ ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _335 => _335.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
7543
+ alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _336 => _336.alpha]), () => ( 1));
7544
+ clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _337 => _337.clip]), () => ( null));
7545
+ unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _338 => _338.unknownClip]), () => ( false));
7516
7546
  } else if (op === _pdfmjs.OPS.setGState) {
7517
- for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _337 => _337[0]]), () => ( []))) {
7547
+ for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _339 => _339[0]]), () => ( []))) {
7518
7548
  if (key === "ca") alpha = typeof value === "number" ? value : 0;
7519
7549
  }
7520
7550
  } else if (op === _pdfmjs.OPS.constructPath) {
7521
7551
  const [operations, coordinates] = args;
7522
- pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _338 => _338.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _339 => _339.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
7552
+ pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _340 => _340.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _341 => _341.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
7523
7553
  } else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
7524
7554
  else if ([
7525
7555
  _pdfmjs.OPS.endPath,
@@ -7539,7 +7569,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
7539
7569
  pendingClip = false;
7540
7570
  pathRect = void 0;
7541
7571
  } else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
7542
- else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _340 => _340[0]]) === "string") {
7572
+ else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _342 => _342[0]]) === "string") {
7543
7573
  if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
7544
7574
  const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
7545
7575
  if (!box || ctm[1] !== 0 || ctm[2] !== 0 || alpha < 0.99 || unknownClip || clip && (box.x1 + (box.x2 - box.x1) * 0.03 < clip.x1 || box.y1 + (box.y2 - box.y1) * 0.03 < clip.y1 || box.x2 - (box.x2 - box.x1) * 0.03 > clip.x2 || box.y2 - (box.y2 - box.y1) * 0.03 > clip.y2)) continue;
@@ -7558,14 +7588,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
7558
7588
  const line = items.filter((item) => !item.isHidden && item.fontSize > 0 && item.x >= box.x2 && item.x - box.x2 <= item.fontSize * 0.7 && Math.abs(item.y + item.h / 2 - (box.y1 + box.y2) / 2) <= item.fontSize * 0.4 && height >= item.fontSize * 0.5 && height <= item.fontSize * 1.2).sort((a, b) => a.x - b.x)[0];
7559
7589
  if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
7560
7590
  const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
7561
- if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _341 => _341.text, 'access', _342 => _342.match, 'call', _343 => _343(/\p{L}/gu), 'optionalAccess', _344 => _344.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
7591
+ if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _343 => _343.text, 'access', _344 => _344.match, 'call', _345 => _345(/\p{L}/gu), 'optionalAccess', _346 => _346.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
7562
7592
  candidates.push({ id, x: box.x1, width, line });
7563
7593
  }
7564
7594
  let restored = 0;
7565
7595
  const used = /* @__PURE__ */ new Set();
7566
7596
  for (const candidate of candidates) {
7567
7597
  const same = candidates.filter((other) => other.id === candidate.id && other.line !== candidate.line && Math.abs(other.line.x - candidate.line.x) <= 1 && Math.abs(other.x - candidate.x) <= 1 && Math.abs(other.width - candidate.width) <= 1 && other.line.fontSize === candidate.line.fontSize && Math.abs(other.line.y - candidate.line.y) >= candidate.line.fontSize * 2);
7568
- const numbered = items.filter((item) => !item.isHidden && /^[①-⑮]\s*/.test(item.text.trim()) && item.fontName === candidate.line.fontName && item.fontSize === candidate.line.fontSize && Math.abs(item.x - candidate.x) <= 1 && (_nullishCoalesce(_optionalChain([item, 'access', _345 => _345.text, 'access', _346 => _346.match, 'call', _347 => _347(/\p{L}/gu), 'optionalAccess', _348 => _348.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
7598
+ const numbered = items.filter((item) => !item.isHidden && /^[①-⑮]\s*/.test(item.text.trim()) && item.fontName === candidate.line.fontName && item.fontSize === candidate.line.fontSize && Math.abs(item.x - candidate.x) <= 1 && (_nullishCoalesce(_optionalChain([item, 'access', _347 => _347.text, 'access', _348 => _348.match, 'call', _349 => _349(/\p{L}/gu), 'optionalAccess', _350 => _350.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
7569
7599
  const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
7570
7600
  if (!same.length && !numberedList || used.has(candidate.line)) continue;
7571
7601
  if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
@@ -7631,7 +7661,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
7631
7661
  return units;
7632
7662
  }
7633
7663
  function arrowDirection(image) {
7634
- if (!_optionalChain([image, 'optionalAccess', _349 => _349.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
7664
+ if (!_optionalChain([image, 'optionalAccess', _351 => _351.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
7635
7665
  const { width, height, data } = image;
7636
7666
  const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
7637
7667
  if (!stride || data.length < width * height * stride) return 0;
@@ -7699,7 +7729,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
7699
7729
  function removeSideTabs(blocks, pageWidths) {
7700
7730
  const edges = /* @__PURE__ */ new Map();
7701
7731
  for (const b of blocks) {
7702
- if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _350 => _350.text, 'optionalAccess', _351 => _351.trim, 'call', _352 => _352()]), () => ( ""))].length <= MAX_CHARS) continue;
7732
+ if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _352 => _352.text, 'optionalAccess', _353 => _353.trim, 'call', _354 => _354()]), () => ( ""))].length <= MAX_CHARS) continue;
7703
7733
  const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
7704
7734
  e.lefts.push(b.bbox.x);
7705
7735
  e.rights.push(b.bbox.x + b.bbox.width);
@@ -7715,7 +7745,7 @@ function removeSideTabs(blocks, pageWidths) {
7715
7745
  const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
7716
7746
  const key = (b) => {
7717
7747
  const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
7718
- const text = _optionalChain([b, 'access', _353 => _353.text, 'optionalAccess', _354 => _354.trim, 'call', _355 => _355()]);
7748
+ const text = _optionalChain([b, 'access', _355 => _355.text, 'optionalAccess', _356 => _356.trim, 'call', _357 => _357()]);
7719
7749
  const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
7720
7750
  if (b.type === "table") {
7721
7751
  if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
@@ -8151,16 +8181,16 @@ function isProseSpread(items) {
8151
8181
  for (let i = 1; i < sorted.length; i++) {
8152
8182
  gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
8153
8183
  }
8154
- const maxGap = _chunkOMGCVZ4Wcjs.safeMax.call(void 0, gaps);
8184
+ const maxGap = _chunkYOLFNCQQcjs.safeMax.call(void 0, gaps);
8155
8185
  const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
8156
8186
  if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
8157
- const minGap = _chunkOMGCVZ4Wcjs.safeMin.call(void 0, gaps);
8187
+ const minGap = _chunkYOLFNCQQcjs.safeMin.call(void 0, gaps);
8158
8188
  return minGap > 0 && maxGap - minGap <= Math.max(2, maxGap * 0.15) && (items.filter((i) => /^\P{L}*\p{Ll}/u.test(i.text)).length * 2 >= items.length || items.some((i) => /\p{L}[,.;:]["”’)]?$/u.test(i.text)));
8159
8189
  }
8160
8190
  function detectColumns(yLines) {
8161
8191
  const allItems = yLines.flat();
8162
8192
  if (allItems.length === 0) return null;
8163
- const pageWidth = _chunkOMGCVZ4Wcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkOMGCVZ4Wcjs.safeMin.call(void 0, allItems.map((i) => i.x));
8193
+ const pageWidth = _chunkYOLFNCQQcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkYOLFNCQQcjs.safeMin.call(void 0, allItems.map((i) => i.x));
8164
8194
  if (pageWidth < 100) return null;
8165
8195
  let bigoLineIdx = -1;
8166
8196
  for (let i = 0; i < yLines.length; i++) {
@@ -8385,7 +8415,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
8385
8415
  var UNDER_BOX_PAIR_OVERLAP = 0.8;
8386
8416
  function markUnderlineItems(items, horizontals, verticals, nonRules) {
8387
8417
  const underlines = [];
8388
- if (_optionalChain([nonRules, 'optionalAccess', _356 => _356.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
8418
+ if (_optionalChain([nonRules, 'optionalAccess', _358 => _358.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
8389
8419
  if (items.length === 0 || horizontals.length === 0) return underlines;
8390
8420
  const tightOwners = /* @__PURE__ */ new Map();
8391
8421
  const tightlyOwned = (line) => {
@@ -8491,7 +8521,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
8491
8521
  if (ow <= 0) continue;
8492
8522
  const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
8493
8523
  if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
8494
- const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _357 => _357.reduce, 'call', _358 => _358((sum, item) => {
8524
+ const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _359 => _359.reduce, 'call', _360 => _360((sum, item) => {
8495
8525
  const below = item.y - o.y1;
8496
8526
  if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
8497
8527
  return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
@@ -8558,13 +8588,13 @@ function partTex(group) {
8558
8588
  const base = Math.min(...g.filter((i) => i.fontSize >= size * SCRIPT_SIZE_RATIO).map((i) => i.y));
8559
8589
  let s = "", run = "";
8560
8590
  const flush = () => {
8561
- if (run) s += _chunkB5M676H3cjs.toTex.call(void 0, run);
8591
+ if (run) s += _chunkT7Z554HTcjs.toTex.call(void 0, run);
8562
8592
  run = "";
8563
8593
  };
8564
8594
  g.forEach((it, k) => {
8565
8595
  if (it.fontSize < size * SCRIPT_SIZE_RATIO && it.y - base >= size * SCRIPT_RISE_EM) {
8566
8596
  flush();
8567
- s += `^{${_chunkB5M676H3cjs.toTex.call(void 0, it.text)}}`;
8597
+ s += `^{${_chunkT7Z554HTcjs.toTex.call(void 0, it.text)}}`;
8568
8598
  return;
8569
8599
  }
8570
8600
  if (k && it.x - (g[k - 1].x + g[k - 1].w) > spaceGapThreshold(it.fontSize)) run += " ";
@@ -8636,6 +8666,7 @@ function headerLineAbove(free, colXs, top) {
8636
8666
  if (baseY - top > fs * MAX_GAP_K) return null;
8637
8667
  const text = [...line].sort((a, b) => a.x - b.x).map((it) => it.text).join(" ").trim();
8638
8668
  if (/^(?:Table|Figure|Fig\.|Chart|Exhibit|Diagram|Source|Note|<?표|<?그림)\s*[\dIVX]/i.test(text)) return null;
8669
+ if (/\(단위[::]/.test(text.replace(/\s+/g, ""))) return null;
8639
8670
  if (line.some((it) => it.seq === void 0 || it.x < x1 - EDGE_TOL || it.x + it.w > x2 + EDGE_TOL)) return null;
8640
8671
  if (above.some((it) => !line.includes(it) && Math.abs(it.y - baseY) <= fs * 0.5)) return null;
8641
8672
  const cols = colXs.slice(1).map(() => []);
@@ -8736,12 +8767,12 @@ function rebuildUnitLine(items, grid) {
8736
8767
  function prependUnitRow(cells, cols, line, usedItems) {
8737
8768
  const text = cleanCellText(line.map((item) => item.text).join(""));
8738
8769
  cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
8739
- for (const cell of cells[0]) _chunkB5M676H3cjs.CELL_EDGES.set(cell, NO_EDGES);
8770
+ for (const cell of cells[0]) _chunkT7Z554HTcjs.CELL_EDGES.set(cell, NO_EDGES);
8740
8771
  for (const item of line) usedItems.add(item);
8741
8772
  }
8742
8773
  function attachUnitRow(items, grid, cells, cols, usedItems) {
8743
8774
  const all = cells.flat();
8744
- if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _359 => _359[0], 'optionalAccess', _360 => _360[0], 'optionalAccess', _361 => _361.text]), () => ( "")))) return false;
8775
+ if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _361 => _361[0], 'optionalAccess', _362 => _362[0], 'optionalAccess', _363 => _363.text]), () => ( "")))) return false;
8745
8776
  const above = items.filter((it) => !usedItems.has(it) && it.y >= grid.bbox.y2 && it.y - grid.bbox.y2 <= 8 && it.x >= grid.bbox.x1 - 3 && it.x + it.w <= grid.bbox.x2 + 3);
8746
8777
  let nearest = Infinity;
8747
8778
  for (const it of above) nearest = Math.min(nearest, it.y);
@@ -8776,7 +8807,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
8776
8807
  let hs = horizontals, vs = verticals;
8777
8808
  const restored = [];
8778
8809
  for (const grid of clipGrids) {
8779
- if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _362 => _362.cells, 'optionalAccess', _363 => _363.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
8810
+ if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _364 => _364.cells, 'optionalAccess', _365 => _365.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
8780
8811
  const { x1, x2, y1: mid, y2: top } = grid.bbox;
8781
8812
  if (!grid.cells.every((c) => fillRects.some((f) => near2(f.x1, c.bbox.x1) && near2(f.x2, c.bbox.x2) && near2(f.y1, c.bbox.y1) && near2(f.y2, c.bbox.y2)))) continue;
8782
8813
  const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
@@ -9240,7 +9271,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
9240
9271
  const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
9241
9272
  const runs = [];
9242
9273
  for (const item of [...line].sort((a, b) => a.x - b.x)) {
9243
- const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _364 => _364[run.length - 1]]);
9274
+ const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _366 => _366[run.length - 1]]);
9244
9275
  if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
9245
9276
  else runs.push([item]);
9246
9277
  }
@@ -9284,7 +9315,7 @@ function groupFrameParagraphUnits(units, frames) {
9284
9315
  for (const unit of units) for (const block of unit) source.set(block, unit);
9285
9316
  const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
9286
9317
  for (const frame of frames) {
9287
- if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _365 => _365.get, 'call', _366 => _366(block), 'optionalAccess', _367 => _367.length]) !== 1)) continue;
9318
+ if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _367 => _367.get, 'call', _368 => _368(block), 'optionalAccess', _369 => _369.length]) !== 1)) continue;
9288
9319
  for (const block of frame) members.set(block, frame);
9289
9320
  }
9290
9321
  const out = [];
@@ -9297,7 +9328,7 @@ function groupFrameParagraphUnits(units, frames) {
9297
9328
  }
9298
9329
  }
9299
9330
  for (const unit of out) {
9300
- if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _368 => _368.get, 'call', _369 => _369(unit[0]), 'optionalAccess', _370 => _370.blocks]) === unit) continue;
9331
+ if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _370 => _370.get, 'call', _371 => _371(unit[0]), 'optionalAccess', _372 => _372.blocks]) === unit) continue;
9301
9332
  const bs = unit.map((b) => b.bbox).filter((b) => !!b);
9302
9333
  if (bs.length !== unit.length) continue;
9303
9334
  const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
@@ -9314,14 +9345,14 @@ function groupFrameParagraphUnits(units, frames) {
9314
9345
  function recordFrameTitle(table, source, pageNum) {
9315
9346
  if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
9316
9347
  const cells = table.cells[0];
9317
- if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _371 => _371.blocks, 'optionalAccess', _372 => _372.length]) || c.text.includes("\n"))) return;
9348
+ if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _373 => _373.blocks, 'optionalAccess', _374 => _374.length]) || c.text.includes("\n"))) return;
9318
9349
  const [label, spacer, title] = cells;
9319
9350
  if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
9320
9351
  if (cells.some((c) => {
9321
- const e = _chunkB5M676H3cjs.CELL_EDGES.get(c);
9352
+ const e = _chunkT7Z554HTcjs.CELL_EDGES.get(c);
9322
9353
  return !e || e.t || e.b || e.l || e.r;
9323
9354
  })) return;
9324
- const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _373 => _373.fontSize]), () => ( 0));
9355
+ const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _375 => _375.fontSize]), () => ( 0));
9325
9356
  if (!xs || xs.length !== 4 || fs <= 0) return;
9326
9357
  const width = xs[3] - xs[0], gap = xs[2] - xs[1];
9327
9358
  if (width < fs * 12 || gap <= 0 || gap > fs * 1.5 || xs[1] - xs[0] > width * 0.25 || xs[3] - xs[2] < width * 0.6) return;
@@ -9379,7 +9410,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
9379
9410
  const extended = [];
9380
9411
  for (let i = 0; i < clipGrids.length; i++) {
9381
9412
  const c = clipGrids[i], parent = c.clipParent;
9382
- if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _374 => _374.cells, 'optionalAccess', _375 => _375.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
9413
+ if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _376 => _376.cells, 'optionalAccess', _377 => _377.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
9383
9414
  if (!clipGrids.some((g) => g.rowYs.length === 2 && g.colXs.length === 2 && near2(g.bbox.x1, parent.x1) && near2(g.bbox.x2, parent.x2) && near2(g.bbox.y1, parent.y1) && near2(g.bbox.y2, parent.y2))) continue;
9384
9415
  if (!c.cells.every((cell) => fills.some((f) => near2(f.x1, cell.bbox.x1) && near2(f.x2, cell.bbox.x2) && near2(f.y1, cell.bbox.y1) && near2(f.y2, cell.bbox.y2)))) continue;
9385
9416
  const host = lineGrids.find((l) => l.rowYs.length > 2 && l.colXs.length === c.colXs.length && c.colXs.every((x, k) => near2(x, l.colXs[k])) && c.rowYs.every((y, k) => near2(y, l.rowYs[k])) && contains4(parent, l.bbox) && l.rowYs.every((y) => horizontals.some((h) => near2(h.y1, y) && near2(h.x1, l.bbox.x1) && near2(h.x2, l.bbox.x2))) && l.colXs.every((x) => verticals.some((v) => near2(v.x1, x) && v.y1 <= l.bbox.y1 + 1.5 && v.y2 >= l.bbox.y2 - 1.5)) && !clipGrids.some((o) => o !== c && !contains4(o.bbox, l.bbox) && Math.min(o.bbox.x2, l.bbox.x2) > Math.max(o.bbox.x1, l.bbox.x1) && Math.min(o.bbox.y2, l.bbox.y2) > Math.max(o.bbox.y1, l.bbox.y1)));
@@ -9402,7 +9433,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
9402
9433
  bbox: computeBBox(items, pageNum),
9403
9434
  style: dominantStyle(items)
9404
9435
  });
9405
- const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _376 => _376.has, 'call', _377 => _377(g)])).map((g) => ({
9436
+ const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _378 => _378.has, 'call', _379 => _379(g)])).map((g) => ({
9406
9437
  type: "paragraph",
9407
9438
  text: g.text.trim(),
9408
9439
  pageNumber: pageNum,
@@ -9411,7 +9442,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
9411
9442
  }));
9412
9443
  const groups = /* @__PURE__ */ new Map();
9413
9444
  for (const g of ordered) {
9414
- const cap = _optionalChain([caps, 'optionalAccess', _378 => _378.get, 'call', _379 => _379(g)]);
9445
+ const cap = _optionalChain([caps, 'optionalAccess', _380 => _380.get, 'call', _381 => _381(g)]);
9415
9446
  if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
9416
9447
  }
9417
9448
  for (const [cap, glyphs] of groups) {
@@ -9442,7 +9473,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
9442
9473
  let prev = null;
9443
9474
  for (const line of streamLines(items)) {
9444
9475
  lex.addLine(mergeLineSimple(line));
9445
- const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _380 => _380(line), 'optionalAccess', _381 => _381.fontSize]), () => ( 0));
9476
+ const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _382 => _382(line), 'optionalAccess', _383 => _383.fontSize]), () => ( 0));
9446
9477
  const left = Math.min(...line.map((i) => i.x)), right = Math.max(...line.map((i) => i.x + i.w));
9447
9478
  const y = line.reduce((n, i) => n + i.y, 0) / line.length;
9448
9479
  const wide = fs > 0 && right - left >= 12 * fs;
@@ -9456,7 +9487,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
9456
9487
  const filled = fillBlanks(items, horizontals, verticals);
9457
9488
  items = filled.items;
9458
9489
  horizontals = filled.horizontals;
9459
- const prevPage = _optionalChain([carry, 'optionalAccess', _382 => _382.page]) === pageNum - 1 ? carry.clip : void 0;
9490
+ const prevPage = _optionalChain([carry, 'optionalAccess', _384 => _384.page]) === pageNum - 1 ? carry.clip : void 0;
9460
9491
  const clipResult = detectTables ? buildClipCellGrids(extracted.clipRects, horizontals, verticals, pageWidth, pageHeight, items.map((it) => ({ x: it.x + it.w / 2, y: it.y + it.h / 2 })), extracted.fillRects, prevPage) : { grids: [], containers: [], page: void 0 };
9461
9492
  if (carry) {
9462
9493
  carry.page = pageNum;
@@ -9713,14 +9744,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
9713
9744
  if (!assignedItems.has(textItems[ti])) usedItems.delete(owners[ti]);
9714
9745
  }
9715
9746
  }
9716
- if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _383 => _383[0], 'optionalAccess', _384 => _384[0], 'optionalAccess', _385 => _385.text]), () => ( "")))) {
9747
+ if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _385 => _385[0], 'optionalAccess', _386 => _386[0], 'optionalAccess', _387 => _387.text]), () => ( "")))) {
9717
9748
  prependUnitRow(finalGrid, numCols, unitLine, usedItems);
9718
9749
  finalRows++;
9719
9750
  }
9720
9751
  if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
9721
9752
  let semanticOneColumn = false;
9722
9753
  if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
9723
- const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _386 => _386[0], 'optionalAccess', _387 => _387.text, 'access', _388 => _388.trim, 'call', _389 => _389()]));
9754
+ const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _388 => _388[0], 'optionalAccess', _389 => _389.text, 'access', _390 => _390.trim, 'call', _391 => _391()]));
9724
9755
  if (populatedRows.length >= 4) {
9725
9756
  const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
9726
9757
  const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
@@ -9816,7 +9847,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
9816
9847
  height: grid.bbox.y2 - grid.bbox.y1
9817
9848
  };
9818
9849
  if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
9819
- const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _390 => _390[0], 'optionalAccess', _391 => _391[0], 'optionalAccess', _392 => _392.text]), () => ( ""));
9850
+ const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _392 => _392[0], 'optionalAccess', _393 => _393[0], 'optionalAccess', _394 => _394.text]), () => ( ""));
9820
9851
  const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
9821
9852
  const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
9822
9853
  const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
@@ -9835,8 +9866,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
9835
9866
  }
9836
9867
  }
9837
9868
  if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
9838
- const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _393 => _393.cells, 'access', _394 => _394[0], 'optionalAccess', _395 => _395[0], 'optionalAccess', _396 => _396.blocks]) : void 0;
9839
- if (_optionalChain([paragraphs, 'optionalAccess', _397 => _397.length])) {
9869
+ const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _395 => _395.cells, 'access', _396 => _396[0], 'optionalAccess', _397 => _397[0], 'optionalAccess', _398 => _398.blocks]) : void 0;
9870
+ if (_optionalChain([paragraphs, 'optionalAccess', _399 => _399.length])) {
9840
9871
  blocks.push(...paragraphs);
9841
9872
  frameParagraphUnits.push(paragraphs);
9842
9873
  recordFrameReadingUnit(paragraphs, tableBbox);
@@ -9883,7 +9914,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
9883
9914
  const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
9884
9915
  const b = cr.bbox;
9885
9916
  const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
9886
- return !blocks.some((x) => x.bbox && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2 && (x.type === "paragraph" ? (_nullishCoalesce(_optionalChain([x, 'access', _398 => _398.text, 'optionalAccess', _399 => _399.match, 'call', _400 => _400(/\p{L}/gu), 'optionalAccess', _401 => _401.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _402 => _402.table, 'optionalAccess', _403 => _403.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
9917
+ return !blocks.some((x) => x.bbox && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2 && (x.type === "paragraph" ? (_nullishCoalesce(_optionalChain([x, 'access', _400 => _400.text, 'optionalAccess', _401 => _401.match, 'call', _402 => _402(/\p{L}/gu), 'optionalAccess', _403 => _403.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _404 => _404.table, 'optionalAccess', _405 => _405.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
9887
9918
  });
9888
9919
  if (clusterResults.length > 0) {
9889
9920
  const ciToIdx = /* @__PURE__ */ new Map();
@@ -9920,7 +9951,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
9920
9951
  groupSizes.push(1);
9921
9952
  }
9922
9953
  const allY = remaining.map((i) => i.y);
9923
- const pageH = _chunkOMGCVZ4Wcjs.safeMax.call(void 0, allY) - _chunkOMGCVZ4Wcjs.safeMin.call(void 0, allY);
9954
+ const pageH = _chunkYOLFNCQQcjs.safeMax.call(void 0, allY) - _chunkYOLFNCQQcjs.safeMin.call(void 0, allY);
9924
9955
  const gapThreshold = Math.max(15, pageH * 0.03);
9925
9956
  const sides = frameColumnTextBands(remaining, spanning, gx);
9926
9957
  const textBlocks = [];
@@ -9936,7 +9967,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
9936
9967
  finalTextBlocks.push(...detectListBlocks(textBlocks));
9937
9968
  } else {
9938
9969
  const allY = remaining.map((i) => i.y);
9939
- const pageH = _chunkOMGCVZ4Wcjs.safeMax.call(void 0, allY) - _chunkOMGCVZ4Wcjs.safeMin.call(void 0, allY);
9970
+ const pageH = _chunkYOLFNCQQcjs.safeMax.call(void 0, allY) - _chunkYOLFNCQQcjs.safeMin.call(void 0, allY);
9940
9971
  const gapThreshold = Math.max(15, pageH * 0.03);
9941
9972
  const groups = xyCutOrder(remaining, gapThreshold);
9942
9973
  const textBlocks = [];
@@ -10268,7 +10299,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
10268
10299
  blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
10269
10300
  } else {
10270
10301
  const allY = items.map((i) => i.y);
10271
- const pageHeight = _chunkOMGCVZ4Wcjs.safeMax.call(void 0, allY) - _chunkOMGCVZ4Wcjs.safeMin.call(void 0, allY);
10302
+ const pageHeight = _chunkYOLFNCQQcjs.safeMax.call(void 0, allY) - _chunkYOLFNCQQcjs.safeMin.call(void 0, allY);
10272
10303
  const gapThreshold = Math.max(15, pageHeight * 0.03);
10273
10304
  const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap);
10274
10305
  for (const group of orderedGroups) {
@@ -10300,19 +10331,19 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
10300
10331
  const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
10301
10332
  return overlapW * overlapH >= b.width * b.height * 0.8;
10302
10333
  });
10303
- const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _404 => _404.text, 'optionalAccess', _405 => _405.match, 'call', _406 => _406(/[\p{L}\p{N}]/gu), 'optionalAccess', _407 => _407.length]), () => ( 0))) >= 2);
10334
+ const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _406 => _406.text, 'optionalAccess', _407 => _407.match, 'call', _408 => _408(/[\p{L}\p{N}]/gu), 'optionalAccess', _409 => _409.length]), () => ( 0))) >= 2);
10304
10335
  const axisFragments = rotatedAxisFragments(candidates);
10305
10336
  const accepted = candidates.filter((b) => {
10306
- if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _408 => _408.text, 'optionalAccess', _409 => _409.match, 'call', _410 => _410(/[\p{L}\p{N}]/gu), 'optionalAccess', _411 => _411.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
10337
+ if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _410 => _410.text, 'optionalAccess', _411 => _411.match, 'call', _412 => _412(/[\p{L}\p{N}]/gu), 'optionalAccess', _413 => _413.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
10307
10338
  const t = b.table;
10308
10339
  if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
10309
10340
  const lone = t.cells.filter((row) => row.filter((c) => c.text.trim()).length === 1 && row.some((c) => c.colSpan === t.cols)).length;
10310
10341
  if (t.rows >= 2 && lone * 2 >= t.rows) return false;
10311
10342
  if (t.rows === 1 && t.cols === 1) {
10312
- const text = _nullishCoalesce(_optionalChain([t, 'access', _412 => _412.cells, 'access', _413 => _413[0], 'optionalAccess', _414 => _414[0], 'optionalAccess', _415 => _415.text]), () => ( ""));
10313
- return (_nullishCoalesce(_optionalChain([text, 'access', _416 => _416.match, 'call', _417 => _417(/\n/g), 'optionalAccess', _418 => _418.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _419 => _419.match, 'call', _420 => _420(/\d/g), 'optionalAccess', _421 => _421.length]), () => ( 0))) >= text.length * 0.25;
10343
+ const text = _nullishCoalesce(_optionalChain([t, 'access', _414 => _414.cells, 'access', _415 => _415[0], 'optionalAccess', _416 => _416[0], 'optionalAccess', _417 => _417.text]), () => ( ""));
10344
+ return (_nullishCoalesce(_optionalChain([text, 'access', _418 => _418.match, 'call', _419 => _419(/\n/g), 'optionalAccess', _420 => _420.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _421 => _421.match, 'call', _422 => _422(/\d/g), 'optionalAccess', _423 => _423.length]), () => ( 0))) >= text.length * 0.25;
10314
10345
  }
10315
- const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _422 => _422.cells, 'access', _423 => _423[0], 'optionalAccess', _424 => _424.filter, 'call', _425 => _425((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _426 => _426.length]), () => ( 0));
10346
+ const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _424 => _424.cells, 'access', _425 => _425[0], 'optionalAccess', _426 => _426.filter, 'call', _427 => _427((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _428 => _428.length]), () => ( 0));
10316
10347
  return t.rows >= 2 && t.cols >= 2 && headerLabels >= t.cols * 0.75 && t.cells.slice(1).some((row) => row.filter((c) => c.text.trim()).length >= 2);
10317
10348
  });
10318
10349
  const selected = candidates.flatMap((b) => accepted.includes(b) ? [b] : b.type === "table" && b.table ? rowParagraphs(b).filter((p) => /[\p{L}\p{N}]{2}/u.test(_nullishCoalesce(p.text, () => ( "")))) : []);
@@ -10329,14 +10360,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
10329
10360
  for (const block of selected) {
10330
10361
  if (seen2.has(block)) continue;
10331
10362
  const frame = FRAME_READING_UNITS.get(block);
10332
- const source = _optionalChain([frame, 'optionalAccess', _427 => _427.blocks, 'access', _428 => _428.every, 'call', _429 => _429((member) => selectedSet.has(member))]) ? frame.blocks : [block];
10363
+ const source = _optionalChain([frame, 'optionalAccess', _429 => _429.blocks, 'access', _430 => _430.every, 'call', _431 => _431((member) => selectedSet.has(member))]) ? frame.blocks : [block];
10333
10364
  source.forEach((member) => seen2.add(member));
10334
10365
  const available = source.filter((member) => !hasOriginal(member));
10335
10366
  const units = frame && available.length === source.length && source === frame.blocks ? [{ blocks: available, bbox: frame.bbox, atomic: true }] : available.map((member) => ({ blocks: [member], bbox: member.bbox, atomic: false }));
10336
10367
  for (const unit of units) {
10337
10368
  const b = unit.bbox;
10338
10369
  const index = blocks.findIndex((existing) => {
10339
- const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _430 => _430.get, 'call', _431 => _431(existing), 'optionalAccess', _432 => _432.bbox]), () => ( existing.bbox));
10370
+ const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _432 => _432.get, 'call', _433 => _433(existing), 'optionalAccess', _434 => _434.bbox]), () => ( existing.bbox));
10340
10371
  if (existing.pageNumber !== page || !e) return false;
10341
10372
  const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
10342
10373
  if (placedHere.has(existing) && Math.abs(e.y + e.height / 2 - b.y - b.height / 2) <= Math.min(e.height, b.height) * 0.25) return e.x > b.x;
@@ -10354,16 +10385,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
10354
10385
  }
10355
10386
  function axisTick(block, candidates) {
10356
10387
  const b = block.bbox;
10357
- if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _433 => _433.text, 'optionalAccess', _434 => _434.trim, 'call', _435 => _435()]), () => ( "")))) return false;
10358
- const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _436 => _436.text, 'optionalAccess', _437 => _437.trim, 'call', _438 => _438()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
10388
+ if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _435 => _435.text, 'optionalAccess', _436 => _436.trim, 'call', _437 => _437()]), () => ( "")))) return false;
10389
+ const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _438 => _438.text, 'optionalAccess', _439 => _439.trim, 'call', _440 => _440()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
10359
10390
  const cy = b.y + b.height / 2, right = b.x + b.width;
10360
10391
  const row = numeric.filter((o) => Math.abs(o.bbox.y + o.bbox.height / 2 - cy) <= Math.min(o.bbox.height, b.height) * 0.35);
10361
10392
  const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
10362
10393
  return row.length >= 2 || column.length >= 2;
10363
10394
  }
10364
10395
  function supportedDiagramLabel(block, labels, region) {
10365
- const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _439 => _439.text, 'optionalAccess', _440 => _440.trim, 'call', _441 => _441()]), () => ( ""));
10366
- if (!b || !/^[\p{L}\p{N}]$/u.test(text) || b.height < 4 || b.width < 1 || b.width > b.height * 2 || b.x < region.x1 || b.y < region.y1 || b.x + b.width > region.x2 || b.y + b.height > region.y2 || b.width * b.height > (region.x2 - region.x1) * (region.y2 - region.y1) * 5e-3 || labels.length < 3 || !labels.some((l) => /\p{L}{3}/u.test(_nullishCoalesce(l.text, () => ( "")))) || labels.filter((l) => !/\p{L}/u.test(_nullishCoalesce(l.text, () => ( ""))) && (_nullishCoalesce(_optionalChain([l, 'access', _442 => _442.text, 'optionalAccess', _443 => _443.match, 'call', _444 => _444(/\p{N}/gu), 'optionalAccess', _445 => _445.length]), () => ( 0))) >= 2).length < 2) return false;
10396
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _441 => _441.text, 'optionalAccess', _442 => _442.trim, 'call', _443 => _443()]), () => ( ""));
10397
+ if (!b || !/^[\p{L}\p{N}]$/u.test(text) || b.height < 4 || b.width < 1 || b.width > b.height * 2 || b.x < region.x1 || b.y < region.y1 || b.x + b.width > region.x2 || b.y + b.height > region.y2 || b.width * b.height > (region.x2 - region.x1) * (region.y2 - region.y1) * 5e-3 || labels.length < 3 || !labels.some((l) => /\p{L}{3}/u.test(_nullishCoalesce(l.text, () => ( "")))) || labels.filter((l) => !/\p{L}/u.test(_nullishCoalesce(l.text, () => ( ""))) && (_nullishCoalesce(_optionalChain([l, 'access', _444 => _444.text, 'optionalAccess', _445 => _445.match, 'call', _446 => _446(/\p{N}/gu), 'optionalAccess', _447 => _447.length]), () => ( 0))) >= 2).length < 2) return false;
10367
10398
  let above = false, below = false;
10368
10399
  for (const label of labels) {
10369
10400
  const a = label.bbox, em = Math.max(b.height, a.height);
@@ -10378,7 +10409,7 @@ function rotatedAxisFragments(candidates) {
10378
10409
  const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
10379
10410
  const axes = [];
10380
10411
  for (const block of paragraphs) {
10381
- const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _446 => _446.text, 'optionalAccess', _447 => _447.trim, 'call', _448 => _448()]), () => ( ""));
10412
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _448 => _448.text, 'optionalAccess', _449 => _449.trim, 'call', _450 => _450()]), () => ( ""));
10382
10413
  if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
10383
10414
  const axis = axes.find((a) => Math.abs(a[0].bbox.x + a[0].bbox.width - b.x - b.width) <= Math.max(a[0].bbox.height, b.height) * 0.5);
10384
10415
  if (axis) axis.push(block);
@@ -10395,8 +10426,8 @@ function rotatedAxisFragments(candidates) {
10395
10426
  const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
10396
10427
  if (top - bottom < em * 6) continue;
10397
10428
  const left = paragraphs.filter((block) => {
10398
- const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _449 => _449.text, 'optionalAccess', _450 => _450.trim, 'call', _451 => _451()]), () => ( ""));
10399
- return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _452 => _452.match, 'call', _453 => _453(/[\p{L}\p{N}]/gu), 'optionalAccess', _454 => _454.length]), () => ( 0))) <= 3 && b.width <= b.height * 3 && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && b.y >= bottom && b.y + b.height <= top;
10429
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _451 => _451.text, 'optionalAccess', _452 => _452.trim, 'call', _453 => _453()]), () => ( ""));
10430
+ return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _454 => _454.match, 'call', _455 => _455(/[\p{L}\p{N}]/gu), 'optionalAccess', _456 => _456.length]), () => ( 0))) <= 3 && b.width <= b.height * 3 && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && b.y >= bottom && b.y + b.height <= top;
10400
10431
  });
10401
10432
  const stack = left.filter((a) => left.some((b) => {
10402
10433
  if (a === b || !aligned(a, b)) return false;
@@ -10406,7 +10437,7 @@ function rotatedAxisFragments(candidates) {
10406
10437
  if (stack.length < 2) continue;
10407
10438
  for (const block of paragraphs) {
10408
10439
  const b = block.bbox;
10409
- if (b.y >= bottom && b.y + b.height <= top && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && /^[\p{L}\p{N}]$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _455 => _455.text, 'optionalAccess', _456 => _456.trim, 'call', _457 => _457()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
10440
+ if (b.y >= bottom && b.y + b.height <= top && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && /^[\p{L}\p{N}]$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _457 => _457.text, 'optionalAccess', _458 => _458.trim, 'call', _459 => _459()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
10410
10441
  }
10411
10442
  }
10412
10443
  return fragments;
@@ -10510,4 +10541,4 @@ function rowParagraphs(block) {
10510
10541
 
10511
10542
 
10512
10543
  exports.DEFAULT_OCR_MODELS = DEFAULT_OCR_MODELS; exports.resolveOcrModels = resolveOcrModels; exports.ocrSelectionKey = ocrSelectionKey; exports.ocrSourcePath = ocrSourcePath; exports.ensureOcrModelsFor = ensureOcrModelsFor; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.grayCrop = grayCrop; exports.inkStats = inkStats; exports.splitRowBands = splitRowBands; exports.leadingTriangle = leadingTriangle; exports.arrowGlyph = arrowGlyph; exports.leaderRuns = leaderRuns; exports.inkBounds = inkBounds; exports.bracketFeatures = bracketFeatures; exports.slantedPair = slantedPair; exports.romanStems = romanStems; exports.circledAt = circledAt; exports.quoteHead = quoteHead; exports.edgeTrim = edgeTrim; exports.tallInkCount = tallInkCount; exports.gapGlyphs = gapGlyphs; exports.ringBullet = ringBullet; exports.dashRatio = dashRatio; exports.leadingRing = leadingRing; exports.discAt = discAt; exports.serifOne = serifOne; exports.starRun = starRun; exports.bracketShape = bracketShape; exports.leadingBullet = leadingBullet; exports.rememberOcrTextGaps = rememberOcrTextGaps; exports.copyOcrTextGaps = copyOcrTextGaps; exports.findOcrTextGaps = findOcrTextGaps; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; exports.NO_EDGES = NO_EDGES; exports.hasOpenCellSeam = hasOpenCellSeam; exports.joinCellEdges = joinCellEdges; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.computeBBox = computeBBox; exports.dominantStyle = dominantStyle; exports.normalizeItems = normalizeItems; exports.groupByY = groupByY; exports.mergeLineSimple = mergeLineSimple; exports.WrapLexicon = WrapLexicon; exports.startsNewItem = startsNewItem; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.splitPageBreakWraps = splitPageBreakWraps; exports.latinSoftWrap = latinSoftWrap; exports.TOC_BLOCKS = TOC_BLOCKS; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.mergeStackedHeadingLines = mergeStackedHeadingLines; exports.detectTypographyHeadings = detectTypographyHeadings; exports.detectDocumentStyleHeadings = detectDocumentStyleHeadings; exports.detectSiblingStyleHeadings = detectSiblingStyleHeadings; exports.detectRepeatedPageLabels = detectRepeatedPageLabels; exports.detectPageLeadHeadings = detectPageLeadHeadings; exports.refineDocumentStyleHeadings = refineDocumentStyleHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.runningLinePatterns = runningLinePatterns; exports.stripAbsorbedRunningLines = stripAbsorbedRunningLines; exports.CLIP_TABLES = CLIP_TABLES; exports.FRAME_TITLE_BLOCKS = FRAME_TITLE_BLOCKS; exports.TABLE_COLXS = TABLE_COLXS; exports.TABLE_ROWYS = TABLE_ROWYS; exports.TABLE_TAIL = TABLE_TAIL; exports.PART_COLXS = PART_COLXS; exports.EMPTY_PARTS = EMPTY_PARTS; exports.IMAGE_CELLS = IMAGE_CELLS; exports.FILLER_CELLS = FILLER_CELLS; exports.CONT_PARTS = CONT_PARTS; exports.CELL_LINES = CELL_LINES; exports.ROW_RULES = ROW_RULES; exports.trimTrailingEmptyTableCols = trimTrailingEmptyTableCols; exports.restoreImageBullets = restoreImageBullets; exports.detectRightArrowRegions = detectRightArrowRegions; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.UNRULED_REGION_TABLES = UNRULED_REGION_TABLES; exports.mergeOcrImageRegions = mergeOcrImageRegions;
10513
- //# sourceMappingURL=chunk-BUFGW3UJ.cjs.map
10544
+ //# sourceMappingURL=chunk-TBGNGQ2O.cjs.map