kordoc 4.24.0 → 4.24.2
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 +26 -54
- package/dist/{-VEOO4BOM.js → -SRNEV7LS.js} +11 -11
- package/dist/{chunk-P35SCAJN.js → chunk-3HN65YAL.js} +2 -2
- package/dist/{chunk-H5PDQ66I.js → chunk-4745MFQU.js} +3 -3
- package/dist/{chunk-ENCAYXDI.js → chunk-4XC4O7FJ.js} +4 -4
- package/dist/{chunk-EN3PK6OT.js → chunk-7NTMM6PO.js} +2 -2
- package/dist/{chunk-GEY6ZMXH.js → chunk-C6ZVB547.js} +43 -23
- package/dist/{chunk-GEY6ZMXH.js.map → chunk-C6ZVB547.js.map} +1 -1
- package/dist/{chunk-CKCJU42Y.js → chunk-DHMBPMKC.js} +74 -30
- package/dist/chunk-DHMBPMKC.js.map +1 -0
- package/dist/{chunk-ZGNHJCDR.js → chunk-E6VBLBOO.js} +2 -2
- package/dist/{chunk-O2SLKE4L.js → chunk-E7B5CXYI.js} +2 -2
- package/dist/{chunk-DKWEZWCF.cjs → chunk-HLTPMSYW.cjs} +3 -3
- package/dist/{chunk-DKWEZWCF.cjs.map → chunk-HLTPMSYW.cjs.map} +1 -1
- package/dist/{chunk-DZT3CHNZ.cjs → chunk-IGG63DFK.cjs} +3 -3
- package/dist/{chunk-DZT3CHNZ.cjs.map → chunk-IGG63DFK.cjs.map} +1 -1
- package/dist/{chunk-IHNIPVPJ.cjs → chunk-JFUUFJZW.cjs} +6 -6
- package/dist/{chunk-IHNIPVPJ.cjs.map → chunk-JFUUFJZW.cjs.map} +1 -1
- package/dist/{chunk-PX6X4YOR.js → chunk-JMOAMKAR.js} +4 -4
- package/dist/{chunk-P6FNIU5P.js → chunk-KUC5I5MB.js} +2 -2
- package/dist/{chunk-Z5G6QNVH.js → chunk-LMEF7FN5.js} +2 -2
- package/dist/{chunk-OJISMR2Z.js → chunk-M46PB75E.js} +2 -2
- package/dist/{chunk-G4HWEM6Q.js → chunk-MHNJOJQV.js} +4 -4
- package/dist/{chunk-Z62PHCSU.js → chunk-NJ5RUDCW.js} +3 -3
- package/dist/{chunk-DM5YPONO.js → chunk-NMFFIUI6.js} +2 -2
- package/dist/{chunk-HOXHBG4C.cjs → chunk-PNSALBXH.cjs} +2 -2
- package/dist/{chunk-HOXHBG4C.cjs.map → chunk-PNSALBXH.cjs.map} +1 -1
- package/dist/{chunk-FHFPQ6MX.cjs → chunk-PNX5FYHC.cjs} +24 -24
- package/dist/{chunk-FHFPQ6MX.cjs.map → chunk-PNX5FYHC.cjs.map} +1 -1
- package/dist/{chunk-IZYYKE5F.js → chunk-R2GIGE5H.js} +2 -2
- package/dist/{chunk-55DOBEGD.js → chunk-RIRPLFPN.js} +2 -2
- package/dist/{chunk-3M2BIQLZ.js → chunk-TDMBTG7U.js} +2 -2
- package/dist/{chunk-6YDPTTIY.js → chunk-TW3V6FSH.js} +2 -2
- package/dist/{chunk-OHDGEGDJ.cjs → chunk-UNICY546.cjs} +23 -23
- package/dist/{chunk-OHDGEGDJ.cjs.map → chunk-UNICY546.cjs.map} +1 -1
- package/dist/{chunk-SRUBDR3Z.js → chunk-VPSF5LEM.js} +3 -3
- package/dist/{chunk-4VPN5MHS.js → chunk-W24TJJNN.js} +2 -2
- package/dist/{chunk-DBPDAG7N.js → chunk-WDSTW3BD.js} +2 -2
- package/dist/{chunk-XLY5ZJRP.js → chunk-WJAFE3Z6.js} +2 -2
- package/dist/chunks-AL4P5TO5.js +10 -0
- package/dist/cli.js +41 -30
- package/dist/cli.js.map +1 -1
- package/dist/{formula-4GRNVWIQ.js → formula-DSB574H7.js} +4 -4
- package/dist/{formula-R3OWFGCZ.cjs → formula-HK2MNZ3Q.cjs} +9 -9
- package/dist/{formula-R3OWFGCZ.cjs.map → formula-HK2MNZ3Q.cjs.map} +1 -1
- package/dist/{formula-6Y467S4R.js → formula-U2LZ67KI.js} +3 -3
- package/dist/{image-ocr-CGJJCD4E.js → image-ocr-3QB2HLSI.js} +9 -9
- package/dist/{image-ocr-ZLL66KNO.js → image-ocr-J54Q3YWP.js} +6 -6
- package/dist/{image-ocr-EBKG45KF.cjs → image-ocr-QNIMVE5A.cjs} +17 -17
- package/dist/{image-ocr-EBKG45KF.cjs.map → image-ocr-QNIMVE5A.cjs.map} +1 -1
- package/dist/index.cjs +683 -619
- 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 +106 -42
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +36 -33
- package/dist/mcp.js.map +1 -1
- package/dist/{model-bundle-RD4KSNTB.js → model-bundle-CGWU4ALC.js} +5 -5
- package/dist/{models-OLGCZBXI.js → models-A3TF3BDV.js} +5 -5
- package/dist/{parse-worker-v2-YZY2GQY5.js → parse-worker-v2-MNUD4WAR.js} +20 -13
- package/dist/parse-worker-v2-MNUD4WAR.js.map +1 -0
- package/dist/{parser-IHCFHLHN.js → parser-C3ARF26I.js} +12 -12
- package/dist/{parser-J22QBXPP.js → parser-OBGWEWSU.js} +9 -9
- package/dist/{parser-DX4I3GT7.cjs → parser-RPAHN3OR.cjs} +157 -157
- package/dist/{parser-DX4I3GT7.cjs.map → parser-RPAHN3OR.cjs.map} +1 -1
- package/dist/{pdf-ocr-TYIH23RP.js → pdf-ocr-ENLVEEYL.js} +9 -9
- package/dist/pdf-ocr-GA5QJFNK.cjs +31 -0
- package/dist/{pdf-ocr-WU7SZHWM.cjs.map → pdf-ocr-GA5QJFNK.cjs.map} +1 -1
- package/dist/{pdf-ocr-H2247ZZH.js → pdf-ocr-K53REDNY.js} +6 -6
- package/dist/{profile-io-GH3TYTNJ.js → profile-io-ZGFEO7CB.js} +3 -3
- package/dist/{rasterize-7TFTVFMB.js → rasterize-QMC2SAUT.js} +3 -3
- package/dist/{redact-doc-DSSQOO3A.js → redact-doc-JH6RZZBE.js} +11 -11
- package/dist/{render-NKXZQINI.js → render-ZGKQLKPJ.js} +7 -7
- package/dist/seal-KMGYTJAV.js +10 -0
- package/dist/{setup-JVLMX2TH.js → setup-LAQGCYQ2.js} +3 -3
- package/dist/visual-4OYJFGXL.js +21 -0
- package/dist/{watch-5RZVHAKI.js → watch-7YPB4TKC.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-CKCJU42Y.js.map +0 -1
- package/dist/chunks-LV5EJBZ4.js +0 -10
- package/dist/parse-worker-v2-YZY2GQY5.js.map +0 -1
- package/dist/pdf-ocr-WU7SZHWM.cjs +0 -31
- package/dist/seal-JIVSSI3Z.js +0 -10
- package/dist/visual-BKVZN6HP.js +0 -21
- /package/dist/{-VEOO4BOM.js.map → -SRNEV7LS.js.map} +0 -0
- /package/dist/{chunk-P35SCAJN.js.map → chunk-3HN65YAL.js.map} +0 -0
- /package/dist/{chunk-H5PDQ66I.js.map → chunk-4745MFQU.js.map} +0 -0
- /package/dist/{chunk-ENCAYXDI.js.map → chunk-4XC4O7FJ.js.map} +0 -0
- /package/dist/{chunk-EN3PK6OT.js.map → chunk-7NTMM6PO.js.map} +0 -0
- /package/dist/{chunk-ZGNHJCDR.js.map → chunk-E6VBLBOO.js.map} +0 -0
- /package/dist/{chunk-O2SLKE4L.js.map → chunk-E7B5CXYI.js.map} +0 -0
- /package/dist/{chunk-PX6X4YOR.js.map → chunk-JMOAMKAR.js.map} +0 -0
- /package/dist/{chunk-P6FNIU5P.js.map → chunk-KUC5I5MB.js.map} +0 -0
- /package/dist/{chunk-Z5G6QNVH.js.map → chunk-LMEF7FN5.js.map} +0 -0
- /package/dist/{chunk-OJISMR2Z.js.map → chunk-M46PB75E.js.map} +0 -0
- /package/dist/{chunk-G4HWEM6Q.js.map → chunk-MHNJOJQV.js.map} +0 -0
- /package/dist/{chunk-Z62PHCSU.js.map → chunk-NJ5RUDCW.js.map} +0 -0
- /package/dist/{chunk-DM5YPONO.js.map → chunk-NMFFIUI6.js.map} +0 -0
- /package/dist/{chunk-IZYYKE5F.js.map → chunk-R2GIGE5H.js.map} +0 -0
- /package/dist/{chunk-55DOBEGD.js.map → chunk-RIRPLFPN.js.map} +0 -0
- /package/dist/{chunk-3M2BIQLZ.js.map → chunk-TDMBTG7U.js.map} +0 -0
- /package/dist/{chunk-6YDPTTIY.js.map → chunk-TW3V6FSH.js.map} +0 -0
- /package/dist/{chunk-SRUBDR3Z.js.map → chunk-VPSF5LEM.js.map} +0 -0
- /package/dist/{chunk-4VPN5MHS.js.map → chunk-W24TJJNN.js.map} +0 -0
- /package/dist/{chunk-DBPDAG7N.js.map → chunk-WDSTW3BD.js.map} +0 -0
- /package/dist/{chunk-XLY5ZJRP.js.map → chunk-WJAFE3Z6.js.map} +0 -0
- /package/dist/{chunks-LV5EJBZ4.js.map → chunks-AL4P5TO5.js.map} +0 -0
- /package/dist/{formula-4GRNVWIQ.js.map → formula-DSB574H7.js.map} +0 -0
- /package/dist/{formula-6Y467S4R.js.map → formula-U2LZ67KI.js.map} +0 -0
- /package/dist/{image-ocr-CGJJCD4E.js.map → image-ocr-3QB2HLSI.js.map} +0 -0
- /package/dist/{image-ocr-ZLL66KNO.js.map → image-ocr-J54Q3YWP.js.map} +0 -0
- /package/dist/{model-bundle-RD4KSNTB.js.map → model-bundle-CGWU4ALC.js.map} +0 -0
- /package/dist/{models-OLGCZBXI.js.map → models-A3TF3BDV.js.map} +0 -0
- /package/dist/{parser-IHCFHLHN.js.map → parser-C3ARF26I.js.map} +0 -0
- /package/dist/{parser-J22QBXPP.js.map → parser-OBGWEWSU.js.map} +0 -0
- /package/dist/{pdf-ocr-H2247ZZH.js.map → pdf-ocr-ENLVEEYL.js.map} +0 -0
- /package/dist/{pdf-ocr-TYIH23RP.js.map → pdf-ocr-K53REDNY.js.map} +0 -0
- /package/dist/{profile-io-GH3TYTNJ.js.map → profile-io-ZGFEO7CB.js.map} +0 -0
- /package/dist/{rasterize-7TFTVFMB.js.map → rasterize-QMC2SAUT.js.map} +0 -0
- /package/dist/{redact-doc-DSSQOO3A.js.map → redact-doc-JH6RZZBE.js.map} +0 -0
- /package/dist/{render-NKXZQINI.js.map → render-ZGKQLKPJ.js.map} +0 -0
- /package/dist/{seal-JIVSSI3Z.js.map → seal-KMGYTJAV.js.map} +0 -0
- /package/dist/{setup-JVLMX2TH.js.map → setup-LAQGCYQ2.js.map} +0 -0
- /package/dist/{visual-BKVZN6HP.js.map → visual-4OYJFGXL.js.map} +0 -0
- /package/dist/{watch-5RZVHAKI.js.map → watch-7YPB4TKC.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 _chunkIGG63DFKcjs = require('./chunk-IGG63DFK.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 _chunkUNICY546cjs = require('./chunk-UNICY546.cjs');
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
@@ -78,12 +78,12 @@ var _chunkOHDGEGDJcjs = require('./chunk-OHDGEGDJ.cjs');
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
var
|
|
82
|
-
require('./chunk-
|
|
81
|
+
var _chunkJFUUFJZWcjs = require('./chunk-JFUUFJZW.cjs');
|
|
82
|
+
require('./chunk-HLTPMSYW.cjs');
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
var
|
|
86
|
+
var _chunkPNSALBXHcjs = require('./chunk-PNSALBXH.cjs');
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -220,7 +220,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
220
220
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
221
221
|
state.seen.set(hash, filename);
|
|
222
222
|
if (withBytes) {
|
|
223
|
-
const png =
|
|
223
|
+
const png = _chunkIGG63DFKcjs.encodePng.call(void 0, w, h, rgba);
|
|
224
224
|
state.totalBytes += png.length;
|
|
225
225
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
226
226
|
}
|
|
@@ -616,13 +616,13 @@ function ocrVectorOps(opList, paths) {
|
|
|
616
616
|
|
|
617
617
|
// src/pdf/split-row-pattern.ts
|
|
618
618
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
619
|
-
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !
|
|
619
|
+
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !_chunkUNICY546cjs.IMAGE_CELLS.has(cell);
|
|
620
620
|
var labelsOf = (cell) => {
|
|
621
621
|
const labels = textOf(cell).split("\n").map((s) => s.trim()).filter(Boolean);
|
|
622
622
|
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;
|
|
623
623
|
};
|
|
624
624
|
var alignedLabels = (label, value, count) => {
|
|
625
|
-
const L =
|
|
625
|
+
const L = _chunkUNICY546cjs.CELL_LINES.get(label), V = _chunkUNICY546cjs.CELL_LINES.get(value);
|
|
626
626
|
let next = 0;
|
|
627
627
|
return !!L && !!V && L.length === count && V.length >= count && Math.abs(L[0].y - V[0].y) <= 1 && L.every((l) => {
|
|
628
628
|
while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
|
|
@@ -630,7 +630,7 @@ var alignedLabels = (label, value, count) => {
|
|
|
630
630
|
});
|
|
631
631
|
};
|
|
632
632
|
function partialAlignedLabelCells(table, owner, first) {
|
|
633
|
-
const pageOf = (a) => _nullishCoalesce(
|
|
633
|
+
const pageOf = (a) => _nullishCoalesce(_chunkJFUUFJZWcjs.CELL_PAGES.get(_nullishCoalesce(a.cell, () => ( table.cells[a.r][a.c]))), () => ( (a.r < first ? -1 : -2)));
|
|
634
634
|
const pairs = [];
|
|
635
635
|
let carried = false;
|
|
636
636
|
for (let c = 0; c < table.cols; ) {
|
|
@@ -653,10 +653,10 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
653
653
|
const keyed = pairs.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
|
|
654
654
|
if (keyed.length !== 1) return;
|
|
655
655
|
const label = keyed[0], value = pairs.find((p) => p.c === label.c + label.cs), context = pairs.find((p) => p.c + p.cs === label.c);
|
|
656
|
-
if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([
|
|
656
|
+
if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([_chunkJFUUFJZWcjs.CELL_EDGES, 'access', _21 => _21.get, 'call', _22 => _22(context.upper), 'optionalAccess', _23 => _23.b]) || !_optionalChain([_chunkJFUUFJZWcjs.CELL_EDGES, 'access', _24 => _24.get, 'call', _25 => _25(context.lower), 'optionalAccess', _26 => _26.t])) return;
|
|
657
657
|
const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
|
|
658
658
|
if (D.length < 2 || sequence.length < 3 || new Set(sequence).size !== sequence.length || !alignedLabels(label.upper, value.upper, U.length)) return;
|
|
659
|
-
const L =
|
|
659
|
+
const L = _chunkUNICY546cjs.CELL_LINES.get(label.lower), V = _chunkUNICY546cjs.CELL_LINES.get(value.lower);
|
|
660
660
|
if (!L || !V || L.length !== D.length) return;
|
|
661
661
|
let next = V.findIndex((v) => Math.abs(v.y - L[0].y) <= 1);
|
|
662
662
|
if (next <= 0 || !V.slice(0, next).every((v) => v.y > L[0].y + 1) || !L.every((l) => {
|
|
@@ -676,14 +676,14 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
676
676
|
continue;
|
|
677
677
|
}
|
|
678
678
|
if (list.length < 3 || new Set(list).size !== list.length) continue;
|
|
679
|
-
const visible = _nullishCoalesce(_optionalChain([
|
|
679
|
+
const visible = _nullishCoalesce(_optionalChain([_chunkUNICY546cjs.CELL_LINES, 'access', _31 => _31.get, 'call', _32 => _32(lc), 'optionalAccess', _33 => _33.length]), () => ( 0)), values = _chunkUNICY546cjs.CELL_LINES.get(vc);
|
|
680
680
|
if (visible < 3 || visible > list.length || !values || !alignedLabels(lc, vc, visible)) continue;
|
|
681
681
|
const top = Math.max(...values.map((v2) => v2.y)), bottom = Math.min(...values.map((v2) => v2.y));
|
|
682
682
|
const contexts = [];
|
|
683
683
|
for (let rr = r; rr < r + l.rs && rr < table.rows; rr++) {
|
|
684
684
|
const a = _optionalChain([owner, 'access', _34 => _34[rr], 'optionalAccess', _35 => _35[context.c]]), cell = a ? table.cells[a.r][a.c] : void 0;
|
|
685
685
|
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;
|
|
686
|
-
const lines =
|
|
686
|
+
const lines = _chunkUNICY546cjs.CELL_LINES.get(cell);
|
|
687
687
|
if (!_optionalChain([lines, 'optionalAccess', _36 => _36.length]) || lines.some((line) => line.y > top + 1 || line.y < bottom - 1)) break;
|
|
688
688
|
contexts.push(textOf(cell).replace(/\s+/g, ""));
|
|
689
689
|
}
|
|
@@ -985,7 +985,7 @@ function rowStarts(t) {
|
|
|
985
985
|
}
|
|
986
986
|
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));
|
|
987
987
|
function cellPage(cell) {
|
|
988
|
-
const p =
|
|
988
|
+
const p = _chunkJFUUFJZWcjs.CELL_PAGES.get(cell);
|
|
989
989
|
if (p !== void 0 || !_optionalChain([cell, 'access', _103 => _103.blocks, 'optionalAccess', _104 => _104.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
990
990
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
991
991
|
}
|
|
@@ -1014,7 +1014,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1014
1014
|
rows.forEach((starts, r) => {
|
|
1015
1015
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
1016
1016
|
for (const { cell } of starts) {
|
|
1017
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
1017
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkJFUUFJZWcjs.CELL_PAGES.set(cell, page2);
|
|
1018
1018
|
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))]);
|
|
1019
1019
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
1020
1020
|
}
|
|
@@ -1074,8 +1074,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1074
1074
|
if (!splits.length) continue;
|
|
1075
1075
|
const clone = (cell, patch) => {
|
|
1076
1076
|
const out = { ...cell, ...patch };
|
|
1077
|
-
const p =
|
|
1078
|
-
if (p !== void 0)
|
|
1077
|
+
const p = _chunkJFUUFJZWcjs.CELL_PAGES.get(cell);
|
|
1078
|
+
if (p !== void 0) _chunkJFUUFJZWcjs.CELL_PAGES.set(out, p);
|
|
1079
1079
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
1080
1080
|
return out;
|
|
1081
1081
|
};
|
|
@@ -1086,7 +1086,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1086
1086
|
for (const { cell, c, split } of splits) {
|
|
1087
1087
|
cells[r][c] = clone(cell, { ...split.head, rowSpan: cut - r });
|
|
1088
1088
|
const tail = { ...cell, ...split.tail, rowSpan: r + cell.rowSpan - cut };
|
|
1089
|
-
|
|
1089
|
+
_chunkJFUUFJZWcjs.CELL_PAGES.set(tail, split.page);
|
|
1090
1090
|
setSplits(tail, split.rest);
|
|
1091
1091
|
cells[cut][c] = tail;
|
|
1092
1092
|
}
|
|
@@ -1096,7 +1096,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1096
1096
|
for (const { cell, c, split } of splits) {
|
|
1097
1097
|
cells[r][c] = clone(cell, split.head);
|
|
1098
1098
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
1099
|
-
|
|
1099
|
+
_chunkJFUUFJZWcjs.CELL_PAGES.set(tail, split.page);
|
|
1100
1100
|
setSplits(tail, split.rest);
|
|
1101
1101
|
row[c] = tail;
|
|
1102
1102
|
}
|
|
@@ -1215,19 +1215,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1215
1215
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
1216
1216
|
}
|
|
1217
1217
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
1218
|
-
const lines =
|
|
1219
|
-
if (lines)
|
|
1220
|
-
if (
|
|
1221
|
-
const edges =
|
|
1218
|
+
const lines = _chunkUNICY546cjs.CELL_LINES.get(a.cell);
|
|
1219
|
+
if (lines) _chunkUNICY546cjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
1220
|
+
if (_chunkUNICY546cjs.IMAGE_CELLS.has(a.cell)) _chunkUNICY546cjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
1221
|
+
const edges = _chunkJFUUFJZWcjs.CELL_EDGES.get(a.cell);
|
|
1222
1222
|
if (edges) {
|
|
1223
|
-
|
|
1223
|
+
_chunkJFUUFJZWcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
1224
1224
|
edged = true;
|
|
1225
1225
|
}
|
|
1226
1226
|
return true;
|
|
1227
1227
|
};
|
|
1228
|
-
for (const a of pa) if (!
|
|
1228
|
+
for (const a of pa) if (!_chunkUNICY546cjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
1229
1229
|
for (const a of ca) {
|
|
1230
|
-
if (a.r < skip ||
|
|
1230
|
+
if (a.r < skip || _chunkUNICY546cjs.FILLER_CELLS.has(a.cell)) continue;
|
|
1231
1231
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
1232
1232
|
}
|
|
1233
1233
|
const first = prev.rows;
|
|
@@ -1251,9 +1251,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1251
1251
|
const grown = { ...above, rs: newRs };
|
|
1252
1252
|
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;
|
|
1253
1253
|
}
|
|
1254
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1254
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkUNICY546cjs.FILLER_CELLS.add(grid[r][c]);
|
|
1255
1255
|
if (edged) {
|
|
1256
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1256
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkJFUUFJZWcjs.CELL_EDGES.set(grid[r][c], _chunkUNICY546cjs.NO_EDGES);
|
|
1257
1257
|
}
|
|
1258
1258
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1259
1259
|
let r = prev.rows;
|
|
@@ -1262,7 +1262,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1262
1262
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1263
1263
|
}
|
|
1264
1264
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1265
|
-
const pr =
|
|
1265
|
+
const pr = _chunkUNICY546cjs.ROW_RULES.get(prev), cr = _chunkUNICY546cjs.ROW_RULES.get(curr);
|
|
1266
1266
|
const shifted = dx !== 0;
|
|
1267
1267
|
const cut = {
|
|
1268
1268
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1270,13 +1270,13 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1270
1270
|
list: !shifted ? "any" : skip > 0 && ca.filter((a) => a.r < skip && a.cell.text.trim()).length < 2 ? "none" : "multi"
|
|
1271
1271
|
};
|
|
1272
1272
|
let partial = !skip && cols === prev.cols && cols === curr.cols && cut.ruled && prevBottom !== void 0 ? partialAlignedLabelCells(table, owner, first) : void 0;
|
|
1273
|
-
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]) ||
|
|
1273
|
+
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]) || _chunkUNICY546cjs.startsNewItem.call(void 0, partial.value.upper.text, partial.value.lower.text))) partial = void 0;
|
|
1274
1274
|
const selected = partial ? /* @__PURE__ */ new Set([partial.label.c, partial.value.c]) : void 0;
|
|
1275
1275
|
let split = !selected && rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
|
|
1276
1276
|
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 });
|
|
1277
1277
|
if (pr && cr) {
|
|
1278
1278
|
const cutRuled = pr.bottom || cr.top;
|
|
1279
|
-
|
|
1279
|
+
_chunkUNICY546cjs.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) });
|
|
1280
1280
|
}
|
|
1281
1281
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1282
1282
|
}
|
|
@@ -1338,18 +1338,18 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1338
1338
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1339
1339
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1340
1340
|
if (selected && !selected.has(u.c)) continue;
|
|
1341
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1342
|
-
const openSeam = hasContent(a) && hasContent(b) &&
|
|
1341
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkUNICY546cjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
1342
|
+
const openSeam = hasContent(a) && hasContent(b) && _chunkUNICY546cjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
|
|
1343
1343
|
if (!r || r === first) return false;
|
|
1344
1344
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1345
1345
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1346
|
-
const ue =
|
|
1346
|
+
const ue = _chunkJFUUFJZWcjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkJFUUFJZWcjs.CELL_EDGES.get(table.cells[down.r][down.c]);
|
|
1347
1347
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1348
1348
|
});
|
|
1349
1349
|
if (!selected && !openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1350
1350
|
if (!straddles && !midWord) continue;
|
|
1351
1351
|
if (u.r >= last && d.rs < 2) continue;
|
|
1352
|
-
const U =
|
|
1352
|
+
const U = _chunkUNICY546cjs.CELL_LINES.get(a);
|
|
1353
1353
|
if (!_optionalChain([U, 'optionalAccess', _134 => _134.length]) || !hasContent(b)) continue;
|
|
1354
1354
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1355
1355
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -1367,7 +1367,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1367
1367
|
return merged;
|
|
1368
1368
|
}
|
|
1369
1369
|
function longLastLine(c) {
|
|
1370
|
-
const L =
|
|
1370
|
+
const L = _chunkUNICY546cjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _135 => _135[L.length - 1]]);
|
|
1371
1371
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1372
1372
|
}
|
|
1373
1373
|
function filledToBottom(U, bottom) {
|
|
@@ -1400,7 +1400,7 @@ function nextItemHead(prev, next) {
|
|
|
1400
1400
|
return false;
|
|
1401
1401
|
}
|
|
1402
1402
|
function continuesAcross(u, d, x1, x2) {
|
|
1403
|
-
const U =
|
|
1403
|
+
const U = _chunkUNICY546cjs.CELL_LINES.get(u), D = _chunkUNICY546cjs.CELL_LINES.get(d);
|
|
1404
1404
|
if (!_optionalChain([U, 'optionalAccess', _136 => _136.length]) || !_optionalChain([D, 'optionalAccess', _137 => _137.length])) return false;
|
|
1405
1405
|
const last = U[U.length - 1];
|
|
1406
1406
|
const fs = last.h || 10;
|
|
@@ -1418,7 +1418,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1418
1418
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1419
1419
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1420
1420
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1421
|
-
const newItem =
|
|
1421
|
+
const newItem = _chunkUNICY546cjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1422
1422
|
const all = D.length ? U.concat(D) : U;
|
|
1423
1423
|
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));
|
|
1424
1424
|
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;
|
|
@@ -1435,10 +1435,10 @@ function outlineContinues(u, d) {
|
|
|
1435
1435
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1436
1436
|
}
|
|
1437
1437
|
function lineEnded(c, x1, x2, next) {
|
|
1438
|
-
const L =
|
|
1438
|
+
const L = _chunkUNICY546cjs.CELL_LINES.get(c);
|
|
1439
1439
|
if (!L || L.length !== 1) return false;
|
|
1440
1440
|
const l = L[0], h = l.h || 10;
|
|
1441
|
-
const d0 = next ? _optionalChain([
|
|
1441
|
+
const d0 = next ? _optionalChain([_chunkUNICY546cjs.CELL_LINES, 'access', _138 => _138.get, 'call', _139 => _139(next), 'optionalAccess', _140 => _140[0]]) : void 0;
|
|
1442
1442
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1443
1443
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _141 => _141.text]), () => ( "")))) * h;
|
|
1444
1444
|
}
|
|
@@ -1449,15 +1449,15 @@ function firstWordUnits(text) {
|
|
|
1449
1449
|
return units;
|
|
1450
1450
|
}
|
|
1451
1451
|
function appendCell(a, b) {
|
|
1452
|
-
if (
|
|
1452
|
+
if (_chunkUNICY546cjs.IMAGE_CELLS.has(b)) _chunkUNICY546cjs.IMAGE_CELLS.add(a);
|
|
1453
1453
|
if (_optionalChain([a, 'access', _142 => _142.blocks, 'optionalAccess', _143 => _143.length]) || _optionalChain([b, 'access', _144 => _144.blocks, 'optionalAccess', _145 => _145.length])) {
|
|
1454
1454
|
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 }));
|
|
1455
1455
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1456
1456
|
}
|
|
1457
1457
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1458
|
-
|
|
1458
|
+
_chunkUNICY546cjs.joinCellEdges.call(void 0, a, b);
|
|
1459
1459
|
}
|
|
1460
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _148 => _148.blocks, 'optionalAccess', _149 => _149.length]) ||
|
|
1460
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _148 => _148.blocks, 'optionalAccess', _149 => _149.length]) || _chunkUNICY546cjs.IMAGE_CELLS.has(cell);
|
|
1461
1461
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1462
1462
|
var batchim = (ch) => {
|
|
1463
1463
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1465,7 +1465,7 @@ var batchim = (ch) => {
|
|
|
1465
1465
|
};
|
|
1466
1466
|
function clauseContinues(u, d) {
|
|
1467
1467
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1468
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1468
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkUNICY546cjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1469
1469
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1470
1470
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1471
1471
|
}
|
|
@@ -1473,8 +1473,8 @@ function quantityContinues(u, d) {
|
|
|
1473
1473
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1474
1474
|
}
|
|
1475
1475
|
function wordOverflows(u, d, x1, x2) {
|
|
1476
|
-
const U =
|
|
1477
|
-
if (!_optionalChain([U, 'optionalAccess', _150 => _150.length]) ||
|
|
1476
|
+
const U = _chunkUNICY546cjs.CELL_LINES.get(u);
|
|
1477
|
+
if (!_optionalChain([U, 'optionalAccess', _150 => _150.length]) || _chunkUNICY546cjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1478
1478
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1479
1479
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1480
1480
|
}
|
|
@@ -1532,7 +1532,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1532
1532
|
if (!carriedSplit) {
|
|
1533
1533
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1534
1534
|
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;
|
|
1535
|
-
const oneLine = (c) => _optionalChain([
|
|
1535
|
+
const oneLine = (c) => _optionalChain([_chunkUNICY546cjs.CELL_LINES, 'access', _152 => _152.get, 'call', _153 => _153(c), 'optionalAccess', _154 => _154.length]) === 1;
|
|
1536
1536
|
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;
|
|
1537
1537
|
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));
|
|
1538
1538
|
if (!(cut.open && !newCell)) {
|
|
@@ -1624,19 +1624,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1624
1624
|
placeJoined(blocks, i, j, joined);
|
|
1625
1625
|
continue;
|
|
1626
1626
|
}
|
|
1627
|
-
if (
|
|
1627
|
+
if (_chunkUNICY546cjs.EMPTY_PARTS.has(curr.table)) {
|
|
1628
1628
|
blocks.splice(j, 1);
|
|
1629
1629
|
i++;
|
|
1630
1630
|
continue;
|
|
1631
1631
|
}
|
|
1632
1632
|
if (joined === null) continue;
|
|
1633
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1633
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkUNICY546cjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1634
1634
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1635
1635
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1636
1636
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1637
1637
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1638
|
-
const px =
|
|
1639
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1638
|
+
const px = _chunkUNICY546cjs.TABLE_COLXS.get(prev.table), cx = _chunkUNICY546cjs.TABLE_COLXS.get(curr.table);
|
|
1639
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkUNICY546cjs.CLIP_TABLES.has(prev.table) && !_chunkUNICY546cjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1640
1640
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1641
1641
|
let currCells = curr.table.cells;
|
|
1642
1642
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1647,16 +1647,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1647
1647
|
blocks.splice(j, 1);
|
|
1648
1648
|
continue;
|
|
1649
1649
|
}
|
|
1650
|
-
if (px && cx && !
|
|
1650
|
+
if (px && cx && !_chunkUNICY546cjs.CLIP_TABLES.has(prev.table) && !_chunkUNICY546cjs.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 && _chunkUNICY546cjs.CELL_LINES.has(c))) {
|
|
1651
1651
|
const dx = px[0] - cx[0];
|
|
1652
1652
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1653
1653
|
if (_optionalChain([part, 'optionalAccess', _175 => _175.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1654
1654
|
const last = prev.table.rows - 1;
|
|
1655
1655
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1656
|
-
const U =
|
|
1657
|
-
|
|
1656
|
+
const U = _chunkUNICY546cjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkUNICY546cjs.CELL_LINES.get(currCells[0][c]);
|
|
1657
|
+
_chunkUNICY546cjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1658
1658
|
}
|
|
1659
|
-
|
|
1659
|
+
_chunkUNICY546cjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1660
1660
|
placeJoined(blocks, i, j, part.table);
|
|
1661
1661
|
continue;
|
|
1662
1662
|
}
|
|
@@ -1669,20 +1669,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1669
1669
|
caption: prev.table.caption,
|
|
1670
1670
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1671
1671
|
};
|
|
1672
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1673
|
-
if (
|
|
1672
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkUNICY546cjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1673
|
+
if (_chunkUNICY546cjs.CLIP_TABLES.has(prev.table) || _chunkUNICY546cjs.CLIP_TABLES.has(curr.table)) _chunkUNICY546cjs.CLIP_TABLES.add(merged);
|
|
1674
1674
|
placeJoined(blocks, i, j, merged);
|
|
1675
1675
|
}
|
|
1676
1676
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1677
1677
|
const t = blocks[i].table;
|
|
1678
|
-
if (blocks[i].type === "table" && t &&
|
|
1678
|
+
if (blocks[i].type === "table" && t && _chunkUNICY546cjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1679
1679
|
}
|
|
1680
1680
|
}
|
|
1681
1681
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1682
1682
|
if (!pageHeights) return;
|
|
1683
1683
|
for (let i = 0; i < blocks.length; i++) {
|
|
1684
1684
|
const L = blocks[i];
|
|
1685
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1685
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkUNICY546cjs.CLIP_TABLES.has(L.table) || _chunkUNICY546cjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1686
1686
|
const ph = pageHeights.get(L.pageNumber);
|
|
1687
1687
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1688
1688
|
let s0 = i, s1 = i;
|
|
@@ -1711,8 +1711,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1711
1711
|
}
|
|
1712
1712
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1713
1713
|
const pt = prev.table, ct = curr.table;
|
|
1714
|
-
if (!
|
|
1715
|
-
const px =
|
|
1714
|
+
if (!_chunkUNICY546cjs.CLIP_TABLES.has(pt) || !_chunkUNICY546cjs.CLIP_TABLES.has(ct)) return null;
|
|
1715
|
+
const px = _chunkUNICY546cjs.TABLE_COLXS.get(pt), cx = _chunkUNICY546cjs.TABLE_COLXS.get(ct);
|
|
1716
1716
|
if (!px || !cx) return null;
|
|
1717
1717
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1718
1718
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -1728,15 +1728,15 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1728
1728
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1729
1729
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1730
1730
|
};
|
|
1731
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1731
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkUNICY546cjs.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);
|
|
1732
1732
|
}
|
|
1733
1733
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _180 => _180.bbox, 'optionalAccess', _181 => _181.y]), lex);
|
|
1734
1734
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1735
|
-
|
|
1736
|
-
const ys =
|
|
1737
|
-
if (ys)
|
|
1738
|
-
|
|
1739
|
-
|
|
1735
|
+
_chunkUNICY546cjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1736
|
+
const ys = _chunkUNICY546cjs.TABLE_ROWYS.get(pt);
|
|
1737
|
+
if (ys) _chunkUNICY546cjs.TABLE_ROWYS.set(res.table, ys);
|
|
1738
|
+
_chunkUNICY546cjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkUNICY546cjs.PART_COLXS.get(pt), () => ( px)));
|
|
1739
|
+
_chunkUNICY546cjs.CLIP_TABLES.add(res.table);
|
|
1740
1740
|
return res.table;
|
|
1741
1741
|
}
|
|
1742
1742
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
@@ -1760,12 +1760,12 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
1760
1760
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1761
1761
|
}
|
|
1762
1762
|
function pushedLead(prev, curr) {
|
|
1763
|
-
if (!
|
|
1763
|
+
if (!_chunkUNICY546cjs.CLIP_TABLES.has(prev.table) || !_chunkUNICY546cjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1764
1764
|
const lead = leadRows(curr.table);
|
|
1765
1765
|
return lead.image && lead.height > prev.bbox.y;
|
|
1766
1766
|
}
|
|
1767
1767
|
function leadRows(t) {
|
|
1768
|
-
const ys =
|
|
1768
|
+
const ys = _chunkUNICY546cjs.TABLE_ROWYS.get(t);
|
|
1769
1769
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1770
1770
|
const anchors = anchorsOf(t);
|
|
1771
1771
|
let end = 1, image = false;
|
|
@@ -1773,17 +1773,17 @@ function leadRows(t) {
|
|
|
1773
1773
|
for (const a of anchors) {
|
|
1774
1774
|
if (a.r !== r) continue;
|
|
1775
1775
|
end = Math.max(end, r + a.rs);
|
|
1776
|
-
if (
|
|
1776
|
+
if (_chunkUNICY546cjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1777
1777
|
}
|
|
1778
1778
|
}
|
|
1779
1779
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1780
1780
|
}
|
|
1781
1781
|
function tailOf(b) {
|
|
1782
|
-
const t = b.table &&
|
|
1782
|
+
const t = b.table && _chunkUNICY546cjs.TABLE_TAIL.get(b.table);
|
|
1783
1783
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1784
1784
|
}
|
|
1785
1785
|
function firstRowSig(t) {
|
|
1786
|
-
const x =
|
|
1786
|
+
const x = _chunkUNICY546cjs.TABLE_COLXS.get(t);
|
|
1787
1787
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1788
1788
|
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, "") }));
|
|
1789
1789
|
}
|
|
@@ -1836,7 +1836,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1836
1836
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1837
1837
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1838
1838
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1839
|
-
const px =
|
|
1839
|
+
const px = _chunkUNICY546cjs.TABLE_COLXS.get(pb.table), cx = _chunkUNICY546cjs.TABLE_COLXS.get(cur.table);
|
|
1840
1840
|
if (!px || !cx) break;
|
|
1841
1841
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1842
1842
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1907,7 +1907,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1907
1907
|
var COL_MATCH_TOL = 0.5;
|
|
1908
1908
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1909
1909
|
function lastRowCell(t, x1, x2) {
|
|
1910
|
-
const xs =
|
|
1910
|
+
const xs = _chunkUNICY546cjs.TABLE_COLXS.get(t);
|
|
1911
1911
|
const covered = /* @__PURE__ */ new Set();
|
|
1912
1912
|
for (let r = 0; r < t.rows; r++) {
|
|
1913
1913
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -1925,7 +1925,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1925
1925
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1926
1926
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1927
1927
|
const part = blocks[j];
|
|
1928
|
-
const from = part.table ?
|
|
1928
|
+
const from = part.table ? _chunkUNICY546cjs.CONT_PARTS.get(part.table) : void 0;
|
|
1929
1929
|
if (!from || !part.table) {
|
|
1930
1930
|
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
1931
1931
|
continue;
|
|
@@ -1941,12 +1941,12 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1941
1941
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1942
1942
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1943
1943
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1944
|
-
if (
|
|
1945
|
-
|
|
1946
|
-
const lines =
|
|
1947
|
-
if (_optionalChain([lines, 'optionalAccess', _205 => _205.length]))
|
|
1948
|
-
if (part.pageNumber && part.bbox)
|
|
1949
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _206 => _206.blocks, 'optionalAccess', _207 => _207.length]) ||
|
|
1944
|
+
if (_chunkUNICY546cjs.IMAGE_CELLS.has(add)) _chunkUNICY546cjs.IMAGE_CELLS.add(cell);
|
|
1945
|
+
_chunkUNICY546cjs.joinCellEdges.call(void 0, cell, add);
|
|
1946
|
+
const lines = _chunkUNICY546cjs.CELL_LINES.get(add);
|
|
1947
|
+
if (_optionalChain([lines, 'optionalAccess', _205 => _205.length])) _chunkUNICY546cjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkUNICY546cjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1948
|
+
if (part.pageNumber && part.bbox) _chunkUNICY546cjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkUNICY546cjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1949
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _206 => _206.blocks, 'optionalAccess', _207 => _207.length]) || _chunkUNICY546cjs.IMAGE_CELLS.has(cell)) _chunkUNICY546cjs.EMPTY_PARTS.delete(prev.table);
|
|
1950
1950
|
blocks.splice(j, 1);
|
|
1951
1951
|
if (cell.blocks && at > 0) {
|
|
1952
1952
|
const nextAt = cell.blocks[at];
|
|
@@ -1958,11 +1958,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1958
1958
|
}
|
|
1959
1959
|
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
1960
1960
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1961
|
-
if (!_optionalChain([prev, 'optionalAccess', _208 => _208.table]) || !_optionalChain([frame, 'optionalAccess', _209 => _209.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !
|
|
1961
|
+
if (!_optionalChain([prev, 'optionalAccess', _208 => _208.table]) || !_optionalChain([frame, 'optionalAccess', _209 => _209.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkUNICY546cjs.CLIP_TABLES.has(frame.table)) return;
|
|
1962
1962
|
const inner = _optionalChain([frame, 'access', _210 => _210.table, 'access', _211 => _211.cells, 'access', _212 => _212[0], 'optionalAccess', _213 => _213[0], 'optionalAccess', _214 => _214.blocks]);
|
|
1963
1963
|
const next = _optionalChain([inner, 'optionalAccess', _215 => _215[0]]);
|
|
1964
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _216 => _216.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
1965
|
-
const px =
|
|
1964
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _216 => _216.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkUNICY546cjs.CLIP_TABLES.has(prev.table) || !_chunkUNICY546cjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1965
|
+
const px = _chunkUNICY546cjs.TABLE_COLXS.get(prev.table), nx = _chunkUNICY546cjs.TABLE_COLXS.get(next.table);
|
|
1966
1966
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1967
1967
|
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)]);
|
|
1968
1968
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
@@ -1972,15 +1972,15 @@ function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
|
1972
1972
|
function fillNestedContinuation(blocks, at) {
|
|
1973
1973
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1974
1974
|
const t = _optionalChain([prev, 'optionalAccess', _223 => _223.table]), u = _optionalChain([next, 'optionalAccess', _224 => _224.table]);
|
|
1975
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1976
|
-
const xs =
|
|
1975
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkUNICY546cjs.CLIP_TABLES.has(t) || !_chunkUNICY546cjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1976
|
+
const xs = _chunkUNICY546cjs.TABLE_COLXS.get(u);
|
|
1977
1977
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1978
1978
|
const add = _optionalChain([u, 'access', _225 => _225.cells, 'access', _226 => _226[0], 'optionalAccess', _227 => _227[0]]);
|
|
1979
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _228 => _228.blocks, 'optionalAccess', _229 => _229.length]) ||
|
|
1979
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _228 => _228.blocks, 'optionalAccess', _229 => _229.length]) || _chunkUNICY546cjs.IMAGE_CELLS.has(cell)) return;
|
|
1980
1980
|
cell.text = add.text;
|
|
1981
1981
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1982
|
-
if (
|
|
1983
|
-
|
|
1982
|
+
if (_chunkUNICY546cjs.IMAGE_CELLS.has(add)) _chunkUNICY546cjs.IMAGE_CELLS.add(cell);
|
|
1983
|
+
_chunkUNICY546cjs.joinCellEdges.call(void 0, cell, add);
|
|
1984
1984
|
blocks.splice(at, 1);
|
|
1985
1985
|
}
|
|
1986
1986
|
|
|
@@ -2580,12 +2580,12 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
2580
2580
|
}
|
|
2581
2581
|
}
|
|
2582
2582
|
for (const q of queues.values()) for (let k = 0; k < q.length; k++) {
|
|
2583
|
-
const pair = k + 1 < q.length ?
|
|
2583
|
+
const pair = k + 1 < q.length ? _chunkJFUUFJZWcjs.pairedNumber.call(void 0, q[k], q[k + 1]) : void 0;
|
|
2584
2584
|
if (pair !== void 0) {
|
|
2585
2585
|
q[k] = pair;
|
|
2586
2586
|
q[k + 1] = "";
|
|
2587
2587
|
k++;
|
|
2588
|
-
} else q[k] =
|
|
2588
|
+
} else q[k] = _chunkJFUUFJZWcjs.mapPuaText.call(void 0, q[k]);
|
|
2589
2589
|
}
|
|
2590
2590
|
const byFont = /* @__PURE__ */ new Map();
|
|
2591
2591
|
for (const it of items) {
|
|
@@ -2620,15 +2620,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
2620
2620
|
function marginContextBlocks(raw, page, view) {
|
|
2621
2621
|
const [x1, y1, x2, y2] = view;
|
|
2622
2622
|
const width = x2 - x1, height = y2 - y1;
|
|
2623
|
-
const items =
|
|
2623
|
+
const items = _chunkUNICY546cjs.filterHiddenText.call(void 0, _chunkUNICY546cjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
2624
2624
|
for (const item of items) {
|
|
2625
2625
|
item.x -= x1;
|
|
2626
2626
|
item.y -= y1;
|
|
2627
2627
|
}
|
|
2628
|
-
return
|
|
2629
|
-
const bbox =
|
|
2628
|
+
return _chunkUNICY546cjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
2629
|
+
const bbox = _chunkUNICY546cjs.computeBBox.call(void 0, line, page);
|
|
2630
2630
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
2631
|
-
return [{ type: "paragraph", text:
|
|
2631
|
+
return [{ type: "paragraph", text: _chunkUNICY546cjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkUNICY546cjs.dominantStyle.call(void 0, line) }];
|
|
2632
2632
|
});
|
|
2633
2633
|
}
|
|
2634
2634
|
|
|
@@ -2664,7 +2664,7 @@ var WINANSI_REVERSE = {
|
|
|
2664
2664
|
};
|
|
2665
2665
|
function symbolFontTable(fontName) {
|
|
2666
2666
|
if (!fontName) return void 0;
|
|
2667
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
2667
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkJFUUFJZWcjs.WINGDINGS;
|
|
2668
2668
|
return void 0;
|
|
2669
2669
|
}
|
|
2670
2670
|
function remapSymbolText(text, table) {
|
|
@@ -3567,7 +3567,7 @@ function mergeEnclosedDigits(items) {
|
|
|
3567
3567
|
if (!/^\d\d?$/.test(digits)) continue;
|
|
3568
3568
|
const mid = (inside2[0].x + inside2[inside2.length - 1].x + inside2[inside2.length - 1].w) / 2;
|
|
3569
3569
|
if (Math.abs(mid - (s.x + s.w / 2)) > s.fontSize * 0.15) continue;
|
|
3570
|
-
s.text =
|
|
3570
|
+
s.text = _chunkJFUUFJZWcjs.enclosedNumber.call(void 0, Number(digits));
|
|
3571
3571
|
for (const d of inside2) drop.add(d);
|
|
3572
3572
|
}
|
|
3573
3573
|
if (!drop.size) return;
|
|
@@ -3749,7 +3749,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3749
3749
|
if (block.type !== "heading" || !block.text) continue;
|
|
3750
3750
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
3751
3751
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _304 => _304.style, 'optionalAccess', _305 => _305.fontSize]), () => ( 0));
|
|
3752
|
-
const tocEntry = i > 0 &&
|
|
3752
|
+
const tocEntry = i > 0 && _chunkUNICY546cjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkUNICY546cjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
3753
3753
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
3754
3754
|
const proseStyle = _optionalChain([block, 'access', _306 => _306.style, 'optionalAccess', _307 => _307.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
3755
3755
|
const next = blocks[i + 1];
|
|
@@ -3847,7 +3847,7 @@ function splitSingleCellTables(blocks) {
|
|
|
3847
3847
|
const out = [];
|
|
3848
3848
|
for (const b of blocks) {
|
|
3849
3849
|
const t = b.type === "table" ? b.table : void 0;
|
|
3850
|
-
const title = t &&
|
|
3850
|
+
const title = t && _chunkUNICY546cjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3851
3851
|
if (title) {
|
|
3852
3852
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3853
3853
|
continue;
|
|
@@ -3883,7 +3883,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
3883
3883
|
const lines = cell.text.split("\n");
|
|
3884
3884
|
const out = [lines[0]];
|
|
3885
3885
|
for (const line of lines.slice(1)) {
|
|
3886
|
-
if (
|
|
3886
|
+
if (_chunkUNICY546cjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
3887
3887
|
else out.push(line);
|
|
3888
3888
|
}
|
|
3889
3889
|
cell.text = out.join("\n");
|
|
@@ -3903,10 +3903,10 @@ function cleanPdfText(text, opts) {
|
|
|
3903
3903
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
3904
3904
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
3905
3905
|
if (line.startsWith("|")) {
|
|
3906
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
3906
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkUNICY546cjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
3907
3907
|
}
|
|
3908
3908
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _387 => _387.exec, 'call', _388 => _388(line), 'optionalAccess', _389 => _389[0]]), () => ( ""));
|
|
3909
|
-
return mark +
|
|
3909
|
+
return mark + _chunkUNICY546cjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
3910
3910
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
3911
3911
|
}
|
|
3912
3912
|
function startsWithMarker(line) {
|
|
@@ -3938,7 +3938,7 @@ function mergeKoreanLines(text) {
|
|
|
3938
3938
|
continue;
|
|
3939
3939
|
}
|
|
3940
3940
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
3941
|
-
result[result.length - 1] = prev +
|
|
3941
|
+
result[result.length - 1] = prev + _chunkUNICY546cjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
3942
3942
|
} else {
|
|
3943
3943
|
result.push(curr);
|
|
3944
3944
|
}
|
|
@@ -3954,7 +3954,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3954
3954
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3955
3955
|
for (const a of annots) {
|
|
3956
3956
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3957
|
-
const url =
|
|
3957
|
+
const url = _chunkPNSALBXHcjs.sanitizeHref.call(void 0, a.url);
|
|
3958
3958
|
if (!url) continue;
|
|
3959
3959
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3960
3960
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -4006,7 +4006,7 @@ function mergeLinkRuns(markdown) {
|
|
|
4006
4006
|
|
|
4007
4007
|
// src/pdf/formula-ocr.ts
|
|
4008
4008
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
4009
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
4009
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-HK2MNZ3Q.cjs")));
|
|
4010
4010
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
4011
4011
|
await ensureFormulaModels((p) => {
|
|
4012
4012
|
if (p.phase === "download" && p.total) {
|
|
@@ -4197,13 +4197,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
4197
4197
|
try {
|
|
4198
4198
|
return await Promise.race([
|
|
4199
4199
|
loadingTask.promise.catch((e) => {
|
|
4200
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
4200
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkPNSALBXHcjs.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)");
|
|
4201
4201
|
throw e;
|
|
4202
4202
|
}),
|
|
4203
4203
|
new Promise((_, reject) => {
|
|
4204
4204
|
timer = setTimeout(() => {
|
|
4205
4205
|
loadingTask.destroy();
|
|
4206
|
-
reject(new (0,
|
|
4206
|
+
reject(new (0, _chunkPNSALBXHcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
4207
4207
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
4208
4208
|
})
|
|
4209
4209
|
]);
|
|
@@ -4213,14 +4213,14 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
4213
4213
|
}
|
|
4214
4214
|
async function parsePdfDocument(buffer, options) {
|
|
4215
4215
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _390 => _390.formulaOcr]) ? buffer : null;
|
|
4216
|
-
const ocrOptionError =
|
|
4217
|
-
if (ocrOptionError) throw new (0,
|
|
4218
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _391 => _391.ocr]) === void 0 && await
|
|
4216
|
+
const ocrOptionError = _chunkJFUUFJZWcjs.validateOcrOptions.call(void 0, options);
|
|
4217
|
+
if (ocrOptionError) throw new (0, _chunkPNSALBXHcjs.KordocError)(ocrOptionError);
|
|
4218
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _391 => _391.ocr]) === void 0 && await _chunkUNICY546cjs.ocrModelsCached.call(void 0, _chunkUNICY546cjs.resolveOcrModels.call(void 0, options));
|
|
4219
4219
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _392 => _392.ocr]) || autoOcr ? buffer : null;
|
|
4220
4220
|
const doc = await loadPdfWithTimeout(buffer);
|
|
4221
4221
|
try {
|
|
4222
4222
|
const pageCount = doc.numPages;
|
|
4223
|
-
if (pageCount === 0) throw new (0,
|
|
4223
|
+
if (pageCount === 0) throw new (0, _chunkPNSALBXHcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
4224
4224
|
const metadata = { pageCount, pageMode: "layout" };
|
|
4225
4225
|
await extractPdfMetadata(doc, metadata);
|
|
4226
4226
|
const blocks = [];
|
|
@@ -4249,7 +4249,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4249
4249
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
4250
4250
|
const carry = {};
|
|
4251
4251
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
4252
|
-
const wrapLexicon = new (0,
|
|
4252
|
+
const wrapLexicon = new (0, _chunkUNICY546cjs.WrapLexicon)();
|
|
4253
4253
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
4254
4254
|
const headerContext = [];
|
|
4255
4255
|
if (pageFilter && _optionalChain([options, 'optionalAccess', _395 => _395.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
@@ -4296,8 +4296,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4296
4296
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
4297
4297
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4298
4298
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4299
|
-
const items =
|
|
4300
|
-
const filtered =
|
|
4299
|
+
const items = _chunkUNICY546cjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
4300
|
+
const filtered = _chunkUNICY546cjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
4301
4301
|
const joined = joinVerticalColumns(filtered.visible);
|
|
4302
4302
|
const visible = dropTabLeaderDots(joined);
|
|
4303
4303
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -4324,7 +4324,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4324
4324
|
} : rawOps;
|
|
4325
4325
|
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _402 => _402(loadedName), 'optionalAccess', _403 => _403.name]));
|
|
4326
4326
|
remapControlGlyphs(visible, differencesOf);
|
|
4327
|
-
await
|
|
4327
|
+
await _chunkUNICY546cjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
4328
4328
|
const faces = /* @__PURE__ */ new Map();
|
|
4329
4329
|
for (const it of visible) {
|
|
4330
4330
|
if (!it.fontName) continue;
|
|
@@ -4337,12 +4337,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4337
4337
|
it.fontName = face;
|
|
4338
4338
|
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _405 => _405(face), 'optionalAccess', _406 => _406.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
4339
4339
|
}
|
|
4340
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
4341
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
4340
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkJFUUFJZWcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
4341
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkJFUUFJZWcjs.escapeLiteralTags.call(void 0, it.text);
|
|
4342
4342
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
4343
4343
|
const pageArea = pageW * pageH;
|
|
4344
4344
|
if (pageArea > 0) {
|
|
4345
|
-
const imageRegions =
|
|
4345
|
+
const imageRegions = _chunkUNICY546cjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
4346
4346
|
let uncovered = 0;
|
|
4347
4347
|
for (const r of imageRegions) {
|
|
4348
4348
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -4368,11 +4368,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4368
4368
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
4369
4369
|
}
|
|
4370
4370
|
const marks = superscriptNoteMarks(visible);
|
|
4371
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
4371
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkUNICY546cjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
4372
4372
|
const stamp = marginStamp(visible);
|
|
4373
4373
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
4374
|
-
const rightArrows = _optionalChain([options, 'optionalAccess', _407 => _407.tables]) !== false ? await
|
|
4375
|
-
const pageBlocks = orderTwoUpPage(
|
|
4374
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _407 => _407.tables]) !== false ? await _chunkUNICY546cjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
4375
|
+
const pageBlocks = orderTwoUpPage(_chunkUNICY546cjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _408 => _408.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
4376
4376
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
4377
4377
|
for (const b of pageBlocks) blocks.push(b);
|
|
4378
4378
|
try {
|
|
@@ -4398,11 +4398,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4398
4398
|
if (_optionalChain([options, 'optionalAccess', _410 => _410.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
4399
4399
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
4400
4400
|
}
|
|
4401
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
4401
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkPNSALBXHcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
4402
4402
|
parsedPages++;
|
|
4403
4403
|
_optionalChain([options, 'optionalAccess', _411 => _411.onProgress, 'optionalCall', _412 => _412(parsedPages, totalTarget)]);
|
|
4404
4404
|
} catch (pageErr) {
|
|
4405
|
-
if (pageErr instanceof
|
|
4405
|
+
if (pageErr instanceof _chunkPNSALBXHcjs.KordocError) throw pageErr;
|
|
4406
4406
|
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" });
|
|
4407
4407
|
} finally {
|
|
4408
4408
|
_optionalChain([loadedPage, 'optionalAccess', _413 => _413.cleanup, 'call', _414 => _414()]);
|
|
@@ -4433,12 +4433,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4433
4433
|
}
|
|
4434
4434
|
if (targets.size > 0) {
|
|
4435
4435
|
try {
|
|
4436
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
4436
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-GA5QJFNK.cjs")));
|
|
4437
4437
|
const mode = typeof _optionalChain([options, 'optionalAccess', _419 => _419.ocr]) === "function" ? options.ocr : "builtin";
|
|
4438
4438
|
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _420 => _420.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _421 => _421.find, 'call', _422 => _422((q) => q.page === p), 'optionalAccess', _423 => _423.needsOcr])));
|
|
4439
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
4439
|
+
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-GA5QJFNK.cjs")));
|
|
4440
4440
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _424 => _424.onProgress]), _optionalChain([options, 'optionalAccess', _425 => _425.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
4441
|
-
for (const obs of ocrPageBlocks.values())
|
|
4441
|
+
for (const obs of ocrPageBlocks.values()) _chunkJFUUFJZWcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
4442
4442
|
if (ocrPageBlocks.size > 0) {
|
|
4443
4443
|
const replacePages = /* @__PURE__ */ new Set();
|
|
4444
4444
|
for (const [p, obs] of ocrPageBlocks) {
|
|
@@ -4449,7 +4449,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4449
4449
|
continue;
|
|
4450
4450
|
}
|
|
4451
4451
|
const regions = ocrRegions.get(p);
|
|
4452
|
-
if (!regions ||
|
|
4452
|
+
if (!regions || _chunkUNICY546cjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
4453
4453
|
ocrDone.add(p);
|
|
4454
4454
|
if (_optionalChain([pageImageBlocks, 'access', _430 => _430.get, 'call', _431 => _431(p), 'optionalAccess', _432 => _432.length]) === 1) pageImageBlocks.delete(p);
|
|
4455
4455
|
}
|
|
@@ -4502,17 +4502,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4502
4502
|
}
|
|
4503
4503
|
}
|
|
4504
4504
|
if (_optionalChain([options, 'optionalAccess', _433 => _433.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
4505
|
-
const removed =
|
|
4506
|
-
const running =
|
|
4505
|
+
const removed = _chunkUNICY546cjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
4506
|
+
const running = _chunkUNICY546cjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
4507
4507
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
4508
4508
|
blocks.splice(removed[ri], 1);
|
|
4509
4509
|
}
|
|
4510
|
-
const stripped =
|
|
4510
|
+
const stripped = _chunkUNICY546cjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
4511
4511
|
if (stripped !== blocks) {
|
|
4512
4512
|
blocks.length = 0;
|
|
4513
4513
|
blocks.push(...stripped);
|
|
4514
4514
|
}
|
|
4515
|
-
const kept =
|
|
4515
|
+
const kept = _chunkUNICY546cjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
4516
4516
|
if (kept !== blocks) {
|
|
4517
4517
|
blocks.length = 0;
|
|
4518
4518
|
blocks.push(...kept);
|
|
@@ -4521,12 +4521,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4521
4521
|
mergeContinuedCells(blocks, pageHeights);
|
|
4522
4522
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
4523
4523
|
if (_optionalChain([options, 'optionalAccess', _434 => _434.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
4524
|
-
const boxes =
|
|
4524
|
+
const boxes = _chunkUNICY546cjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
4525
4525
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
4526
4526
|
}
|
|
4527
4527
|
splitContactTables(blocks);
|
|
4528
|
-
if (!_optionalChain([options, 'optionalAccess', _435 => _435.keepTrailingEmptyCols]))
|
|
4529
|
-
|
|
4528
|
+
if (!_optionalChain([options, 'optionalAccess', _435 => _435.keepTrailingEmptyCols])) _chunkUNICY546cjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
4529
|
+
_chunkUNICY546cjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
4530
4530
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
4531
4531
|
if (_optionalChain([options, 'optionalAccess', _436 => _436.formulaOcr]) && formulaBuffer) {
|
|
4532
4532
|
try {
|
|
@@ -4538,21 +4538,21 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4538
4538
|
});
|
|
4539
4539
|
}
|
|
4540
4540
|
}
|
|
4541
|
-
const medianFontSize =
|
|
4541
|
+
const medianFontSize = _chunkUNICY546cjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
4542
4542
|
if (medianFontSize > 0) {
|
|
4543
|
-
|
|
4544
|
-
}
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4543
|
+
_chunkUNICY546cjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
4544
|
+
}
|
|
4545
|
+
_chunkUNICY546cjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
4546
|
+
_chunkUNICY546cjs.detectTypographyHeadings.call(void 0, blocks);
|
|
4547
|
+
_chunkUNICY546cjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
4548
|
+
_chunkUNICY546cjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
4549
|
+
_chunkUNICY546cjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
4550
|
+
_chunkUNICY546cjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
4551
|
+
_chunkUNICY546cjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
4552
|
+
_chunkUNICY546cjs.detectMarkerHeadings.call(void 0, blocks);
|
|
4553
4553
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
4554
|
-
|
|
4555
|
-
|
|
4554
|
+
_chunkUNICY546cjs.detectTableCaptions.call(void 0, blocks);
|
|
4555
|
+
_chunkUNICY546cjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
4556
4556
|
sanitizeBlockControlChars(blocks);
|
|
4557
4557
|
let outBlocks = splitSingleCellTables(blocks);
|
|
4558
4558
|
if (_optionalChain([options, 'optionalAccess', _437 => _437.layoutTables]) !== "keep") {
|
|
@@ -4573,19 +4573,19 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4573
4573
|
const shown = /* @__PURE__ */ new Map();
|
|
4574
4574
|
const markContent = (bs) => {
|
|
4575
4575
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
4576
|
-
if (
|
|
4577
|
-
const lines =
|
|
4578
|
-
if (lines)
|
|
4576
|
+
if (_chunkUNICY546cjs.IMAGE_CELLS.has(c)) _chunkJFUUFJZWcjs.CONTENT_CELLS.add(c);
|
|
4577
|
+
const lines = _chunkUNICY546cjs.CELL_LINES.get(c);
|
|
4578
|
+
if (lines) _chunkJFUUFJZWcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
4579
4579
|
markContent(c.blocks);
|
|
4580
4580
|
}
|
|
4581
4581
|
};
|
|
4582
4582
|
const visual = (bs) => bs.flatMap((b) => {
|
|
4583
4583
|
if (b.type !== "table") return [b];
|
|
4584
|
-
if (!hancom && b.table &&
|
|
4584
|
+
if (!hancom && b.table && _chunkUNICY546cjs.CLIP_TABLES.has(b.table)) return [b];
|
|
4585
4585
|
let v = shown.get(b);
|
|
4586
4586
|
if (!v) {
|
|
4587
4587
|
markContent([b]);
|
|
4588
|
-
shown.set(b, v =
|
|
4588
|
+
shown.set(b, v = _chunkJFUUFJZWcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _440 => _440.keepTrailingEmptyCols])));
|
|
4589
4589
|
}
|
|
4590
4590
|
return v;
|
|
4591
4591
|
});
|
|
@@ -4594,13 +4594,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4594
4594
|
blocks.length = 0;
|
|
4595
4595
|
for (const b of kept) blocks.push(b);
|
|
4596
4596
|
}
|
|
4597
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
4598
|
-
if (_optionalChain([options, 'optionalAccess', _442 => _442.tableFormat]) === "gfm")
|
|
4597
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkJFUUFJZWcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _441 => _441.tableFormat]) }), { keepLoneNumbers: true }));
|
|
4598
|
+
if (_optionalChain([options, 'optionalAccess', _442 => _442.tableFormat]) === "gfm") _chunkJFUUFJZWcjs.assignTableIds.call(void 0, blocks);
|
|
4599
4599
|
let markdown = finishMarkdown(outBlocks);
|
|
4600
4600
|
const outline = collectPdfOutline(outBlocks);
|
|
4601
4601
|
return {
|
|
4602
4602
|
markdown,
|
|
4603
|
-
pages:
|
|
4603
|
+
pages: _chunkIGG63DFKcjs.blocksToPages.call(void 0, splitPageTables(_chunkUNICY546cjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
4604
4604
|
blocks,
|
|
4605
4605
|
metadata,
|
|
4606
4606
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -4680,5 +4680,5 @@ function marginStamp(items) {
|
|
|
4680
4680
|
|
|
4681
4681
|
|
|
4682
4682
|
|
|
4683
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
4684
|
-
//# sourceMappingURL=parser-
|
|
4683
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkUNICY546cjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkUNICY546cjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkUNICY546cjs.removeHeaderFooterBlocks;
|
|
4684
|
+
//# sourceMappingURL=parser-RPAHN3OR.cjs.map
|