kordoc 4.14.2 → 4.14.3

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.
Files changed (151) hide show
  1. package/README.md +38 -5
  2. package/dist/{-AQKXLFIM.js → -7XBPXCXN.js} +13 -11
  3. package/dist/{chunk-FOJZNMMK.js → chunk-2LQGSDZ6.js} +1 -1
  4. package/dist/chunk-2LQGSDZ6.js.map +1 -0
  5. package/dist/chunk-4R67INKT.js +1002 -0
  6. package/dist/chunk-4R67INKT.js.map +1 -0
  7. package/dist/{chunk-ILU76UF3.js → chunk-4RJ5D7MT.js} +2 -2
  8. package/dist/chunk-4RJ5D7MT.js.map +1 -0
  9. package/dist/{chunk-EQZI77PP.cjs → chunk-5VVS2QIJ.cjs} +3 -3
  10. package/dist/{chunk-EQZI77PP.cjs.map → chunk-5VVS2QIJ.cjs.map} +1 -1
  11. package/dist/{chunk-3DUADAY2.js → chunk-A275ZQLX.js} +209 -87
  12. package/dist/chunk-A275ZQLX.js.map +1 -0
  13. package/dist/{chunk-EISO3POT.js → chunk-CVEERPMP.js} +788 -194
  14. package/dist/chunk-CVEERPMP.js.map +1 -0
  15. package/dist/{chunk-ZWD734EY.js → chunk-D6KQKMU3.js} +2 -2
  16. package/dist/{chunk-QOMNEWCQ.cjs → chunk-EBZUZC6F.cjs} +305 -31
  17. package/dist/chunk-EBZUZC6F.cjs.map +1 -0
  18. package/dist/{chunk-HR2XNERB.cjs → chunk-EMGF6EEV.cjs} +2 -2
  19. package/dist/{chunk-HR2XNERB.cjs.map → chunk-EMGF6EEV.cjs.map} +1 -1
  20. package/dist/{chunk-GDW4YP7K.js → chunk-FAZR34CA.js} +2 -2
  21. package/dist/{chunk-TNCKOL2O.js → chunk-GTINVM5K.js} +2 -2
  22. package/dist/{chunk-L7DMSMAG.cjs → chunk-HX4UUF7Y.cjs} +1 -1
  23. package/dist/chunk-HX4UUF7Y.cjs.map +1 -0
  24. package/dist/{chunk-UET462HB.js → chunk-I4NNYWIR.js} +2 -2
  25. package/dist/chunk-IH56ZISC.js +620 -0
  26. package/dist/chunk-IH56ZISC.js.map +1 -0
  27. package/dist/{chunk-EDNJLUSE.js → chunk-IHZEFW4L.js} +2 -2
  28. package/dist/chunk-IW2CB755.cjs +1002 -0
  29. package/dist/chunk-IW2CB755.cjs.map +1 -0
  30. package/dist/{chunk-ZWOFQRIB.js → chunk-JCVIOLBF.js} +3 -3
  31. package/dist/{chunk-JQEFP45L.js → chunk-L5EH2NVO.js} +2 -2
  32. package/dist/{chunk-247ANM72.cjs → chunk-NOAQRCV6.cjs} +219 -97
  33. package/dist/chunk-NOAQRCV6.cjs.map +1 -0
  34. package/dist/{chunk-7IAQ4HOK.js → chunk-NQCUAGLR.js} +1 -1
  35. package/dist/chunk-NQCUAGLR.js.map +1 -0
  36. package/dist/{chunk-NS55SM7A.js → chunk-O2PGQNYE.js} +2 -2
  37. package/dist/{chunk-QC5T6D4J.js → chunk-QGW7NMTX.js} +299 -25
  38. package/dist/chunk-QGW7NMTX.js.map +1 -0
  39. package/dist/{chunk-A7QC2ZVP.js → chunk-UVVEBI22.js} +209 -87
  40. package/dist/chunk-UVVEBI22.js.map +1 -0
  41. package/dist/chunk-VJHAUMCF.js +949 -0
  42. package/dist/chunk-VJHAUMCF.js.map +1 -0
  43. package/dist/{chunk-C7FQBSON.js → chunk-VNFJPTU4.js} +2 -2
  44. package/dist/{chunk-VQ5W4MYO.js → chunk-VYOGXNQ3.js} +298 -24
  45. package/dist/chunk-VYOGXNQ3.js.map +1 -0
  46. package/dist/{chunk-DOGPOY4B.js → chunk-WB5LW52Z.js} +2 -2
  47. package/dist/{chunk-TSFS5VKD.js → chunk-YGBZABI4.js} +332 -141
  48. package/dist/chunk-YGBZABI4.js.map +1 -0
  49. package/dist/chunks-I7TEMJXH.js +10 -0
  50. package/dist/cli.js +228 -97
  51. package/dist/cli.js.map +1 -1
  52. package/dist/{formula-PJJ6S3Z2.cjs → formula-CPO2TZGB.cjs} +9 -9
  53. package/dist/{formula-PJJ6S3Z2.cjs.map → formula-CPO2TZGB.cjs.map} +1 -1
  54. package/dist/{formula-5S7WWXGH.js → formula-NOIDZEBA.js} +4 -4
  55. package/dist/{formula-JGFTXWYT.js → formula-X44GV7TN.js} +3 -3
  56. package/dist/{image-ocr-WCAYXLOA.js → image-ocr-72RAR4WR.js} +34 -16
  57. package/dist/image-ocr-72RAR4WR.js.map +1 -0
  58. package/dist/{image-ocr-FLIL7MGN.js → image-ocr-R6W6A75P.js} +32 -14
  59. package/dist/image-ocr-R6W6A75P.js.map +1 -0
  60. package/dist/{image-ocr-ZTYAGV3W.cjs → image-ocr-SUGT64ZM.cjs} +36 -18
  61. package/dist/image-ocr-SUGT64ZM.cjs.map +1 -0
  62. package/dist/index.cjs +2416 -1184
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +62 -25
  65. package/dist/index.d.ts +62 -25
  66. package/dist/index.js +1853 -621
  67. package/dist/index.js.map +1 -1
  68. package/dist/mcp.js +74 -53
  69. package/dist/mcp.js.map +1 -1
  70. package/dist/{model-bundle-FSPZZ2EM.js → model-bundle-57CLEBCO.js} +5 -5
  71. package/dist/{models-CJPAQK5R.js → models-7ELIFTD7.js} +5 -5
  72. package/dist/{parser-SCUTZAIJ.js → parser-4NKAYWAX.js} +261 -241
  73. package/dist/parser-4NKAYWAX.js.map +1 -0
  74. package/dist/{parser-A4TMPJAM.js → parser-HWFQRSUQ.js} +261 -241
  75. package/dist/parser-HWFQRSUQ.js.map +1 -0
  76. package/dist/{parser-VCXE4I5A.cjs → parser-RANGXGBD.cjs} +289 -269
  77. package/dist/parser-RANGXGBD.cjs.map +1 -0
  78. package/dist/pdf-ocr-BNC34MNU.js +13 -0
  79. package/dist/pdf-ocr-QX2GB33Q.js +16 -0
  80. package/dist/pdf-ocr-VHSFACH7.cjs +14 -0
  81. package/dist/{pdf-ocr-MBZZ57LD.cjs.map → pdf-ocr-VHSFACH7.cjs.map} +1 -1
  82. package/dist/{profile-io-LBM263K7.js → profile-io-V52PL5ZO.js} +3 -3
  83. package/dist/{rasterize-46RG4ZF6.js → rasterize-ZIGLJDOG.js} +3 -3
  84. package/dist/redact-TIQEQI3M.js +18 -0
  85. package/dist/redact-doc-KXZ3TZAG.js +1216 -0
  86. package/dist/redact-doc-KXZ3TZAG.js.map +1 -0
  87. package/dist/{render-NGP5T24S.js → render-U5PE6V2E.js} +7 -7
  88. package/dist/seal-DNXJBILR.js +10 -0
  89. package/dist/{setup-AU4OCHNH.js → setup-YRDM4ODP.js} +3 -3
  90. package/dist/visual-5XWMA4EV.js +19 -0
  91. package/dist/{watch-MKPUCPXM.js → watch-5IOLBATT.js} +12 -12
  92. package/package.json +2 -2
  93. package/dist/chunk-247ANM72.cjs.map +0 -1
  94. package/dist/chunk-3DUADAY2.js.map +0 -1
  95. package/dist/chunk-422427XJ.cjs +0 -571
  96. package/dist/chunk-422427XJ.cjs.map +0 -1
  97. package/dist/chunk-7IAQ4HOK.js.map +0 -1
  98. package/dist/chunk-A7QC2ZVP.js.map +0 -1
  99. package/dist/chunk-DZIXKL7E.js +0 -145
  100. package/dist/chunk-DZIXKL7E.js.map +0 -1
  101. package/dist/chunk-EISO3POT.js.map +0 -1
  102. package/dist/chunk-EP7KOI2V.js +0 -571
  103. package/dist/chunk-EP7KOI2V.js.map +0 -1
  104. package/dist/chunk-FOJZNMMK.js.map +0 -1
  105. package/dist/chunk-ILU76UF3.js.map +0 -1
  106. package/dist/chunk-KVWV4ULP.js +0 -516
  107. package/dist/chunk-KVWV4ULP.js.map +0 -1
  108. package/dist/chunk-L7DMSMAG.cjs.map +0 -1
  109. package/dist/chunk-QC5T6D4J.js.map +0 -1
  110. package/dist/chunk-QOMNEWCQ.cjs.map +0 -1
  111. package/dist/chunk-TSFS5VKD.js.map +0 -1
  112. package/dist/chunk-VQ5W4MYO.js.map +0 -1
  113. package/dist/chunks-SX77P5CV.js +0 -10
  114. package/dist/image-ocr-FLIL7MGN.js.map +0 -1
  115. package/dist/image-ocr-WCAYXLOA.js.map +0 -1
  116. package/dist/image-ocr-ZTYAGV3W.cjs.map +0 -1
  117. package/dist/parser-A4TMPJAM.js.map +0 -1
  118. package/dist/parser-SCUTZAIJ.js.map +0 -1
  119. package/dist/parser-VCXE4I5A.cjs.map +0 -1
  120. package/dist/pdf-ocr-76SAUXMZ.js +0 -13
  121. package/dist/pdf-ocr-CPU55CVF.js +0 -16
  122. package/dist/pdf-ocr-MBZZ57LD.cjs +0 -14
  123. package/dist/redact-7ILEAUTS.js +0 -12
  124. package/dist/seal-RGUPOLXD.js +0 -10
  125. package/dist/visual-NZLYIYEM.js +0 -19
  126. /package/dist/{-AQKXLFIM.js.map → -7XBPXCXN.js.map} +0 -0
  127. /package/dist/{chunk-ZWD734EY.js.map → chunk-D6KQKMU3.js.map} +0 -0
  128. /package/dist/{chunk-GDW4YP7K.js.map → chunk-FAZR34CA.js.map} +0 -0
  129. /package/dist/{chunk-TNCKOL2O.js.map → chunk-GTINVM5K.js.map} +0 -0
  130. /package/dist/{chunk-UET462HB.js.map → chunk-I4NNYWIR.js.map} +0 -0
  131. /package/dist/{chunk-EDNJLUSE.js.map → chunk-IHZEFW4L.js.map} +0 -0
  132. /package/dist/{chunk-ZWOFQRIB.js.map → chunk-JCVIOLBF.js.map} +0 -0
  133. /package/dist/{chunk-JQEFP45L.js.map → chunk-L5EH2NVO.js.map} +0 -0
  134. /package/dist/{chunk-NS55SM7A.js.map → chunk-O2PGQNYE.js.map} +0 -0
  135. /package/dist/{chunk-C7FQBSON.js.map → chunk-VNFJPTU4.js.map} +0 -0
  136. /package/dist/{chunk-DOGPOY4B.js.map → chunk-WB5LW52Z.js.map} +0 -0
  137. /package/dist/{chunks-SX77P5CV.js.map → chunks-I7TEMJXH.js.map} +0 -0
  138. /package/dist/{formula-5S7WWXGH.js.map → formula-NOIDZEBA.js.map} +0 -0
  139. /package/dist/{formula-JGFTXWYT.js.map → formula-X44GV7TN.js.map} +0 -0
  140. /package/dist/{model-bundle-FSPZZ2EM.js.map → model-bundle-57CLEBCO.js.map} +0 -0
  141. /package/dist/{models-CJPAQK5R.js.map → models-7ELIFTD7.js.map} +0 -0
  142. /package/dist/{pdf-ocr-76SAUXMZ.js.map → pdf-ocr-BNC34MNU.js.map} +0 -0
  143. /package/dist/{pdf-ocr-CPU55CVF.js.map → pdf-ocr-QX2GB33Q.js.map} +0 -0
  144. /package/dist/{profile-io-LBM263K7.js.map → profile-io-V52PL5ZO.js.map} +0 -0
  145. /package/dist/{rasterize-46RG4ZF6.js.map → rasterize-ZIGLJDOG.js.map} +0 -0
  146. /package/dist/{redact-7ILEAUTS.js.map → redact-TIQEQI3M.js.map} +0 -0
  147. /package/dist/{render-NGP5T24S.js.map → render-U5PE6V2E.js.map} +0 -0
  148. /package/dist/{seal-RGUPOLXD.js.map → seal-DNXJBILR.js.map} +0 -0
  149. /package/dist/{setup-AU4OCHNH.js.map → setup-YRDM4ODP.js.map} +0 -0
  150. /package/dist/{visual-NZLYIYEM.js.map → visual-5XWMA4EV.js.map} +0 -0
  151. /package/dist/{watch-MKPUCPXM.js.map → watch-5IOLBATT.js.map} +0 -0
@@ -1,11 +1,18 @@
1
1
  import {
2
+ WINGDINGS,
2
3
  blocksToMarkdown,
3
4
  encodePng
4
- } from "./chunk-VQ5W4MYO.js";
5
+ } from "./chunk-VYOGXNQ3.js";
5
6
  import {
6
7
  parsePageRange
7
8
  } from "./chunk-GE43BE46.js";
8
9
  import {
10
+ CELL_LINES,
11
+ CLIP_TABLES,
12
+ EMPTY_PARTS,
13
+ FILLER_CELLS,
14
+ IMAGE_CELLS,
15
+ TABLE_COLXS,
9
16
  collapseEvenSpacing,
10
17
  computeMedianFontSizeFromFreq,
11
18
  detectHeadings,
@@ -15,15 +22,15 @@ import {
15
22
  extractImageRegions,
16
23
  extractPageBlocksWithLines,
17
24
  filterHiddenText,
18
- mergeCrossPageTables,
19
25
  normalizeItems,
20
- removeHeaderFooterBlocks
21
- } from "./chunk-A7QC2ZVP.js";
22
- import "./chunk-FOJZNMMK.js";
26
+ removeHeaderFooterBlocks,
27
+ trimTrailingEmptyTableCols
28
+ } from "./chunk-UVVEBI22.js";
29
+ import "./chunk-2LQGSDZ6.js";
23
30
  import {
24
31
  KordocError,
25
32
  sanitizeHref
26
- } from "./chunk-JQEFP45L.js";
33
+ } from "./chunk-L5EH2NVO.js";
27
34
 
28
35
  // src/pdf/image-extract.ts
29
36
  import { OPS, ImageKind } from "pdfjs-dist/legacy/build/pdf.mjs";
@@ -107,7 +114,7 @@ function toRgba(img) {
107
114
  }
108
115
  return null;
109
116
  }
110
- async function extractPageImages(page, fnArray, argsArray, pageNumber, state, warnings) {
117
+ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, warnings, withBytes = true) {
111
118
  const blocks = [];
112
119
  const images = [];
113
120
  const pageSeenIds = /* @__PURE__ */ new Set();
@@ -146,12 +153,14 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
146
153
  if (state.seen.has(hash)) continue;
147
154
  const rgba = toRgba(imgData);
148
155
  if (!rgba) continue;
149
- const png = encodePng(w, h, rgba);
150
156
  state.imageIndex++;
151
- state.totalBytes += png.length;
152
157
  const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
153
158
  state.seen.set(hash, filename);
154
- images.push({ filename, data: png, mimeType: "image/png" });
159
+ if (withBytes) {
160
+ const png = encodePng(w, h, rgba);
161
+ state.totalBytes += png.length;
162
+ images.push({ filename, data: png, mimeType: "image/png" });
163
+ }
155
164
  blocks.push({ type: "image", text: filename, pageNumber });
156
165
  }
157
166
  return { blocks, images };
@@ -322,232 +331,241 @@ function summarizeDocumentQuality(pages) {
322
331
  };
323
332
  }
324
333
 
334
+ // src/pdf/table-parts.ts
335
+ var PART_COL_TOL = 1;
336
+ function anchorsOf(table) {
337
+ const out = [];
338
+ const covered = /* @__PURE__ */ new Set();
339
+ for (let r = 0; r < table.rows; r++) {
340
+ for (let c = 0; c < table.cols; c++) {
341
+ if (covered.has(r * 1e5 + c)) continue;
342
+ const cell = table.cells[r]?.[c];
343
+ if (!cell) continue;
344
+ out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
345
+ for (let dr = 0; dr < cell.rowSpan; dr++) {
346
+ for (let dc = 0; dc < cell.colSpan; dc++) if (dr || dc) covered.add((r + dr) * 1e5 + (c + dc));
347
+ }
348
+ }
349
+ }
350
+ return out;
351
+ }
352
+ function unionCoords(a, b) {
353
+ const out = [...a];
354
+ for (const v of b) if (!a.some((x) => Math.abs(x - v) <= PART_COL_TOL)) out.push(v);
355
+ return out.sort((x, y) => x - y);
356
+ }
357
+ var indexOf = (coords, x) => {
358
+ let best = -1, bestD = Infinity;
359
+ for (let i = 0; i < coords.length; i++) {
360
+ const d = Math.abs(coords[i] - x);
361
+ if (d < bestD) {
362
+ bestD = d;
363
+ best = i;
364
+ }
365
+ }
366
+ return bestD <= PART_COL_TOL ? best : -1;
367
+ };
368
+ var rowText = (anchors, r) => anchors.filter((a) => a.r === r).map((a) => a.cell.text.replace(/\s+/g, "")).join("|");
369
+ function joinSplitParts(prev, pcx, curr, ccx) {
370
+ if (pcx.length !== prev.cols + 1 || ccx.length !== curr.cols + 1) return null;
371
+ const U = unionCoords(pcx, ccx);
372
+ const cols = U.length - 1;
373
+ if (cols < 1) return null;
374
+ const pa = anchorsOf(prev), ca = anchorsOf(curr);
375
+ let skip = 0;
376
+ while (skip < Math.min(3, curr.rows - 1, prev.rows) && rowText(ca, skip) !== "" && rowText(ca, skip) === rowText(pa, skip)) skip++;
377
+ const rows = prev.rows + curr.rows - skip;
378
+ const grid = Array.from({ length: rows }, () => Array.from({ length: cols }, () => ({ text: "", colSpan: 1, rowSpan: 1 })));
379
+ const owner = Array.from({ length: rows }, () => new Array(cols).fill(null));
380
+ const place = (a, x, rowOff) => {
381
+ const c1 = indexOf(U, x[a.c]), c2 = indexOf(U, x[a.c + a.cs]);
382
+ if (c1 < 0 || c2 <= c1) return false;
383
+ const r = a.r + rowOff;
384
+ const placed = { r, c: c1, rs: a.rs, cs: c2 - c1, cell: a.cell };
385
+ for (let dr = 0; dr < a.rs; dr++) for (let dc = c1; dc < c2; dc++) {
386
+ if (r + dr < rows) owner[r + dr][dc] = placed;
387
+ }
388
+ grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
389
+ const lines = CELL_LINES.get(a.cell);
390
+ if (lines) CELL_LINES.set(grid[r][c1], lines);
391
+ if (IMAGE_CELLS.has(a.cell)) IMAGE_CELLS.add(grid[r][c1]);
392
+ return true;
393
+ };
394
+ for (const a of pa) if (!FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
395
+ for (const a of ca) {
396
+ if (a.r < skip || FILLER_CELLS.has(a.cell)) continue;
397
+ if (!place(a, ccx, prev.rows - skip)) return null;
398
+ }
399
+ const first = prev.rows;
400
+ for (let c = 0; c < cols; c++) {
401
+ const above = owner[first - 1]?.[c];
402
+ if (!above) continue;
403
+ let r = first;
404
+ while (r < rows && owner[r][c] === null) r++;
405
+ if (r === first) continue;
406
+ const span = r - first;
407
+ let ok = true;
408
+ for (let dc = above.c; dc < above.c + above.cs && ok; dc++) {
409
+ for (let rr = first; rr < first + span; rr++) if (owner[rr][dc] !== null) {
410
+ ok = false;
411
+ break;
412
+ }
413
+ }
414
+ if (!ok) continue;
415
+ const newRs = above.rs + span;
416
+ grid[above.r][above.c].rowSpan = newRs;
417
+ const grown = { ...above, rs: newRs };
418
+ 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;
419
+ }
420
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) FILLER_CELLS.add(grid[r][c]);
421
+ const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
422
+ if (rows > prev.rows) mergeSplitRow(table, owner, prev.rows, U);
423
+ return { table, colXs: U };
424
+ }
425
+ var FULL_LINE_TOL = 1;
426
+ var FULL_LINE_MIN_FRAC = 0.5;
427
+ var FULL_LINE_EDGE_MIN = 12;
428
+ var SINGLE_LINE_WORD_GAP = 3.5;
429
+ var SHORT_LINE_GAP = 1.5;
430
+ function continuesAcross(u, d, x1, x2) {
431
+ const U = CELL_LINES.get(u), D = CELL_LINES.get(d);
432
+ if (!U?.length || !D?.length) return false;
433
+ const last = U[U.length - 1];
434
+ const fs = last.h || 10;
435
+ let minL = Infinity, maxR = -Infinity;
436
+ for (const l of U) {
437
+ minL = Math.min(minL, l.l);
438
+ maxR = Math.max(maxR, l.r);
439
+ }
440
+ for (const l of D) {
441
+ minL = Math.min(minL, l.l);
442
+ maxR = Math.max(maxR, l.r);
443
+ }
444
+ if (maxR - last.r > FULL_LINE_TOL * fs) return false;
445
+ if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
446
+ if (last.r - last.l < FULL_LINE_MIN_FRAC * (x2 - x1)) return false;
447
+ const leftAligned = (l) => l.l - minL <= fs && maxR - l.r > SHORT_LINE_GAP * fs;
448
+ return U.some(leftAligned) || D.some(leftAligned);
449
+ }
450
+ function mergeSplitRow(table, owner, first, colXs) {
451
+ const last = first - 1;
452
+ const pairs = [];
453
+ for (let c = 0; c < table.cols; ) {
454
+ const a = owner[last][c], b = owner[first][c];
455
+ if (!a || !b) return;
456
+ if (a !== b) {
457
+ if (a.c !== b.c || a.cs !== b.cs || a.r + a.rs - 1 !== last || b.r !== first || b.rs !== 1) return;
458
+ pairs.push([a, b]);
459
+ }
460
+ c = a.c + a.cs;
461
+ }
462
+ if (!pairs.some(([u, d]) => continuesAcross(u.cell, d.cell, colXs[u.c], colXs[u.c + u.cs]))) return;
463
+ for (const [u, d] of pairs) {
464
+ const a = table.cells[u.r][u.c], b = table.cells[d.r][d.c];
465
+ if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
466
+ if (b.blocks?.length) a.blocks = [...a.blocks ?? [], ...b.blocks];
467
+ }
468
+ for (let r = 0; r < first; r++) for (let c = 0; c < table.cols; c++) {
469
+ const o = owner[r][c];
470
+ if (o && o.r === r && o.c === c && r + table.cells[r][c].rowSpan > first) table.cells[r][c].rowSpan--;
471
+ }
472
+ table.cells.splice(first, 1);
473
+ table.rows--;
474
+ }
475
+ var NEIGHBOR_TABLE_EPSILON = 0.2;
476
+ function besideBoth(b, p, c) {
477
+ if (b.type === "table" || !b.bbox) return false;
478
+ const bx1 = b.bbox.x, bx2 = b.bbox.x + b.bbox.width;
479
+ return [p.bbox, c.bbox].every((t) => bx2 <= t.x + 1 || bx1 >= t.x + t.width - 1);
480
+ }
481
+ function mergeCrossPageTables(blocks, pageHeights) {
482
+ for (let i = blocks.length - 2; i >= 0; i--) {
483
+ const prev = blocks[i];
484
+ if (prev.type !== "table" || !prev.table || !prev.bbox || !prev.pageNumber) continue;
485
+ let j = i + 1;
486
+ while (j < blocks.length && blocks[j].type !== "table" && (blocks[j].pageNumber ?? 0) <= prev.pageNumber + 1) j++;
487
+ const curr = blocks[j];
488
+ if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
489
+ const joined = j === i + 1 || blocks.slice(i + 1, j).every((b) => besideBoth(b, prev, curr)) ? looksContinued(prev, curr, pageHeights) ? joinClipParts(prev, curr, pageHeights) ?? false : null : null;
490
+ if (joined) {
491
+ blocks[i] = { ...prev, table: joined };
492
+ blocks.splice(j, 1);
493
+ continue;
494
+ }
495
+ if (EMPTY_PARTS.has(curr.table)) {
496
+ blocks.splice(j, 1);
497
+ i++;
498
+ continue;
499
+ }
500
+ if (joined === null) continue;
501
+ if (prev.table.cols !== curr.table.cols || EMPTY_PARTS.has(prev.table)) continue;
502
+ const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
503
+ const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
504
+ const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
505
+ if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
506
+ const px = TABLE_COLXS.get(prev.table), cx = TABLE_COLXS.get(curr.table);
507
+ if (px && cx && (px.length !== cx.length || px.some((x, k) => Math.abs(x - cx[k]) > CONTINUATION_COL_TOL))) continue;
508
+ let currCells = curr.table.cells;
509
+ if (currCells.length > 1 && prev.table.cells.length > 0 && rowTextsEqual(prev.table.cells[0], currCells[0])) {
510
+ currCells = currCells.slice(1);
511
+ }
512
+ if (currCells.length === 0) {
513
+ blocks.splice(j, 1);
514
+ continue;
515
+ }
516
+ const merged = {
517
+ rows: prev.table.rows + currCells.length,
518
+ cols: prev.table.cols,
519
+ cells: [...prev.table.cells, ...currCells],
520
+ hasHeader: prev.table.hasHeader,
521
+ caption: prev.table.caption
522
+ };
523
+ if (px ?? cx) TABLE_COLXS.set(merged, px ?? cx);
524
+ if (CLIP_TABLES.has(prev.table) || CLIP_TABLES.has(curr.table)) CLIP_TABLES.add(merged);
525
+ blocks[i] = { ...prev, table: merged };
526
+ blocks.splice(j, 1);
527
+ }
528
+ for (let i = blocks.length - 1; i >= 0; i--) {
529
+ const t = blocks[i].table;
530
+ if (blocks[i].type === "table" && t && EMPTY_PARTS.has(t)) blocks.splice(i, 1);
531
+ }
532
+ }
533
+ function joinClipParts(prev, curr, pageHeights) {
534
+ const pt = prev.table, ct = curr.table;
535
+ if (!CLIP_TABLES.has(pt) || !CLIP_TABLES.has(ct)) return null;
536
+ const px = TABLE_COLXS.get(pt), cx = TABLE_COLXS.get(ct);
537
+ if (!px || !cx) return null;
538
+ const sameCols = px.length === cx.length && px.every((x, k) => Math.abs(x - cx[k]) <= CONTINUATION_COL_TOL);
539
+ if (!sameCols) {
540
+ if (!pageHeights?.get(prev.pageNumber) || !pageHeights?.get(curr.pageNumber)) return null;
541
+ if (Math.abs(px[px.length - 1] - cx[cx.length - 1]) > CONTINUATION_COL_TOL) return null;
542
+ if (!px.some((x) => Math.abs(x - cx[0]) <= CONTINUATION_COL_TOL)) return null;
543
+ }
544
+ const res = joinSplitParts(pt, px, ct, cx);
545
+ if (!res) return null;
546
+ TABLE_COLXS.set(res.table, res.colXs);
547
+ CLIP_TABLES.add(res.table);
548
+ return res.table;
549
+ }
550
+ var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
551
+ function looksContinued(prev, curr, pageHeights) {
552
+ const ph = pageHeights?.get(prev.pageNumber), ch = pageHeights?.get(curr.pageNumber);
553
+ if (ph && ch && (prev.bbox.y > ph * PAGE_EDGE_BAND || curr.bbox.y + curr.bbox.height < ch * (1 - PAGE_EDGE_BAND))) return false;
554
+ const firstText = curr.table.cells[0]?.find((c) => c.text.trim())?.text ?? "";
555
+ return !ANNEX_HEAD_RE.test(firstText);
556
+ }
557
+ function rowTextsEqual(a, b) {
558
+ if (a.length !== b.length) return false;
559
+ const norm = (t) => t.replace(/\s+/g, "");
560
+ for (let i = 0; i < a.length; i++) {
561
+ if (norm(a[i].text) !== norm(b[i].text)) return false;
562
+ }
563
+ return a.some((c) => c.text.trim() !== "");
564
+ }
565
+ var CONTINUATION_COL_TOL = 2;
566
+ var PAGE_EDGE_BAND = 0.16;
567
+
325
568
  // src/pdf/symbol-fonts.ts
326
- var WINGDINGS = [
327
- "\u{1F589}",
328
- "\u2702",
329
- "\u2701",
330
- "\u{1F453}",
331
- "\u{1F56D}",
332
- "\u{1F56E}",
333
- "\u{1F56F}",
334
- "\u{1F57F}",
335
- "\u2706",
336
- "\u{1F582}",
337
- "\u{1F583}",
338
- "\u{1F4EA}",
339
- "\u{1F4EB}",
340
- "\u{1F4EC}",
341
- "\u{1F4ED}",
342
- "\u{1F4C1}",
343
- "\u{1F4C2}",
344
- "\u{1F4C4}",
345
- "\u{1F5CF}",
346
- "\u{1F5D0}",
347
- "\u{1F5C4}",
348
- "\u231B",
349
- "\u{1F5AE}",
350
- "\u{1F5B0}",
351
- "\u{1F5B2}",
352
- "\u{1F5B3}",
353
- "\u{1F5B4}",
354
- "\u{1F5AB}",
355
- "\u{1F5AC}",
356
- "\u2707",
357
- "\u270D",
358
- "\u{1F58E}",
359
- "\u270C",
360
- "\u{1F44C}",
361
- "\u{1F44D}",
362
- "\u{1F44E}",
363
- "\u261C",
364
- "\u261E",
365
- "\u261D",
366
- "\u261F",
367
- "\u{1F590}",
368
- "\u263A",
369
- "\u{1F610}",
370
- "\u2639",
371
- "\u{1F4A3}",
372
- "\u2620",
373
- "\u{1F3F3}",
374
- "\u{1F3F1}",
375
- "\u2708",
376
- "\u263C",
377
- "\u{1F4A7}",
378
- "\u2744",
379
- "\u{1F546}",
380
- "\u271E",
381
- "\u{1F548}",
382
- "\u2720",
383
- "\u2721",
384
- "\u262A",
385
- "\u262F",
386
- "\u0950",
387
- "\u2638",
388
- "\u2648",
389
- "\u2649",
390
- "\u264A",
391
- "\u264B",
392
- "\u264C",
393
- "\u264D",
394
- "\u264E",
395
- "\u264F",
396
- "\u2650",
397
- "\u2651",
398
- "\u2652",
399
- "\u2653",
400
- "\u{1F670}",
401
- "\u{1F675}",
402
- "\u25CF",
403
- "\u25CB",
404
- "\u25A0",
405
- "\u25A1",
406
- "\u25A1",
407
- "\u2751",
408
- "\u2752",
409
- "\u2B27",
410
- "\u29EB",
411
- "\u25C6",
412
- "\u2756",
413
- "\u2B25",
414
- "\u2327",
415
- "\u2BB9",
416
- "\u2318",
417
- "\u{1F3F5}",
418
- "\u{1F3F6}",
419
- "\u{1F676}",
420
- "\u{1F677}",
421
- "",
422
- "\u24EA",
423
- "\u2460",
424
- "\u2461",
425
- "\u2462",
426
- "\u2463",
427
- "\u2464",
428
- "\u2465",
429
- "\u2466",
430
- "\u2467",
431
- "\u2468",
432
- "\u2469",
433
- "\u24FF",
434
- "\u2776",
435
- "\u2777",
436
- "\u2778",
437
- "\u2779",
438
- "\u277A",
439
- "\u277B",
440
- "\u277C",
441
- "\u277D",
442
- "\u277E",
443
- "\u277F",
444
- "\u{1F662}",
445
- "\u{1F660}",
446
- "\u{1F661}",
447
- "\u{1F663}",
448
- "\u{1F65E}",
449
- "\u{1F65C}",
450
- "\u{1F65D}",
451
- "\u{1F65F}",
452
- "\xB7",
453
- "\u2022",
454
- "\u25AA",
455
- "\u26AA",
456
- "\u25CB",
457
- "\u25EF",
458
- "\u25C9",
459
- "\u25CE",
460
- "\u{1F53F}",
461
- "\u25AA",
462
- "\u25FB",
463
- "\u{1F7C2}",
464
- "\u2726",
465
- "\u2605",
466
- "\u2736",
467
- "\u2734",
468
- "\u2739",
469
- "\u2735",
470
- "\u2BD0",
471
- "\u2316",
472
- "\u27E1",
473
- "\u2311",
474
- "\u2BD1",
475
- "\u272A",
476
- "\u2730",
477
- "\u{1F550}",
478
- "\u{1F551}",
479
- "\u{1F552}",
480
- "\u{1F553}",
481
- "\u{1F554}",
482
- "\u{1F555}",
483
- "\u{1F556}",
484
- "\u{1F557}",
485
- "\u{1F558}",
486
- "\u{1F559}",
487
- "\u{1F55A}",
488
- "\u{1F55B}",
489
- "\u2BB0",
490
- "\u2BB1",
491
- "\u2BB2",
492
- "\u2BB3",
493
- "\u2BB4",
494
- "\u2BB5",
495
- "\u2BB6",
496
- "\u2BB7",
497
- "\u{1F66A}",
498
- "\u{1F66B}",
499
- "\u{1F655}",
500
- "\u{1F654}",
501
- "\u{1F657}",
502
- "\u{1F656}",
503
- "\u{1F650}",
504
- "\u{1F651}",
505
- "\u{1F652}",
506
- "\u{1F653}",
507
- "\u232B",
508
- "\u2326",
509
- "\u2B98",
510
- "\u2B9A",
511
- "\u2B99",
512
- "\u2B9B",
513
- "\u2B88",
514
- "\u2B8A",
515
- "\u2B89",
516
- "\u2B8B",
517
- "\u2190",
518
- "\u2192",
519
- "\u2191",
520
- "\u2193",
521
- "\u2196",
522
- "\u2197",
523
- "\u2199",
524
- "\u2198",
525
- "\u2B05",
526
- "\u2794",
527
- "\u2B06",
528
- "\u2B07",
529
- "\u2B09",
530
- "\u2B08",
531
- "\u2B0B",
532
- "\u2B0A",
533
- "\u21E6",
534
- "\u21E8",
535
- "\u21E7",
536
- "\u21E9",
537
- "\u2B04",
538
- "\u21F3",
539
- "\u2B00",
540
- "\u2B01",
541
- "\u2B03",
542
- "\u2B02",
543
- "\u{1F8AC}",
544
- "\u{1F8AD}",
545
- "\u2717",
546
- "\u2714",
547
- "\u2612",
548
- "\u2611",
549
- ""
550
- ];
551
569
  var WINANSI_REVERSE = {
552
570
  8364: 128,
553
571
  8218: 130,
@@ -620,7 +638,8 @@ function remapSymbolFontItems(items, resolveFontName) {
620
638
  function normalizeAraea(text) {
621
639
  return text.replace(/(?<![\u1100-\u115F])\u119E/g, "\u318D");
622
640
  }
623
- var cleanChars = (text) => normalizeAraea(stripControlChars(text));
641
+ var stripNoUnicodeGlyph = (text) => text.includes("\uF000") ? text.replace(/\uF000/g, "") : text;
642
+ var cleanChars = (text) => normalizeAraea(stripNoUnicodeGlyph(stripControlChars(text)));
624
643
  function sanitizeBlockControlChars(blocks) {
625
644
  for (const b of blocks) {
626
645
  if (b.text) b.text = cleanChars(b.text);
@@ -734,7 +753,7 @@ function applyLinkAnnotations(items, annots) {
734
753
 
735
754
  // src/pdf/formula-ocr.ts
736
755
  async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
737
- const formulaMod = await import("./formula-JGFTXWYT.js");
756
+ const formulaMod = await import("./formula-X44GV7TN.js");
738
757
  const { FormulaPipeline, ensureFormulaModels } = formulaMod;
739
758
  await ensureFormulaModels((p) => {
740
759
  if (p.phase === "download" && p.total) {
@@ -984,7 +1003,7 @@ async function parsePdfDocument(buffer, options) {
984
1003
  const pageBlocks = extractPageBlocksWithLines(visible, i, opList, viewport.width, viewport.height, void 0, options?.tables !== false);
985
1004
  for (const b of pageBlocks) blocks.push(b);
986
1005
  try {
987
- const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings);
1006
+ const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, options?.images !== false);
988
1007
  if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
989
1008
  extractedImages.push(...pageImages);
990
1009
  } catch {
@@ -1026,7 +1045,7 @@ async function parsePdfDocument(buffer, options) {
1026
1045
  }
1027
1046
  if (targets.size > 0) {
1028
1047
  try {
1029
- const { runPdfOcr } = await import("./pdf-ocr-76SAUXMZ.js");
1048
+ const { runPdfOcr } = await import("./pdf-ocr-BNC34MNU.js");
1030
1049
  const mode = typeof options.ocr === "function" ? options.ocr : "builtin";
1031
1050
  const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, options.onProgress, options.tables !== false);
1032
1051
  if (ocrPageBlocks.size > 0) {
@@ -1081,7 +1100,8 @@ async function parsePdfDocument(buffer, options) {
1081
1100
  blocks.splice(removed[ri], 1);
1082
1101
  }
1083
1102
  }
1084
- mergeCrossPageTables(blocks);
1103
+ mergeCrossPageTables(blocks, pageHeights);
1104
+ if (!options?.keepTrailingEmptyCols) trimTrailingEmptyTableCols(blocks);
1085
1105
  injectPageImageBlocks(blocks, pageImageBlocks);
1086
1106
  if (options?.formulaOcr && formulaBuffer) {
1087
1107
  try {
@@ -1163,4 +1183,4 @@ export {
1163
1183
  parsePdfDocument,
1164
1184
  removeHeaderFooterBlocks
1165
1185
  };
1166
- //# sourceMappingURL=parser-A4TMPJAM.js.map
1186
+ //# sourceMappingURL=parser-HWFQRSUQ.js.map