kordoc 4.24.48 → 4.24.49
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.
- package/README.md +3 -3
- package/dist/{-3EMVBTE7.js → -22V6D2US.js} +42 -42
- package/dist/{chunk-TOOOWCKQ.cjs → chunk-2UWWWM4Q.cjs} +98 -98
- package/dist/{chunk-TOOOWCKQ.cjs.map → chunk-2UWWWM4Q.cjs.map} +1 -1
- package/dist/{chunk-MHAPDR6T.cjs → chunk-367WLMPO.cjs} +59 -67
- package/dist/chunk-367WLMPO.cjs.map +1 -0
- package/dist/{chunk-WVUR3HYW.js → chunk-4HJKBRZJ.js} +129 -40
- package/dist/chunk-4HJKBRZJ.js.map +1 -0
- package/dist/{chunk-7F5SKDUG.js → chunk-4MWUBTAE.js} +2 -2
- package/dist/{chunk-4N2ESXR2.js → chunk-67GSFYG7.js} +2 -2
- package/dist/{chunk-WICMTKWR.js → chunk-6BFWLS7E.js} +3 -3
- package/dist/{chunk-LBH4KAQM.cjs → chunk-6NZ32OTX.cjs} +8 -3
- package/dist/chunk-6NZ32OTX.cjs.map +1 -0
- package/dist/{chunk-JC2TMUU5.js → chunk-7KKL3PRK.js} +5 -13
- package/dist/chunk-7KKL3PRK.js.map +1 -0
- package/dist/{chunk-7EL6BCO5.js → chunk-AUAJVQQK.js} +2 -2
- package/dist/{chunk-QJBVP2BS.js → chunk-AXW2FMVR.js} +2 -2
- package/dist/{chunk-SUOJQHIN.js → chunk-CCQMSIZQ.js} +19 -19
- package/dist/{chunk-OUUI7I5V.js → chunk-DA5AXURC.js} +52 -4
- package/dist/chunk-DA5AXURC.js.map +1 -0
- package/dist/{chunk-3UY7ARXP.js → chunk-DAAJO62F.js} +2 -2
- package/dist/{chunk-QM65ELZE.js → chunk-EUJX7HTR.js} +32 -10
- package/dist/chunk-EUJX7HTR.js.map +1 -0
- package/dist/{chunk-E47LO7XG.js → chunk-EYSXMDA7.js} +17 -17
- package/dist/{chunk-TQ4QOCKT.js → chunk-FU6ZDWCI.js} +7 -2
- package/dist/chunk-FU6ZDWCI.js.map +1 -0
- package/dist/{chunk-MHLTZ3VI.js → chunk-HETGOJ6V.js} +2 -2
- package/dist/{chunk-OQPIN2OY.js → chunk-HW7WVYBF.js} +2 -2
- package/dist/{chunk-LHZL52HO.cjs → chunk-IRAZCKQ6.cjs} +3 -3
- package/dist/{chunk-LHZL52HO.cjs.map → chunk-IRAZCKQ6.cjs.map} +1 -1
- package/dist/{chunk-AC7FZDVP.js → chunk-KB4ORA7M.js} +2 -2
- package/dist/{chunk-SHYNOLL6.js → chunk-KXHUHGMC.js} +2 -2
- package/dist/{chunk-WO6PZMMB.js → chunk-L3JP55ZY.js} +2 -2
- package/dist/{chunk-OBNOOHAW.js → chunk-LCRSRVFJ.js} +2 -2
- package/dist/{chunk-OBNOOHAW.js.map → chunk-LCRSRVFJ.js.map} +1 -1
- package/dist/{chunk-OO4DHHTG.js → chunk-LFFARZYZ.js} +2 -2
- package/dist/{chunk-OO4DHHTG.js.map → chunk-LFFARZYZ.js.map} +1 -1
- package/dist/{chunk-NLPIXQOV.js → chunk-LOSCIAHY.js} +2 -2
- package/dist/{chunk-HW3DZ7TY.js → chunk-M5RQ2PNP.js} +6 -14
- package/dist/chunk-M5RQ2PNP.js.map +1 -0
- package/dist/{chunk-GFWCBYAI.js → chunk-MIJTZKWF.js} +2 -2
- package/dist/{chunk-PHU4VSNF.js → chunk-MLBX6KQM.js} +37 -3
- package/dist/chunk-MLBX6KQM.js.map +1 -0
- package/dist/{chunk-D4TKVZKB.js → chunk-OAETOHH3.js} +3 -3
- package/dist/{chunk-SI3GXM7Z.js → chunk-PMGJQWSW.js} +2 -2
- package/dist/{chunk-QOBWIFJA.cjs → chunk-PVV6OY4M.cjs} +135 -87
- package/dist/{chunk-QOBWIFJA.cjs.map → chunk-PVV6OY4M.cjs.map} +1 -1
- package/dist/{chunk-VXHZPUMS.cjs → chunk-PW7MQZI4.cjs} +2 -2
- package/dist/{chunk-VXHZPUMS.cjs.map → chunk-PW7MQZI4.cjs.map} +1 -1
- package/dist/{chunk-MYIRYP6D.js → chunk-Q7FDPJUS.js} +10 -10
- package/dist/{chunk-N6B5BINC.js → chunk-R2RLNUNK.js} +6 -6
- package/dist/{chunk-FQMPHPHE.js → chunk-RQLEGKEV.js} +2 -2
- package/dist/{chunk-KTGOULMH.js → chunk-S54DZB2Z.js} +51 -3
- package/dist/chunk-S54DZB2Z.js.map +1 -0
- package/dist/{chunk-D7SOY3VR.js → chunk-TAHS42ED.js} +33 -11
- package/dist/chunk-TAHS42ED.js.map +1 -0
- package/dist/{chunk-YFTD6WOP.cjs → chunk-TQOAPKLU.cjs} +6 -6
- package/dist/{chunk-YFTD6WOP.cjs.map → chunk-TQOAPKLU.cjs.map} +1 -1
- package/dist/{chunk-A6EOKPKG.cjs → chunk-UBY2PLKR.cjs} +54 -32
- package/dist/chunk-UBY2PLKR.cjs.map +1 -0
- package/dist/{chunk-UN2F6EKQ.js → chunk-UJELMNOU.js} +7 -2
- package/dist/chunk-UJELMNOU.js.map +1 -0
- package/dist/{chunk-REERG473.js → chunk-UU54HN5I.js} +6 -6
- package/dist/{chunk-E5RJLP2S.js → chunk-VMOUAWGD.js} +7 -7
- package/dist/{chunk-6YUMHSBG.js → chunk-WLFZOBZR.js} +3 -3
- package/dist/{chunk-SJXTCW7I.cjs → chunk-Y4MFHEK4.cjs} +40 -6
- package/dist/chunk-Y4MFHEK4.cjs.map +1 -0
- package/dist/{chunk-UJ3TZF4Y.js → chunk-Y6QW3FJQ.js} +2 -2
- package/dist/{chunk-GOYAJVR6.js → chunk-ZF24SO45.js} +37 -3
- package/dist/chunk-ZF24SO45.js.map +1 -0
- package/dist/chunks-Q7242OJE.js +11 -0
- package/dist/cli.js +73 -53
- package/dist/cli.js.map +1 -1
- package/dist/{formula-DUHNPES2.js → formula-BYEDWWZU.js} +4 -4
- package/dist/{formula-XNCKOV6K.js → formula-FQLMMBDP.js} +3 -3
- package/dist/{formula-7RJOEJHX.cjs → formula-QJEOIVKR.cjs} +9 -9
- package/dist/{formula-7RJOEJHX.cjs.map → formula-QJEOIVKR.cjs.map} +1 -1
- package/dist/generator-FTM6GOGB.cjs +11 -0
- package/dist/{generator-XXVCF6TG.cjs.map → generator-FTM6GOGB.cjs.map} +1 -1
- package/dist/generator-Q3L7RNUY.js +17 -0
- package/dist/generator-SU73HZHR.js +10 -0
- package/dist/{image-ocr-PYOXD5K4.js → image-ocr-7Y3FCGRR.js} +12 -10
- package/dist/image-ocr-7Y3FCGRR.js.map +1 -0
- package/dist/{image-ocr-NFCTNIL5.js → image-ocr-VIGZE4YL.js} +9 -7
- package/dist/image-ocr-VIGZE4YL.js.map +1 -0
- package/dist/{image-ocr-ZLAPJMES.cjs → image-ocr-WRILL3WO.cjs} +29 -27
- package/dist/image-ocr-WRILL3WO.cjs.map +1 -0
- package/dist/index.cjs +1250 -1161
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +207 -118
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +42 -43
- package/dist/mcp.js.map +1 -1
- package/dist/memo-T5ZQEXEA.js +17 -0
- package/dist/{model-bundle-TIHWFIN5.js → model-bundle-UJRQPYUU.js} +5 -5
- package/dist/{models-YBHBEM6J.js → models-64YLAWTI.js} +5 -5
- package/dist/{parse-worker-v2-Q7ST3SDO.js → parse-worker-v2-QWQZKFQO.js} +25 -24
- package/dist/parse-worker-v2-QWQZKFQO.js.map +1 -0
- package/dist/{parser-7JSQYNLS.js → parser-JPWANPLM.js} +77 -32
- package/dist/parser-JPWANPLM.js.map +1 -0
- package/dist/{parser-A76QS3VJ.cjs → parser-RB6CBNAM.cjs} +259 -214
- package/dist/parser-RB6CBNAM.cjs.map +1 -0
- package/dist/{parser-V25GYLBJ.js → parser-XFU3VRWM.js} +80 -35
- package/dist/parser-XFU3VRWM.js.map +1 -0
- package/dist/pdf-ocr-NOJHEH4M.cjs +42 -0
- package/dist/{pdf-ocr-5YCDSSLG.cjs.map → pdf-ocr-NOJHEH4M.cjs.map} +1 -1
- package/dist/{pdf-ocr-IJXT6ZJR.js → pdf-ocr-XTZZEYKJ.js} +6 -6
- package/dist/{pdf-ocr-GEAW23FB.js → pdf-ocr-ZV3KYIIE.js} +9 -9
- package/dist/{profile-io-Y7SMMS2R.js → profile-io-FAJORRD2.js} +3 -3
- package/dist/{rasterize-MLEHT6PU.js → rasterize-4ZJUA2DZ.js} +3 -3
- package/dist/{redact-doc-GPO2UTTJ.js → redact-doc-JPNROEH6.js} +30 -30
- package/dist/{render-TNWY53S4.js → render-D4WBOBKI.js} +13 -13
- package/dist/{rewrite-fallback-AHGTN757.js → rewrite-fallback-OF3QI6CX.js} +14 -14
- package/dist/seal-DQWEHIAM.js +16 -0
- package/dist/{setup-TJ57DQ6I.js → setup-YC25YCQB.js} +3 -3
- package/dist/to-hwpx-D7OMPDUQ.js +21 -0
- package/dist/to-hwpx-LUA6F5RR.cjs +16 -0
- package/dist/{to-hwpx-XLQUY2L2.cjs.map → to-hwpx-LUA6F5RR.cjs.map} +1 -1
- package/dist/{to-hwpx-DLVARUND.js → to-hwpx-ZWN64NCQ.js} +5 -5
- package/dist/visual-SW7NPY6K.js +37 -0
- package/dist/{watch-6CHDQ355.js → watch-ZU576VSR.js} +24 -24
- package/package.json +1 -1
- package/dist/chunk-A6EOKPKG.cjs.map +0 -1
- package/dist/chunk-D7SOY3VR.js.map +0 -1
- package/dist/chunk-GOYAJVR6.js.map +0 -1
- package/dist/chunk-HW3DZ7TY.js.map +0 -1
- package/dist/chunk-JC2TMUU5.js.map +0 -1
- package/dist/chunk-KTGOULMH.js.map +0 -1
- package/dist/chunk-LBH4KAQM.cjs.map +0 -1
- package/dist/chunk-MHAPDR6T.cjs.map +0 -1
- package/dist/chunk-OUUI7I5V.js.map +0 -1
- package/dist/chunk-PHU4VSNF.js.map +0 -1
- package/dist/chunk-QM65ELZE.js.map +0 -1
- package/dist/chunk-SJXTCW7I.cjs.map +0 -1
- package/dist/chunk-TQ4QOCKT.js.map +0 -1
- package/dist/chunk-UN2F6EKQ.js.map +0 -1
- package/dist/chunk-WVUR3HYW.js.map +0 -1
- package/dist/chunks-QTVEFJOS.js +0 -11
- package/dist/generator-6BFIABTF.js +0 -10
- package/dist/generator-XJLIBYDJ.js +0 -17
- package/dist/generator-XXVCF6TG.cjs +0 -11
- package/dist/hancom-7F53R77A.cjs +0 -85
- package/dist/hancom-7F53R77A.cjs.map +0 -1
- package/dist/hancom-D4E3WBPI.js +0 -84
- package/dist/hancom-D4E3WBPI.js.map +0 -1
- package/dist/hancom-IPF6HM5F.js +0 -85
- package/dist/hancom-IPF6HM5F.js.map +0 -1
- package/dist/image-ocr-NFCTNIL5.js.map +0 -1
- package/dist/image-ocr-PYOXD5K4.js.map +0 -1
- package/dist/image-ocr-ZLAPJMES.cjs.map +0 -1
- package/dist/memo-CNW6ZJFE.js +0 -17
- package/dist/parse-worker-v2-Q7ST3SDO.js.map +0 -1
- package/dist/parser-7JSQYNLS.js.map +0 -1
- package/dist/parser-A76QS3VJ.cjs.map +0 -1
- package/dist/parser-V25GYLBJ.js.map +0 -1
- package/dist/pdf-ocr-5YCDSSLG.cjs +0 -42
- package/dist/seal-7HBR3HBQ.js +0 -16
- package/dist/to-hwpx-6JF6Q2TZ.js +0 -21
- package/dist/to-hwpx-XLQUY2L2.cjs +0 -16
- package/dist/visual-VBDQUUKP.js +0 -37
- /package/dist/{-3EMVBTE7.js.map → -22V6D2US.js.map} +0 -0
- /package/dist/{chunk-7F5SKDUG.js.map → chunk-4MWUBTAE.js.map} +0 -0
- /package/dist/{chunk-4N2ESXR2.js.map → chunk-67GSFYG7.js.map} +0 -0
- /package/dist/{chunk-WICMTKWR.js.map → chunk-6BFWLS7E.js.map} +0 -0
- /package/dist/{chunk-7EL6BCO5.js.map → chunk-AUAJVQQK.js.map} +0 -0
- /package/dist/{chunk-QJBVP2BS.js.map → chunk-AXW2FMVR.js.map} +0 -0
- /package/dist/{chunk-SUOJQHIN.js.map → chunk-CCQMSIZQ.js.map} +0 -0
- /package/dist/{chunk-3UY7ARXP.js.map → chunk-DAAJO62F.js.map} +0 -0
- /package/dist/{chunk-E47LO7XG.js.map → chunk-EYSXMDA7.js.map} +0 -0
- /package/dist/{chunk-MHLTZ3VI.js.map → chunk-HETGOJ6V.js.map} +0 -0
- /package/dist/{chunk-OQPIN2OY.js.map → chunk-HW7WVYBF.js.map} +0 -0
- /package/dist/{chunk-AC7FZDVP.js.map → chunk-KB4ORA7M.js.map} +0 -0
- /package/dist/{chunk-SHYNOLL6.js.map → chunk-KXHUHGMC.js.map} +0 -0
- /package/dist/{chunk-WO6PZMMB.js.map → chunk-L3JP55ZY.js.map} +0 -0
- /package/dist/{chunk-NLPIXQOV.js.map → chunk-LOSCIAHY.js.map} +0 -0
- /package/dist/{chunk-GFWCBYAI.js.map → chunk-MIJTZKWF.js.map} +0 -0
- /package/dist/{chunk-D4TKVZKB.js.map → chunk-OAETOHH3.js.map} +0 -0
- /package/dist/{chunk-SI3GXM7Z.js.map → chunk-PMGJQWSW.js.map} +0 -0
- /package/dist/{chunk-MYIRYP6D.js.map → chunk-Q7FDPJUS.js.map} +0 -0
- /package/dist/{chunk-N6B5BINC.js.map → chunk-R2RLNUNK.js.map} +0 -0
- /package/dist/{chunk-FQMPHPHE.js.map → chunk-RQLEGKEV.js.map} +0 -0
- /package/dist/{chunk-REERG473.js.map → chunk-UU54HN5I.js.map} +0 -0
- /package/dist/{chunk-E5RJLP2S.js.map → chunk-VMOUAWGD.js.map} +0 -0
- /package/dist/{chunk-6YUMHSBG.js.map → chunk-WLFZOBZR.js.map} +0 -0
- /package/dist/{chunk-UJ3TZF4Y.js.map → chunk-Y6QW3FJQ.js.map} +0 -0
- /package/dist/{chunks-QTVEFJOS.js.map → chunks-Q7242OJE.js.map} +0 -0
- /package/dist/{formula-DUHNPES2.js.map → formula-BYEDWWZU.js.map} +0 -0
- /package/dist/{formula-XNCKOV6K.js.map → formula-FQLMMBDP.js.map} +0 -0
- /package/dist/{generator-6BFIABTF.js.map → generator-Q3L7RNUY.js.map} +0 -0
- /package/dist/{generator-XJLIBYDJ.js.map → generator-SU73HZHR.js.map} +0 -0
- /package/dist/{memo-CNW6ZJFE.js.map → memo-T5ZQEXEA.js.map} +0 -0
- /package/dist/{model-bundle-TIHWFIN5.js.map → model-bundle-UJRQPYUU.js.map} +0 -0
- /package/dist/{models-YBHBEM6J.js.map → models-64YLAWTI.js.map} +0 -0
- /package/dist/{pdf-ocr-GEAW23FB.js.map → pdf-ocr-XTZZEYKJ.js.map} +0 -0
- /package/dist/{pdf-ocr-IJXT6ZJR.js.map → pdf-ocr-ZV3KYIIE.js.map} +0 -0
- /package/dist/{profile-io-Y7SMMS2R.js.map → profile-io-FAJORRD2.js.map} +0 -0
- /package/dist/{rasterize-MLEHT6PU.js.map → rasterize-4ZJUA2DZ.js.map} +0 -0
- /package/dist/{redact-doc-GPO2UTTJ.js.map → redact-doc-JPNROEH6.js.map} +0 -0
- /package/dist/{render-TNWY53S4.js.map → render-D4WBOBKI.js.map} +0 -0
- /package/dist/{rewrite-fallback-AHGTN757.js.map → rewrite-fallback-OF3QI6CX.js.map} +0 -0
- /package/dist/{seal-7HBR3HBQ.js.map → seal-DQWEHIAM.js.map} +0 -0
- /package/dist/{setup-TJ57DQ6I.js.map → setup-YC25YCQB.js.map} +0 -0
- /package/dist/{to-hwpx-6JF6Q2TZ.js.map → to-hwpx-D7OMPDUQ.js.map} +0 -0
- /package/dist/{to-hwpx-DLVARUND.js.map → to-hwpx-ZWN64NCQ.js.map} +0 -0
- /package/dist/{visual-VBDQUUKP.js.map → visual-SW7NPY6K.js.map} +0 -0
- /package/dist/{watch-6CHDQ355.js.map → watch-ZU576VSR.js.map} +0 -0
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var _chunkSJXTCW7Icjs = require('./chunk-SJXTCW7I.cjs');
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
var
|
|
7
|
+
var _chunkY4MFHEK4cjs = require('./chunk-Y4MFHEK4.cjs');
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
|
|
12
|
-
var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
13
11
|
|
|
14
12
|
|
|
15
13
|
|
|
@@ -63,16 +61,19 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
63
61
|
|
|
64
62
|
|
|
65
63
|
|
|
64
|
+
var _chunkUBY2PLKRcjs = require('./chunk-UBY2PLKR.cjs');
|
|
66
65
|
|
|
67
66
|
|
|
67
|
+
var _chunkMMK32GPDcjs = require('./chunk-MMK32GPD.cjs');
|
|
68
|
+
require('./chunk-IRAZCKQ6.cjs');
|
|
68
69
|
|
|
69
|
-
var _chunkA6EOKPKGcjs = require('./chunk-A6EOKPKG.cjs');
|
|
70
70
|
|
|
71
|
+
var _chunk6NZ32OTXcjs = require('./chunk-6NZ32OTX.cjs');
|
|
71
72
|
|
|
72
|
-
var _chunkMMK32GPDcjs = require('./chunk-MMK32GPD.cjs');
|
|
73
|
-
require('./chunk-LHZL52HO.cjs');
|
|
74
73
|
|
|
75
74
|
|
|
75
|
+
var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
76
|
+
|
|
76
77
|
|
|
77
78
|
|
|
78
79
|
|
|
@@ -87,11 +88,12 @@ require('./chunk-LHZL52HO.cjs');
|
|
|
87
88
|
|
|
88
89
|
|
|
89
90
|
|
|
90
|
-
var _chunkYFTD6WOPcjs = require('./chunk-YFTD6WOP.cjs');
|
|
91
91
|
|
|
92
|
+
var _chunkTQOAPKLUcjs = require('./chunk-TQOAPKLU.cjs');
|
|
92
93
|
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
|
|
96
|
+
var _chunkPW7MQZI4cjs = require('./chunk-PW7MQZI4.cjs');
|
|
95
97
|
|
|
96
98
|
|
|
97
99
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -347,8 +349,9 @@ var MIN_DIM = 8;
|
|
|
347
349
|
var MAX_PIXELS = 36e6;
|
|
348
350
|
var MAX_IMAGES_PER_DOC = 200;
|
|
349
351
|
var MAX_TOTAL_IMAGE_BYTES = 128 * 1024 * 1024;
|
|
350
|
-
|
|
351
|
-
|
|
352
|
+
var MAX_PENDING_RAW_BYTES = 64 * 1024 * 1024;
|
|
353
|
+
function createPdfImageState(blanked, webp) {
|
|
354
|
+
return { imageIndex: 0, totalBytes: 0, seen: /* @__PURE__ */ new Map(), globalKeys: /* @__PURE__ */ new Map(), capWarned: false, blanked, rawKeys: /* @__PURE__ */ new Map(), pdfiumGlobal: /* @__PURE__ */ new Map(), webp, pending: [], pendingRaw: 0, renamed: /* @__PURE__ */ new Map(), oversize: 0 };
|
|
352
355
|
}
|
|
353
356
|
function contentHash(data) {
|
|
354
357
|
return _crypto.createHash.call(void 0, "sha1").update(data).digest("hex");
|
|
@@ -437,7 +440,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
437
440
|
if (first) for (let k = 0; k < paints; k++) consume(first.raw);
|
|
438
441
|
continue;
|
|
439
442
|
}
|
|
440
|
-
if (capReached(state, pageNumber, warnings)) continue;
|
|
443
|
+
if (await capReached(state, pageNumber, warnings)) continue;
|
|
441
444
|
if (state.blanked) {
|
|
442
445
|
const w2 = op === _pdfmjs.OPS.paintImageXObject ? _optionalChain([argsArray, 'access', _9 => _9[i], 'optionalAccess', _10 => _10[1]]) : void 0;
|
|
443
446
|
const h2 = op === _pdfmjs.OPS.paintImageXObject ? _optionalChain([argsArray, 'access', _11 => _11[i], 'optionalAccess', _12 => _12[2]]) : void 0;
|
|
@@ -467,7 +470,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
467
470
|
} else if (op !== _pdfmjs.OPS.paintInlineImageXObject) {
|
|
468
471
|
continue;
|
|
469
472
|
}
|
|
470
|
-
if (capReached(state, pageNumber, warnings)) continue;
|
|
473
|
+
if (await capReached(state, pageNumber, warnings)) continue;
|
|
471
474
|
if (fromPristine) {
|
|
472
475
|
if (!pristine) {
|
|
473
476
|
const p = await (await state.blanked.pristine()).getPage(pageNumber);
|
|
@@ -499,13 +502,9 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
499
502
|
const rgba = toRgba(imgData, withBytes || !!readQr);
|
|
500
503
|
if (!rgba) continue;
|
|
501
504
|
state.imageIndex++;
|
|
502
|
-
const filename =
|
|
505
|
+
const filename = imageFilename(state, w, h);
|
|
503
506
|
state.seen.set(hash, filename);
|
|
504
|
-
if (withBytes)
|
|
505
|
-
const png = _chunkLBH4KAQMcjs.encodePng.call(void 0, w, h, rgba);
|
|
506
|
-
state.totalBytes += png.length;
|
|
507
|
-
images.push({ filename, data: png, mimeType: "image/png" });
|
|
508
|
-
}
|
|
507
|
+
if (withBytes) await pushImage(state, filename, w, h, rgba, images);
|
|
509
508
|
const qr = readQr ? await readQr({ data: rgba, width: w, height: h }) : [];
|
|
510
509
|
blocks.push({ type: "image", text: filename, pageNumber, ...qr.length ? { qr } : {} });
|
|
511
510
|
}
|
|
@@ -530,7 +529,8 @@ function pairingCounts(fnArray, argsArray, pdfium) {
|
|
|
530
529
|
for (const [size, n] of count) if (n !== 0) unpaired.add(size);
|
|
531
530
|
return unpaired;
|
|
532
531
|
}
|
|
533
|
-
function capReached(state, pageNumber, warnings) {
|
|
532
|
+
async function capReached(state, pageNumber, warnings) {
|
|
533
|
+
if (state.pending.length && state.totalBytes + state.pendingRaw * 1.1 + 1024 * state.pending.length >= MAX_TOTAL_IMAGE_BYTES) await drain(state, 0);
|
|
534
534
|
if (state.imageIndex < MAX_IMAGES_PER_DOC && state.totalBytes < MAX_TOTAL_IMAGE_BYTES) return false;
|
|
535
535
|
if (!state.capWarned) {
|
|
536
536
|
state.capWarned = true;
|
|
@@ -538,6 +538,51 @@ function capReached(state, pageNumber, warnings) {
|
|
|
538
538
|
}
|
|
539
539
|
return true;
|
|
540
540
|
}
|
|
541
|
+
async function pushImage(state, filename, w, h, rgba, images) {
|
|
542
|
+
if (!webpable(state, w, h)) {
|
|
543
|
+
if (state.webp) state.oversize++;
|
|
544
|
+
const png = _chunk6NZ32OTXcjs.encodePng.call(void 0, w, h, rgba);
|
|
545
|
+
state.totalBytes += png.length;
|
|
546
|
+
images.push({ filename, data: png, mimeType: "image/png" });
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
await drain(state, MAX_PENDING_RAW_BYTES - rgba.length);
|
|
550
|
+
const image = { filename, data: NO_BYTES, mimeType: "image/webp" };
|
|
551
|
+
images.push(image);
|
|
552
|
+
const done = state.webp(rgba, w, h).then(
|
|
553
|
+
(webp) => {
|
|
554
|
+
image.data = webp;
|
|
555
|
+
state.totalBytes += webp.length;
|
|
556
|
+
},
|
|
557
|
+
// 실패해도 파싱은 계속한다 — 그 그림만 PNG 로. 블록의 이름은 flushPdfImages 가 바꾼다
|
|
558
|
+
() => {
|
|
559
|
+
image.data = _chunk6NZ32OTXcjs.encodePng.call(void 0, w, h, rgba);
|
|
560
|
+
image.mimeType = "image/png";
|
|
561
|
+
image.filename = filename.replace(/\.webp$/, ".png");
|
|
562
|
+
state.totalBytes += image.data.length;
|
|
563
|
+
state.renamed.set(filename, image.filename);
|
|
564
|
+
}
|
|
565
|
+
);
|
|
566
|
+
state.pending.push({ done, raw: rgba.length });
|
|
567
|
+
state.pendingRaw += rgba.length;
|
|
568
|
+
}
|
|
569
|
+
async function drain(state, keep) {
|
|
570
|
+
while (state.pending.length && state.pendingRaw > keep) {
|
|
571
|
+
const p = state.pending.shift();
|
|
572
|
+
state.pendingRaw -= p.raw;
|
|
573
|
+
await p.done;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
async function flushPdfImages(state, warnings, pageImages) {
|
|
577
|
+
await drain(state, 0);
|
|
578
|
+
if (state.oversize) warnings.push({ message: `WebP \uD55C\uB3C4(\uAC00\uB85C\xB7\uC138\uB85C 16,383px)\uB97C \uB118\uB294 \uADF8\uB9BC ${state.oversize}\uAC1C\uB97C PNG \uB85C \uB0C8\uC2B5\uB2C8\uB2E4`, code: "SKIPPED_IMAGE" });
|
|
579
|
+
if (!state.renamed.size) return;
|
|
580
|
+
for (const list of pageImages.values()) for (const b of list) b.text = _nullishCoalesce(state.renamed.get(b.text), () => ( b.text));
|
|
581
|
+
warnings.push({ message: `WebP \uC778\uCF54\uB529 \uC2E4\uD328\uB85C \uADF8\uB9BC ${state.renamed.size}\uAC1C\uB97C PNG \uB85C \uB0C8\uC2B5\uB2C8\uB2E4`, code: "SKIPPED_IMAGE" });
|
|
582
|
+
}
|
|
583
|
+
var WEBP_MAX_DIM = 16383;
|
|
584
|
+
var webpable = (state, w, h) => !!state.webp && w <= WEBP_MAX_DIM && h <= WEBP_MAX_DIM;
|
|
585
|
+
var imageFilename = (state, w, h) => `image_${String(state.imageIndex).padStart(3, "0")}.${webpable(state, w, h) ? "webp" : "png"}`;
|
|
541
586
|
var UNDECODED = /* @__PURE__ */ Symbol("undecoded");
|
|
542
587
|
async function extractPdfiumImage(image, pageNumber, state, warnings, withBytes, images, readQr) {
|
|
543
588
|
const { width: w, height: h } = image;
|
|
@@ -553,13 +598,9 @@ async function extractPdfiumImage(image, pageNumber, state, warnings, withBytes,
|
|
|
553
598
|
state.rawKeys.set(image.raw, hash);
|
|
554
599
|
if (state.seen.has(hash)) return null;
|
|
555
600
|
state.imageIndex++;
|
|
556
|
-
const filename =
|
|
601
|
+
const filename = imageFilename(state, w, h);
|
|
557
602
|
state.seen.set(hash, filename);
|
|
558
|
-
if (withBytes)
|
|
559
|
-
const png = _chunkLBH4KAQMcjs.encodePng.call(void 0, w, h, rgba);
|
|
560
|
-
state.totalBytes += png.length;
|
|
561
|
-
images.push({ filename, data: png, mimeType: "image/png" });
|
|
562
|
-
}
|
|
603
|
+
if (withBytes) await pushImage(state, filename, w, h, rgba, images);
|
|
563
604
|
const qr = readQr ? await readQr({ data: rgba, width: w, height: h }) : [];
|
|
564
605
|
return { type: "image", text: filename, pageNumber, ...qr.length ? { qr } : {} };
|
|
565
606
|
}
|
|
@@ -951,13 +992,13 @@ function ocrVectorOps(opList, paths) {
|
|
|
951
992
|
|
|
952
993
|
// src/pdf/split-row-pattern.ts
|
|
953
994
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
954
|
-
var plain = (cell) => !_optionalChain([cell, 'access', _29 => _29.blocks, 'optionalAccess', _30 => _30.length]) && !
|
|
995
|
+
var plain = (cell) => !_optionalChain([cell, 'access', _29 => _29.blocks, 'optionalAccess', _30 => _30.length]) && !_chunkUBY2PLKRcjs.IMAGE_CELLS.has(cell);
|
|
955
996
|
var labelsOf = (cell) => {
|
|
956
997
|
const labels = textOf(cell).split("\n").map((s) => s.trim()).filter(Boolean);
|
|
957
998
|
return labels.length && labels.every((s) => /^\p{L}[\p{L}\p{N} ]{0,15}[::]$/u.test(s)) ? labels.map((s) => s.replace(/\s+/g, "").replace(/:/g, ":")) : void 0;
|
|
958
999
|
};
|
|
959
1000
|
var alignedLabels = (label, value, count) => {
|
|
960
|
-
const L =
|
|
1001
|
+
const L = _chunkUBY2PLKRcjs.CELL_LINES.get(label), V = _chunkUBY2PLKRcjs.CELL_LINES.get(value);
|
|
961
1002
|
let next = 0;
|
|
962
1003
|
return !!L && !!V && L.length === count && V.length >= count && Math.abs(L[0].y - V[0].y) <= 1 && L.every((l) => {
|
|
963
1004
|
while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
|
|
@@ -965,7 +1006,7 @@ var alignedLabels = (label, value, count) => {
|
|
|
965
1006
|
});
|
|
966
1007
|
};
|
|
967
1008
|
function partialAlignedLabelCells(table, owner, first) {
|
|
968
|
-
const pageOf = (a) => _nullishCoalesce(
|
|
1009
|
+
const pageOf = (a) => _nullishCoalesce(_chunkTQOAPKLUcjs.CELL_PAGES.get(_nullishCoalesce(a.cell, () => ( table.cells[a.r][a.c]))), () => ( (a.r < first ? -1 : -2)));
|
|
969
1010
|
const pairs = [];
|
|
970
1011
|
let carried = false;
|
|
971
1012
|
for (let c = 0; c < table.cols; ) {
|
|
@@ -988,10 +1029,10 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
988
1029
|
const keyed = pairs.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
|
|
989
1030
|
if (keyed.length !== 1) return;
|
|
990
1031
|
const label = keyed[0], value = pairs.find((p) => p.c === label.c + label.cs), context = pairs.find((p) => p.c + p.cs === label.c);
|
|
991
|
-
if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([
|
|
1032
|
+
if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([_chunkTQOAPKLUcjs.CELL_EDGES, 'access', _41 => _41.get, 'call', _42 => _42(context.upper), 'optionalAccess', _43 => _43.b]) || !_optionalChain([_chunkTQOAPKLUcjs.CELL_EDGES, 'access', _44 => _44.get, 'call', _45 => _45(context.lower), 'optionalAccess', _46 => _46.t])) return;
|
|
992
1033
|
const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
|
|
993
1034
|
if (D.length < 2 || sequence.length < 3 || new Set(sequence).size !== sequence.length || !alignedLabels(label.upper, value.upper, U.length)) return;
|
|
994
|
-
const L =
|
|
1035
|
+
const L = _chunkUBY2PLKRcjs.CELL_LINES.get(label.lower), V = _chunkUBY2PLKRcjs.CELL_LINES.get(value.lower);
|
|
995
1036
|
if (!L || !V || L.length !== D.length) return;
|
|
996
1037
|
let next = V.findIndex((v) => Math.abs(v.y - L[0].y) <= 1);
|
|
997
1038
|
if (next <= 0 || !V.slice(0, next).every((v) => v.y > L[0].y + 1) || !L.every((l) => {
|
|
@@ -1011,14 +1052,14 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
1011
1052
|
continue;
|
|
1012
1053
|
}
|
|
1013
1054
|
if (list.length < 3 || new Set(list).size !== list.length) continue;
|
|
1014
|
-
const visible = _nullishCoalesce(_optionalChain([
|
|
1055
|
+
const visible = _nullishCoalesce(_optionalChain([_chunkUBY2PLKRcjs.CELL_LINES, 'access', _51 => _51.get, 'call', _52 => _52(lc), 'optionalAccess', _53 => _53.length]), () => ( 0)), values = _chunkUBY2PLKRcjs.CELL_LINES.get(vc);
|
|
1015
1056
|
if (visible < 3 || visible > list.length || !values || !alignedLabels(lc, vc, visible)) continue;
|
|
1016
1057
|
const top = Math.max(...values.map((v2) => v2.y)), bottom = Math.min(...values.map((v2) => v2.y));
|
|
1017
1058
|
const contexts = [];
|
|
1018
1059
|
for (let rr = r; rr < r + l.rs && rr < table.rows; rr++) {
|
|
1019
1060
|
const a = _optionalChain([owner, 'access', _54 => _54[rr], 'optionalAccess', _55 => _55[context.c]]), cell = a ? table.cells[a.r][a.c] : void 0;
|
|
1020
1061
|
if (!a || a.r !== rr || a.c !== context.c || a.cs !== context.cs || a.rs !== 1 || !cell || !plain(cell) || !textOf(cell) || pageOf(a) !== pageOf(l)) break;
|
|
1021
|
-
const lines =
|
|
1062
|
+
const lines = _chunkUBY2PLKRcjs.CELL_LINES.get(cell);
|
|
1022
1063
|
if (!_optionalChain([lines, 'optionalAccess', _56 => _56.length]) || lines.some((line) => line.y > top + 1 || line.y < bottom - 1)) break;
|
|
1023
1064
|
contexts.push(textOf(cell).replace(/\s+/g, ""));
|
|
1024
1065
|
}
|
|
@@ -1320,7 +1361,7 @@ function rowStarts(t) {
|
|
|
1320
1361
|
}
|
|
1321
1362
|
var covering = (t, r) => rowStarts(t).slice(0, r + 1).flatMap((starts, rr) => starts.filter((s) => rr + s.cell.rowSpan > r).map((s) => s.cell));
|
|
1322
1363
|
function cellPage(cell) {
|
|
1323
|
-
const p =
|
|
1364
|
+
const p = _chunkTQOAPKLUcjs.CELL_PAGES.get(cell);
|
|
1324
1365
|
if (p !== void 0 || !_optionalChain([cell, 'access', _123 => _123.blocks, 'optionalAccess', _124 => _124.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
1325
1366
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
1326
1367
|
}
|
|
@@ -1349,7 +1390,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1349
1390
|
rows.forEach((starts, r) => {
|
|
1350
1391
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
1351
1392
|
for (const { cell } of starts) {
|
|
1352
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
1393
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkTQOAPKLUcjs.CELL_PAGES.set(cell, page2);
|
|
1353
1394
|
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _127 => _127.find, 'call', _128 => _128((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
|
|
1354
1395
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
1355
1396
|
}
|
|
@@ -1409,8 +1450,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1409
1450
|
if (!splits.length) continue;
|
|
1410
1451
|
const clone = (cell, patch) => {
|
|
1411
1452
|
const out = { ...cell, ...patch };
|
|
1412
|
-
const p =
|
|
1413
|
-
if (p !== void 0)
|
|
1453
|
+
const p = _chunkTQOAPKLUcjs.CELL_PAGES.get(cell);
|
|
1454
|
+
if (p !== void 0) _chunkTQOAPKLUcjs.CELL_PAGES.set(out, p);
|
|
1414
1455
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
1415
1456
|
return out;
|
|
1416
1457
|
};
|
|
@@ -1421,7 +1462,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1421
1462
|
for (const { cell, c, split } of splits) {
|
|
1422
1463
|
cells[r][c] = clone(cell, { ...split.head, rowSpan: cut - r });
|
|
1423
1464
|
const tail = { ...cell, ...split.tail, rowSpan: r + cell.rowSpan - cut };
|
|
1424
|
-
|
|
1465
|
+
_chunkTQOAPKLUcjs.CELL_PAGES.set(tail, split.page);
|
|
1425
1466
|
setSplits(tail, split.rest);
|
|
1426
1467
|
cells[cut][c] = tail;
|
|
1427
1468
|
}
|
|
@@ -1431,7 +1472,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1431
1472
|
for (const { cell, c, split } of splits) {
|
|
1432
1473
|
cells[r][c] = clone(cell, split.head);
|
|
1433
1474
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
1434
|
-
|
|
1475
|
+
_chunkTQOAPKLUcjs.CELL_PAGES.set(tail, split.page);
|
|
1435
1476
|
setSplits(tail, split.rest);
|
|
1436
1477
|
row[c] = tail;
|
|
1437
1478
|
}
|
|
@@ -1522,7 +1563,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1522
1563
|
if (cols < 1) return null;
|
|
1523
1564
|
const pa = anchorsOf(prev), ca = anchorsOf(curr);
|
|
1524
1565
|
const cutOpen = (() => {
|
|
1525
|
-
const u =
|
|
1566
|
+
const u = _chunkUBY2PLKRcjs.ROW_RULES.get(prev), d = _chunkUBY2PLKRcjs.ROW_RULES.get(curr);
|
|
1526
1567
|
return !!u && !!d && !u.bottom && !d.top;
|
|
1527
1568
|
})();
|
|
1528
1569
|
let skip = 0, head = 0;
|
|
@@ -1554,19 +1595,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1554
1595
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
1555
1596
|
}
|
|
1556
1597
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
1557
|
-
const lines =
|
|
1558
|
-
if (lines)
|
|
1559
|
-
if (
|
|
1560
|
-
const edges =
|
|
1598
|
+
const lines = _chunkUBY2PLKRcjs.CELL_LINES.get(a.cell);
|
|
1599
|
+
if (lines) _chunkUBY2PLKRcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
1600
|
+
if (_chunkUBY2PLKRcjs.IMAGE_CELLS.has(a.cell)) _chunkUBY2PLKRcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
1601
|
+
const edges = _chunkTQOAPKLUcjs.CELL_EDGES.get(a.cell);
|
|
1561
1602
|
if (edges) {
|
|
1562
|
-
|
|
1603
|
+
_chunkTQOAPKLUcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
1563
1604
|
edged = true;
|
|
1564
1605
|
}
|
|
1565
1606
|
return true;
|
|
1566
1607
|
};
|
|
1567
|
-
for (const a of pa) if (!
|
|
1608
|
+
for (const a of pa) if (!_chunkUBY2PLKRcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
1568
1609
|
for (const a of ca) {
|
|
1569
|
-
if (a.r < skip ||
|
|
1610
|
+
if (a.r < skip || _chunkUBY2PLKRcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
1570
1611
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
1571
1612
|
}
|
|
1572
1613
|
const first = prev.rows;
|
|
@@ -1590,9 +1631,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1590
1631
|
const grown = { ...above, rs: newRs };
|
|
1591
1632
|
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;
|
|
1592
1633
|
}
|
|
1593
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1634
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkUBY2PLKRcjs.FILLER_CELLS.add(grid[r][c]);
|
|
1594
1635
|
if (edged) {
|
|
1595
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1636
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkTQOAPKLUcjs.CELL_EDGES.set(grid[r][c], _chunkUBY2PLKRcjs.NO_EDGES);
|
|
1596
1637
|
}
|
|
1597
1638
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1598
1639
|
let r = prev.rows;
|
|
@@ -1601,7 +1642,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1601
1642
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1602
1643
|
}
|
|
1603
1644
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1604
|
-
const pr =
|
|
1645
|
+
const pr = _chunkUBY2PLKRcjs.ROW_RULES.get(prev), cr = _chunkUBY2PLKRcjs.ROW_RULES.get(curr);
|
|
1605
1646
|
const shifted = dx !== 0;
|
|
1606
1647
|
const cut = {
|
|
1607
1648
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1609,13 +1650,13 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1609
1650
|
list: !shifted ? "any" : skip > 0 && ca.filter((a) => a.r < skip && a.cell.text.trim()).length < 2 ? "none" : "multi"
|
|
1610
1651
|
};
|
|
1611
1652
|
let partial = !skip && cols === prev.cols && cols === curr.cols && cut.ruled && prevBottom !== void 0 ? partialAlignedLabelCells(table, owner, first) : void 0;
|
|
1612
|
-
if (partial && (continuesAcross(partial.context.upper, partial.context.lower, U[partial.context.c], U[partial.context.c + partial.context.cs]) || clauseContinues(partial.context.upper, partial.context.lower) || quantityContinues(partial.context.upper, partial.context.lower) || !continuesAcross(partial.value.upper, partial.value.lower, U[partial.value.c], U[partial.value.c + partial.value.cs]) ||
|
|
1653
|
+
if (partial && (continuesAcross(partial.context.upper, partial.context.lower, U[partial.context.c], U[partial.context.c + partial.context.cs]) || clauseContinues(partial.context.upper, partial.context.lower) || quantityContinues(partial.context.upper, partial.context.lower) || !continuesAcross(partial.value.upper, partial.value.lower, U[partial.value.c], U[partial.value.c + partial.value.cs]) || _chunkUBY2PLKRcjs.startsNewItem.call(void 0, partial.value.upper.text, partial.value.lower.text))) partial = void 0;
|
|
1613
1654
|
const selected = partial ? /* @__PURE__ */ new Set([partial.label.c, partial.value.c]) : void 0;
|
|
1614
1655
|
let split = !selected && rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
|
|
1615
1656
|
if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U, selected) && !selected) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
|
|
1616
1657
|
if (pr && cr) {
|
|
1617
1658
|
const cutRuled = pr.bottom || cr.top;
|
|
1618
|
-
|
|
1659
|
+
_chunkUBY2PLKRcjs.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) });
|
|
1619
1660
|
}
|
|
1620
1661
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1621
1662
|
}
|
|
@@ -1677,18 +1718,18 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1677
1718
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1678
1719
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1679
1720
|
if (selected && !selected.has(u.c)) continue;
|
|
1680
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1681
|
-
const openSeam = hasContent(a) && hasContent(b) &&
|
|
1721
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkUBY2PLKRcjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
1722
|
+
const openSeam = hasContent(a) && hasContent(b) && _chunkUBY2PLKRcjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
|
|
1682
1723
|
if (!r || r === first) return false;
|
|
1683
1724
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1684
1725
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1685
|
-
const ue =
|
|
1726
|
+
const ue = _chunkTQOAPKLUcjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkTQOAPKLUcjs.CELL_EDGES.get(table.cells[down.r][down.c]);
|
|
1686
1727
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1687
1728
|
});
|
|
1688
1729
|
if (!selected && !openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1689
1730
|
if (!straddles && !midWord) continue;
|
|
1690
1731
|
if (u.r >= last && d.rs < 2) continue;
|
|
1691
|
-
const U =
|
|
1732
|
+
const U = _chunkUBY2PLKRcjs.CELL_LINES.get(a);
|
|
1692
1733
|
if (!_optionalChain([U, 'optionalAccess', _154 => _154.length]) || !hasContent(b)) continue;
|
|
1693
1734
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1694
1735
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -1706,7 +1747,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1706
1747
|
return merged;
|
|
1707
1748
|
}
|
|
1708
1749
|
function longLastLine(c) {
|
|
1709
|
-
const L =
|
|
1750
|
+
const L = _chunkUBY2PLKRcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _155 => _155[L.length - 1]]);
|
|
1710
1751
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1711
1752
|
}
|
|
1712
1753
|
function filledToBottom(U, bottom) {
|
|
@@ -1739,7 +1780,7 @@ function nextItemHead(prev, next) {
|
|
|
1739
1780
|
return false;
|
|
1740
1781
|
}
|
|
1741
1782
|
function continuesAcross(u, d, x1, x2) {
|
|
1742
|
-
const U =
|
|
1783
|
+
const U = _chunkUBY2PLKRcjs.CELL_LINES.get(u), D = _chunkUBY2PLKRcjs.CELL_LINES.get(d);
|
|
1743
1784
|
if (!_optionalChain([U, 'optionalAccess', _156 => _156.length]) || !_optionalChain([D, 'optionalAccess', _157 => _157.length])) return false;
|
|
1744
1785
|
const last = U[U.length - 1];
|
|
1745
1786
|
const fs = last.h || 10;
|
|
@@ -1757,7 +1798,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1757
1798
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1758
1799
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1759
1800
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1760
|
-
const newItem =
|
|
1801
|
+
const newItem = _chunkUBY2PLKRcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1761
1802
|
const all = D.length ? U.concat(D) : U;
|
|
1762
1803
|
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));
|
|
1763
1804
|
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;
|
|
@@ -1774,10 +1815,10 @@ function outlineContinues(u, d) {
|
|
|
1774
1815
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1775
1816
|
}
|
|
1776
1817
|
function lineEnded(c, x1, x2, next) {
|
|
1777
|
-
const L =
|
|
1818
|
+
const L = _chunkUBY2PLKRcjs.CELL_LINES.get(c);
|
|
1778
1819
|
if (!L || L.length !== 1) return false;
|
|
1779
1820
|
const l = L[0], h = l.h || 10;
|
|
1780
|
-
const d0 = next ? _optionalChain([
|
|
1821
|
+
const d0 = next ? _optionalChain([_chunkUBY2PLKRcjs.CELL_LINES, 'access', _158 => _158.get, 'call', _159 => _159(next), 'optionalAccess', _160 => _160[0]]) : void 0;
|
|
1781
1822
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1782
1823
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _161 => _161.text]), () => ( "")))) * h;
|
|
1783
1824
|
}
|
|
@@ -1788,15 +1829,15 @@ function firstWordUnits(text) {
|
|
|
1788
1829
|
return units;
|
|
1789
1830
|
}
|
|
1790
1831
|
function appendCell(a, b) {
|
|
1791
|
-
if (
|
|
1832
|
+
if (_chunkUBY2PLKRcjs.IMAGE_CELLS.has(b)) _chunkUBY2PLKRcjs.IMAGE_CELLS.add(a);
|
|
1792
1833
|
if (_optionalChain([a, 'access', _162 => _162.blocks, 'optionalAccess', _163 => _163.length]) || _optionalChain([b, 'access', _164 => _164.blocks, 'optionalAccess', _165 => _165.length])) {
|
|
1793
1834
|
const asBlocks = (c) => _optionalChain([c, 'access', _166 => _166.blocks, 'optionalAccess', _167 => _167.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
|
|
1794
1835
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1795
1836
|
}
|
|
1796
1837
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1797
|
-
|
|
1838
|
+
_chunkUBY2PLKRcjs.joinCellEdges.call(void 0, a, b);
|
|
1798
1839
|
}
|
|
1799
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _168 => _168.blocks, 'optionalAccess', _169 => _169.length]) ||
|
|
1840
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _168 => _168.blocks, 'optionalAccess', _169 => _169.length]) || _chunkUBY2PLKRcjs.IMAGE_CELLS.has(cell);
|
|
1800
1841
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1801
1842
|
var batchim = (ch) => {
|
|
1802
1843
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1804,7 +1845,7 @@ var batchim = (ch) => {
|
|
|
1804
1845
|
};
|
|
1805
1846
|
function clauseContinues(u, d) {
|
|
1806
1847
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1807
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1848
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkUBY2PLKRcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1808
1849
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1809
1850
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1810
1851
|
}
|
|
@@ -1812,8 +1853,8 @@ function quantityContinues(u, d) {
|
|
|
1812
1853
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1813
1854
|
}
|
|
1814
1855
|
function wordOverflows(u, d, x1, x2) {
|
|
1815
|
-
const U =
|
|
1816
|
-
if (!_optionalChain([U, 'optionalAccess', _170 => _170.length]) ||
|
|
1856
|
+
const U = _chunkUBY2PLKRcjs.CELL_LINES.get(u);
|
|
1857
|
+
if (!_optionalChain([U, 'optionalAccess', _170 => _170.length]) || _chunkUBY2PLKRcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1817
1858
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1818
1859
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1819
1860
|
}
|
|
@@ -1882,7 +1923,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1882
1923
|
if (!carriedSplit && !band) {
|
|
1883
1924
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1884
1925
|
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;
|
|
1885
|
-
const oneLine = (c) => _optionalChain([
|
|
1926
|
+
const oneLine = (c) => _optionalChain([_chunkUBY2PLKRcjs.CELL_LINES, 'access', _172 => _172.get, 'call', _173 => _173(c), 'optionalAccess', _174 => _174.length]) === 1;
|
|
1886
1927
|
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;
|
|
1887
1928
|
if (cut.ruled && pairs.some(([u, d]) => u.rs >= 2 && hasContent(u.cell) && hasContent(d.cell) && oneLine(cell(u)) && oneLine(cell(d)) && norm(cell(u)) !== norm(cell(d)))) return false;
|
|
1888
1929
|
const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d)) || quantityContinues(cell(u), cell(d));
|
|
@@ -1975,19 +2016,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1975
2016
|
placeJoined(blocks, i, j, joined);
|
|
1976
2017
|
continue;
|
|
1977
2018
|
}
|
|
1978
|
-
if (
|
|
2019
|
+
if (_chunkUBY2PLKRcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1979
2020
|
blocks.splice(j, 1);
|
|
1980
2021
|
i++;
|
|
1981
2022
|
continue;
|
|
1982
2023
|
}
|
|
1983
2024
|
if (joined === null) continue;
|
|
1984
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
2025
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkUBY2PLKRcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1985
2026
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1986
2027
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1987
2028
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1988
2029
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1989
|
-
const px =
|
|
1990
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
2030
|
+
const px = _chunkUBY2PLKRcjs.TABLE_COLXS.get(prev.table), cx = _chunkUBY2PLKRcjs.TABLE_COLXS.get(curr.table);
|
|
2031
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkUBY2PLKRcjs.CLIP_TABLES.has(prev.table) && !_chunkUBY2PLKRcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1991
2032
|
if (!px !== !cx) continue;
|
|
1992
2033
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1993
2034
|
let currCells = curr.table.cells;
|
|
@@ -1999,16 +2040,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1999
2040
|
blocks.splice(j, 1);
|
|
2000
2041
|
continue;
|
|
2001
2042
|
}
|
|
2002
|
-
if (px && cx && !
|
|
2043
|
+
if (px && cx && !_chunkUBY2PLKRcjs.CLIP_TABLES.has(prev.table) && !_chunkUBY2PLKRcjs.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 && _chunkUBY2PLKRcjs.CELL_LINES.has(c))) {
|
|
2003
2044
|
const dx = px[0] - cx[0];
|
|
2004
2045
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
2005
2046
|
if (_optionalChain([part, 'optionalAccess', _195 => _195.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
2006
2047
|
const last = prev.table.rows - 1;
|
|
2007
2048
|
for (let c = 0; c < part.table.cols; c++) {
|
|
2008
|
-
const U =
|
|
2009
|
-
|
|
2049
|
+
const U = _chunkUBY2PLKRcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkUBY2PLKRcjs.CELL_LINES.get(currCells[0][c]);
|
|
2050
|
+
_chunkUBY2PLKRcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
2010
2051
|
}
|
|
2011
|
-
|
|
2052
|
+
_chunkUBY2PLKRcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
2012
2053
|
placeJoined(blocks, i, j, part.table);
|
|
2013
2054
|
continue;
|
|
2014
2055
|
}
|
|
@@ -2021,20 +2062,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
2021
2062
|
caption: prev.table.caption,
|
|
2022
2063
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
2023
2064
|
};
|
|
2024
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
2025
|
-
if (
|
|
2065
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkUBY2PLKRcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
2066
|
+
if (_chunkUBY2PLKRcjs.CLIP_TABLES.has(prev.table) || _chunkUBY2PLKRcjs.CLIP_TABLES.has(curr.table)) _chunkUBY2PLKRcjs.CLIP_TABLES.add(merged);
|
|
2026
2067
|
placeJoined(blocks, i, j, merged);
|
|
2027
2068
|
}
|
|
2028
2069
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
2029
2070
|
const t = blocks[i].table;
|
|
2030
|
-
if (blocks[i].type === "table" && t &&
|
|
2071
|
+
if (blocks[i].type === "table" && t && _chunkUBY2PLKRcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
2031
2072
|
}
|
|
2032
2073
|
}
|
|
2033
2074
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
2034
2075
|
if (!pageHeights) return;
|
|
2035
2076
|
for (let i = 0; i < blocks.length; i++) {
|
|
2036
2077
|
const L = blocks[i];
|
|
2037
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
2078
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkUBY2PLKRcjs.CLIP_TABLES.has(L.table) || _chunkUBY2PLKRcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
2038
2079
|
const ph = pageHeights.get(L.pageNumber);
|
|
2039
2080
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
2040
2081
|
let s0 = i, s1 = i;
|
|
@@ -2053,8 +2094,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
2053
2094
|
if (Math.abs(R.bbox.width - L.bbox.width) > Math.max(R.bbox.width, L.bbox.width) * NEIGHBOR_TABLE_EPSILON) continue;
|
|
2054
2095
|
if (!looksContinued(L, R) || restartsTable(blocks, i, R.table, pageHeights)) continue;
|
|
2055
2096
|
const rt = R.table;
|
|
2056
|
-
if (rt.rows === 1 && rt.cols === 1 && !
|
|
2057
|
-
const px =
|
|
2097
|
+
if (rt.rows === 1 && rt.cols === 1 && !_chunkUBY2PLKRcjs.CLIP_TABLES.has(rt) && L.table.rows >= 2) {
|
|
2098
|
+
const px = _chunkUBY2PLKRcjs.TABLE_COLXS.get(L.table), lb = L.bbox;
|
|
2058
2099
|
const dx = lb.x + lb.width - (R.bbox.x + R.bbox.width);
|
|
2059
2100
|
const last = L.table.cells[L.table.rows - 1];
|
|
2060
2101
|
let col = 0;
|
|
@@ -2083,8 +2124,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
2083
2124
|
}
|
|
2084
2125
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
2085
2126
|
const pt = prev.table, ct = curr.table;
|
|
2086
|
-
if (!
|
|
2087
|
-
const px =
|
|
2127
|
+
if (!_chunkUBY2PLKRcjs.CLIP_TABLES.has(pt) || !_chunkUBY2PLKRcjs.CLIP_TABLES.has(ct)) return null;
|
|
2128
|
+
const px = _chunkUBY2PLKRcjs.TABLE_COLXS.get(pt), cx = _chunkUBY2PLKRcjs.TABLE_COLXS.get(ct);
|
|
2088
2129
|
if (!px || !cx) return null;
|
|
2089
2130
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
2090
2131
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -2100,15 +2141,15 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
2100
2141
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
2101
2142
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
2102
2143
|
};
|
|
2103
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
2144
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkUBY2PLKRcjs.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);
|
|
2104
2145
|
}
|
|
2105
2146
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _200 => _200.bbox, 'optionalAccess', _201 => _201.y]), lex);
|
|
2106
2147
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
2107
|
-
|
|
2108
|
-
const ys =
|
|
2109
|
-
if (ys)
|
|
2110
|
-
|
|
2111
|
-
|
|
2148
|
+
_chunkUBY2PLKRcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
2149
|
+
const ys = _chunkUBY2PLKRcjs.TABLE_ROWYS.get(pt);
|
|
2150
|
+
if (ys) _chunkUBY2PLKRcjs.TABLE_ROWYS.set(res.table, ys);
|
|
2151
|
+
_chunkUBY2PLKRcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkUBY2PLKRcjs.PART_COLXS.get(pt), () => ( px)));
|
|
2152
|
+
_chunkUBY2PLKRcjs.CLIP_TABLES.add(res.table);
|
|
2112
2153
|
return res.table;
|
|
2113
2154
|
}
|
|
2114
2155
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
@@ -2132,12 +2173,12 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
2132
2173
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
2133
2174
|
}
|
|
2134
2175
|
function pushedLead(prev, curr) {
|
|
2135
|
-
if (!
|
|
2176
|
+
if (!_chunkUBY2PLKRcjs.CLIP_TABLES.has(prev.table) || !_chunkUBY2PLKRcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
2136
2177
|
const lead = leadRows(curr.table);
|
|
2137
2178
|
return lead.image && lead.height > prev.bbox.y;
|
|
2138
2179
|
}
|
|
2139
2180
|
function leadRows(t) {
|
|
2140
|
-
const ys =
|
|
2181
|
+
const ys = _chunkUBY2PLKRcjs.TABLE_ROWYS.get(t);
|
|
2141
2182
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
2142
2183
|
const anchors = anchorsOf(t);
|
|
2143
2184
|
let end = 1, image = false;
|
|
@@ -2145,17 +2186,17 @@ function leadRows(t) {
|
|
|
2145
2186
|
for (const a of anchors) {
|
|
2146
2187
|
if (a.r !== r) continue;
|
|
2147
2188
|
end = Math.max(end, r + a.rs);
|
|
2148
|
-
if (
|
|
2189
|
+
if (_chunkUBY2PLKRcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
2149
2190
|
}
|
|
2150
2191
|
}
|
|
2151
2192
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
2152
2193
|
}
|
|
2153
2194
|
function tailOf(b) {
|
|
2154
|
-
const t = b.table &&
|
|
2195
|
+
const t = b.table && _chunkUBY2PLKRcjs.TABLE_TAIL.get(b.table);
|
|
2155
2196
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
2156
2197
|
}
|
|
2157
2198
|
function firstRowSig(t) {
|
|
2158
|
-
const x =
|
|
2199
|
+
const x = _chunkUBY2PLKRcjs.TABLE_COLXS.get(t);
|
|
2159
2200
|
if (!x || x.length !== t.cols + 1) return null;
|
|
2160
2201
|
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, "") }));
|
|
2161
2202
|
}
|
|
@@ -2208,7 +2249,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
2208
2249
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
2209
2250
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
2210
2251
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
2211
|
-
const px =
|
|
2252
|
+
const px = _chunkUBY2PLKRcjs.TABLE_COLXS.get(pb.table), cx = _chunkUBY2PLKRcjs.TABLE_COLXS.get(cur.table);
|
|
2212
2253
|
if (!px || !cx) break;
|
|
2213
2254
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
2214
2255
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -2279,7 +2320,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
2279
2320
|
var COL_MATCH_TOL = 0.5;
|
|
2280
2321
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
2281
2322
|
function lastRowCell(t, x1, x2) {
|
|
2282
|
-
const xs =
|
|
2323
|
+
const xs = _chunkUBY2PLKRcjs.TABLE_COLXS.get(t);
|
|
2283
2324
|
const covered = /* @__PURE__ */ new Set();
|
|
2284
2325
|
for (let r = 0; r < t.rows; r++) {
|
|
2285
2326
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -2297,7 +2338,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
2297
2338
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
2298
2339
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
2299
2340
|
const part = blocks[j];
|
|
2300
|
-
const from = part.table ?
|
|
2341
|
+
const from = part.table ? _chunkUBY2PLKRcjs.CONT_PARTS.get(part.table) : void 0;
|
|
2301
2342
|
if (!from || !part.table) {
|
|
2302
2343
|
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
2303
2344
|
continue;
|
|
@@ -2313,12 +2354,12 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
2313
2354
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
2314
2355
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
2315
2356
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
2316
|
-
if (
|
|
2317
|
-
|
|
2318
|
-
const lines =
|
|
2319
|
-
if (_optionalChain([lines, 'optionalAccess', _225 => _225.length]))
|
|
2320
|
-
if (part.pageNumber && part.bbox)
|
|
2321
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _226 => _226.blocks, 'optionalAccess', _227 => _227.length]) ||
|
|
2357
|
+
if (_chunkUBY2PLKRcjs.IMAGE_CELLS.has(add)) _chunkUBY2PLKRcjs.IMAGE_CELLS.add(cell);
|
|
2358
|
+
_chunkUBY2PLKRcjs.joinCellEdges.call(void 0, cell, add);
|
|
2359
|
+
const lines = _chunkUBY2PLKRcjs.CELL_LINES.get(add);
|
|
2360
|
+
if (_optionalChain([lines, 'optionalAccess', _225 => _225.length])) _chunkUBY2PLKRcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkUBY2PLKRcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
2361
|
+
if (part.pageNumber && part.bbox) _chunkUBY2PLKRcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkUBY2PLKRcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
2362
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _226 => _226.blocks, 'optionalAccess', _227 => _227.length]) || _chunkUBY2PLKRcjs.IMAGE_CELLS.has(cell)) _chunkUBY2PLKRcjs.EMPTY_PARTS.delete(prev.table);
|
|
2322
2363
|
blocks.splice(j, 1);
|
|
2323
2364
|
if (cell.blocks && at > 0) {
|
|
2324
2365
|
const nextAt = cell.blocks[at];
|
|
@@ -2330,11 +2371,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
2330
2371
|
}
|
|
2331
2372
|
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
2332
2373
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
2333
|
-
if (!_optionalChain([prev, 'optionalAccess', _228 => _228.table]) || !_optionalChain([frame, 'optionalAccess', _229 => _229.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !
|
|
2374
|
+
if (!_optionalChain([prev, 'optionalAccess', _228 => _228.table]) || !_optionalChain([frame, 'optionalAccess', _229 => _229.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkUBY2PLKRcjs.CLIP_TABLES.has(frame.table)) return;
|
|
2334
2375
|
const inner = _optionalChain([frame, 'access', _230 => _230.table, 'access', _231 => _231.cells, 'access', _232 => _232[0], 'optionalAccess', _233 => _233[0], 'optionalAccess', _234 => _234.blocks]);
|
|
2335
2376
|
const next = _optionalChain([inner, 'optionalAccess', _235 => _235[0]]);
|
|
2336
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _236 => _236.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
2337
|
-
const px =
|
|
2377
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _236 => _236.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkUBY2PLKRcjs.CLIP_TABLES.has(prev.table) || !_chunkUBY2PLKRcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
2378
|
+
const px = _chunkUBY2PLKRcjs.TABLE_COLXS.get(prev.table), nx = _chunkUBY2PLKRcjs.TABLE_COLXS.get(next.table);
|
|
2338
2379
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
2339
2380
|
const ph = _optionalChain([pageHeights, 'optionalAccess', _237 => _237.get, 'call', _238 => _238(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _239 => _239.get, 'call', _240 => _240(next.pageNumber)]);
|
|
2340
2381
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
@@ -2344,15 +2385,15 @@ function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
|
2344
2385
|
function fillNestedContinuation(blocks, at) {
|
|
2345
2386
|
const prev = blocks[at - 1], next = blocks[at];
|
|
2346
2387
|
const t = _optionalChain([prev, 'optionalAccess', _243 => _243.table]), u = _optionalChain([next, 'optionalAccess', _244 => _244.table]);
|
|
2347
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
2348
|
-
const xs =
|
|
2388
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkUBY2PLKRcjs.CLIP_TABLES.has(t) || !_chunkUBY2PLKRcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
2389
|
+
const xs = _chunkUBY2PLKRcjs.TABLE_COLXS.get(u);
|
|
2349
2390
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
2350
2391
|
const add = _optionalChain([u, 'access', _245 => _245.cells, 'access', _246 => _246[0], 'optionalAccess', _247 => _247[0]]);
|
|
2351
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _248 => _248.blocks, 'optionalAccess', _249 => _249.length]) ||
|
|
2392
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _248 => _248.blocks, 'optionalAccess', _249 => _249.length]) || _chunkUBY2PLKRcjs.IMAGE_CELLS.has(cell)) return;
|
|
2352
2393
|
cell.text = add.text;
|
|
2353
2394
|
if (add.blocks) cell.blocks = add.blocks;
|
|
2354
|
-
if (
|
|
2355
|
-
|
|
2395
|
+
if (_chunkUBY2PLKRcjs.IMAGE_CELLS.has(add)) _chunkUBY2PLKRcjs.IMAGE_CELLS.add(cell);
|
|
2396
|
+
_chunkUBY2PLKRcjs.joinCellEdges.call(void 0, cell, add);
|
|
2356
2397
|
blocks.splice(at, 1);
|
|
2357
2398
|
}
|
|
2358
2399
|
|
|
@@ -2952,12 +2993,12 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
2952
2993
|
}
|
|
2953
2994
|
}
|
|
2954
2995
|
for (const q of queues.values()) for (let k = 0; k < q.length; k++) {
|
|
2955
|
-
const pair = k + 1 < q.length ?
|
|
2996
|
+
const pair = k + 1 < q.length ? _chunkTQOAPKLUcjs.pairedNumber.call(void 0, q[k], q[k + 1]) : void 0;
|
|
2956
2997
|
if (pair !== void 0) {
|
|
2957
2998
|
q[k] = pair;
|
|
2958
2999
|
q[k + 1] = "";
|
|
2959
3000
|
k++;
|
|
2960
|
-
} else q[k] =
|
|
3001
|
+
} else q[k] = _chunkTQOAPKLUcjs.mapPuaText.call(void 0, q[k]);
|
|
2961
3002
|
}
|
|
2962
3003
|
const byFont = /* @__PURE__ */ new Map();
|
|
2963
3004
|
for (const it of items) {
|
|
@@ -3047,15 +3088,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
3047
3088
|
function marginContextBlocks(raw, page, view) {
|
|
3048
3089
|
const [x1, y1, x2, y2] = view;
|
|
3049
3090
|
const width = x2 - x1, height = y2 - y1;
|
|
3050
|
-
const items =
|
|
3091
|
+
const items = _chunkUBY2PLKRcjs.filterHiddenText.call(void 0, _chunkUBY2PLKRcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
3051
3092
|
for (const item of items) {
|
|
3052
3093
|
item.x -= x1;
|
|
3053
3094
|
item.y -= y1;
|
|
3054
3095
|
}
|
|
3055
|
-
return
|
|
3056
|
-
const bbox =
|
|
3096
|
+
return _chunkUBY2PLKRcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
3097
|
+
const bbox = _chunkUBY2PLKRcjs.computeBBox.call(void 0, line, page);
|
|
3057
3098
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
3058
|
-
return [{ type: "paragraph", text:
|
|
3099
|
+
return [{ type: "paragraph", text: _chunkUBY2PLKRcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkUBY2PLKRcjs.dominantStyle.call(void 0, line) }];
|
|
3059
3100
|
});
|
|
3060
3101
|
}
|
|
3061
3102
|
|
|
@@ -3091,7 +3132,7 @@ var WINANSI_REVERSE = {
|
|
|
3091
3132
|
};
|
|
3092
3133
|
function symbolFontTable(fontName) {
|
|
3093
3134
|
if (!fontName) return void 0;
|
|
3094
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
3135
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkTQOAPKLUcjs.WINGDINGS;
|
|
3095
3136
|
return void 0;
|
|
3096
3137
|
}
|
|
3097
3138
|
function remapSymbolText(text, table) {
|
|
@@ -3324,7 +3365,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
3324
3365
|
for (const i of members) drop.add(i);
|
|
3325
3366
|
const toks = cur.map((it) => {
|
|
3326
3367
|
const bar2 = isBarItem(it);
|
|
3327
|
-
const text = bar2 ? "" : plain2.has(items.indexOf(it)) ?
|
|
3368
|
+
const text = bar2 ? "" : plain2.has(items.indexOf(it)) ? _chunkTQOAPKLUcjs.toTex.call(void 0, it.text) : FUNC_RE.test(it.text.trim()) ? it.text.trim() : [...it.text].map(decodeEq).join("");
|
|
3328
3369
|
return { text, x: it.x, y: it.y, w: it.w, size: sizeOf(it), bar: bar2 };
|
|
3329
3370
|
});
|
|
3330
3371
|
const tex = layout(toks).replace(/\}\\text\{/g, "");
|
|
@@ -4164,7 +4205,7 @@ function mergeEnclosedDigits(items) {
|
|
|
4164
4205
|
if (!/^\d\d?$/.test(digits)) continue;
|
|
4165
4206
|
const mid = (inside2[0].x + inside2[inside2.length - 1].x + inside2[inside2.length - 1].w) / 2;
|
|
4166
4207
|
if (Math.abs(mid - (s.x + s.w / 2)) > s.fontSize * 0.15) continue;
|
|
4167
|
-
s.text =
|
|
4208
|
+
s.text = _chunkTQOAPKLUcjs.enclosedNumber.call(void 0, Number(digits));
|
|
4168
4209
|
for (const d of inside2) drop.add(d);
|
|
4169
4210
|
}
|
|
4170
4211
|
if (!drop.size) return;
|
|
@@ -4361,7 +4402,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
4361
4402
|
if (block.type !== "heading" || !block.text) continue;
|
|
4362
4403
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
4363
4404
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _331 => _331.style, 'optionalAccess', _332 => _332.fontSize]), () => ( 0));
|
|
4364
|
-
const tocEntry = i > 0 &&
|
|
4405
|
+
const tocEntry = i > 0 && _chunkUBY2PLKRcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkUBY2PLKRcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
4365
4406
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
4366
4407
|
const proseStyle = _optionalChain([block, 'access', _333 => _333.style, 'optionalAccess', _334 => _334.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
4367
4408
|
const next = blocks[i + 1];
|
|
@@ -4459,7 +4500,7 @@ function splitSingleCellTables(blocks) {
|
|
|
4459
4500
|
const out = [];
|
|
4460
4501
|
for (const b of blocks) {
|
|
4461
4502
|
const t = b.type === "table" ? b.table : void 0;
|
|
4462
|
-
const title = t &&
|
|
4503
|
+
const title = t && _chunkUBY2PLKRcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
4463
4504
|
if (title) {
|
|
4464
4505
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
4465
4506
|
continue;
|
|
@@ -4495,7 +4536,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
4495
4536
|
const lines = cell.text.split("\n");
|
|
4496
4537
|
const out = [lines[0]];
|
|
4497
4538
|
for (const line of lines.slice(1)) {
|
|
4498
|
-
if (
|
|
4539
|
+
if (_chunkUBY2PLKRcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
4499
4540
|
else out.push(line);
|
|
4500
4541
|
}
|
|
4501
4542
|
cell.text = out.join("\n");
|
|
@@ -4515,10 +4556,10 @@ function cleanPdfText(text, opts) {
|
|
|
4515
4556
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
4516
4557
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
4517
4558
|
if (line.startsWith("|")) {
|
|
4518
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
4559
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkUBY2PLKRcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
4519
4560
|
}
|
|
4520
4561
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _414 => _414.exec, 'call', _415 => _415(line), 'optionalAccess', _416 => _416[0]]), () => ( ""));
|
|
4521
|
-
return mark +
|
|
4562
|
+
return mark + _chunkUBY2PLKRcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
4522
4563
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
4523
4564
|
}
|
|
4524
4565
|
function startsWithMarker(line) {
|
|
@@ -4550,7 +4591,7 @@ function mergeKoreanLines(text) {
|
|
|
4550
4591
|
continue;
|
|
4551
4592
|
}
|
|
4552
4593
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
4553
|
-
result[result.length - 1] = prev +
|
|
4594
|
+
result[result.length - 1] = prev + _chunkUBY2PLKRcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
4554
4595
|
} else {
|
|
4555
4596
|
result.push(curr);
|
|
4556
4597
|
}
|
|
@@ -4566,7 +4607,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
4566
4607
|
const wrapped = /* @__PURE__ */ new Set();
|
|
4567
4608
|
for (const a of annots) {
|
|
4568
4609
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
4569
|
-
const url =
|
|
4610
|
+
const url = _chunkPW7MQZI4cjs.sanitizeHref.call(void 0, a.url);
|
|
4570
4611
|
if (!url) continue;
|
|
4571
4612
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
4572
4613
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -4618,7 +4659,7 @@ function mergeLinkRuns(markdown) {
|
|
|
4618
4659
|
|
|
4619
4660
|
// src/pdf/formula-ocr.ts
|
|
4620
4661
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
4621
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
4662
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-QJEOIVKR.cjs")));
|
|
4622
4663
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
4623
4664
|
await ensureFormulaModels((p) => {
|
|
4624
4665
|
if (p.phase === "download" && p.total) {
|
|
@@ -4809,13 +4850,13 @@ async function loadPdfWithTimeout(buffer, data) {
|
|
|
4809
4850
|
try {
|
|
4810
4851
|
return await Promise.race([
|
|
4811
4852
|
loadingTask.promise.catch((e) => {
|
|
4812
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
4853
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkPW7MQZI4cjs.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)");
|
|
4813
4854
|
throw e;
|
|
4814
4855
|
}),
|
|
4815
4856
|
new Promise((_, reject) => {
|
|
4816
4857
|
timer = setTimeout(() => {
|
|
4817
4858
|
loadingTask.destroy();
|
|
4818
|
-
reject(new (0,
|
|
4859
|
+
reject(new (0, _chunkPW7MQZI4cjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
4819
4860
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
4820
4861
|
})
|
|
4821
4862
|
]);
|
|
@@ -4826,8 +4867,8 @@ async function loadPdfWithTimeout(buffer, data) {
|
|
|
4826
4867
|
async function parsePdfDocument(buffer, options) {
|
|
4827
4868
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _417 => _417.formulaOcr]) ? buffer : null;
|
|
4828
4869
|
const ocrOptionError = _chunkMMK32GPDcjs.validateOcrOptions.call(void 0, options);
|
|
4829
|
-
if (ocrOptionError) throw new (0,
|
|
4830
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _418 => _418.ocr]) === void 0 && await
|
|
4870
|
+
if (ocrOptionError) throw new (0, _chunkPW7MQZI4cjs.KordocError)(ocrOptionError);
|
|
4871
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _418 => _418.ocr]) === void 0 && await _chunkUBY2PLKRcjs.ocrModelsCached.call(void 0, _chunkUBY2PLKRcjs.resolveOcrModels.call(void 0, options)) && (_optionalChain([options, 'optionalAccess', _419 => _419.ocrRec]) !== "auto" || await _chunkUBY2PLKRcjs.ocrModelsCached.call(void 0, _chunkUBY2PLKRcjs.handwritingFallbackModels.call(void 0, _chunkUBY2PLKRcjs.resolveOcrModels.call(void 0, options))));
|
|
4831
4872
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _420 => _420.ocr]) || autoOcr ? buffer : null;
|
|
4832
4873
|
const pdfjsData = new Uint8Array(buffer.slice(0));
|
|
4833
4874
|
const blanked = blankLargeImageStreams(pdfjsData);
|
|
@@ -4839,7 +4880,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4839
4880
|
let pristine;
|
|
4840
4881
|
try {
|
|
4841
4882
|
const pageCount = doc.numPages;
|
|
4842
|
-
if (pageCount === 0) throw new (0,
|
|
4883
|
+
if (pageCount === 0) throw new (0, _chunkPW7MQZI4cjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
4843
4884
|
const metadata = { pageCount, pageMode: "layout" };
|
|
4844
4885
|
await extractPdfMetadata(doc, metadata);
|
|
4845
4886
|
const blocks = [];
|
|
@@ -4861,9 +4902,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4861
4902
|
const skippedImagePages = /* @__PURE__ */ new Map();
|
|
4862
4903
|
const uncoveredImageRegions = /* @__PURE__ */ new Map();
|
|
4863
4904
|
const largeImageRegions = /* @__PURE__ */ new Set();
|
|
4864
|
-
const
|
|
4865
|
-
const
|
|
4866
|
-
if (
|
|
4905
|
+
const wantWebp = _optionalChain([options, 'optionalAccess', _425 => _425.imageFormat]) === "webp" && options.images !== false;
|
|
4906
|
+
const encodeWebp = wantWebp ? await _chunkY4MFHEK4cjs.loadWebpEncoder.call(void 0, ) : null;
|
|
4907
|
+
if (wantWebp && !encodeWebp) warnings.push(_chunkY4MFHEK4cjs.WEBP_UNAVAILABLE);
|
|
4908
|
+
const imageState = createPdfImageState(pdfium ? { decoder: pdfium, sizes: blanked.sizes, pristine: () => pristine ??= loadPdfWithTimeout(buffer) } : void 0, _nullishCoalesce(encodeWebp, () => ( void 0)));
|
|
4909
|
+
const readQr = _optionalChain([options, 'optionalAccess', _426 => _426.qrCodes]) ? await _chunkY4MFHEK4cjs.loadQrReader.call(void 0, ) : null;
|
|
4910
|
+
if (_optionalChain([options, 'optionalAccess', _427 => _427.qrCodes]) && !readQr) warnings.push(_chunkY4MFHEK4cjs.QR_UNAVAILABLE);
|
|
4867
4911
|
const imageBulletShapes = /* @__PURE__ */ new Map();
|
|
4868
4912
|
const imageArrowDirections = /* @__PURE__ */ new Map();
|
|
4869
4913
|
const extractedImages = [];
|
|
@@ -4871,10 +4915,10 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4871
4915
|
const carry = {};
|
|
4872
4916
|
const preciseGaps = await isHancomPdf(doc);
|
|
4873
4917
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
4874
|
-
const wrapLexicon = new (0,
|
|
4918
|
+
const wrapLexicon = new (0, _chunkUBY2PLKRcjs.WrapLexicon)();
|
|
4875
4919
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
4876
4920
|
const headerContext = [];
|
|
4877
|
-
if (pageFilter && _optionalChain([options, 'optionalAccess',
|
|
4921
|
+
if (pageFilter && _optionalChain([options, 'optionalAccess', _428 => _428.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
4878
4922
|
for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
|
|
4879
4923
|
let contextPage;
|
|
4880
4924
|
try {
|
|
@@ -4884,7 +4928,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4884
4928
|
headerContext.push(...marginContextBlocks(content.items, number, contextPage.view));
|
|
4885
4929
|
} catch (e7) {
|
|
4886
4930
|
} finally {
|
|
4887
|
-
_optionalChain([contextPage, 'optionalAccess',
|
|
4931
|
+
_optionalChain([contextPage, 'optionalAccess', _429 => _429.cleanup, 'call', _430 => _430()]);
|
|
4888
4932
|
}
|
|
4889
4933
|
}
|
|
4890
4934
|
}
|
|
@@ -4911,23 +4955,23 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4911
4955
|
return void 0;
|
|
4912
4956
|
}
|
|
4913
4957
|
};
|
|
4914
|
-
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call',
|
|
4958
|
+
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _431 => _431(loadedName), 'optionalAccess', _432 => _432.differences]);
|
|
4915
4959
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4916
4960
|
markTrailingSpaceGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4917
4961
|
const restoreSoftHyphens = softHyphenHeads(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4918
|
-
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call',
|
|
4962
|
+
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _433 => _433(n), 'optionalAccess', _434 => _434.name]));
|
|
4919
4963
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
4920
4964
|
restoreUnmappedCidSpaces(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
4921
4965
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4922
4966
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4923
4967
|
restoreSoftHyphens();
|
|
4924
4968
|
rawItems.push(...spaceMappedDots(rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n)));
|
|
4925
|
-
const items =
|
|
4969
|
+
const items = _chunkUBY2PLKRcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
4926
4970
|
if (!preciseGaps) for (const it of items) {
|
|
4927
4971
|
delete it.fx;
|
|
4928
4972
|
delete it.fw;
|
|
4929
4973
|
}
|
|
4930
|
-
const filtered =
|
|
4974
|
+
const filtered = _chunkUBY2PLKRcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
4931
4975
|
const joined = joinVerticalColumns(filtered.visible);
|
|
4932
4976
|
const visible = dropTabLeaderDots(joined);
|
|
4933
4977
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -4952,27 +4996,27 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4952
4996
|
fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
|
|
4953
4997
|
argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
|
|
4954
4998
|
} : rawOps;
|
|
4955
|
-
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call',
|
|
4999
|
+
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _435 => _435(loadedName), 'optionalAccess', _436 => _436.name]));
|
|
4956
5000
|
remapControlGlyphs(visible, differencesOf);
|
|
4957
|
-
await
|
|
5001
|
+
await _chunkUBY2PLKRcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
4958
5002
|
const faces = /* @__PURE__ */ new Map();
|
|
4959
5003
|
for (const it of visible) {
|
|
4960
5004
|
if (!it.fontName) continue;
|
|
4961
5005
|
let face = faces.get(it.fontName);
|
|
4962
5006
|
if (face === void 0) {
|
|
4963
5007
|
const obj = fontObj(it.fontName);
|
|
4964
|
-
face = _optionalChain([obj, 'optionalAccess',
|
|
5008
|
+
face = _optionalChain([obj, 'optionalAccess', _437 => _437.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
|
|
4965
5009
|
faces.set(it.fontName, face);
|
|
4966
5010
|
}
|
|
4967
5011
|
it.fontName = face;
|
|
4968
|
-
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call',
|
|
5012
|
+
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _438 => _438(face), 'optionalAccess', _439 => _439.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
4969
5013
|
}
|
|
4970
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
4971
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
5014
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkTQOAPKLUcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
5015
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkTQOAPKLUcjs.escapeLiteralTags.call(void 0, it.text);
|
|
4972
5016
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
4973
5017
|
const pageArea = pageW * pageH;
|
|
4974
5018
|
if (pageArea > 0) {
|
|
4975
|
-
const imageRegions =
|
|
5019
|
+
const imageRegions = _chunkUBY2PLKRcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
4976
5020
|
let uncovered = 0;
|
|
4977
5021
|
for (const r of imageRegions) {
|
|
4978
5022
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -4999,15 +5043,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4999
5043
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
5000
5044
|
}
|
|
5001
5045
|
const marks = superscriptNoteMarks(visible);
|
|
5002
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
5046
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkUBY2PLKRcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
5003
5047
|
const stamp = marginStamp(visible);
|
|
5004
5048
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
5005
|
-
const rightArrows = _optionalChain([options, 'optionalAccess',
|
|
5006
|
-
const pageBlocks = orderTwoUpPage(
|
|
5049
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _440 => _440.tables]) !== false ? await _chunkUBY2PLKRcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
5050
|
+
const pageBlocks = orderTwoUpPage(_chunkUBY2PLKRcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _441 => _441.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
5007
5051
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
5008
5052
|
for (const b of pageBlocks) blocks.push(b);
|
|
5009
5053
|
try {
|
|
5010
|
-
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess',
|
|
5054
|
+
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _442 => _442.images]) !== false, _nullishCoalesce(readQr, () => ( void 0)));
|
|
5011
5055
|
if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
|
|
5012
5056
|
extractedImages.push(...pageImages);
|
|
5013
5057
|
} catch (e10) {
|
|
@@ -5026,17 +5070,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5026
5070
|
const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
|
|
5027
5071
|
const quality = computePageQuality(i, pageText, vector.glyphs);
|
|
5028
5072
|
pageQuality.push(quality);
|
|
5029
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5073
|
+
if (_optionalChain([options, 'optionalAccess', _443 => _443.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
5030
5074
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
5031
5075
|
}
|
|
5032
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
5076
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkPW7MQZI4cjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
5033
5077
|
parsedPages++;
|
|
5034
|
-
_optionalChain([options, 'optionalAccess',
|
|
5078
|
+
_optionalChain([options, 'optionalAccess', _444 => _444.onProgress, 'optionalCall', _445 => _445(parsedPages, totalTarget)]);
|
|
5035
5079
|
} catch (pageErr) {
|
|
5036
|
-
if (pageErr instanceof
|
|
5080
|
+
if (pageErr instanceof _chunkPW7MQZI4cjs.KordocError) throw pageErr;
|
|
5037
5081
|
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" });
|
|
5038
5082
|
} finally {
|
|
5039
|
-
_optionalChain([loadedPage, 'optionalAccess',
|
|
5083
|
+
_optionalChain([loadedPage, 'optionalAccess', _446 => _446.cleanup, 'call', _447 => _447()]);
|
|
5040
5084
|
}
|
|
5041
5085
|
if (loadedFonts.size > FONT_CACHE_LIMIT) {
|
|
5042
5086
|
await doc.cleanup();
|
|
@@ -5044,14 +5088,14 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5044
5088
|
}
|
|
5045
5089
|
}
|
|
5046
5090
|
const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
|
|
5047
|
-
const isImageBased = _optionalChain([pageFilter, 'optionalAccess',
|
|
5091
|
+
const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _448 => _448.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
|
|
5048
5092
|
const ocrDone = /* @__PURE__ */ new Set();
|
|
5049
5093
|
const ocrLinesOut = /* @__PURE__ */ new Map();
|
|
5050
|
-
const ocrRegions = _optionalChain([options, 'optionalAccess',
|
|
5094
|
+
const ocrRegions = _optionalChain([options, 'optionalAccess', _449 => _449.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _450 => _450.ocr]) === true) : /* @__PURE__ */ new Map();
|
|
5051
5095
|
if (ocrBuffer) {
|
|
5052
5096
|
const inScope = (p) => !pageFilter || pageFilter.has(p);
|
|
5053
5097
|
const targets = /* @__PURE__ */ new Set();
|
|
5054
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5098
|
+
if (_optionalChain([options, 'optionalAccess', _451 => _451.ocr]) === "force" || isImageBased) {
|
|
5055
5099
|
for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
|
|
5056
5100
|
} else {
|
|
5057
5101
|
for (const pq of pageQuality) {
|
|
@@ -5064,25 +5108,25 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5064
5108
|
}
|
|
5065
5109
|
if (targets.size > 0) {
|
|
5066
5110
|
try {
|
|
5067
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
5068
|
-
const mode = typeof _optionalChain([options, 'optionalAccess',
|
|
5069
|
-
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess',
|
|
5070
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
5071
|
-
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess',
|
|
5072
|
-
for (const obs of ocrPageBlocks.values())
|
|
5111
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-NOJHEH4M.cjs")));
|
|
5112
|
+
const mode = typeof _optionalChain([options, 'optionalAccess', _452 => _452.ocr]) === "function" ? options.ocr : "builtin";
|
|
5113
|
+
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _453 => _453.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _454 => _454.find, 'call', _455 => _455((q) => q.page === p), 'optionalAccess', _456 => _456.needsOcr])));
|
|
5114
|
+
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-NOJHEH4M.cjs")));
|
|
5115
|
+
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _457 => _457.onProgress]), _optionalChain([options, 'optionalAccess', _458 => _458.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
5116
|
+
for (const obs of ocrPageBlocks.values()) _chunkTQOAPKLUcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
5073
5117
|
if (ocrPageBlocks.size > 0) {
|
|
5074
5118
|
const replacePages = /* @__PURE__ */ new Set();
|
|
5075
5119
|
for (const [p, obs] of ocrPageBlocks) {
|
|
5076
|
-
const needsOcr = _optionalChain([pageQuality, 'access',
|
|
5077
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5120
|
+
const needsOcr = _optionalChain([pageQuality, 'access', _459 => _459.find, 'call', _460 => _460((q) => q.page === p), 'optionalAccess', _461 => _461.needsOcr]);
|
|
5121
|
+
if (_optionalChain([options, 'optionalAccess', _462 => _462.ocr]) === "force" || isImageBased || needsOcr) {
|
|
5078
5122
|
replacePages.add(p);
|
|
5079
5123
|
ocrDone.add(p);
|
|
5080
5124
|
continue;
|
|
5081
5125
|
}
|
|
5082
5126
|
const regions = ocrRegions.get(p);
|
|
5083
|
-
if (!regions ||
|
|
5127
|
+
if (!regions || _chunkUBY2PLKRcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
5084
5128
|
ocrDone.add(p);
|
|
5085
|
-
if (_optionalChain([pageImageBlocks, 'access',
|
|
5129
|
+
if (_optionalChain([pageImageBlocks, 'access', _463 => _463.get, 'call', _464 => _464(p), 'optionalAccess', _465 => _465.length]) === 1) pageImageBlocks.delete(p);
|
|
5086
5130
|
}
|
|
5087
5131
|
if (replacePages.size) {
|
|
5088
5132
|
const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
|
|
@@ -5132,18 +5176,18 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5132
5176
|
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" });
|
|
5133
5177
|
}
|
|
5134
5178
|
}
|
|
5135
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5136
|
-
const removed =
|
|
5137
|
-
const running =
|
|
5179
|
+
if (_optionalChain([options, 'optionalAccess', _466 => _466.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
5180
|
+
const removed = _chunkUBY2PLKRcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
5181
|
+
const running = _chunkUBY2PLKRcjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
5138
5182
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
5139
5183
|
blocks.splice(removed[ri], 1);
|
|
5140
5184
|
}
|
|
5141
|
-
const stripped =
|
|
5185
|
+
const stripped = _chunkUBY2PLKRcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
5142
5186
|
if (stripped !== blocks) {
|
|
5143
5187
|
blocks.length = 0;
|
|
5144
5188
|
blocks.push(...stripped);
|
|
5145
5189
|
}
|
|
5146
|
-
const kept =
|
|
5190
|
+
const kept = _chunkUBY2PLKRcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
5147
5191
|
if (kept !== blocks) {
|
|
5148
5192
|
blocks.length = 0;
|
|
5149
5193
|
blocks.push(...kept);
|
|
@@ -5151,15 +5195,16 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5151
5195
|
}
|
|
5152
5196
|
mergeContinuedCells(blocks, pageHeights);
|
|
5153
5197
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
5154
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5155
|
-
const boxes =
|
|
5198
|
+
if (_optionalChain([options, 'optionalAccess', _467 => _467.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
5199
|
+
const boxes = _chunkUBY2PLKRcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
5156
5200
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
5157
5201
|
}
|
|
5158
5202
|
splitContactTables(blocks);
|
|
5159
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
5160
|
-
|
|
5203
|
+
if (!_optionalChain([options, 'optionalAccess', _468 => _468.keepTrailingEmptyCols])) _chunkUBY2PLKRcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
5204
|
+
_chunkUBY2PLKRcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
5205
|
+
await flushPdfImages(imageState, warnings, pageImageBlocks);
|
|
5161
5206
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
5162
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5207
|
+
if (_optionalChain([options, 'optionalAccess', _469 => _469.formulaOcr]) && formulaBuffer) {
|
|
5163
5208
|
try {
|
|
5164
5209
|
await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
|
|
5165
5210
|
} catch (e) {
|
|
@@ -5169,54 +5214,54 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5169
5214
|
});
|
|
5170
5215
|
}
|
|
5171
5216
|
}
|
|
5172
|
-
const medianFontSize =
|
|
5217
|
+
const medianFontSize = _chunkUBY2PLKRcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
5173
5218
|
if (medianFontSize > 0) {
|
|
5174
|
-
|
|
5175
|
-
}
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5219
|
+
_chunkUBY2PLKRcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
5220
|
+
}
|
|
5221
|
+
_chunkUBY2PLKRcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
5222
|
+
_chunkUBY2PLKRcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
5223
|
+
_chunkUBY2PLKRcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
5224
|
+
_chunkUBY2PLKRcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
5225
|
+
_chunkUBY2PLKRcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
5226
|
+
_chunkUBY2PLKRcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
5227
|
+
_chunkUBY2PLKRcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
5228
|
+
_chunkUBY2PLKRcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
5184
5229
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
5185
|
-
|
|
5186
|
-
|
|
5230
|
+
_chunkUBY2PLKRcjs.detectTableCaptions.call(void 0, blocks);
|
|
5231
|
+
_chunkUBY2PLKRcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
5187
5232
|
sanitizeBlockControlChars(blocks);
|
|
5188
5233
|
let outBlocks = splitSingleCellTables(blocks);
|
|
5189
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5234
|
+
if (_optionalChain([options, 'optionalAccess', _470 => _470.layoutTables]) !== "keep") {
|
|
5190
5235
|
blocks.length = 0;
|
|
5191
5236
|
for (const block of outBlocks) blocks.push(block);
|
|
5192
5237
|
}
|
|
5193
5238
|
outBlocks = inlineFootnotes(outBlocks, noteMarks);
|
|
5194
5239
|
outBlocks = relocateEndnotes(outBlocks);
|
|
5195
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5240
|
+
if (_optionalChain([options, 'optionalAccess', _471 => _471.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
|
|
5196
5241
|
if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
|
|
5197
5242
|
const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
|
|
5198
5243
|
if (!b.bbox || !h) return false;
|
|
5199
5244
|
return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
|
|
5200
5245
|
});
|
|
5201
5246
|
joinLatinCellWraps(outBlocks);
|
|
5202
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5247
|
+
if (_optionalChain([options, 'optionalAccess', _472 => _472.layoutTables]) !== "keep") {
|
|
5203
5248
|
const hancom = await isHancomPdf(doc);
|
|
5204
5249
|
const shown = /* @__PURE__ */ new Map();
|
|
5205
5250
|
const markContent = (bs) => {
|
|
5206
5251
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
5207
|
-
if (
|
|
5208
|
-
const lines =
|
|
5209
|
-
if (lines)
|
|
5252
|
+
if (_chunkUBY2PLKRcjs.IMAGE_CELLS.has(c)) _chunkTQOAPKLUcjs.CONTENT_CELLS.add(c);
|
|
5253
|
+
const lines = _chunkUBY2PLKRcjs.CELL_LINES.get(c);
|
|
5254
|
+
if (lines) _chunkTQOAPKLUcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
5210
5255
|
markContent(c.blocks);
|
|
5211
5256
|
}
|
|
5212
5257
|
};
|
|
5213
5258
|
const visual = (bs) => bs.flatMap((b) => {
|
|
5214
5259
|
if (b.type !== "table") return [b];
|
|
5215
|
-
if (!hancom && b.table &&
|
|
5260
|
+
if (!hancom && b.table && _chunkUBY2PLKRcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
5216
5261
|
let v = shown.get(b);
|
|
5217
5262
|
if (!v) {
|
|
5218
5263
|
markContent([b]);
|
|
5219
|
-
shown.set(b, v =
|
|
5264
|
+
shown.set(b, v = _chunkTQOAPKLUcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _473 => _473.keepTrailingEmptyCols])));
|
|
5220
5265
|
}
|
|
5221
5266
|
return v;
|
|
5222
5267
|
});
|
|
@@ -5225,13 +5270,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5225
5270
|
blocks.length = 0;
|
|
5226
5271
|
for (const b of kept) blocks.push(b);
|
|
5227
5272
|
}
|
|
5228
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
5229
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5273
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkTQOAPKLUcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _474 => _474.tableFormat]) }), { keepLoneNumbers: true }));
|
|
5274
|
+
if (_optionalChain([options, 'optionalAccess', _475 => _475.tableFormat]) === "gfm") _chunkTQOAPKLUcjs.assignTableIds.call(void 0, blocks);
|
|
5230
5275
|
let markdown = finishMarkdown(outBlocks);
|
|
5231
5276
|
const outline = collectPdfOutline(outBlocks);
|
|
5232
5277
|
return {
|
|
5233
5278
|
markdown,
|
|
5234
|
-
pages:
|
|
5279
|
+
pages: _chunkY4MFHEK4cjs.blocksToPages.call(void 0, splitPageTables(_chunkUBY2PLKRcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
5235
5280
|
blocks,
|
|
5236
5281
|
metadata,
|
|
5237
5282
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -5240,20 +5285,20 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5240
5285
|
pageQuality,
|
|
5241
5286
|
qualitySummary: summarizeDocumentQuality(pageQuality),
|
|
5242
5287
|
images: extractedImages.length > 0 ? extractedImages : void 0,
|
|
5243
|
-
..._optionalChain([options, 'optionalAccess',
|
|
5288
|
+
..._optionalChain([options, 'optionalAccess', _476 => _476.ocrLines]) ? { ocrLines: [...ocrLinesOut.values()].sort((a, b) => a.pageNumber - b.pageNumber) } : {}
|
|
5244
5289
|
};
|
|
5245
5290
|
} finally {
|
|
5246
5291
|
await doc.destroy().catch(() => {
|
|
5247
5292
|
});
|
|
5248
|
-
_optionalChain([pdfium, 'optionalAccess',
|
|
5249
|
-
await _optionalChain([pristine, 'optionalAccess',
|
|
5293
|
+
_optionalChain([pdfium, 'optionalAccess', _477 => _477.close, 'call', _478 => _478()]);
|
|
5294
|
+
await _optionalChain([pristine, 'optionalAccess', _479 => _479.then, 'call', _480 => _480((d) => d.destroy()), 'access', _481 => _481.catch, 'call', _482 => _482(() => {
|
|
5250
5295
|
})]);
|
|
5251
5296
|
}
|
|
5252
5297
|
}
|
|
5253
5298
|
async function extractPdfMetadata(doc, metadata) {
|
|
5254
5299
|
try {
|
|
5255
5300
|
const result = await doc.getMetadata();
|
|
5256
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
5301
|
+
if (!_optionalChain([result, 'optionalAccess', _483 => _483.info])) return;
|
|
5257
5302
|
const info = result.info;
|
|
5258
5303
|
if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
|
|
5259
5304
|
if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
|
|
@@ -5269,8 +5314,8 @@ async function extractPdfMetadata(doc, metadata) {
|
|
|
5269
5314
|
}
|
|
5270
5315
|
async function isHancomPdf(doc) {
|
|
5271
5316
|
try {
|
|
5272
|
-
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async
|
|
5273
|
-
return [_optionalChain([info, 'optionalAccess',
|
|
5317
|
+
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _484 => _484.info]);
|
|
5318
|
+
return [_optionalChain([info, 'optionalAccess', _485 => _485.Producer]), _optionalChain([info, 'optionalAccess', _486 => _486.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
|
|
5274
5319
|
} catch (e12) {
|
|
5275
5320
|
return false;
|
|
5276
5321
|
}
|
|
@@ -5314,5 +5359,5 @@ function marginStamp(items) {
|
|
|
5314
5359
|
|
|
5315
5360
|
|
|
5316
5361
|
|
|
5317
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
5318
|
-
//# sourceMappingURL=parser-
|
|
5362
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkUBY2PLKRcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkUBY2PLKRcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkUBY2PLKRcjs.removeHeaderFooterBlocks;
|
|
5363
|
+
//# sourceMappingURL=parser-RB6CBNAM.cjs.map
|