kordoc 4.21.21 → 4.21.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/{-ZYF6HX4M.js → -PLOEMNCA.js} +11 -11
- package/dist/{chunk-RBRHO7WL.js → chunk-3BJW5KXR.js} +2 -2
- package/dist/{chunk-FBJVDBMO.js → chunk-64MCJ5GC.js} +2 -2
- package/dist/{chunk-BC54LBST.js → chunk-64V65GZM.js} +3 -3
- package/dist/{chunk-QHNVH4TC.js → chunk-6LJ22335.js} +6 -6
- package/dist/{chunk-TRO4CQHJ.js → chunk-6Z4NAN36.js} +4 -4
- package/dist/{chunk-PTF4NCFM.js → chunk-7MIA3IFO.js} +2 -2
- package/dist/{chunk-7YAJCXCD.js → chunk-7TLZ56ZK.js} +2 -2
- package/dist/{chunk-ZZIQWSGC.js → chunk-BMQATDUY.js} +2 -2
- package/dist/{chunk-YHPJTLCA.js → chunk-BZC24YXS.js} +2 -2
- package/dist/{chunk-J5PBI3ZC.js → chunk-EL7BGP7X.js} +3 -3
- package/dist/{chunk-5HTFWUJE.js → chunk-G4DVIZTZ.js} +2 -2
- package/dist/{chunk-YQZOPT3A.js → chunk-GYQGKVTQ.js} +5 -5
- package/dist/{chunk-YQZOPT3A.js.map → chunk-GYQGKVTQ.js.map} +1 -1
- package/dist/{chunk-T7PN5D4D.cjs → chunk-H5Q6J2MB.cjs} +6 -6
- package/dist/{chunk-T7PN5D4D.cjs.map → chunk-H5Q6J2MB.cjs.map} +1 -1
- package/dist/{chunk-HWIW3WK2.js → chunk-H6EXISSP.js} +3 -3
- package/dist/{chunk-H2MS4VG3.cjs → chunk-HY5O4B6O.cjs} +3 -3
- package/dist/{chunk-H2MS4VG3.cjs.map → chunk-HY5O4B6O.cjs.map} +1 -1
- package/dist/{chunk-BG6LUCQL.js → chunk-K7FP2VOU.js} +2 -2
- package/dist/{chunk-KTLHADU4.js → chunk-KFJP2HYL.js} +2 -2
- package/dist/{chunk-DTZIZ5PP.cjs → chunk-LNKHTD47.cjs} +13 -13
- package/dist/{chunk-DTZIZ5PP.cjs.map → chunk-LNKHTD47.cjs.map} +1 -1
- package/dist/{chunk-2ZGP7A5T.js → chunk-LZVOL2H2.js} +2 -2
- package/dist/{chunk-CY4QM2KQ.js → chunk-M5SPGZKY.js} +2 -2
- package/dist/{chunk-YM3K3LCD.js → chunk-NT4LPP2I.js} +10 -10
- package/dist/{chunk-T3DTTK23.js → chunk-PQW2RPZZ.js} +2 -2
- package/dist/{chunk-3TCF5HPP.js → chunk-PY72S2AG.js} +2 -2
- package/dist/{chunk-MCUX2Y2C.cjs → chunk-QSOWCFOV.cjs} +2 -2
- package/dist/{chunk-MCUX2Y2C.cjs.map → chunk-QSOWCFOV.cjs.map} +1 -1
- package/dist/{chunk-57VNFMMS.cjs → chunk-QY627PK3.cjs} +3 -3
- package/dist/{chunk-57VNFMMS.cjs.map → chunk-QY627PK3.cjs.map} +1 -1
- package/dist/{chunk-KBV4WFZ6.js → chunk-SQSGBKCL.js} +4 -4
- package/dist/{chunk-KBV4WFZ6.js.map → chunk-SQSGBKCL.js.map} +1 -1
- package/dist/{chunk-TMUUDMDH.cjs → chunk-SZM6BSK4.cjs} +23 -23
- package/dist/{chunk-TMUUDMDH.cjs.map → chunk-SZM6BSK4.cjs.map} +1 -1
- package/dist/{chunk-WGMYVRSA.js → chunk-VUSPHKQ6.js} +2 -2
- package/dist/{chunk-FZMGF6XU.js → chunk-ZQZDGIN4.js} +2 -2
- package/dist/chunks-YV22WKEN.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-P7M7IH2L.js → formula-I7GNHDP4.js} +4 -4
- package/dist/{formula-6XNIXZ5L.js → formula-L4ISZCZ7.js} +3 -3
- package/dist/{formula-A3I5VAP7.cjs → formula-LDXFM42U.cjs} +9 -9
- package/dist/{formula-A3I5VAP7.cjs.map → formula-LDXFM42U.cjs.map} +1 -1
- package/dist/{image-ocr-3C6W3KZO.js → image-ocr-BSAPJIFP.js} +6 -6
- package/dist/{image-ocr-ITNY454I.js → image-ocr-I7IVLLPD.js} +9 -9
- package/dist/{image-ocr-UJRSQ2T3.cjs → image-ocr-NCKZ4EOH.cjs} +15 -15
- package/dist/{image-ocr-UJRSQ2T3.cjs.map → image-ocr-NCKZ4EOH.cjs.map} +1 -1
- package/dist/index.cjs +276 -276
- package/dist/index.js +5 -5
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-LAWQH75O.js → model-bundle-M3GRBX2A.js} +5 -5
- package/dist/{models-6QTD2CFM.js → models-5RXMJK6N.js} +5 -5
- package/dist/{parse-worker-v2-FEPJG3ER.js → parse-worker-v2-72KKZMDO.js} +12 -12
- package/dist/{parser-56I364YM.js → parser-AHSXHMAF.js} +8 -8
- package/dist/{parser-KFCY3NIN.js → parser-QLNX2EFP.js} +11 -11
- package/dist/{parser-VKWUMUML.cjs → parser-XQL37S4F.cjs} +136 -136
- package/dist/{parser-VKWUMUML.cjs.map → parser-XQL37S4F.cjs.map} +1 -1
- package/dist/pdf-ocr-CR4W75XF.js +22 -0
- package/dist/pdf-ocr-FL32Z4MB.js +18 -0
- package/dist/pdf-ocr-V42HOZKB.cjs +19 -0
- package/dist/{pdf-ocr-OKAHNEJA.cjs.map → pdf-ocr-V42HOZKB.cjs.map} +1 -1
- package/dist/{profile-io-OCITHUQF.js → profile-io-FTGHBFAH.js} +3 -3
- package/dist/{rasterize-SFCG4YOI.js → rasterize-346O4XV4.js} +3 -3
- package/dist/{redact-doc-5SMPXIGG.js → redact-doc-O6UVSWKP.js} +11 -11
- package/dist/{render-FGPG5A2N.js → render-CUR3VCK5.js} +7 -7
- package/dist/seal-QUUK6RBL.js +10 -0
- package/dist/{setup-JQVYZO7I.js → setup-6EA7CJZU.js} +3 -3
- package/dist/visual-EMOEYBC4.js +20 -0
- package/dist/{watch-C77BUSP7.js → watch-EQRSWNAQ.js} +12 -12
- package/package.json +1 -1
- package/dist/chunks-MDMJRCJ7.js +0 -10
- package/dist/pdf-ocr-MME37BL4.js +0 -18
- package/dist/pdf-ocr-OKAHNEJA.cjs +0 -19
- package/dist/pdf-ocr-ZZ6AJL6Z.js +0 -22
- package/dist/seal-GA7NZDTG.js +0 -10
- package/dist/visual-YMG644YW.js +0 -20
- /package/dist/{-ZYF6HX4M.js.map → -PLOEMNCA.js.map} +0 -0
- /package/dist/{chunk-RBRHO7WL.js.map → chunk-3BJW5KXR.js.map} +0 -0
- /package/dist/{chunk-FBJVDBMO.js.map → chunk-64MCJ5GC.js.map} +0 -0
- /package/dist/{chunk-BC54LBST.js.map → chunk-64V65GZM.js.map} +0 -0
- /package/dist/{chunk-QHNVH4TC.js.map → chunk-6LJ22335.js.map} +0 -0
- /package/dist/{chunk-TRO4CQHJ.js.map → chunk-6Z4NAN36.js.map} +0 -0
- /package/dist/{chunk-PTF4NCFM.js.map → chunk-7MIA3IFO.js.map} +0 -0
- /package/dist/{chunk-7YAJCXCD.js.map → chunk-7TLZ56ZK.js.map} +0 -0
- /package/dist/{chunk-ZZIQWSGC.js.map → chunk-BMQATDUY.js.map} +0 -0
- /package/dist/{chunk-YHPJTLCA.js.map → chunk-BZC24YXS.js.map} +0 -0
- /package/dist/{chunk-J5PBI3ZC.js.map → chunk-EL7BGP7X.js.map} +0 -0
- /package/dist/{chunk-5HTFWUJE.js.map → chunk-G4DVIZTZ.js.map} +0 -0
- /package/dist/{chunk-HWIW3WK2.js.map → chunk-H6EXISSP.js.map} +0 -0
- /package/dist/{chunk-BG6LUCQL.js.map → chunk-K7FP2VOU.js.map} +0 -0
- /package/dist/{chunk-KTLHADU4.js.map → chunk-KFJP2HYL.js.map} +0 -0
- /package/dist/{chunk-2ZGP7A5T.js.map → chunk-LZVOL2H2.js.map} +0 -0
- /package/dist/{chunk-CY4QM2KQ.js.map → chunk-M5SPGZKY.js.map} +0 -0
- /package/dist/{chunk-YM3K3LCD.js.map → chunk-NT4LPP2I.js.map} +0 -0
- /package/dist/{chunk-T3DTTK23.js.map → chunk-PQW2RPZZ.js.map} +0 -0
- /package/dist/{chunk-3TCF5HPP.js.map → chunk-PY72S2AG.js.map} +0 -0
- /package/dist/{chunk-WGMYVRSA.js.map → chunk-VUSPHKQ6.js.map} +0 -0
- /package/dist/{chunk-FZMGF6XU.js.map → chunk-ZQZDGIN4.js.map} +0 -0
- /package/dist/{chunks-MDMJRCJ7.js.map → chunks-YV22WKEN.js.map} +0 -0
- /package/dist/{formula-P7M7IH2L.js.map → formula-I7GNHDP4.js.map} +0 -0
- /package/dist/{formula-6XNIXZ5L.js.map → formula-L4ISZCZ7.js.map} +0 -0
- /package/dist/{image-ocr-3C6W3KZO.js.map → image-ocr-BSAPJIFP.js.map} +0 -0
- /package/dist/{image-ocr-ITNY454I.js.map → image-ocr-I7IVLLPD.js.map} +0 -0
- /package/dist/{model-bundle-LAWQH75O.js.map → model-bundle-M3GRBX2A.js.map} +0 -0
- /package/dist/{models-6QTD2CFM.js.map → models-5RXMJK6N.js.map} +0 -0
- /package/dist/{parse-worker-v2-FEPJG3ER.js.map → parse-worker-v2-72KKZMDO.js.map} +0 -0
- /package/dist/{parser-56I364YM.js.map → parser-AHSXHMAF.js.map} +0 -0
- /package/dist/{parser-KFCY3NIN.js.map → parser-QLNX2EFP.js.map} +0 -0
- /package/dist/{pdf-ocr-MME37BL4.js.map → pdf-ocr-CR4W75XF.js.map} +0 -0
- /package/dist/{pdf-ocr-ZZ6AJL6Z.js.map → pdf-ocr-FL32Z4MB.js.map} +0 -0
- /package/dist/{profile-io-OCITHUQF.js.map → profile-io-FTGHBFAH.js.map} +0 -0
- /package/dist/{rasterize-SFCG4YOI.js.map → rasterize-346O4XV4.js.map} +0 -0
- /package/dist/{redact-doc-5SMPXIGG.js.map → redact-doc-O6UVSWKP.js.map} +0 -0
- /package/dist/{render-FGPG5A2N.js.map → render-CUR3VCK5.js.map} +0 -0
- /package/dist/{seal-GA7NZDTG.js.map → seal-QUUK6RBL.js.map} +0 -0
- /package/dist/{setup-JQVYZO7I.js.map → setup-6EA7CJZU.js.map} +0 -0
- /package/dist/{visual-YMG644YW.js.map → visual-EMOEYBC4.js.map} +0 -0
- /package/dist/{watch-C77BUSP7.js.map → watch-EQRSWNAQ.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkQY627PK3cjs = require('./chunk-QY627PK3.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -59,7 +59,7 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
var
|
|
62
|
+
var _chunkSZM6BSK4cjs = require('./chunk-SZM6BSK4.cjs');
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
@@ -72,12 +72,12 @@ var _chunkTMUUDMDHcjs = require('./chunk-TMUUDMDH.cjs');
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
var
|
|
76
|
-
require('./chunk-
|
|
75
|
+
var _chunkH5Q6J2MBcjs = require('./chunk-H5Q6J2MB.cjs');
|
|
76
|
+
require('./chunk-HY5O4B6O.cjs');
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
var
|
|
80
|
+
var _chunkQSOWCFOVcjs = require('./chunk-QSOWCFOV.cjs');
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -214,7 +214,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
214
214
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
215
215
|
state.seen.set(hash, filename);
|
|
216
216
|
if (withBytes) {
|
|
217
|
-
const png =
|
|
217
|
+
const png = _chunkQY627PK3cjs.encodePng.call(void 0, w, h, rgba);
|
|
218
218
|
state.totalBytes += png.length;
|
|
219
219
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
220
220
|
}
|
|
@@ -694,7 +694,7 @@ function rowStarts(t) {
|
|
|
694
694
|
}
|
|
695
695
|
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));
|
|
696
696
|
function cellPage(cell) {
|
|
697
|
-
const p =
|
|
697
|
+
const p = _chunkH5Q6J2MBcjs.CELL_PAGES.get(cell);
|
|
698
698
|
if (p !== void 0 || !_optionalChain([cell, 'access', _15 => _15.blocks, 'optionalAccess', _16 => _16.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
699
699
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
700
700
|
}
|
|
@@ -723,7 +723,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
723
723
|
rows.forEach((starts, r) => {
|
|
724
724
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
725
725
|
for (const { cell } of starts) {
|
|
726
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
726
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkH5Q6J2MBcjs.CELL_PAGES.set(cell, page2);
|
|
727
727
|
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _19 => _19.find, 'call', _20 => _20((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
|
|
728
728
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
729
729
|
}
|
|
@@ -772,8 +772,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
772
772
|
if (!splits.length) continue;
|
|
773
773
|
const clone = (cell, patch) => {
|
|
774
774
|
const out = { ...cell, ...patch };
|
|
775
|
-
const p =
|
|
776
|
-
if (p !== void 0)
|
|
775
|
+
const p = _chunkH5Q6J2MBcjs.CELL_PAGES.get(cell);
|
|
776
|
+
if (p !== void 0) _chunkH5Q6J2MBcjs.CELL_PAGES.set(out, p);
|
|
777
777
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
778
778
|
return out;
|
|
779
779
|
};
|
|
@@ -783,7 +783,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
783
783
|
for (const { cell, c, split } of splits) {
|
|
784
784
|
cells[r][c] = clone(cell, split.head);
|
|
785
785
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
786
|
-
|
|
786
|
+
_chunkH5Q6J2MBcjs.CELL_PAGES.set(tail, split.page);
|
|
787
787
|
setSplits(tail, split.rest);
|
|
788
788
|
row[c] = tail;
|
|
789
789
|
}
|
|
@@ -902,19 +902,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
902
902
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
903
903
|
}
|
|
904
904
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
905
|
-
const lines =
|
|
906
|
-
if (lines)
|
|
907
|
-
if (
|
|
908
|
-
const edges =
|
|
905
|
+
const lines = _chunkSZM6BSK4cjs.CELL_LINES.get(a.cell);
|
|
906
|
+
if (lines) _chunkSZM6BSK4cjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
907
|
+
if (_chunkSZM6BSK4cjs.IMAGE_CELLS.has(a.cell)) _chunkSZM6BSK4cjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
908
|
+
const edges = _chunkH5Q6J2MBcjs.CELL_EDGES.get(a.cell);
|
|
909
909
|
if (edges) {
|
|
910
|
-
|
|
910
|
+
_chunkH5Q6J2MBcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
911
911
|
edged = true;
|
|
912
912
|
}
|
|
913
913
|
return true;
|
|
914
914
|
};
|
|
915
|
-
for (const a of pa) if (!
|
|
915
|
+
for (const a of pa) if (!_chunkSZM6BSK4cjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
916
916
|
for (const a of ca) {
|
|
917
|
-
if (a.r < skip ||
|
|
917
|
+
if (a.r < skip || _chunkSZM6BSK4cjs.FILLER_CELLS.has(a.cell)) continue;
|
|
918
918
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
919
919
|
}
|
|
920
920
|
const first = prev.rows;
|
|
@@ -938,9 +938,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
938
938
|
const grown = { ...above, rs: newRs };
|
|
939
939
|
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;
|
|
940
940
|
}
|
|
941
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
941
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkSZM6BSK4cjs.FILLER_CELLS.add(grid[r][c]);
|
|
942
942
|
if (edged) {
|
|
943
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
943
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkH5Q6J2MBcjs.CELL_EDGES.set(grid[r][c], _chunkSZM6BSK4cjs.NO_EDGES);
|
|
944
944
|
}
|
|
945
945
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
946
946
|
let r = prev.rows;
|
|
@@ -949,7 +949,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
949
949
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
950
950
|
}
|
|
951
951
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
952
|
-
const pr =
|
|
952
|
+
const pr = _chunkSZM6BSK4cjs.ROW_RULES.get(prev), cr = _chunkSZM6BSK4cjs.ROW_RULES.get(curr);
|
|
953
953
|
const shifted = dx !== 0;
|
|
954
954
|
const cut = {
|
|
955
955
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -960,7 +960,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
960
960
|
if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U)) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
|
|
961
961
|
if (pr && cr) {
|
|
962
962
|
const cutRuled = pr.bottom || cr.top;
|
|
963
|
-
|
|
963
|
+
_chunkSZM6BSK4cjs.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) });
|
|
964
964
|
}
|
|
965
965
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
966
966
|
}
|
|
@@ -1021,11 +1021,11 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1021
1021
|
c = u.c + u.cs;
|
|
1022
1022
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1023
1023
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1024
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1024
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkSZM6BSK4cjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
1025
1025
|
if (!flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1026
1026
|
if (!straddles && !midWord) continue;
|
|
1027
1027
|
if (u.r >= last && d.rs < 2) continue;
|
|
1028
|
-
const U =
|
|
1028
|
+
const U = _chunkSZM6BSK4cjs.CELL_LINES.get(a);
|
|
1029
1029
|
if (!_optionalChain([U, 'optionalAccess', _30 => _30.length]) || !hasContent(b)) continue;
|
|
1030
1030
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1031
1031
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -1043,7 +1043,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1043
1043
|
return merged;
|
|
1044
1044
|
}
|
|
1045
1045
|
function longLastLine(c) {
|
|
1046
|
-
const L =
|
|
1046
|
+
const L = _chunkSZM6BSK4cjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _31 => _31[L.length - 1]]);
|
|
1047
1047
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1048
1048
|
}
|
|
1049
1049
|
function filledToBottom(U, bottom) {
|
|
@@ -1076,7 +1076,7 @@ function nextItemHead(prev, next) {
|
|
|
1076
1076
|
return false;
|
|
1077
1077
|
}
|
|
1078
1078
|
function continuesAcross(u, d, x1, x2) {
|
|
1079
|
-
const U =
|
|
1079
|
+
const U = _chunkSZM6BSK4cjs.CELL_LINES.get(u), D = _chunkSZM6BSK4cjs.CELL_LINES.get(d);
|
|
1080
1080
|
if (!_optionalChain([U, 'optionalAccess', _32 => _32.length]) || !_optionalChain([D, 'optionalAccess', _33 => _33.length])) return false;
|
|
1081
1081
|
const last = U[U.length - 1];
|
|
1082
1082
|
const fs = last.h || 10;
|
|
@@ -1094,7 +1094,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1094
1094
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1095
1095
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1096
1096
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1097
|
-
const newItem =
|
|
1097
|
+
const newItem = _chunkSZM6BSK4cjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1098
1098
|
const all = D.length ? U.concat(D) : U;
|
|
1099
1099
|
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));
|
|
1100
1100
|
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;
|
|
@@ -1111,10 +1111,10 @@ function outlineContinues(u, d) {
|
|
|
1111
1111
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1112
1112
|
}
|
|
1113
1113
|
function lineEnded(c, x1, x2, next) {
|
|
1114
|
-
const L =
|
|
1114
|
+
const L = _chunkSZM6BSK4cjs.CELL_LINES.get(c);
|
|
1115
1115
|
if (!L || L.length !== 1) return false;
|
|
1116
1116
|
const l = L[0], h = l.h || 10;
|
|
1117
|
-
const d0 = next ? _optionalChain([
|
|
1117
|
+
const d0 = next ? _optionalChain([_chunkSZM6BSK4cjs.CELL_LINES, 'access', _34 => _34.get, 'call', _35 => _35(next), 'optionalAccess', _36 => _36[0]]) : void 0;
|
|
1118
1118
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1119
1119
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _37 => _37.text]), () => ( "")))) * h;
|
|
1120
1120
|
}
|
|
@@ -1130,9 +1130,9 @@ function appendCell(a, b) {
|
|
|
1130
1130
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1131
1131
|
}
|
|
1132
1132
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1133
|
-
|
|
1133
|
+
_chunkSZM6BSK4cjs.joinCellEdges.call(void 0, a, b);
|
|
1134
1134
|
}
|
|
1135
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _44 => _44.blocks, 'optionalAccess', _45 => _45.length]) ||
|
|
1135
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _44 => _44.blocks, 'optionalAccess', _45 => _45.length]) || _chunkSZM6BSK4cjs.IMAGE_CELLS.has(cell);
|
|
1136
1136
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1137
1137
|
var batchim = (ch) => {
|
|
1138
1138
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1140,7 +1140,7 @@ var batchim = (ch) => {
|
|
|
1140
1140
|
};
|
|
1141
1141
|
function clauseContinues(u, d) {
|
|
1142
1142
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1143
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1143
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkSZM6BSK4cjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1144
1144
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1145
1145
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1146
1146
|
}
|
|
@@ -1148,8 +1148,8 @@ function quantityContinues(u, d) {
|
|
|
1148
1148
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1149
1149
|
}
|
|
1150
1150
|
function wordOverflows(u, d, x1, x2) {
|
|
1151
|
-
const U =
|
|
1152
|
-
if (!_optionalChain([U, 'optionalAccess', _46 => _46.length]) ||
|
|
1151
|
+
const U = _chunkSZM6BSK4cjs.CELL_LINES.get(u);
|
|
1152
|
+
if (!_optionalChain([U, 'optionalAccess', _46 => _46.length]) || _chunkSZM6BSK4cjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1153
1153
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1154
1154
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1155
1155
|
}
|
|
@@ -1217,7 +1217,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1217
1217
|
if (!carriedSplit) {
|
|
1218
1218
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1219
1219
|
if (pairs.some(([u, d]) => hasContent(d.cell) && norm(cell(d)) !== norm(cell(u)) && lineEnded(cell(u), colXs[u.c], colXs[u.c + u.cs], cell(d)))) return false;
|
|
1220
|
-
const oneLine = (c) => _optionalChain([
|
|
1220
|
+
const oneLine = (c) => _optionalChain([_chunkSZM6BSK4cjs.CELL_LINES, 'access', _48 => _48.get, 'call', _49 => _49(c), 'optionalAccess', _50 => _50.length]) === 1;
|
|
1221
1221
|
if (pairs.some(([u, d]) => nextItemHead(cell(u).text, cell(d).text)) && pairs.some(([u, d]) => hasContent(u.cell) && hasContent(d.cell) && oneLine(cell(u)) && oneLine(cell(d)) && norm(cell(u)) !== norm(cell(d)))) return false;
|
|
1222
1222
|
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));
|
|
1223
1223
|
if (!(cut.open && !newCell)) {
|
|
@@ -1302,19 +1302,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1302
1302
|
placeJoined(blocks, i, j, joined);
|
|
1303
1303
|
continue;
|
|
1304
1304
|
}
|
|
1305
|
-
if (
|
|
1305
|
+
if (_chunkSZM6BSK4cjs.EMPTY_PARTS.has(curr.table)) {
|
|
1306
1306
|
blocks.splice(j, 1);
|
|
1307
1307
|
i++;
|
|
1308
1308
|
continue;
|
|
1309
1309
|
}
|
|
1310
1310
|
if (joined === null) continue;
|
|
1311
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1311
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkSZM6BSK4cjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1312
1312
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1313
1313
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1314
1314
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1315
1315
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1316
|
-
const px =
|
|
1317
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1316
|
+
const px = _chunkSZM6BSK4cjs.TABLE_COLXS.get(prev.table), cx = _chunkSZM6BSK4cjs.TABLE_COLXS.get(curr.table);
|
|
1317
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkSZM6BSK4cjs.CLIP_TABLES.has(prev.table) && !_chunkSZM6BSK4cjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1318
1318
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1319
1319
|
let currCells = curr.table.cells;
|
|
1320
1320
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1325,16 +1325,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1325
1325
|
blocks.splice(j, 1);
|
|
1326
1326
|
continue;
|
|
1327
1327
|
}
|
|
1328
|
-
if (px && cx && !
|
|
1328
|
+
if (px && cx && !_chunkSZM6BSK4cjs.CLIP_TABLES.has(prev.table) && !_chunkSZM6BSK4cjs.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 && _chunkSZM6BSK4cjs.CELL_LINES.has(c))) {
|
|
1329
1329
|
const dx = px[0] - cx[0];
|
|
1330
1330
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1331
1331
|
if (_optionalChain([part, 'optionalAccess', _67 => _67.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1332
1332
|
const last = prev.table.rows - 1;
|
|
1333
1333
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1334
|
-
const U =
|
|
1335
|
-
|
|
1334
|
+
const U = _chunkSZM6BSK4cjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkSZM6BSK4cjs.CELL_LINES.get(currCells[0][c]);
|
|
1335
|
+
_chunkSZM6BSK4cjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1336
1336
|
}
|
|
1337
|
-
|
|
1337
|
+
_chunkSZM6BSK4cjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1338
1338
|
placeJoined(blocks, i, j, part.table);
|
|
1339
1339
|
continue;
|
|
1340
1340
|
}
|
|
@@ -1347,20 +1347,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1347
1347
|
caption: prev.table.caption,
|
|
1348
1348
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1349
1349
|
};
|
|
1350
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1351
|
-
if (
|
|
1350
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkSZM6BSK4cjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1351
|
+
if (_chunkSZM6BSK4cjs.CLIP_TABLES.has(prev.table) || _chunkSZM6BSK4cjs.CLIP_TABLES.has(curr.table)) _chunkSZM6BSK4cjs.CLIP_TABLES.add(merged);
|
|
1352
1352
|
placeJoined(blocks, i, j, merged);
|
|
1353
1353
|
}
|
|
1354
1354
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1355
1355
|
const t = blocks[i].table;
|
|
1356
|
-
if (blocks[i].type === "table" && t &&
|
|
1356
|
+
if (blocks[i].type === "table" && t && _chunkSZM6BSK4cjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1357
1357
|
}
|
|
1358
1358
|
}
|
|
1359
1359
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1360
1360
|
if (!pageHeights) return;
|
|
1361
1361
|
for (let i = 0; i < blocks.length; i++) {
|
|
1362
1362
|
const L = blocks[i];
|
|
1363
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1363
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkSZM6BSK4cjs.CLIP_TABLES.has(L.table) || _chunkSZM6BSK4cjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1364
1364
|
const ph = pageHeights.get(L.pageNumber);
|
|
1365
1365
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1366
1366
|
let s0 = i, s1 = i;
|
|
@@ -1389,8 +1389,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1389
1389
|
}
|
|
1390
1390
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1391
1391
|
const pt = prev.table, ct = curr.table;
|
|
1392
|
-
if (!
|
|
1393
|
-
const px =
|
|
1392
|
+
if (!_chunkSZM6BSK4cjs.CLIP_TABLES.has(pt) || !_chunkSZM6BSK4cjs.CLIP_TABLES.has(ct)) return null;
|
|
1393
|
+
const px = _chunkSZM6BSK4cjs.TABLE_COLXS.get(pt), cx = _chunkSZM6BSK4cjs.TABLE_COLXS.get(ct);
|
|
1394
1394
|
if (!px || !cx) return null;
|
|
1395
1395
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1396
1396
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -1406,15 +1406,15 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1406
1406
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1407
1407
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1408
1408
|
};
|
|
1409
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1409
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkSZM6BSK4cjs.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);
|
|
1410
1410
|
}
|
|
1411
1411
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _72 => _72.bbox, 'optionalAccess', _73 => _73.y]), lex);
|
|
1412
1412
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1413
|
-
|
|
1414
|
-
const ys =
|
|
1415
|
-
if (ys)
|
|
1416
|
-
|
|
1417
|
-
|
|
1413
|
+
_chunkSZM6BSK4cjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1414
|
+
const ys = _chunkSZM6BSK4cjs.TABLE_ROWYS.get(pt);
|
|
1415
|
+
if (ys) _chunkSZM6BSK4cjs.TABLE_ROWYS.set(res.table, ys);
|
|
1416
|
+
_chunkSZM6BSK4cjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkSZM6BSK4cjs.PART_COLXS.get(pt), () => ( px)));
|
|
1417
|
+
_chunkSZM6BSK4cjs.CLIP_TABLES.add(res.table);
|
|
1418
1418
|
return res.table;
|
|
1419
1419
|
}
|
|
1420
1420
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
@@ -1438,12 +1438,12 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
1438
1438
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1439
1439
|
}
|
|
1440
1440
|
function pushedLead(prev, curr) {
|
|
1441
|
-
if (!
|
|
1441
|
+
if (!_chunkSZM6BSK4cjs.CLIP_TABLES.has(prev.table) || !_chunkSZM6BSK4cjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1442
1442
|
const lead = leadRows(curr.table);
|
|
1443
1443
|
return lead.image && lead.height > prev.bbox.y;
|
|
1444
1444
|
}
|
|
1445
1445
|
function leadRows(t) {
|
|
1446
|
-
const ys =
|
|
1446
|
+
const ys = _chunkSZM6BSK4cjs.TABLE_ROWYS.get(t);
|
|
1447
1447
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1448
1448
|
const anchors = anchorsOf(t);
|
|
1449
1449
|
let end = 1, image = false;
|
|
@@ -1451,17 +1451,17 @@ function leadRows(t) {
|
|
|
1451
1451
|
for (const a of anchors) {
|
|
1452
1452
|
if (a.r !== r) continue;
|
|
1453
1453
|
end = Math.max(end, r + a.rs);
|
|
1454
|
-
if (
|
|
1454
|
+
if (_chunkSZM6BSK4cjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1455
1455
|
}
|
|
1456
1456
|
}
|
|
1457
1457
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1458
1458
|
}
|
|
1459
1459
|
function tailOf(b) {
|
|
1460
|
-
const t = b.table &&
|
|
1460
|
+
const t = b.table && _chunkSZM6BSK4cjs.TABLE_TAIL.get(b.table);
|
|
1461
1461
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1462
1462
|
}
|
|
1463
1463
|
function firstRowSig(t) {
|
|
1464
|
-
const x =
|
|
1464
|
+
const x = _chunkSZM6BSK4cjs.TABLE_COLXS.get(t);
|
|
1465
1465
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1466
1466
|
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, "") }));
|
|
1467
1467
|
}
|
|
@@ -1514,7 +1514,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1514
1514
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1515
1515
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1516
1516
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1517
|
-
const px =
|
|
1517
|
+
const px = _chunkSZM6BSK4cjs.TABLE_COLXS.get(pb.table), cx = _chunkSZM6BSK4cjs.TABLE_COLXS.get(cur.table);
|
|
1518
1518
|
if (!px || !cx) break;
|
|
1519
1519
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1520
1520
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1585,7 +1585,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1585
1585
|
var COL_MATCH_TOL = 0.5;
|
|
1586
1586
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1587
1587
|
function lastRowCell(t, x1, x2) {
|
|
1588
|
-
const xs =
|
|
1588
|
+
const xs = _chunkSZM6BSK4cjs.TABLE_COLXS.get(t);
|
|
1589
1589
|
const covered = /* @__PURE__ */ new Set();
|
|
1590
1590
|
for (let r = 0; r < t.rows; r++) {
|
|
1591
1591
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -1603,7 +1603,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1603
1603
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1604
1604
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1605
1605
|
const part = blocks[j];
|
|
1606
|
-
const from = part.table ?
|
|
1606
|
+
const from = part.table ? _chunkSZM6BSK4cjs.CONT_PARTS.get(part.table) : void 0;
|
|
1607
1607
|
if (!from || !part.table) continue;
|
|
1608
1608
|
let i = j - 1;
|
|
1609
1609
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
@@ -1616,11 +1616,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1616
1616
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1617
1617
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1618
1618
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1619
|
-
|
|
1620
|
-
const lines =
|
|
1621
|
-
if (_optionalChain([lines, 'optionalAccess', _97 => _97.length]))
|
|
1622
|
-
if (part.pageNumber && part.bbox)
|
|
1623
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _98 => _98.blocks, 'optionalAccess', _99 => _99.length]))
|
|
1619
|
+
_chunkSZM6BSK4cjs.joinCellEdges.call(void 0, cell, add);
|
|
1620
|
+
const lines = _chunkSZM6BSK4cjs.CELL_LINES.get(add);
|
|
1621
|
+
if (_optionalChain([lines, 'optionalAccess', _97 => _97.length])) _chunkSZM6BSK4cjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkSZM6BSK4cjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1622
|
+
if (part.pageNumber && part.bbox) _chunkSZM6BSK4cjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkSZM6BSK4cjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1623
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _98 => _98.blocks, 'optionalAccess', _99 => _99.length])) _chunkSZM6BSK4cjs.EMPTY_PARTS.delete(prev.table);
|
|
1624
1624
|
blocks.splice(j, 1);
|
|
1625
1625
|
if (cell.blocks && at > 0) {
|
|
1626
1626
|
const nextAt = cell.blocks[at];
|
|
@@ -1632,11 +1632,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1632
1632
|
}
|
|
1633
1633
|
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1634
1634
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1635
|
-
if (!_optionalChain([prev, 'optionalAccess', _100 => _100.table]) || !_optionalChain([frame, 'optionalAccess', _101 => _101.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !
|
|
1635
|
+
if (!_optionalChain([prev, 'optionalAccess', _100 => _100.table]) || !_optionalChain([frame, 'optionalAccess', _101 => _101.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkSZM6BSK4cjs.CLIP_TABLES.has(frame.table)) return;
|
|
1636
1636
|
const inner = _optionalChain([frame, 'access', _102 => _102.table, 'access', _103 => _103.cells, 'access', _104 => _104[0], 'optionalAccess', _105 => _105[0], 'optionalAccess', _106 => _106.blocks]);
|
|
1637
1637
|
const next = _optionalChain([inner, 'optionalAccess', _107 => _107[0]]);
|
|
1638
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _108 => _108.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
1639
|
-
const px =
|
|
1638
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _108 => _108.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkSZM6BSK4cjs.CLIP_TABLES.has(prev.table) || !_chunkSZM6BSK4cjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1639
|
+
const px = _chunkSZM6BSK4cjs.TABLE_COLXS.get(prev.table), nx = _chunkSZM6BSK4cjs.TABLE_COLXS.get(next.table);
|
|
1640
1640
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1641
1641
|
const ph = _optionalChain([pageHeights, 'optionalAccess', _109 => _109.get, 'call', _110 => _110(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _111 => _111.get, 'call', _112 => _112(next.pageNumber)]);
|
|
1642
1642
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
@@ -1645,14 +1645,14 @@ function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
|
1645
1645
|
function fillNestedContinuation(blocks, at) {
|
|
1646
1646
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1647
1647
|
const t = _optionalChain([prev, 'optionalAccess', _113 => _113.table]), u = _optionalChain([next, 'optionalAccess', _114 => _114.table]);
|
|
1648
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1649
|
-
const xs =
|
|
1648
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkSZM6BSK4cjs.CLIP_TABLES.has(t) || !_chunkSZM6BSK4cjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1649
|
+
const xs = _chunkSZM6BSK4cjs.TABLE_COLXS.get(u);
|
|
1650
1650
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1651
1651
|
const add = _optionalChain([u, 'access', _115 => _115.cells, 'access', _116 => _116[0], 'optionalAccess', _117 => _117[0]]);
|
|
1652
1652
|
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _118 => _118.blocks, 'optionalAccess', _119 => _119.length])) return;
|
|
1653
1653
|
cell.text = add.text;
|
|
1654
1654
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1655
|
-
|
|
1655
|
+
_chunkSZM6BSK4cjs.joinCellEdges.call(void 0, cell, add);
|
|
1656
1656
|
blocks.splice(at, 1);
|
|
1657
1657
|
}
|
|
1658
1658
|
|
|
@@ -1872,15 +1872,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
1872
1872
|
function marginContextBlocks(raw, page, view) {
|
|
1873
1873
|
const [x1, y1, x2, y2] = view;
|
|
1874
1874
|
const width = x2 - x1, height = y2 - y1;
|
|
1875
|
-
const items =
|
|
1875
|
+
const items = _chunkSZM6BSK4cjs.filterHiddenText.call(void 0, _chunkSZM6BSK4cjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
1876
1876
|
for (const item of items) {
|
|
1877
1877
|
item.x -= x1;
|
|
1878
1878
|
item.y -= y1;
|
|
1879
1879
|
}
|
|
1880
|
-
return
|
|
1881
|
-
const bbox =
|
|
1880
|
+
return _chunkSZM6BSK4cjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
1881
|
+
const bbox = _chunkSZM6BSK4cjs.computeBBox.call(void 0, line, page);
|
|
1882
1882
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
1883
|
-
return [{ type: "paragraph", text:
|
|
1883
|
+
return [{ type: "paragraph", text: _chunkSZM6BSK4cjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkSZM6BSK4cjs.dominantStyle.call(void 0, line) }];
|
|
1884
1884
|
});
|
|
1885
1885
|
}
|
|
1886
1886
|
|
|
@@ -1916,7 +1916,7 @@ var WINANSI_REVERSE = {
|
|
|
1916
1916
|
};
|
|
1917
1917
|
function symbolFontTable(fontName) {
|
|
1918
1918
|
if (!fontName) return void 0;
|
|
1919
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
1919
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkH5Q6J2MBcjs.WINGDINGS;
|
|
1920
1920
|
return void 0;
|
|
1921
1921
|
}
|
|
1922
1922
|
function remapSymbolText(text, table) {
|
|
@@ -2975,7 +2975,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
2975
2975
|
if (block.type !== "heading" || !block.text) continue;
|
|
2976
2976
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
2977
2977
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _192 => _192.style, 'optionalAccess', _193 => _193.fontSize]), () => ( 0));
|
|
2978
|
-
const tocEntry = i > 0 &&
|
|
2978
|
+
const tocEntry = i > 0 && _chunkSZM6BSK4cjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkSZM6BSK4cjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
2979
2979
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
2980
2980
|
const proseStyle = _optionalChain([block, 'access', _194 => _194.style, 'optionalAccess', _195 => _195.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
2981
2981
|
const next = blocks[i + 1];
|
|
@@ -3058,7 +3058,7 @@ function splitSingleCellTables(blocks) {
|
|
|
3058
3058
|
const out = [];
|
|
3059
3059
|
for (const b of blocks) {
|
|
3060
3060
|
const t = b.type === "table" ? b.table : void 0;
|
|
3061
|
-
const title = t &&
|
|
3061
|
+
const title = t && _chunkSZM6BSK4cjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3062
3062
|
if (title) {
|
|
3063
3063
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3064
3064
|
continue;
|
|
@@ -3094,7 +3094,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
3094
3094
|
const lines = cell.text.split("\n");
|
|
3095
3095
|
const out = [lines[0]];
|
|
3096
3096
|
for (const line of lines.slice(1)) {
|
|
3097
|
-
if (
|
|
3097
|
+
if (_chunkSZM6BSK4cjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
3098
3098
|
else out.push(line);
|
|
3099
3099
|
}
|
|
3100
3100
|
cell.text = out.join("\n");
|
|
@@ -3114,10 +3114,10 @@ function cleanPdfText(text, opts) {
|
|
|
3114
3114
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
3115
3115
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
3116
3116
|
if (line.startsWith("|")) {
|
|
3117
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
3117
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkSZM6BSK4cjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
3118
3118
|
}
|
|
3119
3119
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _275 => _275.exec, 'call', _276 => _276(line), 'optionalAccess', _277 => _277[0]]), () => ( ""));
|
|
3120
|
-
return mark +
|
|
3120
|
+
return mark + _chunkSZM6BSK4cjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
3121
3121
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
3122
3122
|
}
|
|
3123
3123
|
function startsWithMarker(line) {
|
|
@@ -3149,7 +3149,7 @@ function mergeKoreanLines(text) {
|
|
|
3149
3149
|
continue;
|
|
3150
3150
|
}
|
|
3151
3151
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
3152
|
-
result[result.length - 1] = prev +
|
|
3152
|
+
result[result.length - 1] = prev + _chunkSZM6BSK4cjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
3153
3153
|
} else {
|
|
3154
3154
|
result.push(curr);
|
|
3155
3155
|
}
|
|
@@ -3165,7 +3165,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3165
3165
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3166
3166
|
for (const a of annots) {
|
|
3167
3167
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3168
|
-
const url =
|
|
3168
|
+
const url = _chunkQSOWCFOVcjs.sanitizeHref.call(void 0, a.url);
|
|
3169
3169
|
if (!url) continue;
|
|
3170
3170
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3171
3171
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -3217,7 +3217,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3217
3217
|
|
|
3218
3218
|
// src/pdf/formula-ocr.ts
|
|
3219
3219
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3220
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
3220
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-LDXFM42U.cjs")));
|
|
3221
3221
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3222
3222
|
await ensureFormulaModels((p) => {
|
|
3223
3223
|
if (p.phase === "download" && p.total) {
|
|
@@ -3408,13 +3408,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3408
3408
|
try {
|
|
3409
3409
|
return await Promise.race([
|
|
3410
3410
|
loadingTask.promise.catch((e) => {
|
|
3411
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
3411
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkQSOWCFOVcjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C PDF \uD30C\uC77C\uC785\uB2C8\uB2E4 (PDF \uC5F4\uAE30 \uC554\uD638\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4)");
|
|
3412
3412
|
throw e;
|
|
3413
3413
|
}),
|
|
3414
3414
|
new Promise((_, reject) => {
|
|
3415
3415
|
timer = setTimeout(() => {
|
|
3416
3416
|
loadingTask.destroy();
|
|
3417
|
-
reject(new (0,
|
|
3417
|
+
reject(new (0, _chunkQSOWCFOVcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
3418
3418
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
3419
3419
|
})
|
|
3420
3420
|
]);
|
|
@@ -3424,12 +3424,12 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3424
3424
|
}
|
|
3425
3425
|
async function parsePdfDocument(buffer, options) {
|
|
3426
3426
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _278 => _278.formulaOcr]) ? buffer : null;
|
|
3427
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _279 => _279.ocr]) === void 0 && await
|
|
3427
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _279 => _279.ocr]) === void 0 && await _chunkSZM6BSK4cjs.ocrModelsCached.call(void 0, );
|
|
3428
3428
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _280 => _280.ocr]) || autoOcr ? buffer : null;
|
|
3429
3429
|
const doc = await loadPdfWithTimeout(buffer);
|
|
3430
3430
|
try {
|
|
3431
3431
|
const pageCount = doc.numPages;
|
|
3432
|
-
if (pageCount === 0) throw new (0,
|
|
3432
|
+
if (pageCount === 0) throw new (0, _chunkQSOWCFOVcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
3433
3433
|
const metadata = { pageCount, pageMode: "layout" };
|
|
3434
3434
|
await extractPdfMetadata(doc, metadata);
|
|
3435
3435
|
const blocks = [];
|
|
@@ -3458,7 +3458,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3458
3458
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
3459
3459
|
const carry = {};
|
|
3460
3460
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
3461
|
-
const wrapLexicon = new (0,
|
|
3461
|
+
const wrapLexicon = new (0, _chunkSZM6BSK4cjs.WrapLexicon)();
|
|
3462
3462
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
3463
3463
|
const headerContext = [];
|
|
3464
3464
|
if (pageFilter && _optionalChain([options, 'optionalAccess', _283 => _283.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
@@ -3505,8 +3505,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3505
3505
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3506
3506
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3507
3507
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3508
|
-
const items =
|
|
3509
|
-
const filtered =
|
|
3508
|
+
const items = _chunkSZM6BSK4cjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
3509
|
+
const filtered = _chunkSZM6BSK4cjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
3510
3510
|
const joined = joinVerticalColumns(filtered.visible);
|
|
3511
3511
|
const visible = dropTabLeaderDots(joined);
|
|
3512
3512
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -3532,7 +3532,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3532
3532
|
} : rawOps;
|
|
3533
3533
|
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _290 => _290(loadedName), 'optionalAccess', _291 => _291.name]));
|
|
3534
3534
|
remapControlGlyphs(visible, differencesOf);
|
|
3535
|
-
await
|
|
3535
|
+
await _chunkSZM6BSK4cjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
3536
3536
|
const faces = /* @__PURE__ */ new Map();
|
|
3537
3537
|
for (const it of visible) {
|
|
3538
3538
|
if (!it.fontName) continue;
|
|
@@ -3545,12 +3545,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3545
3545
|
it.fontName = face;
|
|
3546
3546
|
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _293 => _293(face), 'optionalAccess', _294 => _294.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
3547
3547
|
}
|
|
3548
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
3549
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
3548
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkH5Q6J2MBcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
3549
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkH5Q6J2MBcjs.escapeLiteralTags.call(void 0, it.text);
|
|
3550
3550
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
3551
3551
|
const pageArea = pageW * pageH;
|
|
3552
3552
|
if (pageArea > 0) {
|
|
3553
|
-
const imageRegions =
|
|
3553
|
+
const imageRegions = _chunkSZM6BSK4cjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
3554
3554
|
let uncovered = 0;
|
|
3555
3555
|
for (const r of imageRegions) {
|
|
3556
3556
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -3576,11 +3576,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3576
3576
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
3577
3577
|
}
|
|
3578
3578
|
const marks = superscriptNoteMarks(visible);
|
|
3579
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
3579
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkSZM6BSK4cjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
3580
3580
|
const stamp = marginStamp(visible);
|
|
3581
3581
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
3582
|
-
const rightArrows = _optionalChain([options, 'optionalAccess', _295 => _295.tables]) !== false ? await
|
|
3583
|
-
const pageBlocks = orderTwoUpPage(
|
|
3582
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _295 => _295.tables]) !== false ? await _chunkSZM6BSK4cjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
3583
|
+
const pageBlocks = orderTwoUpPage(_chunkSZM6BSK4cjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _296 => _296.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
3584
3584
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
3585
3585
|
for (const b of pageBlocks) blocks.push(b);
|
|
3586
3586
|
try {
|
|
@@ -3606,11 +3606,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3606
3606
|
if (_optionalChain([options, 'optionalAccess', _298 => _298.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
3607
3607
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
3608
3608
|
}
|
|
3609
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
3609
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkQSOWCFOVcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
3610
3610
|
parsedPages++;
|
|
3611
3611
|
_optionalChain([options, 'optionalAccess', _299 => _299.onProgress, 'optionalCall', _300 => _300(parsedPages, totalTarget)]);
|
|
3612
3612
|
} catch (pageErr) {
|
|
3613
|
-
if (pageErr instanceof
|
|
3613
|
+
if (pageErr instanceof _chunkQSOWCFOVcjs.KordocError) throw pageErr;
|
|
3614
3614
|
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" });
|
|
3615
3615
|
} finally {
|
|
3616
3616
|
_optionalChain([loadedPage, 'optionalAccess', _301 => _301.cleanup, 'call', _302 => _302()]);
|
|
@@ -3640,11 +3640,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3640
3640
|
}
|
|
3641
3641
|
if (targets.size > 0) {
|
|
3642
3642
|
try {
|
|
3643
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3643
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-V42HOZKB.cjs")));
|
|
3644
3644
|
const mode = typeof _optionalChain([options, 'optionalAccess', _307 => _307.ocr]) === "function" ? options.ocr : "builtin";
|
|
3645
3645
|
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _308 => _308.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _309 => _309.find, 'call', _310 => _310((q) => q.page === p), 'optionalAccess', _311 => _311.needsOcr])));
|
|
3646
3646
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _312 => _312.onProgress]), _optionalChain([options, 'optionalAccess', _313 => _313.tables]) !== false, vectorPageOps, regionPages);
|
|
3647
|
-
for (const obs of ocrPageBlocks.values())
|
|
3647
|
+
for (const obs of ocrPageBlocks.values()) _chunkH5Q6J2MBcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
3648
3648
|
if (ocrPageBlocks.size > 0) {
|
|
3649
3649
|
const replacePages = /* @__PURE__ */ new Set();
|
|
3650
3650
|
for (const [p, obs] of ocrPageBlocks) {
|
|
@@ -3655,7 +3655,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3655
3655
|
continue;
|
|
3656
3656
|
}
|
|
3657
3657
|
const regions = ocrRegions.get(p);
|
|
3658
|
-
if (!regions ||
|
|
3658
|
+
if (!regions || _chunkSZM6BSK4cjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
3659
3659
|
ocrDone.add(p);
|
|
3660
3660
|
if (_optionalChain([pageImageBlocks, 'access', _318 => _318.get, 'call', _319 => _319(p), 'optionalAccess', _320 => _320.length]) === 1) pageImageBlocks.delete(p);
|
|
3661
3661
|
}
|
|
@@ -3708,17 +3708,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3708
3708
|
}
|
|
3709
3709
|
}
|
|
3710
3710
|
if (_optionalChain([options, 'optionalAccess', _321 => _321.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
3711
|
-
const removed =
|
|
3712
|
-
const running =
|
|
3711
|
+
const removed = _chunkSZM6BSK4cjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
3712
|
+
const running = _chunkSZM6BSK4cjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
3713
3713
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
3714
3714
|
blocks.splice(removed[ri], 1);
|
|
3715
3715
|
}
|
|
3716
|
-
const stripped =
|
|
3716
|
+
const stripped = _chunkSZM6BSK4cjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
3717
3717
|
if (stripped !== blocks) {
|
|
3718
3718
|
blocks.length = 0;
|
|
3719
3719
|
blocks.push(...stripped);
|
|
3720
3720
|
}
|
|
3721
|
-
const kept =
|
|
3721
|
+
const kept = _chunkSZM6BSK4cjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
3722
3722
|
if (kept !== blocks) {
|
|
3723
3723
|
blocks.length = 0;
|
|
3724
3724
|
blocks.push(...kept);
|
|
@@ -3727,12 +3727,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3727
3727
|
mergeContinuedCells(blocks, pageHeights);
|
|
3728
3728
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
3729
3729
|
if (_optionalChain([options, 'optionalAccess', _322 => _322.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
3730
|
-
const boxes =
|
|
3730
|
+
const boxes = _chunkSZM6BSK4cjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
3731
3731
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
3732
3732
|
}
|
|
3733
3733
|
splitContactTables(blocks);
|
|
3734
|
-
if (!_optionalChain([options, 'optionalAccess', _323 => _323.keepTrailingEmptyCols]))
|
|
3735
|
-
|
|
3734
|
+
if (!_optionalChain([options, 'optionalAccess', _323 => _323.keepTrailingEmptyCols])) _chunkSZM6BSK4cjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
3735
|
+
_chunkSZM6BSK4cjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
3736
3736
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
3737
3737
|
if (_optionalChain([options, 'optionalAccess', _324 => _324.formulaOcr]) && formulaBuffer) {
|
|
3738
3738
|
try {
|
|
@@ -3744,21 +3744,21 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3744
3744
|
});
|
|
3745
3745
|
}
|
|
3746
3746
|
}
|
|
3747
|
-
const medianFontSize =
|
|
3747
|
+
const medianFontSize = _chunkSZM6BSK4cjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
3748
3748
|
if (medianFontSize > 0) {
|
|
3749
|
-
|
|
3750
|
-
}
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3749
|
+
_chunkSZM6BSK4cjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
3750
|
+
}
|
|
3751
|
+
_chunkSZM6BSK4cjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
3752
|
+
_chunkSZM6BSK4cjs.detectTypographyHeadings.call(void 0, blocks);
|
|
3753
|
+
_chunkSZM6BSK4cjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
3754
|
+
_chunkSZM6BSK4cjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
3755
|
+
_chunkSZM6BSK4cjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
3756
|
+
_chunkSZM6BSK4cjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
3757
|
+
_chunkSZM6BSK4cjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
3758
|
+
_chunkSZM6BSK4cjs.detectMarkerHeadings.call(void 0, blocks);
|
|
3759
3759
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3760
|
-
|
|
3761
|
-
|
|
3760
|
+
_chunkSZM6BSK4cjs.detectTableCaptions.call(void 0, blocks);
|
|
3761
|
+
_chunkSZM6BSK4cjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3762
3762
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3763
3763
|
sanitizeBlockControlChars(blocks);
|
|
3764
3764
|
let outBlocks = splitSingleCellTables(blocks);
|
|
@@ -3780,19 +3780,19 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3780
3780
|
const shown = /* @__PURE__ */ new Map();
|
|
3781
3781
|
const markContent = (bs) => {
|
|
3782
3782
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
3783
|
-
if (
|
|
3784
|
-
const lines =
|
|
3785
|
-
if (lines)
|
|
3783
|
+
if (_chunkSZM6BSK4cjs.IMAGE_CELLS.has(c)) _chunkH5Q6J2MBcjs.CONTENT_CELLS.add(c);
|
|
3784
|
+
const lines = _chunkSZM6BSK4cjs.CELL_LINES.get(c);
|
|
3785
|
+
if (lines) _chunkH5Q6J2MBcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
3786
3786
|
markContent(c.blocks);
|
|
3787
3787
|
}
|
|
3788
3788
|
};
|
|
3789
3789
|
const visual = (bs) => bs.flatMap((b) => {
|
|
3790
3790
|
if (b.type !== "table") return [b];
|
|
3791
|
-
if (!hancom && b.table &&
|
|
3791
|
+
if (!hancom && b.table && _chunkSZM6BSK4cjs.CLIP_TABLES.has(b.table)) return [b];
|
|
3792
3792
|
let v = shown.get(b);
|
|
3793
3793
|
if (!v) {
|
|
3794
3794
|
markContent([b]);
|
|
3795
|
-
shown.set(b, v =
|
|
3795
|
+
shown.set(b, v = _chunkH5Q6J2MBcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _328 => _328.keepTrailingEmptyCols])));
|
|
3796
3796
|
}
|
|
3797
3797
|
return v;
|
|
3798
3798
|
});
|
|
@@ -3801,12 +3801,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3801
3801
|
blocks.length = 0;
|
|
3802
3802
|
for (const b of kept) blocks.push(b);
|
|
3803
3803
|
}
|
|
3804
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
3805
|
-
if (_optionalChain([options, 'optionalAccess', _330 => _330.tableFormat]) === "gfm")
|
|
3804
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkH5Q6J2MBcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _329 => _329.tableFormat]) }), { keepLoneNumbers: true }));
|
|
3805
|
+
if (_optionalChain([options, 'optionalAccess', _330 => _330.tableFormat]) === "gfm") _chunkH5Q6J2MBcjs.assignTableIds.call(void 0, blocks);
|
|
3806
3806
|
let markdown = finishMarkdown(outBlocks);
|
|
3807
3807
|
return {
|
|
3808
3808
|
markdown,
|
|
3809
|
-
pages:
|
|
3809
|
+
pages: _chunkQY627PK3cjs.blocksToPages.call(void 0, splitPageTables(_chunkSZM6BSK4cjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
3810
3810
|
blocks,
|
|
3811
3811
|
metadata,
|
|
3812
3812
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3885,5 +3885,5 @@ function marginStamp(items) {
|
|
|
3885
3885
|
|
|
3886
3886
|
|
|
3887
3887
|
|
|
3888
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
3889
|
-
//# sourceMappingURL=parser-
|
|
3888
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkSZM6BSK4cjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkSZM6BSK4cjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkSZM6BSK4cjs.removeHeaderFooterBlocks;
|
|
3889
|
+
//# sourceMappingURL=parser-XQL37S4F.cjs.map
|