kordoc 4.24.81 → 4.24.82
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 +40 -3
- package/README.md +43 -33
- package/THIRD_PARTY/hayro-pdf.txt +361 -0
- package/dist/{-NY5EAGMN.js → -DOI2WS2X.js} +22 -22
- package/dist/{chunk-JB22LEUF.js → chunk-3CLLAJTD.js} +2 -2
- package/dist/{chunk-KQIEYWSK.js → chunk-3LCJVBNH.js} +7 -7
- package/dist/{chunk-KBNIONYK.js → chunk-4C6EU227.js} +5 -5
- package/dist/{chunk-NFK4FREL.js → chunk-4EQZ7S7Q.js} +2 -2
- package/dist/{chunk-NFK4FREL.js.map → chunk-4EQZ7S7Q.js.map} +1 -1
- package/dist/{chunk-PDZHASZZ.js → chunk-5M5BK2KR.js} +3 -3
- package/dist/{chunk-WFBAUIVS.js → chunk-6XIIPA2N.js} +18 -23
- package/dist/chunk-6XIIPA2N.js.map +1 -0
- package/dist/{chunk-UQHK7JM3.js → chunk-7LARA6JJ.js} +3 -3
- package/dist/{chunk-ESTZ4A5D.cjs → chunk-AIAWKYBK.cjs} +3 -3
- package/dist/{chunk-ESTZ4A5D.cjs.map → chunk-AIAWKYBK.cjs.map} +1 -1
- package/dist/{chunk-NW4KWWOO.js → chunk-AWCNLRD7.js} +158 -53
- package/dist/chunk-AWCNLRD7.js.map +1 -0
- package/dist/{chunk-ATXF6SFZ.js → chunk-BBPVSM5G.js} +11 -11
- package/dist/{chunk-DQBRFEGG.js → chunk-BVNYRR2Q.js} +2 -2
- package/dist/{chunk-FFLYV7UE.js → chunk-D5EQXF3A.js} +4 -4
- package/dist/{chunk-F35QX3FJ.js → chunk-D6O3STKQ.js} +10 -10
- package/dist/{chunk-DKP45NXS.js → chunk-E3TTZQCH.js} +2 -2
- package/dist/{chunk-HZ7Y52BX.js → chunk-FDNNYTES.js} +2 -2
- package/dist/{chunk-LXYO4VKX.cjs → chunk-FG3SD2G3.cjs} +229 -124
- package/dist/chunk-FG3SD2G3.cjs.map +1 -0
- package/dist/{chunk-VUASNILI.js → chunk-FP4YQ6PH.js} +2 -2
- package/dist/{chunk-PTNLFPNY.cjs → chunk-G7ERL37A.cjs} +58 -58
- package/dist/{chunk-PTNLFPNY.cjs.map → chunk-G7ERL37A.cjs.map} +1 -1
- package/dist/{chunk-LS5GXXKY.js → chunk-GCIY73JI.js} +2 -2
- package/dist/{chunk-HXA6WK2Q.cjs → chunk-HHOGCXPD.cjs} +3 -3
- package/dist/{chunk-HXA6WK2Q.cjs.map → chunk-HHOGCXPD.cjs.map} +1 -1
- package/dist/{chunk-CN3CVJS7.js → chunk-HJZ26CTR.js} +2 -2
- package/dist/{chunk-EM2FOISF.cjs → chunk-HURH2Q3V.cjs} +104 -104
- package/dist/{chunk-EM2FOISF.cjs.map → chunk-HURH2Q3V.cjs.map} +1 -1
- package/dist/{chunk-FKRPLMWM.js → chunk-I3XQFXW3.js} +2 -2
- package/dist/{chunk-W4MJEQNR.js → chunk-IK2ZHZIK.js} +159 -54
- package/dist/chunk-IK2ZHZIK.js.map +1 -0
- package/dist/{chunk-CLCEUM43.js → chunk-JJIUF3BO.js} +3 -3
- package/dist/{chunk-62OTKCT7.js → chunk-L7IGFD7A.js} +2 -2
- package/dist/{chunk-62OTKCT7.js.map → chunk-L7IGFD7A.js.map} +1 -1
- package/dist/{chunk-VUSJFAR6.js → chunk-LHEA3T5U.js} +2 -2
- package/dist/{chunk-IDAGPWDM.js → chunk-LLTWOQHF.js} +2 -2
- package/dist/{chunk-CBRCNSZR.js → chunk-MEOVK2T4.js} +2 -2
- package/dist/{chunk-ETXAD3SI.js → chunk-MN67UQWM.js} +2 -2
- package/dist/{chunk-ZQ7HBPYW.js → chunk-OPFB4HIV.js} +2 -2
- package/dist/{chunk-5NNL2KEI.js → chunk-PF4X6Q2A.js} +6 -6
- package/dist/{chunk-7P63PYE4.js → chunk-R67KB3VI.js} +2 -2
- package/dist/{chunk-GTWSIP6X.js → chunk-RI7RJQHA.js} +2 -2
- package/dist/{chunk-YA6YQISD.js → chunk-RUKITL4B.js} +5 -5
- package/dist/{chunk-6DX7WPNL.cjs → chunk-RW6YV66W.cjs} +6 -6
- package/dist/{chunk-6DX7WPNL.cjs.map → chunk-RW6YV66W.cjs.map} +1 -1
- package/dist/{chunk-CQ5DOA7D.cjs → chunk-UBZROOIA.cjs} +2 -2
- package/dist/{chunk-CQ5DOA7D.cjs.map → chunk-UBZROOIA.cjs.map} +1 -1
- package/dist/{chunk-TYYAW34Z.js → chunk-UVDXETZT.js} +2 -2
- package/dist/{chunk-4I4BABFL.js → chunk-VKX2R7NH.js} +2 -2
- package/dist/{chunk-SL7HO3BU.js → chunk-VTLJ7GQ6.js} +5 -5
- package/dist/{chunk-3A6S77VJ.js → chunk-WCCO4LDT.js} +2 -2
- package/dist/{chunk-MCVDIQL7.js → chunk-WGBQGATZ.js} +6 -6
- package/dist/{chunk-5K75SJQ7.cjs → chunk-WPILSYFA.cjs} +88 -88
- package/dist/{chunk-5K75SJQ7.cjs.map → chunk-WPILSYFA.cjs.map} +1 -1
- package/dist/{chunk-4CZN32UA.js → chunk-YH74TGTU.js} +2 -2
- package/dist/{chunk-6GOLWDBQ.cjs → chunk-YIATOFKC.cjs} +8 -8
- package/dist/{chunk-6GOLWDBQ.cjs.map → chunk-YIATOFKC.cjs.map} +1 -1
- package/dist/{chunk-7E3GZZDW.js → chunk-YQ3FNNH3.js} +3 -3
- package/dist/chunks-SPCEB5T5.js +11 -0
- package/dist/cli.js +46 -46
- package/dist/{formula-5DHIYJUB.cjs → formula-EOGDE2KW.cjs} +9 -9
- package/dist/{formula-5DHIYJUB.cjs.map → formula-EOGDE2KW.cjs.map} +1 -1
- package/dist/{formula-LGZHKHFO.js → formula-J4LHFTZY.js} +3 -3
- package/dist/{formula-PN64SKTR.js → formula-Y35QOUQG.js} +4 -4
- package/dist/generator-GFZKAOIU.cjs +12 -0
- package/dist/{generator-JCAIE47E.cjs.map → generator-GFZKAOIU.cjs.map} +1 -1
- package/dist/generator-TNUWCZBX.js +11 -0
- package/dist/generator-YERQXN6P.js +18 -0
- package/dist/{hancom-NAHN4T2V.js → hancom-CYTGBQMY.js} +2 -2
- package/dist/{hancom-6WNGLXDE.js → hancom-K3DXLFM7.js} +2 -2
- package/dist/{hancom-47XQI2A7.cjs → hancom-S2AZ3HZK.cjs} +5 -5
- package/dist/{hancom-47XQI2A7.cjs.map → hancom-S2AZ3HZK.cjs.map} +1 -1
- package/dist/hayro-pdf.wasm +0 -0
- package/dist/{image-ocr-YBXRT254.js → image-ocr-2TDI2P6X.js} +11 -11
- package/dist/{image-ocr-ZLS36MLH.cjs → image-ocr-4FN5XYX5.cjs} +36 -36
- package/dist/{image-ocr-ZLS36MLH.cjs.map → image-ocr-4FN5XYX5.cjs.map} +1 -1
- package/dist/{image-ocr-J7UKZU3H.js → image-ocr-OKGTS42T.js} +8 -8
- package/dist/index.cjs +1116 -1121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -17
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +37 -37
- package/dist/mcp.js.map +1 -1
- package/dist/memo-WYTLFL7W.js +17 -0
- package/dist/{model-bundle-MXSFABVN.js → model-bundle-4B2TOR2Y.js} +5 -5
- package/dist/{models-NF54Y6MA.js → models-3VJKRFZA.js} +5 -5
- package/dist/{parse-worker-v2-7ODPHRII.js → parse-worker-v2-KB2MQD24.js} +23 -23
- package/dist/{parser-YHAEVWPI.js → parser-GNNRTTBQ.js} +1153 -643
- package/dist/parser-GNNRTTBQ.js.map +1 -0
- package/dist/{parser-LIGIOQX6.js → parser-RIXKUWYL.js} +1150 -640
- package/dist/parser-RIXKUWYL.js.map +1 -0
- package/dist/{parser-NIB7K6KD.cjs → parser-WP6URQHZ.cjs} +1459 -949
- package/dist/parser-WP6URQHZ.cjs.map +1 -0
- package/dist/pdf-ocr-KZHDUVLH.cjs +43 -0
- package/dist/{pdf-ocr-OMQ6NPAB.cjs.map → pdf-ocr-KZHDUVLH.cjs.map} +1 -1
- package/dist/{pdf-ocr-XYCAJZFG.js → pdf-ocr-YQ3EO3MU.js} +9 -9
- package/dist/{pdf-ocr-3M63HYMD.js → pdf-ocr-YUIYIQ3V.js} +6 -6
- package/dist/{profile-io-YZHR4TPC.js → profile-io-TERSCXHN.js} +3 -3
- package/dist/{rasterize-HTFNHKJ5.js → rasterize-37XS6Q7N.js} +3 -3
- package/dist/{redact-doc-PLIVDKLR.js → redact-doc-4JKKOFR7.js} +22 -22
- package/dist/{render-4LQP4V6V.js → render-ITR44KDL.js} +12 -12
- package/dist/{rewrite-fallback-WBSLK753.js → rewrite-fallback-HDPR4FHH.js} +13 -13
- package/dist/seal-RLAVI3L6.js +16 -0
- package/dist/{setup-5FCNDOAI.js → setup-VQJ5E4C7.js} +3 -3
- package/dist/{to-hwpx-H7QZRFNB.js → to-hwpx-6TMP7TXQ.js} +4 -4
- package/dist/{to-hwpx-WGWHCASX.js → to-hwpx-AOJP2SOM.js} +7 -7
- package/dist/to-hwpx-LHHVLGBY.cjs +16 -0
- package/dist/{to-hwpx-4A5PFFJ2.cjs.map → to-hwpx-LHHVLGBY.cjs.map} +1 -1
- package/dist/visual-H5ADD24W.js +40 -0
- package/dist/{watch-KB3LUYYV.js → watch-AM2GZPBV.js} +23 -23
- package/package.json +1 -2
- package/dist/chunk-LXYO4VKX.cjs.map +0 -1
- package/dist/chunk-NW4KWWOO.js.map +0 -1
- package/dist/chunk-W4MJEQNR.js.map +0 -1
- package/dist/chunk-WFBAUIVS.js.map +0 -1
- package/dist/chunks-ZCMJYLNX.js +0 -11
- package/dist/generator-D26AQTCK.js +0 -18
- package/dist/generator-JCAIE47E.cjs +0 -12
- package/dist/generator-X77EPAWM.js +0 -11
- package/dist/memo-S6GPWVYP.js +0 -17
- package/dist/parser-LIGIOQX6.js.map +0 -1
- package/dist/parser-NIB7K6KD.cjs.map +0 -1
- package/dist/parser-YHAEVWPI.js.map +0 -1
- package/dist/pdf-ocr-OMQ6NPAB.cjs +0 -43
- package/dist/seal-WMAKEFGP.js +0 -16
- package/dist/to-hwpx-4A5PFFJ2.cjs +0 -16
- package/dist/visual-UXJ3IK2J.js +0 -40
- /package/dist/{-NY5EAGMN.js.map → -DOI2WS2X.js.map} +0 -0
- /package/dist/{chunk-JB22LEUF.js.map → chunk-3CLLAJTD.js.map} +0 -0
- /package/dist/{chunk-KQIEYWSK.js.map → chunk-3LCJVBNH.js.map} +0 -0
- /package/dist/{chunk-KBNIONYK.js.map → chunk-4C6EU227.js.map} +0 -0
- /package/dist/{chunk-PDZHASZZ.js.map → chunk-5M5BK2KR.js.map} +0 -0
- /package/dist/{chunk-UQHK7JM3.js.map → chunk-7LARA6JJ.js.map} +0 -0
- /package/dist/{chunk-ATXF6SFZ.js.map → chunk-BBPVSM5G.js.map} +0 -0
- /package/dist/{chunk-DQBRFEGG.js.map → chunk-BVNYRR2Q.js.map} +0 -0
- /package/dist/{chunk-FFLYV7UE.js.map → chunk-D5EQXF3A.js.map} +0 -0
- /package/dist/{chunk-F35QX3FJ.js.map → chunk-D6O3STKQ.js.map} +0 -0
- /package/dist/{chunk-DKP45NXS.js.map → chunk-E3TTZQCH.js.map} +0 -0
- /package/dist/{chunk-HZ7Y52BX.js.map → chunk-FDNNYTES.js.map} +0 -0
- /package/dist/{chunk-VUASNILI.js.map → chunk-FP4YQ6PH.js.map} +0 -0
- /package/dist/{chunk-LS5GXXKY.js.map → chunk-GCIY73JI.js.map} +0 -0
- /package/dist/{chunk-CN3CVJS7.js.map → chunk-HJZ26CTR.js.map} +0 -0
- /package/dist/{chunk-FKRPLMWM.js.map → chunk-I3XQFXW3.js.map} +0 -0
- /package/dist/{chunk-CLCEUM43.js.map → chunk-JJIUF3BO.js.map} +0 -0
- /package/dist/{chunk-VUSJFAR6.js.map → chunk-LHEA3T5U.js.map} +0 -0
- /package/dist/{chunk-IDAGPWDM.js.map → chunk-LLTWOQHF.js.map} +0 -0
- /package/dist/{chunk-CBRCNSZR.js.map → chunk-MEOVK2T4.js.map} +0 -0
- /package/dist/{chunk-ETXAD3SI.js.map → chunk-MN67UQWM.js.map} +0 -0
- /package/dist/{chunk-ZQ7HBPYW.js.map → chunk-OPFB4HIV.js.map} +0 -0
- /package/dist/{chunk-5NNL2KEI.js.map → chunk-PF4X6Q2A.js.map} +0 -0
- /package/dist/{chunk-7P63PYE4.js.map → chunk-R67KB3VI.js.map} +0 -0
- /package/dist/{chunk-GTWSIP6X.js.map → chunk-RI7RJQHA.js.map} +0 -0
- /package/dist/{chunk-YA6YQISD.js.map → chunk-RUKITL4B.js.map} +0 -0
- /package/dist/{chunk-TYYAW34Z.js.map → chunk-UVDXETZT.js.map} +0 -0
- /package/dist/{chunk-4I4BABFL.js.map → chunk-VKX2R7NH.js.map} +0 -0
- /package/dist/{chunk-SL7HO3BU.js.map → chunk-VTLJ7GQ6.js.map} +0 -0
- /package/dist/{chunk-3A6S77VJ.js.map → chunk-WCCO4LDT.js.map} +0 -0
- /package/dist/{chunk-MCVDIQL7.js.map → chunk-WGBQGATZ.js.map} +0 -0
- /package/dist/{chunk-4CZN32UA.js.map → chunk-YH74TGTU.js.map} +0 -0
- /package/dist/{chunk-7E3GZZDW.js.map → chunk-YQ3FNNH3.js.map} +0 -0
- /package/dist/{chunks-ZCMJYLNX.js.map → chunks-SPCEB5T5.js.map} +0 -0
- /package/dist/{formula-LGZHKHFO.js.map → formula-J4LHFTZY.js.map} +0 -0
- /package/dist/{formula-PN64SKTR.js.map → formula-Y35QOUQG.js.map} +0 -0
- /package/dist/{generator-D26AQTCK.js.map → generator-TNUWCZBX.js.map} +0 -0
- /package/dist/{generator-X77EPAWM.js.map → generator-YERQXN6P.js.map} +0 -0
- /package/dist/{hancom-NAHN4T2V.js.map → hancom-CYTGBQMY.js.map} +0 -0
- /package/dist/{hancom-6WNGLXDE.js.map → hancom-K3DXLFM7.js.map} +0 -0
- /package/dist/{image-ocr-YBXRT254.js.map → image-ocr-2TDI2P6X.js.map} +0 -0
- /package/dist/{image-ocr-J7UKZU3H.js.map → image-ocr-OKGTS42T.js.map} +0 -0
- /package/dist/{memo-S6GPWVYP.js.map → memo-WYTLFL7W.js.map} +0 -0
- /package/dist/{model-bundle-MXSFABVN.js.map → model-bundle-4B2TOR2Y.js.map} +0 -0
- /package/dist/{models-NF54Y6MA.js.map → models-3VJKRFZA.js.map} +0 -0
- /package/dist/{parse-worker-v2-7ODPHRII.js.map → parse-worker-v2-KB2MQD24.js.map} +0 -0
- /package/dist/{pdf-ocr-3M63HYMD.js.map → pdf-ocr-YQ3EO3MU.js.map} +0 -0
- /package/dist/{pdf-ocr-XYCAJZFG.js.map → pdf-ocr-YUIYIQ3V.js.map} +0 -0
- /package/dist/{profile-io-YZHR4TPC.js.map → profile-io-TERSCXHN.js.map} +0 -0
- /package/dist/{rasterize-HTFNHKJ5.js.map → rasterize-37XS6Q7N.js.map} +0 -0
- /package/dist/{redact-doc-PLIVDKLR.js.map → redact-doc-4JKKOFR7.js.map} +0 -0
- /package/dist/{render-4LQP4V6V.js.map → render-ITR44KDL.js.map} +0 -0
- /package/dist/{rewrite-fallback-WBSLK753.js.map → rewrite-fallback-HDPR4FHH.js.map} +0 -0
- /package/dist/{seal-WMAKEFGP.js.map → seal-RLAVI3L6.js.map} +0 -0
- /package/dist/{setup-5FCNDOAI.js.map → setup-VQJ5E4C7.js.map} +0 -0
- /package/dist/{to-hwpx-H7QZRFNB.js.map → to-hwpx-6TMP7TXQ.js.map} +0 -0
- /package/dist/{to-hwpx-WGWHCASX.js.map → to-hwpx-AOJP2SOM.js.map} +0 -0
- /package/dist/{visual-UXJ3IK2J.js.map → visual-H5ADD24W.js.map} +0 -0
- /package/dist/{watch-KB3LUYYV.js.map → watch-AM2GZPBV.js.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
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; }
|
|
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; }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkHHOGCXPDcjs = require('./chunk-HHOGCXPD.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -71,11 +71,14 @@ var _chunkHHLZQQNLcjs = require('./chunk-HHLZQQNL.cjs');
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
var _chunkFG3SD2G3cjs = require('./chunk-FG3SD2G3.cjs');
|
|
75
78
|
|
|
76
79
|
|
|
77
80
|
var _chunkMMK32GPDcjs = require('./chunk-MMK32GPD.cjs');
|
|
78
|
-
require('./chunk-
|
|
81
|
+
require('./chunk-AIAWKYBK.cjs');
|
|
79
82
|
|
|
80
83
|
|
|
81
84
|
|
|
@@ -92,234 +95,944 @@ require('./chunk-ESTZ4A5D.cjs');
|
|
|
92
95
|
|
|
93
96
|
|
|
94
97
|
|
|
95
|
-
var
|
|
98
|
+
var _chunkYIATOFKCcjs = require('./chunk-YIATOFKC.cjs');
|
|
96
99
|
|
|
97
100
|
|
|
98
101
|
|
|
99
|
-
var
|
|
102
|
+
var _chunkUBZROOIAcjs = require('./chunk-UBZROOIA.cjs');
|
|
100
103
|
|
|
101
104
|
|
|
102
105
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
103
106
|
|
|
104
|
-
// src/pdf/
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
// src/pdf/hayro.ts
|
|
108
|
+
var compiled;
|
|
109
|
+
async function wasmBytes() {
|
|
110
|
+
const url = new URL("./hayro-pdf.wasm", _chunkGS7T56RPcjs.importMetaUrl);
|
|
111
|
+
if (typeof process !== "undefined" && _optionalChain([process, 'access', _2 => _2.versions, 'optionalAccess', _3 => _3.node])) {
|
|
112
|
+
const { readFile } = await Promise.resolve().then(() => _interopRequireWildcard(require("fs/promises")));
|
|
113
|
+
return readFile(url);
|
|
114
|
+
}
|
|
115
|
+
const res = await fetch(url);
|
|
116
|
+
if (!res.ok) throw new Error(`hayro-pdf.wasm \uC744 \uBC1B\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (${res.status})`);
|
|
117
|
+
return res.arrayBuffer();
|
|
118
|
+
}
|
|
119
|
+
function module() {
|
|
120
|
+
compiled ??= wasmBytes().then((b) => WebAssembly.compile(b)).catch((e) => {
|
|
121
|
+
compiled = void 0;
|
|
122
|
+
throw e;
|
|
123
|
+
});
|
|
124
|
+
return compiled;
|
|
125
|
+
}
|
|
126
|
+
var decoder = new TextDecoder();
|
|
127
|
+
var encoder = new TextEncoder();
|
|
128
|
+
var HayroOpenError = class extends Error {
|
|
129
|
+
constructor(reason) {
|
|
130
|
+
super(`PDF \uB97C \uC5F4 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 (${reason})`);
|
|
131
|
+
this.reason = reason;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
};
|
|
135
|
+
async function openHayro(buffer) {
|
|
136
|
+
const w = new WebAssembly.Instance(await module()).exports;
|
|
137
|
+
const src = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
138
|
+
const p = w.alloc(src.length) >>> 0;
|
|
139
|
+
new Uint8Array(w.memory.buffer, p, src.length).set(src);
|
|
140
|
+
const rc = w.open(p, src.length);
|
|
141
|
+
if (rc !== 0) throw new HayroOpenError(rc === 2 ? "password" : rc === 3 ? "encryption" : "invalid");
|
|
142
|
+
let alive = true;
|
|
143
|
+
const bytesView = () => new Uint8Array(w.memory.buffer, w.bytes_ptr() >>> 0, w.bytes_len() >>> 0);
|
|
144
|
+
const bytes = () => bytesView().slice();
|
|
145
|
+
const f64 = () => {
|
|
146
|
+
const p2 = w.f64_ptr() >>> 0;
|
|
147
|
+
return new Float64Array(w.memory.buffer.slice(p2, p2 + (w.f64_len() >>> 0) * 8));
|
|
115
148
|
};
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
149
|
+
const text = () => decoder.decode(bytesView());
|
|
150
|
+
const withStr = (s, fn) => {
|
|
151
|
+
const b = encoder.encode(s), q = w.alloc(b.length) >>> 0;
|
|
152
|
+
new Uint8Array(w.memory.buffer, q, b.length).set(b);
|
|
153
|
+
try {
|
|
154
|
+
return fn(q, b.length);
|
|
155
|
+
} finally {
|
|
156
|
+
w.dealloc(q, b.length);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const call = (fn) => {
|
|
160
|
+
if (!alive) throw new Error("\uB2EB\uD78C PDF \uBB38\uC11C\uC785\uB2C8\uB2E4");
|
|
161
|
+
try {
|
|
162
|
+
return fn();
|
|
163
|
+
} catch (e) {
|
|
164
|
+
if (e instanceof WebAssembly.RuntimeError) alive = false;
|
|
165
|
+
throw e;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
pageCount: () => call(() => w.page_count()),
|
|
170
|
+
events: (page) => call(() => {
|
|
171
|
+
if (w.events(page) < 0) throw new Error(text());
|
|
172
|
+
return { events: f64(), strings: text().split("") };
|
|
173
|
+
}),
|
|
174
|
+
pageView: (page) => call(() => {
|
|
175
|
+
w.page_view(page);
|
|
176
|
+
return Array.from(f64());
|
|
177
|
+
}),
|
|
178
|
+
pageRotate: (page) => call(() => w.page_rotate(page)),
|
|
179
|
+
fontInfo: (key) => call(() => {
|
|
180
|
+
withStr(key, (q, l) => w.font_info(q, l));
|
|
181
|
+
return text();
|
|
182
|
+
}),
|
|
183
|
+
fontFile: (key) => call(() => {
|
|
184
|
+
withStr(key, (q, l) => w.font_file(q, l));
|
|
185
|
+
return bytes();
|
|
186
|
+
}),
|
|
187
|
+
image: (id) => call(() => {
|
|
188
|
+
if (withStr(id, (q, l) => w.image(q, l)) !== 3) return null;
|
|
189
|
+
const [width = 0, height = 0, kind = 0] = f64();
|
|
190
|
+
return { width, height, kind, data: bytes() };
|
|
191
|
+
}),
|
|
192
|
+
info: () => call(() => {
|
|
193
|
+
w.info();
|
|
194
|
+
return JSON.parse(text() || "{}");
|
|
195
|
+
}),
|
|
196
|
+
links: (page) => call(() => {
|
|
197
|
+
w.links(page);
|
|
198
|
+
return JSON.parse(text() || "[]");
|
|
199
|
+
}),
|
|
200
|
+
close: () => {
|
|
201
|
+
alive = false;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/pdf/bidi.ts
|
|
207
|
+
var baseTypes = ["BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "S", "B", "S", "WS", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "B", "B", "B", "S", "WS", "ON", "ON", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "ON", "ES", "CS", "ES", "CS", "CS", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "BN", "BN", "BN", "BN", "BN", "BN", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "CS", "ON", "ET", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "L", "ON", "ON", "BN", "ON", "ON", "ET", "ET", "EN", "EN", "ON", "L", "ON", "ON", "ON", "EN", "L", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L"];
|
|
208
|
+
var arabicTypes = ["AN", "AN", "AN", "AN", "AN", "AN", "ON", "ON", "AL", "ET", "ET", "AL", "CS", "AL", "ON", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "ET", "AN", "AN", "AL", "AL", "AL", "NSM", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "NSM", "NSM", "ON", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "AL", "AL", "AL", "AL", "AL", "AL"];
|
|
209
|
+
function isOdd(i) {
|
|
210
|
+
return (i & 1) !== 0;
|
|
211
|
+
}
|
|
212
|
+
function isEven(i) {
|
|
213
|
+
return (i & 1) === 0;
|
|
214
|
+
}
|
|
215
|
+
function findUnequal(arr, start, value) {
|
|
216
|
+
let j, jj;
|
|
217
|
+
for (j = start, jj = arr.length; j < jj; ++j) {
|
|
218
|
+
if (arr[j] !== value) {
|
|
219
|
+
return j;
|
|
122
220
|
}
|
|
123
221
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
for (; ; ) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
222
|
+
return j;
|
|
223
|
+
}
|
|
224
|
+
function setValues(arr, start, end, value) {
|
|
225
|
+
for (let j = start; j < end; ++j) {
|
|
226
|
+
arr[j] = value;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function reverseValues(arr, start, end) {
|
|
230
|
+
for (let i = start, j = end - 1; i < j; ++i, --j) {
|
|
231
|
+
const temp = arr[i];
|
|
232
|
+
arr[i] = arr[j];
|
|
233
|
+
arr[j] = temp;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function createBidiText(str, isLTR, vertical = false) {
|
|
237
|
+
let dir = "ltr";
|
|
238
|
+
if (vertical) {
|
|
239
|
+
dir = "ttb";
|
|
240
|
+
} else if (!isLTR) {
|
|
241
|
+
dir = "rtl";
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
str,
|
|
245
|
+
dir
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
var chars = [];
|
|
249
|
+
var types = [];
|
|
250
|
+
function bidi(str, startLevel = -1, vertical = false) {
|
|
251
|
+
let isLTR = true;
|
|
252
|
+
const strLength = str.length;
|
|
253
|
+
if (strLength === 0 || vertical) {
|
|
254
|
+
return createBidiText(str, isLTR, vertical);
|
|
255
|
+
}
|
|
256
|
+
chars.length = strLength;
|
|
257
|
+
types.length = strLength;
|
|
258
|
+
let numBidi = 0;
|
|
259
|
+
let i, ii;
|
|
260
|
+
for (i = 0; i < strLength; ++i) {
|
|
261
|
+
chars[i] = str.charAt(i);
|
|
262
|
+
const charCode = str.charCodeAt(i);
|
|
263
|
+
let charType = "L";
|
|
264
|
+
if (charCode <= 255) {
|
|
265
|
+
charType = baseTypes[charCode];
|
|
266
|
+
} else if (1424 <= charCode && charCode <= 1524) {
|
|
267
|
+
charType = "R";
|
|
268
|
+
} else if (1536 <= charCode && charCode <= 1791) {
|
|
269
|
+
charType = arabicTypes[charCode & 255];
|
|
270
|
+
} else if (1792 <= charCode && charCode <= 2220 || 64336 <= charCode && charCode <= 65023 || 65136 <= charCode && charCode <= 65279) {
|
|
271
|
+
charType = "AL";
|
|
272
|
+
}
|
|
273
|
+
if (charType === "R" || charType === "AL" || charType === "AN") {
|
|
274
|
+
numBidi++;
|
|
275
|
+
}
|
|
276
|
+
types[i] = charType;
|
|
277
|
+
}
|
|
278
|
+
if (numBidi === 0) {
|
|
279
|
+
isLTR = true;
|
|
280
|
+
return createBidiText(str, isLTR);
|
|
281
|
+
}
|
|
282
|
+
if (startLevel === -1) {
|
|
283
|
+
if (numBidi / strLength < 0.3 && strLength > 4) {
|
|
284
|
+
isLTR = true;
|
|
285
|
+
startLevel = 0;
|
|
286
|
+
} else {
|
|
287
|
+
isLTR = false;
|
|
288
|
+
startLevel = 1;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const levels = [];
|
|
292
|
+
for (i = 0; i < strLength; ++i) {
|
|
293
|
+
levels[i] = startLevel;
|
|
294
|
+
}
|
|
295
|
+
const e = isOdd(startLevel) ? "R" : "L";
|
|
296
|
+
const sor = e;
|
|
297
|
+
const eor = sor;
|
|
298
|
+
let lastType = sor;
|
|
299
|
+
for (i = 0; i < strLength; ++i) {
|
|
300
|
+
if (types[i] === "NSM") {
|
|
301
|
+
types[i] = lastType;
|
|
302
|
+
} else {
|
|
303
|
+
lastType = types[i];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
lastType = sor;
|
|
307
|
+
let t;
|
|
308
|
+
for (i = 0; i < strLength; ++i) {
|
|
309
|
+
t = types[i];
|
|
310
|
+
if (t === "EN") {
|
|
311
|
+
types[i] = lastType === "AL" ? "AN" : "EN";
|
|
312
|
+
} else if (t === "R" || t === "L" || t === "AL") {
|
|
313
|
+
lastType = t;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
for (i = 0; i < strLength; ++i) {
|
|
317
|
+
t = types[i];
|
|
318
|
+
if (t === "AL") {
|
|
319
|
+
types[i] = "R";
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
for (i = 1; i < strLength - 1; ++i) {
|
|
323
|
+
if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
|
|
324
|
+
types[i] = "EN";
|
|
325
|
+
}
|
|
326
|
+
if (types[i] === "CS" && (types[i - 1] === "EN" || types[i - 1] === "AN") && types[i + 1] === types[i - 1]) {
|
|
327
|
+
types[i] = types[i - 1];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
for (i = 0; i < strLength; ++i) {
|
|
331
|
+
if (types[i] === "EN") {
|
|
332
|
+
for (let j = i - 1; j >= 0; --j) {
|
|
333
|
+
if (types[j] !== "ET") {
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
types[j] = "EN";
|
|
337
|
+
}
|
|
338
|
+
for (let j = i + 1; j < strLength; ++j) {
|
|
339
|
+
if (types[j] !== "ET") {
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
types[j] = "EN";
|
|
147
343
|
}
|
|
148
344
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
345
|
+
}
|
|
346
|
+
for (i = 0; i < strLength; ++i) {
|
|
347
|
+
t = types[i];
|
|
348
|
+
if (t === "WS" || t === "ES" || t === "ET" || t === "CS") {
|
|
349
|
+
types[i] = "ON";
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
lastType = sor;
|
|
353
|
+
for (i = 0; i < strLength; ++i) {
|
|
354
|
+
t = types[i];
|
|
355
|
+
if (t === "EN") {
|
|
356
|
+
types[i] = lastType === "L" ? "L" : "EN";
|
|
357
|
+
} else if (t === "R" || t === "L") {
|
|
358
|
+
lastType = t;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
for (i = 0; i < strLength; ++i) {
|
|
362
|
+
if (types[i] === "ON") {
|
|
363
|
+
const end = findUnequal(types, i + 1, "ON");
|
|
364
|
+
let before = sor;
|
|
365
|
+
if (i > 0) {
|
|
366
|
+
before = types[i - 1];
|
|
367
|
+
}
|
|
368
|
+
let after = eor;
|
|
369
|
+
if (end + 1 < strLength) {
|
|
370
|
+
after = types[end + 1];
|
|
371
|
+
}
|
|
372
|
+
if (before !== "L") {
|
|
373
|
+
before = "R";
|
|
374
|
+
}
|
|
375
|
+
if (after !== "L") {
|
|
376
|
+
after = "R";
|
|
377
|
+
}
|
|
378
|
+
if (before === after) {
|
|
379
|
+
setValues(types, i, end, before);
|
|
380
|
+
}
|
|
381
|
+
i = end - 1;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
for (i = 0; i < strLength; ++i) {
|
|
385
|
+
if (types[i] === "ON") {
|
|
386
|
+
types[i] = e;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
for (i = 0; i < strLength; ++i) {
|
|
390
|
+
t = types[i];
|
|
391
|
+
if (isEven(levels[i])) {
|
|
392
|
+
if (t === "R") {
|
|
393
|
+
levels[i] += 1;
|
|
394
|
+
} else if (t === "AN" || t === "EN") {
|
|
395
|
+
levels[i] += 2;
|
|
396
|
+
}
|
|
397
|
+
} else if (t === "L" || t === "AN" || t === "EN") {
|
|
398
|
+
levels[i] += 1;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
let highestLevel = -1;
|
|
402
|
+
let lowestOddLevel = 99;
|
|
403
|
+
let level;
|
|
404
|
+
for (i = 0, ii = levels.length; i < ii; ++i) {
|
|
405
|
+
level = levels[i];
|
|
406
|
+
if (highestLevel < level) {
|
|
407
|
+
highestLevel = level;
|
|
408
|
+
}
|
|
409
|
+
if (lowestOddLevel > level && isOdd(level)) {
|
|
410
|
+
lowestOddLevel = level;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
for (level = highestLevel; level >= lowestOddLevel; --level) {
|
|
414
|
+
let start = -1;
|
|
415
|
+
for (i = 0, ii = levels.length; i < ii; ++i) {
|
|
416
|
+
if (levels[i] < level) {
|
|
417
|
+
if (start >= 0) {
|
|
418
|
+
reverseValues(chars, start, i);
|
|
419
|
+
start = -1;
|
|
420
|
+
}
|
|
421
|
+
} else if (start < 0) {
|
|
422
|
+
start = i;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (start >= 0) {
|
|
426
|
+
reverseValues(chars, start, levels.length);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
for (i = 0, ii = chars.length; i < ii; ++i) {
|
|
430
|
+
const ch = chars[i];
|
|
431
|
+
if (ch === "<" || ch === ">") {
|
|
432
|
+
chars[i] = "";
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return createBidiText(chars.join(""), isLTR);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// src/pdf/hayro-meta.ts
|
|
439
|
+
var PDF_DOC_ENCODING = {
|
|
440
|
+
24: 728,
|
|
441
|
+
25: 711,
|
|
442
|
+
26: 710,
|
|
443
|
+
27: 729,
|
|
444
|
+
28: 733,
|
|
445
|
+
29: 731,
|
|
446
|
+
30: 730,
|
|
447
|
+
31: 732,
|
|
448
|
+
128: 8226,
|
|
449
|
+
129: 8224,
|
|
450
|
+
130: 8225,
|
|
451
|
+
131: 8230,
|
|
452
|
+
132: 8212,
|
|
453
|
+
133: 8211,
|
|
454
|
+
134: 402,
|
|
455
|
+
135: 8260,
|
|
456
|
+
136: 8249,
|
|
457
|
+
137: 8250,
|
|
458
|
+
138: 8722,
|
|
459
|
+
139: 8240,
|
|
460
|
+
140: 8222,
|
|
461
|
+
141: 8220,
|
|
462
|
+
142: 8221,
|
|
463
|
+
143: 8216,
|
|
464
|
+
144: 8217,
|
|
465
|
+
145: 8218,
|
|
466
|
+
146: 8482,
|
|
467
|
+
147: 64257,
|
|
468
|
+
148: 64258,
|
|
469
|
+
149: 321,
|
|
470
|
+
150: 338,
|
|
471
|
+
151: 352,
|
|
472
|
+
152: 376,
|
|
473
|
+
153: 381,
|
|
474
|
+
154: 305,
|
|
475
|
+
155: 322,
|
|
476
|
+
156: 339,
|
|
477
|
+
157: 353,
|
|
478
|
+
158: 382,
|
|
479
|
+
160: 8364
|
|
480
|
+
};
|
|
481
|
+
function pdfString(str) {
|
|
482
|
+
if (str[0] >= "\xEF") {
|
|
483
|
+
let encoding;
|
|
484
|
+
if (str[0] === "\xFE" && str[1] === "\xFF") {
|
|
485
|
+
encoding = "utf-16be";
|
|
486
|
+
if (str.length % 2 === 1) str = str.slice(0, -1);
|
|
487
|
+
} else if (str[0] === "\xFF" && str[1] === "\xFE") {
|
|
488
|
+
encoding = "utf-16le";
|
|
489
|
+
if (str.length % 2 === 1) str = str.slice(0, -1);
|
|
490
|
+
} else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") encoding = "utf-8";
|
|
491
|
+
if (encoding) {
|
|
492
|
+
try {
|
|
493
|
+
const decoded = new TextDecoder(encoding, { fatal: true }).decode(Uint8Array.from(str, (c) => c.charCodeAt(0) & 255));
|
|
494
|
+
return decoded.includes("\x1B") ? decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "") : decoded;
|
|
495
|
+
} catch (e2) {
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
let out = "";
|
|
500
|
+
for (let i = 0; i < str.length; i++) {
|
|
501
|
+
const code = str.charCodeAt(i);
|
|
502
|
+
if (code === 27) {
|
|
503
|
+
while (++i < str.length && str.charCodeAt(i) !== 27) {
|
|
504
|
+
}
|
|
154
505
|
continue;
|
|
155
506
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const w = /\/Width\s+(\d+)\b(?!\s+\d+\s+R)/.exec(dict), h = /\/Height\s+(\d+)\b(?!\s+\d+\s+R)/.exec(dict);
|
|
159
|
-
if (!w || !h || Number(w[1]) <= SMALL_IMAGE_DIM && Number(h[1]) <= SMALL_IMAGE_DIM) continue;
|
|
160
|
-
const bpcs = [...dict.matchAll(/\/BitsPerComponent\s+(\d+)\b(?!\s+\d+\s+R)/g)];
|
|
161
|
-
if (bpcs.length !== 1 || (_nullishCoalesce(dict.match(/\/BitsPerComponent\b/g), () => ( []))).length !== 1) continue;
|
|
162
|
-
const bpc = bpcs[0];
|
|
163
|
-
const digits = dictStart + bpc.index + bpc[0].length - bpc[1].length;
|
|
164
|
-
bytes.fill(32, digits, digits + bpc[1].length - 1);
|
|
165
|
-
bytes[digits + bpc[1].length - 1] = 48;
|
|
166
|
-
const data = bytes.subarray(start, stop);
|
|
167
|
-
const raw = _crypto.createHash.call(void 0, "sha1").update(data).digest("hex");
|
|
168
|
-
const shape = dict.replace(/\s+/g, " ").trim();
|
|
169
|
-
blanked.byRaw.set(raw, (_nullishCoalesce(blanked.byRaw.get(raw), () => ( true))) && (_nullishCoalesce(dicts.get(raw), () => ( shape))) === shape);
|
|
170
|
-
blanked.sizes.add(`${w[1]}x${h[1]}`);
|
|
171
|
-
dicts.set(raw, shape);
|
|
172
|
-
data.fill(0);
|
|
173
|
-
}
|
|
174
|
-
return blanked;
|
|
175
|
-
function indirectLengths() {
|
|
176
|
-
const found = /* @__PURE__ */ new Map();
|
|
177
|
-
for (let i = buf.indexOf("obj"); i >= 0; i = buf.indexOf("obj", i + 1)) {
|
|
178
|
-
const num = /(\d+)\s+(\d+)\s+$/.exec(str(i - NEAR, i));
|
|
179
|
-
const value = num && /^\s*(\d+)\s*endobj/.exec(str(i + 3, i + 3 + NEAR));
|
|
180
|
-
if (value) found.set(`${num[1]} ${num[2]}`, Number(value[1]));
|
|
181
|
-
}
|
|
182
|
-
return found;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// src/pdf/pdfium-images.ts
|
|
187
|
-
|
|
188
|
-
var IMAGE_OBJECT = 3;
|
|
189
|
-
var FORM_OBJECT = 5;
|
|
190
|
-
function hasPdfiumFunctions(m) {
|
|
191
|
-
const fns = [
|
|
192
|
-
"_FPDF_LoadPage",
|
|
193
|
-
"_FPDF_ClosePage",
|
|
194
|
-
"_FPDFPage_CountObjects",
|
|
195
|
-
"_FPDFPage_GetObject",
|
|
196
|
-
"_FPDFPageObj_GetType",
|
|
197
|
-
"_FPDFFormObj_CountObjects",
|
|
198
|
-
"_FPDFFormObj_GetObject",
|
|
199
|
-
"_FPDFPage_GetAnnotCount",
|
|
200
|
-
"_FPDFPage_GetAnnot",
|
|
201
|
-
"_FPDFPage_CloseAnnot",
|
|
202
|
-
"_FPDFAnnot_GetObjectCount",
|
|
203
|
-
"_FPDFAnnot_GetObject",
|
|
204
|
-
"_FPDFImageObj_GetImagePixelSize",
|
|
205
|
-
"_FPDFImageObj_GetImageDataRaw",
|
|
206
|
-
"_FPDFImageObj_GetBitmap",
|
|
207
|
-
"_FPDFBitmap_GetBuffer",
|
|
208
|
-
"_FPDFBitmap_GetWidth",
|
|
209
|
-
"_FPDFBitmap_GetHeight",
|
|
210
|
-
"_FPDFBitmap_GetStride",
|
|
211
|
-
"_FPDFBitmap_GetFormat",
|
|
212
|
-
"_FPDFBitmap_Destroy"
|
|
213
|
-
];
|
|
214
|
-
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;
|
|
215
|
-
}
|
|
216
|
-
async function openPdfiumImages(buffer, blanked) {
|
|
217
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("@hyzyla/pdfium"))).catch(() => null);
|
|
218
|
-
if (!mod) return null;
|
|
219
|
-
const lib = await mod.PDFiumLibrary.init().catch(() => null);
|
|
220
|
-
if (!lib) return null;
|
|
221
|
-
const doc = await lib.loadDocument(new Uint8Array(buffer)).catch(() => null);
|
|
222
|
-
if (!doc) {
|
|
223
|
-
lib.destroy();
|
|
224
|
-
return null;
|
|
507
|
+
const mapped = PDF_DOC_ENCODING[code];
|
|
508
|
+
out += mapped ? String.fromCharCode(mapped) : str.charAt(i);
|
|
225
509
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
510
|
+
return out;
|
|
511
|
+
}
|
|
512
|
+
function pdfInfo(doc) {
|
|
513
|
+
const raw = doc.info(), info = {};
|
|
514
|
+
for (const [k, v] of Object.entries(raw)) info[k] = pdfString(v);
|
|
515
|
+
return info;
|
|
516
|
+
}
|
|
517
|
+
function validAbsoluteUrl(url) {
|
|
518
|
+
if (!url) return void 0;
|
|
519
|
+
try {
|
|
520
|
+
if (url.startsWith("www.") && (_nullishCoalesce(_optionalChain([url, 'access', _4 => _4.match, 'call', _5 => _5(/\./g), 'optionalAccess', _6 => _6.length]), () => ( 0))) >= 2) url = `http://${url}`;
|
|
521
|
+
try {
|
|
522
|
+
url = decodeURIComponent(escape(url));
|
|
523
|
+
} catch (e3) {
|
|
524
|
+
}
|
|
525
|
+
const u = new URL(url);
|
|
526
|
+
if (["http:", "https:", "ftp:", "mailto:", "tel:"].includes(u.protocol)) return u.href;
|
|
527
|
+
} catch (e4) {
|
|
528
|
+
}
|
|
529
|
+
return void 0;
|
|
530
|
+
}
|
|
531
|
+
function jsUrl(js) {
|
|
532
|
+
return _optionalChain([/^\s*(app\.launchURL|window\.open|xfa\.host\.gotoURL)\((?:'|")([^'"]*)(?:'|")(?:,\s*(\w+)\)|\))/i, 'access', _7 => _7.exec, 'call', _8 => _8(js), 'optionalAccess', _9 => _9[2]]) || void 0;
|
|
533
|
+
}
|
|
534
|
+
function pdfLinkAnnotations(doc, page) {
|
|
535
|
+
return doc.links(page).map((l) => {
|
|
536
|
+
let url;
|
|
537
|
+
if (l.uri !== void 0) url = l.uri;
|
|
538
|
+
else if (l.file !== void 0 || l.filespec !== void 0) {
|
|
539
|
+
const file = _nullishCoalesce(l.file, () => ( pdfString(l.filespec).replaceAll("\\\\", "\\").replaceAll("\\/", "/").replaceAll("\\", "/")));
|
|
540
|
+
url = l.dest !== void 0 ? file.split("#", 1)[0] + "#" + pdfString(l.dest) : file;
|
|
541
|
+
} else if (l.js !== void 0) url = jsUrl(pdfString(l.js));
|
|
542
|
+
return { subtype: "Link", rect: l.rect, url: url === void 0 ? void 0 : validAbsoluteUrl(url) };
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// src/pdf/hayro-text.ts
|
|
547
|
+
var EV = {
|
|
548
|
+
GLYPH: 1,
|
|
549
|
+
SAVE: 2,
|
|
550
|
+
RESTORE: 3,
|
|
551
|
+
BEGIN_TEXT: 4,
|
|
552
|
+
END_TEXT: 5,
|
|
553
|
+
FONT: 6,
|
|
554
|
+
XOBJECT: 7,
|
|
555
|
+
MARK_BEGIN: 8,
|
|
556
|
+
MARK_END: 9,
|
|
557
|
+
CLIP_PUSH: 10,
|
|
558
|
+
CLIP_POP: 11,
|
|
559
|
+
RUN_END: 12,
|
|
560
|
+
TEXT_MATRIX: 13,
|
|
561
|
+
PATH: 20,
|
|
562
|
+
IMAGE: 21,
|
|
563
|
+
FORM_BEGIN: 22,
|
|
564
|
+
FORM_END: 23,
|
|
565
|
+
FONT_KEY: 24,
|
|
566
|
+
/** ExtGState /SMask 그룹의 내용 — pdfjs 는 연산자 목록에만 끼워 넣고 글 추출은 들여다보지 않는다 */
|
|
567
|
+
SMASK_BEGIN: 25,
|
|
568
|
+
SMASK_END: 26,
|
|
569
|
+
/** Tz(가로 비율, 퍼센트) */
|
|
570
|
+
HSCALE: 27,
|
|
571
|
+
/** w(선 굵기) */
|
|
572
|
+
LINE_WIDTH: 28,
|
|
573
|
+
/** 연산자 목록의 CTM 에 곱할 행렬(주석 appearance 앞뒤) */
|
|
574
|
+
CTM: 29
|
|
575
|
+
};
|
|
576
|
+
var { GLYPH, SAVE, RESTORE, FONT, XOBJECT, MARK_BEGIN, MARK_END } = EV;
|
|
577
|
+
var FIXED = { 1: 32, 6: 4, 7: 2, 8: 4, 21: 11, 22: 11, 24: 2, 27: 2, 28: 2, 29: 7 };
|
|
578
|
+
function pathLength(ev, at) {
|
|
579
|
+
const n = ev[at];
|
|
580
|
+
if (n === -1) return 5;
|
|
581
|
+
let k = at + 1;
|
|
582
|
+
for (let s = 0; s < n; s++) {
|
|
583
|
+
const op = ev[k];
|
|
584
|
+
k += op === 0 || op === 1 || op === 5 ? 3 : op === 2 ? 5 : op === 3 ? 7 : 1;
|
|
585
|
+
}
|
|
586
|
+
return k - at;
|
|
587
|
+
}
|
|
588
|
+
function eventLength(ev, i) {
|
|
589
|
+
const t = ev[i];
|
|
590
|
+
if (t === EV.PATH) return 13 + pathLength(ev, i + 13);
|
|
591
|
+
if (t === EV.CLIP_PUSH) return 2 + pathLength(ev, i + 2);
|
|
592
|
+
return _nullishCoalesce(FIXED[t], () => ( 1));
|
|
593
|
+
}
|
|
594
|
+
var TRACKING = 0.102;
|
|
595
|
+
var NOT_A_SPACE = 0.03;
|
|
596
|
+
var NEGATIVE = -0.2;
|
|
597
|
+
var IN_FLOW_MIN = 0.102;
|
|
598
|
+
var IN_FLOW_MAX = 0.6;
|
|
599
|
+
var VERTICAL_SHIFT = 0.25;
|
|
600
|
+
var SPECIAL_CHAR = /^(\s)|(\p{Mn})|(\p{Cf})$/u;
|
|
601
|
+
var isPrivateUse = (cp) => cp >= 57344 && cp <= 63743;
|
|
602
|
+
function applyActualText(ev, strs) {
|
|
603
|
+
const open = [];
|
|
604
|
+
const actual = [];
|
|
605
|
+
for (let i = 0; i < ev.length; i += eventLength(ev, i)) {
|
|
606
|
+
const t = ev[i];
|
|
607
|
+
if (t === MARK_BEGIN) {
|
|
608
|
+
const o = ev[i + 3] ? { text: pdfString(_nullishCoalesce(strs[ev[i + 3] - 1], () => ( ""))), glyphs: [], nested: false } : null;
|
|
609
|
+
if (o) {
|
|
610
|
+
const outer = actual[actual.length - 1];
|
|
611
|
+
if (outer) outer.nested = true;
|
|
612
|
+
actual.push(o);
|
|
613
|
+
}
|
|
614
|
+
open.push(o);
|
|
615
|
+
} else if (t === GLYPH) _optionalChain([actual, 'access', _10 => _10[actual.length - 1], 'optionalAccess', _11 => _11.glyphs, 'access', _12 => _12.push, 'call', _13 => _13(i)]);
|
|
616
|
+
else if (t === MARK_END) {
|
|
617
|
+
const o = open.pop();
|
|
618
|
+
if (!o) continue;
|
|
619
|
+
actual.pop();
|
|
620
|
+
if (o.nested || !o.text || !o.glyphs.length || !o.glyphs.every((g) => isPrivateUse(ev[g + 1]))) continue;
|
|
621
|
+
const chars2 = [...o.text];
|
|
622
|
+
const whole = chars2.length !== o.glyphs.length;
|
|
623
|
+
o.glyphs.forEach((g, k) => {
|
|
624
|
+
const s = whole ? k ? "" : o.text : chars2[k];
|
|
625
|
+
strs.push(s);
|
|
626
|
+
ev[g + 1] = -strs.length;
|
|
627
|
+
});
|
|
628
|
+
}
|
|
232
629
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
630
|
+
}
|
|
631
|
+
function hayroTextPage(doc, pageNumber) {
|
|
632
|
+
const { events, strings } = doc.events(pageNumber - 1);
|
|
633
|
+
applyActualText(events, strings);
|
|
634
|
+
return { ...buildItems(events, strings, doc.pageView(pageNumber - 1)), events, strings };
|
|
635
|
+
}
|
|
636
|
+
function hayroFontInfo(doc, key) {
|
|
637
|
+
const raw = doc.fontInfo(key);
|
|
638
|
+
return raw ? JSON.parse(raw) : null;
|
|
639
|
+
}
|
|
640
|
+
var freshTci = () => ({ prev: null, width: 0, totalWidth: 0, scale: 0, height: 0, fs: 0, fontName: "" });
|
|
641
|
+
function unrotate(x, y, m, lx, ly, pm) {
|
|
642
|
+
if (m[0] && m[1] === 0 && m[2] === 0) return m[0] > 0 ? [x, y, lx, ly] : [-x, -y, -lx, -ly];
|
|
643
|
+
if (m[1] && m[0] === 0 && m[3] === 0) return m[1] > 0 ? [y, x, ly, lx] : [-y, -x, -ly, -lx];
|
|
644
|
+
const inv = (u, v, k) => {
|
|
645
|
+
const s = Math.hypot(k[0], k[1]);
|
|
646
|
+
return [(k[0] * u + k[1] * v) / s, (k[2] * u + k[3] * v) / s];
|
|
647
|
+
};
|
|
648
|
+
return [...inv(x, y, m), ...inv(lx, ly, pm)];
|
|
649
|
+
}
|
|
650
|
+
var PJ = 16;
|
|
651
|
+
function buildItems(ev, strs, view) {
|
|
652
|
+
const items = [];
|
|
653
|
+
const fonts = [];
|
|
654
|
+
const fontNames = /* @__PURE__ */ new Map();
|
|
655
|
+
let font = null, res = null, size = 0;
|
|
656
|
+
const stack = [];
|
|
657
|
+
let item = null;
|
|
658
|
+
let tci = freshTci();
|
|
659
|
+
const last = [" ", " "];
|
|
660
|
+
let lastPos = 0;
|
|
661
|
+
const saveLastChar = (c) => {
|
|
662
|
+
const next = (lastPos + 1) % 2;
|
|
663
|
+
const r = last[lastPos] !== " " && last[next] === " ";
|
|
664
|
+
last[lastPos] = c;
|
|
665
|
+
lastPos = next;
|
|
666
|
+
return r;
|
|
239
667
|
};
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
m.wasmExports.free(p);
|
|
245
|
-
return size;
|
|
668
|
+
const shouldAddWhitespace = () => last[lastPos] !== " " && last[(lastPos + 1) % 2] === " ";
|
|
669
|
+
const resetLastChars = () => {
|
|
670
|
+
last[0] = last[1] = " ";
|
|
671
|
+
lastPos = 0;
|
|
246
672
|
};
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return hash;
|
|
673
|
+
const flush = (eol2 = false) => {
|
|
674
|
+
if (!item) return;
|
|
675
|
+
tci.totalWidth += tci.width * tci.scale;
|
|
676
|
+
const it = { str: bidi(_chunkFG3SD2G3cjs.normalizeUnicode.call(void 0, item.str.join(""))).str, transform: item.t, width: tci.totalWidth, height: tci.height, fontName: item.fontName };
|
|
677
|
+
if (eol2) it.hasEOL = true;
|
|
678
|
+
items.push(it);
|
|
679
|
+
item = null;
|
|
255
680
|
};
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
681
|
+
const eol = (t) => {
|
|
682
|
+
resetLastChars();
|
|
683
|
+
if (item) flush(true);
|
|
684
|
+
else items.push({ str: "", transform: t, width: 0, height: 0, fontName: _nullishCoalesce(font, () => ( "")), hasEOL: true });
|
|
685
|
+
};
|
|
686
|
+
const pushWhitespace = (width) => {
|
|
687
|
+
items.push({ str: " ", transform: tci.prev, width, height: 0, fontName: tci.fontName });
|
|
688
|
+
};
|
|
689
|
+
let maskDepth = 0, tmLive = false;
|
|
690
|
+
const tciStack = [];
|
|
691
|
+
for (let i = 0; i < ev.length; i += eventLength(ev, i)) {
|
|
692
|
+
const type = ev[i];
|
|
693
|
+
if (type === EV.SMASK_BEGIN) {
|
|
694
|
+
maskDepth++;
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
697
|
+
if (type === EV.SMASK_END) {
|
|
698
|
+
maskDepth--;
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
if (maskDepth) continue;
|
|
702
|
+
if (type === EV.TEXT_MATRIX) {
|
|
703
|
+
if (item) tmLive = true;
|
|
704
|
+
} else if (type === SAVE) stack.push([font, res, size]);
|
|
705
|
+
else if (type === RESTORE) {
|
|
706
|
+
const [f, r, s] = _nullishCoalesce(stack.pop(), () => ( [null, null, 0]));
|
|
707
|
+
if (f !== font || s !== size || r !== res) flush();
|
|
708
|
+
font = f;
|
|
709
|
+
res = r;
|
|
710
|
+
size = s;
|
|
711
|
+
} else if (type === FONT) {
|
|
712
|
+
const name = _nullishCoalesce(strs[ev[i + 1]], () => ( "")), s = ev[i + 2];
|
|
713
|
+
const key = `hy_${name}`;
|
|
714
|
+
fonts.push(key);
|
|
715
|
+
if (!fontNames.has(key)) fontNames.set(key, _nullishCoalesce(strs[ev[i + 3]], () => ( "")));
|
|
716
|
+
if (font && res === name && size === s) continue;
|
|
717
|
+
flush();
|
|
718
|
+
font = key;
|
|
719
|
+
res = name;
|
|
720
|
+
size = s;
|
|
721
|
+
} else if (type === EV.FONT_KEY) {
|
|
722
|
+
const key = _nullishCoalesce(strs[ev[i + 1]], () => ( ""));
|
|
723
|
+
const prevKey = fonts[fonts.length - 1];
|
|
724
|
+
if (key && prevKey !== void 0) {
|
|
725
|
+
if (!fontNames.has(key)) fontNames.set(key, _nullishCoalesce(fontNames.get(prevKey), () => ( "")));
|
|
726
|
+
fonts[fonts.length - 1] = key;
|
|
727
|
+
if (font === prevKey) font = key;
|
|
728
|
+
if (_optionalChain([item, 'optionalAccess', _14 => _14.fontName]) === prevKey) {
|
|
729
|
+
item.fontName = key;
|
|
730
|
+
tci.fontName = key;
|
|
273
731
|
}
|
|
274
|
-
};
|
|
275
|
-
walk(m._FPDFPage_CountObjects(page), (i) => m._FPDFPage_GetObject(page, i), 0);
|
|
276
|
-
for (let i = 0; i < m._FPDFPage_GetAnnotCount(page); i++) {
|
|
277
|
-
const annot = m._FPDFPage_GetAnnot(page, i);
|
|
278
|
-
if (!annot) continue;
|
|
279
|
-
open.annots.push(annot);
|
|
280
|
-
walk(m._FPDFAnnot_GetObjectCount(annot), (j) => m._FPDFAnnot_GetObject(annot, j), 0);
|
|
281
732
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
733
|
+
} else if (type === XOBJECT || type === MARK_BEGIN || type === MARK_END) flush();
|
|
734
|
+
else if (type === EV.FORM_BEGIN) {
|
|
735
|
+
flush();
|
|
736
|
+
resetLastChars();
|
|
737
|
+
tciStack.push(tci);
|
|
738
|
+
tci = freshTci();
|
|
739
|
+
} else if (type === EV.FORM_END) {
|
|
740
|
+
flush();
|
|
741
|
+
resetLastChars();
|
|
742
|
+
tci = _nullishCoalesce(tciStack.pop(), () => ( freshTci()));
|
|
743
|
+
} else if (type === GLYPH) {
|
|
744
|
+
const cp = ev[i + 1];
|
|
745
|
+
const u = cp === 1114112 ? "\0" : cp > 0 ? String.fromCodePoint(cp) : cp < 0 ? _nullishCoalesce(strs[-cp - 1], () => ( "")) : String.fromCharCode(ev[i + 2]);
|
|
746
|
+
const t = [ev[i + PJ], ev[i + PJ + 1], ev[i + PJ + 2], ev[i + PJ + 3], ev[i + PJ + 4], ev[i + PJ + 5]];
|
|
747
|
+
const x = t[4], y = t[5], endX = ev[i + PJ + 6], endY = ev[i + PJ + 7];
|
|
748
|
+
const fs = ev[i + PJ + 12], sd = ev[i + PJ + 13], sdx = ev[i + PJ + 14];
|
|
749
|
+
const scale = () => Math.hypot(ev[i + PJ + 8], ev[i + PJ + 9]) * Math.hypot(ev[i + PJ + 10], ev[i + PJ + 11]);
|
|
750
|
+
if (tmLive) {
|
|
751
|
+
const sc = scale();
|
|
752
|
+
if (sc !== tci.scale) {
|
|
753
|
+
tci.totalWidth += tci.width * tci.scale;
|
|
754
|
+
tci.width = 0;
|
|
755
|
+
tci.scale = sc;
|
|
756
|
+
}
|
|
757
|
+
tmLive = false;
|
|
758
|
+
}
|
|
759
|
+
const cat = SPECIAL_CHAR.exec(u);
|
|
760
|
+
if (!u || _optionalChain([cat, 'optionalAccess', _15 => _15[1]])) {
|
|
761
|
+
saveLastChar(" ");
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
if (_optionalChain([cat, 'optionalAccess', _16 => _16[3]])) continue;
|
|
765
|
+
const diacritic = !!_optionalChain([cat, 'optionalAccess', _17 => _17[2]]);
|
|
766
|
+
if (!diacritic && view.length === 4 && (x + sd < view[0] || x > view[2] || y < view[1] || y > view[3])) continue;
|
|
767
|
+
const prev = tci.prev;
|
|
768
|
+
if (!diacritic && prev && (x !== prev[4] || y !== prev[5])) {
|
|
769
|
+
const [px, py, lx, ly] = unrotate(x, y, t, prev[4], prev[5], prev);
|
|
770
|
+
const advanceX = (px - lx) / tci.scale, advanceY = Math.abs(py - ly);
|
|
771
|
+
const o = Math.sign(tci.width), f = tci.fs;
|
|
772
|
+
if (advanceX < o * (f * NEGATIVE)) {
|
|
773
|
+
if (advanceY > 0.5 * tci.height) eol(t);
|
|
774
|
+
else {
|
|
775
|
+
resetLastChars();
|
|
776
|
+
flush();
|
|
777
|
+
}
|
|
778
|
+
} else if (advanceY > tci.height) eol(t);
|
|
779
|
+
else {
|
|
780
|
+
if (advanceX <= o * (f * NOT_A_SPACE)) resetLastChars();
|
|
781
|
+
if (advanceX <= o * (f * TRACKING)) {
|
|
782
|
+
if (shouldAddWhitespace()) {
|
|
783
|
+
resetLastChars();
|
|
784
|
+
flush();
|
|
785
|
+
pushWhitespace(Math.abs(advanceX));
|
|
786
|
+
} else tci.width += advanceX;
|
|
787
|
+
} else if (o * (f * IN_FLOW_MIN) <= advanceX && advanceX <= o * (f * IN_FLOW_MAX)) {
|
|
788
|
+
if (item) {
|
|
789
|
+
resetLastChars();
|
|
790
|
+
item.str.push(" ");
|
|
300
791
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
792
|
+
if (!item) {
|
|
793
|
+
resetLastChars();
|
|
794
|
+
pushWhitespace(Math.abs(advanceX));
|
|
795
|
+
} else tci.width += advanceX;
|
|
796
|
+
} else {
|
|
797
|
+
flush();
|
|
798
|
+
resetLastChars();
|
|
799
|
+
pushWhitespace(Math.abs(advanceX));
|
|
305
800
|
}
|
|
801
|
+
if (advanceY > tci.height * VERTICAL_SHIFT) flush();
|
|
306
802
|
}
|
|
307
|
-
return rgba;
|
|
308
|
-
} finally {
|
|
309
|
-
m._FPDFBitmap_Destroy(bitmap);
|
|
310
803
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
804
|
+
if (!item) {
|
|
805
|
+
item = { str: [], t, fontName: _nullishCoalesce(font, () => ( "")) };
|
|
806
|
+
tci.fontName = item.fontName;
|
|
807
|
+
tci.width = tci.totalWidth = 0;
|
|
808
|
+
tci.height = Math.hypot(t[2], t[3]);
|
|
809
|
+
tci.scale = scale();
|
|
810
|
+
tci.fs = fs;
|
|
811
|
+
}
|
|
812
|
+
tci.width += sdx;
|
|
813
|
+
if (sdx) tci.prev = [t[0], t[1], t[2], t[3], endX, endY];
|
|
814
|
+
if (saveLastChar(u)) item.str.push(" ");
|
|
815
|
+
item.str.push(u);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
flush();
|
|
819
|
+
return { items, fonts, fontNames };
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// src/pdf/hayro-ops.ts
|
|
823
|
+
var UNITS_PER_EM = 1e3;
|
|
824
|
+
function pathArgs(ev, at) {
|
|
825
|
+
const n = ev[at];
|
|
826
|
+
if (n === -1) return [[_chunkFG3SD2G3cjs.OPS.rectangle], [ev[at + 1], ev[at + 2], ev[at + 3], ev[at + 4]]];
|
|
827
|
+
const ops = [], coords = [];
|
|
828
|
+
let k = at + 1;
|
|
829
|
+
for (let s = 0; s < n; s++) {
|
|
830
|
+
const op = ev[k++];
|
|
831
|
+
if (op === 5 && s + 4 < n) {
|
|
832
|
+
ops.push(_chunkFG3SD2G3cjs.OPS.rectangle);
|
|
833
|
+
coords.push(ev[k], ev[k + 1], ev[k + 3] - ev[k], ev[k + 7] - ev[k + 1]);
|
|
834
|
+
k += 12;
|
|
835
|
+
s += 4;
|
|
836
|
+
continue;
|
|
316
837
|
}
|
|
838
|
+
if (op === 0 || op === 5) {
|
|
839
|
+
ops.push(_chunkFG3SD2G3cjs.OPS.moveTo);
|
|
840
|
+
coords.push(ev[k++], ev[k++]);
|
|
841
|
+
} else if (op === 1) {
|
|
842
|
+
ops.push(_chunkFG3SD2G3cjs.OPS.lineTo);
|
|
843
|
+
coords.push(ev[k++], ev[k++]);
|
|
844
|
+
} else if (op === 2) {
|
|
845
|
+
const cx = ev[k++], cy = ev[k++], x = ev[k++], y = ev[k++];
|
|
846
|
+
const px = coords.length >= 2 ? coords[coords.length - 2] : x, py = coords.length >= 2 ? coords[coords.length - 1] : y;
|
|
847
|
+
ops.push(_chunkFG3SD2G3cjs.OPS.curveTo);
|
|
848
|
+
coords.push(px + 2 / 3 * (cx - px), py + 2 / 3 * (cy - py), x + 2 / 3 * (cx - x), y + 2 / 3 * (cy - y), x, y);
|
|
849
|
+
} else if (op === 3) {
|
|
850
|
+
ops.push(_chunkFG3SD2G3cjs.OPS.curveTo);
|
|
851
|
+
coords.push(ev[k++], ev[k++], ev[k++], ev[k++], ev[k++], ev[k++]);
|
|
852
|
+
} else ops.push(_chunkFG3SD2G3cjs.OPS.closePath);
|
|
853
|
+
}
|
|
854
|
+
return [ops, coords];
|
|
855
|
+
}
|
|
856
|
+
var PAINT = { 1: _chunkFG3SD2G3cjs.OPS.fill, 2: _chunkFG3SD2G3cjs.OPS.eoFill, 3: _chunkFG3SD2G3cjs.OPS.stroke, 4: _chunkFG3SD2G3cjs.OPS.fillStroke, 5: _chunkFG3SD2G3cjs.OPS.eoFillStroke };
|
|
857
|
+
function hayroOps(ev, strs) {
|
|
858
|
+
const fnArray = [], argsArray = [];
|
|
859
|
+
const push = (fn, args) => {
|
|
860
|
+
fnArray.push(fn);
|
|
861
|
+
argsArray.push(args);
|
|
317
862
|
};
|
|
863
|
+
let font = "", size = 0;
|
|
864
|
+
const stack = [];
|
|
865
|
+
let pendingTm = false;
|
|
866
|
+
let run = [];
|
|
867
|
+
let runTm = null;
|
|
868
|
+
for (let i = 0; i < ev.length; i += eventLength(ev, i)) {
|
|
869
|
+
const t = ev[i];
|
|
870
|
+
switch (t) {
|
|
871
|
+
case EV.SAVE:
|
|
872
|
+
stack.push([font, size]);
|
|
873
|
+
push(_chunkFG3SD2G3cjs.OPS.save, []);
|
|
874
|
+
break;
|
|
875
|
+
case EV.RESTORE: {
|
|
876
|
+
const s = stack.pop();
|
|
877
|
+
if (s) [font, size] = s;
|
|
878
|
+
push(_chunkFG3SD2G3cjs.OPS.restore, []);
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
case EV.BEGIN_TEXT:
|
|
882
|
+
push(_chunkFG3SD2G3cjs.OPS.beginText, []);
|
|
883
|
+
break;
|
|
884
|
+
case EV.END_TEXT:
|
|
885
|
+
push(_chunkFG3SD2G3cjs.OPS.endText, []);
|
|
886
|
+
break;
|
|
887
|
+
case EV.FONT:
|
|
888
|
+
font = `hy_${_nullishCoalesce(strs[ev[i + 1]], () => ( ""))}`;
|
|
889
|
+
size = ev[i + 2];
|
|
890
|
+
push(_chunkFG3SD2G3cjs.OPS.setFont, [font, size]);
|
|
891
|
+
break;
|
|
892
|
+
case EV.FONT_KEY: {
|
|
893
|
+
const key = _nullishCoalesce(strs[ev[i + 1]], () => ( ""));
|
|
894
|
+
if (key && fnArray[fnArray.length - 1] === _chunkFG3SD2G3cjs.OPS.setFont) {
|
|
895
|
+
argsArray[argsArray.length - 1][0] = key;
|
|
896
|
+
font = key;
|
|
897
|
+
}
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
900
|
+
case EV.TEXT_MATRIX:
|
|
901
|
+
pendingTm = true;
|
|
902
|
+
break;
|
|
903
|
+
case EV.GLYPH: {
|
|
904
|
+
const cp = ev[i + 1], code = ev[i + 2];
|
|
905
|
+
const unicode = cp === 1114112 ? "\0" : cp > 0 ? String.fromCodePoint(cp) : cp < 0 ? _nullishCoalesce(strs[-cp - 1], () => ( "")) : String.fromCharCode(code);
|
|
906
|
+
if (!run.length && pendingTm) {
|
|
907
|
+
const k = size ? UNITS_PER_EM / size : UNITS_PER_EM;
|
|
908
|
+
runTm = [ev[i + 3] * k, ev[i + 4] * k, ev[i + 5] * k, ev[i + 6] * k, ev[i + 7], ev[i + 8]];
|
|
909
|
+
}
|
|
910
|
+
const gid = ev[i + 14];
|
|
911
|
+
if (run.length && ev[i + 31]) run.push(ev[i + 31]);
|
|
912
|
+
run.push({ unicode, originalCharCode: code, fontChar: String.fromCodePoint(57344 + gid), width: ev[i + 15], isSpace: unicode === " " });
|
|
913
|
+
break;
|
|
914
|
+
}
|
|
915
|
+
case EV.RUN_END:
|
|
916
|
+
if (runTm) push(_chunkFG3SD2G3cjs.OPS.setTextMatrix, runTm);
|
|
917
|
+
if (run.length) push(_chunkFG3SD2G3cjs.OPS.showText, [run]);
|
|
918
|
+
run = [];
|
|
919
|
+
runTm = null;
|
|
920
|
+
pendingTm = false;
|
|
921
|
+
break;
|
|
922
|
+
// 선 굵기는 pdf.js 처럼 콘텐츠의 w 자리에 낸다 — 선 판정은 q/Q 와 무관하게 직전 w 를 채움 괘선에도 쓴다
|
|
923
|
+
case EV.LINE_WIDTH:
|
|
924
|
+
push(_chunkFG3SD2G3cjs.OPS.setLineWidth, [ev[i + 1]]);
|
|
925
|
+
break;
|
|
926
|
+
case EV.CTM:
|
|
927
|
+
push(_chunkFG3SD2G3cjs.OPS.transform, [ev[i + 1], ev[i + 2], ev[i + 3], ev[i + 4], ev[i + 5], ev[i + 6]]);
|
|
928
|
+
break;
|
|
929
|
+
case EV.PATH: {
|
|
930
|
+
const code = ev[i + 1];
|
|
931
|
+
if (code === 6) {
|
|
932
|
+
const at = fnArray.length - 3, c = ev[i + 2], a2 = ev[i + 5] / 255;
|
|
933
|
+
const extra = [];
|
|
934
|
+
if (c >= 0) extra.push([_chunkFG3SD2G3cjs.OPS.setStrokeRGBColor, [c, ev[i + 3], ev[i + 4]]]);
|
|
935
|
+
if (a2 < 1) extra.push([_chunkFG3SD2G3cjs.OPS.setGState, [[["CA", a2]]]]);
|
|
936
|
+
fnArray.splice(at, 0, ...extra.map((e) => e[0]));
|
|
937
|
+
argsArray.splice(at, 0, ...extra.map((e) => e[1]));
|
|
938
|
+
fnArray[fnArray.length - 2] = fnArray[fnArray.length - 2] === _chunkFG3SD2G3cjs.OPS.eoFill ? _chunkFG3SD2G3cjs.OPS.eoFillStroke : _chunkFG3SD2G3cjs.OPS.fillStroke;
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
push(_chunkFG3SD2G3cjs.OPS.save, []);
|
|
942
|
+
push(_chunkFG3SD2G3cjs.OPS.transform, [ev[i + 7], ev[i + 8], ev[i + 9], ev[i + 10], ev[i + 11], ev[i + 12]]);
|
|
943
|
+
const r = ev[i + 2], g = ev[i + 3], b = ev[i + 4], a = ev[i + 5] / 255;
|
|
944
|
+
const fills = code !== 3, strokes = code >= 3;
|
|
945
|
+
if (r >= 0) {
|
|
946
|
+
if (fills) push(_chunkFG3SD2G3cjs.OPS.setFillRGBColor, [r, g, b]);
|
|
947
|
+
if (strokes) push(_chunkFG3SD2G3cjs.OPS.setStrokeRGBColor, [r, g, b]);
|
|
948
|
+
}
|
|
949
|
+
if (a < 1) push(_chunkFG3SD2G3cjs.OPS.setGState, [[...fills ? [["ca", a]] : [], ...strokes ? [["CA", a]] : []]]);
|
|
950
|
+
push(_chunkFG3SD2G3cjs.OPS.constructPath, [...pathArgs(ev, i + 13), null]);
|
|
951
|
+
push(_nullishCoalesce(PAINT[code], () => ( _chunkFG3SD2G3cjs.OPS.endPath)), []);
|
|
952
|
+
push(_chunkFG3SD2G3cjs.OPS.restore, []);
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
955
|
+
case EV.CLIP_PUSH:
|
|
956
|
+
push(_chunkFG3SD2G3cjs.OPS.constructPath, [...pathArgs(ev, i + 2), null]);
|
|
957
|
+
push(ev[i + 1] === 1 ? _chunkFG3SD2G3cjs.OPS.eoClip : _chunkFG3SD2G3cjs.OPS.clip, []);
|
|
958
|
+
push(_chunkFG3SD2G3cjs.OPS.endPath, []);
|
|
959
|
+
break;
|
|
960
|
+
case EV.IMAGE: {
|
|
961
|
+
const w = ev[i + 1], h = ev[i + 2], a = ev[i + 3], b = ev[i + 4], c = ev[i + 5], d = ev[i + 6];
|
|
962
|
+
push(_chunkFG3SD2G3cjs.OPS.save, []);
|
|
963
|
+
push(_chunkFG3SD2G3cjs.OPS.transform, [a * w, b * w, -c * h, -d * h, ev[i + 7] + c * h, ev[i + 8] + d * h]);
|
|
964
|
+
push(ev[i + 9] === 1 ? _chunkFG3SD2G3cjs.OPS.paintImageMaskXObject : _chunkFG3SD2G3cjs.OPS.paintImageXObject, [strs[ev[i + 10]] || null, ev[i + 1], ev[i + 2]]);
|
|
965
|
+
push(_chunkFG3SD2G3cjs.OPS.restore, []);
|
|
966
|
+
break;
|
|
967
|
+
}
|
|
968
|
+
case EV.FORM_BEGIN: {
|
|
969
|
+
const m = [ev[i + 1], ev[i + 2], ev[i + 3], ev[i + 4], ev[i + 5], ev[i + 6]];
|
|
970
|
+
const [x0, y0, x1, y1] = [ev[i + 7], ev[i + 8], ev[i + 9], ev[i + 10]];
|
|
971
|
+
const xs = [], ys = [];
|
|
972
|
+
for (const [px, py] of [[x0, y0], [x1, y0], [x0, y1], [x1, y1]]) {
|
|
973
|
+
xs.push(m[0] * px + m[2] * py + m[4]);
|
|
974
|
+
ys.push(m[1] * px + m[3] * py + m[5]);
|
|
975
|
+
}
|
|
976
|
+
push(_chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin, [[1, 0, 0, 1, 0, 0], [Math.min(...xs), Math.min(...ys), Math.max(...xs), Math.max(...ys)]]);
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
case EV.FORM_END:
|
|
980
|
+
push(_chunkFG3SD2G3cjs.OPS.paintFormXObjectEnd, []);
|
|
981
|
+
break;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
return { fnArray, argsArray };
|
|
985
|
+
}
|
|
986
|
+
function hayroFontData(file) {
|
|
987
|
+
if (file.length < 12) return void 0;
|
|
988
|
+
const dv = new DataView(file.buffer, file.byteOffset, file.byteLength);
|
|
989
|
+
const n = dv.getUint16(4);
|
|
990
|
+
const tables = /* @__PURE__ */ new Map();
|
|
991
|
+
for (let i = 0; i < n && 12 + 16 * i + 16 <= file.length; i++) {
|
|
992
|
+
const r = 12 + 16 * i;
|
|
993
|
+
tables.set(String.fromCharCode(file[r], file[r + 1], file[r + 2], file[r + 3]), [dv.getUint32(r + 8), dv.getUint32(r + 12)]);
|
|
994
|
+
}
|
|
995
|
+
const keep = ["head", "loca", "glyf", "maxp"].filter((t) => tables.has(t));
|
|
996
|
+
if (!["head", "loca", "glyf"].every((t) => tables.has(t))) return void 0;
|
|
997
|
+
const maxp = tables.get("maxp"), numGlyphs = maxp ? dv.getUint16(maxp[0] + 4) : 65535;
|
|
998
|
+
const cmap = new Uint8Array(12 + 16 + 12);
|
|
999
|
+
const cv = new DataView(cmap.buffer);
|
|
1000
|
+
cv.setUint16(2, 1);
|
|
1001
|
+
cv.setUint16(4, 3);
|
|
1002
|
+
cv.setUint16(6, 10);
|
|
1003
|
+
cv.setUint32(8, 12);
|
|
1004
|
+
cv.setUint16(12, 12);
|
|
1005
|
+
cv.setUint32(16, 16 + 12);
|
|
1006
|
+
cv.setUint32(24, 1);
|
|
1007
|
+
cv.setUint32(28, 57344);
|
|
1008
|
+
cv.setUint32(32, 57344 + Math.max(0, numGlyphs - 1));
|
|
1009
|
+
cv.setUint32(36, 0);
|
|
1010
|
+
const names = ["cmap", ...keep];
|
|
1011
|
+
const blobs = [cmap, ...keep.map((t) => {
|
|
1012
|
+
const [o, l] = tables.get(t);
|
|
1013
|
+
return file.subarray(o, o + l);
|
|
1014
|
+
})];
|
|
1015
|
+
let off = 12 + 16 * names.length;
|
|
1016
|
+
const offsets = blobs.map((b) => {
|
|
1017
|
+
const o = off;
|
|
1018
|
+
off += b.length + 3 & ~3;
|
|
1019
|
+
return o;
|
|
1020
|
+
});
|
|
1021
|
+
const out = new Uint8Array(off), ov = new DataView(out.buffer);
|
|
1022
|
+
ov.setUint32(0, 65536);
|
|
1023
|
+
ov.setUint16(4, names.length);
|
|
1024
|
+
names.forEach((t, k) => {
|
|
1025
|
+
const r = 12 + 16 * k;
|
|
1026
|
+
for (let c = 0; c < 4; c++) out[r + c] = t.charCodeAt(c);
|
|
1027
|
+
ov.setUint32(r + 8, offsets[k]);
|
|
1028
|
+
ov.setUint32(r + 12, blobs[k].length);
|
|
1029
|
+
out.set(blobs[k], offsets[k]);
|
|
1030
|
+
});
|
|
1031
|
+
return out;
|
|
318
1032
|
}
|
|
319
1033
|
|
|
320
1034
|
// src/pdf/image-extract.ts
|
|
321
|
-
|
|
322
|
-
var _pdfmjs = require('pdfjs-dist/legacy/build/pdf.mjs');
|
|
1035
|
+
var _crypto = require('crypto');
|
|
323
1036
|
var IMAGE_RESOLVE_TIMEOUT_MS = 5e3;
|
|
324
1037
|
function resolveImgData(page, objId) {
|
|
325
1038
|
const store = objId.startsWith("g_") ? page.commonObjs : page.objs;
|
|
@@ -339,7 +1052,7 @@ function resolveImgData(page, objId) {
|
|
|
339
1052
|
resolve(_nullishCoalesce(data, () => ( null)));
|
|
340
1053
|
}
|
|
341
1054
|
});
|
|
342
|
-
} catch (
|
|
1055
|
+
} catch (e5) {
|
|
343
1056
|
if (!done) {
|
|
344
1057
|
done = true;
|
|
345
1058
|
clearTimeout(timer);
|
|
@@ -353,8 +1066,8 @@ var MAX_PIXELS = 36e6;
|
|
|
353
1066
|
var MAX_IMAGES_PER_DOC = 200;
|
|
354
1067
|
var MAX_TOTAL_IMAGE_BYTES = 128 * 1024 * 1024;
|
|
355
1068
|
var MAX_PENDING_RAW_BYTES = 64 * 1024 * 1024;
|
|
356
|
-
function createPdfImageState(
|
|
357
|
-
return { imageIndex: 0, totalBytes: 0, seen: /* @__PURE__ */ new Map(), globalKeys: /* @__PURE__ */ new Map(), capWarned: false,
|
|
1069
|
+
function createPdfImageState(webp, placement = false, dropBlank = false) {
|
|
1070
|
+
return { imageIndex: 0, totalBytes: 0, seen: /* @__PURE__ */ new Map(), globalKeys: /* @__PURE__ */ new Map(), capWarned: false, webp, pending: [], pendingRaw: 0, renamed: /* @__PURE__ */ new Map(), oversize: 0, placement, dropBlank };
|
|
358
1071
|
}
|
|
359
1072
|
function contentHash(data) {
|
|
360
1073
|
return _crypto.createHash.call(void 0, "sha1").update(data).digest("hex");
|
|
@@ -363,14 +1076,14 @@ var NO_BYTES = new Uint8Array(0);
|
|
|
363
1076
|
function toRgba(img, convert = true) {
|
|
364
1077
|
const { width: w, height: h, kind, data } = img;
|
|
365
1078
|
if (!data || !w || !h) return null;
|
|
366
|
-
if (kind ===
|
|
1079
|
+
if (kind === _chunkFG3SD2G3cjs.ImageKind.RGBA_32BPP) {
|
|
367
1080
|
if (data.length < w * h * 4) return null;
|
|
368
1081
|
if (!convert) return NO_BYTES;
|
|
369
1082
|
const rgba = new Uint8Array(w * h * 4);
|
|
370
1083
|
rgba.set(data.subarray(0, w * h * 4));
|
|
371
1084
|
return rgba;
|
|
372
1085
|
}
|
|
373
|
-
if (kind ===
|
|
1086
|
+
if (kind === _chunkFG3SD2G3cjs.ImageKind.RGB_24BPP) {
|
|
374
1087
|
if (data.length < w * h * 3) return null;
|
|
375
1088
|
if (!convert) return NO_BYTES;
|
|
376
1089
|
const rgba = new Uint8Array(w * h * 4);
|
|
@@ -382,7 +1095,7 @@ function toRgba(img, convert = true) {
|
|
|
382
1095
|
}
|
|
383
1096
|
return rgba;
|
|
384
1097
|
}
|
|
385
|
-
if (kind ===
|
|
1098
|
+
if (kind === _chunkFG3SD2G3cjs.ImageKind.GRAYSCALE_1BPP) {
|
|
386
1099
|
const stride = w + 7 >> 3;
|
|
387
1100
|
if (data.length < stride * h) return null;
|
|
388
1101
|
if (!convert) return NO_BYTES;
|
|
@@ -406,32 +1119,10 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
406
1119
|
const blocks = [];
|
|
407
1120
|
const images = [];
|
|
408
1121
|
const pageSeenIds = /* @__PURE__ */ new Set();
|
|
409
|
-
let pdfiumQueue;
|
|
410
|
-
let unpairedSizes;
|
|
411
|
-
const pdfiumById = /* @__PURE__ */ new Map();
|
|
412
|
-
const takePdfium = (match) => {
|
|
413
|
-
const k = pdfiumQueue.findIndex(match);
|
|
414
|
-
return k < 0 ? void 0 : pdfiumQueue.splice(k, 1)[0];
|
|
415
|
-
};
|
|
416
|
-
const reusedRaws = [];
|
|
417
|
-
const consume = (raw) => {
|
|
418
|
-
if (pdfiumQueue) takePdfium((x) => x.raw === raw);
|
|
419
|
-
else reusedRaws.push(raw);
|
|
420
|
-
};
|
|
421
|
-
const pairable = (w, h) => {
|
|
422
|
-
if (!pdfiumQueue) {
|
|
423
|
-
pdfiumQueue = state.blanked.decoder.page(pageNumber);
|
|
424
|
-
unpairedSizes = pairingCounts(fnArray, argsArray, pdfiumQueue);
|
|
425
|
-
for (const raw of reusedRaws) takePdfium((x) => x.raw === raw);
|
|
426
|
-
}
|
|
427
|
-
return w !== void 0 && !unpairedSizes.has(`${w}x${h}`) && !unpairedSizes.has("repeat");
|
|
428
|
-
};
|
|
429
|
-
let pristine;
|
|
430
|
-
let paintIndex = -1;
|
|
431
1122
|
const regions = state.placement ? /* @__PURE__ */ new Map() : void 0;
|
|
432
|
-
if (regions)
|
|
1123
|
+
if (regions) _chunkFG3SD2G3cjs.extractImageRegions.call(void 0, fnArray, argsArray, false, regions);
|
|
433
1124
|
const placed = (block, i) => {
|
|
434
|
-
const r = _optionalChain([regions, 'optionalAccess',
|
|
1125
|
+
const r = _optionalChain([regions, 'optionalAccess', _18 => _18.get, 'call', _19 => _19(i)]);
|
|
435
1126
|
if (r) block.bbox = { page: pageNumber, x: r.x1, y: r.y1, width: r.x2 - r.x1, height: r.y2 - r.y1 };
|
|
436
1127
|
return block;
|
|
437
1128
|
};
|
|
@@ -439,70 +1130,30 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
439
1130
|
const op = fnArray[i];
|
|
440
1131
|
let imgData = null;
|
|
441
1132
|
let dedupeId = null;
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
paintIndex++;
|
|
445
|
-
const paints = op === _pdfmjs.OPS.paintImageXObjectRepeat ? (_nullishCoalesce(_optionalChain([argsArray, 'access', _6 => _6[i], 'optionalAccess', _7 => _7[3], 'optionalAccess', _8 => _8.length]), () => ( 2))) / 2 : 1;
|
|
446
|
-
const objId = _optionalChain([argsArray, 'access', _9 => _9[i], 'optionalAccess', _10 => _10[0]]);
|
|
1133
|
+
if (op === _chunkFG3SD2G3cjs.OPS.paintImageXObject || op === _chunkFG3SD2G3cjs.OPS.paintImageXObjectRepeat) {
|
|
1134
|
+
const objId = _optionalChain([argsArray, 'access', _20 => _20[i], 'optionalAccess', _21 => _21[0]]);
|
|
447
1135
|
if (typeof objId !== "string") continue;
|
|
448
|
-
if (pageSeenIds.has(objId))
|
|
449
|
-
const first = pdfiumById.get(objId);
|
|
450
|
-
if (first) for (let k = 0; k < paints; k++) consume(first.raw);
|
|
451
|
-
continue;
|
|
452
|
-
}
|
|
1136
|
+
if (pageSeenIds.has(objId)) continue;
|
|
453
1137
|
if (await capReached(state, pageNumber, warnings)) continue;
|
|
454
|
-
if (state.blanked) {
|
|
455
|
-
const w2 = op === _pdfmjs.OPS.paintImageXObject ? _optionalChain([argsArray, 'access', _11 => _11[i], 'optionalAccess', _12 => _12[1]]) : void 0;
|
|
456
|
-
const h2 = op === _pdfmjs.OPS.paintImageXObject ? _optionalChain([argsArray, 'access', _13 => _13[i], 'optionalAccess', _14 => _14[2]]) : void 0;
|
|
457
|
-
const large = w2 === void 0 || h2 === void 0 || w2 > SMALL_IMAGE_DIM || h2 > SMALL_IMAGE_DIM;
|
|
458
|
-
const known = state.pdfiumGlobal.get(objId);
|
|
459
|
-
const reuse = known && (!known.blanked || known.sameRawSamePixels && state.rawKeys.has(known.raw));
|
|
460
|
-
let image;
|
|
461
|
-
if (reuse) {
|
|
462
|
-
image = known;
|
|
463
|
-
for (let k = 0; k < paints; k++) consume(known.raw);
|
|
464
|
-
} else {
|
|
465
|
-
image = large && pairable(w2, h2) ? _nullishCoalesce(takePdfium((x) => x.width === w2 && x.height === h2), () => ( null)) : null;
|
|
466
|
-
if (image) for (let k = 1; k < paints; k++) consume(image.raw);
|
|
467
|
-
if (image && objId.startsWith("g_")) state.pdfiumGlobal.set(objId, image);
|
|
468
|
-
}
|
|
469
|
-
pdfiumById.set(objId, image);
|
|
470
|
-
const block = _optionalChain([image, 'optionalAccess', _15 => _15.blanked]) ? await extractPdfiumImage(image, pageNumber, state, warnings, withBytes, images, readQr) : UNDECODED;
|
|
471
|
-
if (block !== UNDECODED) {
|
|
472
|
-
pageSeenIds.add(objId);
|
|
473
|
-
if (block) blocks.push(placed(block, i));
|
|
474
|
-
continue;
|
|
475
|
-
}
|
|
476
|
-
fromPristine = large && (!!_optionalChain([image, 'optionalAccess', _16 => _16.blanked]) || !image && (w2 === void 0 || state.blanked.sizes.has(`${w2}x${h2}`)));
|
|
477
|
-
}
|
|
478
1138
|
pageSeenIds.add(objId);
|
|
479
1139
|
dedupeId = objId;
|
|
480
|
-
} else if (op !==
|
|
1140
|
+
} else if (op !== _chunkFG3SD2G3cjs.OPS.paintInlineImageXObject) {
|
|
481
1141
|
continue;
|
|
482
1142
|
}
|
|
483
1143
|
if (await capReached(state, pageNumber, warnings)) continue;
|
|
484
|
-
if (
|
|
485
|
-
if (!pristine) {
|
|
486
|
-
const p = await (await state.blanked.pristine()).getPage(pageNumber);
|
|
487
|
-
const ops = await p.getOperatorList();
|
|
488
|
-
pristine = { page: p, ids: paintImageIds(ops.fnArray, ops.argsArray) };
|
|
489
|
-
}
|
|
490
|
-
dedupeId = pristine.ids[paintIndex];
|
|
491
|
-
if (typeof dedupeId !== "string") continue;
|
|
492
|
-
imgData = await resolveImgData(pristine.page, dedupeId);
|
|
493
|
-
} else if (dedupeId) {
|
|
1144
|
+
if (dedupeId) {
|
|
494
1145
|
imgData = await resolveImgData(page, dedupeId);
|
|
495
1146
|
} else {
|
|
496
|
-
imgData = _optionalChain([argsArray, 'access',
|
|
1147
|
+
imgData = _optionalChain([argsArray, 'access', _22 => _22[i], 'optionalAccess', _23 => _23[0]]);
|
|
497
1148
|
}
|
|
498
|
-
if (!_optionalChain([imgData, 'optionalAccess',
|
|
1149
|
+
if (!_optionalChain([imgData, 'optionalAccess', _24 => _24.data]) || !imgData.width || !imgData.height) continue;
|
|
499
1150
|
const { width: w, height: h } = imgData;
|
|
500
1151
|
if (w < MIN_DIM || h < MIN_DIM) continue;
|
|
501
1152
|
if (w * h > MAX_PIXELS) {
|
|
502
1153
|
warnings.push({ page: pageNumber, message: `\uC774\uBBF8\uC9C0 \uD06C\uAE30 \uCD08\uACFC\uB85C \uCD94\uCD9C \uC0DD\uB7B5 (${w}\xD7${h})`, code: "SKIPPED_IMAGE" });
|
|
503
1154
|
continue;
|
|
504
1155
|
}
|
|
505
|
-
const globalId = _optionalChain([dedupeId, 'optionalAccess',
|
|
1156
|
+
const globalId = _optionalChain([dedupeId, 'optionalAccess', _25 => _25.startsWith, 'call', _26 => _26("g_")]) ? dedupeId : void 0;
|
|
506
1157
|
let hash = globalId ? state.globalKeys.get(globalId) : void 0;
|
|
507
1158
|
if (hash === void 0) {
|
|
508
1159
|
hash = `${w}x${h}k${_nullishCoalesce(imgData.kind, () => ( "?"))}h${contentHash(imgData.data)}${dedupeId ? "" : "inline"}`;
|
|
@@ -511,7 +1162,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
511
1162
|
if (state.seen.has(hash)) continue;
|
|
512
1163
|
const rgba = toRgba(imgData, withBytes || !!readQr || state.dropBlank);
|
|
513
1164
|
if (!rgba) continue;
|
|
514
|
-
if (state.dropBlank &&
|
|
1165
|
+
if (state.dropBlank && _chunkHHOGCXPDcjs.isBlankRgba.call(void 0, rgba)) {
|
|
515
1166
|
state.seen.set(hash, "");
|
|
516
1167
|
continue;
|
|
517
1168
|
}
|
|
@@ -522,27 +1173,8 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
522
1173
|
const qr = readQr ? await readQr({ data: rgba, width: w, height: h }) : [];
|
|
523
1174
|
blocks.push(placed({ type: "image", text: filename, pageNumber, ...qr.length ? { qr } : {} }, i));
|
|
524
1175
|
}
|
|
525
|
-
_optionalChain([pristine, 'optionalAccess', _22 => _22.page, 'access', _23 => _23.cleanup, 'call', _24 => _24()]);
|
|
526
1176
|
return { blocks, images };
|
|
527
1177
|
}
|
|
528
|
-
function paintImageIds(fnArray, argsArray) {
|
|
529
|
-
const ids = [];
|
|
530
|
-
for (let i = 0; i < fnArray.length; i++) if (fnArray[i] === _pdfmjs.OPS.paintImageXObject || fnArray[i] === _pdfmjs.OPS.paintImageXObjectRepeat) ids.push(_optionalChain([argsArray, 'access', _25 => _25[i], 'optionalAccess', _26 => _26[0]]));
|
|
531
|
-
return ids;
|
|
532
|
-
}
|
|
533
|
-
function pairingCounts(fnArray, argsArray, pdfium) {
|
|
534
|
-
const count = /* @__PURE__ */ new Map();
|
|
535
|
-
const unpaired = /* @__PURE__ */ new Set();
|
|
536
|
-
for (let i = 0; i < fnArray.length; i++) {
|
|
537
|
-
if (fnArray[i] === _pdfmjs.OPS.paintImageXObjectRepeat) unpaired.add("repeat");
|
|
538
|
-
if (fnArray[i] !== _pdfmjs.OPS.paintImageXObject) continue;
|
|
539
|
-
const w = _optionalChain([argsArray, 'access', _27 => _27[i], 'optionalAccess', _28 => _28[1]]), h = _optionalChain([argsArray, 'access', _29 => _29[i], 'optionalAccess', _30 => _30[2]]);
|
|
540
|
-
if (w > SMALL_IMAGE_DIM || h > SMALL_IMAGE_DIM) count.set(`${w}x${h}`, (_nullishCoalesce(count.get(`${w}x${h}`), () => ( 0))) + 1);
|
|
541
|
-
}
|
|
542
|
-
for (const x of pdfium) count.set(`${x.width}x${x.height}`, (_nullishCoalesce(count.get(`${x.width}x${x.height}`), () => ( 0))) - 1);
|
|
543
|
-
for (const [size, n] of count) if (n !== 0) unpaired.add(size);
|
|
544
|
-
return unpaired;
|
|
545
|
-
}
|
|
546
1178
|
async function capReached(state, pageNumber, warnings) {
|
|
547
1179
|
if (state.pending.length && state.totalBytes + state.pendingRaw * 1.1 + 1024 * state.pending.length >= MAX_TOTAL_IMAGE_BYTES) await drain(state, 0);
|
|
548
1180
|
if (state.imageIndex < MAX_IMAGES_PER_DOC && state.totalBytes < MAX_TOTAL_IMAGE_BYTES) return false;
|
|
@@ -597,31 +1229,6 @@ async function flushPdfImages(state, warnings, pageImages) {
|
|
|
597
1229
|
var WEBP_MAX_DIM = 16383;
|
|
598
1230
|
var webpable = (state, w, h) => !!state.webp && w <= WEBP_MAX_DIM && h <= WEBP_MAX_DIM;
|
|
599
1231
|
var imageFilename = (state, w, h) => `image_${String(state.imageIndex).padStart(3, "0")}.${webpable(state, w, h) ? "webp" : "png"}`;
|
|
600
|
-
var UNDECODED = /* @__PURE__ */ Symbol("undecoded");
|
|
601
|
-
async function extractPdfiumImage(image, pageNumber, state, warnings, withBytes, images, readQr) {
|
|
602
|
-
const { width: w, height: h } = image;
|
|
603
|
-
if (w < MIN_DIM || h < MIN_DIM) return null;
|
|
604
|
-
if (w * h > MAX_PIXELS) {
|
|
605
|
-
warnings.push({ page: pageNumber, message: `\uC774\uBBF8\uC9C0 \uD06C\uAE30 \uCD08\uACFC\uB85C \uCD94\uCD9C \uC0DD\uB7B5 (${w}\xD7${h})`, code: "SKIPPED_IMAGE" });
|
|
606
|
-
return null;
|
|
607
|
-
}
|
|
608
|
-
if (image.sameRawSamePixels && state.rawKeys.has(image.raw)) return null;
|
|
609
|
-
const rgba = state.blanked.decoder.decode(image);
|
|
610
|
-
if (!rgba) return UNDECODED;
|
|
611
|
-
const hash = `${w}x${h}kPh${contentHash(rgba)}`;
|
|
612
|
-
state.rawKeys.set(image.raw, hash);
|
|
613
|
-
if (state.seen.has(hash)) return null;
|
|
614
|
-
if (state.dropBlank && _chunkHXA6WK2Qcjs.isBlankRgba.call(void 0, rgba)) {
|
|
615
|
-
state.seen.set(hash, "");
|
|
616
|
-
return null;
|
|
617
|
-
}
|
|
618
|
-
state.imageIndex++;
|
|
619
|
-
const filename = imageFilename(state, w, h);
|
|
620
|
-
state.seen.set(hash, filename);
|
|
621
|
-
if (withBytes) await pushImage(state, filename, w, h, rgba, images);
|
|
622
|
-
const qr = readQr ? await readQr({ data: rgba, width: w, height: h }) : [];
|
|
623
|
-
return { type: "image", text: filename, pageNumber, ...qr.length ? { qr } : {} };
|
|
624
|
-
}
|
|
625
1232
|
function injectPageImageBlocks(blocks, pageImages) {
|
|
626
1233
|
if (pageImages.size === 0) return;
|
|
627
1234
|
const lastIndexForPage = /* @__PURE__ */ new Map();
|
|
@@ -843,7 +1450,6 @@ function summarizeDocumentQuality(pages) {
|
|
|
843
1450
|
}
|
|
844
1451
|
|
|
845
1452
|
// src/pdf/vector-glyphs.ts
|
|
846
|
-
|
|
847
1453
|
var GLYPH_MIN_H = 3;
|
|
848
1454
|
var GLYPH_MAX_H = 40;
|
|
849
1455
|
var GLYPH_MAX_ASPECT = 2;
|
|
@@ -892,55 +1498,55 @@ function collectGlyphPaths(fnArray, argsArray) {
|
|
|
892
1498
|
const op = fnArray[i];
|
|
893
1499
|
const args = argsArray[i];
|
|
894
1500
|
switch (op) {
|
|
895
|
-
case
|
|
1501
|
+
case _chunkFG3SD2G3cjs.OPS.save:
|
|
896
1502
|
stack.push([ctm, color]);
|
|
897
1503
|
break;
|
|
898
|
-
case
|
|
1504
|
+
case _chunkFG3SD2G3cjs.OPS.restore:
|
|
899
1505
|
[ctm, color] = _nullishCoalesce(stack.pop(), () => ( [[1, 0, 0, 1, 0, 0], 0]));
|
|
900
1506
|
break;
|
|
901
|
-
case
|
|
1507
|
+
case _chunkFG3SD2G3cjs.OPS.transform:
|
|
902
1508
|
ctm = mul(ctm, args);
|
|
903
1509
|
break;
|
|
904
|
-
case
|
|
1510
|
+
case _chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin: {
|
|
905
1511
|
stack.push([ctm, color]);
|
|
906
1512
|
const m = args[0];
|
|
907
1513
|
if (Array.isArray(m) && m.length >= 6) ctm = mul(ctm, m);
|
|
908
1514
|
break;
|
|
909
1515
|
}
|
|
910
|
-
case
|
|
1516
|
+
case _chunkFG3SD2G3cjs.OPS.paintFormXObjectEnd:
|
|
911
1517
|
[ctm, color] = _nullishCoalesce(stack.pop(), () => ( [[1, 0, 0, 1, 0, 0], 0]));
|
|
912
1518
|
break;
|
|
913
|
-
case
|
|
1519
|
+
case _chunkFG3SD2G3cjs.OPS.setFillRGBColor: {
|
|
914
1520
|
const c = args;
|
|
915
1521
|
color = c[0] << 16 | c[1] << 8 | c[2];
|
|
916
1522
|
break;
|
|
917
1523
|
}
|
|
918
|
-
case
|
|
1524
|
+
case _chunkFG3SD2G3cjs.OPS.constructPath: {
|
|
919
1525
|
const [subOps, coords] = args;
|
|
920
1526
|
if (!Array.isArray(subOps) || !Array.isArray(coords)) break;
|
|
921
1527
|
ops.push(i);
|
|
922
1528
|
let ci = 0;
|
|
923
1529
|
for (const s of subOps) {
|
|
924
|
-
if (s ===
|
|
1530
|
+
if (s === _chunkFG3SD2G3cjs.OPS.moveTo) {
|
|
925
1531
|
add(coords[ci], coords[ci + 1]);
|
|
926
1532
|
ci += 2;
|
|
927
1533
|
subs++;
|
|
928
|
-
} else if (s ===
|
|
1534
|
+
} else if (s === _chunkFG3SD2G3cjs.OPS.lineTo) {
|
|
929
1535
|
add(coords[ci], coords[ci + 1]);
|
|
930
1536
|
ci += 2;
|
|
931
1537
|
segs++;
|
|
932
|
-
} else if (s ===
|
|
1538
|
+
} else if (s === _chunkFG3SD2G3cjs.OPS.curveTo) {
|
|
933
1539
|
add(coords[ci], coords[ci + 1]);
|
|
934
1540
|
add(coords[ci + 2], coords[ci + 3]);
|
|
935
1541
|
add(coords[ci + 4], coords[ci + 5]);
|
|
936
1542
|
ci += 6;
|
|
937
1543
|
segs++;
|
|
938
|
-
} else if (s ===
|
|
1544
|
+
} else if (s === _chunkFG3SD2G3cjs.OPS.curveTo2 || s === _chunkFG3SD2G3cjs.OPS.curveTo3) {
|
|
939
1545
|
add(coords[ci], coords[ci + 1]);
|
|
940
1546
|
add(coords[ci + 2], coords[ci + 3]);
|
|
941
1547
|
ci += 4;
|
|
942
1548
|
segs++;
|
|
943
|
-
} else if (s ===
|
|
1549
|
+
} else if (s === _chunkFG3SD2G3cjs.OPS.rectangle) {
|
|
944
1550
|
const rx = coords[ci], ry = coords[ci + 1], rw = coords[ci + 2], rh = coords[ci + 3];
|
|
945
1551
|
add(rx, ry);
|
|
946
1552
|
add(rx + rw, ry + rh);
|
|
@@ -954,12 +1560,12 @@ function collectGlyphPaths(fnArray, argsArray) {
|
|
|
954
1560
|
}
|
|
955
1561
|
break;
|
|
956
1562
|
}
|
|
957
|
-
case
|
|
958
|
-
case
|
|
959
|
-
case
|
|
960
|
-
case
|
|
961
|
-
case
|
|
962
|
-
case
|
|
1563
|
+
case _chunkFG3SD2G3cjs.OPS.fill:
|
|
1564
|
+
case _chunkFG3SD2G3cjs.OPS.eoFill:
|
|
1565
|
+
case _chunkFG3SD2G3cjs.OPS.fillStroke:
|
|
1566
|
+
case _chunkFG3SD2G3cjs.OPS.eoFillStroke:
|
|
1567
|
+
case _chunkFG3SD2G3cjs.OPS.closeFillStroke:
|
|
1568
|
+
case _chunkFG3SD2G3cjs.OPS.closeEOFillStroke: {
|
|
963
1569
|
const w = x2 - x1, h = y2 - y1;
|
|
964
1570
|
if (segs > rects * 4 && h >= GLYPH_MIN_H && h <= GLYPH_MAX_H && w <= h * GLYPH_MAX_ASPECT && segs >= GLYPH_MIN_SEGS && subs >= GLYPH_MIN_SUBS) {
|
|
965
1571
|
out.push({ x1, y1, x2, y2, segs, subs, color, ops: [...ops, i] });
|
|
@@ -967,9 +1573,9 @@ function collectGlyphPaths(fnArray, argsArray) {
|
|
|
967
1573
|
reset();
|
|
968
1574
|
break;
|
|
969
1575
|
}
|
|
970
|
-
case
|
|
971
|
-
case
|
|
972
|
-
case
|
|
1576
|
+
case _chunkFG3SD2G3cjs.OPS.stroke:
|
|
1577
|
+
case _chunkFG3SD2G3cjs.OPS.closeStroke:
|
|
1578
|
+
case _chunkFG3SD2G3cjs.OPS.endPath:
|
|
973
1579
|
reset();
|
|
974
1580
|
break;
|
|
975
1581
|
}
|
|
@@ -1050,7 +1656,7 @@ function ocrVectorOps(opList, paths) {
|
|
|
1050
1656
|
const argsArray = [];
|
|
1051
1657
|
for (let i = 0; i < opList.fnArray.length; i++) {
|
|
1052
1658
|
const op = opList.fnArray[i];
|
|
1053
|
-
if (drop.has(i) || op ===
|
|
1659
|
+
if (drop.has(i) || op === _chunkFG3SD2G3cjs.OPS.clip || op === _chunkFG3SD2G3cjs.OPS.eoClip) continue;
|
|
1054
1660
|
fnArray.push(op);
|
|
1055
1661
|
argsArray.push(opList.argsArray[i]);
|
|
1056
1662
|
}
|
|
@@ -1059,13 +1665,13 @@ function ocrVectorOps(opList, paths) {
|
|
|
1059
1665
|
|
|
1060
1666
|
// src/pdf/split-row-pattern.ts
|
|
1061
1667
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
1062
|
-
var plain = (cell) => !_optionalChain([cell, 'access',
|
|
1668
|
+
var plain = (cell) => !_optionalChain([cell, 'access', _27 => _27.blocks, 'optionalAccess', _28 => _28.length]) && !_chunkFG3SD2G3cjs.IMAGE_CELLS.has(cell);
|
|
1063
1669
|
var labelsOf = (cell) => {
|
|
1064
1670
|
const labels = textOf(cell).split("\n").map((s) => s.trim()).filter(Boolean);
|
|
1065
1671
|
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;
|
|
1066
1672
|
};
|
|
1067
1673
|
var alignedLabels = (label, value, count) => {
|
|
1068
|
-
const L =
|
|
1674
|
+
const L = _chunkFG3SD2G3cjs.CELL_LINES.get(label), V = _chunkFG3SD2G3cjs.CELL_LINES.get(value);
|
|
1069
1675
|
let next = 0;
|
|
1070
1676
|
return !!L && !!V && L.length === count && V.length >= count && Math.abs(L[0].y - V[0].y) <= 1 && L.every((l) => {
|
|
1071
1677
|
while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
|
|
@@ -1073,18 +1679,18 @@ var alignedLabels = (label, value, count) => {
|
|
|
1073
1679
|
});
|
|
1074
1680
|
};
|
|
1075
1681
|
function partialAlignedLabelCells(table, owner, first) {
|
|
1076
|
-
const pageOf = (a) => _nullishCoalesce(
|
|
1682
|
+
const pageOf = (a) => _nullishCoalesce(_chunkYIATOFKCcjs.CELL_PAGES.get(_nullishCoalesce(a.cell, () => ( table.cells[a.r][a.c]))), () => ( (a.r < first ? -1 : -2)));
|
|
1077
1683
|
const pairs = [];
|
|
1078
1684
|
let carried = false;
|
|
1079
1685
|
for (let c = 0; c < table.cols; ) {
|
|
1080
|
-
const u = _optionalChain([owner, 'access',
|
|
1686
|
+
const u = _optionalChain([owner, 'access', _29 => _29[first - 1], 'optionalAccess', _30 => _30[c]]), d = _optionalChain([owner, 'access', _31 => _31[first], 'optionalAccess', _32 => _32[c]]);
|
|
1081
1687
|
if (u && u === d) {
|
|
1082
1688
|
carried = true;
|
|
1083
1689
|
c = u.c + u.cs;
|
|
1084
1690
|
continue;
|
|
1085
1691
|
}
|
|
1086
1692
|
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
1087
|
-
if (!_optionalChain([upper, 'optionalAccess',
|
|
1693
|
+
if (!_optionalChain([upper, 'optionalAccess', _33 => _33.text, 'access', _34 => _34.trim, 'call', _35 => _35()]) && !_optionalChain([lower, 'optionalAccess', _36 => _36.text, 'access', _37 => _37.trim, 'call', _38 => _38()])) {
|
|
1088
1694
|
c++;
|
|
1089
1695
|
continue;
|
|
1090
1696
|
}
|
|
@@ -1096,10 +1702,10 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
1096
1702
|
const keyed = pairs.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
|
|
1097
1703
|
if (keyed.length !== 1) return;
|
|
1098
1704
|
const label = keyed[0], value = pairs.find((p) => p.c === label.c + label.cs), context = pairs.find((p) => p.c + p.cs === label.c);
|
|
1099
|
-
if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([
|
|
1705
|
+
if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([_chunkYIATOFKCcjs.CELL_EDGES, 'access', _39 => _39.get, 'call', _40 => _40(context.upper), 'optionalAccess', _41 => _41.b]) || !_optionalChain([_chunkYIATOFKCcjs.CELL_EDGES, 'access', _42 => _42.get, 'call', _43 => _43(context.lower), 'optionalAccess', _44 => _44.t])) return;
|
|
1100
1706
|
const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
|
|
1101
1707
|
if (D.length < 2 || sequence.length < 3 || new Set(sequence).size !== sequence.length || !alignedLabels(label.upper, value.upper, U.length)) return;
|
|
1102
|
-
const L =
|
|
1708
|
+
const L = _chunkFG3SD2G3cjs.CELL_LINES.get(label.lower), V = _chunkFG3SD2G3cjs.CELL_LINES.get(value.lower);
|
|
1103
1709
|
if (!L || !V || L.length !== D.length) return;
|
|
1104
1710
|
let next = V.findIndex((v) => Math.abs(v.y - L[0].y) <= 1);
|
|
1105
1711
|
if (next <= 0 || !V.slice(0, next).every((v) => v.y > L[0].y + 1) || !L.every((l) => {
|
|
@@ -1109,7 +1715,7 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
1109
1715
|
let peers = 0, shared = false;
|
|
1110
1716
|
for (let r = 0; r < table.rows; r++) {
|
|
1111
1717
|
if (r === first - 1 || r === first) continue;
|
|
1112
|
-
const l = _optionalChain([owner, 'access',
|
|
1718
|
+
const l = _optionalChain([owner, 'access', _45 => _45[r], 'optionalAccess', _46 => _46[label.c]]), v = _optionalChain([owner, 'access', _47 => _47[r], 'optionalAccess', _48 => _48[value.c]]);
|
|
1113
1719
|
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;
|
|
1114
1720
|
const lc = table.cells[r][l.c], vc = table.cells[r][v.c];
|
|
1115
1721
|
const list = labelsOf(lc);
|
|
@@ -1119,15 +1725,15 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
1119
1725
|
continue;
|
|
1120
1726
|
}
|
|
1121
1727
|
if (list.length < 3 || new Set(list).size !== list.length) continue;
|
|
1122
|
-
const visible = _nullishCoalesce(_optionalChain([
|
|
1728
|
+
const visible = _nullishCoalesce(_optionalChain([_chunkFG3SD2G3cjs.CELL_LINES, 'access', _49 => _49.get, 'call', _50 => _50(lc), 'optionalAccess', _51 => _51.length]), () => ( 0)), values = _chunkFG3SD2G3cjs.CELL_LINES.get(vc);
|
|
1123
1729
|
if (visible < 3 || visible > list.length || !values || !alignedLabels(lc, vc, visible)) continue;
|
|
1124
1730
|
const top = Math.max(...values.map((v2) => v2.y)), bottom = Math.min(...values.map((v2) => v2.y));
|
|
1125
1731
|
const contexts = [];
|
|
1126
1732
|
for (let rr = r; rr < r + l.rs && rr < table.rows; rr++) {
|
|
1127
|
-
const a = _optionalChain([owner, 'access',
|
|
1733
|
+
const a = _optionalChain([owner, 'access', _52 => _52[rr], 'optionalAccess', _53 => _53[context.c]]), cell = a ? table.cells[a.r][a.c] : void 0;
|
|
1128
1734
|
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;
|
|
1129
|
-
const lines =
|
|
1130
|
-
if (!_optionalChain([lines, 'optionalAccess',
|
|
1735
|
+
const lines = _chunkFG3SD2G3cjs.CELL_LINES.get(cell);
|
|
1736
|
+
if (!_optionalChain([lines, 'optionalAccess', _54 => _54.length]) || lines.some((line) => line.y > top + 1 || line.y < bottom - 1)) break;
|
|
1131
1737
|
contexts.push(textOf(cell).replace(/\s+/g, ""));
|
|
1132
1738
|
}
|
|
1133
1739
|
if (new Set(contexts).size >= 2) shared = true;
|
|
@@ -1138,14 +1744,14 @@ function matchesCompleteAlignedLabelListRow(table, owner, first) {
|
|
|
1138
1744
|
const pairs = [];
|
|
1139
1745
|
let carried = false;
|
|
1140
1746
|
for (let c = 0; c < table.cols; ) {
|
|
1141
|
-
const u = _optionalChain([owner, 'access',
|
|
1747
|
+
const u = _optionalChain([owner, 'access', _55 => _55[first - 1], 'optionalAccess', _56 => _56[c]]), d = _optionalChain([owner, 'access', _57 => _57[first], 'optionalAccess', _58 => _58[c]]);
|
|
1142
1748
|
if (u && u === d) {
|
|
1143
1749
|
carried = true;
|
|
1144
1750
|
c = u.c + u.cs;
|
|
1145
1751
|
continue;
|
|
1146
1752
|
}
|
|
1147
1753
|
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
1148
|
-
if (!_optionalChain([upper, 'optionalAccess',
|
|
1754
|
+
if (!_optionalChain([upper, 'optionalAccess', _59 => _59.text, 'access', _60 => _60.trim, 'call', _61 => _61()]) && !_optionalChain([lower, 'optionalAccess', _62 => _62.text, 'access', _63 => _63.trim, 'call', _64 => _64()])) {
|
|
1149
1755
|
c++;
|
|
1150
1756
|
continue;
|
|
1151
1757
|
}
|
|
@@ -1163,10 +1769,10 @@ function matchesCompleteAlignedLabelListRow(table, owner, first) {
|
|
|
1163
1769
|
let peers = 0;
|
|
1164
1770
|
for (let r = 0; r < table.rows; r++) {
|
|
1165
1771
|
if (r === first - 1 || r === first) continue;
|
|
1166
|
-
const L = _optionalChain([owner, 'access',
|
|
1167
|
-
if (_optionalChain([L, 'optionalAccess',
|
|
1772
|
+
const L = _optionalChain([owner, 'access', _65 => _65[r], 'optionalAccess', _66 => _66[label.c]]), V = _optionalChain([owner, 'access', _67 => _67[r], 'optionalAccess', _68 => _68[value.c]]);
|
|
1773
|
+
if (_optionalChain([L, 'optionalAccess', _69 => _69.r]) !== r || _optionalChain([V, 'optionalAccess', _70 => _70.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;
|
|
1168
1774
|
const l = table.cells[r][label.c], v = table.cells[r][value.c];
|
|
1169
|
-
if (!plain(l) || !plain(v) || !textOf(v) || _optionalChain([labelsOf, 'call',
|
|
1775
|
+
if (!plain(l) || !plain(v) || !textOf(v) || _optionalChain([labelsOf, 'call', _71 => _71(l), 'optionalAccess', _72 => _72.join, 'call', _73 => _73("|")]) !== sequence.join("|") || !alignedLabels(l, v, sequence.length)) continue;
|
|
1170
1776
|
if (++peers >= 2) return true;
|
|
1171
1777
|
}
|
|
1172
1778
|
return false;
|
|
@@ -1175,13 +1781,13 @@ function matchesIndependentRowPair(table, owner, first) {
|
|
|
1175
1781
|
const norm = (cell) => textOf(cell).replace(/\s+/g, "");
|
|
1176
1782
|
const pairs = [];
|
|
1177
1783
|
for (let c = 0; c < table.cols; ) {
|
|
1178
|
-
const u = _optionalChain([owner, 'access',
|
|
1784
|
+
const u = _optionalChain([owner, 'access', _74 => _74[first - 1], 'optionalAccess', _75 => _75[c]]), d = _optionalChain([owner, 'access', _76 => _76[first], 'optionalAccess', _77 => _77[c]]);
|
|
1179
1785
|
if (u && u === d) {
|
|
1180
1786
|
c = u.c + u.cs;
|
|
1181
1787
|
continue;
|
|
1182
1788
|
}
|
|
1183
1789
|
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
1184
|
-
if (!_optionalChain([upper, 'optionalAccess',
|
|
1790
|
+
if (!_optionalChain([upper, 'optionalAccess', _78 => _78.text, 'access', _79 => _79.trim, 'call', _80 => _80()]) && !_optionalChain([lower, 'optionalAccess', _81 => _81.text, 'access', _82 => _82.trim, 'call', _83 => _83()])) {
|
|
1185
1791
|
c++;
|
|
1186
1792
|
continue;
|
|
1187
1793
|
}
|
|
@@ -1193,8 +1799,8 @@ function matchesIndependentRowPair(table, owner, first) {
|
|
|
1193
1799
|
return table.cells.some((_, r) => {
|
|
1194
1800
|
if (r + 1 >= table.rows || r + 1 >= first - 1 && r <= first) return false;
|
|
1195
1801
|
return pairs.every((p) => [p.upper, p.lower].every((text, i) => {
|
|
1196
|
-
const a = _optionalChain([owner, 'access',
|
|
1197
|
-
return _optionalChain([a, 'optionalAccess',
|
|
1802
|
+
const a = _optionalChain([owner, 'access', _84 => _84[r + i], 'optionalAccess', _85 => _85[p.c]]), cell = _optionalChain([table, 'access', _86 => _86.cells, 'access', _87 => _87[r + i], 'optionalAccess', _88 => _88[p.c]]);
|
|
1803
|
+
return _optionalChain([a, 'optionalAccess', _89 => _89.r]) === r + i && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(cell) === text;
|
|
1198
1804
|
}));
|
|
1199
1805
|
});
|
|
1200
1806
|
}
|
|
@@ -1203,7 +1809,7 @@ function matchesCompleteContextRow(table, owner, first) {
|
|
|
1203
1809
|
const context = [];
|
|
1204
1810
|
let value;
|
|
1205
1811
|
for (let c = 0; c < table.cols; ) {
|
|
1206
|
-
const u = _optionalChain([owner, 'access',
|
|
1812
|
+
const u = _optionalChain([owner, 'access', _90 => _90[first - 1], 'optionalAccess', _91 => _91[c]]), d = _optionalChain([owner, 'access', _92 => _92[first], 'optionalAccess', _93 => _93[c]]);
|
|
1207
1813
|
if (u && u === d) {
|
|
1208
1814
|
const cell = table.cells[u.r][u.c];
|
|
1209
1815
|
if (u.r === first - 1 && u.rs === 2 && plain(cell) && textOf(cell)) context.push({ c, cs: u.cs, text: norm(textOf(cell)) });
|
|
@@ -1211,7 +1817,7 @@ function matchesCompleteContextRow(table, owner, first) {
|
|
|
1211
1817
|
continue;
|
|
1212
1818
|
}
|
|
1213
1819
|
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
1214
|
-
if (!_optionalChain([upper, 'optionalAccess',
|
|
1820
|
+
if (!_optionalChain([upper, 'optionalAccess', _94 => _94.text, 'access', _95 => _95.trim, 'call', _96 => _96()]) && !_optionalChain([lower, 'optionalAccess', _97 => _97.text, 'access', _98 => _98.trim, 'call', _99 => _99()])) {
|
|
1215
1821
|
c++;
|
|
1216
1822
|
continue;
|
|
1217
1823
|
}
|
|
@@ -1222,8 +1828,8 @@ function matchesCompleteContextRow(table, owner, first) {
|
|
|
1222
1828
|
if (!value || !context.length) return false;
|
|
1223
1829
|
const proof = [...context, value];
|
|
1224
1830
|
return table.cells.some((row, r) => r !== first - 1 && r !== first && proof.every((p) => {
|
|
1225
|
-
const a = _optionalChain([owner, 'access',
|
|
1226
|
-
return _optionalChain([a, 'optionalAccess',
|
|
1831
|
+
const a = _optionalChain([owner, 'access', _100 => _100[r], 'optionalAccess', _101 => _101[p.c]]), cell = row[p.c];
|
|
1832
|
+
return _optionalChain([a, 'optionalAccess', _102 => _102.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(textOf(cell)) === p.text;
|
|
1227
1833
|
}));
|
|
1228
1834
|
}
|
|
1229
1835
|
function matchesCompleteSiblingRow(table, owner, first) {
|
|
@@ -1251,7 +1857,7 @@ function matchesCompleteSiblingRow(table, owner, first) {
|
|
|
1251
1857
|
const norm = (s, title) => (title ? s.replace(/^[가-힣]\.\s*/, "") : s).replace(/\s+/g, "");
|
|
1252
1858
|
return table.cells.some((row, r) => r !== first - 1 && r !== first && pairs.every((p) => {
|
|
1253
1859
|
const anchor = owner[r][p.c], peer = row[p.c];
|
|
1254
|
-
return _optionalChain([anchor, 'optionalAccess',
|
|
1860
|
+
return _optionalChain([anchor, 'optionalAccess', _103 => _103.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);
|
|
1255
1861
|
}));
|
|
1256
1862
|
}
|
|
1257
1863
|
function matchesCompleteRubricRow(table, owner, first) {
|
|
@@ -1285,7 +1891,7 @@ function matchesCompleteRubricRow(table, owner, first) {
|
|
|
1285
1891
|
return table.cells.some((row, r) => {
|
|
1286
1892
|
if (r === first - 1 || r === first || !pairs.every((p) => {
|
|
1287
1893
|
const a = owner[r][p.c];
|
|
1288
|
-
return _optionalChain([a, 'optionalAccess',
|
|
1894
|
+
return _optionalChain([a, 'optionalAccess', _104 => _104.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && plain(row[p.c]);
|
|
1289
1895
|
})) return false;
|
|
1290
1896
|
const peer = textOf(row[main.c]), peerMarks = items(peer);
|
|
1291
1897
|
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;
|
|
@@ -1307,11 +1913,11 @@ function hasNumberedRowSequence(table, owner, first) {
|
|
|
1307
1913
|
if (first < 3) return false;
|
|
1308
1914
|
const rows = [first - 3, first - 2, first - 1, first];
|
|
1309
1915
|
const separate = (c, cs) => rows.every((r) => {
|
|
1310
|
-
const a = _optionalChain([owner, 'access',
|
|
1311
|
-
return _optionalChain([a, 'optionalAccess',
|
|
1916
|
+
const a = _optionalChain([owner, 'access', _105 => _105[r], 'optionalAccess', _106 => _106[c]]), cell = _optionalChain([table, 'access', _107 => _107.cells, 'access', _108 => _108[r], 'optionalAccess', _109 => _109[c]]);
|
|
1917
|
+
return _optionalChain([a, 'optionalAccess', _110 => _110.r]) === r && a.c === c && a.rs === 1 && a.cs === cs && !!cell && plain(cell) && !!textOf(cell);
|
|
1312
1918
|
});
|
|
1313
1919
|
for (let c = 0; c < table.cols; c++) {
|
|
1314
|
-
const a = _optionalChain([owner, 'access',
|
|
1920
|
+
const a = _optionalChain([owner, 'access', _111 => _111[first], 'optionalAccess', _112 => _112[c]]);
|
|
1315
1921
|
if (!a || !separate(c, a.cs)) continue;
|
|
1316
1922
|
const marks = rows.map((r) => {
|
|
1317
1923
|
const lines = textOf(table.cells[r][c]).split("\n"), firstMark = itemMark(lines[0]);
|
|
@@ -1320,7 +1926,7 @@ function hasNumberedRowSequence(table, owner, first) {
|
|
|
1320
1926
|
const head = marks[0];
|
|
1321
1927
|
if (!head || marks.some((m, i) => !m || m.style !== head.style || m.n !== head.n + i)) continue;
|
|
1322
1928
|
for (let d = 0; d < table.cols; d++) {
|
|
1323
|
-
const side = _optionalChain([owner, 'access',
|
|
1929
|
+
const side = _optionalChain([owner, 'access', _113 => _113[first], 'optionalAccess', _114 => _114[d]]);
|
|
1324
1930
|
if (side && (d + side.cs <= c || d >= c + a.cs) && separate(d, side.cs)) return true;
|
|
1325
1931
|
}
|
|
1326
1932
|
}
|
|
@@ -1393,7 +1999,7 @@ var CELL_SPLITS = /* @__PURE__ */ new WeakMap();
|
|
|
1393
1999
|
function relocate(src, dst, from = 0) {
|
|
1394
2000
|
const out = [];
|
|
1395
2001
|
for (const s of _nullishCoalesce(CELL_SPLITS.get(src), () => ( []))) {
|
|
1396
|
-
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access',
|
|
2002
|
+
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access', _115 => _115.at, 'call', _116 => _116(-1), 'optionalAccess', _117 => _117.at]), () => ( 0))));
|
|
1397
2003
|
if (at >= 0) out.push({ at, page: s.page });
|
|
1398
2004
|
}
|
|
1399
2005
|
return out;
|
|
@@ -1417,7 +2023,7 @@ function rowStarts(t) {
|
|
|
1417
2023
|
const starts = [];
|
|
1418
2024
|
for (let c = 0; c < t.cols; c++) {
|
|
1419
2025
|
if (covered.has(r * 1e5 + c)) continue;
|
|
1420
|
-
const cell = _optionalChain([t, 'access',
|
|
2026
|
+
const cell = _optionalChain([t, 'access', _118 => _118.cells, 'access', _119 => _119[r], 'optionalAccess', _120 => _120[c]]);
|
|
1421
2027
|
if (!cell) continue;
|
|
1422
2028
|
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);
|
|
1423
2029
|
starts.push({ cell, c });
|
|
@@ -1428,8 +2034,8 @@ function rowStarts(t) {
|
|
|
1428
2034
|
}
|
|
1429
2035
|
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));
|
|
1430
2036
|
function cellPage(cell) {
|
|
1431
|
-
const p =
|
|
1432
|
-
if (p !== void 0 || !_optionalChain([cell, 'access',
|
|
2037
|
+
const p = _chunkYIATOFKCcjs.CELL_PAGES.get(cell);
|
|
2038
|
+
if (p !== void 0 || !_optionalChain([cell, 'access', _121 => _121.blocks, 'optionalAccess', _122 => _122.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
1433
2039
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
1434
2040
|
}
|
|
1435
2041
|
function tableRowPages(t, pageNumber) {
|
|
@@ -1440,7 +2046,7 @@ function tableRowPages(t, pageNumber) {
|
|
|
1440
2046
|
for (const { cell } of starts) {
|
|
1441
2047
|
const p = cellPage(cell);
|
|
1442
2048
|
if (p !== void 0) mark = Math.max(_nullishCoalesce(mark, () => ( p)), p);
|
|
1443
|
-
else if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
2049
|
+
else if (cell.text.trim() || _optionalChain([cell, 'access', _123 => _123.blocks, 'optionalAccess', _124 => _124.length])) text = true;
|
|
1444
2050
|
}
|
|
1445
2051
|
const page = _nullishCoalesce(mark, () => ( (text ? pageNumber : prev)));
|
|
1446
2052
|
prev = page !== void 0 && prev !== void 0 ? Math.max(prev, page) : _nullishCoalesce(page, () => ( prev));
|
|
@@ -1457,8 +2063,8 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1457
2063
|
rows.forEach((starts, r) => {
|
|
1458
2064
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
1459
2065
|
for (const { cell } of starts) {
|
|
1460
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
1461
|
-
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess',
|
|
2066
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkYIATOFKCcjs.CELL_PAGES.set(cell, page2);
|
|
2067
|
+
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _125 => _125.find, 'call', _126 => _126((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
|
|
1462
2068
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
1463
2069
|
}
|
|
1464
2070
|
});
|
|
@@ -1467,8 +2073,8 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1467
2073
|
const tailPage = cp[0];
|
|
1468
2074
|
if (tailPage === void 0 || tailPage === prev.pageNumber) return;
|
|
1469
2075
|
for (let r = 0; r < pt.rows; r++) for (const { cell, c } of rows[r]) {
|
|
1470
|
-
const head = _optionalChain([ptRows, 'access',
|
|
1471
|
-
if (!_optionalChain([head, 'optionalAccess',
|
|
2076
|
+
const head = _optionalChain([ptRows, 'access', _127 => _127[r], 'optionalAccess', _128 => _128.find, 'call', _129 => _129((s) => s.c === c), 'optionalAccess', _130 => _130.cell]), tail = _optionalChain([ctRows, 'access', _131 => _131[0], 'optionalAccess', _132 => _132.find, 'call', _133 => _133((s) => s.c === c), 'optionalAccess', _134 => _134.cell]);
|
|
2077
|
+
if (!_optionalChain([head, 'optionalAccess', _135 => _135.text, 'access', _136 => _136.trim, 'call', _137 => _137()]) || !_optionalChain([tail, 'optionalAccess', _138 => _138.text, 'access', _139 => _139.trim, 'call', _140 => _140()]) || _optionalChain([cell, 'access', _141 => _141.blocks, 'optionalAccess', _142 => _142.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;
|
|
1472
2078
|
const from = head.text.trimEnd().length, at = cell.text.indexOf(tail.text.trim().slice(0, 20), from);
|
|
1473
2079
|
if (at >= from) setSplits(cell, [...relocate(head, cell), { at, page: tailPage }, ...relocate(tail, cell, at)]);
|
|
1474
2080
|
}
|
|
@@ -1479,7 +2085,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1479
2085
|
for (const { cell } of ctRows[cr]) for (const b of _nullishCoalesce(cell.blocks, () => ( []))) b.pageNumber ??= page;
|
|
1480
2086
|
const heads = covering(pt, pt.rows - 1);
|
|
1481
2087
|
for (const cell of covering(table, pt.rows - 1)) {
|
|
1482
|
-
if (_optionalChain([cell, 'access',
|
|
2088
|
+
if (_optionalChain([cell, 'access', _143 => _143.blocks, 'optionalAccess', _144 => _144.length])) continue;
|
|
1483
2089
|
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];
|
|
1484
2090
|
if (!head) continue;
|
|
1485
2091
|
const from = head.text.trimEnd().length;
|
|
@@ -1490,7 +2096,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1490
2096
|
}
|
|
1491
2097
|
function splitCell(cell, page) {
|
|
1492
2098
|
if (page === void 0) return null;
|
|
1493
|
-
if (_optionalChain([cell, 'access',
|
|
2099
|
+
if (_optionalChain([cell, 'access', _145 => _145.blocks, 'optionalAccess', _146 => _146.length])) {
|
|
1494
2100
|
const k2 = cell.blocks.findIndex((b) => (_nullishCoalesce(b.pageNumber, () => ( page))) > page);
|
|
1495
2101
|
if (k2 <= 0) return null;
|
|
1496
2102
|
const head = cell.blocks.slice(0, k2), tail = cell.blocks.slice(k2);
|
|
@@ -1517,8 +2123,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1517
2123
|
if (!splits.length) continue;
|
|
1518
2124
|
const clone = (cell, patch) => {
|
|
1519
2125
|
const out = { ...cell, ...patch };
|
|
1520
|
-
const p =
|
|
1521
|
-
if (p !== void 0)
|
|
2126
|
+
const p = _chunkYIATOFKCcjs.CELL_PAGES.get(cell);
|
|
2127
|
+
if (p !== void 0) _chunkYIATOFKCcjs.CELL_PAGES.set(out, p);
|
|
1522
2128
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
1523
2129
|
return out;
|
|
1524
2130
|
};
|
|
@@ -1529,7 +2135,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1529
2135
|
for (const { cell, c, split } of splits) {
|
|
1530
2136
|
cells[r][c] = clone(cell, { ...split.head, rowSpan: cut - r });
|
|
1531
2137
|
const tail = { ...cell, ...split.tail, rowSpan: r + cell.rowSpan - cut };
|
|
1532
|
-
|
|
2138
|
+
_chunkYIATOFKCcjs.CELL_PAGES.set(tail, split.page);
|
|
1533
2139
|
setSplits(tail, split.rest);
|
|
1534
2140
|
cells[cut][c] = tail;
|
|
1535
2141
|
}
|
|
@@ -1539,7 +2145,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1539
2145
|
for (const { cell, c, split } of splits) {
|
|
1540
2146
|
cells[r][c] = clone(cell, split.head);
|
|
1541
2147
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
1542
|
-
|
|
2148
|
+
_chunkYIATOFKCcjs.CELL_PAGES.set(tail, split.page);
|
|
1543
2149
|
setSplits(tail, split.rest);
|
|
1544
2150
|
row[c] = tail;
|
|
1545
2151
|
}
|
|
@@ -1581,7 +2187,7 @@ function anchorsOf(table) {
|
|
|
1581
2187
|
for (let r = 0; r < table.rows; r++) {
|
|
1582
2188
|
for (let c = 0; c < table.cols; c++) {
|
|
1583
2189
|
if (covered.has(r * 1e5 + c)) continue;
|
|
1584
|
-
const cell = _optionalChain([table, 'access',
|
|
2190
|
+
const cell = _optionalChain([table, 'access', _147 => _147.cells, 'access', _148 => _148[r], 'optionalAccess', _149 => _149[c]]);
|
|
1585
2191
|
if (!cell) continue;
|
|
1586
2192
|
out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
|
|
1587
2193
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
@@ -1630,7 +2236,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1630
2236
|
if (cols < 1) return null;
|
|
1631
2237
|
const pa = anchorsOf(prev), ca = anchorsOf(curr);
|
|
1632
2238
|
const cutOpen = (() => {
|
|
1633
|
-
const u =
|
|
2239
|
+
const u = _chunkFG3SD2G3cjs.ROW_RULES.get(prev), d = _chunkFG3SD2G3cjs.ROW_RULES.get(curr);
|
|
1634
2240
|
return !!u && !!d && !u.bottom && !d.top;
|
|
1635
2241
|
})();
|
|
1636
2242
|
let skip = 0, head = 0;
|
|
@@ -1662,24 +2268,24 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1662
2268
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
1663
2269
|
}
|
|
1664
2270
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
1665
|
-
const lines =
|
|
1666
|
-
if (lines)
|
|
1667
|
-
if (
|
|
1668
|
-
const edges =
|
|
2271
|
+
const lines = _chunkFG3SD2G3cjs.CELL_LINES.get(a.cell);
|
|
2272
|
+
if (lines) _chunkFG3SD2G3cjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
2273
|
+
if (_chunkFG3SD2G3cjs.IMAGE_CELLS.has(a.cell)) _chunkFG3SD2G3cjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
2274
|
+
const edges = _chunkYIATOFKCcjs.CELL_EDGES.get(a.cell);
|
|
1669
2275
|
if (edges) {
|
|
1670
|
-
|
|
2276
|
+
_chunkYIATOFKCcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
1671
2277
|
edged = true;
|
|
1672
2278
|
}
|
|
1673
2279
|
return true;
|
|
1674
2280
|
};
|
|
1675
|
-
for (const a of pa) if (!
|
|
2281
|
+
for (const a of pa) if (!_chunkFG3SD2G3cjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
1676
2282
|
for (const a of ca) {
|
|
1677
|
-
if (a.r < skip ||
|
|
2283
|
+
if (a.r < skip || _chunkFG3SD2G3cjs.FILLER_CELLS.has(a.cell)) continue;
|
|
1678
2284
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
1679
2285
|
}
|
|
1680
2286
|
const first = prev.rows;
|
|
1681
2287
|
for (let c = 0; c < cols; c++) {
|
|
1682
|
-
const above = _optionalChain([owner, 'access',
|
|
2288
|
+
const above = _optionalChain([owner, 'access', _150 => _150[first - 1], 'optionalAccess', _151 => _151[c]]);
|
|
1683
2289
|
if (!above) continue;
|
|
1684
2290
|
let r = first;
|
|
1685
2291
|
while (r < rows && owner[r][c] === null) r++;
|
|
@@ -1698,9 +2304,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1698
2304
|
const grown = { ...above, rs: newRs };
|
|
1699
2305
|
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;
|
|
1700
2306
|
}
|
|
1701
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
2307
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkFG3SD2G3cjs.FILLER_CELLS.add(grid[r][c]);
|
|
1702
2308
|
if (edged) {
|
|
1703
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
2309
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkYIATOFKCcjs.CELL_EDGES.set(grid[r][c], _chunkFG3SD2G3cjs.NO_EDGES);
|
|
1704
2310
|
}
|
|
1705
2311
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1706
2312
|
let r = prev.rows;
|
|
@@ -1709,7 +2315,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1709
2315
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1710
2316
|
}
|
|
1711
2317
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1712
|
-
const pr =
|
|
2318
|
+
const pr = _chunkFG3SD2G3cjs.ROW_RULES.get(prev), cr = _chunkFG3SD2G3cjs.ROW_RULES.get(curr);
|
|
1713
2319
|
const shifted = dx !== 0;
|
|
1714
2320
|
const cut = {
|
|
1715
2321
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1717,13 +2323,13 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1717
2323
|
list: !shifted ? "any" : skip > 0 && ca.filter((a) => a.r < skip && a.cell.text.trim()).length < 2 ? "none" : "multi"
|
|
1718
2324
|
};
|
|
1719
2325
|
let partial = !skip && cols === prev.cols && cols === curr.cols && cut.ruled && prevBottom !== void 0 ? partialAlignedLabelCells(table, owner, first) : void 0;
|
|
1720
|
-
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]) ||
|
|
2326
|
+
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]) || _chunkFG3SD2G3cjs.startsNewItem.call(void 0, partial.value.upper.text, partial.value.lower.text))) partial = void 0;
|
|
1721
2327
|
const selected = partial ? /* @__PURE__ */ new Set([partial.label.c, partial.value.c]) : void 0;
|
|
1722
2328
|
let split = !selected && rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
|
|
1723
2329
|
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 });
|
|
1724
2330
|
if (pr && cr) {
|
|
1725
2331
|
const cutRuled = pr.bottom || cr.top;
|
|
1726
|
-
|
|
2332
|
+
_chunkFG3SD2G3cjs.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) });
|
|
1727
2333
|
}
|
|
1728
2334
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1729
2335
|
}
|
|
@@ -1785,19 +2391,19 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1785
2391
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1786
2392
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1787
2393
|
if (selected && !selected.has(u.c)) continue;
|
|
1788
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1789
|
-
const openSeam = hasContent(a) && hasContent(b) &&
|
|
2394
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkFG3SD2G3cjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
2395
|
+
const openSeam = hasContent(a) && hasContent(b) && _chunkFG3SD2G3cjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
|
|
1790
2396
|
if (!r || r === first) return false;
|
|
1791
2397
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1792
2398
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1793
|
-
const ue =
|
|
2399
|
+
const ue = _chunkYIATOFKCcjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkYIATOFKCcjs.CELL_EDGES.get(table.cells[down.r][down.c]);
|
|
1794
2400
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1795
2401
|
});
|
|
1796
2402
|
if (!selected && !openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1797
2403
|
if (!straddles && !midWord) continue;
|
|
1798
2404
|
if (u.r >= last && d.rs < 2) continue;
|
|
1799
|
-
const U =
|
|
1800
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
2405
|
+
const U = _chunkFG3SD2G3cjs.CELL_LINES.get(a);
|
|
2406
|
+
if (!_optionalChain([U, 'optionalAccess', _152 => _152.length]) || !hasContent(b)) continue;
|
|
1801
2407
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1802
2408
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
1803
2409
|
const lu = U[U.length - 1];
|
|
@@ -1814,7 +2420,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1814
2420
|
return merged;
|
|
1815
2421
|
}
|
|
1816
2422
|
function longLastLine(c) {
|
|
1817
|
-
const L =
|
|
2423
|
+
const L = _chunkFG3SD2G3cjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _153 => _153[L.length - 1]]);
|
|
1818
2424
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1819
2425
|
}
|
|
1820
2426
|
function filledToBottom(U, bottom) {
|
|
@@ -1847,8 +2453,8 @@ function nextItemHead(prev, next) {
|
|
|
1847
2453
|
return false;
|
|
1848
2454
|
}
|
|
1849
2455
|
function continuesAcross(u, d, x1, x2) {
|
|
1850
|
-
const U =
|
|
1851
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
2456
|
+
const U = _chunkFG3SD2G3cjs.CELL_LINES.get(u), D = _chunkFG3SD2G3cjs.CELL_LINES.get(d);
|
|
2457
|
+
if (!_optionalChain([U, 'optionalAccess', _154 => _154.length]) || !_optionalChain([D, 'optionalAccess', _155 => _155.length])) return false;
|
|
1852
2458
|
const last = U[U.length - 1];
|
|
1853
2459
|
const fs = last.h || 10;
|
|
1854
2460
|
let minL = Infinity, maxR = -Infinity;
|
|
@@ -1865,7 +2471,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1865
2471
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1866
2472
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1867
2473
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1868
|
-
const newItem =
|
|
2474
|
+
const newItem = _chunkFG3SD2G3cjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1869
2475
|
const all = D.length ? U.concat(D) : U;
|
|
1870
2476
|
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));
|
|
1871
2477
|
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;
|
|
@@ -1882,12 +2488,12 @@ function outlineContinues(u, d) {
|
|
|
1882
2488
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1883
2489
|
}
|
|
1884
2490
|
function lineEnded(c, x1, x2, next) {
|
|
1885
|
-
const L =
|
|
2491
|
+
const L = _chunkFG3SD2G3cjs.CELL_LINES.get(c);
|
|
1886
2492
|
if (!L || L.length !== 1) return false;
|
|
1887
2493
|
const l = L[0], h = l.h || 10;
|
|
1888
|
-
const d0 = next ? _optionalChain([
|
|
2494
|
+
const d0 = next ? _optionalChain([_chunkFG3SD2G3cjs.CELL_LINES, 'access', _156 => _156.get, 'call', _157 => _157(next), 'optionalAccess', _158 => _158[0]]) : void 0;
|
|
1889
2495
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1890
|
-
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
2496
|
+
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _159 => _159.text]), () => ( "")))) * h;
|
|
1891
2497
|
}
|
|
1892
2498
|
function firstWordUnits(text) {
|
|
1893
2499
|
const word = _nullishCoalesce(flowText(text).trim().replace(/^([(\[「『<〈])\s+/, "$1").split(/\s+/)[0], () => ( ""));
|
|
@@ -1896,15 +2502,15 @@ function firstWordUnits(text) {
|
|
|
1896
2502
|
return units;
|
|
1897
2503
|
}
|
|
1898
2504
|
function appendCell(a, b) {
|
|
1899
|
-
if (
|
|
1900
|
-
if (_optionalChain([a, 'access',
|
|
1901
|
-
const asBlocks = (c) => _optionalChain([c, 'access',
|
|
2505
|
+
if (_chunkFG3SD2G3cjs.IMAGE_CELLS.has(b)) _chunkFG3SD2G3cjs.IMAGE_CELLS.add(a);
|
|
2506
|
+
if (_optionalChain([a, 'access', _160 => _160.blocks, 'optionalAccess', _161 => _161.length]) || _optionalChain([b, 'access', _162 => _162.blocks, 'optionalAccess', _163 => _163.length])) {
|
|
2507
|
+
const asBlocks = (c) => _optionalChain([c, 'access', _164 => _164.blocks, 'optionalAccess', _165 => _165.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
|
|
1902
2508
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1903
2509
|
}
|
|
1904
2510
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1905
|
-
|
|
2511
|
+
_chunkFG3SD2G3cjs.joinCellEdges.call(void 0, a, b);
|
|
1906
2512
|
}
|
|
1907
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access',
|
|
2513
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _166 => _166.blocks, 'optionalAccess', _167 => _167.length]) || _chunkFG3SD2G3cjs.IMAGE_CELLS.has(cell);
|
|
1908
2514
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1909
2515
|
var batchim = (ch) => {
|
|
1910
2516
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1912,7 +2518,7 @@ var batchim = (ch) => {
|
|
|
1912
2518
|
};
|
|
1913
2519
|
function clauseContinues(u, d) {
|
|
1914
2520
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1915
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
2521
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkFG3SD2G3cjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1916
2522
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1917
2523
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1918
2524
|
}
|
|
@@ -1920,8 +2526,8 @@ function quantityContinues(u, d) {
|
|
|
1920
2526
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1921
2527
|
}
|
|
1922
2528
|
function wordOverflows(u, d, x1, x2) {
|
|
1923
|
-
const U =
|
|
1924
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
2529
|
+
const U = _chunkFG3SD2G3cjs.CELL_LINES.get(u);
|
|
2530
|
+
if (!_optionalChain([U, 'optionalAccess', _168 => _168.length]) || _chunkFG3SD2G3cjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1925
2531
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1926
2532
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1927
2533
|
}
|
|
@@ -1931,7 +2537,7 @@ function listContinues(u, d, multi = false) {
|
|
|
1931
2537
|
const marks = u.text.split("\n").map((l) => itemMark(l.trim()));
|
|
1932
2538
|
let last = -1, count = 0;
|
|
1933
2539
|
marks.forEach((m, i) => {
|
|
1934
|
-
if (_optionalChain([m, 'optionalAccess',
|
|
2540
|
+
if (_optionalChain([m, 'optionalAccess', _169 => _169.style]) === head.style) {
|
|
1935
2541
|
last = i;
|
|
1936
2542
|
count++;
|
|
1937
2543
|
}
|
|
@@ -1991,7 +2597,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1991
2597
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1992
2598
|
const openCut = cut.open && !newCell;
|
|
1993
2599
|
if (!openCut && 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;
|
|
1994
|
-
const oneLine = (c) => _optionalChain([
|
|
2600
|
+
const oneLine = (c) => _optionalChain([_chunkFG3SD2G3cjs.CELL_LINES, 'access', _170 => _170.get, 'call', _171 => _171(c), 'optionalAccess', _172 => _172.length]) === 1;
|
|
1995
2601
|
if (!openCut && 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;
|
|
1996
2602
|
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;
|
|
1997
2603
|
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));
|
|
@@ -2023,8 +2629,8 @@ function besideOwn(b, p, c) {
|
|
|
2023
2629
|
}
|
|
2024
2630
|
var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
|
|
2025
2631
|
function pageNumberBetween(b, p, c, pageHeights) {
|
|
2026
|
-
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
2027
|
-
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess',
|
|
2632
|
+
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _173 => _173.text, 'optionalAccess', _174 => _174.trim, 'call', _175 => _175()]), () => ( "")))) return false;
|
|
2633
|
+
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _176 => _176.get, 'call', _177 => _177(b.pageNumber)]) : void 0;
|
|
2028
2634
|
if (!h) return false;
|
|
2029
2635
|
if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
|
|
2030
2636
|
if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
|
|
@@ -2048,7 +2654,7 @@ function insideTable(b, t) {
|
|
|
2048
2654
|
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;
|
|
2049
2655
|
}
|
|
2050
2656
|
function startsWithUnitRow(table) {
|
|
2051
|
-
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access',
|
|
2657
|
+
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _178 => _178.cells, 'access', _179 => _179[0], 'optionalAccess', _180 => _180[0], 'optionalAccess', _181 => _181.text]), () => ( ""))) && _optionalChain([table, 'access', _182 => _182.cells, 'access', _183 => _183[0], 'optionalAccess', _184 => _184.slice, 'call', _185 => _185(1), 'access', _186 => _186.every, 'call', _187 => _187((c) => !c.text.trim())]);
|
|
2052
2658
|
}
|
|
2053
2659
|
function sameHeadShape(a, b) {
|
|
2054
2660
|
if (!a || !b || a.length !== b.length) return false;
|
|
@@ -2060,7 +2666,7 @@ function sameHeadShape(a, b) {
|
|
|
2060
2666
|
return tall;
|
|
2061
2667
|
}
|
|
2062
2668
|
function hasBoxTitle(t) {
|
|
2063
|
-
const titles = _nullishCoalesce(_optionalChain([t, 'access',
|
|
2669
|
+
const titles = _nullishCoalesce(_optionalChain([t, 'access', _188 => _188.cells, 'access', _189 => _189[0], 'optionalAccess', _190 => _190.filter, 'call', _191 => _191((c) => c.text.trim())]), () => ( []));
|
|
2064
2670
|
if (titles.length !== 1 || titles[0].rowSpan < 2) return false;
|
|
2065
2671
|
const body = t.cells[titles[0].rowSpan];
|
|
2066
2672
|
return !!body && body[0].colSpan === t.cols && !!body[0].text.trim();
|
|
@@ -2074,7 +2680,7 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
2074
2680
|
const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
|
|
2075
2681
|
while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
|
|
2076
2682
|
const curr = blocks[j];
|
|
2077
|
-
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess',
|
|
2683
|
+
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _192 => _192.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
|
|
2078
2684
|
if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
|
|
2079
2685
|
if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
|
|
2080
2686
|
if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
|
|
@@ -2084,19 +2690,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
2084
2690
|
placeJoined(blocks, i, j, joined);
|
|
2085
2691
|
continue;
|
|
2086
2692
|
}
|
|
2087
|
-
if (
|
|
2693
|
+
if (_chunkFG3SD2G3cjs.EMPTY_PARTS.has(curr.table)) {
|
|
2088
2694
|
blocks.splice(j, 1);
|
|
2089
2695
|
i++;
|
|
2090
2696
|
continue;
|
|
2091
2697
|
}
|
|
2092
2698
|
if (joined === null) continue;
|
|
2093
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
2699
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkFG3SD2G3cjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
2094
2700
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
2095
2701
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
2096
2702
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
2097
2703
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
2098
|
-
const px =
|
|
2099
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
2704
|
+
const px = _chunkFG3SD2G3cjs.TABLE_COLXS.get(prev.table), cx = _chunkFG3SD2G3cjs.TABLE_COLXS.get(curr.table);
|
|
2705
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkFG3SD2G3cjs.CLIP_TABLES.has(prev.table) && !_chunkFG3SD2G3cjs.CLIP_TABLES.has(curr.table))) continue;
|
|
2100
2706
|
if (!px !== !cx) continue;
|
|
2101
2707
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
2102
2708
|
let currCells = curr.table.cells;
|
|
@@ -2108,16 +2714,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
2108
2714
|
blocks.splice(j, 1);
|
|
2109
2715
|
continue;
|
|
2110
2716
|
}
|
|
2111
|
-
if (px && cx && !
|
|
2717
|
+
if (px && cx && !_chunkFG3SD2G3cjs.CLIP_TABLES.has(prev.table) && !_chunkFG3SD2G3cjs.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 && _chunkFG3SD2G3cjs.CELL_LINES.has(c))) {
|
|
2112
2718
|
const dx = px[0] - cx[0];
|
|
2113
2719
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
2114
|
-
if (_optionalChain([part, 'optionalAccess',
|
|
2720
|
+
if (_optionalChain([part, 'optionalAccess', _193 => _193.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
2115
2721
|
const last = prev.table.rows - 1;
|
|
2116
2722
|
for (let c = 0; c < part.table.cols; c++) {
|
|
2117
|
-
const U =
|
|
2118
|
-
|
|
2723
|
+
const U = _chunkFG3SD2G3cjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkFG3SD2G3cjs.CELL_LINES.get(currCells[0][c]);
|
|
2724
|
+
_chunkFG3SD2G3cjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
2119
2725
|
}
|
|
2120
|
-
|
|
2726
|
+
_chunkFG3SD2G3cjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
2121
2727
|
placeJoined(blocks, i, j, part.table);
|
|
2122
2728
|
continue;
|
|
2123
2729
|
}
|
|
@@ -2130,20 +2736,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
2130
2736
|
caption: prev.table.caption,
|
|
2131
2737
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
2132
2738
|
};
|
|
2133
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
2134
|
-
if (
|
|
2739
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkFG3SD2G3cjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
2740
|
+
if (_chunkFG3SD2G3cjs.CLIP_TABLES.has(prev.table) || _chunkFG3SD2G3cjs.CLIP_TABLES.has(curr.table)) _chunkFG3SD2G3cjs.CLIP_TABLES.add(merged);
|
|
2135
2741
|
placeJoined(blocks, i, j, merged);
|
|
2136
2742
|
}
|
|
2137
2743
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
2138
2744
|
const t = blocks[i].table;
|
|
2139
|
-
if (blocks[i].type === "table" && t &&
|
|
2745
|
+
if (blocks[i].type === "table" && t && _chunkFG3SD2G3cjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
2140
2746
|
}
|
|
2141
2747
|
}
|
|
2142
2748
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
2143
2749
|
if (!pageHeights) return;
|
|
2144
2750
|
for (let i = 0; i < blocks.length; i++) {
|
|
2145
2751
|
const L = blocks[i];
|
|
2146
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
2752
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkFG3SD2G3cjs.CLIP_TABLES.has(L.table) || _chunkFG3SD2G3cjs.EMPTY_PARTS.has(L.table)) continue;
|
|
2147
2753
|
const ph = pageHeights.get(L.pageNumber);
|
|
2148
2754
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
2149
2755
|
let s0 = i, s1 = i;
|
|
@@ -2162,8 +2768,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
2162
2768
|
if (Math.abs(R.bbox.width - L.bbox.width) > Math.max(R.bbox.width, L.bbox.width) * NEIGHBOR_TABLE_EPSILON) continue;
|
|
2163
2769
|
if (!looksContinued(L, R) || restartsTable(blocks, i, R.table, pageHeights)) continue;
|
|
2164
2770
|
const rt = R.table;
|
|
2165
|
-
if (rt.rows === 1 && rt.cols === 1 && !
|
|
2166
|
-
const px =
|
|
2771
|
+
if (rt.rows === 1 && rt.cols === 1 && !_chunkFG3SD2G3cjs.CLIP_TABLES.has(rt) && L.table.rows >= 2) {
|
|
2772
|
+
const px = _chunkFG3SD2G3cjs.TABLE_COLXS.get(L.table), lb = L.bbox;
|
|
2167
2773
|
const dx = lb.x + lb.width - (R.bbox.x + R.bbox.width);
|
|
2168
2774
|
const last = L.table.cells[L.table.rows - 1];
|
|
2169
2775
|
let col = 0;
|
|
@@ -2192,12 +2798,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
2192
2798
|
}
|
|
2193
2799
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
2194
2800
|
const pt = prev.table, ct = curr.table;
|
|
2195
|
-
if (!
|
|
2196
|
-
const px =
|
|
2801
|
+
if (!_chunkFG3SD2G3cjs.CLIP_TABLES.has(pt) || !_chunkFG3SD2G3cjs.CLIP_TABLES.has(ct)) return null;
|
|
2802
|
+
const px = _chunkFG3SD2G3cjs.TABLE_COLXS.get(pt), cx = _chunkFG3SD2G3cjs.TABLE_COLXS.get(ct);
|
|
2197
2803
|
if (!px || !cx) return null;
|
|
2198
2804
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
2199
2805
|
if (!shiftedSame(px, cx, false)) {
|
|
2200
|
-
if (!_optionalChain([pageHeights, 'optionalAccess',
|
|
2806
|
+
if (!_optionalChain([pageHeights, 'optionalAccess', _194 => _194.get, 'call', _195 => _195(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _196 => _196.get, 'call', _197 => _197(curr.pageNumber)])) return null;
|
|
2201
2807
|
dx = px[px.length - 1] - cx[cx.length - 1];
|
|
2202
2808
|
within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
2203
2809
|
if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
|
|
@@ -2209,19 +2815,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
2209
2815
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
2210
2816
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
2211
2817
|
};
|
|
2212
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
2818
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkFG3SD2G3cjs.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);
|
|
2213
2819
|
}
|
|
2214
|
-
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access',
|
|
2820
|
+
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _198 => _198.bbox, 'optionalAccess', _199 => _199.y]), lex);
|
|
2215
2821
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
2216
|
-
|
|
2217
|
-
const ys =
|
|
2218
|
-
if (ys)
|
|
2219
|
-
|
|
2220
|
-
|
|
2822
|
+
_chunkFG3SD2G3cjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
2823
|
+
const ys = _chunkFG3SD2G3cjs.TABLE_ROWYS.get(pt);
|
|
2824
|
+
if (ys) _chunkFG3SD2G3cjs.TABLE_ROWYS.set(res.table, ys);
|
|
2825
|
+
_chunkFG3SD2G3cjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkFG3SD2G3cjs.PART_COLXS.get(pt), () => ( px)));
|
|
2826
|
+
_chunkFG3SD2G3cjs.CLIP_TABLES.add(res.table);
|
|
2221
2827
|
return res.table;
|
|
2222
2828
|
}
|
|
2223
2829
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
2224
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
2830
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _200 => _200.get, 'call', _201 => _201(prev.pageNumber)]);
|
|
2225
2831
|
if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
|
|
2226
2832
|
return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
|
|
2227
2833
|
}
|
|
@@ -2232,21 +2838,21 @@ function headingRow(row) {
|
|
|
2232
2838
|
}
|
|
2233
2839
|
var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
|
|
2234
2840
|
function looksContinued(prev, curr, pageHeights) {
|
|
2235
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
2841
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _202 => _202.get, 'call', _203 => _203(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _204 => _204.get, 'call', _205 => _205(curr.pageNumber)]);
|
|
2236
2842
|
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;
|
|
2237
2843
|
const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
|
|
2238
|
-
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access',
|
|
2844
|
+
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _206 => _206.find, 'call', _207 => _207((c) => c.text.trim()), 'optionalAccess', _208 => _208.text]), () => ( ""));
|
|
2239
2845
|
if (!ANNEX_HEAD_RE.test(firstText)) return true;
|
|
2240
2846
|
const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
|
|
2241
2847
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
2242
2848
|
}
|
|
2243
2849
|
function pushedLead(prev, curr) {
|
|
2244
|
-
if (!
|
|
2850
|
+
if (!_chunkFG3SD2G3cjs.CLIP_TABLES.has(prev.table) || !_chunkFG3SD2G3cjs.CLIP_TABLES.has(curr.table)) return false;
|
|
2245
2851
|
const lead = leadRows(curr.table);
|
|
2246
2852
|
return lead.image && lead.height > prev.bbox.y;
|
|
2247
2853
|
}
|
|
2248
2854
|
function leadRows(t) {
|
|
2249
|
-
const ys =
|
|
2855
|
+
const ys = _chunkFG3SD2G3cjs.TABLE_ROWYS.get(t);
|
|
2250
2856
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
2251
2857
|
const anchors = anchorsOf(t);
|
|
2252
2858
|
let end = 1, image = false;
|
|
@@ -2254,17 +2860,17 @@ function leadRows(t) {
|
|
|
2254
2860
|
for (const a of anchors) {
|
|
2255
2861
|
if (a.r !== r) continue;
|
|
2256
2862
|
end = Math.max(end, r + a.rs);
|
|
2257
|
-
if (
|
|
2863
|
+
if (_chunkFG3SD2G3cjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
2258
2864
|
}
|
|
2259
2865
|
}
|
|
2260
2866
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
2261
2867
|
}
|
|
2262
2868
|
function tailOf(b) {
|
|
2263
|
-
const t = b.table &&
|
|
2869
|
+
const t = b.table && _chunkFG3SD2G3cjs.TABLE_TAIL.get(b.table);
|
|
2264
2870
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
2265
2871
|
}
|
|
2266
2872
|
function firstRowSig(t) {
|
|
2267
|
-
const x =
|
|
2873
|
+
const x = _chunkFG3SD2G3cjs.TABLE_COLXS.get(t);
|
|
2268
2874
|
if (!x || x.length !== t.cols + 1) return null;
|
|
2269
2875
|
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, "") }));
|
|
2270
2876
|
}
|
|
@@ -2289,9 +2895,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
|
|
|
2289
2895
|
}
|
|
2290
2896
|
function restartsTitledForm(head, curr) {
|
|
2291
2897
|
if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
|
|
2292
|
-
const full = (t) => _optionalChain([t, 'access',
|
|
2898
|
+
const full = (t) => _optionalChain([t, 'access', _209 => _209.cells, 'access', _210 => _210[0], 'access', _211 => _211[0], 'optionalAccess', _212 => _212.colSpan]) === t.cols;
|
|
2293
2899
|
if (!full(head) || !full(curr)) return false;
|
|
2294
|
-
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
2900
|
+
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _213 => _213.text]), () => ( ""))).replace(/\s+/g, "");
|
|
2295
2901
|
const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
|
|
2296
2902
|
if (!ht || !ct || ht === ct) return false;
|
|
2297
2903
|
const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
|
|
@@ -2317,7 +2923,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
2317
2923
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
2318
2924
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
2319
2925
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
2320
|
-
const px =
|
|
2926
|
+
const px = _chunkFG3SD2G3cjs.TABLE_COLXS.get(pb.table), cx = _chunkFG3SD2G3cjs.TABLE_COLXS.get(cur.table);
|
|
2321
2927
|
if (!px || !cx) break;
|
|
2322
2928
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
2323
2929
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -2334,7 +2940,7 @@ function continueRowSpans(prevCells, currCells) {
|
|
|
2334
2940
|
if (hasContent(cell) || (cell.rowSpan || 1) < 2) continue;
|
|
2335
2941
|
let anchor;
|
|
2336
2942
|
for (let r = last - 1; r >= 0 && !anchor; r--) {
|
|
2337
|
-
const a = _optionalChain([prevCells, 'access',
|
|
2943
|
+
const a = _optionalChain([prevCells, 'access', _214 => _214[r], 'optionalAccess', _215 => _215[c]]);
|
|
2338
2944
|
if (a && r + (a.rowSpan || 1) === last && (a.colSpan || 1) === (cell.colSpan || 1) && (hasContent(a) || a.rowSpan >= 2)) anchor = a;
|
|
2339
2945
|
}
|
|
2340
2946
|
if (!anchor) continue;
|
|
@@ -2388,12 +2994,12 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
2388
2994
|
var COL_MATCH_TOL = 0.5;
|
|
2389
2995
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
2390
2996
|
function lastRowCell(t, x1, x2) {
|
|
2391
|
-
const xs =
|
|
2997
|
+
const xs = _chunkFG3SD2G3cjs.TABLE_COLXS.get(t);
|
|
2392
2998
|
const covered = /* @__PURE__ */ new Set();
|
|
2393
2999
|
for (let r = 0; r < t.rows; r++) {
|
|
2394
3000
|
for (let c = 0; c < t.cols; c++) {
|
|
2395
3001
|
if (covered.has(r * 1e5 + c)) continue;
|
|
2396
|
-
const cell = _optionalChain([t, 'access',
|
|
3002
|
+
const cell = _optionalChain([t, 'access', _216 => _216.cells, 'access', _217 => _217[r], 'optionalAccess', _218 => _218[c]]);
|
|
2397
3003
|
if (!cell) continue;
|
|
2398
3004
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
|
|
2399
3005
|
if (r + cell.rowSpan !== t.rows) continue;
|
|
@@ -2406,7 +3012,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
2406
3012
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
2407
3013
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
2408
3014
|
const part = blocks[j];
|
|
2409
|
-
const from = part.table ?
|
|
3015
|
+
const from = part.table ? _chunkFG3SD2G3cjs.CONT_PARTS.get(part.table) : void 0;
|
|
2410
3016
|
if (!from || !part.table) {
|
|
2411
3017
|
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
2412
3018
|
continue;
|
|
@@ -2416,18 +3022,18 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
2416
3022
|
const prev = blocks[i];
|
|
2417
3023
|
if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
|
|
2418
3024
|
const cell = lastRowCell(prev.table, from.x1, from.x2);
|
|
2419
|
-
const add = _optionalChain([part, 'access',
|
|
3025
|
+
const add = _optionalChain([part, 'access', _219 => _219.table, 'access', _220 => _220.cells, 'access', _221 => _221[0], 'optionalAccess', _222 => _222[0]]);
|
|
2420
3026
|
if (!cell || !add) continue;
|
|
2421
3027
|
const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
|
|
2422
3028
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
2423
3029
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
2424
3030
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
2425
|
-
if (
|
|
2426
|
-
|
|
2427
|
-
const lines =
|
|
2428
|
-
if (_optionalChain([lines, 'optionalAccess',
|
|
2429
|
-
if (part.pageNumber && part.bbox)
|
|
2430
|
-
if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
3031
|
+
if (_chunkFG3SD2G3cjs.IMAGE_CELLS.has(add)) _chunkFG3SD2G3cjs.IMAGE_CELLS.add(cell);
|
|
3032
|
+
_chunkFG3SD2G3cjs.joinCellEdges.call(void 0, cell, add);
|
|
3033
|
+
const lines = _chunkFG3SD2G3cjs.CELL_LINES.get(add);
|
|
3034
|
+
if (_optionalChain([lines, 'optionalAccess', _223 => _223.length])) _chunkFG3SD2G3cjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkFG3SD2G3cjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
3035
|
+
if (part.pageNumber && part.bbox) _chunkFG3SD2G3cjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkFG3SD2G3cjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
3036
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _224 => _224.blocks, 'optionalAccess', _225 => _225.length]) || _chunkFG3SD2G3cjs.IMAGE_CELLS.has(cell)) _chunkFG3SD2G3cjs.EMPTY_PARTS.delete(prev.table);
|
|
2431
3037
|
blocks.splice(j, 1);
|
|
2432
3038
|
if (cell.blocks && at > 0) {
|
|
2433
3039
|
const nextAt = cell.blocks[at];
|
|
@@ -2439,35 +3045,32 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
2439
3045
|
}
|
|
2440
3046
|
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
2441
3047
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
2442
|
-
if (!_optionalChain([prev, 'optionalAccess',
|
|
2443
|
-
const inner = _optionalChain([frame, 'access',
|
|
2444
|
-
const next = _optionalChain([inner, 'optionalAccess',
|
|
2445
|
-
if (!inner || !_optionalChain([next, 'optionalAccess',
|
|
2446
|
-
const px =
|
|
3048
|
+
if (!_optionalChain([prev, 'optionalAccess', _226 => _226.table]) || !_optionalChain([frame, 'optionalAccess', _227 => _227.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkFG3SD2G3cjs.CLIP_TABLES.has(frame.table)) return;
|
|
3049
|
+
const inner = _optionalChain([frame, 'access', _228 => _228.table, 'access', _229 => _229.cells, 'access', _230 => _230[0], 'optionalAccess', _231 => _231[0], 'optionalAccess', _232 => _232.blocks]);
|
|
3050
|
+
const next = _optionalChain([inner, 'optionalAccess', _233 => _233[0]]);
|
|
3051
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _234 => _234.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkFG3SD2G3cjs.CLIP_TABLES.has(prev.table) || !_chunkFG3SD2G3cjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
3052
|
+
const px = _chunkFG3SD2G3cjs.TABLE_COLXS.get(prev.table), nx = _chunkFG3SD2G3cjs.TABLE_COLXS.get(next.table);
|
|
2447
3053
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
2448
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
3054
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _235 => _235.get, 'call', _236 => _236(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _237 => _237.get, 'call', _238 => _238(next.pageNumber)]);
|
|
2449
3055
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
2450
|
-
if (splitOnly && (inner.length !== 1 || !_optionalChain([joinSplitParts, 'call',
|
|
3056
|
+
if (splitOnly && (inner.length !== 1 || !_optionalChain([joinSplitParts, 'call', _239 => _239(prev.table, px, next.table, nx, 0, prev.bbox.y), 'optionalAccess', _240 => _240.split]))) return;
|
|
2451
3057
|
blocks.splice(at, 1, ...inner);
|
|
2452
3058
|
}
|
|
2453
3059
|
function fillNestedContinuation(blocks, at) {
|
|
2454
3060
|
const prev = blocks[at - 1], next = blocks[at];
|
|
2455
|
-
const t = _optionalChain([prev, 'optionalAccess',
|
|
2456
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
2457
|
-
const xs =
|
|
3061
|
+
const t = _optionalChain([prev, 'optionalAccess', _241 => _241.table]), u = _optionalChain([next, 'optionalAccess', _242 => _242.table]);
|
|
3062
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkFG3SD2G3cjs.CLIP_TABLES.has(t) || !_chunkFG3SD2G3cjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
3063
|
+
const xs = _chunkFG3SD2G3cjs.TABLE_COLXS.get(u);
|
|
2458
3064
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
2459
|
-
const add = _optionalChain([u, 'access',
|
|
2460
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access',
|
|
3065
|
+
const add = _optionalChain([u, 'access', _243 => _243.cells, 'access', _244 => _244[0], 'optionalAccess', _245 => _245[0]]);
|
|
3066
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _246 => _246.blocks, 'optionalAccess', _247 => _247.length]) || _chunkFG3SD2G3cjs.IMAGE_CELLS.has(cell)) return;
|
|
2461
3067
|
cell.text = add.text;
|
|
2462
3068
|
if (add.blocks) cell.blocks = add.blocks;
|
|
2463
|
-
if (
|
|
2464
|
-
|
|
3069
|
+
if (_chunkFG3SD2G3cjs.IMAGE_CELLS.has(add)) _chunkFG3SD2G3cjs.IMAGE_CELLS.add(cell);
|
|
3070
|
+
_chunkFG3SD2G3cjs.joinCellEdges.call(void 0, cell, add);
|
|
2465
3071
|
blocks.splice(at, 1);
|
|
2466
3072
|
}
|
|
2467
3073
|
|
|
2468
|
-
// src/pdf/symbol-glyphs.ts
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
3074
|
// src/pdf/known-font-glyphs.ts
|
|
2472
3075
|
|
|
2473
3076
|
var FACES = {
|
|
@@ -2871,7 +3474,7 @@ var KNOWN = {
|
|
|
2871
3474
|
// │
|
|
2872
3475
|
};
|
|
2873
3476
|
function knownFontPua(name, outline, width) {
|
|
2874
|
-
const face = FACES[_nullishCoalesce(_optionalChain([name, 'optionalAccess',
|
|
3477
|
+
const face = FACES[_nullishCoalesce(_optionalChain([name, 'optionalAccess', _248 => _248.replace, 'call', _249 => _249(/^[A-Z]{6}\+/, "")]), () => ( ""))];
|
|
2875
3478
|
if (!face) return null;
|
|
2876
3479
|
const hit = KNOWN[_crypto.createHash.call(void 0, "sha256").update(JSON.stringify([outline.upm, width, outline.contours])).digest("hex").slice(0, 16)];
|
|
2877
3480
|
return hit && hit[1] & face ? hit[0] : null;
|
|
@@ -2906,13 +3509,13 @@ function glyphId(b, cmap, code) {
|
|
|
2906
3509
|
if (code < start || code > end) continue;
|
|
2907
3510
|
const delta = i16(b, deltas + 2 * s), ro = u16(b, ranges + 2 * s);
|
|
2908
3511
|
if (!ro) return code + delta & 65535;
|
|
2909
|
-
const
|
|
2910
|
-
return
|
|
3512
|
+
const g = u16(b, ranges + 2 * s + ro + 2 * (code - start));
|
|
3513
|
+
return g ? g + delta & 65535 : -1;
|
|
2911
3514
|
}
|
|
2912
3515
|
} else if (fmt === 12) {
|
|
2913
3516
|
const groups = u32(b, off + 12);
|
|
2914
|
-
for (let
|
|
2915
|
-
const r = off + 16 + 12 *
|
|
3517
|
+
for (let g = 0; g < groups; g++) {
|
|
3518
|
+
const r = off + 16 + 12 * g, sc = u32(b, r), ec = u32(b, r + 4);
|
|
2916
3519
|
if (code >= sc && code <= ec) return u32(b, r + 8) + code - sc;
|
|
2917
3520
|
}
|
|
2918
3521
|
}
|
|
@@ -2929,13 +3532,13 @@ function readOutline(b, code) {
|
|
|
2929
3532
|
const a = longLoca ? u32(b, loca + 4 * gid) : 2 * u16(b, loca + 2 * gid);
|
|
2930
3533
|
const z = longLoca ? u32(b, loca + 4 * gid + 4) : 2 * u16(b, loca + 2 * gid + 2);
|
|
2931
3534
|
if (z <= a) return null;
|
|
2932
|
-
const
|
|
3535
|
+
const g = glyf + a, nc = i16(b, g);
|
|
2933
3536
|
if (nc <= 0 || nc > 8) return null;
|
|
2934
3537
|
const ends = [];
|
|
2935
|
-
for (let i = 0; i < nc; i++) ends.push(u16(b,
|
|
3538
|
+
for (let i = 0; i < nc; i++) ends.push(u16(b, g + 10 + 2 * i));
|
|
2936
3539
|
const np = ends[nc - 1] + 1;
|
|
2937
3540
|
if (np > 400) return null;
|
|
2938
|
-
let o =
|
|
3541
|
+
let o = g + 10 + 2 * nc;
|
|
2939
3542
|
o += 2 + u16(b, o);
|
|
2940
3543
|
const flags = [];
|
|
2941
3544
|
while (flags.length < np) {
|
|
@@ -3034,23 +3637,23 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
3034
3637
|
let font = "";
|
|
3035
3638
|
for (let i = 0; i < fnArray.length; i++) {
|
|
3036
3639
|
const fn = fnArray[i], args = argsArray[i];
|
|
3037
|
-
if (fn ===
|
|
3038
|
-
else if (fn ===
|
|
3039
|
-
else if (fn ===
|
|
3040
|
-
else if (fn ===
|
|
3041
|
-
for (const
|
|
3042
|
-
const glyph =
|
|
3640
|
+
if (fn === _chunkFG3SD2G3cjs.OPS.setFont) font = String(args[0]);
|
|
3641
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.save || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin) saved.push(font);
|
|
3642
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.restore || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectEnd) font = _nullishCoalesce(saved.pop(), () => ( font));
|
|
3643
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.showText) {
|
|
3644
|
+
for (const g of args[0]) {
|
|
3645
|
+
const glyph = g;
|
|
3043
3646
|
if (!glyph || glyph.unicode !== NO_UNICODE || typeof glyph.fontChar !== "string") continue;
|
|
3044
3647
|
const key = font + "\0" + glyph.fontChar + "\0" + typeof glyph.width + ":" + String(glyph.width);
|
|
3045
3648
|
if (!cache.has(key)) {
|
|
3046
3649
|
let sym = null;
|
|
3047
3650
|
try {
|
|
3048
|
-
const source = fontObj(font), data = _optionalChain([source, 'optionalAccess',
|
|
3651
|
+
const source = fontObj(font), data = _optionalChain([source, 'optionalAccess', _250 => _250.data]);
|
|
3049
3652
|
const code = glyph.fontChar.codePointAt(0);
|
|
3050
3653
|
const outline = data && code !== void 0 ? readOutline(data, code) : null;
|
|
3051
|
-
const pua = outline ? knownFontPua(_optionalChain([source, 'optionalAccess',
|
|
3654
|
+
const pua = outline ? knownFontPua(_optionalChain([source, 'optionalAccess', _251 => _251.name]), outline, glyph.width) : null;
|
|
3052
3655
|
if (outline) sym = pua !== null ? String.fromCodePoint(pua) : classifyOutline(outline);
|
|
3053
|
-
} catch (
|
|
3656
|
+
} catch (e6) {
|
|
3054
3657
|
}
|
|
3055
3658
|
cache.set(key, sym);
|
|
3056
3659
|
}
|
|
@@ -3061,12 +3664,12 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
3061
3664
|
}
|
|
3062
3665
|
}
|
|
3063
3666
|
for (const q of queues.values()) for (let k = 0; k < q.length; k++) {
|
|
3064
|
-
const pair = k + 1 < q.length ?
|
|
3667
|
+
const pair = k + 1 < q.length ? _chunkYIATOFKCcjs.pairedNumber.call(void 0, q[k], q[k + 1]) : void 0;
|
|
3065
3668
|
if (pair !== void 0) {
|
|
3066
3669
|
q[k] = pair;
|
|
3067
3670
|
q[k + 1] = "";
|
|
3068
3671
|
k++;
|
|
3069
|
-
} else q[k] =
|
|
3672
|
+
} else q[k] = _chunkYIATOFKCcjs.mapPuaText.call(void 0, q[k]);
|
|
3070
3673
|
}
|
|
3071
3674
|
const byFont = /* @__PURE__ */ new Map();
|
|
3072
3675
|
for (const it of items) {
|
|
@@ -3078,7 +3681,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
3078
3681
|
}
|
|
3079
3682
|
for (const [f, list] of byFont) {
|
|
3080
3683
|
const q = queues.get(f);
|
|
3081
|
-
const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access',
|
|
3684
|
+
const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access', _252 => _252.str, 'access', _253 => _253.match, 'call', _254 => _254(//g), 'optionalAccess', _255 => _255.length]), () => ( 0))), 0);
|
|
3082
3685
|
if (!q || q.length !== want) continue;
|
|
3083
3686
|
let k = 0;
|
|
3084
3687
|
for (const it of list) it.str = it.str.replace(//g, () => q[k++]);
|
|
@@ -3099,42 +3702,42 @@ function spaceMappedDots(fnArray, argsArray, fontObj) {
|
|
|
3099
3702
|
];
|
|
3100
3703
|
for (let i = 0; i < fnArray.length; i++) {
|
|
3101
3704
|
const fn = fnArray[i], args = argsArray[i];
|
|
3102
|
-
if (fn ===
|
|
3103
|
-
else if (fn ===
|
|
3705
|
+
if (fn === _chunkFG3SD2G3cjs.OPS.save) stack.push({ ctm: ctm.slice(), font, size });
|
|
3706
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.restore) {
|
|
3104
3707
|
const s = stack.pop();
|
|
3105
3708
|
if (s) ({ ctm, font, size } = s);
|
|
3106
|
-
} else if (fn ===
|
|
3107
|
-
else if (fn ===
|
|
3709
|
+
} else if (fn === _chunkFG3SD2G3cjs.OPS.transform) ctm = mul3(ctm, args);
|
|
3710
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.setFont) {
|
|
3108
3711
|
font = String(args[0]);
|
|
3109
3712
|
size = Number(args[1]) || 0;
|
|
3110
|
-
} else if (fn ===
|
|
3111
|
-
else if (fn ===
|
|
3112
|
-
else if (fn ===
|
|
3113
|
-
const
|
|
3713
|
+
} else if (fn === _chunkFG3SD2G3cjs.OPS.setTextMatrix) tm = args.slice(0, 6);
|
|
3714
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.beginText) tm = [1, 0, 0, 1, 0, 0];
|
|
3715
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.showText) {
|
|
3716
|
+
const g = _nullishCoalesce(args[0][0], () => ( null));
|
|
3114
3717
|
const at = tm;
|
|
3115
3718
|
tm = null;
|
|
3116
|
-
if (!at || !
|
|
3117
|
-
const code = _nullishCoalesce(
|
|
3719
|
+
if (!at || !g || g.unicode !== " " && g.unicode !== "\xA0" || typeof g.fontChar !== "string") continue;
|
|
3720
|
+
const code = _nullishCoalesce(g.fontChar.codePointAt(0), () => ( 0));
|
|
3118
3721
|
if (code < 57344 || code > 63743) continue;
|
|
3119
3722
|
const key = font + "\0" + code;
|
|
3120
3723
|
if (!cache.has(key)) {
|
|
3121
3724
|
let dot = false;
|
|
3122
3725
|
try {
|
|
3123
|
-
const data = _optionalChain([fontObj, 'call',
|
|
3726
|
+
const data = _optionalChain([fontObj, 'call', _256 => _256(font), 'optionalAccess', _257 => _257.data]);
|
|
3124
3727
|
const ol = data ? readOutline(data, code) : null;
|
|
3125
3728
|
if (ol && ol.contours.length === 1 && ol.contours[0].length === 4 && ol.contours[0].every((p) => p[2])) {
|
|
3126
3729
|
const b = boxOf(ol.contours[0]), u = ol.upm;
|
|
3127
3730
|
const w = (b.x2 - b.x1) / u, h = (b.y2 - b.y1) / u, mid = (b.y1 + b.y2) / 2 / u;
|
|
3128
3731
|
dot = w <= 0.25 && h <= 0.25 && Math.abs(w - h) <= 0.05 && mid >= 0.2 && mid <= 0.5;
|
|
3129
3732
|
}
|
|
3130
|
-
} catch (
|
|
3733
|
+
} catch (e7) {
|
|
3131
3734
|
}
|
|
3132
3735
|
cache.set(key, dot);
|
|
3133
3736
|
}
|
|
3134
3737
|
if (!cache.get(key)) continue;
|
|
3135
3738
|
const m = mul3(ctm, at);
|
|
3136
3739
|
const fs = size * Math.hypot(m[2], m[3]);
|
|
3137
|
-
out.push({ str: "\xB7", transform: [fs, 0, 0, fs, m[4], m[5]], width: (Number(
|
|
3740
|
+
out.push({ str: "\xB7", transform: [fs, 0, 0, fs, m[4], m[5]], width: (Number(g.width) || 0) / 1e3 * fs, height: fs });
|
|
3138
3741
|
}
|
|
3139
3742
|
}
|
|
3140
3743
|
return out;
|
|
@@ -3156,15 +3759,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
3156
3759
|
function marginContextBlocks(raw, page, view) {
|
|
3157
3760
|
const [x1, y1, x2, y2] = view;
|
|
3158
3761
|
const width = x2 - x1, height = y2 - y1;
|
|
3159
|
-
const items =
|
|
3762
|
+
const items = _chunkFG3SD2G3cjs.filterHiddenText.call(void 0, _chunkFG3SD2G3cjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
3160
3763
|
for (const item of items) {
|
|
3161
3764
|
item.x -= x1;
|
|
3162
3765
|
item.y -= y1;
|
|
3163
3766
|
}
|
|
3164
|
-
return
|
|
3165
|
-
const bbox =
|
|
3767
|
+
return _chunkFG3SD2G3cjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
3768
|
+
const bbox = _chunkFG3SD2G3cjs.computeBBox.call(void 0, line, page);
|
|
3166
3769
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
3167
|
-
return [{ type: "paragraph", text:
|
|
3770
|
+
return [{ type: "paragraph", text: _chunkFG3SD2G3cjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkFG3SD2G3cjs.dominantStyle.call(void 0, line) }];
|
|
3168
3771
|
});
|
|
3169
3772
|
}
|
|
3170
3773
|
|
|
@@ -3200,7 +3803,7 @@ var WINANSI_REVERSE = {
|
|
|
3200
3803
|
};
|
|
3201
3804
|
function symbolFontTable(fontName) {
|
|
3202
3805
|
if (!fontName) return void 0;
|
|
3203
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
3806
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkYIATOFKCcjs.WINGDINGS;
|
|
3204
3807
|
return void 0;
|
|
3205
3808
|
}
|
|
3206
3809
|
function remapSymbolText(text, table) {
|
|
@@ -3328,7 +3931,7 @@ function layout(toks) {
|
|
|
3328
3931
|
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);
|
|
3329
3932
|
if (!bar) continue;
|
|
3330
3933
|
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);
|
|
3331
|
-
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access',
|
|
3934
|
+
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _258 => _258[0], 'optionalAccess', _259 => _259.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
|
|
3332
3935
|
rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
|
|
3333
3936
|
}
|
|
3334
3937
|
const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
|
|
@@ -3433,7 +4036,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
3433
4036
|
for (const i of members) drop.add(i);
|
|
3434
4037
|
const toks = cur.map((it) => {
|
|
3435
4038
|
const bar2 = isBarItem(it);
|
|
3436
|
-
const text = bar2 ? "" : plain2.has(items.indexOf(it)) ?
|
|
4039
|
+
const text = bar2 ? "" : plain2.has(items.indexOf(it)) ? _chunkYIATOFKCcjs.toTex.call(void 0, it.text) : FUNC_RE.test(it.text.trim()) ? it.text.trim() : [...it.text].map(decodeEq).join("");
|
|
3437
4040
|
return { text, x: it.x, y: it.y, w: it.w, size: sizeOf(it), bar: bar2 };
|
|
3438
4041
|
});
|
|
3439
4042
|
const tex = layout(toks).replace(/\}\\text\{/g, "");
|
|
@@ -3444,7 +4047,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
3444
4047
|
for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
|
|
3445
4048
|
const top = [...ys].sort((p, q) => q[1] - p[1]);
|
|
3446
4049
|
const bar = cur.find(isBarItem);
|
|
3447
|
-
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access',
|
|
4050
|
+
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _260 => _260[0], 'optionalAccess', _261 => _261[0]]), () => ( cur[0].y));
|
|
3448
4051
|
const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
|
|
3449
4052
|
const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
|
|
3450
4053
|
added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
|
|
@@ -3457,7 +4060,6 @@ function wrapEquationRuns(items, faceName) {
|
|
|
3457
4060
|
}
|
|
3458
4061
|
|
|
3459
4062
|
// src/pdf/glyph-names.ts
|
|
3460
|
-
|
|
3461
4063
|
var NAMED = {
|
|
3462
4064
|
zero: "0",
|
|
3463
4065
|
one: "1",
|
|
@@ -3575,13 +4177,13 @@ function restoreNamedGlyphs(items, fnArray, argsArray, differencesOf, faceOf = (
|
|
|
3575
4177
|
for (let i = 0; i < fnArray.length; i++) {
|
|
3576
4178
|
const fn = fnArray[i];
|
|
3577
4179
|
const args = argsArray[i];
|
|
3578
|
-
if (fn ===
|
|
3579
|
-
else if (fn ===
|
|
3580
|
-
else if (fn ===
|
|
3581
|
-
else if (fn ===
|
|
4180
|
+
if (fn === _chunkFG3SD2G3cjs.OPS.setFont) font = String(args[0]);
|
|
4181
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.save || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin) saved.push(font);
|
|
4182
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.restore || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectEnd) font = _nullishCoalesce(saved.pop(), () => ( font));
|
|
4183
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.showText && targets.get(font)) {
|
|
3582
4184
|
let list = streams.get(font);
|
|
3583
4185
|
if (!list) streams.set(font, list = []);
|
|
3584
|
-
for (const
|
|
4186
|
+
for (const g of args[0]) if (g && typeof g === "object") list.push(g);
|
|
3585
4187
|
}
|
|
3586
4188
|
}
|
|
3587
4189
|
const failed = /* @__PURE__ */ new Set();
|
|
@@ -3597,8 +4199,8 @@ function restoreNamedGlyphs(items, fnArray, argsArray, differencesOf, faceOf = (
|
|
|
3597
4199
|
const s = it.str;
|
|
3598
4200
|
let gi = _nullishCoalesce(cursor.get(fontName), () => ( 0)), k = 0, out = "";
|
|
3599
4201
|
while (k < s.length) {
|
|
3600
|
-
const
|
|
3601
|
-
if (!
|
|
4202
|
+
const g = glyphs[gi];
|
|
4203
|
+
if (!g) {
|
|
3602
4204
|
if (/^\s*$/.test(s.slice(k))) {
|
|
3603
4205
|
out += s.slice(k);
|
|
3604
4206
|
break;
|
|
@@ -3606,10 +4208,10 @@ function restoreNamedGlyphs(items, fnArray, argsArray, differencesOf, faceOf = (
|
|
|
3606
4208
|
failed.add(fontName);
|
|
3607
4209
|
break;
|
|
3608
4210
|
}
|
|
3609
|
-
const code = _nullishCoalesce(
|
|
4211
|
+
const code = _nullishCoalesce(g.originalCharCode, () => ( -1));
|
|
3610
4212
|
const name = diffs[code];
|
|
3611
|
-
const raw = _nullishCoalesce(
|
|
3612
|
-
const exp = /^\p{Cf}$/u.test(raw) ? "" :
|
|
4213
|
+
const raw = _nullishCoalesce(g.unicode, () => ( ""));
|
|
4214
|
+
const exp = /^\p{Cf}$/u.test(raw) ? "" : _chunkFG3SD2G3cjs.normalizeUnicode.call(void 0, raw);
|
|
3613
4215
|
const tex = texCmGlyph(faceOf(fontName), code, name);
|
|
3614
4216
|
if (tex !== void 0 && (exp === "" || s.startsWith(exp, k))) {
|
|
3615
4217
|
out += tex;
|
|
@@ -3647,7 +4249,7 @@ function restoreNamedGlyphs(items, fnArray, argsArray, differencesOf, faceOf = (
|
|
|
3647
4249
|
continue;
|
|
3648
4250
|
}
|
|
3649
4251
|
let j = gi + 1;
|
|
3650
|
-
while (j < glyphs.length && j <= gi + 8 && !s.startsWith(
|
|
4252
|
+
while (j < glyphs.length && j <= gi + 8 && !s.startsWith(_chunkFG3SD2G3cjs.normalizeUnicode.call(void 0, _nullishCoalesce(glyphs[j].unicode, () => ( ""))) || "\0", k)) j++;
|
|
3651
4253
|
if (j < glyphs.length && j <= gi + 8) {
|
|
3652
4254
|
gi = j;
|
|
3653
4255
|
continue;
|
|
@@ -3673,7 +4275,7 @@ function restoreUnmappedCidSpaces(items, fnArray, argsArray, fontOf) {
|
|
|
3673
4275
|
const mapOf = (font2) => {
|
|
3674
4276
|
if (!maps.has(font2)) {
|
|
3675
4277
|
const f = fontOf(font2);
|
|
3676
|
-
const m = _optionalChain([f, 'optionalAccess',
|
|
4278
|
+
const m = _optionalChain([f, 'optionalAccess', _262 => _262.composite]) ? _optionalChain([f, 'access', _263 => _263.toUnicode, 'optionalAccess', _264 => _264._map]) : void 0;
|
|
3677
4279
|
maps.set(font2, m && m.length > 0 ? m : null);
|
|
3678
4280
|
}
|
|
3679
4281
|
return maps.get(font2);
|
|
@@ -3685,24 +4287,24 @@ function restoreUnmappedCidSpaces(items, fnArray, argsArray, fontOf) {
|
|
|
3685
4287
|
for (let i = 0; i < fnArray.length; i++) {
|
|
3686
4288
|
const fn = fnArray[i];
|
|
3687
4289
|
const args = argsArray[i];
|
|
3688
|
-
if (fn ===
|
|
3689
|
-
else if (fn ===
|
|
3690
|
-
else if (fn ===
|
|
3691
|
-
else if (fn ===
|
|
4290
|
+
if (fn === _chunkFG3SD2G3cjs.OPS.setFont) font = String(args[0]);
|
|
4291
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.save || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin) saved.push(font);
|
|
4292
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.restore || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectEnd) font = _nullishCoalesce(saved.pop(), () => ( font));
|
|
4293
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.showText) {
|
|
3692
4294
|
const map = mapOf(font);
|
|
3693
4295
|
if (!map) continue;
|
|
3694
4296
|
for (const raw of args[0]) {
|
|
3695
4297
|
if (!raw || typeof raw !== "object") continue;
|
|
3696
|
-
const
|
|
3697
|
-
const code =
|
|
3698
|
-
if (code === void 0 || typeof
|
|
3699
|
-
if (map[code] === " ") spaceWidth.set(font, Math.max(_nullishCoalesce(spaceWidth.get(font), () => ( 0)),
|
|
3700
|
-
else if (map[code] === void 0 &&
|
|
4298
|
+
const g = raw;
|
|
4299
|
+
const code = g.originalCharCode;
|
|
4300
|
+
if (code === void 0 || typeof g.width !== "number") continue;
|
|
4301
|
+
if (map[code] === " ") spaceWidth.set(font, Math.max(_nullishCoalesce(spaceWidth.get(font), () => ( 0)), g.width));
|
|
4302
|
+
else if (map[code] === void 0 && g.unicode === String.fromCharCode(code)) {
|
|
3701
4303
|
let codes = unmapped.get(font);
|
|
3702
4304
|
if (!codes) unmapped.set(font, codes = /* @__PURE__ */ new Map());
|
|
3703
4305
|
const seen = codes.get(code);
|
|
3704
|
-
if (seen) seen.glyphs.push(
|
|
3705
|
-
else codes.set(code, { width:
|
|
4306
|
+
if (seen) seen.glyphs.push(g);
|
|
4307
|
+
else codes.set(code, { width: g.width, glyphs: [g] });
|
|
3706
4308
|
}
|
|
3707
4309
|
}
|
|
3708
4310
|
}
|
|
@@ -3712,22 +4314,22 @@ function restoreUnmappedCidSpaces(items, fnArray, argsArray, fontOf) {
|
|
|
3712
4314
|
const sw = spaceWidth.get(fontName);
|
|
3713
4315
|
if (!sw) continue;
|
|
3714
4316
|
const mapped = new Set(Array.from(_nullishCoalesce(mapOf(fontName), () => ( [])), (v) => v));
|
|
3715
|
-
const
|
|
4317
|
+
const chars2 = /* @__PURE__ */ new Set();
|
|
3716
4318
|
for (const [code, { width, glyphs }] of codes) {
|
|
3717
4319
|
const ch = String.fromCharCode(code);
|
|
3718
4320
|
if (width > sw * 1.5 || mapped.has(ch)) continue;
|
|
3719
|
-
|
|
3720
|
-
for (const
|
|
4321
|
+
chars2.add(ch);
|
|
4322
|
+
for (const g of glyphs) g.unicode = " ";
|
|
3721
4323
|
}
|
|
3722
|
-
if (
|
|
4324
|
+
if (chars2.size) spaceChars.set(fontName, chars2);
|
|
3723
4325
|
}
|
|
3724
4326
|
if (!spaceChars.size) return 0;
|
|
3725
4327
|
let changed = 0;
|
|
3726
4328
|
for (const it of items) {
|
|
3727
|
-
const
|
|
3728
|
-
if (!
|
|
4329
|
+
const chars2 = it.fontName ? spaceChars.get(it.fontName) : void 0;
|
|
4330
|
+
if (!chars2 || typeof it.str !== "string") continue;
|
|
3729
4331
|
let out = "";
|
|
3730
|
-
for (const ch of it.str) out +=
|
|
4332
|
+
for (const ch of it.str) out += chars2.has(ch) ? " " : ch;
|
|
3731
4333
|
if (out !== it.str) {
|
|
3732
4334
|
it.str = out;
|
|
3733
4335
|
changed++;
|
|
@@ -3737,8 +4339,7 @@ function restoreUnmappedCidSpaces(items, fnArray, argsArray, fontOf) {
|
|
|
3737
4339
|
}
|
|
3738
4340
|
|
|
3739
4341
|
// src/pdf/occluded-text.ts
|
|
3740
|
-
|
|
3741
|
-
var glyphText = (s) => _pdfmjs.normalizeUnicode.call(void 0, s).replace(/\s+/g, "");
|
|
4342
|
+
var glyphText = (s) => _chunkFG3SD2G3cjs.normalizeUnicode.call(void 0, s).replace(/\s+/g, "");
|
|
3742
4343
|
function occludedTextItems(items, fnArray, argsArray) {
|
|
3743
4344
|
const covers = [];
|
|
3744
4345
|
let drawn = "";
|
|
@@ -3760,21 +4361,21 @@ function occludedTextItems(items, fnArray, argsArray) {
|
|
|
3760
4361
|
for (let i = 0; i < fnArray.length; i++) {
|
|
3761
4362
|
const fn = fnArray[i];
|
|
3762
4363
|
const args = argsArray[i];
|
|
3763
|
-
if (fn ===
|
|
4364
|
+
if (fn === _chunkFG3SD2G3cjs.OPS.save || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin) {
|
|
3764
4365
|
stack.push({ ctm: ctm.slice(), alpha, normalBlend, clip });
|
|
3765
|
-
const m = fn ===
|
|
4366
|
+
const m = fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin ? args[0] : null;
|
|
3766
4367
|
if (Array.isArray(m) && m.length >= 6) ctm = mul2(ctm, m);
|
|
3767
|
-
const bbox = fn ===
|
|
4368
|
+
const bbox = fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin ? args[1] : null;
|
|
3768
4369
|
if (Array.isArray(bbox) && bbox.length === 4 && clip !== null) {
|
|
3769
4370
|
const axisAligned = ctm[1] === 0 && ctm[2] === 0 || ctm[0] === 0 && ctm[3] === 0;
|
|
3770
4371
|
const bounds = box(bbox[0], bbox[1], bbox[2] - bbox[0], bbox[3] - bbox[1]);
|
|
3771
4372
|
clip = axisAligned ? clip ? meet(clip, bounds) : bounds : null;
|
|
3772
4373
|
}
|
|
3773
|
-
} else if (fn ===
|
|
4374
|
+
} else if (fn === _chunkFG3SD2G3cjs.OPS.restore || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectEnd) {
|
|
3774
4375
|
const s = stack.pop();
|
|
3775
4376
|
if (s) ({ ctm, alpha, normalBlend, clip } = s);
|
|
3776
|
-
} else if (fn ===
|
|
3777
|
-
else if (fn ===
|
|
4377
|
+
} else if (fn === _chunkFG3SD2G3cjs.OPS.transform) ctm = mul2(ctm, args);
|
|
4378
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.setGState) {
|
|
3778
4379
|
const entries = args[0];
|
|
3779
4380
|
if (Array.isArray(entries)) for (const e of entries) {
|
|
3780
4381
|
if (!Array.isArray(e)) continue;
|
|
@@ -3782,11 +4383,11 @@ function occludedTextItems(items, fnArray, argsArray) {
|
|
|
3782
4383
|
else if (e[0] === "BM") normalBlend = e[1] === "source-over" || e[1] === "Normal";
|
|
3783
4384
|
else if (e[0] === "SMask" && e[1]) normalBlend = false;
|
|
3784
4385
|
}
|
|
3785
|
-
} else if (fn ===
|
|
3786
|
-
for (const
|
|
3787
|
-
if (
|
|
4386
|
+
} else if (fn === _chunkFG3SD2G3cjs.OPS.showText) {
|
|
4387
|
+
for (const g of args[0]) {
|
|
4388
|
+
if (g && typeof g === "object" && typeof g.unicode === "string") drawn += glyphText(g.unicode);
|
|
3788
4389
|
}
|
|
3789
|
-
} else if (fn ===
|
|
4390
|
+
} else if (fn === _chunkFG3SD2G3cjs.OPS.constructPath) {
|
|
3790
4391
|
const sub = args[0];
|
|
3791
4392
|
const coords = args[1];
|
|
3792
4393
|
if (!Array.isArray(sub)) {
|
|
@@ -3795,18 +4396,18 @@ function occludedTextItems(items, fnArray, argsArray) {
|
|
|
3795
4396
|
}
|
|
3796
4397
|
let ci = 0;
|
|
3797
4398
|
for (const op of sub) {
|
|
3798
|
-
if (op ===
|
|
4399
|
+
if (op === _chunkFG3SD2G3cjs.OPS.rectangle) {
|
|
3799
4400
|
path.push(box(coords[ci], coords[ci + 1], coords[ci + 2], coords[ci + 3]));
|
|
3800
4401
|
ci += 4;
|
|
3801
4402
|
} else {
|
|
3802
4403
|
pathOk = false;
|
|
3803
|
-
ci += op ===
|
|
4404
|
+
ci += op === _chunkFG3SD2G3cjs.OPS.curveTo ? 6 : op === _chunkFG3SD2G3cjs.OPS.curveTo2 || op === _chunkFG3SD2G3cjs.OPS.curveTo3 ? 4 : op === _chunkFG3SD2G3cjs.OPS.closePath ? 0 : 2;
|
|
3804
4405
|
}
|
|
3805
4406
|
}
|
|
3806
|
-
} else if (fn ===
|
|
4407
|
+
} else if (fn === _chunkFG3SD2G3cjs.OPS.clip || fn === _chunkFG3SD2G3cjs.OPS.eoClip) {
|
|
3807
4408
|
clip = clip === null || !pathOk || path.length !== 1 ? null : clip ? meet(clip, path[0]) : path[0];
|
|
3808
|
-
} else if (fn ===
|
|
3809
|
-
const fills = fn !==
|
|
4409
|
+
} else if (fn === _chunkFG3SD2G3cjs.OPS.fill || fn === _chunkFG3SD2G3cjs.OPS.eoFill || fn === _chunkFG3SD2G3cjs.OPS.fillStroke || fn === _chunkFG3SD2G3cjs.OPS.eoFillStroke || fn === _chunkFG3SD2G3cjs.OPS.endPath || fn === _chunkFG3SD2G3cjs.OPS.stroke || fn === _chunkFG3SD2G3cjs.OPS.closeStroke || fn === _chunkFG3SD2G3cjs.OPS.closeFillStroke || fn === _chunkFG3SD2G3cjs.OPS.closeEOFillStroke) {
|
|
4410
|
+
const fills = fn !== _chunkFG3SD2G3cjs.OPS.endPath && fn !== _chunkFG3SD2G3cjs.OPS.stroke && fn !== _chunkFG3SD2G3cjs.OPS.closeStroke;
|
|
3810
4411
|
if (fills && pathOk && path.length === 1 && alpha >= 1 && normalBlend && clip !== null && drawn.length > 0) {
|
|
3811
4412
|
const rect = clip ? meet(path[0], clip) : path[0];
|
|
3812
4413
|
if (rect.x2 > rect.x1 && rect.y2 > rect.y1) covers.push({ at: drawn.length, rect });
|
|
@@ -3867,40 +4468,40 @@ function joinVerticalColumns(items) {
|
|
|
3867
4468
|
if (columns.length < 2) return joinLoneColumns(items);
|
|
3868
4469
|
const groups = [];
|
|
3869
4470
|
for (const col of columns) {
|
|
3870
|
-
const
|
|
3871
|
-
const last = _optionalChain([
|
|
4471
|
+
const g = groups[groups.length - 1];
|
|
4472
|
+
const last = _optionalChain([g, 'optionalAccess', _265 => _265[g.length - 1]]);
|
|
3872
4473
|
const fs = col.items[0].fontSize;
|
|
3873
|
-
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)
|
|
4474
|
+
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) g.push(col);
|
|
3874
4475
|
else groups.push([col]);
|
|
3875
4476
|
}
|
|
3876
4477
|
const drop = /* @__PURE__ */ new Set();
|
|
3877
4478
|
const add = [];
|
|
3878
|
-
for (const
|
|
3879
|
-
if (
|
|
3880
|
-
const fs =
|
|
4479
|
+
for (const g of groups) {
|
|
4480
|
+
if (g.length < 2) continue;
|
|
4481
|
+
const fs = g[0].items[0].fontSize;
|
|
3881
4482
|
const med = (v) => v.sort((a, b) => a - b)[v.length >> 1];
|
|
3882
|
-
const step = med(
|
|
3883
|
-
const colGap = med(
|
|
4483
|
+
const step = med(g.flatMap((c) => c.items.slice(1).map((it, k) => c.items[k].y - it.y)));
|
|
4484
|
+
const colGap = med(g.slice(1).map((c, k) => g[k].x - c.x));
|
|
3884
4485
|
if (step > colGap * 0.8 || step > fs * 1.15) continue;
|
|
3885
|
-
const gapped =
|
|
3886
|
-
if (gapped * 2 <
|
|
3887
|
-
const x1 = Math.min(...
|
|
3888
|
-
const top = Math.max(...
|
|
3889
|
-
const bottom = Math.min(...
|
|
3890
|
-
const members = new Set(
|
|
4486
|
+
const gapped = g.filter((c) => c.items.slice(1).some((it, k) => c.items[k].y - it.y > fs * 1.3)).length;
|
|
4487
|
+
if (gapped * 2 < g.length) continue;
|
|
4488
|
+
const x1 = Math.min(...g.map((c) => c.x)), x2 = Math.max(...g.map((c) => c.x)) + fs;
|
|
4489
|
+
const top = Math.max(...g.map((c) => c.items[0].y)) + fs * 0.2;
|
|
4490
|
+
const bottom = Math.min(...g.map((c) => c.items[c.items.length - 1].y)) - fs * 0.2;
|
|
4491
|
+
const members = new Set(g.flatMap((c) => c.items));
|
|
3891
4492
|
const inside2 = items.filter((i) => !members.has(i) && i.x + i.w / 2 >= x1 - 1 && i.x + i.w / 2 <= x2 + 1 && i.y <= top && i.y >= bottom - fs);
|
|
3892
4493
|
if (inside2.some((i) => !PUNCT.test(i.text))) continue;
|
|
3893
4494
|
const spread2 = fs * 2.2;
|
|
3894
|
-
const lineH = items.some((i) => !members.has(i) && !inside2.includes(i) && i.x + i.w > x1 && i.x < x2 && i.y < bottom && i.y >= top - spread2 *
|
|
4495
|
+
const lineH = items.some((i) => !members.has(i) && !inside2.includes(i) && i.x + i.w > x1 && i.x < x2 && i.y < bottom && i.y >= top - spread2 * g.length) ? (top - bottom) / g.length : spread2;
|
|
3895
4496
|
for (const p of inside2) {
|
|
3896
|
-
const col = [...
|
|
4497
|
+
const col = [...g].filter((c) => c.x <= p.x).sort((a, b) => b.x - a.x)[0];
|
|
3897
4498
|
if (col) {
|
|
3898
4499
|
col.items.push(p);
|
|
3899
4500
|
members.add(p);
|
|
3900
4501
|
}
|
|
3901
4502
|
}
|
|
3902
|
-
const hangul =
|
|
3903
|
-
|
|
4503
|
+
const hangul = g.some((c) => c.items.some((it) => /[가-힣]/.test(it.text)));
|
|
4504
|
+
g.forEach((col, k) => {
|
|
3904
4505
|
col.items.sort((a, b) => b.y - a.y);
|
|
3905
4506
|
let text = "";
|
|
3906
4507
|
for (let n = 0; n < col.items.length; n++) {
|
|
@@ -3942,16 +4543,16 @@ function joinLoneColumns(items) {
|
|
|
3942
4543
|
if (col.items[k - 1].y - col.items[k].y > fs * 4) segs.push([col.items[k]]);
|
|
3943
4544
|
else segs[segs.length - 1].push(col.items[k]);
|
|
3944
4545
|
}
|
|
3945
|
-
if (segs.some((
|
|
3946
|
-
for (const
|
|
3947
|
-
const steps =
|
|
4546
|
+
if (segs.some((g) => g.slice(1).some((it, k) => g[k].y - it.y < fs * 0.8))) continue;
|
|
4547
|
+
for (const g of segs) {
|
|
4548
|
+
const steps = g.slice(1).map((it, k) => g[k].y - it.y).sort((a, b) => a - b);
|
|
3948
4549
|
const med = _nullishCoalesce(steps[steps.length >> 1], () => ( 0));
|
|
3949
4550
|
let text = "";
|
|
3950
|
-
|
|
3951
|
-
if (k &&
|
|
4551
|
+
g.forEach((it, k) => {
|
|
4552
|
+
if (k && g[k - 1].y - it.y > med * 1.2) text += " ";
|
|
3952
4553
|
text += it.text;
|
|
3953
4554
|
});
|
|
3954
|
-
add.push({ ...
|
|
4555
|
+
add.push({ ...g[0], text, x: col.x, w: [...text].length * fs * 0.5, h: fs });
|
|
3955
4556
|
}
|
|
3956
4557
|
for (const m of members) drop.add(m);
|
|
3957
4558
|
}
|
|
@@ -3959,7 +4560,6 @@ function joinLoneColumns(items) {
|
|
|
3959
4560
|
}
|
|
3960
4561
|
|
|
3961
4562
|
// src/pdf/tracked-text.ts
|
|
3962
|
-
|
|
3963
4563
|
var TRACKED = /^(?:[^\s\u1100-\u11ff\u3130-\u318f\uac00-\ud7a3] ){3,}[^\s\u1100-\u11ff\u3130-\u318f\uac00-\ud7a3]$/;
|
|
3964
4564
|
var SPACED_NUMBER = /^(?=[^\d]*\d)(?=\S* )[\d\s\-().·,☎]+$/;
|
|
3965
4565
|
function restoreTrackedSpacing(items, fnArray, argsArray) {
|
|
@@ -3970,14 +4570,14 @@ function restoreTrackedSpacing(items, fnArray, argsArray) {
|
|
|
3970
4570
|
for (let i = 0; i < fnArray.length; i++) {
|
|
3971
4571
|
const fn = fnArray[i];
|
|
3972
4572
|
const args = argsArray[i];
|
|
3973
|
-
if (fn ===
|
|
3974
|
-
else if (fn ===
|
|
3975
|
-
else if (fn ===
|
|
3976
|
-
else if (fn ===
|
|
4573
|
+
if (fn === _chunkFG3SD2G3cjs.OPS.setFont) font = String(args[0]);
|
|
4574
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.save || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin) saved.push(font);
|
|
4575
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.restore || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectEnd) font = _nullishCoalesce(saved.pop(), () => ( font));
|
|
4576
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.showText) {
|
|
3977
4577
|
let list = streams.get(font);
|
|
3978
4578
|
if (!list) streams.set(font, list = []);
|
|
3979
|
-
for (const
|
|
3980
|
-
if (
|
|
4579
|
+
for (const g of args[0]) {
|
|
4580
|
+
if (g && typeof g === "object" && typeof g.unicode === "string") list.push(_chunkFG3SD2G3cjs.normalizeUnicode.call(void 0, g.unicode));
|
|
3981
4581
|
}
|
|
3982
4582
|
}
|
|
3983
4583
|
}
|
|
@@ -3994,9 +4594,9 @@ function restoreTrackedSpacing(items, fnArray, argsArray) {
|
|
|
3994
4594
|
while (gi < glyphs.length && /^\s*$/.test(glyphs[gi])) gi++;
|
|
3995
4595
|
let got = "", text = "";
|
|
3996
4596
|
while (gi < glyphs.length && got.length < want.length) {
|
|
3997
|
-
const
|
|
3998
|
-
text +=
|
|
3999
|
-
got +=
|
|
4597
|
+
const g = glyphs[gi++];
|
|
4598
|
+
text += g;
|
|
4599
|
+
got += g.replace(/\s+/g, "");
|
|
4000
4600
|
}
|
|
4001
4601
|
if (got !== want) {
|
|
4002
4602
|
failed.add(f);
|
|
@@ -4025,14 +4625,14 @@ function markSyntheticSpaces(items, fnArray, argsArray) {
|
|
|
4025
4625
|
for (let i = 0; i < fnArray.length; i++) {
|
|
4026
4626
|
const fn = fnArray[i];
|
|
4027
4627
|
const args = argsArray[i];
|
|
4028
|
-
if (fn ===
|
|
4029
|
-
else if (fn ===
|
|
4030
|
-
else if (fn ===
|
|
4031
|
-
else if (fn ===
|
|
4628
|
+
if (fn === _chunkFG3SD2G3cjs.OPS.setFont) font = String(args[0]);
|
|
4629
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.save || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin) saved.push(font);
|
|
4630
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.restore || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectEnd) font = _nullishCoalesce(saved.pop(), () => ( font));
|
|
4631
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.showText) {
|
|
4032
4632
|
let list = streams.get(font);
|
|
4033
4633
|
if (!list) streams.set(font, list = []);
|
|
4034
|
-
for (const
|
|
4035
|
-
if (
|
|
4634
|
+
for (const g of args[0]) {
|
|
4635
|
+
if (g && typeof g === "object" && typeof g.unicode === "string") list.push(_chunkFG3SD2G3cjs.normalizeUnicode.call(void 0, g.unicode));
|
|
4036
4636
|
}
|
|
4037
4637
|
}
|
|
4038
4638
|
}
|
|
@@ -4072,26 +4672,26 @@ function joinTrackedHangul(items, fnArray, argsArray) {
|
|
|
4072
4672
|
for (let i = 0; i < fnArray.length; i++) {
|
|
4073
4673
|
const fn = fnArray[i];
|
|
4074
4674
|
const args = argsArray[i];
|
|
4075
|
-
if (fn ===
|
|
4076
|
-
else if (fn ===
|
|
4077
|
-
else if (fn ===
|
|
4078
|
-
else if (fn ===
|
|
4675
|
+
if (fn === _chunkFG3SD2G3cjs.OPS.setFont) font = String(args[0]);
|
|
4676
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.save || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectBegin) saved.push(font);
|
|
4677
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.restore || fn === _chunkFG3SD2G3cjs.OPS.paintFormXObjectEnd) font = _nullishCoalesce(saved.pop(), () => ( font));
|
|
4678
|
+
else if (fn === _chunkFG3SD2G3cjs.OPS.showText) {
|
|
4079
4679
|
let list = streams.get(font);
|
|
4080
4680
|
if (!list) streams.set(font, list = []);
|
|
4081
4681
|
let gap = null;
|
|
4082
|
-
for (const
|
|
4083
|
-
if (typeof
|
|
4084
|
-
if (gap !== null) gap -=
|
|
4682
|
+
for (const g of args[0]) {
|
|
4683
|
+
if (typeof g === "number") {
|
|
4684
|
+
if (gap !== null) gap -= g / 1e3;
|
|
4085
4685
|
continue;
|
|
4086
4686
|
}
|
|
4087
|
-
if (
|
|
4088
|
-
list.push({ u:
|
|
4687
|
+
if (g && typeof g === "object" && typeof g.unicode === "string") {
|
|
4688
|
+
list.push({ u: _chunkFG3SD2G3cjs.normalizeUnicode.call(void 0, g.unicode), gap });
|
|
4089
4689
|
gap = 0;
|
|
4090
4690
|
}
|
|
4091
4691
|
}
|
|
4092
4692
|
}
|
|
4093
4693
|
}
|
|
4094
|
-
const isSpace = (
|
|
4694
|
+
const isSpace = (g) => g !== void 0 && /^\s+$/.test(g.u);
|
|
4095
4695
|
const cursor = /* @__PURE__ */ new Map();
|
|
4096
4696
|
const failed = /* @__PURE__ */ new Set();
|
|
4097
4697
|
const edits = [];
|
|
@@ -4115,15 +4715,15 @@ function joinTrackedHangul(items, fnArray, argsArray) {
|
|
|
4115
4715
|
while (isSpace(glyphs[gi])) gi++;
|
|
4116
4716
|
while (k + 1 < s.length && /\s/.test(s[k + 1])) k++;
|
|
4117
4717
|
} else {
|
|
4118
|
-
const gap = _optionalChain([glyphs, 'access',
|
|
4718
|
+
const gap = _optionalChain([glyphs, 'access', _266 => _266[gi], 'optionalAccess', _267 => _267.gap]);
|
|
4119
4719
|
if (gap != null && gap <= TRACKING_MAX_EM && /[가-힣]/.test(_nullishCoalesce(s[k - 1], () => ( ""))) && /[가-힣]/.test(_nullishCoalesce(s[k + 1], () => ( "")))) fake.add(k);
|
|
4120
4720
|
}
|
|
4121
4721
|
continue;
|
|
4122
4722
|
}
|
|
4123
|
-
let
|
|
4124
|
-
while (gi < glyphs.length && !
|
|
4125
|
-
if (!
|
|
4126
|
-
else k +=
|
|
4723
|
+
let g = "";
|
|
4724
|
+
while (gi < glyphs.length && !g) g = glyphs[gi++].u.replace(/\s+/g, "");
|
|
4725
|
+
if (!g || s.slice(k, k + g.length) !== g) ok = false;
|
|
4726
|
+
else k += g.length - 1;
|
|
4127
4727
|
}
|
|
4128
4728
|
if (!ok) {
|
|
4129
4729
|
failed.add(f);
|
|
@@ -4137,9 +4737,9 @@ function joinTrackedHangul(items, fnArray, argsArray) {
|
|
|
4137
4737
|
function markTrailingSpaceGlyphs(items, fnArray, argsArray) {
|
|
4138
4738
|
const glyphs = [];
|
|
4139
4739
|
for (let i = 0; i < fnArray.length; i++) {
|
|
4140
|
-
if (fnArray[i] !==
|
|
4141
|
-
for (const
|
|
4142
|
-
if (
|
|
4740
|
+
if (fnArray[i] !== _chunkFG3SD2G3cjs.OPS.showText) continue;
|
|
4741
|
+
for (const g of argsArray[i][0]) {
|
|
4742
|
+
if (g && typeof g === "object" && typeof g.unicode === "string") glyphs.push(_chunkFG3SD2G3cjs.normalizeUnicode.call(void 0, g.unicode));
|
|
4143
4743
|
}
|
|
4144
4744
|
}
|
|
4145
4745
|
const text = items.filter((it) => typeof it.str === "string" && it.str.trim());
|
|
@@ -4165,13 +4765,13 @@ function markTrailingSpaceGlyphs(items, fnArray, argsArray) {
|
|
|
4165
4765
|
function softHyphenHeads(items, fnArray, argsArray) {
|
|
4166
4766
|
const glyphs = [];
|
|
4167
4767
|
for (let i = 0; i < fnArray.length; i++) {
|
|
4168
|
-
if (fnArray[i] !==
|
|
4169
|
-
for (const
|
|
4170
|
-
const o =
|
|
4171
|
-
if (
|
|
4768
|
+
if (fnArray[i] !== _chunkFG3SD2G3cjs.OPS.showText) continue;
|
|
4769
|
+
for (const g of argsArray[i][0]) {
|
|
4770
|
+
const o = g;
|
|
4771
|
+
if (g && typeof g === "object" && typeof o.unicode === "string") glyphs.push({ u: o.unicode, w: typeof o.width === "number" ? o.width : 0 });
|
|
4172
4772
|
}
|
|
4173
4773
|
}
|
|
4174
|
-
if (!glyphs.some((
|
|
4774
|
+
if (!glyphs.some((g) => g.u === "\xAD" && g.w > 0)) return () => {
|
|
4175
4775
|
};
|
|
4176
4776
|
const text = items.filter((it) => typeof it.str === "string" && it.str.trim());
|
|
4177
4777
|
const heads = [];
|
|
@@ -4188,14 +4788,14 @@ function softHyphenHeads(items, fnArray, argsArray) {
|
|
|
4188
4788
|
gi++;
|
|
4189
4789
|
}
|
|
4190
4790
|
if (soft >= 0) {
|
|
4191
|
-
const before = _nullishCoalesce(_optionalChain([glyphs, 'access',
|
|
4791
|
+
const before = _nullishCoalesce(_optionalChain([glyphs, 'access', _268 => _268[soft - 1], 'optionalAccess', _269 => _269.u]), () => ( ""));
|
|
4192
4792
|
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());
|
|
4193
4793
|
if (!wrapped) heads.push([it, spaced2 || !/^[\d.,]+%?(?:\s|$)/.test(it.str.trimStart()) ? "- " : "-"]);
|
|
4194
4794
|
}
|
|
4195
4795
|
const pushed = heads.length;
|
|
4196
4796
|
let got = "";
|
|
4197
4797
|
while (gi < glyphs.length && got.length < want.length) {
|
|
4198
|
-
if (glyphs[gi].u !== "\xAD") got +=
|
|
4798
|
+
if (glyphs[gi].u !== "\xAD") got += _chunkFG3SD2G3cjs.normalizeUnicode.call(void 0, glyphs[gi].u).replace(/\s+/g, "");
|
|
4199
4799
|
gi++;
|
|
4200
4800
|
}
|
|
4201
4801
|
if (got !== want) {
|
|
@@ -4249,7 +4849,7 @@ function relocateEndnotes(blocks) {
|
|
|
4249
4849
|
}
|
|
4250
4850
|
const shapes = /* @__PURE__ */ new Map();
|
|
4251
4851
|
for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
|
|
4252
|
-
const main = _optionalChain([[...shapes], 'access',
|
|
4852
|
+
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]]);
|
|
4253
4853
|
if (!main || !/#/.test(main)) return blocks;
|
|
4254
4854
|
const lastRun = (hs) => {
|
|
4255
4855
|
let run2 = [];
|
|
@@ -4275,7 +4875,7 @@ function relocateEndnotes(blocks) {
|
|
|
4275
4875
|
const start = run[0].idx;
|
|
4276
4876
|
const groups = run.map((h, k) => ({ ref: h.ref, blocks: blocks.slice(h.idx, k + 1 < run.length ? run[k + 1].idx : blocks.length) }));
|
|
4277
4877
|
const byRef = /* @__PURE__ */ new Map();
|
|
4278
|
-
for (const
|
|
4878
|
+
for (const g of groups) byRef.set(g.ref, [..._nullishCoalesce(byRef.get(g.ref), () => ( [])), ...g.blocks]);
|
|
4279
4879
|
const out = [];
|
|
4280
4880
|
for (let i = 0; i < start; i++) {
|
|
4281
4881
|
out.push(blocks[i]);
|
|
@@ -4312,7 +4912,7 @@ function dropTabLeaderDots(items) {
|
|
|
4312
4912
|
let run = [];
|
|
4313
4913
|
const flush = () => {
|
|
4314
4914
|
const last = run[run.length - 1];
|
|
4315
|
-
const tailPage = _optionalChain([DOTS_PAGE, 'access',
|
|
4915
|
+
const tailPage = _optionalChain([DOTS_PAGE, 'access', _274 => _274.exec, 'call', _275 => _275(last.text.trim()), 'optionalAccess', _276 => _276[1]]);
|
|
4316
4916
|
const dots = run.reduce((n, d) => n + d.text.trim().replace(/\d+$/, "").length, 0);
|
|
4317
4917
|
if (dots >= MIN_DOTS && (tailPage ? run.length > 1 : pageNoAfter(last.x + last.w, last))) {
|
|
4318
4918
|
const body = tailPage ? run.slice(0, -1) : run;
|
|
@@ -4349,7 +4949,7 @@ function mergeEnclosedDigits(items) {
|
|
|
4349
4949
|
if (!/^\d\d?$/.test(digits)) continue;
|
|
4350
4950
|
const mid = (inside2[0].x + inside2[inside2.length - 1].x + inside2[inside2.length - 1].w) / 2;
|
|
4351
4951
|
if (Math.abs(mid - (s.x + s.w / 2)) > s.fontSize * 0.15) continue;
|
|
4352
|
-
s.text =
|
|
4952
|
+
s.text = _chunkYIATOFKCcjs.enclosedNumber.call(void 0, Number(digits));
|
|
4353
4953
|
for (const d of inside2) drop.add(d);
|
|
4354
4954
|
}
|
|
4355
4955
|
if (!drop.size) return;
|
|
@@ -4435,7 +5035,7 @@ function inlineFootnotes(blocks, pages) {
|
|
|
4435
5035
|
open = true;
|
|
4436
5036
|
continue;
|
|
4437
5037
|
}
|
|
4438
|
-
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access',
|
|
5038
|
+
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;
|
|
4439
5039
|
if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
|
|
4440
5040
|
notes[notes.length - 1].text += " " + b.text.trim();
|
|
4441
5041
|
notes[notes.length - 1].blocks.push(b);
|
|
@@ -4458,7 +5058,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
|
|
|
4458
5058
|
var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
|
|
4459
5059
|
var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
|
|
4460
5060
|
function isRunningHead(block, page, pageHeight) {
|
|
4461
|
-
const box = block.bbox, text = _optionalChain([block, 'access',
|
|
5061
|
+
const box = block.bbox, text = _optionalChain([block, 'access', _281 => _281.text, 'optionalAccess', _282 => _282.trim, 'call', _283 => _283()]);
|
|
4462
5062
|
if (!box || !text || !pageHeight) return false;
|
|
4463
5063
|
const top = box.y + box.height >= pageHeight * 0.9;
|
|
4464
5064
|
const bottom = box.y <= pageHeight * 0.1;
|
|
@@ -4466,7 +5066,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
4466
5066
|
const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
|
|
4467
5067
|
if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
|
|
4468
5068
|
if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
|
|
4469
|
-
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access',
|
|
5069
|
+
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _284 => _284.style, 'optionalAccess', _285 => _285.fontSize]), () => ( 0))) * 1.6) return true;
|
|
4470
5070
|
if (!text.includes(" ")) return false;
|
|
4471
5071
|
const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
|
|
4472
5072
|
if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
|
|
@@ -4475,7 +5075,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
4475
5075
|
return right > left && box.width >= (right - left) * 0.6;
|
|
4476
5076
|
}
|
|
4477
5077
|
function unbalancedClose(text) {
|
|
4478
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
5078
|
+
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)));
|
|
4479
5079
|
}
|
|
4480
5080
|
function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
4481
5081
|
const byPage = /* @__PURE__ */ new Map();
|
|
@@ -4487,19 +5087,19 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
4487
5087
|
const bodyStyle = /* @__PURE__ */ new Map();
|
|
4488
5088
|
const bodySizes = /* @__PURE__ */ new Map();
|
|
4489
5089
|
for (const [pageNumber, page] of byPage) {
|
|
4490
|
-
const
|
|
5090
|
+
const chars2 = /* @__PURE__ */ new Map();
|
|
4491
5091
|
const sizes = /* @__PURE__ */ new Map();
|
|
4492
5092
|
let proseChars = 0;
|
|
4493
5093
|
for (const b of page) {
|
|
4494
|
-
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access',
|
|
5094
|
+
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _292 => _292.style, 'optionalAccess', _293 => _293.fontName]) || !b.style.fontSize) continue;
|
|
4495
5095
|
const key2 = `${b.style.fontName}:${b.style.fontSize}`;
|
|
4496
|
-
|
|
5096
|
+
chars2.set(key2, (_nullishCoalesce(chars2.get(key2), () => ( 0))) + b.text.length);
|
|
4497
5097
|
if (b.type === "paragraph" && b.style.fontName === "ocr") {
|
|
4498
5098
|
sizes.set(b.style.fontSize, (_nullishCoalesce(sizes.get(b.style.fontSize), () => ( 0))) + b.text.length);
|
|
4499
5099
|
proseChars += b.text.length;
|
|
4500
5100
|
}
|
|
4501
5101
|
}
|
|
4502
|
-
const [key, count] = _nullishCoalesce([...
|
|
5102
|
+
const [key, count] = _nullishCoalesce([...chars2].sort((a, b) => b[1] - a[1])[0], () => ( []));
|
|
4503
5103
|
if (key && count >= 300) bodyStyle.set(pageNumber, key);
|
|
4504
5104
|
if (proseChars >= 300) {
|
|
4505
5105
|
let cumulative = 0;
|
|
@@ -4515,13 +5115,13 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
4515
5115
|
const citedProse = /* @__PURE__ */ new Set();
|
|
4516
5116
|
const numberedProse = /* @__PURE__ */ new Set();
|
|
4517
5117
|
for (const page of byPage.values()) {
|
|
4518
|
-
const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
5118
|
+
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)]), () => ( ""))));
|
|
4519
5119
|
let chain = [];
|
|
4520
5120
|
const finish = () => {
|
|
4521
|
-
if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access',
|
|
5121
|
+
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;
|
|
4522
5122
|
for (const b of chain) numberedProse.add(b);
|
|
4523
5123
|
const first = chain[0], size = first.style.fontSize;
|
|
4524
|
-
for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
5124
|
+
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);
|
|
4525
5125
|
};
|
|
4526
5126
|
for (const b of numbered) {
|
|
4527
5127
|
const prev = chain.at(-1), size = b.style.fontSize;
|
|
@@ -4535,9 +5135,9 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
4535
5135
|
}
|
|
4536
5136
|
for (let i = 0; i + 1 < blocks.length; i++) {
|
|
4537
5137
|
const prose = blocks[i], reference = blocks[i + 1];
|
|
4538
|
-
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access',
|
|
4539
|
-
const source = _nullishCoalesce(_optionalChain([reference, 'access',
|
|
4540
|
-
if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access',
|
|
5138
|
+
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _314 => _314.style, 'optionalAccess', _315 => _315.fontSize]), () => ( 0));
|
|
5139
|
+
const source = _nullishCoalesce(_optionalChain([reference, 'access', _316 => _316.text, 'optionalAccess', _317 => _317.replace, 'call', _318 => _318(/<[^>]+>/g, ""), 'access', _319 => _319.trim, 'call', _320 => _320()]), () => ( ""));
|
|
5140
|
+
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;
|
|
4541
5141
|
citedProse.add(prose);
|
|
4542
5142
|
citedProse.add(reference);
|
|
4543
5143
|
}
|
|
@@ -4545,49 +5145,49 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
4545
5145
|
const block = blocks[i];
|
|
4546
5146
|
if (block.type !== "heading" || !block.text) continue;
|
|
4547
5147
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
4548
|
-
const fsz = _nullishCoalesce(_optionalChain([block, 'access',
|
|
4549
|
-
const tocEntry = i > 0 &&
|
|
5148
|
+
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _331 => _331.style, 'optionalAccess', _332 => _332.fontSize]), () => ( 0));
|
|
5149
|
+
const tocEntry = i > 0 && _chunkFG3SD2G3cjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkFG3SD2G3cjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
4550
5150
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
4551
|
-
const proseStyle = _optionalChain([block, 'access',
|
|
5151
|
+
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;
|
|
4552
5152
|
const next = blocks[i + 1];
|
|
4553
|
-
const nb = _optionalChain([next, 'optionalAccess',
|
|
4554
|
-
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
4555
|
-
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess',
|
|
5153
|
+
const nb = _optionalChain([next, 'optionalAccess', _335 => _335.bbox]), bb = block.bbox;
|
|
5154
|
+
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;
|
|
5155
|
+
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _338 => _338.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
|
|
4556
5156
|
next.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
4557
5157
|
blocks.splice(i--, 1);
|
|
4558
5158
|
continue;
|
|
4559
5159
|
}
|
|
4560
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
5160
|
+
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) {
|
|
4561
5161
|
block.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
4562
5162
|
block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
|
|
4563
5163
|
blocks.splice(i + 1, 1);
|
|
4564
5164
|
}
|
|
4565
5165
|
const after = blocks[i + 2];
|
|
4566
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
5166
|
+
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])) {
|
|
4567
5167
|
block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
|
|
4568
5168
|
blocks.splice(i + 1, 2);
|
|
4569
5169
|
}
|
|
4570
5170
|
const tiny = fsz > 0 && fsz < 7.5;
|
|
4571
5171
|
const prev = blocks[i - 1];
|
|
4572
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
5172
|
+
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) {
|
|
4573
5173
|
prev.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
4574
5174
|
prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
|
|
4575
5175
|
blocks.splice(i--, 1);
|
|
4576
5176
|
continue;
|
|
4577
5177
|
}
|
|
4578
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
5178
|
+
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)) {
|
|
4579
5179
|
block.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
4580
5180
|
blocks.splice(i - 1, 1);
|
|
4581
5181
|
i -= 2;
|
|
4582
5182
|
continue;
|
|
4583
5183
|
}
|
|
4584
|
-
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
4585
|
-
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess',
|
|
4586
|
-
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess',
|
|
5184
|
+
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _369 => _369.style, 'optionalAccess', _370 => _370.fontSize]), () => ( 0));
|
|
5185
|
+
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");
|
|
5186
|
+
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _376 => _376.get, 'call', _377 => _377(_nullishCoalesce(_optionalChain([block, 'access', _378 => _378.style, 'optionalAccess', _379 => _379.fontName]), () => ( "")))]), () => ( ""));
|
|
4587
5187
|
const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
|
|
4588
|
-
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access',
|
|
4589
|
-
const ocrFragment = _optionalChain([block, 'access',
|
|
4590
|
-
const crowdedOcr = _optionalChain([block, 'access',
|
|
5188
|
+
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;
|
|
5189
|
+
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);
|
|
5190
|
+
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;
|
|
4591
5191
|
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)"·"가)" 앞머리 번호는 빼고 센다
|
|
4592
5192
|
unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
|
|
4593
5193
|
block.type = "paragraph";
|
|
@@ -4637,34 +5237,34 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
|
|
|
4637
5237
|
function captionTableText(t) {
|
|
4638
5238
|
if (!t || t.rows !== 1 || t.cols !== 2) return null;
|
|
4639
5239
|
const [label, body] = t.cells[0];
|
|
4640
|
-
if (!label || !body || _optionalChain([label, 'access',
|
|
5240
|
+
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;
|
|
4641
5241
|
return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
|
|
4642
5242
|
}
|
|
4643
5243
|
function splitSingleCellTables(blocks) {
|
|
4644
5244
|
const out = [];
|
|
4645
5245
|
for (const b of blocks) {
|
|
4646
5246
|
const t = b.type === "table" ? b.table : void 0;
|
|
4647
|
-
const title = t &&
|
|
5247
|
+
const title = t && _chunkFG3SD2G3cjs.FRAME_TITLE_BLOCKS.get(t);
|
|
4648
5248
|
if (title) {
|
|
4649
5249
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
4650
5250
|
continue;
|
|
4651
5251
|
}
|
|
4652
|
-
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access',
|
|
5252
|
+
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;
|
|
4653
5253
|
const squash = (s) => s.replace(/\s/g, "");
|
|
4654
5254
|
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;
|
|
4655
|
-
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess',
|
|
5255
|
+
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _403 => _403.type]) === "table" ? captionTableText(inner.table) : null)));
|
|
4656
5256
|
if (caption) {
|
|
4657
5257
|
out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
|
|
4658
5258
|
continue;
|
|
4659
5259
|
}
|
|
4660
|
-
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access',
|
|
5260
|
+
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;
|
|
4661
5261
|
if (!cell) {
|
|
4662
5262
|
out.push(b);
|
|
4663
5263
|
continue;
|
|
4664
5264
|
}
|
|
4665
5265
|
const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
|
|
4666
|
-
if (_optionalChain([t, 'optionalAccess',
|
|
4667
|
-
if (_optionalChain([cell, 'access',
|
|
5266
|
+
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 });
|
|
5267
|
+
if (_optionalChain([cell, 'access', _410 => _410.blocks, 'optionalAccess', _411 => _411.length])) {
|
|
4668
5268
|
out.push(...splitSingleCellTables(cell.blocks));
|
|
4669
5269
|
continue;
|
|
4670
5270
|
}
|
|
@@ -4680,7 +5280,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
4680
5280
|
const lines = cell.text.split("\n");
|
|
4681
5281
|
const out = [lines[0]];
|
|
4682
5282
|
for (const line of lines.slice(1)) {
|
|
4683
|
-
if (
|
|
5283
|
+
if (_chunkFG3SD2G3cjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
4684
5284
|
else out.push(line);
|
|
4685
5285
|
}
|
|
4686
5286
|
cell.text = out.join("\n");
|
|
@@ -4691,19 +5291,19 @@ function joinLatinCellWraps(blocks) {
|
|
|
4691
5291
|
}
|
|
4692
5292
|
function cleanPdfText(text, opts) {
|
|
4693
5293
|
let clean = normalizeAraea(stripControlChars(text));
|
|
4694
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
5294
|
+
if (!_optionalChain([opts, 'optionalAccess', _412 => _412.keepLoneNumbers])) {
|
|
4695
5295
|
clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
|
|
4696
5296
|
}
|
|
4697
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
5297
|
+
if (!_optionalChain([opts, 'optionalAccess', _413 => _413.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
|
|
4698
5298
|
return mergeKoreanLines(
|
|
4699
5299
|
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))
|
|
4700
5300
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
4701
5301
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
4702
5302
|
if (line.startsWith("|")) {
|
|
4703
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
5303
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkFG3SD2G3cjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
4704
5304
|
}
|
|
4705
|
-
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access',
|
|
4706
|
-
return mark +
|
|
5305
|
+
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _414 => _414.exec, 'call', _415 => _415(line), 'optionalAccess', _416 => _416[0]]), () => ( ""));
|
|
5306
|
+
return mark + _chunkFG3SD2G3cjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
4707
5307
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
4708
5308
|
}
|
|
4709
5309
|
function startsWithMarker(line) {
|
|
@@ -4735,7 +5335,7 @@ function mergeKoreanLines(text) {
|
|
|
4735
5335
|
continue;
|
|
4736
5336
|
}
|
|
4737
5337
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
4738
|
-
result[result.length - 1] = prev +
|
|
5338
|
+
result[result.length - 1] = prev + _chunkFG3SD2G3cjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
4739
5339
|
} else {
|
|
4740
5340
|
result.push(curr);
|
|
4741
5341
|
}
|
|
@@ -4751,7 +5351,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
4751
5351
|
const wrapped = /* @__PURE__ */ new Set();
|
|
4752
5352
|
for (const a of annots) {
|
|
4753
5353
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
4754
|
-
const url =
|
|
5354
|
+
const url = _chunkUBZROOIAcjs.sanitizeHref.call(void 0, a.url);
|
|
4755
5355
|
if (!url) continue;
|
|
4756
5356
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
4757
5357
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -4783,7 +5383,7 @@ function addressKey(s) {
|
|
|
4783
5383
|
let t = s.replace(/\\(.)/g, "$1").replace(/\s+/g, "");
|
|
4784
5384
|
try {
|
|
4785
5385
|
t = decodeURI(t);
|
|
4786
|
-
} catch (
|
|
5386
|
+
} catch (e8) {
|
|
4787
5387
|
}
|
|
4788
5388
|
return t.toLowerCase().replace(/^(?:[a-z][a-z0-9+.-]*:)?(?:\/\/)?(?:www\.)?/, "").replace(/[/.,;:)\]]+$/, "");
|
|
4789
5389
|
}
|
|
@@ -4803,7 +5403,7 @@ function mergeLinkRuns(markdown) {
|
|
|
4803
5403
|
|
|
4804
5404
|
// src/pdf/formula-ocr.ts
|
|
4805
5405
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
4806
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
5406
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-EOGDE2KW.cjs")));
|
|
4807
5407
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
4808
5408
|
await ensureFormulaModels((p) => {
|
|
4809
5409
|
if (p.phase === "download" && p.total) {
|
|
@@ -4922,27 +5522,7 @@ function formatMb(bytes) {
|
|
|
4922
5522
|
return `${(bytes / 1024 / 1024).toFixed(1)}MB`;
|
|
4923
5523
|
}
|
|
4924
5524
|
|
|
4925
|
-
// src/pdf/polyfill.ts
|
|
4926
|
-
var _pdfworkermjs = require('pdfjs-dist/legacy/build/pdf.worker.mjs'); var pdfjsWorker = _interopRequireWildcard(_pdfworkermjs);
|
|
4927
|
-
var g = globalThis;
|
|
4928
|
-
if (typeof g.DOMMatrix === "undefined") {
|
|
4929
|
-
g.DOMMatrix = (_class = class DOMMatrix {
|
|
4930
|
-
__init() {this.m = [1, 0, 0, 1, 0, 0]}
|
|
4931
|
-
constructor(init) {;_class.prototype.__init.call(this);
|
|
4932
|
-
if (init) this.m = init;
|
|
4933
|
-
}
|
|
4934
|
-
}, _class);
|
|
4935
|
-
}
|
|
4936
|
-
if (typeof g.Path2D === "undefined") {
|
|
4937
|
-
g.Path2D = class Path2D {
|
|
4938
|
-
};
|
|
4939
|
-
}
|
|
4940
|
-
g.pdfjsWorker = pdfjsWorker;
|
|
4941
|
-
|
|
4942
5525
|
// src/pdf/parser.ts
|
|
4943
|
-
|
|
4944
|
-
var _module = require('module');
|
|
4945
|
-
var _path = require('path');
|
|
4946
5526
|
function ocrImageRegions(regions, large, all) {
|
|
4947
5527
|
if (all) return regions;
|
|
4948
5528
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -4952,89 +5532,62 @@ function ocrImageRegions(regions, large, all) {
|
|
|
4952
5532
|
}
|
|
4953
5533
|
return out;
|
|
4954
5534
|
}
|
|
4955
|
-
_pdfmjs.GlobalWorkerOptions.workerSrc = "";
|
|
4956
5535
|
var MAX_PAGES = 5e3;
|
|
4957
5536
|
var MAX_TOTAL_TEXT = 100 * 1024 * 1024;
|
|
4958
|
-
|
|
4959
|
-
var PDF_LOAD_TIMEOUT_MS = 3e4;
|
|
4960
|
-
var pdfjsAssets = {};
|
|
4961
|
-
try {
|
|
4962
|
-
const _require = _module.createRequire.call(void 0, _chunkGS7T56RPcjs.importMetaUrl);
|
|
4963
|
-
const pkgDir = _path.dirname.call(void 0, _require.resolve("pdfjs-dist/package.json"));
|
|
4964
|
-
pdfjsAssets.cMapUrl = _path.join.call(void 0, pkgDir, "cmaps") + "/";
|
|
4965
|
-
pdfjsAssets.cMapPacked = true;
|
|
4966
|
-
pdfjsAssets.standardFontDataUrl = _path.join.call(void 0, pkgDir, "standard_fonts") + "/";
|
|
4967
|
-
} catch (e6) {
|
|
4968
|
-
}
|
|
4969
|
-
var HEADLESS_FONT_DOCUMENT = {
|
|
4970
|
-
createElement: () => ({ sheet: { cssRules: [], insertRule() {
|
|
4971
|
-
} }, remove() {
|
|
4972
|
-
} }),
|
|
4973
|
-
documentElement: { getElementsByTagName: () => [{ append() {
|
|
4974
|
-
} }] }
|
|
4975
|
-
};
|
|
4976
|
-
var PDFJS_DOCUMENT_OPTIONS = {
|
|
4977
|
-
useSystemFonts: true,
|
|
4978
|
-
// 글꼴 /Differences 글리프 이름 — ToUnicode 없는 옛 숫자·작은 대문자 복원(glyph-names.ts)
|
|
4979
|
-
fontExtraProperties: true,
|
|
4980
|
-
disableFontFace: false,
|
|
4981
|
-
ownerDocument: HEADLESS_FONT_DOCUMENT,
|
|
4982
|
-
isEvalSupported: false,
|
|
4983
|
-
verbosity: 0,
|
|
4984
|
-
// 오류만 — 경고("Warning: Indexing all PDF objects")를 console.log 로 stdout 에 찍어 MCP·CLI JSON 을 깼다
|
|
4985
|
-
...pdfjsAssets
|
|
4986
|
-
};
|
|
4987
|
-
async function loadPdfWithTimeout(buffer, data) {
|
|
4988
|
-
const loadingTask = _pdfmjs.getDocument.call(void 0, {
|
|
4989
|
-
// pdfjs transfers its input to the worker; retain the caller's buffer for reuse.
|
|
4990
|
-
data: _nullishCoalesce(data, () => ( new Uint8Array(buffer.slice(0)))),
|
|
4991
|
-
...PDFJS_DOCUMENT_OPTIONS
|
|
4992
|
-
});
|
|
4993
|
-
let timer;
|
|
5537
|
+
async function loadPdf(buffer) {
|
|
4994
5538
|
try {
|
|
4995
|
-
return await
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
}),
|
|
5000
|
-
new Promise((_, reject) => {
|
|
5001
|
-
timer = setTimeout(() => {
|
|
5002
|
-
loadingTask.destroy();
|
|
5003
|
-
reject(new (0, _chunkCQ5DOA7Dcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
5004
|
-
}, PDF_LOAD_TIMEOUT_MS);
|
|
5005
|
-
})
|
|
5006
|
-
]);
|
|
5007
|
-
} finally {
|
|
5008
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
5539
|
+
return await openHayro(new Uint8Array(buffer));
|
|
5540
|
+
} catch (e) {
|
|
5541
|
+
if (!(e instanceof HayroOpenError)) throw e;
|
|
5542
|
+
throw new (0, _chunkUBZROOIAcjs.KordocError)(e.reason === "password" ? "\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)" : e.reason === "encryption" ? "\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 PDF \uC554\uD638\uD654\uC785\uB2C8\uB2E4" : "PDF \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
5009
5543
|
}
|
|
5010
5544
|
}
|
|
5011
5545
|
async function parsePdfDocument(buffer, options) {
|
|
5012
|
-
const formulaBuffer = _optionalChain([options, 'optionalAccess',
|
|
5546
|
+
const formulaBuffer = _optionalChain([options, 'optionalAccess', _417 => _417.formulaOcr]) ? buffer : null;
|
|
5013
5547
|
const ocrOptionError = _chunkMMK32GPDcjs.validateOcrOptions.call(void 0, options);
|
|
5014
|
-
if (ocrOptionError) throw new (0,
|
|
5015
|
-
const autoOcr = _optionalChain([options, 'optionalAccess',
|
|
5016
|
-
const ocrBuffer = _optionalChain([options, 'optionalAccess',
|
|
5017
|
-
const
|
|
5018
|
-
const
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
}
|
|
5024
|
-
|
|
5548
|
+
if (ocrOptionError) throw new (0, _chunkUBZROOIAcjs.KordocError)(ocrOptionError);
|
|
5549
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _418 => _418.ocr]) === void 0 && await _chunkFG3SD2G3cjs.ocrModelsCached.call(void 0, _chunkFG3SD2G3cjs.resolveOcrModels.call(void 0, options)) && (_optionalChain([options, 'optionalAccess', _419 => _419.ocrRec]) !== "auto" || await _chunkFG3SD2G3cjs.ocrModelsCached.call(void 0, _chunkFG3SD2G3cjs.handwritingFallbackModels.call(void 0, _chunkFG3SD2G3cjs.resolveOcrModels.call(void 0, options))));
|
|
5550
|
+
const ocrBuffer = _optionalChain([options, 'optionalAccess', _420 => _420.ocr]) || autoOcr ? buffer : null;
|
|
5551
|
+
const doc = await loadPdf(buffer);
|
|
5552
|
+
const imageObjs = { get(id, cb) {
|
|
5553
|
+
const v = doc.image(id);
|
|
5554
|
+
_optionalChain([cb, 'optionalCall', _421 => _421(v)]);
|
|
5555
|
+
return v;
|
|
5556
|
+
} };
|
|
5557
|
+
const imagePage = { objs: imageObjs, commonObjs: imageObjs };
|
|
5558
|
+
const fontObjs = /* @__PURE__ */ new Map();
|
|
5559
|
+
const fontObj = (key) => {
|
|
5560
|
+
if (!key.startsWith("hy_")) return void 0;
|
|
5561
|
+
if (!fontObjs.has(key)) {
|
|
5562
|
+
try {
|
|
5563
|
+
const info = hayroFontInfo(doc, key);
|
|
5564
|
+
if (!info) fontObjs.set(key, null);
|
|
5565
|
+
else {
|
|
5566
|
+
const differences = [], map = [];
|
|
5567
|
+
for (const [c, n] of info.differences) differences[c] = n;
|
|
5568
|
+
for (const [c, u] of info.toUnicode) map[c] = u;
|
|
5569
|
+
fontObjs.set(key, { name: info.name, isType3Font: info.subtype === "Type3", composite: info.composite, differences, toUnicode: { _map: map }, data: hayroFontData(doc.fontFile(key)) });
|
|
5570
|
+
}
|
|
5571
|
+
} catch (e9) {
|
|
5572
|
+
fontObjs.set(key, null);
|
|
5573
|
+
}
|
|
5574
|
+
}
|
|
5575
|
+
return fontObjs.get(key);
|
|
5576
|
+
};
|
|
5025
5577
|
try {
|
|
5026
|
-
const pageCount = doc.
|
|
5027
|
-
if (pageCount === 0) throw new (0,
|
|
5578
|
+
const pageCount = doc.pageCount();
|
|
5579
|
+
if (pageCount === 0) throw new (0, _chunkUBZROOIAcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
5028
5580
|
const metadata = { pageCount, pageMode: "layout" };
|
|
5029
|
-
|
|
5581
|
+
const info = pdfInfo(doc);
|
|
5582
|
+
extractPdfMetadata(info, metadata);
|
|
5030
5583
|
const blocks = [];
|
|
5031
5584
|
const warnings = [];
|
|
5032
5585
|
const pageQuality = [];
|
|
5033
5586
|
let totalChars = 0;
|
|
5034
5587
|
let totalTextBytes = 0;
|
|
5035
5588
|
const effectivePageCount = Math.min(pageCount, MAX_PAGES);
|
|
5036
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
5037
|
-
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess',
|
|
5589
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _422 => _422.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
|
|
5590
|
+
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _423 => _423.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
|
|
5038
5591
|
warnings.push({ message: `${pageCount}\uCABD \uC911 \uC55E ${MAX_PAGES}\uCABD\uB9CC \uD30C\uC2F1\uD588\uC2B5\uB2C8\uB2E4 (\uCABD \uC218 \uC0C1\uD55C)`, code: "PARTIAL_PARSE" });
|
|
5039
5592
|
}
|
|
5040
5593
|
const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
|
|
@@ -5046,65 +5599,51 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5046
5599
|
const skippedImagePages = /* @__PURE__ */ new Map();
|
|
5047
5600
|
const uncoveredImageRegions = /* @__PURE__ */ new Map();
|
|
5048
5601
|
const largeImageRegions = /* @__PURE__ */ new Set();
|
|
5049
|
-
const wantWebp = _optionalChain([options, 'optionalAccess',
|
|
5602
|
+
const wantWebp = _optionalChain([options, 'optionalAccess', _424 => _424.imageFormat]) === "webp" && options.images !== false;
|
|
5050
5603
|
const encodeWebp = wantWebp ? await _chunkTV7B6DJQcjs.loadWebpEncoder.call(void 0, ) : null;
|
|
5051
5604
|
if (wantWebp && !encodeWebp) warnings.push(_chunkTV7B6DJQcjs.WEBP_UNAVAILABLE);
|
|
5052
|
-
const imageState = createPdfImageState(
|
|
5053
|
-
const readQr = _optionalChain([options, 'optionalAccess',
|
|
5054
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5605
|
+
const imageState = createPdfImageState(_nullishCoalesce(encodeWebp, () => ( void 0)), _optionalChain([options, 'optionalAccess', _425 => _425.imagePlacement]) === "flow", !!_optionalChain([options, 'optionalAccess', _426 => _426.dropBlankImages]) && _optionalChain([options, 'optionalAccess', _427 => _427.images]) !== false);
|
|
5606
|
+
const readQr = _optionalChain([options, 'optionalAccess', _428 => _428.qrCodes]) ? await _chunkHHOGCXPDcjs.loadQrReader.call(void 0, ) : null;
|
|
5607
|
+
if (_optionalChain([options, 'optionalAccess', _429 => _429.qrCodes]) && !readQr) warnings.push(_chunkHHOGCXPDcjs.QR_UNAVAILABLE);
|
|
5055
5608
|
const imageBulletShapes = /* @__PURE__ */ new Map();
|
|
5056
5609
|
const imageArrowDirections = /* @__PURE__ */ new Map();
|
|
5057
5610
|
const extractedImages = [];
|
|
5058
5611
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
5059
5612
|
const carry = {};
|
|
5060
|
-
const hancomPdf =
|
|
5061
|
-
const preciseGaps = hancomPdf ||
|
|
5613
|
+
const hancomPdf = isHancomPdf(info);
|
|
5614
|
+
const preciseGaps = hancomPdf || isPreciseGapProducer(info);
|
|
5062
5615
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
5063
|
-
const wrapLexicon = new (0,
|
|
5616
|
+
const wrapLexicon = new (0, _chunkFG3SD2G3cjs.WrapLexicon)();
|
|
5064
5617
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
5065
5618
|
const headerContext = [];
|
|
5066
|
-
if (pageFilter && _optionalChain([options, 'optionalAccess',
|
|
5619
|
+
if (pageFilter && _optionalChain([options, 'optionalAccess', _430 => _430.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
5067
5620
|
for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
|
|
5068
|
-
let contextPage;
|
|
5069
5621
|
try {
|
|
5070
|
-
|
|
5071
|
-
const content =
|
|
5072
|
-
pageHeights.set(number,
|
|
5073
|
-
headerContext.push(...marginContextBlocks(content.items, number,
|
|
5074
|
-
} catch (
|
|
5075
|
-
} finally {
|
|
5076
|
-
_optionalChain([contextPage, 'optionalAccess', _436 => _436.cleanup, 'call', _437 => _437()]);
|
|
5622
|
+
const view = doc.pageView(number - 1);
|
|
5623
|
+
const content = hayroTextPage(doc, number);
|
|
5624
|
+
pageHeights.set(number, view[3] - view[1]);
|
|
5625
|
+
headerContext.push(...marginContextBlocks(content.items, number, view));
|
|
5626
|
+
} catch (e10) {
|
|
5077
5627
|
}
|
|
5078
5628
|
}
|
|
5079
5629
|
}
|
|
5080
5630
|
let parsedPages = 0;
|
|
5081
|
-
const loadedFonts = /* @__PURE__ */ new Set();
|
|
5082
5631
|
for (let i = 1; i <= effectivePageCount; i++) {
|
|
5083
5632
|
if (pageFilter && !pageFilter.has(i)) continue;
|
|
5084
|
-
let loadedPage;
|
|
5085
5633
|
try {
|
|
5086
|
-
const page =
|
|
5087
|
-
|
|
5088
|
-
const
|
|
5089
|
-
const [viewX1, viewY1, viewX2, viewY2] = page.view;
|
|
5634
|
+
const page = hayroTextPage(doc, i);
|
|
5635
|
+
const rotate = doc.pageRotate(i - 1);
|
|
5636
|
+
const [viewX1, viewY1, viewX2, viewY2] = doc.pageView(i - 1);
|
|
5090
5637
|
const pageW = viewX2 - viewX1, pageH = viewY2 - viewY1;
|
|
5091
5638
|
pageHeights.set(i, pageH);
|
|
5092
5639
|
pageWidths.set(i, pageW);
|
|
5093
|
-
const rawItems =
|
|
5094
|
-
const rawOps =
|
|
5095
|
-
|
|
5096
|
-
const fontObj = (loadedName) => {
|
|
5097
|
-
try {
|
|
5098
|
-
return page.commonObjs.has(loadedName) ? page.commonObjs.get(loadedName) : void 0;
|
|
5099
|
-
} catch (e8) {
|
|
5100
|
-
return void 0;
|
|
5101
|
-
}
|
|
5102
|
-
};
|
|
5103
|
-
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _438 => _438(loadedName), 'optionalAccess', _439 => _439.differences]);
|
|
5640
|
+
const rawItems = page.items;
|
|
5641
|
+
const rawOps = hayroOps(page.events, page.strings);
|
|
5642
|
+
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _431 => _431(loadedName), 'optionalAccess', _432 => _432.differences]);
|
|
5104
5643
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
5105
5644
|
markTrailingSpaceGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
5106
5645
|
const restoreSoftHyphens = softHyphenHeads(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
5107
|
-
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call',
|
|
5646
|
+
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _433 => _433(n), 'optionalAccess', _434 => _434.name]));
|
|
5108
5647
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
5109
5648
|
restoreUnmappedCidSpaces(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
5110
5649
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
@@ -5112,12 +5651,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5112
5651
|
if (hancomPdf) joinTrackedHangul(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
5113
5652
|
restoreSoftHyphens();
|
|
5114
5653
|
rawItems.push(...spaceMappedDots(rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n)));
|
|
5115
|
-
const items =
|
|
5654
|
+
const items = _chunkFG3SD2G3cjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
5116
5655
|
if (!preciseGaps) for (const it of items) {
|
|
5117
5656
|
delete it.fx;
|
|
5118
5657
|
delete it.fw;
|
|
5119
5658
|
}
|
|
5120
|
-
const filtered =
|
|
5659
|
+
const filtered = _chunkFG3SD2G3cjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
5121
5660
|
const joined = joinVerticalColumns(filtered.visible);
|
|
5122
5661
|
const visible = dropTabLeaderDots(joined);
|
|
5123
5662
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -5129,9 +5668,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5129
5668
|
}
|
|
5130
5669
|
mergeEnclosedDigits(visible);
|
|
5131
5670
|
try {
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
} catch (e9) {
|
|
5671
|
+
applyLinkAnnotations(visible, pdfLinkAnnotations(doc, i - 1));
|
|
5672
|
+
} catch (e11) {
|
|
5135
5673
|
}
|
|
5136
5674
|
const shifted = viewX1 !== 0 || viewY1 !== 0;
|
|
5137
5675
|
if (shifted) for (const item of visible) {
|
|
@@ -5139,30 +5677,30 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5139
5677
|
item.y -= viewY1;
|
|
5140
5678
|
}
|
|
5141
5679
|
const opList = shifted ? {
|
|
5142
|
-
fnArray: [
|
|
5680
|
+
fnArray: [_chunkFG3SD2G3cjs.OPS.transform, ...rawOps.fnArray],
|
|
5143
5681
|
argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
|
|
5144
5682
|
} : rawOps;
|
|
5145
|
-
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call',
|
|
5683
|
+
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _435 => _435(loadedName), 'optionalAccess', _436 => _436.name]));
|
|
5146
5684
|
remapControlGlyphs(visible, differencesOf);
|
|
5147
|
-
await
|
|
5685
|
+
await _chunkFG3SD2G3cjs.restoreImageBullets.call(void 0, visible, imagePage, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
5148
5686
|
const faces = /* @__PURE__ */ new Map();
|
|
5149
5687
|
for (const it of visible) {
|
|
5150
5688
|
if (!it.fontName) continue;
|
|
5151
5689
|
let face = faces.get(it.fontName);
|
|
5152
5690
|
if (face === void 0) {
|
|
5153
5691
|
const obj = fontObj(it.fontName);
|
|
5154
|
-
face = _optionalChain([obj, 'optionalAccess',
|
|
5692
|
+
face = _optionalChain([obj, 'optionalAccess', _437 => _437.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
|
|
5155
5693
|
faces.set(it.fontName, face);
|
|
5156
5694
|
}
|
|
5157
5695
|
it.fontName = face;
|
|
5158
|
-
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call',
|
|
5696
|
+
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _438 => _438(face), 'optionalAccess', _439 => _439.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
5159
5697
|
}
|
|
5160
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
5161
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
5698
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkYIATOFKCcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
5699
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkYIATOFKCcjs.escapeLiteralTags.call(void 0, it.text);
|
|
5162
5700
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
5163
5701
|
const pageArea = pageW * pageH;
|
|
5164
5702
|
if (pageArea > 0) {
|
|
5165
|
-
const imageRegions =
|
|
5703
|
+
const imageRegions = _chunkFG3SD2G3cjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
5166
5704
|
let uncovered = 0;
|
|
5167
5705
|
for (const r of imageRegions) {
|
|
5168
5706
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -5178,7 +5716,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5178
5716
|
});
|
|
5179
5717
|
if (!hasText2) {
|
|
5180
5718
|
if (large) uncovered++;
|
|
5181
|
-
if (
|
|
5719
|
+
if (rotate % 360 === 0 && viewX1 === 0 && viewY1 === 0) {
|
|
5182
5720
|
const regions = _nullishCoalesce(uncoveredImageRegions.get(i), () => ( []));
|
|
5183
5721
|
regions.push(r);
|
|
5184
5722
|
uncoveredImageRegions.set(i, regions);
|
|
@@ -5189,18 +5727,18 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5189
5727
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
5190
5728
|
}
|
|
5191
5729
|
const marks = superscriptNoteMarks(visible);
|
|
5192
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
5730
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkFG3SD2G3cjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
5193
5731
|
const stamp = marginStamp(visible);
|
|
5194
5732
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
5195
|
-
const rightArrows = _optionalChain([options, 'optionalAccess',
|
|
5196
|
-
const pageBlocks = orderTwoUpPage(
|
|
5733
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _440 => _440.tables]) !== false ? await _chunkFG3SD2G3cjs.detectRightArrowRegions.call(void 0, imagePage, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
5734
|
+
const pageBlocks = orderTwoUpPage(_chunkFG3SD2G3cjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _441 => _441.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
5197
5735
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
5198
5736
|
for (const b of pageBlocks) blocks.push(b);
|
|
5199
5737
|
try {
|
|
5200
|
-
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(
|
|
5738
|
+
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(imagePage, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _442 => _442.images]) !== false, _nullishCoalesce(readQr, () => ( void 0)));
|
|
5201
5739
|
if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
|
|
5202
5740
|
extractedImages.push(...pageImages);
|
|
5203
|
-
} catch (
|
|
5741
|
+
} catch (e12) {
|
|
5204
5742
|
}
|
|
5205
5743
|
let pageText = "";
|
|
5206
5744
|
for (const b of pageBlocks) {
|
|
@@ -5216,32 +5754,26 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5216
5754
|
const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
|
|
5217
5755
|
const quality = computePageQuality(i, pageText, vector.glyphs);
|
|
5218
5756
|
pageQuality.push(quality);
|
|
5219
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5757
|
+
if (_optionalChain([options, 'optionalAccess', _443 => _443.ocr]) && quality.ocrReason === "vector_text" && rotate % 360 === 0 && viewX1 === 0 && viewY1 === 0) {
|
|
5220
5758
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
5221
5759
|
}
|
|
5222
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
5760
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkUBZROOIAcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
5223
5761
|
parsedPages++;
|
|
5224
|
-
_optionalChain([options, 'optionalAccess',
|
|
5762
|
+
_optionalChain([options, 'optionalAccess', _444 => _444.onProgress, 'optionalCall', _445 => _445(parsedPages, totalTarget)]);
|
|
5225
5763
|
} catch (pageErr) {
|
|
5226
|
-
if (pageErr instanceof
|
|
5764
|
+
if (pageErr instanceof _chunkUBZROOIAcjs.KordocError) throw pageErr;
|
|
5227
5765
|
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" });
|
|
5228
|
-
} finally {
|
|
5229
|
-
_optionalChain([loadedPage, 'optionalAccess', _453 => _453.cleanup, 'call', _454 => _454()]);
|
|
5230
|
-
}
|
|
5231
|
-
if (loadedFonts.size > FONT_CACHE_LIMIT) {
|
|
5232
|
-
await doc.cleanup();
|
|
5233
|
-
loadedFonts.clear();
|
|
5234
5766
|
}
|
|
5235
5767
|
}
|
|
5236
5768
|
const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
|
|
5237
|
-
const isImageBased = _optionalChain([pageFilter, 'optionalAccess',
|
|
5769
|
+
const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _446 => _446.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
|
|
5238
5770
|
const ocrDone = /* @__PURE__ */ new Set();
|
|
5239
5771
|
const ocrLinesOut = /* @__PURE__ */ new Map();
|
|
5240
|
-
const ocrRegions = _optionalChain([options, 'optionalAccess',
|
|
5772
|
+
const ocrRegions = _optionalChain([options, 'optionalAccess', _447 => _447.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _448 => _448.ocr]) === true) : /* @__PURE__ */ new Map();
|
|
5241
5773
|
if (ocrBuffer) {
|
|
5242
5774
|
const inScope = (p) => !pageFilter || pageFilter.has(p);
|
|
5243
5775
|
const targets = /* @__PURE__ */ new Set();
|
|
5244
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5776
|
+
if (_optionalChain([options, 'optionalAccess', _449 => _449.ocr]) === "force" || isImageBased) {
|
|
5245
5777
|
for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
|
|
5246
5778
|
} else {
|
|
5247
5779
|
for (const pq of pageQuality) {
|
|
@@ -5254,25 +5786,25 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5254
5786
|
}
|
|
5255
5787
|
if (targets.size > 0) {
|
|
5256
5788
|
try {
|
|
5257
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
5258
|
-
const mode = typeof _optionalChain([options, 'optionalAccess',
|
|
5259
|
-
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess',
|
|
5260
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
5261
|
-
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess',
|
|
5262
|
-
for (const obs of ocrPageBlocks.values())
|
|
5789
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-KZHDUVLH.cjs")));
|
|
5790
|
+
const mode = typeof _optionalChain([options, 'optionalAccess', _450 => _450.ocr]) === "function" ? options.ocr : "builtin";
|
|
5791
|
+
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _451 => _451.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _452 => _452.find, 'call', _453 => _453((q) => q.page === p), 'optionalAccess', _454 => _454.needsOcr])));
|
|
5792
|
+
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-KZHDUVLH.cjs")));
|
|
5793
|
+
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _455 => _455.onProgress]), _optionalChain([options, 'optionalAccess', _456 => _456.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
5794
|
+
for (const obs of ocrPageBlocks.values()) _chunkYIATOFKCcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
5263
5795
|
if (ocrPageBlocks.size > 0) {
|
|
5264
5796
|
const replacePages = /* @__PURE__ */ new Set();
|
|
5265
5797
|
for (const [p, obs] of ocrPageBlocks) {
|
|
5266
|
-
const needsOcr = _optionalChain([pageQuality, 'access',
|
|
5267
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5798
|
+
const needsOcr = _optionalChain([pageQuality, 'access', _457 => _457.find, 'call', _458 => _458((q) => q.page === p), 'optionalAccess', _459 => _459.needsOcr]);
|
|
5799
|
+
if (_optionalChain([options, 'optionalAccess', _460 => _460.ocr]) === "force" || isImageBased || needsOcr) {
|
|
5268
5800
|
replacePages.add(p);
|
|
5269
5801
|
ocrDone.add(p);
|
|
5270
5802
|
continue;
|
|
5271
5803
|
}
|
|
5272
5804
|
const regions = ocrRegions.get(p);
|
|
5273
|
-
if (!regions ||
|
|
5805
|
+
if (!regions || _chunkFG3SD2G3cjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
5274
5806
|
ocrDone.add(p);
|
|
5275
|
-
if (_optionalChain([pageImageBlocks, 'access',
|
|
5807
|
+
if (_optionalChain([pageImageBlocks, 'access', _461 => _461.get, 'call', _462 => _462(p), 'optionalAccess', _463 => _463.length]) === 1) pageImageBlocks.delete(p);
|
|
5276
5808
|
}
|
|
5277
5809
|
if (replacePages.size) {
|
|
5278
5810
|
const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
|
|
@@ -5322,18 +5854,18 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5322
5854
|
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" });
|
|
5323
5855
|
}
|
|
5324
5856
|
}
|
|
5325
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5326
|
-
const removed =
|
|
5327
|
-
const running =
|
|
5857
|
+
if (_optionalChain([options, 'optionalAccess', _464 => _464.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
5858
|
+
const removed = _chunkFG3SD2G3cjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
5859
|
+
const running = _chunkFG3SD2G3cjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
5328
5860
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
5329
5861
|
blocks.splice(removed[ri], 1);
|
|
5330
5862
|
}
|
|
5331
|
-
const stripped =
|
|
5863
|
+
const stripped = _chunkFG3SD2G3cjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
5332
5864
|
if (stripped !== blocks) {
|
|
5333
5865
|
blocks.length = 0;
|
|
5334
5866
|
blocks.push(...stripped);
|
|
5335
5867
|
}
|
|
5336
|
-
const kept =
|
|
5868
|
+
const kept = _chunkFG3SD2G3cjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
5337
5869
|
if (kept !== blocks) {
|
|
5338
5870
|
blocks.length = 0;
|
|
5339
5871
|
blocks.push(...kept);
|
|
@@ -5341,16 +5873,16 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5341
5873
|
}
|
|
5342
5874
|
mergeContinuedCells(blocks, pageHeights);
|
|
5343
5875
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
5344
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5345
|
-
const boxes =
|
|
5876
|
+
if (_optionalChain([options, 'optionalAccess', _465 => _465.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
5877
|
+
const boxes = _chunkFG3SD2G3cjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
5346
5878
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
5347
5879
|
}
|
|
5348
5880
|
splitContactTables(blocks);
|
|
5349
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
5350
|
-
|
|
5881
|
+
if (!_optionalChain([options, 'optionalAccess', _466 => _466.keepTrailingEmptyCols])) _chunkFG3SD2G3cjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
5882
|
+
_chunkFG3SD2G3cjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
5351
5883
|
await flushPdfImages(imageState, warnings, pageImageBlocks);
|
|
5352
5884
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
5353
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5885
|
+
if (_optionalChain([options, 'optionalAccess', _467 => _467.formulaOcr]) && formulaBuffer) {
|
|
5354
5886
|
try {
|
|
5355
5887
|
await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
|
|
5356
5888
|
} catch (e) {
|
|
@@ -5360,55 +5892,55 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5360
5892
|
});
|
|
5361
5893
|
}
|
|
5362
5894
|
}
|
|
5363
|
-
const medianFontSize =
|
|
5895
|
+
const medianFontSize = _chunkFG3SD2G3cjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
5364
5896
|
if (medianFontSize > 0) {
|
|
5365
|
-
|
|
5366
|
-
}
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5897
|
+
_chunkFG3SD2G3cjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
5898
|
+
}
|
|
5899
|
+
_chunkFG3SD2G3cjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
5900
|
+
_chunkFG3SD2G3cjs.detectTypographyHeadings.call(void 0, blocks);
|
|
5901
|
+
_chunkFG3SD2G3cjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
5902
|
+
_chunkFG3SD2G3cjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
5903
|
+
_chunkFG3SD2G3cjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
5904
|
+
_chunkFG3SD2G3cjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
5905
|
+
_chunkFG3SD2G3cjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
5906
|
+
_chunkFG3SD2G3cjs.detectMarkerHeadings.call(void 0, blocks);
|
|
5375
5907
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
5376
|
-
|
|
5377
|
-
|
|
5908
|
+
_chunkFG3SD2G3cjs.detectTableCaptions.call(void 0, blocks);
|
|
5909
|
+
_chunkFG3SD2G3cjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
5378
5910
|
sanitizeBlockControlChars(blocks);
|
|
5379
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5911
|
+
if (_optionalChain([options, 'optionalAccess', _468 => _468.imagePlacement]) === "flow") moveImagesInFlow(blocks);
|
|
5380
5912
|
let outBlocks = splitSingleCellTables(blocks);
|
|
5381
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5913
|
+
if (_optionalChain([options, 'optionalAccess', _469 => _469.layoutTables]) !== "keep") {
|
|
5382
5914
|
blocks.length = 0;
|
|
5383
5915
|
for (const block of outBlocks) blocks.push(block);
|
|
5384
5916
|
}
|
|
5385
5917
|
outBlocks = inlineFootnotes(outBlocks, noteMarks);
|
|
5386
5918
|
outBlocks = relocateEndnotes(outBlocks);
|
|
5387
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5919
|
+
if (_optionalChain([options, 'optionalAccess', _470 => _470.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
|
|
5388
5920
|
if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
|
|
5389
5921
|
const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
|
|
5390
5922
|
if (!b.bbox || !h) return false;
|
|
5391
5923
|
return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
|
|
5392
5924
|
});
|
|
5393
5925
|
joinLatinCellWraps(outBlocks);
|
|
5394
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5395
|
-
const hancom =
|
|
5926
|
+
if (_optionalChain([options, 'optionalAccess', _471 => _471.layoutTables]) !== "keep") {
|
|
5927
|
+
const hancom = isHancomPdf(info);
|
|
5396
5928
|
const shown = /* @__PURE__ */ new Map();
|
|
5397
5929
|
const markContent = (bs) => {
|
|
5398
5930
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
5399
|
-
if (
|
|
5400
|
-
const lines =
|
|
5401
|
-
if (lines)
|
|
5931
|
+
if (_chunkFG3SD2G3cjs.IMAGE_CELLS.has(c)) _chunkYIATOFKCcjs.CONTENT_CELLS.add(c);
|
|
5932
|
+
const lines = _chunkFG3SD2G3cjs.CELL_LINES.get(c);
|
|
5933
|
+
if (lines) _chunkYIATOFKCcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
5402
5934
|
markContent(c.blocks);
|
|
5403
5935
|
}
|
|
5404
5936
|
};
|
|
5405
5937
|
const visual = (bs) => bs.flatMap((b) => {
|
|
5406
5938
|
if (b.type !== "table") return [b];
|
|
5407
|
-
if (!hancom && b.table &&
|
|
5939
|
+
if (!hancom && b.table && _chunkFG3SD2G3cjs.CLIP_TABLES.has(b.table)) return [b];
|
|
5408
5940
|
let v = shown.get(b);
|
|
5409
5941
|
if (!v) {
|
|
5410
5942
|
markContent([b]);
|
|
5411
|
-
shown.set(b, v =
|
|
5943
|
+
shown.set(b, v = _chunkYIATOFKCcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _472 => _472.keepTrailingEmptyCols])));
|
|
5412
5944
|
}
|
|
5413
5945
|
return v;
|
|
5414
5946
|
});
|
|
@@ -5417,13 +5949,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5417
5949
|
blocks.length = 0;
|
|
5418
5950
|
for (const b of kept) blocks.push(b);
|
|
5419
5951
|
}
|
|
5420
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
5421
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5952
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkYIATOFKCcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _473 => _473.tableFormat]) }), { keepLoneNumbers: true }));
|
|
5953
|
+
if (_optionalChain([options, 'optionalAccess', _474 => _474.tableFormat]) === "gfm") _chunkYIATOFKCcjs.assignTableIds.call(void 0, blocks);
|
|
5422
5954
|
let markdown = finishMarkdown(outBlocks);
|
|
5423
5955
|
const outline = collectPdfOutline(outBlocks);
|
|
5424
5956
|
return {
|
|
5425
5957
|
markdown,
|
|
5426
|
-
pages:
|
|
5958
|
+
pages: _chunkHHOGCXPDcjs.blocksToPages.call(void 0, splitPageTables(_chunkFG3SD2G3cjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
5427
5959
|
blocks,
|
|
5428
5960
|
metadata,
|
|
5429
5961
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -5432,48 +5964,28 @@ async function parsePdfDocument(buffer, options) {
|
|
|
5432
5964
|
pageQuality,
|
|
5433
5965
|
qualitySummary: summarizeDocumentQuality(pageQuality),
|
|
5434
5966
|
images: extractedImages.length > 0 ? extractedImages : void 0,
|
|
5435
|
-
..._optionalChain([options, 'optionalAccess',
|
|
5967
|
+
..._optionalChain([options, 'optionalAccess', _475 => _475.ocrLines]) ? { ocrLines: [...ocrLinesOut.values()].sort((a, b) => a.pageNumber - b.pageNumber) } : {}
|
|
5436
5968
|
};
|
|
5437
5969
|
} finally {
|
|
5438
|
-
|
|
5439
|
-
});
|
|
5440
|
-
_optionalChain([pdfium, 'optionalAccess', _485 => _485.close, 'call', _486 => _486()]);
|
|
5441
|
-
await _optionalChain([pristine, 'optionalAccess', _487 => _487.then, 'call', _488 => _488((d) => d.destroy()), 'access', _489 => _489.catch, 'call', _490 => _490(() => {
|
|
5442
|
-
})]);
|
|
5970
|
+
doc.close();
|
|
5443
5971
|
}
|
|
5444
5972
|
}
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
if (typeof info.Creator === "string" && info.Creator.trim()) metadata.creator = info.Creator.trim();
|
|
5453
|
-
if (typeof info.Subject === "string" && info.Subject.trim()) metadata.description = info.Subject.trim();
|
|
5454
|
-
if (typeof info.Keywords === "string" && info.Keywords.trim()) {
|
|
5455
|
-
metadata.keywords = info.Keywords.split(/[,;]/).map((k) => k.trim()).filter(Boolean);
|
|
5456
|
-
}
|
|
5457
|
-
if (typeof info.CreationDate === "string") metadata.createdAt = parsePdfDate(info.CreationDate);
|
|
5458
|
-
if (typeof info.ModDate === "string") metadata.modifiedAt = parsePdfDate(info.ModDate);
|
|
5459
|
-
} catch (e11) {
|
|
5460
|
-
}
|
|
5461
|
-
}
|
|
5462
|
-
async function isPreciseGapProducer(doc) {
|
|
5463
|
-
try {
|
|
5464
|
-
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _492 => _492.info]);
|
|
5465
|
-
return [_optionalChain([info, 'optionalAccess', _493 => _493.Producer]), _optionalChain([info, 'optionalAccess', _494 => _494.Creator])].some((v) => typeof v === "string" && /^\s*(?:microsoft: print to pdf|libreoffice)\b/i.test(v));
|
|
5466
|
-
} catch (e12) {
|
|
5467
|
-
return false;
|
|
5973
|
+
function extractPdfMetadata(info, metadata) {
|
|
5974
|
+
if (_optionalChain([info, 'access', _476 => _476.Title, 'optionalAccess', _477 => _477.trim, 'call', _478 => _478()])) metadata.title = info.Title.trim();
|
|
5975
|
+
if (_optionalChain([info, 'access', _479 => _479.Author, 'optionalAccess', _480 => _480.trim, 'call', _481 => _481()])) metadata.author = info.Author.trim();
|
|
5976
|
+
if (_optionalChain([info, 'access', _482 => _482.Creator, 'optionalAccess', _483 => _483.trim, 'call', _484 => _484()])) metadata.creator = info.Creator.trim();
|
|
5977
|
+
if (_optionalChain([info, 'access', _485 => _485.Subject, 'optionalAccess', _486 => _486.trim, 'call', _487 => _487()])) metadata.description = info.Subject.trim();
|
|
5978
|
+
if (_optionalChain([info, 'access', _488 => _488.Keywords, 'optionalAccess', _489 => _489.trim, 'call', _490 => _490()])) {
|
|
5979
|
+
metadata.keywords = info.Keywords.split(/[,;]/).map((k) => k.trim()).filter(Boolean);
|
|
5468
5980
|
}
|
|
5981
|
+
if (typeof info.CreationDate === "string") metadata.createdAt = parsePdfDate(info.CreationDate);
|
|
5982
|
+
if (typeof info.ModDate === "string") metadata.modifiedAt = parsePdfDate(info.ModDate);
|
|
5469
5983
|
}
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
return false;
|
|
5476
|
-
}
|
|
5984
|
+
function isHancomPdf(info) {
|
|
5985
|
+
return [info.Producer, info.Creator].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
|
|
5986
|
+
}
|
|
5987
|
+
function isPreciseGapProducer(info) {
|
|
5988
|
+
return [info.Producer, info.Creator].some((v) => typeof v === "string" && /^\s*(?:microsoft: print to pdf|libreoffice)\b/i.test(v));
|
|
5477
5989
|
}
|
|
5478
5990
|
function parsePdfDate(dateStr) {
|
|
5479
5991
|
const m = dateStr.match(/D:(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?/);
|
|
@@ -5482,14 +5994,13 @@ function parsePdfDate(dateStr) {
|
|
|
5482
5994
|
return `${year}-${month}-${day}T${hour}:${min}:${sec}`;
|
|
5483
5995
|
}
|
|
5484
5996
|
async function extractPdfMetadataOnly(buffer) {
|
|
5485
|
-
const doc = await
|
|
5997
|
+
const doc = await loadPdf(buffer);
|
|
5486
5998
|
try {
|
|
5487
|
-
const metadata = { pageCount: doc.
|
|
5488
|
-
|
|
5999
|
+
const metadata = { pageCount: doc.pageCount() };
|
|
6000
|
+
extractPdfMetadata(pdfInfo(doc), metadata);
|
|
5489
6001
|
return metadata;
|
|
5490
6002
|
} finally {
|
|
5491
|
-
|
|
5492
|
-
});
|
|
6003
|
+
doc.close();
|
|
5493
6004
|
}
|
|
5494
6005
|
}
|
|
5495
6006
|
function marginStamp(items) {
|
|
@@ -5514,6 +6025,5 @@ function marginStamp(items) {
|
|
|
5514
6025
|
|
|
5515
6026
|
|
|
5516
6027
|
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
//# sourceMappingURL=parser-NIB7K6KD.cjs.map
|
|
6028
|
+
exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkFG3SD2G3cjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkFG3SD2G3cjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.isPreciseGapProducer = isPreciseGapProducer; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkFG3SD2G3cjs.removeHeaderFooterBlocks;
|
|
6029
|
+
//# sourceMappingURL=parser-WP6URQHZ.cjs.map
|