kordoc 4.24.69 → 4.24.70

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 (179) hide show
  1. package/README.md +3 -3
  2. package/dist/{-KG4BXVPV.js → -JPBHAOIR.js} +21 -21
  3. package/dist/{chunk-4SKZG3K4.cjs → chunk-3EPX46NF.cjs} +2 -2
  4. package/dist/{chunk-4SKZG3K4.cjs.map → chunk-3EPX46NF.cjs.map} +1 -1
  5. package/dist/{chunk-KXVMRGSM.js → chunk-6PVJCEF7.js} +2 -2
  6. package/dist/{chunk-I776RNAM.js → chunk-6SQF5PAM.js} +2 -2
  7. package/dist/{chunk-FQHTZNNA.js → chunk-6T6VP4AQ.js} +6 -6
  8. package/dist/{chunk-6RAP7IYO.js → chunk-6UNCF3PJ.js} +2 -2
  9. package/dist/{chunk-3APUYEC6.js → chunk-7CLI2Y6A.js} +2 -2
  10. package/dist/{chunk-6T2QXCFD.cjs → chunk-7D6KEQNU.cjs} +60 -59
  11. package/dist/chunk-7D6KEQNU.cjs.map +1 -0
  12. package/dist/{chunk-AQSU4NAT.cjs → chunk-A5MTYCTO.cjs} +8 -8
  13. package/dist/{chunk-AQSU4NAT.cjs.map → chunk-A5MTYCTO.cjs.map} +1 -1
  14. package/dist/{chunk-ZPSCL2UV.js → chunk-CVH5PB65.js} +2 -2
  15. package/dist/{chunk-SQXRRR75.cjs → chunk-EESBEBUC.cjs} +190 -170
  16. package/dist/chunk-EESBEBUC.cjs.map +1 -0
  17. package/dist/{chunk-OWYYRDZR.js → chunk-FPGY6TH2.js} +2 -2
  18. package/dist/{chunk-YJA4HQUO.js → chunk-G3UCY3T7.js} +2 -2
  19. package/dist/{chunk-R32ERRRI.js → chunk-G5YCISXC.js} +28 -8
  20. package/dist/chunk-G5YCISXC.js.map +1 -0
  21. package/dist/{chunk-ONKURIVQ.js → chunk-HUKGGV5M.js} +2 -2
  22. package/dist/{chunk-JDHX44G4.js → chunk-ICK4R4HF.js} +2 -2
  23. package/dist/{chunk-OZWNUIUS.cjs → chunk-JLMNWMZJ.cjs} +88 -88
  24. package/dist/{chunk-OZWNUIUS.cjs.map → chunk-JLMNWMZJ.cjs.map} +1 -1
  25. package/dist/{chunk-QXZZ37WG.js → chunk-JVVTJDJY.js} +3 -3
  26. package/dist/{chunk-3MQXPZ6R.js → chunk-KET32GPP.js} +3 -3
  27. package/dist/{chunk-3CUPBG7W.js → chunk-KV5YT6L4.js} +3 -3
  28. package/dist/{chunk-OYXFVDEL.js → chunk-LEITYWHM.js} +2 -2
  29. package/dist/{chunk-C3OMT5XO.js → chunk-MIERFAOB.js} +2 -2
  30. package/dist/{chunk-53KBBSHJ.js → chunk-MU7YOHDK.js} +2 -2
  31. package/dist/{chunk-LERHV2DV.js → chunk-N426QQP6.js} +2 -2
  32. package/dist/{chunk-V37SADMF.js → chunk-N6XPJBIS.js} +27 -7
  33. package/dist/chunk-N6XPJBIS.js.map +1 -0
  34. package/dist/{chunk-6RWM6WRI.cjs → chunk-NIFJSZR7.cjs} +3 -3
  35. package/dist/{chunk-6RWM6WRI.cjs.map → chunk-NIFJSZR7.cjs.map} +1 -1
  36. package/dist/{chunk-XHAM4CGG.js → chunk-O2RV2FMS.js} +7 -6
  37. package/dist/chunk-O2RV2FMS.js.map +1 -0
  38. package/dist/{chunk-OEBMM2WZ.js → chunk-OHSTI6C3.js} +2 -2
  39. package/dist/{chunk-5ZDXCGBI.cjs → chunk-OTIYXYOL.cjs} +104 -104
  40. package/dist/{chunk-5ZDXCGBI.cjs.map → chunk-OTIYXYOL.cjs.map} +1 -1
  41. package/dist/{chunk-EM6II5KB.js → chunk-Q4DDUA7U.js} +2 -2
  42. package/dist/{chunk-AAIU5QXZ.js → chunk-QTRQ4KM3.js} +2 -2
  43. package/dist/{chunk-3LYXCBQ6.js → chunk-R6J7X4ND.js} +2 -2
  44. package/dist/{chunk-MHRKKMCS.js → chunk-RTQ2N6DG.js} +6 -6
  45. package/dist/{chunk-4NPX2NIK.js → chunk-TAATW772.js} +10 -10
  46. package/dist/{chunk-U456OELH.js → chunk-UD7DB4U3.js} +2 -2
  47. package/dist/{chunk-YBV3DCBB.js → chunk-UMVD6PRZ.js} +3 -3
  48. package/dist/{chunk-6ZWX733V.js → chunk-VCRBRUCO.js} +7 -6
  49. package/dist/chunk-VCRBRUCO.js.map +1 -0
  50. package/dist/{chunk-KCA54CHN.js → chunk-VZ2J3654.js} +5 -5
  51. package/dist/{chunk-GMTI7GBK.js → chunk-WVQDRZF5.js} +11 -11
  52. package/dist/{chunk-EBBPXRLU.js → chunk-XHBJCOWB.js} +4 -4
  53. package/dist/{chunk-YYGN4RAC.cjs → chunk-XRZERCPJ.cjs} +3 -3
  54. package/dist/{chunk-YYGN4RAC.cjs.map → chunk-XRZERCPJ.cjs.map} +1 -1
  55. package/dist/{chunk-MQHAFMEU.js → chunk-YG42FESS.js} +15 -15
  56. package/dist/{chunk-PZ7NOQHD.js → chunk-YY54476T.js} +2 -2
  57. package/dist/{chunk-4P4ZWHNQ.js → chunk-ZMPNA2W7.js} +7 -7
  58. package/dist/chunks-7ABYRV7K.js +11 -0
  59. package/dist/cli.js +45 -45
  60. package/dist/{formula-TO3RLKBZ.js → formula-BJU6ZM3X.js} +3 -3
  61. package/dist/{formula-4HIPZCUM.cjs → formula-BVDS6XNY.cjs} +9 -9
  62. package/dist/{formula-4HIPZCUM.cjs.map → formula-BVDS6XNY.cjs.map} +1 -1
  63. package/dist/{formula-ACYUF2DL.js → formula-ESTBYQ67.js} +4 -4
  64. package/dist/generator-B5RBQFEP.js +18 -0
  65. package/dist/generator-JBGS3C5H.cjs +12 -0
  66. package/dist/{generator-UAEKNWCY.cjs.map → generator-JBGS3C5H.cjs.map} +1 -1
  67. package/dist/generator-NZFUFJL4.js +11 -0
  68. package/dist/{hancom-FCNE5FBM.js → hancom-FINYE4NT.js} +2 -2
  69. package/dist/{hancom-JLRWAJ7K.js → hancom-TE4NLTFM.js} +2 -2
  70. package/dist/{hancom-4FAVUJFH.cjs → hancom-YC2LGVBP.cjs} +5 -5
  71. package/dist/{hancom-4FAVUJFH.cjs.map → hancom-YC2LGVBP.cjs.map} +1 -1
  72. package/dist/{image-ocr-ZIHIC6E7.js → image-ocr-L256UYPI.js} +7 -7
  73. package/dist/{image-ocr-HGYEY56S.cjs → image-ocr-T77T2NQO.cjs} +28 -28
  74. package/dist/{image-ocr-HGYEY56S.cjs.map → image-ocr-T77T2NQO.cjs.map} +1 -1
  75. package/dist/{image-ocr-53K5Y7RJ.js → image-ocr-TB5QRYYM.js} +10 -10
  76. package/dist/index.cjs +1115 -1115
  77. package/dist/index.js +9 -9
  78. package/dist/mcp.js +36 -36
  79. package/dist/memo-VDT6J2FA.js +17 -0
  80. package/dist/{model-bundle-VR77PCZE.js → model-bundle-THGO5EUW.js} +5 -5
  81. package/dist/{models-CLF7ODRG.js → models-MKIZDK2U.js} +5 -5
  82. package/dist/{parse-worker-v2-WXRS3WBA.js → parse-worker-v2-MGNDWJDE.js} +22 -22
  83. package/dist/{parser-LKSBUPHG.js → parser-C6EZWRQM.js} +12 -12
  84. package/dist/{parser-H27KVKB7.js → parser-EULDI5W6.js} +9 -9
  85. package/dist/{parser-7UHFKMVL.cjs → parser-IC2X7P2S.cjs} +166 -166
  86. package/dist/{parser-7UHFKMVL.cjs.map → parser-IC2X7P2S.cjs.map} +1 -1
  87. package/dist/{pdf-ocr-ABMCDMIV.js → pdf-ocr-4Y6VPEZC.js} +9 -9
  88. package/dist/pdf-ocr-7SNY67NL.cjs +43 -0
  89. package/dist/{pdf-ocr-Z22C7K6C.cjs.map → pdf-ocr-7SNY67NL.cjs.map} +1 -1
  90. package/dist/{pdf-ocr-AYLXK6OF.js → pdf-ocr-LQ5SYFCE.js} +6 -6
  91. package/dist/{profile-io-HGOQULXZ.js → profile-io-SDJTSIFY.js} +3 -3
  92. package/dist/{rasterize-5RWYKMSP.js → rasterize-TGFUBV6B.js} +3 -3
  93. package/dist/{redact-doc-HNKVSOLJ.js → redact-doc-X5WKER3O.js} +21 -21
  94. package/dist/{render-TUDHFNDV.js → render-6KIT7GYL.js} +12 -12
  95. package/dist/{rewrite-fallback-EWVH2MR4.js → rewrite-fallback-ARYCZKU6.js} +13 -13
  96. package/dist/seal-4IPGOMFX.js +16 -0
  97. package/dist/{setup-5EEOZUUH.js → setup-ZEMI2HI4.js} +3 -3
  98. package/dist/to-hwpx-MVDTG25O.cjs +16 -0
  99. package/dist/{to-hwpx-RNZ72ZYF.cjs.map → to-hwpx-MVDTG25O.cjs.map} +1 -1
  100. package/dist/{to-hwpx-UHNIAQ2L.js → to-hwpx-QRVTR6VA.js} +4 -4
  101. package/dist/{to-hwpx-6KY7WGVN.js → to-hwpx-XCS6LSWE.js} +7 -7
  102. package/dist/visual-4D32BQGS.js +38 -0
  103. package/dist/{watch-SZJOKRCO.js → watch-LFL26YPL.js} +22 -22
  104. package/package.json +1 -1
  105. package/dist/chunk-6T2QXCFD.cjs.map +0 -1
  106. package/dist/chunk-6ZWX733V.js.map +0 -1
  107. package/dist/chunk-R32ERRRI.js.map +0 -1
  108. package/dist/chunk-SQXRRR75.cjs.map +0 -1
  109. package/dist/chunk-V37SADMF.js.map +0 -1
  110. package/dist/chunk-XHAM4CGG.js.map +0 -1
  111. package/dist/chunks-HN36MEGV.js +0 -11
  112. package/dist/generator-5NUDHWLL.js +0 -11
  113. package/dist/generator-K2CNNN64.js +0 -18
  114. package/dist/generator-UAEKNWCY.cjs +0 -12
  115. package/dist/memo-ALIRNVIU.js +0 -17
  116. package/dist/pdf-ocr-Z22C7K6C.cjs +0 -43
  117. package/dist/seal-R6WDXSRI.js +0 -16
  118. package/dist/to-hwpx-RNZ72ZYF.cjs +0 -16
  119. package/dist/visual-Z5HND4S7.js +0 -38
  120. /package/dist/{-KG4BXVPV.js.map → -JPBHAOIR.js.map} +0 -0
  121. /package/dist/{chunk-KXVMRGSM.js.map → chunk-6PVJCEF7.js.map} +0 -0
  122. /package/dist/{chunk-I776RNAM.js.map → chunk-6SQF5PAM.js.map} +0 -0
  123. /package/dist/{chunk-FQHTZNNA.js.map → chunk-6T6VP4AQ.js.map} +0 -0
  124. /package/dist/{chunk-6RAP7IYO.js.map → chunk-6UNCF3PJ.js.map} +0 -0
  125. /package/dist/{chunk-3APUYEC6.js.map → chunk-7CLI2Y6A.js.map} +0 -0
  126. /package/dist/{chunk-ZPSCL2UV.js.map → chunk-CVH5PB65.js.map} +0 -0
  127. /package/dist/{chunk-OWYYRDZR.js.map → chunk-FPGY6TH2.js.map} +0 -0
  128. /package/dist/{chunk-YJA4HQUO.js.map → chunk-G3UCY3T7.js.map} +0 -0
  129. /package/dist/{chunk-ONKURIVQ.js.map → chunk-HUKGGV5M.js.map} +0 -0
  130. /package/dist/{chunk-JDHX44G4.js.map → chunk-ICK4R4HF.js.map} +0 -0
  131. /package/dist/{chunk-QXZZ37WG.js.map → chunk-JVVTJDJY.js.map} +0 -0
  132. /package/dist/{chunk-3MQXPZ6R.js.map → chunk-KET32GPP.js.map} +0 -0
  133. /package/dist/{chunk-3CUPBG7W.js.map → chunk-KV5YT6L4.js.map} +0 -0
  134. /package/dist/{chunk-OYXFVDEL.js.map → chunk-LEITYWHM.js.map} +0 -0
  135. /package/dist/{chunk-C3OMT5XO.js.map → chunk-MIERFAOB.js.map} +0 -0
  136. /package/dist/{chunk-53KBBSHJ.js.map → chunk-MU7YOHDK.js.map} +0 -0
  137. /package/dist/{chunk-LERHV2DV.js.map → chunk-N426QQP6.js.map} +0 -0
  138. /package/dist/{chunk-OEBMM2WZ.js.map → chunk-OHSTI6C3.js.map} +0 -0
  139. /package/dist/{chunk-EM6II5KB.js.map → chunk-Q4DDUA7U.js.map} +0 -0
  140. /package/dist/{chunk-AAIU5QXZ.js.map → chunk-QTRQ4KM3.js.map} +0 -0
  141. /package/dist/{chunk-3LYXCBQ6.js.map → chunk-R6J7X4ND.js.map} +0 -0
  142. /package/dist/{chunk-MHRKKMCS.js.map → chunk-RTQ2N6DG.js.map} +0 -0
  143. /package/dist/{chunk-4NPX2NIK.js.map → chunk-TAATW772.js.map} +0 -0
  144. /package/dist/{chunk-U456OELH.js.map → chunk-UD7DB4U3.js.map} +0 -0
  145. /package/dist/{chunk-YBV3DCBB.js.map → chunk-UMVD6PRZ.js.map} +0 -0
  146. /package/dist/{chunk-KCA54CHN.js.map → chunk-VZ2J3654.js.map} +0 -0
  147. /package/dist/{chunk-GMTI7GBK.js.map → chunk-WVQDRZF5.js.map} +0 -0
  148. /package/dist/{chunk-EBBPXRLU.js.map → chunk-XHBJCOWB.js.map} +0 -0
  149. /package/dist/{chunk-MQHAFMEU.js.map → chunk-YG42FESS.js.map} +0 -0
  150. /package/dist/{chunk-PZ7NOQHD.js.map → chunk-YY54476T.js.map} +0 -0
  151. /package/dist/{chunk-4P4ZWHNQ.js.map → chunk-ZMPNA2W7.js.map} +0 -0
  152. /package/dist/{chunks-HN36MEGV.js.map → chunks-7ABYRV7K.js.map} +0 -0
  153. /package/dist/{formula-TO3RLKBZ.js.map → formula-BJU6ZM3X.js.map} +0 -0
  154. /package/dist/{formula-ACYUF2DL.js.map → formula-ESTBYQ67.js.map} +0 -0
  155. /package/dist/{generator-5NUDHWLL.js.map → generator-B5RBQFEP.js.map} +0 -0
  156. /package/dist/{generator-K2CNNN64.js.map → generator-NZFUFJL4.js.map} +0 -0
  157. /package/dist/{hancom-FCNE5FBM.js.map → hancom-FINYE4NT.js.map} +0 -0
  158. /package/dist/{hancom-JLRWAJ7K.js.map → hancom-TE4NLTFM.js.map} +0 -0
  159. /package/dist/{image-ocr-ZIHIC6E7.js.map → image-ocr-L256UYPI.js.map} +0 -0
  160. /package/dist/{image-ocr-53K5Y7RJ.js.map → image-ocr-TB5QRYYM.js.map} +0 -0
  161. /package/dist/{memo-ALIRNVIU.js.map → memo-VDT6J2FA.js.map} +0 -0
  162. /package/dist/{model-bundle-VR77PCZE.js.map → model-bundle-THGO5EUW.js.map} +0 -0
  163. /package/dist/{models-CLF7ODRG.js.map → models-MKIZDK2U.js.map} +0 -0
  164. /package/dist/{parse-worker-v2-WXRS3WBA.js.map → parse-worker-v2-MGNDWJDE.js.map} +0 -0
  165. /package/dist/{parser-LKSBUPHG.js.map → parser-C6EZWRQM.js.map} +0 -0
  166. /package/dist/{parser-H27KVKB7.js.map → parser-EULDI5W6.js.map} +0 -0
  167. /package/dist/{pdf-ocr-ABMCDMIV.js.map → pdf-ocr-4Y6VPEZC.js.map} +0 -0
  168. /package/dist/{pdf-ocr-AYLXK6OF.js.map → pdf-ocr-LQ5SYFCE.js.map} +0 -0
  169. /package/dist/{profile-io-HGOQULXZ.js.map → profile-io-SDJTSIFY.js.map} +0 -0
  170. /package/dist/{rasterize-5RWYKMSP.js.map → rasterize-TGFUBV6B.js.map} +0 -0
  171. /package/dist/{redact-doc-HNKVSOLJ.js.map → redact-doc-X5WKER3O.js.map} +0 -0
  172. /package/dist/{render-TUDHFNDV.js.map → render-6KIT7GYL.js.map} +0 -0
  173. /package/dist/{rewrite-fallback-EWVH2MR4.js.map → rewrite-fallback-ARYCZKU6.js.map} +0 -0
  174. /package/dist/{seal-R6WDXSRI.js.map → seal-4IPGOMFX.js.map} +0 -0
  175. /package/dist/{setup-5EEOZUUH.js.map → setup-ZEMI2HI4.js.map} +0 -0
  176. /package/dist/{to-hwpx-6KY7WGVN.js.map → to-hwpx-QRVTR6VA.js.map} +0 -0
  177. /package/dist/{to-hwpx-UHNIAQ2L.js.map → to-hwpx-XCS6LSWE.js.map} +0 -0
  178. /package/dist/{visual-Z5HND4S7.js.map → visual-4D32BQGS.js.map} +0 -0
  179. /package/dist/{watch-SZJOKRCO.js.map → watch-LFL26YPL.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
2
 
3
3
 
4
- var _chunk6RWM6WRIcjs = require('./chunk-6RWM6WRI.cjs');
4
+ var _chunkNIFJSZR7cjs = require('./chunk-NIFJSZR7.cjs');
5
5
 
6
6
 
7
7
 
@@ -9,11 +9,11 @@ var _chunk6RWM6WRIcjs = require('./chunk-6RWM6WRI.cjs');
9
9
 
10
10
 
11
11
 
12
- var _chunkAQSU4NATcjs = require('./chunk-AQSU4NAT.cjs');
12
+ var _chunkA5MTYCTOcjs = require('./chunk-A5MTYCTO.cjs');
13
13
 
14
14
 
15
15
 
16
- var _chunk4SKZG3K4cjs = require('./chunk-4SKZG3K4.cjs');
16
+ var _chunk3EPX46NFcjs = require('./chunk-3EPX46NF.cjs');
17
17
 
18
18
  // src/ocr/models.ts
19
19
  var _path = require('path');
@@ -65,7 +65,7 @@ var OCR_REC_DICT = {
65
65
  sizeMb: 1
66
66
  };
67
67
  function getOcrModelsDir() {
68
- return _chunk6RWM6WRIcjs.getModelsDir.call(void 0, "ppocr");
68
+ return _chunkNIFJSZR7cjs.getModelsDir.call(void 0, "ppocr");
69
69
  }
70
70
  var DEFAULT_OCR_MODELS = Object.freeze({
71
71
  det: { spec: OCR_DET_MODEL },
@@ -110,7 +110,7 @@ async function ensureOcrModelsFor(sel, onProgress) {
110
110
  if (!stamp || verifiedInProcess.get(path) !== stamp) todo.push(s.spec);
111
111
  }
112
112
  if (!todo.length) return;
113
- await _chunk6RWM6WRIcjs.ensureModelsIn.call(void 0, dir, todo, onProgress);
113
+ await _chunkNIFJSZR7cjs.ensureModelsIn.call(void 0, dir, todo, onProgress);
114
114
  for (const spec of todo) {
115
115
  const path = _path.join.call(void 0, dir, spec.filename), stamp = await fileStamp(path);
116
116
  if (stamp) verifiedInProcess.set(path, stamp);
@@ -3414,16 +3414,16 @@ function recordOpenEndCellEdges(grid, cells, horizontals) {
3414
3414
  }
3415
3415
  function takeClipCellEdges(from, to) {
3416
3416
  const e = CLIP_CELL_EDGES.get(from);
3417
- if (e) _chunkAQSU4NATcjs.CELL_EDGES.set(to, e);
3417
+ if (e) _chunkA5MTYCTOcjs.CELL_EDGES.set(to, e);
3418
3418
  }
3419
3419
  function hasOpenCellSeam(a, b) {
3420
- const u = _chunkAQSU4NATcjs.CELL_EDGES.get(a), d = _chunkAQSU4NATcjs.CELL_EDGES.get(b);
3420
+ const u = _chunkA5MTYCTOcjs.CELL_EDGES.get(a), d = _chunkA5MTYCTOcjs.CELL_EDGES.get(b);
3421
3421
  return !!u && !!d && u.t && !u.b && !d.t && d.b && u.l && u.r && d.l && d.r;
3422
3422
  }
3423
3423
  function joinCellEdges(a, b) {
3424
- const u = _chunkAQSU4NATcjs.CELL_EDGES.get(a), d = _chunkAQSU4NATcjs.CELL_EDGES.get(b);
3424
+ const u = _chunkA5MTYCTOcjs.CELL_EDGES.get(a), d = _chunkA5MTYCTOcjs.CELL_EDGES.get(b);
3425
3425
  if (!u || !d) return;
3426
- _chunkAQSU4NATcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
3426
+ _chunkA5MTYCTOcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
3427
3427
  }
3428
3428
 
3429
3429
  // src/pdf/cell-extract.ts
@@ -3608,7 +3608,7 @@ function tagScripts(text, lines) {
3608
3608
  const [s, e, kind] = marks[m];
3609
3609
  out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
3610
3610
  }
3611
- return _chunkAQSU4NATcjs.tidyScriptTags.call(void 0, out);
3611
+ return _chunkA5MTYCTOcjs.tidyScriptTags.call(void 0, out);
3612
3612
  }
3613
3613
 
3614
3614
  // src/pdf/line-wrap.ts
@@ -3848,7 +3848,8 @@ function joinPageBreakWraps(blocks, lex) {
3848
3848
  pageLeft.set(b.pageNumber, Math.min(_nullishCoalesce(pageLeft.get(b.pageNumber), () => ( Infinity)), b.bbox.x));
3849
3849
  }
3850
3850
  for (let i = blocks.length - 1; i > 0; i--) {
3851
- const a = blocks[i - 1], b = blocks[i];
3851
+ const note = i >= 2 && footnoteBetween(blocks[i - 2], blocks[i - 1], blocks[i]) ? blocks[i - 1] : null;
3852
+ const a = note ? blocks[i - 2] : blocks[i - 1], b = blocks[i];
3852
3853
  if (!a.pageNumber || b.pageNumber !== a.pageNumber + 1 || !a.text || !b.text) continue;
3853
3854
  if (a.type !== "paragraph" && a.type !== "list" || b.type !== "paragraph") continue;
3854
3855
  const last = a.bbox && PARA_LAST_LINE.get(a.bbox), fs = last ? last.fontSize : 0;
@@ -3872,8 +3873,17 @@ function joinPageBreakWraps(blocks, lex) {
3872
3873
  if (bl) PARA_LAST_LINE.set(a.bbox, bl);
3873
3874
  else PARA_LAST_LINE.delete(a.bbox);
3874
3875
  blocks.splice(i, 1);
3876
+ if (note) i--;
3875
3877
  }
3876
3878
  }
3879
+ function footnoteBetween(a, f, b) {
3880
+ if (f.type !== "paragraph" || !f.text || !a.pageNumber || f.pageNumber !== a.pageNumber || b.pageNumber !== a.pageNumber + 1) return false;
3881
+ const afs = _nullishCoalesce(_optionalChain([a, 'access', _101 => _101.style, 'optionalAccess', _102 => _102.fontSize]), () => ( 0)), ffs = _nullishCoalesce(_optionalChain([f, 'access', _103 => _103.style, 'optionalAccess', _104 => _104.fontSize]), () => ( 0));
3882
+ if (!afs || !ffs || ffs > afs * 0.95 || !a.bbox || !f.bbox || f.bbox.y + f.bbox.height > a.bbox.y + 1) return false;
3883
+ const at = _nullishCoalesce(_optionalChain([a, 'access', _105 => _105.text, 'optionalAccess', _106 => _106.replace, 'call', _107 => _107(MARKUP, ""), 'access', _108 => _108.trimEnd, 'call', _109 => _109()]), () => ( ""));
3884
+ if (/[가-힣]/.test(at) || SENTENCE_END.test(at)) return false;
3885
+ return /^(?:\d{1,2}\)?\s|\*|※)/.test(f.text.replace(MARKUP, "").trimStart());
3886
+ }
3877
3887
  function splitPageBreakWraps(blocks) {
3878
3888
  return blocks.flatMap((b) => {
3879
3889
  const cuts = b.bbox && PAGE_BREAK_JOINS.get(b.bbox);
@@ -3910,7 +3920,7 @@ function bodyLineJoins(lines, lex) {
3910
3920
  for (const l of lines) if (!HANGING.test(l.text) && l.right > inner) inner = l.right;
3911
3921
  const full = (l) => right - l.right < BODY_FULL_TOL * l.fontSize || right - inner <= 1.2 * l.fontSize && inner - l.right < BODY_FULL_TOL * l.fontSize;
3912
3922
  const nextWordNoRoom = (a, b) => {
3913
- const w = _optionalChain([b, 'access', _101 => _101.text, 'access', _102 => _102.trim, 'call', _103 => _103(), 'access', _104 => _104.match, 'call', _105 => _105(/^\S+/), 'optionalAccess', _106 => _106[0]]);
3923
+ const w = _optionalChain([b, 'access', _110 => _110.text, 'access', _111 => _111.trim, 'call', _112 => _112(), 'access', _113 => _113.match, 'call', _114 => _114(/^\S+/), 'optionalAccess', _115 => _115[0]]);
3914
3924
  const n = [...b.text.trim()].length;
3915
3925
  if (!w || n === 0) return false;
3916
3926
  const em = (b.right - b.left) / n;
@@ -3936,7 +3946,7 @@ function bodyLineJoins(lines, lex) {
3936
3946
  const a = lines[i], b = lines[i + 1];
3937
3947
  const fs = a.fontSize;
3938
3948
  const own = i === i1 ? p2 : p1;
3939
- const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess', _107 => _107.bodyPitch, 'call', _108 => _108(fs)]), () => ( Infinity));
3949
+ const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess', _116 => _116.bodyPitch, 'call', _117 => _117(fs)]), () => ( Infinity));
3940
3950
  const maxPitch = Number.isFinite(others) ? Math.min(BODY_MAX_PITCH_ABS_EM * fs, Math.max(BODY_MAX_PITCH_EM * fs, others * BODY_PITCH_REL)) : BODY_MAX_PITCH_EM * fs;
3941
3951
  const wordWrap = ragged && !full(a) && nextWordNoRoom(a, b) && !MULTI_LEVEL_NUMBER.test(b.text.trimStart());
3942
3952
  const wraps = fs > 0 && (full(a) || wordWrap) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && a.y - b.y < maxPitch && Math.abs(b.fontSize - fs) <= 0.15 * fs && !startsNewItem(a.text, b.text) && !(SENTENCE_END.test(a.text.trimEnd()) && MULTI_LEVEL_NUMBER.test(b.text.trimStart()));
@@ -4109,7 +4119,7 @@ function cellTextToString(items, wrap) {
4109
4119
  const merged = mergeSuperscriptRows(lines).map((line) => sortLineByX(line));
4110
4120
  const textLines = merged.map((s) => {
4111
4121
  if (s.length === 1) return s[0].text;
4112
- if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _109 => _109.lex]) && (wrap.lex.isWord(s[0].text + s[1].text) || wrap.lex.evidence(s[0].text, s[1].text) === "" || REGION_LABELS.has(s[0].text + s[1].text)) && s[1].x - (s[0].x + s[0].w) >= Math.max(s[0].fontSize, s[1].fontSize) * 1.5 && s[1].x + s[1].w - s[0].x >= wrap.box.x2 - wrap.box.x1 - Math.max(s[0].fontSize, s[1].fontSize) * 2) return s[0].text + s[1].text;
4122
+ if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _118 => _118.lex]) && (wrap.lex.isWord(s[0].text + s[1].text) || wrap.lex.evidence(s[0].text, s[1].text) === "" || REGION_LABELS.has(s[0].text + s[1].text)) && s[1].x - (s[0].x + s[0].w) >= Math.max(s[0].fontSize, s[1].fontSize) * 1.5 && s[1].x + s[1].w - s[0].x >= wrap.box.x2 - wrap.box.x1 - Math.max(s[0].fontSize, s[1].fontSize) * 2) return s[0].text + s[1].text;
4113
4123
  const evenSpaced = detectEvenSpacedItems(s, true);
4114
4124
  const tracked = trackedSpaces(s);
4115
4125
  const hangulLine = s.some((it) => /[가-힣]/.test(it.text));
@@ -4125,7 +4135,7 @@ function cellTextToString(items, wrap) {
4125
4135
  result += s[j].text;
4126
4136
  } else if (s[j].hasSpaceBefore && exactGap(s[j - 1], s[j], gap) >= avgFs * 0.05) {
4127
4137
  result += " " + s[j].text;
4128
- } else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _110 => _110[j]])) {
4138
+ } else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _119 => _119[j]])) {
4129
4139
  result += " " + s[j].text;
4130
4140
  } else {
4131
4141
  result += s[j].text;
@@ -4252,12 +4262,12 @@ function markEvenRun(items, visible, result, start, end) {
4252
4262
  }
4253
4263
  function mergeCellTextLines(textLines, wrap) {
4254
4264
  if (textLines.length <= 1) return textLines[0] || "";
4255
- const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess', _111 => _111.wraps, 'access', _112 => _112[k]]) && (_nullishCoalesce(_optionalChain([wrap, 'access', _113 => _113.wide, 'optionalAccess', _114 => _114[k]]), () => ( true)));
4265
+ const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess', _120 => _120.wraps, 'access', _121 => _121[k]]) && (_nullishCoalesce(_optionalChain([wrap, 'access', _122 => _122.wide, 'optionalAccess', _123 => _123[k]]), () => ( true)));
4256
4266
  const merged = [textLines[0]];
4257
4267
  for (let i = 1; i < textLines.length; i++) {
4258
4268
  const prev = merged[merged.length - 1];
4259
4269
  const curr = textLines[i];
4260
- if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access', _115 => _115.spaced, 'optionalAccess', _116 => _116[i - 1]]) && !startsNewItem(prev, curr) && wrapJoiner(prev, curr, wrap.lex, false) === "" : /[가-힣]$/.test(prev) && /^[가-힣]+$/.test(curr) && curr.length <= 8 && !curr.includes(" ")) {
4270
+ if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access', _124 => _124.spaced, 'optionalAccess', _125 => _125[i - 1]]) && !startsNewItem(prev, curr) && wrapJoiner(prev, curr, wrap.lex, false) === "" : /[가-힣]$/.test(prev) && /^[가-힣]+$/.test(curr) && curr.length <= 8 && !curr.includes(" ")) {
4261
4271
  merged[merged.length - 1] = prev + curr;
4262
4272
  } else if (curr.trim().length <= 3 && /^[)\]%}]/.test(curr.trim())) {
4263
4273
  merged[merged.length - 1] = prev + curr.trim();
@@ -4397,34 +4407,34 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs, kept,
4397
4407
  if (numRows > maxRows || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
4398
4408
  if (items.length === 0) return null;
4399
4409
  if (numRows >= 3) {
4400
- if (_optionalChain([rowYs, 'optionalAccess', _117 => _117.length]) !== numRows + 1) return null;
4410
+ if (_optionalChain([rowYs, 'optionalAccess', _126 => _126.length]) !== numRows + 1) return null;
4401
4411
  const rebuilt2 = [];
4402
4412
  let expanded = 0;
4403
4413
  const ocr = items.every((it) => it.fontName === "ocr");
4404
4414
  for (let r = 0; r < numRows; r++) {
4405
4415
  const row = originalCells[r].map((cell) => cell.text);
4406
4416
  if (r === 0 || numRows === 3 && r === 1) {
4407
- _optionalChain([kept, 'optionalAccess', _118 => _118.set, 'call', _119 => _119(rebuilt2.length, r)]);
4417
+ _optionalChain([kept, 'optionalAccess', _127 => _127.set, 'call', _128 => _128(rebuilt2.length, r)]);
4408
4418
  rebuilt2.push(row);
4409
4419
  continue;
4410
4420
  }
4411
4421
  const span2 = Math.min(numRows - r, Math.max(1, ...originalCells[r].map((cell) => _nullishCoalesce(cell.rowSpan, () => ( 1)))));
4412
4422
  const filled = originalCells[r].filter((cell) => cell.text.trim());
4413
4423
  const spanning = filled.filter((cell) => (_nullishCoalesce(cell.rowSpan, () => ( 1))) >= span2);
4414
- const loose = ocr && filled.length >= MIN_UNDERSEGMENTED_COLUMNS && spanning.length * 2 > filled.length && originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell, c) => !cell.text.trim() || (_nullishCoalesce(_optionalChain([originalCells, 'access', _120 => _120[r], 'access', _121 => _121[c], 'optionalAccess', _122 => _122.rowSpan]), () => ( 1))) === 1));
4424
+ const loose = ocr && filled.length >= MIN_UNDERSEGMENTED_COLUMNS && spanning.length * 2 > filled.length && originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell, c) => !cell.text.trim() || (_nullishCoalesce(_optionalChain([originalCells, 'access', _129 => _129[r], 'access', _130 => _130[c], 'optionalAccess', _131 => _131.rowSpan]), () => ( 1))) === 1));
4415
4425
  const band = span2 > 1 && (loose || originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell) => !cell.text.trim()))) ? span2 : 1;
4416
4426
  const rowItems = items.filter((item) => itemCenterY(item) <= rowYs[r] + 1 && itemCenterY(item) >= rowYs[r + band] - 1);
4417
4427
  const body = normalizeUndersegmentedTable([originalCells[r]], colXs, rowItems, void 0, void 0, void 0, band > 1 ? 2 : MIN_ALIGNED_LINES);
4418
4428
  if (body) {
4419
4429
  originalCells[r].forEach((cell, c) => {
4420
4430
  const cols = Array.from({ length: Math.max(1, _nullishCoalesce(cell.colSpan, () => ( 1))) }, (_, k) => c + k);
4421
- if (cell.text.trim() && body.every((cells) => cols.every((k) => !_optionalChain([cells, 'access', _123 => _123[k], 'optionalAccess', _124 => _124.trim, 'call', _125 => _125()])))) body[0][c] = cell.text;
4431
+ if (cell.text.trim() && body.every((cells) => cols.every((k) => !_optionalChain([cells, 'access', _132 => _132[k], 'optionalAccess', _133 => _133.trim, 'call', _134 => _134()])))) body[0][c] = cell.text;
4422
4432
  });
4423
4433
  rebuilt2.push(...body);
4424
4434
  expanded++;
4425
4435
  r += band - 1;
4426
4436
  } else {
4427
- _optionalChain([kept, 'optionalAccess', _126 => _126.set, 'call', _127 => _127(rebuilt2.length, r)]);
4437
+ _optionalChain([kept, 'optionalAccess', _135 => _135.set, 'call', _136 => _136(rebuilt2.length, r)]);
4428
4438
  rebuilt2.push(row);
4429
4439
  }
4430
4440
  }
@@ -4508,7 +4518,7 @@ function sortLineByX(items) {
4508
4518
  e++;
4509
4519
  }
4510
4520
  const run = items.slice(s, e), seqs = run.map((i) => i.seq);
4511
- const ok = !wide ? !run.some((i) => _optionalChain([i, 'access', _128 => _128.text, 'optionalAccess', _129 => _129.startsWith, 'call', _130 => _130("$")])) : Math.max(...seqs) - Math.min(...seqs) <= 2 * (e - s - 1) && run.every((i) => Math.abs((_nullishCoalesce(i.fontSize, () => ( 0))) - (_nullishCoalesce(run[0].fontSize, () => ( 0)))) <= 0.5);
4521
+ const ok = !wide ? !run.some((i) => _optionalChain([i, 'access', _137 => _137.text, 'optionalAccess', _138 => _138.startsWith, 'call', _139 => _139("$")])) : Math.max(...seqs) - Math.min(...seqs) <= 2 * (e - s - 1) && run.every((i) => Math.abs((_nullishCoalesce(i.fontSize, () => ( 0))) - (_nullishCoalesce(run[0].fontSize, () => ( 0)))) <= 0.5);
4512
4522
  if (e - s > 1 && seqs.every((q) => q !== void 0) && ok) {
4513
4523
  run.sort((a, b) => a.seq - b.seq);
4514
4524
  for (let k = 0; k < run.length; k++) items[s + k] = run[k];
@@ -4520,9 +4530,10 @@ function sortLineByX(items) {
4520
4530
  function isCjkLatinAutospace(prevText, nextText, gap, fontSize, hangulLine = false) {
4521
4531
  if (!(gap < fontSize * 0.35)) return false;
4522
4532
  if (hangulLine) return false;
4523
- const a = prevText.replace(/(?:<\/?u>|~~)+$/, "").slice(-1), b = _nullishCoalesce(nextText.replace(/^(?:<\/?u>|~~)+/, "")[0], () => ( ""));
4533
+ const a = prevText.replace(/(?:<\/?u>|~~)+$/, "").slice(-1), b = _nullishCoalesce(nextText.replace(/^(?:<\/?u>|~~)+/, "").replace(/^\(/, "")[0], () => ( ""));
4524
4534
  const cjk = /[\u3000-\u303f\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\uff00-\uffef]/, latin = /[A-Za-z0-9]/;
4525
- return cjk.test(a) && latin.test(b) || latin.test(a) && cjk.test(b);
4535
+ const cjkOrQuote = /[\u3000-\u303f\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\uff00-\uffef\u2018-\u201f]/;
4536
+ return cjk.test(a) && latin.test(b) || latin.test(a) && cjk.test(b) || cjkOrQuote.test(a) && cjkOrQuote.test(b) && (cjk.test(a) || cjk.test(b));
4526
4537
  }
4527
4538
  function filterHiddenText(items, pageWidth, pageHeight, originX = 0, originY = 0) {
4528
4539
  let hiddenCount = 0;
@@ -4580,7 +4591,7 @@ function dominantStyle(items) {
4580
4591
  let maxCount = 0, dominantSize = 0;
4581
4592
  for (const i of items) {
4582
4593
  if (i.fontSize <= 0) continue;
4583
- const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _131 => _131.text, 'access', _132 => _132.match, 'call', _133 => _133(/[\p{L}\p{N}]/gu), 'optionalAccess', _134 => _134.length]), () => ( 0)));
4594
+ const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _140 => _140.text, 'access', _141 => _141.match, 'call', _142 => _142(/[\p{L}\p{N}]/gu), 'optionalAccess', _143 => _143.length]), () => ( 0)));
4584
4595
  freq.set(i.fontSize, count);
4585
4596
  if (count > maxCount) {
4586
4597
  maxCount = count;
@@ -4588,7 +4599,7 @@ function dominantStyle(items) {
4588
4599
  }
4589
4600
  }
4590
4601
  if (dominantSize === 0) return void 0;
4591
- const fontName = _optionalChain([items, 'access', _135 => _135.find, 'call', _136 => _136((i) => i.fontSize === dominantSize), 'optionalAccess', _137 => _137.fontName]) || void 0;
4602
+ const fontName = _optionalChain([items, 'access', _144 => _144.find, 'call', _145 => _145((i) => i.fontSize === dominantSize), 'optionalAccess', _146 => _146.fontName]) || void 0;
4592
4603
  return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
4593
4604
  }
4594
4605
  function normalizeItems(rawItems) {
@@ -4743,7 +4754,7 @@ function splitAroundOverlays(c, overlays) {
4743
4754
  const ov = overlays.filter((o) => {
4744
4755
  for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
4745
4756
  const prefix = c.text.slice(0, at);
4746
- const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _138 => _138.match, 'call', _139 => _139(/\s+/g), 'optionalAccess', _140 => _140.length]), () => ( 0))) * ws;
4757
+ const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _147 => _147.match, 'call', _148 => _148(/\s+/g), 'optionalAccess', _149 => _149.length]), () => ( 0))) * ws;
4747
4758
  if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
4748
4759
  }
4749
4760
  return true;
@@ -4905,7 +4916,7 @@ function trackedSpaces(sorted, med = trackingShift([sorted])) {
4905
4916
  });
4906
4917
  }
4907
4918
  function mergeLineSimple(items) {
4908
- if (items.length <= 1) return _optionalChain([items, 'access', _141 => _141[0], 'optionalAccess', _142 => _142.text]) || "";
4919
+ if (items.length <= 1) return _optionalChain([items, 'access', _150 => _150[0], 'optionalAccess', _151 => _151.text]) || "";
4909
4920
  const sorted = sortLineByX([...items]);
4910
4921
  const tracked = trackedSpaces(sorted);
4911
4922
  const isEvenSpaced = detectEvenSpacedItems(sorted);
@@ -4940,7 +4951,7 @@ function mergeLineSimple(items) {
4940
4951
  result += sorted[i].text;
4941
4952
  continue;
4942
4953
  }
4943
- if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _143 => _143[i]])) result += " ";
4954
+ if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _152 => _152[i]])) result += " ";
4944
4955
  result += sorted[i].text;
4945
4956
  }
4946
4957
  return result;
@@ -4997,7 +5008,7 @@ function isProseTable(table) {
4997
5008
  if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
4998
5009
  for (let c = 0; c < table.cols; c++) {
4999
5010
  const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
5000
- if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _144 => _144.match, 'call', _145 => _145(/\p{L}/gu), 'optionalAccess', _146 => _146.length]), () => ( 0))) >= 2)) return false;
5011
+ if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _153 => _153.match, 'call', _154 => _154(/\p{L}/gu), 'optionalAccess', _155 => _155.length]), () => ( 0))) >= 2)) return false;
5001
5012
  }
5002
5013
  return true;
5003
5014
  }
@@ -5026,7 +5037,7 @@ var TICK = /^-?[\d,]+(?:\.\d+)?%?$/;
5026
5037
  var QUANTITY = /^[-−–]?[\d,]*\.?\d+%?$/;
5027
5038
  var quantity = (token) => Number(token.replace(/^[−–]/, "-").replace(/[,%]/g, ""));
5028
5039
  function isValueAxisColumn(table, c) {
5029
- const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _147 => _147[c], 'optionalAccess', _148 => _148.text]), () => ( ""))).split("\n").map((line) => line.trim().split(/\s+/)));
5040
+ const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _156 => _156[c], 'optionalAccess', _157 => _157.text]), () => ( ""))).split("\n").map((line) => line.trim().split(/\s+/)));
5030
5041
  const others = table.cells.flatMap((row) => row.filter((_, k) => k !== c).map((cell) => cell.text.trim().split(/\s+/))).filter((tokens) => tokens.every((token) => QUANTITY.test(token))).flat().map(quantity).filter((v) => !(Number.isInteger(v) && v >= 1900 && v <= 2100));
5031
5042
  for (const ticks of [lines.flat().filter((t) => TICK.test(t)).map(quantity), lines.map((tokens) => tokens[0]).filter((t) => TICK.test(t)).map(quantity)]) {
5032
5043
  const run = fallingRun(ticks);
@@ -5059,7 +5070,7 @@ function isChartTable(table, ocr = false) {
5059
5070
  if (numeric < texts.length * 0.5) return false;
5060
5071
  if (ocr && table.cols >= 3 && table.cells.slice(0, 3).some((row) => row.filter((cell) => /[가-힣]{2}/.test(cell.text)).length >= 2)) return false;
5061
5072
  for (let c = 0; c < table.cols; c++) {
5062
- if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _149 => _149[c], 'optionalAccess', _150 => _150.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
5073
+ if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _158 => _158[c], 'optionalAccess', _159 => _159.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
5063
5074
  }
5064
5075
  const values = texts.filter((text) => text.split(/\s+/).every((token) => QUANTITY.test(token))).length;
5065
5076
  const cells = table.rows * table.cols;
@@ -5068,7 +5079,7 @@ function isChartTable(table, ocr = false) {
5068
5079
  function isProseFragmentTable(table) {
5069
5080
  const texts = table.cells.flat().map((cell) => cell.text.trim()).filter(Boolean);
5070
5081
  if (texts.length < 4) return false;
5071
- const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access', _151 => _151.match, 'call', _152 => _152(/[가-힣]/g), 'optionalAccess', _153 => _153.length]), () => ( 0));
5082
+ const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access', _160 => _160.match, 'call', _161 => _161(/[가-힣]/g), 'optionalAccess', _162 => _162.length]), () => ( 0));
5072
5083
  if (texts.filter((text) => hangul(text) >= 2).length < texts.length * 0.7) return false;
5073
5084
  if (texts.length >= 12 && texts.filter((text) => hangul(text) >= 15 && !text.includes("\n")).length >= texts.length * 0.4) return true;
5074
5085
  return texts.filter((text) => /(?:[다요고서는을를에게지며면어아야니까던]|[.,?!])$/.test(text)).length >= texts.length * 0.3;
@@ -5121,7 +5132,7 @@ function clusterCellLines(items) {
5121
5132
  }
5122
5133
  var WRAP_INDENT_MAX = 3;
5123
5134
  function joinClusterCellLines(lines, box, lex) {
5124
- let out = _nullishCoalesce(_optionalChain([lines, 'access', _154 => _154[0], 'optionalAccess', _155 => _155.text]), () => ( ""));
5135
+ let out = _nullishCoalesce(_optionalChain([lines, 'access', _163 => _163[0], 'optionalAccess', _164 => _164.text]), () => ( ""));
5125
5136
  for (let i = 1; i < lines.length; i++) {
5126
5137
  const a = lines[i - 1], b = lines[i];
5127
5138
  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) === "";
@@ -5446,7 +5457,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
5446
5457
  continue;
5447
5458
  }
5448
5459
  const top = rows[i - 1];
5449
- const title = _optionalChain([top, 'optionalAccess', _156 => _156.items, 'access', _157 => _157.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;
5460
+ const title = _optionalChain([top, 'optionalAccess', _165 => _165.items, 'access', _166 => _166.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;
5450
5461
  const tableRows = title ? [title, ...body] : body;
5451
5462
  const cells = tableRows.map((row, idx) => {
5452
5463
  if (title && idx === 0) return [{ text: row.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }];
@@ -5503,12 +5514,12 @@ function isTwoColumnProse(r) {
5503
5514
  if (t.rows < (ocr ? 6 : 8)) return false;
5504
5515
  const dense = [];
5505
5516
  for (let c = 0; c < t.cols; c++) {
5506
- const filled = t.cells.filter((row) => _optionalChain([row, 'access', _158 => _158[c], 'optionalAccess', _159 => _159.text, 'access', _160 => _160.trim, 'call', _161 => _161()])).length;
5517
+ const filled = t.cells.filter((row) => _optionalChain([row, 'access', _167 => _167[c], 'optionalAccess', _168 => _168.text, 'access', _169 => _169.trim, 'call', _170 => _170()])).length;
5507
5518
  if (filled / t.rows >= 0.3) dense.push(c);
5508
5519
  }
5509
5520
  if (dense.length !== 2) return false;
5510
5521
  for (const c of dense) {
5511
- const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _162 => _162[c], 'optionalAccess', _163 => _163.text, 'access', _164 => _164.replace, 'call', _165 => _165(/\s+/g, ""), 'access', _166 => _166.length]), () => ( 0))).filter((n) => n > 0);
5522
+ const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _171 => _171[c], 'optionalAccess', _172 => _172.text, 'access', _173 => _173.replace, 'call', _174 => _174(/\s+/g, ""), 'access', _175 => _175.length]), () => ( 0))).filter((n) => n > 0);
5512
5523
  const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
5513
5524
  if (avg < (ocr ? 15 : 12)) return false;
5514
5525
  }
@@ -5970,7 +5981,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
5970
5981
  const runs = [];
5971
5982
  for (const it of sorted) {
5972
5983
  const last = runs[runs.length - 1];
5973
- const prev = _optionalChain([last, 'optionalAccess', _167 => _167[last.length - 1]]);
5984
+ const prev = _optionalChain([last, 'optionalAccess', _176 => _176[last.length - 1]]);
5974
5985
  if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
5975
5986
  else runs.push([it]);
5976
5987
  }
@@ -6021,7 +6032,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
6021
6032
  assignedGroups.add(gi);
6022
6033
  usedCols.add(ci);
6023
6034
  }
6024
- const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _168 => _168.find, 'call', _169 => _169((a) => a.items === g), 'optionalAccess', _170 => _170.col]), () => ( -1)));
6035
+ const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _177 => _177.find, 'call', _178 => _178((a) => a.items === g), 'optionalAccess', _179 => _179.col]), () => ( -1)));
6025
6036
  if (groups.length <= numCols && colOf.some((c, g) => g > 0 && c < colOf[g - 1])) {
6026
6037
  const G = groups.length, cost = (g, c2) => Math.abs(groupCenters[g] - colCenters[c2]);
6027
6038
  const best = groups.map(() => new Array(numCols).fill(Infinity)), from = groups.map(() => new Array(numCols).fill(-1));
@@ -6058,7 +6069,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
6058
6069
  function buildClusterTable(rows, columns, pageNum, lex) {
6059
6070
  const numRows = rows.length;
6060
6071
  if (numRows < MIN_ROWS || columns.length < MIN_COLS) return null;
6061
- const headFaces = new Set(_optionalChain([rows, 'access', _171 => _171[0], 'optionalAccess', _172 => _172.items, 'access', _173 => _173.map, 'call', _174 => _174((i) => i.fontName)]));
6072
+ const headFaces = new Set(_optionalChain([rows, 'access', _180 => _180[0], 'optionalAccess', _181 => _181.items, 'access', _182 => _182.map, 'call', _183 => _183((i) => i.fontName)]));
6062
6073
  const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
6063
6074
  const assigned = rows.map((row, r) => assignRowItems(row.items, columns, columns.length, r === 0 ? headerFace : void 0));
6064
6075
  const cuts = supportedOcrColumnCuts(assigned);
@@ -6129,7 +6140,7 @@ function buildClusterTable(rows, columns, pageNum, lex) {
6129
6140
  const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
6130
6141
  if (nonEmptyCols !== 1) continue;
6131
6142
  if (cells[r][0].text.trim() !== "") continue;
6132
- const contentText = _optionalChain([cells, 'access', _175 => _175[r], 'access', _176 => _176.find, 'call', _177 => _177((c) => c.text.trim()), 'optionalAccess', _178 => _178.text, 'access', _179 => _179.trim, 'call', _180 => _180()]) || "";
6143
+ const contentText = _optionalChain([cells, 'access', _184 => _184[r], 'access', _185 => _185.find, 'call', _186 => _186((c) => c.text.trim()), 'optionalAccess', _187 => _187.text, 'access', _188 => _188.trim, 'call', _189 => _189()]) || "";
6133
6144
  if (/^[○●▶\-·]/.test(contentText)) continue;
6134
6145
  for (let pr = r - 1; pr >= 0; pr--) {
6135
6146
  if (cells[pr].some((c) => c.text.trim())) {
@@ -6362,7 +6373,7 @@ function stackedTableBands(items) {
6362
6373
  const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
6363
6374
  while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
6364
6375
  if (runs.length < 2) return null;
6365
- if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _181 => _181[i + 1], 'optionalAccess', _182 => _182.start]), () => ( lines.length))))) return null;
6376
+ if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _190 => _190[i + 1], 'optionalAccess', _191 => _191.start]), () => ( lines.length))))) return null;
6366
6377
  const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
6367
6378
  const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
6368
6379
  const tail = lines.slice(runs[runs.length - 1].end);
@@ -6630,7 +6641,7 @@ function splitTrailingColumnRegion(items) {
6630
6641
  }
6631
6642
  function panelBlocks(items, panel, pageNum) {
6632
6643
  const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
6633
- const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _183 => _183(line), 'optionalAccess', _184 => _184.fontName]), () => ( ""));
6644
+ const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _192 => _192(line), 'optionalAccess', _193 => _193.fontName]), () => ( ""));
6634
6645
  const runs = [];
6635
6646
  for (const line of lines) {
6636
6647
  const last = runs[runs.length - 1];
@@ -6711,7 +6722,7 @@ function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0) {
6711
6722
  const vMinGap = Math.max(minGap, columnGap);
6712
6723
  const vCut = findVerticalCutWithOutlierFilter(items, vMinGap);
6713
6724
  const hValid = hCut.gap >= minGap;
6714
- const vValid = (vCut.gap >= vMinGap || vCut.gap >= PROSE_GUTTER_MIN_GAP && isProseGutter(items, vCut.position)) && !splitsSpacedLabel(items, vCut.position);
6725
+ const vValid = (vCut.gap >= vMinGap || vCut.gap >= PROSE_GUTTER_MIN_GAP && isProseGutter(items, vCut.position)) && !splitsSpacedLabel(items, vCut.position) && !splitsLoneRowTail(items, vCut.position);
6715
6726
  let useHorizontal;
6716
6727
  if (hValid && vValid) useHorizontal = (vCut.gap <= hCut.gap * 1.5 || staggeredSides(items, vCut.position)) && !gapInsideLongerColumn(items, hCut.position, hCut.gap, vCut.position);
6717
6728
  else if (hValid) useHorizontal = true;
@@ -6837,7 +6848,7 @@ function validWrapBands(items, bands) {
6837
6848
  }
6838
6849
  function inheritedWrapBands(items) {
6839
6850
  const source = XY_WRAP_ITEMS.get(items[0]);
6840
- const present = _optionalChain([source, 'optionalAccess', _185 => _185.length]) === items.length ? new Set(items) : null;
6851
+ const present = _optionalChain([source, 'optionalAccess', _194 => _194.length]) === items.length ? new Set(items) : null;
6841
6852
  const sameLeaf = present && source.every((item) => present.has(item));
6842
6853
  return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
6843
6854
  }
@@ -6866,6 +6877,15 @@ function tocRecordBoundaries(rows) {
6866
6877
  }
6867
6878
  return out;
6868
6879
  }
6880
+ function splitsLoneRowTail(items, x) {
6881
+ const left = groupByY(items.filter((i) => i.x + i.w / 2 < x)), right = groupByY(items.filter((i) => i.x + i.w / 2 >= x));
6882
+ if (right.length !== 1 || left.length < 2) return false;
6883
+ const tail = right[0], box = computeBBox(items, 0), tailBox = computeBBox(tail, 0);
6884
+ const head = left.find((r) => Math.abs(r[0].y - tail[0].y) <= 2);
6885
+ if (!head) return false;
6886
+ const headBox = computeBBox(head, 0), fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _195 => _195(tail), 'optionalAccess', _196 => _196.fontSize]), () => ( 10));
6887
+ return tailBox.x - (headBox.x + headBox.width) <= fs * 3 && tailBox.x + tailBox.width >= box.x + box.width - fs && headBox.width >= box.width / 2;
6888
+ }
6869
6889
  function wrappedLineBands(items, inherited) {
6870
6890
  const rows = groupByY(items);
6871
6891
  const records = tocRecordBoundaries(rows);
@@ -6876,7 +6896,7 @@ function wrappedLineBands(items, inherited) {
6876
6896
  left: box.x,
6877
6897
  right: box.x + box.width,
6878
6898
  y: row.reduce((n, i) => n + i.y, 0) / row.length,
6879
- fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _186 => _186(row), 'optionalAccess', _187 => _187.fontSize]), () => ( 0)),
6899
+ fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _197 => _197(row), 'optionalAccess', _198 => _198.fontSize]), () => ( 0)),
6880
6900
  sources: row.map((item) => ({ item, state: { ...item } }))
6881
6901
  };
6882
6902
  });
@@ -7012,10 +7032,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
7012
7032
  const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
7013
7033
  const geo = lines.map((l) => {
7014
7034
  const b = computeBBox(l.items, pageNum);
7015
- 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', _188 => _188(l.items), 'optionalAccess', _189 => _189.fontSize]), () => ( 0)) };
7035
+ 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', _199 => _199(l.items), 'optionalAccess', _200 => _200.fontSize]), () => ( 0)) };
7016
7036
  });
7017
7037
  const joins = bodyLineJoins(geo, lex);
7018
- const first = _optionalChain([lines, 'access', _190 => _190[0], 'optionalAccess', _191 => _191.items, 'access', _192 => _192[0]]);
7038
+ const first = _optionalChain([lines, 'access', _201 => _201[0], 'optionalAccess', _202 => _202.items, 'access', _203 => _203[0]]);
7019
7039
  const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
7020
7040
  const hasBand = (top, bottom) => {
7021
7041
  let lo = 0, hi = bands.length;
@@ -7092,15 +7112,15 @@ function computeMedianFontSizeFromFreq(freq) {
7092
7112
  function detectHeadings(blocks, medianFontSize) {
7093
7113
  for (let bi = 0; bi < blocks.length; bi++) {
7094
7114
  const block = blocks[bi];
7095
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontSize])) continue;
7115
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _204 => _204.style, 'optionalAccess', _205 => _205.fontSize])) continue;
7096
7116
  const text = block.text.trim();
7097
7117
  if (text.length === 0 || text.length > 200) continue;
7098
7118
  if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
7099
7119
  const ratio = block.style.fontSize / medianFontSize;
7100
7120
  let level = 0;
7101
- if (ratio >= _chunkAQSU4NATcjs.HEADING_RATIO_H1) level = 1;
7102
- else if (ratio >= _chunkAQSU4NATcjs.HEADING_RATIO_H2) level = 2;
7103
- else if (ratio >= _chunkAQSU4NATcjs.HEADING_RATIO_H3) level = 3;
7121
+ if (ratio >= _chunkA5MTYCTOcjs.HEADING_RATIO_H1) level = 1;
7122
+ else if (ratio >= _chunkA5MTYCTOcjs.HEADING_RATIO_H2) level = 2;
7123
+ else if (ratio >= _chunkA5MTYCTOcjs.HEADING_RATIO_H3) level = 3;
7104
7124
  if (level > 0) {
7105
7125
  block.type = "heading";
7106
7126
  block.level = level;
@@ -7109,21 +7129,21 @@ function detectHeadings(blocks, medianFontSize) {
7109
7129
  }
7110
7130
  }
7111
7131
  function isChapterNumber(block, next, medianFontSize) {
7112
- const size = _nullishCoalesce(_optionalChain([block, 'access', _195 => _195.style, 'optionalAccess', _196 => _196.fontSize]), () => ( 0));
7113
- const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _197 => _197.style, 'optionalAccess', _198 => _198.fontSize]), () => ( 0));
7114
- const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _199 => _199.text, 'optionalAccess', _200 => _200.trim, 'call', _201 => _201()]), () => ( ""));
7115
- const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _202 => _202.bbox]);
7116
- return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _203 => _203.text, 'optionalAccess', _204 => _204.trim, 'call', _205 => _205()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkAQSU4NATcjs.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;
7132
+ const size = _nullishCoalesce(_optionalChain([block, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontSize]), () => ( 0));
7133
+ const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _208 => _208.style, 'optionalAccess', _209 => _209.fontSize]), () => ( 0));
7134
+ const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _210 => _210.text, 'optionalAccess', _211 => _211.trim, 'call', _212 => _212()]), () => ( ""));
7135
+ const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _213 => _213.bbox]);
7136
+ return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _214 => _214.text, 'optionalAccess', _215 => _215.trim, 'call', _216 => _216()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkA5MTYCTOcjs.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;
7117
7137
  }
7118
7138
  function mergeStackedHeadingLines(blocks, medianFontSize) {
7119
7139
  for (let i = 0; i < blocks.length - 1; ) {
7120
7140
  const a = blocks[i], b = blocks[i + 1];
7121
7141
  const ab = a.bbox, bb = b.bbox;
7122
- const af = _nullishCoalesce(_optionalChain([a, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _208 => _208.style, 'optionalAccess', _209 => _209.fontSize]), () => ( 0));
7142
+ const af = _nullishCoalesce(_optionalChain([a, 'access', _217 => _217.style, 'optionalAccess', _218 => _218.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _219 => _219.style, 'optionalAccess', _220 => _220.fontSize]), () => ( 0));
7123
7143
  const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
7124
- const centered = ab && bb && _optionalChain([a, 'access', _210 => _210.style, 'optionalAccess', _211 => _211.fontName]) === _optionalChain([b, 'access', _212 => _212.style, 'optionalAccess', _213 => _213.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
7144
+ const centered = ab && bb && _optionalChain([a, 'access', _221 => _221.style, 'optionalAccess', _222 => _222.fontName]) === _optionalChain([b, 'access', _223 => _223.style, 'optionalAccess', _224 => _224.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
7125
7145
  const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
7126
- const wrapped = sameAnchor && _optionalChain([a, 'access', _214 => _214.style, 'optionalAccess', _215 => _215.fontName]) === _optionalChain([b, 'access', _216 => _216.style, 'optionalAccess', _217 => _217.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _218 => _218.text, 'optionalAccess', _219 => _219.trim, 'call', _220 => _220(), 'access', _221 => _221.split, 'call', _222 => _222(/\s+/), 'access', _223 => _223.length]), () => ( 0))) >= 3;
7146
+ const wrapped = sameAnchor && _optionalChain([a, 'access', _225 => _225.style, 'optionalAccess', _226 => _226.fontName]) === _optionalChain([b, 'access', _227 => _227.style, 'optionalAccess', _228 => _228.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _229 => _229.text, 'optionalAccess', _230 => _230.trim, 'call', _231 => _231(), 'access', _232 => _232.split, 'call', _233 => _233(/\s+/), 'access', _234 => _234.length]), () => ( 0))) >= 3;
7127
7147
  const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
7128
7148
  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)) {
7129
7149
  i++;
@@ -7152,25 +7172,25 @@ function detectTypographyHeadings(blocks) {
7152
7172
  if (page.some((block) => block.type === "heading")) continue;
7153
7173
  const faceWeight = /* @__PURE__ */ new Map();
7154
7174
  for (const block of page) {
7155
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _224 => _224.style, 'optionalAccess', _225 => _225.fontName])) continue;
7175
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _235 => _235.style, 'optionalAccess', _236 => _236.fontName])) continue;
7156
7176
  const faces = FACE_CHARS.get(block);
7157
7177
  if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
7158
7178
  else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
7159
7179
  }
7160
- const bodyFace = _optionalChain([[...faceWeight], 'access', _226 => _226.sort, 'call', _227 => _227((a, b) => b[1] - a[1]), 'access', _228 => _228[0], 'optionalAccess', _229 => _229[0]]);
7180
+ const bodyFace = _optionalChain([[...faceWeight], 'access', _237 => _237.sort, 'call', _238 => _238((a, b) => b[1] - a[1]), 'access', _239 => _239[0], 'optionalAccess', _240 => _240[0]]);
7161
7181
  if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
7162
7182
  const sizeWeight = /* @__PURE__ */ new Map();
7163
7183
  for (const block of page) {
7164
- if (block.type !== "paragraph" || !_optionalChain([block, 'access', _230 => _230.style, 'optionalAccess', _231 => _231.fontSize])) continue;
7184
+ if (block.type !== "paragraph" || !_optionalChain([block, 'access', _241 => _241.style, 'optionalAccess', _242 => _242.fontSize])) continue;
7165
7185
  const faces = FACE_CHARS.get(block);
7166
- const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _232 => _232.text, 'optionalAccess', _233 => _233.length]), () => ( 0)) : 0;
7186
+ const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _243 => _243.text, 'optionalAccess', _244 => _244.length]), () => ( 0)) : 0;
7167
7187
  if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
7168
7188
  }
7169
- const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _234 => _234.sort, 'call', _235 => _235((a, b) => b[1] - a[1]), 'access', _236 => _236[0], 'optionalAccess', _237 => _237[0]]), () => ( 0));
7189
+ const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _245 => _245.sort, 'call', _246 => _246((a, b) => b[1] - a[1]), 'access', _247 => _247[0], 'optionalAccess', _248 => _248[0]]), () => ( 0));
7170
7190
  for (let i = 0; i < page.length; i++) {
7171
7191
  const block = page[i];
7172
7192
  const { text, bbox, style } = block;
7173
- if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _238 => _238.fontName]) || !style.fontSize) continue;
7193
+ if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _249 => _249.fontName]) || !style.fontSize) continue;
7174
7194
  const title = text.trim();
7175
7195
  const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
7176
7196
  const faces = FACE_CHARS.get(block);
@@ -7200,16 +7220,16 @@ function detectDocumentStyleHeadings(blocks) {
7200
7220
  for (const page of byPage.values()) {
7201
7221
  const faceChars = /* @__PURE__ */ new Map();
7202
7222
  for (const block of page) {
7203
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _239 => _239.style, 'optionalAccess', _240 => _240.fontName])) continue;
7223
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _250 => _250.style, 'optionalAccess', _251 => _251.fontName])) continue;
7204
7224
  faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
7205
7225
  }
7206
- const bodyFace = _optionalChain([[...faceChars], 'access', _241 => _241.sort, 'call', _242 => _242((a, b) => b[1] - a[1]), 'access', _243 => _243[0], 'optionalAccess', _244 => _244[0]]);
7226
+ const bodyFace = _optionalChain([[...faceChars], 'access', _252 => _252.sort, 'call', _253 => _253((a, b) => b[1] - a[1]), 'access', _254 => _254[0], 'optionalAccess', _255 => _255[0]]);
7207
7227
  if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
7208
- const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _245 => _245.style, 'optionalAccess', _246 => _246.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
7228
+ const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _256 => _256.style, 'optionalAccess', _257 => _257.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
7209
7229
  for (const label of labels) {
7210
- const peers = labels.filter((b) => _optionalChain([b, 'access', _247 => _247.style, 'optionalAccess', _248 => _248.fontName]) === _optionalChain([label, 'access', _249 => _249.style, 'optionalAccess', _250 => _250.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
7230
+ const peers = labels.filter((b) => _optionalChain([b, 'access', _258 => _258.style, 'optionalAccess', _259 => _259.fontName]) === _optionalChain([label, 'access', _260 => _260.style, 'optionalAccess', _261 => _261.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
7211
7231
  if (peers.length < 2) continue;
7212
- const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _251 => _251.style, 'optionalAccess', _252 => _252.fontName]) !== _optionalChain([label, 'access', _253 => _253.style, 'optionalAccess', _254 => _254.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);
7232
+ const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _262 => _262.style, 'optionalAccess', _263 => _263.fontName]) !== _optionalChain([label, 'access', _264 => _264.style, 'optionalAccess', _265 => _265.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);
7213
7233
  if (value) {
7214
7234
  label.type = "heading";
7215
7235
  label.level = 2;
@@ -7218,7 +7238,7 @@ function detectDocumentStyleHeadings(blocks) {
7218
7238
  const first = page.find((b) => b.type !== "image" && b.type !== "separator");
7219
7239
  const second = page[page.indexOf(first) + 1];
7220
7240
  const third = page[page.indexOf(first) + 2];
7221
- if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _255 => _255.style, 'optionalAccess', _256 => _256.fontName]) || !_optionalChain([second, 'access', _257 => _257.style, 'optionalAccess', _258 => _258.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', _259 => _259.style, 'optionalAccess', _260 => _260.fontName]) !== bodyFace) continue;
7241
+ if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _266 => _266.style, 'optionalAccess', _267 => _267.fontName]) || !_optionalChain([second, 'access', _268 => _268.style, 'optionalAccess', _269 => _269.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', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) !== bodyFace) continue;
7222
7242
  first.type = "heading";
7223
7243
  first.level = 1;
7224
7244
  first.text = `${first.text.trim()} ${second.text.trim()}`;
@@ -7242,18 +7262,18 @@ function detectSiblingStyleHeadings(blocks) {
7242
7262
  for (const page of byPage.values()) {
7243
7263
  const bodyChars = /* @__PURE__ */ new Map();
7244
7264
  for (const block of page) {
7245
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _261 => _261.style, 'optionalAccess', _262 => _262.fontName])) continue;
7265
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _272 => _272.style, 'optionalAccess', _273 => _273.fontName])) continue;
7246
7266
  const face = block.style.fontName;
7247
7267
  bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
7248
7268
  }
7249
- const bodyFace = _optionalChain([[...bodyChars], 'access', _263 => _263.sort, 'call', _264 => _264((a, b) => b[1] - a[1]), 'access', _265 => _265[0], 'optionalAccess', _266 => _266[0]]);
7250
- const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _267 => _267.style, 'optionalAccess', _268 => _268.fontName]) && b.style.fontName !== bodyFace);
7269
+ const bodyFace = _optionalChain([[...bodyChars], 'access', _274 => _274.sort, 'call', _275 => _275((a, b) => b[1] - a[1]), 'access', _276 => _276[0], 'optionalAccess', _277 => _277[0]]);
7270
+ const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _278 => _278.style, 'optionalAccess', _279 => _279.fontName]) && b.style.fontName !== bodyFace);
7251
7271
  for (const anchor of anchors) {
7252
7272
  const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
7253
7273
  const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
7254
- const peers = anchors.filter((b) => _optionalChain([b, 'access', _269 => _269.style, 'optionalAccess', _270 => _270.fontName]) === _optionalChain([anchor, 'access', _271 => _271.style, 'optionalAccess', _272 => _272.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _273 => _273.style, 'optionalAccess', _274 => _274.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _275 => _275.style, 'optionalAccess', _276 => _276.fontSize]), () => ( 0)))) < 0.5);
7274
+ const peers = anchors.filter((b) => _optionalChain([b, 'access', _280 => _280.style, 'optionalAccess', _281 => _281.fontName]) === _optionalChain([anchor, 'access', _282 => _282.style, 'optionalAccess', _283 => _283.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _284 => _284.style, 'optionalAccess', _285 => _285.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _286 => _286.style, 'optionalAccess', _287 => _287.fontSize]), () => ( 0)))) < 0.5);
7255
7275
  if (peers.length < 2 && !numbered && !lettered) continue;
7256
- const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _277 => _277.style, 'optionalAccess', _278 => _278.fontName]) === _optionalChain([anchor, 'access', _279 => _279.style, 'optionalAccess', _280 => _280.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _281 => _281.style, 'optionalAccess', _282 => _282.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _283 => _283.style, 'optionalAccess', _284 => _284.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _285 => _285.style, 'optionalAccess', _286 => _286.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()));
7276
+ const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _288 => _288.style, 'optionalAccess', _289 => _289.fontName]) === _optionalChain([anchor, 'access', _290 => _290.style, 'optionalAccess', _291 => _291.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _292 => _292.style, 'optionalAccess', _293 => _293.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _294 => _294.style, 'optionalAccess', _295 => _295.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _296 => _296.style, 'optionalAccess', _297 => _297.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()));
7257
7277
  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));
7258
7278
  if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
7259
7279
  for (const sibling of siblings) {
@@ -7272,13 +7292,13 @@ function detectRepeatedPageLabels(blocks) {
7272
7292
  }
7273
7293
  for (const page of byPage.values()) {
7274
7294
  const bodyChars = /* @__PURE__ */ new Map();
7275
- for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _287 => _287.style, 'optionalAccess', _288 => _288.fontName])) {
7295
+ for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _298 => _298.style, 'optionalAccess', _299 => _299.fontName])) {
7276
7296
  const faces = FACE_CHARS.get(b);
7277
7297
  if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
7278
7298
  else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
7279
7299
  }
7280
- const bodyFace = _optionalChain([[...bodyChars], 'access', _289 => _289.sort, 'call', _290 => _290((a, b) => b[1] - a[1]), 'access', _291 => _291[0], 'optionalAccess', _292 => _292[0]]);
7281
- const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _293 => _293.style, 'optionalAccess', _294 => _294.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);
7300
+ const bodyFace = _optionalChain([[...bodyChars], 'access', _300 => _300.sort, 'call', _301 => _301((a, b) => b[1] - a[1]), 'access', _302 => _302[0], 'optionalAccess', _303 => _303[0]]);
7301
+ const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _304 => _304.style, 'optionalAccess', _305 => _305.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);
7282
7302
  const groups = /* @__PURE__ */ new Map();
7283
7303
  for (const b of candidates) {
7284
7304
  const key = `${b.style.fontName}:${b.style.fontSize}`;
@@ -7314,19 +7334,19 @@ function detectPageLeadHeadings(blocks) {
7314
7334
  for (const page of byPage.values()) {
7315
7335
  const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
7316
7336
  const [first, second, third] = content;
7317
- if (!_optionalChain([first, 'optionalAccess', _295 => _295.bbox]) || !first.text || !_optionalChain([first, 'access', _296 => _296.style, 'optionalAccess', _297 => _297.fontSize]) || !second) continue;
7337
+ if (!_optionalChain([first, 'optionalAccess', _306 => _306.bbox]) || !first.text || !_optionalChain([first, 'access', _307 => _307.style, 'optionalAccess', _308 => _308.fontSize]) || !second) continue;
7318
7338
  const firstText = first.text.trim();
7319
7339
  const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
7320
7340
  const hasImage = page.some((b) => b.type === "image");
7321
- 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', _298 => _298.text, 'optionalAccess', _299 => _299.trim, 'call', _300 => _300()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _301 => _301.text, 'optionalAccess', _302 => _302.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
7341
+ 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', _309 => _309.text, 'optionalAccess', _310 => _310.trim, 'call', _311 => _311()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _312 => _312.text, 'optionalAccess', _313 => _313.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
7322
7342
  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);
7323
- const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _303 => _303.text, 'optionalAccess', _304 => _304.length]), () => ( 0))) >= 100;
7343
+ const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _314 => _314.text, 'optionalAccess', _315 => _315.length]), () => ( 0))) >= 100;
7324
7344
  if (firstIsTitle || firstAboveProse || firstIsSection) {
7325
7345
  first.type = "heading";
7326
7346
  first.level = 1;
7327
7347
  }
7328
- if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _305 => _305.style, 'optionalAccess', _306 => _306.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _307 => _307.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;
7329
- const distinctFace = _optionalChain([third, 'access', _308 => _308.style, 'optionalAccess', _309 => _309.fontName]) !== second.style.fontName;
7348
+ if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _316 => _316.style, 'optionalAccess', _317 => _317.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _318 => _318.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;
7349
+ const distinctFace = _optionalChain([third, 'access', _319 => _319.style, 'optionalAccess', _320 => _320.fontName]) !== second.style.fontName;
7330
7350
  const namedContents = /^Table of Contents$/i.test(second.text.trim());
7331
7351
  if (distinctFace && third.text.length >= 60 || namedContents) {
7332
7352
  second.type = "heading";
@@ -7337,24 +7357,24 @@ function detectPageLeadHeadings(blocks) {
7337
7357
  function refineDocumentStyleHeadings(blocks) {
7338
7358
  const faceChars = /* @__PURE__ */ new Map();
7339
7359
  for (const block of blocks) {
7340
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _310 => _310.style, 'optionalAccess', _311 => _311.fontName])) continue;
7360
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _321 => _321.style, 'optionalAccess', _322 => _322.fontName])) continue;
7341
7361
  faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
7342
7362
  }
7343
7363
  const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
7344
7364
  if (!bodyFace || !bodyChars || bodyChars < 300) return;
7345
7365
  for (let i = 0; i < blocks.length; i++) {
7346
7366
  const block = blocks[i];
7347
- const text = _nullishCoalesce(_optionalChain([block, 'access', _312 => _312.text, 'optionalAccess', _313 => _313.trim, 'call', _314 => _314()]), () => ( ""));
7367
+ const text = _nullishCoalesce(_optionalChain([block, 'access', _323 => _323.text, 'optionalAccess', _324 => _324.trim, 'call', _325 => _325()]), () => ( ""));
7348
7368
  if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
7349
7369
  block.type = "paragraph";
7350
7370
  block.level = void 0;
7351
7371
  continue;
7352
7372
  }
7353
7373
  const box = block.bbox, style = block.style;
7354
- if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _315 => _315.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;
7374
+ if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _326 => _326.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;
7355
7375
  const previous = blocks[i - 1], next = blocks[i + 1];
7356
- const pb = _optionalChain([previous, 'optionalAccess', _316 => _316.bbox]), nb = _optionalChain([next, 'optionalAccess', _317 => _317.bbox]);
7357
- if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _318 => _318.style, 'optionalAccess', _319 => _319.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;
7376
+ const pb = _optionalChain([previous, 'optionalAccess', _327 => _327.bbox]), nb = _optionalChain([next, 'optionalAccess', _328 => _328.bbox]);
7377
+ if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _329 => _329.style, 'optionalAccess', _330 => _330.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;
7358
7378
  block.type = "heading";
7359
7379
  block.level = 2;
7360
7380
  }
@@ -7404,7 +7424,7 @@ function detectMarkerHeadings(blocks) {
7404
7424
  block.level = 4;
7405
7425
  continue;
7406
7426
  }
7407
- if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _320 => _320.style, 'optionalAccess', _321 => _321.fontSize])) {
7427
+ if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _331 => _331.style, 'optionalAccess', _332 => _332.fontSize])) {
7408
7428
  const prev = blocks[i - 1];
7409
7429
  const next = blocks[i + 1];
7410
7430
  const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
@@ -7445,7 +7465,7 @@ function detectTableCaptions(blocks) {
7445
7465
  block.table.caption = blocks[i - 1].text.trim();
7446
7466
  blocks.splice(i - 1, 1);
7447
7467
  i--;
7448
- } else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _322 => _322[i + 2], 'optionalAccess', _323 => _323.type]) !== "table") {
7468
+ } else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _333 => _333[i + 2], 'optionalAccess', _334 => _334.type]) !== "table") {
7449
7469
  const cap = blocks[i + 1].bbox, tbl = block.bbox;
7450
7470
  block.table.caption = blocks[i + 1].text.trim();
7451
7471
  if (cap && tbl && cap.y + cap.height <= tbl.y + 1) block.table.captionBelow = true;
@@ -7530,7 +7550,7 @@ function detectKoreanListBlocks(blocks) {
7530
7550
  }
7531
7551
  const listType = label.family === "arabicDot" ? "ordered" : "unordered";
7532
7552
  const listBlock = { ...b, type: "list", listType };
7533
- const pb = _optionalChain([lastTopLevelList, 'optionalAccess', _324 => _324.bbox]), cb = b.bbox;
7553
+ const pb = _optionalChain([lastTopLevelList, 'optionalAccess', _335 => _335.bbox]), cb = b.bbox;
7534
7554
  const notIndented = depth > 0 && !!pb && !!cb && pb.page === cb.page && cb.x >= pb.x + pb.width && cb.y >= pb.y + pb.height;
7535
7555
  if (notIndented) familyStack = [label.family];
7536
7556
  if (depth === 0 || notIndented) {
@@ -7688,7 +7708,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
7688
7708
  const b = blocks[bi];
7689
7709
  const cellTexts = b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean) : [];
7690
7710
  const headBox = cellTexts.length <= 4 && !!b.bbox && b.bbox.height <= (_nullishCoalesce(pageHeights.get(b.bbox.page), () => ( Infinity))) * 0.05;
7691
- const text = !tables ? _optionalChain([b, 'access', _325 => _325.text, 'optionalAccess', _326 => _326.trim, 'call', _327 => _327()]) : cellTexts.length ? (headBox ? [...cellTexts].sort() : cellTexts).join(" | ") : void 0;
7711
+ const text = !tables ? _optionalChain([b, 'access', _336 => _336.text, 'optionalAccess', _337 => _337.trim, 'call', _338 => _338()]) : cellTexts.length ? (headBox ? [...cellTexts].sort() : cellTexts).join(" | ") : void 0;
7692
7712
  if (!b.bbox || !b.pageNumber || !text) continue;
7693
7713
  const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
7694
7714
  if (!ph) continue;
@@ -7721,7 +7741,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
7721
7741
  for (const [p, count] of patternCount) {
7722
7742
  const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
7723
7743
  const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
7724
- const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _328 => _328.get, 'call', _329 => _329(p), 'optionalAccess', _330 => _330.size]), () => ( 0))) > 1;
7744
+ const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _339 => _339.get, 'call', _340 => _340(p), 'optionalAccess', _341 => _341.size]), () => ( 0))) > 1;
7725
7745
  const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
7726
7746
  const dense = pages.length >= span2 * 0.4;
7727
7747
  const loose = looseVaryingNumber(occ, entries === topEntries) && (entries === bottomEntries || dense || tracksPages(occ));
@@ -7733,8 +7753,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
7733
7753
  for (const e of entries) {
7734
7754
  const norm = e.text.replace(/\d+/g, "#");
7735
7755
  if (!repeatedPatterns.has(norm)) continue;
7736
- const noteMark = _optionalChain([e, 'access', _331 => _331.text, 'access', _332 => _332.match, 'call', _333 => _333(/^\d{1,3}\)/), 'optionalAccess', _334 => _334[0]]);
7737
- if (noteMark && _optionalChain([notes, 'optionalAccess', _335 => _335.get, 'call', _336 => _336(e.page), 'optionalAccess', _337 => _337.marks, 'access', _338 => _338.some, 'call', _339 => _339((m) => m.mark === noteMark)])) continue;
7756
+ const noteMark = _optionalChain([e, 'access', _342 => _342.text, 'access', _343 => _343.match, 'call', _344 => _344(/^\d{1,3}\)/), 'optionalAccess', _345 => _345[0]]);
7757
+ if (noteMark && _optionalChain([notes, 'optionalAccess', _346 => _346.get, 'call', _347 => _347(e.page), 'optionalAccess', _348 => _348.marks, 'access', _349 => _349.some, 'call', _350 => _350((m) => m.mark === noteMark)])) continue;
7738
7758
  const cand = blocks[e.blockIdx];
7739
7759
  const cb = cand.bbox;
7740
7760
  const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::]|\*\s+\S)/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
@@ -7748,7 +7768,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
7748
7768
  if (bi === e.blockIdx) continue;
7749
7769
  const o = blocks[bi];
7750
7770
  if (!o.bbox || o.bbox.page !== cb.page) continue;
7751
- const oNorm = _optionalChain([o, 'access', _340 => _340.text, 'optionalAccess', _341 => _341.trim, 'call', _342 => _342(), 'access', _343 => _343.replace, 'call', _344 => _344(/\d+/g, "#")]);
7771
+ const oNorm = _optionalChain([o, 'access', _351 => _351.text, 'optionalAccess', _352 => _352.trim, 'call', _353 => _353(), 'access', _354 => _354.replace, 'call', _355 => _355(/\d+/g, "#")]);
7752
7772
  if (oNorm && repeatedPatterns.has(oNorm)) continue;
7753
7773
  const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
7754
7774
  if (overlap2 >= cb.height * 0.5) {
@@ -7876,7 +7896,7 @@ function recordRowRules(table, cells, bbox, hs) {
7876
7896
  function markImageCell(cell) {
7877
7897
  IMAGE_CELLS.add(cell);
7878
7898
  }
7879
- var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _345 => _345.text, 'optionalAccess', _346 => _346.trim, 'call', _347 => _347()]) && !_optionalChain([cell, 'access', _348 => _348.blocks, 'optionalAccess', _349 => _349.length]) && !IMAGE_CELLS.has(cell);
7899
+ var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _356 => _356.text, 'optionalAccess', _357 => _357.trim, 'call', _358 => _358()]) && !_optionalChain([cell, 'access', _359 => _359.blocks, 'optionalAccess', _360 => _360.length]) && !IMAGE_CELLS.has(cell);
7880
7900
  function trimTable(table) {
7881
7901
  let cols = table.cols;
7882
7902
  while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
@@ -7892,7 +7912,7 @@ function trimTable(table) {
7892
7912
  function trimTrailingEmptyTableCols(blocks) {
7893
7913
  for (const b of blocks) {
7894
7914
  if (b.type !== "table" || !b.table) continue;
7895
- for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _350 => _350.blocks, 'optionalAccess', _351 => _351.length])) trimTrailingEmptyTableCols(cell.blocks);
7915
+ for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _361 => _361.blocks, 'optionalAccess', _362 => _362.length])) trimTrailingEmptyTableCols(cell.blocks);
7896
7916
  trimTable(b.table);
7897
7917
  }
7898
7918
  }
@@ -7912,7 +7932,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
7912
7932
  }
7913
7933
  const ok = owner.every((row) => {
7914
7934
  const o = row[c];
7915
- return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _352 => _352.blocks, 'optionalAccess', _353 => _353.length]));
7935
+ return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _363 => _363.blocks, 'optionalAccess', _364 => _364.length]));
7916
7936
  });
7917
7937
  if (!ok) continue;
7918
7938
  const spanning = /* @__PURE__ */ new Set();
@@ -7939,7 +7959,7 @@ var multiply = (m, t) => [
7939
7959
  m[1] * t[4] + m[3] * t[5] + m[5]
7940
7960
  ];
7941
7961
  function hollowCircle(image) {
7942
- if (!_optionalChain([image, 'optionalAccess', _354 => _354.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;
7962
+ if (!_optionalChain([image, 'optionalAccess', _365 => _365.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;
7943
7963
  const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
7944
7964
  const { width, height, data } = image;
7945
7965
  if (!stride || data.length < width * height * stride) return false;
@@ -8004,9 +8024,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
8004
8024
  const op = fnArray[i], args = argsArray[i];
8005
8025
  if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
8006
8026
  stack.push({ ctm, alpha, clip, unknownClip });
8007
- const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _355 => _355[0]]) : void 0;
8027
+ const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _366 => _366[0]]) : void 0;
8008
8028
  if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
8009
- const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _356 => _356[1]]) : void 0;
8029
+ const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _367 => _367[1]]) : void 0;
8010
8030
  if (Array.isArray(bounds) && bounds.length === 4) {
8011
8031
  const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
8012
8032
  if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
@@ -8014,17 +8034,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
8014
8034
  }
8015
8035
  } else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
8016
8036
  const state = stack.pop();
8017
- ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _357 => _357.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
8018
- alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _358 => _358.alpha]), () => ( 1));
8019
- clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _359 => _359.clip]), () => ( null));
8020
- unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _360 => _360.unknownClip]), () => ( false));
8037
+ ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _368 => _368.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
8038
+ alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _369 => _369.alpha]), () => ( 1));
8039
+ clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _370 => _370.clip]), () => ( null));
8040
+ unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _371 => _371.unknownClip]), () => ( false));
8021
8041
  } else if (op === _pdfmjs.OPS.setGState) {
8022
- for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _361 => _361[0]]), () => ( []))) {
8042
+ for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _372 => _372[0]]), () => ( []))) {
8023
8043
  if (key === "ca") alpha = typeof value === "number" ? value : 0;
8024
8044
  }
8025
8045
  } else if (op === _pdfmjs.OPS.constructPath) {
8026
8046
  const [operations, coordinates] = args;
8027
- pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _362 => _362.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _363 => _363.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
8047
+ pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _373 => _373.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _374 => _374.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
8028
8048
  } else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
8029
8049
  else if ([
8030
8050
  _pdfmjs.OPS.endPath,
@@ -8044,7 +8064,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
8044
8064
  pendingClip = false;
8045
8065
  pathRect = void 0;
8046
8066
  } else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
8047
- else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _364 => _364[0]]) === "string") {
8067
+ else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _375 => _375[0]]) === "string") {
8048
8068
  if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
8049
8069
  const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
8050
8070
  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;
@@ -8063,14 +8083,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
8063
8083
  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];
8064
8084
  if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
8065
8085
  const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
8066
- if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _365 => _365.text, 'access', _366 => _366.match, 'call', _367 => _367(/\p{L}/gu), 'optionalAccess', _368 => _368.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
8086
+ if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _376 => _376.text, 'access', _377 => _377.match, 'call', _378 => _378(/\p{L}/gu), 'optionalAccess', _379 => _379.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
8067
8087
  candidates.push({ id, x: box.x1, width, line });
8068
8088
  }
8069
8089
  let restored = 0;
8070
8090
  const used = /* @__PURE__ */ new Set();
8071
8091
  for (const candidate of candidates) {
8072
8092
  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);
8073
- 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', _369 => _369.text, 'access', _370 => _370.match, 'call', _371 => _371(/\p{L}/gu), 'optionalAccess', _372 => _372.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
8093
+ 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', _380 => _380.text, 'access', _381 => _381.match, 'call', _382 => _382(/\p{L}/gu), 'optionalAccess', _383 => _383.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
8074
8094
  const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
8075
8095
  if (!same.length && !numberedList || used.has(candidate.line)) continue;
8076
8096
  if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
@@ -8136,7 +8156,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
8136
8156
  return units;
8137
8157
  }
8138
8158
  function arrowDirection(image) {
8139
- if (!_optionalChain([image, 'optionalAccess', _373 => _373.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
8159
+ if (!_optionalChain([image, 'optionalAccess', _384 => _384.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
8140
8160
  const { width, height, data } = image;
8141
8161
  const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
8142
8162
  if (!stride || data.length < width * height * stride) return 0;
@@ -8204,7 +8224,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
8204
8224
  function removeSideTabs(blocks, pageWidths) {
8205
8225
  const edges = /* @__PURE__ */ new Map();
8206
8226
  for (const b of blocks) {
8207
- if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _374 => _374.text, 'optionalAccess', _375 => _375.trim, 'call', _376 => _376()]), () => ( ""))].length <= MAX_CHARS) continue;
8227
+ if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _385 => _385.text, 'optionalAccess', _386 => _386.trim, 'call', _387 => _387()]), () => ( ""))].length <= MAX_CHARS) continue;
8208
8228
  const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
8209
8229
  e.lefts.push(b.bbox.x);
8210
8230
  e.rights.push(b.bbox.x + b.bbox.width);
@@ -8220,7 +8240,7 @@ function removeSideTabs(blocks, pageWidths) {
8220
8240
  const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
8221
8241
  const key = (b) => {
8222
8242
  const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
8223
- const text = _optionalChain([b, 'access', _377 => _377.text, 'optionalAccess', _378 => _378.trim, 'call', _379 => _379()]);
8243
+ const text = _optionalChain([b, 'access', _388 => _388.text, 'optionalAccess', _389 => _389.trim, 'call', _390 => _390()]);
8224
8244
  const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
8225
8245
  if (b.type === "table") {
8226
8246
  if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
@@ -8886,16 +8906,16 @@ function isProseSpread(items) {
8886
8906
  for (let i = 1; i < sorted.length; i++) {
8887
8907
  gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
8888
8908
  }
8889
- const maxGap = _chunk4SKZG3K4cjs.safeMax.call(void 0, gaps);
8909
+ const maxGap = _chunk3EPX46NFcjs.safeMax.call(void 0, gaps);
8890
8910
  const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
8891
8911
  if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
8892
- const minGap = _chunk4SKZG3K4cjs.safeMin.call(void 0, gaps);
8912
+ const minGap = _chunk3EPX46NFcjs.safeMin.call(void 0, gaps);
8893
8913
  return minGap > 0 && maxGap - minGap <= Math.max(2, maxGap * 0.15) && (items.filter((i) => /^\P{L}*\p{Ll}/u.test(i.text)).length * 2 >= items.length || items.some((i) => /\p{L}[,.;:]["”’)]?$/u.test(i.text)));
8894
8914
  }
8895
8915
  function detectColumns(yLines) {
8896
8916
  const allItems = yLines.flat();
8897
8917
  if (allItems.length === 0) return null;
8898
- const pageWidth = _chunk4SKZG3K4cjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunk4SKZG3K4cjs.safeMin.call(void 0, allItems.map((i) => i.x));
8918
+ const pageWidth = _chunk3EPX46NFcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunk3EPX46NFcjs.safeMin.call(void 0, allItems.map((i) => i.x));
8899
8919
  if (pageWidth < 100) return null;
8900
8920
  let bigoLineIdx = -1;
8901
8921
  for (let i = 0; i < yLines.length; i++) {
@@ -9120,7 +9140,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
9120
9140
  var UNDER_BOX_PAIR_OVERLAP = 0.8;
9121
9141
  function markUnderlineItems(items, horizontals, verticals, nonRules) {
9122
9142
  const underlines = [];
9123
- if (_optionalChain([nonRules, 'optionalAccess', _380 => _380.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
9143
+ if (_optionalChain([nonRules, 'optionalAccess', _391 => _391.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
9124
9144
  if (items.length === 0 || horizontals.length === 0) return underlines;
9125
9145
  const tightOwners = /* @__PURE__ */ new Map();
9126
9146
  const tightlyOwned = (line) => {
@@ -9226,7 +9246,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
9226
9246
  if (ow <= 0) continue;
9227
9247
  const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
9228
9248
  if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
9229
- const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _381 => _381.reduce, 'call', _382 => _382((sum, item) => {
9249
+ const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _392 => _392.reduce, 'call', _393 => _393((sum, item) => {
9230
9250
  const below = item.y - o.y1;
9231
9251
  if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
9232
9252
  return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
@@ -9293,13 +9313,13 @@ function partTex(group) {
9293
9313
  const base = Math.min(...g.filter((i) => i.fontSize >= size * SCRIPT_SIZE_RATIO).map((i) => i.y));
9294
9314
  let s = "", run = "";
9295
9315
  const flush = () => {
9296
- if (run) s += _chunkAQSU4NATcjs.toTex.call(void 0, run);
9316
+ if (run) s += _chunkA5MTYCTOcjs.toTex.call(void 0, run);
9297
9317
  run = "";
9298
9318
  };
9299
9319
  g.forEach((it, k) => {
9300
9320
  if (it.fontSize < size * SCRIPT_SIZE_RATIO && it.y - base >= size * SCRIPT_RISE_EM) {
9301
9321
  flush();
9302
- s += `^{${_chunkAQSU4NATcjs.toTex.call(void 0, it.text)}}`;
9322
+ s += `^{${_chunkA5MTYCTOcjs.toTex.call(void 0, it.text)}}`;
9303
9323
  return;
9304
9324
  }
9305
9325
  if (k && it.x - (g[k - 1].x + g[k - 1].w) > spaceGapThreshold(it.fontSize)) run += " ";
@@ -9472,12 +9492,12 @@ function rebuildUnitLine(items, grid) {
9472
9492
  function prependUnitRow(cells, cols, line, usedItems) {
9473
9493
  const text = cleanCellText(line.map((item) => item.text).join(""));
9474
9494
  cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
9475
- for (const cell of cells[0]) _chunkAQSU4NATcjs.CELL_EDGES.set(cell, NO_EDGES);
9495
+ for (const cell of cells[0]) _chunkA5MTYCTOcjs.CELL_EDGES.set(cell, NO_EDGES);
9476
9496
  for (const item of line) usedItems.add(item);
9477
9497
  }
9478
9498
  function attachUnitRow(items, grid, cells, cols, usedItems) {
9479
9499
  const all = cells.flat();
9480
- if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _383 => _383[0], 'optionalAccess', _384 => _384[0], 'optionalAccess', _385 => _385.text]), () => ( "")))) return false;
9500
+ if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _394 => _394[0], 'optionalAccess', _395 => _395[0], 'optionalAccess', _396 => _396.text]), () => ( "")))) return false;
9481
9501
  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);
9482
9502
  let nearest = Infinity;
9483
9503
  for (const it of above) nearest = Math.min(nearest, it.y);
@@ -9512,7 +9532,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
9512
9532
  let hs = horizontals, vs = verticals;
9513
9533
  const restored = [];
9514
9534
  for (const grid of clipGrids) {
9515
- if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _386 => _386.cells, 'optionalAccess', _387 => _387.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
9535
+ if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _397 => _397.cells, 'optionalAccess', _398 => _398.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
9516
9536
  const { x1, x2, y1: mid, y2: top } = grid.bbox;
9517
9537
  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;
9518
9538
  const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
@@ -9976,7 +9996,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
9976
9996
  const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
9977
9997
  const runs = [];
9978
9998
  for (const item of [...line].sort((a, b) => a.x - b.x)) {
9979
- const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _388 => _388[run.length - 1]]);
9999
+ const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _399 => _399[run.length - 1]]);
9980
10000
  if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
9981
10001
  else runs.push([item]);
9982
10002
  }
@@ -10020,7 +10040,7 @@ function groupFrameParagraphUnits(units, frames) {
10020
10040
  for (const unit of units) for (const block of unit) source.set(block, unit);
10021
10041
  const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
10022
10042
  for (const frame of frames) {
10023
- if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _389 => _389.get, 'call', _390 => _390(block), 'optionalAccess', _391 => _391.length]) !== 1)) continue;
10043
+ if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _400 => _400.get, 'call', _401 => _401(block), 'optionalAccess', _402 => _402.length]) !== 1)) continue;
10024
10044
  for (const block of frame) members.set(block, frame);
10025
10045
  }
10026
10046
  const out = [];
@@ -10033,7 +10053,7 @@ function groupFrameParagraphUnits(units, frames) {
10033
10053
  }
10034
10054
  }
10035
10055
  for (const unit of out) {
10036
- if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _392 => _392.get, 'call', _393 => _393(unit[0]), 'optionalAccess', _394 => _394.blocks]) === unit) continue;
10056
+ if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _403 => _403.get, 'call', _404 => _404(unit[0]), 'optionalAccess', _405 => _405.blocks]) === unit) continue;
10037
10057
  const bs = unit.map((b) => b.bbox).filter((b) => !!b);
10038
10058
  if (bs.length !== unit.length) continue;
10039
10059
  const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
@@ -10050,14 +10070,14 @@ function groupFrameParagraphUnits(units, frames) {
10050
10070
  function recordFrameTitle(table, source, pageNum) {
10051
10071
  if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
10052
10072
  const cells = table.cells[0];
10053
- if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _395 => _395.blocks, 'optionalAccess', _396 => _396.length]) || c.text.includes("\n"))) return;
10073
+ if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _406 => _406.blocks, 'optionalAccess', _407 => _407.length]) || c.text.includes("\n"))) return;
10054
10074
  const [label, spacer, title] = cells;
10055
10075
  if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
10056
10076
  if (cells.some((c) => {
10057
- const e = _chunkAQSU4NATcjs.CELL_EDGES.get(c);
10077
+ const e = _chunkA5MTYCTOcjs.CELL_EDGES.get(c);
10058
10078
  return !e || e.t || e.b || e.l || e.r;
10059
10079
  })) return;
10060
- const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _397 => _397.fontSize]), () => ( 0));
10080
+ const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _408 => _408.fontSize]), () => ( 0));
10061
10081
  if (!xs || xs.length !== 4 || fs <= 0) return;
10062
10082
  const width = xs[3] - xs[0], gap = xs[2] - xs[1];
10063
10083
  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;
@@ -10121,7 +10141,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
10121
10141
  const extended = [];
10122
10142
  for (let i = 0; i < clipGrids.length; i++) {
10123
10143
  const c = clipGrids[i], parent = c.clipParent;
10124
- if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _398 => _398.cells, 'optionalAccess', _399 => _399.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
10144
+ if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _409 => _409.cells, 'optionalAccess', _410 => _410.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
10125
10145
  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;
10126
10146
  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;
10127
10147
  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)));
@@ -10144,7 +10164,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
10144
10164
  bbox: computeBBox(items, pageNum),
10145
10165
  style: dominantStyle(items)
10146
10166
  });
10147
- const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _400 => _400.has, 'call', _401 => _401(g)])).map((g) => ({
10167
+ const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _411 => _411.has, 'call', _412 => _412(g)])).map((g) => ({
10148
10168
  type: "paragraph",
10149
10169
  text: g.text.trim(),
10150
10170
  pageNumber: pageNum,
@@ -10153,7 +10173,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
10153
10173
  }));
10154
10174
  const groups = /* @__PURE__ */ new Map();
10155
10175
  for (const g of ordered) {
10156
- const cap = _optionalChain([caps, 'optionalAccess', _402 => _402.get, 'call', _403 => _403(g)]);
10176
+ const cap = _optionalChain([caps, 'optionalAccess', _413 => _413.get, 'call', _414 => _414(g)]);
10157
10177
  if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
10158
10178
  }
10159
10179
  for (const [cap, glyphs] of groups) {
@@ -10185,7 +10205,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
10185
10205
  let prev = null;
10186
10206
  for (const line of streamLines(items)) {
10187
10207
  lex.addLine(mergeLineSimple(line));
10188
- const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _404 => _404(line), 'optionalAccess', _405 => _405.fontSize]), () => ( 0));
10208
+ const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _415 => _415(line), 'optionalAccess', _416 => _416.fontSize]), () => ( 0));
10189
10209
  const left = Math.min(...line.map((i) => i.x)), right = Math.max(...line.map((i) => i.x + i.w));
10190
10210
  const y = line.reduce((n, i) => n + i.y, 0) / line.length;
10191
10211
  const wide = fs > 0 && right - left >= 12 * fs;
@@ -10199,7 +10219,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
10199
10219
  const filled = fillBlanks(items, horizontals, verticals);
10200
10220
  items = filled.items;
10201
10221
  horizontals = filled.horizontals;
10202
- const prevPage = _optionalChain([carry, 'optionalAccess', _406 => _406.page]) === pageNum - 1 ? carry.clip : void 0;
10222
+ const prevPage = _optionalChain([carry, 'optionalAccess', _417 => _417.page]) === pageNum - 1 ? carry.clip : void 0;
10203
10223
  const images = extractImageRegions(opList.fnArray, opList.argsArray);
10204
10224
  const clipRects = images.length ? withoutImageOnlyClips(extracted.clipRects, images) : extracted.clipRects;
10205
10225
  const clipResult = detectTables ? buildClipCellGrids(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 };
@@ -10497,7 +10517,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
10497
10517
  const nested = pendingNested.length ? takePendingNested(pendingNested, cell.bbox, !!grid.cells) : [];
10498
10518
  const lone = nested.length === 1 && !cellItems.length ? nested[0] : null;
10499
10519
  const cw = cell.bbox.x2 - cell.bbox.x1;
10500
- if (_optionalChain([lone, 'optionalAccess', _407 => _407.table]) && lone.bbox && lone.table.rows === 1 && lone.table.cols === 1 && CLIP_TABLES.has(lone.table) && !_optionalChain([lone, 'access', _408 => _408.table, 'access', _409 => _409.cells, 'access', _410 => _410[0], 'access', _411 => _411[0], 'access', _412 => _412.blocks, 'optionalAccess', _413 => _413.some, 'call', _414 => _414((b2) => b2.type === "table")]) && lone.bbox.width >= cw * 0.9 && /^[^\n]{1,30}$/.test(lone.table.cells[0][0].text.trim())) {
10520
+ if (_optionalChain([lone, 'optionalAccess', _418 => _418.table]) && lone.bbox && lone.table.rows === 1 && lone.table.cols === 1 && CLIP_TABLES.has(lone.table) && !_optionalChain([lone, 'access', _419 => _419.table, 'access', _420 => _420.cells, 'access', _421 => _421[0], 'access', _422 => _422[0], 'access', _423 => _423.blocks, 'optionalAccess', _424 => _424.some, 'call', _425 => _425((b2) => b2.type === "table")]) && lone.bbox.width >= cw * 0.9 && /^[^\n]{1,30}$/.test(lone.table.cells[0][0].text.trim())) {
10501
10521
  irGrid[cell.row][cell.col] = { text: lone.table.cells[0][0].text, colSpan: cell.colSpan, rowSpan: cell.rowSpan };
10502
10522
  takeClipCellEdges(cell, irGrid[cell.row][cell.col]);
10503
10523
  continue;
@@ -10547,10 +10567,10 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
10547
10567
  const ls = irGrid.slice(1).flat().flatMap((c) => c.text.split("\n")).map((t) => t.trim()).filter(Boolean);
10548
10568
  const numericLine = (t) => {
10549
10569
  const cs = t.replace(/\s+/g, "");
10550
- return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access', _415 => _415.match, 'call', _416 => _416(/[\d.,%()+\-−–—△▲▽▼]/g), 'optionalAccess', _417 => _417.length]), () => ( 0))) >= cs.length * 0.85;
10570
+ return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access', _426 => _426.match, 'call', _427 => _427(/[\d.,%()+\-−–—△▲▽▼]/g), 'optionalAccess', _428 => _428.length]), () => ( 0))) >= cs.length * 0.85;
10551
10571
  };
10552
10572
  const labelValueLine = (t) => {
10553
- const hangul = _nullishCoalesce(_optionalChain([t, 'access', _418 => _418.match, 'call', _419 => _419(/[가-힣]/g), 'optionalAccess', _420 => _420.length]), () => ( 0));
10573
+ const hangul = _nullishCoalesce(_optionalChain([t, 'access', _429 => _429.match, 'call', _430 => _430(/[가-힣]/g), 'optionalAccess', _431 => _431.length]), () => ( 0));
10554
10574
  return hangul > 0 && hangul <= 6 && /\d,\d{3}/.test(t) && numericLine(t.replace(/[가-힣()]/g, ""));
10555
10575
  };
10556
10576
  const bulletLine = (t) => /^\s*[○◦•□■▪]/.test(t) || /^\s*-\s*[^\d\s.,−-]/.test(t) && t.replace(/\s+/g, "").length > 7;
@@ -10560,14 +10580,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
10560
10580
  const share = ls.filter((t) => numericLine(t) || lvLines.has(t)).length / ls.length;
10561
10581
  if (share >= 0.5) return true;
10562
10582
  const colShares = Array.from({ length: numCols }, (_, c) => {
10563
- const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _421 => _421[c], 'optionalAccess', _422 => _422.text]), () => ( ""))).split("\n")).map((t) => t.trim()).filter(Boolean);
10583
+ const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _432 => _432[c], 'optionalAccess', _433 => _433.text]), () => ( ""))).split("\n")).map((t) => t.trim()).filter(Boolean);
10564
10584
  return cl.length ? cl.filter(numericLine).length / cl.length : null;
10565
10585
  }).filter((v) => v !== null);
10566
10586
  return share >= 0.35 && colShares.some((v) => v >= 0.8) && colShares.every((v) => v >= 0.8 || v <= 0.2);
10567
10587
  })();
10568
10588
  const layoutProse = irGrid.some((row) => row.some((c) => c.colSpan >= numCols - 1 && c.text.length > 60));
10569
10589
  const maxRows = numericBody ? layoutProse ? OCR_NUMERIC_MAX_ROWS_FRAMED : OCR_NUMERIC_MAX_ROWS : 5;
10570
- const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access', _423 => _423.match, 'call', _424 => _424(/[가-힣]/g), 'optionalAccess', _425 => _425.length]), () => ( 0))) > 6 && !/^[-−]?[\d,.]+$/.test(t.replace(/\s+/g, ""));
10590
+ const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access', _434 => _434.match, 'call', _435 => _435(/[가-힣]/g), 'optionalAccess', _436 => _436.length]), () => ( 0))) > 6 && !/^[-−]?[\d,.]+$/.test(t.replace(/\s+/g, ""));
10571
10591
  const proseCols = numRows === 2 ? (_nullishCoalesce(irGrid[1], () => ( []))).filter((c) => {
10572
10592
  const ls = c.text.split("\n").map((t) => t.trim()).filter(Boolean);
10573
10593
  return ls.length >= 3 && ls.filter(proseLine).length >= ls.length * 0.6;
@@ -10588,8 +10608,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
10588
10608
  finalGrid = rebuilt.map((row, i) => {
10589
10609
  const o = kept.get(i);
10590
10610
  return row.map((rawText, c) => {
10591
- const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access', _426 => _426[o], 'optionalAccess', _427 => _427[c]]);
10592
- return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _428 => _428.colSpan]), () => ( 1)), rowSpan: src ? spanRows(o, src.rowSpan) : 1 };
10611
+ const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access', _437 => _437[o], 'optionalAccess', _438 => _438[c]]);
10612
+ return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _439 => _439.colSpan]), () => ( 1)), rowSpan: src ? spanRows(o, src.rowSpan) : 1 };
10593
10613
  });
10594
10614
  });
10595
10615
  finalRows = finalGrid.length;
@@ -10609,14 +10629,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
10609
10629
  if (!assignedItems.has(textItems[ti]) && !inExpanded(textItems[ti])) usedItems.delete(owners[ti]);
10610
10630
  }
10611
10631
  }
10612
- if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _429 => _429[0], 'optionalAccess', _430 => _430[0], 'optionalAccess', _431 => _431.text]), () => ( "")))) {
10632
+ if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _440 => _440[0], 'optionalAccess', _441 => _441[0], 'optionalAccess', _442 => _442.text]), () => ( "")))) {
10613
10633
  prependUnitRow(finalGrid, numCols, unitLine, usedItems);
10614
10634
  finalRows++;
10615
10635
  }
10616
10636
  if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
10617
10637
  let semanticOneColumn = false;
10618
10638
  if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
10619
- const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _432 => _432[0], 'optionalAccess', _433 => _433.text, 'access', _434 => _434.trim, 'call', _435 => _435()]));
10639
+ const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _443 => _443[0], 'optionalAccess', _444 => _444.text, 'access', _445 => _445.trim, 'call', _446 => _446()]));
10620
10640
  if (populatedRows.length >= 4) {
10621
10641
  const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
10622
10642
  const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
@@ -10714,7 +10734,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
10714
10734
  height: grid.bbox.y2 - grid.bbox.y1
10715
10735
  };
10716
10736
  if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
10717
- const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _436 => _436[0], 'optionalAccess', _437 => _437[0], 'optionalAccess', _438 => _438.text]), () => ( ""));
10737
+ const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _447 => _447[0], 'optionalAccess', _448 => _448[0], 'optionalAccess', _449 => _449.text]), () => ( ""));
10718
10738
  const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
10719
10739
  const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
10720
10740
  const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
@@ -10733,8 +10753,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
10733
10753
  }
10734
10754
  }
10735
10755
  if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
10736
- const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _439 => _439.cells, 'access', _440 => _440[0], 'optionalAccess', _441 => _441[0], 'optionalAccess', _442 => _442.blocks]) : void 0;
10737
- if (_optionalChain([paragraphs, 'optionalAccess', _443 => _443.length])) {
10756
+ const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _450 => _450.cells, 'access', _451 => _451[0], 'optionalAccess', _452 => _452[0], 'optionalAccess', _453 => _453.blocks]) : void 0;
10757
+ if (_optionalChain([paragraphs, 'optionalAccess', _454 => _454.length])) {
10738
10758
  blocks.push(...paragraphs);
10739
10759
  frameParagraphUnits.push(paragraphs);
10740
10760
  recordFrameReadingUnit(paragraphs, tableBbox);
@@ -10781,7 +10801,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
10781
10801
  const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
10782
10802
  const b = cr.bbox;
10783
10803
  const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
10784
- 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', _444 => _444.text, 'optionalAccess', _445 => _445.match, 'call', _446 => _446(/\p{L}/gu), 'optionalAccess', _447 => _447.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _448 => _448.table, 'optionalAccess', _449 => _449.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
10804
+ 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', _455 => _455.text, 'optionalAccess', _456 => _456.match, 'call', _457 => _457(/\p{L}/gu), 'optionalAccess', _458 => _458.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _459 => _459.table, 'optionalAccess', _460 => _460.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
10785
10805
  });
10786
10806
  if (clusterResults.length > 0) {
10787
10807
  const ciToIdx = /* @__PURE__ */ new Map();
@@ -10818,7 +10838,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
10818
10838
  groupSizes.push(1);
10819
10839
  }
10820
10840
  const allY = remaining.map((i) => i.y);
10821
- const pageH = _chunk4SKZG3K4cjs.safeMax.call(void 0, allY) - _chunk4SKZG3K4cjs.safeMin.call(void 0, allY);
10841
+ const pageH = _chunk3EPX46NFcjs.safeMax.call(void 0, allY) - _chunk3EPX46NFcjs.safeMin.call(void 0, allY);
10822
10842
  const gapThreshold = Math.max(15, pageH * 0.03);
10823
10843
  const sides = frameColumnTextBands(remaining, spanning, gx);
10824
10844
  const textBlocks = [];
@@ -10834,7 +10854,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
10834
10854
  finalTextBlocks.push(...detectListBlocks(textBlocks));
10835
10855
  } else {
10836
10856
  const allY = remaining.map((i) => i.y);
10837
- const pageH = _chunk4SKZG3K4cjs.safeMax.call(void 0, allY) - _chunk4SKZG3K4cjs.safeMin.call(void 0, allY);
10857
+ const pageH = _chunk3EPX46NFcjs.safeMax.call(void 0, allY) - _chunk3EPX46NFcjs.safeMin.call(void 0, allY);
10838
10858
  const gapThreshold = Math.max(15, pageH * 0.03);
10839
10859
  const groups = xyCutOrder(remaining, gapThreshold);
10840
10860
  const textBlocks = [];
@@ -11196,7 +11216,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
11196
11216
  blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
11197
11217
  } else {
11198
11218
  const allY = items.map((i) => i.y);
11199
- const pageHeight = _chunk4SKZG3K4cjs.safeMax.call(void 0, allY) - _chunk4SKZG3K4cjs.safeMin.call(void 0, allY);
11219
+ const pageHeight = _chunk3EPX46NFcjs.safeMax.call(void 0, allY) - _chunk3EPX46NFcjs.safeMin.call(void 0, allY);
11200
11220
  const gapThreshold = Math.max(15, pageHeight * 0.03);
11201
11221
  const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap);
11202
11222
  for (const group of orderedGroups) {
@@ -11253,19 +11273,19 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
11253
11273
  const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
11254
11274
  return overlapW * overlapH >= b.width * b.height * 0.8;
11255
11275
  });
11256
- const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _450 => _450.text, 'optionalAccess', _451 => _451.match, 'call', _452 => _452(/[\p{L}\p{N}]/gu), 'optionalAccess', _453 => _453.length]), () => ( 0))) >= 2);
11276
+ const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _461 => _461.text, 'optionalAccess', _462 => _462.match, 'call', _463 => _463(/[\p{L}\p{N}]/gu), 'optionalAccess', _464 => _464.length]), () => ( 0))) >= 2);
11257
11277
  const axisFragments = rotatedAxisFragments(candidates);
11258
11278
  const accepted = candidates.filter((b) => {
11259
- if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _454 => _454.text, 'optionalAccess', _455 => _455.match, 'call', _456 => _456(/[\p{L}\p{N}]/gu), 'optionalAccess', _457 => _457.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
11279
+ if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _465 => _465.text, 'optionalAccess', _466 => _466.match, 'call', _467 => _467(/[\p{L}\p{N}]/gu), 'optionalAccess', _468 => _468.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
11260
11280
  const t = b.table;
11261
11281
  if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
11262
11282
  const lone = t.cells.filter((row) => row.filter((c) => c.text.trim()).length === 1 && row.some((c) => c.colSpan === t.cols)).length;
11263
11283
  if (t.rows >= 2 && lone * 2 >= t.rows) return false;
11264
11284
  if (t.rows === 1 && t.cols === 1) {
11265
- const text = _nullishCoalesce(_optionalChain([t, 'access', _458 => _458.cells, 'access', _459 => _459[0], 'optionalAccess', _460 => _460[0], 'optionalAccess', _461 => _461.text]), () => ( ""));
11266
- return (_nullishCoalesce(_optionalChain([text, 'access', _462 => _462.match, 'call', _463 => _463(/\n/g), 'optionalAccess', _464 => _464.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _465 => _465.match, 'call', _466 => _466(/\d/g), 'optionalAccess', _467 => _467.length]), () => ( 0))) >= text.length * 0.25;
11285
+ const text = _nullishCoalesce(_optionalChain([t, 'access', _469 => _469.cells, 'access', _470 => _470[0], 'optionalAccess', _471 => _471[0], 'optionalAccess', _472 => _472.text]), () => ( ""));
11286
+ return (_nullishCoalesce(_optionalChain([text, 'access', _473 => _473.match, 'call', _474 => _474(/\n/g), 'optionalAccess', _475 => _475.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _476 => _476.match, 'call', _477 => _477(/\d/g), 'optionalAccess', _478 => _478.length]), () => ( 0))) >= text.length * 0.25;
11267
11287
  }
11268
- const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _468 => _468.cells, 'access', _469 => _469[0], 'optionalAccess', _470 => _470.filter, 'call', _471 => _471((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _472 => _472.length]), () => ( 0));
11288
+ const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _479 => _479.cells, 'access', _480 => _480[0], 'optionalAccess', _481 => _481.filter, 'call', _482 => _482((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _483 => _483.length]), () => ( 0));
11269
11289
  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);
11270
11290
  });
11271
11291
  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, () => ( "")))) : []);
@@ -11282,14 +11302,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
11282
11302
  for (const block of selected) {
11283
11303
  if (seen2.has(block)) continue;
11284
11304
  const frame = FRAME_READING_UNITS.get(block);
11285
- const source = _optionalChain([frame, 'optionalAccess', _473 => _473.blocks, 'access', _474 => _474.every, 'call', _475 => _475((member) => selectedSet.has(member))]) ? frame.blocks : [block];
11305
+ const source = _optionalChain([frame, 'optionalAccess', _484 => _484.blocks, 'access', _485 => _485.every, 'call', _486 => _486((member) => selectedSet.has(member))]) ? frame.blocks : [block];
11286
11306
  source.forEach((member) => seen2.add(member));
11287
11307
  const available = source.filter((member) => !hasOriginal(member));
11288
11308
  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 }));
11289
11309
  for (const unit of units) {
11290
11310
  const b = unit.bbox;
11291
11311
  const index = blocks.findIndex((existing) => {
11292
- const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _476 => _476.get, 'call', _477 => _477(existing), 'optionalAccess', _478 => _478.bbox]), () => ( existing.bbox));
11312
+ const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _487 => _487.get, 'call', _488 => _488(existing), 'optionalAccess', _489 => _489.bbox]), () => ( existing.bbox));
11293
11313
  if (existing.pageNumber !== page || !e) return false;
11294
11314
  const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
11295
11315
  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;
@@ -11307,16 +11327,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
11307
11327
  }
11308
11328
  function axisTick(block, candidates) {
11309
11329
  const b = block.bbox;
11310
- if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _479 => _479.text, 'optionalAccess', _480 => _480.trim, 'call', _481 => _481()]), () => ( "")))) return false;
11311
- const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _482 => _482.text, 'optionalAccess', _483 => _483.trim, 'call', _484 => _484()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
11330
+ if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _490 => _490.text, 'optionalAccess', _491 => _491.trim, 'call', _492 => _492()]), () => ( "")))) return false;
11331
+ const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _493 => _493.text, 'optionalAccess', _494 => _494.trim, 'call', _495 => _495()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
11312
11332
  const cy = b.y + b.height / 2, right = b.x + b.width;
11313
11333
  const row = numeric.filter((o) => Math.abs(o.bbox.y + o.bbox.height / 2 - cy) <= Math.min(o.bbox.height, b.height) * 0.35);
11314
11334
  const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
11315
11335
  return row.length >= 2 || column.length >= 2;
11316
11336
  }
11317
11337
  function supportedDiagramLabel(block, labels, region) {
11318
- const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _485 => _485.text, 'optionalAccess', _486 => _486.trim, 'call', _487 => _487()]), () => ( ""));
11319
- 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', _488 => _488.text, 'optionalAccess', _489 => _489.match, 'call', _490 => _490(/\p{N}/gu), 'optionalAccess', _491 => _491.length]), () => ( 0))) >= 2).length < 2) return false;
11338
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _496 => _496.text, 'optionalAccess', _497 => _497.trim, 'call', _498 => _498()]), () => ( ""));
11339
+ 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', _499 => _499.text, 'optionalAccess', _500 => _500.match, 'call', _501 => _501(/\p{N}/gu), 'optionalAccess', _502 => _502.length]), () => ( 0))) >= 2).length < 2) return false;
11320
11340
  let above = false, below = false;
11321
11341
  for (const label of labels) {
11322
11342
  const a = label.bbox, em = Math.max(b.height, a.height);
@@ -11331,7 +11351,7 @@ function rotatedAxisFragments(candidates) {
11331
11351
  const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
11332
11352
  const axes = [];
11333
11353
  for (const block of paragraphs) {
11334
- const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _492 => _492.text, 'optionalAccess', _493 => _493.trim, 'call', _494 => _494()]), () => ( ""));
11354
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _503 => _503.text, 'optionalAccess', _504 => _504.trim, 'call', _505 => _505()]), () => ( ""));
11335
11355
  if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
11336
11356
  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);
11337
11357
  if (axis) axis.push(block);
@@ -11348,8 +11368,8 @@ function rotatedAxisFragments(candidates) {
11348
11368
  const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
11349
11369
  if (top - bottom < em * 6) continue;
11350
11370
  const left = paragraphs.filter((block) => {
11351
- const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _495 => _495.text, 'optionalAccess', _496 => _496.trim, 'call', _497 => _497()]), () => ( ""));
11352
- return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _498 => _498.match, 'call', _499 => _499(/[\p{L}\p{N}]/gu), 'optionalAccess', _500 => _500.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;
11371
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _506 => _506.text, 'optionalAccess', _507 => _507.trim, 'call', _508 => _508()]), () => ( ""));
11372
+ return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _509 => _509.match, 'call', _510 => _510(/[\p{L}\p{N}]/gu), 'optionalAccess', _511 => _511.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;
11353
11373
  });
11354
11374
  const stack = left.filter((a) => left.some((b) => {
11355
11375
  if (a === b || !aligned(a, b)) return false;
@@ -11359,7 +11379,7 @@ function rotatedAxisFragments(candidates) {
11359
11379
  if (stack.length < 2) continue;
11360
11380
  for (const block of paragraphs) {
11361
11381
  const b = block.bbox;
11362
- 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', _501 => _501.text, 'optionalAccess', _502 => _502.trim, 'call', _503 => _503()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
11382
+ 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', _512 => _512.text, 'optionalAccess', _513 => _513.trim, 'call', _514 => _514()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
11363
11383
  }
11364
11384
  }
11365
11385
  return fragments;
@@ -11466,4 +11486,4 @@ function rowParagraphs(block) {
11466
11486
 
11467
11487
 
11468
11488
  exports.DEFAULT_OCR_MODELS = DEFAULT_OCR_MODELS; exports.resolveOcrModels = resolveOcrModels; exports.handwritingFallbackModels = handwritingFallbackModels; exports.ocrSelectionKey = ocrSelectionKey; exports.ocrSourcePath = ocrSourcePath; exports.ensureOcrModelsFor = ensureOcrModelsFor; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.grayCrop = grayCrop; exports.inkStats = inkStats; exports.splitRowBands = splitRowBands; exports.leadingTriangle = leadingTriangle; exports.arrowGlyph = arrowGlyph; exports.leaderRuns = leaderRuns; exports.inkBounds = inkBounds; exports.bracketFeatures = bracketFeatures; exports.slantedPair = slantedPair; exports.romanStems = romanStems; exports.circledAt = circledAt; exports.ringBoxes = ringBoxes; exports.quoteHead = quoteHead; exports.edgeTrim = edgeTrim; exports.tallInkCount = tallInkCount; exports.gapGlyphs = gapGlyphs; exports.ringBullet = ringBullet; exports.dashRatio = dashRatio; exports.leadingRing = leadingRing; exports.discAt = discAt; exports.serifOne = serifOne; exports.starRun = starRun; exports.bracketShape = bracketShape; exports.leadingBullet = leadingBullet; exports.stackedGlyphBands = stackedGlyphBands; exports.rememberOcrTextGaps = rememberOcrTextGaps; exports.copyOcrTextGaps = copyOcrTextGaps; exports.findOcrTextGaps = findOcrTextGaps; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; exports.NO_EDGES = NO_EDGES; exports.hasOpenCellSeam = hasOpenCellSeam; exports.joinCellEdges = joinCellEdges; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.computeBBox = computeBBox; exports.dominantStyle = dominantStyle; exports.normalizeItems = normalizeItems; exports.groupByY = groupByY; exports.mergeLineSimple = mergeLineSimple; exports.WrapLexicon = WrapLexicon; exports.startsNewItem = startsNewItem; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.splitPageBreakWraps = splitPageBreakWraps; exports.latinSoftWrap = latinSoftWrap; exports.TOC_BLOCKS = TOC_BLOCKS; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.mergeStackedHeadingLines = mergeStackedHeadingLines; exports.detectTypographyHeadings = detectTypographyHeadings; exports.detectDocumentStyleHeadings = detectDocumentStyleHeadings; exports.detectSiblingStyleHeadings = detectSiblingStyleHeadings; exports.detectRepeatedPageLabels = detectRepeatedPageLabels; exports.detectPageLeadHeadings = detectPageLeadHeadings; exports.refineDocumentStyleHeadings = refineDocumentStyleHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.runningLinePatterns = runningLinePatterns; exports.stripAbsorbedRunningLines = stripAbsorbedRunningLines; exports.CLIP_TABLES = CLIP_TABLES; exports.FRAME_TITLE_BLOCKS = FRAME_TITLE_BLOCKS; exports.TABLE_COLXS = TABLE_COLXS; exports.TABLE_ROWYS = TABLE_ROWYS; exports.TABLE_TAIL = TABLE_TAIL; exports.PART_COLXS = PART_COLXS; exports.EMPTY_PARTS = EMPTY_PARTS; exports.IMAGE_CELLS = IMAGE_CELLS; exports.FILLER_CELLS = FILLER_CELLS; exports.CONT_PARTS = CONT_PARTS; exports.CELL_LINES = CELL_LINES; exports.ROW_RULES = ROW_RULES; exports.trimTrailingEmptyTableCols = trimTrailingEmptyTableCols; exports.restoreImageBullets = restoreImageBullets; exports.detectRightArrowRegions = detectRightArrowRegions; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.UNRULED_REGION_TABLES = UNRULED_REGION_TABLES; exports.mergeOcrImageRegions = mergeOcrImageRegions;
11469
- //# sourceMappingURL=chunk-SQXRRR75.cjs.map
11489
+ //# sourceMappingURL=chunk-EESBEBUC.cjs.map