kordoc 4.18.2 → 4.18.4

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 (152) hide show
  1. package/dist/{-I3CP33G4.js → -DDAVBMHD.js} +11 -11
  2. package/dist/{chunk-O2DI4GHD.js → chunk-274ZPMHK.js} +2 -2
  3. package/dist/{chunk-QGFZU3JE.cjs → chunk-3WLZOJIE.cjs} +10 -8
  4. package/dist/chunk-3WLZOJIE.cjs.map +1 -0
  5. package/dist/{chunk-UZGZRGYM.cjs → chunk-3XSP7V5P.cjs} +10 -5
  6. package/dist/chunk-3XSP7V5P.cjs.map +1 -0
  7. package/dist/{chunk-GM7XIZF2.js → chunk-4IBY5LTJ.js} +2 -2
  8. package/dist/chunk-6H25SXDI.js +11 -0
  9. package/dist/chunk-6H25SXDI.js.map +1 -0
  10. package/dist/{chunk-N5DQFA7L.js → chunk-7GR2GCJF.js} +10 -5
  11. package/dist/chunk-7GR2GCJF.js.map +1 -0
  12. package/dist/{chunk-YNLW6EGU.cjs → chunk-AVIZ55NQ.cjs} +3 -3
  13. package/dist/chunk-AVIZ55NQ.cjs.map +1 -0
  14. package/dist/chunk-DC6CTQTK.js +9 -0
  15. package/dist/chunk-DC6CTQTK.js.map +1 -0
  16. package/dist/{chunk-L5RLJPI3.js → chunk-DUV7Y6IQ.js} +3 -3
  17. package/dist/{chunk-KDMAYOWH.cjs → chunk-E2644XCO.cjs} +698 -189
  18. package/dist/chunk-E2644XCO.cjs.map +1 -0
  19. package/dist/{chunk-LSOD2A6N.js → chunk-ELOPDQES.js} +2 -2
  20. package/dist/{chunk-M4P7YS2N.js → chunk-F2GDLA45.js} +81 -61
  21. package/dist/chunk-F2GDLA45.js.map +1 -0
  22. package/dist/{chunk-OBILAVWC.js → chunk-F5YVCJVF.js} +10 -5
  23. package/dist/chunk-F5YVCJVF.js.map +1 -0
  24. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  25. package/dist/{chunk-4B2EXELH.js → chunk-HRJJDNRD.js} +2 -2
  26. package/dist/{chunk-CKUIFTXJ.js → chunk-IAXGGQGD.js} +2 -2
  27. package/dist/{chunk-BL7KRE6X.js → chunk-IBQCK4F3.js} +7 -3
  28. package/dist/chunk-IBQCK4F3.js.map +1 -0
  29. package/dist/chunk-J55UQC5H.cjs.map +1 -1
  30. package/dist/{chunk-OGAYGUJF.js → chunk-KUUSP6OS.js} +581 -72
  31. package/dist/chunk-KUUSP6OS.js.map +1 -0
  32. package/dist/{chunk-LACO375L.js → chunk-LGF2IO66.js} +4 -3
  33. package/dist/chunk-LGF2IO66.js.map +1 -0
  34. package/dist/{chunk-L64QRUMK.js → chunk-MXA6YW2W.js} +582 -73
  35. package/dist/chunk-MXA6YW2W.js.map +1 -0
  36. package/dist/{chunk-OI5ZSSIC.cjs → chunk-OIUSF2VA.cjs} +16 -12
  37. package/dist/chunk-OIUSF2VA.cjs.map +1 -0
  38. package/dist/{chunk-6OKBTY72.js → chunk-QVCHFCT2.js} +2 -2
  39. package/dist/{chunk-C2CVOC5K.js → chunk-RCI7LY4N.js} +8 -4
  40. package/dist/chunk-RCI7LY4N.js.map +1 -0
  41. package/dist/{chunk-W2YYBPW5.cjs → chunk-SVNBZEL6.cjs} +3 -3
  42. package/dist/chunk-SVNBZEL6.cjs.map +1 -0
  43. package/dist/{chunk-VSY5PAJ5.js → chunk-T2BJPT6D.js} +3 -3
  44. package/dist/{chunk-VSY5PAJ5.js.map → chunk-T2BJPT6D.js.map} +1 -1
  45. package/dist/chunk-TK3FDAEE.cjs +9 -0
  46. package/dist/chunk-TK3FDAEE.cjs.map +1 -0
  47. package/dist/{chunk-F5HING4Y.js → chunk-TMJVD6FW.js} +5 -4
  48. package/dist/chunk-TMJVD6FW.js.map +1 -0
  49. package/dist/{chunk-T4MXCSBP.js → chunk-V5X4LLVM.js} +71 -47
  50. package/dist/chunk-V5X4LLVM.js.map +1 -0
  51. package/dist/{chunk-IA3UKDHA.js → chunk-VTVK2JMI.js} +3 -2
  52. package/dist/{chunk-IA3UKDHA.js.map → chunk-VTVK2JMI.js.map} +1 -1
  53. package/dist/{chunk-B2E6C2LH.js → chunk-XG4SYOZL.js} +6 -4
  54. package/dist/chunk-XG4SYOZL.js.map +1 -0
  55. package/dist/{chunk-QP7IXF7R.js → chunk-YCY2R4FM.js} +2 -2
  56. package/dist/{chunk-NZM2SSI4.js → chunk-Z2PPDQK2.js} +2 -2
  57. package/dist/chunks-5QTTAT5T.js +10 -0
  58. package/dist/cli.js +179 -119
  59. package/dist/cli.js.map +1 -1
  60. package/dist/{formula-E3N7KDDG.js → formula-7ZOZ5QJ6.js} +8 -4
  61. package/dist/{formula-E3N7KDDG.js.map → formula-7ZOZ5QJ6.js.map} +1 -1
  62. package/dist/{formula-AQZODKZF.js → formula-HQFZEXFF.js} +7 -3
  63. package/dist/{formula-AQZODKZF.js.map → formula-HQFZEXFF.js.map} +1 -1
  64. package/dist/{formula-VY4ITOMN.cjs → formula-YYJQBKEN.cjs} +13 -9
  65. package/dist/formula-YYJQBKEN.cjs.map +1 -0
  66. package/dist/{image-ocr-IMYXOHHV.js → image-ocr-4BGX2EJJ.js} +7 -6
  67. package/dist/{image-ocr-IMYXOHHV.js.map → image-ocr-4BGX2EJJ.js.map} +1 -1
  68. package/dist/{image-ocr-6LYEBMVR.cjs → image-ocr-CC26Q5KG.cjs} +16 -15
  69. package/dist/image-ocr-CC26Q5KG.cjs.map +1 -0
  70. package/dist/{image-ocr-LN3GSQPW.js → image-ocr-RK3HJVCI.js} +10 -9
  71. package/dist/{image-ocr-LN3GSQPW.js.map → image-ocr-RK3HJVCI.js.map} +1 -1
  72. package/dist/index.cjs +860 -817
  73. package/dist/index.cjs.map +1 -1
  74. package/dist/index.js +141 -98
  75. package/dist/index.js.map +1 -1
  76. package/dist/mcp.js +26 -26
  77. package/dist/mcp.js.map +1 -1
  78. package/dist/{model-bundle-IHKNDLOT.js → model-bundle-VHRXG63R.js} +5 -5
  79. package/dist/{models-YXITRAMR.js → models-G3WA24SY.js} +5 -5
  80. package/dist/page-range-QHHFTL7X.cjs.map +1 -1
  81. package/dist/{parser-7KECZTTP.cjs → parser-BGORCLIU.cjs} +461 -243
  82. package/dist/parser-BGORCLIU.cjs.map +1 -0
  83. package/dist/{parser-M3T2EWUN.js → parser-GFDGAVLV.js} +255 -37
  84. package/dist/parser-GFDGAVLV.js.map +1 -0
  85. package/dist/{parser-KB4BYQBZ.js → parser-SOWTUOMK.js} +258 -40
  86. package/dist/parser-SOWTUOMK.js.map +1 -0
  87. package/dist/pdf-ocr-7IOOVR2I.js +20 -0
  88. package/dist/pdf-ocr-EJ2HNZN6.cjs +17 -0
  89. package/dist/pdf-ocr-EJ2HNZN6.cjs.map +1 -0
  90. package/dist/pdf-ocr-RACAZU3N.js +16 -0
  91. package/dist/{profile-io-GQWQR7YQ.js → profile-io-Q2T47RVH.js} +3 -3
  92. package/dist/{rasterize-Y6TVFQ3M.js → rasterize-OAVMUTE6.js} +3 -3
  93. package/dist/{redact-doc-TRPZ3HNW.js → redact-doc-ECFOVR4X.js} +11 -11
  94. package/dist/{render-GHT5HKBO.js → render-NSKWZVTD.js} +7 -7
  95. package/dist/seal-A4MG7MPQ.js +10 -0
  96. package/dist/{setup-AGSCEHDB.js → setup-REH2KZP2.js} +3 -3
  97. package/dist/visual-B56WQAGW.js +20 -0
  98. package/dist/{watch-ALSEW4GB.js → watch-JXDUZYBY.js} +13 -13
  99. package/dist/watch-JXDUZYBY.js.map +1 -0
  100. package/package.json +1 -1
  101. package/dist/chunk-B2E6C2LH.js.map +0 -1
  102. package/dist/chunk-BL7KRE6X.js.map +0 -1
  103. package/dist/chunk-C2CVOC5K.js.map +0 -1
  104. package/dist/chunk-F5HING4Y.js.map +0 -1
  105. package/dist/chunk-KDMAYOWH.cjs.map +0 -1
  106. package/dist/chunk-L64QRUMK.js.map +0 -1
  107. package/dist/chunk-LACO375L.js.map +0 -1
  108. package/dist/chunk-M4P7YS2N.js.map +0 -1
  109. package/dist/chunk-N5DQFA7L.js.map +0 -1
  110. package/dist/chunk-OBILAVWC.js.map +0 -1
  111. package/dist/chunk-OGAYGUJF.js.map +0 -1
  112. package/dist/chunk-OI5ZSSIC.cjs.map +0 -1
  113. package/dist/chunk-QGFZU3JE.cjs.map +0 -1
  114. package/dist/chunk-T4MXCSBP.js.map +0 -1
  115. package/dist/chunk-UZGZRGYM.cjs.map +0 -1
  116. package/dist/chunk-W2YYBPW5.cjs.map +0 -1
  117. package/dist/chunk-YNLW6EGU.cjs.map +0 -1
  118. package/dist/chunks-IFFRC5IQ.js +0 -10
  119. package/dist/formula-VY4ITOMN.cjs.map +0 -1
  120. package/dist/image-ocr-6LYEBMVR.cjs.map +0 -1
  121. package/dist/parser-7KECZTTP.cjs.map +0 -1
  122. package/dist/parser-KB4BYQBZ.js.map +0 -1
  123. package/dist/parser-M3T2EWUN.js.map +0 -1
  124. package/dist/pdf-ocr-4S2OAHUX.js +0 -15
  125. package/dist/pdf-ocr-IGYCZ7G2.cjs +0 -16
  126. package/dist/pdf-ocr-IGYCZ7G2.cjs.map +0 -1
  127. package/dist/pdf-ocr-YEBFWU2K.js +0 -19
  128. package/dist/seal-3YTXSABW.js +0 -10
  129. package/dist/visual-R3E35Q2K.js +0 -20
  130. package/dist/watch-ALSEW4GB.js.map +0 -1
  131. /package/dist/{-I3CP33G4.js.map → -DDAVBMHD.js.map} +0 -0
  132. /package/dist/{chunk-O2DI4GHD.js.map → chunk-274ZPMHK.js.map} +0 -0
  133. /package/dist/{chunk-GM7XIZF2.js.map → chunk-4IBY5LTJ.js.map} +0 -0
  134. /package/dist/{chunk-L5RLJPI3.js.map → chunk-DUV7Y6IQ.js.map} +0 -0
  135. /package/dist/{chunk-LSOD2A6N.js.map → chunk-ELOPDQES.js.map} +0 -0
  136. /package/dist/{chunk-4B2EXELH.js.map → chunk-HRJJDNRD.js.map} +0 -0
  137. /package/dist/{chunk-CKUIFTXJ.js.map → chunk-IAXGGQGD.js.map} +0 -0
  138. /package/dist/{chunk-6OKBTY72.js.map → chunk-QVCHFCT2.js.map} +0 -0
  139. /package/dist/{chunk-QP7IXF7R.js.map → chunk-YCY2R4FM.js.map} +0 -0
  140. /package/dist/{chunk-NZM2SSI4.js.map → chunk-Z2PPDQK2.js.map} +0 -0
  141. /package/dist/{chunks-IFFRC5IQ.js.map → chunks-5QTTAT5T.js.map} +0 -0
  142. /package/dist/{model-bundle-IHKNDLOT.js.map → model-bundle-VHRXG63R.js.map} +0 -0
  143. /package/dist/{models-YXITRAMR.js.map → models-G3WA24SY.js.map} +0 -0
  144. /package/dist/{pdf-ocr-4S2OAHUX.js.map → pdf-ocr-7IOOVR2I.js.map} +0 -0
  145. /package/dist/{pdf-ocr-YEBFWU2K.js.map → pdf-ocr-RACAZU3N.js.map} +0 -0
  146. /package/dist/{profile-io-GQWQR7YQ.js.map → profile-io-Q2T47RVH.js.map} +0 -0
  147. /package/dist/{rasterize-Y6TVFQ3M.js.map → rasterize-OAVMUTE6.js.map} +0 -0
  148. /package/dist/{redact-doc-TRPZ3HNW.js.map → redact-doc-ECFOVR4X.js.map} +0 -0
  149. /package/dist/{render-GHT5HKBO.js.map → render-NSKWZVTD.js.map} +0 -0
  150. /package/dist/{seal-3YTXSABW.js.map → seal-A4MG7MPQ.js.map} +0 -0
  151. /package/dist/{setup-AGSCEHDB.js.map → setup-REH2KZP2.js.map} +0 -0
  152. /package/dist/{visual-R3E35Q2K.js.map → visual-B56WQAGW.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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; } async function _asyncOptionalChain(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 = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
2
 
3
3
 
4
- var _chunkW2YYBPW5cjs = require('./chunk-W2YYBPW5.cjs');
4
+ var _chunkSVNBZEL6cjs = require('./chunk-SVNBZEL6.cjs');
5
5
 
6
6
 
7
7
 
@@ -48,7 +48,6 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
48
48
 
49
49
 
50
50
 
51
- var _chunkKDMAYOWHcjs = require('./chunk-KDMAYOWH.cjs');
52
51
 
53
52
 
54
53
 
@@ -58,12 +57,22 @@ var _chunkKDMAYOWHcjs = require('./chunk-KDMAYOWH.cjs');
58
57
 
59
58
 
60
59
 
61
- var _chunkQGFZU3JEcjs = require('./chunk-QGFZU3JE.cjs');
62
- require('./chunk-YNLW6EGU.cjs');
60
+ var _chunkE2644XCOcjs = require('./chunk-E2644XCO.cjs');
63
61
 
64
62
 
65
63
 
66
- var _chunkUZGZRGYMcjs = require('./chunk-UZGZRGYM.cjs');
64
+
65
+
66
+
67
+
68
+
69
+
70
+ var _chunk3WLZOJIEcjs = require('./chunk-3WLZOJIE.cjs');
71
+ require('./chunk-AVIZ55NQ.cjs');
72
+
73
+
74
+
75
+ var _chunk3XSP7V5Pcjs = require('./chunk-3XSP7V5P.cjs');
67
76
 
68
77
 
69
78
  var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
@@ -79,41 +88,103 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
79
88
  const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
80
89
  return overlapW * overlapH >= b.width * b.height * 0.8;
81
90
  });
91
+ const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _2 => _2.text, 'optionalAccess', _3 => _3.match, 'call', _4 => _4(/[\p{L}\p{N}]/gu), 'optionalAccess', _5 => _5.length]), () => ( 0))) >= 2);
92
+ const axisFragments = rotatedAxisFragments(candidates);
82
93
  const accepted = candidates.filter((b) => {
83
- if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _2 => _2.text, 'optionalAccess', _3 => _3.match, 'call', _4 => _4(/[\p{L}\p{N}]/gu), 'optionalAccess', _5 => _5.length]), () => ( 0))) >= 2;
94
+ if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _6 => _6.text, 'optionalAccess', _7 => _7.match, 'call', _8 => _8(/[\p{L}\p{N}]/gu), 'optionalAccess', _9 => _9.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && supportedDiagramLabel(b, labels, region);
84
95
  const t = b.table;
85
96
  if (b.type !== "table" || !t) return false;
86
97
  if (t.rows === 1 && t.cols === 1) {
87
- const text = _nullishCoalesce(_optionalChain([t, 'access', _6 => _6.cells, 'access', _7 => _7[0], 'optionalAccess', _8 => _8[0], 'optionalAccess', _9 => _9.text]), () => ( ""));
88
- return (_nullishCoalesce(_optionalChain([text, 'access', _10 => _10.match, 'call', _11 => _11(/\n/g), 'optionalAccess', _12 => _12.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _13 => _13.match, 'call', _14 => _14(/\d/g), 'optionalAccess', _15 => _15.length]), () => ( 0))) >= text.length * 0.25;
98
+ const text = _nullishCoalesce(_optionalChain([t, 'access', _10 => _10.cells, 'access', _11 => _11[0], 'optionalAccess', _12 => _12[0], 'optionalAccess', _13 => _13.text]), () => ( ""));
99
+ return (_nullishCoalesce(_optionalChain([text, 'access', _14 => _14.match, 'call', _15 => _15(/\n/g), 'optionalAccess', _16 => _16.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _17 => _17.match, 'call', _18 => _18(/\d/g), 'optionalAccess', _19 => _19.length]), () => ( 0))) >= text.length * 0.25;
89
100
  }
90
- const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _16 => _16.cells, 'access', _17 => _17[0], 'optionalAccess', _18 => _18.filter, 'call', _19 => _19((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _20 => _20.length]), () => ( 0));
101
+ const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _20 => _20.cells, 'access', _21 => _21[0], 'optionalAccess', _22 => _22.filter, 'call', _23 => _23((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _24 => _24.length]), () => ( 0));
91
102
  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);
92
103
  });
93
104
  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, () => ( "")))) : []);
94
- for (const block of selected) {
105
+ const hasOriginal = (block) => blocks.some((existing) => {
95
106
  const b = block.bbox;
96
- const hasOriginal = blocks.some((existing) => {
97
- if (existing.pageNumber !== page || !existing.bbox || existing.type === "image") return false;
98
- const e = existing.bbox;
99
- const x = Math.max(0, Math.min(e.x + e.width, b.x + b.width) - Math.max(e.x, b.x));
100
- const y = Math.max(0, Math.min(e.y + e.height, b.y + b.height) - Math.max(e.y, b.y));
101
- return x * y > b.width * b.height * 0.2;
102
- });
103
- if (hasOriginal) continue;
104
- const index = blocks.findIndex((existing) => {
105
- const e = existing.bbox;
106
- if (existing.pageNumber !== page || !e) return false;
107
- const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
108
- return e.y < b.y || beside;
109
- });
110
- const placed = block.type === "paragraph" ? { ...block, style: void 0 } : block;
111
- blocks.splice(index < 0 ? blocks.length : index, 0, placed);
112
- added++;
107
+ if (existing.pageNumber !== page || !existing.bbox || existing.type === "image") return false;
108
+ const e = existing.bbox;
109
+ const x = Math.max(0, Math.min(e.x + e.width, b.x + b.width) - Math.max(e.x, b.x));
110
+ const y = Math.max(0, Math.min(e.y + e.height, b.y + b.height) - Math.max(e.y, b.y));
111
+ return x * y > b.width * b.height * 0.2;
112
+ });
113
+ const selectedSet = new Set(selected), seen = /* @__PURE__ */ new Set();
114
+ for (const block of selected) {
115
+ if (seen.has(block)) continue;
116
+ const frame = _chunkE2644XCOcjs.FRAME_READING_UNITS.get(block);
117
+ const source = _optionalChain([frame, 'optionalAccess', _25 => _25.blocks, 'access', _26 => _26.every, 'call', _27 => _27((member) => selectedSet.has(member))]) ? frame.blocks : [block];
118
+ source.forEach((member) => seen.add(member));
119
+ const available = source.filter((member) => !hasOriginal(member));
120
+ 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 }));
121
+ for (const unit of units) {
122
+ const b = unit.bbox;
123
+ const index = blocks.findIndex((existing) => {
124
+ const e = _nullishCoalesce(_optionalChain([_chunkE2644XCOcjs.FRAME_READING_UNITS, 'access', _28 => _28.get, 'call', _29 => _29(existing), 'optionalAccess', _30 => _30.bbox]), () => ( existing.bbox));
125
+ if (existing.pageNumber !== page || !e) return false;
126
+ const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
127
+ return e.y < b.y || beside;
128
+ });
129
+ const placed = unit.blocks.map((member) => member.type === "paragraph" ? { ...member, style: void 0 } : member);
130
+ if (unit.atomic) _chunkE2644XCOcjs.recordFrameReadingUnit.call(void 0, placed, unit.bbox);
131
+ blocks.splice(index < 0 ? blocks.length : index, 0, ...placed);
132
+ added += placed.length;
133
+ }
113
134
  }
114
135
  }
115
136
  return added;
116
137
  }
138
+ function supportedDiagramLabel(block, labels, region) {
139
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _31 => _31.text, 'optionalAccess', _32 => _32.trim, 'call', _33 => _33()]), () => ( ""));
140
+ 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', _34 => _34.text, 'optionalAccess', _35 => _35.match, 'call', _36 => _36(/\p{N}/gu), 'optionalAccess', _37 => _37.length]), () => ( 0))) >= 2).length < 2) return false;
141
+ let above = false, below = false;
142
+ for (const label of labels) {
143
+ const a = label.bbox, em = Math.max(b.height, a.height);
144
+ if (b.x + b.width < a.x - em * 2 || b.x > a.x + a.width + em * 2) continue;
145
+ const upperGap = a.y - (b.y + b.height), lowerGap = b.y - (a.y + a.height);
146
+ if (upperGap >= 0 && upperGap <= em * 4) above = true;
147
+ if (lowerGap >= 0 && lowerGap <= em * 4) below = true;
148
+ }
149
+ return above && below;
150
+ }
151
+ function rotatedAxisFragments(candidates) {
152
+ const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
153
+ const axes = [];
154
+ for (const block of paragraphs) {
155
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _38 => _38.text, 'optionalAccess', _39 => _39.trim, 'call', _40 => _40()]), () => ( ""));
156
+ if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
157
+ 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);
158
+ if (axis) axis.push(block);
159
+ else axes.push([block]);
160
+ }
161
+ const fragments = /* @__PURE__ */ new Set();
162
+ const aligned = (a, b) => {
163
+ const x = a.bbox, y = b.bbox, tolerance = Math.max(x.height, y.height) * 0.5;
164
+ return Math.abs(x.x - y.x) <= tolerance || Math.abs(x.x + x.width - y.x - y.width) <= tolerance;
165
+ };
166
+ for (const axis of axes) {
167
+ if (axis.length < 3) continue;
168
+ const bottom = Math.min(...axis.map((a) => a.bbox.y)), top = Math.max(...axis.map((a) => a.bbox.y + a.bbox.height));
169
+ const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
170
+ if (top - bottom < em * 6) continue;
171
+ const left = paragraphs.filter((block) => {
172
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _41 => _41.text, 'optionalAccess', _42 => _42.trim, 'call', _43 => _43()]), () => ( ""));
173
+ return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _44 => _44.match, 'call', _45 => _45(/[\p{L}\p{N}]/gu), 'optionalAccess', _46 => _46.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;
174
+ });
175
+ const stack = left.filter((a) => left.some((b) => {
176
+ if (a === b || !aligned(a, b)) return false;
177
+ const x = a.bbox, y = b.bbox, gap = Math.max(x.y, y.y) - Math.min(x.y + x.height, y.y + y.height);
178
+ return gap >= -Math.min(x.height, y.height) * 0.5 && gap <= Math.max(x.height, y.height);
179
+ }));
180
+ if (stack.length < 2) continue;
181
+ for (const block of paragraphs) {
182
+ const b = block.bbox;
183
+ 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', _47 => _47.text, 'optionalAccess', _48 => _48.trim, 'call', _49 => _49()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
184
+ }
185
+ }
186
+ return fragments;
187
+ }
117
188
  function rowParagraphs(block) {
118
189
  const t = block.table, b = block.bbox;
119
190
  const h = b.height / t.rows;
@@ -218,7 +289,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
218
289
  let imgData = null;
219
290
  let dedupeId = null;
220
291
  if (op === _pdfmjs.OPS.paintImageXObject || op === _pdfmjs.OPS.paintImageXObjectRepeat) {
221
- const objId = _optionalChain([argsArray, 'access', _21 => _21[i], 'optionalAccess', _22 => _22[0]]);
292
+ const objId = _optionalChain([argsArray, 'access', _50 => _50[i], 'optionalAccess', _51 => _51[0]]);
222
293
  if (typeof objId !== "string" || pageSeenIds.has(objId)) continue;
223
294
  pageSeenIds.add(objId);
224
295
  dedupeId = objId;
@@ -235,16 +306,16 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
235
306
  if (dedupeId) {
236
307
  imgData = await resolveImgData(page, dedupeId);
237
308
  } else {
238
- imgData = _optionalChain([argsArray, 'access', _23 => _23[i], 'optionalAccess', _24 => _24[0]]);
309
+ imgData = _optionalChain([argsArray, 'access', _52 => _52[i], 'optionalAccess', _53 => _53[0]]);
239
310
  }
240
- if (!_optionalChain([imgData, 'optionalAccess', _25 => _25.data]) || !imgData.width || !imgData.height) continue;
311
+ if (!_optionalChain([imgData, 'optionalAccess', _54 => _54.data]) || !imgData.width || !imgData.height) continue;
241
312
  const { width: w, height: h } = imgData;
242
313
  if (w < MIN_DIM || h < MIN_DIM) continue;
243
314
  if (w * h > MAX_PIXELS) {
244
315
  warnings.push({ page: pageNumber, message: `\uC774\uBBF8\uC9C0 \uD06C\uAE30 \uCD08\uACFC\uB85C \uCD94\uCD9C \uC0DD\uB7B5 (${w}\xD7${h})`, code: "SKIPPED_IMAGE" });
245
316
  continue;
246
317
  }
247
- const globalId = _optionalChain([dedupeId, 'optionalAccess', _26 => _26.startsWith, 'call', _27 => _27("g_")]) ? dedupeId : void 0;
318
+ const globalId = _optionalChain([dedupeId, 'optionalAccess', _55 => _55.startsWith, 'call', _56 => _56("g_")]) ? dedupeId : void 0;
248
319
  let hash = globalId ? state.globalKeys.get(globalId) : void 0;
249
320
  if (hash === void 0) {
250
321
  hash = `${w}x${h}k${_nullishCoalesce(imgData.kind, () => ( "?"))}h${contentHash(imgData.data)}${dedupeId ? "" : "inline"}`;
@@ -257,7 +328,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
257
328
  const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
258
329
  state.seen.set(hash, filename);
259
330
  if (withBytes) {
260
- const png = _chunkW2YYBPW5cjs.encodePng.call(void 0, w, h, rgba);
331
+ const png = _chunkSVNBZEL6cjs.encodePng.call(void 0, w, h, rgba);
261
332
  state.totalBytes += png.length;
262
333
  images.push({ filename, data: png, mimeType: "image/png" });
263
334
  }
@@ -695,7 +766,7 @@ function anchorsOf(table) {
695
766
  for (let r = 0; r < table.rows; r++) {
696
767
  for (let c = 0; c < table.cols; c++) {
697
768
  if (covered.has(r * 1e5 + c)) continue;
698
- const cell = _optionalChain([table, 'access', _28 => _28.cells, 'access', _29 => _29[r], 'optionalAccess', _30 => _30[c]]);
769
+ const cell = _optionalChain([table, 'access', _57 => _57.cells, 'access', _58 => _58[r], 'optionalAccess', _59 => _59[c]]);
699
770
  if (!cell) continue;
700
771
  out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
701
772
  for (let dr = 0; dr < cell.rowSpan; dr++) {
@@ -772,24 +843,24 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
772
843
  if (r + dr < rows) owner[r + dr][dc] = placed;
773
844
  }
774
845
  grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
775
- const lines = _chunkKDMAYOWHcjs.CELL_LINES.get(a.cell);
776
- if (lines) _chunkKDMAYOWHcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
777
- if (_chunkKDMAYOWHcjs.IMAGE_CELLS.has(a.cell)) _chunkKDMAYOWHcjs.IMAGE_CELLS.add(grid[r][c1]);
778
- const edges = _chunkQGFZU3JEcjs.CELL_EDGES.get(a.cell);
846
+ const lines = _chunkE2644XCOcjs.CELL_LINES.get(a.cell);
847
+ if (lines) _chunkE2644XCOcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
848
+ if (_chunkE2644XCOcjs.IMAGE_CELLS.has(a.cell)) _chunkE2644XCOcjs.IMAGE_CELLS.add(grid[r][c1]);
849
+ const edges = _chunk3WLZOJIEcjs.CELL_EDGES.get(a.cell);
779
850
  if (edges) {
780
- _chunkQGFZU3JEcjs.CELL_EDGES.set(grid[r][c1], edges);
851
+ _chunk3WLZOJIEcjs.CELL_EDGES.set(grid[r][c1], edges);
781
852
  edged = true;
782
853
  }
783
854
  return true;
784
855
  };
785
- for (const a of pa) if (!_chunkKDMAYOWHcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
856
+ for (const a of pa) if (!_chunkE2644XCOcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
786
857
  for (const a of ca) {
787
- if (a.r < skip || _chunkKDMAYOWHcjs.FILLER_CELLS.has(a.cell)) continue;
858
+ if (a.r < skip || _chunkE2644XCOcjs.FILLER_CELLS.has(a.cell)) continue;
788
859
  if (!place(a, cxU, prev.rows - skip, dx)) return null;
789
860
  }
790
861
  const first = prev.rows;
791
862
  for (let c = 0; c < cols; c++) {
792
- const above = _optionalChain([owner, 'access', _31 => _31[first - 1], 'optionalAccess', _32 => _32[c]]);
863
+ const above = _optionalChain([owner, 'access', _60 => _60[first - 1], 'optionalAccess', _61 => _61[c]]);
793
864
  if (!above) continue;
794
865
  let r = first;
795
866
  while (r < rows && owner[r][c] === null) r++;
@@ -808,9 +879,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
808
879
  const grown = { ...above, rs: newRs };
809
880
  for (let rr = above.r; rr < above.r + newRs; rr++) for (let dc = above.c; dc < above.c + above.cs; dc++) owner[rr][dc] = grown;
810
881
  }
811
- for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkKDMAYOWHcjs.FILLER_CELLS.add(grid[r][c]);
882
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkE2644XCOcjs.FILLER_CELLS.add(grid[r][c]);
812
883
  if (edged) {
813
- for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkQGFZU3JEcjs.CELL_EDGES.set(grid[r][c], _chunkKDMAYOWHcjs.NO_EDGES);
884
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunk3WLZOJIEcjs.CELL_EDGES.set(grid[r][c], _chunkE2644XCOcjs.NO_EDGES);
814
885
  }
815
886
  for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
816
887
  let r = prev.rows;
@@ -819,7 +890,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
819
890
  for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
820
891
  }
821
892
  const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
822
- const pr = _chunkKDMAYOWHcjs.ROW_RULES.get(prev), cr = _chunkKDMAYOWHcjs.ROW_RULES.get(curr);
893
+ const pr = _chunkE2644XCOcjs.ROW_RULES.get(prev), cr = _chunkE2644XCOcjs.ROW_RULES.get(curr);
823
894
  const shifted = dx !== 0;
824
895
  const cut = {
825
896
  open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
@@ -830,7 +901,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
830
901
  if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U)) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
831
902
  if (pr && cr) {
832
903
  const cutRuled = pr.bottom || cr.top;
833
- _chunkKDMAYOWHcjs.ROW_RULES.set(table, { top: pr.top, bottom: cr.bottom, innerRuled: pr.innerRuled + cr.innerRuled + (!split && cutRuled ? 1 : 0), innerOpen: pr.innerOpen + cr.innerOpen + (!split && !cutRuled ? 1 : 0) });
904
+ _chunkE2644XCOcjs.ROW_RULES.set(table, { top: pr.top, bottom: cr.bottom, innerRuled: pr.innerRuled + cr.innerRuled + (!split && cutRuled ? 1 : 0), innerOpen: pr.innerOpen + cr.innerOpen + (!split && !cutRuled ? 1 : 0) });
834
905
  }
835
906
  return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
836
907
  }
@@ -884,8 +955,8 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
884
955
  if (!crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
885
956
  if (!straddles && !midWord) continue;
886
957
  if (u.r >= last && d.rs < 2) continue;
887
- const U = _chunkKDMAYOWHcjs.CELL_LINES.get(a);
888
- if (!_optionalChain([U, 'optionalAccess', _33 => _33.length]) || !hasContent(b)) continue;
958
+ const U = _chunkE2644XCOcjs.CELL_LINES.get(a);
959
+ if (!_optionalChain([U, 'optionalAccess', _62 => _62.length]) || !hasContent(b)) continue;
889
960
  if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
890
961
  if (U.length > STRADDLE_MAX_LINES) continue;
891
962
  const lu = U[U.length - 1];
@@ -919,9 +990,20 @@ var CARRIED_MIN_COL_W = 4;
919
990
  var LABEL_ROOM = 1.5;
920
991
  var HANGING_MIN = 0.5;
921
992
  var HANGING_TOL = 1;
993
+ var KO_ITEMS = "\uAC00\uB098\uB2E4\uB77C\uB9C8\uBC14\uC0AC\uC544\uC790\uCC28\uCE74\uD0C0\uD30C\uD558\uAC70\uB108\uB354\uB7EC\uBA38\uBC84\uC11C\uC5B4\uC800\uCC98\uCEE4\uD130\uD37C\uD5C8\uACE0\uB178\uB3C4\uB85C\uBAA8\uBCF4\uC18C\uC624\uC870\uCD08\uCF54\uD1A0\uD3EC\uD638\uAD6C\uB204\uB450\uB8E8\uBB34\uBD80\uC218\uC6B0\uC8FC\uCD94\uCFE0\uD22C\uD478\uD6C4";
994
+ var ITEM_MARK = /^\s*(?:([가-힣])\.|(\d{1,3})[.)]|\(([가-힣\d]{1,3})\))(?=\s)/;
995
+ function nextItemHead(prev, next) {
996
+ const a = ITEM_MARK.exec(prev), b = ITEM_MARK.exec(next);
997
+ if (!a || !b) return false;
998
+ const succ = (x, y) => /^\d+$/.test(x) ? /^\d+$/.test(y) && Number(y) === Number(x) + 1 : KO_ITEMS.indexOf(x) >= 0 && KO_ITEMS.indexOf(y) === KO_ITEMS.indexOf(x) + 1;
999
+ if (a[1] && b[1]) return succ(a[1], b[1]);
1000
+ if (a[2] && b[2]) return succ(a[2], b[2]) && prev.trimStart()[a[2].length] === next.trimStart()[b[2].length];
1001
+ if (a[3] && b[3]) return succ(a[3], b[3]);
1002
+ return false;
1003
+ }
922
1004
  function continuesAcross(u, d, x1, x2) {
923
- const U = _chunkKDMAYOWHcjs.CELL_LINES.get(u), D = _chunkKDMAYOWHcjs.CELL_LINES.get(d);
924
- if (!_optionalChain([U, 'optionalAccess', _34 => _34.length]) || !_optionalChain([D, 'optionalAccess', _35 => _35.length])) return false;
1005
+ const U = _chunkE2644XCOcjs.CELL_LINES.get(u), D = _chunkE2644XCOcjs.CELL_LINES.get(d);
1006
+ if (!_optionalChain([U, 'optionalAccess', _63 => _63.length]) || !_optionalChain([D, 'optionalAccess', _64 => _64.length])) return false;
925
1007
  const last = U[U.length - 1];
926
1008
  const fs = last.h || 10;
927
1009
  let minL = Infinity, maxR = -Infinity;
@@ -938,7 +1020,7 @@ function continuesAcross(u, d, x1, x2) {
938
1020
  if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
939
1021
  const indented = last.l - minL >= HANGING_MIN * fs;
940
1022
  if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
941
- const newItem = _chunkKDMAYOWHcjs.startsNewItem.call(void 0, u.text, d.text);
1023
+ const newItem = _chunkE2644XCOcjs.startsNewItem.call(void 0, u.text, d.text);
942
1024
  const all = D.length ? U.concat(D) : U;
943
1025
  const leftAligned = (l) => maxR - l.r > SHORT_LINE_GAP * fs && (l.l - minL <= fs || !newItem && all.some((o) => o !== l && Math.abs(o.l - l.l) <= HANGING_TOL && Math.abs(o.r - l.r) >= HANGING_MIN * fs));
944
1026
  const hanging = U.length >= 2 && U.every((l) => maxR - l.r <= FULL_LINE_TOL * fs) && indented && Math.abs(D[0].l - last.l) <= HANGING_TOL;
@@ -955,12 +1037,12 @@ function outlineContinues(u, d) {
955
1037
  return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
956
1038
  }
957
1039
  function lineEnded(c, x1, x2, next) {
958
- const L = _chunkKDMAYOWHcjs.CELL_LINES.get(c);
1040
+ const L = _chunkE2644XCOcjs.CELL_LINES.get(c);
959
1041
  if (!L || L.length !== 1) return false;
960
1042
  const l = L[0], h = l.h || 10;
961
- const d0 = next ? _optionalChain([_chunkKDMAYOWHcjs.CELL_LINES, 'access', _36 => _36.get, 'call', _37 => _37(next), 'optionalAccess', _38 => _38[0]]) : void 0;
1043
+ const d0 = next ? _optionalChain([_chunkE2644XCOcjs.CELL_LINES, 'access', _65 => _65.get, 'call', _66 => _66(next), 'optionalAccess', _67 => _67[0]]) : void 0;
962
1044
  if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
963
- return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _39 => _39.text]), () => ( "")))) * h;
1045
+ return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _68 => _68.text]), () => ( "")))) * h;
964
1046
  }
965
1047
  function firstWordUnits(text) {
966
1048
  const word = _nullishCoalesce(flowText(text).trim().replace(/^([(\[「『<〈])\s+/, "$1").split(/\s+/)[0], () => ( ""));
@@ -969,14 +1051,14 @@ function firstWordUnits(text) {
969
1051
  return units;
970
1052
  }
971
1053
  function appendCell(a, b) {
972
- if (_optionalChain([a, 'access', _40 => _40.blocks, 'optionalAccess', _41 => _41.length]) || _optionalChain([b, 'access', _42 => _42.blocks, 'optionalAccess', _43 => _43.length])) {
973
- const asBlocks = (c) => _optionalChain([c, 'access', _44 => _44.blocks, 'optionalAccess', _45 => _45.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
1054
+ if (_optionalChain([a, 'access', _69 => _69.blocks, 'optionalAccess', _70 => _70.length]) || _optionalChain([b, 'access', _71 => _71.blocks, 'optionalAccess', _72 => _72.length])) {
1055
+ const asBlocks = (c) => _optionalChain([c, 'access', _73 => _73.blocks, 'optionalAccess', _74 => _74.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
974
1056
  a.blocks = [...asBlocks(a), ...asBlocks(b)];
975
1057
  }
976
1058
  if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
977
- _chunkKDMAYOWHcjs.joinCellEdges.call(void 0, a, b);
1059
+ _chunkE2644XCOcjs.joinCellEdges.call(void 0, a, b);
978
1060
  }
979
- var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _46 => _46.blocks, 'optionalAccess', _47 => _47.length]) || _chunkKDMAYOWHcjs.IMAGE_CELLS.has(cell);
1061
+ var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _75 => _75.blocks, 'optionalAccess', _76 => _76.length]) || _chunkE2644XCOcjs.IMAGE_CELLS.has(cell);
980
1062
  var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
981
1063
  var batchim = (ch) => {
982
1064
  const k = ch.charCodeAt(0) - 44032;
@@ -984,13 +1066,13 @@ var batchim = (ch) => {
984
1066
  };
985
1067
  function clauseContinues(u, d) {
986
1068
  const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
987
- if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkKDMAYOWHcjs.startsNewItem.call(void 0, u.text, head)) return false;
1069
+ if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkE2644XCOcjs.startsNewItem.call(void 0, u.text, head)) return false;
988
1070
  const last = tail[tail.length - 1], before = tail[tail.length - 2];
989
1071
  return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
990
1072
  }
991
1073
  function wordOverflows(u, d, x1, x2) {
992
- const U = _chunkKDMAYOWHcjs.CELL_LINES.get(u);
993
- if (!_optionalChain([U, 'optionalAccess', _48 => _48.length]) || _chunkKDMAYOWHcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
1074
+ const U = _chunkE2644XCOcjs.CELL_LINES.get(u);
1075
+ if (!_optionalChain([U, 'optionalAccess', _77 => _77.length]) || _chunkE2644XCOcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
994
1076
  const last = U[U.length - 1], units = firstWordUnits(d.text);
995
1077
  return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
996
1078
  }
@@ -1012,7 +1094,7 @@ function listContinues(u, d, multi = false) {
1012
1094
  const marks = u.text.split("\n").map((l) => itemMark(l.trim()));
1013
1095
  let last = -1, count = 0;
1014
1096
  marks.forEach((m, i) => {
1015
- if (_optionalChain([m, 'optionalAccess', _49 => _49.style]) === head.style) {
1097
+ if (_optionalChain([m, 'optionalAccess', _78 => _78.style]) === head.style) {
1016
1098
  last = i;
1017
1099
  count++;
1018
1100
  }
@@ -1050,6 +1132,8 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
1050
1132
  if (!carriedSplit) {
1051
1133
  const norm = (c) => flowText(c.text).replace(/\s+/g, "");
1052
1134
  if (pairs.some(([u, d]) => hasContent(d.cell) && norm(cell(d)) !== norm(cell(u)) && lineEnded(cell(u), colXs[u.c], colXs[u.c + u.cs], cell(d)))) return false;
1135
+ const oneLine = (c) => _optionalChain([_chunkE2644XCOcjs.CELL_LINES, 'access', _79 => _79.get, 'call', _80 => _80(c), 'optionalAccess', _81 => _81.length]) === 1;
1136
+ if (pairs.some(([u, d]) => nextItemHead(cell(u).text, cell(d).text)) && pairs.some(([u, d]) => hasContent(u.cell) && hasContent(d.cell) && oneLine(cell(u)) && oneLine(cell(d)) && norm(cell(u)) !== norm(cell(d)))) return false;
1053
1137
  const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d));
1054
1138
  if (!(cut.open && !newCell)) {
1055
1139
  if (pairs.some((p) => p[1].rs > 1 && !flows(p))) return false;
@@ -1079,8 +1163,8 @@ function besideOwn(b, p, c) {
1079
1163
  }
1080
1164
  var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
1081
1165
  function pageNumberBetween(b, p, c, pageHeights) {
1082
- if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _50 => _50.text, 'optionalAccess', _51 => _51.trim, 'call', _52 => _52()]), () => ( "")))) return false;
1083
- const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _53 => _53.get, 'call', _54 => _54(b.pageNumber)]) : void 0;
1166
+ if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _82 => _82.text, 'optionalAccess', _83 => _83.trim, 'call', _84 => _84()]), () => ( "")))) return false;
1167
+ const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _85 => _85.get, 'call', _86 => _86(b.pageNumber)]) : void 0;
1084
1168
  if (!h) return false;
1085
1169
  if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
1086
1170
  if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
@@ -1103,14 +1187,14 @@ function insideTable(b, t) {
1103
1187
  return b.bbox.x >= o.x - 1 && b.bbox.x + b.bbox.width <= o.x + o.width + 1 && b.bbox.y >= o.y - 1 && b.bbox.y + b.bbox.height <= o.y + o.height + 1;
1104
1188
  }
1105
1189
  function startsWithUnitRow(table) {
1106
- return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _55 => _55.cells, 'access', _56 => _56[0], 'optionalAccess', _57 => _57[0], 'optionalAccess', _58 => _58.text]), () => ( ""))) && _optionalChain([table, 'access', _59 => _59.cells, 'access', _60 => _60[0], 'optionalAccess', _61 => _61.slice, 'call', _62 => _62(1), 'access', _63 => _63.every, 'call', _64 => _64((c) => !c.text.trim())]);
1190
+ return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _87 => _87.cells, 'access', _88 => _88[0], 'optionalAccess', _89 => _89[0], 'optionalAccess', _90 => _90.text]), () => ( ""))) && _optionalChain([table, 'access', _91 => _91.cells, 'access', _92 => _92[0], 'optionalAccess', _93 => _93.slice, 'call', _94 => _94(1), 'access', _95 => _95.every, 'call', _96 => _96((c) => !c.text.trim())]);
1107
1191
  }
1108
1192
  function sameHeadShape(a, b) {
1109
1193
  if (!a || !b || a.length !== b.length) return false;
1110
1194
  let tall = false;
1111
1195
  for (let c = 0; c < a.length; c++) {
1112
1196
  if (a[c].colSpan !== b[c].colSpan || a[c].rowSpan !== b[c].rowSpan) return false;
1113
- if (a[c].rowSpan >= 2 && a[c].text.trim()) tall = true;
1197
+ if (a[c].rowSpan >= 2 && a[c].text.trim() && b[c].text.trim()) tall = true;
1114
1198
  }
1115
1199
  return tall;
1116
1200
  }
@@ -1123,7 +1207,7 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1123
1207
  const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
1124
1208
  while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
1125
1209
  const curr = blocks[j];
1126
- const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _65 => _65.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
1210
+ const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _97 => _97.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
1127
1211
  if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
1128
1212
  if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
1129
1213
  if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
@@ -1132,38 +1216,39 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1132
1216
  placeJoined(blocks, i, j, joined);
1133
1217
  continue;
1134
1218
  }
1135
- if (_chunkKDMAYOWHcjs.EMPTY_PARTS.has(curr.table)) {
1219
+ if (_chunkE2644XCOcjs.EMPTY_PARTS.has(curr.table)) {
1136
1220
  blocks.splice(j, 1);
1137
1221
  i++;
1138
1222
  continue;
1139
1223
  }
1140
1224
  if (joined === null) continue;
1141
- if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkKDMAYOWHcjs.EMPTY_PARTS.has(prev.table)) continue;
1225
+ if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkE2644XCOcjs.EMPTY_PARTS.has(prev.table)) continue;
1142
1226
  const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
1143
1227
  const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
1144
1228
  const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
1145
1229
  if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
1146
- const px = _chunkKDMAYOWHcjs.TABLE_COLXS.get(prev.table), cx = _chunkKDMAYOWHcjs.TABLE_COLXS.get(curr.table);
1147
- if (px && cx && !shiftedSame(px, cx, !_chunkKDMAYOWHcjs.CLIP_TABLES.has(prev.table) && !_chunkKDMAYOWHcjs.CLIP_TABLES.has(curr.table))) continue;
1230
+ const px = _chunkE2644XCOcjs.TABLE_COLXS.get(prev.table), cx = _chunkE2644XCOcjs.TABLE_COLXS.get(curr.table);
1231
+ if (px && cx && !shiftedSame(px, cx, !_chunkE2644XCOcjs.CLIP_TABLES.has(prev.table) && !_chunkE2644XCOcjs.CLIP_TABLES.has(curr.table))) continue;
1148
1232
  if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
1149
1233
  let currCells = curr.table.cells;
1150
- if (currCells.length > 1 && prev.table.cells.length > 0 && rowTextsEqual(prev.table.cells[0], currCells[0])) {
1151
- currCells = currCells.slice(1);
1152
- }
1234
+ const headRows = repeatedHeaderRows(prev.table, curr.table);
1235
+ if (headRows < 0) continue;
1236
+ if (headRows) currCells = currCells.slice(headRows);
1237
+ if (currCells.length) continueRowSpans(prev.table.cells, currCells);
1153
1238
  if (currCells.length === 0) {
1154
1239
  blocks.splice(j, 1);
1155
1240
  continue;
1156
1241
  }
1157
- if (px && cx && !_chunkKDMAYOWHcjs.CLIP_TABLES.has(prev.table) && !_chunkKDMAYOWHcjs.CLIP_TABLES.has(curr.table) && currCells.length < curr.table.cells.length && curr.table.cells[0].filter((c) => c.text.trim()).length >= 2 && prev.table.cells.at(-1).concat(currCells[0]).every((c) => c.rowSpan === 1 && c.colSpan === 1 && _chunkKDMAYOWHcjs.CELL_LINES.has(c))) {
1242
+ if (px && cx && !_chunkE2644XCOcjs.CLIP_TABLES.has(prev.table) && !_chunkE2644XCOcjs.CLIP_TABLES.has(curr.table) && currCells.length < curr.table.cells.length && curr.table.cells[0].filter((c) => c.text.trim()).length >= 2 && prev.table.cells.at(-1).concat(currCells[0]).every((c) => c.rowSpan === 1 && c.colSpan === 1 && _chunkE2644XCOcjs.CELL_LINES.has(c))) {
1158
1243
  const dx = px[0] - cx[0];
1159
1244
  const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
1160
- if (_optionalChain([part, 'optionalAccess', _66 => _66.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
1245
+ if (_optionalChain([part, 'optionalAccess', _98 => _98.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
1161
1246
  const last = prev.table.rows - 1;
1162
1247
  for (let c = 0; c < part.table.cols; c++) {
1163
- const U = _chunkKDMAYOWHcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkKDMAYOWHcjs.CELL_LINES.get(currCells[0][c]);
1164
- _chunkKDMAYOWHcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
1248
+ const U = _chunkE2644XCOcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkE2644XCOcjs.CELL_LINES.get(currCells[0][c]);
1249
+ _chunkE2644XCOcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
1165
1250
  }
1166
- _chunkKDMAYOWHcjs.TABLE_COLXS.set(part.table, part.colXs);
1251
+ _chunkE2644XCOcjs.TABLE_COLXS.set(part.table, part.colXs);
1167
1252
  placeJoined(blocks, i, j, part.table);
1168
1253
  continue;
1169
1254
  }
@@ -1176,20 +1261,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1176
1261
  caption: prev.table.caption,
1177
1262
  ...prev.table.renderAsTable ? { renderAsTable: true } : {}
1178
1263
  };
1179
- if (_nullishCoalesce(px, () => ( cx))) _chunkKDMAYOWHcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
1180
- if (_chunkKDMAYOWHcjs.CLIP_TABLES.has(prev.table) || _chunkKDMAYOWHcjs.CLIP_TABLES.has(curr.table)) _chunkKDMAYOWHcjs.CLIP_TABLES.add(merged);
1264
+ if (_nullishCoalesce(px, () => ( cx))) _chunkE2644XCOcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
1265
+ if (_chunkE2644XCOcjs.CLIP_TABLES.has(prev.table) || _chunkE2644XCOcjs.CLIP_TABLES.has(curr.table)) _chunkE2644XCOcjs.CLIP_TABLES.add(merged);
1181
1266
  placeJoined(blocks, i, j, merged);
1182
1267
  }
1183
1268
  for (let i = blocks.length - 1; i >= 0; i--) {
1184
1269
  const t = blocks[i].table;
1185
- if (blocks[i].type === "table" && t && _chunkKDMAYOWHcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
1270
+ if (blocks[i].type === "table" && t && _chunkE2644XCOcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
1186
1271
  }
1187
1272
  }
1188
1273
  function mergeColumnFlow(blocks, pageHeights, lex) {
1189
1274
  if (!pageHeights) return;
1190
1275
  for (let i = 0; i < blocks.length; i++) {
1191
1276
  const L = blocks[i];
1192
- if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkKDMAYOWHcjs.CLIP_TABLES.has(L.table) || _chunkKDMAYOWHcjs.EMPTY_PARTS.has(L.table)) continue;
1277
+ if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkE2644XCOcjs.CLIP_TABLES.has(L.table) || _chunkE2644XCOcjs.EMPTY_PARTS.has(L.table)) continue;
1193
1278
  const ph = pageHeights.get(L.pageNumber);
1194
1279
  if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
1195
1280
  let s0 = i, s1 = i;
@@ -1218,12 +1303,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
1218
1303
  }
1219
1304
  function joinClipParts(prev, curr, pageHeights, lex) {
1220
1305
  const pt = prev.table, ct = curr.table;
1221
- if (!_chunkKDMAYOWHcjs.CLIP_TABLES.has(pt) || !_chunkKDMAYOWHcjs.CLIP_TABLES.has(ct)) return null;
1222
- const px = _chunkKDMAYOWHcjs.TABLE_COLXS.get(pt), cx = _chunkKDMAYOWHcjs.TABLE_COLXS.get(ct);
1306
+ if (!_chunkE2644XCOcjs.CLIP_TABLES.has(pt) || !_chunkE2644XCOcjs.CLIP_TABLES.has(ct)) return null;
1307
+ const px = _chunkE2644XCOcjs.TABLE_COLXS.get(pt), cx = _chunkE2644XCOcjs.TABLE_COLXS.get(ct);
1223
1308
  if (!px || !cx) return null;
1224
1309
  let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
1225
1310
  if (!shiftedSame(px, cx, false)) {
1226
- if (!_optionalChain([pageHeights, 'optionalAccess', _67 => _67.get, 'call', _68 => _68(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _69 => _69.get, 'call', _70 => _70(curr.pageNumber)])) return null;
1311
+ if (!_optionalChain([pageHeights, 'optionalAccess', _99 => _99.get, 'call', _100 => _100(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _101 => _101.get, 'call', _102 => _102(curr.pageNumber)])) return null;
1227
1312
  dx = px[px.length - 1] - cx[cx.length - 1];
1228
1313
  within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
1229
1314
  if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
@@ -1235,19 +1320,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
1235
1320
  const inner = b.slice(1, -1).map((x) => x + dx);
1236
1321
  return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
1237
1322
  };
1238
- foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkKDMAYOWHcjs.PART_COLXS.get(ct), () => ( cx))) && (headingRow(_nullishCoalesce(ct.cells[0], () => ( []))) || px.length > FOREIGN_FIRST_ROW_CELLS && anchorsOf(ct).filter((a) => a.r === 0).length >= FOREIGN_FIRST_ROW_CELLS);
1323
+ foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkE2644XCOcjs.PART_COLXS.get(ct), () => ( cx))) && (headingRow(_nullishCoalesce(ct.cells[0], () => ( []))) || px.length > FOREIGN_FIRST_ROW_CELLS && anchorsOf(ct).filter((a) => a.r === 0).length >= FOREIGN_FIRST_ROW_CELLS);
1239
1324
  }
1240
- const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _71 => _71.bbox, 'optionalAccess', _72 => _72.y]), lex);
1325
+ const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _103 => _103.bbox, 'optionalAccess', _104 => _104.y]), lex);
1241
1326
  if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
1242
- _chunkKDMAYOWHcjs.TABLE_COLXS.set(res.table, res.colXs);
1243
- const ys = _chunkKDMAYOWHcjs.TABLE_ROWYS.get(pt);
1244
- if (ys) _chunkKDMAYOWHcjs.TABLE_ROWYS.set(res.table, ys);
1245
- _chunkKDMAYOWHcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkKDMAYOWHcjs.PART_COLXS.get(pt), () => ( px)));
1246
- _chunkKDMAYOWHcjs.CLIP_TABLES.add(res.table);
1327
+ _chunkE2644XCOcjs.TABLE_COLXS.set(res.table, res.colXs);
1328
+ const ys = _chunkE2644XCOcjs.TABLE_ROWYS.get(pt);
1329
+ if (ys) _chunkE2644XCOcjs.TABLE_ROWYS.set(res.table, ys);
1330
+ _chunkE2644XCOcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkE2644XCOcjs.PART_COLXS.get(pt), () => ( px)));
1331
+ _chunkE2644XCOcjs.CLIP_TABLES.add(res.table);
1247
1332
  return res.table;
1248
1333
  }
1249
1334
  function prevLacksLeftCols(prev, px, xs, pageHeights) {
1250
- const ph = _optionalChain([pageHeights, 'optionalAccess', _73 => _73.get, 'call', _74 => _74(prev.pageNumber)]);
1335
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _105 => _105.get, 'call', _106 => _106(prev.pageNumber)]);
1251
1336
  if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
1252
1337
  return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
1253
1338
  }
@@ -1258,21 +1343,21 @@ function headingRow(row) {
1258
1343
  }
1259
1344
  var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
1260
1345
  function looksContinued(prev, curr, pageHeights) {
1261
- const ph = _optionalChain([pageHeights, 'optionalAccess', _75 => _75.get, 'call', _76 => _76(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _77 => _77.get, 'call', _78 => _78(curr.pageNumber)]);
1346
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _107 => _107.get, 'call', _108 => _108(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _109 => _109.get, 'call', _110 => _110(curr.pageNumber)]);
1262
1347
  if (ph && ch && (prev.bbox.y > ph * PAGE_EDGE_BAND && !pushedLead(prev, curr) || curr.bbox.y + curr.bbox.height < ch * (1 - PAGE_EDGE_BAND))) return false;
1263
1348
  const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
1264
- const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _79 => _79.find, 'call', _80 => _80((c) => c.text.trim()), 'optionalAccess', _81 => _81.text]), () => ( ""));
1349
+ const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _111 => _111.find, 'call', _112 => _112((c) => c.text.trim()), 'optionalAccess', _113 => _113.text]), () => ( ""));
1265
1350
  if (!ANNEX_HEAD_RE.test(firstText)) return true;
1266
1351
  const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
1267
1352
  return filled.length >= 2 && filled.every((t) => t === filled[0]);
1268
1353
  }
1269
1354
  function pushedLead(prev, curr) {
1270
- if (!_chunkKDMAYOWHcjs.CLIP_TABLES.has(prev.table) || !_chunkKDMAYOWHcjs.CLIP_TABLES.has(curr.table)) return false;
1355
+ if (!_chunkE2644XCOcjs.CLIP_TABLES.has(prev.table) || !_chunkE2644XCOcjs.CLIP_TABLES.has(curr.table)) return false;
1271
1356
  const lead = leadRows(curr.table);
1272
1357
  return lead.image && lead.height > prev.bbox.y;
1273
1358
  }
1274
1359
  function leadRows(t) {
1275
- const ys = _chunkKDMAYOWHcjs.TABLE_ROWYS.get(t);
1360
+ const ys = _chunkE2644XCOcjs.TABLE_ROWYS.get(t);
1276
1361
  if (!ys || ys.length < 2) return { height: 0, image: false };
1277
1362
  const anchors = anchorsOf(t);
1278
1363
  let end = 1, image = false;
@@ -1280,17 +1365,17 @@ function leadRows(t) {
1280
1365
  for (const a of anchors) {
1281
1366
  if (a.r !== r) continue;
1282
1367
  end = Math.max(end, r + a.rs);
1283
- if (_chunkKDMAYOWHcjs.IMAGE_CELLS.has(a.cell)) image = true;
1368
+ if (_chunkE2644XCOcjs.IMAGE_CELLS.has(a.cell)) image = true;
1284
1369
  }
1285
1370
  }
1286
1371
  return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
1287
1372
  }
1288
1373
  function tailOf(b) {
1289
- const t = b.table && _chunkKDMAYOWHcjs.TABLE_TAIL.get(b.table);
1374
+ const t = b.table && _chunkE2644XCOcjs.TABLE_TAIL.get(b.table);
1290
1375
  return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
1291
1376
  }
1292
1377
  function firstRowSig(t) {
1293
- const x = _chunkKDMAYOWHcjs.TABLE_COLXS.get(t);
1378
+ const x = _chunkE2644XCOcjs.TABLE_COLXS.get(t);
1294
1379
  if (!x || x.length !== t.cols + 1) return null;
1295
1380
  return anchorsOf(t).filter((a) => a.r === 0).map((a) => ({ x1: x[a.c], x2: x[a.c + a.cs], t: flowText(a.cell.text).replace(/\s+/g, "") }));
1296
1381
  }
@@ -1315,9 +1400,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
1315
1400
  }
1316
1401
  function restartsTitledForm(head, curr) {
1317
1402
  if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
1318
- const full = (t) => _optionalChain([t, 'access', _82 => _82.cells, 'access', _83 => _83[0], 'access', _84 => _84[0], 'optionalAccess', _85 => _85.colSpan]) === t.cols;
1403
+ const full = (t) => _optionalChain([t, 'access', _114 => _114.cells, 'access', _115 => _115[0], 'access', _116 => _116[0], 'optionalAccess', _117 => _117.colSpan]) === t.cols;
1319
1404
  if (!full(head) || !full(curr)) return false;
1320
- const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _86 => _86.text]), () => ( ""))).replace(/\s+/g, "");
1405
+ const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _118 => _118.text]), () => ( ""))).replace(/\s+/g, "");
1321
1406
  const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
1322
1407
  if (!ht || !ct || ht === ct) return false;
1323
1408
  const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
@@ -1343,7 +1428,7 @@ function chainHead(blocks, i, pageHeights) {
1343
1428
  if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
1344
1429
  if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
1345
1430
  if (!looksContinued(pb, cur, pageHeights)) break;
1346
- const px = _chunkKDMAYOWHcjs.TABLE_COLXS.get(pb.table), cx = _chunkKDMAYOWHcjs.TABLE_COLXS.get(cur.table);
1431
+ const px = _chunkE2644XCOcjs.TABLE_COLXS.get(pb.table), cx = _chunkE2644XCOcjs.TABLE_COLXS.get(cur.table);
1347
1432
  if (!px || !cx) break;
1348
1433
  const dx = px[px.length - 1] - cx[cx.length - 1];
1349
1434
  if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
@@ -1351,6 +1436,45 @@ function chainHead(blocks, i, pageHeights) {
1351
1436
  }
1352
1437
  return k;
1353
1438
  }
1439
+ var ROW_CONTINUATIONS = /* @__PURE__ */ new WeakMap();
1440
+ function continueRowSpans(prevCells, currCells) {
1441
+ const first = currCells[0];
1442
+ const last = prevCells.length;
1443
+ for (let c = 0; c < first.length; c++) {
1444
+ const cell = first[c];
1445
+ if (hasContent(cell) || (cell.rowSpan || 1) < 2) continue;
1446
+ let anchor;
1447
+ for (let r = last - 1; r >= 0 && !anchor; r--) {
1448
+ const a = _optionalChain([prevCells, 'access', _119 => _119[r], 'optionalAccess', _120 => _120[c]]);
1449
+ if (a && r + (a.rowSpan || 1) === last && (a.colSpan || 1) === (cell.colSpan || 1) && (hasContent(a) || a.rowSpan >= 2)) anchor = a;
1450
+ }
1451
+ if (!anchor) continue;
1452
+ if (!hasContent(anchor)) {
1453
+ ROW_CONTINUATIONS.set(anchor, cell);
1454
+ continue;
1455
+ }
1456
+ for (let part = cell; part; ) {
1457
+ const next = ROW_CONTINUATIONS.get(part);
1458
+ anchor.rowSpan = (anchor.rowSpan || 1) + part.rowSpan;
1459
+ part.rowSpan = 1;
1460
+ part.colSpan = 1;
1461
+ ROW_CONTINUATIONS.delete(part);
1462
+ part = next;
1463
+ }
1464
+ }
1465
+ }
1466
+ function repeatedHeaderRows(prev, curr) {
1467
+ if (!rowTextsEqual(prev.cells[0], curr.cells[0])) return 0;
1468
+ const pa = anchorsOf(prev), ca = anchorsOf(curr);
1469
+ let depth = 1;
1470
+ for (let r = 0; r < depth && r < prev.rows; r++) {
1471
+ for (const a of pa) if (a.r === r) depth = Math.max(depth, r + a.rs);
1472
+ }
1473
+ if (depth >= curr.rows || depth > prev.rows) return -1;
1474
+ const p = pa.filter((a) => a.r < depth), d = ca.filter((a) => a.r < depth);
1475
+ const norm = (text) => flowText(text).replace(/\s+/g, "");
1476
+ return p.length === d.length && p.every((a, i) => a.r === d[i].r && a.c === d[i].c && a.rs === d[i].rs && a.cs === d[i].cs && norm(a.cell.text) === norm(d[i].cell.text)) ? depth : -1;
1477
+ }
1354
1478
  function rowTextsEqual(a, b) {
1355
1479
  if (a.length !== b.length) return false;
1356
1480
  const norm = (t) => flowText(t).replace(/\s+/g, "");
@@ -1375,12 +1499,12 @@ var RESTART_LOOKBACK_PAGES = 5;
1375
1499
  var COL_MATCH_TOL = 0.5;
1376
1500
  var CONTINUED_TABLE_PAGE_BAND = 0.16;
1377
1501
  function lastRowCell(t, x1, x2) {
1378
- const xs = _chunkKDMAYOWHcjs.TABLE_COLXS.get(t);
1502
+ const xs = _chunkE2644XCOcjs.TABLE_COLXS.get(t);
1379
1503
  const covered = /* @__PURE__ */ new Set();
1380
1504
  for (let r = 0; r < t.rows; r++) {
1381
1505
  for (let c = 0; c < t.cols; c++) {
1382
1506
  if (covered.has(r * 1e5 + c)) continue;
1383
- const cell = _optionalChain([t, 'access', _87 => _87.cells, 'access', _88 => _88[r], 'optionalAccess', _89 => _89[c]]);
1507
+ const cell = _optionalChain([t, 'access', _121 => _121.cells, 'access', _122 => _122[r], 'optionalAccess', _123 => _123[c]]);
1384
1508
  if (!cell) continue;
1385
1509
  for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
1386
1510
  if (r + cell.rowSpan !== t.rows) continue;
@@ -1393,23 +1517,23 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
1393
1517
  function mergeContinuedCells(blocks, pageHeights) {
1394
1518
  for (let j = blocks.length - 1; j > 0; j--) {
1395
1519
  const part = blocks[j];
1396
- const from = part.table ? _chunkKDMAYOWHcjs.CONT_PARTS.get(part.table) : void 0;
1520
+ const from = part.table ? _chunkE2644XCOcjs.CONT_PARTS.get(part.table) : void 0;
1397
1521
  if (!from || !part.table) continue;
1398
1522
  let i = j - 1;
1399
1523
  while (i >= 0 && blocks[i].type !== "table") i--;
1400
1524
  const prev = blocks[i];
1401
1525
  if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
1402
1526
  const cell = lastRowCell(prev.table, from.x1, from.x2);
1403
- const add = _optionalChain([part, 'access', _90 => _90.table, 'access', _91 => _91.cells, 'access', _92 => _92[0], 'optionalAccess', _93 => _93[0]]);
1527
+ const add = _optionalChain([part, 'access', _124 => _124.table, 'access', _125 => _125.cells, 'access', _126 => _126[0], 'optionalAccess', _127 => _127[0]]);
1404
1528
  if (!cell || !add) continue;
1405
1529
  const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
1406
1530
  if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
1407
1531
  cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
1408
- _chunkKDMAYOWHcjs.joinCellEdges.call(void 0, cell, add);
1409
- const lines = _chunkKDMAYOWHcjs.CELL_LINES.get(add);
1410
- if (_optionalChain([lines, 'optionalAccess', _94 => _94.length])) _chunkKDMAYOWHcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkKDMAYOWHcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
1411
- if (part.pageNumber && part.bbox) _chunkKDMAYOWHcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkKDMAYOWHcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
1412
- if (cell.text.trim() || _optionalChain([cell, 'access', _95 => _95.blocks, 'optionalAccess', _96 => _96.length])) _chunkKDMAYOWHcjs.EMPTY_PARTS.delete(prev.table);
1532
+ _chunkE2644XCOcjs.joinCellEdges.call(void 0, cell, add);
1533
+ const lines = _chunkE2644XCOcjs.CELL_LINES.get(add);
1534
+ if (_optionalChain([lines, 'optionalAccess', _128 => _128.length])) _chunkE2644XCOcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkE2644XCOcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
1535
+ if (part.pageNumber && part.bbox) _chunkE2644XCOcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkE2644XCOcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
1536
+ if (cell.text.trim() || _optionalChain([cell, 'access', _129 => _129.blocks, 'optionalAccess', _130 => _130.length])) _chunkE2644XCOcjs.EMPTY_PARTS.delete(prev.table);
1413
1537
  blocks.splice(j, 1);
1414
1538
  if (cell.blocks && at > 0) {
1415
1539
  const nextAt = cell.blocks[at];
@@ -1421,30 +1545,58 @@ function mergeContinuedCells(blocks, pageHeights) {
1421
1545
  }
1422
1546
  function unwrapContinuedTable(blocks, at, pageHeights) {
1423
1547
  const prev = blocks[at - 1], frame = blocks[at];
1424
- if (!_optionalChain([prev, 'optionalAccess', _97 => _97.table]) || !_optionalChain([frame, 'optionalAccess', _98 => _98.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkKDMAYOWHcjs.CLIP_TABLES.has(frame.table)) return;
1425
- const inner = _optionalChain([frame, 'access', _99 => _99.table, 'access', _100 => _100.cells, 'access', _101 => _101[0], 'optionalAccess', _102 => _102[0], 'optionalAccess', _103 => _103.blocks]);
1426
- const next = _optionalChain([inner, 'optionalAccess', _104 => _104[0]]);
1427
- if (!inner || !_optionalChain([next, 'optionalAccess', _105 => _105.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkKDMAYOWHcjs.CLIP_TABLES.has(prev.table) || !_chunkKDMAYOWHcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
1428
- const px = _chunkKDMAYOWHcjs.TABLE_COLXS.get(prev.table), nx = _chunkKDMAYOWHcjs.TABLE_COLXS.get(next.table);
1548
+ if (!_optionalChain([prev, 'optionalAccess', _131 => _131.table]) || !_optionalChain([frame, 'optionalAccess', _132 => _132.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkE2644XCOcjs.CLIP_TABLES.has(frame.table)) return;
1549
+ const inner = _optionalChain([frame, 'access', _133 => _133.table, 'access', _134 => _134.cells, 'access', _135 => _135[0], 'optionalAccess', _136 => _136[0], 'optionalAccess', _137 => _137.blocks]);
1550
+ const next = _optionalChain([inner, 'optionalAccess', _138 => _138[0]]);
1551
+ if (!inner || !_optionalChain([next, 'optionalAccess', _139 => _139.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkE2644XCOcjs.CLIP_TABLES.has(prev.table) || !_chunkE2644XCOcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
1552
+ const px = _chunkE2644XCOcjs.TABLE_COLXS.get(prev.table), nx = _chunkE2644XCOcjs.TABLE_COLXS.get(next.table);
1429
1553
  if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
1430
- const ph = _optionalChain([pageHeights, 'optionalAccess', _106 => _106.get, 'call', _107 => _107(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _108 => _108.get, 'call', _109 => _109(next.pageNumber)]);
1554
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _140 => _140.get, 'call', _141 => _141(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _142 => _142.get, 'call', _143 => _143(next.pageNumber)]);
1431
1555
  if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
1432
1556
  blocks.splice(at, 1, ...inner);
1433
1557
  }
1434
1558
  function fillNestedContinuation(blocks, at) {
1435
1559
  const prev = blocks[at - 1], next = blocks[at];
1436
- const t = _optionalChain([prev, 'optionalAccess', _110 => _110.table]), u = _optionalChain([next, 'optionalAccess', _111 => _111.table]);
1437
- if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkKDMAYOWHcjs.CLIP_TABLES.has(t) || !_chunkKDMAYOWHcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
1438
- const xs = _chunkKDMAYOWHcjs.TABLE_COLXS.get(u);
1560
+ const t = _optionalChain([prev, 'optionalAccess', _144 => _144.table]), u = _optionalChain([next, 'optionalAccess', _145 => _145.table]);
1561
+ if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkE2644XCOcjs.CLIP_TABLES.has(t) || !_chunkE2644XCOcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
1562
+ const xs = _chunkE2644XCOcjs.TABLE_COLXS.get(u);
1439
1563
  const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
1440
- const add = _optionalChain([u, 'access', _112 => _112.cells, 'access', _113 => _113[0], 'optionalAccess', _114 => _114[0]]);
1441
- if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _115 => _115.blocks, 'optionalAccess', _116 => _116.length])) return;
1564
+ const add = _optionalChain([u, 'access', _146 => _146.cells, 'access', _147 => _147[0], 'optionalAccess', _148 => _148[0]]);
1565
+ if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _149 => _149.blocks, 'optionalAccess', _150 => _150.length])) return;
1442
1566
  cell.text = add.text;
1443
1567
  if (add.blocks) cell.blocks = add.blocks;
1444
- _chunkKDMAYOWHcjs.joinCellEdges.call(void 0, cell, add);
1568
+ _chunkE2644XCOcjs.joinCellEdges.call(void 0, cell, add);
1445
1569
  blocks.splice(at, 1);
1446
1570
  }
1447
1571
 
1572
+ // src/pdf/selection-context.ts
1573
+ function selectionContextPages(selected, pageCount) {
1574
+ const out = /* @__PURE__ */ new Set();
1575
+ for (const page of selected) {
1576
+ for (let distance = 1; distance <= 4; distance++) {
1577
+ for (const neighbor of [page - distance, page + distance]) {
1578
+ if (neighbor < 1 || neighbor > pageCount || selected.has(neighbor)) continue;
1579
+ out.add(neighbor);
1580
+ }
1581
+ }
1582
+ }
1583
+ return [...out].sort((a, b) => a - b);
1584
+ }
1585
+ function marginContextBlocks(raw, page, view) {
1586
+ const [x1, y1, x2, y2] = view;
1587
+ const width = x2 - x1, height = y2 - y1;
1588
+ const items = _chunkE2644XCOcjs.filterHiddenText.call(void 0, _chunkE2644XCOcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
1589
+ for (const item of items) {
1590
+ item.x -= x1;
1591
+ item.y -= y1;
1592
+ }
1593
+ return _chunkE2644XCOcjs.groupByY.call(void 0, items).flatMap((line) => {
1594
+ const bbox = _chunkE2644XCOcjs.computeBBox.call(void 0, line, page);
1595
+ if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
1596
+ return [{ type: "paragraph", text: _chunkE2644XCOcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkE2644XCOcjs.dominantStyle.call(void 0, line) }];
1597
+ });
1598
+ }
1599
+
1448
1600
  // src/pdf/symbol-fonts.ts
1449
1601
  var WINANSI_REVERSE = {
1450
1602
  8364: 128,
@@ -1477,7 +1629,7 @@ var WINANSI_REVERSE = {
1477
1629
  };
1478
1630
  function symbolFontTable(fontName) {
1479
1631
  if (!fontName) return void 0;
1480
- if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkQGFZU3JEcjs.WINGDINGS;
1632
+ if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunk3WLZOJIEcjs.WINGDINGS;
1481
1633
  return void 0;
1482
1634
  }
1483
1635
  function remapSymbolText(text, table) {
@@ -1605,7 +1757,7 @@ function layout(toks) {
1605
1757
  const bar = rest.find((t) => t.bar && t.x >= rt.x && t.x <= rt.x + rt.w + 2 && Math.abs(t.y - rt.y) <= size * 1.5);
1606
1758
  if (!bar) continue;
1607
1759
  const inner = rest.filter((t) => !t.bar && t !== rt && t.x + t.w / 2 > bar.x && t.x + t.w / 2 < bar.x + bar.w && bar.y - t.y > 0 && bar.y - t.y <= size * 1.4);
1608
- const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _117 => _117[0], 'optionalAccess', _118 => _118.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
1760
+ const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _151 => _151[0], 'optionalAccess', _152 => _152.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
1609
1761
  rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
1610
1762
  }
1611
1763
  const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
@@ -1707,7 +1859,7 @@ function wrapEquationRuns(items, faceName) {
1707
1859
  for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
1708
1860
  const top = [...ys].sort((p, q) => q[1] - p[1]);
1709
1861
  const bar = cur.find(isBarItem);
1710
- const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _119 => _119[0], 'optionalAccess', _120 => _120[0]]), () => ( cur[0].y));
1862
+ const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _153 => _153[0], 'optionalAccess', _154 => _154[0]]), () => ( cur[0].y));
1711
1863
  const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
1712
1864
  const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
1713
1865
  added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
@@ -1752,6 +1904,9 @@ var NAMED = {
1752
1904
  quotedblright: "\u201D",
1753
1905
  quotesingle: "'",
1754
1906
  quotedbl: '"',
1907
+ bullet: "\u2022",
1908
+ openbullet: "\u25E6",
1909
+ whitebullet: "\u25E6",
1755
1910
  question: "?",
1756
1911
  exclam: "!",
1757
1912
  percent: "%",
@@ -1768,7 +1923,9 @@ function glyphNameText(name) {
1768
1923
  let out = "";
1769
1924
  for (const part of base.split("_")) {
1770
1925
  const uni = _nullishCoalesce(/^uni([0-9A-F]{4})$/.exec(part), () => ( /^u([0-9A-F]{4,6})$/.exec(part)));
1771
- const ch = /^[A-Za-z]$/.test(part) ? part : _nullishCoalesce(NAMED[part], () => ( (uni ? String.fromCodePoint(parseInt(uni[1], 16)) : void 0)));
1926
+ const code = uni ? parseInt(uni[1], 16) : void 0;
1927
+ if (code !== void 0 && (code > 1114111 || code >= 55296 && code <= 57343)) return void 0;
1928
+ const ch = /^[A-Za-z]$/.test(part) ? part : _nullishCoalesce(NAMED[part], () => ( (code !== void 0 ? String.fromCodePoint(code) : void 0)));
1772
1929
  if (ch === void 0) return void 0;
1773
1930
  out += ch;
1774
1931
  }
@@ -2053,7 +2210,7 @@ function joinVerticalColumns(items) {
2053
2210
  const groups = [];
2054
2211
  for (const col of columns) {
2055
2212
  const g2 = groups[groups.length - 1];
2056
- const last = _optionalChain([g2, 'optionalAccess', _121 => _121[g2.length - 1]]);
2213
+ const last = _optionalChain([g2, 'optionalAccess', _155 => _155[g2.length - 1]]);
2057
2214
  const fs = col.items[0].fontSize;
2058
2215
  if (last && last.x - col.x >= fs * 1.2 && last.x - col.x <= fs * 4 && Math.abs(last.items[0].y - col.items[0].y) <= fs * 1.2) g2.push(col);
2059
2216
  else groups.push([col]);
@@ -2239,7 +2396,7 @@ function relocateEndnotes(blocks) {
2239
2396
  }
2240
2397
  const shapes = /* @__PURE__ */ new Map();
2241
2398
  for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
2242
- const main = _optionalChain([[...shapes], 'access', _122 => _122.sort, 'call', _123 => _123((a, b) => b[1] - a[1]), 'access', _124 => _124[0], 'optionalAccess', _125 => _125[0]]);
2399
+ const main = _optionalChain([[...shapes], 'access', _156 => _156.sort, 'call', _157 => _157((a, b) => b[1] - a[1]), 'access', _158 => _158[0], 'optionalAccess', _159 => _159[0]]);
2243
2400
  if (!main || !/#/.test(main)) return blocks;
2244
2401
  const lastRun = (hs) => {
2245
2402
  let run2 = [];
@@ -2377,7 +2534,7 @@ function inlineFootnotes(blocks, pages) {
2377
2534
  open = true;
2378
2535
  continue;
2379
2536
  }
2380
- const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _126 => _126.style, 'optionalAccess', _127 => _127.fontSize]), () => ( _optionalChain([b, 'access', _128 => _128.bbox, 'optionalAccess', _129 => _129.height]))), () => ( 10))) * 1.5;
2537
+ const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _160 => _160.style, 'optionalAccess', _161 => _161.fontSize]), () => ( _optionalChain([b, 'access', _162 => _162.bbox, 'optionalAccess', _163 => _163.height]))), () => ( 10))) * 1.5;
2381
2538
  if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
2382
2539
  notes[notes.length - 1].text += " " + b.text.trim();
2383
2540
  notes[notes.length - 1].blocks.push(b);
@@ -2400,7 +2557,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
2400
2557
  var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
2401
2558
  var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
2402
2559
  function isRunningHead(block, page, pageHeight) {
2403
- const box = block.bbox, text = _optionalChain([block, 'access', _130 => _130.text, 'optionalAccess', _131 => _131.trim, 'call', _132 => _132()]);
2560
+ const box = block.bbox, text = _optionalChain([block, 'access', _164 => _164.text, 'optionalAccess', _165 => _165.trim, 'call', _166 => _166()]);
2404
2561
  if (!box || !text || !pageHeight) return false;
2405
2562
  const top = box.y + box.height >= pageHeight * 0.9;
2406
2563
  const bottom = box.y <= pageHeight * 0.1;
@@ -2408,7 +2565,7 @@ function isRunningHead(block, page, pageHeight) {
2408
2565
  const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
2409
2566
  if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
2410
2567
  if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
2411
- if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _133 => _133.style, 'optionalAccess', _134 => _134.fontSize]), () => ( 0))) * 1.6) return true;
2568
+ if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _167 => _167.style, 'optionalAccess', _168 => _168.fontSize]), () => ( 0))) * 1.6) return true;
2412
2569
  if (!text.includes(" ")) return false;
2413
2570
  const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
2414
2571
  if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
@@ -2417,7 +2574,7 @@ function isRunningHead(block, page, pageHeight) {
2417
2574
  return right > left && box.width >= (right - left) * 0.6;
2418
2575
  }
2419
2576
  function unbalancedClose(text) {
2420
- return (_nullishCoalesce(_optionalChain([text, 'access', _135 => _135.match, 'call', _136 => _136(/\)/g), 'optionalAccess', _137 => _137.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _138 => _138.match, 'call', _139 => _139(/\(/g), 'optionalAccess', _140 => _140.length]), () => ( 0)));
2577
+ return (_nullishCoalesce(_optionalChain([text, 'access', _169 => _169.match, 'call', _170 => _170(/\)/g), 'optionalAccess', _171 => _171.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _172 => _172.match, 'call', _173 => _173(/\(/g), 'optionalAccess', _174 => _174.length]), () => ( 0)));
2421
2578
  }
2422
2579
  function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2423
2580
  const byPage = /* @__PURE__ */ new Map();
@@ -2433,7 +2590,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2433
2590
  const sizes = /* @__PURE__ */ new Map();
2434
2591
  let proseChars = 0;
2435
2592
  for (const b of page) {
2436
- if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _141 => _141.style, 'optionalAccess', _142 => _142.fontName]) || !b.style.fontSize) continue;
2593
+ if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _175 => _175.style, 'optionalAccess', _176 => _176.fontName]) || !b.style.fontSize) continue;
2437
2594
  const key2 = `${b.style.fontName}:${b.style.fontSize}`;
2438
2595
  chars.set(key2, (_nullishCoalesce(chars.get(key2), () => ( 0))) + b.text.length);
2439
2596
  if (b.type === "paragraph" && b.style.fontName === "ocr") {
@@ -2454,54 +2611,83 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2454
2611
  }
2455
2612
  }
2456
2613
  }
2614
+ const citedProse = /* @__PURE__ */ new Set();
2615
+ const numberedProse = /* @__PURE__ */ new Set();
2616
+ for (const page of byPage.values()) {
2617
+ const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access', _177 => _177.text, 'optionalAccess', _178 => _178.trim, 'call', _179 => _179()]), () => ( ""))) && b.bbox && _optionalChain([b, 'access', _180 => _180.style, 'optionalAccess', _181 => _181.fontName]) && b.style.fontSize && !/Bold|Black|Heavy|Semibold/i.test(_nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _182 => _182.get, 'call', _183 => _183(b.style.fontName)]), () => ( ""))));
2618
+ let chain = [];
2619
+ const finish = () => {
2620
+ if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access', _184 => _184.text, 'optionalAccess', _185 => _185.length]), () => ( 0))) >= 40 && b.bbox.height >= b.style.fontSize * 2.4)) return;
2621
+ for (const b of chain) numberedProse.add(b);
2622
+ const first = chain[0], size = first.style.fontSize;
2623
+ for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access', _186 => _186.text, 'optionalAccess', _187 => _187.trim, 'call', _188 => _188()]), () => ( ""))) && _optionalChain([b, 'access', _189 => _189.style, 'optionalAccess', _190 => _190.fontName]) === _optionalChain([first, 'access', _191 => _191.style, 'optionalAccess', _192 => _192.fontName]) && _optionalChain([b, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontSize]) === size && b.bbox && Math.abs(b.bbox.x - first.bbox.x) <= size * 0.5 && (_nullishCoalesce(_optionalChain([b, 'access', _195 => _195.text, 'optionalAccess', _196 => _196.length]), () => ( 0))) >= 15) numberedProse.add(b);
2624
+ };
2625
+ for (const b of numbered) {
2626
+ const prev = chain.at(-1), size = b.style.fontSize;
2627
+ if (!prev || b.text.trim().charCodeAt(0) !== prev.text.trim().charCodeAt(0) + 1 || b.style.fontName !== prev.style.fontName || size !== prev.style.fontSize || Math.abs(b.bbox.x - prev.bbox.x) > size * 0.5 || prev.bbox.y - (b.bbox.y + b.bbox.height) > size * 8) {
2628
+ finish();
2629
+ chain = [];
2630
+ }
2631
+ chain.push(b);
2632
+ }
2633
+ finish();
2634
+ }
2635
+ for (let i = 0; i + 1 < blocks.length; i++) {
2636
+ const prose = blocks[i], reference = blocks[i + 1];
2637
+ const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _197 => _197.style, 'optionalAccess', _198 => _198.fontSize]), () => ( 0));
2638
+ const source = _nullishCoalesce(_optionalChain([reference, 'access', _199 => _199.text, 'optionalAccess', _200 => _200.replace, 'call', _201 => _201(/<[^>]+>/g, ""), 'access', _202 => _202.trim, 'call', _203 => _203()]), () => ( ""));
2639
+ if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access', _204 => _204.text, 'optionalAccess', _205 => _205.length]), () => ( 0))) < 40 || !a || !b || size <= 0 || a.height < size * 2.4 || prose.pageNumber !== reference.pageNumber || _optionalChain([prose, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontName]) !== _optionalChain([reference, 'access', _208 => _208.style, 'optionalAccess', _209 => _209.fontName]) || _optionalChain([prose, 'access', _210 => _210.style, 'optionalAccess', _211 => _211.fontSize]) !== _optionalChain([reference, 'access', _212 => _212.style, 'optionalAccess', _213 => _213.fontSize]) || Math.abs(a.x - b.x) > size && !(/^[○●•◦]\s/.test(_nullishCoalesce(prose.text, () => ( ""))) && b.x >= a.x && b.x - a.x <= size * 2) || a.y - (b.y + b.height) < 0 || a.y - (b.y + b.height) > size || !/^[((].*(?:제\s*\d+\s*조|(?:Article|Section)\s+\d+).*[))]$/i.test(source)) continue;
2640
+ citedProse.add(prose);
2641
+ citedProse.add(reference);
2642
+ }
2457
2643
  for (let i = 0; i < blocks.length; i++) {
2458
2644
  const block = blocks[i];
2459
2645
  if (block.type !== "heading" || !block.text) continue;
2460
2646
  const text = block.text.replace(/<[^>]+>/g, "").trim();
2461
- const fsz = _nullishCoalesce(_optionalChain([block, 'access', _143 => _143.style, 'optionalAccess', _144 => _144.fontSize]), () => ( 0));
2462
- const tocEntry = i > 0 && _chunkKDMAYOWHcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkKDMAYOWHcjs.TOC_BLOCKS.has(blocks[i + 1]);
2647
+ const fsz = _nullishCoalesce(_optionalChain([block, 'access', _214 => _214.style, 'optionalAccess', _215 => _215.fontSize]), () => ( 0));
2648
+ const tocEntry = i > 0 && _chunkE2644XCOcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkE2644XCOcjs.TOC_BLOCKS.has(blocks[i + 1]);
2463
2649
  const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
2464
- const proseStyle = _optionalChain([block, 'access', _145 => _145.style, 'optionalAccess', _146 => _146.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
2650
+ const proseStyle = _optionalChain([block, 'access', _216 => _216.style, 'optionalAccess', _217 => _217.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
2465
2651
  const next = blocks[i + 1];
2466
- const nb = _optionalChain([next, 'optionalAccess', _147 => _147.bbox]), bb = block.bbox;
2467
- const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _148 => _148.style, 'optionalAccess', _149 => _149.fontSize]), () => ( 0))) * 1.2 && Math.abs(bb.x - nb.x) > fsz && Math.abs(bb.x + bb.width / 2 - (nb.x + nb.width / 2)) < nb.width * 0.1;
2468
- if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _150 => _150.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
2652
+ const nb = _optionalChain([next, 'optionalAccess', _218 => _218.bbox]), bb = block.bbox;
2653
+ const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _219 => _219.style, 'optionalAccess', _220 => _220.fontSize]), () => ( 0))) * 1.2 && Math.abs(bb.x - nb.x) > fsz && Math.abs(bb.x + bb.width / 2 - (nb.x + nb.width / 2)) < nb.width * 0.1;
2654
+ if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _221 => _221.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
2469
2655
  next.text = `${block.text.trim()} ${next.text.trim()}`;
2470
2656
  blocks.splice(i--, 1);
2471
2657
  continue;
2472
2658
  }
2473
- if ((_optionalChain([next, 'optionalAccess', _151 => _151.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _152 => _152.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _153 => _153.style, 'optionalAccess', _154 => _154.fontName]) === _optionalChain([block, 'access', _155 => _155.style, 'optionalAccess', _156 => _156.fontName]) && _optionalChain([next, 'access', _157 => _157.style, 'optionalAccess', _158 => _158.fontSize]) === _optionalChain([block, 'access', _159 => _159.style, 'optionalAccess', _160 => _160.fontSize]) && fsz > 0 && /^[a-z]/.test(next.text.trim()) && next.text.trim().length <= 40 && !/[.:;!?]$/.test(next.text.trim()) && block.bbox.y - (next.bbox.y + next.bbox.height) < fsz * 1.2 && Math.abs(next.bbox.x - block.bbox.x) < fsz) {
2659
+ if ((_optionalChain([next, 'optionalAccess', _222 => _222.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _223 => _223.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _224 => _224.style, 'optionalAccess', _225 => _225.fontName]) === _optionalChain([block, 'access', _226 => _226.style, 'optionalAccess', _227 => _227.fontName]) && _optionalChain([next, 'access', _228 => _228.style, 'optionalAccess', _229 => _229.fontSize]) === _optionalChain([block, 'access', _230 => _230.style, 'optionalAccess', _231 => _231.fontSize]) && fsz > 0 && /^[a-z]/.test(next.text.trim()) && next.text.trim().length <= 40 && !/[.:;!?]$/.test(next.text.trim()) && block.bbox.y - (next.bbox.y + next.bbox.height) < fsz * 1.2 && Math.abs(next.bbox.x - block.bbox.x) < fsz) {
2474
2660
  block.text = `${block.text.trim()} ${next.text.trim()}`;
2475
2661
  block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
2476
2662
  blocks.splice(i + 1, 1);
2477
2663
  }
2478
2664
  const after = blocks[i + 2];
2479
- if ((_optionalChain([next, 'optionalAccess', _161 => _161.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _162 => _162.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _163 => _163.text, 'optionalAccess', _164 => _164.trim, 'call', _165 => _165()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _166 => _166.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _167 => _167.style, 'optionalAccess', _168 => _168.fontSize]) === _optionalChain([block, 'access', _169 => _169.style, 'optionalAccess', _170 => _170.fontSize])) {
2665
+ if ((_optionalChain([next, 'optionalAccess', _232 => _232.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _233 => _233.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _234 => _234.text, 'optionalAccess', _235 => _235.trim, 'call', _236 => _236()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _237 => _237.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _238 => _238.style, 'optionalAccess', _239 => _239.fontSize]) === _optionalChain([block, 'access', _240 => _240.style, 'optionalAccess', _241 => _241.fontSize])) {
2480
2666
  block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
2481
2667
  blocks.splice(i + 1, 2);
2482
2668
  }
2483
2669
  const tiny = fsz > 0 && fsz < 7.5;
2484
2670
  const prev = blocks[i - 1];
2485
- if (_optionalChain([prev, 'optionalAccess', _171 => _171.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _172 => _172.text, 'optionalAccess', _173 => _173.trim, 'call', _174 => _174()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
2671
+ if (_optionalChain([prev, 'optionalAccess', _242 => _242.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _243 => _243.text, 'optionalAccess', _244 => _244.trim, 'call', _245 => _245()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
2486
2672
  prev.text = `${prev.text.trim()} ${block.text.trim()}`;
2487
2673
  prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
2488
2674
  blocks.splice(i--, 1);
2489
2675
  continue;
2490
2676
  }
2491
- if (_optionalChain([prev, 'optionalAccess', _175 => _175.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _176 => _176.text, 'optionalAccess', _177 => _177.trim, 'call', _178 => _178()]), () => ( ""))) && prev.bbox && block.bbox && fsz > 0 && (Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x && block.bbox.x - (prev.bbox.x + prev.bbox.width) < fsz * 3 || Math.abs(prev.bbox.x - block.bbox.x) < 2 && (_nullishCoalesce(_optionalChain([prev, 'access', _179 => _179.style, 'optionalAccess', _180 => _180.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
2677
+ if (_optionalChain([prev, 'optionalAccess', _246 => _246.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _247 => _247.text, 'optionalAccess', _248 => _248.trim, 'call', _249 => _249()]), () => ( ""))) && prev.bbox && block.bbox && fsz > 0 && (Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x && block.bbox.x - (prev.bbox.x + prev.bbox.width) < fsz * 3 || Math.abs(prev.bbox.x - block.bbox.x) < 2 && (_nullishCoalesce(_optionalChain([prev, 'access', _250 => _250.style, 'optionalAccess', _251 => _251.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
2492
2678
  block.text = `${prev.text.trim()} ${block.text.trim()}`;
2493
2679
  blocks.splice(i - 1, 1);
2494
2680
  i -= 2;
2495
2681
  continue;
2496
2682
  }
2497
- const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _181 => _181.style, 'optionalAccess', _182 => _182.fontSize]), () => ( 0));
2498
- const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _183 => _183.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _184 => _184.style, 'optionalAccess', _185 => _185.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _186 => _186.style, 'optionalAccess', _187 => _187.fontSize]), () => ( 0))) >= size * 1.3 && box.y - (next.bbox.y + next.bbox.height) <= size * 3 && Math.min(box.x + box.width, next.bbox.x + next.bbox.width) - Math.max(box.x, next.bbox.x) >= Math.min(box.width, next.bbox.width) * 0.5 && !page.some((o) => o !== block && o.bbox && o.bbox.y > box.y + box.height && o.type !== "image");
2499
- const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _188 => _188.get, 'call', _189 => _189(_nullishCoalesce(_optionalChain([block, 'access', _190 => _190.style, 'optionalAccess', _191 => _191.fontName]), () => ( "")))]), () => ( ""));
2683
+ const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _252 => _252.style, 'optionalAccess', _253 => _253.fontSize]), () => ( 0));
2684
+ const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _254 => _254.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _255 => _255.style, 'optionalAccess', _256 => _256.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _257 => _257.style, 'optionalAccess', _258 => _258.fontSize]), () => ( 0))) >= size * 1.3 && box.y - (next.bbox.y + next.bbox.height) <= size * 3 && Math.min(box.x + box.width, next.bbox.x + next.bbox.width) - Math.max(box.x, next.bbox.x) >= Math.min(box.width, next.bbox.width) * 0.5 && !page.some((o) => o !== block && o.bbox && o.bbox.y > box.y + box.height && o.type !== "image");
2685
+ const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _259 => _259.get, 'call', _260 => _260(_nullishCoalesce(_optionalChain([block, 'access', _261 => _261.style, 'optionalAccess', _262 => _262.fontName]), () => ( "")))]), () => ( ""));
2500
2686
  const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
2501
- const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _192 => _192[i - 1], 'optionalAccess', _193 => _193.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
2502
- const ocrFragment = _optionalChain([block, 'access', _194 => _194.style, 'optionalAccess', _195 => _195.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _196 => _196.match, 'call', _197 => _197(/\p{L}/gu), 'optionalAccess', _198 => _198.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
2503
- const crowdedOcr = _optionalChain([block, 'access', _199 => _199.style, 'optionalAccess', _200 => _200.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _201 => _201.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _202 => _202.style, 'optionalAccess', _203 => _203.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _204 => _204.text, 'optionalAccess', _205 => _205.length]), () => ( 0))) >= 15 && Math.abs(o.bbox.x - box.x) <= size * 0.25 && Math.min(o.bbox.y + o.bbox.height, box.y + box.height) - Math.max(o.bbox.y, box.y) >= o.bbox.height * 0.2) && prev.bbox.y > box.y && next.bbox.y < box.y;
2504
- if (ocrFragment || crowdedOcr || tocEntry || proseStyle || kicker || byline || tiny || !/\p{L}/u.test(text) && !chapterNumber || /^[a-z]/.test(text) || CAPTION.test(text) || EQUATION_NUMBER.test(block.text) || DISPLAY_MATH.test(text) || // 닫는 괄호가 여는 괄호보다 많으면 앞 줄에서 이어진 문장 조각이다 ("Fact-checking) and is used …") — "1)"·"가)" 앞머리 번호는 빼고 센다
2687
+ const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _263 => _263[i - 1], 'optionalAccess', _264 => _264.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
2688
+ const ocrFragment = _optionalChain([block, 'access', _265 => _265.style, 'optionalAccess', _266 => _266.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _267 => _267.match, 'call', _268 => _268(/\p{L}/gu), 'optionalAccess', _269 => _269.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
2689
+ const crowdedOcr = _optionalChain([block, 'access', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _272 => _272.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _273 => _273.style, 'optionalAccess', _274 => _274.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _275 => _275.text, 'optionalAccess', _276 => _276.length]), () => ( 0))) >= 15 && Math.abs(o.bbox.x - box.x) <= size * 0.25 && Math.min(o.bbox.y + o.bbox.height, box.y + box.height) - Math.max(o.bbox.y, box.y) >= o.bbox.height * 0.2) && prev.bbox.y > box.y && next.bbox.y < box.y;
2690
+ if (numberedProse.has(block) || citedProse.has(block) || ocrFragment || crowdedOcr || tocEntry || proseStyle || kicker || byline || tiny || !/\p{L}/u.test(text) && !chapterNumber || /^[a-z]/.test(text) || CAPTION.test(text) || EQUATION_NUMBER.test(block.text) || DISPLAY_MATH.test(text) || // 닫는 괄호가 여는 괄호보다 많으면 앞 줄에서 이어진 문장 조각이다 ("Fact-checking) and is used …") — "1)"·"가)" 앞머리 번호는 빼고 센다
2505
2691
  unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
2506
2692
  block.type = "paragraph";
2507
2693
  block.level = void 0;
@@ -2535,28 +2721,37 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
2535
2721
  function captionTableText(t) {
2536
2722
  if (!t || t.rows !== 1 || t.cols !== 2) return null;
2537
2723
  const [label, body] = t.cells[0];
2538
- if (!label || !body || _optionalChain([label, 'access', _206 => _206.blocks, 'optionalAccess', _207 => _207.length]) || _optionalChain([body, 'access', _208 => _208.blocks, 'optionalAccess', _209 => _209.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
2724
+ if (!label || !body || _optionalChain([label, 'access', _277 => _277.blocks, 'optionalAccess', _278 => _278.length]) || _optionalChain([body, 'access', _279 => _279.blocks, 'optionalAccess', _280 => _280.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
2539
2725
  return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
2540
2726
  }
2541
2727
  function splitSingleCellTables(blocks) {
2542
2728
  const out = [];
2543
2729
  for (const b of blocks) {
2544
2730
  const t = b.type === "table" ? b.table : void 0;
2545
- const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _210 => _210.cells, 'access', _211 => _211[0], 'optionalAccess', _212 => _212[0], 'optionalAccess', _213 => _213.blocks, 'optionalAccess', _214 => _214.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
2731
+ const title = t && _chunkE2644XCOcjs.FRAME_TITLE_BLOCKS.get(t);
2732
+ if (title) {
2733
+ out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
2734
+ continue;
2735
+ }
2736
+ const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _281 => _281.cells, 'access', _282 => _282[0], 'optionalAccess', _283 => _283[0], 'optionalAccess', _284 => _284.blocks, 'optionalAccess', _285 => _285.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
2546
2737
  const squash = (s) => s.replace(/\s/g, "");
2547
2738
  const inner = only && (!squash(t.cells[0][0].text) || only.type === "table" && squash(t.cells[0][0].text) === squash(only.table.cells.flat().map((c) => c.text).join(""))) ? only : void 0;
2548
- const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _215 => _215.type]) === "table" ? captionTableText(inner.table) : null)));
2739
+ const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _286 => _286.type]) === "table" ? captionTableText(inner.table) : null)));
2549
2740
  if (caption) {
2550
2741
  out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
2551
2742
  continue;
2552
2743
  }
2553
- const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _216 => _216.cells, 'access', _217 => _217[0], 'optionalAccess', _218 => _218[0]]) : void 0;
2554
- if (!cell || _optionalChain([cell, 'access', _219 => _219.blocks, 'optionalAccess', _220 => _220.some, 'call', _221 => _221((x) => x.type === "table")])) {
2744
+ const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _287 => _287.cells, 'access', _288 => _288[0], 'optionalAccess', _289 => _289[0]]) : void 0;
2745
+ if (!cell) {
2555
2746
  out.push(b);
2556
2747
  continue;
2557
2748
  }
2558
2749
  const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
2559
- if (_optionalChain([t, 'optionalAccess', _222 => _222.caption, 'optionalAccess', _223 => _223.trim, 'call', _224 => _224()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
2750
+ if (_optionalChain([t, 'optionalAccess', _290 => _290.caption, 'optionalAccess', _291 => _291.trim, 'call', _292 => _292()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
2751
+ if (_optionalChain([cell, 'access', _293 => _293.blocks, 'optionalAccess', _294 => _294.length])) {
2752
+ out.push(...splitSingleCellTables(cell.blocks));
2753
+ continue;
2754
+ }
2560
2755
  for (const text of lines) out.push({ type: "paragraph", text, pageNumber: b.pageNumber, bbox: b.bbox });
2561
2756
  }
2562
2757
  return out;
@@ -2569,7 +2764,7 @@ function joinLatinCellWraps(blocks) {
2569
2764
  const lines = cell.text.split("\n");
2570
2765
  const out = [lines[0]];
2571
2766
  for (const line of lines.slice(1)) {
2572
- if (_chunkKDMAYOWHcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
2767
+ if (_chunkE2644XCOcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
2573
2768
  else out.push(line);
2574
2769
  }
2575
2770
  cell.text = out.join("\n");
@@ -2580,19 +2775,19 @@ function joinLatinCellWraps(blocks) {
2580
2775
  }
2581
2776
  function cleanPdfText(text, opts) {
2582
2777
  let clean = normalizeAraea(stripControlChars(text));
2583
- if (!_optionalChain([opts, 'optionalAccess', _225 => _225.keepLoneNumbers])) {
2778
+ if (!_optionalChain([opts, 'optionalAccess', _295 => _295.keepLoneNumbers])) {
2584
2779
  clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
2585
2780
  }
2586
- if (!_optionalChain([opts, 'optionalAccess', _226 => _226.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
2781
+ if (!_optionalChain([opts, 'optionalAccess', _296 => _296.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
2587
2782
  return mergeKoreanLines(
2588
2783
  clean.replace(/^[\s]*[-–—]\s*[-–—]?\d+[-–—]?[\s]*[-–—]?[\s]*$/gm, "").replace(/^\s*\d+\s*\/\s*\d+\s*$/gm, "").replace(/\.(?: \.){3,}/g, (m) => ".".repeat(m.length + 1 >> 1))
2589
2784
  ).replace(/^(?!\| ---).*$/gm, (line) => {
2590
2785
  if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
2591
2786
  if (line.startsWith("|")) {
2592
- return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkKDMAYOWHcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
2787
+ return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkE2644XCOcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
2593
2788
  }
2594
- const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _227 => _227.exec, 'call', _228 => _228(line), 'optionalAccess', _229 => _229[0]]), () => ( ""));
2595
- return mark + _chunkKDMAYOWHcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
2789
+ const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _297 => _297.exec, 'call', _298 => _298(line), 'optionalAccess', _299 => _299[0]]), () => ( ""));
2790
+ return mark + _chunkE2644XCOcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
2596
2791
  }).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
2597
2792
  }
2598
2793
  function startsWithMarker(line) {
@@ -2624,7 +2819,7 @@ function mergeKoreanLines(text) {
2624
2819
  continue;
2625
2820
  }
2626
2821
  if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
2627
- result[result.length - 1] = prev + _chunkKDMAYOWHcjs.wrapJoiner.call(void 0, prev, curr) + curr;
2822
+ result[result.length - 1] = prev + _chunkE2644XCOcjs.wrapJoiner.call(void 0, prev, curr) + curr;
2628
2823
  } else {
2629
2824
  result.push(curr);
2630
2825
  }
@@ -2640,7 +2835,7 @@ function applyLinkAnnotations(items, annots) {
2640
2835
  const wrapped = /* @__PURE__ */ new Set();
2641
2836
  for (const a of annots) {
2642
2837
  if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
2643
- const url = _chunkUZGZRGYMcjs.sanitizeHref.call(void 0, a.url);
2838
+ const url = _chunk3XSP7V5Pcjs.sanitizeHref.call(void 0, a.url);
2644
2839
  if (!url) continue;
2645
2840
  const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
2646
2841
  const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
@@ -2681,7 +2876,7 @@ function mergeLinkRuns(markdown) {
2681
2876
 
2682
2877
  // src/pdf/formula-ocr.ts
2683
2878
  async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
2684
- const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-VY4ITOMN.cjs")));
2879
+ const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-YYJQBKEN.cjs")));
2685
2880
  const { FormulaPipeline, ensureFormulaModels } = formulaMod;
2686
2881
  await ensureFormulaModels((p) => {
2687
2882
  if (p.phase === "download" && p.total) {
@@ -2860,13 +3055,13 @@ async function loadPdfWithTimeout(buffer) {
2860
3055
  try {
2861
3056
  return await Promise.race([
2862
3057
  loadingTask.promise.catch((e) => {
2863
- if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkUZGZRGYMcjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C PDF \uD30C\uC77C\uC785\uB2C8\uB2E4 (PDF \uC5F4\uAE30 \uC554\uD638\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4)");
3058
+ if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunk3XSP7V5Pcjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C PDF \uD30C\uC77C\uC785\uB2C8\uB2E4 (PDF \uC5F4\uAE30 \uC554\uD638\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4)");
2864
3059
  throw e;
2865
3060
  }),
2866
3061
  new Promise((_, reject) => {
2867
3062
  timer = setTimeout(() => {
2868
3063
  loadingTask.destroy();
2869
- reject(new (0, _chunkUZGZRGYMcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
3064
+ reject(new (0, _chunk3XSP7V5Pcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
2870
3065
  }, PDF_LOAD_TIMEOUT_MS);
2871
3066
  })
2872
3067
  ]);
@@ -2875,13 +3070,13 @@ async function loadPdfWithTimeout(buffer) {
2875
3070
  }
2876
3071
  }
2877
3072
  async function parsePdfDocument(buffer, options) {
2878
- const formulaBuffer = _optionalChain([options, 'optionalAccess', _230 => _230.formulaOcr]) ? buffer : null;
2879
- const autoOcr = _optionalChain([options, 'optionalAccess', _231 => _231.ocr]) === void 0 && await _chunkKDMAYOWHcjs.ocrModelsCached.call(void 0, );
2880
- const ocrBuffer = _optionalChain([options, 'optionalAccess', _232 => _232.ocr]) || autoOcr ? buffer : null;
3073
+ const formulaBuffer = _optionalChain([options, 'optionalAccess', _300 => _300.formulaOcr]) ? buffer : null;
3074
+ const autoOcr = _optionalChain([options, 'optionalAccess', _301 => _301.ocr]) === void 0 && await _chunkE2644XCOcjs.ocrModelsCached.call(void 0, );
3075
+ const ocrBuffer = _optionalChain([options, 'optionalAccess', _302 => _302.ocr]) || autoOcr ? buffer : null;
2881
3076
  const doc = await loadPdfWithTimeout(buffer);
2882
3077
  try {
2883
3078
  const pageCount = doc.numPages;
2884
- if (pageCount === 0) throw new (0, _chunkUZGZRGYMcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
3079
+ if (pageCount === 0) throw new (0, _chunk3XSP7V5Pcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
2885
3080
  const metadata = { pageCount, pageMode: "layout" };
2886
3081
  await extractPdfMetadata(doc, metadata);
2887
3082
  const blocks = [];
@@ -2890,8 +3085,8 @@ async function parsePdfDocument(buffer, options) {
2890
3085
  let totalChars = 0;
2891
3086
  let totalTextBytes = 0;
2892
3087
  const effectivePageCount = Math.min(pageCount, MAX_PAGES);
2893
- const pageFilter = _optionalChain([options, 'optionalAccess', _233 => _233.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
2894
- if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _234 => _234.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
3088
+ const pageFilter = _optionalChain([options, 'optionalAccess', _303 => _303.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
3089
+ if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _304 => _304.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
2895
3090
  warnings.push({ message: `${pageCount}\uCABD \uC911 \uC55E ${MAX_PAGES}\uCABD\uB9CC \uD30C\uC2F1\uD588\uC2B5\uB2C8\uB2E4 (\uCABD \uC218 \uC0C1\uD55C)`, code: "PARTIAL_PARSE" });
2896
3091
  }
2897
3092
  const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
@@ -2904,12 +3099,29 @@ async function parsePdfDocument(buffer, options) {
2904
3099
  const uncoveredImageRegions = /* @__PURE__ */ new Map();
2905
3100
  const largeImageRegions = /* @__PURE__ */ new Set();
2906
3101
  const imageState = createPdfImageState();
3102
+ const imageBulletShapes = /* @__PURE__ */ new Map();
3103
+ const imageArrowDirections = /* @__PURE__ */ new Map();
2907
3104
  const extractedImages = [];
2908
3105
  const pageImageBlocks = /* @__PURE__ */ new Map();
2909
3106
  const carry = {};
2910
3107
  const vectorPageOps = /* @__PURE__ */ new Map();
2911
- const wrapLexicon = new (0, _chunkKDMAYOWHcjs.WrapLexicon)();
3108
+ const wrapLexicon = new (0, _chunkE2644XCOcjs.WrapLexicon)();
2912
3109
  const noteMarks = /* @__PURE__ */ new Map();
3110
+ const headerContext = [];
3111
+ if (pageFilter && _optionalChain([options, 'optionalAccess', _305 => _305.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
3112
+ for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
3113
+ let contextPage;
3114
+ try {
3115
+ contextPage = await doc.getPage(number);
3116
+ const content = await contextPage.getTextContent();
3117
+ pageHeights.set(number, contextPage.view[3] - contextPage.view[1]);
3118
+ headerContext.push(...marginContextBlocks(content.items, number, contextPage.view));
3119
+ } catch (e4) {
3120
+ } finally {
3121
+ _optionalChain([contextPage, 'optionalAccess', _306 => _306.cleanup, 'call', _307 => _307()]);
3122
+ }
3123
+ }
3124
+ }
2913
3125
  let parsedPages = 0;
2914
3126
  for (let i = 1; i <= effectivePageCount; i++) {
2915
3127
  if (pageFilter && !pageFilter.has(i)) continue;
@@ -2927,17 +3139,17 @@ async function parsePdfDocument(buffer, options) {
2927
3139
  const fontObj = (loadedName) => {
2928
3140
  try {
2929
3141
  return page.commonObjs.has(loadedName) ? page.commonObjs.get(loadedName) : void 0;
2930
- } catch (e4) {
3142
+ } catch (e5) {
2931
3143
  return void 0;
2932
3144
  }
2933
3145
  };
2934
- const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _235 => _235(loadedName), 'optionalAccess', _236 => _236.differences]);
2935
- restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _237 => _237(n), 'optionalAccess', _238 => _238.name]));
3146
+ const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _308 => _308(loadedName), 'optionalAccess', _309 => _309.differences]);
3147
+ restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _310 => _310(n), 'optionalAccess', _311 => _311.name]));
2936
3148
  restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
2937
3149
  markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
2938
3150
  const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
2939
- const items = _chunkKDMAYOWHcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
2940
- const filtered = _chunkKDMAYOWHcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
3151
+ const items = _chunkE2644XCOcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
3152
+ const filtered = _chunkE2644XCOcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
2941
3153
  const joined = joinVerticalColumns(filtered.visible);
2942
3154
  const visible = dropTabLeaderDots(joined);
2943
3155
  const hiddenCount = filtered.hiddenCount + occluded.size;
@@ -2950,7 +3162,7 @@ async function parsePdfDocument(buffer, options) {
2950
3162
  try {
2951
3163
  const annots = await page.getAnnotations();
2952
3164
  applyLinkAnnotations(visible, annots);
2953
- } catch (e5) {
3165
+ } catch (e6) {
2954
3166
  }
2955
3167
  const shifted = viewX1 !== 0 || viewY1 !== 0;
2956
3168
  if (shifted) for (const item of visible) {
@@ -2961,26 +3173,27 @@ async function parsePdfDocument(buffer, options) {
2961
3173
  fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
2962
3174
  argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
2963
3175
  } : rawOps;
2964
- remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _239 => _239(loadedName), 'optionalAccess', _240 => _240.name]));
3176
+ remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _312 => _312(loadedName), 'optionalAccess', _313 => _313.name]));
2965
3177
  remapControlGlyphs(visible, differencesOf);
3178
+ await _chunkE2644XCOcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
2966
3179
  const faces = /* @__PURE__ */ new Map();
2967
3180
  for (const it of visible) {
2968
3181
  if (!it.fontName) continue;
2969
3182
  let face = faces.get(it.fontName);
2970
3183
  if (face === void 0) {
2971
3184
  const obj = fontObj(it.fontName);
2972
- face = _optionalChain([obj, 'optionalAccess', _241 => _241.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
3185
+ face = _optionalChain([obj, 'optionalAccess', _314 => _314.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
2973
3186
  faces.set(it.fontName, face);
2974
3187
  }
2975
3188
  it.fontName = face;
2976
- if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _242 => _242(face), 'optionalAccess', _243 => _243.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
3189
+ if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _315 => _315(face), 'optionalAccess', _316 => _316.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
2977
3190
  }
2978
- for (const it of visible) if (it.text.includes("$")) it.text = _chunkQGFZU3JEcjs.escapeLiteralDollar.call(void 0, it.text);
2979
- for (const it of visible) if (it.text.includes("<")) it.text = _chunkQGFZU3JEcjs.escapeLiteralTags.call(void 0, it.text);
3191
+ for (const it of visible) if (it.text.includes("$")) it.text = _chunk3WLZOJIEcjs.escapeLiteralDollar.call(void 0, it.text);
3192
+ for (const it of visible) if (it.text.includes("<")) it.text = _chunk3WLZOJIEcjs.escapeLiteralTags.call(void 0, it.text);
2980
3193
  wrapEquationRuns(visible, (face) => faceNames.get(face));
2981
3194
  const pageArea = pageW * pageH;
2982
3195
  if (pageArea > 0) {
2983
- const imageRegions = _chunkKDMAYOWHcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
3196
+ const imageRegions = _chunkE2644XCOcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
2984
3197
  let uncovered = 0;
2985
3198
  for (const r of imageRegions) {
2986
3199
  const area = (r.x2 - r.x1) * (r.y2 - r.y1);
@@ -3006,17 +3219,18 @@ async function parsePdfDocument(buffer, options) {
3006
3219
  if (uncovered > 0) skippedImagePages.set(i, uncovered);
3007
3220
  }
3008
3221
  const marks = superscriptNoteMarks(visible);
3009
- if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkKDMAYOWHcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
3222
+ if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkE2644XCOcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
3010
3223
  const stamp = marginStamp(visible);
3011
3224
  const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
3012
- const pageBlocks = orderTwoUpPage(_chunkKDMAYOWHcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _244 => _244.tables]) !== false, carry, wrapLexicon), pageW, pageH);
3225
+ const rightArrows = _optionalChain([options, 'optionalAccess', _317 => _317.tables]) !== false ? await _chunkE2644XCOcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
3226
+ const pageBlocks = orderTwoUpPage(_chunkE2644XCOcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _318 => _318.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
3013
3227
  if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
3014
3228
  for (const b of pageBlocks) blocks.push(b);
3015
3229
  try {
3016
- const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _245 => _245.images]) !== false);
3230
+ const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _319 => _319.images]) !== false);
3017
3231
  if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
3018
3232
  extractedImages.push(...pageImages);
3019
- } catch (e6) {
3233
+ } catch (e7) {
3020
3234
  }
3021
3235
  let pageText = "";
3022
3236
  for (const b of pageBlocks) {
@@ -3032,27 +3246,27 @@ async function parsePdfDocument(buffer, options) {
3032
3246
  const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
3033
3247
  const quality = computePageQuality(i, pageText, vector.glyphs);
3034
3248
  pageQuality.push(quality);
3035
- if (_optionalChain([options, 'optionalAccess', _246 => _246.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
3249
+ if (_optionalChain([options, 'optionalAccess', _320 => _320.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
3036
3250
  vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
3037
3251
  }
3038
- if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkUZGZRGYMcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
3252
+ if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunk3XSP7V5Pcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
3039
3253
  parsedPages++;
3040
- _optionalChain([options, 'optionalAccess', _247 => _247.onProgress, 'optionalCall', _248 => _248(parsedPages, totalTarget)]);
3254
+ _optionalChain([options, 'optionalAccess', _321 => _321.onProgress, 'optionalCall', _322 => _322(parsedPages, totalTarget)]);
3041
3255
  } catch (pageErr) {
3042
- if (pageErr instanceof _chunkUZGZRGYMcjs.KordocError) throw pageErr;
3256
+ if (pageErr instanceof _chunk3XSP7V5Pcjs.KordocError) throw pageErr;
3043
3257
  warnings.push({ page: i, message: `\uD398\uC774\uC9C0 ${i} \uD30C\uC2F1 \uC2E4\uD328: ${pageErr instanceof Error ? pageErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
3044
3258
  } finally {
3045
- _optionalChain([loadedPage, 'optionalAccess', _249 => _249.cleanup, 'call', _250 => _250()]);
3259
+ _optionalChain([loadedPage, 'optionalAccess', _323 => _323.cleanup, 'call', _324 => _324()]);
3046
3260
  }
3047
3261
  }
3048
3262
  const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
3049
- const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _251 => _251.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
3263
+ const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _325 => _325.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
3050
3264
  const ocrDone = /* @__PURE__ */ new Set();
3051
- const ocrRegions = _optionalChain([options, 'optionalAccess', _252 => _252.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _253 => _253.ocr]) === true) : /* @__PURE__ */ new Map();
3265
+ const ocrRegions = _optionalChain([options, 'optionalAccess', _326 => _326.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _327 => _327.ocr]) === true) : /* @__PURE__ */ new Map();
3052
3266
  if (ocrBuffer) {
3053
3267
  const inScope = (p) => !pageFilter || pageFilter.has(p);
3054
3268
  const targets = /* @__PURE__ */ new Set();
3055
- if (_optionalChain([options, 'optionalAccess', _254 => _254.ocr]) === "force" || isImageBased) {
3269
+ if (_optionalChain([options, 'optionalAccess', _328 => _328.ocr]) === "force" || isImageBased) {
3056
3270
  for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
3057
3271
  } else {
3058
3272
  for (const pq of pageQuality) {
@@ -3065,16 +3279,16 @@ async function parsePdfDocument(buffer, options) {
3065
3279
  }
3066
3280
  if (targets.size > 0) {
3067
3281
  try {
3068
- const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-IGYCZ7G2.cjs")));
3069
- const mode = typeof _optionalChain([options, 'optionalAccess', _255 => _255.ocr]) === "function" ? options.ocr : "builtin";
3070
- const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _256 => _256.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _257 => _257.find, 'call', _258 => _258((q) => q.page === p), 'optionalAccess', _259 => _259.needsOcr])));
3071
- const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _260 => _260.onProgress]), _optionalChain([options, 'optionalAccess', _261 => _261.tables]) !== false, vectorPageOps, regionPages);
3072
- for (const obs of ocrPageBlocks.values()) _chunkQGFZU3JEcjs.stripScriptTags.call(void 0, { blocks: obs });
3282
+ const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-EJ2HNZN6.cjs")));
3283
+ const mode = typeof _optionalChain([options, 'optionalAccess', _329 => _329.ocr]) === "function" ? options.ocr : "builtin";
3284
+ const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _330 => _330.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _331 => _331.find, 'call', _332 => _332((q) => q.page === p), 'optionalAccess', _333 => _333.needsOcr])));
3285
+ const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _334 => _334.onProgress]), _optionalChain([options, 'optionalAccess', _335 => _335.tables]) !== false, vectorPageOps, regionPages);
3286
+ for (const obs of ocrPageBlocks.values()) _chunk3WLZOJIEcjs.stripScriptTags.call(void 0, { blocks: obs });
3073
3287
  if (ocrPageBlocks.size > 0) {
3074
3288
  const replacePages = /* @__PURE__ */ new Set();
3075
3289
  for (const [p, obs] of ocrPageBlocks) {
3076
- const needsOcr = _optionalChain([pageQuality, 'access', _262 => _262.find, 'call', _263 => _263((q) => q.page === p), 'optionalAccess', _264 => _264.needsOcr]);
3077
- if (_optionalChain([options, 'optionalAccess', _265 => _265.ocr]) === "force" || isImageBased || needsOcr) {
3290
+ const needsOcr = _optionalChain([pageQuality, 'access', _336 => _336.find, 'call', _337 => _337((q) => q.page === p), 'optionalAccess', _338 => _338.needsOcr]);
3291
+ if (_optionalChain([options, 'optionalAccess', _339 => _339.ocr]) === "force" || isImageBased || needsOcr) {
3078
3292
  replacePages.add(p);
3079
3293
  ocrDone.add(p);
3080
3294
  continue;
@@ -3082,7 +3296,7 @@ async function parsePdfDocument(buffer, options) {
3082
3296
  const regions = ocrRegions.get(p);
3083
3297
  if (!regions || mergeOcrImageRegions(blocks, p, regions, obs) === 0) continue;
3084
3298
  ocrDone.add(p);
3085
- if (_optionalChain([pageImageBlocks, 'access', _266 => _266.get, 'call', _267 => _267(p), 'optionalAccess', _268 => _268.length]) === 1) pageImageBlocks.delete(p);
3299
+ if (_optionalChain([pageImageBlocks, 'access', _340 => _340.get, 'call', _341 => _341(p), 'optionalAccess', _342 => _342.length]) === 1) pageImageBlocks.delete(p);
3086
3300
  }
3087
3301
  if (replacePages.size) {
3088
3302
  const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
@@ -3132,12 +3346,12 @@ async function parsePdfDocument(buffer, options) {
3132
3346
  warnings.push({ page, message: `${count}\uAC1C \uC774\uBBF8\uC9C0 \uC601\uC5ED\uC5D0 \uCD94\uCD9C \uAC00\uB2A5\uD55C \uD14D\uC2A4\uD2B8 \uC5C6\uC74C (\uADF8\uB9BC/\uCC28\uD2B8/\uB3C4\uC7A5 \uB0B4\uC6A9 \uB204\uB77D \uAC00\uB2A5 \u2014 \uADF8\uB9BC \uC18D \uAE00\uC740 ocr: true / CLI --ocr \uB85C \uC77D\uC2B5\uB2C8\uB2E4)`, code: "SKIPPED_IMAGE" });
3133
3347
  }
3134
3348
  }
3135
- if (_optionalChain([options, 'optionalAccess', _269 => _269.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
3136
- const removed = _chunkKDMAYOWHcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks);
3349
+ if (_optionalChain([options, 'optionalAccess', _343 => _343.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
3350
+ const removed = _chunkE2644XCOcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
3137
3351
  for (let ri = removed.length - 1; ri >= 0; ri--) {
3138
3352
  blocks.splice(removed[ri], 1);
3139
3353
  }
3140
- const kept = _chunkKDMAYOWHcjs.removeSideTabs.call(void 0, blocks, pageWidths);
3354
+ const kept = _chunkE2644XCOcjs.removeSideTabs.call(void 0, blocks, pageWidths);
3141
3355
  if (kept !== blocks) {
3142
3356
  blocks.length = 0;
3143
3357
  blocks.push(...kept);
@@ -3145,15 +3359,15 @@ async function parsePdfDocument(buffer, options) {
3145
3359
  }
3146
3360
  mergeContinuedCells(blocks, pageHeights);
3147
3361
  mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
3148
- if (_optionalChain([options, 'optionalAccess', _270 => _270.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
3149
- const boxes = _chunkKDMAYOWHcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
3362
+ if (_optionalChain([options, 'optionalAccess', _344 => _344.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
3363
+ const boxes = _chunkE2644XCOcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
3150
3364
  for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
3151
3365
  }
3152
3366
  splitContactTables(blocks);
3153
- if (!_optionalChain([options, 'optionalAccess', _271 => _271.keepTrailingEmptyCols])) _chunkKDMAYOWHcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
3154
- _chunkKDMAYOWHcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
3367
+ if (!_optionalChain([options, 'optionalAccess', _345 => _345.keepTrailingEmptyCols])) _chunkE2644XCOcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
3368
+ _chunkE2644XCOcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
3155
3369
  injectPageImageBlocks(blocks, pageImageBlocks);
3156
- if (_optionalChain([options, 'optionalAccess', _272 => _272.formulaOcr]) && formulaBuffer) {
3370
+ if (_optionalChain([options, 'optionalAccess', _346 => _346.formulaOcr]) && formulaBuffer) {
3157
3371
  try {
3158
3372
  await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
3159
3373
  } catch (e) {
@@ -3163,49 +3377,53 @@ async function parsePdfDocument(buffer, options) {
3163
3377
  });
3164
3378
  }
3165
3379
  }
3166
- const medianFontSize = _chunkKDMAYOWHcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
3380
+ const medianFontSize = _chunkE2644XCOcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
3167
3381
  if (medianFontSize > 0) {
3168
- _chunkKDMAYOWHcjs.detectHeadings.call(void 0, blocks, medianFontSize);
3169
- }
3170
- _chunkKDMAYOWHcjs.detectDocumentStyleHeadings.call(void 0, blocks);
3171
- _chunkKDMAYOWHcjs.detectTypographyHeadings.call(void 0, blocks);
3172
- _chunkKDMAYOWHcjs.detectSiblingStyleHeadings.call(void 0, blocks);
3173
- _chunkKDMAYOWHcjs.detectRepeatedPageLabels.call(void 0, blocks);
3174
- _chunkKDMAYOWHcjs.detectPageLeadHeadings.call(void 0, blocks);
3175
- _chunkKDMAYOWHcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
3176
- _chunkKDMAYOWHcjs.refineDocumentStyleHeadings.call(void 0, blocks);
3177
- _chunkKDMAYOWHcjs.detectMarkerHeadings.call(void 0, blocks);
3382
+ _chunkE2644XCOcjs.detectHeadings.call(void 0, blocks, medianFontSize);
3383
+ }
3384
+ _chunkE2644XCOcjs.detectDocumentStyleHeadings.call(void 0, blocks);
3385
+ _chunkE2644XCOcjs.detectTypographyHeadings.call(void 0, blocks);
3386
+ _chunkE2644XCOcjs.detectSiblingStyleHeadings.call(void 0, blocks);
3387
+ _chunkE2644XCOcjs.detectRepeatedPageLabels.call(void 0, blocks);
3388
+ _chunkE2644XCOcjs.detectPageLeadHeadings.call(void 0, blocks);
3389
+ _chunkE2644XCOcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
3390
+ _chunkE2644XCOcjs.refineDocumentStyleHeadings.call(void 0, blocks);
3391
+ _chunkE2644XCOcjs.detectMarkerHeadings.call(void 0, blocks);
3178
3392
  demoteNonHeadingRoles(blocks, pageHeights, faceNames);
3179
- _chunkKDMAYOWHcjs.detectTableCaptions.call(void 0, blocks);
3180
- _chunkKDMAYOWHcjs.detectKoreanListBlocks.call(void 0, blocks);
3393
+ _chunkE2644XCOcjs.detectTableCaptions.call(void 0, blocks);
3394
+ _chunkE2644XCOcjs.detectKoreanListBlocks.call(void 0, blocks);
3181
3395
  const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
3182
3396
  sanitizeBlockControlChars(blocks);
3183
3397
  let outBlocks = splitSingleCellTables(blocks);
3398
+ if (_optionalChain([options, 'optionalAccess', _347 => _347.layoutTables]) !== "keep") {
3399
+ blocks.length = 0;
3400
+ for (const block of outBlocks) blocks.push(block);
3401
+ }
3184
3402
  outBlocks = inlineFootnotes(outBlocks, noteMarks);
3185
3403
  outBlocks = relocateEndnotes(outBlocks);
3186
- if (_optionalChain([options, 'optionalAccess', _273 => _273.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
3404
+ if (_optionalChain([options, 'optionalAccess', _348 => _348.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
3187
3405
  if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
3188
3406
  const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
3189
3407
  if (!b.bbox || !h) return false;
3190
3408
  return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
3191
3409
  });
3192
3410
  joinLatinCellWraps(outBlocks);
3193
- if (_optionalChain([options, 'optionalAccess', _274 => _274.layoutTables]) !== "keep") {
3411
+ if (_optionalChain([options, 'optionalAccess', _349 => _349.layoutTables]) !== "keep") {
3194
3412
  const hancom = await isHancomPdf(doc);
3195
3413
  const shown = /* @__PURE__ */ new Map();
3196
3414
  const markContent = (bs) => {
3197
3415
  for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
3198
- if (_chunkKDMAYOWHcjs.IMAGE_CELLS.has(c)) _chunkQGFZU3JEcjs.CONTENT_CELLS.add(c);
3416
+ if (_chunkE2644XCOcjs.IMAGE_CELLS.has(c)) _chunk3WLZOJIEcjs.CONTENT_CELLS.add(c);
3199
3417
  markContent(c.blocks);
3200
3418
  }
3201
3419
  };
3202
3420
  const visual = (bs) => bs.flatMap((b) => {
3203
3421
  if (b.type !== "table") return [b];
3204
- if (!hancom && b.table && _chunkKDMAYOWHcjs.CLIP_TABLES.has(b.table)) return [b];
3422
+ if (!hancom && b.table && _chunkE2644XCOcjs.CLIP_TABLES.has(b.table)) return [b];
3205
3423
  let v = shown.get(b);
3206
3424
  if (!v) {
3207
3425
  markContent([b]);
3208
- shown.set(b, v = _chunkQGFZU3JEcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _275 => _275.keepTrailingEmptyCols])));
3426
+ shown.set(b, v = _chunk3WLZOJIEcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _350 => _350.keepTrailingEmptyCols])));
3209
3427
  }
3210
3428
  return v;
3211
3429
  });
@@ -3214,11 +3432,11 @@ async function parsePdfDocument(buffer, options) {
3214
3432
  blocks.length = 0;
3215
3433
  for (const b of kept) blocks.push(b);
3216
3434
  }
3217
- const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkQGFZU3JEcjs.blocksToMarkdown.call(void 0, bs), { keepLoneNumbers: true }));
3435
+ const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunk3WLZOJIEcjs.blocksToMarkdown.call(void 0, bs), { keepLoneNumbers: true }));
3218
3436
  let markdown = finishMarkdown(outBlocks);
3219
3437
  return {
3220
3438
  markdown,
3221
- pages: _chunkW2YYBPW5cjs.blocksToPages.call(void 0, outBlocks, finishMarkdown),
3439
+ pages: _chunkSVNBZEL6cjs.blocksToPages.call(void 0, outBlocks, finishMarkdown),
3222
3440
  blocks,
3223
3441
  metadata,
3224
3442
  outline: outline.length > 0 ? outline : void 0,
@@ -3236,7 +3454,7 @@ async function parsePdfDocument(buffer, options) {
3236
3454
  async function extractPdfMetadata(doc, metadata) {
3237
3455
  try {
3238
3456
  const result = await doc.getMetadata();
3239
- if (!_optionalChain([result, 'optionalAccess', _276 => _276.info])) return;
3457
+ if (!_optionalChain([result, 'optionalAccess', _351 => _351.info])) return;
3240
3458
  const info = result.info;
3241
3459
  if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
3242
3460
  if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
@@ -3247,14 +3465,14 @@ async function extractPdfMetadata(doc, metadata) {
3247
3465
  }
3248
3466
  if (typeof info.CreationDate === "string") metadata.createdAt = parsePdfDate(info.CreationDate);
3249
3467
  if (typeof info.ModDate === "string") metadata.modifiedAt = parsePdfDate(info.ModDate);
3250
- } catch (e7) {
3468
+ } catch (e8) {
3251
3469
  }
3252
3470
  }
3253
3471
  async function isHancomPdf(doc) {
3254
3472
  try {
3255
- const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _277 => _277.info]);
3256
- return [_optionalChain([info, 'optionalAccess', _278 => _278.Producer]), _optionalChain([info, 'optionalAccess', _279 => _279.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
3257
- } catch (e8) {
3473
+ const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _352 => _352.info]);
3474
+ return [_optionalChain([info, 'optionalAccess', _353 => _353.Producer]), _optionalChain([info, 'optionalAccess', _354 => _354.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
3475
+ } catch (e9) {
3258
3476
  return false;
3259
3477
  }
3260
3478
  }
@@ -3296,5 +3514,5 @@ function marginStamp(items) {
3296
3514
 
3297
3515
 
3298
3516
 
3299
- exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkKDMAYOWHcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkKDMAYOWHcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkKDMAYOWHcjs.removeHeaderFooterBlocks;
3300
- //# sourceMappingURL=parser-7KECZTTP.cjs.map
3517
+ exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkE2644XCOcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkE2644XCOcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkE2644XCOcjs.removeHeaderFooterBlocks;
3518
+ //# sourceMappingURL=parser-BGORCLIU.cjs.map