kordoc 4.21.19 → 4.21.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +7 -5
  2. package/dist/{-FLYHAUQ6.js → -ZYF6HX4M.js} +11 -11
  3. package/dist/{chunk-TC6DQLYN.js → chunk-2ZGP7A5T.js} +2 -2
  4. package/dist/{chunk-4VM6BT4W.js → chunk-3TCF5HPP.js} +2 -2
  5. package/dist/{chunk-2DNJW2HO.cjs → chunk-57VNFMMS.cjs} +3 -3
  6. package/dist/{chunk-2DNJW2HO.cjs.map → chunk-57VNFMMS.cjs.map} +1 -1
  7. package/dist/{chunk-OON4IJU2.js → chunk-5HTFWUJE.js} +2 -2
  8. package/dist/{chunk-AQ5GIBBH.js → chunk-7YAJCXCD.js} +2 -2
  9. package/dist/{chunk-3O4YC67B.js → chunk-BC54LBST.js} +3 -3
  10. package/dist/{chunk-GK4QLKNT.js → chunk-BG6LUCQL.js} +2 -2
  11. package/dist/{chunk-SM42XSI3.js → chunk-CY4QM2KQ.js} +2 -2
  12. package/dist/{chunk-KLKV47XO.cjs → chunk-DTZIZ5PP.cjs} +13 -13
  13. package/dist/{chunk-KLKV47XO.cjs.map → chunk-DTZIZ5PP.cjs.map} +1 -1
  14. package/dist/{chunk-INZGI6PI.js → chunk-FBJVDBMO.js} +2 -2
  15. package/dist/{chunk-Z2OOYQ4I.js → chunk-FZMGF6XU.js} +2 -2
  16. package/dist/{chunk-JGGYLUGD.cjs → chunk-H2MS4VG3.cjs} +3 -3
  17. package/dist/{chunk-JGGYLUGD.cjs.map → chunk-H2MS4VG3.cjs.map} +1 -1
  18. package/dist/{chunk-3PCAJWGK.js → chunk-HWIW3WK2.js} +42 -3
  19. package/dist/{chunk-3PCAJWGK.js.map → chunk-HWIW3WK2.js.map} +1 -1
  20. package/dist/{chunk-F6N7CDB7.js → chunk-J5PBI3ZC.js} +3 -3
  21. package/dist/{chunk-DQ2YGTRS.js → chunk-KBV4WFZ6.js} +145 -123
  22. package/dist/chunk-KBV4WFZ6.js.map +1 -0
  23. package/dist/{chunk-YDIVY65W.js → chunk-KTLHADU4.js} +2 -2
  24. package/dist/{chunk-3KW2Q655.cjs → chunk-MCUX2Y2C.cjs} +2 -2
  25. package/dist/{chunk-3KW2Q655.cjs.map → chunk-MCUX2Y2C.cjs.map} +1 -1
  26. package/dist/{chunk-X6WXU4LA.js → chunk-PTF4NCFM.js} +2 -2
  27. package/dist/{chunk-46PYORID.js → chunk-QHNVH4TC.js} +6 -6
  28. package/dist/{chunk-RYRUQ73F.js → chunk-RBRHO7WL.js} +2 -2
  29. package/dist/{chunk-CLAIAXMX.js → chunk-T3DTTK23.js} +2 -2
  30. package/dist/{chunk-DZVZVZAD.cjs → chunk-T7PN5D4D.cjs} +6 -6
  31. package/dist/{chunk-DZVZVZAD.cjs.map → chunk-T7PN5D4D.cjs.map} +1 -1
  32. package/dist/{chunk-EYLEVRHT.cjs → chunk-TMUUDMDH.cjs} +274 -172
  33. package/dist/chunk-TMUUDMDH.cjs.map +1 -0
  34. package/dist/{chunk-VIFY6DJZ.js → chunk-TRO4CQHJ.js} +4 -4
  35. package/dist/{chunk-OWLDTF5Q.js → chunk-WGMYVRSA.js} +2 -2
  36. package/dist/{chunk-AMXIYV73.js → chunk-YHPJTLCA.js} +2 -2
  37. package/dist/{chunk-QWOZRYUA.js → chunk-YM3K3LCD.js} +450 -110
  38. package/dist/chunk-YM3K3LCD.js.map +1 -0
  39. package/dist/{chunk-Y5OSPKBU.js → chunk-YQZOPT3A.js} +225 -43
  40. package/dist/chunk-YQZOPT3A.js.map +1 -0
  41. package/dist/{chunk-UDODNSDU.js → chunk-ZZIQWSGC.js} +2 -2
  42. package/dist/chunks-MDMJRCJ7.js +10 -0
  43. package/dist/cli.js +30 -30
  44. package/dist/{formula-2YYGN7UE.js → formula-6XNIXZ5L.js} +3 -3
  45. package/dist/{formula-EKXCURKO.cjs → formula-A3I5VAP7.cjs} +9 -9
  46. package/dist/{formula-EKXCURKO.cjs.map → formula-A3I5VAP7.cjs.map} +1 -1
  47. package/dist/{formula-Z5UPXBQM.js → formula-P7M7IH2L.js} +4 -4
  48. package/dist/{image-ocr-23R7RVHP.js → image-ocr-3C6W3KZO.js} +6 -6
  49. package/dist/{image-ocr-IMLFZ2JC.js → image-ocr-ITNY454I.js} +9 -9
  50. package/dist/{image-ocr-TE76KKNV.cjs → image-ocr-UJRSQ2T3.cjs} +15 -15
  51. package/dist/{image-ocr-TE76KKNV.cjs.map → image-ocr-UJRSQ2T3.cjs.map} +1 -1
  52. package/dist/index.cjs +1064 -687
  53. package/dist/index.cjs.map +1 -1
  54. package/dist/index.d.cts +1 -1
  55. package/dist/index.d.ts +1 -1
  56. package/dist/index.js +482 -105
  57. package/dist/index.js.map +1 -1
  58. package/dist/mcp.js +22 -22
  59. package/dist/{model-bundle-GTSRH2DY.js → model-bundle-LAWQH75O.js} +5 -5
  60. package/dist/{models-2J3NS7G2.js → models-6QTD2CFM.js} +5 -5
  61. package/dist/{parse-worker-v2-VO5UY3MP.js → parse-worker-v2-FEPJG3ER.js} +12 -12
  62. package/dist/{parser-FXGAKPUI.js → parser-56I364YM.js} +16 -8
  63. package/dist/{parser-JVUZ7EEV.js.map → parser-56I364YM.js.map} +1 -1
  64. package/dist/{parser-JVUZ7EEV.js → parser-KFCY3NIN.js} +19 -11
  65. package/dist/{parser-FXGAKPUI.js.map → parser-KFCY3NIN.js.map} +1 -1
  66. package/dist/{parser-D5VMCDLG.cjs → parser-VKWUMUML.cjs} +142 -134
  67. package/dist/parser-VKWUMUML.cjs.map +1 -0
  68. package/dist/pdf-ocr-MME37BL4.js +18 -0
  69. package/dist/pdf-ocr-OKAHNEJA.cjs +19 -0
  70. package/dist/{pdf-ocr-YFNUYBYJ.cjs.map → pdf-ocr-OKAHNEJA.cjs.map} +1 -1
  71. package/dist/pdf-ocr-ZZ6AJL6Z.js +22 -0
  72. package/dist/{profile-io-ULK73H2G.js → profile-io-OCITHUQF.js} +3 -3
  73. package/dist/{rasterize-FG3NX3GA.js → rasterize-SFCG4YOI.js} +3 -3
  74. package/dist/{redact-doc-NMKTKG24.js → redact-doc-5SMPXIGG.js} +11 -11
  75. package/dist/{render-GQUUGPOJ.js → render-FGPG5A2N.js} +7 -7
  76. package/dist/seal-GA7NZDTG.js +10 -0
  77. package/dist/{setup-PRBHD7JI.js → setup-JQVYZO7I.js} +3 -3
  78. package/dist/visual-YMG644YW.js +20 -0
  79. package/dist/{watch-LFSXNO2B.js → watch-C77BUSP7.js} +12 -12
  80. package/package.json +1 -1
  81. package/dist/chunk-DQ2YGTRS.js.map +0 -1
  82. package/dist/chunk-EYLEVRHT.cjs.map +0 -1
  83. package/dist/chunk-QWOZRYUA.js.map +0 -1
  84. package/dist/chunk-Y5OSPKBU.js.map +0 -1
  85. package/dist/chunks-J46DCTUC.js +0 -10
  86. package/dist/parser-D5VMCDLG.cjs.map +0 -1
  87. package/dist/pdf-ocr-364WQ5TY.js +0 -18
  88. package/dist/pdf-ocr-4MZELYCR.js +0 -22
  89. package/dist/pdf-ocr-YFNUYBYJ.cjs +0 -19
  90. package/dist/seal-EVHTG5GH.js +0 -10
  91. package/dist/visual-TCIR6MOG.js +0 -20
  92. /package/dist/{-FLYHAUQ6.js.map → -ZYF6HX4M.js.map} +0 -0
  93. /package/dist/{chunk-TC6DQLYN.js.map → chunk-2ZGP7A5T.js.map} +0 -0
  94. /package/dist/{chunk-4VM6BT4W.js.map → chunk-3TCF5HPP.js.map} +0 -0
  95. /package/dist/{chunk-OON4IJU2.js.map → chunk-5HTFWUJE.js.map} +0 -0
  96. /package/dist/{chunk-AQ5GIBBH.js.map → chunk-7YAJCXCD.js.map} +0 -0
  97. /package/dist/{chunk-3O4YC67B.js.map → chunk-BC54LBST.js.map} +0 -0
  98. /package/dist/{chunk-GK4QLKNT.js.map → chunk-BG6LUCQL.js.map} +0 -0
  99. /package/dist/{chunk-SM42XSI3.js.map → chunk-CY4QM2KQ.js.map} +0 -0
  100. /package/dist/{chunk-INZGI6PI.js.map → chunk-FBJVDBMO.js.map} +0 -0
  101. /package/dist/{chunk-Z2OOYQ4I.js.map → chunk-FZMGF6XU.js.map} +0 -0
  102. /package/dist/{chunk-F6N7CDB7.js.map → chunk-J5PBI3ZC.js.map} +0 -0
  103. /package/dist/{chunk-YDIVY65W.js.map → chunk-KTLHADU4.js.map} +0 -0
  104. /package/dist/{chunk-X6WXU4LA.js.map → chunk-PTF4NCFM.js.map} +0 -0
  105. /package/dist/{chunk-46PYORID.js.map → chunk-QHNVH4TC.js.map} +0 -0
  106. /package/dist/{chunk-RYRUQ73F.js.map → chunk-RBRHO7WL.js.map} +0 -0
  107. /package/dist/{chunk-CLAIAXMX.js.map → chunk-T3DTTK23.js.map} +0 -0
  108. /package/dist/{chunk-VIFY6DJZ.js.map → chunk-TRO4CQHJ.js.map} +0 -0
  109. /package/dist/{chunk-OWLDTF5Q.js.map → chunk-WGMYVRSA.js.map} +0 -0
  110. /package/dist/{chunk-AMXIYV73.js.map → chunk-YHPJTLCA.js.map} +0 -0
  111. /package/dist/{chunk-UDODNSDU.js.map → chunk-ZZIQWSGC.js.map} +0 -0
  112. /package/dist/{chunks-J46DCTUC.js.map → chunks-MDMJRCJ7.js.map} +0 -0
  113. /package/dist/{formula-2YYGN7UE.js.map → formula-6XNIXZ5L.js.map} +0 -0
  114. /package/dist/{formula-Z5UPXBQM.js.map → formula-P7M7IH2L.js.map} +0 -0
  115. /package/dist/{image-ocr-23R7RVHP.js.map → image-ocr-3C6W3KZO.js.map} +0 -0
  116. /package/dist/{image-ocr-IMLFZ2JC.js.map → image-ocr-ITNY454I.js.map} +0 -0
  117. /package/dist/{model-bundle-GTSRH2DY.js.map → model-bundle-LAWQH75O.js.map} +0 -0
  118. /package/dist/{models-2J3NS7G2.js.map → models-6QTD2CFM.js.map} +0 -0
  119. /package/dist/{parse-worker-v2-VO5UY3MP.js.map → parse-worker-v2-FEPJG3ER.js.map} +0 -0
  120. /package/dist/{pdf-ocr-364WQ5TY.js.map → pdf-ocr-MME37BL4.js.map} +0 -0
  121. /package/dist/{pdf-ocr-4MZELYCR.js.map → pdf-ocr-ZZ6AJL6Z.js.map} +0 -0
  122. /package/dist/{profile-io-ULK73H2G.js.map → profile-io-OCITHUQF.js.map} +0 -0
  123. /package/dist/{rasterize-FG3NX3GA.js.map → rasterize-SFCG4YOI.js.map} +0 -0
  124. /package/dist/{redact-doc-NMKTKG24.js.map → redact-doc-5SMPXIGG.js.map} +0 -0
  125. /package/dist/{render-GQUUGPOJ.js.map → render-FGPG5A2N.js.map} +0 -0
  126. /package/dist/{seal-EVHTG5GH.js.map → seal-GA7NZDTG.js.map} +0 -0
  127. /package/dist/{setup-PRBHD7JI.js.map → setup-JQVYZO7I.js.map} +0 -0
  128. /package/dist/{visual-TCIR6MOG.js.map → visual-YMG644YW.js.map} +0 -0
  129. /package/dist/{watch-LFSXNO2B.js.map → watch-C77BUSP7.js.map} +0 -0
@@ -4,15 +4,15 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkDZVZVZADcjs = require('./chunk-DZVZVZAD.cjs');
7
+ var _chunkT7PN5D4Dcjs = require('./chunk-T7PN5D4D.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunkJGGYLUGDcjs = require('./chunk-JGGYLUGD.cjs');
11
+ var _chunkH2MS4VG3cjs = require('./chunk-H2MS4VG3.cjs');
12
12
 
13
13
 
14
14
 
15
- var _chunk3KW2Q655cjs = require('./chunk-3KW2Q655.cjs');
15
+ var _chunkMCUX2Y2Ccjs = require('./chunk-MCUX2Y2C.cjs');
16
16
 
17
17
  // src/ocr/models.ts
18
18
  var _path = require('path');
@@ -40,10 +40,10 @@ var OCR_REC_DICT = {
40
40
  };
41
41
  var ALL_OCR_MODELS = [OCR_DET_MODEL, OCR_REC_MODEL, OCR_REC_DICT];
42
42
  function getOcrModelsDir() {
43
- return _chunkJGGYLUGDcjs.getModelsDir.call(void 0, "ppocr");
43
+ return _chunkH2MS4VG3cjs.getModelsDir.call(void 0, "ppocr");
44
44
  }
45
45
  async function ensureOcrModels(onProgress) {
46
- return _chunkJGGYLUGDcjs.ensureModelsIn.call(void 0, getOcrModelsDir(), ALL_OCR_MODELS, onProgress);
46
+ return _chunkH2MS4VG3cjs.ensureModelsIn.call(void 0, getOcrModelsDir(), ALL_OCR_MODELS, onProgress);
47
47
  }
48
48
  async function ocrModelsCached() {
49
49
  const dir = getOcrModelsDir();
@@ -1944,7 +1944,7 @@ function dropGridsInside(lineGrids, clipGrids, containers = [], verticals = [])
1944
1944
  const ga = area(g);
1945
1945
  return ga > 0 && ix * iy / ga >= 0.5;
1946
1946
  };
1947
- const inside = (c, g) => c.x1 >= g.x1 - 1 && c.x2 <= g.x2 + 1 && c.y1 >= g.y1 - 1 && c.y2 <= g.y2 + 1;
1947
+ const inside = (c, g) => c.x1 >= g.x1 - 3 && c.x2 <= g.x2 + 3 && c.y1 >= g.y1 - 3 && c.y2 <= g.y2 + 3;
1948
1948
  const stackedOnly = (g) => {
1949
1949
  const stacked = clipGrids.filter((c) => inside(c.bbox, g.bbox)).sort((a, b) => a.bbox.y1 - b.bbox.y1);
1950
1950
  if (stacked.length < 2 || g.colXs.length < 3 || stacked.reduce((s, c) => s + area(c.bbox), 0) < area(g.bbox) * 0.5) return false;
@@ -2135,7 +2135,7 @@ function tagScripts(text, lines) {
2135
2135
  const [s, e, kind] = marks[m];
2136
2136
  out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
2137
2137
  }
2138
- return _chunkDZVZVZADcjs.tidyScriptTags.call(void 0, out);
2138
+ return _chunkT7PN5D4Dcjs.tidyScriptTags.call(void 0, out);
2139
2139
  }
2140
2140
 
2141
2141
  // src/pdf/line-wrap.ts
@@ -3415,6 +3415,49 @@ function isExamLayoutTable(table) {
3415
3415
  return layout >= texts.length * 0.6;
3416
3416
  }
3417
3417
 
3418
+ // src/pdf/cluster-cell-text.ts
3419
+ function clusterCellLines(items) {
3420
+ const hOf = (i) => i.h > 0 ? i.h : i.fontSize;
3421
+ const lines = [];
3422
+ for (const it of [...items].sort((a, b) => b.y - a.y || a.x - b.x)) {
3423
+ const bottom = it.y, top = it.y + hOf(it);
3424
+ const line = lines.find((l) => Math.min(l.top, top) - Math.max(l.bottom, bottom) >= Math.min(l.top - l.bottom, top - bottom) * 0.5);
3425
+ if (line) {
3426
+ line.items.push(it);
3427
+ line.bottom = Math.min(line.bottom, bottom);
3428
+ line.top = Math.max(line.top, top);
3429
+ } else lines.push({ bottom, top, items: [it] });
3430
+ }
3431
+ return lines.sort((a, b) => b.top - a.top).map(({ items: line }) => {
3432
+ line.sort((a, b) => a.x - b.x);
3433
+ let s = line[0].text;
3434
+ for (let i = 1; i < line.length; i++) {
3435
+ const gap = line[i].x - (line[i - 1].x + line[i - 1].w);
3436
+ const fs = (line[i].fontSize + line[i - 1].fontSize) / 2;
3437
+ s += (!isCjkLatinAutospace(line[i - 1].text, line[i].text, gap, fs) && (line[i].hasSpaceBefore && gap >= fs * 0.05 || gap > spaceGapThreshold(fs)) ? " " : "") + line[i].text;
3438
+ }
3439
+ const last = line.reduce((a, b) => b.x + b.w > a.x + a.w ? b : a);
3440
+ return {
3441
+ text: s,
3442
+ left: line[0].x,
3443
+ right: last.x + last.w,
3444
+ fontSize: line[0].fontSize,
3445
+ spaceAfter: last.spaceAfter,
3446
+ firstCharW: line[0].w / Math.max(1, [...line[0].text.replace(/<\/?u>|~~/g, "")].length)
3447
+ };
3448
+ });
3449
+ }
3450
+ var WRAP_INDENT_MAX = 3;
3451
+ function joinClusterCellLines(lines, box, lex) {
3452
+ let out = _nullishCoalesce(_optionalChain([lines, 'access', _105 => _105[0], 'optionalAccess', _106 => _106.text]), () => ( ""));
3453
+ for (let i = 1; i < lines.length; i++) {
3454
+ const a = lines[i - 1], b = lines[i];
3455
+ 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) === "";
3456
+ out += (join2 ? "" : " ") + b.text;
3457
+ }
3458
+ return out;
3459
+ }
3460
+
3418
3461
  // src/pdf/cluster-detector.ts
3419
3462
  var Y_TOL = 3;
3420
3463
  var COL_CLUSTER_TOL = 15;
@@ -3423,7 +3466,7 @@ var MIN_COLS = 2;
3423
3466
  var MIN_GAP_FACTOR = 2;
3424
3467
  var MIN_GAP_ABSOLUTE = 20;
3425
3468
  var MIN_COL_FILL_RATIO = 0.4;
3426
- function detectClusterTables(items, pageNum, rejected) {
3469
+ function detectClusterTables(items, pageNum, rejected, lex) {
3427
3470
  const tab = sideTabGlyphs(items);
3428
3471
  if (tab.size) items = items.filter((i) => !tab.has(i));
3429
3472
  if (items.length < MIN_ROWS * MIN_COLS) return [];
@@ -3444,7 +3487,7 @@ function detectClusterTables(items, pageNum, rejected) {
3444
3487
  const mergedRows = mergeMultiLineRows(headerAndBelow, columns);
3445
3488
  const tableRegions = findTableRegionsByHeader(mergedRows, columns, headerItems);
3446
3489
  for (const region of tableRegions) {
3447
- const table = buildClusterTable(region.rows, columns, pageNum);
3490
+ const table = buildClusterTable(region.rows, columns, pageNum, lex);
3448
3491
  if (table) {
3449
3492
  expandUsedItems(table.usedItems, originMap);
3450
3493
  results.push(table);
@@ -3459,8 +3502,8 @@ function detectClusterTables(items, pageNum, rejected) {
3459
3502
  const tableRegions = findTableRegions(rows, columns);
3460
3503
  for (const region of tableRegions) {
3461
3504
  const own = extractColumnClusters(region.rows.filter((row) => hasSuspiciousGaps(row)));
3462
- const ownTable = own.length >= MIN_COLS && own.length < columns.length ? buildClusterTable(mergeMultiLineRows(region.rows, own), own, pageNum) : null;
3463
- const table = ownTable && ownTable.table.cells.every((row, r) => row.every((cell) => (r === 0 || cell.colSpan >= ownTable.table.cols || cell.text.trim().length <= 30) && !/\p{Co}/u.test(cell.text))) ? ownTable : buildClusterTable(mergeMultiLineRows(region.rows, columns), columns, pageNum);
3505
+ const ownTable = own.length >= MIN_COLS && own.length < columns.length ? buildClusterTable(mergeMultiLineRows(region.rows, own), own, pageNum, lex) : null;
3506
+ const table = ownTable && ownTable.table.cells.every((row, r) => row.every((cell) => (r === 0 || cell.colSpan >= ownTable.table.cols || cell.text.trim().length <= 30) && !/\p{Co}/u.test(cell.text))) ? ownTable : buildClusterTable(mergeMultiLineRows(region.rows, columns), columns, pageNum, lex);
3464
3507
  if (table) {
3465
3508
  expandUsedItems(table.usedItems, originMap);
3466
3509
  results.push(table);
@@ -3617,7 +3660,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
3617
3660
  continue;
3618
3661
  }
3619
3662
  const top = rows[i - 1];
3620
- const title = _optionalChain([top, 'optionalAccess', _105 => _105.items, 'access', _106 => _106.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;
3663
+ const title = _optionalChain([top, 'optionalAccess', _107 => _107.items, 'access', _108 => _108.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;
3621
3664
  const tableRows = title ? [title, ...body] : body;
3622
3665
  const cells = tableRows.map((row, idx) => {
3623
3666
  if (title && idx === 0) return [{ text: row.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }];
@@ -3673,12 +3716,12 @@ function isTwoColumnProse(r) {
3673
3716
  if (t.rows < 8) return false;
3674
3717
  const dense = [];
3675
3718
  for (let c = 0; c < t.cols; c++) {
3676
- const filled = t.cells.filter((row) => _optionalChain([row, 'access', _107 => _107[c], 'optionalAccess', _108 => _108.text, 'access', _109 => _109.trim, 'call', _110 => _110()])).length;
3719
+ const filled = t.cells.filter((row) => _optionalChain([row, 'access', _109 => _109[c], 'optionalAccess', _110 => _110.text, 'access', _111 => _111.trim, 'call', _112 => _112()])).length;
3677
3720
  if (filled / t.rows >= 0.3) dense.push(c);
3678
3721
  }
3679
3722
  if (dense.length !== 2) return false;
3680
3723
  for (const c of dense) {
3681
- const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _111 => _111[c], 'optionalAccess', _112 => _112.text, 'access', _113 => _113.replace, 'call', _114 => _114(/\s+/g, ""), 'access', _115 => _115.length]), () => ( 0))).filter((n) => n > 0);
3724
+ const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _113 => _113[c], 'optionalAccess', _114 => _114.text, 'access', _115 => _115.replace, 'call', _116 => _116(/\s+/g, ""), 'access', _117 => _117.length]), () => ( 0))).filter((n) => n > 0);
3682
3725
  const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
3683
3726
  if (avg < 12) return false;
3684
3727
  }
@@ -4092,7 +4135,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
4092
4135
  const runs = [];
4093
4136
  for (const it of sorted) {
4094
4137
  const last = runs[runs.length - 1];
4095
- const prev = _optionalChain([last, 'optionalAccess', _116 => _116[last.length - 1]]);
4138
+ const prev = _optionalChain([last, 'optionalAccess', _118 => _118[last.length - 1]]);
4096
4139
  if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
4097
4140
  else runs.push([it]);
4098
4141
  }
@@ -4157,7 +4200,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
4157
4200
  }
4158
4201
  return result;
4159
4202
  }
4160
- function buildClusterTable(rows, columns, pageNum) {
4203
+ function buildClusterTable(rows, columns, pageNum, lex) {
4161
4204
  const numCols = columns.length;
4162
4205
  const numRows = rows.length;
4163
4206
  if (numRows < MIN_ROWS || numCols < MIN_COLS) return null;
@@ -4166,7 +4209,8 @@ function buildClusterTable(rows, columns, pageNum) {
4166
4209
  () => Array.from({ length: numCols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }))
4167
4210
  );
4168
4211
  const usedItems = /* @__PURE__ */ new Set();
4169
- const headFaces = new Set(_optionalChain([rows, 'access', _117 => _117[0], 'optionalAccess', _118 => _118.items, 'access', _119 => _119.map, 'call', _120 => _120((i) => i.fontName)]));
4212
+ const lines = cells.map((row) => row.map(() => []));
4213
+ const headFaces = new Set(_optionalChain([rows, 'access', _119 => _119[0], 'optionalAccess', _120 => _120.items, 'access', _121 => _121.map, 'call', _122 => _122((i) => i.fontName)]));
4170
4214
  const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
4171
4215
  for (let r = 0; r < numRows; r++) {
4172
4216
  const row = rows[r];
@@ -4177,12 +4221,18 @@ function buildClusterTable(rows, columns, pageNum) {
4177
4221
  }
4178
4222
  const assignments = assignRowItems(row.items, columns, numCols, r === 0 ? headerFace : void 0);
4179
4223
  for (const { col, items } of assignments) {
4180
- const text = joinCellItems(items);
4181
- const existing = cells[r][col].text;
4182
- cells[r][col].text = existing ? existing + " " + text : text;
4224
+ const cell = lines[r][col];
4225
+ if (cell.length) cell[cell.length - 1].spaceAfter = true;
4226
+ cell.push(...clusterCellLines(items));
4183
4227
  for (const item of items) usedItems.add(item);
4184
4228
  }
4185
4229
  }
4230
+ const boxes = columns.map((_, c) => {
4231
+ const col = lines.flatMap((row) => row[c]);
4232
+ return { x1: Math.min(...col.map((l) => l.left)), x2: Math.max(...col.map((l) => l.right)) };
4233
+ });
4234
+ const textOf = (r, c) => joinClusterCellLines(lines[r][c], boxes[c], lex);
4235
+ for (let r = 0; r < numRows; r++) for (let c = 0; c < numCols; c++) if (lines[r][c].length) cells[r][c].text = textOf(r, c);
4186
4236
  let emptyRows = 0;
4187
4237
  for (const row of cells) {
4188
4238
  if (row.every((c) => c.text === "")) emptyRows++;
@@ -4196,15 +4246,15 @@ function buildClusterTable(rows, columns, pageNum) {
4196
4246
  const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
4197
4247
  if (nonEmptyCols !== 1) continue;
4198
4248
  if (cells[r][0].text.trim() !== "") continue;
4199
- const contentText = _optionalChain([cells, 'access', _121 => _121[r], 'access', _122 => _122.find, 'call', _123 => _123((c) => c.text.trim()), 'optionalAccess', _124 => _124.text, 'access', _125 => _125.trim, 'call', _126 => _126()]) || "";
4249
+ const contentText = _optionalChain([cells, 'access', _123 => _123[r], 'access', _124 => _124.find, 'call', _125 => _125((c) => c.text.trim()), 'optionalAccess', _126 => _126.text, 'access', _127 => _127.trim, 'call', _128 => _128()]) || "";
4200
4250
  if (/^[○●▶\-·]/.test(contentText)) continue;
4201
4251
  for (let pr = r - 1; pr >= 0; pr--) {
4202
4252
  if (cells[pr].some((c) => c.text.trim())) {
4203
4253
  if (cells[pr][0].colSpan > 1) break;
4204
4254
  for (let c = 0; c < numCols; c++) {
4205
- const prev = cells[pr][c].text.trim();
4206
- const curr = cells[r][c].text.trim();
4207
- if (curr) cells[pr][c].text = prev ? prev + " " + curr : curr;
4255
+ if (!cells[r][c].text.trim()) continue;
4256
+ lines[pr][c].push(...lines[r][c]);
4257
+ cells[pr][c].text = textOf(pr, c);
4208
4258
  }
4209
4259
  for (let c = 0; c < numCols; c++) cells[r][c].text = "";
4210
4260
  break;
@@ -4251,29 +4301,6 @@ function buildClusterTable(rows, columns, pageNum) {
4251
4301
  usedItems
4252
4302
  };
4253
4303
  }
4254
- function joinCellItems(items) {
4255
- const hOf = (i) => i.h > 0 ? i.h : i.fontSize;
4256
- const lines = [];
4257
- for (const it of [...items].sort((a, b) => b.y - a.y || a.x - b.x)) {
4258
- const bottom = it.y, top = it.y + hOf(it);
4259
- const line = lines.find((l) => Math.min(l.top, top) - Math.max(l.bottom, bottom) >= Math.min(l.top - l.bottom, top - bottom) * 0.5);
4260
- if (line) {
4261
- line.items.push(it);
4262
- line.bottom = Math.min(line.bottom, bottom);
4263
- line.top = Math.max(line.top, top);
4264
- } else lines.push({ bottom, top, items: [it] });
4265
- }
4266
- return lines.sort((a, b) => b.top - a.top).map(({ items: line }) => {
4267
- line.sort((a, b) => a.x - b.x);
4268
- let s = line[0].text;
4269
- for (let i = 1; i < line.length; i++) {
4270
- const gap = line[i].x - (line[i - 1].x + line[i - 1].w);
4271
- const fs = (line[i].fontSize + line[i - 1].fontSize) / 2;
4272
- s += (!isCjkLatinAutospace(line[i - 1].text, line[i].text, gap, fs) && (line[i].hasSpaceBefore && gap >= fs * 0.05 || gap > spaceGapThreshold(fs)) ? " " : "") + line[i].text;
4273
- }
4274
- return s;
4275
- }).join(" ");
4276
- }
4277
4304
 
4278
4305
  // src/pdf/page-regions.ts
4279
4306
  function splitTwoColumnProse(items, cutX) {
@@ -4452,7 +4479,7 @@ function stackedTableBands(items) {
4452
4479
  const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
4453
4480
  while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
4454
4481
  if (runs.length < 2) return null;
4455
- if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _127 => _127[i + 1], 'optionalAccess', _128 => _128.start]), () => ( lines.length))))) return null;
4482
+ if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _129 => _129[i + 1], 'optionalAccess', _130 => _130.start]), () => ( lines.length))))) return null;
4456
4483
  const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
4457
4484
  const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
4458
4485
  const tail = lines.slice(runs[runs.length - 1].end);
@@ -4720,7 +4747,7 @@ function splitTrailingColumnRegion(items) {
4720
4747
  }
4721
4748
  function panelBlocks(items, panel, pageNum) {
4722
4749
  const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
4723
- const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _129 => _129(line), 'optionalAccess', _130 => _130.fontName]), () => ( ""));
4750
+ const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _131 => _131(line), 'optionalAccess', _132 => _132.fontName]), () => ( ""));
4724
4751
  const runs = [];
4725
4752
  for (const line of lines) {
4726
4753
  const last = runs[runs.length - 1];
@@ -4902,7 +4929,7 @@ function validWrapBands(items, bands) {
4902
4929
  }
4903
4930
  function inheritedWrapBands(items) {
4904
4931
  const source = XY_WRAP_ITEMS.get(items[0]);
4905
- const present = _optionalChain([source, 'optionalAccess', _131 => _131.length]) === items.length ? new Set(items) : null;
4932
+ const present = _optionalChain([source, 'optionalAccess', _133 => _133.length]) === items.length ? new Set(items) : null;
4906
4933
  const sameLeaf = present && source.every((item) => present.has(item));
4907
4934
  return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
4908
4935
  }
@@ -4941,7 +4968,7 @@ function wrappedLineBands(items, inherited) {
4941
4968
  left: box.x,
4942
4969
  right: box.x + box.width,
4943
4970
  y: row.reduce((n, i) => n + i.y, 0) / row.length,
4944
- fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _132 => _132(row), 'optionalAccess', _133 => _133.fontSize]), () => ( 0)),
4971
+ fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _134 => _134(row), 'optionalAccess', _135 => _135.fontSize]), () => ( 0)),
4945
4972
  sources: row.map((item) => ({ item, state: { ...item } }))
4946
4973
  };
4947
4974
  });
@@ -5077,10 +5104,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
5077
5104
  const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
5078
5105
  const geo = lines.map((l) => {
5079
5106
  const b = computeBBox(l.items, pageNum);
5080
- 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', _134 => _134(l.items), 'optionalAccess', _135 => _135.fontSize]), () => ( 0)) };
5107
+ 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', _136 => _136(l.items), 'optionalAccess', _137 => _137.fontSize]), () => ( 0)) };
5081
5108
  });
5082
5109
  const joins = bodyLineJoins(geo, lex);
5083
- const first = _optionalChain([lines, 'access', _136 => _136[0], 'optionalAccess', _137 => _137.items, 'access', _138 => _138[0]]);
5110
+ const first = _optionalChain([lines, 'access', _138 => _138[0], 'optionalAccess', _139 => _139.items, 'access', _140 => _140[0]]);
5084
5111
  const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
5085
5112
  const hasBand = (top, bottom) => {
5086
5113
  let lo = 0, hi = bands.length;
@@ -5157,15 +5184,15 @@ function computeMedianFontSizeFromFreq(freq) {
5157
5184
  function detectHeadings(blocks, medianFontSize) {
5158
5185
  for (let bi = 0; bi < blocks.length; bi++) {
5159
5186
  const block = blocks[bi];
5160
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _139 => _139.style, 'optionalAccess', _140 => _140.fontSize])) continue;
5187
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _141 => _141.style, 'optionalAccess', _142 => _142.fontSize])) continue;
5161
5188
  const text = block.text.trim();
5162
5189
  if (text.length === 0 || text.length > 200) continue;
5163
5190
  if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
5164
5191
  const ratio = block.style.fontSize / medianFontSize;
5165
5192
  let level = 0;
5166
- if (ratio >= _chunkDZVZVZADcjs.HEADING_RATIO_H1) level = 1;
5167
- else if (ratio >= _chunkDZVZVZADcjs.HEADING_RATIO_H2) level = 2;
5168
- else if (ratio >= _chunkDZVZVZADcjs.HEADING_RATIO_H3) level = 3;
5193
+ if (ratio >= _chunkT7PN5D4Dcjs.HEADING_RATIO_H1) level = 1;
5194
+ else if (ratio >= _chunkT7PN5D4Dcjs.HEADING_RATIO_H2) level = 2;
5195
+ else if (ratio >= _chunkT7PN5D4Dcjs.HEADING_RATIO_H3) level = 3;
5169
5196
  if (level > 0) {
5170
5197
  block.type = "heading";
5171
5198
  block.level = level;
@@ -5174,21 +5201,21 @@ function detectHeadings(blocks, medianFontSize) {
5174
5201
  }
5175
5202
  }
5176
5203
  function isChapterNumber(block, next, medianFontSize) {
5177
- const size = _nullishCoalesce(_optionalChain([block, 'access', _141 => _141.style, 'optionalAccess', _142 => _142.fontSize]), () => ( 0));
5178
- const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _143 => _143.style, 'optionalAccess', _144 => _144.fontSize]), () => ( 0));
5179
- const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _145 => _145.text, 'optionalAccess', _146 => _146.trim, 'call', _147 => _147()]), () => ( ""));
5180
- const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _148 => _148.bbox]);
5181
- return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _149 => _149.text, 'optionalAccess', _150 => _150.trim, 'call', _151 => _151()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkDZVZVZADcjs.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;
5204
+ const size = _nullishCoalesce(_optionalChain([block, 'access', _143 => _143.style, 'optionalAccess', _144 => _144.fontSize]), () => ( 0));
5205
+ const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _145 => _145.style, 'optionalAccess', _146 => _146.fontSize]), () => ( 0));
5206
+ const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _147 => _147.text, 'optionalAccess', _148 => _148.trim, 'call', _149 => _149()]), () => ( ""));
5207
+ const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _150 => _150.bbox]);
5208
+ return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _151 => _151.text, 'optionalAccess', _152 => _152.trim, 'call', _153 => _153()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkT7PN5D4Dcjs.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;
5182
5209
  }
5183
5210
  function mergeStackedHeadingLines(blocks, medianFontSize) {
5184
5211
  for (let i = 0; i < blocks.length - 1; ) {
5185
5212
  const a = blocks[i], b = blocks[i + 1];
5186
5213
  const ab = a.bbox, bb = b.bbox;
5187
- const af = _nullishCoalesce(_optionalChain([a, 'access', _152 => _152.style, 'optionalAccess', _153 => _153.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _154 => _154.style, 'optionalAccess', _155 => _155.fontSize]), () => ( 0));
5214
+ const af = _nullishCoalesce(_optionalChain([a, 'access', _154 => _154.style, 'optionalAccess', _155 => _155.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _156 => _156.style, 'optionalAccess', _157 => _157.fontSize]), () => ( 0));
5188
5215
  const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
5189
- const centered = ab && bb && _optionalChain([a, 'access', _156 => _156.style, 'optionalAccess', _157 => _157.fontName]) === _optionalChain([b, 'access', _158 => _158.style, 'optionalAccess', _159 => _159.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
5216
+ const centered = ab && bb && _optionalChain([a, 'access', _158 => _158.style, 'optionalAccess', _159 => _159.fontName]) === _optionalChain([b, 'access', _160 => _160.style, 'optionalAccess', _161 => _161.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
5190
5217
  const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
5191
- const wrapped = sameAnchor && _optionalChain([a, 'access', _160 => _160.style, 'optionalAccess', _161 => _161.fontName]) === _optionalChain([b, 'access', _162 => _162.style, 'optionalAccess', _163 => _163.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _164 => _164.text, 'optionalAccess', _165 => _165.trim, 'call', _166 => _166(), 'access', _167 => _167.split, 'call', _168 => _168(/\s+/), 'access', _169 => _169.length]), () => ( 0))) >= 3;
5218
+ const wrapped = sameAnchor && _optionalChain([a, 'access', _162 => _162.style, 'optionalAccess', _163 => _163.fontName]) === _optionalChain([b, 'access', _164 => _164.style, 'optionalAccess', _165 => _165.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _166 => _166.text, 'optionalAccess', _167 => _167.trim, 'call', _168 => _168(), 'access', _169 => _169.split, 'call', _170 => _170(/\s+/), 'access', _171 => _171.length]), () => ( 0))) >= 3;
5192
5219
  const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
5193
5220
  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)) {
5194
5221
  i++;
@@ -5217,25 +5244,25 @@ function detectTypographyHeadings(blocks) {
5217
5244
  if (page.some((block) => block.type === "heading")) continue;
5218
5245
  const faceWeight = /* @__PURE__ */ new Map();
5219
5246
  for (const block of page) {
5220
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _170 => _170.style, 'optionalAccess', _171 => _171.fontName])) continue;
5247
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _172 => _172.style, 'optionalAccess', _173 => _173.fontName])) continue;
5221
5248
  const faces = FACE_CHARS.get(block);
5222
5249
  if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
5223
5250
  else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
5224
5251
  }
5225
- const bodyFace = _optionalChain([[...faceWeight], 'access', _172 => _172.sort, 'call', _173 => _173((a, b) => b[1] - a[1]), 'access', _174 => _174[0], 'optionalAccess', _175 => _175[0]]);
5252
+ const bodyFace = _optionalChain([[...faceWeight], 'access', _174 => _174.sort, 'call', _175 => _175((a, b) => b[1] - a[1]), 'access', _176 => _176[0], 'optionalAccess', _177 => _177[0]]);
5226
5253
  if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
5227
5254
  const sizeWeight = /* @__PURE__ */ new Map();
5228
5255
  for (const block of page) {
5229
- if (block.type !== "paragraph" || !_optionalChain([block, 'access', _176 => _176.style, 'optionalAccess', _177 => _177.fontSize])) continue;
5256
+ if (block.type !== "paragraph" || !_optionalChain([block, 'access', _178 => _178.style, 'optionalAccess', _179 => _179.fontSize])) continue;
5230
5257
  const faces = FACE_CHARS.get(block);
5231
- const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _178 => _178.text, 'optionalAccess', _179 => _179.length]), () => ( 0)) : 0;
5258
+ const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _180 => _180.text, 'optionalAccess', _181 => _181.length]), () => ( 0)) : 0;
5232
5259
  if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
5233
5260
  }
5234
- const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _180 => _180.sort, 'call', _181 => _181((a, b) => b[1] - a[1]), 'access', _182 => _182[0], 'optionalAccess', _183 => _183[0]]), () => ( 0));
5261
+ const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _182 => _182.sort, 'call', _183 => _183((a, b) => b[1] - a[1]), 'access', _184 => _184[0], 'optionalAccess', _185 => _185[0]]), () => ( 0));
5235
5262
  for (let i = 0; i < page.length; i++) {
5236
5263
  const block = page[i];
5237
5264
  const { text, bbox, style } = block;
5238
- if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _184 => _184.fontName]) || !style.fontSize) continue;
5265
+ if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _186 => _186.fontName]) || !style.fontSize) continue;
5239
5266
  const title = text.trim();
5240
5267
  const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
5241
5268
  const faces = FACE_CHARS.get(block);
@@ -5265,16 +5292,16 @@ function detectDocumentStyleHeadings(blocks) {
5265
5292
  for (const page of byPage.values()) {
5266
5293
  const faceChars = /* @__PURE__ */ new Map();
5267
5294
  for (const block of page) {
5268
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _185 => _185.style, 'optionalAccess', _186 => _186.fontName])) continue;
5295
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _187 => _187.style, 'optionalAccess', _188 => _188.fontName])) continue;
5269
5296
  faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
5270
5297
  }
5271
- const bodyFace = _optionalChain([[...faceChars], 'access', _187 => _187.sort, 'call', _188 => _188((a, b) => b[1] - a[1]), 'access', _189 => _189[0], 'optionalAccess', _190 => _190[0]]);
5298
+ const bodyFace = _optionalChain([[...faceChars], 'access', _189 => _189.sort, 'call', _190 => _190((a, b) => b[1] - a[1]), 'access', _191 => _191[0], 'optionalAccess', _192 => _192[0]]);
5272
5299
  if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
5273
- const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _191 => _191.style, 'optionalAccess', _192 => _192.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
5300
+ const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
5274
5301
  for (const label of labels) {
5275
- const peers = labels.filter((b) => _optionalChain([b, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontName]) === _optionalChain([label, 'access', _195 => _195.style, 'optionalAccess', _196 => _196.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
5302
+ const peers = labels.filter((b) => _optionalChain([b, 'access', _195 => _195.style, 'optionalAccess', _196 => _196.fontName]) === _optionalChain([label, 'access', _197 => _197.style, 'optionalAccess', _198 => _198.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
5276
5303
  if (peers.length < 2) continue;
5277
- const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _197 => _197.style, 'optionalAccess', _198 => _198.fontName]) !== _optionalChain([label, 'access', _199 => _199.style, 'optionalAccess', _200 => _200.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);
5304
+ const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _199 => _199.style, 'optionalAccess', _200 => _200.fontName]) !== _optionalChain([label, 'access', _201 => _201.style, 'optionalAccess', _202 => _202.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);
5278
5305
  if (value) {
5279
5306
  label.type = "heading";
5280
5307
  label.level = 2;
@@ -5283,7 +5310,7 @@ function detectDocumentStyleHeadings(blocks) {
5283
5310
  const first = page.find((b) => b.type !== "image" && b.type !== "separator");
5284
5311
  const second = page[page.indexOf(first) + 1];
5285
5312
  const third = page[page.indexOf(first) + 2];
5286
- if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _201 => _201.style, 'optionalAccess', _202 => _202.fontName]) || !_optionalChain([second, 'access', _203 => _203.style, 'optionalAccess', _204 => _204.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', _205 => _205.style, 'optionalAccess', _206 => _206.fontName]) !== bodyFace) continue;
5313
+ if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _203 => _203.style, 'optionalAccess', _204 => _204.fontName]) || !_optionalChain([second, 'access', _205 => _205.style, 'optionalAccess', _206 => _206.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', _207 => _207.style, 'optionalAccess', _208 => _208.fontName]) !== bodyFace) continue;
5287
5314
  first.type = "heading";
5288
5315
  first.level = 1;
5289
5316
  first.text = `${first.text.trim()} ${second.text.trim()}`;
@@ -5307,18 +5334,18 @@ function detectSiblingStyleHeadings(blocks) {
5307
5334
  for (const page of byPage.values()) {
5308
5335
  const bodyChars = /* @__PURE__ */ new Map();
5309
5336
  for (const block of page) {
5310
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _207 => _207.style, 'optionalAccess', _208 => _208.fontName])) continue;
5337
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _209 => _209.style, 'optionalAccess', _210 => _210.fontName])) continue;
5311
5338
  const face = block.style.fontName;
5312
5339
  bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
5313
5340
  }
5314
- const bodyFace = _optionalChain([[...bodyChars], 'access', _209 => _209.sort, 'call', _210 => _210((a, b) => b[1] - a[1]), 'access', _211 => _211[0], 'optionalAccess', _212 => _212[0]]);
5315
- const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _213 => _213.style, 'optionalAccess', _214 => _214.fontName]) && b.style.fontName !== bodyFace);
5341
+ const bodyFace = _optionalChain([[...bodyChars], 'access', _211 => _211.sort, 'call', _212 => _212((a, b) => b[1] - a[1]), 'access', _213 => _213[0], 'optionalAccess', _214 => _214[0]]);
5342
+ const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _215 => _215.style, 'optionalAccess', _216 => _216.fontName]) && b.style.fontName !== bodyFace);
5316
5343
  for (const anchor of anchors) {
5317
5344
  const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
5318
5345
  const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
5319
- const peers = anchors.filter((b) => _optionalChain([b, 'access', _215 => _215.style, 'optionalAccess', _216 => _216.fontName]) === _optionalChain([anchor, 'access', _217 => _217.style, 'optionalAccess', _218 => _218.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _219 => _219.style, 'optionalAccess', _220 => _220.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _221 => _221.style, 'optionalAccess', _222 => _222.fontSize]), () => ( 0)))) < 0.5);
5346
+ const peers = anchors.filter((b) => _optionalChain([b, 'access', _217 => _217.style, 'optionalAccess', _218 => _218.fontName]) === _optionalChain([anchor, 'access', _219 => _219.style, 'optionalAccess', _220 => _220.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _221 => _221.style, 'optionalAccess', _222 => _222.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _223 => _223.style, 'optionalAccess', _224 => _224.fontSize]), () => ( 0)))) < 0.5);
5320
5347
  if (peers.length < 2 && !numbered && !lettered) continue;
5321
- const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _223 => _223.style, 'optionalAccess', _224 => _224.fontName]) === _optionalChain([anchor, 'access', _225 => _225.style, 'optionalAccess', _226 => _226.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _227 => _227.style, 'optionalAccess', _228 => _228.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _229 => _229.style, 'optionalAccess', _230 => _230.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _231 => _231.style, 'optionalAccess', _232 => _232.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()));
5348
+ const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _225 => _225.style, 'optionalAccess', _226 => _226.fontName]) === _optionalChain([anchor, 'access', _227 => _227.style, 'optionalAccess', _228 => _228.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _229 => _229.style, 'optionalAccess', _230 => _230.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _231 => _231.style, 'optionalAccess', _232 => _232.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _233 => _233.style, 'optionalAccess', _234 => _234.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()));
5322
5349
  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));
5323
5350
  if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
5324
5351
  for (const sibling of siblings) {
@@ -5337,13 +5364,13 @@ function detectRepeatedPageLabels(blocks) {
5337
5364
  }
5338
5365
  for (const page of byPage.values()) {
5339
5366
  const bodyChars = /* @__PURE__ */ new Map();
5340
- for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _233 => _233.style, 'optionalAccess', _234 => _234.fontName])) {
5367
+ for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _235 => _235.style, 'optionalAccess', _236 => _236.fontName])) {
5341
5368
  const faces = FACE_CHARS.get(b);
5342
5369
  if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
5343
5370
  else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
5344
5371
  }
5345
- const bodyFace = _optionalChain([[...bodyChars], 'access', _235 => _235.sort, 'call', _236 => _236((a, b) => b[1] - a[1]), 'access', _237 => _237[0], 'optionalAccess', _238 => _238[0]]);
5346
- const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _239 => _239.style, 'optionalAccess', _240 => _240.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);
5372
+ const bodyFace = _optionalChain([[...bodyChars], 'access', _237 => _237.sort, 'call', _238 => _238((a, b) => b[1] - a[1]), 'access', _239 => _239[0], 'optionalAccess', _240 => _240[0]]);
5373
+ const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _241 => _241.style, 'optionalAccess', _242 => _242.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);
5347
5374
  const groups = /* @__PURE__ */ new Map();
5348
5375
  for (const b of candidates) {
5349
5376
  const key = `${b.style.fontName}:${b.style.fontSize}`;
@@ -5379,19 +5406,19 @@ function detectPageLeadHeadings(blocks) {
5379
5406
  for (const page of byPage.values()) {
5380
5407
  const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
5381
5408
  const [first, second, third] = content;
5382
- if (!_optionalChain([first, 'optionalAccess', _241 => _241.bbox]) || !first.text || !_optionalChain([first, 'access', _242 => _242.style, 'optionalAccess', _243 => _243.fontSize]) || !second) continue;
5409
+ if (!_optionalChain([first, 'optionalAccess', _243 => _243.bbox]) || !first.text || !_optionalChain([first, 'access', _244 => _244.style, 'optionalAccess', _245 => _245.fontSize]) || !second) continue;
5383
5410
  const firstText = first.text.trim();
5384
5411
  const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
5385
5412
  const hasImage = page.some((b) => b.type === "image");
5386
- 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', _244 => _244.text, 'optionalAccess', _245 => _245.trim, 'call', _246 => _246()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _247 => _247.text, 'optionalAccess', _248 => _248.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
5413
+ 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', _246 => _246.text, 'optionalAccess', _247 => _247.trim, 'call', _248 => _248()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _249 => _249.text, 'optionalAccess', _250 => _250.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
5387
5414
  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);
5388
- const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _249 => _249.text, 'optionalAccess', _250 => _250.length]), () => ( 0))) >= 100;
5415
+ const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _251 => _251.text, 'optionalAccess', _252 => _252.length]), () => ( 0))) >= 100;
5389
5416
  if (firstIsTitle || firstAboveProse || firstIsSection) {
5390
5417
  first.type = "heading";
5391
5418
  first.level = 1;
5392
5419
  }
5393
- if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _251 => _251.style, 'optionalAccess', _252 => _252.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _253 => _253.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;
5394
- const distinctFace = _optionalChain([third, 'access', _254 => _254.style, 'optionalAccess', _255 => _255.fontName]) !== second.style.fontName;
5420
+ if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _253 => _253.style, 'optionalAccess', _254 => _254.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _255 => _255.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;
5421
+ const distinctFace = _optionalChain([third, 'access', _256 => _256.style, 'optionalAccess', _257 => _257.fontName]) !== second.style.fontName;
5395
5422
  const namedContents = /^Table of Contents$/i.test(second.text.trim());
5396
5423
  if (distinctFace && third.text.length >= 60 || namedContents) {
5397
5424
  second.type = "heading";
@@ -5402,24 +5429,24 @@ function detectPageLeadHeadings(blocks) {
5402
5429
  function refineDocumentStyleHeadings(blocks) {
5403
5430
  const faceChars = /* @__PURE__ */ new Map();
5404
5431
  for (const block of blocks) {
5405
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _256 => _256.style, 'optionalAccess', _257 => _257.fontName])) continue;
5432
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _258 => _258.style, 'optionalAccess', _259 => _259.fontName])) continue;
5406
5433
  faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
5407
5434
  }
5408
5435
  const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
5409
5436
  if (!bodyFace || !bodyChars || bodyChars < 300) return;
5410
5437
  for (let i = 0; i < blocks.length; i++) {
5411
5438
  const block = blocks[i];
5412
- const text = _nullishCoalesce(_optionalChain([block, 'access', _258 => _258.text, 'optionalAccess', _259 => _259.trim, 'call', _260 => _260()]), () => ( ""));
5439
+ const text = _nullishCoalesce(_optionalChain([block, 'access', _260 => _260.text, 'optionalAccess', _261 => _261.trim, 'call', _262 => _262()]), () => ( ""));
5413
5440
  if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
5414
5441
  block.type = "paragraph";
5415
5442
  block.level = void 0;
5416
5443
  continue;
5417
5444
  }
5418
5445
  const box = block.bbox, style = block.style;
5419
- if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _261 => _261.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;
5446
+ if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _263 => _263.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;
5420
5447
  const previous = blocks[i - 1], next = blocks[i + 1];
5421
- const pb = _optionalChain([previous, 'optionalAccess', _262 => _262.bbox]), nb = _optionalChain([next, 'optionalAccess', _263 => _263.bbox]);
5422
- if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _264 => _264.style, 'optionalAccess', _265 => _265.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;
5448
+ const pb = _optionalChain([previous, 'optionalAccess', _264 => _264.bbox]), nb = _optionalChain([next, 'optionalAccess', _265 => _265.bbox]);
5449
+ if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _266 => _266.style, 'optionalAccess', _267 => _267.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;
5423
5450
  block.type = "heading";
5424
5451
  block.level = 2;
5425
5452
  }
@@ -5469,7 +5496,7 @@ function detectMarkerHeadings(blocks) {
5469
5496
  block.level = 4;
5470
5497
  continue;
5471
5498
  }
5472
- if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _266 => _266.style, 'optionalAccess', _267 => _267.fontSize])) {
5499
+ if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _268 => _268.style, 'optionalAccess', _269 => _269.fontSize])) {
5473
5500
  const prev = blocks[i - 1];
5474
5501
  const next = blocks[i + 1];
5475
5502
  const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
@@ -5510,7 +5537,7 @@ function detectTableCaptions(blocks) {
5510
5537
  block.table.caption = blocks[i - 1].text.trim();
5511
5538
  blocks.splice(i - 1, 1);
5512
5539
  i--;
5513
- } else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _268 => _268[i + 2], 'optionalAccess', _269 => _269.type]) !== "table") {
5540
+ } else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _270 => _270[i + 2], 'optionalAccess', _271 => _271.type]) !== "table") {
5514
5541
  block.table.caption = blocks[i + 1].text.trim();
5515
5542
  blocks.splice(i + 1, 1);
5516
5543
  }
@@ -5717,6 +5744,20 @@ function detectSpecialKoreanTables(blocks) {
5717
5744
  flushKvTable();
5718
5745
  return result;
5719
5746
  }
5747
+ function tracksPages(occ) {
5748
+ const nums = occ.map((o) => [...o.text.matchAll(/\d+/g)].map((m) => +m[0]));
5749
+ if (!nums.length || nums.some((n) => n.length !== nums[0].length)) return false;
5750
+ return nums[0].some((_, j) => new Set(occ.map((o, k) => o.page - nums[k][j])).size === 1);
5751
+ }
5752
+ function looseVaryingNumber(occ) {
5753
+ const nums = occ.map((o) => [...o.text.matchAll(/\d+/g)]);
5754
+ if (!nums.length || nums.some((n) => n.length !== nums[0].length)) return false;
5755
+ const loose = (text, m) => !/\p{L}/u.test(_nullishCoalesce(text[m.index - 1], () => ( " "))) && !/\p{L}/u.test(_nullishCoalesce(text[m.index + m[0].length], () => ( " ")));
5756
+ for (let j = 0; j < nums[0].length; j++) {
5757
+ if (new Set(nums.map((n) => n[j][0])).size > 1 && occ.every((o, k) => loose(o.text, nums[k][j]))) return true;
5758
+ }
5759
+ return false;
5760
+ }
5720
5761
  function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables = false, context = []) {
5721
5762
  if (context.length && !tables) {
5722
5763
  const removed = removeHeaderFooterBlocks([...blocks, ...context], pageHeights, [], notes).filter((index) => index < blocks.length);
@@ -5729,7 +5770,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
5729
5770
  const bottomEntries = [];
5730
5771
  for (let bi = 0; bi < blocks.length; bi++) {
5731
5772
  const b = blocks[bi];
5732
- const text = !tables ? _optionalChain([b, 'access', _270 => _270.text, 'optionalAccess', _271 => _271.trim, 'call', _272 => _272()]) : b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean).join(" | ") : void 0;
5773
+ const text = !tables ? _optionalChain([b, 'access', _272 => _272.text, 'optionalAccess', _273 => _273.trim, 'call', _274 => _274()]) : b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean).join(" | ") : void 0;
5733
5774
  if (!b.bbox || !b.pageNumber || !text) continue;
5734
5775
  const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
5735
5776
  if (!ph) continue;
@@ -5746,6 +5787,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
5746
5787
  const patternCount = /* @__PURE__ */ new Map();
5747
5788
  const patternPages = /* @__PURE__ */ new Map();
5748
5789
  const patternNumbers = /* @__PURE__ */ new Map();
5790
+ const patternOcc = /* @__PURE__ */ new Map();
5749
5791
  for (const e of entries) {
5750
5792
  const norm = e.text.replace(/\d+/g, "#");
5751
5793
  patternCount.set(norm, (patternCount.get(norm) || 0) + 1);
@@ -5755,21 +5797,26 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
5755
5797
  const pages = patternPages.get(norm) || /* @__PURE__ */ new Set();
5756
5798
  pages.add(e.page);
5757
5799
  patternPages.set(norm, pages);
5800
+ patternOcc.set(norm, [..._nullishCoalesce(patternOcc.get(norm), () => ( [])), e]);
5758
5801
  }
5759
5802
  const repeatedPatterns = /* @__PURE__ */ new Set();
5760
5803
  for (const [p, count] of patternCount) {
5761
5804
  const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
5762
5805
  const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
5763
- const pageNumbered = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _273 => _273.get, 'call', _274 => _274(p), 'optionalAccess', _275 => _275.size]), () => ( 0))) > 1;
5764
- if (count >= MIN_REPEAT2 && pages.length >= MIN_REPEAT2 && (pages.length >= span2 * 0.4 || pageNumbered)) {
5806
+ const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _275 => _275.get, 'call', _276 => _276(p), 'optionalAccess', _277 => _277.size]), () => ( 0))) > 1;
5807
+ const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
5808
+ const dense = pages.length >= span2 * 0.4;
5809
+ const loose = looseVaryingNumber(occ) && (entries === bottomEntries || dense || tracksPages(occ));
5810
+ const pageNumbered = varying && (loose || dense && new Set(occ.map((o) => o.text)).size * 2 <= occ.length);
5811
+ if (count >= MIN_REPEAT2 && pages.length >= MIN_REPEAT2 && (varying ? pageNumbered : dense)) {
5765
5812
  repeatedPatterns.add(p);
5766
5813
  }
5767
5814
  }
5768
5815
  for (const e of entries) {
5769
5816
  const norm = e.text.replace(/\d+/g, "#");
5770
5817
  if (!repeatedPatterns.has(norm)) continue;
5771
- const noteMark = _optionalChain([e, 'access', _276 => _276.text, 'access', _277 => _277.match, 'call', _278 => _278(/^\d{1,3}\)/), 'optionalAccess', _279 => _279[0]]);
5772
- if (noteMark && _optionalChain([notes, 'optionalAccess', _280 => _280.get, 'call', _281 => _281(e.page), 'optionalAccess', _282 => _282.marks, 'access', _283 => _283.some, 'call', _284 => _284((m) => m.mark === noteMark)])) continue;
5818
+ const noteMark = _optionalChain([e, 'access', _278 => _278.text, 'access', _279 => _279.match, 'call', _280 => _280(/^\d{1,3}\)/), 'optionalAccess', _281 => _281[0]]);
5819
+ if (noteMark && _optionalChain([notes, 'optionalAccess', _282 => _282.get, 'call', _283 => _283(e.page), 'optionalAccess', _284 => _284.marks, 'access', _285 => _285.some, 'call', _286 => _286((m) => m.mark === noteMark)])) continue;
5773
5820
  const cand = blocks[e.blockIdx];
5774
5821
  const cb = cand.bbox;
5775
5822
  const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::])/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
@@ -5783,7 +5830,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
5783
5830
  if (bi === e.blockIdx) continue;
5784
5831
  const o = blocks[bi];
5785
5832
  if (!o.bbox || o.bbox.page !== cb.page) continue;
5786
- const oNorm = _optionalChain([o, 'access', _285 => _285.text, 'optionalAccess', _286 => _286.trim, 'call', _287 => _287(), 'access', _288 => _288.replace, 'call', _289 => _289(/\d+/g, "#")]);
5833
+ const oNorm = _optionalChain([o, 'access', _287 => _287.text, 'optionalAccess', _288 => _288.trim, 'call', _289 => _289(), 'access', _290 => _290.replace, 'call', _291 => _291(/\d+/g, "#")]);
5787
5834
  if (oNorm && repeatedPatterns.has(oNorm)) continue;
5788
5835
  const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
5789
5836
  if (overlap2 >= cb.height * 0.5) {
@@ -5799,6 +5846,59 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
5799
5846
  }
5800
5847
  return [...removeSet].sort((a, b) => a - b);
5801
5848
  }
5849
+ function runningLinePatterns(removed, pageHeights) {
5850
+ const occ = /* @__PURE__ */ new Map();
5851
+ for (const b of removed) {
5852
+ const ph = b.bbox && b.pageNumber ? pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber) : void 0;
5853
+ const key = b.text ? runningKey(b.text) : "";
5854
+ if (!ph || !b.bbox || !b.pageNumber || !/\p{L}/u.test(key) || ph - b.bbox.y <= ph * 0.5) continue;
5855
+ (_nullishCoalesce(occ.get(key), () => ( occ.set(key, []).get(key)))).push({ page: b.pageNumber, nums: (_nullishCoalesce(b.text.match(/\d+/g), () => ( []))).join(",") });
5856
+ }
5857
+ const out = /* @__PURE__ */ new Map();
5858
+ for (const [key, list] of occ) {
5859
+ if (!pageNumberAtEnd(key)) continue;
5860
+ const offsets = new Set(list.map((o) => o.page - +o.nums));
5861
+ if (offsets.size === 1) out.set(key, [...offsets][0]);
5862
+ }
5863
+ return out;
5864
+ }
5865
+ var runningKey = (s) => s.replace(/\d+/g, "#").replace(/\s+/g, " ").trim();
5866
+ var pageNumberAtEnd = (key) => (_nullishCoalesce(key.match(/#/g), () => ( []))).length === 1 && /#\s*[)\]]?$/.test(key);
5867
+ function stripAbsorbedRunningLines(blocks, pageHeights, running) {
5868
+ if (!running.size) return blocks;
5869
+ const matches = (line, page) => {
5870
+ const offset = running.get(runningKey(line));
5871
+ return offset !== void 0 && page - +(_nullishCoalesce(line.match(/\d+/g), () => ( []))).pop() === offset;
5872
+ };
5873
+ const out = [];
5874
+ for (const b of blocks) {
5875
+ const ph = b.bbox && b.pageNumber ? pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber) : void 0;
5876
+ if (!ph || !b.bbox || !b.pageNumber || b.bbox.y > ph * 0.12) {
5877
+ out.push(b);
5878
+ continue;
5879
+ }
5880
+ if (b.type === "paragraph" && b.text) {
5881
+ const lines = b.text.split("\n");
5882
+ let hi = lines.length;
5883
+ while (hi > 0 && !lines[hi - 1].trim()) hi--;
5884
+ if (hi > 0 && matches(lines[hi - 1], b.pageNumber)) {
5885
+ const text = lines.slice(0, hi - 1).join("\n").trim();
5886
+ if (!text) continue;
5887
+ b.text = text;
5888
+ }
5889
+ } else if (b.type === "table" && b.table && b.table.cells.length) {
5890
+ const t = b.table, last = t.cells.length - 1;
5891
+ if (matches(t.cells[last].map((c) => c.text.trim()).filter(Boolean).join(" "), b.pageNumber) && !t.cells.slice(0, last).some((row, i) => row.some((c) => i + (c.rowSpan || 1) - 1 >= last))) {
5892
+ t.cells.pop();
5893
+ if (!t.cells.length) continue;
5894
+ t.rows = t.cells.length;
5895
+ t.hasHeader = t.hasHeader && t.rows > 1;
5896
+ }
5897
+ }
5898
+ out.push(b);
5899
+ }
5900
+ return out;
5901
+ }
5802
5902
 
5803
5903
  // src/pdf/table-meta.ts
5804
5904
  var CLIP_TABLES = /* @__PURE__ */ new WeakSet();
@@ -5858,7 +5958,7 @@ function recordRowRules(table, cells, bbox, hs) {
5858
5958
  function markImageCell(cell) {
5859
5959
  IMAGE_CELLS.add(cell);
5860
5960
  }
5861
- var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _290 => _290.text, 'optionalAccess', _291 => _291.trim, 'call', _292 => _292()]) && !_optionalChain([cell, 'access', _293 => _293.blocks, 'optionalAccess', _294 => _294.length]) && !IMAGE_CELLS.has(cell);
5961
+ var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _292 => _292.text, 'optionalAccess', _293 => _293.trim, 'call', _294 => _294()]) && !_optionalChain([cell, 'access', _295 => _295.blocks, 'optionalAccess', _296 => _296.length]) && !IMAGE_CELLS.has(cell);
5862
5962
  function trimTable(table) {
5863
5963
  let cols = table.cols;
5864
5964
  while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
@@ -5874,7 +5974,7 @@ function trimTable(table) {
5874
5974
  function trimTrailingEmptyTableCols(blocks) {
5875
5975
  for (const b of blocks) {
5876
5976
  if (b.type !== "table" || !b.table) continue;
5877
- for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _295 => _295.blocks, 'optionalAccess', _296 => _296.length])) trimTrailingEmptyTableCols(cell.blocks);
5977
+ for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _297 => _297.blocks, 'optionalAccess', _298 => _298.length])) trimTrailingEmptyTableCols(cell.blocks);
5878
5978
  trimTable(b.table);
5879
5979
  }
5880
5980
  }
@@ -5894,7 +5994,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
5894
5994
  }
5895
5995
  const ok = owner.every((row) => {
5896
5996
  const o = row[c];
5897
- return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _297 => _297.blocks, 'optionalAccess', _298 => _298.length]));
5997
+ return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _299 => _299.blocks, 'optionalAccess', _300 => _300.length]));
5898
5998
  });
5899
5999
  if (!ok) continue;
5900
6000
  const spanning = /* @__PURE__ */ new Set();
@@ -5921,7 +6021,7 @@ var multiply = (m, t) => [
5921
6021
  m[1] * t[4] + m[3] * t[5] + m[5]
5922
6022
  ];
5923
6023
  function hollowCircle(image) {
5924
- if (!_optionalChain([image, 'optionalAccess', _299 => _299.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;
6024
+ if (!_optionalChain([image, 'optionalAccess', _301 => _301.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;
5925
6025
  const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
5926
6026
  const { width, height, data } = image;
5927
6027
  if (!stride || data.length < width * height * stride) return false;
@@ -5986,9 +6086,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
5986
6086
  const op = fnArray[i], args = argsArray[i];
5987
6087
  if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
5988
6088
  stack.push({ ctm, alpha, clip, unknownClip });
5989
- const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _300 => _300[0]]) : void 0;
6089
+ const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _302 => _302[0]]) : void 0;
5990
6090
  if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
5991
- const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _301 => _301[1]]) : void 0;
6091
+ const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _303 => _303[1]]) : void 0;
5992
6092
  if (Array.isArray(bounds) && bounds.length === 4) {
5993
6093
  const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
5994
6094
  if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
@@ -5996,17 +6096,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
5996
6096
  }
5997
6097
  } else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
5998
6098
  const state = stack.pop();
5999
- ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _302 => _302.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
6000
- alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _303 => _303.alpha]), () => ( 1));
6001
- clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _304 => _304.clip]), () => ( null));
6002
- unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _305 => _305.unknownClip]), () => ( false));
6099
+ ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _304 => _304.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
6100
+ alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _305 => _305.alpha]), () => ( 1));
6101
+ clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _306 => _306.clip]), () => ( null));
6102
+ unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _307 => _307.unknownClip]), () => ( false));
6003
6103
  } else if (op === _pdfmjs.OPS.setGState) {
6004
- for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _306 => _306[0]]), () => ( []))) {
6104
+ for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _308 => _308[0]]), () => ( []))) {
6005
6105
  if (key === "ca") alpha = typeof value === "number" ? value : 0;
6006
6106
  }
6007
6107
  } else if (op === _pdfmjs.OPS.constructPath) {
6008
6108
  const [operations, coordinates] = args;
6009
- pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _307 => _307.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _308 => _308.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
6109
+ pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _309 => _309.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _310 => _310.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
6010
6110
  } else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
6011
6111
  else if ([
6012
6112
  _pdfmjs.OPS.endPath,
@@ -6026,7 +6126,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
6026
6126
  pendingClip = false;
6027
6127
  pathRect = void 0;
6028
6128
  } else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
6029
- else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _309 => _309[0]]) === "string") {
6129
+ else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _311 => _311[0]]) === "string") {
6030
6130
  if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
6031
6131
  const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
6032
6132
  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;
@@ -6045,14 +6145,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
6045
6145
  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];
6046
6146
  if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
6047
6147
  const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
6048
- if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _310 => _310.text, 'access', _311 => _311.match, 'call', _312 => _312(/\p{L}/gu), 'optionalAccess', _313 => _313.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
6148
+ if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _312 => _312.text, 'access', _313 => _313.match, 'call', _314 => _314(/\p{L}/gu), 'optionalAccess', _315 => _315.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
6049
6149
  candidates.push({ id, x: box.x1, width, line });
6050
6150
  }
6051
6151
  let restored = 0;
6052
6152
  const used = /* @__PURE__ */ new Set();
6053
6153
  for (const candidate of candidates) {
6054
6154
  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);
6055
- 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', _314 => _314.text, 'access', _315 => _315.match, 'call', _316 => _316(/\p{L}/gu), 'optionalAccess', _317 => _317.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
6155
+ 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', _316 => _316.text, 'access', _317 => _317.match, 'call', _318 => _318(/\p{L}/gu), 'optionalAccess', _319 => _319.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
6056
6156
  const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
6057
6157
  if (!same.length && !numberedList || used.has(candidate.line)) continue;
6058
6158
  if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
@@ -6118,7 +6218,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
6118
6218
  return units;
6119
6219
  }
6120
6220
  function arrowDirection(image) {
6121
- if (!_optionalChain([image, 'optionalAccess', _318 => _318.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
6221
+ if (!_optionalChain([image, 'optionalAccess', _320 => _320.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
6122
6222
  const { width, height, data } = image;
6123
6223
  const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
6124
6224
  if (!stride || data.length < width * height * stride) return 0;
@@ -6186,7 +6286,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
6186
6286
  function removeSideTabs(blocks, pageWidths) {
6187
6287
  const edges = /* @__PURE__ */ new Map();
6188
6288
  for (const b of blocks) {
6189
- if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _319 => _319.text, 'optionalAccess', _320 => _320.trim, 'call', _321 => _321()]), () => ( ""))].length <= MAX_CHARS) continue;
6289
+ if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _321 => _321.text, 'optionalAccess', _322 => _322.trim, 'call', _323 => _323()]), () => ( ""))].length <= MAX_CHARS) continue;
6190
6290
  const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
6191
6291
  e.lefts.push(b.bbox.x);
6192
6292
  e.rights.push(b.bbox.x + b.bbox.width);
@@ -6202,7 +6302,7 @@ function removeSideTabs(blocks, pageWidths) {
6202
6302
  const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
6203
6303
  const key = (b) => {
6204
6304
  const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
6205
- const text = _optionalChain([b, 'access', _322 => _322.text, 'optionalAccess', _323 => _323.trim, 'call', _324 => _324()]);
6305
+ const text = _optionalChain([b, 'access', _324 => _324.text, 'optionalAccess', _325 => _325.trim, 'call', _326 => _326()]);
6206
6306
  const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
6207
6307
  if (b.type === "table") {
6208
6308
  if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
@@ -6551,16 +6651,16 @@ function isProseSpread(items) {
6551
6651
  for (let i = 1; i < sorted.length; i++) {
6552
6652
  gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
6553
6653
  }
6554
- const maxGap = _chunk3KW2Q655cjs.safeMax.call(void 0, gaps);
6654
+ const maxGap = _chunkMCUX2Y2Ccjs.safeMax.call(void 0, gaps);
6555
6655
  const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
6556
6656
  if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
6557
- const minGap = _chunk3KW2Q655cjs.safeMin.call(void 0, gaps);
6657
+ const minGap = _chunkMCUX2Y2Ccjs.safeMin.call(void 0, gaps);
6558
6658
  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;
6559
6659
  }
6560
6660
  function detectColumns(yLines) {
6561
6661
  const allItems = yLines.flat();
6562
6662
  if (allItems.length === 0) return null;
6563
- const pageWidth = _chunk3KW2Q655cjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunk3KW2Q655cjs.safeMin.call(void 0, allItems.map((i) => i.x));
6663
+ const pageWidth = _chunkMCUX2Y2Ccjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkMCUX2Y2Ccjs.safeMin.call(void 0, allItems.map((i) => i.x));
6564
6664
  if (pageWidth < 100) return null;
6565
6665
  let bigoLineIdx = -1;
6566
6666
  for (let i = 0; i < yLines.length; i++) {
@@ -6785,7 +6885,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
6785
6885
  var UNDER_BOX_PAIR_OVERLAP = 0.8;
6786
6886
  function markUnderlineItems(items, horizontals, verticals, nonRules) {
6787
6887
  const underlines = [];
6788
- if (_optionalChain([nonRules, 'optionalAccess', _325 => _325.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
6888
+ if (_optionalChain([nonRules, 'optionalAccess', _327 => _327.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
6789
6889
  if (items.length === 0 || horizontals.length === 0) return underlines;
6790
6890
  const tightOwners = /* @__PURE__ */ new Map();
6791
6891
  const tightlyOwned = (line) => {
@@ -6891,7 +6991,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
6891
6991
  if (ow <= 0) continue;
6892
6992
  const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
6893
6993
  if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
6894
- const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _326 => _326.reduce, 'call', _327 => _327((sum, item) => {
6994
+ const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _328 => _328.reduce, 'call', _329 => _329((sum, item) => {
6895
6995
  const below = item.y - o.y1;
6896
6996
  if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
6897
6997
  return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
@@ -7095,8 +7195,8 @@ function edgesOf(box, h, v, hNear = EDGE_NEAR2) {
7095
7195
  }
7096
7196
  function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
7097
7197
  if (!grids.some((g) => g.cells)) return;
7098
- const h = rules(_optionalChain([nonRules, 'optionalAccess', _328 => _328.size]) ? horizontals.filter((l) => !nonRules.has(l)) : horizontals, "h");
7099
- const v = rules(_optionalChain([nonRules, 'optionalAccess', _329 => _329.size]) ? verticals.filter((l) => !nonRules.has(l)) : verticals, "v");
7198
+ const h = rules(_optionalChain([nonRules, 'optionalAccess', _330 => _330.size]) ? horizontals.filter((l) => !nonRules.has(l)) : horizontals, "h");
7199
+ const v = rules(_optionalChain([nonRules, 'optionalAccess', _331 => _331.size]) ? verticals.filter((l) => !nonRules.has(l)) : verticals, "v");
7100
7200
  for (const g of grids) for (const c of _nullishCoalesce(g.cells, () => ( []))) {
7101
7201
  const near2 = c.filler ? Math.min(EDGE_NEAR2, (c.bbox.y2 - c.bbox.y1) / 3) : EDGE_NEAR2;
7102
7202
  CLIP_CELL_EDGES.set(c, edgesOf(c.bbox, h, v, near2));
@@ -7104,12 +7204,12 @@ function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
7104
7204
  }
7105
7205
  function takeClipCellEdges(from, to) {
7106
7206
  const e = CLIP_CELL_EDGES.get(from);
7107
- if (e) _chunkDZVZVZADcjs.CELL_EDGES.set(to, e);
7207
+ if (e) _chunkT7PN5D4Dcjs.CELL_EDGES.set(to, e);
7108
7208
  }
7109
7209
  function joinCellEdges(a, b) {
7110
- const u = _chunkDZVZVZADcjs.CELL_EDGES.get(a), d = _chunkDZVZVZADcjs.CELL_EDGES.get(b);
7210
+ const u = _chunkT7PN5D4Dcjs.CELL_EDGES.get(a), d = _chunkT7PN5D4Dcjs.CELL_EDGES.get(b);
7111
7211
  if (!u || !d) return;
7112
- _chunkDZVZVZADcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
7212
+ _chunkT7PN5D4Dcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
7113
7213
  }
7114
7214
 
7115
7215
  // src/pdf/table-unit-row.ts
@@ -7125,12 +7225,12 @@ function rebuildUnitLine(items, grid) {
7125
7225
  function prependUnitRow(cells, cols, line, usedItems) {
7126
7226
  const text = cleanCellText(line.map((item) => item.text).join(""));
7127
7227
  cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
7128
- for (const cell of cells[0]) _chunkDZVZVZADcjs.CELL_EDGES.set(cell, NO_EDGES);
7228
+ for (const cell of cells[0]) _chunkT7PN5D4Dcjs.CELL_EDGES.set(cell, NO_EDGES);
7129
7229
  for (const item of line) usedItems.add(item);
7130
7230
  }
7131
7231
  function attachUnitRow(items, grid, cells, cols, usedItems) {
7132
7232
  const all = cells.flat();
7133
- if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _330 => _330[0], 'optionalAccess', _331 => _331[0], 'optionalAccess', _332 => _332.text]), () => ( "")))) return false;
7233
+ if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _332 => _332[0], 'optionalAccess', _333 => _333[0], 'optionalAccess', _334 => _334.text]), () => ( "")))) return false;
7134
7234
  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);
7135
7235
  let nearest = Infinity;
7136
7236
  for (const it of above) nearest = Math.min(nearest, it.y);
@@ -7165,7 +7265,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
7165
7265
  let hs = horizontals, vs = verticals;
7166
7266
  const restored = [];
7167
7267
  for (const grid of clipGrids) {
7168
- if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _333 => _333.cells, 'optionalAccess', _334 => _334.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
7268
+ if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _335 => _335.cells, 'optionalAccess', _336 => _336.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
7169
7269
  const { x1, x2, y1: mid, y2: top } = grid.bbox;
7170
7270
  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;
7171
7271
  const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
@@ -7577,7 +7677,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
7577
7677
  const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
7578
7678
  const runs = [];
7579
7679
  for (const item of [...line].sort((a, b) => a.x - b.x)) {
7580
- const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _335 => _335[run.length - 1]]);
7680
+ const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _337 => _337[run.length - 1]]);
7581
7681
  if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
7582
7682
  else runs.push([item]);
7583
7683
  }
@@ -7621,7 +7721,7 @@ function groupFrameParagraphUnits(units, frames) {
7621
7721
  for (const unit of units) for (const block of unit) source.set(block, unit);
7622
7722
  const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
7623
7723
  for (const frame of frames) {
7624
- if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _336 => _336.get, 'call', _337 => _337(block), 'optionalAccess', _338 => _338.length]) !== 1)) continue;
7724
+ if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _338 => _338.get, 'call', _339 => _339(block), 'optionalAccess', _340 => _340.length]) !== 1)) continue;
7625
7725
  for (const block of frame) members.set(block, frame);
7626
7726
  }
7627
7727
  const out = [];
@@ -7634,7 +7734,7 @@ function groupFrameParagraphUnits(units, frames) {
7634
7734
  }
7635
7735
  }
7636
7736
  for (const unit of out) {
7637
- if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _339 => _339.get, 'call', _340 => _340(unit[0]), 'optionalAccess', _341 => _341.blocks]) === unit) continue;
7737
+ if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _341 => _341.get, 'call', _342 => _342(unit[0]), 'optionalAccess', _343 => _343.blocks]) === unit) continue;
7638
7738
  const bs = unit.map((b) => b.bbox).filter((b) => !!b);
7639
7739
  if (bs.length !== unit.length) continue;
7640
7740
  const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
@@ -7651,14 +7751,14 @@ function groupFrameParagraphUnits(units, frames) {
7651
7751
  function recordFrameTitle(table, source, pageNum) {
7652
7752
  if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
7653
7753
  const cells = table.cells[0];
7654
- if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _342 => _342.blocks, 'optionalAccess', _343 => _343.length]) || c.text.includes("\n"))) return;
7754
+ if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _344 => _344.blocks, 'optionalAccess', _345 => _345.length]) || c.text.includes("\n"))) return;
7655
7755
  const [label, spacer, title] = cells;
7656
7756
  if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
7657
7757
  if (cells.some((c) => {
7658
- const e = _chunkDZVZVZADcjs.CELL_EDGES.get(c);
7758
+ const e = _chunkT7PN5D4Dcjs.CELL_EDGES.get(c);
7659
7759
  return !e || e.t || e.b || e.l || e.r;
7660
7760
  })) return;
7661
- const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _344 => _344.fontSize]), () => ( 0));
7761
+ const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _346 => _346.fontSize]), () => ( 0));
7662
7762
  if (!xs || xs.length !== 4 || fs <= 0) return;
7663
7763
  const width = xs[3] - xs[0], gap = xs[2] - xs[1];
7664
7764
  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;
@@ -7716,7 +7816,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
7716
7816
  const extended = [];
7717
7817
  for (let i = 0; i < clipGrids.length; i++) {
7718
7818
  const c = clipGrids[i], parent = c.clipParent;
7719
- if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _345 => _345.cells, 'optionalAccess', _346 => _346.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
7819
+ if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _347 => _347.cells, 'optionalAccess', _348 => _348.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
7720
7820
  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;
7721
7821
  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;
7722
7822
  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)));
@@ -7739,7 +7839,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
7739
7839
  bbox: computeBBox(items, pageNum),
7740
7840
  style: dominantStyle(items)
7741
7841
  });
7742
- const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _347 => _347.has, 'call', _348 => _348(g)])).map((g) => ({
7842
+ const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _349 => _349.has, 'call', _350 => _350(g)])).map((g) => ({
7743
7843
  type: "paragraph",
7744
7844
  text: g.text.trim(),
7745
7845
  pageNumber: pageNum,
@@ -7748,7 +7848,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
7748
7848
  }));
7749
7849
  const groups = /* @__PURE__ */ new Map();
7750
7850
  for (const g of ordered) {
7751
- const cap = _optionalChain([caps, 'optionalAccess', _349 => _349.get, 'call', _350 => _350(g)]);
7851
+ const cap = _optionalChain([caps, 'optionalAccess', _351 => _351.get, 'call', _352 => _352(g)]);
7752
7852
  if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
7753
7853
  }
7754
7854
  for (const [cap, glyphs] of groups) {
@@ -7782,7 +7882,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
7782
7882
  const filled = fillBlanks(items, horizontals, verticals);
7783
7883
  items = filled.items;
7784
7884
  horizontals = filled.horizontals;
7785
- const prevPage = _optionalChain([carry, 'optionalAccess', _351 => _351.page]) === pageNum - 1 ? carry.clip : void 0;
7885
+ const prevPage = _optionalChain([carry, 'optionalAccess', _353 => _353.page]) === pageNum - 1 ? carry.clip : void 0;
7786
7886
  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 };
7787
7887
  if (carry) {
7788
7888
  carry.page = pageNum;
@@ -8111,14 +8211,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
8111
8211
  if (!assignedItems.has(textItems[ti])) usedItems.delete(owners[ti]);
8112
8212
  }
8113
8213
  }
8114
- if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _352 => _352[0], 'optionalAccess', _353 => _353[0], 'optionalAccess', _354 => _354.text]), () => ( "")))) {
8214
+ if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _354 => _354[0], 'optionalAccess', _355 => _355[0], 'optionalAccess', _356 => _356.text]), () => ( "")))) {
8115
8215
  prependUnitRow(finalGrid, numCols, unitLine, usedItems);
8116
8216
  finalRows++;
8117
8217
  }
8118
8218
  if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
8119
8219
  let semanticOneColumn = false;
8120
8220
  if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
8121
- const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _355 => _355[0], 'optionalAccess', _356 => _356.text, 'access', _357 => _357.trim, 'call', _358 => _358()]));
8221
+ const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _357 => _357[0], 'optionalAccess', _358 => _358.text, 'access', _359 => _359.trim, 'call', _360 => _360()]));
8122
8222
  if (populatedRows.length >= 4) {
8123
8223
  const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
8124
8224
  const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
@@ -8214,7 +8314,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
8214
8314
  height: grid.bbox.y2 - grid.bbox.y1
8215
8315
  };
8216
8316
  if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
8217
- const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _359 => _359[0], 'optionalAccess', _360 => _360[0], 'optionalAccess', _361 => _361.text]), () => ( ""));
8317
+ const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _361 => _361[0], 'optionalAccess', _362 => _362[0], 'optionalAccess', _363 => _363.text]), () => ( ""));
8218
8318
  const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
8219
8319
  const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
8220
8320
  const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
@@ -8233,8 +8333,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
8233
8333
  }
8234
8334
  }
8235
8335
  if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
8236
- const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _362 => _362.cells, 'access', _363 => _363[0], 'optionalAccess', _364 => _364[0], 'optionalAccess', _365 => _365.blocks]) : void 0;
8237
- if (_optionalChain([paragraphs, 'optionalAccess', _366 => _366.length])) {
8336
+ const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _364 => _364.cells, 'access', _365 => _365[0], 'optionalAccess', _366 => _366[0], 'optionalAccess', _367 => _367.blocks]) : void 0;
8337
+ if (_optionalChain([paragraphs, 'optionalAccess', _368 => _368.length])) {
8238
8338
  blocks.push(...paragraphs);
8239
8339
  frameParagraphUnits.push(paragraphs);
8240
8340
  recordFrameReadingUnit(paragraphs, tableBbox);
@@ -8274,10 +8374,10 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
8274
8374
  spaceAfter: i.spaceAfter
8275
8375
  }));
8276
8376
  const proseColumns = findTwoColumnProseCutX(clusterItems) !== null || detectPersistentColumnGutter(remaining.map((i) => ({ x: i.x, y: i.y, w: i.w, h: i.h > 0 ? i.h : i.fontSize }))) !== null;
8277
- const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum)).filter((cr) => {
8377
+ const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
8278
8378
  const b = cr.bbox;
8279
8379
  const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
8280
- 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', _367 => _367.text, 'optionalAccess', _368 => _368.match, 'call', _369 => _369(/\p{L}/gu), 'optionalAccess', _370 => _370.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _371 => _371.table, 'optionalAccess', _372 => _372.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
8380
+ 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', _369 => _369.text, 'optionalAccess', _370 => _370.match, 'call', _371 => _371(/\p{L}/gu), 'optionalAccess', _372 => _372.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _373 => _373.table, 'optionalAccess', _374 => _374.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
8281
8381
  });
8282
8382
  if (clusterResults.length > 0) {
8283
8383
  const ciToIdx = /* @__PURE__ */ new Map();
@@ -8314,7 +8414,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
8314
8414
  groupSizes.push(1);
8315
8415
  }
8316
8416
  const allY = remaining.map((i) => i.y);
8317
- const pageH = _chunk3KW2Q655cjs.safeMax.call(void 0, allY) - _chunk3KW2Q655cjs.safeMin.call(void 0, allY);
8417
+ const pageH = _chunkMCUX2Y2Ccjs.safeMax.call(void 0, allY) - _chunkMCUX2Y2Ccjs.safeMin.call(void 0, allY);
8318
8418
  const gapThreshold = Math.max(15, pageH * 0.03);
8319
8419
  const sides = frameColumnTextBands(remaining, spanning, gx);
8320
8420
  const textBlocks = [];
@@ -8330,7 +8430,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
8330
8430
  finalTextBlocks.push(...detectListBlocks(textBlocks));
8331
8431
  } else {
8332
8432
  const allY = remaining.map((i) => i.y);
8333
- const pageH = _chunk3KW2Q655cjs.safeMax.call(void 0, allY) - _chunk3KW2Q655cjs.safeMin.call(void 0, allY);
8433
+ const pageH = _chunkMCUX2Y2Ccjs.safeMax.call(void 0, allY) - _chunkMCUX2Y2Ccjs.safeMin.call(void 0, allY);
8334
8434
  const gapThreshold = Math.max(15, pageH * 0.03);
8335
8435
  const groups = xyCutOrder(remaining, gapThreshold);
8336
8436
  const textBlocks = [];
@@ -8626,7 +8726,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
8626
8726
  if (regions) return regions.flatMap((region) => extractPageBlocksFallback(region, pageNum, false, detectTables, lex));
8627
8727
  }
8628
8728
  const rejected = { prose: 0 };
8629
- const clusterResults = detectTables ? detectClusterTables(clusterItems, pageNum, rejected) : [];
8729
+ const clusterResults = detectTables ? detectClusterTables(clusterItems, pageNum, rejected, lex) : [];
8630
8730
  if (clusterResults.length > 0) {
8631
8731
  const ciToIdx = /* @__PURE__ */ new Map();
8632
8732
  for (let ci = 0; ci < clusterItems.length; ci++) ciToIdx.set(clusterItems[ci], ci);
@@ -8658,7 +8758,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
8658
8758
  blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
8659
8759
  } else {
8660
8760
  const allY = items.map((i) => i.y);
8661
- const pageHeight = _chunk3KW2Q655cjs.safeMax.call(void 0, allY) - _chunk3KW2Q655cjs.safeMin.call(void 0, allY);
8761
+ const pageHeight = _chunkMCUX2Y2Ccjs.safeMax.call(void 0, allY) - _chunkMCUX2Y2Ccjs.safeMin.call(void 0, allY);
8662
8762
  const gapThreshold = Math.max(15, pageHeight * 0.03);
8663
8763
  const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap);
8664
8764
  for (const group of orderedGroups) {
@@ -8690,17 +8790,17 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
8690
8790
  const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
8691
8791
  return overlapW * overlapH >= b.width * b.height * 0.8;
8692
8792
  });
8693
- const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _373 => _373.text, 'optionalAccess', _374 => _374.match, 'call', _375 => _375(/[\p{L}\p{N}]/gu), 'optionalAccess', _376 => _376.length]), () => ( 0))) >= 2);
8793
+ const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _375 => _375.text, 'optionalAccess', _376 => _376.match, 'call', _377 => _377(/[\p{L}\p{N}]/gu), 'optionalAccess', _378 => _378.length]), () => ( 0))) >= 2);
8694
8794
  const axisFragments = rotatedAxisFragments(candidates);
8695
8795
  const accepted = candidates.filter((b) => {
8696
- if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _377 => _377.text, 'optionalAccess', _378 => _378.match, 'call', _379 => _379(/[\p{L}\p{N}]/gu), 'optionalAccess', _380 => _380.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
8796
+ if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _379 => _379.text, 'optionalAccess', _380 => _380.match, 'call', _381 => _381(/[\p{L}\p{N}]/gu), 'optionalAccess', _382 => _382.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
8697
8797
  const t = b.table;
8698
8798
  if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
8699
8799
  if (t.rows === 1 && t.cols === 1) {
8700
- const text = _nullishCoalesce(_optionalChain([t, 'access', _381 => _381.cells, 'access', _382 => _382[0], 'optionalAccess', _383 => _383[0], 'optionalAccess', _384 => _384.text]), () => ( ""));
8701
- return (_nullishCoalesce(_optionalChain([text, 'access', _385 => _385.match, 'call', _386 => _386(/\n/g), 'optionalAccess', _387 => _387.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _388 => _388.match, 'call', _389 => _389(/\d/g), 'optionalAccess', _390 => _390.length]), () => ( 0))) >= text.length * 0.25;
8800
+ const text = _nullishCoalesce(_optionalChain([t, 'access', _383 => _383.cells, 'access', _384 => _384[0], 'optionalAccess', _385 => _385[0], 'optionalAccess', _386 => _386.text]), () => ( ""));
8801
+ return (_nullishCoalesce(_optionalChain([text, 'access', _387 => _387.match, 'call', _388 => _388(/\n/g), 'optionalAccess', _389 => _389.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _390 => _390.match, 'call', _391 => _391(/\d/g), 'optionalAccess', _392 => _392.length]), () => ( 0))) >= text.length * 0.25;
8702
8802
  }
8703
- const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _391 => _391.cells, 'access', _392 => _392[0], 'optionalAccess', _393 => _393.filter, 'call', _394 => _394((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _395 => _395.length]), () => ( 0));
8803
+ const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _393 => _393.cells, 'access', _394 => _394[0], 'optionalAccess', _395 => _395.filter, 'call', _396 => _396((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _397 => _397.length]), () => ( 0));
8704
8804
  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);
8705
8805
  });
8706
8806
  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, () => ( "")))) : []);
@@ -8717,14 +8817,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
8717
8817
  for (const block of selected) {
8718
8818
  if (seen2.has(block)) continue;
8719
8819
  const frame = FRAME_READING_UNITS.get(block);
8720
- const source = _optionalChain([frame, 'optionalAccess', _396 => _396.blocks, 'access', _397 => _397.every, 'call', _398 => _398((member) => selectedSet.has(member))]) ? frame.blocks : [block];
8820
+ const source = _optionalChain([frame, 'optionalAccess', _398 => _398.blocks, 'access', _399 => _399.every, 'call', _400 => _400((member) => selectedSet.has(member))]) ? frame.blocks : [block];
8721
8821
  source.forEach((member) => seen2.add(member));
8722
8822
  const available = source.filter((member) => !hasOriginal(member));
8723
8823
  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 }));
8724
8824
  for (const unit of units) {
8725
8825
  const b = unit.bbox;
8726
8826
  const index = blocks.findIndex((existing) => {
8727
- const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _399 => _399.get, 'call', _400 => _400(existing), 'optionalAccess', _401 => _401.bbox]), () => ( existing.bbox));
8827
+ const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _401 => _401.get, 'call', _402 => _402(existing), 'optionalAccess', _403 => _403.bbox]), () => ( existing.bbox));
8728
8828
  if (existing.pageNumber !== page || !e) return false;
8729
8829
  const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
8730
8830
  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;
@@ -8742,16 +8842,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
8742
8842
  }
8743
8843
  function axisTick(block, candidates) {
8744
8844
  const b = block.bbox;
8745
- if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _402 => _402.text, 'optionalAccess', _403 => _403.trim, 'call', _404 => _404()]), () => ( "")))) return false;
8746
- const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _405 => _405.text, 'optionalAccess', _406 => _406.trim, 'call', _407 => _407()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
8845
+ if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _404 => _404.text, 'optionalAccess', _405 => _405.trim, 'call', _406 => _406()]), () => ( "")))) return false;
8846
+ const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _407 => _407.text, 'optionalAccess', _408 => _408.trim, 'call', _409 => _409()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
8747
8847
  const cy = b.y + b.height / 2, right = b.x + b.width;
8748
8848
  const row = numeric.filter((o) => Math.abs(o.bbox.y + o.bbox.height / 2 - cy) <= Math.min(o.bbox.height, b.height) * 0.35);
8749
8849
  const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
8750
8850
  return row.length >= 2 || column.length >= 2;
8751
8851
  }
8752
8852
  function supportedDiagramLabel(block, labels, region) {
8753
- const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _408 => _408.text, 'optionalAccess', _409 => _409.trim, 'call', _410 => _410()]), () => ( ""));
8754
- 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', _411 => _411.text, 'optionalAccess', _412 => _412.match, 'call', _413 => _413(/\p{N}/gu), 'optionalAccess', _414 => _414.length]), () => ( 0))) >= 2).length < 2) return false;
8853
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _410 => _410.text, 'optionalAccess', _411 => _411.trim, 'call', _412 => _412()]), () => ( ""));
8854
+ 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', _413 => _413.text, 'optionalAccess', _414 => _414.match, 'call', _415 => _415(/\p{N}/gu), 'optionalAccess', _416 => _416.length]), () => ( 0))) >= 2).length < 2) return false;
8755
8855
  let above = false, below = false;
8756
8856
  for (const label of labels) {
8757
8857
  const a = label.bbox, em = Math.max(b.height, a.height);
@@ -8766,7 +8866,7 @@ function rotatedAxisFragments(candidates) {
8766
8866
  const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
8767
8867
  const axes = [];
8768
8868
  for (const block of paragraphs) {
8769
- const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _415 => _415.text, 'optionalAccess', _416 => _416.trim, 'call', _417 => _417()]), () => ( ""));
8869
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _417 => _417.text, 'optionalAccess', _418 => _418.trim, 'call', _419 => _419()]), () => ( ""));
8770
8870
  if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
8771
8871
  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);
8772
8872
  if (axis) axis.push(block);
@@ -8783,8 +8883,8 @@ function rotatedAxisFragments(candidates) {
8783
8883
  const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
8784
8884
  if (top - bottom < em * 6) continue;
8785
8885
  const left = paragraphs.filter((block) => {
8786
- const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _418 => _418.text, 'optionalAccess', _419 => _419.trim, 'call', _420 => _420()]), () => ( ""));
8787
- return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _421 => _421.match, 'call', _422 => _422(/[\p{L}\p{N}]/gu), 'optionalAccess', _423 => _423.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;
8886
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _420 => _420.text, 'optionalAccess', _421 => _421.trim, 'call', _422 => _422()]), () => ( ""));
8887
+ return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _423 => _423.match, 'call', _424 => _424(/[\p{L}\p{N}]/gu), 'optionalAccess', _425 => _425.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;
8788
8888
  });
8789
8889
  const stack = left.filter((a) => left.some((b) => {
8790
8890
  if (a === b || !aligned(a, b)) return false;
@@ -8794,7 +8894,7 @@ function rotatedAxisFragments(candidates) {
8794
8894
  if (stack.length < 2) continue;
8795
8895
  for (const block of paragraphs) {
8796
8896
  const b = block.bbox;
8797
- 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', _424 => _424.text, 'optionalAccess', _425 => _425.trim, 'call', _426 => _426()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
8897
+ 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', _426 => _426.text, 'optionalAccess', _427 => _427.trim, 'call', _428 => _428()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
8798
8898
  }
8799
8899
  }
8800
8900
  return fragments;
@@ -8868,5 +8968,7 @@ function rowParagraphs(block) {
8868
8968
 
8869
8969
 
8870
8970
 
8871
- exports.OCR_DET_MODEL = OCR_DET_MODEL; exports.OCR_REC_MODEL = OCR_REC_MODEL; exports.OCR_REC_DICT = OCR_REC_DICT; exports.getOcrModelsDir = getOcrModelsDir; exports.ensureOcrModels = ensureOcrModels; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; 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.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.NO_EDGES = NO_EDGES; exports.joinCellEdges = joinCellEdges; exports.restoreImageBullets = restoreImageBullets; exports.detectRightArrowRegions = detectRightArrowRegions; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.UNRULED_REGION_TABLES = UNRULED_REGION_TABLES; exports.mergeOcrImageRegions = mergeOcrImageRegions;
8872
- //# sourceMappingURL=chunk-EYLEVRHT.cjs.map
8971
+
8972
+
8973
+ exports.OCR_DET_MODEL = OCR_DET_MODEL; exports.OCR_REC_MODEL = OCR_REC_MODEL; exports.OCR_REC_DICT = OCR_REC_DICT; exports.getOcrModelsDir = getOcrModelsDir; exports.ensureOcrModels = ensureOcrModels; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; 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.NO_EDGES = NO_EDGES; exports.joinCellEdges = joinCellEdges; exports.restoreImageBullets = restoreImageBullets; exports.detectRightArrowRegions = detectRightArrowRegions; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.UNRULED_REGION_TABLES = UNRULED_REGION_TABLES; exports.mergeOcrImageRegions = mergeOcrImageRegions;
8974
+ //# sourceMappingURL=chunk-TMUUDMDH.cjs.map