kordoc 4.24.47 → 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/NOTICE +21 -0
- package/README.md +4 -4
- package/dist/{-PWMZE4CC.js → -22V6D2US.js} +42 -42
- package/dist/{chunk-RQ4XTX4J.cjs → chunk-2UWWWM4Q.cjs} +98 -98
- package/dist/{chunk-RQ4XTX4J.cjs.map → chunk-2UWWWM4Q.cjs.map} +1 -1
- package/dist/{chunk-3CWVQNFL.cjs → chunk-367WLMPO.cjs} +59 -67
- package/dist/chunk-367WLMPO.cjs.map +1 -0
- package/dist/{chunk-Z5TDZDWU.js → chunk-4HJKBRZJ.js} +153 -50
- package/dist/chunk-4HJKBRZJ.js.map +1 -0
- package/dist/{chunk-GRQXAWNW.js → chunk-4MWUBTAE.js} +2 -2
- package/dist/{chunk-TN5ZK2WN.js → chunk-67GSFYG7.js} +2 -2
- package/dist/{chunk-TGLXN6VH.js → chunk-6BFWLS7E.js} +3 -3
- package/dist/{chunk-X7RBVVDC.cjs → chunk-6NZ32OTX.cjs} +9 -3
- package/dist/chunk-6NZ32OTX.cjs.map +1 -0
- package/dist/{chunk-Q3UCWUEV.js → chunk-7KKL3PRK.js} +5 -13
- package/dist/chunk-7KKL3PRK.js.map +1 -0
- package/dist/{chunk-T5J4GW6B.js → chunk-AUAJVQQK.js} +2 -2
- package/dist/{chunk-KIVWAZKL.js → chunk-AXW2FMVR.js} +2 -2
- package/dist/{chunk-LEUAWTMU.js → chunk-CCQMSIZQ.js} +19 -19
- package/dist/{chunk-PM46GSMV.js → chunk-DA5AXURC.js} +194 -6
- package/dist/chunk-DA5AXURC.js.map +1 -0
- package/dist/{chunk-SUIH5LY7.js → chunk-DAAJO62F.js} +2 -2
- package/dist/{chunk-4MNRUPS5.js → chunk-EUJX7HTR.js} +53 -10
- package/dist/chunk-EUJX7HTR.js.map +1 -0
- package/dist/{chunk-56FEGA44.js → chunk-EYSXMDA7.js} +17 -17
- package/dist/{chunk-VKVDMH7X.js → chunk-FU6ZDWCI.js} +8 -2
- package/dist/chunk-FU6ZDWCI.js.map +1 -0
- package/dist/{chunk-KSE5HSU3.js → chunk-HETGOJ6V.js} +8 -5
- package/dist/chunk-HETGOJ6V.js.map +1 -0
- package/dist/{chunk-HFQFCAEJ.js → chunk-HW7WVYBF.js} +2 -2
- package/dist/{chunk-O2652KK3.cjs → chunk-IRAZCKQ6.cjs} +3 -3
- package/dist/{chunk-O2652KK3.cjs.map → chunk-IRAZCKQ6.cjs.map} +1 -1
- package/dist/{chunk-AB7MYMPZ.js → chunk-KB4ORA7M.js} +2 -2
- package/dist/{chunk-57BKTVR5.js → chunk-KXHUHGMC.js} +2 -2
- package/dist/{chunk-YLYSJSEP.js → chunk-L3JP55ZY.js} +2 -2
- package/dist/{chunk-2CBIY2OH.js → chunk-LCRSRVFJ.js} +2 -2
- package/dist/{chunk-2CBIY2OH.js.map → chunk-LCRSRVFJ.js.map} +1 -1
- package/dist/{chunk-IPXFIH5E.js → chunk-LFFARZYZ.js} +8 -5
- package/dist/chunk-LFFARZYZ.js.map +1 -0
- package/dist/{chunk-BO2IJGNZ.js → chunk-LOSCIAHY.js} +2 -2
- package/dist/{chunk-SQ5Q4Q3R.js → chunk-M5RQ2PNP.js} +6 -14
- package/dist/chunk-M5RQ2PNP.js.map +1 -0
- package/dist/{chunk-MOWJOFIH.js → chunk-MIJTZKWF.js} +2 -2
- package/dist/chunk-MLBX6KQM.js +153 -0
- package/dist/chunk-MLBX6KQM.js.map +1 -0
- package/dist/{chunk-HMD35PMD.js → chunk-OAETOHH3.js} +3 -3
- package/dist/{chunk-IWC6PTMT.js → chunk-PMGJQWSW.js} +2 -2
- package/dist/{chunk-LMHE4HDR.cjs → chunk-PVV6OY4M.cjs} +286 -98
- package/dist/chunk-PVV6OY4M.cjs.map +1 -0
- package/dist/{chunk-BKK2SMVM.cjs → chunk-PW7MQZI4.cjs} +2 -2
- package/dist/{chunk-BKK2SMVM.cjs.map → chunk-PW7MQZI4.cjs.map} +1 -1
- package/dist/{chunk-NYIJU4Q6.js → chunk-Q7FDPJUS.js} +10 -10
- package/dist/{chunk-FI7ULBC6.js → chunk-R2RLNUNK.js} +6 -6
- package/dist/{chunk-AO3YFJVW.js → chunk-RQLEGKEV.js} +2 -2
- package/dist/{chunk-OAKJNKAS.js → chunk-S54DZB2Z.js} +193 -5
- package/dist/chunk-S54DZB2Z.js.map +1 -0
- package/dist/{chunk-A67OXFXM.js → chunk-TAHS42ED.js} +54 -11
- package/dist/chunk-TAHS42ED.js.map +1 -0
- package/dist/{chunk-WAFJUSUF.cjs → chunk-TQOAPKLU.cjs} +11 -8
- package/dist/chunk-TQOAPKLU.cjs.map +1 -0
- package/dist/{chunk-UFY6XX4U.cjs → chunk-UBY2PLKR.cjs} +75 -32
- package/dist/chunk-UBY2PLKR.cjs.map +1 -0
- package/dist/{chunk-U556XJW6.js → chunk-UJELMNOU.js} +8 -2
- package/dist/chunk-UJELMNOU.js.map +1 -0
- package/dist/{chunk-FOTG4MMD.js → chunk-UU54HN5I.js} +6 -6
- package/dist/{chunk-BP5GDQBT.js → chunk-VMOUAWGD.js} +7 -7
- package/dist/{chunk-2VXVBB5Q.js → chunk-WLFZOBZR.js} +3 -3
- package/dist/chunk-Y4MFHEK4.cjs +156 -0
- package/dist/chunk-Y4MFHEK4.cjs.map +1 -0
- package/dist/{chunk-VL43TUO6.js → chunk-Y6QW3FJQ.js} +2 -2
- package/dist/chunk-ZF24SO45.js +154 -0
- package/dist/chunk-ZF24SO45.js.map +1 -0
- package/dist/chunks-Q7242OJE.js +11 -0
- package/dist/cli.js +74 -53
- package/dist/cli.js.map +1 -1
- package/dist/{formula-W5MTLANP.js → formula-BYEDWWZU.js} +4 -4
- package/dist/{formula-2BQBGPM2.js → formula-FQLMMBDP.js} +3 -3
- package/dist/{formula-V6CNOC4G.cjs → formula-QJEOIVKR.cjs} +9 -9
- package/dist/{formula-V6CNOC4G.cjs.map → formula-QJEOIVKR.cjs.map} +1 -1
- package/dist/generator-FTM6GOGB.cjs +11 -0
- package/dist/{generator-U2BRFTJ4.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-COBRSG6O.js → image-ocr-7Y3FCGRR.js} +12 -10
- package/dist/image-ocr-7Y3FCGRR.js.map +1 -0
- package/dist/{image-ocr-2WSZULNO.js → image-ocr-VIGZE4YL.js} +9 -7
- package/dist/image-ocr-VIGZE4YL.js.map +1 -0
- package/dist/{image-ocr-MVOSHIY5.cjs → image-ocr-WRILL3WO.cjs} +29 -27
- package/dist/image-ocr-WRILL3WO.cjs.map +1 -0
- package/dist/index.cjs +1645 -1542
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -5
- package/dist/index.d.ts +18 -5
- package/dist/index.js +231 -128
- 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-LFLRW2SI.js → model-bundle-UJRQPYUU.js} +5 -5
- package/dist/{models-UGOWUUAL.js → models-64YLAWTI.js} +5 -5
- package/dist/{parse-worker-v2-LCCTZWPT.js → parse-worker-v2-QWQZKFQO.js} +26 -24
- package/dist/parse-worker-v2-QWQZKFQO.js.map +1 -0
- package/dist/{parser-JAL2OOOL.js → parser-JPWANPLM.js} +428 -42
- package/dist/parser-JPWANPLM.js.map +1 -0
- package/dist/{parser-RE52HQXO.cjs → parser-RB6CBNAM.cjs} +720 -334
- package/dist/parser-RB6CBNAM.cjs.map +1 -0
- package/dist/{parser-J56FGU6P.js → parser-XFU3VRWM.js} +431 -45
- package/dist/parser-XFU3VRWM.js.map +1 -0
- package/dist/pdf-ocr-NOJHEH4M.cjs +42 -0
- package/dist/{pdf-ocr-5O336TCR.cjs.map → pdf-ocr-NOJHEH4M.cjs.map} +1 -1
- package/dist/{pdf-ocr-PQZZVFI5.js → pdf-ocr-XTZZEYKJ.js} +6 -6
- package/dist/{pdf-ocr-NQ3HAL77.js → pdf-ocr-ZV3KYIIE.js} +9 -9
- package/dist/{profile-io-K22CB2ZB.js → profile-io-FAJORRD2.js} +3 -3
- package/dist/{rasterize-A6B5K4QN.js → rasterize-4ZJUA2DZ.js} +3 -3
- package/dist/{redact-doc-TPXMML5Q.js → redact-doc-JPNROEH6.js} +30 -30
- package/dist/{render-ROFIMWW5.js → render-D4WBOBKI.js} +13 -13
- package/dist/{rewrite-fallback-WG7Z3LR3.js → rewrite-fallback-OF3QI6CX.js} +14 -14
- package/dist/seal-DQWEHIAM.js +16 -0
- package/dist/{setup-J5SHDFIE.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-RWDQB3T2.cjs.map → to-hwpx-LUA6F5RR.cjs.map} +1 -1
- package/dist/{to-hwpx-X7JE6YJB.js → to-hwpx-ZWN64NCQ.js} +5 -5
- package/dist/visual-SW7NPY6K.js +37 -0
- package/dist/{watch-WZBW6UE7.js → watch-ZU576VSR.js} +24 -24
- package/package.json +3 -2
- package/dist/chunk-3CWVQNFL.cjs.map +0 -1
- package/dist/chunk-4MNRUPS5.js.map +0 -1
- package/dist/chunk-A67OXFXM.js.map +0 -1
- package/dist/chunk-AYM7XTI2.js +0 -31
- package/dist/chunk-AYM7XTI2.js.map +0 -1
- package/dist/chunk-CQ33HCSU.js +0 -32
- package/dist/chunk-CQ33HCSU.js.map +0 -1
- package/dist/chunk-IPXFIH5E.js.map +0 -1
- package/dist/chunk-KSE5HSU3.js.map +0 -1
- package/dist/chunk-LMHE4HDR.cjs.map +0 -1
- package/dist/chunk-OAKJNKAS.js.map +0 -1
- package/dist/chunk-PM46GSMV.js.map +0 -1
- package/dist/chunk-Q3UCWUEV.js.map +0 -1
- package/dist/chunk-SQ5Q4Q3R.js.map +0 -1
- package/dist/chunk-U556XJW6.js.map +0 -1
- package/dist/chunk-UFY6XX4U.cjs.map +0 -1
- package/dist/chunk-VKVDMH7X.js.map +0 -1
- package/dist/chunk-WAFJUSUF.cjs.map +0 -1
- package/dist/chunk-WPLAEJU5.cjs +0 -31
- package/dist/chunk-WPLAEJU5.cjs.map +0 -1
- package/dist/chunk-X7RBVVDC.cjs.map +0 -1
- package/dist/chunk-Z5TDZDWU.js.map +0 -1
- package/dist/chunks-SHXTE5HM.js +0 -11
- package/dist/generator-E4VQKPRP.js +0 -10
- package/dist/generator-MBR4V3JQ.js +0 -17
- package/dist/generator-U2BRFTJ4.cjs +0 -11
- package/dist/hancom-7SU4XBXJ.js +0 -84
- package/dist/hancom-7SU4XBXJ.js.map +0 -1
- package/dist/hancom-MP7D7HWW.cjs +0 -85
- package/dist/hancom-MP7D7HWW.cjs.map +0 -1
- package/dist/hancom-RNJWH63M.js +0 -85
- package/dist/hancom-RNJWH63M.js.map +0 -1
- package/dist/image-ocr-2WSZULNO.js.map +0 -1
- package/dist/image-ocr-COBRSG6O.js.map +0 -1
- package/dist/image-ocr-MVOSHIY5.cjs.map +0 -1
- package/dist/memo-QJ5RKTBN.js +0 -17
- package/dist/parse-worker-v2-LCCTZWPT.js.map +0 -1
- package/dist/parser-J56FGU6P.js.map +0 -1
- package/dist/parser-JAL2OOOL.js.map +0 -1
- package/dist/parser-RE52HQXO.cjs.map +0 -1
- package/dist/pdf-ocr-5O336TCR.cjs +0 -42
- package/dist/seal-35U76WY2.js +0 -16
- package/dist/to-hwpx-RWDQB3T2.cjs +0 -16
- package/dist/to-hwpx-XQULU2I7.js +0 -21
- package/dist/visual-4HRP2VIH.js +0 -37
- /package/dist/{-PWMZE4CC.js.map → -22V6D2US.js.map} +0 -0
- /package/dist/{chunk-GRQXAWNW.js.map → chunk-4MWUBTAE.js.map} +0 -0
- /package/dist/{chunk-TN5ZK2WN.js.map → chunk-67GSFYG7.js.map} +0 -0
- /package/dist/{chunk-TGLXN6VH.js.map → chunk-6BFWLS7E.js.map} +0 -0
- /package/dist/{chunk-T5J4GW6B.js.map → chunk-AUAJVQQK.js.map} +0 -0
- /package/dist/{chunk-KIVWAZKL.js.map → chunk-AXW2FMVR.js.map} +0 -0
- /package/dist/{chunk-LEUAWTMU.js.map → chunk-CCQMSIZQ.js.map} +0 -0
- /package/dist/{chunk-SUIH5LY7.js.map → chunk-DAAJO62F.js.map} +0 -0
- /package/dist/{chunk-56FEGA44.js.map → chunk-EYSXMDA7.js.map} +0 -0
- /package/dist/{chunk-HFQFCAEJ.js.map → chunk-HW7WVYBF.js.map} +0 -0
- /package/dist/{chunk-AB7MYMPZ.js.map → chunk-KB4ORA7M.js.map} +0 -0
- /package/dist/{chunk-57BKTVR5.js.map → chunk-KXHUHGMC.js.map} +0 -0
- /package/dist/{chunk-YLYSJSEP.js.map → chunk-L3JP55ZY.js.map} +0 -0
- /package/dist/{chunk-BO2IJGNZ.js.map → chunk-LOSCIAHY.js.map} +0 -0
- /package/dist/{chunk-MOWJOFIH.js.map → chunk-MIJTZKWF.js.map} +0 -0
- /package/dist/{chunk-HMD35PMD.js.map → chunk-OAETOHH3.js.map} +0 -0
- /package/dist/{chunk-IWC6PTMT.js.map → chunk-PMGJQWSW.js.map} +0 -0
- /package/dist/{chunk-NYIJU4Q6.js.map → chunk-Q7FDPJUS.js.map} +0 -0
- /package/dist/{chunk-FI7ULBC6.js.map → chunk-R2RLNUNK.js.map} +0 -0
- /package/dist/{chunk-AO3YFJVW.js.map → chunk-RQLEGKEV.js.map} +0 -0
- /package/dist/{chunk-FOTG4MMD.js.map → chunk-UU54HN5I.js.map} +0 -0
- /package/dist/{chunk-BP5GDQBT.js.map → chunk-VMOUAWGD.js.map} +0 -0
- /package/dist/{chunk-2VXVBB5Q.js.map → chunk-WLFZOBZR.js.map} +0 -0
- /package/dist/{chunk-VL43TUO6.js.map → chunk-Y6QW3FJQ.js.map} +0 -0
- /package/dist/{chunks-SHXTE5HM.js.map → chunks-Q7242OJE.js.map} +0 -0
- /package/dist/{formula-W5MTLANP.js.map → formula-BYEDWWZU.js.map} +0 -0
- /package/dist/{formula-2BQBGPM2.js.map → formula-FQLMMBDP.js.map} +0 -0
- /package/dist/{generator-E4VQKPRP.js.map → generator-Q3L7RNUY.js.map} +0 -0
- /package/dist/{generator-MBR4V3JQ.js.map → generator-SU73HZHR.js.map} +0 -0
- /package/dist/{memo-QJ5RKTBN.js.map → memo-T5ZQEXEA.js.map} +0 -0
- /package/dist/{model-bundle-LFLRW2SI.js.map → model-bundle-UJRQPYUU.js.map} +0 -0
- /package/dist/{models-UGOWUUAL.js.map → models-64YLAWTI.js.map} +0 -0
- /package/dist/{pdf-ocr-NQ3HAL77.js.map → pdf-ocr-XTZZEYKJ.js.map} +0 -0
- /package/dist/{pdf-ocr-PQZZVFI5.js.map → pdf-ocr-ZV3KYIIE.js.map} +0 -0
- /package/dist/{profile-io-K22CB2ZB.js.map → profile-io-FAJORRD2.js.map} +0 -0
- /package/dist/{rasterize-A6B5K4QN.js.map → rasterize-4ZJUA2DZ.js.map} +0 -0
- /package/dist/{redact-doc-TPXMML5Q.js.map → redact-doc-JPNROEH6.js.map} +0 -0
- /package/dist/{render-ROFIMWW5.js.map → render-D4WBOBKI.js.map} +0 -0
- /package/dist/{rewrite-fallback-WG7Z3LR3.js.map → rewrite-fallback-OF3QI6CX.js.map} +0 -0
- /package/dist/{seal-35U76WY2.js.map → seal-DQWEHIAM.js.map} +0 -0
- /package/dist/{setup-J5SHDFIE.js.map → setup-YC25YCQB.js.map} +0 -0
- /package/dist/{to-hwpx-X7JE6YJB.js.map → to-hwpx-D7OMPDUQ.js.map} +0 -0
- /package/dist/{to-hwpx-XQULU2I7.js.map → to-hwpx-ZWN64NCQ.js.map} +0 -0
- /package/dist/{visual-4HRP2VIH.js.map → visual-SW7NPY6K.js.map} +0 -0
- /package/dist/{watch-WZBW6UE7.js.map → watch-ZU576VSR.js.map} +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
|
-
var _chunkWPLAEJU5cjs = require('./chunk-WPLAEJU5.cjs');
|
|
4
3
|
|
|
5
4
|
|
|
6
|
-
var _chunkX7RBVVDCcjs = require('./chunk-X7RBVVDC.cjs');
|
|
7
5
|
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
7
|
+
var _chunkY4MFHEK4cjs = require('./chunk-Y4MFHEK4.cjs');
|
|
11
8
|
|
|
12
9
|
|
|
13
10
|
|
|
@@ -64,15 +61,19 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
64
61
|
|
|
65
62
|
|
|
66
63
|
|
|
67
|
-
var
|
|
64
|
+
var _chunkUBY2PLKRcjs = require('./chunk-UBY2PLKR.cjs');
|
|
68
65
|
|
|
69
66
|
|
|
70
67
|
var _chunkMMK32GPDcjs = require('./chunk-MMK32GPD.cjs');
|
|
71
|
-
require('./chunk-
|
|
68
|
+
require('./chunk-IRAZCKQ6.cjs');
|
|
69
|
+
|
|
72
70
|
|
|
71
|
+
var _chunk6NZ32OTXcjs = require('./chunk-6NZ32OTX.cjs');
|
|
73
72
|
|
|
74
73
|
|
|
75
74
|
|
|
75
|
+
var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
76
|
+
|
|
76
77
|
|
|
77
78
|
|
|
78
79
|
|
|
@@ -85,17 +86,236 @@ require('./chunk-O2652KK3.cjs');
|
|
|
85
86
|
|
|
86
87
|
|
|
87
88
|
|
|
88
|
-
var _chunkWAFJUSUFcjs = require('./chunk-WAFJUSUF.cjs');
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
var
|
|
92
|
+
var _chunkTQOAPKLUcjs = require('./chunk-TQOAPKLU.cjs');
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
var _chunkPW7MQZI4cjs = require('./chunk-PW7MQZI4.cjs');
|
|
93
97
|
|
|
94
98
|
|
|
95
99
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
96
100
|
|
|
97
|
-
// src/pdf/image-
|
|
101
|
+
// src/pdf/image-blank.ts
|
|
98
102
|
var _crypto = require('crypto');
|
|
103
|
+
var SMALL_IMAGE_DIM = 128;
|
|
104
|
+
var NEAR = 64;
|
|
105
|
+
var isWordByte = (c) => c !== void 0 && (c === 95 || c >= 48 && c <= 57 || (c | 32) >= 97 && (c | 32) <= 122);
|
|
106
|
+
function blankLargeImageStreams(bytes) {
|
|
107
|
+
const blanked = { byRaw: /* @__PURE__ */ new Map(), sizes: /* @__PURE__ */ new Set() };
|
|
108
|
+
const buf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
109
|
+
const str = (a, b) => buf.toString("latin1", Math.max(0, a), Math.min(buf.length, b));
|
|
110
|
+
const each = function* (word) {
|
|
111
|
+
for (let i = buf.indexOf(word); i >= 0; i = buf.indexOf(word, i + 1)) if (!isWordByte(buf[i + word.length])) yield i;
|
|
112
|
+
};
|
|
113
|
+
if (!each("/Encrypt").next().done) return blanked;
|
|
114
|
+
const masks = /* @__PURE__ */ new Set();
|
|
115
|
+
for (const key of ["/SMask", "/Mask"]) {
|
|
116
|
+
for (const i of each(key)) {
|
|
117
|
+
const ref = /^\s+(\d+)\s+(\d+)\s+R\b/.exec(str(i + key.length, i + key.length + NEAR));
|
|
118
|
+
if (ref) masks.add(`${ref[1]} ${ref[2]}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
let lengths;
|
|
122
|
+
const dicts = /* @__PURE__ */ new Map();
|
|
123
|
+
let pos = 0;
|
|
124
|
+
for (; ; ) {
|
|
125
|
+
let at = buf.indexOf("obj", pos);
|
|
126
|
+
let m = null;
|
|
127
|
+
while (at >= 0 && (isWordByte(buf[at + 3]) || !(m = /(\d+)\s+(\d+)\s+$/.exec(str(Math.max(pos, at - NEAR), at))))) at = buf.indexOf("obj", at + 1);
|
|
128
|
+
if (at < 0 || !m) break;
|
|
129
|
+
pos = at + 3;
|
|
130
|
+
const head = buf.indexOf("stream", pos);
|
|
131
|
+
const end = buf.indexOf("endobj", pos);
|
|
132
|
+
if (head < 0 || end >= 0 && end < head) continue;
|
|
133
|
+
const dict = str(pos, head);
|
|
134
|
+
const dictStart = pos;
|
|
135
|
+
const start = head + 6 + (buf[head + 6] === 13 ? 2 : 1);
|
|
136
|
+
let length;
|
|
137
|
+
const direct = /\/Length\s+(\d+)\b(?!\s+\d+\s+R)/.exec(dict);
|
|
138
|
+
if (direct) length = Number(direct[1]);
|
|
139
|
+
else {
|
|
140
|
+
const ref = /\/Length\s+(\d+)\s+(\d+)\s+R\b/.exec(dict);
|
|
141
|
+
if (ref) {
|
|
142
|
+
lengths ??= indirectLengths();
|
|
143
|
+
length = lengths.get(`${ref[1]} ${ref[2]}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const stop = length === void 0 ? -1 : start + length;
|
|
147
|
+
if (stop < 0 || !/^\s*endstream/.test(str(stop, stop + 16))) {
|
|
148
|
+
const e = buf.indexOf("endstream", start);
|
|
149
|
+
if (e < 0) break;
|
|
150
|
+
pos = e;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
pos = stop;
|
|
154
|
+
if (!/\/Subtype\s*\/Image\b/.test(dict) || masks.has(`${m[1]} ${m[2]}`) || /\/(?:SMask|Mask|SMaskInData)\b/.test(dict) || /\/(?:ImageMask|IM)\s+true\b/.test(dict)) continue;
|
|
155
|
+
const w = /\/Width\s+(\d+)\b(?!\s+\d+\s+R)/.exec(dict), h = /\/Height\s+(\d+)\b(?!\s+\d+\s+R)/.exec(dict);
|
|
156
|
+
if (!w || !h || Number(w[1]) <= SMALL_IMAGE_DIM && Number(h[1]) <= SMALL_IMAGE_DIM) continue;
|
|
157
|
+
const bpcs = [...dict.matchAll(/\/BitsPerComponent\s+(\d+)\b(?!\s+\d+\s+R)/g)];
|
|
158
|
+
if (bpcs.length !== 1 || (_nullishCoalesce(dict.match(/\/BitsPerComponent\b/g), () => ( []))).length !== 1) continue;
|
|
159
|
+
const bpc = bpcs[0];
|
|
160
|
+
const digits = dictStart + bpc.index + bpc[0].length - bpc[1].length;
|
|
161
|
+
bytes.fill(32, digits, digits + bpc[1].length - 1);
|
|
162
|
+
bytes[digits + bpc[1].length - 1] = 48;
|
|
163
|
+
const data = bytes.subarray(start, stop);
|
|
164
|
+
const raw = _crypto.createHash.call(void 0, "sha1").update(data).digest("hex");
|
|
165
|
+
const shape = dict.replace(/\s+/g, " ").trim();
|
|
166
|
+
blanked.byRaw.set(raw, (_nullishCoalesce(blanked.byRaw.get(raw), () => ( true))) && (_nullishCoalesce(dicts.get(raw), () => ( shape))) === shape);
|
|
167
|
+
blanked.sizes.add(`${w[1]}x${h[1]}`);
|
|
168
|
+
dicts.set(raw, shape);
|
|
169
|
+
data.fill(0);
|
|
170
|
+
}
|
|
171
|
+
return blanked;
|
|
172
|
+
function indirectLengths() {
|
|
173
|
+
const found = /* @__PURE__ */ new Map();
|
|
174
|
+
for (let i = buf.indexOf("obj"); i >= 0; i = buf.indexOf("obj", i + 1)) {
|
|
175
|
+
const num = /(\d+)\s+(\d+)\s+$/.exec(str(i - NEAR, i));
|
|
176
|
+
const value = num && /^\s*(\d+)\s*endobj/.exec(str(i + 3, i + 3 + NEAR));
|
|
177
|
+
if (value) found.set(`${num[1]} ${num[2]}`, Number(value[1]));
|
|
178
|
+
}
|
|
179
|
+
return found;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// src/pdf/pdfium-images.ts
|
|
184
|
+
|
|
185
|
+
var IMAGE_OBJECT = 3;
|
|
186
|
+
var FORM_OBJECT = 5;
|
|
187
|
+
function hasPdfiumFunctions(m) {
|
|
188
|
+
const fns = [
|
|
189
|
+
"_FPDF_LoadPage",
|
|
190
|
+
"_FPDF_ClosePage",
|
|
191
|
+
"_FPDFPage_CountObjects",
|
|
192
|
+
"_FPDFPage_GetObject",
|
|
193
|
+
"_FPDFPageObj_GetType",
|
|
194
|
+
"_FPDFFormObj_CountObjects",
|
|
195
|
+
"_FPDFFormObj_GetObject",
|
|
196
|
+
"_FPDFPage_GetAnnotCount",
|
|
197
|
+
"_FPDFPage_GetAnnot",
|
|
198
|
+
"_FPDFPage_CloseAnnot",
|
|
199
|
+
"_FPDFAnnot_GetObjectCount",
|
|
200
|
+
"_FPDFAnnot_GetObject",
|
|
201
|
+
"_FPDFImageObj_GetImagePixelSize",
|
|
202
|
+
"_FPDFImageObj_GetImageDataRaw",
|
|
203
|
+
"_FPDFImageObj_GetBitmap",
|
|
204
|
+
"_FPDFBitmap_GetBuffer",
|
|
205
|
+
"_FPDFBitmap_GetWidth",
|
|
206
|
+
"_FPDFBitmap_GetHeight",
|
|
207
|
+
"_FPDFBitmap_GetStride",
|
|
208
|
+
"_FPDFBitmap_GetFormat",
|
|
209
|
+
"_FPDFBitmap_Destroy"
|
|
210
|
+
];
|
|
211
|
+
return fns.every((f) => typeof m[f] === "function") && typeof _optionalChain([m, 'access', _2 => _2.wasmExports, 'optionalAccess', _3 => _3.malloc]) === "function" && typeof m.wasmExports.free === "function" && m.HEAPU8 instanceof Uint8Array && m.HEAPU32 instanceof Uint32Array;
|
|
212
|
+
}
|
|
213
|
+
async function openPdfiumImages(buffer, blanked) {
|
|
214
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("@hyzyla/pdfium"))).catch(() => null);
|
|
215
|
+
if (!mod) return null;
|
|
216
|
+
const lib = await mod.PDFiumLibrary.init().catch(() => null);
|
|
217
|
+
if (!lib) return null;
|
|
218
|
+
const doc = await lib.loadDocument(new Uint8Array(buffer)).catch(() => null);
|
|
219
|
+
if (!doc) {
|
|
220
|
+
lib.destroy();
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
const m = lib.module;
|
|
224
|
+
const docHandle = doc.documentIdx;
|
|
225
|
+
if (!m || typeof docHandle !== "number" || !hasPdfiumFunctions(m)) {
|
|
226
|
+
doc.destroy();
|
|
227
|
+
lib.destroy();
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
let open = null;
|
|
231
|
+
const closePage = () => {
|
|
232
|
+
if (!open) return;
|
|
233
|
+
for (const a of open.annots) m._FPDFPage_CloseAnnot(a);
|
|
234
|
+
m._FPDF_ClosePage(open.page);
|
|
235
|
+
open = null;
|
|
236
|
+
};
|
|
237
|
+
const pixelSize = (obj) => {
|
|
238
|
+
const p = m.wasmExports.malloc(8);
|
|
239
|
+
const ok = m._FPDFImageObj_GetImagePixelSize(obj, p, p + 4);
|
|
240
|
+
const size = ok ? [m.HEAPU32[p >> 2], m.HEAPU32[(p >> 2) + 1]] : [0, 0];
|
|
241
|
+
m.wasmExports.free(p);
|
|
242
|
+
return size;
|
|
243
|
+
};
|
|
244
|
+
const rawHash = (obj) => {
|
|
245
|
+
const n = m._FPDFImageObj_GetImageDataRaw(obj, 0, 0);
|
|
246
|
+
if (!n) return "";
|
|
247
|
+
const p = m.wasmExports.malloc(n);
|
|
248
|
+
m._FPDFImageObj_GetImageDataRaw(obj, p, n);
|
|
249
|
+
const hash = _crypto.createHash.call(void 0, "sha1").update(m.HEAPU8.subarray(p, p + n)).digest("hex");
|
|
250
|
+
m.wasmExports.free(p);
|
|
251
|
+
return hash;
|
|
252
|
+
};
|
|
253
|
+
return {
|
|
254
|
+
page(pageNumber) {
|
|
255
|
+
closePage();
|
|
256
|
+
const page = m._FPDF_LoadPage(docHandle, pageNumber - 1);
|
|
257
|
+
if (!page) return [];
|
|
258
|
+
open = { page, annots: [] };
|
|
259
|
+
const out = [];
|
|
260
|
+
const walk = (count, get, depth) => {
|
|
261
|
+
for (let i = 0; i < count; i++) {
|
|
262
|
+
const obj = get(i);
|
|
263
|
+
const type = m._FPDFPageObj_GetType(obj);
|
|
264
|
+
if (type === FORM_OBJECT && depth < 32) walk(m._FPDFFormObj_CountObjects(obj), (j) => m._FPDFFormObj_GetObject(obj, j), depth + 1);
|
|
265
|
+
if (type !== IMAGE_OBJECT) continue;
|
|
266
|
+
const [width, height] = pixelSize(obj);
|
|
267
|
+
if (width <= SMALL_IMAGE_DIM && height <= SMALL_IMAGE_DIM) continue;
|
|
268
|
+
const raw = rawHash(obj);
|
|
269
|
+
out.push({ width, height, raw, blanked: blanked.byRaw.has(raw), sameRawSamePixels: blanked.byRaw.get(raw) === true, handle: obj });
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
walk(m._FPDFPage_CountObjects(page), (i) => m._FPDFPage_GetObject(page, i), 0);
|
|
273
|
+
for (let i = 0; i < m._FPDFPage_GetAnnotCount(page); i++) {
|
|
274
|
+
const annot = m._FPDFPage_GetAnnot(page, i);
|
|
275
|
+
if (!annot) continue;
|
|
276
|
+
open.annots.push(annot);
|
|
277
|
+
walk(m._FPDFAnnot_GetObjectCount(annot), (j) => m._FPDFAnnot_GetObject(annot, j), 0);
|
|
278
|
+
}
|
|
279
|
+
return out;
|
|
280
|
+
},
|
|
281
|
+
decode(image) {
|
|
282
|
+
const bitmap = m._FPDFImageObj_GetBitmap(image.handle);
|
|
283
|
+
if (!bitmap) return null;
|
|
284
|
+
try {
|
|
285
|
+
const w = m._FPDFBitmap_GetWidth(bitmap), h = m._FPDFBitmap_GetHeight(bitmap);
|
|
286
|
+
const stride = m._FPDFBitmap_GetStride(bitmap), format = m._FPDFBitmap_GetFormat(bitmap);
|
|
287
|
+
const bpp = format === 1 ? 1 : format === 2 ? 3 : format === 3 || format === 4 ? 4 : 0;
|
|
288
|
+
if (!bpp || w !== image.width || h !== image.height) return null;
|
|
289
|
+
const src = m.HEAPU8, base = m._FPDFBitmap_GetBuffer(bitmap);
|
|
290
|
+
const rgba = new Uint8Array(w * h * 4);
|
|
291
|
+
for (let y = 0; y < h; y++) {
|
|
292
|
+
for (let x = 0, s = base + y * stride, d = y * w * 4; x < w; x++, s += bpp, d += 4) {
|
|
293
|
+
if (bpp === 1) {
|
|
294
|
+
rgba[d] = rgba[d + 1] = rgba[d + 2] = src[s];
|
|
295
|
+
rgba[d + 3] = 255;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
rgba[d] = src[s + 2];
|
|
299
|
+
rgba[d + 1] = src[s + 1];
|
|
300
|
+
rgba[d + 2] = src[s];
|
|
301
|
+
rgba[d + 3] = format === 4 ? src[s + 3] : 255;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return rgba;
|
|
305
|
+
} finally {
|
|
306
|
+
m._FPDFBitmap_Destroy(bitmap);
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
close() {
|
|
310
|
+
closePage();
|
|
311
|
+
doc.destroy();
|
|
312
|
+
lib.destroy();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// src/pdf/image-extract.ts
|
|
318
|
+
|
|
99
319
|
var _pdfmjs = require('pdfjs-dist/legacy/build/pdf.mjs');
|
|
100
320
|
var IMAGE_RESOLVE_TIMEOUT_MS = 5e3;
|
|
101
321
|
function resolveImgData(page, objId) {
|
|
@@ -129,8 +349,9 @@ var MIN_DIM = 8;
|
|
|
129
349
|
var MAX_PIXELS = 36e6;
|
|
130
350
|
var MAX_IMAGES_PER_DOC = 200;
|
|
131
351
|
var MAX_TOTAL_IMAGE_BYTES = 128 * 1024 * 1024;
|
|
132
|
-
|
|
133
|
-
|
|
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 };
|
|
134
355
|
}
|
|
135
356
|
function contentHash(data) {
|
|
136
357
|
return _crypto.createHash.call(void 0, "sha1").update(data).digest("hex");
|
|
@@ -178,62 +399,211 @@ function toRgba(img, convert = true) {
|
|
|
178
399
|
}
|
|
179
400
|
return null;
|
|
180
401
|
}
|
|
181
|
-
async function extractPageImages(page, fnArray, argsArray, pageNumber, state, warnings, withBytes = true) {
|
|
402
|
+
async function extractPageImages(page, fnArray, argsArray, pageNumber, state, warnings, withBytes = true, readQr) {
|
|
182
403
|
const blocks = [];
|
|
183
404
|
const images = [];
|
|
184
405
|
const pageSeenIds = /* @__PURE__ */ new Set();
|
|
406
|
+
let pdfiumQueue;
|
|
407
|
+
let unpairedSizes;
|
|
408
|
+
const pdfiumById = /* @__PURE__ */ new Map();
|
|
409
|
+
const takePdfium = (match) => {
|
|
410
|
+
const k = pdfiumQueue.findIndex(match);
|
|
411
|
+
return k < 0 ? void 0 : pdfiumQueue.splice(k, 1)[0];
|
|
412
|
+
};
|
|
413
|
+
const reusedRaws = [];
|
|
414
|
+
const consume = (raw) => {
|
|
415
|
+
if (pdfiumQueue) takePdfium((x) => x.raw === raw);
|
|
416
|
+
else reusedRaws.push(raw);
|
|
417
|
+
};
|
|
418
|
+
const pairable = (w, h) => {
|
|
419
|
+
if (!pdfiumQueue) {
|
|
420
|
+
pdfiumQueue = state.blanked.decoder.page(pageNumber);
|
|
421
|
+
unpairedSizes = pairingCounts(fnArray, argsArray, pdfiumQueue);
|
|
422
|
+
for (const raw of reusedRaws) takePdfium((x) => x.raw === raw);
|
|
423
|
+
}
|
|
424
|
+
return w !== void 0 && !unpairedSizes.has(`${w}x${h}`) && !unpairedSizes.has("repeat");
|
|
425
|
+
};
|
|
426
|
+
let pristine;
|
|
427
|
+
let paintIndex = -1;
|
|
185
428
|
for (let i = 0; i < fnArray.length; i++) {
|
|
186
429
|
const op = fnArray[i];
|
|
187
430
|
let imgData = null;
|
|
188
431
|
let dedupeId = null;
|
|
432
|
+
let fromPristine = false;
|
|
189
433
|
if (op === _pdfmjs.OPS.paintImageXObject || op === _pdfmjs.OPS.paintImageXObjectRepeat) {
|
|
190
|
-
|
|
191
|
-
|
|
434
|
+
paintIndex++;
|
|
435
|
+
const paints = op === _pdfmjs.OPS.paintImageXObjectRepeat ? (_nullishCoalesce(_optionalChain([argsArray, 'access', _4 => _4[i], 'optionalAccess', _5 => _5[3], 'optionalAccess', _6 => _6.length]), () => ( 2))) / 2 : 1;
|
|
436
|
+
const objId = _optionalChain([argsArray, 'access', _7 => _7[i], 'optionalAccess', _8 => _8[0]]);
|
|
437
|
+
if (typeof objId !== "string") continue;
|
|
438
|
+
if (pageSeenIds.has(objId)) {
|
|
439
|
+
const first = pdfiumById.get(objId);
|
|
440
|
+
if (first) for (let k = 0; k < paints; k++) consume(first.raw);
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if (await capReached(state, pageNumber, warnings)) continue;
|
|
444
|
+
if (state.blanked) {
|
|
445
|
+
const w2 = op === _pdfmjs.OPS.paintImageXObject ? _optionalChain([argsArray, 'access', _9 => _9[i], 'optionalAccess', _10 => _10[1]]) : void 0;
|
|
446
|
+
const h2 = op === _pdfmjs.OPS.paintImageXObject ? _optionalChain([argsArray, 'access', _11 => _11[i], 'optionalAccess', _12 => _12[2]]) : void 0;
|
|
447
|
+
const large = w2 === void 0 || h2 === void 0 || w2 > SMALL_IMAGE_DIM || h2 > SMALL_IMAGE_DIM;
|
|
448
|
+
const known = state.pdfiumGlobal.get(objId);
|
|
449
|
+
const reuse = known && (!known.blanked || known.sameRawSamePixels && state.rawKeys.has(known.raw));
|
|
450
|
+
let image;
|
|
451
|
+
if (reuse) {
|
|
452
|
+
image = known;
|
|
453
|
+
for (let k = 0; k < paints; k++) consume(known.raw);
|
|
454
|
+
} else {
|
|
455
|
+
image = large && pairable(w2, h2) ? _nullishCoalesce(takePdfium((x) => x.width === w2 && x.height === h2), () => ( null)) : null;
|
|
456
|
+
if (image) for (let k = 1; k < paints; k++) consume(image.raw);
|
|
457
|
+
if (image && objId.startsWith("g_")) state.pdfiumGlobal.set(objId, image);
|
|
458
|
+
}
|
|
459
|
+
pdfiumById.set(objId, image);
|
|
460
|
+
const block = _optionalChain([image, 'optionalAccess', _13 => _13.blanked]) ? await extractPdfiumImage(image, pageNumber, state, warnings, withBytes, images, readQr) : UNDECODED;
|
|
461
|
+
if (block !== UNDECODED) {
|
|
462
|
+
pageSeenIds.add(objId);
|
|
463
|
+
if (block) blocks.push(block);
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
fromPristine = large && (!!_optionalChain([image, 'optionalAccess', _14 => _14.blanked]) || !image && (w2 === void 0 || state.blanked.sizes.has(`${w2}x${h2}`)));
|
|
467
|
+
}
|
|
192
468
|
pageSeenIds.add(objId);
|
|
193
469
|
dedupeId = objId;
|
|
194
470
|
} else if (op !== _pdfmjs.OPS.paintInlineImageXObject) {
|
|
195
471
|
continue;
|
|
196
472
|
}
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
473
|
+
if (await capReached(state, pageNumber, warnings)) continue;
|
|
474
|
+
if (fromPristine) {
|
|
475
|
+
if (!pristine) {
|
|
476
|
+
const p = await (await state.blanked.pristine()).getPage(pageNumber);
|
|
477
|
+
const ops = await p.getOperatorList();
|
|
478
|
+
pristine = { page: p, ids: paintImageIds(ops.fnArray, ops.argsArray) };
|
|
201
479
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
480
|
+
dedupeId = pristine.ids[paintIndex];
|
|
481
|
+
if (typeof dedupeId !== "string") continue;
|
|
482
|
+
imgData = await resolveImgData(pristine.page, dedupeId);
|
|
483
|
+
} else if (dedupeId) {
|
|
205
484
|
imgData = await resolveImgData(page, dedupeId);
|
|
206
485
|
} else {
|
|
207
|
-
imgData = _optionalChain([argsArray, 'access',
|
|
486
|
+
imgData = _optionalChain([argsArray, 'access', _15 => _15[i], 'optionalAccess', _16 => _16[0]]);
|
|
208
487
|
}
|
|
209
|
-
if (!_optionalChain([imgData, 'optionalAccess',
|
|
488
|
+
if (!_optionalChain([imgData, 'optionalAccess', _17 => _17.data]) || !imgData.width || !imgData.height) continue;
|
|
210
489
|
const { width: w, height: h } = imgData;
|
|
211
490
|
if (w < MIN_DIM || h < MIN_DIM) continue;
|
|
212
491
|
if (w * h > MAX_PIXELS) {
|
|
213
492
|
warnings.push({ page: pageNumber, message: `\uC774\uBBF8\uC9C0 \uD06C\uAE30 \uCD08\uACFC\uB85C \uCD94\uCD9C \uC0DD\uB7B5 (${w}\xD7${h})`, code: "SKIPPED_IMAGE" });
|
|
214
493
|
continue;
|
|
215
494
|
}
|
|
216
|
-
const globalId = _optionalChain([dedupeId, 'optionalAccess',
|
|
495
|
+
const globalId = _optionalChain([dedupeId, 'optionalAccess', _18 => _18.startsWith, 'call', _19 => _19("g_")]) ? dedupeId : void 0;
|
|
217
496
|
let hash = globalId ? state.globalKeys.get(globalId) : void 0;
|
|
218
497
|
if (hash === void 0) {
|
|
219
498
|
hash = `${w}x${h}k${_nullishCoalesce(imgData.kind, () => ( "?"))}h${contentHash(imgData.data)}${dedupeId ? "" : "inline"}`;
|
|
220
499
|
if (globalId) state.globalKeys.set(globalId, hash);
|
|
221
500
|
}
|
|
222
501
|
if (state.seen.has(hash)) continue;
|
|
223
|
-
const rgba = toRgba(imgData, withBytes);
|
|
502
|
+
const rgba = toRgba(imgData, withBytes || !!readQr);
|
|
224
503
|
if (!rgba) continue;
|
|
225
504
|
state.imageIndex++;
|
|
226
|
-
const filename =
|
|
505
|
+
const filename = imageFilename(state, w, h);
|
|
227
506
|
state.seen.set(hash, filename);
|
|
228
|
-
if (withBytes)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
images.push({ filename, data: png, mimeType: "image/png" });
|
|
232
|
-
}
|
|
233
|
-
blocks.push({ type: "image", text: filename, pageNumber });
|
|
507
|
+
if (withBytes) await pushImage(state, filename, w, h, rgba, images);
|
|
508
|
+
const qr = readQr ? await readQr({ data: rgba, width: w, height: h }) : [];
|
|
509
|
+
blocks.push({ type: "image", text: filename, pageNumber, ...qr.length ? { qr } : {} });
|
|
234
510
|
}
|
|
511
|
+
_optionalChain([pristine, 'optionalAccess', _20 => _20.page, 'access', _21 => _21.cleanup, 'call', _22 => _22()]);
|
|
235
512
|
return { blocks, images };
|
|
236
513
|
}
|
|
514
|
+
function paintImageIds(fnArray, argsArray) {
|
|
515
|
+
const ids = [];
|
|
516
|
+
for (let i = 0; i < fnArray.length; i++) if (fnArray[i] === _pdfmjs.OPS.paintImageXObject || fnArray[i] === _pdfmjs.OPS.paintImageXObjectRepeat) ids.push(_optionalChain([argsArray, 'access', _23 => _23[i], 'optionalAccess', _24 => _24[0]]));
|
|
517
|
+
return ids;
|
|
518
|
+
}
|
|
519
|
+
function pairingCounts(fnArray, argsArray, pdfium) {
|
|
520
|
+
const count = /* @__PURE__ */ new Map();
|
|
521
|
+
const unpaired = /* @__PURE__ */ new Set();
|
|
522
|
+
for (let i = 0; i < fnArray.length; i++) {
|
|
523
|
+
if (fnArray[i] === _pdfmjs.OPS.paintImageXObjectRepeat) unpaired.add("repeat");
|
|
524
|
+
if (fnArray[i] !== _pdfmjs.OPS.paintImageXObject) continue;
|
|
525
|
+
const w = _optionalChain([argsArray, 'access', _25 => _25[i], 'optionalAccess', _26 => _26[1]]), h = _optionalChain([argsArray, 'access', _27 => _27[i], 'optionalAccess', _28 => _28[2]]);
|
|
526
|
+
if (w > SMALL_IMAGE_DIM || h > SMALL_IMAGE_DIM) count.set(`${w}x${h}`, (_nullishCoalesce(count.get(`${w}x${h}`), () => ( 0))) + 1);
|
|
527
|
+
}
|
|
528
|
+
for (const x of pdfium) count.set(`${x.width}x${x.height}`, (_nullishCoalesce(count.get(`${x.width}x${x.height}`), () => ( 0))) - 1);
|
|
529
|
+
for (const [size, n] of count) if (n !== 0) unpaired.add(size);
|
|
530
|
+
return unpaired;
|
|
531
|
+
}
|
|
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
|
+
if (state.imageIndex < MAX_IMAGES_PER_DOC && state.totalBytes < MAX_TOTAL_IMAGE_BYTES) return false;
|
|
535
|
+
if (!state.capWarned) {
|
|
536
|
+
state.capWarned = true;
|
|
537
|
+
warnings.push({ page: pageNumber, message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC0C1\uD55C \uB3C4\uB2EC (${MAX_IMAGES_PER_DOC}\uAC1C/128MB) \u2014 \uC774\uD6C4 \uC774\uBBF8\uC9C0 \uC0DD\uB7B5`, code: "SKIPPED_IMAGE" });
|
|
538
|
+
}
|
|
539
|
+
return true;
|
|
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"}`;
|
|
586
|
+
var UNDECODED = /* @__PURE__ */ Symbol("undecoded");
|
|
587
|
+
async function extractPdfiumImage(image, pageNumber, state, warnings, withBytes, images, readQr) {
|
|
588
|
+
const { width: w, height: h } = image;
|
|
589
|
+
if (w < MIN_DIM || h < MIN_DIM) return null;
|
|
590
|
+
if (w * h > MAX_PIXELS) {
|
|
591
|
+
warnings.push({ page: pageNumber, message: `\uC774\uBBF8\uC9C0 \uD06C\uAE30 \uCD08\uACFC\uB85C \uCD94\uCD9C \uC0DD\uB7B5 (${w}\xD7${h})`, code: "SKIPPED_IMAGE" });
|
|
592
|
+
return null;
|
|
593
|
+
}
|
|
594
|
+
if (image.sameRawSamePixels && state.rawKeys.has(image.raw)) return null;
|
|
595
|
+
const rgba = state.blanked.decoder.decode(image);
|
|
596
|
+
if (!rgba) return UNDECODED;
|
|
597
|
+
const hash = `${w}x${h}kPh${contentHash(rgba)}`;
|
|
598
|
+
state.rawKeys.set(image.raw, hash);
|
|
599
|
+
if (state.seen.has(hash)) return null;
|
|
600
|
+
state.imageIndex++;
|
|
601
|
+
const filename = imageFilename(state, w, h);
|
|
602
|
+
state.seen.set(hash, filename);
|
|
603
|
+
if (withBytes) await pushImage(state, filename, w, h, rgba, images);
|
|
604
|
+
const qr = readQr ? await readQr({ data: rgba, width: w, height: h }) : [];
|
|
605
|
+
return { type: "image", text: filename, pageNumber, ...qr.length ? { qr } : {} };
|
|
606
|
+
}
|
|
237
607
|
function injectPageImageBlocks(blocks, pageImages) {
|
|
238
608
|
if (pageImages.size === 0) return;
|
|
239
609
|
const lastIndexForPage = /* @__PURE__ */ new Map();
|
|
@@ -622,13 +992,13 @@ function ocrVectorOps(opList, paths) {
|
|
|
622
992
|
|
|
623
993
|
// src/pdf/split-row-pattern.ts
|
|
624
994
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
625
|
-
var plain = (cell) => !_optionalChain([cell, 'access',
|
|
995
|
+
var plain = (cell) => !_optionalChain([cell, 'access', _29 => _29.blocks, 'optionalAccess', _30 => _30.length]) && !_chunkUBY2PLKRcjs.IMAGE_CELLS.has(cell);
|
|
626
996
|
var labelsOf = (cell) => {
|
|
627
997
|
const labels = textOf(cell).split("\n").map((s) => s.trim()).filter(Boolean);
|
|
628
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;
|
|
629
999
|
};
|
|
630
1000
|
var alignedLabels = (label, value, count) => {
|
|
631
|
-
const L =
|
|
1001
|
+
const L = _chunkUBY2PLKRcjs.CELL_LINES.get(label), V = _chunkUBY2PLKRcjs.CELL_LINES.get(value);
|
|
632
1002
|
let next = 0;
|
|
633
1003
|
return !!L && !!V && L.length === count && V.length >= count && Math.abs(L[0].y - V[0].y) <= 1 && L.every((l) => {
|
|
634
1004
|
while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
|
|
@@ -636,18 +1006,18 @@ var alignedLabels = (label, value, count) => {
|
|
|
636
1006
|
});
|
|
637
1007
|
};
|
|
638
1008
|
function partialAlignedLabelCells(table, owner, first) {
|
|
639
|
-
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)));
|
|
640
1010
|
const pairs = [];
|
|
641
1011
|
let carried = false;
|
|
642
1012
|
for (let c = 0; c < table.cols; ) {
|
|
643
|
-
const u = _optionalChain([owner, 'access',
|
|
1013
|
+
const u = _optionalChain([owner, 'access', _31 => _31[first - 1], 'optionalAccess', _32 => _32[c]]), d = _optionalChain([owner, 'access', _33 => _33[first], 'optionalAccess', _34 => _34[c]]);
|
|
644
1014
|
if (u && u === d) {
|
|
645
1015
|
carried = true;
|
|
646
1016
|
c = u.c + u.cs;
|
|
647
1017
|
continue;
|
|
648
1018
|
}
|
|
649
1019
|
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
650
|
-
if (!_optionalChain([upper, 'optionalAccess',
|
|
1020
|
+
if (!_optionalChain([upper, 'optionalAccess', _35 => _35.text, 'access', _36 => _36.trim, 'call', _37 => _37()]) && !_optionalChain([lower, 'optionalAccess', _38 => _38.text, 'access', _39 => _39.trim, 'call', _40 => _40()])) {
|
|
651
1021
|
c++;
|
|
652
1022
|
continue;
|
|
653
1023
|
}
|
|
@@ -659,10 +1029,10 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
659
1029
|
const keyed = pairs.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
|
|
660
1030
|
if (keyed.length !== 1) return;
|
|
661
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);
|
|
662
|
-
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;
|
|
663
1033
|
const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
|
|
664
1034
|
if (D.length < 2 || sequence.length < 3 || new Set(sequence).size !== sequence.length || !alignedLabels(label.upper, value.upper, U.length)) return;
|
|
665
|
-
const L =
|
|
1035
|
+
const L = _chunkUBY2PLKRcjs.CELL_LINES.get(label.lower), V = _chunkUBY2PLKRcjs.CELL_LINES.get(value.lower);
|
|
666
1036
|
if (!L || !V || L.length !== D.length) return;
|
|
667
1037
|
let next = V.findIndex((v) => Math.abs(v.y - L[0].y) <= 1);
|
|
668
1038
|
if (next <= 0 || !V.slice(0, next).every((v) => v.y > L[0].y + 1) || !L.every((l) => {
|
|
@@ -672,7 +1042,7 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
672
1042
|
let peers = 0, shared = false;
|
|
673
1043
|
for (let r = 0; r < table.rows; r++) {
|
|
674
1044
|
if (r === first - 1 || r === first) continue;
|
|
675
|
-
const l = _optionalChain([owner, 'access',
|
|
1045
|
+
const l = _optionalChain([owner, 'access', _47 => _47[r], 'optionalAccess', _48 => _48[label.c]]), v = _optionalChain([owner, 'access', _49 => _49[r], 'optionalAccess', _50 => _50[value.c]]);
|
|
676
1046
|
if (!l || !v || l.r !== r || v.r !== r || l.c !== label.c || v.c !== value.c || l.cs !== label.cs || v.cs !== value.cs || l.rs !== v.rs) continue;
|
|
677
1047
|
const lc = table.cells[r][l.c], vc = table.cells[r][v.c];
|
|
678
1048
|
const list = labelsOf(lc);
|
|
@@ -682,15 +1052,15 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
682
1052
|
continue;
|
|
683
1053
|
}
|
|
684
1054
|
if (list.length < 3 || new Set(list).size !== list.length) continue;
|
|
685
|
-
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);
|
|
686
1056
|
if (visible < 3 || visible > list.length || !values || !alignedLabels(lc, vc, visible)) continue;
|
|
687
1057
|
const top = Math.max(...values.map((v2) => v2.y)), bottom = Math.min(...values.map((v2) => v2.y));
|
|
688
1058
|
const contexts = [];
|
|
689
1059
|
for (let rr = r; rr < r + l.rs && rr < table.rows; rr++) {
|
|
690
|
-
const a = _optionalChain([owner, 'access',
|
|
1060
|
+
const a = _optionalChain([owner, 'access', _54 => _54[rr], 'optionalAccess', _55 => _55[context.c]]), cell = a ? table.cells[a.r][a.c] : void 0;
|
|
691
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;
|
|
692
|
-
const lines =
|
|
693
|
-
if (!_optionalChain([lines, 'optionalAccess',
|
|
1062
|
+
const lines = _chunkUBY2PLKRcjs.CELL_LINES.get(cell);
|
|
1063
|
+
if (!_optionalChain([lines, 'optionalAccess', _56 => _56.length]) || lines.some((line) => line.y > top + 1 || line.y < bottom - 1)) break;
|
|
694
1064
|
contexts.push(textOf(cell).replace(/\s+/g, ""));
|
|
695
1065
|
}
|
|
696
1066
|
if (new Set(contexts).size >= 2) shared = true;
|
|
@@ -701,14 +1071,14 @@ function matchesCompleteAlignedLabelListRow(table, owner, first) {
|
|
|
701
1071
|
const pairs = [];
|
|
702
1072
|
let carried = false;
|
|
703
1073
|
for (let c = 0; c < table.cols; ) {
|
|
704
|
-
const u = _optionalChain([owner, 'access',
|
|
1074
|
+
const u = _optionalChain([owner, 'access', _57 => _57[first - 1], 'optionalAccess', _58 => _58[c]]), d = _optionalChain([owner, 'access', _59 => _59[first], 'optionalAccess', _60 => _60[c]]);
|
|
705
1075
|
if (u && u === d) {
|
|
706
1076
|
carried = true;
|
|
707
1077
|
c = u.c + u.cs;
|
|
708
1078
|
continue;
|
|
709
1079
|
}
|
|
710
1080
|
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
711
|
-
if (!_optionalChain([upper, 'optionalAccess',
|
|
1081
|
+
if (!_optionalChain([upper, 'optionalAccess', _61 => _61.text, 'access', _62 => _62.trim, 'call', _63 => _63()]) && !_optionalChain([lower, 'optionalAccess', _64 => _64.text, 'access', _65 => _65.trim, 'call', _66 => _66()])) {
|
|
712
1082
|
c++;
|
|
713
1083
|
continue;
|
|
714
1084
|
}
|
|
@@ -726,10 +1096,10 @@ function matchesCompleteAlignedLabelListRow(table, owner, first) {
|
|
|
726
1096
|
let peers = 0;
|
|
727
1097
|
for (let r = 0; r < table.rows; r++) {
|
|
728
1098
|
if (r === first - 1 || r === first) continue;
|
|
729
|
-
const L = _optionalChain([owner, 'access',
|
|
730
|
-
if (_optionalChain([L, 'optionalAccess',
|
|
1099
|
+
const L = _optionalChain([owner, 'access', _67 => _67[r], 'optionalAccess', _68 => _68[label.c]]), V = _optionalChain([owner, 'access', _69 => _69[r], 'optionalAccess', _70 => _70[value.c]]);
|
|
1100
|
+
if (_optionalChain([L, 'optionalAccess', _71 => _71.r]) !== r || _optionalChain([V, 'optionalAccess', _72 => _72.r]) !== r || L.c !== label.c || V.c !== value.c || L.rs !== 1 || V.rs !== 1 || L.cs !== label.cs || V.cs !== value.cs) continue;
|
|
731
1101
|
const l = table.cells[r][label.c], v = table.cells[r][value.c];
|
|
732
|
-
if (!plain(l) || !plain(v) || !textOf(v) || _optionalChain([labelsOf, 'call',
|
|
1102
|
+
if (!plain(l) || !plain(v) || !textOf(v) || _optionalChain([labelsOf, 'call', _73 => _73(l), 'optionalAccess', _74 => _74.join, 'call', _75 => _75("|")]) !== sequence.join("|") || !alignedLabels(l, v, sequence.length)) continue;
|
|
733
1103
|
if (++peers >= 2) return true;
|
|
734
1104
|
}
|
|
735
1105
|
return false;
|
|
@@ -738,13 +1108,13 @@ function matchesIndependentRowPair(table, owner, first) {
|
|
|
738
1108
|
const norm = (cell) => textOf(cell).replace(/\s+/g, "");
|
|
739
1109
|
const pairs = [];
|
|
740
1110
|
for (let c = 0; c < table.cols; ) {
|
|
741
|
-
const u = _optionalChain([owner, 'access',
|
|
1111
|
+
const u = _optionalChain([owner, 'access', _76 => _76[first - 1], 'optionalAccess', _77 => _77[c]]), d = _optionalChain([owner, 'access', _78 => _78[first], 'optionalAccess', _79 => _79[c]]);
|
|
742
1112
|
if (u && u === d) {
|
|
743
1113
|
c = u.c + u.cs;
|
|
744
1114
|
continue;
|
|
745
1115
|
}
|
|
746
1116
|
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
747
|
-
if (!_optionalChain([upper, 'optionalAccess',
|
|
1117
|
+
if (!_optionalChain([upper, 'optionalAccess', _80 => _80.text, 'access', _81 => _81.trim, 'call', _82 => _82()]) && !_optionalChain([lower, 'optionalAccess', _83 => _83.text, 'access', _84 => _84.trim, 'call', _85 => _85()])) {
|
|
748
1118
|
c++;
|
|
749
1119
|
continue;
|
|
750
1120
|
}
|
|
@@ -756,8 +1126,8 @@ function matchesIndependentRowPair(table, owner, first) {
|
|
|
756
1126
|
return table.cells.some((_, r) => {
|
|
757
1127
|
if (r + 1 >= table.rows || r + 1 >= first - 1 && r <= first) return false;
|
|
758
1128
|
return pairs.every((p) => [p.upper, p.lower].every((text, i) => {
|
|
759
|
-
const a = _optionalChain([owner, 'access',
|
|
760
|
-
return _optionalChain([a, 'optionalAccess',
|
|
1129
|
+
const a = _optionalChain([owner, 'access', _86 => _86[r + i], 'optionalAccess', _87 => _87[p.c]]), cell = _optionalChain([table, 'access', _88 => _88.cells, 'access', _89 => _89[r + i], 'optionalAccess', _90 => _90[p.c]]);
|
|
1130
|
+
return _optionalChain([a, 'optionalAccess', _91 => _91.r]) === r + i && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(cell) === text;
|
|
761
1131
|
}));
|
|
762
1132
|
});
|
|
763
1133
|
}
|
|
@@ -766,7 +1136,7 @@ function matchesCompleteContextRow(table, owner, first) {
|
|
|
766
1136
|
const context = [];
|
|
767
1137
|
let value;
|
|
768
1138
|
for (let c = 0; c < table.cols; ) {
|
|
769
|
-
const u = _optionalChain([owner, 'access',
|
|
1139
|
+
const u = _optionalChain([owner, 'access', _92 => _92[first - 1], 'optionalAccess', _93 => _93[c]]), d = _optionalChain([owner, 'access', _94 => _94[first], 'optionalAccess', _95 => _95[c]]);
|
|
770
1140
|
if (u && u === d) {
|
|
771
1141
|
const cell = table.cells[u.r][u.c];
|
|
772
1142
|
if (u.r === first - 1 && u.rs === 2 && plain(cell) && textOf(cell)) context.push({ c, cs: u.cs, text: norm(textOf(cell)) });
|
|
@@ -774,7 +1144,7 @@ function matchesCompleteContextRow(table, owner, first) {
|
|
|
774
1144
|
continue;
|
|
775
1145
|
}
|
|
776
1146
|
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
777
|
-
if (!_optionalChain([upper, 'optionalAccess',
|
|
1147
|
+
if (!_optionalChain([upper, 'optionalAccess', _96 => _96.text, 'access', _97 => _97.trim, 'call', _98 => _98()]) && !_optionalChain([lower, 'optionalAccess', _99 => _99.text, 'access', _100 => _100.trim, 'call', _101 => _101()])) {
|
|
778
1148
|
c++;
|
|
779
1149
|
continue;
|
|
780
1150
|
}
|
|
@@ -785,8 +1155,8 @@ function matchesCompleteContextRow(table, owner, first) {
|
|
|
785
1155
|
if (!value || !context.length) return false;
|
|
786
1156
|
const proof = [...context, value];
|
|
787
1157
|
return table.cells.some((row, r) => r !== first - 1 && r !== first && proof.every((p) => {
|
|
788
|
-
const a = _optionalChain([owner, 'access',
|
|
789
|
-
return _optionalChain([a, 'optionalAccess',
|
|
1158
|
+
const a = _optionalChain([owner, 'access', _102 => _102[r], 'optionalAccess', _103 => _103[p.c]]), cell = row[p.c];
|
|
1159
|
+
return _optionalChain([a, 'optionalAccess', _104 => _104.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(textOf(cell)) === p.text;
|
|
790
1160
|
}));
|
|
791
1161
|
}
|
|
792
1162
|
function matchesCompleteSiblingRow(table, owner, first) {
|
|
@@ -814,7 +1184,7 @@ function matchesCompleteSiblingRow(table, owner, first) {
|
|
|
814
1184
|
const norm = (s, title) => (title ? s.replace(/^[가-힣]\.\s*/, "") : s).replace(/\s+/g, "");
|
|
815
1185
|
return table.cells.some((row, r) => r !== first - 1 && r !== first && pairs.every((p) => {
|
|
816
1186
|
const anchor = owner[r][p.c], peer = row[p.c];
|
|
817
|
-
return _optionalChain([anchor, 'optionalAccess',
|
|
1187
|
+
return _optionalChain([anchor, 'optionalAccess', _105 => _105.r]) === r && anchor.c === p.c && anchor.rs === 1 && anchor.cs === p.cs && plain(peer) && norm(textOf(peer), p === main) === norm(textOf(p.upper) + "\n" + textOf(p.lower), p === main);
|
|
818
1188
|
}));
|
|
819
1189
|
}
|
|
820
1190
|
function matchesCompleteRubricRow(table, owner, first) {
|
|
@@ -848,7 +1218,7 @@ function matchesCompleteRubricRow(table, owner, first) {
|
|
|
848
1218
|
return table.cells.some((row, r) => {
|
|
849
1219
|
if (r === first - 1 || r === first || !pairs.every((p) => {
|
|
850
1220
|
const a = owner[r][p.c];
|
|
851
|
-
return _optionalChain([a, 'optionalAccess',
|
|
1221
|
+
return _optionalChain([a, 'optionalAccess', _106 => _106.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && plain(row[p.c]);
|
|
852
1222
|
})) return false;
|
|
853
1223
|
const peer = textOf(row[main.c]), peerMarks = items(peer);
|
|
854
1224
|
return peerMarks.length === marks.length && peerMarks.every((m, i) => m.n === marks[i].n) && values(row[score.c]).join("|") === scores.join("|") && norm(peer.slice(peerMarks[peerMarks.length - 1].at)) === tail;
|
|
@@ -870,11 +1240,11 @@ function hasNumberedRowSequence(table, owner, first) {
|
|
|
870
1240
|
if (first < 3) return false;
|
|
871
1241
|
const rows = [first - 3, first - 2, first - 1, first];
|
|
872
1242
|
const separate = (c, cs) => rows.every((r) => {
|
|
873
|
-
const a = _optionalChain([owner, 'access',
|
|
874
|
-
return _optionalChain([a, 'optionalAccess',
|
|
1243
|
+
const a = _optionalChain([owner, 'access', _107 => _107[r], 'optionalAccess', _108 => _108[c]]), cell = _optionalChain([table, 'access', _109 => _109.cells, 'access', _110 => _110[r], 'optionalAccess', _111 => _111[c]]);
|
|
1244
|
+
return _optionalChain([a, 'optionalAccess', _112 => _112.r]) === r && a.c === c && a.rs === 1 && a.cs === cs && !!cell && plain(cell) && !!textOf(cell);
|
|
875
1245
|
});
|
|
876
1246
|
for (let c = 0; c < table.cols; c++) {
|
|
877
|
-
const a = _optionalChain([owner, 'access',
|
|
1247
|
+
const a = _optionalChain([owner, 'access', _113 => _113[first], 'optionalAccess', _114 => _114[c]]);
|
|
878
1248
|
if (!a || !separate(c, a.cs)) continue;
|
|
879
1249
|
const marks = rows.map((r) => {
|
|
880
1250
|
const lines = textOf(table.cells[r][c]).split("\n"), firstMark = itemMark(lines[0]);
|
|
@@ -883,7 +1253,7 @@ function hasNumberedRowSequence(table, owner, first) {
|
|
|
883
1253
|
const head = marks[0];
|
|
884
1254
|
if (!head || marks.some((m, i) => !m || m.style !== head.style || m.n !== head.n + i)) continue;
|
|
885
1255
|
for (let d = 0; d < table.cols; d++) {
|
|
886
|
-
const side = _optionalChain([owner, 'access',
|
|
1256
|
+
const side = _optionalChain([owner, 'access', _115 => _115[first], 'optionalAccess', _116 => _116[d]]);
|
|
887
1257
|
if (side && (d + side.cs <= c || d >= c + a.cs) && separate(d, side.cs)) return true;
|
|
888
1258
|
}
|
|
889
1259
|
}
|
|
@@ -956,7 +1326,7 @@ var CELL_SPLITS = /* @__PURE__ */ new WeakMap();
|
|
|
956
1326
|
function relocate(src, dst, from = 0) {
|
|
957
1327
|
const out = [];
|
|
958
1328
|
for (const s of _nullishCoalesce(CELL_SPLITS.get(src), () => ( []))) {
|
|
959
|
-
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access',
|
|
1329
|
+
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access', _117 => _117.at, 'call', _118 => _118(-1), 'optionalAccess', _119 => _119.at]), () => ( 0))));
|
|
960
1330
|
if (at >= 0) out.push({ at, page: s.page });
|
|
961
1331
|
}
|
|
962
1332
|
return out;
|
|
@@ -980,7 +1350,7 @@ function rowStarts(t) {
|
|
|
980
1350
|
const starts = [];
|
|
981
1351
|
for (let c = 0; c < t.cols; c++) {
|
|
982
1352
|
if (covered.has(r * 1e5 + c)) continue;
|
|
983
|
-
const cell = _optionalChain([t, 'access',
|
|
1353
|
+
const cell = _optionalChain([t, 'access', _120 => _120.cells, 'access', _121 => _121[r], 'optionalAccess', _122 => _122[c]]);
|
|
984
1354
|
if (!cell) continue;
|
|
985
1355
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) if (dr || dc) covered.add((r + dr) * 1e5 + c + dc);
|
|
986
1356
|
starts.push({ cell, c });
|
|
@@ -991,8 +1361,8 @@ function rowStarts(t) {
|
|
|
991
1361
|
}
|
|
992
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));
|
|
993
1363
|
function cellPage(cell) {
|
|
994
|
-
const p =
|
|
995
|
-
if (p !== void 0 || !_optionalChain([cell, 'access',
|
|
1364
|
+
const p = _chunkTQOAPKLUcjs.CELL_PAGES.get(cell);
|
|
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;
|
|
996
1366
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
997
1367
|
}
|
|
998
1368
|
function tableRowPages(t, pageNumber) {
|
|
@@ -1003,7 +1373,7 @@ function tableRowPages(t, pageNumber) {
|
|
|
1003
1373
|
for (const { cell } of starts) {
|
|
1004
1374
|
const p = cellPage(cell);
|
|
1005
1375
|
if (p !== void 0) mark = Math.max(_nullishCoalesce(mark, () => ( p)), p);
|
|
1006
|
-
else if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
1376
|
+
else if (cell.text.trim() || _optionalChain([cell, 'access', _125 => _125.blocks, 'optionalAccess', _126 => _126.length])) text = true;
|
|
1007
1377
|
}
|
|
1008
1378
|
const page = _nullishCoalesce(mark, () => ( (text ? pageNumber : prev)));
|
|
1009
1379
|
prev = page !== void 0 && prev !== void 0 ? Math.max(prev, page) : _nullishCoalesce(page, () => ( prev));
|
|
@@ -1020,8 +1390,8 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1020
1390
|
rows.forEach((starts, r) => {
|
|
1021
1391
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
1022
1392
|
for (const { cell } of starts) {
|
|
1023
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
1024
|
-
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess',
|
|
1393
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkTQOAPKLUcjs.CELL_PAGES.set(cell, page2);
|
|
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))]);
|
|
1025
1395
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
1026
1396
|
}
|
|
1027
1397
|
});
|
|
@@ -1030,8 +1400,8 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1030
1400
|
const tailPage = cp[0];
|
|
1031
1401
|
if (tailPage === void 0 || tailPage === prev.pageNumber) return;
|
|
1032
1402
|
for (let r = 0; r < pt.rows; r++) for (const { cell, c } of rows[r]) {
|
|
1033
|
-
const head = _optionalChain([ptRows, 'access',
|
|
1034
|
-
if (!_optionalChain([head, 'optionalAccess',
|
|
1403
|
+
const head = _optionalChain([ptRows, 'access', _129 => _129[r], 'optionalAccess', _130 => _130.find, 'call', _131 => _131((s) => s.c === c), 'optionalAccess', _132 => _132.cell]), tail = _optionalChain([ctRows, 'access', _133 => _133[0], 'optionalAccess', _134 => _134.find, 'call', _135 => _135((s) => s.c === c), 'optionalAccess', _136 => _136.cell]);
|
|
1404
|
+
if (!_optionalChain([head, 'optionalAccess', _137 => _137.text, 'access', _138 => _138.trim, 'call', _139 => _139()]) || !_optionalChain([tail, 'optionalAccess', _140 => _140.text, 'access', _141 => _141.trim, 'call', _142 => _142()]) || _optionalChain([cell, 'access', _143 => _143.blocks, 'optionalAccess', _144 => _144.length]) || cell.colSpan !== head.colSpan || cell.colSpan !== tail.colSpan || cell.rowSpan <= head.rowSpan || r + head.rowSpan !== pt.rows || r + cell.rowSpan <= pt.rows || !cell.text.startsWith(head.text.trimEnd()) || !cell.text.trimEnd().endsWith(tail.text.trimEnd())) continue;
|
|
1035
1405
|
const from = head.text.trimEnd().length, at = cell.text.indexOf(tail.text.trim().slice(0, 20), from);
|
|
1036
1406
|
if (at >= from) setSplits(cell, [...relocate(head, cell), { at, page: tailPage }, ...relocate(tail, cell, at)]);
|
|
1037
1407
|
}
|
|
@@ -1042,7 +1412,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1042
1412
|
for (const { cell } of ctRows[cr]) for (const b of _nullishCoalesce(cell.blocks, () => ( []))) b.pageNumber ??= page;
|
|
1043
1413
|
const heads = covering(pt, pt.rows - 1);
|
|
1044
1414
|
for (const cell of covering(table, pt.rows - 1)) {
|
|
1045
|
-
if (_optionalChain([cell, 'access',
|
|
1415
|
+
if (_optionalChain([cell, 'access', _145 => _145.blocks, 'optionalAccess', _146 => _146.length])) continue;
|
|
1046
1416
|
const head = heads.filter((h) => h.text.trim() && cell.text.startsWith(h.text.trimEnd()) && cell.text.trim().length > h.text.trim().length).sort((a, b) => b.text.length - a.text.length)[0];
|
|
1047
1417
|
if (!head) continue;
|
|
1048
1418
|
const from = head.text.trimEnd().length;
|
|
@@ -1053,7 +1423,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1053
1423
|
}
|
|
1054
1424
|
function splitCell(cell, page) {
|
|
1055
1425
|
if (page === void 0) return null;
|
|
1056
|
-
if (_optionalChain([cell, 'access',
|
|
1426
|
+
if (_optionalChain([cell, 'access', _147 => _147.blocks, 'optionalAccess', _148 => _148.length])) {
|
|
1057
1427
|
const k2 = cell.blocks.findIndex((b) => (_nullishCoalesce(b.pageNumber, () => ( page))) > page);
|
|
1058
1428
|
if (k2 <= 0) return null;
|
|
1059
1429
|
const head = cell.blocks.slice(0, k2), tail = cell.blocks.slice(k2);
|
|
@@ -1080,8 +1450,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1080
1450
|
if (!splits.length) continue;
|
|
1081
1451
|
const clone = (cell, patch) => {
|
|
1082
1452
|
const out = { ...cell, ...patch };
|
|
1083
|
-
const p =
|
|
1084
|
-
if (p !== void 0)
|
|
1453
|
+
const p = _chunkTQOAPKLUcjs.CELL_PAGES.get(cell);
|
|
1454
|
+
if (p !== void 0) _chunkTQOAPKLUcjs.CELL_PAGES.set(out, p);
|
|
1085
1455
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
1086
1456
|
return out;
|
|
1087
1457
|
};
|
|
@@ -1092,7 +1462,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1092
1462
|
for (const { cell, c, split } of splits) {
|
|
1093
1463
|
cells[r][c] = clone(cell, { ...split.head, rowSpan: cut - r });
|
|
1094
1464
|
const tail = { ...cell, ...split.tail, rowSpan: r + cell.rowSpan - cut };
|
|
1095
|
-
|
|
1465
|
+
_chunkTQOAPKLUcjs.CELL_PAGES.set(tail, split.page);
|
|
1096
1466
|
setSplits(tail, split.rest);
|
|
1097
1467
|
cells[cut][c] = tail;
|
|
1098
1468
|
}
|
|
@@ -1102,7 +1472,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1102
1472
|
for (const { cell, c, split } of splits) {
|
|
1103
1473
|
cells[r][c] = clone(cell, split.head);
|
|
1104
1474
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
1105
|
-
|
|
1475
|
+
_chunkTQOAPKLUcjs.CELL_PAGES.set(tail, split.page);
|
|
1106
1476
|
setSplits(tail, split.rest);
|
|
1107
1477
|
row[c] = tail;
|
|
1108
1478
|
}
|
|
@@ -1144,7 +1514,7 @@ function anchorsOf(table) {
|
|
|
1144
1514
|
for (let r = 0; r < table.rows; r++) {
|
|
1145
1515
|
for (let c = 0; c < table.cols; c++) {
|
|
1146
1516
|
if (covered.has(r * 1e5 + c)) continue;
|
|
1147
|
-
const cell = _optionalChain([table, 'access',
|
|
1517
|
+
const cell = _optionalChain([table, 'access', _149 => _149.cells, 'access', _150 => _150[r], 'optionalAccess', _151 => _151[c]]);
|
|
1148
1518
|
if (!cell) continue;
|
|
1149
1519
|
out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
|
|
1150
1520
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
@@ -1193,7 +1563,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1193
1563
|
if (cols < 1) return null;
|
|
1194
1564
|
const pa = anchorsOf(prev), ca = anchorsOf(curr);
|
|
1195
1565
|
const cutOpen = (() => {
|
|
1196
|
-
const u =
|
|
1566
|
+
const u = _chunkUBY2PLKRcjs.ROW_RULES.get(prev), d = _chunkUBY2PLKRcjs.ROW_RULES.get(curr);
|
|
1197
1567
|
return !!u && !!d && !u.bottom && !d.top;
|
|
1198
1568
|
})();
|
|
1199
1569
|
let skip = 0, head = 0;
|
|
@@ -1225,24 +1595,24 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1225
1595
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
1226
1596
|
}
|
|
1227
1597
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
1228
|
-
const lines =
|
|
1229
|
-
if (lines)
|
|
1230
|
-
if (
|
|
1231
|
-
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);
|
|
1232
1602
|
if (edges) {
|
|
1233
|
-
|
|
1603
|
+
_chunkTQOAPKLUcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
1234
1604
|
edged = true;
|
|
1235
1605
|
}
|
|
1236
1606
|
return true;
|
|
1237
1607
|
};
|
|
1238
|
-
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;
|
|
1239
1609
|
for (const a of ca) {
|
|
1240
|
-
if (a.r < skip ||
|
|
1610
|
+
if (a.r < skip || _chunkUBY2PLKRcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
1241
1611
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
1242
1612
|
}
|
|
1243
1613
|
const first = prev.rows;
|
|
1244
1614
|
for (let c = 0; c < cols; c++) {
|
|
1245
|
-
const above = _optionalChain([owner, 'access',
|
|
1615
|
+
const above = _optionalChain([owner, 'access', _152 => _152[first - 1], 'optionalAccess', _153 => _153[c]]);
|
|
1246
1616
|
if (!above) continue;
|
|
1247
1617
|
let r = first;
|
|
1248
1618
|
while (r < rows && owner[r][c] === null) r++;
|
|
@@ -1261,9 +1631,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1261
1631
|
const grown = { ...above, rs: newRs };
|
|
1262
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;
|
|
1263
1633
|
}
|
|
1264
|
-
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]);
|
|
1265
1635
|
if (edged) {
|
|
1266
|
-
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);
|
|
1267
1637
|
}
|
|
1268
1638
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1269
1639
|
let r = prev.rows;
|
|
@@ -1272,7 +1642,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1272
1642
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1273
1643
|
}
|
|
1274
1644
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1275
|
-
const pr =
|
|
1645
|
+
const pr = _chunkUBY2PLKRcjs.ROW_RULES.get(prev), cr = _chunkUBY2PLKRcjs.ROW_RULES.get(curr);
|
|
1276
1646
|
const shifted = dx !== 0;
|
|
1277
1647
|
const cut = {
|
|
1278
1648
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1280,13 +1650,13 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1280
1650
|
list: !shifted ? "any" : skip > 0 && ca.filter((a) => a.r < skip && a.cell.text.trim()).length < 2 ? "none" : "multi"
|
|
1281
1651
|
};
|
|
1282
1652
|
let partial = !skip && cols === prev.cols && cols === curr.cols && cut.ruled && prevBottom !== void 0 ? partialAlignedLabelCells(table, owner, first) : void 0;
|
|
1283
|
-
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;
|
|
1284
1654
|
const selected = partial ? /* @__PURE__ */ new Set([partial.label.c, partial.value.c]) : void 0;
|
|
1285
1655
|
let split = !selected && rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
|
|
1286
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 });
|
|
1287
1657
|
if (pr && cr) {
|
|
1288
1658
|
const cutRuled = pr.bottom || cr.top;
|
|
1289
|
-
|
|
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) });
|
|
1290
1660
|
}
|
|
1291
1661
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1292
1662
|
}
|
|
@@ -1348,19 +1718,19 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1348
1718
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1349
1719
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1350
1720
|
if (selected && !selected.has(u.c)) continue;
|
|
1351
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1352
|
-
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) => {
|
|
1353
1723
|
if (!r || r === first) return false;
|
|
1354
1724
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1355
1725
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1356
|
-
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]);
|
|
1357
1727
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1358
1728
|
});
|
|
1359
1729
|
if (!selected && !openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1360
1730
|
if (!straddles && !midWord) continue;
|
|
1361
1731
|
if (u.r >= last && d.rs < 2) continue;
|
|
1362
|
-
const U =
|
|
1363
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1732
|
+
const U = _chunkUBY2PLKRcjs.CELL_LINES.get(a);
|
|
1733
|
+
if (!_optionalChain([U, 'optionalAccess', _154 => _154.length]) || !hasContent(b)) continue;
|
|
1364
1734
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1365
1735
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
1366
1736
|
const lu = U[U.length - 1];
|
|
@@ -1377,7 +1747,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1377
1747
|
return merged;
|
|
1378
1748
|
}
|
|
1379
1749
|
function longLastLine(c) {
|
|
1380
|
-
const L =
|
|
1750
|
+
const L = _chunkUBY2PLKRcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _155 => _155[L.length - 1]]);
|
|
1381
1751
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1382
1752
|
}
|
|
1383
1753
|
function filledToBottom(U, bottom) {
|
|
@@ -1410,8 +1780,8 @@ function nextItemHead(prev, next) {
|
|
|
1410
1780
|
return false;
|
|
1411
1781
|
}
|
|
1412
1782
|
function continuesAcross(u, d, x1, x2) {
|
|
1413
|
-
const U =
|
|
1414
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1783
|
+
const U = _chunkUBY2PLKRcjs.CELL_LINES.get(u), D = _chunkUBY2PLKRcjs.CELL_LINES.get(d);
|
|
1784
|
+
if (!_optionalChain([U, 'optionalAccess', _156 => _156.length]) || !_optionalChain([D, 'optionalAccess', _157 => _157.length])) return false;
|
|
1415
1785
|
const last = U[U.length - 1];
|
|
1416
1786
|
const fs = last.h || 10;
|
|
1417
1787
|
let minL = Infinity, maxR = -Infinity;
|
|
@@ -1428,7 +1798,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1428
1798
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1429
1799
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1430
1800
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1431
|
-
const newItem =
|
|
1801
|
+
const newItem = _chunkUBY2PLKRcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1432
1802
|
const all = D.length ? U.concat(D) : U;
|
|
1433
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));
|
|
1434
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;
|
|
@@ -1445,12 +1815,12 @@ function outlineContinues(u, d) {
|
|
|
1445
1815
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1446
1816
|
}
|
|
1447
1817
|
function lineEnded(c, x1, x2, next) {
|
|
1448
|
-
const L =
|
|
1818
|
+
const L = _chunkUBY2PLKRcjs.CELL_LINES.get(c);
|
|
1449
1819
|
if (!L || L.length !== 1) return false;
|
|
1450
1820
|
const l = L[0], h = l.h || 10;
|
|
1451
|
-
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;
|
|
1452
1822
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1453
|
-
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
1823
|
+
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _161 => _161.text]), () => ( "")))) * h;
|
|
1454
1824
|
}
|
|
1455
1825
|
function firstWordUnits(text) {
|
|
1456
1826
|
const word = _nullishCoalesce(flowText(text).trim().replace(/^([(\[「『<〈])\s+/, "$1").split(/\s+/)[0], () => ( ""));
|
|
@@ -1459,15 +1829,15 @@ function firstWordUnits(text) {
|
|
|
1459
1829
|
return units;
|
|
1460
1830
|
}
|
|
1461
1831
|
function appendCell(a, b) {
|
|
1462
|
-
if (
|
|
1463
|
-
if (_optionalChain([a, 'access',
|
|
1464
|
-
const asBlocks = (c) => _optionalChain([c, 'access',
|
|
1832
|
+
if (_chunkUBY2PLKRcjs.IMAGE_CELLS.has(b)) _chunkUBY2PLKRcjs.IMAGE_CELLS.add(a);
|
|
1833
|
+
if (_optionalChain([a, 'access', _162 => _162.blocks, 'optionalAccess', _163 => _163.length]) || _optionalChain([b, 'access', _164 => _164.blocks, 'optionalAccess', _165 => _165.length])) {
|
|
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 }));
|
|
1465
1835
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1466
1836
|
}
|
|
1467
1837
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1468
|
-
|
|
1838
|
+
_chunkUBY2PLKRcjs.joinCellEdges.call(void 0, a, b);
|
|
1469
1839
|
}
|
|
1470
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access',
|
|
1840
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _168 => _168.blocks, 'optionalAccess', _169 => _169.length]) || _chunkUBY2PLKRcjs.IMAGE_CELLS.has(cell);
|
|
1471
1841
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1472
1842
|
var batchim = (ch) => {
|
|
1473
1843
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1475,7 +1845,7 @@ var batchim = (ch) => {
|
|
|
1475
1845
|
};
|
|
1476
1846
|
function clauseContinues(u, d) {
|
|
1477
1847
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1478
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1848
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkUBY2PLKRcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1479
1849
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1480
1850
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1481
1851
|
}
|
|
@@ -1483,8 +1853,8 @@ function quantityContinues(u, d) {
|
|
|
1483
1853
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1484
1854
|
}
|
|
1485
1855
|
function wordOverflows(u, d, x1, x2) {
|
|
1486
|
-
const U =
|
|
1487
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
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;
|
|
1488
1858
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1489
1859
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1490
1860
|
}
|
|
@@ -1494,7 +1864,7 @@ function listContinues(u, d, multi = false) {
|
|
|
1494
1864
|
const marks = u.text.split("\n").map((l) => itemMark(l.trim()));
|
|
1495
1865
|
let last = -1, count = 0;
|
|
1496
1866
|
marks.forEach((m, i) => {
|
|
1497
|
-
if (_optionalChain([m, 'optionalAccess',
|
|
1867
|
+
if (_optionalChain([m, 'optionalAccess', _171 => _171.style]) === head.style) {
|
|
1498
1868
|
last = i;
|
|
1499
1869
|
count++;
|
|
1500
1870
|
}
|
|
@@ -1553,7 +1923,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1553
1923
|
if (!carriedSplit && !band) {
|
|
1554
1924
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1555
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;
|
|
1556
|
-
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;
|
|
1557
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;
|
|
1558
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;
|
|
1559
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));
|
|
@@ -1585,8 +1955,8 @@ function besideOwn(b, p, c) {
|
|
|
1585
1955
|
}
|
|
1586
1956
|
var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
|
|
1587
1957
|
function pageNumberBetween(b, p, c, pageHeights) {
|
|
1588
|
-
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
1589
|
-
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess',
|
|
1958
|
+
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _175 => _175.text, 'optionalAccess', _176 => _176.trim, 'call', _177 => _177()]), () => ( "")))) return false;
|
|
1959
|
+
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _178 => _178.get, 'call', _179 => _179(b.pageNumber)]) : void 0;
|
|
1590
1960
|
if (!h) return false;
|
|
1591
1961
|
if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
|
|
1592
1962
|
if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
|
|
@@ -1610,7 +1980,7 @@ function insideTable(b, t) {
|
|
|
1610
1980
|
return b.bbox.x >= o.x - 1 && b.bbox.x + b.bbox.width <= o.x + o.width + 1 && b.bbox.y >= o.y - 1 && b.bbox.y + b.bbox.height <= o.y + o.height + 1;
|
|
1611
1981
|
}
|
|
1612
1982
|
function startsWithUnitRow(table) {
|
|
1613
|
-
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access',
|
|
1983
|
+
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _180 => _180.cells, 'access', _181 => _181[0], 'optionalAccess', _182 => _182[0], 'optionalAccess', _183 => _183.text]), () => ( ""))) && _optionalChain([table, 'access', _184 => _184.cells, 'access', _185 => _185[0], 'optionalAccess', _186 => _186.slice, 'call', _187 => _187(1), 'access', _188 => _188.every, 'call', _189 => _189((c) => !c.text.trim())]);
|
|
1614
1984
|
}
|
|
1615
1985
|
function sameHeadShape(a, b) {
|
|
1616
1986
|
if (!a || !b || a.length !== b.length) return false;
|
|
@@ -1622,7 +1992,7 @@ function sameHeadShape(a, b) {
|
|
|
1622
1992
|
return tall;
|
|
1623
1993
|
}
|
|
1624
1994
|
function hasBoxTitle(t) {
|
|
1625
|
-
const titles = _nullishCoalesce(_optionalChain([t, 'access',
|
|
1995
|
+
const titles = _nullishCoalesce(_optionalChain([t, 'access', _190 => _190.cells, 'access', _191 => _191[0], 'optionalAccess', _192 => _192.filter, 'call', _193 => _193((c) => c.text.trim())]), () => ( []));
|
|
1626
1996
|
if (titles.length !== 1 || titles[0].rowSpan < 2) return false;
|
|
1627
1997
|
const body = t.cells[titles[0].rowSpan];
|
|
1628
1998
|
return !!body && body[0].colSpan === t.cols && !!body[0].text.trim();
|
|
@@ -1636,7 +2006,7 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1636
2006
|
const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
|
|
1637
2007
|
while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
|
|
1638
2008
|
const curr = blocks[j];
|
|
1639
|
-
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess',
|
|
2009
|
+
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _194 => _194.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
|
|
1640
2010
|
if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
|
|
1641
2011
|
if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
|
|
1642
2012
|
if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
|
|
@@ -1646,19 +2016,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1646
2016
|
placeJoined(blocks, i, j, joined);
|
|
1647
2017
|
continue;
|
|
1648
2018
|
}
|
|
1649
|
-
if (
|
|
2019
|
+
if (_chunkUBY2PLKRcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1650
2020
|
blocks.splice(j, 1);
|
|
1651
2021
|
i++;
|
|
1652
2022
|
continue;
|
|
1653
2023
|
}
|
|
1654
2024
|
if (joined === null) continue;
|
|
1655
|
-
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;
|
|
1656
2026
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1657
2027
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1658
2028
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1659
2029
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1660
|
-
const px =
|
|
1661
|
-
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;
|
|
1662
2032
|
if (!px !== !cx) continue;
|
|
1663
2033
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1664
2034
|
let currCells = curr.table.cells;
|
|
@@ -1670,16 +2040,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1670
2040
|
blocks.splice(j, 1);
|
|
1671
2041
|
continue;
|
|
1672
2042
|
}
|
|
1673
|
-
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))) {
|
|
1674
2044
|
const dx = px[0] - cx[0];
|
|
1675
2045
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1676
|
-
if (_optionalChain([part, 'optionalAccess',
|
|
2046
|
+
if (_optionalChain([part, 'optionalAccess', _195 => _195.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1677
2047
|
const last = prev.table.rows - 1;
|
|
1678
2048
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1679
|
-
const U =
|
|
1680
|
-
|
|
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 }))));
|
|
1681
2051
|
}
|
|
1682
|
-
|
|
2052
|
+
_chunkUBY2PLKRcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1683
2053
|
placeJoined(blocks, i, j, part.table);
|
|
1684
2054
|
continue;
|
|
1685
2055
|
}
|
|
@@ -1692,20 +2062,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1692
2062
|
caption: prev.table.caption,
|
|
1693
2063
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1694
2064
|
};
|
|
1695
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1696
|
-
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);
|
|
1697
2067
|
placeJoined(blocks, i, j, merged);
|
|
1698
2068
|
}
|
|
1699
2069
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1700
2070
|
const t = blocks[i].table;
|
|
1701
|
-
if (blocks[i].type === "table" && t &&
|
|
2071
|
+
if (blocks[i].type === "table" && t && _chunkUBY2PLKRcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1702
2072
|
}
|
|
1703
2073
|
}
|
|
1704
2074
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1705
2075
|
if (!pageHeights) return;
|
|
1706
2076
|
for (let i = 0; i < blocks.length; i++) {
|
|
1707
2077
|
const L = blocks[i];
|
|
1708
|
-
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;
|
|
1709
2079
|
const ph = pageHeights.get(L.pageNumber);
|
|
1710
2080
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1711
2081
|
let s0 = i, s1 = i;
|
|
@@ -1724,8 +2094,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1724
2094
|
if (Math.abs(R.bbox.width - L.bbox.width) > Math.max(R.bbox.width, L.bbox.width) * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1725
2095
|
if (!looksContinued(L, R) || restartsTable(blocks, i, R.table, pageHeights)) continue;
|
|
1726
2096
|
const rt = R.table;
|
|
1727
|
-
if (rt.rows === 1 && rt.cols === 1 && !
|
|
1728
|
-
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;
|
|
1729
2099
|
const dx = lb.x + lb.width - (R.bbox.x + R.bbox.width);
|
|
1730
2100
|
const last = L.table.cells[L.table.rows - 1];
|
|
1731
2101
|
let col = 0;
|
|
@@ -1754,12 +2124,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1754
2124
|
}
|
|
1755
2125
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1756
2126
|
const pt = prev.table, ct = curr.table;
|
|
1757
|
-
if (!
|
|
1758
|
-
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);
|
|
1759
2129
|
if (!px || !cx) return null;
|
|
1760
2130
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1761
2131
|
if (!shiftedSame(px, cx, false)) {
|
|
1762
|
-
if (!_optionalChain([pageHeights, 'optionalAccess',
|
|
2132
|
+
if (!_optionalChain([pageHeights, 'optionalAccess', _196 => _196.get, 'call', _197 => _197(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _198 => _198.get, 'call', _199 => _199(curr.pageNumber)])) return null;
|
|
1763
2133
|
dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1764
2134
|
within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1765
2135
|
if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
|
|
@@ -1771,19 +2141,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1771
2141
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1772
2142
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1773
2143
|
};
|
|
1774
|
-
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);
|
|
1775
2145
|
}
|
|
1776
|
-
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access',
|
|
2146
|
+
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _200 => _200.bbox, 'optionalAccess', _201 => _201.y]), lex);
|
|
1777
2147
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1778
|
-
|
|
1779
|
-
const ys =
|
|
1780
|
-
if (ys)
|
|
1781
|
-
|
|
1782
|
-
|
|
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);
|
|
1783
2153
|
return res.table;
|
|
1784
2154
|
}
|
|
1785
2155
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
1786
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
2156
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _202 => _202.get, 'call', _203 => _203(prev.pageNumber)]);
|
|
1787
2157
|
if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
|
|
1788
2158
|
return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
|
|
1789
2159
|
}
|
|
@@ -1794,21 +2164,21 @@ function headingRow(row) {
|
|
|
1794
2164
|
}
|
|
1795
2165
|
var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
|
|
1796
2166
|
function looksContinued(prev, curr, pageHeights) {
|
|
1797
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
2167
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _204 => _204.get, 'call', _205 => _205(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _206 => _206.get, 'call', _207 => _207(curr.pageNumber)]);
|
|
1798
2168
|
if (ph && ch && (prev.bbox.y > ph * PAGE_EDGE_BAND && !pushedLead(prev, curr) || curr.bbox.y + curr.bbox.height < ch * (1 - PAGE_EDGE_BAND))) return false;
|
|
1799
2169
|
const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
|
|
1800
|
-
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access',
|
|
2170
|
+
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _208 => _208.find, 'call', _209 => _209((c) => c.text.trim()), 'optionalAccess', _210 => _210.text]), () => ( ""));
|
|
1801
2171
|
if (!ANNEX_HEAD_RE.test(firstText)) return true;
|
|
1802
2172
|
const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
|
|
1803
2173
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1804
2174
|
}
|
|
1805
2175
|
function pushedLead(prev, curr) {
|
|
1806
|
-
if (!
|
|
2176
|
+
if (!_chunkUBY2PLKRcjs.CLIP_TABLES.has(prev.table) || !_chunkUBY2PLKRcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1807
2177
|
const lead = leadRows(curr.table);
|
|
1808
2178
|
return lead.image && lead.height > prev.bbox.y;
|
|
1809
2179
|
}
|
|
1810
2180
|
function leadRows(t) {
|
|
1811
|
-
const ys =
|
|
2181
|
+
const ys = _chunkUBY2PLKRcjs.TABLE_ROWYS.get(t);
|
|
1812
2182
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1813
2183
|
const anchors = anchorsOf(t);
|
|
1814
2184
|
let end = 1, image = false;
|
|
@@ -1816,17 +2186,17 @@ function leadRows(t) {
|
|
|
1816
2186
|
for (const a of anchors) {
|
|
1817
2187
|
if (a.r !== r) continue;
|
|
1818
2188
|
end = Math.max(end, r + a.rs);
|
|
1819
|
-
if (
|
|
2189
|
+
if (_chunkUBY2PLKRcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1820
2190
|
}
|
|
1821
2191
|
}
|
|
1822
2192
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1823
2193
|
}
|
|
1824
2194
|
function tailOf(b) {
|
|
1825
|
-
const t = b.table &&
|
|
2195
|
+
const t = b.table && _chunkUBY2PLKRcjs.TABLE_TAIL.get(b.table);
|
|
1826
2196
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1827
2197
|
}
|
|
1828
2198
|
function firstRowSig(t) {
|
|
1829
|
-
const x =
|
|
2199
|
+
const x = _chunkUBY2PLKRcjs.TABLE_COLXS.get(t);
|
|
1830
2200
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1831
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, "") }));
|
|
1832
2202
|
}
|
|
@@ -1851,9 +2221,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
|
|
|
1851
2221
|
}
|
|
1852
2222
|
function restartsTitledForm(head, curr) {
|
|
1853
2223
|
if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
|
|
1854
|
-
const full = (t) => _optionalChain([t, 'access',
|
|
2224
|
+
const full = (t) => _optionalChain([t, 'access', _211 => _211.cells, 'access', _212 => _212[0], 'access', _213 => _213[0], 'optionalAccess', _214 => _214.colSpan]) === t.cols;
|
|
1855
2225
|
if (!full(head) || !full(curr)) return false;
|
|
1856
|
-
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
2226
|
+
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _215 => _215.text]), () => ( ""))).replace(/\s+/g, "");
|
|
1857
2227
|
const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
|
|
1858
2228
|
if (!ht || !ct || ht === ct) return false;
|
|
1859
2229
|
const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
|
|
@@ -1879,7 +2249,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1879
2249
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1880
2250
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1881
2251
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1882
|
-
const px =
|
|
2252
|
+
const px = _chunkUBY2PLKRcjs.TABLE_COLXS.get(pb.table), cx = _chunkUBY2PLKRcjs.TABLE_COLXS.get(cur.table);
|
|
1883
2253
|
if (!px || !cx) break;
|
|
1884
2254
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1885
2255
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1896,7 +2266,7 @@ function continueRowSpans(prevCells, currCells) {
|
|
|
1896
2266
|
if (hasContent(cell) || (cell.rowSpan || 1) < 2) continue;
|
|
1897
2267
|
let anchor;
|
|
1898
2268
|
for (let r = last - 1; r >= 0 && !anchor; r--) {
|
|
1899
|
-
const a = _optionalChain([prevCells, 'access',
|
|
2269
|
+
const a = _optionalChain([prevCells, 'access', _216 => _216[r], 'optionalAccess', _217 => _217[c]]);
|
|
1900
2270
|
if (a && r + (a.rowSpan || 1) === last && (a.colSpan || 1) === (cell.colSpan || 1) && (hasContent(a) || a.rowSpan >= 2)) anchor = a;
|
|
1901
2271
|
}
|
|
1902
2272
|
if (!anchor) continue;
|
|
@@ -1950,12 +2320,12 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1950
2320
|
var COL_MATCH_TOL = 0.5;
|
|
1951
2321
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1952
2322
|
function lastRowCell(t, x1, x2) {
|
|
1953
|
-
const xs =
|
|
2323
|
+
const xs = _chunkUBY2PLKRcjs.TABLE_COLXS.get(t);
|
|
1954
2324
|
const covered = /* @__PURE__ */ new Set();
|
|
1955
2325
|
for (let r = 0; r < t.rows; r++) {
|
|
1956
2326
|
for (let c = 0; c < t.cols; c++) {
|
|
1957
2327
|
if (covered.has(r * 1e5 + c)) continue;
|
|
1958
|
-
const cell = _optionalChain([t, 'access',
|
|
2328
|
+
const cell = _optionalChain([t, 'access', _218 => _218.cells, 'access', _219 => _219[r], 'optionalAccess', _220 => _220[c]]);
|
|
1959
2329
|
if (!cell) continue;
|
|
1960
2330
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
|
|
1961
2331
|
if (r + cell.rowSpan !== t.rows) continue;
|
|
@@ -1968,7 +2338,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1968
2338
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1969
2339
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1970
2340
|
const part = blocks[j];
|
|
1971
|
-
const from = part.table ?
|
|
2341
|
+
const from = part.table ? _chunkUBY2PLKRcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1972
2342
|
if (!from || !part.table) {
|
|
1973
2343
|
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
1974
2344
|
continue;
|
|
@@ -1978,18 +2348,18 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1978
2348
|
const prev = blocks[i];
|
|
1979
2349
|
if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
|
|
1980
2350
|
const cell = lastRowCell(prev.table, from.x1, from.x2);
|
|
1981
|
-
const add = _optionalChain([part, 'access',
|
|
2351
|
+
const add = _optionalChain([part, 'access', _221 => _221.table, 'access', _222 => _222.cells, 'access', _223 => _223[0], 'optionalAccess', _224 => _224[0]]);
|
|
1982
2352
|
if (!cell || !add) continue;
|
|
1983
2353
|
const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
|
|
1984
2354
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1985
2355
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1986
2356
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1987
|
-
if (
|
|
1988
|
-
|
|
1989
|
-
const lines =
|
|
1990
|
-
if (_optionalChain([lines, 'optionalAccess',
|
|
1991
|
-
if (part.pageNumber && part.bbox)
|
|
1992
|
-
if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
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);
|
|
1993
2363
|
blocks.splice(j, 1);
|
|
1994
2364
|
if (cell.blocks && at > 0) {
|
|
1995
2365
|
const nextAt = cell.blocks[at];
|
|
@@ -2001,29 +2371,29 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
2001
2371
|
}
|
|
2002
2372
|
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
2003
2373
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
2004
|
-
if (!_optionalChain([prev, 'optionalAccess',
|
|
2005
|
-
const inner = _optionalChain([frame, 'access',
|
|
2006
|
-
const next = _optionalChain([inner, 'optionalAccess',
|
|
2007
|
-
if (!inner || !_optionalChain([next, 'optionalAccess',
|
|
2008
|
-
const px =
|
|
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;
|
|
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]);
|
|
2376
|
+
const next = _optionalChain([inner, 'optionalAccess', _235 => _235[0]]);
|
|
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);
|
|
2009
2379
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
2010
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
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)]);
|
|
2011
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;
|
|
2012
|
-
if (splitOnly && (inner.length !== 1 || !_optionalChain([joinSplitParts, 'call',
|
|
2382
|
+
if (splitOnly && (inner.length !== 1 || !_optionalChain([joinSplitParts, 'call', _241 => _241(prev.table, px, next.table, nx, 0, prev.bbox.y), 'optionalAccess', _242 => _242.split]))) return;
|
|
2013
2383
|
blocks.splice(at, 1, ...inner);
|
|
2014
2384
|
}
|
|
2015
2385
|
function fillNestedContinuation(blocks, at) {
|
|
2016
2386
|
const prev = blocks[at - 1], next = blocks[at];
|
|
2017
|
-
const t = _optionalChain([prev, 'optionalAccess',
|
|
2018
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
2019
|
-
const xs =
|
|
2387
|
+
const t = _optionalChain([prev, 'optionalAccess', _243 => _243.table]), u = _optionalChain([next, 'optionalAccess', _244 => _244.table]);
|
|
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);
|
|
2020
2390
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
2021
|
-
const add = _optionalChain([u, 'access',
|
|
2022
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access',
|
|
2391
|
+
const add = _optionalChain([u, 'access', _245 => _245.cells, 'access', _246 => _246[0], 'optionalAccess', _247 => _247[0]]);
|
|
2392
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _248 => _248.blocks, 'optionalAccess', _249 => _249.length]) || _chunkUBY2PLKRcjs.IMAGE_CELLS.has(cell)) return;
|
|
2023
2393
|
cell.text = add.text;
|
|
2024
2394
|
if (add.blocks) cell.blocks = add.blocks;
|
|
2025
|
-
if (
|
|
2026
|
-
|
|
2395
|
+
if (_chunkUBY2PLKRcjs.IMAGE_CELLS.has(add)) _chunkUBY2PLKRcjs.IMAGE_CELLS.add(cell);
|
|
2396
|
+
_chunkUBY2PLKRcjs.joinCellEdges.call(void 0, cell, add);
|
|
2027
2397
|
blocks.splice(at, 1);
|
|
2028
2398
|
}
|
|
2029
2399
|
|
|
@@ -2433,7 +2803,7 @@ var KNOWN = {
|
|
|
2433
2803
|
// │
|
|
2434
2804
|
};
|
|
2435
2805
|
function knownFontPua(name, outline, width) {
|
|
2436
|
-
const face = FACES[_nullishCoalesce(_optionalChain([name, 'optionalAccess',
|
|
2806
|
+
const face = FACES[_nullishCoalesce(_optionalChain([name, 'optionalAccess', _250 => _250.replace, 'call', _251 => _251(/^[A-Z]{6}\+/, "")]), () => ( ""))];
|
|
2437
2807
|
if (!face) return null;
|
|
2438
2808
|
const hit = KNOWN[_crypto.createHash.call(void 0, "sha256").update(JSON.stringify([outline.upm, width, outline.contours])).digest("hex").slice(0, 16)];
|
|
2439
2809
|
return hit && hit[1] & face ? hit[0] : null;
|
|
@@ -2607,10 +2977,10 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
2607
2977
|
if (!cache.has(key)) {
|
|
2608
2978
|
let sym = null;
|
|
2609
2979
|
try {
|
|
2610
|
-
const source = fontObj(font), data = _optionalChain([source, 'optionalAccess',
|
|
2980
|
+
const source = fontObj(font), data = _optionalChain([source, 'optionalAccess', _252 => _252.data]);
|
|
2611
2981
|
const code = glyph.fontChar.codePointAt(0);
|
|
2612
2982
|
const outline = data && code !== void 0 ? readOutline(data, code) : null;
|
|
2613
|
-
const pua = outline ? knownFontPua(_optionalChain([source, 'optionalAccess',
|
|
2983
|
+
const pua = outline ? knownFontPua(_optionalChain([source, 'optionalAccess', _253 => _253.name]), outline, glyph.width) : null;
|
|
2614
2984
|
if (outline) sym = pua !== null ? String.fromCodePoint(pua) : classifyOutline(outline);
|
|
2615
2985
|
} catch (e3) {
|
|
2616
2986
|
}
|
|
@@ -2623,12 +2993,12 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
2623
2993
|
}
|
|
2624
2994
|
}
|
|
2625
2995
|
for (const q of queues.values()) for (let k = 0; k < q.length; k++) {
|
|
2626
|
-
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;
|
|
2627
2997
|
if (pair !== void 0) {
|
|
2628
2998
|
q[k] = pair;
|
|
2629
2999
|
q[k + 1] = "";
|
|
2630
3000
|
k++;
|
|
2631
|
-
} else q[k] =
|
|
3001
|
+
} else q[k] = _chunkTQOAPKLUcjs.mapPuaText.call(void 0, q[k]);
|
|
2632
3002
|
}
|
|
2633
3003
|
const byFont = /* @__PURE__ */ new Map();
|
|
2634
3004
|
for (const it of items) {
|
|
@@ -2640,7 +3010,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
2640
3010
|
}
|
|
2641
3011
|
for (const [f, list] of byFont) {
|
|
2642
3012
|
const q = queues.get(f);
|
|
2643
|
-
const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access',
|
|
3013
|
+
const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access', _254 => _254.str, 'access', _255 => _255.match, 'call', _256 => _256(//g), 'optionalAccess', _257 => _257.length]), () => ( 0))), 0);
|
|
2644
3014
|
if (!q || q.length !== want) continue;
|
|
2645
3015
|
let k = 0;
|
|
2646
3016
|
for (const it of list) it.str = it.str.replace(//g, () => q[k++]);
|
|
@@ -2682,7 +3052,7 @@ function spaceMappedDots(fnArray, argsArray, fontObj) {
|
|
|
2682
3052
|
if (!cache.has(key)) {
|
|
2683
3053
|
let dot = false;
|
|
2684
3054
|
try {
|
|
2685
|
-
const data = _optionalChain([fontObj, 'call',
|
|
3055
|
+
const data = _optionalChain([fontObj, 'call', _258 => _258(font), 'optionalAccess', _259 => _259.data]);
|
|
2686
3056
|
const ol = data ? readOutline(data, code) : null;
|
|
2687
3057
|
if (ol && ol.contours.length === 1 && ol.contours[0].length === 4 && ol.contours[0].every((p) => p[2])) {
|
|
2688
3058
|
const b = boxOf(ol.contours[0]), u = ol.upm;
|
|
@@ -2718,15 +3088,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
2718
3088
|
function marginContextBlocks(raw, page, view) {
|
|
2719
3089
|
const [x1, y1, x2, y2] = view;
|
|
2720
3090
|
const width = x2 - x1, height = y2 - y1;
|
|
2721
|
-
const items =
|
|
3091
|
+
const items = _chunkUBY2PLKRcjs.filterHiddenText.call(void 0, _chunkUBY2PLKRcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
2722
3092
|
for (const item of items) {
|
|
2723
3093
|
item.x -= x1;
|
|
2724
3094
|
item.y -= y1;
|
|
2725
3095
|
}
|
|
2726
|
-
return
|
|
2727
|
-
const bbox =
|
|
3096
|
+
return _chunkUBY2PLKRcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
3097
|
+
const bbox = _chunkUBY2PLKRcjs.computeBBox.call(void 0, line, page);
|
|
2728
3098
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
2729
|
-
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) }];
|
|
2730
3100
|
});
|
|
2731
3101
|
}
|
|
2732
3102
|
|
|
@@ -2762,7 +3132,7 @@ var WINANSI_REVERSE = {
|
|
|
2762
3132
|
};
|
|
2763
3133
|
function symbolFontTable(fontName) {
|
|
2764
3134
|
if (!fontName) return void 0;
|
|
2765
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
3135
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkTQOAPKLUcjs.WINGDINGS;
|
|
2766
3136
|
return void 0;
|
|
2767
3137
|
}
|
|
2768
3138
|
function remapSymbolText(text, table) {
|
|
@@ -2890,7 +3260,7 @@ function layout(toks) {
|
|
|
2890
3260
|
const bar = rest.find((t) => t.bar && t.x >= rt.x && t.x <= rt.x + rt.w + 2 && Math.abs(t.y - rt.y) <= size * 1.5);
|
|
2891
3261
|
if (!bar) continue;
|
|
2892
3262
|
const inner = rest.filter((t) => !t.bar && t !== rt && t.x + t.w / 2 > bar.x && t.x + t.w / 2 < bar.x + bar.w && bar.y - t.y > 0 && bar.y - t.y <= size * 1.4);
|
|
2893
|
-
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access',
|
|
3263
|
+
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _260 => _260[0], 'optionalAccess', _261 => _261.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
|
|
2894
3264
|
rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
|
|
2895
3265
|
}
|
|
2896
3266
|
const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
|
|
@@ -2995,7 +3365,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
2995
3365
|
for (const i of members) drop.add(i);
|
|
2996
3366
|
const toks = cur.map((it) => {
|
|
2997
3367
|
const bar2 = isBarItem(it);
|
|
2998
|
-
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("");
|
|
2999
3369
|
return { text, x: it.x, y: it.y, w: it.w, size: sizeOf(it), bar: bar2 };
|
|
3000
3370
|
});
|
|
3001
3371
|
const tex = layout(toks).replace(/\}\\text\{/g, "");
|
|
@@ -3006,7 +3376,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
3006
3376
|
for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
|
|
3007
3377
|
const top = [...ys].sort((p, q) => q[1] - p[1]);
|
|
3008
3378
|
const bar = cur.find(isBarItem);
|
|
3009
|
-
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access',
|
|
3379
|
+
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _262 => _262[0], 'optionalAccess', _263 => _263[0]]), () => ( cur[0].y));
|
|
3010
3380
|
const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
|
|
3011
3381
|
const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
|
|
3012
3382
|
added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
|
|
@@ -3235,7 +3605,7 @@ function restoreUnmappedCidSpaces(items, fnArray, argsArray, fontOf) {
|
|
|
3235
3605
|
const mapOf = (font2) => {
|
|
3236
3606
|
if (!maps.has(font2)) {
|
|
3237
3607
|
const f = fontOf(font2);
|
|
3238
|
-
const m = _optionalChain([f, 'optionalAccess',
|
|
3608
|
+
const m = _optionalChain([f, 'optionalAccess', _264 => _264.composite]) ? _optionalChain([f, 'access', _265 => _265.toUnicode, 'optionalAccess', _266 => _266._map]) : void 0;
|
|
3239
3609
|
maps.set(font2, m && m.length > 0 ? m : null);
|
|
3240
3610
|
}
|
|
3241
3611
|
return maps.get(font2);
|
|
@@ -3430,7 +3800,7 @@ function joinVerticalColumns(items) {
|
|
|
3430
3800
|
const groups = [];
|
|
3431
3801
|
for (const col of columns) {
|
|
3432
3802
|
const g2 = groups[groups.length - 1];
|
|
3433
|
-
const last = _optionalChain([g2, 'optionalAccess',
|
|
3803
|
+
const last = _optionalChain([g2, 'optionalAccess', _267 => _267[g2.length - 1]]);
|
|
3434
3804
|
const fs = col.items[0].fontSize;
|
|
3435
3805
|
if (last && last.x - col.x >= fs * 1.2 && last.x - col.x <= fs * 4 && Math.abs(last.items[0].y - col.items[0].y) <= fs * 1.2) g2.push(col);
|
|
3436
3806
|
else groups.push([col]);
|
|
@@ -3674,7 +4044,7 @@ function softHyphenHeads(items, fnArray, argsArray) {
|
|
|
3674
4044
|
gi++;
|
|
3675
4045
|
}
|
|
3676
4046
|
if (soft >= 0) {
|
|
3677
|
-
const before = _nullishCoalesce(_optionalChain([glyphs, 'access',
|
|
4047
|
+
const before = _nullishCoalesce(_optionalChain([glyphs, 'access', _268 => _268[soft - 1], 'optionalAccess', _269 => _269.u]), () => ( ""));
|
|
3678
4048
|
const wrapped = !!prev && Math.abs(prev.transform[5] - it.transform[5]) >= 3 && /\p{Script=Latin}$/u.test(before) && /^\p{Ll}/u.test(it.str.trimStart());
|
|
3679
4049
|
if (!wrapped) heads.push([it, spaced2 || !/^[\d.,]+%?(?:\s|$)/.test(it.str.trimStart()) ? "- " : "-"]);
|
|
3680
4050
|
}
|
|
@@ -3735,7 +4105,7 @@ function relocateEndnotes(blocks) {
|
|
|
3735
4105
|
}
|
|
3736
4106
|
const shapes = /* @__PURE__ */ new Map();
|
|
3737
4107
|
for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
|
|
3738
|
-
const main = _optionalChain([[...shapes], 'access',
|
|
4108
|
+
const main = _optionalChain([[...shapes], 'access', _270 => _270.sort, 'call', _271 => _271((a, b) => b[1] - a[1]), 'access', _272 => _272[0], 'optionalAccess', _273 => _273[0]]);
|
|
3739
4109
|
if (!main || !/#/.test(main)) return blocks;
|
|
3740
4110
|
const lastRun = (hs) => {
|
|
3741
4111
|
let run2 = [];
|
|
@@ -3798,7 +4168,7 @@ function dropTabLeaderDots(items) {
|
|
|
3798
4168
|
let run = [];
|
|
3799
4169
|
const flush = () => {
|
|
3800
4170
|
const last = run[run.length - 1];
|
|
3801
|
-
const tailPage = _optionalChain([DOTS_PAGE, 'access',
|
|
4171
|
+
const tailPage = _optionalChain([DOTS_PAGE, 'access', _274 => _274.exec, 'call', _275 => _275(last.text.trim()), 'optionalAccess', _276 => _276[1]]);
|
|
3802
4172
|
const dots = run.reduce((n, d) => n + d.text.trim().replace(/\d+$/, "").length, 0);
|
|
3803
4173
|
if (dots >= MIN_DOTS && (tailPage ? run.length > 1 : pageNoAfter(last.x + last.w, last))) {
|
|
3804
4174
|
const body = tailPage ? run.slice(0, -1) : run;
|
|
@@ -3835,7 +4205,7 @@ function mergeEnclosedDigits(items) {
|
|
|
3835
4205
|
if (!/^\d\d?$/.test(digits)) continue;
|
|
3836
4206
|
const mid = (inside2[0].x + inside2[inside2.length - 1].x + inside2[inside2.length - 1].w) / 2;
|
|
3837
4207
|
if (Math.abs(mid - (s.x + s.w / 2)) > s.fontSize * 0.15) continue;
|
|
3838
|
-
s.text =
|
|
4208
|
+
s.text = _chunkTQOAPKLUcjs.enclosedNumber.call(void 0, Number(digits));
|
|
3839
4209
|
for (const d of inside2) drop.add(d);
|
|
3840
4210
|
}
|
|
3841
4211
|
if (!drop.size) return;
|
|
@@ -3921,7 +4291,7 @@ function inlineFootnotes(blocks, pages) {
|
|
|
3921
4291
|
open = true;
|
|
3922
4292
|
continue;
|
|
3923
4293
|
}
|
|
3924
|
-
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access',
|
|
4294
|
+
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _277 => _277.style, 'optionalAccess', _278 => _278.fontSize]), () => ( _optionalChain([b, 'access', _279 => _279.bbox, 'optionalAccess', _280 => _280.height]))), () => ( 10))) * 1.5;
|
|
3925
4295
|
if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
|
|
3926
4296
|
notes[notes.length - 1].text += " " + b.text.trim();
|
|
3927
4297
|
notes[notes.length - 1].blocks.push(b);
|
|
@@ -3944,7 +4314,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
|
|
|
3944
4314
|
var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
|
|
3945
4315
|
var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
|
|
3946
4316
|
function isRunningHead(block, page, pageHeight) {
|
|
3947
|
-
const box = block.bbox, text = _optionalChain([block, 'access',
|
|
4317
|
+
const box = block.bbox, text = _optionalChain([block, 'access', _281 => _281.text, 'optionalAccess', _282 => _282.trim, 'call', _283 => _283()]);
|
|
3948
4318
|
if (!box || !text || !pageHeight) return false;
|
|
3949
4319
|
const top = box.y + box.height >= pageHeight * 0.9;
|
|
3950
4320
|
const bottom = box.y <= pageHeight * 0.1;
|
|
@@ -3952,7 +4322,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
3952
4322
|
const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
|
|
3953
4323
|
if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
|
|
3954
4324
|
if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
|
|
3955
|
-
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access',
|
|
4325
|
+
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _284 => _284.style, 'optionalAccess', _285 => _285.fontSize]), () => ( 0))) * 1.6) return true;
|
|
3956
4326
|
if (!text.includes(" ")) return false;
|
|
3957
4327
|
const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
|
|
3958
4328
|
if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
|
|
@@ -3961,7 +4331,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
3961
4331
|
return right > left && box.width >= (right - left) * 0.6;
|
|
3962
4332
|
}
|
|
3963
4333
|
function unbalancedClose(text) {
|
|
3964
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
4334
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _286 => _286.match, 'call', _287 => _287(/\)/g), 'optionalAccess', _288 => _288.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _289 => _289.match, 'call', _290 => _290(/\(/g), 'optionalAccess', _291 => _291.length]), () => ( 0)));
|
|
3965
4335
|
}
|
|
3966
4336
|
function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
3967
4337
|
const byPage = /* @__PURE__ */ new Map();
|
|
@@ -3977,7 +4347,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3977
4347
|
const sizes = /* @__PURE__ */ new Map();
|
|
3978
4348
|
let proseChars = 0;
|
|
3979
4349
|
for (const b of page) {
|
|
3980
|
-
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access',
|
|
4350
|
+
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _292 => _292.style, 'optionalAccess', _293 => _293.fontName]) || !b.style.fontSize) continue;
|
|
3981
4351
|
const key2 = `${b.style.fontName}:${b.style.fontSize}`;
|
|
3982
4352
|
chars.set(key2, (_nullishCoalesce(chars.get(key2), () => ( 0))) + b.text.length);
|
|
3983
4353
|
if (b.type === "paragraph" && b.style.fontName === "ocr") {
|
|
@@ -4001,13 +4371,13 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
4001
4371
|
const citedProse = /* @__PURE__ */ new Set();
|
|
4002
4372
|
const numberedProse = /* @__PURE__ */ new Set();
|
|
4003
4373
|
for (const page of byPage.values()) {
|
|
4004
|
-
const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
4374
|
+
const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access', _294 => _294.text, 'optionalAccess', _295 => _295.trim, 'call', _296 => _296()]), () => ( ""))) && b.bbox && _optionalChain([b, 'access', _297 => _297.style, 'optionalAccess', _298 => _298.fontName]) && b.style.fontSize && !/Bold|Black|Heavy|Semibold/i.test(_nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _299 => _299.get, 'call', _300 => _300(b.style.fontName)]), () => ( ""))));
|
|
4005
4375
|
let chain = [];
|
|
4006
4376
|
const finish = () => {
|
|
4007
|
-
if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access',
|
|
4377
|
+
if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access', _301 => _301.text, 'optionalAccess', _302 => _302.length]), () => ( 0))) >= 40 && b.bbox.height >= b.style.fontSize * 2.4)) return;
|
|
4008
4378
|
for (const b of chain) numberedProse.add(b);
|
|
4009
4379
|
const first = chain[0], size = first.style.fontSize;
|
|
4010
|
-
for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
4380
|
+
for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access', _303 => _303.text, 'optionalAccess', _304 => _304.trim, 'call', _305 => _305()]), () => ( ""))) && _optionalChain([b, 'access', _306 => _306.style, 'optionalAccess', _307 => _307.fontName]) === _optionalChain([first, 'access', _308 => _308.style, 'optionalAccess', _309 => _309.fontName]) && _optionalChain([b, 'access', _310 => _310.style, 'optionalAccess', _311 => _311.fontSize]) === size && b.bbox && Math.abs(b.bbox.x - first.bbox.x) <= size * 0.5 && (_nullishCoalesce(_optionalChain([b, 'access', _312 => _312.text, 'optionalAccess', _313 => _313.length]), () => ( 0))) >= 15) numberedProse.add(b);
|
|
4011
4381
|
};
|
|
4012
4382
|
for (const b of numbered) {
|
|
4013
4383
|
const prev = chain.at(-1), size = b.style.fontSize;
|
|
@@ -4021,9 +4391,9 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
4021
4391
|
}
|
|
4022
4392
|
for (let i = 0; i + 1 < blocks.length; i++) {
|
|
4023
4393
|
const prose = blocks[i], reference = blocks[i + 1];
|
|
4024
|
-
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access',
|
|
4025
|
-
const source = _nullishCoalesce(_optionalChain([reference, 'access',
|
|
4026
|
-
if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access',
|
|
4394
|
+
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _314 => _314.style, 'optionalAccess', _315 => _315.fontSize]), () => ( 0));
|
|
4395
|
+
const source = _nullishCoalesce(_optionalChain([reference, 'access', _316 => _316.text, 'optionalAccess', _317 => _317.replace, 'call', _318 => _318(/<[^>]+>/g, ""), 'access', _319 => _319.trim, 'call', _320 => _320()]), () => ( ""));
|
|
4396
|
+
if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access', _321 => _321.text, 'optionalAccess', _322 => _322.length]), () => ( 0))) < 40 || !a || !b || size <= 0 || a.height < size * 2.4 || prose.pageNumber !== reference.pageNumber || _optionalChain([prose, 'access', _323 => _323.style, 'optionalAccess', _324 => _324.fontName]) !== _optionalChain([reference, 'access', _325 => _325.style, 'optionalAccess', _326 => _326.fontName]) || _optionalChain([prose, 'access', _327 => _327.style, 'optionalAccess', _328 => _328.fontSize]) !== _optionalChain([reference, 'access', _329 => _329.style, 'optionalAccess', _330 => _330.fontSize]) || Math.abs(a.x - b.x) > size && !(/^[○●•◦]\s/.test(_nullishCoalesce(prose.text, () => ( ""))) && b.x >= a.x && b.x - a.x <= size * 2) || a.y - (b.y + b.height) < 0 || a.y - (b.y + b.height) > size || !/^[((].*(?:제\s*\d+\s*조|(?:Article|Section)\s+\d+).*[))]$/i.test(source)) continue;
|
|
4027
4397
|
citedProse.add(prose);
|
|
4028
4398
|
citedProse.add(reference);
|
|
4029
4399
|
}
|
|
@@ -4031,49 +4401,49 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
4031
4401
|
const block = blocks[i];
|
|
4032
4402
|
if (block.type !== "heading" || !block.text) continue;
|
|
4033
4403
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
4034
|
-
const fsz = _nullishCoalesce(_optionalChain([block, 'access',
|
|
4035
|
-
const tocEntry = i > 0 &&
|
|
4404
|
+
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _331 => _331.style, 'optionalAccess', _332 => _332.fontSize]), () => ( 0));
|
|
4405
|
+
const tocEntry = i > 0 && _chunkUBY2PLKRcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkUBY2PLKRcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
4036
4406
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
4037
|
-
const proseStyle = _optionalChain([block, 'access',
|
|
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;
|
|
4038
4408
|
const next = blocks[i + 1];
|
|
4039
|
-
const nb = _optionalChain([next, 'optionalAccess',
|
|
4040
|
-
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
4041
|
-
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess',
|
|
4409
|
+
const nb = _optionalChain([next, 'optionalAccess', _335 => _335.bbox]), bb = block.bbox;
|
|
4410
|
+
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _336 => _336.style, 'optionalAccess', _337 => _337.fontSize]), () => ( 0))) * 1.2 && Math.abs(bb.x - nb.x) > fsz && Math.abs(bb.x + bb.width / 2 - (nb.x + nb.width / 2)) < nb.width * 0.1;
|
|
4411
|
+
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _338 => _338.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
|
|
4042
4412
|
next.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
4043
4413
|
blocks.splice(i--, 1);
|
|
4044
4414
|
continue;
|
|
4045
4415
|
}
|
|
4046
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
4416
|
+
if ((_optionalChain([next, 'optionalAccess', _339 => _339.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _340 => _340.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _341 => _341.style, 'optionalAccess', _342 => _342.fontName]) === _optionalChain([block, 'access', _343 => _343.style, 'optionalAccess', _344 => _344.fontName]) && _optionalChain([next, 'access', _345 => _345.style, 'optionalAccess', _346 => _346.fontSize]) === _optionalChain([block, 'access', _347 => _347.style, 'optionalAccess', _348 => _348.fontSize]) && fsz > 0 && /^[a-z]/.test(next.text.trim()) && next.text.trim().length <= 40 && !/[.:;!?]$/.test(next.text.trim()) && block.bbox.y - (next.bbox.y + next.bbox.height) < fsz * 1.2 && Math.abs(next.bbox.x - block.bbox.x) < fsz) {
|
|
4047
4417
|
block.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
4048
4418
|
block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
|
|
4049
4419
|
blocks.splice(i + 1, 1);
|
|
4050
4420
|
}
|
|
4051
4421
|
const after = blocks[i + 2];
|
|
4052
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
4422
|
+
if ((_optionalChain([next, 'optionalAccess', _349 => _349.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _350 => _350.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _351 => _351.text, 'optionalAccess', _352 => _352.trim, 'call', _353 => _353()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _354 => _354.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _355 => _355.style, 'optionalAccess', _356 => _356.fontSize]) === _optionalChain([block, 'access', _357 => _357.style, 'optionalAccess', _358 => _358.fontSize])) {
|
|
4053
4423
|
block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
|
|
4054
4424
|
blocks.splice(i + 1, 2);
|
|
4055
4425
|
}
|
|
4056
4426
|
const tiny = fsz > 0 && fsz < 7.5;
|
|
4057
4427
|
const prev = blocks[i - 1];
|
|
4058
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
4428
|
+
if (_optionalChain([prev, 'optionalAccess', _359 => _359.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _360 => _360.text, 'optionalAccess', _361 => _361.trim, 'call', _362 => _362()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
|
|
4059
4429
|
prev.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
4060
4430
|
prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
|
|
4061
4431
|
blocks.splice(i--, 1);
|
|
4062
4432
|
continue;
|
|
4063
4433
|
}
|
|
4064
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
4434
|
+
if (_optionalChain([prev, 'optionalAccess', _363 => _363.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _364 => _364.text, 'optionalAccess', _365 => _365.trim, 'call', _366 => _366()]), () => ( ""))) && prev.bbox && block.bbox && fsz > 0 && (Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x && block.bbox.x - (prev.bbox.x + prev.bbox.width) < fsz * 3 || Math.abs(prev.bbox.x - block.bbox.x) < 2 && (_nullishCoalesce(_optionalChain([prev, 'access', _367 => _367.style, 'optionalAccess', _368 => _368.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
|
|
4065
4435
|
block.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
4066
4436
|
blocks.splice(i - 1, 1);
|
|
4067
4437
|
i -= 2;
|
|
4068
4438
|
continue;
|
|
4069
4439
|
}
|
|
4070
|
-
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
4071
|
-
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess',
|
|
4072
|
-
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess',
|
|
4440
|
+
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _369 => _369.style, 'optionalAccess', _370 => _370.fontSize]), () => ( 0));
|
|
4441
|
+
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _371 => _371.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _372 => _372.style, 'optionalAccess', _373 => _373.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _374 => _374.style, 'optionalAccess', _375 => _375.fontSize]), () => ( 0))) >= size * 1.3 && box.y - (next.bbox.y + next.bbox.height) <= size * 3 && Math.min(box.x + box.width, next.bbox.x + next.bbox.width) - Math.max(box.x, next.bbox.x) >= Math.min(box.width, next.bbox.width) * 0.5 && !page.some((o) => o !== block && o.bbox && o.bbox.y > box.y + box.height && o.type !== "image");
|
|
4442
|
+
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _376 => _376.get, 'call', _377 => _377(_nullishCoalesce(_optionalChain([block, 'access', _378 => _378.style, 'optionalAccess', _379 => _379.fontName]), () => ( "")))]), () => ( ""));
|
|
4073
4443
|
const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
|
|
4074
|
-
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access',
|
|
4075
|
-
const ocrFragment = _optionalChain([block, 'access',
|
|
4076
|
-
const crowdedOcr = _optionalChain([block, 'access',
|
|
4444
|
+
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _380 => _380[i - 1], 'optionalAccess', _381 => _381.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
|
|
4445
|
+
const ocrFragment = _optionalChain([block, 'access', _382 => _382.style, 'optionalAccess', _383 => _383.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _384 => _384.match, 'call', _385 => _385(/\p{L}/gu), 'optionalAccess', _386 => _386.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
|
|
4446
|
+
const crowdedOcr = _optionalChain([block, 'access', _387 => _387.style, 'optionalAccess', _388 => _388.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _389 => _389.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _390 => _390.style, 'optionalAccess', _391 => _391.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _392 => _392.text, 'optionalAccess', _393 => _393.length]), () => ( 0))) >= 15 && Math.abs(o.bbox.x - box.x) <= size * 0.25 && Math.min(o.bbox.y + o.bbox.height, box.y + box.height) - Math.max(o.bbox.y, box.y) >= o.bbox.height * 0.2) && prev.bbox.y > box.y && next.bbox.y < box.y;
|
|
4077
4447
|
if (numberedProse.has(block) || citedProse.has(block) || ocrFragment || crowdedOcr || tocEntry || proseStyle || kicker || byline || tiny || !/\p{L}/u.test(text) && !chapterNumber || /^[a-z]/.test(text) || CAPTION.test(text) || EQUATION_NUMBER.test(block.text) || DISPLAY_MATH.test(text) || // 닫는 괄호가 여는 괄호보다 많으면 앞 줄에서 이어진 문장 조각이다 ("Fact-checking) and is used …") — "1)"·"가)" 앞머리 번호는 빼고 센다
|
|
4078
4448
|
unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
|
|
4079
4449
|
block.type = "paragraph";
|
|
@@ -4123,34 +4493,34 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
|
|
|
4123
4493
|
function captionTableText(t) {
|
|
4124
4494
|
if (!t || t.rows !== 1 || t.cols !== 2) return null;
|
|
4125
4495
|
const [label, body] = t.cells[0];
|
|
4126
|
-
if (!label || !body || _optionalChain([label, 'access',
|
|
4496
|
+
if (!label || !body || _optionalChain([label, 'access', _394 => _394.blocks, 'optionalAccess', _395 => _395.length]) || _optionalChain([body, 'access', _396 => _396.blocks, 'optionalAccess', _397 => _397.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
|
|
4127
4497
|
return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
|
|
4128
4498
|
}
|
|
4129
4499
|
function splitSingleCellTables(blocks) {
|
|
4130
4500
|
const out = [];
|
|
4131
4501
|
for (const b of blocks) {
|
|
4132
4502
|
const t = b.type === "table" ? b.table : void 0;
|
|
4133
|
-
const title = t &&
|
|
4503
|
+
const title = t && _chunkUBY2PLKRcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
4134
4504
|
if (title) {
|
|
4135
4505
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
4136
4506
|
continue;
|
|
4137
4507
|
}
|
|
4138
|
-
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access',
|
|
4508
|
+
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _398 => _398.cells, 'access', _399 => _399[0], 'optionalAccess', _400 => _400[0], 'optionalAccess', _401 => _401.blocks, 'optionalAccess', _402 => _402.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
|
|
4139
4509
|
const squash = (s) => s.replace(/\s/g, "");
|
|
4140
4510
|
const inner = only && (!squash(t.cells[0][0].text) || only.type === "table" && squash(t.cells[0][0].text) === squash(only.table.cells.flat().map((c) => c.text).join(""))) ? only : void 0;
|
|
4141
|
-
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess',
|
|
4511
|
+
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _403 => _403.type]) === "table" ? captionTableText(inner.table) : null)));
|
|
4142
4512
|
if (caption) {
|
|
4143
4513
|
out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
|
|
4144
4514
|
continue;
|
|
4145
4515
|
}
|
|
4146
|
-
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access',
|
|
4516
|
+
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _404 => _404.cells, 'access', _405 => _405[0], 'optionalAccess', _406 => _406[0]]) : void 0;
|
|
4147
4517
|
if (!cell) {
|
|
4148
4518
|
out.push(b);
|
|
4149
4519
|
continue;
|
|
4150
4520
|
}
|
|
4151
4521
|
const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
|
|
4152
|
-
if (_optionalChain([t, 'optionalAccess',
|
|
4153
|
-
if (_optionalChain([cell, 'access',
|
|
4522
|
+
if (_optionalChain([t, 'optionalAccess', _407 => _407.caption, 'optionalAccess', _408 => _408.trim, 'call', _409 => _409()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
|
|
4523
|
+
if (_optionalChain([cell, 'access', _410 => _410.blocks, 'optionalAccess', _411 => _411.length])) {
|
|
4154
4524
|
out.push(...splitSingleCellTables(cell.blocks));
|
|
4155
4525
|
continue;
|
|
4156
4526
|
}
|
|
@@ -4166,7 +4536,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
4166
4536
|
const lines = cell.text.split("\n");
|
|
4167
4537
|
const out = [lines[0]];
|
|
4168
4538
|
for (const line of lines.slice(1)) {
|
|
4169
|
-
if (
|
|
4539
|
+
if (_chunkUBY2PLKRcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
4170
4540
|
else out.push(line);
|
|
4171
4541
|
}
|
|
4172
4542
|
cell.text = out.join("\n");
|
|
@@ -4177,19 +4547,19 @@ function joinLatinCellWraps(blocks) {
|
|
|
4177
4547
|
}
|
|
4178
4548
|
function cleanPdfText(text, opts) {
|
|
4179
4549
|
let clean = normalizeAraea(stripControlChars(text));
|
|
4180
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
4550
|
+
if (!_optionalChain([opts, 'optionalAccess', _412 => _412.keepLoneNumbers])) {
|
|
4181
4551
|
clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
|
|
4182
4552
|
}
|
|
4183
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
4553
|
+
if (!_optionalChain([opts, 'optionalAccess', _413 => _413.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
|
|
4184
4554
|
return mergeKoreanLines(
|
|
4185
4555
|
clean.replace(/^[\s]*[-–—]\s*[-–—]?\d+[-–—]?[\s]*[-–—]?[\s]*$/gm, "").replace(/^\s*\d+\s*\/\s*\d+\s*$/gm, "").replace(/\.(?: \.){3,}/g, (m) => ".".repeat(m.length + 1 >> 1))
|
|
4186
4556
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
4187
4557
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
4188
4558
|
if (line.startsWith("|")) {
|
|
4189
|
-
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>"));
|
|
4190
4560
|
}
|
|
4191
|
-
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access',
|
|
4192
|
-
return mark +
|
|
4561
|
+
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _414 => _414.exec, 'call', _415 => _415(line), 'optionalAccess', _416 => _416[0]]), () => ( ""));
|
|
4562
|
+
return mark + _chunkUBY2PLKRcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
4193
4563
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
4194
4564
|
}
|
|
4195
4565
|
function startsWithMarker(line) {
|
|
@@ -4221,7 +4591,7 @@ function mergeKoreanLines(text) {
|
|
|
4221
4591
|
continue;
|
|
4222
4592
|
}
|
|
4223
4593
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
4224
|
-
result[result.length - 1] = prev +
|
|
4594
|
+
result[result.length - 1] = prev + _chunkUBY2PLKRcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
4225
4595
|
} else {
|
|
4226
4596
|
result.push(curr);
|
|
4227
4597
|
}
|
|
@@ -4237,7 +4607,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
4237
4607
|
const wrapped = /* @__PURE__ */ new Set();
|
|
4238
4608
|
for (const a of annots) {
|
|
4239
4609
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
4240
|
-
const url =
|
|
4610
|
+
const url = _chunkPW7MQZI4cjs.sanitizeHref.call(void 0, a.url);
|
|
4241
4611
|
if (!url) continue;
|
|
4242
4612
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
4243
4613
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -4289,7 +4659,7 @@ function mergeLinkRuns(markdown) {
|
|
|
4289
4659
|
|
|
4290
4660
|
// src/pdf/formula-ocr.ts
|
|
4291
4661
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
4292
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
4662
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-QJEOIVKR.cjs")));
|
|
4293
4663
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
4294
4664
|
await ensureFormulaModels((p) => {
|
|
4295
4665
|
if (p.phase === "download" && p.total) {
|
|
@@ -4470,23 +4840,23 @@ var PDFJS_DOCUMENT_OPTIONS = {
|
|
|
4470
4840
|
// 오류만 — 경고("Warning: Indexing all PDF objects")를 console.log 로 stdout 에 찍어 MCP·CLI JSON 을 깼다
|
|
4471
4841
|
...pdfjsAssets
|
|
4472
4842
|
};
|
|
4473
|
-
async function loadPdfWithTimeout(buffer) {
|
|
4843
|
+
async function loadPdfWithTimeout(buffer, data) {
|
|
4474
4844
|
const loadingTask = _pdfmjs.getDocument.call(void 0, {
|
|
4475
4845
|
// pdfjs transfers its input to the worker; retain the caller's buffer for reuse.
|
|
4476
|
-
data: new Uint8Array(buffer.slice(0)),
|
|
4846
|
+
data: _nullishCoalesce(data, () => ( new Uint8Array(buffer.slice(0)))),
|
|
4477
4847
|
...PDFJS_DOCUMENT_OPTIONS
|
|
4478
4848
|
});
|
|
4479
4849
|
let timer;
|
|
4480
4850
|
try {
|
|
4481
4851
|
return await Promise.race([
|
|
4482
4852
|
loadingTask.promise.catch((e) => {
|
|
4483
|
-
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)");
|
|
4484
4854
|
throw e;
|
|
4485
4855
|
}),
|
|
4486
4856
|
new Promise((_, reject) => {
|
|
4487
4857
|
timer = setTimeout(() => {
|
|
4488
4858
|
loadingTask.destroy();
|
|
4489
|
-
reject(new (0,
|
|
4859
|
+
reject(new (0, _chunkPW7MQZI4cjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
4490
4860
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
4491
4861
|
})
|
|
4492
4862
|
]);
|
|
@@ -4495,15 +4865,22 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
4495
4865
|
}
|
|
4496
4866
|
}
|
|
4497
4867
|
async function parsePdfDocument(buffer, options) {
|
|
4498
|
-
const formulaBuffer = _optionalChain([options, 'optionalAccess',
|
|
4868
|
+
const formulaBuffer = _optionalChain([options, 'optionalAccess', _417 => _417.formulaOcr]) ? buffer : null;
|
|
4499
4869
|
const ocrOptionError = _chunkMMK32GPDcjs.validateOcrOptions.call(void 0, options);
|
|
4500
|
-
if (ocrOptionError) throw new (0,
|
|
4501
|
-
const autoOcr = _optionalChain([options, 'optionalAccess',
|
|
4502
|
-
const ocrBuffer = _optionalChain([options, 'optionalAccess',
|
|
4503
|
-
const
|
|
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))));
|
|
4872
|
+
const ocrBuffer = _optionalChain([options, 'optionalAccess', _420 => _420.ocr]) || autoOcr ? buffer : null;
|
|
4873
|
+
const pdfjsData = new Uint8Array(buffer.slice(0));
|
|
4874
|
+
const blanked = blankLargeImageStreams(pdfjsData);
|
|
4875
|
+
const pdfium = blanked.byRaw.size > 0 ? await openPdfiumImages(buffer, blanked) : null;
|
|
4876
|
+
const doc = await loadPdfWithTimeout(buffer, blanked.byRaw.size === 0 || pdfium ? pdfjsData : void 0).catch((e) => {
|
|
4877
|
+
_optionalChain([pdfium, 'optionalAccess', _421 => _421.close, 'call', _422 => _422()]);
|
|
4878
|
+
throw e;
|
|
4879
|
+
});
|
|
4880
|
+
let pristine;
|
|
4504
4881
|
try {
|
|
4505
4882
|
const pageCount = doc.numPages;
|
|
4506
|
-
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.");
|
|
4507
4884
|
const metadata = { pageCount, pageMode: "layout" };
|
|
4508
4885
|
await extractPdfMetadata(doc, metadata);
|
|
4509
4886
|
const blocks = [];
|
|
@@ -4512,8 +4889,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4512
4889
|
let totalChars = 0;
|
|
4513
4890
|
let totalTextBytes = 0;
|
|
4514
4891
|
const effectivePageCount = Math.min(pageCount, MAX_PAGES);
|
|
4515
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
4516
|
-
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess',
|
|
4892
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _423 => _423.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
|
|
4893
|
+
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _424 => _424.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
|
|
4517
4894
|
warnings.push({ message: `${pageCount}\uCABD \uC911 \uC55E ${MAX_PAGES}\uCABD\uB9CC \uD30C\uC2F1\uD588\uC2B5\uB2C8\uB2E4 (\uCABD \uC218 \uC0C1\uD55C)`, code: "PARTIAL_PARSE" });
|
|
4518
4895
|
}
|
|
4519
4896
|
const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
|
|
@@ -4525,7 +4902,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4525
4902
|
const skippedImagePages = /* @__PURE__ */ new Map();
|
|
4526
4903
|
const uncoveredImageRegions = /* @__PURE__ */ new Map();
|
|
4527
4904
|
const largeImageRegions = /* @__PURE__ */ new Set();
|
|
4528
|
-
const
|
|
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);
|
|
4529
4911
|
const imageBulletShapes = /* @__PURE__ */ new Map();
|
|
4530
4912
|
const imageArrowDirections = /* @__PURE__ */ new Map();
|
|
4531
4913
|
const extractedImages = [];
|
|
@@ -4533,10 +4915,10 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4533
4915
|
const carry = {};
|
|
4534
4916
|
const preciseGaps = await isHancomPdf(doc);
|
|
4535
4917
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
4536
|
-
const wrapLexicon = new (0,
|
|
4918
|
+
const wrapLexicon = new (0, _chunkUBY2PLKRcjs.WrapLexicon)();
|
|
4537
4919
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
4538
4920
|
const headerContext = [];
|
|
4539
|
-
if (pageFilter && _optionalChain([options, 'optionalAccess',
|
|
4921
|
+
if (pageFilter && _optionalChain([options, 'optionalAccess', _428 => _428.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
4540
4922
|
for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
|
|
4541
4923
|
let contextPage;
|
|
4542
4924
|
try {
|
|
@@ -4546,7 +4928,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4546
4928
|
headerContext.push(...marginContextBlocks(content.items, number, contextPage.view));
|
|
4547
4929
|
} catch (e7) {
|
|
4548
4930
|
} finally {
|
|
4549
|
-
_optionalChain([contextPage, 'optionalAccess',
|
|
4931
|
+
_optionalChain([contextPage, 'optionalAccess', _429 => _429.cleanup, 'call', _430 => _430()]);
|
|
4550
4932
|
}
|
|
4551
4933
|
}
|
|
4552
4934
|
}
|
|
@@ -4573,23 +4955,23 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4573
4955
|
return void 0;
|
|
4574
4956
|
}
|
|
4575
4957
|
};
|
|
4576
|
-
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call',
|
|
4958
|
+
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _431 => _431(loadedName), 'optionalAccess', _432 => _432.differences]);
|
|
4577
4959
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4578
4960
|
markTrailingSpaceGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4579
4961
|
const restoreSoftHyphens = softHyphenHeads(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4580
|
-
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]));
|
|
4581
4963
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
4582
4964
|
restoreUnmappedCidSpaces(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
4583
4965
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4584
4966
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4585
4967
|
restoreSoftHyphens();
|
|
4586
4968
|
rawItems.push(...spaceMappedDots(rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n)));
|
|
4587
|
-
const items =
|
|
4969
|
+
const items = _chunkUBY2PLKRcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
4588
4970
|
if (!preciseGaps) for (const it of items) {
|
|
4589
4971
|
delete it.fx;
|
|
4590
4972
|
delete it.fw;
|
|
4591
4973
|
}
|
|
4592
|
-
const filtered =
|
|
4974
|
+
const filtered = _chunkUBY2PLKRcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
4593
4975
|
const joined = joinVerticalColumns(filtered.visible);
|
|
4594
4976
|
const visible = dropTabLeaderDots(joined);
|
|
4595
4977
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -4614,27 +4996,27 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4614
4996
|
fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
|
|
4615
4997
|
argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
|
|
4616
4998
|
} : rawOps;
|
|
4617
|
-
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call',
|
|
4999
|
+
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _435 => _435(loadedName), 'optionalAccess', _436 => _436.name]));
|
|
4618
5000
|
remapControlGlyphs(visible, differencesOf);
|
|
4619
|
-
await
|
|
5001
|
+
await _chunkUBY2PLKRcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
4620
5002
|
const faces = /* @__PURE__ */ new Map();
|
|
4621
5003
|
for (const it of visible) {
|
|
4622
5004
|
if (!it.fontName) continue;
|
|
4623
5005
|
let face = faces.get(it.fontName);
|
|
4624
5006
|
if (face === void 0) {
|
|
4625
5007
|
const obj = fontObj(it.fontName);
|
|
4626
|
-
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;
|
|
4627
5009
|
faces.set(it.fontName, face);
|
|
4628
5010
|
}
|
|
4629
5011
|
it.fontName = face;
|
|
4630
|
-
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}\+/, ""));
|
|
4631
5013
|
}
|
|
4632
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
4633
|
-
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);
|
|
4634
5016
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
4635
5017
|
const pageArea = pageW * pageH;
|
|
4636
5018
|
if (pageArea > 0) {
|
|
4637
|
-
const imageRegions =
|
|
5019
|
+
const imageRegions = _chunkUBY2PLKRcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
4638
5020
|
let uncovered = 0;
|
|
4639
5021
|
for (const r of imageRegions) {
|
|
4640
5022
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -4661,15 +5043,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4661
5043
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
4662
5044
|
}
|
|
4663
5045
|
const marks = superscriptNoteMarks(visible);
|
|
4664
|
-
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) });
|
|
4665
5047
|
const stamp = marginStamp(visible);
|
|
4666
5048
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
4667
|
-
const rightArrows = _optionalChain([options, 'optionalAccess',
|
|
4668
|
-
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);
|
|
4669
5051
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
4670
5052
|
for (const b of pageBlocks) blocks.push(b);
|
|
4671
5053
|
try {
|
|
4672
|
-
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)));
|
|
4673
5055
|
if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
|
|
4674
5056
|
extractedImages.push(...pageImages);
|
|
4675
5057
|
} catch (e10) {
|
|
@@ -4688,17 +5070,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4688
5070
|
const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
|
|
4689
5071
|
const quality = computePageQuality(i, pageText, vector.glyphs);
|
|
4690
5072
|
pageQuality.push(quality);
|
|
4691
|
-
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) {
|
|
4692
5074
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
4693
5075
|
}
|
|
4694
|
-
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");
|
|
4695
5077
|
parsedPages++;
|
|
4696
|
-
_optionalChain([options, 'optionalAccess',
|
|
5078
|
+
_optionalChain([options, 'optionalAccess', _444 => _444.onProgress, 'optionalCall', _445 => _445(parsedPages, totalTarget)]);
|
|
4697
5079
|
} catch (pageErr) {
|
|
4698
|
-
if (pageErr instanceof
|
|
5080
|
+
if (pageErr instanceof _chunkPW7MQZI4cjs.KordocError) throw pageErr;
|
|
4699
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" });
|
|
4700
5082
|
} finally {
|
|
4701
|
-
_optionalChain([loadedPage, 'optionalAccess',
|
|
5083
|
+
_optionalChain([loadedPage, 'optionalAccess', _446 => _446.cleanup, 'call', _447 => _447()]);
|
|
4702
5084
|
}
|
|
4703
5085
|
if (loadedFonts.size > FONT_CACHE_LIMIT) {
|
|
4704
5086
|
await doc.cleanup();
|
|
@@ -4706,14 +5088,14 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4706
5088
|
}
|
|
4707
5089
|
}
|
|
4708
5090
|
const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
|
|
4709
|
-
const isImageBased = _optionalChain([pageFilter, 'optionalAccess',
|
|
5091
|
+
const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _448 => _448.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
|
|
4710
5092
|
const ocrDone = /* @__PURE__ */ new Set();
|
|
4711
5093
|
const ocrLinesOut = /* @__PURE__ */ new Map();
|
|
4712
|
-
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();
|
|
4713
5095
|
if (ocrBuffer) {
|
|
4714
5096
|
const inScope = (p) => !pageFilter || pageFilter.has(p);
|
|
4715
5097
|
const targets = /* @__PURE__ */ new Set();
|
|
4716
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5098
|
+
if (_optionalChain([options, 'optionalAccess', _451 => _451.ocr]) === "force" || isImageBased) {
|
|
4717
5099
|
for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
|
|
4718
5100
|
} else {
|
|
4719
5101
|
for (const pq of pageQuality) {
|
|
@@ -4726,25 +5108,25 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4726
5108
|
}
|
|
4727
5109
|
if (targets.size > 0) {
|
|
4728
5110
|
try {
|
|
4729
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
4730
|
-
const mode = typeof _optionalChain([options, 'optionalAccess',
|
|
4731
|
-
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess',
|
|
4732
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
4733
|
-
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess',
|
|
4734
|
-
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 });
|
|
4735
5117
|
if (ocrPageBlocks.size > 0) {
|
|
4736
5118
|
const replacePages = /* @__PURE__ */ new Set();
|
|
4737
5119
|
for (const [p, obs] of ocrPageBlocks) {
|
|
4738
|
-
const needsOcr = _optionalChain([pageQuality, 'access',
|
|
4739
|
-
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) {
|
|
4740
5122
|
replacePages.add(p);
|
|
4741
5123
|
ocrDone.add(p);
|
|
4742
5124
|
continue;
|
|
4743
5125
|
}
|
|
4744
5126
|
const regions = ocrRegions.get(p);
|
|
4745
|
-
if (!regions ||
|
|
5127
|
+
if (!regions || _chunkUBY2PLKRcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
4746
5128
|
ocrDone.add(p);
|
|
4747
|
-
if (_optionalChain([pageImageBlocks, 'access',
|
|
5129
|
+
if (_optionalChain([pageImageBlocks, 'access', _463 => _463.get, 'call', _464 => _464(p), 'optionalAccess', _465 => _465.length]) === 1) pageImageBlocks.delete(p);
|
|
4748
5130
|
}
|
|
4749
5131
|
if (replacePages.size) {
|
|
4750
5132
|
const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
|
|
@@ -4794,18 +5176,18 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4794
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" });
|
|
4795
5177
|
}
|
|
4796
5178
|
}
|
|
4797
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4798
|
-
const removed =
|
|
4799
|
-
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);
|
|
4800
5182
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
4801
5183
|
blocks.splice(removed[ri], 1);
|
|
4802
5184
|
}
|
|
4803
|
-
const stripped =
|
|
5185
|
+
const stripped = _chunkUBY2PLKRcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
4804
5186
|
if (stripped !== blocks) {
|
|
4805
5187
|
blocks.length = 0;
|
|
4806
5188
|
blocks.push(...stripped);
|
|
4807
5189
|
}
|
|
4808
|
-
const kept =
|
|
5190
|
+
const kept = _chunkUBY2PLKRcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
4809
5191
|
if (kept !== blocks) {
|
|
4810
5192
|
blocks.length = 0;
|
|
4811
5193
|
blocks.push(...kept);
|
|
@@ -4813,15 +5195,16 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4813
5195
|
}
|
|
4814
5196
|
mergeContinuedCells(blocks, pageHeights);
|
|
4815
5197
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
4816
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4817
|
-
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);
|
|
4818
5200
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
4819
5201
|
}
|
|
4820
5202
|
splitContactTables(blocks);
|
|
4821
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
4822
|
-
|
|
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);
|
|
4823
5206
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
4824
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5207
|
+
if (_optionalChain([options, 'optionalAccess', _469 => _469.formulaOcr]) && formulaBuffer) {
|
|
4825
5208
|
try {
|
|
4826
5209
|
await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
|
|
4827
5210
|
} catch (e) {
|
|
@@ -4831,54 +5214,54 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4831
5214
|
});
|
|
4832
5215
|
}
|
|
4833
5216
|
}
|
|
4834
|
-
const medianFontSize =
|
|
5217
|
+
const medianFontSize = _chunkUBY2PLKRcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
4835
5218
|
if (medianFontSize > 0) {
|
|
4836
|
-
|
|
4837
|
-
}
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
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);
|
|
4846
5229
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
4847
|
-
|
|
4848
|
-
|
|
5230
|
+
_chunkUBY2PLKRcjs.detectTableCaptions.call(void 0, blocks);
|
|
5231
|
+
_chunkUBY2PLKRcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
4849
5232
|
sanitizeBlockControlChars(blocks);
|
|
4850
5233
|
let outBlocks = splitSingleCellTables(blocks);
|
|
4851
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5234
|
+
if (_optionalChain([options, 'optionalAccess', _470 => _470.layoutTables]) !== "keep") {
|
|
4852
5235
|
blocks.length = 0;
|
|
4853
5236
|
for (const block of outBlocks) blocks.push(block);
|
|
4854
5237
|
}
|
|
4855
5238
|
outBlocks = inlineFootnotes(outBlocks, noteMarks);
|
|
4856
5239
|
outBlocks = relocateEndnotes(outBlocks);
|
|
4857
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5240
|
+
if (_optionalChain([options, 'optionalAccess', _471 => _471.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
|
|
4858
5241
|
if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
|
|
4859
5242
|
const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
|
|
4860
5243
|
if (!b.bbox || !h) return false;
|
|
4861
5244
|
return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
|
|
4862
5245
|
});
|
|
4863
5246
|
joinLatinCellWraps(outBlocks);
|
|
4864
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5247
|
+
if (_optionalChain([options, 'optionalAccess', _472 => _472.layoutTables]) !== "keep") {
|
|
4865
5248
|
const hancom = await isHancomPdf(doc);
|
|
4866
5249
|
const shown = /* @__PURE__ */ new Map();
|
|
4867
5250
|
const markContent = (bs) => {
|
|
4868
5251
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
4869
|
-
if (
|
|
4870
|
-
const lines =
|
|
4871
|
-
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));
|
|
4872
5255
|
markContent(c.blocks);
|
|
4873
5256
|
}
|
|
4874
5257
|
};
|
|
4875
5258
|
const visual = (bs) => bs.flatMap((b) => {
|
|
4876
5259
|
if (b.type !== "table") return [b];
|
|
4877
|
-
if (!hancom && b.table &&
|
|
5260
|
+
if (!hancom && b.table && _chunkUBY2PLKRcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
4878
5261
|
let v = shown.get(b);
|
|
4879
5262
|
if (!v) {
|
|
4880
5263
|
markContent([b]);
|
|
4881
|
-
shown.set(b, v =
|
|
5264
|
+
shown.set(b, v = _chunkTQOAPKLUcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _473 => _473.keepTrailingEmptyCols])));
|
|
4882
5265
|
}
|
|
4883
5266
|
return v;
|
|
4884
5267
|
});
|
|
@@ -4887,13 +5270,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4887
5270
|
blocks.length = 0;
|
|
4888
5271
|
for (const b of kept) blocks.push(b);
|
|
4889
5272
|
}
|
|
4890
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
4891
|
-
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);
|
|
4892
5275
|
let markdown = finishMarkdown(outBlocks);
|
|
4893
5276
|
const outline = collectPdfOutline(outBlocks);
|
|
4894
5277
|
return {
|
|
4895
5278
|
markdown,
|
|
4896
|
-
pages:
|
|
5279
|
+
pages: _chunkY4MFHEK4cjs.blocksToPages.call(void 0, splitPageTables(_chunkUBY2PLKRcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
4897
5280
|
blocks,
|
|
4898
5281
|
metadata,
|
|
4899
5282
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -4902,17 +5285,20 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4902
5285
|
pageQuality,
|
|
4903
5286
|
qualitySummary: summarizeDocumentQuality(pageQuality),
|
|
4904
5287
|
images: extractedImages.length > 0 ? extractedImages : void 0,
|
|
4905
|
-
..._optionalChain([options, 'optionalAccess',
|
|
5288
|
+
..._optionalChain([options, 'optionalAccess', _476 => _476.ocrLines]) ? { ocrLines: [...ocrLinesOut.values()].sort((a, b) => a.pageNumber - b.pageNumber) } : {}
|
|
4906
5289
|
};
|
|
4907
5290
|
} finally {
|
|
4908
5291
|
await doc.destroy().catch(() => {
|
|
4909
5292
|
});
|
|
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(() => {
|
|
5295
|
+
})]);
|
|
4910
5296
|
}
|
|
4911
5297
|
}
|
|
4912
5298
|
async function extractPdfMetadata(doc, metadata) {
|
|
4913
5299
|
try {
|
|
4914
5300
|
const result = await doc.getMetadata();
|
|
4915
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
5301
|
+
if (!_optionalChain([result, 'optionalAccess', _483 => _483.info])) return;
|
|
4916
5302
|
const info = result.info;
|
|
4917
5303
|
if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
|
|
4918
5304
|
if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
|
|
@@ -4928,8 +5314,8 @@ async function extractPdfMetadata(doc, metadata) {
|
|
|
4928
5314
|
}
|
|
4929
5315
|
async function isHancomPdf(doc) {
|
|
4930
5316
|
try {
|
|
4931
|
-
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async
|
|
4932
|
-
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));
|
|
4933
5319
|
} catch (e12) {
|
|
4934
5320
|
return false;
|
|
4935
5321
|
}
|
|
@@ -4973,5 +5359,5 @@ function marginStamp(items) {
|
|
|
4973
5359
|
|
|
4974
5360
|
|
|
4975
5361
|
|
|
4976
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
4977
|
-
//# 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
|