kordoc 4.21.19 → 4.21.21
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 +7 -5
- package/dist/{-FLYHAUQ6.js → -ZYF6HX4M.js} +11 -11
- package/dist/{chunk-TC6DQLYN.js → chunk-2ZGP7A5T.js} +2 -2
- package/dist/{chunk-4VM6BT4W.js → chunk-3TCF5HPP.js} +2 -2
- package/dist/{chunk-2DNJW2HO.cjs → chunk-57VNFMMS.cjs} +3 -3
- package/dist/{chunk-2DNJW2HO.cjs.map → chunk-57VNFMMS.cjs.map} +1 -1
- package/dist/{chunk-OON4IJU2.js → chunk-5HTFWUJE.js} +2 -2
- package/dist/{chunk-AQ5GIBBH.js → chunk-7YAJCXCD.js} +2 -2
- package/dist/{chunk-3O4YC67B.js → chunk-BC54LBST.js} +3 -3
- package/dist/{chunk-GK4QLKNT.js → chunk-BG6LUCQL.js} +2 -2
- package/dist/{chunk-SM42XSI3.js → chunk-CY4QM2KQ.js} +2 -2
- package/dist/{chunk-KLKV47XO.cjs → chunk-DTZIZ5PP.cjs} +13 -13
- package/dist/{chunk-KLKV47XO.cjs.map → chunk-DTZIZ5PP.cjs.map} +1 -1
- package/dist/{chunk-INZGI6PI.js → chunk-FBJVDBMO.js} +2 -2
- package/dist/{chunk-Z2OOYQ4I.js → chunk-FZMGF6XU.js} +2 -2
- package/dist/{chunk-JGGYLUGD.cjs → chunk-H2MS4VG3.cjs} +3 -3
- package/dist/{chunk-JGGYLUGD.cjs.map → chunk-H2MS4VG3.cjs.map} +1 -1
- package/dist/{chunk-3PCAJWGK.js → chunk-HWIW3WK2.js} +42 -3
- package/dist/{chunk-3PCAJWGK.js.map → chunk-HWIW3WK2.js.map} +1 -1
- package/dist/{chunk-F6N7CDB7.js → chunk-J5PBI3ZC.js} +3 -3
- package/dist/{chunk-DQ2YGTRS.js → chunk-KBV4WFZ6.js} +145 -123
- package/dist/chunk-KBV4WFZ6.js.map +1 -0
- package/dist/{chunk-YDIVY65W.js → chunk-KTLHADU4.js} +2 -2
- package/dist/{chunk-3KW2Q655.cjs → chunk-MCUX2Y2C.cjs} +2 -2
- package/dist/{chunk-3KW2Q655.cjs.map → chunk-MCUX2Y2C.cjs.map} +1 -1
- package/dist/{chunk-X6WXU4LA.js → chunk-PTF4NCFM.js} +2 -2
- package/dist/{chunk-46PYORID.js → chunk-QHNVH4TC.js} +6 -6
- package/dist/{chunk-RYRUQ73F.js → chunk-RBRHO7WL.js} +2 -2
- package/dist/{chunk-CLAIAXMX.js → chunk-T3DTTK23.js} +2 -2
- package/dist/{chunk-DZVZVZAD.cjs → chunk-T7PN5D4D.cjs} +6 -6
- package/dist/{chunk-DZVZVZAD.cjs.map → chunk-T7PN5D4D.cjs.map} +1 -1
- package/dist/{chunk-EYLEVRHT.cjs → chunk-TMUUDMDH.cjs} +274 -172
- package/dist/chunk-TMUUDMDH.cjs.map +1 -0
- package/dist/{chunk-VIFY6DJZ.js → chunk-TRO4CQHJ.js} +4 -4
- package/dist/{chunk-OWLDTF5Q.js → chunk-WGMYVRSA.js} +2 -2
- package/dist/{chunk-AMXIYV73.js → chunk-YHPJTLCA.js} +2 -2
- package/dist/{chunk-QWOZRYUA.js → chunk-YM3K3LCD.js} +450 -110
- package/dist/chunk-YM3K3LCD.js.map +1 -0
- package/dist/{chunk-Y5OSPKBU.js → chunk-YQZOPT3A.js} +225 -43
- package/dist/chunk-YQZOPT3A.js.map +1 -0
- package/dist/{chunk-UDODNSDU.js → chunk-ZZIQWSGC.js} +2 -2
- package/dist/chunks-MDMJRCJ7.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-2YYGN7UE.js → formula-6XNIXZ5L.js} +3 -3
- package/dist/{formula-EKXCURKO.cjs → formula-A3I5VAP7.cjs} +9 -9
- package/dist/{formula-EKXCURKO.cjs.map → formula-A3I5VAP7.cjs.map} +1 -1
- package/dist/{formula-Z5UPXBQM.js → formula-P7M7IH2L.js} +4 -4
- package/dist/{image-ocr-23R7RVHP.js → image-ocr-3C6W3KZO.js} +6 -6
- package/dist/{image-ocr-IMLFZ2JC.js → image-ocr-ITNY454I.js} +9 -9
- package/dist/{image-ocr-TE76KKNV.cjs → image-ocr-UJRSQ2T3.cjs} +15 -15
- package/dist/{image-ocr-TE76KKNV.cjs.map → image-ocr-UJRSQ2T3.cjs.map} +1 -1
- package/dist/index.cjs +1064 -687
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +482 -105
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-GTSRH2DY.js → model-bundle-LAWQH75O.js} +5 -5
- package/dist/{models-2J3NS7G2.js → models-6QTD2CFM.js} +5 -5
- package/dist/{parse-worker-v2-VO5UY3MP.js → parse-worker-v2-FEPJG3ER.js} +12 -12
- package/dist/{parser-FXGAKPUI.js → parser-56I364YM.js} +16 -8
- package/dist/{parser-JVUZ7EEV.js.map → parser-56I364YM.js.map} +1 -1
- package/dist/{parser-JVUZ7EEV.js → parser-KFCY3NIN.js} +19 -11
- package/dist/{parser-FXGAKPUI.js.map → parser-KFCY3NIN.js.map} +1 -1
- package/dist/{parser-D5VMCDLG.cjs → parser-VKWUMUML.cjs} +142 -134
- package/dist/parser-VKWUMUML.cjs.map +1 -0
- package/dist/pdf-ocr-MME37BL4.js +18 -0
- package/dist/pdf-ocr-OKAHNEJA.cjs +19 -0
- package/dist/{pdf-ocr-YFNUYBYJ.cjs.map → pdf-ocr-OKAHNEJA.cjs.map} +1 -1
- package/dist/pdf-ocr-ZZ6AJL6Z.js +22 -0
- package/dist/{profile-io-ULK73H2G.js → profile-io-OCITHUQF.js} +3 -3
- package/dist/{rasterize-FG3NX3GA.js → rasterize-SFCG4YOI.js} +3 -3
- package/dist/{redact-doc-NMKTKG24.js → redact-doc-5SMPXIGG.js} +11 -11
- package/dist/{render-GQUUGPOJ.js → render-FGPG5A2N.js} +7 -7
- package/dist/seal-GA7NZDTG.js +10 -0
- package/dist/{setup-PRBHD7JI.js → setup-JQVYZO7I.js} +3 -3
- package/dist/visual-YMG644YW.js +20 -0
- package/dist/{watch-LFSXNO2B.js → watch-C77BUSP7.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-DQ2YGTRS.js.map +0 -1
- package/dist/chunk-EYLEVRHT.cjs.map +0 -1
- package/dist/chunk-QWOZRYUA.js.map +0 -1
- package/dist/chunk-Y5OSPKBU.js.map +0 -1
- package/dist/chunks-J46DCTUC.js +0 -10
- package/dist/parser-D5VMCDLG.cjs.map +0 -1
- package/dist/pdf-ocr-364WQ5TY.js +0 -18
- package/dist/pdf-ocr-4MZELYCR.js +0 -22
- package/dist/pdf-ocr-YFNUYBYJ.cjs +0 -19
- package/dist/seal-EVHTG5GH.js +0 -10
- package/dist/visual-TCIR6MOG.js +0 -20
- /package/dist/{-FLYHAUQ6.js.map → -ZYF6HX4M.js.map} +0 -0
- /package/dist/{chunk-TC6DQLYN.js.map → chunk-2ZGP7A5T.js.map} +0 -0
- /package/dist/{chunk-4VM6BT4W.js.map → chunk-3TCF5HPP.js.map} +0 -0
- /package/dist/{chunk-OON4IJU2.js.map → chunk-5HTFWUJE.js.map} +0 -0
- /package/dist/{chunk-AQ5GIBBH.js.map → chunk-7YAJCXCD.js.map} +0 -0
- /package/dist/{chunk-3O4YC67B.js.map → chunk-BC54LBST.js.map} +0 -0
- /package/dist/{chunk-GK4QLKNT.js.map → chunk-BG6LUCQL.js.map} +0 -0
- /package/dist/{chunk-SM42XSI3.js.map → chunk-CY4QM2KQ.js.map} +0 -0
- /package/dist/{chunk-INZGI6PI.js.map → chunk-FBJVDBMO.js.map} +0 -0
- /package/dist/{chunk-Z2OOYQ4I.js.map → chunk-FZMGF6XU.js.map} +0 -0
- /package/dist/{chunk-F6N7CDB7.js.map → chunk-J5PBI3ZC.js.map} +0 -0
- /package/dist/{chunk-YDIVY65W.js.map → chunk-KTLHADU4.js.map} +0 -0
- /package/dist/{chunk-X6WXU4LA.js.map → chunk-PTF4NCFM.js.map} +0 -0
- /package/dist/{chunk-46PYORID.js.map → chunk-QHNVH4TC.js.map} +0 -0
- /package/dist/{chunk-RYRUQ73F.js.map → chunk-RBRHO7WL.js.map} +0 -0
- /package/dist/{chunk-CLAIAXMX.js.map → chunk-T3DTTK23.js.map} +0 -0
- /package/dist/{chunk-VIFY6DJZ.js.map → chunk-TRO4CQHJ.js.map} +0 -0
- /package/dist/{chunk-OWLDTF5Q.js.map → chunk-WGMYVRSA.js.map} +0 -0
- /package/dist/{chunk-AMXIYV73.js.map → chunk-YHPJTLCA.js.map} +0 -0
- /package/dist/{chunk-UDODNSDU.js.map → chunk-ZZIQWSGC.js.map} +0 -0
- /package/dist/{chunks-J46DCTUC.js.map → chunks-MDMJRCJ7.js.map} +0 -0
- /package/dist/{formula-2YYGN7UE.js.map → formula-6XNIXZ5L.js.map} +0 -0
- /package/dist/{formula-Z5UPXBQM.js.map → formula-P7M7IH2L.js.map} +0 -0
- /package/dist/{image-ocr-23R7RVHP.js.map → image-ocr-3C6W3KZO.js.map} +0 -0
- /package/dist/{image-ocr-IMLFZ2JC.js.map → image-ocr-ITNY454I.js.map} +0 -0
- /package/dist/{model-bundle-GTSRH2DY.js.map → model-bundle-LAWQH75O.js.map} +0 -0
- /package/dist/{models-2J3NS7G2.js.map → models-6QTD2CFM.js.map} +0 -0
- /package/dist/{parse-worker-v2-VO5UY3MP.js.map → parse-worker-v2-FEPJG3ER.js.map} +0 -0
- /package/dist/{pdf-ocr-364WQ5TY.js.map → pdf-ocr-MME37BL4.js.map} +0 -0
- /package/dist/{pdf-ocr-4MZELYCR.js.map → pdf-ocr-ZZ6AJL6Z.js.map} +0 -0
- /package/dist/{profile-io-ULK73H2G.js.map → profile-io-OCITHUQF.js.map} +0 -0
- /package/dist/{rasterize-FG3NX3GA.js.map → rasterize-SFCG4YOI.js.map} +0 -0
- /package/dist/{redact-doc-NMKTKG24.js.map → redact-doc-5SMPXIGG.js.map} +0 -0
- /package/dist/{render-GQUUGPOJ.js.map → render-FGPG5A2N.js.map} +0 -0
- /package/dist/{seal-EVHTG5GH.js.map → seal-GA7NZDTG.js.map} +0 -0
- /package/dist/{setup-PRBHD7JI.js.map → setup-JQVYZO7I.js.map} +0 -0
- /package/dist/{visual-TCIR6MOG.js.map → visual-YMG644YW.js.map} +0 -0
- /package/dist/{watch-LFSXNO2B.js.map → watch-C77BUSP7.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 _chunk57VNFMMScjs = require('./chunk-57VNFMMS.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -57,9 +57,9 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
var _chunkEYLEVRHTcjs = require('./chunk-EYLEVRHT.cjs');
|
|
61
60
|
|
|
62
61
|
|
|
62
|
+
var _chunkTMUUDMDHcjs = require('./chunk-TMUUDMDH.cjs');
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
@@ -70,12 +70,14 @@ var _chunkEYLEVRHTcjs = require('./chunk-EYLEVRHT.cjs');
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
var _chunkDZVZVZADcjs = require('./chunk-DZVZVZAD.cjs');
|
|
74
|
-
require('./chunk-JGGYLUGD.cjs');
|
|
75
73
|
|
|
76
74
|
|
|
75
|
+
var _chunkT7PN5D4Dcjs = require('./chunk-T7PN5D4D.cjs');
|
|
76
|
+
require('./chunk-H2MS4VG3.cjs');
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
var _chunkMCUX2Y2Ccjs = require('./chunk-MCUX2Y2C.cjs');
|
|
79
81
|
|
|
80
82
|
|
|
81
83
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -212,7 +214,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
212
214
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
213
215
|
state.seen.set(hash, filename);
|
|
214
216
|
if (withBytes) {
|
|
215
|
-
const png =
|
|
217
|
+
const png = _chunk57VNFMMScjs.encodePng.call(void 0, w, h, rgba);
|
|
216
218
|
state.totalBytes += png.length;
|
|
217
219
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
218
220
|
}
|
|
@@ -692,7 +694,7 @@ function rowStarts(t) {
|
|
|
692
694
|
}
|
|
693
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));
|
|
694
696
|
function cellPage(cell) {
|
|
695
|
-
const p =
|
|
697
|
+
const p = _chunkT7PN5D4Dcjs.CELL_PAGES.get(cell);
|
|
696
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;
|
|
697
699
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
698
700
|
}
|
|
@@ -721,7 +723,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
721
723
|
rows.forEach((starts, r) => {
|
|
722
724
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
723
725
|
for (const { cell } of starts) {
|
|
724
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
726
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkT7PN5D4Dcjs.CELL_PAGES.set(cell, page2);
|
|
725
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))]);
|
|
726
728
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
727
729
|
}
|
|
@@ -770,8 +772,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
770
772
|
if (!splits.length) continue;
|
|
771
773
|
const clone = (cell, patch) => {
|
|
772
774
|
const out = { ...cell, ...patch };
|
|
773
|
-
const p =
|
|
774
|
-
if (p !== void 0)
|
|
775
|
+
const p = _chunkT7PN5D4Dcjs.CELL_PAGES.get(cell);
|
|
776
|
+
if (p !== void 0) _chunkT7PN5D4Dcjs.CELL_PAGES.set(out, p);
|
|
775
777
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
776
778
|
return out;
|
|
777
779
|
};
|
|
@@ -781,7 +783,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
781
783
|
for (const { cell, c, split } of splits) {
|
|
782
784
|
cells[r][c] = clone(cell, split.head);
|
|
783
785
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
784
|
-
|
|
786
|
+
_chunkT7PN5D4Dcjs.CELL_PAGES.set(tail, split.page);
|
|
785
787
|
setSplits(tail, split.rest);
|
|
786
788
|
row[c] = tail;
|
|
787
789
|
}
|
|
@@ -900,19 +902,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
900
902
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
901
903
|
}
|
|
902
904
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
903
|
-
const lines =
|
|
904
|
-
if (lines)
|
|
905
|
-
if (
|
|
906
|
-
const edges =
|
|
905
|
+
const lines = _chunkTMUUDMDHcjs.CELL_LINES.get(a.cell);
|
|
906
|
+
if (lines) _chunkTMUUDMDHcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
907
|
+
if (_chunkTMUUDMDHcjs.IMAGE_CELLS.has(a.cell)) _chunkTMUUDMDHcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
908
|
+
const edges = _chunkT7PN5D4Dcjs.CELL_EDGES.get(a.cell);
|
|
907
909
|
if (edges) {
|
|
908
|
-
|
|
910
|
+
_chunkT7PN5D4Dcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
909
911
|
edged = true;
|
|
910
912
|
}
|
|
911
913
|
return true;
|
|
912
914
|
};
|
|
913
|
-
for (const a of pa) if (!
|
|
915
|
+
for (const a of pa) if (!_chunkTMUUDMDHcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
914
916
|
for (const a of ca) {
|
|
915
|
-
if (a.r < skip ||
|
|
917
|
+
if (a.r < skip || _chunkTMUUDMDHcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
916
918
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
917
919
|
}
|
|
918
920
|
const first = prev.rows;
|
|
@@ -936,9 +938,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
936
938
|
const grown = { ...above, rs: newRs };
|
|
937
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;
|
|
938
940
|
}
|
|
939
|
-
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) _chunkTMUUDMDHcjs.FILLER_CELLS.add(grid[r][c]);
|
|
940
942
|
if (edged) {
|
|
941
|
-
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) _chunkT7PN5D4Dcjs.CELL_EDGES.set(grid[r][c], _chunkTMUUDMDHcjs.NO_EDGES);
|
|
942
944
|
}
|
|
943
945
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
944
946
|
let r = prev.rows;
|
|
@@ -947,7 +949,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
947
949
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
948
950
|
}
|
|
949
951
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
950
|
-
const pr =
|
|
952
|
+
const pr = _chunkTMUUDMDHcjs.ROW_RULES.get(prev), cr = _chunkTMUUDMDHcjs.ROW_RULES.get(curr);
|
|
951
953
|
const shifted = dx !== 0;
|
|
952
954
|
const cut = {
|
|
953
955
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -958,7 +960,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
958
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 });
|
|
959
961
|
if (pr && cr) {
|
|
960
962
|
const cutRuled = pr.bottom || cr.top;
|
|
961
|
-
|
|
963
|
+
_chunkTMUUDMDHcjs.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) });
|
|
962
964
|
}
|
|
963
965
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
964
966
|
}
|
|
@@ -1019,11 +1021,11 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1019
1021
|
c = u.c + u.cs;
|
|
1020
1022
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1021
1023
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1022
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1024
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkTMUUDMDHcjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
1023
1025
|
if (!flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1024
1026
|
if (!straddles && !midWord) continue;
|
|
1025
1027
|
if (u.r >= last && d.rs < 2) continue;
|
|
1026
|
-
const U =
|
|
1028
|
+
const U = _chunkTMUUDMDHcjs.CELL_LINES.get(a);
|
|
1027
1029
|
if (!_optionalChain([U, 'optionalAccess', _30 => _30.length]) || !hasContent(b)) continue;
|
|
1028
1030
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1029
1031
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -1041,7 +1043,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1041
1043
|
return merged;
|
|
1042
1044
|
}
|
|
1043
1045
|
function longLastLine(c) {
|
|
1044
|
-
const L =
|
|
1046
|
+
const L = _chunkTMUUDMDHcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _31 => _31[L.length - 1]]);
|
|
1045
1047
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1046
1048
|
}
|
|
1047
1049
|
function filledToBottom(U, bottom) {
|
|
@@ -1074,7 +1076,7 @@ function nextItemHead(prev, next) {
|
|
|
1074
1076
|
return false;
|
|
1075
1077
|
}
|
|
1076
1078
|
function continuesAcross(u, d, x1, x2) {
|
|
1077
|
-
const U =
|
|
1079
|
+
const U = _chunkTMUUDMDHcjs.CELL_LINES.get(u), D = _chunkTMUUDMDHcjs.CELL_LINES.get(d);
|
|
1078
1080
|
if (!_optionalChain([U, 'optionalAccess', _32 => _32.length]) || !_optionalChain([D, 'optionalAccess', _33 => _33.length])) return false;
|
|
1079
1081
|
const last = U[U.length - 1];
|
|
1080
1082
|
const fs = last.h || 10;
|
|
@@ -1092,7 +1094,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1092
1094
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1093
1095
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1094
1096
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1095
|
-
const newItem =
|
|
1097
|
+
const newItem = _chunkTMUUDMDHcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1096
1098
|
const all = D.length ? U.concat(D) : U;
|
|
1097
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));
|
|
1098
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;
|
|
@@ -1109,10 +1111,10 @@ function outlineContinues(u, d) {
|
|
|
1109
1111
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1110
1112
|
}
|
|
1111
1113
|
function lineEnded(c, x1, x2, next) {
|
|
1112
|
-
const L =
|
|
1114
|
+
const L = _chunkTMUUDMDHcjs.CELL_LINES.get(c);
|
|
1113
1115
|
if (!L || L.length !== 1) return false;
|
|
1114
1116
|
const l = L[0], h = l.h || 10;
|
|
1115
|
-
const d0 = next ? _optionalChain([
|
|
1117
|
+
const d0 = next ? _optionalChain([_chunkTMUUDMDHcjs.CELL_LINES, 'access', _34 => _34.get, 'call', _35 => _35(next), 'optionalAccess', _36 => _36[0]]) : void 0;
|
|
1116
1118
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1117
1119
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _37 => _37.text]), () => ( "")))) * h;
|
|
1118
1120
|
}
|
|
@@ -1128,9 +1130,9 @@ function appendCell(a, b) {
|
|
|
1128
1130
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1129
1131
|
}
|
|
1130
1132
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1131
|
-
|
|
1133
|
+
_chunkTMUUDMDHcjs.joinCellEdges.call(void 0, a, b);
|
|
1132
1134
|
}
|
|
1133
|
-
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]) || _chunkTMUUDMDHcjs.IMAGE_CELLS.has(cell);
|
|
1134
1136
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1135
1137
|
var batchim = (ch) => {
|
|
1136
1138
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1138,7 +1140,7 @@ var batchim = (ch) => {
|
|
|
1138
1140
|
};
|
|
1139
1141
|
function clauseContinues(u, d) {
|
|
1140
1142
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1141
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1143
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkTMUUDMDHcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1142
1144
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1143
1145
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1144
1146
|
}
|
|
@@ -1146,8 +1148,8 @@ function quantityContinues(u, d) {
|
|
|
1146
1148
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1147
1149
|
}
|
|
1148
1150
|
function wordOverflows(u, d, x1, x2) {
|
|
1149
|
-
const U =
|
|
1150
|
-
if (!_optionalChain([U, 'optionalAccess', _46 => _46.length]) ||
|
|
1151
|
+
const U = _chunkTMUUDMDHcjs.CELL_LINES.get(u);
|
|
1152
|
+
if (!_optionalChain([U, 'optionalAccess', _46 => _46.length]) || _chunkTMUUDMDHcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1151
1153
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1152
1154
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1153
1155
|
}
|
|
@@ -1215,7 +1217,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1215
1217
|
if (!carriedSplit) {
|
|
1216
1218
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1217
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;
|
|
1218
|
-
const oneLine = (c) => _optionalChain([
|
|
1220
|
+
const oneLine = (c) => _optionalChain([_chunkTMUUDMDHcjs.CELL_LINES, 'access', _48 => _48.get, 'call', _49 => _49(c), 'optionalAccess', _50 => _50.length]) === 1;
|
|
1219
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;
|
|
1220
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));
|
|
1221
1223
|
if (!(cut.open && !newCell)) {
|
|
@@ -1300,19 +1302,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1300
1302
|
placeJoined(blocks, i, j, joined);
|
|
1301
1303
|
continue;
|
|
1302
1304
|
}
|
|
1303
|
-
if (
|
|
1305
|
+
if (_chunkTMUUDMDHcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1304
1306
|
blocks.splice(j, 1);
|
|
1305
1307
|
i++;
|
|
1306
1308
|
continue;
|
|
1307
1309
|
}
|
|
1308
1310
|
if (joined === null) continue;
|
|
1309
|
-
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 || _chunkTMUUDMDHcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1310
1312
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1311
1313
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1312
1314
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1313
1315
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1314
|
-
const px =
|
|
1315
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1316
|
+
const px = _chunkTMUUDMDHcjs.TABLE_COLXS.get(prev.table), cx = _chunkTMUUDMDHcjs.TABLE_COLXS.get(curr.table);
|
|
1317
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkTMUUDMDHcjs.CLIP_TABLES.has(prev.table) && !_chunkTMUUDMDHcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1316
1318
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1317
1319
|
let currCells = curr.table.cells;
|
|
1318
1320
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1323,16 +1325,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1323
1325
|
blocks.splice(j, 1);
|
|
1324
1326
|
continue;
|
|
1325
1327
|
}
|
|
1326
|
-
if (px && cx && !
|
|
1328
|
+
if (px && cx && !_chunkTMUUDMDHcjs.CLIP_TABLES.has(prev.table) && !_chunkTMUUDMDHcjs.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 && _chunkTMUUDMDHcjs.CELL_LINES.has(c))) {
|
|
1327
1329
|
const dx = px[0] - cx[0];
|
|
1328
1330
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1329
1331
|
if (_optionalChain([part, 'optionalAccess', _67 => _67.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1330
1332
|
const last = prev.table.rows - 1;
|
|
1331
1333
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1332
|
-
const U =
|
|
1333
|
-
|
|
1334
|
+
const U = _chunkTMUUDMDHcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkTMUUDMDHcjs.CELL_LINES.get(currCells[0][c]);
|
|
1335
|
+
_chunkTMUUDMDHcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1334
1336
|
}
|
|
1335
|
-
|
|
1337
|
+
_chunkTMUUDMDHcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1336
1338
|
placeJoined(blocks, i, j, part.table);
|
|
1337
1339
|
continue;
|
|
1338
1340
|
}
|
|
@@ -1345,20 +1347,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1345
1347
|
caption: prev.table.caption,
|
|
1346
1348
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1347
1349
|
};
|
|
1348
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1349
|
-
if (
|
|
1350
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkTMUUDMDHcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1351
|
+
if (_chunkTMUUDMDHcjs.CLIP_TABLES.has(prev.table) || _chunkTMUUDMDHcjs.CLIP_TABLES.has(curr.table)) _chunkTMUUDMDHcjs.CLIP_TABLES.add(merged);
|
|
1350
1352
|
placeJoined(blocks, i, j, merged);
|
|
1351
1353
|
}
|
|
1352
1354
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1353
1355
|
const t = blocks[i].table;
|
|
1354
|
-
if (blocks[i].type === "table" && t &&
|
|
1356
|
+
if (blocks[i].type === "table" && t && _chunkTMUUDMDHcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1355
1357
|
}
|
|
1356
1358
|
}
|
|
1357
1359
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1358
1360
|
if (!pageHeights) return;
|
|
1359
1361
|
for (let i = 0; i < blocks.length; i++) {
|
|
1360
1362
|
const L = blocks[i];
|
|
1361
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1363
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkTMUUDMDHcjs.CLIP_TABLES.has(L.table) || _chunkTMUUDMDHcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1362
1364
|
const ph = pageHeights.get(L.pageNumber);
|
|
1363
1365
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1364
1366
|
let s0 = i, s1 = i;
|
|
@@ -1387,8 +1389,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1387
1389
|
}
|
|
1388
1390
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1389
1391
|
const pt = prev.table, ct = curr.table;
|
|
1390
|
-
if (!
|
|
1391
|
-
const px =
|
|
1392
|
+
if (!_chunkTMUUDMDHcjs.CLIP_TABLES.has(pt) || !_chunkTMUUDMDHcjs.CLIP_TABLES.has(ct)) return null;
|
|
1393
|
+
const px = _chunkTMUUDMDHcjs.TABLE_COLXS.get(pt), cx = _chunkTMUUDMDHcjs.TABLE_COLXS.get(ct);
|
|
1392
1394
|
if (!px || !cx) return null;
|
|
1393
1395
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1394
1396
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -1404,15 +1406,15 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1404
1406
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1405
1407
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1406
1408
|
};
|
|
1407
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1409
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkTMUUDMDHcjs.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);
|
|
1408
1410
|
}
|
|
1409
1411
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _72 => _72.bbox, 'optionalAccess', _73 => _73.y]), lex);
|
|
1410
1412
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1411
|
-
|
|
1412
|
-
const ys =
|
|
1413
|
-
if (ys)
|
|
1414
|
-
|
|
1415
|
-
|
|
1413
|
+
_chunkTMUUDMDHcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1414
|
+
const ys = _chunkTMUUDMDHcjs.TABLE_ROWYS.get(pt);
|
|
1415
|
+
if (ys) _chunkTMUUDMDHcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1416
|
+
_chunkTMUUDMDHcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkTMUUDMDHcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1417
|
+
_chunkTMUUDMDHcjs.CLIP_TABLES.add(res.table);
|
|
1416
1418
|
return res.table;
|
|
1417
1419
|
}
|
|
1418
1420
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
@@ -1436,12 +1438,12 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
1436
1438
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1437
1439
|
}
|
|
1438
1440
|
function pushedLead(prev, curr) {
|
|
1439
|
-
if (!
|
|
1441
|
+
if (!_chunkTMUUDMDHcjs.CLIP_TABLES.has(prev.table) || !_chunkTMUUDMDHcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1440
1442
|
const lead = leadRows(curr.table);
|
|
1441
1443
|
return lead.image && lead.height > prev.bbox.y;
|
|
1442
1444
|
}
|
|
1443
1445
|
function leadRows(t) {
|
|
1444
|
-
const ys =
|
|
1446
|
+
const ys = _chunkTMUUDMDHcjs.TABLE_ROWYS.get(t);
|
|
1445
1447
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1446
1448
|
const anchors = anchorsOf(t);
|
|
1447
1449
|
let end = 1, image = false;
|
|
@@ -1449,17 +1451,17 @@ function leadRows(t) {
|
|
|
1449
1451
|
for (const a of anchors) {
|
|
1450
1452
|
if (a.r !== r) continue;
|
|
1451
1453
|
end = Math.max(end, r + a.rs);
|
|
1452
|
-
if (
|
|
1454
|
+
if (_chunkTMUUDMDHcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1453
1455
|
}
|
|
1454
1456
|
}
|
|
1455
1457
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1456
1458
|
}
|
|
1457
1459
|
function tailOf(b) {
|
|
1458
|
-
const t = b.table &&
|
|
1460
|
+
const t = b.table && _chunkTMUUDMDHcjs.TABLE_TAIL.get(b.table);
|
|
1459
1461
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1460
1462
|
}
|
|
1461
1463
|
function firstRowSig(t) {
|
|
1462
|
-
const x =
|
|
1464
|
+
const x = _chunkTMUUDMDHcjs.TABLE_COLXS.get(t);
|
|
1463
1465
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1464
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, "") }));
|
|
1465
1467
|
}
|
|
@@ -1512,7 +1514,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1512
1514
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1513
1515
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1514
1516
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1515
|
-
const px =
|
|
1517
|
+
const px = _chunkTMUUDMDHcjs.TABLE_COLXS.get(pb.table), cx = _chunkTMUUDMDHcjs.TABLE_COLXS.get(cur.table);
|
|
1516
1518
|
if (!px || !cx) break;
|
|
1517
1519
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1518
1520
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1583,7 +1585,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1583
1585
|
var COL_MATCH_TOL = 0.5;
|
|
1584
1586
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1585
1587
|
function lastRowCell(t, x1, x2) {
|
|
1586
|
-
const xs =
|
|
1588
|
+
const xs = _chunkTMUUDMDHcjs.TABLE_COLXS.get(t);
|
|
1587
1589
|
const covered = /* @__PURE__ */ new Set();
|
|
1588
1590
|
for (let r = 0; r < t.rows; r++) {
|
|
1589
1591
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -1601,7 +1603,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1601
1603
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1602
1604
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1603
1605
|
const part = blocks[j];
|
|
1604
|
-
const from = part.table ?
|
|
1606
|
+
const from = part.table ? _chunkTMUUDMDHcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1605
1607
|
if (!from || !part.table) continue;
|
|
1606
1608
|
let i = j - 1;
|
|
1607
1609
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
@@ -1614,11 +1616,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1614
1616
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1615
1617
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1616
1618
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1617
|
-
|
|
1618
|
-
const lines =
|
|
1619
|
-
if (_optionalChain([lines, 'optionalAccess', _97 => _97.length]))
|
|
1620
|
-
if (part.pageNumber && part.bbox)
|
|
1621
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _98 => _98.blocks, 'optionalAccess', _99 => _99.length]))
|
|
1619
|
+
_chunkTMUUDMDHcjs.joinCellEdges.call(void 0, cell, add);
|
|
1620
|
+
const lines = _chunkTMUUDMDHcjs.CELL_LINES.get(add);
|
|
1621
|
+
if (_optionalChain([lines, 'optionalAccess', _97 => _97.length])) _chunkTMUUDMDHcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkTMUUDMDHcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1622
|
+
if (part.pageNumber && part.bbox) _chunkTMUUDMDHcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkTMUUDMDHcjs.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])) _chunkTMUUDMDHcjs.EMPTY_PARTS.delete(prev.table);
|
|
1622
1624
|
blocks.splice(j, 1);
|
|
1623
1625
|
if (cell.blocks && at > 0) {
|
|
1624
1626
|
const nextAt = cell.blocks[at];
|
|
@@ -1630,11 +1632,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1630
1632
|
}
|
|
1631
1633
|
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1632
1634
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1633
|
-
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 || !_chunkTMUUDMDHcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1634
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]);
|
|
1635
1637
|
const next = _optionalChain([inner, 'optionalAccess', _107 => _107[0]]);
|
|
1636
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _108 => _108.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
1637
|
-
const px =
|
|
1638
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _108 => _108.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkTMUUDMDHcjs.CLIP_TABLES.has(prev.table) || !_chunkTMUUDMDHcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1639
|
+
const px = _chunkTMUUDMDHcjs.TABLE_COLXS.get(prev.table), nx = _chunkTMUUDMDHcjs.TABLE_COLXS.get(next.table);
|
|
1638
1640
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1639
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)]);
|
|
1640
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;
|
|
@@ -1643,14 +1645,14 @@ function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
|
1643
1645
|
function fillNestedContinuation(blocks, at) {
|
|
1644
1646
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1645
1647
|
const t = _optionalChain([prev, 'optionalAccess', _113 => _113.table]), u = _optionalChain([next, 'optionalAccess', _114 => _114.table]);
|
|
1646
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1647
|
-
const xs =
|
|
1648
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkTMUUDMDHcjs.CLIP_TABLES.has(t) || !_chunkTMUUDMDHcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1649
|
+
const xs = _chunkTMUUDMDHcjs.TABLE_COLXS.get(u);
|
|
1648
1650
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1649
1651
|
const add = _optionalChain([u, 'access', _115 => _115.cells, 'access', _116 => _116[0], 'optionalAccess', _117 => _117[0]]);
|
|
1650
1652
|
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _118 => _118.blocks, 'optionalAccess', _119 => _119.length])) return;
|
|
1651
1653
|
cell.text = add.text;
|
|
1652
1654
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1653
|
-
|
|
1655
|
+
_chunkTMUUDMDHcjs.joinCellEdges.call(void 0, cell, add);
|
|
1654
1656
|
blocks.splice(at, 1);
|
|
1655
1657
|
}
|
|
1656
1658
|
|
|
@@ -1870,15 +1872,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
1870
1872
|
function marginContextBlocks(raw, page, view) {
|
|
1871
1873
|
const [x1, y1, x2, y2] = view;
|
|
1872
1874
|
const width = x2 - x1, height = y2 - y1;
|
|
1873
|
-
const items =
|
|
1875
|
+
const items = _chunkTMUUDMDHcjs.filterHiddenText.call(void 0, _chunkTMUUDMDHcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
1874
1876
|
for (const item of items) {
|
|
1875
1877
|
item.x -= x1;
|
|
1876
1878
|
item.y -= y1;
|
|
1877
1879
|
}
|
|
1878
|
-
return
|
|
1879
|
-
const bbox =
|
|
1880
|
+
return _chunkTMUUDMDHcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
1881
|
+
const bbox = _chunkTMUUDMDHcjs.computeBBox.call(void 0, line, page);
|
|
1880
1882
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
1881
|
-
return [{ type: "paragraph", text:
|
|
1883
|
+
return [{ type: "paragraph", text: _chunkTMUUDMDHcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkTMUUDMDHcjs.dominantStyle.call(void 0, line) }];
|
|
1882
1884
|
});
|
|
1883
1885
|
}
|
|
1884
1886
|
|
|
@@ -1914,7 +1916,7 @@ var WINANSI_REVERSE = {
|
|
|
1914
1916
|
};
|
|
1915
1917
|
function symbolFontTable(fontName) {
|
|
1916
1918
|
if (!fontName) return void 0;
|
|
1917
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
1919
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkT7PN5D4Dcjs.WINGDINGS;
|
|
1918
1920
|
return void 0;
|
|
1919
1921
|
}
|
|
1920
1922
|
function remapSymbolText(text, table) {
|
|
@@ -2973,7 +2975,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
2973
2975
|
if (block.type !== "heading" || !block.text) continue;
|
|
2974
2976
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
2975
2977
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _192 => _192.style, 'optionalAccess', _193 => _193.fontSize]), () => ( 0));
|
|
2976
|
-
const tocEntry = i > 0 &&
|
|
2978
|
+
const tocEntry = i > 0 && _chunkTMUUDMDHcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkTMUUDMDHcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
2977
2979
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
2978
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;
|
|
2979
2981
|
const next = blocks[i + 1];
|
|
@@ -3056,7 +3058,7 @@ function splitSingleCellTables(blocks) {
|
|
|
3056
3058
|
const out = [];
|
|
3057
3059
|
for (const b of blocks) {
|
|
3058
3060
|
const t = b.type === "table" ? b.table : void 0;
|
|
3059
|
-
const title = t &&
|
|
3061
|
+
const title = t && _chunkTMUUDMDHcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3060
3062
|
if (title) {
|
|
3061
3063
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3062
3064
|
continue;
|
|
@@ -3092,7 +3094,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
3092
3094
|
const lines = cell.text.split("\n");
|
|
3093
3095
|
const out = [lines[0]];
|
|
3094
3096
|
for (const line of lines.slice(1)) {
|
|
3095
|
-
if (
|
|
3097
|
+
if (_chunkTMUUDMDHcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
3096
3098
|
else out.push(line);
|
|
3097
3099
|
}
|
|
3098
3100
|
cell.text = out.join("\n");
|
|
@@ -3112,10 +3114,10 @@ function cleanPdfText(text, opts) {
|
|
|
3112
3114
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
3113
3115
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
3114
3116
|
if (line.startsWith("|")) {
|
|
3115
|
-
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) => _chunkTMUUDMDHcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
3116
3118
|
}
|
|
3117
3119
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _275 => _275.exec, 'call', _276 => _276(line), 'optionalAccess', _277 => _277[0]]), () => ( ""));
|
|
3118
|
-
return mark +
|
|
3120
|
+
return mark + _chunkTMUUDMDHcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
3119
3121
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
3120
3122
|
}
|
|
3121
3123
|
function startsWithMarker(line) {
|
|
@@ -3147,7 +3149,7 @@ function mergeKoreanLines(text) {
|
|
|
3147
3149
|
continue;
|
|
3148
3150
|
}
|
|
3149
3151
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
3150
|
-
result[result.length - 1] = prev +
|
|
3152
|
+
result[result.length - 1] = prev + _chunkTMUUDMDHcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
3151
3153
|
} else {
|
|
3152
3154
|
result.push(curr);
|
|
3153
3155
|
}
|
|
@@ -3163,7 +3165,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3163
3165
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3164
3166
|
for (const a of annots) {
|
|
3165
3167
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3166
|
-
const url =
|
|
3168
|
+
const url = _chunkMCUX2Y2Ccjs.sanitizeHref.call(void 0, a.url);
|
|
3167
3169
|
if (!url) continue;
|
|
3168
3170
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3169
3171
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -3215,7 +3217,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3215
3217
|
|
|
3216
3218
|
// src/pdf/formula-ocr.ts
|
|
3217
3219
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3218
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
3220
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-A3I5VAP7.cjs")));
|
|
3219
3221
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3220
3222
|
await ensureFormulaModels((p) => {
|
|
3221
3223
|
if (p.phase === "download" && p.total) {
|
|
@@ -3406,13 +3408,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3406
3408
|
try {
|
|
3407
3409
|
return await Promise.race([
|
|
3408
3410
|
loadingTask.promise.catch((e) => {
|
|
3409
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
3411
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkMCUX2Y2Ccjs.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)");
|
|
3410
3412
|
throw e;
|
|
3411
3413
|
}),
|
|
3412
3414
|
new Promise((_, reject) => {
|
|
3413
3415
|
timer = setTimeout(() => {
|
|
3414
3416
|
loadingTask.destroy();
|
|
3415
|
-
reject(new (0,
|
|
3417
|
+
reject(new (0, _chunkMCUX2Y2Ccjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
3416
3418
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
3417
3419
|
})
|
|
3418
3420
|
]);
|
|
@@ -3422,12 +3424,12 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3422
3424
|
}
|
|
3423
3425
|
async function parsePdfDocument(buffer, options) {
|
|
3424
3426
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _278 => _278.formulaOcr]) ? buffer : null;
|
|
3425
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _279 => _279.ocr]) === void 0 && await
|
|
3427
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _279 => _279.ocr]) === void 0 && await _chunkTMUUDMDHcjs.ocrModelsCached.call(void 0, );
|
|
3426
3428
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _280 => _280.ocr]) || autoOcr ? buffer : null;
|
|
3427
3429
|
const doc = await loadPdfWithTimeout(buffer);
|
|
3428
3430
|
try {
|
|
3429
3431
|
const pageCount = doc.numPages;
|
|
3430
|
-
if (pageCount === 0) throw new (0,
|
|
3432
|
+
if (pageCount === 0) throw new (0, _chunkMCUX2Y2Ccjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
3431
3433
|
const metadata = { pageCount, pageMode: "layout" };
|
|
3432
3434
|
await extractPdfMetadata(doc, metadata);
|
|
3433
3435
|
const blocks = [];
|
|
@@ -3456,7 +3458,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3456
3458
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
3457
3459
|
const carry = {};
|
|
3458
3460
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
3459
|
-
const wrapLexicon = new (0,
|
|
3461
|
+
const wrapLexicon = new (0, _chunkTMUUDMDHcjs.WrapLexicon)();
|
|
3460
3462
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
3461
3463
|
const headerContext = [];
|
|
3462
3464
|
if (pageFilter && _optionalChain([options, 'optionalAccess', _283 => _283.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
@@ -3503,8 +3505,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3503
3505
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3504
3506
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3505
3507
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3506
|
-
const items =
|
|
3507
|
-
const filtered =
|
|
3508
|
+
const items = _chunkTMUUDMDHcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
3509
|
+
const filtered = _chunkTMUUDMDHcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
3508
3510
|
const joined = joinVerticalColumns(filtered.visible);
|
|
3509
3511
|
const visible = dropTabLeaderDots(joined);
|
|
3510
3512
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -3530,7 +3532,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3530
3532
|
} : rawOps;
|
|
3531
3533
|
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _290 => _290(loadedName), 'optionalAccess', _291 => _291.name]));
|
|
3532
3534
|
remapControlGlyphs(visible, differencesOf);
|
|
3533
|
-
await
|
|
3535
|
+
await _chunkTMUUDMDHcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
3534
3536
|
const faces = /* @__PURE__ */ new Map();
|
|
3535
3537
|
for (const it of visible) {
|
|
3536
3538
|
if (!it.fontName) continue;
|
|
@@ -3543,12 +3545,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3543
3545
|
it.fontName = face;
|
|
3544
3546
|
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _293 => _293(face), 'optionalAccess', _294 => _294.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
3545
3547
|
}
|
|
3546
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
3547
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
3548
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkT7PN5D4Dcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
3549
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkT7PN5D4Dcjs.escapeLiteralTags.call(void 0, it.text);
|
|
3548
3550
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
3549
3551
|
const pageArea = pageW * pageH;
|
|
3550
3552
|
if (pageArea > 0) {
|
|
3551
|
-
const imageRegions =
|
|
3553
|
+
const imageRegions = _chunkTMUUDMDHcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
3552
3554
|
let uncovered = 0;
|
|
3553
3555
|
for (const r of imageRegions) {
|
|
3554
3556
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -3574,11 +3576,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3574
3576
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
3575
3577
|
}
|
|
3576
3578
|
const marks = superscriptNoteMarks(visible);
|
|
3577
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
3579
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkTMUUDMDHcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
3578
3580
|
const stamp = marginStamp(visible);
|
|
3579
3581
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
3580
|
-
const rightArrows = _optionalChain([options, 'optionalAccess', _295 => _295.tables]) !== false ? await
|
|
3581
|
-
const pageBlocks = orderTwoUpPage(
|
|
3582
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _295 => _295.tables]) !== false ? await _chunkTMUUDMDHcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
3583
|
+
const pageBlocks = orderTwoUpPage(_chunkTMUUDMDHcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _296 => _296.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
3582
3584
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
3583
3585
|
for (const b of pageBlocks) blocks.push(b);
|
|
3584
3586
|
try {
|
|
@@ -3604,11 +3606,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3604
3606
|
if (_optionalChain([options, 'optionalAccess', _298 => _298.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
3605
3607
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
3606
3608
|
}
|
|
3607
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
3609
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkMCUX2Y2Ccjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
3608
3610
|
parsedPages++;
|
|
3609
3611
|
_optionalChain([options, 'optionalAccess', _299 => _299.onProgress, 'optionalCall', _300 => _300(parsedPages, totalTarget)]);
|
|
3610
3612
|
} catch (pageErr) {
|
|
3611
|
-
if (pageErr instanceof
|
|
3613
|
+
if (pageErr instanceof _chunkMCUX2Y2Ccjs.KordocError) throw pageErr;
|
|
3612
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" });
|
|
3613
3615
|
} finally {
|
|
3614
3616
|
_optionalChain([loadedPage, 'optionalAccess', _301 => _301.cleanup, 'call', _302 => _302()]);
|
|
@@ -3638,11 +3640,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3638
3640
|
}
|
|
3639
3641
|
if (targets.size > 0) {
|
|
3640
3642
|
try {
|
|
3641
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3643
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-OKAHNEJA.cjs")));
|
|
3642
3644
|
const mode = typeof _optionalChain([options, 'optionalAccess', _307 => _307.ocr]) === "function" ? options.ocr : "builtin";
|
|
3643
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])));
|
|
3644
3646
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _312 => _312.onProgress]), _optionalChain([options, 'optionalAccess', _313 => _313.tables]) !== false, vectorPageOps, regionPages);
|
|
3645
|
-
for (const obs of ocrPageBlocks.values())
|
|
3647
|
+
for (const obs of ocrPageBlocks.values()) _chunkT7PN5D4Dcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
3646
3648
|
if (ocrPageBlocks.size > 0) {
|
|
3647
3649
|
const replacePages = /* @__PURE__ */ new Set();
|
|
3648
3650
|
for (const [p, obs] of ocrPageBlocks) {
|
|
@@ -3653,7 +3655,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3653
3655
|
continue;
|
|
3654
3656
|
}
|
|
3655
3657
|
const regions = ocrRegions.get(p);
|
|
3656
|
-
if (!regions ||
|
|
3658
|
+
if (!regions || _chunkTMUUDMDHcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
3657
3659
|
ocrDone.add(p);
|
|
3658
3660
|
if (_optionalChain([pageImageBlocks, 'access', _318 => _318.get, 'call', _319 => _319(p), 'optionalAccess', _320 => _320.length]) === 1) pageImageBlocks.delete(p);
|
|
3659
3661
|
}
|
|
@@ -3706,11 +3708,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3706
3708
|
}
|
|
3707
3709
|
}
|
|
3708
3710
|
if (_optionalChain([options, 'optionalAccess', _321 => _321.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
3709
|
-
const removed =
|
|
3711
|
+
const removed = _chunkTMUUDMDHcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
3712
|
+
const running = _chunkTMUUDMDHcjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
3710
3713
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
3711
3714
|
blocks.splice(removed[ri], 1);
|
|
3712
3715
|
}
|
|
3713
|
-
const
|
|
3716
|
+
const stripped = _chunkTMUUDMDHcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
3717
|
+
if (stripped !== blocks) {
|
|
3718
|
+
blocks.length = 0;
|
|
3719
|
+
blocks.push(...stripped);
|
|
3720
|
+
}
|
|
3721
|
+
const kept = _chunkTMUUDMDHcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
3714
3722
|
if (kept !== blocks) {
|
|
3715
3723
|
blocks.length = 0;
|
|
3716
3724
|
blocks.push(...kept);
|
|
@@ -3719,12 +3727,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3719
3727
|
mergeContinuedCells(blocks, pageHeights);
|
|
3720
3728
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
3721
3729
|
if (_optionalChain([options, 'optionalAccess', _322 => _322.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
3722
|
-
const boxes =
|
|
3730
|
+
const boxes = _chunkTMUUDMDHcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
3723
3731
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
3724
3732
|
}
|
|
3725
3733
|
splitContactTables(blocks);
|
|
3726
|
-
if (!_optionalChain([options, 'optionalAccess', _323 => _323.keepTrailingEmptyCols]))
|
|
3727
|
-
|
|
3734
|
+
if (!_optionalChain([options, 'optionalAccess', _323 => _323.keepTrailingEmptyCols])) _chunkTMUUDMDHcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
3735
|
+
_chunkTMUUDMDHcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
3728
3736
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
3729
3737
|
if (_optionalChain([options, 'optionalAccess', _324 => _324.formulaOcr]) && formulaBuffer) {
|
|
3730
3738
|
try {
|
|
@@ -3736,21 +3744,21 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3736
3744
|
});
|
|
3737
3745
|
}
|
|
3738
3746
|
}
|
|
3739
|
-
const medianFontSize =
|
|
3747
|
+
const medianFontSize = _chunkTMUUDMDHcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
3740
3748
|
if (medianFontSize > 0) {
|
|
3741
|
-
|
|
3742
|
-
}
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3749
|
+
_chunkTMUUDMDHcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
3750
|
+
}
|
|
3751
|
+
_chunkTMUUDMDHcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
3752
|
+
_chunkTMUUDMDHcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
3753
|
+
_chunkTMUUDMDHcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
3754
|
+
_chunkTMUUDMDHcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
3755
|
+
_chunkTMUUDMDHcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
3756
|
+
_chunkTMUUDMDHcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
3757
|
+
_chunkTMUUDMDHcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
3758
|
+
_chunkTMUUDMDHcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
3751
3759
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3752
|
-
|
|
3753
|
-
|
|
3760
|
+
_chunkTMUUDMDHcjs.detectTableCaptions.call(void 0, blocks);
|
|
3761
|
+
_chunkTMUUDMDHcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3754
3762
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3755
3763
|
sanitizeBlockControlChars(blocks);
|
|
3756
3764
|
let outBlocks = splitSingleCellTables(blocks);
|
|
@@ -3772,19 +3780,19 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3772
3780
|
const shown = /* @__PURE__ */ new Map();
|
|
3773
3781
|
const markContent = (bs) => {
|
|
3774
3782
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
3775
|
-
if (
|
|
3776
|
-
const lines =
|
|
3777
|
-
if (lines)
|
|
3783
|
+
if (_chunkTMUUDMDHcjs.IMAGE_CELLS.has(c)) _chunkT7PN5D4Dcjs.CONTENT_CELLS.add(c);
|
|
3784
|
+
const lines = _chunkTMUUDMDHcjs.CELL_LINES.get(c);
|
|
3785
|
+
if (lines) _chunkT7PN5D4Dcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
3778
3786
|
markContent(c.blocks);
|
|
3779
3787
|
}
|
|
3780
3788
|
};
|
|
3781
3789
|
const visual = (bs) => bs.flatMap((b) => {
|
|
3782
3790
|
if (b.type !== "table") return [b];
|
|
3783
|
-
if (!hancom && b.table &&
|
|
3791
|
+
if (!hancom && b.table && _chunkTMUUDMDHcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
3784
3792
|
let v = shown.get(b);
|
|
3785
3793
|
if (!v) {
|
|
3786
3794
|
markContent([b]);
|
|
3787
|
-
shown.set(b, v =
|
|
3795
|
+
shown.set(b, v = _chunkT7PN5D4Dcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _328 => _328.keepTrailingEmptyCols])));
|
|
3788
3796
|
}
|
|
3789
3797
|
return v;
|
|
3790
3798
|
});
|
|
@@ -3793,12 +3801,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3793
3801
|
blocks.length = 0;
|
|
3794
3802
|
for (const b of kept) blocks.push(b);
|
|
3795
3803
|
}
|
|
3796
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
3797
|
-
if (_optionalChain([options, 'optionalAccess', _330 => _330.tableFormat]) === "gfm")
|
|
3804
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkT7PN5D4Dcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _329 => _329.tableFormat]) }), { keepLoneNumbers: true }));
|
|
3805
|
+
if (_optionalChain([options, 'optionalAccess', _330 => _330.tableFormat]) === "gfm") _chunkT7PN5D4Dcjs.assignTableIds.call(void 0, blocks);
|
|
3798
3806
|
let markdown = finishMarkdown(outBlocks);
|
|
3799
3807
|
return {
|
|
3800
3808
|
markdown,
|
|
3801
|
-
pages:
|
|
3809
|
+
pages: _chunk57VNFMMScjs.blocksToPages.call(void 0, splitPageTables(_chunkTMUUDMDHcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
3802
3810
|
blocks,
|
|
3803
3811
|
metadata,
|
|
3804
3812
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3877,5 +3885,5 @@ function marginStamp(items) {
|
|
|
3877
3885
|
|
|
3878
3886
|
|
|
3879
3887
|
|
|
3880
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
3881
|
-
//# sourceMappingURL=parser-
|
|
3888
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkTMUUDMDHcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkTMUUDMDHcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkTMUUDMDHcjs.removeHeaderFooterBlocks;
|
|
3889
|
+
//# sourceMappingURL=parser-VKWUMUML.cjs.map
|