kordoc 4.22.0 → 4.22.1
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 +15 -9
- package/dist/{-KRYEEYOX.js → -FYKHW5G6.js} +11 -11
- package/dist/{chunk-NKWY4UJ4.js → chunk-3H5QG6I2.js} +2 -2
- package/dist/{chunk-D5DRW3S5.js → chunk-3SPOIAST.js} +2 -2
- package/dist/{chunk-2ZRU6WJQ.js → chunk-5FD3LAKC.js} +2 -2
- package/dist/{chunk-HIM23MJP.js → chunk-5SVJU22Z.js} +2 -2
- package/dist/{chunk-4W7GCW3Z.js → chunk-5VBAHUGC.js} +3 -3
- package/dist/{chunk-BKEDPKXS.js → chunk-7FASIFQP.js} +2 -2
- package/dist/{chunk-72DOHOTQ.js → chunk-7RND4SNB.js} +3 -3
- package/dist/{chunk-PWCVNTMX.js → chunk-AIAIBNIB.js} +2 -2
- package/dist/{chunk-B4IKM3CG.js → chunk-ATODI25J.js} +2 -2
- package/dist/{chunk-GBQXV6MI.cjs → chunk-B35C5HJK.cjs} +3 -3
- package/dist/{chunk-GBQXV6MI.cjs.map → chunk-B35C5HJK.cjs.map} +1 -1
- package/dist/{chunk-NNGZXPPA.js → chunk-DOBJ7BW5.js} +2 -2
- package/dist/{chunk-LJSZ3HCI.cjs → chunk-EXVTF6XE.cjs} +27 -26
- package/dist/chunk-EXVTF6XE.cjs.map +1 -0
- package/dist/{chunk-HI45PG3J.js → chunk-IB5TO2CO.js} +2 -2
- package/dist/{chunk-GWJV3FYA.js → chunk-IK4W2M4P.js} +2 -2
- package/dist/{chunk-SP3DBTDN.js → chunk-JHHXTNZQ.js} +3 -3
- package/dist/{chunk-746T2J3U.js → chunk-LHO7E3RW.js} +2 -2
- package/dist/{chunk-GQJ4MFLT.cjs → chunk-M2CBEXHN.cjs} +2 -2
- package/dist/{chunk-GQJ4MFLT.cjs.map → chunk-M2CBEXHN.cjs.map} +1 -1
- package/dist/{chunk-DCXK7PYL.js → chunk-M4JC7TXG.js} +6 -5
- package/dist/{chunk-POPIFZOT.js.map → chunk-M4JC7TXG.js.map} +1 -1
- package/dist/{chunk-BXBOFBHR.js → chunk-MDS3GH43.js} +2 -2
- package/dist/{chunk-BXBOFBHR.js.map → chunk-MDS3GH43.js.map} +1 -1
- package/dist/{chunk-DZFGZBMV.js → chunk-ME4NQSLE.js} +2 -2
- package/dist/{chunk-7YVDZCHF.js → chunk-MGJYVNDX.js} +4 -4
- package/dist/{chunk-EFO7H2D4.cjs → chunk-OSFB5SQS.cjs} +3 -3
- package/dist/{chunk-EFO7H2D4.cjs.map → chunk-OSFB5SQS.cjs.map} +1 -1
- package/dist/{chunk-POPIFZOT.js → chunk-QH4B3PL7.js} +6 -5
- package/dist/{chunk-DCXK7PYL.js.map → chunk-QH4B3PL7.js.map} +1 -1
- package/dist/{chunk-VHDD33Q4.js → chunk-R37TFXMP.js} +6 -6
- package/dist/{chunk-DKSQ22RU.cjs → chunk-RO7AORMO.cjs} +6 -6
- package/dist/{chunk-DKSQ22RU.cjs.map → chunk-RO7AORMO.cjs.map} +1 -1
- package/dist/{chunk-PMVM7BS6.js → chunk-SMPK5TUQ.js} +2 -2
- package/dist/{chunk-PMVM7BS6.js.map → chunk-SMPK5TUQ.js.map} +1 -1
- package/dist/{chunk-PPYQUI3X.js → chunk-TSZQ4LMV.js} +2 -2
- package/dist/{chunk-7BJDDE7V.js → chunk-YE4IN3D7.js} +11 -11
- package/dist/{chunk-EXKBLZUH.cjs → chunk-ZECSXHYP.cjs} +23 -23
- package/dist/{chunk-EXKBLZUH.cjs.map → chunk-ZECSXHYP.cjs.map} +1 -1
- package/dist/chunks-4XIAEJEX.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-XSXXXRA6.js → formula-JBTYYSKB.js} +4 -4
- package/dist/{formula-QPKCUYLS.cjs → formula-PYDSQGLS.cjs} +9 -9
- package/dist/{formula-QPKCUYLS.cjs.map → formula-PYDSQGLS.cjs.map} +1 -1
- package/dist/{formula-2G43QHEV.js → formula-RUS4SF3O.js} +3 -3
- package/dist/{image-ocr-ZQMWJHKE.cjs → image-ocr-PLNNCEOR.cjs} +17 -17
- package/dist/{image-ocr-ZQMWJHKE.cjs.map → image-ocr-PLNNCEOR.cjs.map} +1 -1
- package/dist/{image-ocr-L46V4HIX.js → image-ocr-QJT4EIQU.js} +9 -9
- package/dist/{image-ocr-XY3TUBYK.js → image-ocr-VA6WV6E4.js} +6 -6
- package/dist/index.cjs +302 -302
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-QFDCCCI2.js → model-bundle-U2YY7ATC.js} +5 -5
- package/dist/{models-T2QBJSY5.js → models-BOJ2SFCR.js} +5 -5
- package/dist/{parse-worker-v2-PT6LULNS.js → parse-worker-v2-ZHMFK3U3.js} +12 -12
- package/dist/{parser-BGSWEVUB.cjs → parser-6337Z4U2.cjs} +146 -146
- package/dist/{parser-BGSWEVUB.cjs.map → parser-6337Z4U2.cjs.map} +1 -1
- package/dist/{parser-LM6FNKVB.js → parser-A2EWLK2J.js} +9 -9
- package/dist/{parser-2EIOJGOS.js → parser-HM6N7J4R.js} +12 -12
- package/dist/{pdf-ocr-GSELGUFG.js → pdf-ocr-JDER5BHI.js} +8 -6
- package/dist/{pdf-ocr-C5OFY2RY.js → pdf-ocr-MEVC6HXG.js} +11 -9
- package/dist/pdf-ocr-PGXNUFU7.cjs +31 -0
- package/dist/pdf-ocr-PGXNUFU7.cjs.map +1 -0
- package/dist/{profile-io-Y2TLZ62F.js → profile-io-OJ23SPYO.js} +3 -3
- package/dist/{rasterize-FB6MFPS3.js → rasterize-76CWCLSU.js} +3 -3
- package/dist/{redact-doc-AV2EOKPP.js → redact-doc-EZQIHRVT.js} +11 -11
- package/dist/{render-M5BW4TLH.js → render-JZFJPFWK.js} +7 -7
- package/dist/seal-P2NOP4LC.js +10 -0
- package/dist/{setup-DVKUFC73.js → setup-RIVS74JN.js} +3 -3
- package/dist/visual-R5GGZBTU.js +21 -0
- package/dist/{watch-S35AWINM.js → watch-WMH222E5.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-LJSZ3HCI.cjs.map +0 -1
- package/dist/chunks-5AVQEPIH.js +0 -10
- package/dist/pdf-ocr-A2UWUATF.cjs +0 -29
- package/dist/pdf-ocr-A2UWUATF.cjs.map +0 -1
- package/dist/seal-JXYWI5CN.js +0 -10
- package/dist/visual-DBVBTOAV.js +0 -21
- /package/dist/{-KRYEEYOX.js.map → -FYKHW5G6.js.map} +0 -0
- /package/dist/{chunk-NKWY4UJ4.js.map → chunk-3H5QG6I2.js.map} +0 -0
- /package/dist/{chunk-D5DRW3S5.js.map → chunk-3SPOIAST.js.map} +0 -0
- /package/dist/{chunk-2ZRU6WJQ.js.map → chunk-5FD3LAKC.js.map} +0 -0
- /package/dist/{chunk-HIM23MJP.js.map → chunk-5SVJU22Z.js.map} +0 -0
- /package/dist/{chunk-4W7GCW3Z.js.map → chunk-5VBAHUGC.js.map} +0 -0
- /package/dist/{chunk-BKEDPKXS.js.map → chunk-7FASIFQP.js.map} +0 -0
- /package/dist/{chunk-72DOHOTQ.js.map → chunk-7RND4SNB.js.map} +0 -0
- /package/dist/{chunk-PWCVNTMX.js.map → chunk-AIAIBNIB.js.map} +0 -0
- /package/dist/{chunk-B4IKM3CG.js.map → chunk-ATODI25J.js.map} +0 -0
- /package/dist/{chunk-NNGZXPPA.js.map → chunk-DOBJ7BW5.js.map} +0 -0
- /package/dist/{chunk-HI45PG3J.js.map → chunk-IB5TO2CO.js.map} +0 -0
- /package/dist/{chunk-GWJV3FYA.js.map → chunk-IK4W2M4P.js.map} +0 -0
- /package/dist/{chunk-SP3DBTDN.js.map → chunk-JHHXTNZQ.js.map} +0 -0
- /package/dist/{chunk-746T2J3U.js.map → chunk-LHO7E3RW.js.map} +0 -0
- /package/dist/{chunk-DZFGZBMV.js.map → chunk-ME4NQSLE.js.map} +0 -0
- /package/dist/{chunk-7YVDZCHF.js.map → chunk-MGJYVNDX.js.map} +0 -0
- /package/dist/{chunk-VHDD33Q4.js.map → chunk-R37TFXMP.js.map} +0 -0
- /package/dist/{chunk-PPYQUI3X.js.map → chunk-TSZQ4LMV.js.map} +0 -0
- /package/dist/{chunk-7BJDDE7V.js.map → chunk-YE4IN3D7.js.map} +0 -0
- /package/dist/{chunks-5AVQEPIH.js.map → chunks-4XIAEJEX.js.map} +0 -0
- /package/dist/{formula-XSXXXRA6.js.map → formula-JBTYYSKB.js.map} +0 -0
- /package/dist/{formula-2G43QHEV.js.map → formula-RUS4SF3O.js.map} +0 -0
- /package/dist/{image-ocr-L46V4HIX.js.map → image-ocr-QJT4EIQU.js.map} +0 -0
- /package/dist/{image-ocr-XY3TUBYK.js.map → image-ocr-VA6WV6E4.js.map} +0 -0
- /package/dist/{model-bundle-QFDCCCI2.js.map → model-bundle-U2YY7ATC.js.map} +0 -0
- /package/dist/{models-T2QBJSY5.js.map → models-BOJ2SFCR.js.map} +0 -0
- /package/dist/{parse-worker-v2-PT6LULNS.js.map → parse-worker-v2-ZHMFK3U3.js.map} +0 -0
- /package/dist/{parser-LM6FNKVB.js.map → parser-A2EWLK2J.js.map} +0 -0
- /package/dist/{parser-2EIOJGOS.js.map → parser-HM6N7J4R.js.map} +0 -0
- /package/dist/{pdf-ocr-C5OFY2RY.js.map → pdf-ocr-JDER5BHI.js.map} +0 -0
- /package/dist/{pdf-ocr-GSELGUFG.js.map → pdf-ocr-MEVC6HXG.js.map} +0 -0
- /package/dist/{profile-io-Y2TLZ62F.js.map → profile-io-OJ23SPYO.js.map} +0 -0
- /package/dist/{rasterize-FB6MFPS3.js.map → rasterize-76CWCLSU.js.map} +0 -0
- /package/dist/{redact-doc-AV2EOKPP.js.map → redact-doc-EZQIHRVT.js.map} +0 -0
- /package/dist/{render-M5BW4TLH.js.map → render-JZFJPFWK.js.map} +0 -0
- /package/dist/{seal-JXYWI5CN.js.map → seal-P2NOP4LC.js.map} +0 -0
- /package/dist/{setup-DVKUFC73.js.map → setup-RIVS74JN.js.map} +0 -0
- /package/dist/{visual-DBVBTOAV.js.map → visual-R5GGZBTU.js.map} +0 -0
- /package/dist/{watch-S35AWINM.js.map → watch-WMH222E5.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 _chunkOSFB5SQScjs = require('./chunk-OSFB5SQS.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -61,7 +61,7 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
var
|
|
64
|
+
var _chunkZECSXHYPcjs = require('./chunk-ZECSXHYP.cjs');
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
@@ -75,12 +75,12 @@ var _chunkEXKBLZUHcjs = require('./chunk-EXKBLZUH.cjs');
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
var
|
|
79
|
-
require('./chunk-
|
|
78
|
+
var _chunkRO7AORMOcjs = require('./chunk-RO7AORMO.cjs');
|
|
79
|
+
require('./chunk-B35C5HJK.cjs');
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
var
|
|
83
|
+
var _chunkM2CBEXHNcjs = require('./chunk-M2CBEXHN.cjs');
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -217,7 +217,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
217
217
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
218
218
|
state.seen.set(hash, filename);
|
|
219
219
|
if (withBytes) {
|
|
220
|
-
const png =
|
|
220
|
+
const png = _chunkOSFB5SQScjs.encodePng.call(void 0, w, h, rgba);
|
|
221
221
|
state.totalBytes += png.length;
|
|
222
222
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
223
223
|
}
|
|
@@ -613,7 +613,7 @@ function ocrVectorOps(opList, paths) {
|
|
|
613
613
|
|
|
614
614
|
// src/pdf/split-row-pattern.ts
|
|
615
615
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
616
|
-
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !
|
|
616
|
+
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !_chunkZECSXHYPcjs.IMAGE_CELLS.has(cell);
|
|
617
617
|
function matchesCompleteSiblingRow(table, owner, first) {
|
|
618
618
|
const pairs = [];
|
|
619
619
|
for (let c = 0; c < table.cols; ) {
|
|
@@ -766,7 +766,7 @@ function rowStarts(t) {
|
|
|
766
766
|
}
|
|
767
767
|
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));
|
|
768
768
|
function cellPage(cell) {
|
|
769
|
-
const p =
|
|
769
|
+
const p = _chunkRO7AORMOcjs.CELL_PAGES.get(cell);
|
|
770
770
|
if (p !== void 0 || !_optionalChain([cell, 'access', _19 => _19.blocks, 'optionalAccess', _20 => _20.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
771
771
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
772
772
|
}
|
|
@@ -795,7 +795,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
795
795
|
rows.forEach((starts, r) => {
|
|
796
796
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
797
797
|
for (const { cell } of starts) {
|
|
798
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
798
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkRO7AORMOcjs.CELL_PAGES.set(cell, page2);
|
|
799
799
|
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _23 => _23.find, 'call', _24 => _24((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
|
|
800
800
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
801
801
|
}
|
|
@@ -844,8 +844,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
844
844
|
if (!splits.length) continue;
|
|
845
845
|
const clone = (cell, patch) => {
|
|
846
846
|
const out = { ...cell, ...patch };
|
|
847
|
-
const p =
|
|
848
|
-
if (p !== void 0)
|
|
847
|
+
const p = _chunkRO7AORMOcjs.CELL_PAGES.get(cell);
|
|
848
|
+
if (p !== void 0) _chunkRO7AORMOcjs.CELL_PAGES.set(out, p);
|
|
849
849
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
850
850
|
return out;
|
|
851
851
|
};
|
|
@@ -855,7 +855,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
855
855
|
for (const { cell, c, split } of splits) {
|
|
856
856
|
cells[r][c] = clone(cell, split.head);
|
|
857
857
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
858
|
-
|
|
858
|
+
_chunkRO7AORMOcjs.CELL_PAGES.set(tail, split.page);
|
|
859
859
|
setSplits(tail, split.rest);
|
|
860
860
|
row[c] = tail;
|
|
861
861
|
}
|
|
@@ -974,19 +974,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
974
974
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
975
975
|
}
|
|
976
976
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
977
|
-
const lines =
|
|
978
|
-
if (lines)
|
|
979
|
-
if (
|
|
980
|
-
const edges =
|
|
977
|
+
const lines = _chunkZECSXHYPcjs.CELL_LINES.get(a.cell);
|
|
978
|
+
if (lines) _chunkZECSXHYPcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
979
|
+
if (_chunkZECSXHYPcjs.IMAGE_CELLS.has(a.cell)) _chunkZECSXHYPcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
980
|
+
const edges = _chunkRO7AORMOcjs.CELL_EDGES.get(a.cell);
|
|
981
981
|
if (edges) {
|
|
982
|
-
|
|
982
|
+
_chunkRO7AORMOcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
983
983
|
edged = true;
|
|
984
984
|
}
|
|
985
985
|
return true;
|
|
986
986
|
};
|
|
987
|
-
for (const a of pa) if (!
|
|
987
|
+
for (const a of pa) if (!_chunkZECSXHYPcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
988
988
|
for (const a of ca) {
|
|
989
|
-
if (a.r < skip ||
|
|
989
|
+
if (a.r < skip || _chunkZECSXHYPcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
990
990
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
991
991
|
}
|
|
992
992
|
const first = prev.rows;
|
|
@@ -1010,9 +1010,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1010
1010
|
const grown = { ...above, rs: newRs };
|
|
1011
1011
|
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;
|
|
1012
1012
|
}
|
|
1013
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1013
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkZECSXHYPcjs.FILLER_CELLS.add(grid[r][c]);
|
|
1014
1014
|
if (edged) {
|
|
1015
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1015
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkRO7AORMOcjs.CELL_EDGES.set(grid[r][c], _chunkZECSXHYPcjs.NO_EDGES);
|
|
1016
1016
|
}
|
|
1017
1017
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1018
1018
|
let r = prev.rows;
|
|
@@ -1021,7 +1021,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1021
1021
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1022
1022
|
}
|
|
1023
1023
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1024
|
-
const pr =
|
|
1024
|
+
const pr = _chunkZECSXHYPcjs.ROW_RULES.get(prev), cr = _chunkZECSXHYPcjs.ROW_RULES.get(curr);
|
|
1025
1025
|
const shifted = dx !== 0;
|
|
1026
1026
|
const cut = {
|
|
1027
1027
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1032,7 +1032,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1032
1032
|
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 });
|
|
1033
1033
|
if (pr && cr) {
|
|
1034
1034
|
const cutRuled = pr.bottom || cr.top;
|
|
1035
|
-
|
|
1035
|
+
_chunkZECSXHYPcjs.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) });
|
|
1036
1036
|
}
|
|
1037
1037
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1038
1038
|
}
|
|
@@ -1093,18 +1093,18 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1093
1093
|
c = u.c + u.cs;
|
|
1094
1094
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1095
1095
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1096
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1097
|
-
const openSeam = hasContent(a) && hasContent(b) &&
|
|
1096
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkZECSXHYPcjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
1097
|
+
const openSeam = hasContent(a) && hasContent(b) && _chunkZECSXHYPcjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
|
|
1098
1098
|
if (!r || r === first) return false;
|
|
1099
1099
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1100
1100
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1101
|
-
const ue =
|
|
1101
|
+
const ue = _chunkRO7AORMOcjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkRO7AORMOcjs.CELL_EDGES.get(table.cells[down.r][down.c]);
|
|
1102
1102
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1103
1103
|
});
|
|
1104
1104
|
if (!openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1105
1105
|
if (!straddles && !midWord) continue;
|
|
1106
1106
|
if (u.r >= last && d.rs < 2) continue;
|
|
1107
|
-
const U =
|
|
1107
|
+
const U = _chunkZECSXHYPcjs.CELL_LINES.get(a);
|
|
1108
1108
|
if (!_optionalChain([U, 'optionalAccess', _34 => _34.length]) || !hasContent(b)) continue;
|
|
1109
1109
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1110
1110
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -1122,7 +1122,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1122
1122
|
return merged;
|
|
1123
1123
|
}
|
|
1124
1124
|
function longLastLine(c) {
|
|
1125
|
-
const L =
|
|
1125
|
+
const L = _chunkZECSXHYPcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _35 => _35[L.length - 1]]);
|
|
1126
1126
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1127
1127
|
}
|
|
1128
1128
|
function filledToBottom(U, bottom) {
|
|
@@ -1155,7 +1155,7 @@ function nextItemHead(prev, next) {
|
|
|
1155
1155
|
return false;
|
|
1156
1156
|
}
|
|
1157
1157
|
function continuesAcross(u, d, x1, x2) {
|
|
1158
|
-
const U =
|
|
1158
|
+
const U = _chunkZECSXHYPcjs.CELL_LINES.get(u), D = _chunkZECSXHYPcjs.CELL_LINES.get(d);
|
|
1159
1159
|
if (!_optionalChain([U, 'optionalAccess', _36 => _36.length]) || !_optionalChain([D, 'optionalAccess', _37 => _37.length])) return false;
|
|
1160
1160
|
const last = U[U.length - 1];
|
|
1161
1161
|
const fs = last.h || 10;
|
|
@@ -1173,7 +1173,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1173
1173
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1174
1174
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1175
1175
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1176
|
-
const newItem =
|
|
1176
|
+
const newItem = _chunkZECSXHYPcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1177
1177
|
const all = D.length ? U.concat(D) : U;
|
|
1178
1178
|
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));
|
|
1179
1179
|
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;
|
|
@@ -1190,10 +1190,10 @@ function outlineContinues(u, d) {
|
|
|
1190
1190
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1191
1191
|
}
|
|
1192
1192
|
function lineEnded(c, x1, x2, next) {
|
|
1193
|
-
const L =
|
|
1193
|
+
const L = _chunkZECSXHYPcjs.CELL_LINES.get(c);
|
|
1194
1194
|
if (!L || L.length !== 1) return false;
|
|
1195
1195
|
const l = L[0], h = l.h || 10;
|
|
1196
|
-
const d0 = next ? _optionalChain([
|
|
1196
|
+
const d0 = next ? _optionalChain([_chunkZECSXHYPcjs.CELL_LINES, 'access', _38 => _38.get, 'call', _39 => _39(next), 'optionalAccess', _40 => _40[0]]) : void 0;
|
|
1197
1197
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1198
1198
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _41 => _41.text]), () => ( "")))) * h;
|
|
1199
1199
|
}
|
|
@@ -1204,15 +1204,15 @@ function firstWordUnits(text) {
|
|
|
1204
1204
|
return units;
|
|
1205
1205
|
}
|
|
1206
1206
|
function appendCell(a, b) {
|
|
1207
|
-
if (
|
|
1207
|
+
if (_chunkZECSXHYPcjs.IMAGE_CELLS.has(b)) _chunkZECSXHYPcjs.IMAGE_CELLS.add(a);
|
|
1208
1208
|
if (_optionalChain([a, 'access', _42 => _42.blocks, 'optionalAccess', _43 => _43.length]) || _optionalChain([b, 'access', _44 => _44.blocks, 'optionalAccess', _45 => _45.length])) {
|
|
1209
1209
|
const asBlocks = (c) => _optionalChain([c, 'access', _46 => _46.blocks, 'optionalAccess', _47 => _47.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
|
|
1210
1210
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1211
1211
|
}
|
|
1212
1212
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1213
|
-
|
|
1213
|
+
_chunkZECSXHYPcjs.joinCellEdges.call(void 0, a, b);
|
|
1214
1214
|
}
|
|
1215
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _48 => _48.blocks, 'optionalAccess', _49 => _49.length]) ||
|
|
1215
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _48 => _48.blocks, 'optionalAccess', _49 => _49.length]) || _chunkZECSXHYPcjs.IMAGE_CELLS.has(cell);
|
|
1216
1216
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1217
1217
|
var batchim = (ch) => {
|
|
1218
1218
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1220,7 +1220,7 @@ var batchim = (ch) => {
|
|
|
1220
1220
|
};
|
|
1221
1221
|
function clauseContinues(u, d) {
|
|
1222
1222
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1223
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1223
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkZECSXHYPcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1224
1224
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1225
1225
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1226
1226
|
}
|
|
@@ -1228,8 +1228,8 @@ function quantityContinues(u, d) {
|
|
|
1228
1228
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1229
1229
|
}
|
|
1230
1230
|
function wordOverflows(u, d, x1, x2) {
|
|
1231
|
-
const U =
|
|
1232
|
-
if (!_optionalChain([U, 'optionalAccess', _50 => _50.length]) ||
|
|
1231
|
+
const U = _chunkZECSXHYPcjs.CELL_LINES.get(u);
|
|
1232
|
+
if (!_optionalChain([U, 'optionalAccess', _50 => _50.length]) || _chunkZECSXHYPcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1233
1233
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1234
1234
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1235
1235
|
}
|
|
@@ -1297,7 +1297,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1297
1297
|
if (!carriedSplit) {
|
|
1298
1298
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1299
1299
|
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;
|
|
1300
|
-
const oneLine = (c) => _optionalChain([
|
|
1300
|
+
const oneLine = (c) => _optionalChain([_chunkZECSXHYPcjs.CELL_LINES, 'access', _52 => _52.get, 'call', _53 => _53(c), 'optionalAccess', _54 => _54.length]) === 1;
|
|
1301
1301
|
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;
|
|
1302
1302
|
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));
|
|
1303
1303
|
if (!(cut.open && !newCell)) {
|
|
@@ -1382,19 +1382,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1382
1382
|
placeJoined(blocks, i, j, joined);
|
|
1383
1383
|
continue;
|
|
1384
1384
|
}
|
|
1385
|
-
if (
|
|
1385
|
+
if (_chunkZECSXHYPcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1386
1386
|
blocks.splice(j, 1);
|
|
1387
1387
|
i++;
|
|
1388
1388
|
continue;
|
|
1389
1389
|
}
|
|
1390
1390
|
if (joined === null) continue;
|
|
1391
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1391
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkZECSXHYPcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1392
1392
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1393
1393
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1394
1394
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1395
1395
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1396
|
-
const px =
|
|
1397
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1396
|
+
const px = _chunkZECSXHYPcjs.TABLE_COLXS.get(prev.table), cx = _chunkZECSXHYPcjs.TABLE_COLXS.get(curr.table);
|
|
1397
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkZECSXHYPcjs.CLIP_TABLES.has(prev.table) && !_chunkZECSXHYPcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1398
1398
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1399
1399
|
let currCells = curr.table.cells;
|
|
1400
1400
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1405,16 +1405,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1405
1405
|
blocks.splice(j, 1);
|
|
1406
1406
|
continue;
|
|
1407
1407
|
}
|
|
1408
|
-
if (px && cx && !
|
|
1408
|
+
if (px && cx && !_chunkZECSXHYPcjs.CLIP_TABLES.has(prev.table) && !_chunkZECSXHYPcjs.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 && _chunkZECSXHYPcjs.CELL_LINES.has(c))) {
|
|
1409
1409
|
const dx = px[0] - cx[0];
|
|
1410
1410
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1411
1411
|
if (_optionalChain([part, 'optionalAccess', _71 => _71.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1412
1412
|
const last = prev.table.rows - 1;
|
|
1413
1413
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1414
|
-
const U =
|
|
1415
|
-
|
|
1414
|
+
const U = _chunkZECSXHYPcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkZECSXHYPcjs.CELL_LINES.get(currCells[0][c]);
|
|
1415
|
+
_chunkZECSXHYPcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1416
1416
|
}
|
|
1417
|
-
|
|
1417
|
+
_chunkZECSXHYPcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1418
1418
|
placeJoined(blocks, i, j, part.table);
|
|
1419
1419
|
continue;
|
|
1420
1420
|
}
|
|
@@ -1427,20 +1427,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1427
1427
|
caption: prev.table.caption,
|
|
1428
1428
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1429
1429
|
};
|
|
1430
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1431
|
-
if (
|
|
1430
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkZECSXHYPcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1431
|
+
if (_chunkZECSXHYPcjs.CLIP_TABLES.has(prev.table) || _chunkZECSXHYPcjs.CLIP_TABLES.has(curr.table)) _chunkZECSXHYPcjs.CLIP_TABLES.add(merged);
|
|
1432
1432
|
placeJoined(blocks, i, j, merged);
|
|
1433
1433
|
}
|
|
1434
1434
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1435
1435
|
const t = blocks[i].table;
|
|
1436
|
-
if (blocks[i].type === "table" && t &&
|
|
1436
|
+
if (blocks[i].type === "table" && t && _chunkZECSXHYPcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1437
1437
|
}
|
|
1438
1438
|
}
|
|
1439
1439
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1440
1440
|
if (!pageHeights) return;
|
|
1441
1441
|
for (let i = 0; i < blocks.length; i++) {
|
|
1442
1442
|
const L = blocks[i];
|
|
1443
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1443
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkZECSXHYPcjs.CLIP_TABLES.has(L.table) || _chunkZECSXHYPcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1444
1444
|
const ph = pageHeights.get(L.pageNumber);
|
|
1445
1445
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1446
1446
|
let s0 = i, s1 = i;
|
|
@@ -1469,8 +1469,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1469
1469
|
}
|
|
1470
1470
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1471
1471
|
const pt = prev.table, ct = curr.table;
|
|
1472
|
-
if (!
|
|
1473
|
-
const px =
|
|
1472
|
+
if (!_chunkZECSXHYPcjs.CLIP_TABLES.has(pt) || !_chunkZECSXHYPcjs.CLIP_TABLES.has(ct)) return null;
|
|
1473
|
+
const px = _chunkZECSXHYPcjs.TABLE_COLXS.get(pt), cx = _chunkZECSXHYPcjs.TABLE_COLXS.get(ct);
|
|
1474
1474
|
if (!px || !cx) return null;
|
|
1475
1475
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1476
1476
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -1486,15 +1486,15 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1486
1486
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1487
1487
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1488
1488
|
};
|
|
1489
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1489
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkZECSXHYPcjs.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);
|
|
1490
1490
|
}
|
|
1491
1491
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _76 => _76.bbox, 'optionalAccess', _77 => _77.y]), lex);
|
|
1492
1492
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1493
|
-
|
|
1494
|
-
const ys =
|
|
1495
|
-
if (ys)
|
|
1496
|
-
|
|
1497
|
-
|
|
1493
|
+
_chunkZECSXHYPcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1494
|
+
const ys = _chunkZECSXHYPcjs.TABLE_ROWYS.get(pt);
|
|
1495
|
+
if (ys) _chunkZECSXHYPcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1496
|
+
_chunkZECSXHYPcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkZECSXHYPcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1497
|
+
_chunkZECSXHYPcjs.CLIP_TABLES.add(res.table);
|
|
1498
1498
|
return res.table;
|
|
1499
1499
|
}
|
|
1500
1500
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
@@ -1518,12 +1518,12 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
1518
1518
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1519
1519
|
}
|
|
1520
1520
|
function pushedLead(prev, curr) {
|
|
1521
|
-
if (!
|
|
1521
|
+
if (!_chunkZECSXHYPcjs.CLIP_TABLES.has(prev.table) || !_chunkZECSXHYPcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1522
1522
|
const lead = leadRows(curr.table);
|
|
1523
1523
|
return lead.image && lead.height > prev.bbox.y;
|
|
1524
1524
|
}
|
|
1525
1525
|
function leadRows(t) {
|
|
1526
|
-
const ys =
|
|
1526
|
+
const ys = _chunkZECSXHYPcjs.TABLE_ROWYS.get(t);
|
|
1527
1527
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1528
1528
|
const anchors = anchorsOf(t);
|
|
1529
1529
|
let end = 1, image = false;
|
|
@@ -1531,17 +1531,17 @@ function leadRows(t) {
|
|
|
1531
1531
|
for (const a of anchors) {
|
|
1532
1532
|
if (a.r !== r) continue;
|
|
1533
1533
|
end = Math.max(end, r + a.rs);
|
|
1534
|
-
if (
|
|
1534
|
+
if (_chunkZECSXHYPcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1535
1535
|
}
|
|
1536
1536
|
}
|
|
1537
1537
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1538
1538
|
}
|
|
1539
1539
|
function tailOf(b) {
|
|
1540
|
-
const t = b.table &&
|
|
1540
|
+
const t = b.table && _chunkZECSXHYPcjs.TABLE_TAIL.get(b.table);
|
|
1541
1541
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1542
1542
|
}
|
|
1543
1543
|
function firstRowSig(t) {
|
|
1544
|
-
const x =
|
|
1544
|
+
const x = _chunkZECSXHYPcjs.TABLE_COLXS.get(t);
|
|
1545
1545
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1546
1546
|
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, "") }));
|
|
1547
1547
|
}
|
|
@@ -1594,7 +1594,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1594
1594
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1595
1595
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1596
1596
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1597
|
-
const px =
|
|
1597
|
+
const px = _chunkZECSXHYPcjs.TABLE_COLXS.get(pb.table), cx = _chunkZECSXHYPcjs.TABLE_COLXS.get(cur.table);
|
|
1598
1598
|
if (!px || !cx) break;
|
|
1599
1599
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1600
1600
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1665,7 +1665,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1665
1665
|
var COL_MATCH_TOL = 0.5;
|
|
1666
1666
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1667
1667
|
function lastRowCell(t, x1, x2) {
|
|
1668
|
-
const xs =
|
|
1668
|
+
const xs = _chunkZECSXHYPcjs.TABLE_COLXS.get(t);
|
|
1669
1669
|
const covered = /* @__PURE__ */ new Set();
|
|
1670
1670
|
for (let r = 0; r < t.rows; r++) {
|
|
1671
1671
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -1683,7 +1683,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1683
1683
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1684
1684
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1685
1685
|
const part = blocks[j];
|
|
1686
|
-
const from = part.table ?
|
|
1686
|
+
const from = part.table ? _chunkZECSXHYPcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1687
1687
|
if (!from || !part.table) continue;
|
|
1688
1688
|
let i = j - 1;
|
|
1689
1689
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
@@ -1696,12 +1696,12 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1696
1696
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1697
1697
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1698
1698
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1699
|
-
if (
|
|
1700
|
-
|
|
1701
|
-
const lines =
|
|
1702
|
-
if (_optionalChain([lines, 'optionalAccess', _101 => _101.length]))
|
|
1703
|
-
if (part.pageNumber && part.bbox)
|
|
1704
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _102 => _102.blocks, 'optionalAccess', _103 => _103.length]) ||
|
|
1699
|
+
if (_chunkZECSXHYPcjs.IMAGE_CELLS.has(add)) _chunkZECSXHYPcjs.IMAGE_CELLS.add(cell);
|
|
1700
|
+
_chunkZECSXHYPcjs.joinCellEdges.call(void 0, cell, add);
|
|
1701
|
+
const lines = _chunkZECSXHYPcjs.CELL_LINES.get(add);
|
|
1702
|
+
if (_optionalChain([lines, 'optionalAccess', _101 => _101.length])) _chunkZECSXHYPcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkZECSXHYPcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1703
|
+
if (part.pageNumber && part.bbox) _chunkZECSXHYPcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkZECSXHYPcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1704
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _102 => _102.blocks, 'optionalAccess', _103 => _103.length]) || _chunkZECSXHYPcjs.IMAGE_CELLS.has(cell)) _chunkZECSXHYPcjs.EMPTY_PARTS.delete(prev.table);
|
|
1705
1705
|
blocks.splice(j, 1);
|
|
1706
1706
|
if (cell.blocks && at > 0) {
|
|
1707
1707
|
const nextAt = cell.blocks[at];
|
|
@@ -1713,11 +1713,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1713
1713
|
}
|
|
1714
1714
|
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1715
1715
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1716
|
-
if (!_optionalChain([prev, 'optionalAccess', _104 => _104.table]) || !_optionalChain([frame, 'optionalAccess', _105 => _105.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !
|
|
1716
|
+
if (!_optionalChain([prev, 'optionalAccess', _104 => _104.table]) || !_optionalChain([frame, 'optionalAccess', _105 => _105.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkZECSXHYPcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1717
1717
|
const inner = _optionalChain([frame, 'access', _106 => _106.table, 'access', _107 => _107.cells, 'access', _108 => _108[0], 'optionalAccess', _109 => _109[0], 'optionalAccess', _110 => _110.blocks]);
|
|
1718
1718
|
const next = _optionalChain([inner, 'optionalAccess', _111 => _111[0]]);
|
|
1719
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _112 => _112.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
1720
|
-
const px =
|
|
1719
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _112 => _112.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkZECSXHYPcjs.CLIP_TABLES.has(prev.table) || !_chunkZECSXHYPcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1720
|
+
const px = _chunkZECSXHYPcjs.TABLE_COLXS.get(prev.table), nx = _chunkZECSXHYPcjs.TABLE_COLXS.get(next.table);
|
|
1721
1721
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1722
1722
|
const ph = _optionalChain([pageHeights, 'optionalAccess', _113 => _113.get, 'call', _114 => _114(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _115 => _115.get, 'call', _116 => _116(next.pageNumber)]);
|
|
1723
1723
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
@@ -1726,15 +1726,15 @@ function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
|
1726
1726
|
function fillNestedContinuation(blocks, at) {
|
|
1727
1727
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1728
1728
|
const t = _optionalChain([prev, 'optionalAccess', _117 => _117.table]), u = _optionalChain([next, 'optionalAccess', _118 => _118.table]);
|
|
1729
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1730
|
-
const xs =
|
|
1729
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkZECSXHYPcjs.CLIP_TABLES.has(t) || !_chunkZECSXHYPcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1730
|
+
const xs = _chunkZECSXHYPcjs.TABLE_COLXS.get(u);
|
|
1731
1731
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1732
1732
|
const add = _optionalChain([u, 'access', _119 => _119.cells, 'access', _120 => _120[0], 'optionalAccess', _121 => _121[0]]);
|
|
1733
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _122 => _122.blocks, 'optionalAccess', _123 => _123.length]) ||
|
|
1733
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _122 => _122.blocks, 'optionalAccess', _123 => _123.length]) || _chunkZECSXHYPcjs.IMAGE_CELLS.has(cell)) return;
|
|
1734
1734
|
cell.text = add.text;
|
|
1735
1735
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1736
|
-
if (
|
|
1737
|
-
|
|
1736
|
+
if (_chunkZECSXHYPcjs.IMAGE_CELLS.has(add)) _chunkZECSXHYPcjs.IMAGE_CELLS.add(cell);
|
|
1737
|
+
_chunkZECSXHYPcjs.joinCellEdges.call(void 0, cell, add);
|
|
1738
1738
|
blocks.splice(at, 1);
|
|
1739
1739
|
}
|
|
1740
1740
|
|
|
@@ -1954,15 +1954,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
1954
1954
|
function marginContextBlocks(raw, page, view) {
|
|
1955
1955
|
const [x1, y1, x2, y2] = view;
|
|
1956
1956
|
const width = x2 - x1, height = y2 - y1;
|
|
1957
|
-
const items =
|
|
1957
|
+
const items = _chunkZECSXHYPcjs.filterHiddenText.call(void 0, _chunkZECSXHYPcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
1958
1958
|
for (const item of items) {
|
|
1959
1959
|
item.x -= x1;
|
|
1960
1960
|
item.y -= y1;
|
|
1961
1961
|
}
|
|
1962
|
-
return
|
|
1963
|
-
const bbox =
|
|
1962
|
+
return _chunkZECSXHYPcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
1963
|
+
const bbox = _chunkZECSXHYPcjs.computeBBox.call(void 0, line, page);
|
|
1964
1964
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
1965
|
-
return [{ type: "paragraph", text:
|
|
1965
|
+
return [{ type: "paragraph", text: _chunkZECSXHYPcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkZECSXHYPcjs.dominantStyle.call(void 0, line) }];
|
|
1966
1966
|
});
|
|
1967
1967
|
}
|
|
1968
1968
|
|
|
@@ -1998,7 +1998,7 @@ var WINANSI_REVERSE = {
|
|
|
1998
1998
|
};
|
|
1999
1999
|
function symbolFontTable(fontName) {
|
|
2000
2000
|
if (!fontName) return void 0;
|
|
2001
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
2001
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkRO7AORMOcjs.WINGDINGS;
|
|
2002
2002
|
return void 0;
|
|
2003
2003
|
}
|
|
2004
2004
|
function remapSymbolText(text, table) {
|
|
@@ -3063,7 +3063,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3063
3063
|
if (block.type !== "heading" || !block.text) continue;
|
|
3064
3064
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
3065
3065
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _196 => _196.style, 'optionalAccess', _197 => _197.fontSize]), () => ( 0));
|
|
3066
|
-
const tocEntry = i > 0 &&
|
|
3066
|
+
const tocEntry = i > 0 && _chunkZECSXHYPcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkZECSXHYPcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
3067
3067
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
3068
3068
|
const proseStyle = _optionalChain([block, 'access', _198 => _198.style, 'optionalAccess', _199 => _199.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
3069
3069
|
const next = blocks[i + 1];
|
|
@@ -3161,7 +3161,7 @@ function splitSingleCellTables(blocks) {
|
|
|
3161
3161
|
const out = [];
|
|
3162
3162
|
for (const b of blocks) {
|
|
3163
3163
|
const t = b.type === "table" ? b.table : void 0;
|
|
3164
|
-
const title = t &&
|
|
3164
|
+
const title = t && _chunkZECSXHYPcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3165
3165
|
if (title) {
|
|
3166
3166
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3167
3167
|
continue;
|
|
@@ -3197,7 +3197,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
3197
3197
|
const lines = cell.text.split("\n");
|
|
3198
3198
|
const out = [lines[0]];
|
|
3199
3199
|
for (const line of lines.slice(1)) {
|
|
3200
|
-
if (
|
|
3200
|
+
if (_chunkZECSXHYPcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
3201
3201
|
else out.push(line);
|
|
3202
3202
|
}
|
|
3203
3203
|
cell.text = out.join("\n");
|
|
@@ -3217,10 +3217,10 @@ function cleanPdfText(text, opts) {
|
|
|
3217
3217
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
3218
3218
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
3219
3219
|
if (line.startsWith("|")) {
|
|
3220
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
3220
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkZECSXHYPcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
3221
3221
|
}
|
|
3222
3222
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _279 => _279.exec, 'call', _280 => _280(line), 'optionalAccess', _281 => _281[0]]), () => ( ""));
|
|
3223
|
-
return mark +
|
|
3223
|
+
return mark + _chunkZECSXHYPcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
3224
3224
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
3225
3225
|
}
|
|
3226
3226
|
function startsWithMarker(line) {
|
|
@@ -3252,7 +3252,7 @@ function mergeKoreanLines(text) {
|
|
|
3252
3252
|
continue;
|
|
3253
3253
|
}
|
|
3254
3254
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
3255
|
-
result[result.length - 1] = prev +
|
|
3255
|
+
result[result.length - 1] = prev + _chunkZECSXHYPcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
3256
3256
|
} else {
|
|
3257
3257
|
result.push(curr);
|
|
3258
3258
|
}
|
|
@@ -3268,7 +3268,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3268
3268
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3269
3269
|
for (const a of annots) {
|
|
3270
3270
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3271
|
-
const url =
|
|
3271
|
+
const url = _chunkM2CBEXHNcjs.sanitizeHref.call(void 0, a.url);
|
|
3272
3272
|
if (!url) continue;
|
|
3273
3273
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3274
3274
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -3320,7 +3320,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3320
3320
|
|
|
3321
3321
|
// src/pdf/formula-ocr.ts
|
|
3322
3322
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3323
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
3323
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-PYDSQGLS.cjs")));
|
|
3324
3324
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3325
3325
|
await ensureFormulaModels((p) => {
|
|
3326
3326
|
if (p.phase === "download" && p.total) {
|
|
@@ -3511,13 +3511,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3511
3511
|
try {
|
|
3512
3512
|
return await Promise.race([
|
|
3513
3513
|
loadingTask.promise.catch((e) => {
|
|
3514
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
3514
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkM2CBEXHNcjs.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)");
|
|
3515
3515
|
throw e;
|
|
3516
3516
|
}),
|
|
3517
3517
|
new Promise((_, reject) => {
|
|
3518
3518
|
timer = setTimeout(() => {
|
|
3519
3519
|
loadingTask.destroy();
|
|
3520
|
-
reject(new (0,
|
|
3520
|
+
reject(new (0, _chunkM2CBEXHNcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
3521
3521
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
3522
3522
|
})
|
|
3523
3523
|
]);
|
|
@@ -3527,14 +3527,14 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3527
3527
|
}
|
|
3528
3528
|
async function parsePdfDocument(buffer, options) {
|
|
3529
3529
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _282 => _282.formulaOcr]) ? buffer : null;
|
|
3530
|
-
const ocrOptionError =
|
|
3531
|
-
if (ocrOptionError) throw new (0,
|
|
3532
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _283 => _283.ocr]) === void 0 && await
|
|
3530
|
+
const ocrOptionError = _chunkRO7AORMOcjs.validateOcrOptions.call(void 0, options);
|
|
3531
|
+
if (ocrOptionError) throw new (0, _chunkM2CBEXHNcjs.KordocError)(ocrOptionError);
|
|
3532
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _283 => _283.ocr]) === void 0 && await _chunkZECSXHYPcjs.ocrModelsCached.call(void 0, _chunkZECSXHYPcjs.resolveOcrModels.call(void 0, options));
|
|
3533
3533
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _284 => _284.ocr]) || autoOcr ? buffer : null;
|
|
3534
3534
|
const doc = await loadPdfWithTimeout(buffer);
|
|
3535
3535
|
try {
|
|
3536
3536
|
const pageCount = doc.numPages;
|
|
3537
|
-
if (pageCount === 0) throw new (0,
|
|
3537
|
+
if (pageCount === 0) throw new (0, _chunkM2CBEXHNcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
3538
3538
|
const metadata = { pageCount, pageMode: "layout" };
|
|
3539
3539
|
await extractPdfMetadata(doc, metadata);
|
|
3540
3540
|
const blocks = [];
|
|
@@ -3563,7 +3563,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3563
3563
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
3564
3564
|
const carry = {};
|
|
3565
3565
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
3566
|
-
const wrapLexicon = new (0,
|
|
3566
|
+
const wrapLexicon = new (0, _chunkZECSXHYPcjs.WrapLexicon)();
|
|
3567
3567
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
3568
3568
|
const headerContext = [];
|
|
3569
3569
|
if (pageFilter && _optionalChain([options, 'optionalAccess', _287 => _287.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
@@ -3610,8 +3610,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3610
3610
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
3611
3611
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3612
3612
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3613
|
-
const items =
|
|
3614
|
-
const filtered =
|
|
3613
|
+
const items = _chunkZECSXHYPcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
3614
|
+
const filtered = _chunkZECSXHYPcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
3615
3615
|
const joined = joinVerticalColumns(filtered.visible);
|
|
3616
3616
|
const visible = dropTabLeaderDots(joined);
|
|
3617
3617
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -3637,7 +3637,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3637
3637
|
} : rawOps;
|
|
3638
3638
|
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _294 => _294(loadedName), 'optionalAccess', _295 => _295.name]));
|
|
3639
3639
|
remapControlGlyphs(visible, differencesOf);
|
|
3640
|
-
await
|
|
3640
|
+
await _chunkZECSXHYPcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
3641
3641
|
const faces = /* @__PURE__ */ new Map();
|
|
3642
3642
|
for (const it of visible) {
|
|
3643
3643
|
if (!it.fontName) continue;
|
|
@@ -3650,12 +3650,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3650
3650
|
it.fontName = face;
|
|
3651
3651
|
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _297 => _297(face), 'optionalAccess', _298 => _298.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
3652
3652
|
}
|
|
3653
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
3654
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
3653
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkRO7AORMOcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
3654
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkRO7AORMOcjs.escapeLiteralTags.call(void 0, it.text);
|
|
3655
3655
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
3656
3656
|
const pageArea = pageW * pageH;
|
|
3657
3657
|
if (pageArea > 0) {
|
|
3658
|
-
const imageRegions =
|
|
3658
|
+
const imageRegions = _chunkZECSXHYPcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
3659
3659
|
let uncovered = 0;
|
|
3660
3660
|
for (const r of imageRegions) {
|
|
3661
3661
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -3681,11 +3681,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3681
3681
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
3682
3682
|
}
|
|
3683
3683
|
const marks = superscriptNoteMarks(visible);
|
|
3684
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
3684
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkZECSXHYPcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
3685
3685
|
const stamp = marginStamp(visible);
|
|
3686
3686
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
3687
|
-
const rightArrows = _optionalChain([options, 'optionalAccess', _299 => _299.tables]) !== false ? await
|
|
3688
|
-
const pageBlocks = orderTwoUpPage(
|
|
3687
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _299 => _299.tables]) !== false ? await _chunkZECSXHYPcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
3688
|
+
const pageBlocks = orderTwoUpPage(_chunkZECSXHYPcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _300 => _300.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
3689
3689
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
3690
3690
|
for (const b of pageBlocks) blocks.push(b);
|
|
3691
3691
|
try {
|
|
@@ -3711,11 +3711,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3711
3711
|
if (_optionalChain([options, 'optionalAccess', _302 => _302.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
3712
3712
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
3713
3713
|
}
|
|
3714
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
3714
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkM2CBEXHNcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
3715
3715
|
parsedPages++;
|
|
3716
3716
|
_optionalChain([options, 'optionalAccess', _303 => _303.onProgress, 'optionalCall', _304 => _304(parsedPages, totalTarget)]);
|
|
3717
3717
|
} catch (pageErr) {
|
|
3718
|
-
if (pageErr instanceof
|
|
3718
|
+
if (pageErr instanceof _chunkM2CBEXHNcjs.KordocError) throw pageErr;
|
|
3719
3719
|
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" });
|
|
3720
3720
|
} finally {
|
|
3721
3721
|
_optionalChain([loadedPage, 'optionalAccess', _305 => _305.cleanup, 'call', _306 => _306()]);
|
|
@@ -3746,12 +3746,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3746
3746
|
}
|
|
3747
3747
|
if (targets.size > 0) {
|
|
3748
3748
|
try {
|
|
3749
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3749
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-PGXNUFU7.cjs")));
|
|
3750
3750
|
const mode = typeof _optionalChain([options, 'optionalAccess', _311 => _311.ocr]) === "function" ? options.ocr : "builtin";
|
|
3751
3751
|
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _312 => _312.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _313 => _313.find, 'call', _314 => _314((q) => q.page === p), 'optionalAccess', _315 => _315.needsOcr])));
|
|
3752
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3752
|
+
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-PGXNUFU7.cjs")));
|
|
3753
3753
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _316 => _316.onProgress]), _optionalChain([options, 'optionalAccess', _317 => _317.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
3754
|
-
for (const obs of ocrPageBlocks.values())
|
|
3754
|
+
for (const obs of ocrPageBlocks.values()) _chunkRO7AORMOcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
3755
3755
|
if (ocrPageBlocks.size > 0) {
|
|
3756
3756
|
const replacePages = /* @__PURE__ */ new Set();
|
|
3757
3757
|
for (const [p, obs] of ocrPageBlocks) {
|
|
@@ -3762,7 +3762,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3762
3762
|
continue;
|
|
3763
3763
|
}
|
|
3764
3764
|
const regions = ocrRegions.get(p);
|
|
3765
|
-
if (!regions ||
|
|
3765
|
+
if (!regions || _chunkZECSXHYPcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
3766
3766
|
ocrDone.add(p);
|
|
3767
3767
|
if (_optionalChain([pageImageBlocks, 'access', _322 => _322.get, 'call', _323 => _323(p), 'optionalAccess', _324 => _324.length]) === 1) pageImageBlocks.delete(p);
|
|
3768
3768
|
}
|
|
@@ -3815,17 +3815,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3815
3815
|
}
|
|
3816
3816
|
}
|
|
3817
3817
|
if (_optionalChain([options, 'optionalAccess', _325 => _325.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
3818
|
-
const removed =
|
|
3819
|
-
const running =
|
|
3818
|
+
const removed = _chunkZECSXHYPcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
3819
|
+
const running = _chunkZECSXHYPcjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
3820
3820
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
3821
3821
|
blocks.splice(removed[ri], 1);
|
|
3822
3822
|
}
|
|
3823
|
-
const stripped =
|
|
3823
|
+
const stripped = _chunkZECSXHYPcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
3824
3824
|
if (stripped !== blocks) {
|
|
3825
3825
|
blocks.length = 0;
|
|
3826
3826
|
blocks.push(...stripped);
|
|
3827
3827
|
}
|
|
3828
|
-
const kept =
|
|
3828
|
+
const kept = _chunkZECSXHYPcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
3829
3829
|
if (kept !== blocks) {
|
|
3830
3830
|
blocks.length = 0;
|
|
3831
3831
|
blocks.push(...kept);
|
|
@@ -3834,12 +3834,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3834
3834
|
mergeContinuedCells(blocks, pageHeights);
|
|
3835
3835
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
3836
3836
|
if (_optionalChain([options, 'optionalAccess', _326 => _326.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
3837
|
-
const boxes =
|
|
3837
|
+
const boxes = _chunkZECSXHYPcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
3838
3838
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
3839
3839
|
}
|
|
3840
3840
|
splitContactTables(blocks);
|
|
3841
|
-
if (!_optionalChain([options, 'optionalAccess', _327 => _327.keepTrailingEmptyCols]))
|
|
3842
|
-
|
|
3841
|
+
if (!_optionalChain([options, 'optionalAccess', _327 => _327.keepTrailingEmptyCols])) _chunkZECSXHYPcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
3842
|
+
_chunkZECSXHYPcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
3843
3843
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
3844
3844
|
if (_optionalChain([options, 'optionalAccess', _328 => _328.formulaOcr]) && formulaBuffer) {
|
|
3845
3845
|
try {
|
|
@@ -3851,21 +3851,21 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3851
3851
|
});
|
|
3852
3852
|
}
|
|
3853
3853
|
}
|
|
3854
|
-
const medianFontSize =
|
|
3854
|
+
const medianFontSize = _chunkZECSXHYPcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
3855
3855
|
if (medianFontSize > 0) {
|
|
3856
|
-
|
|
3857
|
-
}
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3856
|
+
_chunkZECSXHYPcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
3857
|
+
}
|
|
3858
|
+
_chunkZECSXHYPcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
3859
|
+
_chunkZECSXHYPcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
3860
|
+
_chunkZECSXHYPcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
3861
|
+
_chunkZECSXHYPcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
3862
|
+
_chunkZECSXHYPcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
3863
|
+
_chunkZECSXHYPcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
3864
|
+
_chunkZECSXHYPcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
3865
|
+
_chunkZECSXHYPcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
3866
3866
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3867
|
-
|
|
3868
|
-
|
|
3867
|
+
_chunkZECSXHYPcjs.detectTableCaptions.call(void 0, blocks);
|
|
3868
|
+
_chunkZECSXHYPcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3869
3869
|
sanitizeBlockControlChars(blocks);
|
|
3870
3870
|
let outBlocks = splitSingleCellTables(blocks);
|
|
3871
3871
|
if (_optionalChain([options, 'optionalAccess', _329 => _329.layoutTables]) !== "keep") {
|
|
@@ -3886,19 +3886,19 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3886
3886
|
const shown = /* @__PURE__ */ new Map();
|
|
3887
3887
|
const markContent = (bs) => {
|
|
3888
3888
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
3889
|
-
if (
|
|
3890
|
-
const lines =
|
|
3891
|
-
if (lines)
|
|
3889
|
+
if (_chunkZECSXHYPcjs.IMAGE_CELLS.has(c)) _chunkRO7AORMOcjs.CONTENT_CELLS.add(c);
|
|
3890
|
+
const lines = _chunkZECSXHYPcjs.CELL_LINES.get(c);
|
|
3891
|
+
if (lines) _chunkRO7AORMOcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
3892
3892
|
markContent(c.blocks);
|
|
3893
3893
|
}
|
|
3894
3894
|
};
|
|
3895
3895
|
const visual = (bs) => bs.flatMap((b) => {
|
|
3896
3896
|
if (b.type !== "table") return [b];
|
|
3897
|
-
if (!hancom && b.table &&
|
|
3897
|
+
if (!hancom && b.table && _chunkZECSXHYPcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
3898
3898
|
let v = shown.get(b);
|
|
3899
3899
|
if (!v) {
|
|
3900
3900
|
markContent([b]);
|
|
3901
|
-
shown.set(b, v =
|
|
3901
|
+
shown.set(b, v = _chunkRO7AORMOcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _332 => _332.keepTrailingEmptyCols])));
|
|
3902
3902
|
}
|
|
3903
3903
|
return v;
|
|
3904
3904
|
});
|
|
@@ -3907,13 +3907,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3907
3907
|
blocks.length = 0;
|
|
3908
3908
|
for (const b of kept) blocks.push(b);
|
|
3909
3909
|
}
|
|
3910
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
3911
|
-
if (_optionalChain([options, 'optionalAccess', _334 => _334.tableFormat]) === "gfm")
|
|
3910
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkRO7AORMOcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _333 => _333.tableFormat]) }), { keepLoneNumbers: true }));
|
|
3911
|
+
if (_optionalChain([options, 'optionalAccess', _334 => _334.tableFormat]) === "gfm") _chunkRO7AORMOcjs.assignTableIds.call(void 0, blocks);
|
|
3912
3912
|
let markdown = finishMarkdown(outBlocks);
|
|
3913
3913
|
const outline = collectPdfOutline(outBlocks);
|
|
3914
3914
|
return {
|
|
3915
3915
|
markdown,
|
|
3916
|
-
pages:
|
|
3916
|
+
pages: _chunkOSFB5SQScjs.blocksToPages.call(void 0, splitPageTables(_chunkZECSXHYPcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
3917
3917
|
blocks,
|
|
3918
3918
|
metadata,
|
|
3919
3919
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3993,5 +3993,5 @@ function marginStamp(items) {
|
|
|
3993
3993
|
|
|
3994
3994
|
|
|
3995
3995
|
|
|
3996
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
3997
|
-
//# sourceMappingURL=parser-
|
|
3996
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkZECSXHYPcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkZECSXHYPcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkZECSXHYPcjs.removeHeaderFooterBlocks;
|
|
3997
|
+
//# sourceMappingURL=parser-6337Z4U2.cjs.map
|