kordoc 4.24.13 → 4.24.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/{-NBCZTPBD.js → -MG25ST6Y.js} +11 -11
- package/dist/{chunk-UVQOPGOA.js → chunk-3LFNTOL7.js} +14 -9
- package/dist/chunk-3LFNTOL7.js.map +1 -0
- package/dist/{chunk-BC4LVU4D.js → chunk-7VNYQHJV.js} +2 -2
- package/dist/{chunk-CKOCIQU6.js → chunk-AM6TECXD.js} +2 -2
- package/dist/{chunk-X2E5QCKO.js → chunk-AULD3QAB.js} +2 -2
- package/dist/{chunk-XGESPSWE.cjs → chunk-BUGXM2H5.cjs} +3 -3
- package/dist/{chunk-XGESPSWE.cjs.map → chunk-BUGXM2H5.cjs.map} +1 -1
- package/dist/{chunk-ZUMOEVMV.js → chunk-DIFJPJGN.js} +3 -3
- package/dist/{chunk-XWWQGSEP.js → chunk-ERYRF3EA.js} +2 -2
- package/dist/{chunk-QAGPSWGH.js → chunk-FGERVDQZ.js} +2 -2
- package/dist/{chunk-ZSCDH3NU.js → chunk-FUC3V2FR.js} +2 -2
- package/dist/{chunk-U2VAABMK.cjs → chunk-GV7ECKOK.cjs} +44 -27
- package/dist/chunk-GV7ECKOK.cjs.map +1 -0
- package/dist/{chunk-2H2VYPM2.cjs → chunk-HVILFVAT.cjs} +2 -2
- package/dist/{chunk-2H2VYPM2.cjs.map → chunk-HVILFVAT.cjs.map} +1 -1
- package/dist/{chunk-OVQWOOS3.js → chunk-J3OJWUON.js} +2 -2
- package/dist/{chunk-QVEAR6IR.js → chunk-LMQT2JFS.js} +22 -5
- package/dist/chunk-LMQT2JFS.js.map +1 -0
- package/dist/{chunk-37MTSMUF.js → chunk-LSFVBS2I.js} +2 -2
- package/dist/{chunk-IQGXY63Y.js → chunk-MACV3MZF.js} +23 -6
- package/dist/chunk-MACV3MZF.js.map +1 -0
- package/dist/{chunk-QW2H2HHS.js → chunk-MIJYCKJA.js} +115 -6
- package/dist/chunk-MIJYCKJA.js.map +1 -0
- package/dist/{chunk-DMPX4KLC.js → chunk-NIPFEMJJ.js} +2 -2
- package/dist/{chunk-WOVJRXIA.js → chunk-NVD24SLL.js} +2 -2
- package/dist/{chunk-A232MW5F.js → chunk-PVAJ4DBW.js} +2 -2
- package/dist/{chunk-BJBPBU5B.js → chunk-SSDHVKLM.js} +2 -2
- package/dist/{chunk-4I2CKMKU.js → chunk-TPZPICDM.js} +3 -3
- package/dist/{chunk-KTXDK5A6.js → chunk-UTLHDVC5.js} +2 -2
- package/dist/{chunk-PUHBCAXI.js → chunk-UUNCLJB7.js} +11 -11
- package/dist/{chunk-W52B6GOE.cjs → chunk-V26UPU2L.cjs} +3 -3
- package/dist/{chunk-W52B6GOE.cjs.map → chunk-V26UPU2L.cjs.map} +1 -1
- package/dist/{chunk-A4CYMI55.js → chunk-VBOFP27O.js} +2 -2
- package/dist/{chunk-FJ3IKKDV.js → chunk-WFOPOJHN.js} +115 -6
- package/dist/chunk-WFOPOJHN.js.map +1 -0
- package/dist/{chunk-VPKZB6Y7.cjs → chunk-ZBHS7KLW.cjs} +6 -6
- package/dist/{chunk-VPKZB6Y7.cjs.map → chunk-ZBHS7KLW.cjs.map} +1 -1
- package/dist/{chunk-WAWREGAC.js → chunk-ZIGWQ3IS.js} +2 -2
- package/dist/{chunk-QZ2H4ZTO.cjs → chunk-ZX66BXB5.cjs} +190 -81
- package/dist/chunk-ZX66BXB5.cjs.map +1 -0
- package/dist/chunks-JGSWNVLF.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-M4FM364X.js → formula-4KFXQSEG.js} +4 -4
- package/dist/{formula-ZKZGV6JV.cjs → formula-N6GWFPHK.cjs} +9 -9
- package/dist/{formula-ZKZGV6JV.cjs.map → formula-N6GWFPHK.cjs.map} +1 -1
- package/dist/{formula-WFL6JRCR.js → formula-WAYIKS54.js} +3 -3
- package/dist/{image-ocr-2V3M3ZEA.cjs → image-ocr-GY7SZAHN.cjs} +17 -17
- package/dist/{image-ocr-2V3M3ZEA.cjs.map → image-ocr-GY7SZAHN.cjs.map} +1 -1
- package/dist/{image-ocr-YJISJPKE.js → image-ocr-P5S2QDKW.js} +6 -6
- package/dist/{image-ocr-47CBNIS5.js → image-ocr-QBCR7ZD6.js} +9 -9
- package/dist/index.cjs +368 -363
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +23 -23
- package/dist/{model-bundle-7W344HDI.js → model-bundle-QAM24SYG.js} +5 -5
- package/dist/{models-TBHMNI7M.js → models-YHC236MP.js} +5 -5
- package/dist/{parse-worker-v2-JUYUEXCY.js → parse-worker-v2-LP7NKQBP.js} +12 -12
- package/dist/{parser-EKQCZLML.js → parser-26YUZU55.js} +12 -12
- package/dist/{parser-RNJ4KSDF.js → parser-DFJZ3CCE.js} +9 -9
- package/dist/{parser-R44KTBZX.cjs → parser-JWU6HYZZ.cjs} +159 -159
- package/dist/{parser-R44KTBZX.cjs.map → parser-JWU6HYZZ.cjs.map} +1 -1
- package/dist/{pdf-ocr-EE5KGFVX.js → pdf-ocr-BO6ACAGL.js} +9 -9
- package/dist/{pdf-ocr-ZAF4P74R.js → pdf-ocr-EEWQFS7P.js} +6 -6
- package/dist/pdf-ocr-Z4PBLB75.cjs +35 -0
- package/dist/{pdf-ocr-74BOCXAT.cjs.map → pdf-ocr-Z4PBLB75.cjs.map} +1 -1
- package/dist/{profile-io-RU3RVIYV.js → profile-io-PQXYWUBL.js} +3 -3
- package/dist/{rasterize-UNCPM26D.js → rasterize-CS7WZUGF.js} +3 -3
- package/dist/{redact-doc-BFE4UZCY.js → redact-doc-PI4JNHV6.js} +11 -11
- package/dist/{render-3DXTLKIA.js → render-M2CIEOF4.js} +7 -7
- package/dist/seal-4755WLFB.js +10 -0
- package/dist/{setup-7POQAKDG.js → setup-HGPUR27M.js} +3 -3
- package/dist/visual-JWWGGTKQ.js +21 -0
- package/dist/{watch-37YCXJWW.js → watch-B5ISBY3N.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-FJ3IKKDV.js.map +0 -1
- package/dist/chunk-IQGXY63Y.js.map +0 -1
- package/dist/chunk-QVEAR6IR.js.map +0 -1
- package/dist/chunk-QW2H2HHS.js.map +0 -1
- package/dist/chunk-QZ2H4ZTO.cjs.map +0 -1
- package/dist/chunk-U2VAABMK.cjs.map +0 -1
- package/dist/chunk-UVQOPGOA.js.map +0 -1
- package/dist/chunks-IXFBIZPW.js +0 -10
- package/dist/pdf-ocr-74BOCXAT.cjs +0 -35
- package/dist/seal-3LBTETDG.js +0 -10
- package/dist/visual-7SVIGIJC.js +0 -21
- /package/dist/{-NBCZTPBD.js.map → -MG25ST6Y.js.map} +0 -0
- /package/dist/{chunk-BC4LVU4D.js.map → chunk-7VNYQHJV.js.map} +0 -0
- /package/dist/{chunk-CKOCIQU6.js.map → chunk-AM6TECXD.js.map} +0 -0
- /package/dist/{chunk-X2E5QCKO.js.map → chunk-AULD3QAB.js.map} +0 -0
- /package/dist/{chunk-ZUMOEVMV.js.map → chunk-DIFJPJGN.js.map} +0 -0
- /package/dist/{chunk-XWWQGSEP.js.map → chunk-ERYRF3EA.js.map} +0 -0
- /package/dist/{chunk-QAGPSWGH.js.map → chunk-FGERVDQZ.js.map} +0 -0
- /package/dist/{chunk-ZSCDH3NU.js.map → chunk-FUC3V2FR.js.map} +0 -0
- /package/dist/{chunk-OVQWOOS3.js.map → chunk-J3OJWUON.js.map} +0 -0
- /package/dist/{chunk-37MTSMUF.js.map → chunk-LSFVBS2I.js.map} +0 -0
- /package/dist/{chunk-DMPX4KLC.js.map → chunk-NIPFEMJJ.js.map} +0 -0
- /package/dist/{chunk-WOVJRXIA.js.map → chunk-NVD24SLL.js.map} +0 -0
- /package/dist/{chunk-A232MW5F.js.map → chunk-PVAJ4DBW.js.map} +0 -0
- /package/dist/{chunk-BJBPBU5B.js.map → chunk-SSDHVKLM.js.map} +0 -0
- /package/dist/{chunk-4I2CKMKU.js.map → chunk-TPZPICDM.js.map} +0 -0
- /package/dist/{chunk-KTXDK5A6.js.map → chunk-UTLHDVC5.js.map} +0 -0
- /package/dist/{chunk-PUHBCAXI.js.map → chunk-UUNCLJB7.js.map} +0 -0
- /package/dist/{chunk-A4CYMI55.js.map → chunk-VBOFP27O.js.map} +0 -0
- /package/dist/{chunk-WAWREGAC.js.map → chunk-ZIGWQ3IS.js.map} +0 -0
- /package/dist/{chunks-IXFBIZPW.js.map → chunks-JGSWNVLF.js.map} +0 -0
- /package/dist/{formula-M4FM364X.js.map → formula-4KFXQSEG.js.map} +0 -0
- /package/dist/{formula-WFL6JRCR.js.map → formula-WAYIKS54.js.map} +0 -0
- /package/dist/{image-ocr-YJISJPKE.js.map → image-ocr-P5S2QDKW.js.map} +0 -0
- /package/dist/{image-ocr-47CBNIS5.js.map → image-ocr-QBCR7ZD6.js.map} +0 -0
- /package/dist/{model-bundle-7W344HDI.js.map → model-bundle-QAM24SYG.js.map} +0 -0
- /package/dist/{models-TBHMNI7M.js.map → models-YHC236MP.js.map} +0 -0
- /package/dist/{parse-worker-v2-JUYUEXCY.js.map → parse-worker-v2-LP7NKQBP.js.map} +0 -0
- /package/dist/{parser-EKQCZLML.js.map → parser-26YUZU55.js.map} +0 -0
- /package/dist/{parser-RNJ4KSDF.js.map → parser-DFJZ3CCE.js.map} +0 -0
- /package/dist/{pdf-ocr-EE5KGFVX.js.map → pdf-ocr-BO6ACAGL.js.map} +0 -0
- /package/dist/{pdf-ocr-ZAF4P74R.js.map → pdf-ocr-EEWQFS7P.js.map} +0 -0
- /package/dist/{profile-io-RU3RVIYV.js.map → profile-io-PQXYWUBL.js.map} +0 -0
- /package/dist/{rasterize-UNCPM26D.js.map → rasterize-CS7WZUGF.js.map} +0 -0
- /package/dist/{redact-doc-BFE4UZCY.js.map → redact-doc-PI4JNHV6.js.map} +0 -0
- /package/dist/{render-3DXTLKIA.js.map → render-M2CIEOF4.js.map} +0 -0
- /package/dist/{seal-3LBTETDG.js.map → seal-4755WLFB.js.map} +0 -0
- /package/dist/{setup-7POQAKDG.js.map → setup-HGPUR27M.js.map} +0 -0
- /package/dist/{visual-7SVIGIJC.js.map → visual-JWWGGTKQ.js.map} +0 -0
- /package/dist/{watch-37YCXJWW.js.map → watch-B5ISBY3N.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 _chunkV26UPU2Lcjs = require('./chunk-V26UPU2L.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 _chunkGV7ECKOKcjs = require('./chunk-GV7ECKOK.cjs');
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
@@ -79,12 +79,12 @@ var _chunkU2VAABMKcjs = require('./chunk-U2VAABMK.cjs');
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
var
|
|
83
|
-
require('./chunk-
|
|
82
|
+
var _chunkZBHS7KLWcjs = require('./chunk-ZBHS7KLW.cjs');
|
|
83
|
+
require('./chunk-BUGXM2H5.cjs');
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
var
|
|
87
|
+
var _chunkHVILFVATcjs = require('./chunk-HVILFVAT.cjs');
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -221,7 +221,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
221
221
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
222
222
|
state.seen.set(hash, filename);
|
|
223
223
|
if (withBytes) {
|
|
224
|
-
const png =
|
|
224
|
+
const png = _chunkV26UPU2Lcjs.encodePng.call(void 0, w, h, rgba);
|
|
225
225
|
state.totalBytes += png.length;
|
|
226
226
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
227
227
|
}
|
|
@@ -617,13 +617,13 @@ function ocrVectorOps(opList, paths) {
|
|
|
617
617
|
|
|
618
618
|
// src/pdf/split-row-pattern.ts
|
|
619
619
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
620
|
-
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !
|
|
620
|
+
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !_chunkGV7ECKOKcjs.IMAGE_CELLS.has(cell);
|
|
621
621
|
var labelsOf = (cell) => {
|
|
622
622
|
const labels = textOf(cell).split("\n").map((s) => s.trim()).filter(Boolean);
|
|
623
623
|
return labels.length && labels.every((s) => /^\p{L}[\p{L}\p{N} ]{0,15}[::]$/u.test(s)) ? labels.map((s) => s.replace(/\s+/g, "").replace(/:/g, ":")) : void 0;
|
|
624
624
|
};
|
|
625
625
|
var alignedLabels = (label, value, count) => {
|
|
626
|
-
const L =
|
|
626
|
+
const L = _chunkGV7ECKOKcjs.CELL_LINES.get(label), V = _chunkGV7ECKOKcjs.CELL_LINES.get(value);
|
|
627
627
|
let next = 0;
|
|
628
628
|
return !!L && !!V && L.length === count && V.length >= count && Math.abs(L[0].y - V[0].y) <= 1 && L.every((l) => {
|
|
629
629
|
while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
|
|
@@ -631,7 +631,7 @@ var alignedLabels = (label, value, count) => {
|
|
|
631
631
|
});
|
|
632
632
|
};
|
|
633
633
|
function partialAlignedLabelCells(table, owner, first) {
|
|
634
|
-
const pageOf = (a) => _nullishCoalesce(
|
|
634
|
+
const pageOf = (a) => _nullishCoalesce(_chunkZBHS7KLWcjs.CELL_PAGES.get(_nullishCoalesce(a.cell, () => ( table.cells[a.r][a.c]))), () => ( (a.r < first ? -1 : -2)));
|
|
635
635
|
const pairs = [];
|
|
636
636
|
let carried = false;
|
|
637
637
|
for (let c = 0; c < table.cols; ) {
|
|
@@ -654,10 +654,10 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
654
654
|
const keyed = pairs.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
|
|
655
655
|
if (keyed.length !== 1) return;
|
|
656
656
|
const label = keyed[0], value = pairs.find((p) => p.c === label.c + label.cs), context = pairs.find((p) => p.c + p.cs === label.c);
|
|
657
|
-
if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([
|
|
657
|
+
if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([_chunkZBHS7KLWcjs.CELL_EDGES, 'access', _21 => _21.get, 'call', _22 => _22(context.upper), 'optionalAccess', _23 => _23.b]) || !_optionalChain([_chunkZBHS7KLWcjs.CELL_EDGES, 'access', _24 => _24.get, 'call', _25 => _25(context.lower), 'optionalAccess', _26 => _26.t])) return;
|
|
658
658
|
const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
|
|
659
659
|
if (D.length < 2 || sequence.length < 3 || new Set(sequence).size !== sequence.length || !alignedLabels(label.upper, value.upper, U.length)) return;
|
|
660
|
-
const L =
|
|
660
|
+
const L = _chunkGV7ECKOKcjs.CELL_LINES.get(label.lower), V = _chunkGV7ECKOKcjs.CELL_LINES.get(value.lower);
|
|
661
661
|
if (!L || !V || L.length !== D.length) return;
|
|
662
662
|
let next = V.findIndex((v) => Math.abs(v.y - L[0].y) <= 1);
|
|
663
663
|
if (next <= 0 || !V.slice(0, next).every((v) => v.y > L[0].y + 1) || !L.every((l) => {
|
|
@@ -677,14 +677,14 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
677
677
|
continue;
|
|
678
678
|
}
|
|
679
679
|
if (list.length < 3 || new Set(list).size !== list.length) continue;
|
|
680
|
-
const visible = _nullishCoalesce(_optionalChain([
|
|
680
|
+
const visible = _nullishCoalesce(_optionalChain([_chunkGV7ECKOKcjs.CELL_LINES, 'access', _31 => _31.get, 'call', _32 => _32(lc), 'optionalAccess', _33 => _33.length]), () => ( 0)), values = _chunkGV7ECKOKcjs.CELL_LINES.get(vc);
|
|
681
681
|
if (visible < 3 || visible > list.length || !values || !alignedLabels(lc, vc, visible)) continue;
|
|
682
682
|
const top = Math.max(...values.map((v2) => v2.y)), bottom = Math.min(...values.map((v2) => v2.y));
|
|
683
683
|
const contexts = [];
|
|
684
684
|
for (let rr = r; rr < r + l.rs && rr < table.rows; rr++) {
|
|
685
685
|
const a = _optionalChain([owner, 'access', _34 => _34[rr], 'optionalAccess', _35 => _35[context.c]]), cell = a ? table.cells[a.r][a.c] : void 0;
|
|
686
686
|
if (!a || a.r !== rr || a.c !== context.c || a.cs !== context.cs || a.rs !== 1 || !cell || !plain(cell) || !textOf(cell) || pageOf(a) !== pageOf(l)) break;
|
|
687
|
-
const lines =
|
|
687
|
+
const lines = _chunkGV7ECKOKcjs.CELL_LINES.get(cell);
|
|
688
688
|
if (!_optionalChain([lines, 'optionalAccess', _36 => _36.length]) || lines.some((line) => line.y > top + 1 || line.y < bottom - 1)) break;
|
|
689
689
|
contexts.push(textOf(cell).replace(/\s+/g, ""));
|
|
690
690
|
}
|
|
@@ -986,7 +986,7 @@ function rowStarts(t) {
|
|
|
986
986
|
}
|
|
987
987
|
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));
|
|
988
988
|
function cellPage(cell) {
|
|
989
|
-
const p =
|
|
989
|
+
const p = _chunkZBHS7KLWcjs.CELL_PAGES.get(cell);
|
|
990
990
|
if (p !== void 0 || !_optionalChain([cell, 'access', _103 => _103.blocks, 'optionalAccess', _104 => _104.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
991
991
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
992
992
|
}
|
|
@@ -1015,7 +1015,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1015
1015
|
rows.forEach((starts, r) => {
|
|
1016
1016
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
1017
1017
|
for (const { cell } of starts) {
|
|
1018
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
1018
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkZBHS7KLWcjs.CELL_PAGES.set(cell, page2);
|
|
1019
1019
|
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _107 => _107.find, 'call', _108 => _108((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
|
|
1020
1020
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
1021
1021
|
}
|
|
@@ -1075,8 +1075,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1075
1075
|
if (!splits.length) continue;
|
|
1076
1076
|
const clone = (cell, patch) => {
|
|
1077
1077
|
const out = { ...cell, ...patch };
|
|
1078
|
-
const p =
|
|
1079
|
-
if (p !== void 0)
|
|
1078
|
+
const p = _chunkZBHS7KLWcjs.CELL_PAGES.get(cell);
|
|
1079
|
+
if (p !== void 0) _chunkZBHS7KLWcjs.CELL_PAGES.set(out, p);
|
|
1080
1080
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
1081
1081
|
return out;
|
|
1082
1082
|
};
|
|
@@ -1087,7 +1087,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1087
1087
|
for (const { cell, c, split } of splits) {
|
|
1088
1088
|
cells[r][c] = clone(cell, { ...split.head, rowSpan: cut - r });
|
|
1089
1089
|
const tail = { ...cell, ...split.tail, rowSpan: r + cell.rowSpan - cut };
|
|
1090
|
-
|
|
1090
|
+
_chunkZBHS7KLWcjs.CELL_PAGES.set(tail, split.page);
|
|
1091
1091
|
setSplits(tail, split.rest);
|
|
1092
1092
|
cells[cut][c] = tail;
|
|
1093
1093
|
}
|
|
@@ -1097,7 +1097,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1097
1097
|
for (const { cell, c, split } of splits) {
|
|
1098
1098
|
cells[r][c] = clone(cell, split.head);
|
|
1099
1099
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
1100
|
-
|
|
1100
|
+
_chunkZBHS7KLWcjs.CELL_PAGES.set(tail, split.page);
|
|
1101
1101
|
setSplits(tail, split.rest);
|
|
1102
1102
|
row[c] = tail;
|
|
1103
1103
|
}
|
|
@@ -1188,7 +1188,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1188
1188
|
if (cols < 1) return null;
|
|
1189
1189
|
const pa = anchorsOf(prev), ca = anchorsOf(curr);
|
|
1190
1190
|
const cutOpen = (() => {
|
|
1191
|
-
const u =
|
|
1191
|
+
const u = _chunkGV7ECKOKcjs.ROW_RULES.get(prev), d = _chunkGV7ECKOKcjs.ROW_RULES.get(curr);
|
|
1192
1192
|
return !!u && !!d && !u.bottom && !d.top;
|
|
1193
1193
|
})();
|
|
1194
1194
|
let skip = 0, head = 0;
|
|
@@ -1220,19 +1220,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1220
1220
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
1221
1221
|
}
|
|
1222
1222
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
1223
|
-
const lines =
|
|
1224
|
-
if (lines)
|
|
1225
|
-
if (
|
|
1226
|
-
const edges =
|
|
1223
|
+
const lines = _chunkGV7ECKOKcjs.CELL_LINES.get(a.cell);
|
|
1224
|
+
if (lines) _chunkGV7ECKOKcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
1225
|
+
if (_chunkGV7ECKOKcjs.IMAGE_CELLS.has(a.cell)) _chunkGV7ECKOKcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
1226
|
+
const edges = _chunkZBHS7KLWcjs.CELL_EDGES.get(a.cell);
|
|
1227
1227
|
if (edges) {
|
|
1228
|
-
|
|
1228
|
+
_chunkZBHS7KLWcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
1229
1229
|
edged = true;
|
|
1230
1230
|
}
|
|
1231
1231
|
return true;
|
|
1232
1232
|
};
|
|
1233
|
-
for (const a of pa) if (!
|
|
1233
|
+
for (const a of pa) if (!_chunkGV7ECKOKcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
1234
1234
|
for (const a of ca) {
|
|
1235
|
-
if (a.r < skip ||
|
|
1235
|
+
if (a.r < skip || _chunkGV7ECKOKcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
1236
1236
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
1237
1237
|
}
|
|
1238
1238
|
const first = prev.rows;
|
|
@@ -1256,9 +1256,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1256
1256
|
const grown = { ...above, rs: newRs };
|
|
1257
1257
|
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;
|
|
1258
1258
|
}
|
|
1259
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1259
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkGV7ECKOKcjs.FILLER_CELLS.add(grid[r][c]);
|
|
1260
1260
|
if (edged) {
|
|
1261
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1261
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkZBHS7KLWcjs.CELL_EDGES.set(grid[r][c], _chunkGV7ECKOKcjs.NO_EDGES);
|
|
1262
1262
|
}
|
|
1263
1263
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1264
1264
|
let r = prev.rows;
|
|
@@ -1267,7 +1267,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1267
1267
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1268
1268
|
}
|
|
1269
1269
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1270
|
-
const pr =
|
|
1270
|
+
const pr = _chunkGV7ECKOKcjs.ROW_RULES.get(prev), cr = _chunkGV7ECKOKcjs.ROW_RULES.get(curr);
|
|
1271
1271
|
const shifted = dx !== 0;
|
|
1272
1272
|
const cut = {
|
|
1273
1273
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1275,13 +1275,13 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1275
1275
|
list: !shifted ? "any" : skip > 0 && ca.filter((a) => a.r < skip && a.cell.text.trim()).length < 2 ? "none" : "multi"
|
|
1276
1276
|
};
|
|
1277
1277
|
let partial = !skip && cols === prev.cols && cols === curr.cols && cut.ruled && prevBottom !== void 0 ? partialAlignedLabelCells(table, owner, first) : void 0;
|
|
1278
|
-
if (partial && (continuesAcross(partial.context.upper, partial.context.lower, U[partial.context.c], U[partial.context.c + partial.context.cs]) || clauseContinues(partial.context.upper, partial.context.lower) || quantityContinues(partial.context.upper, partial.context.lower) || !continuesAcross(partial.value.upper, partial.value.lower, U[partial.value.c], U[partial.value.c + partial.value.cs]) ||
|
|
1278
|
+
if (partial && (continuesAcross(partial.context.upper, partial.context.lower, U[partial.context.c], U[partial.context.c + partial.context.cs]) || clauseContinues(partial.context.upper, partial.context.lower) || quantityContinues(partial.context.upper, partial.context.lower) || !continuesAcross(partial.value.upper, partial.value.lower, U[partial.value.c], U[partial.value.c + partial.value.cs]) || _chunkGV7ECKOKcjs.startsNewItem.call(void 0, partial.value.upper.text, partial.value.lower.text))) partial = void 0;
|
|
1279
1279
|
const selected = partial ? /* @__PURE__ */ new Set([partial.label.c, partial.value.c]) : void 0;
|
|
1280
1280
|
let split = !selected && rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
|
|
1281
1281
|
if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U, selected) && !selected) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
|
|
1282
1282
|
if (pr && cr) {
|
|
1283
1283
|
const cutRuled = pr.bottom || cr.top;
|
|
1284
|
-
|
|
1284
|
+
_chunkGV7ECKOKcjs.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) });
|
|
1285
1285
|
}
|
|
1286
1286
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1287
1287
|
}
|
|
@@ -1343,18 +1343,18 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1343
1343
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1344
1344
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1345
1345
|
if (selected && !selected.has(u.c)) continue;
|
|
1346
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1347
|
-
const openSeam = hasContent(a) && hasContent(b) &&
|
|
1346
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkGV7ECKOKcjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
1347
|
+
const openSeam = hasContent(a) && hasContent(b) && _chunkGV7ECKOKcjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
|
|
1348
1348
|
if (!r || r === first) return false;
|
|
1349
1349
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1350
1350
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1351
|
-
const ue =
|
|
1351
|
+
const ue = _chunkZBHS7KLWcjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkZBHS7KLWcjs.CELL_EDGES.get(table.cells[down.r][down.c]);
|
|
1352
1352
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1353
1353
|
});
|
|
1354
1354
|
if (!selected && !openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1355
1355
|
if (!straddles && !midWord) continue;
|
|
1356
1356
|
if (u.r >= last && d.rs < 2) continue;
|
|
1357
|
-
const U =
|
|
1357
|
+
const U = _chunkGV7ECKOKcjs.CELL_LINES.get(a);
|
|
1358
1358
|
if (!_optionalChain([U, 'optionalAccess', _134 => _134.length]) || !hasContent(b)) continue;
|
|
1359
1359
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1360
1360
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -1372,7 +1372,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1372
1372
|
return merged;
|
|
1373
1373
|
}
|
|
1374
1374
|
function longLastLine(c) {
|
|
1375
|
-
const L =
|
|
1375
|
+
const L = _chunkGV7ECKOKcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _135 => _135[L.length - 1]]);
|
|
1376
1376
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1377
1377
|
}
|
|
1378
1378
|
function filledToBottom(U, bottom) {
|
|
@@ -1405,7 +1405,7 @@ function nextItemHead(prev, next) {
|
|
|
1405
1405
|
return false;
|
|
1406
1406
|
}
|
|
1407
1407
|
function continuesAcross(u, d, x1, x2) {
|
|
1408
|
-
const U =
|
|
1408
|
+
const U = _chunkGV7ECKOKcjs.CELL_LINES.get(u), D = _chunkGV7ECKOKcjs.CELL_LINES.get(d);
|
|
1409
1409
|
if (!_optionalChain([U, 'optionalAccess', _136 => _136.length]) || !_optionalChain([D, 'optionalAccess', _137 => _137.length])) return false;
|
|
1410
1410
|
const last = U[U.length - 1];
|
|
1411
1411
|
const fs = last.h || 10;
|
|
@@ -1423,7 +1423,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1423
1423
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1424
1424
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1425
1425
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1426
|
-
const newItem =
|
|
1426
|
+
const newItem = _chunkGV7ECKOKcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1427
1427
|
const all = D.length ? U.concat(D) : U;
|
|
1428
1428
|
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));
|
|
1429
1429
|
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;
|
|
@@ -1440,10 +1440,10 @@ function outlineContinues(u, d) {
|
|
|
1440
1440
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1441
1441
|
}
|
|
1442
1442
|
function lineEnded(c, x1, x2, next) {
|
|
1443
|
-
const L =
|
|
1443
|
+
const L = _chunkGV7ECKOKcjs.CELL_LINES.get(c);
|
|
1444
1444
|
if (!L || L.length !== 1) return false;
|
|
1445
1445
|
const l = L[0], h = l.h || 10;
|
|
1446
|
-
const d0 = next ? _optionalChain([
|
|
1446
|
+
const d0 = next ? _optionalChain([_chunkGV7ECKOKcjs.CELL_LINES, 'access', _138 => _138.get, 'call', _139 => _139(next), 'optionalAccess', _140 => _140[0]]) : void 0;
|
|
1447
1447
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1448
1448
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _141 => _141.text]), () => ( "")))) * h;
|
|
1449
1449
|
}
|
|
@@ -1454,15 +1454,15 @@ function firstWordUnits(text) {
|
|
|
1454
1454
|
return units;
|
|
1455
1455
|
}
|
|
1456
1456
|
function appendCell(a, b) {
|
|
1457
|
-
if (
|
|
1457
|
+
if (_chunkGV7ECKOKcjs.IMAGE_CELLS.has(b)) _chunkGV7ECKOKcjs.IMAGE_CELLS.add(a);
|
|
1458
1458
|
if (_optionalChain([a, 'access', _142 => _142.blocks, 'optionalAccess', _143 => _143.length]) || _optionalChain([b, 'access', _144 => _144.blocks, 'optionalAccess', _145 => _145.length])) {
|
|
1459
1459
|
const asBlocks = (c) => _optionalChain([c, 'access', _146 => _146.blocks, 'optionalAccess', _147 => _147.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
|
|
1460
1460
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1461
1461
|
}
|
|
1462
1462
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1463
|
-
|
|
1463
|
+
_chunkGV7ECKOKcjs.joinCellEdges.call(void 0, a, b);
|
|
1464
1464
|
}
|
|
1465
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _148 => _148.blocks, 'optionalAccess', _149 => _149.length]) ||
|
|
1465
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _148 => _148.blocks, 'optionalAccess', _149 => _149.length]) || _chunkGV7ECKOKcjs.IMAGE_CELLS.has(cell);
|
|
1466
1466
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1467
1467
|
var batchim = (ch) => {
|
|
1468
1468
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1470,7 +1470,7 @@ var batchim = (ch) => {
|
|
|
1470
1470
|
};
|
|
1471
1471
|
function clauseContinues(u, d) {
|
|
1472
1472
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1473
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1473
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkGV7ECKOKcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1474
1474
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1475
1475
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1476
1476
|
}
|
|
@@ -1478,8 +1478,8 @@ function quantityContinues(u, d) {
|
|
|
1478
1478
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1479
1479
|
}
|
|
1480
1480
|
function wordOverflows(u, d, x1, x2) {
|
|
1481
|
-
const U =
|
|
1482
|
-
if (!_optionalChain([U, 'optionalAccess', _150 => _150.length]) ||
|
|
1481
|
+
const U = _chunkGV7ECKOKcjs.CELL_LINES.get(u);
|
|
1482
|
+
if (!_optionalChain([U, 'optionalAccess', _150 => _150.length]) || _chunkGV7ECKOKcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1483
1483
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1484
1484
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1485
1485
|
}
|
|
@@ -1537,7 +1537,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1537
1537
|
if (!carriedSplit) {
|
|
1538
1538
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1539
1539
|
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;
|
|
1540
|
-
const oneLine = (c) => _optionalChain([
|
|
1540
|
+
const oneLine = (c) => _optionalChain([_chunkGV7ECKOKcjs.CELL_LINES, 'access', _152 => _152.get, 'call', _153 => _153(c), 'optionalAccess', _154 => _154.length]) === 1;
|
|
1541
1541
|
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;
|
|
1542
1542
|
if (cut.ruled && pairs.some(([u, d]) => u.rs >= 2 && hasContent(u.cell) && hasContent(d.cell) && oneLine(cell(u)) && oneLine(cell(d)) && norm(cell(u)) !== norm(cell(d)))) return false;
|
|
1543
1543
|
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));
|
|
@@ -1630,19 +1630,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1630
1630
|
placeJoined(blocks, i, j, joined);
|
|
1631
1631
|
continue;
|
|
1632
1632
|
}
|
|
1633
|
-
if (
|
|
1633
|
+
if (_chunkGV7ECKOKcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1634
1634
|
blocks.splice(j, 1);
|
|
1635
1635
|
i++;
|
|
1636
1636
|
continue;
|
|
1637
1637
|
}
|
|
1638
1638
|
if (joined === null) continue;
|
|
1639
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1639
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkGV7ECKOKcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1640
1640
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1641
1641
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1642
1642
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1643
1643
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1644
|
-
const px =
|
|
1645
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1644
|
+
const px = _chunkGV7ECKOKcjs.TABLE_COLXS.get(prev.table), cx = _chunkGV7ECKOKcjs.TABLE_COLXS.get(curr.table);
|
|
1645
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkGV7ECKOKcjs.CLIP_TABLES.has(prev.table) && !_chunkGV7ECKOKcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1646
1646
|
if (!px !== !cx) continue;
|
|
1647
1647
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1648
1648
|
let currCells = curr.table.cells;
|
|
@@ -1654,16 +1654,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1654
1654
|
blocks.splice(j, 1);
|
|
1655
1655
|
continue;
|
|
1656
1656
|
}
|
|
1657
|
-
if (px && cx && !
|
|
1657
|
+
if (px && cx && !_chunkGV7ECKOKcjs.CLIP_TABLES.has(prev.table) && !_chunkGV7ECKOKcjs.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 && _chunkGV7ECKOKcjs.CELL_LINES.has(c))) {
|
|
1658
1658
|
const dx = px[0] - cx[0];
|
|
1659
1659
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1660
1660
|
if (_optionalChain([part, 'optionalAccess', _175 => _175.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1661
1661
|
const last = prev.table.rows - 1;
|
|
1662
1662
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1663
|
-
const U =
|
|
1664
|
-
|
|
1663
|
+
const U = _chunkGV7ECKOKcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkGV7ECKOKcjs.CELL_LINES.get(currCells[0][c]);
|
|
1664
|
+
_chunkGV7ECKOKcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1665
1665
|
}
|
|
1666
|
-
|
|
1666
|
+
_chunkGV7ECKOKcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1667
1667
|
placeJoined(blocks, i, j, part.table);
|
|
1668
1668
|
continue;
|
|
1669
1669
|
}
|
|
@@ -1676,20 +1676,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1676
1676
|
caption: prev.table.caption,
|
|
1677
1677
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1678
1678
|
};
|
|
1679
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1680
|
-
if (
|
|
1679
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkGV7ECKOKcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1680
|
+
if (_chunkGV7ECKOKcjs.CLIP_TABLES.has(prev.table) || _chunkGV7ECKOKcjs.CLIP_TABLES.has(curr.table)) _chunkGV7ECKOKcjs.CLIP_TABLES.add(merged);
|
|
1681
1681
|
placeJoined(blocks, i, j, merged);
|
|
1682
1682
|
}
|
|
1683
1683
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1684
1684
|
const t = blocks[i].table;
|
|
1685
|
-
if (blocks[i].type === "table" && t &&
|
|
1685
|
+
if (blocks[i].type === "table" && t && _chunkGV7ECKOKcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1686
1686
|
}
|
|
1687
1687
|
}
|
|
1688
1688
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1689
1689
|
if (!pageHeights) return;
|
|
1690
1690
|
for (let i = 0; i < blocks.length; i++) {
|
|
1691
1691
|
const L = blocks[i];
|
|
1692
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1692
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkGV7ECKOKcjs.CLIP_TABLES.has(L.table) || _chunkGV7ECKOKcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1693
1693
|
const ph = pageHeights.get(L.pageNumber);
|
|
1694
1694
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1695
1695
|
let s0 = i, s1 = i;
|
|
@@ -1718,8 +1718,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1718
1718
|
}
|
|
1719
1719
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1720
1720
|
const pt = prev.table, ct = curr.table;
|
|
1721
|
-
if (!
|
|
1722
|
-
const px =
|
|
1721
|
+
if (!_chunkGV7ECKOKcjs.CLIP_TABLES.has(pt) || !_chunkGV7ECKOKcjs.CLIP_TABLES.has(ct)) return null;
|
|
1722
|
+
const px = _chunkGV7ECKOKcjs.TABLE_COLXS.get(pt), cx = _chunkGV7ECKOKcjs.TABLE_COLXS.get(ct);
|
|
1723
1723
|
if (!px || !cx) return null;
|
|
1724
1724
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1725
1725
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -1735,15 +1735,15 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1735
1735
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1736
1736
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1737
1737
|
};
|
|
1738
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1738
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkGV7ECKOKcjs.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);
|
|
1739
1739
|
}
|
|
1740
1740
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _180 => _180.bbox, 'optionalAccess', _181 => _181.y]), lex);
|
|
1741
1741
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1742
|
-
|
|
1743
|
-
const ys =
|
|
1744
|
-
if (ys)
|
|
1745
|
-
|
|
1746
|
-
|
|
1742
|
+
_chunkGV7ECKOKcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1743
|
+
const ys = _chunkGV7ECKOKcjs.TABLE_ROWYS.get(pt);
|
|
1744
|
+
if (ys) _chunkGV7ECKOKcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1745
|
+
_chunkGV7ECKOKcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkGV7ECKOKcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1746
|
+
_chunkGV7ECKOKcjs.CLIP_TABLES.add(res.table);
|
|
1747
1747
|
return res.table;
|
|
1748
1748
|
}
|
|
1749
1749
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
@@ -1767,12 +1767,12 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
1767
1767
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1768
1768
|
}
|
|
1769
1769
|
function pushedLead(prev, curr) {
|
|
1770
|
-
if (!
|
|
1770
|
+
if (!_chunkGV7ECKOKcjs.CLIP_TABLES.has(prev.table) || !_chunkGV7ECKOKcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1771
1771
|
const lead = leadRows(curr.table);
|
|
1772
1772
|
return lead.image && lead.height > prev.bbox.y;
|
|
1773
1773
|
}
|
|
1774
1774
|
function leadRows(t) {
|
|
1775
|
-
const ys =
|
|
1775
|
+
const ys = _chunkGV7ECKOKcjs.TABLE_ROWYS.get(t);
|
|
1776
1776
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1777
1777
|
const anchors = anchorsOf(t);
|
|
1778
1778
|
let end = 1, image = false;
|
|
@@ -1780,17 +1780,17 @@ function leadRows(t) {
|
|
|
1780
1780
|
for (const a of anchors) {
|
|
1781
1781
|
if (a.r !== r) continue;
|
|
1782
1782
|
end = Math.max(end, r + a.rs);
|
|
1783
|
-
if (
|
|
1783
|
+
if (_chunkGV7ECKOKcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1784
1784
|
}
|
|
1785
1785
|
}
|
|
1786
1786
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1787
1787
|
}
|
|
1788
1788
|
function tailOf(b) {
|
|
1789
|
-
const t = b.table &&
|
|
1789
|
+
const t = b.table && _chunkGV7ECKOKcjs.TABLE_TAIL.get(b.table);
|
|
1790
1790
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1791
1791
|
}
|
|
1792
1792
|
function firstRowSig(t) {
|
|
1793
|
-
const x =
|
|
1793
|
+
const x = _chunkGV7ECKOKcjs.TABLE_COLXS.get(t);
|
|
1794
1794
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1795
1795
|
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, "") }));
|
|
1796
1796
|
}
|
|
@@ -1843,7 +1843,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1843
1843
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1844
1844
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1845
1845
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1846
|
-
const px =
|
|
1846
|
+
const px = _chunkGV7ECKOKcjs.TABLE_COLXS.get(pb.table), cx = _chunkGV7ECKOKcjs.TABLE_COLXS.get(cur.table);
|
|
1847
1847
|
if (!px || !cx) break;
|
|
1848
1848
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1849
1849
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1914,7 +1914,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1914
1914
|
var COL_MATCH_TOL = 0.5;
|
|
1915
1915
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1916
1916
|
function lastRowCell(t, x1, x2) {
|
|
1917
|
-
const xs =
|
|
1917
|
+
const xs = _chunkGV7ECKOKcjs.TABLE_COLXS.get(t);
|
|
1918
1918
|
const covered = /* @__PURE__ */ new Set();
|
|
1919
1919
|
for (let r = 0; r < t.rows; r++) {
|
|
1920
1920
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -1932,7 +1932,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1932
1932
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1933
1933
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1934
1934
|
const part = blocks[j];
|
|
1935
|
-
const from = part.table ?
|
|
1935
|
+
const from = part.table ? _chunkGV7ECKOKcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1936
1936
|
if (!from || !part.table) {
|
|
1937
1937
|
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
1938
1938
|
continue;
|
|
@@ -1948,12 +1948,12 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1948
1948
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1949
1949
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1950
1950
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1951
|
-
if (
|
|
1952
|
-
|
|
1953
|
-
const lines =
|
|
1954
|
-
if (_optionalChain([lines, 'optionalAccess', _205 => _205.length]))
|
|
1955
|
-
if (part.pageNumber && part.bbox)
|
|
1956
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _206 => _206.blocks, 'optionalAccess', _207 => _207.length]) ||
|
|
1951
|
+
if (_chunkGV7ECKOKcjs.IMAGE_CELLS.has(add)) _chunkGV7ECKOKcjs.IMAGE_CELLS.add(cell);
|
|
1952
|
+
_chunkGV7ECKOKcjs.joinCellEdges.call(void 0, cell, add);
|
|
1953
|
+
const lines = _chunkGV7ECKOKcjs.CELL_LINES.get(add);
|
|
1954
|
+
if (_optionalChain([lines, 'optionalAccess', _205 => _205.length])) _chunkGV7ECKOKcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkGV7ECKOKcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1955
|
+
if (part.pageNumber && part.bbox) _chunkGV7ECKOKcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkGV7ECKOKcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1956
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _206 => _206.blocks, 'optionalAccess', _207 => _207.length]) || _chunkGV7ECKOKcjs.IMAGE_CELLS.has(cell)) _chunkGV7ECKOKcjs.EMPTY_PARTS.delete(prev.table);
|
|
1957
1957
|
blocks.splice(j, 1);
|
|
1958
1958
|
if (cell.blocks && at > 0) {
|
|
1959
1959
|
const nextAt = cell.blocks[at];
|
|
@@ -1965,11 +1965,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1965
1965
|
}
|
|
1966
1966
|
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
1967
1967
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1968
|
-
if (!_optionalChain([prev, 'optionalAccess', _208 => _208.table]) || !_optionalChain([frame, 'optionalAccess', _209 => _209.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !
|
|
1968
|
+
if (!_optionalChain([prev, 'optionalAccess', _208 => _208.table]) || !_optionalChain([frame, 'optionalAccess', _209 => _209.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkGV7ECKOKcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1969
1969
|
const inner = _optionalChain([frame, 'access', _210 => _210.table, 'access', _211 => _211.cells, 'access', _212 => _212[0], 'optionalAccess', _213 => _213[0], 'optionalAccess', _214 => _214.blocks]);
|
|
1970
1970
|
const next = _optionalChain([inner, 'optionalAccess', _215 => _215[0]]);
|
|
1971
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _216 => _216.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
1972
|
-
const px =
|
|
1971
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _216 => _216.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkGV7ECKOKcjs.CLIP_TABLES.has(prev.table) || !_chunkGV7ECKOKcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1972
|
+
const px = _chunkGV7ECKOKcjs.TABLE_COLXS.get(prev.table), nx = _chunkGV7ECKOKcjs.TABLE_COLXS.get(next.table);
|
|
1973
1973
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1974
1974
|
const ph = _optionalChain([pageHeights, 'optionalAccess', _217 => _217.get, 'call', _218 => _218(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _219 => _219.get, 'call', _220 => _220(next.pageNumber)]);
|
|
1975
1975
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
@@ -1979,15 +1979,15 @@ function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
|
1979
1979
|
function fillNestedContinuation(blocks, at) {
|
|
1980
1980
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1981
1981
|
const t = _optionalChain([prev, 'optionalAccess', _223 => _223.table]), u = _optionalChain([next, 'optionalAccess', _224 => _224.table]);
|
|
1982
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1983
|
-
const xs =
|
|
1982
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkGV7ECKOKcjs.CLIP_TABLES.has(t) || !_chunkGV7ECKOKcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1983
|
+
const xs = _chunkGV7ECKOKcjs.TABLE_COLXS.get(u);
|
|
1984
1984
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1985
1985
|
const add = _optionalChain([u, 'access', _225 => _225.cells, 'access', _226 => _226[0], 'optionalAccess', _227 => _227[0]]);
|
|
1986
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _228 => _228.blocks, 'optionalAccess', _229 => _229.length]) ||
|
|
1986
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _228 => _228.blocks, 'optionalAccess', _229 => _229.length]) || _chunkGV7ECKOKcjs.IMAGE_CELLS.has(cell)) return;
|
|
1987
1987
|
cell.text = add.text;
|
|
1988
1988
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1989
|
-
if (
|
|
1990
|
-
|
|
1989
|
+
if (_chunkGV7ECKOKcjs.IMAGE_CELLS.has(add)) _chunkGV7ECKOKcjs.IMAGE_CELLS.add(cell);
|
|
1990
|
+
_chunkGV7ECKOKcjs.joinCellEdges.call(void 0, cell, add);
|
|
1991
1991
|
blocks.splice(at, 1);
|
|
1992
1992
|
}
|
|
1993
1993
|
|
|
@@ -2587,12 +2587,12 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
2587
2587
|
}
|
|
2588
2588
|
}
|
|
2589
2589
|
for (const q of queues.values()) for (let k = 0; k < q.length; k++) {
|
|
2590
|
-
const pair = k + 1 < q.length ?
|
|
2590
|
+
const pair = k + 1 < q.length ? _chunkZBHS7KLWcjs.pairedNumber.call(void 0, q[k], q[k + 1]) : void 0;
|
|
2591
2591
|
if (pair !== void 0) {
|
|
2592
2592
|
q[k] = pair;
|
|
2593
2593
|
q[k + 1] = "";
|
|
2594
2594
|
k++;
|
|
2595
|
-
} else q[k] =
|
|
2595
|
+
} else q[k] = _chunkZBHS7KLWcjs.mapPuaText.call(void 0, q[k]);
|
|
2596
2596
|
}
|
|
2597
2597
|
const byFont = /* @__PURE__ */ new Map();
|
|
2598
2598
|
for (const it of items) {
|
|
@@ -2627,15 +2627,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
2627
2627
|
function marginContextBlocks(raw, page, view) {
|
|
2628
2628
|
const [x1, y1, x2, y2] = view;
|
|
2629
2629
|
const width = x2 - x1, height = y2 - y1;
|
|
2630
|
-
const items =
|
|
2630
|
+
const items = _chunkGV7ECKOKcjs.filterHiddenText.call(void 0, _chunkGV7ECKOKcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
2631
2631
|
for (const item of items) {
|
|
2632
2632
|
item.x -= x1;
|
|
2633
2633
|
item.y -= y1;
|
|
2634
2634
|
}
|
|
2635
|
-
return
|
|
2636
|
-
const bbox =
|
|
2635
|
+
return _chunkGV7ECKOKcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
2636
|
+
const bbox = _chunkGV7ECKOKcjs.computeBBox.call(void 0, line, page);
|
|
2637
2637
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
2638
|
-
return [{ type: "paragraph", text:
|
|
2638
|
+
return [{ type: "paragraph", text: _chunkGV7ECKOKcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkGV7ECKOKcjs.dominantStyle.call(void 0, line) }];
|
|
2639
2639
|
});
|
|
2640
2640
|
}
|
|
2641
2641
|
|
|
@@ -2671,7 +2671,7 @@ var WINANSI_REVERSE = {
|
|
|
2671
2671
|
};
|
|
2672
2672
|
function symbolFontTable(fontName) {
|
|
2673
2673
|
if (!fontName) return void 0;
|
|
2674
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
2674
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkZBHS7KLWcjs.WINGDINGS;
|
|
2675
2675
|
return void 0;
|
|
2676
2676
|
}
|
|
2677
2677
|
function remapSymbolText(text, table) {
|
|
@@ -2904,7 +2904,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
2904
2904
|
for (const i of members) drop.add(i);
|
|
2905
2905
|
const toks = cur.map((it) => {
|
|
2906
2906
|
const bar2 = isBarItem(it);
|
|
2907
|
-
const text = bar2 ? "" : plain2.has(items.indexOf(it)) ?
|
|
2907
|
+
const text = bar2 ? "" : plain2.has(items.indexOf(it)) ? _chunkZBHS7KLWcjs.toTex.call(void 0, it.text) : FUNC_RE.test(it.text.trim()) ? it.text.trim() : [...it.text].map(decodeEq).join("");
|
|
2908
2908
|
return { text, x: it.x, y: it.y, w: it.w, size: sizeOf(it), bar: bar2 };
|
|
2909
2909
|
});
|
|
2910
2910
|
const tex = layout(toks).replace(/\}\\text\{/g, "");
|
|
@@ -3701,7 +3701,7 @@ function mergeEnclosedDigits(items) {
|
|
|
3701
3701
|
if (!/^\d\d?$/.test(digits)) continue;
|
|
3702
3702
|
const mid = (inside2[0].x + inside2[inside2.length - 1].x + inside2[inside2.length - 1].w) / 2;
|
|
3703
3703
|
if (Math.abs(mid - (s.x + s.w / 2)) > s.fontSize * 0.15) continue;
|
|
3704
|
-
s.text =
|
|
3704
|
+
s.text = _chunkZBHS7KLWcjs.enclosedNumber.call(void 0, Number(digits));
|
|
3705
3705
|
for (const d of inside2) drop.add(d);
|
|
3706
3706
|
}
|
|
3707
3707
|
if (!drop.size) return;
|
|
@@ -3883,7 +3883,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3883
3883
|
if (block.type !== "heading" || !block.text) continue;
|
|
3884
3884
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
3885
3885
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _309 => _309.style, 'optionalAccess', _310 => _310.fontSize]), () => ( 0));
|
|
3886
|
-
const tocEntry = i > 0 &&
|
|
3886
|
+
const tocEntry = i > 0 && _chunkGV7ECKOKcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkGV7ECKOKcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
3887
3887
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
3888
3888
|
const proseStyle = _optionalChain([block, 'access', _311 => _311.style, 'optionalAccess', _312 => _312.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
3889
3889
|
const next = blocks[i + 1];
|
|
@@ -3981,7 +3981,7 @@ function splitSingleCellTables(blocks) {
|
|
|
3981
3981
|
const out = [];
|
|
3982
3982
|
for (const b of blocks) {
|
|
3983
3983
|
const t = b.type === "table" ? b.table : void 0;
|
|
3984
|
-
const title = t &&
|
|
3984
|
+
const title = t && _chunkGV7ECKOKcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3985
3985
|
if (title) {
|
|
3986
3986
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3987
3987
|
continue;
|
|
@@ -4017,7 +4017,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
4017
4017
|
const lines = cell.text.split("\n");
|
|
4018
4018
|
const out = [lines[0]];
|
|
4019
4019
|
for (const line of lines.slice(1)) {
|
|
4020
|
-
if (
|
|
4020
|
+
if (_chunkGV7ECKOKcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
4021
4021
|
else out.push(line);
|
|
4022
4022
|
}
|
|
4023
4023
|
cell.text = out.join("\n");
|
|
@@ -4037,10 +4037,10 @@ function cleanPdfText(text, opts) {
|
|
|
4037
4037
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
4038
4038
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
4039
4039
|
if (line.startsWith("|")) {
|
|
4040
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
4040
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkGV7ECKOKcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
4041
4041
|
}
|
|
4042
4042
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _392 => _392.exec, 'call', _393 => _393(line), 'optionalAccess', _394 => _394[0]]), () => ( ""));
|
|
4043
|
-
return mark +
|
|
4043
|
+
return mark + _chunkGV7ECKOKcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
4044
4044
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
4045
4045
|
}
|
|
4046
4046
|
function startsWithMarker(line) {
|
|
@@ -4072,7 +4072,7 @@ function mergeKoreanLines(text) {
|
|
|
4072
4072
|
continue;
|
|
4073
4073
|
}
|
|
4074
4074
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
4075
|
-
result[result.length - 1] = prev +
|
|
4075
|
+
result[result.length - 1] = prev + _chunkGV7ECKOKcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
4076
4076
|
} else {
|
|
4077
4077
|
result.push(curr);
|
|
4078
4078
|
}
|
|
@@ -4088,7 +4088,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
4088
4088
|
const wrapped = /* @__PURE__ */ new Set();
|
|
4089
4089
|
for (const a of annots) {
|
|
4090
4090
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
4091
|
-
const url =
|
|
4091
|
+
const url = _chunkHVILFVATcjs.sanitizeHref.call(void 0, a.url);
|
|
4092
4092
|
if (!url) continue;
|
|
4093
4093
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
4094
4094
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -4140,7 +4140,7 @@ function mergeLinkRuns(markdown) {
|
|
|
4140
4140
|
|
|
4141
4141
|
// src/pdf/formula-ocr.ts
|
|
4142
4142
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
4143
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
4143
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-N6GWFPHK.cjs")));
|
|
4144
4144
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
4145
4145
|
await ensureFormulaModels((p) => {
|
|
4146
4146
|
if (p.phase === "download" && p.total) {
|
|
@@ -4331,13 +4331,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
4331
4331
|
try {
|
|
4332
4332
|
return await Promise.race([
|
|
4333
4333
|
loadingTask.promise.catch((e) => {
|
|
4334
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
4334
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkHVILFVATcjs.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)");
|
|
4335
4335
|
throw e;
|
|
4336
4336
|
}),
|
|
4337
4337
|
new Promise((_, reject) => {
|
|
4338
4338
|
timer = setTimeout(() => {
|
|
4339
4339
|
loadingTask.destroy();
|
|
4340
|
-
reject(new (0,
|
|
4340
|
+
reject(new (0, _chunkHVILFVATcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
4341
4341
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
4342
4342
|
})
|
|
4343
4343
|
]);
|
|
@@ -4347,14 +4347,14 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
4347
4347
|
}
|
|
4348
4348
|
async function parsePdfDocument(buffer, options) {
|
|
4349
4349
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _395 => _395.formulaOcr]) ? buffer : null;
|
|
4350
|
-
const ocrOptionError =
|
|
4351
|
-
if (ocrOptionError) throw new (0,
|
|
4352
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _396 => _396.ocr]) === void 0 && await
|
|
4350
|
+
const ocrOptionError = _chunkZBHS7KLWcjs.validateOcrOptions.call(void 0, options);
|
|
4351
|
+
if (ocrOptionError) throw new (0, _chunkHVILFVATcjs.KordocError)(ocrOptionError);
|
|
4352
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _396 => _396.ocr]) === void 0 && await _chunkGV7ECKOKcjs.ocrModelsCached.call(void 0, _chunkGV7ECKOKcjs.resolveOcrModels.call(void 0, options));
|
|
4353
4353
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _397 => _397.ocr]) || autoOcr ? buffer : null;
|
|
4354
4354
|
const doc = await loadPdfWithTimeout(buffer);
|
|
4355
4355
|
try {
|
|
4356
4356
|
const pageCount = doc.numPages;
|
|
4357
|
-
if (pageCount === 0) throw new (0,
|
|
4357
|
+
if (pageCount === 0) throw new (0, _chunkHVILFVATcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
4358
4358
|
const metadata = { pageCount, pageMode: "layout" };
|
|
4359
4359
|
await extractPdfMetadata(doc, metadata);
|
|
4360
4360
|
const blocks = [];
|
|
@@ -4383,7 +4383,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4383
4383
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
4384
4384
|
const carry = {};
|
|
4385
4385
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
4386
|
-
const wrapLexicon = new (0,
|
|
4386
|
+
const wrapLexicon = new (0, _chunkGV7ECKOKcjs.WrapLexicon)();
|
|
4387
4387
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
4388
4388
|
const headerContext = [];
|
|
4389
4389
|
if (pageFilter && _optionalChain([options, 'optionalAccess', _400 => _400.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
@@ -4433,8 +4433,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4433
4433
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4434
4434
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4435
4435
|
restoreSoftHyphens();
|
|
4436
|
-
const items =
|
|
4437
|
-
const filtered =
|
|
4436
|
+
const items = _chunkGV7ECKOKcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
4437
|
+
const filtered = _chunkGV7ECKOKcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
4438
4438
|
const joined = joinVerticalColumns(filtered.visible);
|
|
4439
4439
|
const visible = dropTabLeaderDots(joined);
|
|
4440
4440
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -4461,7 +4461,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4461
4461
|
} : rawOps;
|
|
4462
4462
|
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _407 => _407(loadedName), 'optionalAccess', _408 => _408.name]));
|
|
4463
4463
|
remapControlGlyphs(visible, differencesOf);
|
|
4464
|
-
await
|
|
4464
|
+
await _chunkGV7ECKOKcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
4465
4465
|
const faces = /* @__PURE__ */ new Map();
|
|
4466
4466
|
for (const it of visible) {
|
|
4467
4467
|
if (!it.fontName) continue;
|
|
@@ -4474,12 +4474,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4474
4474
|
it.fontName = face;
|
|
4475
4475
|
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _410 => _410(face), 'optionalAccess', _411 => _411.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
4476
4476
|
}
|
|
4477
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
4478
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
4477
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkZBHS7KLWcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
4478
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkZBHS7KLWcjs.escapeLiteralTags.call(void 0, it.text);
|
|
4479
4479
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
4480
4480
|
const pageArea = pageW * pageH;
|
|
4481
4481
|
if (pageArea > 0) {
|
|
4482
|
-
const imageRegions =
|
|
4482
|
+
const imageRegions = _chunkGV7ECKOKcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
4483
4483
|
let uncovered = 0;
|
|
4484
4484
|
for (const r of imageRegions) {
|
|
4485
4485
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -4505,11 +4505,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4505
4505
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
4506
4506
|
}
|
|
4507
4507
|
const marks = superscriptNoteMarks(visible);
|
|
4508
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
4508
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkGV7ECKOKcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
4509
4509
|
const stamp = marginStamp(visible);
|
|
4510
4510
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
4511
|
-
const rightArrows = _optionalChain([options, 'optionalAccess', _412 => _412.tables]) !== false ? await
|
|
4512
|
-
const pageBlocks = orderTwoUpPage(
|
|
4511
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _412 => _412.tables]) !== false ? await _chunkGV7ECKOKcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
4512
|
+
const pageBlocks = orderTwoUpPage(_chunkGV7ECKOKcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _413 => _413.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
4513
4513
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
4514
4514
|
for (const b of pageBlocks) blocks.push(b);
|
|
4515
4515
|
try {
|
|
@@ -4535,11 +4535,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4535
4535
|
if (_optionalChain([options, 'optionalAccess', _415 => _415.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
4536
4536
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
4537
4537
|
}
|
|
4538
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
4538
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkHVILFVATcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
4539
4539
|
parsedPages++;
|
|
4540
4540
|
_optionalChain([options, 'optionalAccess', _416 => _416.onProgress, 'optionalCall', _417 => _417(parsedPages, totalTarget)]);
|
|
4541
4541
|
} catch (pageErr) {
|
|
4542
|
-
if (pageErr instanceof
|
|
4542
|
+
if (pageErr instanceof _chunkHVILFVATcjs.KordocError) throw pageErr;
|
|
4543
4543
|
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" });
|
|
4544
4544
|
} finally {
|
|
4545
4545
|
_optionalChain([loadedPage, 'optionalAccess', _418 => _418.cleanup, 'call', _419 => _419()]);
|
|
@@ -4570,12 +4570,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4570
4570
|
}
|
|
4571
4571
|
if (targets.size > 0) {
|
|
4572
4572
|
try {
|
|
4573
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
4573
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-Z4PBLB75.cjs")));
|
|
4574
4574
|
const mode = typeof _optionalChain([options, 'optionalAccess', _424 => _424.ocr]) === "function" ? options.ocr : "builtin";
|
|
4575
4575
|
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _425 => _425.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _426 => _426.find, 'call', _427 => _427((q) => q.page === p), 'optionalAccess', _428 => _428.needsOcr])));
|
|
4576
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
4576
|
+
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-Z4PBLB75.cjs")));
|
|
4577
4577
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _429 => _429.onProgress]), _optionalChain([options, 'optionalAccess', _430 => _430.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
4578
|
-
for (const obs of ocrPageBlocks.values())
|
|
4578
|
+
for (const obs of ocrPageBlocks.values()) _chunkZBHS7KLWcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
4579
4579
|
if (ocrPageBlocks.size > 0) {
|
|
4580
4580
|
const replacePages = /* @__PURE__ */ new Set();
|
|
4581
4581
|
for (const [p, obs] of ocrPageBlocks) {
|
|
@@ -4586,7 +4586,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4586
4586
|
continue;
|
|
4587
4587
|
}
|
|
4588
4588
|
const regions = ocrRegions.get(p);
|
|
4589
|
-
if (!regions ||
|
|
4589
|
+
if (!regions || _chunkGV7ECKOKcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
4590
4590
|
ocrDone.add(p);
|
|
4591
4591
|
if (_optionalChain([pageImageBlocks, 'access', _435 => _435.get, 'call', _436 => _436(p), 'optionalAccess', _437 => _437.length]) === 1) pageImageBlocks.delete(p);
|
|
4592
4592
|
}
|
|
@@ -4639,17 +4639,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4639
4639
|
}
|
|
4640
4640
|
}
|
|
4641
4641
|
if (_optionalChain([options, 'optionalAccess', _438 => _438.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
4642
|
-
const removed =
|
|
4643
|
-
const running =
|
|
4642
|
+
const removed = _chunkGV7ECKOKcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
4643
|
+
const running = _chunkGV7ECKOKcjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
4644
4644
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
4645
4645
|
blocks.splice(removed[ri], 1);
|
|
4646
4646
|
}
|
|
4647
|
-
const stripped =
|
|
4647
|
+
const stripped = _chunkGV7ECKOKcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
4648
4648
|
if (stripped !== blocks) {
|
|
4649
4649
|
blocks.length = 0;
|
|
4650
4650
|
blocks.push(...stripped);
|
|
4651
4651
|
}
|
|
4652
|
-
const kept =
|
|
4652
|
+
const kept = _chunkGV7ECKOKcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
4653
4653
|
if (kept !== blocks) {
|
|
4654
4654
|
blocks.length = 0;
|
|
4655
4655
|
blocks.push(...kept);
|
|
@@ -4658,12 +4658,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4658
4658
|
mergeContinuedCells(blocks, pageHeights);
|
|
4659
4659
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
4660
4660
|
if (_optionalChain([options, 'optionalAccess', _439 => _439.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
4661
|
-
const boxes =
|
|
4661
|
+
const boxes = _chunkGV7ECKOKcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
4662
4662
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
4663
4663
|
}
|
|
4664
4664
|
splitContactTables(blocks);
|
|
4665
|
-
if (!_optionalChain([options, 'optionalAccess', _440 => _440.keepTrailingEmptyCols]))
|
|
4666
|
-
|
|
4665
|
+
if (!_optionalChain([options, 'optionalAccess', _440 => _440.keepTrailingEmptyCols])) _chunkGV7ECKOKcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
4666
|
+
_chunkGV7ECKOKcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
4667
4667
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
4668
4668
|
if (_optionalChain([options, 'optionalAccess', _441 => _441.formulaOcr]) && formulaBuffer) {
|
|
4669
4669
|
try {
|
|
@@ -4675,21 +4675,21 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4675
4675
|
});
|
|
4676
4676
|
}
|
|
4677
4677
|
}
|
|
4678
|
-
const medianFontSize =
|
|
4678
|
+
const medianFontSize = _chunkGV7ECKOKcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
4679
4679
|
if (medianFontSize > 0) {
|
|
4680
|
-
|
|
4681
|
-
}
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4680
|
+
_chunkGV7ECKOKcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
4681
|
+
}
|
|
4682
|
+
_chunkGV7ECKOKcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
4683
|
+
_chunkGV7ECKOKcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
4684
|
+
_chunkGV7ECKOKcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
4685
|
+
_chunkGV7ECKOKcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
4686
|
+
_chunkGV7ECKOKcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
4687
|
+
_chunkGV7ECKOKcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
4688
|
+
_chunkGV7ECKOKcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
4689
|
+
_chunkGV7ECKOKcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
4690
4690
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
4691
|
-
|
|
4692
|
-
|
|
4691
|
+
_chunkGV7ECKOKcjs.detectTableCaptions.call(void 0, blocks);
|
|
4692
|
+
_chunkGV7ECKOKcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
4693
4693
|
sanitizeBlockControlChars(blocks);
|
|
4694
4694
|
let outBlocks = splitSingleCellTables(blocks);
|
|
4695
4695
|
if (_optionalChain([options, 'optionalAccess', _442 => _442.layoutTables]) !== "keep") {
|
|
@@ -4710,19 +4710,19 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4710
4710
|
const shown = /* @__PURE__ */ new Map();
|
|
4711
4711
|
const markContent = (bs) => {
|
|
4712
4712
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
4713
|
-
if (
|
|
4714
|
-
const lines =
|
|
4715
|
-
if (lines)
|
|
4713
|
+
if (_chunkGV7ECKOKcjs.IMAGE_CELLS.has(c)) _chunkZBHS7KLWcjs.CONTENT_CELLS.add(c);
|
|
4714
|
+
const lines = _chunkGV7ECKOKcjs.CELL_LINES.get(c);
|
|
4715
|
+
if (lines) _chunkZBHS7KLWcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
4716
4716
|
markContent(c.blocks);
|
|
4717
4717
|
}
|
|
4718
4718
|
};
|
|
4719
4719
|
const visual = (bs) => bs.flatMap((b) => {
|
|
4720
4720
|
if (b.type !== "table") return [b];
|
|
4721
|
-
if (!hancom && b.table &&
|
|
4721
|
+
if (!hancom && b.table && _chunkGV7ECKOKcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
4722
4722
|
let v = shown.get(b);
|
|
4723
4723
|
if (!v) {
|
|
4724
4724
|
markContent([b]);
|
|
4725
|
-
shown.set(b, v =
|
|
4725
|
+
shown.set(b, v = _chunkZBHS7KLWcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _445 => _445.keepTrailingEmptyCols])));
|
|
4726
4726
|
}
|
|
4727
4727
|
return v;
|
|
4728
4728
|
});
|
|
@@ -4731,13 +4731,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4731
4731
|
blocks.length = 0;
|
|
4732
4732
|
for (const b of kept) blocks.push(b);
|
|
4733
4733
|
}
|
|
4734
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
4735
|
-
if (_optionalChain([options, 'optionalAccess', _447 => _447.tableFormat]) === "gfm")
|
|
4734
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkZBHS7KLWcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _446 => _446.tableFormat]) }), { keepLoneNumbers: true }));
|
|
4735
|
+
if (_optionalChain([options, 'optionalAccess', _447 => _447.tableFormat]) === "gfm") _chunkZBHS7KLWcjs.assignTableIds.call(void 0, blocks);
|
|
4736
4736
|
let markdown = finishMarkdown(outBlocks);
|
|
4737
4737
|
const outline = collectPdfOutline(outBlocks);
|
|
4738
4738
|
return {
|
|
4739
4739
|
markdown,
|
|
4740
|
-
pages:
|
|
4740
|
+
pages: _chunkV26UPU2Lcjs.blocksToPages.call(void 0, splitPageTables(_chunkGV7ECKOKcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
4741
4741
|
blocks,
|
|
4742
4742
|
metadata,
|
|
4743
4743
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -4817,5 +4817,5 @@ function marginStamp(items) {
|
|
|
4817
4817
|
|
|
4818
4818
|
|
|
4819
4819
|
|
|
4820
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
4821
|
-
//# sourceMappingURL=parser-
|
|
4820
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkGV7ECKOKcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkGV7ECKOKcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkGV7ECKOKcjs.removeHeaderFooterBlocks;
|
|
4821
|
+
//# sourceMappingURL=parser-JWU6HYZZ.cjs.map
|