kordoc 4.24.44 → 4.24.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +3 -3
  2. package/dist/{-H334XSXO.js → -U63KR7FM.js} +21 -21
  3. package/dist/{chunk-YN3C6T5M.cjs → chunk-2QHC2YXC.cjs} +221 -115
  4. package/dist/chunk-2QHC2YXC.cjs.map +1 -0
  5. package/dist/{chunk-WXTEM53O.js → chunk-3DV5MIZK.js} +2 -2
  6. package/dist/{chunk-6ZYOH3TZ.js → chunk-3JKPMYNQ.js} +2 -2
  7. package/dist/{chunk-4Y5KRSHV.js → chunk-56HJNAU2.js} +3 -3
  8. package/dist/{chunk-QR5EL3EF.js → chunk-5IEBL77T.js} +2 -2
  9. package/dist/{chunk-HD6RQDGW.js → chunk-7D7CLX3U.js} +2 -2
  10. package/dist/{chunk-2FDWBF47.js → chunk-AJAVVV7C.js} +2 -2
  11. package/dist/{chunk-SXULSPB6.cjs → chunk-ASS2MVTL.cjs} +30 -26
  12. package/dist/chunk-ASS2MVTL.cjs.map +1 -0
  13. package/dist/{chunk-FQMLFAEN.js → chunk-AUSFVOEA.js} +10 -10
  14. package/dist/{chunk-2TJ4E6MT.js → chunk-B3BUBTAB.js} +2 -2
  15. package/dist/{chunk-ZGYKWZJS.cjs → chunk-B773KHRO.cjs} +2 -2
  16. package/dist/{chunk-ZGYKWZJS.cjs.map → chunk-B773KHRO.cjs.map} +1 -1
  17. package/dist/{chunk-NYQ6HNLA.js → chunk-BCRSFFTV.js} +2 -2
  18. package/dist/{chunk-AMLNYJWV.js → chunk-BHL5HQNO.js} +3 -3
  19. package/dist/{chunk-YEKQTHWN.js → chunk-BM4NQPJ7.js} +5 -5
  20. package/dist/{chunk-HDP2NFYZ.js → chunk-BXL3WAEY.js} +8 -4
  21. package/dist/chunk-BXL3WAEY.js.map +1 -0
  22. package/dist/{chunk-IV6GW3K7.js → chunk-DLYJKFRY.js} +2 -2
  23. package/dist/{chunk-TRVRIIER.js → chunk-E6OSXYA4.js} +2 -2
  24. package/dist/{chunk-AS6INVO3.js → chunk-ELEYRONP.js} +9 -5
  25. package/dist/chunk-ELEYRONP.js.map +1 -0
  26. package/dist/{chunk-IT34DGXJ.cjs → chunk-F7MGZMTQ.cjs} +3 -3
  27. package/dist/{chunk-IT34DGXJ.cjs.map → chunk-F7MGZMTQ.cjs.map} +1 -1
  28. package/dist/{chunk-7VVBR5WX.js → chunk-FZFESBG6.js} +111 -5
  29. package/dist/chunk-FZFESBG6.js.map +1 -0
  30. package/dist/{chunk-C2TMQUP4.js → chunk-FZRETZG3.js} +5 -5
  31. package/dist/{chunk-PSB3XI2U.js → chunk-H6YKDFKG.js} +2 -2
  32. package/dist/{chunk-RUCMKRDE.js → chunk-HHORHT5O.js} +2 -2
  33. package/dist/{chunk-JI3WWHN2.js → chunk-HMTXDJZA.js} +6 -6
  34. package/dist/{chunk-B3GHP32M.js → chunk-HVVPLWQD.js} +6 -6
  35. package/dist/{chunk-3EBWTFBT.js → chunk-JKBJDB6X.js} +2 -2
  36. package/dist/{chunk-HB3KLT7N.cjs → chunk-K4BI5IO3.cjs} +58 -58
  37. package/dist/{chunk-HB3KLT7N.cjs.map → chunk-K4BI5IO3.cjs.map} +1 -1
  38. package/dist/{chunk-7W6G4EC7.js → chunk-KXTTQ3RN.js} +2 -2
  39. package/dist/{chunk-NJ2BJDHJ.js → chunk-MKJRT3PP.js} +2 -2
  40. package/dist/{chunk-YSRLHL2J.js → chunk-MOZCSVGA.js} +112 -6
  41. package/dist/chunk-MOZCSVGA.js.map +1 -0
  42. package/dist/{chunk-2KHZVNCS.js → chunk-MVLVCUBP.js} +3 -3
  43. package/dist/{chunk-WF2GLWPA.js → chunk-MXCODLV5.js} +15 -15
  44. package/dist/{chunk-UZTGIVEH.js → chunk-NKWF62JV.js} +5 -5
  45. package/dist/{chunk-ABJ5DR2C.js → chunk-TJYUA2VR.js} +2 -2
  46. package/dist/{chunk-XCRE5EMS.js → chunk-U453MJJB.js} +2 -2
  47. package/dist/{chunk-RFSKHVLF.js → chunk-U4MF5C62.js} +2 -2
  48. package/dist/{chunk-O7EDZT7I.cjs → chunk-VVV54QND.cjs} +98 -98
  49. package/dist/{chunk-O7EDZT7I.cjs.map → chunk-VVV54QND.cjs.map} +1 -1
  50. package/dist/{chunk-GRY6ITVN.js → chunk-W7BLAMBO.js} +2 -2
  51. package/dist/{chunk-UETXNBIQ.js → chunk-WHWBBUSD.js} +7 -7
  52. package/dist/{chunk-6M2Z6QDD.js → chunk-WK3QLJCE.js} +2 -2
  53. package/dist/{chunk-HW6KA2HI.cjs → chunk-XS3SXFUY.cjs} +3 -3
  54. package/dist/{chunk-HW6KA2HI.cjs.map → chunk-XS3SXFUY.cjs.map} +1 -1
  55. package/dist/{chunk-OQCRVBB7.cjs → chunk-YIWEURPR.cjs} +6 -6
  56. package/dist/{chunk-OQCRVBB7.cjs.map → chunk-YIWEURPR.cjs.map} +1 -1
  57. package/dist/{chunk-WLBPDYAT.js → chunk-YOMV4HR6.js} +11 -11
  58. package/dist/chunks-LIB2Y6AD.js +11 -0
  59. package/dist/cli.js +43 -43
  60. package/dist/{formula-DLJ44T7B.js → formula-C46F5MG6.js} +4 -4
  61. package/dist/{formula-2FOYPHV2.js → formula-FBBDRGK6.js} +3 -3
  62. package/dist/{formula-XAUTHBU5.cjs → formula-V2ZZCARY.cjs} +9 -9
  63. package/dist/{formula-XAUTHBU5.cjs.map → formula-V2ZZCARY.cjs.map} +1 -1
  64. package/dist/generator-BNV7GC2V.js +17 -0
  65. package/dist/generator-CKRACBBG.js +10 -0
  66. package/dist/generator-MINQI74H.cjs +11 -0
  67. package/dist/{generator-BIEVUOPW.cjs.map → generator-MINQI74H.cjs.map} +1 -1
  68. package/dist/{hancom-TFYG5RGJ.cjs → hancom-3U6TQO6F.cjs} +5 -5
  69. package/dist/{hancom-TFYG5RGJ.cjs.map → hancom-3U6TQO6F.cjs.map} +1 -1
  70. package/dist/{hancom-B5LZPM5Y.js → hancom-P2ULOGNX.js} +2 -2
  71. package/dist/{hancom-W6XQOGQY.js → hancom-WBVEG72Q.js} +2 -2
  72. package/dist/{image-ocr-6NMWKDT6.cjs → image-ocr-4Y4WGZKF.cjs} +27 -27
  73. package/dist/{image-ocr-6NMWKDT6.cjs.map → image-ocr-4Y4WGZKF.cjs.map} +1 -1
  74. package/dist/{image-ocr-BKFZMHFE.js → image-ocr-7HH262GO.js} +7 -7
  75. package/dist/{image-ocr-XRXLPEBP.js → image-ocr-G5T3YPM5.js} +10 -10
  76. package/dist/index.cjs +1105 -1105
  77. package/dist/index.js +9 -9
  78. package/dist/mcp.js +36 -36
  79. package/dist/memo-CBYIVGEA.js +17 -0
  80. package/dist/{model-bundle-R3AIXPVX.js → model-bundle-APD72FGN.js} +5 -5
  81. package/dist/{models-BLHI4JAU.js → models-RK4ENUTB.js} +5 -5
  82. package/dist/{parse-worker-v2-IB3KIORL.js → parse-worker-v2-TSULPUIC.js} +22 -22
  83. package/dist/{parser-QCPSCSGJ.js → parser-55MAW7G3.js} +9 -9
  84. package/dist/{parser-7VLNB7T6.cjs → parser-K275FDSR.cjs} +159 -159
  85. package/dist/{parser-7VLNB7T6.cjs.map → parser-K275FDSR.cjs.map} +1 -1
  86. package/dist/{parser-QR2TG3WE.js → parser-VBQTQ6K6.js} +12 -12
  87. package/dist/{pdf-ocr-6PZ66I7G.js → pdf-ocr-6AAMBNUY.js} +9 -9
  88. package/dist/pdf-ocr-FR4G5PDF.cjs +42 -0
  89. package/dist/{pdf-ocr-TUCEX4AY.cjs.map → pdf-ocr-FR4G5PDF.cjs.map} +1 -1
  90. package/dist/{pdf-ocr-TGXEFZB5.js → pdf-ocr-YSEEZMJI.js} +6 -6
  91. package/dist/{profile-io-QL4XZ34F.js → profile-io-DSBGIVPH.js} +3 -3
  92. package/dist/{rasterize-PUG2V436.js → rasterize-46HYG3R6.js} +3 -3
  93. package/dist/{redact-doc-XDMXMF3A.js → redact-doc-GN673LJP.js} +21 -21
  94. package/dist/{render-IHE7XBO6.js → render-R7S7ZM3G.js} +12 -12
  95. package/dist/{rewrite-fallback-J2KE4JIC.js → rewrite-fallback-J3IBHAY2.js} +13 -13
  96. package/dist/seal-D6PQOQJI.js +16 -0
  97. package/dist/{setup-FAU3G7N3.js → setup-EFW6CWKF.js} +3 -3
  98. package/dist/{to-hwpx-B5CXJLNS.js → to-hwpx-6TQLW6WX.js} +4 -4
  99. package/dist/{to-hwpx-YLJE3AZW.js → to-hwpx-EPTNQA53.js} +7 -7
  100. package/dist/to-hwpx-X7YKAFO7.cjs +16 -0
  101. package/dist/{to-hwpx-KFQVO5YC.cjs.map → to-hwpx-X7YKAFO7.cjs.map} +1 -1
  102. package/dist/visual-RODVDMIJ.js +37 -0
  103. package/dist/{watch-VKZVO6GV.js → watch-ZQPN6IBT.js} +22 -22
  104. package/package.json +1 -1
  105. package/dist/chunk-7VVBR5WX.js.map +0 -1
  106. package/dist/chunk-AS6INVO3.js.map +0 -1
  107. package/dist/chunk-HDP2NFYZ.js.map +0 -1
  108. package/dist/chunk-SXULSPB6.cjs.map +0 -1
  109. package/dist/chunk-YN3C6T5M.cjs.map +0 -1
  110. package/dist/chunk-YSRLHL2J.js.map +0 -1
  111. package/dist/chunks-IBZZKRII.js +0 -11
  112. package/dist/generator-5QCCBJM6.js +0 -10
  113. package/dist/generator-BIEVUOPW.cjs +0 -11
  114. package/dist/generator-S373GIY7.js +0 -17
  115. package/dist/memo-NMEJZR24.js +0 -17
  116. package/dist/pdf-ocr-TUCEX4AY.cjs +0 -42
  117. package/dist/seal-OXEZMJL4.js +0 -16
  118. package/dist/to-hwpx-KFQVO5YC.cjs +0 -16
  119. package/dist/visual-GJLFH23Q.js +0 -37
  120. /package/dist/{-H334XSXO.js.map → -U63KR7FM.js.map} +0 -0
  121. /package/dist/{chunk-WXTEM53O.js.map → chunk-3DV5MIZK.js.map} +0 -0
  122. /package/dist/{chunk-6ZYOH3TZ.js.map → chunk-3JKPMYNQ.js.map} +0 -0
  123. /package/dist/{chunk-4Y5KRSHV.js.map → chunk-56HJNAU2.js.map} +0 -0
  124. /package/dist/{chunk-QR5EL3EF.js.map → chunk-5IEBL77T.js.map} +0 -0
  125. /package/dist/{chunk-HD6RQDGW.js.map → chunk-7D7CLX3U.js.map} +0 -0
  126. /package/dist/{chunk-2FDWBF47.js.map → chunk-AJAVVV7C.js.map} +0 -0
  127. /package/dist/{chunk-FQMLFAEN.js.map → chunk-AUSFVOEA.js.map} +0 -0
  128. /package/dist/{chunk-2TJ4E6MT.js.map → chunk-B3BUBTAB.js.map} +0 -0
  129. /package/dist/{chunk-NYQ6HNLA.js.map → chunk-BCRSFFTV.js.map} +0 -0
  130. /package/dist/{chunk-AMLNYJWV.js.map → chunk-BHL5HQNO.js.map} +0 -0
  131. /package/dist/{chunk-YEKQTHWN.js.map → chunk-BM4NQPJ7.js.map} +0 -0
  132. /package/dist/{chunk-IV6GW3K7.js.map → chunk-DLYJKFRY.js.map} +0 -0
  133. /package/dist/{chunk-TRVRIIER.js.map → chunk-E6OSXYA4.js.map} +0 -0
  134. /package/dist/{chunk-C2TMQUP4.js.map → chunk-FZRETZG3.js.map} +0 -0
  135. /package/dist/{chunk-PSB3XI2U.js.map → chunk-H6YKDFKG.js.map} +0 -0
  136. /package/dist/{chunk-RUCMKRDE.js.map → chunk-HHORHT5O.js.map} +0 -0
  137. /package/dist/{chunk-JI3WWHN2.js.map → chunk-HMTXDJZA.js.map} +0 -0
  138. /package/dist/{chunk-B3GHP32M.js.map → chunk-HVVPLWQD.js.map} +0 -0
  139. /package/dist/{chunk-3EBWTFBT.js.map → chunk-JKBJDB6X.js.map} +0 -0
  140. /package/dist/{chunk-7W6G4EC7.js.map → chunk-KXTTQ3RN.js.map} +0 -0
  141. /package/dist/{chunk-NJ2BJDHJ.js.map → chunk-MKJRT3PP.js.map} +0 -0
  142. /package/dist/{chunk-2KHZVNCS.js.map → chunk-MVLVCUBP.js.map} +0 -0
  143. /package/dist/{chunk-WF2GLWPA.js.map → chunk-MXCODLV5.js.map} +0 -0
  144. /package/dist/{chunk-UZTGIVEH.js.map → chunk-NKWF62JV.js.map} +0 -0
  145. /package/dist/{chunk-ABJ5DR2C.js.map → chunk-TJYUA2VR.js.map} +0 -0
  146. /package/dist/{chunk-XCRE5EMS.js.map → chunk-U453MJJB.js.map} +0 -0
  147. /package/dist/{chunk-RFSKHVLF.js.map → chunk-U4MF5C62.js.map} +0 -0
  148. /package/dist/{chunk-GRY6ITVN.js.map → chunk-W7BLAMBO.js.map} +0 -0
  149. /package/dist/{chunk-UETXNBIQ.js.map → chunk-WHWBBUSD.js.map} +0 -0
  150. /package/dist/{chunk-6M2Z6QDD.js.map → chunk-WK3QLJCE.js.map} +0 -0
  151. /package/dist/{chunk-WLBPDYAT.js.map → chunk-YOMV4HR6.js.map} +0 -0
  152. /package/dist/{chunks-IBZZKRII.js.map → chunks-LIB2Y6AD.js.map} +0 -0
  153. /package/dist/{formula-DLJ44T7B.js.map → formula-C46F5MG6.js.map} +0 -0
  154. /package/dist/{formula-2FOYPHV2.js.map → formula-FBBDRGK6.js.map} +0 -0
  155. /package/dist/{generator-5QCCBJM6.js.map → generator-BNV7GC2V.js.map} +0 -0
  156. /package/dist/{generator-S373GIY7.js.map → generator-CKRACBBG.js.map} +0 -0
  157. /package/dist/{hancom-B5LZPM5Y.js.map → hancom-P2ULOGNX.js.map} +0 -0
  158. /package/dist/{hancom-W6XQOGQY.js.map → hancom-WBVEG72Q.js.map} +0 -0
  159. /package/dist/{image-ocr-BKFZMHFE.js.map → image-ocr-7HH262GO.js.map} +0 -0
  160. /package/dist/{image-ocr-XRXLPEBP.js.map → image-ocr-G5T3YPM5.js.map} +0 -0
  161. /package/dist/{memo-NMEJZR24.js.map → memo-CBYIVGEA.js.map} +0 -0
  162. /package/dist/{model-bundle-R3AIXPVX.js.map → model-bundle-APD72FGN.js.map} +0 -0
  163. /package/dist/{models-BLHI4JAU.js.map → models-RK4ENUTB.js.map} +0 -0
  164. /package/dist/{parse-worker-v2-IB3KIORL.js.map → parse-worker-v2-TSULPUIC.js.map} +0 -0
  165. /package/dist/{parser-QCPSCSGJ.js.map → parser-55MAW7G3.js.map} +0 -0
  166. /package/dist/{parser-QR2TG3WE.js.map → parser-VBQTQ6K6.js.map} +0 -0
  167. /package/dist/{pdf-ocr-6PZ66I7G.js.map → pdf-ocr-6AAMBNUY.js.map} +0 -0
  168. /package/dist/{pdf-ocr-TGXEFZB5.js.map → pdf-ocr-YSEEZMJI.js.map} +0 -0
  169. /package/dist/{profile-io-QL4XZ34F.js.map → profile-io-DSBGIVPH.js.map} +0 -0
  170. /package/dist/{rasterize-PUG2V436.js.map → rasterize-46HYG3R6.js.map} +0 -0
  171. /package/dist/{redact-doc-XDMXMF3A.js.map → redact-doc-GN673LJP.js.map} +0 -0
  172. /package/dist/{render-IHE7XBO6.js.map → render-R7S7ZM3G.js.map} +0 -0
  173. /package/dist/{rewrite-fallback-J2KE4JIC.js.map → rewrite-fallback-J3IBHAY2.js.map} +0 -0
  174. /package/dist/{seal-OXEZMJL4.js.map → seal-D6PQOQJI.js.map} +0 -0
  175. /package/dist/{setup-FAU3G7N3.js.map → setup-EFW6CWKF.js.map} +0 -0
  176. /package/dist/{to-hwpx-B5CXJLNS.js.map → to-hwpx-6TQLW6WX.js.map} +0 -0
  177. /package/dist/{to-hwpx-YLJE3AZW.js.map → to-hwpx-EPTNQA53.js.map} +0 -0
  178. /package/dist/{visual-GJLFH23Q.js.map → visual-RODVDMIJ.js.map} +0 -0
  179. /package/dist/{watch-VKZVO6GV.js.map → watch-ZQPN6IBT.js.map} +0 -0
@@ -36,7 +36,7 @@
36
36
 
37
37
 
38
38
 
39
- var _chunkSXULSPB6cjs = require('./chunk-SXULSPB6.cjs');
39
+ var _chunkASS2MVTLcjs = require('./chunk-ASS2MVTL.cjs');
40
40
 
41
41
 
42
42
  var _chunkMMK32GPDcjs = require('./chunk-MMK32GPD.cjs');
@@ -46,7 +46,7 @@ var _chunkTK3FDAEEcjs = require('./chunk-TK3FDAEE.cjs');
46
46
 
47
47
 
48
48
 
49
- var _chunkZGYKWZJScjs = require('./chunk-ZGYKWZJS.cjs');
49
+ var _chunkB773KHROcjs = require('./chunk-B773KHRO.cjs');
50
50
 
51
51
  // src/ocr/ocr-stacked-rows.ts
52
52
  var NUMERIC = /^[-+−△▲▽▼]?[\d.,]+[%p]?$|^[-–—·∼~]$|^\([-+−△▲▽▼]?[\d.,]+%?\)$/;
@@ -77,7 +77,10 @@ function splitTable(t) {
77
77
  for (let r = 0; r < t.rows; r++) {
78
78
  const row = _nullishCoalesce(t.cells[r], () => ( []));
79
79
  const anchors = rowAnchors(t, r, cover[r]);
80
- const lines = anchors.map((a) => a.cell.text.split("\n").map((s) => s.trim()).filter(Boolean));
80
+ const lines = anchors.map((a) => {
81
+ const ls = a.cell.text.split("\n").map((s) => s.trim()).filter(Boolean);
82
+ return (_nullishCoalesce(a.cell.rowSpan, () => ( 1))) > 1 && ls.length > 1 && ls.every((l) => !NUMERIC.test(l.replace(/\s+/g, ""))) ? [ls.join("\n")] : ls;
83
+ });
81
84
  const counts = /* @__PURE__ */ new Map();
82
85
  for (const ls of lines) if (ls.length >= 2) counts.set(ls.length, (_nullishCoalesce(counts.get(ls.length), () => ( 0))) + 1);
83
86
  const [k, n] = _nullishCoalesce([...counts].sort((a, b) => b[1] - a[1])[0], () => ( [0, 0]));
@@ -157,6 +160,109 @@ function unframeOcrLayoutTables(blocks, pageHeight) {
157
160
  return out;
158
161
  }
159
162
 
163
+ // src/ocr/ocr-name-value-columns.ts
164
+ var NAME_VALUE = /^([^\d]*?)\s*(\d[\d,.]*\d|\d)([^\d\n]{0,2})(?:\n([^\d]*))?$/;
165
+ function nameValue(text) {
166
+ const m = NAME_VALUE.exec(text.trim());
167
+ if (!m) return null;
168
+ const name = [m[1], _nullishCoalesce(m[4], () => ( ""))].map((s) => s.replace(/\s+/g, " ").trim()).filter(Boolean).join(" ");
169
+ if ((_nullishCoalesce(name.match(/[가-힣A-Za-z]/g), () => ( []))).length < 2) return null;
170
+ return { name, value: (m[2] + m[3]).trim() };
171
+ }
172
+ function owners(t) {
173
+ const own = Array.from({ length: t.rows }, () => Array(t.cols));
174
+ for (let r = 0; r < t.rows; r++) for (let c = 0; c < t.cols; c++) {
175
+ if (own[r][c]) continue;
176
+ const cell = t.cells[r][c];
177
+ for (let i = r; i < Math.min(t.rows, r + Math.max(1, _nullishCoalesce(cell.rowSpan, () => ( 1)))); i++)
178
+ for (let j = c; j < Math.min(t.cols, c + Math.max(1, _nullishCoalesce(cell.colSpan, () => ( 1)))); j++) own[i][j] ??= cell;
179
+ }
180
+ return own;
181
+ }
182
+ function headerCuts(text) {
183
+ const out = [];
184
+ for (const m of text.matchAll(/\s+/g)) {
185
+ const l = text.slice(0, m.index).replace(/\s+/g, ""), r = text.slice(m.index + m[0].length).replace(/\s+/g, "");
186
+ if (l.length >= 2 && r.length >= 2) out.push([l, r]);
187
+ }
188
+ return out;
189
+ }
190
+ function cutAt(text, left) {
191
+ let n = 0;
192
+ for (let i = 0; i < text.length; i++) {
193
+ if (!/\s/.test(text[i])) n++;
194
+ if (n === left.length) return [text.slice(0, i + 1).trim(), text.slice(i + 1).trim()];
195
+ }
196
+ return null;
197
+ }
198
+ function splitTable2(t) {
199
+ if (t.cells.length !== t.rows || t.cells.some((row) => row.length !== t.cols)) return false;
200
+ const own = owners(t);
201
+ const anchor = (r, c) => own[r][c] === t.cells[r][c] ? t.cells[r][c] : null;
202
+ const targets = [];
203
+ for (let c = 0; c < t.cols; c++) {
204
+ let filled = 0, hits = 0, grouped = 0, first = -1;
205
+ for (let r = 0; r < t.rows; r++) {
206
+ const cell = anchor(r, c);
207
+ if (!cell || (_nullishCoalesce(cell.colSpan, () => ( 1))) !== 1 || _optionalChain([cell, 'access', _4 => _4.blocks, 'optionalAccess', _5 => _5.length]) || !cell.text.trim()) continue;
208
+ const nv = nameValue(cell.text);
209
+ if (nv) {
210
+ hits++;
211
+ if (first < 0) first = r;
212
+ if (/,\d{2}|\.\d/.test(nv.value)) grouped++;
213
+ }
214
+ if (first >= 0) filled++;
215
+ }
216
+ if (hits >= 5 && hits >= filled * 0.8 && grouped >= 2) targets.push({ c, first });
217
+ }
218
+ if (!targets.length) return false;
219
+ const starts = /* @__PURE__ */ new Map();
220
+ for (const { first } of targets) starts.set(first, (_nullishCoalesce(starts.get(first), () => ( 0))) + 1);
221
+ const start = [...starts].sort((a, b) => b[1] - a[1] || a[0] - b[0])[0][0];
222
+ for (const tg of targets) if (tg.first > start) tg.first = start;
223
+ const heads = targets.map(({ c, first }) => {
224
+ const cell = first > 0 ? anchor(first - 1, c) : null;
225
+ return cell && (_nullishCoalesce(cell.colSpan, () => ( 1))) === 1 && (_nullishCoalesce(cell.rowSpan, () => ( 1))) === 1 && cell.text.trim() ? cell : null;
226
+ });
227
+ const votes = /* @__PURE__ */ new Map();
228
+ for (const h of heads) if (h) for (const [l, r] of headerCuts(h.text.trim())) votes.set(`${l}\0${r}`, (_nullishCoalesce(votes.get(`${l}\0${r}`), () => ( 0))) + 1);
229
+ const [best, second] = [...votes].sort((a, b) => b[1] - a[1]);
230
+ const cut = best && (!second || best[1] > second[1]) ? best[0].split("\0") : null;
231
+ for (const [k, { c, first }] of [...targets.entries()].reverse()) {
232
+ const grown = /* @__PURE__ */ new Set();
233
+ for (let r = 0; r < t.rows; r++) {
234
+ const cell = anchor(r, c);
235
+ let right = { text: "", colSpan: 1, rowSpan: 1 };
236
+ if (cell && (_nullishCoalesce(cell.colSpan, () => ( 1))) === 1 && !_optionalChain([cell, 'access', _6 => _6.blocks, 'optionalAccess', _7 => _7.length])) {
237
+ const text = cell.text.trim();
238
+ const nv = r >= first ? nameValue(text) : null;
239
+ const head = r === first - 1 && heads[k] === cell && cut && text.replace(/\s+/g, "") === cut.join("") ? cutAt(text, cut[0]) : null;
240
+ if (nv) {
241
+ cell.text = nv.name;
242
+ right = { ...cell, text: nv.value };
243
+ } else if (head) {
244
+ cell.text = head[0];
245
+ right = { ...cell, text: head[1] };
246
+ } else if (r >= first && text && /^[\d,.\s%()+-]+$/.test(text)) {
247
+ right = { ...cell, text };
248
+ cell.text = "";
249
+ } else cell.colSpan = 2;
250
+ grown.add(cell);
251
+ } else if (!grown.has(own[r][c])) {
252
+ own[r][c].colSpan = Math.max(1, _nullishCoalesce(own[r][c].colSpan, () => ( 1))) + 1;
253
+ grown.add(own[r][c]);
254
+ }
255
+ t.cells[r].splice(c + 1, 0, right);
256
+ }
257
+ t.cols++;
258
+ }
259
+ return true;
260
+ }
261
+ function splitOcrNameValueColumns(blocks) {
262
+ for (const b of blocks) if (b.type === "table" && b.table) splitTable2(b.table);
263
+ return blocks;
264
+ }
265
+
160
266
  // src/ocr/ruling-lines.ts
161
267
  var INK_LUMA_MAX = 205;
162
268
  var MIN_LINE_LENGTH_PT = 20;
@@ -517,8 +623,8 @@ var INKLESS_DELTA = 32;
517
623
  function ringAsks(rgba, pageW, box, text, steps, stepPx) {
518
624
  const chars = [...text];
519
625
  if (chars.length !== steps.length || !/[가-힣]/.test(text)) return [];
520
- const gray = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, pageW, box);
521
- const rings = _chunkSXULSPB6cjs.ringBoxes.call(void 0, gray, box.w, box.h, _chunkSXULSPB6cjs.inkStats.call(void 0, gray));
626
+ const gray = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, pageW, box);
627
+ const rings = _chunkASS2MVTLcjs.ringBoxes.call(void 0, gray, box.w, box.h, _chunkASS2MVTLcjs.inkStats.call(void 0, gray));
522
628
  const owner = ringOwners(chars, (i) => (steps[i] + 0.5) * stepPx, rings);
523
629
  return rings.flatMap((r, k) => {
524
630
  const at = owner.indexOf(k);
@@ -558,8 +664,8 @@ function ringGlyph(read, jamo = null, confidence = 1) {
558
664
  function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings = []) {
559
665
  const chars = [...text];
560
666
  if (chars.length !== steps.length) return text;
561
- const gray = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, pageW, box);
562
- const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink: _chunkSXULSPB6cjs.inkStats.call(void 0, gray) };
667
+ const gray = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, pageW, box);
668
+ const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink: _chunkASS2MVTLcjs.inkStats.call(void 0, gray) };
563
669
  if (/[[\]]/.test(text)) brackets(c);
564
670
  if (text.includes("'")) cornerQuotes(c);
565
671
  if (/['"]/.test(text)) quotes(c);
@@ -589,7 +695,7 @@ function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings =
589
695
  function trimInklessEnds(rgba, pageW, box, text, steps, stepPx) {
590
696
  const chars = [...text], { w, h } = box;
591
697
  if (chars.length !== steps.length || steps.some((s) => (s + 0.5) * stepPx > w + stepPx)) return { text, steps };
592
- const gray = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, pageW, box);
698
+ const gray = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, pageW, box);
593
699
  const hist = new Uint32Array(256);
594
700
  for (const v of gray) hist[v]++;
595
701
  let bg = 0;
@@ -620,8 +726,8 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
620
726
  continue;
621
727
  }
622
728
  if (open > 0) {
623
- const f = _chunkSXULSPB6cjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
624
- if (f && _chunkSXULSPB6cjs.bracketShape.call(void 0, f, true) === "\u300D") {
729
+ const f = _chunkASS2MVTLcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
730
+ if (f && _chunkASS2MVTLcjs.bracketShape.call(void 0, f, true) === "\u300D") {
625
731
  chars[i] = "\u300D";
626
732
  open--;
627
733
  }
@@ -631,12 +737,12 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
631
737
  function cornerQuotes({ chars, cx, gray, w, h, ink }) {
632
738
  for (let i = 0; i < chars.length; i++) {
633
739
  if (chars[i] !== "'" || !/^[가-힣]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
634
- const f = _chunkSXULSPB6cjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
635
- if (!f || f.ch < f.charH * 0.45 || _chunkSXULSPB6cjs.bracketShape.call(void 0, f, false) !== "\u300C") continue;
740
+ const f = _chunkASS2MVTLcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
741
+ if (!f || f.ch < f.charH * 0.45 || _chunkASS2MVTLcjs.bracketShape.call(void 0, f, false) !== "\u300C") continue;
636
742
  const rest = chars.slice(i + 1), end = rest.findIndex((c) => c === "'" || c === "\u300D" || c === ",");
637
743
  const pair = end >= 0 && rest[end] !== "'" && (rest[end] === "\u300D" || (() => {
638
- const g = _chunkSXULSPB6cjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i + 1 + end));
639
- return !!g && _chunkSXULSPB6cjs.bracketShape.call(void 0, g, true) === "\u300D";
744
+ const g = _chunkASS2MVTLcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i + 1 + end));
745
+ return !!g && _chunkASS2MVTLcjs.bracketShape.call(void 0, g, true) === "\u300D";
640
746
  })());
641
747
  if (pair) chars[i] = "\u300C";
642
748
  }
@@ -644,8 +750,8 @@ function cornerQuotes({ chars, cx, gray, w, h, ink }) {
644
750
  function brackets({ chars, cx, gray, w, h, ink }) {
645
751
  const shape = chars.map((c, i) => {
646
752
  if (c !== "[" && c !== "]") return null;
647
- const f = _chunkSXULSPB6cjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
648
- return f && _chunkSXULSPB6cjs.bracketShape.call(void 0, f, c === "]");
753
+ const f = _chunkASS2MVTLcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
754
+ return f && _chunkASS2MVTLcjs.bracketShape.call(void 0, f, c === "]");
649
755
  });
650
756
  for (let i = 0; i < chars.length; i++) {
651
757
  if (chars[i] !== "[") continue;
@@ -677,7 +783,7 @@ function quotes({ chars, cx, gray, w, h, ink }) {
677
783
  continue;
678
784
  }
679
785
  if (!year(i) && !single[kind]) continue;
680
- const r = _chunkSXULSPB6cjs.quoteHead.call(void 0, gray, w, h, ink, cx(i));
786
+ const r = _chunkASS2MVTLcjs.quoteHead.call(void 0, gray, w, h, ink, cx(i));
681
787
  if (r !== null && r >= 0.47) {
682
788
  chars[i] = kind === "'" ? "\u2018" : "\u201C";
683
789
  open[kind] = true;
@@ -688,7 +794,7 @@ function dashes({ chars, cx, gray, w, h, ink }) {
688
794
  const head = chars.findIndex((c) => c.trim()), letters = chars.some((c) => /[가-힣A-Za-z]/.test(c));
689
795
  for (let i = 0; i < chars.length; i++) {
690
796
  if (!/^[-\u2013\u2014]$/.test(chars[i])) continue;
691
- const r = _chunkSXULSPB6cjs.dashRatio.call(void 0, gray, w, h, ink, cx(i));
797
+ const r = _chunkASS2MVTLcjs.dashRatio.call(void 0, gray, w, h, ink, cx(i));
692
798
  if (r === null) continue;
693
799
  if (r < 0.65) chars[i] = "-";
694
800
  else if (r > 0.75 && i === head && letters) chars[i] = "\u2014";
@@ -698,7 +804,7 @@ function circled({ chars, cx, gray, w, h, ink }) {
698
804
  const alone = (re, i) => re.test(chars[i]) && !re.test(_nullishCoalesce(chars[i - 1], () => ( ""))) && !re.test(_nullishCoalesce(chars[i + 1], () => ( "")));
699
805
  const at = chars.flatMap((_, i) => alone(/^\d$/, i) && chars[i] !== "0" || alone(/^[ㄱ-ㅎ]$/, i) || alone(/^[A-Za-z]$/, i) && /[a-zCSUVWXZ]/.test(chars[i]) ? [i] : []);
700
806
  if (!at.length) return;
701
- const hit = _chunkSXULSPB6cjs.circledAt.call(void 0, gray, w, h, ink, at.map(cx));
807
+ const hit = _chunkASS2MVTLcjs.circledAt.call(void 0, gray, w, h, ink, at.map(cx));
702
808
  const JAMO = "\u3131\u3134\u3137\u3139\u3141\u3142\u3145\u3147\u3148\u314A\u314B\u314C\u314D\u314E";
703
809
  at.forEach((i, k) => {
704
810
  if (!hit[k]) return;
@@ -711,16 +817,16 @@ function stars({ chars, cx, gray, w, h, ink }) {
711
817
  if (chars[i] !== "*" || chars[i - 1] === "*") continue;
712
818
  let e = i;
713
819
  while (chars[e + 1] === "*") e++;
714
- const n = _chunkSXULSPB6cjs.starRun.call(void 0, gray, w, h, ink, cx(i));
820
+ const n = _chunkASS2MVTLcjs.starRun.call(void 0, gray, w, h, ink, cx(i));
715
821
  if (n > e - i + 1 && n <= 4) chars[e] += "*".repeat(n - (e - i + 1));
716
822
  i = e;
717
823
  }
718
824
  }
719
825
  function discs({ chars, cx, gray, w, h, ink }) {
720
- for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) && _chunkSXULSPB6cjs.discAt.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u25CF";
826
+ for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) && _chunkASS2MVTLcjs.discAt.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u25CF";
721
827
  }
722
828
  function gaps({ chars, cx, gray, w, h, ink }) {
723
- const { glyphs, bandH } = _chunkSXULSPB6cjs.gapGlyphs.call(void 0, gray, w, h, ink);
829
+ const { glyphs, bandH } = _chunkASS2MVTLcjs.gapGlyphs.call(void 0, gray, w, h, ink);
724
830
  if (!glyphs.length) return;
725
831
  const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
726
832
  if (!live.length) return;
@@ -733,7 +839,7 @@ function gaps({ chars, cx, gray, w, h, ink }) {
733
839
  if (tail >= 1 && tail <= 3 && tail < live.length) {
734
840
  const prev = live[live.length - 1 - tail], num = live[live.length - tail];
735
841
  const run = loose.filter((g) => (g.x0 + g.x1) / 2 > cx(prev) && (g.x0 + g.x1) / 2 < cx(num));
736
- const mark = _optionalChain([run, 'access', _4 => _4[0], 'optionalAccess', _5 => _5.mark, 'access', _6 => _6[0]]);
842
+ const mark = _optionalChain([run, 'access', _8 => _8[0], 'optionalAccess', _9 => _9.mark, 'access', _10 => _10[0]]);
737
843
  if (run.length >= 2 && run.length <= 3 && run.every((g) => g.mark[0] === mark) && /^[가-힣?)]$/.test(chars[prev]) && !glyphs.some((g) => !run.includes(g) && (g.x0 + g.x1) / 2 > cx(prev) && (g.x0 + g.x1) / 2 < cx(num)))
738
844
  chars[prev] += " " + mark.repeat(run.length) + " ";
739
845
  }
@@ -791,18 +897,18 @@ function ring({ chars, cx, gray, w, h, ink }) {
791
897
  const rest = chars.slice(k + 1).join("").trimStart();
792
898
  const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
793
899
  if (live.length <= 3 && live.every((i) => /^[Oo]$/.test(chars[i]))) {
794
- if (_optionalChain([_chunkSXULSPB6cjs.leadingBullet.call(void 0, gray, w, h, ink, cx(live[0])), 'optionalAccess', _7 => _7.mark]) === "\u25CE") return false;
795
- if (!live.every((i) => _chunkSXULSPB6cjs.ringBullet.call(void 0, gray, w, h, ink, cx(i)) === "\u25CB")) return false;
900
+ if (_optionalChain([_chunkASS2MVTLcjs.leadingBullet.call(void 0, gray, w, h, ink, cx(live[0])), 'optionalAccess', _11 => _11.mark]) === "\u25CE") return false;
901
+ if (!live.every((i) => _chunkASS2MVTLcjs.ringBullet.call(void 0, gray, w, h, ink, cx(i)) === "\u25CB")) return false;
796
902
  for (const i of live) chars[i] = "\u25CB";
797
903
  return true;
798
904
  }
799
905
  if (/^[A-Z]{2,}/.test(rest) && /^[Oo0]$/.test(chars[k])) {
800
- if (_chunkSXULSPB6cjs.ringBullet.call(void 0, gray, w, h, ink, cx(k)) !== "\u25CB") return false;
906
+ if (_chunkASS2MVTLcjs.ringBullet.call(void 0, gray, w, h, ink, cx(k)) !== "\u25CB") return false;
801
907
  chars[k] = chars[k + 1] === " " ? "\u25CB" : "\u25CB ";
802
908
  return true;
803
909
  }
804
910
  if (!/^[(\[「【<]?\d*[가-힣]/.test(rest)) return false;
805
- const r = _chunkSXULSPB6cjs.ringBullet.call(void 0, gray, w, h, ink, cx(k));
911
+ const r = _chunkASS2MVTLcjs.ringBullet.call(void 0, gray, w, h, ink, cx(k));
806
912
  if (/^[Cc]$/.test(chars[k]) && r !== "\u25CB") return false;
807
913
  if (r) chars[k] = r;
808
914
  return r !== null;
@@ -819,7 +925,7 @@ function parallels({ chars, cx, gray, w, h, ink }) {
819
925
  let p = s - 1, q = e + 1;
820
926
  while (p >= 0 && !chars[p].trim()) p--;
821
927
  while (q < chars.length && !chars[q].trim()) q++;
822
- if (_chunkSXULSPB6cjs.slantedPair.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity)) {
928
+ if (_chunkASS2MVTLcjs.slantedPair.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity)) {
823
929
  chars[s] = "\u2225";
824
930
  for (let k = s + 1; k <= e; k++) chars[k] = "";
825
931
  }
@@ -831,7 +937,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
831
937
  const ROMAN = /^[IⅠ-Ⅲ]$/, LATIN = /[A-Za-z]$/;
832
938
  for (let i = 0; i < chars.length; i++) {
833
939
  if (chars[i] !== "1" || /[\dA-Za-z]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || /^[\dA-Za-z,]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
834
- if (_chunkSXULSPB6cjs.serifOne.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u2160";
940
+ if (_chunkASS2MVTLcjs.serifOne.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u2160";
835
941
  }
836
942
  for (let i = 0; i < chars.length; i++) {
837
943
  const hangul = /^[파피]$/.test(chars[i]);
@@ -841,13 +947,13 @@ function roman({ chars, cx, gray, w, h, ink }) {
841
947
  while (q < chars.length && !chars[q].trim()) q++;
842
948
  const glued = hangul ? chars[p] === "(" && chars[q] === "-" : /[가-힣]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || (_nullishCoalesce(chars[i + 1], () => ( ""))) === "." || chars[p] === "-" && chars[q] === "-";
843
949
  if (!glued) continue;
844
- const n = _chunkSXULSPB6cjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
950
+ const n = _chunkASS2MVTLcjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
845
951
  if (n) chars[i] = String.fromCharCode(8543 + n);
846
952
  }
847
953
  const inRoman = (i) => ROMAN.test(chars[i]) || chars[i] === "1" && (ROMAN.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || ROMAN.test(_nullishCoalesce(chars[i + 1], () => ( ""))));
848
954
  const k = chars.findIndex((c) => c.trim());
849
955
  if (chars[k] === "." && chars.slice(k + 1).some((c) => /[가-힣A-Za-z0-9]/.test(c))) {
850
- const n = _chunkSXULSPB6cjs.romanStems.call(void 0, gray, w, h, ink, -Infinity, cx(k));
956
+ const n = _chunkASS2MVTLcjs.romanStems.call(void 0, gray, w, h, ink, -Infinity, cx(k));
851
957
  if (n) chars[k] = String.fromCharCode(8543 + n) + chars[k];
852
958
  }
853
959
  for (let s = 0; s < chars.length; ) {
@@ -865,7 +971,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
865
971
  let p = s - 1, q = e;
866
972
  while (p >= 0 && !chars[p].trim()) p--;
867
973
  while (q < chars.length && !chars[q].trim()) q++;
868
- const n = _chunkSXULSPB6cjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
974
+ const n = _chunkASS2MVTLcjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
869
975
  const canon = n ? [["\u2160", "I"], ["\u2161", "II"], ["\u2162", "III"]][n - 1] : null;
870
976
  if (canon && !canon.includes(tok)) {
871
977
  chars[s] = canon[0];
@@ -960,7 +1066,7 @@ function joinLeaderItems(items, ends) {
960
1066
  for (const o of items) if (!gone.has(o) && junk(o) && sameLine(o, left) && o.x + o.w / 2 >= left.x + left.w - left.h && o.x + o.w / 2 <= right.x + right.h) gone.add(o);
961
1067
  };
962
1068
  for (const it of [...items].sort((a, b) => b.x - a.x)) {
963
- if (gone.has(it) || !_optionalChain([ends, 'access', _8 => _8.get, 'call', _9 => _9(it), 'optionalAccess', _10 => _10.lead])) continue;
1069
+ if (gone.has(it) || !_optionalChain([ends, 'access', _12 => _12.get, 'call', _13 => _13(it), 'optionalAccess', _14 => _14.lead])) continue;
964
1070
  const left = neighbor(it, true);
965
1071
  if (left) {
966
1072
  dropJunkBetween(left, it);
@@ -968,7 +1074,7 @@ function joinLeaderItems(items, ends) {
968
1074
  }
969
1075
  }
970
1076
  for (const it of [...items].sort((a, b) => a.x - b.x)) {
971
- if (gone.has(it) || !_optionalChain([ends, 'access', _11 => _11.get, 'call', _12 => _12(it), 'optionalAccess', _13 => _13.trail])) continue;
1077
+ if (gone.has(it) || !_optionalChain([ends, 'access', _15 => _15.get, 'call', _16 => _16(it), 'optionalAccess', _17 => _17.trail])) continue;
972
1078
  const right = neighbor(it, false);
973
1079
  if (right) {
974
1080
  dropJunkBetween(it, right);
@@ -1169,7 +1275,7 @@ function rowHeadDashes(rgba, width, items) {
1169
1275
  if (done.has(it) || it.h < 12) continue;
1170
1276
  const row = items.filter((o) => Math.min(o.y + o.h, it.y + it.h) - Math.max(o.y, it.y) >= Math.min(o.h, it.h) * 0.6);
1171
1277
  for (const o of row) done.add(o);
1172
- if (row.reduce((k, o) => k + (_nullishCoalesce(_optionalChain([o, 'access', _14 => _14.text, 'access', _15 => _15.match, 'call', _16 => _16(/[가-힣]/g), 'optionalAccess', _17 => _17.length]), () => ( 0))), 0) < 2) continue;
1278
+ if (row.reduce((k, o) => k + (_nullishCoalesce(_optionalChain([o, 'access', _18 => _18.text, 'access', _19 => _19.match, 'call', _20 => _20(/[가-힣]/g), 'optionalAccess', _21 => _21.length]), () => ( 0))), 0) < 2) continue;
1173
1279
  const first = row.reduce((m, o) => o.x < m.x ? o : m);
1174
1280
  if (!/^[가-힣]/.test(first.text)) continue;
1175
1281
  if (row.filter((o) => /\d/.test(o.text)).length >= 2) continue;
@@ -1214,7 +1320,7 @@ function rowTailBoxes(rgba, width, items) {
1214
1320
  if (done.has(it) || it.h < 12) continue;
1215
1321
  const row = items.filter((o) => Math.min(o.y + o.h, it.y + it.h) - Math.max(o.y, it.y) >= Math.min(o.h, it.h) * 0.6);
1216
1322
  for (const o of row) done.add(o);
1217
- if (row.reduce((k, o) => k + (_nullishCoalesce(_optionalChain([o, 'access', _18 => _18.text, 'access', _19 => _19.match, 'call', _20 => _20(/[가-힣]/g), 'optionalAccess', _21 => _21.length]), () => ( 0))), 0) < 2) continue;
1323
+ if (row.reduce((k, o) => k + (_nullishCoalesce(_optionalChain([o, 'access', _22 => _22.text, 'access', _23 => _23.match, 'call', _24 => _24(/[가-힣]/g), 'optionalAccess', _25 => _25.length]), () => ( 0))), 0) < 2) continue;
1218
1324
  const last = row.reduce((m, o) => o.x + o.w > m.x + m.w ? o : m);
1219
1325
  if (/\d$/.test(last.text.trim())) continue;
1220
1326
  const y0 = Math.min(...row.map((o) => o.y)), y1 = Math.max(...row.map((o) => o.y + o.h)), h = y1 - y0;
@@ -1263,8 +1369,8 @@ function joinGapLeaders(rgba, width, items) {
1263
1369
  if (g1 - g0 < h * 3) continue;
1264
1370
  const pad = Math.round(h * 0.25), y = Math.max(0, Math.min(left.y, num.y) - pad), x = Math.max(0, Math.round(g0 - h));
1265
1371
  const box = { x, y, w: Math.min(width, Math.round(g1 + h)) - x, h: Math.min(Math.floor(rgba.length / 4 / width), Math.max(left.y + left.h, num.y + num.h) + pad) - y };
1266
- const gray = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, width, box);
1267
- const runs = _chunkSXULSPB6cjs.leaderRuns.call(void 0, gray, box.w, box.h, _chunkSXULSPB6cjs.inkStats.call(void 0, gray), LEADER_MIN_DOTS);
1372
+ const gray = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, width, box);
1373
+ const runs = _chunkASS2MVTLcjs.leaderRuns.call(void 0, gray, box.w, box.h, _chunkASS2MVTLcjs.inkStats.call(void 0, gray), LEADER_MIN_DOTS);
1268
1374
  const cover = runs.reduce((k, [a, b]) => k + Math.max(0, Math.min(b, g1 - box.x) - Math.max(a, g0 - box.x)), 0);
1269
1375
  if (cover < (g1 - g0) * 0.6) continue;
1270
1376
  for (const o of items) if (junk(o) && sameLine(o, num) && o.x >= g0 - 2 && o.x + o.w <= g1 + 2) gone.add(o);
@@ -1291,7 +1397,7 @@ function rowHeadBoxes(rgba, width, items) {
1291
1397
  if (done.has(it) || it.h < 12) continue;
1292
1398
  const row = items.filter((o) => Math.min(o.y + o.h, it.y + it.h) - Math.max(o.y, it.y) >= Math.min(o.h, it.h) * 0.6);
1293
1399
  for (const o of row) done.add(o);
1294
- if (row.reduce((k, o) => k + (_nullishCoalesce(_optionalChain([o, 'access', _22 => _22.text, 'access', _23 => _23.match, 'call', _24 => _24(/[가-힣]/g), 'optionalAccess', _25 => _25.length]), () => ( 0))), 0) < 2) continue;
1400
+ if (row.reduce((k, o) => k + (_nullishCoalesce(_optionalChain([o, 'access', _26 => _26.text, 'access', _27 => _27.match, 'call', _28 => _28(/[가-힣]/g), 'optionalAccess', _29 => _29.length]), () => ( 0))), 0) < 2) continue;
1295
1401
  const first = row.reduce((m, o) => o.x < m.x ? o : m);
1296
1402
  if (!/^[가-힣\d]/.test(first.text)) continue;
1297
1403
  const hs = row.map((o) => o.h).sort((a, b) => a - b), h = hs[hs.length >> 1];
@@ -1457,7 +1563,7 @@ function closingParens(rgba, width, items) {
1457
1563
  };
1458
1564
  for (const it of items) {
1459
1565
  const t = it.text.replace(/\s+$/, "");
1460
- if ((_nullishCoalesce(_optionalChain([t, 'access', _26 => _26.match, 'call', _27 => _27(/\(/g), 'optionalAccess', _28 => _28.length]), () => ( 0))) <= (_nullishCoalesce(_optionalChain([t, 'access', _29 => _29.match, 'call', _30 => _30(/\)/g), 'optionalAccess', _31 => _31.length]), () => ( 0))) || !/\([^()]*$/.test(t)) continue;
1566
+ if ((_nullishCoalesce(_optionalChain([t, 'access', _30 => _30.match, 'call', _31 => _31(/\(/g), 'optionalAccess', _32 => _32.length]), () => ( 0))) <= (_nullishCoalesce(_optionalChain([t, 'access', _33 => _33.match, 'call', _34 => _34(/\)/g), 'optionalAccess', _35 => _35.length]), () => ( 0))) || !/\([^()]*$/.test(t)) continue;
1461
1567
  const x0 = it.x + it.w + 2;
1462
1568
  const next = items.filter((o) => o !== it && o.x >= x0 && o.y < it.y + it.h && o.y + o.h > it.y).reduce((m, o) => Math.min(m, o.x), Infinity);
1463
1569
  let x1 = Math.min(width, next, x0 + it.h * 16);
@@ -1531,7 +1637,7 @@ var OcrEngine = class _OcrEngine {
1531
1637
  this.ort = parts.ort;
1532
1638
  this.sharp = parts.sharp;
1533
1639
  }
1534
- static async create(models = _chunkSXULSPB6cjs.DEFAULT_OCR_MODELS) {
1640
+ static async create(models = _chunkASS2MVTLcjs.DEFAULT_OCR_MODELS) {
1535
1641
  _chunkTK3FDAEEcjs.disableOrtTelemetry.call(void 0, );
1536
1642
  const [ortMod, sharpModRaw] = await Promise.all([
1537
1643
  tryImport("onnxruntime-node", () => Promise.resolve().then(() => _interopRequireWildcard(require("onnxruntime-node")))),
@@ -1551,16 +1657,16 @@ var OcrEngine = class _OcrEngine {
1551
1657
  const local = (s) => "spec" in s ? Promise.resolve(null) : verifiedBytes(s);
1552
1658
  const [detBytes, recBytes, dictBytes] = await Promise.all([local(models.det), local(models.rec), local(models.dict)]);
1553
1659
  const session = (s, bytes) => bytes ? ortMod.InferenceSession.create(bytes, sessionOpts).catch(() => {
1554
- throw new (0, _chunkZGYKWZJScjs.KordocError)(`OCR \uBAA8\uB378\uC744 \uC5F4\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${_path.basename.call(void 0, _chunkSXULSPB6cjs.ocrSourcePath.call(void 0, s))} \u2014 ONNX \uBAA8\uB378\uC774 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB410\uC2B5\uB2C8\uB2E4`);
1555
- }) : ortMod.InferenceSession.create(_chunkSXULSPB6cjs.ocrSourcePath.call(void 0, s), sessionOpts);
1660
+ throw new (0, _chunkB773KHROcjs.KordocError)(`OCR \uBAA8\uB378\uC744 \uC5F4\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${_path.basename.call(void 0, _chunkASS2MVTLcjs.ocrSourcePath.call(void 0, s))} \u2014 ONNX \uBAA8\uB378\uC774 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB410\uC2B5\uB2C8\uB2E4`);
1661
+ }) : ortMod.InferenceSession.create(_chunkASS2MVTLcjs.ocrSourcePath.call(void 0, s), sessionOpts);
1556
1662
  const [det, rec, dictYml] = await Promise.all([
1557
1663
  session(models.det, detBytes),
1558
1664
  session(models.rec, recBytes),
1559
- dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0, _chunkSXULSPB6cjs.ocrSourcePath.call(void 0, models.dict), "utf-8")
1665
+ dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0, _chunkASS2MVTLcjs.ocrSourcePath.call(void 0, models.dict), "utf-8")
1560
1666
  ]);
1561
- const dict = _chunkSXULSPB6cjs.parseCharacterDict.call(void 0, dictYml);
1667
+ const dict = _chunkASS2MVTLcjs.parseCharacterDict.call(void 0, dictYml);
1562
1668
  if (dict.length === 0) {
1563
- throw "spec" in models.dict ? new Error("OCR \uC0AC\uC804 \uD30C\uC2F1 \uC2E4\uD328 \u2014 \uBAA8\uB378 \uCE90\uC2DC\uB97C \uC0AD\uC81C \uD6C4 \uC7AC\uB2E4\uC6B4\uB85C\uB4DC\uD558\uC138\uC694") : new (0, _chunkZGYKWZJScjs.KordocError)(`OCR \uC0AC\uC804 \uD30C\uC2F1 \uC2E4\uD328 \u2014 ${_path.basename.call(void 0, models.dict.file.path)} \uC5D0 PostProcess.character_dict \uBAA9\uB85D\uC774 \uC5C6\uC2B5\uB2C8\uB2E4`);
1669
+ throw "spec" in models.dict ? new Error("OCR \uC0AC\uC804 \uD30C\uC2F1 \uC2E4\uD328 \u2014 \uBAA8\uB378 \uCE90\uC2DC\uB97C \uC0AD\uC81C \uD6C4 \uC7AC\uB2E4\uC6B4\uB85C\uB4DC\uD558\uC138\uC694") : new (0, _chunkB773KHROcjs.KordocError)(`OCR \uC0AC\uC804 \uD30C\uC2F1 \uC2E4\uD328 \u2014 ${_path.basename.call(void 0, models.dict.file.path)} \uC5D0 PostProcess.character_dict \uBAA9\uB85D\uC774 \uC5C6\uC2B5\uB2C8\uB2E4`);
1564
1670
  }
1565
1671
  return new _OcrEngine({ det, rec, dict, ort: ortMod, sharp: sharpMod });
1566
1672
  }
@@ -1592,10 +1698,10 @@ var OcrEngine = class _OcrEngine {
1592
1698
  if (it.x - x < it.h * 0.8) return;
1593
1699
  if (items.some((o) => o !== it && o.x < it.x && o.x + o.w > x && o.y < it.y + it.h && o.y + o.h > it.y)) return;
1594
1700
  const box = { x, y: it.y, w: it.x + it.w - x, h: it.h };
1595
- const g = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, width, box);
1596
- const b = _chunkSXULSPB6cjs.leadingBullet.call(void 0, g, box.w, box.h, _chunkSXULSPB6cjs.inkStats.call(void 0, g), it.x - x, 1.05);
1597
- if (_optionalChain([b, 'optionalAccess', _32 => _32.mark]) !== "\u25A1" || b.covers) return;
1598
- const ink = _chunkSXULSPB6cjs.inkStats.call(void 0, g), on = (v) => ink.darkInk ? v <= ink.threshold : v > ink.threshold;
1701
+ const g = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, width, box);
1702
+ const b = _chunkASS2MVTLcjs.leadingBullet.call(void 0, g, box.w, box.h, _chunkASS2MVTLcjs.inkStats.call(void 0, g), it.x - x, 1.05);
1703
+ if (_optionalChain([b, 'optionalAccess', _36 => _36.mark]) !== "\u25A1" || b.covers) return;
1704
+ const ink = _chunkASS2MVTLcjs.inkStats.call(void 0, g), on = (v) => ink.darkInk ? v <= ink.threshold : v > ink.threshold;
1599
1705
  let left = 0;
1600
1706
  while (left < it.x - x && !Array.from({ length: box.h }, (_, y) => g[y * box.w + left]).some(on)) left++;
1601
1707
  it.text = "\u25A1 " + it.text;
@@ -1611,7 +1717,7 @@ var OcrEngine = class _OcrEngine {
1611
1717
  const sample = [...tall].sort((a, b) => b.h - a.h).slice(0, ORIENT_SAMPLE);
1612
1718
  const rots = [0, 90, 270];
1613
1719
  const probe = await this.recognizeJobs(rgba, width, sample.flatMap((box, group2) => rots.map((rot) => ({ box, rot, group: group2 }))), tuning.recBatch);
1614
- const mean = (k) => sample.reduce((sum, _, i) => sum + (_nullishCoalesce(_optionalChain([probe, 'access', _33 => _33[i * rots.length + k], 'optionalAccess', _34 => _34.confidence]), () => ( 0))), 0) / sample.length;
1720
+ const mean = (k) => sample.reduce((sum, _, i) => sum + (_nullishCoalesce(_optionalChain([probe, 'access', _37 => _37[i * rots.length + k], 'optionalAccess', _38 => _38.confidence]), () => ( 0))), 0) / sample.length;
1615
1721
  const [m0, m90, m270] = rots.map((_, k) => mean(k));
1616
1722
  const best2 = Math.max(m90, m270);
1617
1723
  if (best2 >= ORIENT_MIN_CONF && best2 >= m0 + ORIENT_GAIN) {
@@ -1627,12 +1733,12 @@ var OcrEngine = class _OcrEngine {
1627
1733
  const joins = [];
1628
1734
  let group = 0;
1629
1735
  for (const b of boxes) {
1630
- const gray = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, width, b);
1631
- const ink = _chunkSXULSPB6cjs.inkStats.call(void 0, gray);
1736
+ const gray = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, width, b);
1737
+ const ink = _chunkASS2MVTLcjs.inkStats.call(void 0, gray);
1632
1738
  if (tuning.minInkContrast > 0 && ink.contrast < tuning.minInkContrast) continue;
1633
1739
  if (tuning.minInkContrast > 0 && ink.inkRatio < MIN_INK_RATIO) continue;
1634
1740
  if (tuning.splitTall && b.h >= b.w * TALL_RATIO) {
1635
- const bands = _chunkSXULSPB6cjs.splitRowBands.call(void 0, gray, b.w, b.h, ink, 0.45);
1741
+ const bands = _chunkASS2MVTLcjs.splitRowBands.call(void 0, gray, b.w, b.h, ink, 0.45);
1636
1742
  if (bands.length >= 2) {
1637
1743
  for (const sub of bandBoxes(b, bands, height)) jobs.push({ box: sub, rot: 0, group: group++ });
1638
1744
  continue;
@@ -1643,9 +1749,9 @@ var OcrEngine = class _OcrEngine {
1643
1749
  continue;
1644
1750
  }
1645
1751
  }
1646
- const trim = tuning.trimEdges ? _chunkSXULSPB6cjs.edgeTrim.call(void 0, gray, b.w, b.h, ink) : null;
1752
+ const trim = tuning.trimEdges ? _chunkASS2MVTLcjs.edgeTrim.call(void 0, gray, b.w, b.h, ink) : null;
1647
1753
  const keep = trim ? { ...trim, bg: median(gray) } : void 0;
1648
- const leaders = tuning.splitLeaders ? _chunkSXULSPB6cjs.leaderRuns.call(void 0, gray, b.w, b.h, ink, LEADER_MIN_DOTS) : [];
1754
+ const leaders = tuning.splitLeaders ? _chunkASS2MVTLcjs.leaderRuns.call(void 0, gray, b.w, b.h, ink, LEADER_MIN_DOTS) : [];
1649
1755
  if (leaders.length) {
1650
1756
  const join = joins.length;
1651
1757
  joins.push({ box: b, parts: [], trailDots: false });
@@ -1654,7 +1760,7 @@ var OcrEngine = class _OcrEngine {
1654
1760
  const bare = { x: b.x + x0, y: b.y, w: a - x0, h: b.h };
1655
1761
  const end = c > a ? Math.min(c, a + Math.round(b.h * LEADER_CONTEXT)) : a;
1656
1762
  x0 = c;
1657
- if (bare.w >= DET_MIN_SIZE && _chunkSXULSPB6cjs.inkStats.call(void 0, _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, width, bare)).contrast >= Math.max(1, tuning.minInkContrast)) {
1763
+ if (bare.w >= DET_MIN_SIZE && _chunkASS2MVTLcjs.inkStats.call(void 0, _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, width, bare)).contrast >= Math.max(1, tuning.minInkContrast)) {
1658
1764
  jobs.push({ box: { ...bare, w: end - (bare.x - b.x) }, rot: 0, group: group++, join, dotsBefore: dots, trimDots: end > a });
1659
1765
  dots = false;
1660
1766
  }
@@ -1702,40 +1808,40 @@ var OcrEngine = class _OcrEngine {
1702
1808
  let text = tuning.postprocess ? restoreSymbols(raw.trim(), note.ringLead) : raw;
1703
1809
  if (!text.trim()) continue;
1704
1810
  if (tuning.postprocess && job.rot === 0 && text !== "/" && /^[(:;/)]+$/.test(text) && text.includes("/")) {
1705
- const g = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, width, job.box);
1706
- if (_chunkSXULSPB6cjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkSXULSPB6cjs.inkStats.call(void 0, g)) === 1) text = "/";
1811
+ const g = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, width, job.box);
1812
+ if (_chunkASS2MVTLcjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkASS2MVTLcjs.inkStats.call(void 0, g)) === 1) text = "/";
1707
1813
  }
1708
1814
  let ringByShape = false;
1709
1815
  if (tuning.postprocess && job.rot === 0 && !/^[◎●▪□■▣❐❏○ㅇ◆◇◈]/.test(text)) {
1710
1816
  const chars = [...read], k = chars.findIndex((c) => c.trim());
1711
1817
  if (k >= 0 && steps.length === chars.length) {
1712
- const g = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, width, job.box);
1713
- const b = _chunkSXULSPB6cjs.leadingBullet.call(void 0, g, job.box.w, job.box.h, _chunkSXULSPB6cjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx);
1818
+ const g = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, width, job.box);
1819
+ const b = _chunkASS2MVTLcjs.leadingBullet.call(void 0, g, job.box.w, job.box.h, _chunkASS2MVTLcjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx);
1714
1820
  const body = (_nullishCoalesce(text.match(/[가-힣]/g), () => ( []))).length >= 4;
1715
1821
  const miss = /^[Oo0•·ㆍ∙‧○]/.test(text);
1716
- if (_optionalChain([b, 'optionalAccess', _35 => _35.mark]) === "\u25CE" && b.covers && /^[Oo0○©]/.test(text)) {
1822
+ if (_optionalChain([b, 'optionalAccess', _39 => _39.mark]) === "\u25CE" && b.covers && /^[Oo0○©]/.test(text)) {
1717
1823
  text = b.mark + " " + text.slice(1).trimStart();
1718
1824
  ringByShape = true;
1719
- } else if (_optionalChain([b, 'optionalAccess', _36 => _36.mark]) === "\u25A1" || _optionalChain([b, 'optionalAccess', _37 => _37.mark]) === "\u25A3") {
1825
+ } else if (_optionalChain([b, 'optionalAccess', _40 => _40.mark]) === "\u25A1" || _optionalChain([b, 'optionalAccess', _41 => _41.mark]) === "\u25A3") {
1720
1826
  if (!b.covers && body) text = b.mark + " " + text;
1721
- } else if (_optionalChain([b, 'optionalAccess', _38 => _38.mark]) === "\u25C6" || _optionalChain([b, 'optionalAccess', _39 => _39.mark]) === "\u25C7" || _optionalChain([b, 'optionalAccess', _40 => _40.mark]) === "\u25C8") {
1827
+ } else if (_optionalChain([b, 'optionalAccess', _42 => _42.mark]) === "\u25C6" || _optionalChain([b, 'optionalAccess', _43 => _43.mark]) === "\u25C7" || _optionalChain([b, 'optionalAccess', _44 => _44.mark]) === "\u25C8") {
1722
1828
  if (b.covers ? /^[\p{S}\p{P}]/u.test(text) : body) text = b.covers ? b.mark + " " + text.slice(1).trimStart() : b.mark + " " + text;
1723
- } else if (_optionalChain([b, 'optionalAccess', _41 => _41.mark]) === "\u2023") {
1829
+ } else if (_optionalChain([b, 'optionalAccess', _45 => _45.mark]) === "\u2023") {
1724
1830
  if (b.covers ? text.startsWith("\u2192") : body) text = b.covers ? b.mark + " " + text.slice(1).trimStart() : b.mark + " " + text;
1725
- } else if (_optionalChain([b, 'optionalAccess', _42 => _42.mark]) === "\u2750" || _optionalChain([b, 'optionalAccess', _43 => _43.mark]) === "\u274F") {
1831
+ } else if (_optionalChain([b, 'optionalAccess', _46 => _46.mark]) === "\u2750" || _optionalChain([b, 'optionalAccess', _47 => _47.mark]) === "\u274F") {
1726
1832
  if (b.covers ? /^[ㅁ口]/.test(text) : body) text = b.covers ? b.mark + text.slice(1) : b.mark + " " + text;
1727
1833
  } else if (b && b.mark !== "\u25CE" && body) text = b.covers ? miss ? b.mark + " " + text.slice(1).trimStart() : text : b.mark + " " + text;
1728
- else if (!b && body && /^[가-힣]/.test(chars[k]) && _chunkSXULSPB6cjs.leadingRing.call(void 0, g, job.box.w, job.box.h, _chunkSXULSPB6cjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx)) text = "\u25CB " + text;
1834
+ else if (!b && body && /^[가-힣]/.test(chars[k]) && _chunkASS2MVTLcjs.leadingRing.call(void 0, g, job.box.w, job.box.h, _chunkASS2MVTLcjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx)) text = "\u25CB " + text;
1729
1835
  }
1730
1836
  }
1731
1837
  if (tuning.postprocess && /^\d/.test(text) && job.rot === 0) {
1732
- const g = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, width, job.box);
1733
- const tri = _chunkSXULSPB6cjs.leadingTriangle.call(void 0, g, job.box.w, job.box.h, _chunkSXULSPB6cjs.inkStats.call(void 0, g));
1838
+ const g = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, width, job.box);
1839
+ const tri = _chunkASS2MVTLcjs.leadingTriangle.call(void 0, g, job.box.w, job.box.h, _chunkASS2MVTLcjs.inkStats.call(void 0, g));
1734
1840
  if (tri) text = tri + text;
1735
1841
  }
1736
1842
  if (tuning.postprocess && text === "\u2192" && job.rot === 0 && job.join === void 0) {
1737
- const g = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, width, job.box);
1738
- text = _nullishCoalesce(_chunkSXULSPB6cjs.arrowGlyph.call(void 0, g, job.box.w, job.box.h, _chunkSXULSPB6cjs.inkStats.call(void 0, g)), () => ( text));
1843
+ const g = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, width, job.box);
1844
+ text = _nullishCoalesce(_chunkASS2MVTLcjs.arrowGlyph.call(void 0, g, job.box.w, job.box.h, _chunkASS2MVTLcjs.inkStats.call(void 0, g)), () => ( text));
1739
1845
  }
1740
1846
  if (job.footer) {
1741
1847
  if (!/^[-\u2013\u2014]?\s*(?:\d{1,4}|[ivxIVXⅰ-ⅹⅠ-Ⅹ]{1,4})\s*[-\u2013\u2014]?$/.test(text.trim())) continue;
@@ -1746,7 +1852,7 @@ var OcrEngine = class _OcrEngine {
1746
1852
  if (tuning.postprocess && job.rot === 0 && job.join === void 0 && !job.footer) retry.push(job.box);
1747
1853
  if (stats) {
1748
1854
  stats.droppedLowConf++;
1749
- _optionalChain([stats, 'access', _44 => _44.dropped, 'optionalAccess', _45 => _45.push, 'call', _46 => _46({ text, ...this.itemBox(rgba, width, job.box, tuning), confidence })]);
1855
+ _optionalChain([stats, 'access', _48 => _48.dropped, 'optionalAccess', _49 => _49.push, 'call', _50 => _50({ text, ...this.itemBox(rgba, width, job.box, tuning), confidence })]);
1750
1856
  }
1751
1857
  continue;
1752
1858
  }
@@ -1756,7 +1862,7 @@ var OcrEngine = class _OcrEngine {
1756
1862
  continue;
1757
1863
  }
1758
1864
  const item = { text, ...this.itemBox(rgba, width, job.box, tuning), confidence };
1759
- if (job.rot === 0) _chunkSXULSPB6cjs.rememberOcrTextGaps.call(void 0, item, _chunkSXULSPB6cjs.findOcrTextGaps.call(void 0, rgba, width, job.box, read, text, steps, stepPx));
1865
+ if (job.rot === 0) _chunkASS2MVTLcjs.rememberOcrTextGaps.call(void 0, item, _chunkASS2MVTLcjs.findOcrTextGaps.call(void 0, rgba, width, job.box, read, text, steps, stepPx));
1760
1866
  if (job.rot === 0 && job.keep === void 0) boxOf.set(item, job.box);
1761
1867
  items.push(item);
1762
1868
  }
@@ -1769,14 +1875,14 @@ var OcrEngine = class _OcrEngine {
1769
1875
  const r = res[k];
1770
1876
  if (!r || /\s/.test(r.text.trim()) || badThousands(r.text) || r.confidence < it.confidence - 0.05 || skeleton(r.text) !== skeleton(it.text)) return;
1771
1877
  it.text = restoreSymbols(r.text.trim());
1772
- _chunkSXULSPB6cjs.rememberOcrTextGaps.call(void 0, it, _chunkSXULSPB6cjs.findOcrTextGaps.call(void 0, rgba, width, boxOf.get(it), r.text, it.text, r.steps, r.stepPx));
1878
+ _chunkASS2MVTLcjs.rememberOcrTextGaps.call(void 0, it, _chunkASS2MVTLcjs.findOcrTextGaps.call(void 0, rgba, width, boxOf.get(it), r.text, it.text, r.steps, r.stepPx));
1773
1879
  });
1774
1880
  }
1775
1881
  if (retry.length) {
1776
1882
  const subs = [];
1777
1883
  for (const b of retry) {
1778
- const gray = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, width, b);
1779
- const cut = midBlankRow(gray, b.w, b.h, _chunkSXULSPB6cjs.inkStats.call(void 0, gray));
1884
+ const gray = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, width, b);
1885
+ const cut = midBlankRow(gray, b.w, b.h, _chunkASS2MVTLcjs.inkStats.call(void 0, gray));
1780
1886
  if (cut && b.w >= 3 * Math.max(cut[0], b.h - cut[1])) subs.push({ ...b, h: cut[0] }, { ...b, y: b.y + cut[1], h: b.h - cut[1] });
1781
1887
  }
1782
1888
  const overlap = (a, o) => Math.max(0, Math.min(a.x + a.w, o.x + o.w) - Math.max(a.x, o.x)) * Math.max(0, Math.min(a.y + a.h, o.y + o.h) - Math.max(a.y, o.y));
@@ -1818,16 +1924,16 @@ var OcrEngine = class _OcrEngine {
1818
1924
  if (tails.length) {
1819
1925
  const res = await this.recognizeJobs(rgba, width, tails.map((box, k) => ({ box, rot: 0, group: k })), tuning.recBatch);
1820
1926
  tails.forEach((box, k) => {
1821
- const t = _nullishCoalesce(_optionalChain([res, 'access', _47 => _47[k], 'optionalAccess', _48 => _48.text, 'access', _49 => _49.trim, 'call', _50 => _50()]), () => ( ""));
1822
- if (/^\d{1,4}$/.test(t) && (_nullishCoalesce(_optionalChain([res, 'access', _51 => _51[k], 'optionalAccess', _52 => _52.confidence]), () => ( 0))) >= tuning.textScore) items.push({ text: t, ...this.itemBox(rgba, width, box, tuning), confidence: res[k].confidence });
1927
+ const t = _nullishCoalesce(_optionalChain([res, 'access', _51 => _51[k], 'optionalAccess', _52 => _52.text, 'access', _53 => _53.trim, 'call', _54 => _54()]), () => ( ""));
1928
+ if (/^\d{1,4}$/.test(t) && (_nullishCoalesce(_optionalChain([res, 'access', _55 => _55[k], 'optionalAccess', _56 => _56.confidence]), () => ( 0))) >= tuning.textScore) items.push({ text: t, ...this.itemBox(rgba, width, box, tuning), confidence: res[k].confidence });
1823
1929
  });
1824
1930
  }
1825
1931
  const heads = rowHeadBoxes(rgba, width, items);
1826
1932
  if (heads.length) {
1827
1933
  const res = await this.recognizeJobs(rgba, width, heads.map((box, k) => ({ box, rot: 0, group: k })), tuning.recBatch);
1828
1934
  heads.forEach((box, k) => {
1829
- const t = _nullishCoalesce(_optionalChain([res, 'access', _53 => _53[k], 'optionalAccess', _54 => _54.text, 'access', _55 => _55.trim, 'call', _56 => _56()]), () => ( ""));
1830
- if (/^(?:[IVXⅠ-Ⅻ]{1,4}|\d{1,2})\s?\.$/.test(t) && (_nullishCoalesce(_optionalChain([res, 'access', _57 => _57[k], 'optionalAccess', _58 => _58.confidence]), () => ( 0))) >= tuning.textScore) items.push({ text: t, ...this.itemBox(rgba, width, box, tuning), confidence: res[k].confidence });
1935
+ const t = _nullishCoalesce(_optionalChain([res, 'access', _57 => _57[k], 'optionalAccess', _58 => _58.text, 'access', _59 => _59.trim, 'call', _60 => _60()]), () => ( ""));
1936
+ if (/^(?:[IVXⅠ-Ⅻ]{1,4}|\d{1,2})\s?\.$/.test(t) && (_nullishCoalesce(_optionalChain([res, 'access', _61 => _61[k], 'optionalAccess', _62 => _62.confidence]), () => ( 0))) >= tuning.textScore) items.push({ text: t, ...this.itemBox(rgba, width, box, tuning), confidence: res[k].confidence });
1831
1937
  });
1832
1938
  }
1833
1939
  }
@@ -1839,8 +1945,8 @@ var OcrEngine = class _OcrEngine {
1839
1945
  /** 결과 좌표 — det 박스 그대로 또는 박스 안 잉크 외곽 (tightBoxes) */
1840
1946
  itemBox(rgba, width, b, tuning) {
1841
1947
  if (!tuning.tightBoxes) return b;
1842
- const gray = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, width, b);
1843
- const t = _chunkSXULSPB6cjs.inkBounds.call(void 0, gray, b.w, b.h, _chunkSXULSPB6cjs.inkStats.call(void 0, gray));
1948
+ const gray = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, width, b);
1949
+ const t = _chunkASS2MVTLcjs.inkBounds.call(void 0, gray, b.w, b.h, _chunkASS2MVTLcjs.inkStats.call(void 0, gray));
1844
1950
  return { x: b.x + t.x0, y: b.y + t.y0, w: t.x1 - t.x0, h: t.y1 - t.y0 };
1845
1951
  }
1846
1952
  // ─── det ─────────────────────────────────────────────
@@ -1911,7 +2017,7 @@ var OcrEngine = class _OcrEngine {
1911
2017
  const out = await this.rec.run({ [this.rec.inputNames[0]]: tensor });
1912
2018
  const logits = out[this.rec.outputNames[0]];
1913
2019
  const [, T, C] = logits.dims;
1914
- if (C !== this.dict.length + 2) throw new (0, _chunkZGYKWZJScjs.KordocError)(`OCR rec \uCD9C\uB825 \uD074\uB798\uC2A4 ${C}\uAC1C\uAC00 \uC0AC\uC804 ${this.dict.length}\uC790 + 2 \uC640 \uB2E4\uB985\uB2C8\uB2E4 \u2014 \uBAA8\uB378\uC5D0 \uB9DE\uB294 \uC0AC\uC804(ocrRecDict)\uC744 \uC9C0\uC815\uD558\uC138\uC694`);
2020
+ if (C !== this.dict.length + 2) throw new (0, _chunkB773KHROcjs.KordocError)(`OCR rec \uCD9C\uB825 \uD074\uB798\uC2A4 ${C}\uAC1C\uAC00 \uC0AC\uC804 ${this.dict.length}\uC790 + 2 \uC640 \uB2E4\uB985\uB2C8\uB2E4 \u2014 \uBAA8\uB378\uC5D0 \uB9DE\uB294 \uC0AC\uC804(ocrRecDict)\uC744 \uC9C0\uC815\uD558\uC138\uC694`);
1915
2021
  const data = logits.data;
1916
2022
  idx.forEach((ci, k) => {
1917
2023
  const r = ctcDecode(data.subarray(k * T * C, (k + 1) * T * C), T, C, this.dict);
@@ -1921,9 +2027,9 @@ var OcrEngine = class _OcrEngine {
1921
2027
  const chars = r ? [...r.text] : [];
1922
2028
  if (r && job.rot === 0 && chars.length === r.steps.length && r.steps.some((t) => t > last) && !r.text.includes("(cid:")) {
1923
2029
  const tallCh = (c) => !/[\s.,:;\u00b7\u2026'"\u2018-\u201d`\-_~]/.test(c);
1924
- const g = _chunkSXULSPB6cjs.grayCrop.call(void 0, rgba, pageW, job.box);
2030
+ const g = _chunkASS2MVTLcjs.grayCrop.call(void 0, rgba, pageW, job.box);
1925
2031
  const inside = chars.filter((c, i) => r.steps[i] <= last && tallCh(c)).length;
1926
- let budget = inside <= 2 ? _chunkSXULSPB6cjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkSXULSPB6cjs.inkStats.call(void 0, g)) - inside : Infinity;
2032
+ let budget = inside <= 2 ? _chunkASS2MVTLcjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkASS2MVTLcjs.inkStats.call(void 0, g)) - inside : Infinity;
1927
2033
  const keep = chars.map((c, i) => r.steps[i] <= last || !tallCh(c) || budget-- > 0);
1928
2034
  if (!keep.every(Boolean)) kept = { ...r, text: chars.filter((_, i) => keep[i]).join(""), steps: r.steps.filter((_, i) => keep[i]) };
1929
2035
  }
@@ -2034,13 +2140,13 @@ async function tryImport(name, loader) {
2034
2140
  return await loader();
2035
2141
  } catch (e) {
2036
2142
  throw new Error(
2037
- `\uB0B4\uC7A5 OCR \uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 optional dependency '${name}' \uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \`npm install ${name}\` \uD6C4 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.${_chunkZGYKWZJScjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
2143
+ `\uB0B4\uC7A5 OCR \uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 optional dependency '${name}' \uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \`npm install ${name}\` \uD6C4 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.${_chunkB773KHROcjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
2038
2144
  );
2039
2145
  }
2040
2146
  }
2041
2147
  async function verifiedBytes(s) {
2042
2148
  const name = _path.basename.call(void 0, s.file.path);
2043
- const fail = (why2) => new (0, _chunkZGYKWZJScjs.KordocError)(`OCR \uBAA8\uB378 \uD30C\uC77C\uC744 \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${name} (${why2})`);
2149
+ const fail = (why2) => new (0, _chunkB773KHROcjs.KordocError)(`OCR \uBAA8\uB378 \uD30C\uC77C\uC744 \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${name} (${why2})`);
2044
2150
  const why = (e) => {
2045
2151
  const code = e.code;
2046
2152
  return code === "ENOENT" ? "\uD30C\uC77C\uC774 \uC5C6\uC74C" : code === "EACCES" || code === "EPERM" ? "\uAD8C\uD55C \uC5C6\uC74C" : "\uC77D\uAE30 \uC2E4\uD328";
@@ -2061,13 +2167,13 @@ async function verifiedBytes(s) {
2061
2167
  }
2062
2168
  const actual = _crypto.createHash.call(void 0, "sha256").update(bytes).digest("hex");
2063
2169
  if (actual !== s.file.sha256) {
2064
- throw new (0, _chunkZGYKWZJScjs.KordocError)(`OCR \uBAA8\uB378 SHA256 mismatch: ${_path.basename.call(void 0, s.file.path)} \u2014 expected ${s.file.sha256}, got ${actual} (\uB85C\uB4DC \uAC70\uBD80)`);
2170
+ throw new (0, _chunkB773KHROcjs.KordocError)(`OCR \uBAA8\uB378 SHA256 mismatch: ${_path.basename.call(void 0, s.file.path)} \u2014 expected ${s.file.sha256}, got ${actual} (\uB85C\uB4DC \uAC70\uBD80)`);
2065
2171
  }
2066
2172
  return bytes;
2067
2173
  }
2068
2174
  var engines = /* @__PURE__ */ new Map();
2069
- function getOcrEngine(models = _chunkSXULSPB6cjs.DEFAULT_OCR_MODELS) {
2070
- const key = _chunkSXULSPB6cjs.ocrSelectionKey.call(void 0, models);
2175
+ function getOcrEngine(models = _chunkASS2MVTLcjs.DEFAULT_OCR_MODELS) {
2176
+ const key = _chunkASS2MVTLcjs.ocrSelectionKey.call(void 0, models);
2071
2177
  let p = engines.get(key);
2072
2178
  if (!p) {
2073
2179
  p = OcrEngine.create(models).catch((err) => {
@@ -2187,20 +2293,20 @@ var PAGE_TIMEOUT_MS = 12e4;
2187
2293
  var AUTO_REC = { pageConf: 0.9, gain: 0.06 };
2188
2294
  var DEFAULT_AUTO_REC = { pageConf: 0.85, gain: 0.1, lazy: true };
2189
2295
  var DEFAULT_BUILTIN_OCR = Object.freeze({
2190
- models: _chunkSXULSPB6cjs.DEFAULT_OCR_MODELS,
2296
+ models: _chunkASS2MVTLcjs.DEFAULT_OCR_MODELS,
2191
2297
  tuning: DEFAULT_OCR_TUNING,
2192
- handwriting: _chunkSXULSPB6cjs.handwritingFallbackModels.call(void 0, _chunkSXULSPB6cjs.DEFAULT_OCR_MODELS),
2298
+ handwriting: _chunkASS2MVTLcjs.handwritingFallbackModels.call(void 0, _chunkASS2MVTLcjs.DEFAULT_OCR_MODELS),
2193
2299
  autoRec: DEFAULT_AUTO_REC
2194
2300
  });
2195
2301
  var DEFAULT_BUILTIN_OCR_FETCH = Object.freeze({ ...DEFAULT_BUILTIN_OCR, autoRec: { ...DEFAULT_AUTO_REC, fetch: true } });
2196
2302
  function builtinOcrConfig(o) {
2197
- if (!o || o.ocrDet === void 0 && o.ocrDetLongSide === void 0 && o.ocrRec === void 0 && o.ocrRecDict === void 0 && !o.ocrLines) return _optionalChain([o, 'optionalAccess', _59 => _59.ocr]) ? DEFAULT_BUILTIN_OCR_FETCH : DEFAULT_BUILTIN_OCR;
2303
+ if (!o || o.ocrDet === void 0 && o.ocrDetLongSide === void 0 && o.ocrRec === void 0 && o.ocrRecDict === void 0 && !o.ocrLines) return _optionalChain([o, 'optionalAccess', _63 => _63.ocr]) ? DEFAULT_BUILTIN_OCR_FETCH : DEFAULT_BUILTIN_OCR;
2198
2304
  const bad = _chunkMMK32GPDcjs.validateOcrOptions.call(void 0, o);
2199
- if (bad) throw new (0, _chunkZGYKWZJScjs.KordocError)(bad);
2200
- const models = _chunkSXULSPB6cjs.resolveOcrModels.call(void 0, o);
2305
+ if (bad) throw new (0, _chunkB773KHROcjs.KordocError)(bad);
2306
+ const models = _chunkASS2MVTLcjs.resolveOcrModels.call(void 0, o);
2201
2307
  return {
2202
2308
  models,
2203
- ...o.ocrRec === "auto" ? { handwriting: _chunkSXULSPB6cjs.handwritingFallbackModels.call(void 0, models), autoRec: AUTO_REC } : o.ocrRec === void 0 ? { handwriting: _chunkSXULSPB6cjs.handwritingFallbackModels.call(void 0, models), autoRec: o.ocr ? { ...DEFAULT_AUTO_REC, fetch: true } : DEFAULT_AUTO_REC } : {},
2309
+ ...o.ocrRec === "auto" ? { handwriting: _chunkASS2MVTLcjs.handwritingFallbackModels.call(void 0, models), autoRec: AUTO_REC } : o.ocrRec === void 0 ? { handwriting: _chunkASS2MVTLcjs.handwritingFallbackModels.call(void 0, models), autoRec: o.ocr ? { ...DEFAULT_AUTO_REC, fetch: true } : DEFAULT_AUTO_REC } : {},
2204
2310
  tuning: o.ocrDetLongSide === void 0 ? DEFAULT_OCR_TUNING : { ...DEFAULT_OCR_TUNING, detLongSide: o.ocrDetLongSide },
2205
2311
  lines: o.ocrLines === "all" ? "all" : o.ocrLines ? "kept" : void 0
2206
2312
  };
@@ -2214,8 +2320,8 @@ async function recognizeOcrPage(engine, config, tuning, rgba, width, height, sta
2214
2320
  const altStats = { droppedLowConf: 0, ...stats.dropped ? { dropped: [] } : {} };
2215
2321
  let alt;
2216
2322
  try {
2217
- if (auto.lazy && !auto.fetch && !await _chunkSXULSPB6cjs.ocrModelsCached.call(void 0, config.handwriting)) return items;
2218
- if (auto.lazy) await _chunkSXULSPB6cjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
2323
+ if (auto.lazy && !auto.fetch && !await _chunkASS2MVTLcjs.ocrModelsCached.call(void 0, config.handwriting)) return items;
2324
+ if (auto.lazy) await _chunkASS2MVTLcjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
2219
2325
  alt = await (await getOcrEngine(config.handwriting)).recognizePage(rgba, width, height, altStats, tuning, cellRules, rowRules);
2220
2326
  } catch (e) {
2221
2327
  if (!auto.lazy) throw e;
@@ -2254,8 +2360,8 @@ async function runPdfOcr(buffer, targets, mode, warnings, onProgress, detectTabl
2254
2360
  "@hyzyla/pdfium",
2255
2361
  () => Promise.resolve().then(() => _interopRequireWildcard(require("@hyzyla/pdfium")))
2256
2362
  );
2257
- if (mode === "builtin") await _chunkSXULSPB6cjs.ensureOcrModelsFor.call(void 0, config.models, reportModelDownload);
2258
- if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _60 => _60.autoRec, 'optionalAccess', _61 => _61.lazy])) await _chunkSXULSPB6cjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
2363
+ if (mode === "builtin") await _chunkASS2MVTLcjs.ensureOcrModelsFor.call(void 0, config.models, reportModelDownload);
2364
+ if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _64 => _64.autoRec, 'optionalAccess', _65 => _65.lazy])) await _chunkASS2MVTLcjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
2259
2365
  const engine = mode === "builtin" ? await getOcrEngine(config.models) : null;
2260
2366
  const pdfium = await pdfiumMod.PDFiumLibrary.init();
2261
2367
  const doc = await pdfium.loadDocument(new Uint8Array(buffer));
@@ -2264,15 +2370,15 @@ async function runPdfOcr(buffer, targets, mode, warnings, onProgress, detectTabl
2264
2370
  const count = doc.getPageCount();
2265
2371
  for (const pageNo of [...targets].filter((p) => p >= 1 && p <= count).sort((a, b) => a - b)) {
2266
2372
  const page = doc.getPage(pageNo - 1);
2267
- _optionalChain([onProgress, 'optionalCall', _62 => _62(++done, targets.size)]);
2373
+ _optionalChain([onProgress, 'optionalCall', _66 => _66(++done, targets.size)]);
2268
2374
  try {
2269
2375
  const { blocks, lines } = await withTimeout(
2270
- ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, _optionalChain([vectorOps, 'optionalAccess', _63 => _63.get, 'call', _64 => _64(pageNo)]), _optionalChain([imageRegions, 'optionalAccess', _65 => _65.get, 'call', _66 => _66(pageNo)]), config),
2376
+ ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, _optionalChain([vectorOps, 'optionalAccess', _67 => _67.get, 'call', _68 => _68(pageNo)]), _optionalChain([imageRegions, 'optionalAccess', _69 => _69.get, 'call', _70 => _70(pageNo)]), config),
2271
2377
  PAGE_TIMEOUT_MS,
2272
2378
  `OCR \uD398\uC774\uC9C0 ${pageNo} \uD0C0\uC784\uC544\uC6C3 (${PAGE_TIMEOUT_MS / 1e3}\uCD08)`
2273
2379
  );
2274
2380
  result.set(pageNo, blocks);
2275
- if (lines) _optionalChain([linesOut, 'optionalAccess', _67 => _67.set, 'call', _68 => _68(pageNo, lines)]);
2381
+ if (lines) _optionalChain([linesOut, 'optionalAccess', _71 => _71.set, 'call', _72 => _72(pageNo, lines)]);
2276
2382
  } catch (e) {
2277
2383
  warnings.push({
2278
2384
  page: pageNo,
@@ -2356,7 +2462,7 @@ async function ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, ve
2356
2462
  const regionBlocks = regions.flatMap((r, k) => {
2357
2463
  let own = items.filter((it) => inside(it, r));
2358
2464
  const near = reads[k];
2359
- if (_optionalChain([near, 'optionalAccess', _69 => _69.length]) && meanConfidence(near) > meanConfidence(own)) {
2465
+ if (_optionalChain([near, 'optionalAccess', _73 => _73.length]) && meanConfidence(near) > meanConfidence(own)) {
2360
2466
  own = near;
2361
2467
  reread.add(k);
2362
2468
  }
@@ -2364,9 +2470,9 @@ async function ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, ve
2364
2470
  for (const it of own) used.add(it);
2365
2471
  const blocks = ocrItemsToBlocks(own, pageNo, pdfW, pdfH, scale, ruling && rulingToPdfLines(ruling, scale, pdfH), detectTables, void 0, true);
2366
2472
  const x1 = r.x1 * scale - 2, x2 = r.x2 * scale + 2, y1 = (pdfH - r.y2) * scale - 2, y2 = (pdfH - r.y1) * scale + 2;
2367
- const columnRules = _nullishCoalesce(_optionalChain([ruling, 'optionalAccess', _70 => _70.verticals, 'access', _71 => _71.filter, 'call', _72 => _72((s) => Math.min(s.x1, s.x2) >= x1 && Math.max(s.x1, s.x2) <= x2 && Math.min(s.y1, s.y2) >= y1 && Math.max(s.y1, s.y2) <= y2), 'access', _73 => _73.length]), () => ( 0));
2473
+ const columnRules = _nullishCoalesce(_optionalChain([ruling, 'optionalAccess', _74 => _74.verticals, 'access', _75 => _75.filter, 'call', _76 => _76((s) => Math.min(s.x1, s.x2) >= x1 && Math.max(s.x1, s.x2) <= x2 && Math.min(s.y1, s.y2) >= y1 && Math.max(s.y1, s.y2) <= y2), 'access', _77 => _77.length]), () => ( 0));
2368
2474
  if (columnRules < 2) {
2369
- for (const b of blocks) if (b.type === "table") _chunkSXULSPB6cjs.UNRULED_REGION_TABLES.add(b);
2475
+ for (const b of blocks) if (b.type === "table") _chunkASS2MVTLcjs.UNRULED_REGION_TABLES.add(b);
2370
2476
  }
2371
2477
  return blocks;
2372
2478
  });
@@ -2438,7 +2544,7 @@ async function closerReads(rgba, rw, rh, pdfH, hi, regions, engine, tuning = REG
2438
2544
  const items = await engine.recognizePage(crop, cw, ch, void 0, tuning);
2439
2545
  out.push(items.map((it) => {
2440
2546
  const placed = { ...it, x: (it.x + x0) / 2, y: (it.y + y0) / 2, w: it.w / 2, h: it.h / 2 };
2441
- _chunkSXULSPB6cjs.copyOcrTextGaps.call(void 0, it, placed, 0.5, x0 / 2);
2547
+ _chunkASS2MVTLcjs.copyOcrTextGaps.call(void 0, it, placed, 0.5, x0 / 2);
2442
2548
  return placed;
2443
2549
  }));
2444
2550
  }
@@ -2446,7 +2552,7 @@ async function closerReads(rgba, rw, rh, pdfH, hi, regions, engine, tuning = REG
2446
2552
  }
2447
2553
  var proseBox = (b) => {
2448
2554
  const t = b.text.replace(/\s/g, "");
2449
- return b.w >= b.h * 7 && (_nullishCoalesce(_optionalChain([t, 'access', _74 => _74.match, 'call', _75 => _75(/\d/g), 'optionalAccess', _76 => _76.length]), () => ( 0))) < t.length * 0.3;
2555
+ return b.w >= b.h * 7 && (_nullishCoalesce(_optionalChain([t, 'access', _78 => _78.match, 'call', _79 => _79(/\d/g), 'optionalAccess', _80 => _80.length]), () => ( 0))) < t.length * 0.3;
2450
2556
  };
2451
2557
  function groupOcrLines(items, figureRegion = false) {
2452
2558
  const order = items.map((_, i) => i).sort((a, b) => items[a].y + items[a].h / 2 - (items[b].y + items[b].h / 2));
@@ -2526,15 +2632,15 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
2526
2632
  isHidden: false,
2527
2633
  ...xs[i].space ? { hasSpaceBefore: true } : {}
2528
2634
  };
2529
- _chunkSXULSPB6cjs.copyOcrTextGaps.call(void 0, it, normalized, 1 / scale);
2635
+ _chunkASS2MVTLcjs.copyOcrTextGaps.call(void 0, it, normalized, 1 / scale);
2530
2636
  return normalized;
2531
2637
  }).filter((it) => it.text);
2532
- const blocks = unframeOcrLayoutTables(splitStackedOcrRows(_chunkSXULSPB6cjs.extractPageBlocksWithLines.call(void 0, norm, pageNumber, opList, pdfW, pdfH, extraLines, detectTables)), pdfH);
2638
+ const blocks = unframeOcrLayoutTables(splitOcrNameValueColumns(splitStackedOcrRows(_chunkASS2MVTLcjs.extractPageBlocksWithLines.call(void 0, norm, pageNumber, opList, pdfW, pdfH, extraLines, detectTables))), pdfH);
2533
2639
  if (!figureRegion) markOcrHeadings(blocks);
2534
2640
  return blocks;
2535
2641
  }
2536
2642
  function markOcrHeadings(blocks) {
2537
- const sized = blocks.filter((b) => b.type === "paragraph" && b.text && _optionalChain([b, 'access', _77 => _77.style, 'optionalAccess', _78 => _78.fontSize]));
2643
+ const sized = blocks.filter((b) => b.type === "paragraph" && b.text && _optionalChain([b, 'access', _81 => _81.style, 'optionalAccess', _82 => _82.fontSize]));
2538
2644
  const weights = sized.map((b) => [b.style.fontSize, b.text.length]);
2539
2645
  const total = weights.reduce((n, [, w]) => n + w, 0);
2540
2646
  if (total < 100) return;
@@ -2571,9 +2677,9 @@ function markOcrHeadings(blocks) {
2571
2677
  const a = blocks[i - 1], b = blocks[i];
2572
2678
  if (a.type !== "heading" || b.type !== "heading" || !a.bbox || !b.bbox) continue;
2573
2679
  const marker = /^(?:제\s*\d+\s*[장절편부]|chapter\s*\d+|part\s*\d+)$/i.test(a.text.trim());
2574
- const sa = _nullishCoalesce(_optionalChain([a, 'access', _79 => _79.style, 'optionalAccess', _80 => _80.fontSize]), () => ( 0)), sb = _nullishCoalesce(_optionalChain([b, 'access', _81 => _81.style, 'optionalAccess', _82 => _82.fontSize]), () => ( 0));
2680
+ const sa = _nullishCoalesce(_optionalChain([a, 'access', _83 => _83.style, 'optionalAccess', _84 => _84.fontSize]), () => ( 0)), sb = _nullishCoalesce(_optionalChain([b, 'access', _85 => _85.style, 'optionalAccess', _86 => _86.fontSize]), () => ( 0));
2575
2681
  if (!marker && (a.level !== b.level || Math.max(sa, sb) > Math.min(sa, sb) * 1.3)) continue;
2576
- const gap = a.bbox.y - (b.bbox.y + b.bbox.height), size = Math.max(_nullishCoalesce(_optionalChain([a, 'access', _83 => _83.style, 'optionalAccess', _84 => _84.fontSize]), () => ( 0)), _nullishCoalesce(_optionalChain([b, 'access', _85 => _85.style, 'optionalAccess', _86 => _86.fontSize]), () => ( 0)));
2682
+ const gap = a.bbox.y - (b.bbox.y + b.bbox.height), size = Math.max(_nullishCoalesce(_optionalChain([a, 'access', _87 => _87.style, 'optionalAccess', _88 => _88.fontSize]), () => ( 0)), _nullishCoalesce(_optionalChain([b, 'access', _89 => _89.style, 'optionalAccess', _90 => _90.fontSize]), () => ( 0)));
2577
2683
  const across = Math.min(a.bbox.x + a.bbox.width, b.bbox.x + b.bbox.width) - Math.max(a.bbox.x, b.bbox.x);
2578
2684
  if (gap < 0 || gap > size * (marker ? 3 : 1.2) || across <= 0) continue;
2579
2685
  a.level = Math.min(_nullishCoalesce(a.level, () => ( 2)), _nullishCoalesce(b.level, () => ( 2)));
@@ -2588,7 +2694,7 @@ async function tryImport2(name, loader) {
2588
2694
  return await loader();
2589
2695
  } catch (e) {
2590
2696
  throw new Error(
2591
- `OCR \uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 optional dependency '${name}' \uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \`npm install ${name}\` \uD6C4 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.${_chunkZGYKWZJScjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
2697
+ `OCR \uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 optional dependency '${name}' \uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \`npm install ${name}\` \uD6C4 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.${_chunkB773KHROcjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
2592
2698
  );
2593
2699
  }
2594
2700
  }
@@ -2640,4 +2746,4 @@ function bgraToRgba(bgra) {
2640
2746
 
2641
2747
 
2642
2748
  exports.getOcrEngine = getOcrEngine; exports.detectRulingLines = detectRulingLines; exports.rulingToPdfLines = rulingToPdfLines; exports.deskewPage = deskewPage; exports.rotateQuarter = rotateQuarter; exports.MAX_OCR_PIXELS = MAX_OCR_PIXELS; exports.DEFAULT_BUILTIN_OCR = DEFAULT_BUILTIN_OCR; exports.builtinOcrConfig = builtinOcrConfig; exports.recognizeOcrPage = recognizeOcrPage; exports.reportModelDownload = reportModelDownload; exports.toOcrLine = toOcrLine; exports.pageLines = pageLines; exports.cellEdgeVerticals = cellEdgeVerticals; exports.cellEdgeHorizontals = cellEdgeHorizontals; exports.runPdfOcr = runPdfOcr; exports.ocrOnePage = ocrOnePage; exports.stretchFaintCrop = stretchFaintCrop; exports.groupOcrLines = groupOcrLines; exports.ocrItemsToBlocks = ocrItemsToBlocks; exports.markOcrHeadings = markOcrHeadings;
2643
- //# sourceMappingURL=chunk-YN3C6T5M.cjs.map
2749
+ //# sourceMappingURL=chunk-2QHC2YXC.cjs.map