kordoc 4.19.2 → 4.20.0
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/NOTICE +25 -0
- package/README.md +2 -1
- package/THIRD_PARTY/hwp-auto-docfit.LICENSE +23 -0
- package/dist/{-3JIHF2AL.js → -TTRGLREH.js} +11 -11
- package/dist/{chunk-I2TBI7PN.js → chunk-2U475PJF.js} +2 -2
- package/dist/{chunk-R2JM2HOJ.js → chunk-4DIMX2KU.js} +4 -4
- package/dist/{chunk-GNUGD4RO.js → chunk-4WOG2SLT.js} +2 -2
- package/dist/{chunk-QZ63HXEG.js → chunk-527NBMUE.js} +6 -6
- package/dist/{chunk-PWQ2BVAT.js → chunk-7H5GT7HM.js} +22 -3
- package/dist/{chunk-PWQ2BVAT.js.map → chunk-7H5GT7HM.js.map} +1 -1
- package/dist/{chunk-T2DZTOGG.cjs → chunk-AXQDWE42.cjs} +12 -12
- package/dist/{chunk-T2DZTOGG.cjs.map → chunk-AXQDWE42.cjs.map} +1 -1
- package/dist/{chunk-ORGWGR4K.cjs → chunk-CJFIHH2N.cjs} +6 -6
- package/dist/{chunk-ORGWGR4K.cjs.map → chunk-CJFIHH2N.cjs.map} +1 -1
- package/dist/{chunk-XPM7WC54.js → chunk-CKFKC22O.js} +4 -4
- package/dist/{chunk-JK7N4R4K.js → chunk-CPZ2LLZA.js} +2 -2
- package/dist/{chunk-6ZBORHFB.js → chunk-CS2VWXDS.js} +2 -2
- package/dist/{chunk-EUCBMW6C.js → chunk-DPD2L5UK.js} +3 -3
- package/dist/{chunk-AOVMOCTK.js → chunk-GHAJHXYA.js} +2 -2
- package/dist/{chunk-4CS7XE2Q.js → chunk-JYV3XQYW.js} +2 -2
- package/dist/{chunk-MZ6XNFZL.cjs → chunk-K5GCIB2I.cjs} +2 -2
- package/dist/{chunk-MZ6XNFZL.cjs.map → chunk-K5GCIB2I.cjs.map} +1 -1
- package/dist/{chunk-5PGOZBEQ.cjs → chunk-KDCPBF4X.cjs} +22 -22
- package/dist/{chunk-5PGOZBEQ.cjs.map → chunk-KDCPBF4X.cjs.map} +1 -1
- package/dist/{chunk-NV46IWKF.js → chunk-LQ4IDHET.js} +234 -24
- package/dist/chunk-LQ4IDHET.js.map +1 -0
- package/dist/{chunk-U6AJU2VD.js → chunk-MNPPMJBN.js} +2 -2
- package/dist/{chunk-J75TVRJB.js → chunk-MXADBQ7E.js} +2 -2
- package/dist/{chunk-B4R443MV.js → chunk-NVBX2NKZ.js} +2 -2
- package/dist/{chunk-TM4T4NYJ.js → chunk-OX5FA2MU.js} +2 -2
- package/dist/{chunk-WQAGDJIP.cjs → chunk-RMDFN5ZF.cjs} +3 -3
- package/dist/{chunk-WQAGDJIP.cjs.map → chunk-RMDFN5ZF.cjs.map} +1 -1
- package/dist/{chunk-QYJPU4FZ.js → chunk-TM7IOP4P.js} +2 -2
- package/dist/{chunk-OKHKEYTL.js → chunk-URQM5TBD.js} +2 -2
- package/dist/{chunk-VO22VAR3.js → chunk-VVKMBLG2.js} +2 -2
- package/dist/{chunk-JXJDXDOU.js → chunk-WLNEQGQC.js} +3 -3
- package/dist/{chunk-56ZWAREM.js → chunk-WLWWODBQ.js} +2 -2
- package/dist/{chunk-RVBQT2PD.cjs → chunk-WWOU6ZQ3.cjs} +3 -3
- package/dist/{chunk-RVBQT2PD.cjs.map → chunk-WWOU6ZQ3.cjs.map} +1 -1
- package/dist/{chunk-AKSCTGKG.js → chunk-X5YHJHWB.js} +2 -2
- package/dist/chunks-3NIFJFRQ.js +10 -0
- package/dist/cli.js +366 -44
- package/dist/cli.js.map +1 -1
- package/dist/{formula-STIFIS57.js → formula-D6GGALWI.js} +3 -3
- package/dist/{formula-RNATQ3FQ.cjs → formula-FE6LEZTT.cjs} +9 -9
- package/dist/{formula-RNATQ3FQ.cjs.map → formula-FE6LEZTT.cjs.map} +1 -1
- package/dist/{formula-RSTTP626.js → formula-KWOAYEOG.js} +4 -4
- package/dist/{image-ocr-XKSAEEXP.js → image-ocr-XDODV43Y.js} +9 -9
- package/dist/{image-ocr-7L5TBBPA.cjs → image-ocr-XGGIYCZ2.cjs} +15 -15
- package/dist/{image-ocr-7L5TBBPA.cjs.map → image-ocr-XGGIYCZ2.cjs.map} +1 -1
- package/dist/{image-ocr-R6ZDFBAN.js → image-ocr-YYTFOUSY.js} +6 -6
- package/dist/index.cjs +682 -459
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +242 -19
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-NGTKULP7.js → model-bundle-WPFLIKYM.js} +5 -5
- package/dist/{models-QOSU5SYL.js → models-WJ5QYELV.js} +5 -5
- package/dist/{parser-AIQBU7FS.cjs → parser-6P5ZRWXG.cjs} +132 -132
- package/dist/{parser-AIQBU7FS.cjs.map → parser-6P5ZRWXG.cjs.map} +1 -1
- package/dist/{parser-5GUEP6EK.js → parser-LY67CB7A.js} +8 -8
- package/dist/{parser-3G4G6SST.js → parser-QKLUIMHG.js} +11 -11
- package/dist/pdf-ocr-6L4EDRVO.js +20 -0
- package/dist/pdf-ocr-J7DHJJ3I.js +16 -0
- package/dist/pdf-ocr-MODN6GBT.cjs +17 -0
- package/dist/{pdf-ocr-7OAFUDM4.cjs.map → pdf-ocr-MODN6GBT.cjs.map} +1 -1
- package/dist/{profile-io-ZVNMDLLS.js → profile-io-I4ORJOE4.js} +3 -3
- package/dist/{rasterize-Y2RLMVCL.js → rasterize-MZU5LIA5.js} +3 -3
- package/dist/{redact-doc-PNRDDBI3.js → redact-doc-NEUEBXFH.js} +11 -11
- package/dist/{render-S3ALARVO.js → render-IL2DYXDP.js} +7 -7
- package/dist/seal-O5DKZGTR.js +10 -0
- package/dist/{setup-JH66VSFZ.js → setup-PGOCB7YG.js} +3 -3
- package/dist/visual-PYV4ZMLH.js +20 -0
- package/dist/{watch-KMB2FTOD.js → watch-2F5AMHCW.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-NV46IWKF.js.map +0 -1
- package/dist/chunks-2EC2R7PY.js +0 -10
- package/dist/pdf-ocr-7OAFUDM4.cjs +0 -17
- package/dist/pdf-ocr-DAXS5RX4.js +0 -16
- package/dist/pdf-ocr-R3VGX6F2.js +0 -20
- package/dist/seal-EJWPS5VK.js +0 -10
- package/dist/visual-GDXMKDVY.js +0 -20
- /package/dist/{-3JIHF2AL.js.map → -TTRGLREH.js.map} +0 -0
- /package/dist/{chunk-I2TBI7PN.js.map → chunk-2U475PJF.js.map} +0 -0
- /package/dist/{chunk-R2JM2HOJ.js.map → chunk-4DIMX2KU.js.map} +0 -0
- /package/dist/{chunk-GNUGD4RO.js.map → chunk-4WOG2SLT.js.map} +0 -0
- /package/dist/{chunk-QZ63HXEG.js.map → chunk-527NBMUE.js.map} +0 -0
- /package/dist/{chunk-XPM7WC54.js.map → chunk-CKFKC22O.js.map} +0 -0
- /package/dist/{chunk-JK7N4R4K.js.map → chunk-CPZ2LLZA.js.map} +0 -0
- /package/dist/{chunk-6ZBORHFB.js.map → chunk-CS2VWXDS.js.map} +0 -0
- /package/dist/{chunk-EUCBMW6C.js.map → chunk-DPD2L5UK.js.map} +0 -0
- /package/dist/{chunk-AOVMOCTK.js.map → chunk-GHAJHXYA.js.map} +0 -0
- /package/dist/{chunk-4CS7XE2Q.js.map → chunk-JYV3XQYW.js.map} +0 -0
- /package/dist/{chunk-U6AJU2VD.js.map → chunk-MNPPMJBN.js.map} +0 -0
- /package/dist/{chunk-J75TVRJB.js.map → chunk-MXADBQ7E.js.map} +0 -0
- /package/dist/{chunk-B4R443MV.js.map → chunk-NVBX2NKZ.js.map} +0 -0
- /package/dist/{chunk-TM4T4NYJ.js.map → chunk-OX5FA2MU.js.map} +0 -0
- /package/dist/{chunk-QYJPU4FZ.js.map → chunk-TM7IOP4P.js.map} +0 -0
- /package/dist/{chunk-OKHKEYTL.js.map → chunk-URQM5TBD.js.map} +0 -0
- /package/dist/{chunk-VO22VAR3.js.map → chunk-VVKMBLG2.js.map} +0 -0
- /package/dist/{chunk-JXJDXDOU.js.map → chunk-WLNEQGQC.js.map} +0 -0
- /package/dist/{chunk-56ZWAREM.js.map → chunk-WLWWODBQ.js.map} +0 -0
- /package/dist/{chunk-AKSCTGKG.js.map → chunk-X5YHJHWB.js.map} +0 -0
- /package/dist/{chunks-2EC2R7PY.js.map → chunks-3NIFJFRQ.js.map} +0 -0
- /package/dist/{formula-STIFIS57.js.map → formula-D6GGALWI.js.map} +0 -0
- /package/dist/{formula-RSTTP626.js.map → formula-KWOAYEOG.js.map} +0 -0
- /package/dist/{image-ocr-XKSAEEXP.js.map → image-ocr-XDODV43Y.js.map} +0 -0
- /package/dist/{image-ocr-R6ZDFBAN.js.map → image-ocr-YYTFOUSY.js.map} +0 -0
- /package/dist/{model-bundle-NGTKULP7.js.map → model-bundle-WPFLIKYM.js.map} +0 -0
- /package/dist/{models-QOSU5SYL.js.map → models-WJ5QYELV.js.map} +0 -0
- /package/dist/{parser-5GUEP6EK.js.map → parser-LY67CB7A.js.map} +0 -0
- /package/dist/{parser-3G4G6SST.js.map → parser-QKLUIMHG.js.map} +0 -0
- /package/dist/{pdf-ocr-DAXS5RX4.js.map → pdf-ocr-6L4EDRVO.js.map} +0 -0
- /package/dist/{pdf-ocr-R3VGX6F2.js.map → pdf-ocr-J7DHJJ3I.js.map} +0 -0
- /package/dist/{profile-io-ZVNMDLLS.js.map → profile-io-I4ORJOE4.js.map} +0 -0
- /package/dist/{rasterize-Y2RLMVCL.js.map → rasterize-MZU5LIA5.js.map} +0 -0
- /package/dist/{redact-doc-PNRDDBI3.js.map → redact-doc-NEUEBXFH.js.map} +0 -0
- /package/dist/{render-S3ALARVO.js.map → render-IL2DYXDP.js.map} +0 -0
- /package/dist/{seal-EJWPS5VK.js.map → seal-O5DKZGTR.js.map} +0 -0
- /package/dist/{setup-JH66VSFZ.js.map → setup-PGOCB7YG.js.map} +0 -0
- /package/dist/{visual-GDXMKDVY.js.map → visual-PYV4ZMLH.js.map} +0 -0
- /package/dist/{watch-KMB2FTOD.js.map → watch-2F5AMHCW.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 _chunkWWOU6ZQ3cjs = require('./chunk-WWOU6ZQ3.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -58,7 +58,7 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
var
|
|
61
|
+
var _chunkKDCPBF4Xcjs = require('./chunk-KDCPBF4X.cjs');
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
|
|
@@ -70,12 +70,12 @@ var _chunk5PGOZBEQcjs = require('./chunk-5PGOZBEQ.cjs');
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
var
|
|
74
|
-
require('./chunk-
|
|
73
|
+
var _chunkCJFIHH2Ncjs = require('./chunk-CJFIHH2N.cjs');
|
|
74
|
+
require('./chunk-RMDFN5ZF.cjs');
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
var
|
|
78
|
+
var _chunkK5GCIB2Icjs = require('./chunk-K5GCIB2I.cjs');
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -116,7 +116,7 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
116
116
|
const selectedSet = new Set(selected), seen = /* @__PURE__ */ new Set();
|
|
117
117
|
for (const block of selected) {
|
|
118
118
|
if (seen.has(block)) continue;
|
|
119
|
-
const frame =
|
|
119
|
+
const frame = _chunkKDCPBF4Xcjs.FRAME_READING_UNITS.get(block);
|
|
120
120
|
const source = _optionalChain([frame, 'optionalAccess', _25 => _25.blocks, 'access', _26 => _26.every, 'call', _27 => _27((member) => selectedSet.has(member))]) ? frame.blocks : [block];
|
|
121
121
|
source.forEach((member) => seen.add(member));
|
|
122
122
|
const available = source.filter((member) => !hasOriginal(member));
|
|
@@ -124,13 +124,13 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
124
124
|
for (const unit of units) {
|
|
125
125
|
const b = unit.bbox;
|
|
126
126
|
const index = blocks.findIndex((existing) => {
|
|
127
|
-
const e = _nullishCoalesce(_optionalChain([
|
|
127
|
+
const e = _nullishCoalesce(_optionalChain([_chunkKDCPBF4Xcjs.FRAME_READING_UNITS, 'access', _28 => _28.get, 'call', _29 => _29(existing), 'optionalAccess', _30 => _30.bbox]), () => ( existing.bbox));
|
|
128
128
|
if (existing.pageNumber !== page || !e) return false;
|
|
129
129
|
const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
|
|
130
130
|
return e.y < b.y || beside;
|
|
131
131
|
});
|
|
132
132
|
const placed = unit.blocks.map((member) => member.type === "paragraph" ? { ...member, style: void 0 } : member);
|
|
133
|
-
if (unit.atomic)
|
|
133
|
+
if (unit.atomic) _chunkKDCPBF4Xcjs.recordFrameReadingUnit.call(void 0, placed, unit.bbox);
|
|
134
134
|
blocks.splice(index < 0 ? blocks.length : index, 0, ...placed);
|
|
135
135
|
added += placed.length;
|
|
136
136
|
}
|
|
@@ -331,7 +331,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
331
331
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
332
332
|
state.seen.set(hash, filename);
|
|
333
333
|
if (withBytes) {
|
|
334
|
-
const png =
|
|
334
|
+
const png = _chunkWWOU6ZQ3cjs.encodePng.call(void 0, w, h, rgba);
|
|
335
335
|
state.totalBytes += png.length;
|
|
336
336
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
337
337
|
}
|
|
@@ -799,7 +799,7 @@ function rowStarts(t) {
|
|
|
799
799
|
}
|
|
800
800
|
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));
|
|
801
801
|
function cellPage(cell) {
|
|
802
|
-
const p =
|
|
802
|
+
const p = _chunkCJFIHH2Ncjs.CELL_PAGES.get(cell);
|
|
803
803
|
if (p !== void 0 || !_optionalChain([cell, 'access', _63 => _63.blocks, 'optionalAccess', _64 => _64.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
804
804
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
805
805
|
}
|
|
@@ -828,7 +828,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
828
828
|
rows.forEach((starts, r) => {
|
|
829
829
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
830
830
|
for (const { cell } of starts) {
|
|
831
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
831
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkCJFIHH2Ncjs.CELL_PAGES.set(cell, page2);
|
|
832
832
|
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _67 => _67.find, 'call', _68 => _68((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
|
|
833
833
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
834
834
|
}
|
|
@@ -877,8 +877,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
877
877
|
if (!splits.length) continue;
|
|
878
878
|
const clone = (cell, patch) => {
|
|
879
879
|
const out = { ...cell, ...patch };
|
|
880
|
-
const p =
|
|
881
|
-
if (p !== void 0)
|
|
880
|
+
const p = _chunkCJFIHH2Ncjs.CELL_PAGES.get(cell);
|
|
881
|
+
if (p !== void 0) _chunkCJFIHH2Ncjs.CELL_PAGES.set(out, p);
|
|
882
882
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
883
883
|
return out;
|
|
884
884
|
};
|
|
@@ -888,7 +888,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
888
888
|
for (const { cell, c, split } of splits) {
|
|
889
889
|
cells[r][c] = clone(cell, split.head);
|
|
890
890
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
891
|
-
|
|
891
|
+
_chunkCJFIHH2Ncjs.CELL_PAGES.set(tail, split.page);
|
|
892
892
|
setSplits(tail, split.rest);
|
|
893
893
|
row[c] = tail;
|
|
894
894
|
}
|
|
@@ -1007,19 +1007,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1007
1007
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
1008
1008
|
}
|
|
1009
1009
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
1010
|
-
const lines =
|
|
1011
|
-
if (lines)
|
|
1012
|
-
if (
|
|
1013
|
-
const edges =
|
|
1010
|
+
const lines = _chunkKDCPBF4Xcjs.CELL_LINES.get(a.cell);
|
|
1011
|
+
if (lines) _chunkKDCPBF4Xcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
1012
|
+
if (_chunkKDCPBF4Xcjs.IMAGE_CELLS.has(a.cell)) _chunkKDCPBF4Xcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
1013
|
+
const edges = _chunkCJFIHH2Ncjs.CELL_EDGES.get(a.cell);
|
|
1014
1014
|
if (edges) {
|
|
1015
|
-
|
|
1015
|
+
_chunkCJFIHH2Ncjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
1016
1016
|
edged = true;
|
|
1017
1017
|
}
|
|
1018
1018
|
return true;
|
|
1019
1019
|
};
|
|
1020
|
-
for (const a of pa) if (!
|
|
1020
|
+
for (const a of pa) if (!_chunkKDCPBF4Xcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
1021
1021
|
for (const a of ca) {
|
|
1022
|
-
if (a.r < skip ||
|
|
1022
|
+
if (a.r < skip || _chunkKDCPBF4Xcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
1023
1023
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
1024
1024
|
}
|
|
1025
1025
|
const first = prev.rows;
|
|
@@ -1043,9 +1043,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1043
1043
|
const grown = { ...above, rs: newRs };
|
|
1044
1044
|
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;
|
|
1045
1045
|
}
|
|
1046
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1046
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkKDCPBF4Xcjs.FILLER_CELLS.add(grid[r][c]);
|
|
1047
1047
|
if (edged) {
|
|
1048
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1048
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkCJFIHH2Ncjs.CELL_EDGES.set(grid[r][c], _chunkKDCPBF4Xcjs.NO_EDGES);
|
|
1049
1049
|
}
|
|
1050
1050
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1051
1051
|
let r = prev.rows;
|
|
@@ -1054,7 +1054,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1054
1054
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1055
1055
|
}
|
|
1056
1056
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1057
|
-
const pr =
|
|
1057
|
+
const pr = _chunkKDCPBF4Xcjs.ROW_RULES.get(prev), cr = _chunkKDCPBF4Xcjs.ROW_RULES.get(curr);
|
|
1058
1058
|
const shifted = dx !== 0;
|
|
1059
1059
|
const cut = {
|
|
1060
1060
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1065,7 +1065,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1065
1065
|
if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U)) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
|
|
1066
1066
|
if (pr && cr) {
|
|
1067
1067
|
const cutRuled = pr.bottom || cr.top;
|
|
1068
|
-
|
|
1068
|
+
_chunkKDCPBF4Xcjs.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) });
|
|
1069
1069
|
}
|
|
1070
1070
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1071
1071
|
}
|
|
@@ -1119,7 +1119,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1119
1119
|
if (!crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1120
1120
|
if (!straddles && !midWord) continue;
|
|
1121
1121
|
if (u.r >= last && d.rs < 2) continue;
|
|
1122
|
-
const U =
|
|
1122
|
+
const U = _chunkKDCPBF4Xcjs.CELL_LINES.get(a);
|
|
1123
1123
|
if (!_optionalChain([U, 'optionalAccess', _78 => _78.length]) || !hasContent(b)) continue;
|
|
1124
1124
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1125
1125
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -1166,7 +1166,7 @@ function nextItemHead(prev, next) {
|
|
|
1166
1166
|
return false;
|
|
1167
1167
|
}
|
|
1168
1168
|
function continuesAcross(u, d, x1, x2) {
|
|
1169
|
-
const U =
|
|
1169
|
+
const U = _chunkKDCPBF4Xcjs.CELL_LINES.get(u), D = _chunkKDCPBF4Xcjs.CELL_LINES.get(d);
|
|
1170
1170
|
if (!_optionalChain([U, 'optionalAccess', _79 => _79.length]) || !_optionalChain([D, 'optionalAccess', _80 => _80.length])) return false;
|
|
1171
1171
|
const last = U[U.length - 1];
|
|
1172
1172
|
const fs = last.h || 10;
|
|
@@ -1184,7 +1184,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1184
1184
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1185
1185
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1186
1186
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1187
|
-
const newItem =
|
|
1187
|
+
const newItem = _chunkKDCPBF4Xcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1188
1188
|
const all = D.length ? U.concat(D) : U;
|
|
1189
1189
|
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));
|
|
1190
1190
|
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;
|
|
@@ -1201,10 +1201,10 @@ function outlineContinues(u, d) {
|
|
|
1201
1201
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1202
1202
|
}
|
|
1203
1203
|
function lineEnded(c, x1, x2, next) {
|
|
1204
|
-
const L =
|
|
1204
|
+
const L = _chunkKDCPBF4Xcjs.CELL_LINES.get(c);
|
|
1205
1205
|
if (!L || L.length !== 1) return false;
|
|
1206
1206
|
const l = L[0], h = l.h || 10;
|
|
1207
|
-
const d0 = next ? _optionalChain([
|
|
1207
|
+
const d0 = next ? _optionalChain([_chunkKDCPBF4Xcjs.CELL_LINES, 'access', _81 => _81.get, 'call', _82 => _82(next), 'optionalAccess', _83 => _83[0]]) : void 0;
|
|
1208
1208
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1209
1209
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _84 => _84.text]), () => ( "")))) * h;
|
|
1210
1210
|
}
|
|
@@ -1220,9 +1220,9 @@ function appendCell(a, b) {
|
|
|
1220
1220
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1221
1221
|
}
|
|
1222
1222
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1223
|
-
|
|
1223
|
+
_chunkKDCPBF4Xcjs.joinCellEdges.call(void 0, a, b);
|
|
1224
1224
|
}
|
|
1225
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _91 => _91.blocks, 'optionalAccess', _92 => _92.length]) ||
|
|
1225
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _91 => _91.blocks, 'optionalAccess', _92 => _92.length]) || _chunkKDCPBF4Xcjs.IMAGE_CELLS.has(cell);
|
|
1226
1226
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1227
1227
|
var batchim = (ch) => {
|
|
1228
1228
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1230,13 +1230,13 @@ var batchim = (ch) => {
|
|
|
1230
1230
|
};
|
|
1231
1231
|
function clauseContinues(u, d) {
|
|
1232
1232
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1233
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1233
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkKDCPBF4Xcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1234
1234
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1235
1235
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1236
1236
|
}
|
|
1237
1237
|
function wordOverflows(u, d, x1, x2) {
|
|
1238
|
-
const U =
|
|
1239
|
-
if (!_optionalChain([U, 'optionalAccess', _93 => _93.length]) ||
|
|
1238
|
+
const U = _chunkKDCPBF4Xcjs.CELL_LINES.get(u);
|
|
1239
|
+
if (!_optionalChain([U, 'optionalAccess', _93 => _93.length]) || _chunkKDCPBF4Xcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1240
1240
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1241
1241
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1242
1242
|
}
|
|
@@ -1296,7 +1296,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1296
1296
|
if (!carriedSplit) {
|
|
1297
1297
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1298
1298
|
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;
|
|
1299
|
-
const oneLine = (c) => _optionalChain([
|
|
1299
|
+
const oneLine = (c) => _optionalChain([_chunkKDCPBF4Xcjs.CELL_LINES, 'access', _95 => _95.get, 'call', _96 => _96(c), 'optionalAccess', _97 => _97.length]) === 1;
|
|
1300
1300
|
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;
|
|
1301
1301
|
const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d));
|
|
1302
1302
|
if (!(cut.open && !newCell)) {
|
|
@@ -1381,19 +1381,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1381
1381
|
placeJoined(blocks, i, j, joined);
|
|
1382
1382
|
continue;
|
|
1383
1383
|
}
|
|
1384
|
-
if (
|
|
1384
|
+
if (_chunkKDCPBF4Xcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1385
1385
|
blocks.splice(j, 1);
|
|
1386
1386
|
i++;
|
|
1387
1387
|
continue;
|
|
1388
1388
|
}
|
|
1389
1389
|
if (joined === null) continue;
|
|
1390
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1390
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkKDCPBF4Xcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1391
1391
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1392
1392
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1393
1393
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1394
1394
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1395
|
-
const px =
|
|
1396
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1395
|
+
const px = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(prev.table), cx = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(curr.table);
|
|
1396
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(prev.table) && !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1397
1397
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1398
1398
|
let currCells = curr.table.cells;
|
|
1399
1399
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1404,16 +1404,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1404
1404
|
blocks.splice(j, 1);
|
|
1405
1405
|
continue;
|
|
1406
1406
|
}
|
|
1407
|
-
if (px && cx && !
|
|
1407
|
+
if (px && cx && !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(prev.table) && !_chunkKDCPBF4Xcjs.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 && _chunkKDCPBF4Xcjs.CELL_LINES.has(c))) {
|
|
1408
1408
|
const dx = px[0] - cx[0];
|
|
1409
1409
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1410
1410
|
if (_optionalChain([part, 'optionalAccess', _114 => _114.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1411
1411
|
const last = prev.table.rows - 1;
|
|
1412
1412
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1413
|
-
const U =
|
|
1414
|
-
|
|
1413
|
+
const U = _chunkKDCPBF4Xcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkKDCPBF4Xcjs.CELL_LINES.get(currCells[0][c]);
|
|
1414
|
+
_chunkKDCPBF4Xcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1415
1415
|
}
|
|
1416
|
-
|
|
1416
|
+
_chunkKDCPBF4Xcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1417
1417
|
placeJoined(blocks, i, j, part.table);
|
|
1418
1418
|
continue;
|
|
1419
1419
|
}
|
|
@@ -1426,20 +1426,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1426
1426
|
caption: prev.table.caption,
|
|
1427
1427
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1428
1428
|
};
|
|
1429
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1430
|
-
if (
|
|
1429
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkKDCPBF4Xcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1430
|
+
if (_chunkKDCPBF4Xcjs.CLIP_TABLES.has(prev.table) || _chunkKDCPBF4Xcjs.CLIP_TABLES.has(curr.table)) _chunkKDCPBF4Xcjs.CLIP_TABLES.add(merged);
|
|
1431
1431
|
placeJoined(blocks, i, j, merged);
|
|
1432
1432
|
}
|
|
1433
1433
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1434
1434
|
const t = blocks[i].table;
|
|
1435
|
-
if (blocks[i].type === "table" && t &&
|
|
1435
|
+
if (blocks[i].type === "table" && t && _chunkKDCPBF4Xcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1436
1436
|
}
|
|
1437
1437
|
}
|
|
1438
1438
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1439
1439
|
if (!pageHeights) return;
|
|
1440
1440
|
for (let i = 0; i < blocks.length; i++) {
|
|
1441
1441
|
const L = blocks[i];
|
|
1442
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1442
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(L.table) || _chunkKDCPBF4Xcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1443
1443
|
const ph = pageHeights.get(L.pageNumber);
|
|
1444
1444
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1445
1445
|
let s0 = i, s1 = i;
|
|
@@ -1468,8 +1468,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1468
1468
|
}
|
|
1469
1469
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1470
1470
|
const pt = prev.table, ct = curr.table;
|
|
1471
|
-
if (!
|
|
1472
|
-
const px =
|
|
1471
|
+
if (!_chunkKDCPBF4Xcjs.CLIP_TABLES.has(pt) || !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(ct)) return null;
|
|
1472
|
+
const px = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(pt), cx = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(ct);
|
|
1473
1473
|
if (!px || !cx) return null;
|
|
1474
1474
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1475
1475
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -1485,15 +1485,15 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1485
1485
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1486
1486
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1487
1487
|
};
|
|
1488
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1488
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkKDCPBF4Xcjs.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);
|
|
1489
1489
|
}
|
|
1490
1490
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _119 => _119.bbox, 'optionalAccess', _120 => _120.y]), lex);
|
|
1491
1491
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1492
|
-
|
|
1493
|
-
const ys =
|
|
1494
|
-
if (ys)
|
|
1495
|
-
|
|
1496
|
-
|
|
1492
|
+
_chunkKDCPBF4Xcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1493
|
+
const ys = _chunkKDCPBF4Xcjs.TABLE_ROWYS.get(pt);
|
|
1494
|
+
if (ys) _chunkKDCPBF4Xcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1495
|
+
_chunkKDCPBF4Xcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkKDCPBF4Xcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1496
|
+
_chunkKDCPBF4Xcjs.CLIP_TABLES.add(res.table);
|
|
1497
1497
|
return res.table;
|
|
1498
1498
|
}
|
|
1499
1499
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
@@ -1517,12 +1517,12 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
1517
1517
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1518
1518
|
}
|
|
1519
1519
|
function pushedLead(prev, curr) {
|
|
1520
|
-
if (!
|
|
1520
|
+
if (!_chunkKDCPBF4Xcjs.CLIP_TABLES.has(prev.table) || !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1521
1521
|
const lead = leadRows(curr.table);
|
|
1522
1522
|
return lead.image && lead.height > prev.bbox.y;
|
|
1523
1523
|
}
|
|
1524
1524
|
function leadRows(t) {
|
|
1525
|
-
const ys =
|
|
1525
|
+
const ys = _chunkKDCPBF4Xcjs.TABLE_ROWYS.get(t);
|
|
1526
1526
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1527
1527
|
const anchors = anchorsOf(t);
|
|
1528
1528
|
let end = 1, image = false;
|
|
@@ -1530,17 +1530,17 @@ function leadRows(t) {
|
|
|
1530
1530
|
for (const a of anchors) {
|
|
1531
1531
|
if (a.r !== r) continue;
|
|
1532
1532
|
end = Math.max(end, r + a.rs);
|
|
1533
|
-
if (
|
|
1533
|
+
if (_chunkKDCPBF4Xcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1534
1534
|
}
|
|
1535
1535
|
}
|
|
1536
1536
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1537
1537
|
}
|
|
1538
1538
|
function tailOf(b) {
|
|
1539
|
-
const t = b.table &&
|
|
1539
|
+
const t = b.table && _chunkKDCPBF4Xcjs.TABLE_TAIL.get(b.table);
|
|
1540
1540
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1541
1541
|
}
|
|
1542
1542
|
function firstRowSig(t) {
|
|
1543
|
-
const x =
|
|
1543
|
+
const x = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(t);
|
|
1544
1544
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1545
1545
|
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, "") }));
|
|
1546
1546
|
}
|
|
@@ -1593,7 +1593,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1593
1593
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1594
1594
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1595
1595
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1596
|
-
const px =
|
|
1596
|
+
const px = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(pb.table), cx = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(cur.table);
|
|
1597
1597
|
if (!px || !cx) break;
|
|
1598
1598
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1599
1599
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1664,7 +1664,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1664
1664
|
var COL_MATCH_TOL = 0.5;
|
|
1665
1665
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1666
1666
|
function lastRowCell(t, x1, x2) {
|
|
1667
|
-
const xs =
|
|
1667
|
+
const xs = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(t);
|
|
1668
1668
|
const covered = /* @__PURE__ */ new Set();
|
|
1669
1669
|
for (let r = 0; r < t.rows; r++) {
|
|
1670
1670
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -1682,7 +1682,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1682
1682
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1683
1683
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1684
1684
|
const part = blocks[j];
|
|
1685
|
-
const from = part.table ?
|
|
1685
|
+
const from = part.table ? _chunkKDCPBF4Xcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1686
1686
|
if (!from || !part.table) continue;
|
|
1687
1687
|
let i = j - 1;
|
|
1688
1688
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
@@ -1695,11 +1695,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1695
1695
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1696
1696
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1697
1697
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1698
|
-
|
|
1699
|
-
const lines =
|
|
1700
|
-
if (_optionalChain([lines, 'optionalAccess', _144 => _144.length]))
|
|
1701
|
-
if (part.pageNumber && part.bbox)
|
|
1702
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _145 => _145.blocks, 'optionalAccess', _146 => _146.length]))
|
|
1698
|
+
_chunkKDCPBF4Xcjs.joinCellEdges.call(void 0, cell, add);
|
|
1699
|
+
const lines = _chunkKDCPBF4Xcjs.CELL_LINES.get(add);
|
|
1700
|
+
if (_optionalChain([lines, 'optionalAccess', _144 => _144.length])) _chunkKDCPBF4Xcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkKDCPBF4Xcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1701
|
+
if (part.pageNumber && part.bbox) _chunkKDCPBF4Xcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkKDCPBF4Xcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1702
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _145 => _145.blocks, 'optionalAccess', _146 => _146.length])) _chunkKDCPBF4Xcjs.EMPTY_PARTS.delete(prev.table);
|
|
1703
1703
|
blocks.splice(j, 1);
|
|
1704
1704
|
if (cell.blocks && at > 0) {
|
|
1705
1705
|
const nextAt = cell.blocks[at];
|
|
@@ -1711,11 +1711,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1711
1711
|
}
|
|
1712
1712
|
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1713
1713
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1714
|
-
if (!_optionalChain([prev, 'optionalAccess', _147 => _147.table]) || !_optionalChain([frame, 'optionalAccess', _148 => _148.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !
|
|
1714
|
+
if (!_optionalChain([prev, 'optionalAccess', _147 => _147.table]) || !_optionalChain([frame, 'optionalAccess', _148 => _148.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1715
1715
|
const inner = _optionalChain([frame, 'access', _149 => _149.table, 'access', _150 => _150.cells, 'access', _151 => _151[0], 'optionalAccess', _152 => _152[0], 'optionalAccess', _153 => _153.blocks]);
|
|
1716
1716
|
const next = _optionalChain([inner, 'optionalAccess', _154 => _154[0]]);
|
|
1717
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _155 => _155.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
1718
|
-
const px =
|
|
1717
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _155 => _155.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(prev.table) || !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1718
|
+
const px = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(prev.table), nx = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(next.table);
|
|
1719
1719
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1720
1720
|
const ph = _optionalChain([pageHeights, 'optionalAccess', _156 => _156.get, 'call', _157 => _157(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _158 => _158.get, 'call', _159 => _159(next.pageNumber)]);
|
|
1721
1721
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
@@ -1724,14 +1724,14 @@ function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
|
1724
1724
|
function fillNestedContinuation(blocks, at) {
|
|
1725
1725
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1726
1726
|
const t = _optionalChain([prev, 'optionalAccess', _160 => _160.table]), u = _optionalChain([next, 'optionalAccess', _161 => _161.table]);
|
|
1727
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1728
|
-
const xs =
|
|
1727
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(t) || !_chunkKDCPBF4Xcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1728
|
+
const xs = _chunkKDCPBF4Xcjs.TABLE_COLXS.get(u);
|
|
1729
1729
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1730
1730
|
const add = _optionalChain([u, 'access', _162 => _162.cells, 'access', _163 => _163[0], 'optionalAccess', _164 => _164[0]]);
|
|
1731
1731
|
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _165 => _165.blocks, 'optionalAccess', _166 => _166.length])) return;
|
|
1732
1732
|
cell.text = add.text;
|
|
1733
1733
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1734
|
-
|
|
1734
|
+
_chunkKDCPBF4Xcjs.joinCellEdges.call(void 0, cell, add);
|
|
1735
1735
|
blocks.splice(at, 1);
|
|
1736
1736
|
}
|
|
1737
1737
|
|
|
@@ -1751,15 +1751,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
1751
1751
|
function marginContextBlocks(raw, page, view) {
|
|
1752
1752
|
const [x1, y1, x2, y2] = view;
|
|
1753
1753
|
const width = x2 - x1, height = y2 - y1;
|
|
1754
|
-
const items =
|
|
1754
|
+
const items = _chunkKDCPBF4Xcjs.filterHiddenText.call(void 0, _chunkKDCPBF4Xcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
1755
1755
|
for (const item of items) {
|
|
1756
1756
|
item.x -= x1;
|
|
1757
1757
|
item.y -= y1;
|
|
1758
1758
|
}
|
|
1759
|
-
return
|
|
1760
|
-
const bbox =
|
|
1759
|
+
return _chunkKDCPBF4Xcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
1760
|
+
const bbox = _chunkKDCPBF4Xcjs.computeBBox.call(void 0, line, page);
|
|
1761
1761
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
1762
|
-
return [{ type: "paragraph", text:
|
|
1762
|
+
return [{ type: "paragraph", text: _chunkKDCPBF4Xcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkKDCPBF4Xcjs.dominantStyle.call(void 0, line) }];
|
|
1763
1763
|
});
|
|
1764
1764
|
}
|
|
1765
1765
|
|
|
@@ -1795,7 +1795,7 @@ var WINANSI_REVERSE = {
|
|
|
1795
1795
|
};
|
|
1796
1796
|
function symbolFontTable(fontName) {
|
|
1797
1797
|
if (!fontName) return void 0;
|
|
1798
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
1798
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkCJFIHH2Ncjs.WINGDINGS;
|
|
1799
1799
|
return void 0;
|
|
1800
1800
|
}
|
|
1801
1801
|
function remapSymbolText(text, table) {
|
|
@@ -2811,7 +2811,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
2811
2811
|
if (block.type !== "heading" || !block.text) continue;
|
|
2812
2812
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
2813
2813
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _230 => _230.style, 'optionalAccess', _231 => _231.fontSize]), () => ( 0));
|
|
2814
|
-
const tocEntry = i > 0 &&
|
|
2814
|
+
const tocEntry = i > 0 && _chunkKDCPBF4Xcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkKDCPBF4Xcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
2815
2815
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
2816
2816
|
const proseStyle = _optionalChain([block, 'access', _232 => _232.style, 'optionalAccess', _233 => _233.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
2817
2817
|
const next = blocks[i + 1];
|
|
@@ -2894,7 +2894,7 @@ function splitSingleCellTables(blocks) {
|
|
|
2894
2894
|
const out = [];
|
|
2895
2895
|
for (const b of blocks) {
|
|
2896
2896
|
const t = b.type === "table" ? b.table : void 0;
|
|
2897
|
-
const title = t &&
|
|
2897
|
+
const title = t && _chunkKDCPBF4Xcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
2898
2898
|
if (title) {
|
|
2899
2899
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
2900
2900
|
continue;
|
|
@@ -2930,7 +2930,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
2930
2930
|
const lines = cell.text.split("\n");
|
|
2931
2931
|
const out = [lines[0]];
|
|
2932
2932
|
for (const line of lines.slice(1)) {
|
|
2933
|
-
if (
|
|
2933
|
+
if (_chunkKDCPBF4Xcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
2934
2934
|
else out.push(line);
|
|
2935
2935
|
}
|
|
2936
2936
|
cell.text = out.join("\n");
|
|
@@ -2950,10 +2950,10 @@ function cleanPdfText(text, opts) {
|
|
|
2950
2950
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
2951
2951
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
2952
2952
|
if (line.startsWith("|")) {
|
|
2953
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
2953
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkKDCPBF4Xcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
2954
2954
|
}
|
|
2955
2955
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _313 => _313.exec, 'call', _314 => _314(line), 'optionalAccess', _315 => _315[0]]), () => ( ""));
|
|
2956
|
-
return mark +
|
|
2956
|
+
return mark + _chunkKDCPBF4Xcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
2957
2957
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
2958
2958
|
}
|
|
2959
2959
|
function startsWithMarker(line) {
|
|
@@ -2985,7 +2985,7 @@ function mergeKoreanLines(text) {
|
|
|
2985
2985
|
continue;
|
|
2986
2986
|
}
|
|
2987
2987
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
2988
|
-
result[result.length - 1] = prev +
|
|
2988
|
+
result[result.length - 1] = prev + _chunkKDCPBF4Xcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
2989
2989
|
} else {
|
|
2990
2990
|
result.push(curr);
|
|
2991
2991
|
}
|
|
@@ -3001,7 +3001,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3001
3001
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3002
3002
|
for (const a of annots) {
|
|
3003
3003
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3004
|
-
const url =
|
|
3004
|
+
const url = _chunkK5GCIB2Icjs.sanitizeHref.call(void 0, a.url);
|
|
3005
3005
|
if (!url) continue;
|
|
3006
3006
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3007
3007
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -3042,7 +3042,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3042
3042
|
|
|
3043
3043
|
// src/pdf/formula-ocr.ts
|
|
3044
3044
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3045
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
3045
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-FE6LEZTT.cjs")));
|
|
3046
3046
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3047
3047
|
await ensureFormulaModels((p) => {
|
|
3048
3048
|
if (p.phase === "download" && p.total) {
|
|
@@ -3233,13 +3233,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3233
3233
|
try {
|
|
3234
3234
|
return await Promise.race([
|
|
3235
3235
|
loadingTask.promise.catch((e) => {
|
|
3236
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
3236
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkK5GCIB2Icjs.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)");
|
|
3237
3237
|
throw e;
|
|
3238
3238
|
}),
|
|
3239
3239
|
new Promise((_, reject) => {
|
|
3240
3240
|
timer = setTimeout(() => {
|
|
3241
3241
|
loadingTask.destroy();
|
|
3242
|
-
reject(new (0,
|
|
3242
|
+
reject(new (0, _chunkK5GCIB2Icjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
3243
3243
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
3244
3244
|
})
|
|
3245
3245
|
]);
|
|
@@ -3249,12 +3249,12 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3249
3249
|
}
|
|
3250
3250
|
async function parsePdfDocument(buffer, options) {
|
|
3251
3251
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _316 => _316.formulaOcr]) ? buffer : null;
|
|
3252
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _317 => _317.ocr]) === void 0 && await
|
|
3252
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _317 => _317.ocr]) === void 0 && await _chunkKDCPBF4Xcjs.ocrModelsCached.call(void 0, );
|
|
3253
3253
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _318 => _318.ocr]) || autoOcr ? buffer : null;
|
|
3254
3254
|
const doc = await loadPdfWithTimeout(buffer);
|
|
3255
3255
|
try {
|
|
3256
3256
|
const pageCount = doc.numPages;
|
|
3257
|
-
if (pageCount === 0) throw new (0,
|
|
3257
|
+
if (pageCount === 0) throw new (0, _chunkK5GCIB2Icjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
3258
3258
|
const metadata = { pageCount, pageMode: "layout" };
|
|
3259
3259
|
await extractPdfMetadata(doc, metadata);
|
|
3260
3260
|
const blocks = [];
|
|
@@ -3283,7 +3283,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3283
3283
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
3284
3284
|
const carry = {};
|
|
3285
3285
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
3286
|
-
const wrapLexicon = new (0,
|
|
3286
|
+
const wrapLexicon = new (0, _chunkKDCPBF4Xcjs.WrapLexicon)();
|
|
3287
3287
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
3288
3288
|
const headerContext = [];
|
|
3289
3289
|
if (pageFilter && _optionalChain([options, 'optionalAccess', _321 => _321.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
@@ -3328,8 +3328,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3328
3328
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3329
3329
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3330
3330
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3331
|
-
const items =
|
|
3332
|
-
const filtered =
|
|
3331
|
+
const items = _chunkKDCPBF4Xcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
3332
|
+
const filtered = _chunkKDCPBF4Xcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
3333
3333
|
const joined = joinVerticalColumns(filtered.visible);
|
|
3334
3334
|
const visible = dropTabLeaderDots(joined);
|
|
3335
3335
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -3355,7 +3355,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3355
3355
|
} : rawOps;
|
|
3356
3356
|
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _328 => _328(loadedName), 'optionalAccess', _329 => _329.name]));
|
|
3357
3357
|
remapControlGlyphs(visible, differencesOf);
|
|
3358
|
-
await
|
|
3358
|
+
await _chunkKDCPBF4Xcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
3359
3359
|
const faces = /* @__PURE__ */ new Map();
|
|
3360
3360
|
for (const it of visible) {
|
|
3361
3361
|
if (!it.fontName) continue;
|
|
@@ -3368,12 +3368,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3368
3368
|
it.fontName = face;
|
|
3369
3369
|
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _331 => _331(face), 'optionalAccess', _332 => _332.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
3370
3370
|
}
|
|
3371
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
3372
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
3371
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkCJFIHH2Ncjs.escapeLiteralDollar.call(void 0, it.text);
|
|
3372
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkCJFIHH2Ncjs.escapeLiteralTags.call(void 0, it.text);
|
|
3373
3373
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
3374
3374
|
const pageArea = pageW * pageH;
|
|
3375
3375
|
if (pageArea > 0) {
|
|
3376
|
-
const imageRegions =
|
|
3376
|
+
const imageRegions = _chunkKDCPBF4Xcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
3377
3377
|
let uncovered = 0;
|
|
3378
3378
|
for (const r of imageRegions) {
|
|
3379
3379
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -3399,11 +3399,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3399
3399
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
3400
3400
|
}
|
|
3401
3401
|
const marks = superscriptNoteMarks(visible);
|
|
3402
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
3402
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkKDCPBF4Xcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
3403
3403
|
const stamp = marginStamp(visible);
|
|
3404
3404
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
3405
|
-
const rightArrows = _optionalChain([options, 'optionalAccess', _333 => _333.tables]) !== false ? await
|
|
3406
|
-
const pageBlocks = orderTwoUpPage(
|
|
3405
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _333 => _333.tables]) !== false ? await _chunkKDCPBF4Xcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
3406
|
+
const pageBlocks = orderTwoUpPage(_chunkKDCPBF4Xcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _334 => _334.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
3407
3407
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
3408
3408
|
for (const b of pageBlocks) blocks.push(b);
|
|
3409
3409
|
try {
|
|
@@ -3429,11 +3429,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3429
3429
|
if (_optionalChain([options, 'optionalAccess', _336 => _336.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
3430
3430
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
3431
3431
|
}
|
|
3432
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
3432
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkK5GCIB2Icjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
3433
3433
|
parsedPages++;
|
|
3434
3434
|
_optionalChain([options, 'optionalAccess', _337 => _337.onProgress, 'optionalCall', _338 => _338(parsedPages, totalTarget)]);
|
|
3435
3435
|
} catch (pageErr) {
|
|
3436
|
-
if (pageErr instanceof
|
|
3436
|
+
if (pageErr instanceof _chunkK5GCIB2Icjs.KordocError) throw pageErr;
|
|
3437
3437
|
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" });
|
|
3438
3438
|
} finally {
|
|
3439
3439
|
_optionalChain([loadedPage, 'optionalAccess', _339 => _339.cleanup, 'call', _340 => _340()]);
|
|
@@ -3463,11 +3463,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3463
3463
|
}
|
|
3464
3464
|
if (targets.size > 0) {
|
|
3465
3465
|
try {
|
|
3466
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3466
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-MODN6GBT.cjs")));
|
|
3467
3467
|
const mode = typeof _optionalChain([options, 'optionalAccess', _345 => _345.ocr]) === "function" ? options.ocr : "builtin";
|
|
3468
3468
|
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _346 => _346.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _347 => _347.find, 'call', _348 => _348((q) => q.page === p), 'optionalAccess', _349 => _349.needsOcr])));
|
|
3469
3469
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _350 => _350.onProgress]), _optionalChain([options, 'optionalAccess', _351 => _351.tables]) !== false, vectorPageOps, regionPages);
|
|
3470
|
-
for (const obs of ocrPageBlocks.values())
|
|
3470
|
+
for (const obs of ocrPageBlocks.values()) _chunkCJFIHH2Ncjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
3471
3471
|
if (ocrPageBlocks.size > 0) {
|
|
3472
3472
|
const replacePages = /* @__PURE__ */ new Set();
|
|
3473
3473
|
for (const [p, obs] of ocrPageBlocks) {
|
|
@@ -3531,11 +3531,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3531
3531
|
}
|
|
3532
3532
|
}
|
|
3533
3533
|
if (_optionalChain([options, 'optionalAccess', _359 => _359.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
3534
|
-
const removed =
|
|
3534
|
+
const removed = _chunkKDCPBF4Xcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
3535
3535
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
3536
3536
|
blocks.splice(removed[ri], 1);
|
|
3537
3537
|
}
|
|
3538
|
-
const kept =
|
|
3538
|
+
const kept = _chunkKDCPBF4Xcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
3539
3539
|
if (kept !== blocks) {
|
|
3540
3540
|
blocks.length = 0;
|
|
3541
3541
|
blocks.push(...kept);
|
|
@@ -3544,12 +3544,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3544
3544
|
mergeContinuedCells(blocks, pageHeights);
|
|
3545
3545
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
3546
3546
|
if (_optionalChain([options, 'optionalAccess', _360 => _360.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
3547
|
-
const boxes =
|
|
3547
|
+
const boxes = _chunkKDCPBF4Xcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
3548
3548
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
3549
3549
|
}
|
|
3550
3550
|
splitContactTables(blocks);
|
|
3551
|
-
if (!_optionalChain([options, 'optionalAccess', _361 => _361.keepTrailingEmptyCols]))
|
|
3552
|
-
|
|
3551
|
+
if (!_optionalChain([options, 'optionalAccess', _361 => _361.keepTrailingEmptyCols])) _chunkKDCPBF4Xcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
3552
|
+
_chunkKDCPBF4Xcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
3553
3553
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
3554
3554
|
if (_optionalChain([options, 'optionalAccess', _362 => _362.formulaOcr]) && formulaBuffer) {
|
|
3555
3555
|
try {
|
|
@@ -3561,21 +3561,21 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3561
3561
|
});
|
|
3562
3562
|
}
|
|
3563
3563
|
}
|
|
3564
|
-
const medianFontSize =
|
|
3564
|
+
const medianFontSize = _chunkKDCPBF4Xcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
3565
3565
|
if (medianFontSize > 0) {
|
|
3566
|
-
|
|
3567
|
-
}
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3566
|
+
_chunkKDCPBF4Xcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
3567
|
+
}
|
|
3568
|
+
_chunkKDCPBF4Xcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
3569
|
+
_chunkKDCPBF4Xcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
3570
|
+
_chunkKDCPBF4Xcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
3571
|
+
_chunkKDCPBF4Xcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
3572
|
+
_chunkKDCPBF4Xcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
3573
|
+
_chunkKDCPBF4Xcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
3574
|
+
_chunkKDCPBF4Xcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
3575
|
+
_chunkKDCPBF4Xcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
3576
3576
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3577
|
-
|
|
3578
|
-
|
|
3577
|
+
_chunkKDCPBF4Xcjs.detectTableCaptions.call(void 0, blocks);
|
|
3578
|
+
_chunkKDCPBF4Xcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3579
3579
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3580
3580
|
sanitizeBlockControlChars(blocks);
|
|
3581
3581
|
let outBlocks = splitSingleCellTables(blocks);
|
|
@@ -3597,17 +3597,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3597
3597
|
const shown = /* @__PURE__ */ new Map();
|
|
3598
3598
|
const markContent = (bs) => {
|
|
3599
3599
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
3600
|
-
if (
|
|
3600
|
+
if (_chunkKDCPBF4Xcjs.IMAGE_CELLS.has(c)) _chunkCJFIHH2Ncjs.CONTENT_CELLS.add(c);
|
|
3601
3601
|
markContent(c.blocks);
|
|
3602
3602
|
}
|
|
3603
3603
|
};
|
|
3604
3604
|
const visual = (bs) => bs.flatMap((b) => {
|
|
3605
3605
|
if (b.type !== "table") return [b];
|
|
3606
|
-
if (!hancom && b.table &&
|
|
3606
|
+
if (!hancom && b.table && _chunkKDCPBF4Xcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
3607
3607
|
let v = shown.get(b);
|
|
3608
3608
|
if (!v) {
|
|
3609
3609
|
markContent([b]);
|
|
3610
|
-
shown.set(b, v =
|
|
3610
|
+
shown.set(b, v = _chunkCJFIHH2Ncjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _366 => _366.keepTrailingEmptyCols])));
|
|
3611
3611
|
}
|
|
3612
3612
|
return v;
|
|
3613
3613
|
});
|
|
@@ -3616,12 +3616,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3616
3616
|
blocks.length = 0;
|
|
3617
3617
|
for (const b of kept) blocks.push(b);
|
|
3618
3618
|
}
|
|
3619
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
3620
|
-
if (_optionalChain([options, 'optionalAccess', _368 => _368.tableFormat]) === "gfm")
|
|
3619
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkCJFIHH2Ncjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _367 => _367.tableFormat]) }), { keepLoneNumbers: true }));
|
|
3620
|
+
if (_optionalChain([options, 'optionalAccess', _368 => _368.tableFormat]) === "gfm") _chunkCJFIHH2Ncjs.assignTableIds.call(void 0, blocks);
|
|
3621
3621
|
let markdown = finishMarkdown(outBlocks);
|
|
3622
3622
|
return {
|
|
3623
3623
|
markdown,
|
|
3624
|
-
pages:
|
|
3624
|
+
pages: _chunkWWOU6ZQ3cjs.blocksToPages.call(void 0, splitPageTables(_chunkKDCPBF4Xcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
3625
3625
|
blocks,
|
|
3626
3626
|
metadata,
|
|
3627
3627
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3700,5 +3700,5 @@ function marginStamp(items) {
|
|
|
3700
3700
|
|
|
3701
3701
|
|
|
3702
3702
|
|
|
3703
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
3704
|
-
//# sourceMappingURL=parser-
|
|
3703
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkKDCPBF4Xcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkKDCPBF4Xcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkKDCPBF4Xcjs.removeHeaderFooterBlocks;
|
|
3704
|
+
//# sourceMappingURL=parser-6P5ZRWXG.cjs.map
|