kordoc 4.22.4 → 4.22.5

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 (128) hide show
  1. package/README.md +8 -7
  2. package/dist/{-HAK3YFWW.js → -WFRWBH7T.js} +11 -11
  3. package/dist/{chunk-F3AWNFMO.js → chunk-2L3Q7REU.js} +3 -3
  4. package/dist/{chunk-CWBH66IQ.js → chunk-35ZHXEJA.js} +3 -3
  5. package/dist/{chunk-Q6SVCBMK.js → chunk-3BR7VKWL.js} +2 -2
  6. package/dist/{chunk-G2325K2F.js → chunk-3G3TLZDK.js} +2 -2
  7. package/dist/{chunk-36DK6AOX.js → chunk-3YEL7P4L.js} +2 -2
  8. package/dist/{chunk-S45M7IQH.cjs → chunk-4SUB43EJ.cjs} +24 -24
  9. package/dist/{chunk-S45M7IQH.cjs.map → chunk-4SUB43EJ.cjs.map} +1 -1
  10. package/dist/{chunk-5ARHF54C.js → chunk-4TWN7PWJ.js} +2 -2
  11. package/dist/{chunk-WCTC3LSV.js → chunk-52HIK4C2.js} +4 -3
  12. package/dist/chunk-52HIK4C2.js.map +1 -0
  13. package/dist/{chunk-3TUJ34V7.js → chunk-63N6CEJE.js} +2 -2
  14. package/dist/{chunk-DEFT7Z3B.js → chunk-6MCC2XNB.js} +2 -2
  15. package/dist/{chunk-C5J5LDWM.js → chunk-6MQKNB6K.js} +4 -3
  16. package/dist/chunk-6MQKNB6K.js.map +1 -0
  17. package/dist/{chunk-MJSHXESK.cjs → chunk-AS25R4EU.cjs} +2 -2
  18. package/dist/{chunk-MJSHXESK.cjs.map → chunk-AS25R4EU.cjs.map} +1 -1
  19. package/dist/{chunk-AYV5VRHL.js → chunk-C3REGEQO.js} +2 -2
  20. package/dist/{chunk-4X7AR4EH.cjs → chunk-C6B5GWN7.cjs} +24 -23
  21. package/dist/chunk-C6B5GWN7.cjs.map +1 -0
  22. package/dist/{chunk-A3SKXHAN.js → chunk-CO7O3ZT6.js} +2 -2
  23. package/dist/{chunk-WNW77CAY.js → chunk-CRSTBATY.js} +2 -2
  24. package/dist/{chunk-MYTMZSQO.js → chunk-CW67DAAH.js} +2 -2
  25. package/dist/{chunk-RPSILMQY.js → chunk-DN55FTJP.js} +2 -2
  26. package/dist/{chunk-HN3QMHTT.js → chunk-HLPMC7L4.js} +5 -4
  27. package/dist/chunk-HLPMC7L4.js.map +1 -0
  28. package/dist/{chunk-LVVSMYG4.js → chunk-LE4VHWIT.js} +4 -4
  29. package/dist/{chunk-VXQWAPC6.cjs → chunk-N6KXGIIN.cjs} +3 -3
  30. package/dist/{chunk-VXQWAPC6.cjs.map → chunk-N6KXGIIN.cjs.map} +1 -1
  31. package/dist/{chunk-G4KNI7EO.js → chunk-PSORL4PA.js} +11 -11
  32. package/dist/{chunk-FAFSBCU2.js → chunk-RYKDIUHT.js} +4 -4
  33. package/dist/{chunk-SSL3TKJY.js → chunk-SETAYS6P.js} +2 -2
  34. package/dist/{chunk-Q65HT2BL.js → chunk-T7OZ7X6A.js} +2 -2
  35. package/dist/{chunk-UJVVL6BI.js → chunk-TOUJCO2P.js} +2 -2
  36. package/dist/{chunk-EVL6HZQL.js → chunk-U3GUZQ54.js} +1286 -1279
  37. package/dist/chunk-U3GUZQ54.js.map +1 -0
  38. package/dist/{chunk-EYQLJ57Y.cjs → chunk-UCK6WGHY.cjs} +3 -3
  39. package/dist/{chunk-EYQLJ57Y.cjs.map → chunk-UCK6WGHY.cjs.map} +1 -1
  40. package/dist/{chunk-K2NWHLCD.cjs → chunk-YG4GFQB7.cjs} +6 -6
  41. package/dist/{chunk-K2NWHLCD.cjs.map → chunk-YG4GFQB7.cjs.map} +1 -1
  42. package/dist/chunks-NXABWR6G.js +10 -0
  43. package/dist/cli.js +30 -30
  44. package/dist/{formula-PWAUR5PF.js → formula-FSVHUQ6Y.js} +4 -4
  45. package/dist/{formula-KSTY73DQ.js → formula-L625ULJP.js} +3 -3
  46. package/dist/{formula-JGFYGFYX.cjs → formula-QZGTF3DZ.cjs} +9 -9
  47. package/dist/{formula-JGFYGFYX.cjs.map → formula-QZGTF3DZ.cjs.map} +1 -1
  48. package/dist/{image-ocr-UULNAC5Y.cjs → image-ocr-AELVAU75.cjs} +17 -17
  49. package/dist/{image-ocr-UULNAC5Y.cjs.map → image-ocr-AELVAU75.cjs.map} +1 -1
  50. package/dist/{image-ocr-RASJHOAK.js → image-ocr-KE3RUS3R.js} +6 -6
  51. package/dist/{image-ocr-RPBPO3VT.js → image-ocr-QTZNBP5V.js} +9 -9
  52. package/dist/index.cjs +790 -782
  53. package/dist/index.cjs.map +1 -1
  54. package/dist/index.js +249 -241
  55. package/dist/index.js.map +1 -1
  56. package/dist/mcp.js +22 -22
  57. package/dist/{model-bundle-ZPQ4IFT7.js → model-bundle-F6TU6ZAV.js} +5 -5
  58. package/dist/{models-YJQ5VHOR.js → models-ZHNNVH2W.js} +5 -5
  59. package/dist/{parse-worker-v2-7PNZYASF.js → parse-worker-v2-KQRG3NQO.js} +12 -12
  60. package/dist/{parser-ER3VLB37.js → parser-RVMH4PUB.js} +133 -20
  61. package/dist/parser-RVMH4PUB.js.map +1 -0
  62. package/dist/{parser-DR6ZHYEB.js → parser-WBKVRDPV.js} +129 -16
  63. package/dist/parser-WBKVRDPV.js.map +1 -0
  64. package/dist/{parser-ZFXVZZKQ.cjs → parser-WNDH2X6N.cjs} +397 -284
  65. package/dist/parser-WNDH2X6N.cjs.map +1 -0
  66. package/dist/pdf-ocr-IOUZTPPH.cjs +31 -0
  67. package/dist/{pdf-ocr-QWTGWYQT.cjs.map → pdf-ocr-IOUZTPPH.cjs.map} +1 -1
  68. package/dist/{pdf-ocr-BYT7XVID.js → pdf-ocr-X5XLGL5J.js} +6 -6
  69. package/dist/{pdf-ocr-DRQN5BXA.js → pdf-ocr-ZP2CUWSO.js} +9 -9
  70. package/dist/{profile-io-3QYTSPNH.js → profile-io-B4VSI4LW.js} +3 -3
  71. package/dist/{rasterize-LPLWCBXV.js → rasterize-Y7NVUVXU.js} +3 -3
  72. package/dist/{redact-doc-HDA6ZG3N.js → redact-doc-GIBTFWCO.js} +11 -11
  73. package/dist/{render-MYZGD3SB.js → render-JVCGYRRO.js} +7 -7
  74. package/dist/seal-WNX2ZJTK.js +10 -0
  75. package/dist/{setup-EF5TQVAI.js → setup-7L7EQPMG.js} +3 -3
  76. package/dist/visual-VPWPXIHN.js +21 -0
  77. package/dist/{watch-PM5PRSFW.js → watch-VYMFGX72.js} +12 -12
  78. package/package.json +1 -1
  79. package/dist/chunk-4X7AR4EH.cjs.map +0 -1
  80. package/dist/chunk-C5J5LDWM.js.map +0 -1
  81. package/dist/chunk-EVL6HZQL.js.map +0 -1
  82. package/dist/chunk-HN3QMHTT.js.map +0 -1
  83. package/dist/chunk-WCTC3LSV.js.map +0 -1
  84. package/dist/chunks-3N7OFSA4.js +0 -10
  85. package/dist/parser-DR6ZHYEB.js.map +0 -1
  86. package/dist/parser-ER3VLB37.js.map +0 -1
  87. package/dist/parser-ZFXVZZKQ.cjs.map +0 -1
  88. package/dist/pdf-ocr-QWTGWYQT.cjs +0 -31
  89. package/dist/seal-XA5V6A6V.js +0 -10
  90. package/dist/visual-DB7NJOID.js +0 -21
  91. /package/dist/{-HAK3YFWW.js.map → -WFRWBH7T.js.map} +0 -0
  92. /package/dist/{chunk-F3AWNFMO.js.map → chunk-2L3Q7REU.js.map} +0 -0
  93. /package/dist/{chunk-CWBH66IQ.js.map → chunk-35ZHXEJA.js.map} +0 -0
  94. /package/dist/{chunk-Q6SVCBMK.js.map → chunk-3BR7VKWL.js.map} +0 -0
  95. /package/dist/{chunk-G2325K2F.js.map → chunk-3G3TLZDK.js.map} +0 -0
  96. /package/dist/{chunk-36DK6AOX.js.map → chunk-3YEL7P4L.js.map} +0 -0
  97. /package/dist/{chunk-5ARHF54C.js.map → chunk-4TWN7PWJ.js.map} +0 -0
  98. /package/dist/{chunk-3TUJ34V7.js.map → chunk-63N6CEJE.js.map} +0 -0
  99. /package/dist/{chunk-DEFT7Z3B.js.map → chunk-6MCC2XNB.js.map} +0 -0
  100. /package/dist/{chunk-AYV5VRHL.js.map → chunk-C3REGEQO.js.map} +0 -0
  101. /package/dist/{chunk-A3SKXHAN.js.map → chunk-CO7O3ZT6.js.map} +0 -0
  102. /package/dist/{chunk-WNW77CAY.js.map → chunk-CRSTBATY.js.map} +0 -0
  103. /package/dist/{chunk-MYTMZSQO.js.map → chunk-CW67DAAH.js.map} +0 -0
  104. /package/dist/{chunk-RPSILMQY.js.map → chunk-DN55FTJP.js.map} +0 -0
  105. /package/dist/{chunk-LVVSMYG4.js.map → chunk-LE4VHWIT.js.map} +0 -0
  106. /package/dist/{chunk-G4KNI7EO.js.map → chunk-PSORL4PA.js.map} +0 -0
  107. /package/dist/{chunk-FAFSBCU2.js.map → chunk-RYKDIUHT.js.map} +0 -0
  108. /package/dist/{chunk-SSL3TKJY.js.map → chunk-SETAYS6P.js.map} +0 -0
  109. /package/dist/{chunk-Q65HT2BL.js.map → chunk-T7OZ7X6A.js.map} +0 -0
  110. /package/dist/{chunk-UJVVL6BI.js.map → chunk-TOUJCO2P.js.map} +0 -0
  111. /package/dist/{chunks-3N7OFSA4.js.map → chunks-NXABWR6G.js.map} +0 -0
  112. /package/dist/{formula-PWAUR5PF.js.map → formula-FSVHUQ6Y.js.map} +0 -0
  113. /package/dist/{formula-KSTY73DQ.js.map → formula-L625ULJP.js.map} +0 -0
  114. /package/dist/{image-ocr-RASJHOAK.js.map → image-ocr-KE3RUS3R.js.map} +0 -0
  115. /package/dist/{image-ocr-RPBPO3VT.js.map → image-ocr-QTZNBP5V.js.map} +0 -0
  116. /package/dist/{model-bundle-ZPQ4IFT7.js.map → model-bundle-F6TU6ZAV.js.map} +0 -0
  117. /package/dist/{models-YJQ5VHOR.js.map → models-ZHNNVH2W.js.map} +0 -0
  118. /package/dist/{parse-worker-v2-7PNZYASF.js.map → parse-worker-v2-KQRG3NQO.js.map} +0 -0
  119. /package/dist/{pdf-ocr-BYT7XVID.js.map → pdf-ocr-X5XLGL5J.js.map} +0 -0
  120. /package/dist/{pdf-ocr-DRQN5BXA.js.map → pdf-ocr-ZP2CUWSO.js.map} +0 -0
  121. /package/dist/{profile-io-3QYTSPNH.js.map → profile-io-B4VSI4LW.js.map} +0 -0
  122. /package/dist/{rasterize-LPLWCBXV.js.map → rasterize-Y7NVUVXU.js.map} +0 -0
  123. /package/dist/{redact-doc-HDA6ZG3N.js.map → redact-doc-GIBTFWCO.js.map} +0 -0
  124. /package/dist/{render-MYZGD3SB.js.map → render-JVCGYRRO.js.map} +0 -0
  125. /package/dist/{seal-XA5V6A6V.js.map → seal-WNX2ZJTK.js.map} +0 -0
  126. /package/dist/{setup-EF5TQVAI.js.map → setup-7L7EQPMG.js.map} +0 -0
  127. /package/dist/{visual-DB7NJOID.js.map → visual-VPWPXIHN.js.map} +0 -0
  128. /package/dist/{watch-PM5PRSFW.js.map → watch-VYMFGX72.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 _chunkVXQWAPC6cjs = require('./chunk-VXQWAPC6.cjs');
4
+ var _chunkN6KXGIINcjs = require('./chunk-N6KXGIIN.cjs');
5
5
 
6
6
 
7
7
 
@@ -61,7 +61,7 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
61
61
 
62
62
 
63
63
 
64
- var _chunk4X7AR4EHcjs = require('./chunk-4X7AR4EH.cjs');
64
+ var _chunkC6B5GWN7cjs = require('./chunk-C6B5GWN7.cjs');
65
65
 
66
66
 
67
67
 
@@ -75,12 +75,13 @@ var _chunk4X7AR4EHcjs = require('./chunk-4X7AR4EH.cjs');
75
75
 
76
76
 
77
77
 
78
- var _chunkK2NWHLCDcjs = require('./chunk-K2NWHLCD.cjs');
79
- require('./chunk-EYQLJ57Y.cjs');
80
78
 
79
+ var _chunkYG4GFQB7cjs = require('./chunk-YG4GFQB7.cjs');
80
+ require('./chunk-UCK6WGHY.cjs');
81
81
 
82
82
 
83
- var _chunkMJSHXESKcjs = require('./chunk-MJSHXESK.cjs');
83
+
84
+ var _chunkAS25R4EUcjs = require('./chunk-AS25R4EU.cjs');
84
85
 
85
86
 
86
87
  var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
@@ -217,7 +218,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
217
218
  const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
218
219
  state.seen.set(hash, filename);
219
220
  if (withBytes) {
220
- const png = _chunkVXQWAPC6cjs.encodePng.call(void 0, w, h, rgba);
221
+ const png = _chunkN6KXGIINcjs.encodePng.call(void 0, w, h, rgba);
221
222
  state.totalBytes += png.length;
222
223
  images.push({ filename, data: png, mimeType: "image/png" });
223
224
  }
@@ -613,20 +614,21 @@ function ocrVectorOps(opList, paths) {
613
614
 
614
615
  // src/pdf/split-row-pattern.ts
615
616
  var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
616
- var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !_chunk4X7AR4EHcjs.IMAGE_CELLS.has(cell);
617
+ var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !_chunkC6B5GWN7cjs.IMAGE_CELLS.has(cell);
617
618
  var labelsOf = (cell) => {
618
619
  const labels = textOf(cell).split("\n").map((s) => s.trim()).filter(Boolean);
619
620
  return labels.length && labels.every((s) => /^\p{L}[\p{L}\p{N} ]{0,15}[::]$/u.test(s)) ? labels.map((s) => s.replace(/\s+/g, "").replace(/:/g, ":")) : void 0;
620
621
  };
621
622
  var alignedLabels = (label, value, count) => {
622
- const L = _chunk4X7AR4EHcjs.CELL_LINES.get(label), V = _chunk4X7AR4EHcjs.CELL_LINES.get(value);
623
+ const L = _chunkC6B5GWN7cjs.CELL_LINES.get(label), V = _chunkC6B5GWN7cjs.CELL_LINES.get(value);
623
624
  let next = 0;
624
625
  return !!L && !!V && L.length === count && V.length >= count && Math.abs(L[0].y - V[0].y) <= 1 && L.every((l) => {
625
626
  while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
626
627
  return next++ < V.length;
627
628
  });
628
629
  };
629
- function matchesCompleteAlignedLabelListRow(table, owner, first) {
630
+ function partialAlignedLabelCells(table, owner, first) {
631
+ const pageOf = (a) => _nullishCoalesce(_chunkYG4GFQB7cjs.CELL_PAGES.get(_nullishCoalesce(a.cell, () => ( table.cells[a.r][a.c]))), () => ( (a.r < first ? -1 : -2)));
630
632
  const pairs = [];
631
633
  let carried = false;
632
634
  for (let c = 0; c < table.cols; ) {
@@ -641,6 +643,67 @@ function matchesCompleteAlignedLabelListRow(table, owner, first) {
641
643
  c++;
642
644
  continue;
643
645
  }
646
+ if (!u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower) || !textOf(upper) || !textOf(lower)) return;
647
+ pairs.push({ c, cs: u.cs, upper, lower });
648
+ c += u.cs;
649
+ }
650
+ if (!carried || pairs.length !== 3) return;
651
+ const keyed = pairs.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
652
+ if (keyed.length !== 1) return;
653
+ const label = keyed[0], value = pairs.find((p) => p.c === label.c + label.cs), context = pairs.find((p) => p.c + p.cs === label.c);
654
+ if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([_chunkYG4GFQB7cjs.CELL_EDGES, 'access', _21 => _21.get, 'call', _22 => _22(context.upper), 'optionalAccess', _23 => _23.b]) || !_optionalChain([_chunkYG4GFQB7cjs.CELL_EDGES, 'access', _24 => _24.get, 'call', _25 => _25(context.lower), 'optionalAccess', _26 => _26.t])) return;
655
+ const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
656
+ if (D.length < 2 || sequence.length < 3 || new Set(sequence).size !== sequence.length || !alignedLabels(label.upper, value.upper, U.length)) return;
657
+ const L = _chunkC6B5GWN7cjs.CELL_LINES.get(label.lower), V = _chunkC6B5GWN7cjs.CELL_LINES.get(value.lower);
658
+ if (!L || !V || L.length !== D.length) return;
659
+ let next = V.findIndex((v) => Math.abs(v.y - L[0].y) <= 1);
660
+ if (next <= 0 || !V.slice(0, next).every((v) => v.y > L[0].y + 1) || !L.every((l) => {
661
+ while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
662
+ return next++ < V.length;
663
+ })) return;
664
+ let peers = 0, shared = false;
665
+ for (let r = 0; r < table.rows; r++) {
666
+ if (r === first - 1 || r === first) continue;
667
+ const l = _optionalChain([owner, 'access', _27 => _27[r], 'optionalAccess', _28 => _28[label.c]]), v = _optionalChain([owner, 'access', _29 => _29[r], 'optionalAccess', _30 => _30[value.c]]);
668
+ if (!l || !v || l.r !== r || v.r !== r || l.c !== label.c || v.c !== value.c || l.cs !== label.cs || v.cs !== value.cs || l.rs !== v.rs) continue;
669
+ const lc = table.cells[r][l.c], vc = table.cells[r][v.c];
670
+ const list = labelsOf(lc);
671
+ if (!plain(lc) || !plain(vc) || !textOf(vc) || !list || pageOf(l) !== pageOf(v)) continue;
672
+ if (l.rs === 1) {
673
+ if (list.join("|") === sequence.join("|") && alignedLabels(lc, vc, list.length)) peers++;
674
+ continue;
675
+ }
676
+ if (list.length < 3 || new Set(list).size !== list.length) continue;
677
+ const visible = _nullishCoalesce(_optionalChain([_chunkC6B5GWN7cjs.CELL_LINES, 'access', _31 => _31.get, 'call', _32 => _32(lc), 'optionalAccess', _33 => _33.length]), () => ( 0)), values = _chunkC6B5GWN7cjs.CELL_LINES.get(vc);
678
+ if (visible < 3 || visible > list.length || !values || !alignedLabels(lc, vc, visible)) continue;
679
+ const top = Math.max(...values.map((v2) => v2.y)), bottom = Math.min(...values.map((v2) => v2.y));
680
+ const contexts = [];
681
+ for (let rr = r; rr < r + l.rs && rr < table.rows; rr++) {
682
+ const a = _optionalChain([owner, 'access', _34 => _34[rr], 'optionalAccess', _35 => _35[context.c]]), cell = a ? table.cells[a.r][a.c] : void 0;
683
+ if (!a || a.r !== rr || a.c !== context.c || a.cs !== context.cs || a.rs !== 1 || !cell || !plain(cell) || !textOf(cell) || pageOf(a) !== pageOf(l)) break;
684
+ const lines = _chunkC6B5GWN7cjs.CELL_LINES.get(cell);
685
+ if (!_optionalChain([lines, 'optionalAccess', _36 => _36.length]) || lines.some((line) => line.y > top + 1 || line.y < bottom - 1)) break;
686
+ contexts.push(textOf(cell).replace(/\s+/g, ""));
687
+ }
688
+ if (new Set(contexts).size >= 2) shared = true;
689
+ }
690
+ return peers >= 2 && shared ? { context, label, value } : void 0;
691
+ }
692
+ function matchesCompleteAlignedLabelListRow(table, owner, first) {
693
+ const pairs = [];
694
+ let carried = false;
695
+ for (let c = 0; c < table.cols; ) {
696
+ const u = _optionalChain([owner, 'access', _37 => _37[first - 1], 'optionalAccess', _38 => _38[c]]), d = _optionalChain([owner, 'access', _39 => _39[first], 'optionalAccess', _40 => _40[c]]);
697
+ if (u && u === d) {
698
+ carried = true;
699
+ c = u.c + u.cs;
700
+ continue;
701
+ }
702
+ const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
703
+ if (!_optionalChain([upper, 'optionalAccess', _41 => _41.text, 'access', _42 => _42.trim, 'call', _43 => _43()]) && !_optionalChain([lower, 'optionalAccess', _44 => _44.text, 'access', _45 => _45.trim, 'call', _46 => _46()])) {
704
+ c++;
705
+ continue;
706
+ }
644
707
  if (!u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower)) return false;
645
708
  pairs.push({ c, cs: u.cs, upper, lower });
646
709
  c += u.cs;
@@ -655,10 +718,10 @@ function matchesCompleteAlignedLabelListRow(table, owner, first) {
655
718
  let peers = 0;
656
719
  for (let r = 0; r < table.rows; r++) {
657
720
  if (r === first - 1 || r === first) continue;
658
- const L = _optionalChain([owner, 'access', _21 => _21[r], 'optionalAccess', _22 => _22[label.c]]), V = _optionalChain([owner, 'access', _23 => _23[r], 'optionalAccess', _24 => _24[value.c]]);
659
- if (_optionalChain([L, 'optionalAccess', _25 => _25.r]) !== r || _optionalChain([V, 'optionalAccess', _26 => _26.r]) !== r || L.c !== label.c || V.c !== value.c || L.rs !== 1 || V.rs !== 1 || L.cs !== label.cs || V.cs !== value.cs) continue;
721
+ const L = _optionalChain([owner, 'access', _47 => _47[r], 'optionalAccess', _48 => _48[label.c]]), V = _optionalChain([owner, 'access', _49 => _49[r], 'optionalAccess', _50 => _50[value.c]]);
722
+ if (_optionalChain([L, 'optionalAccess', _51 => _51.r]) !== r || _optionalChain([V, 'optionalAccess', _52 => _52.r]) !== r || L.c !== label.c || V.c !== value.c || L.rs !== 1 || V.rs !== 1 || L.cs !== label.cs || V.cs !== value.cs) continue;
660
723
  const l = table.cells[r][label.c], v = table.cells[r][value.c];
661
- if (!plain(l) || !plain(v) || !textOf(v) || _optionalChain([labelsOf, 'call', _27 => _27(l), 'optionalAccess', _28 => _28.join, 'call', _29 => _29("|")]) !== sequence.join("|") || !alignedLabels(l, v, sequence.length)) continue;
724
+ if (!plain(l) || !plain(v) || !textOf(v) || _optionalChain([labelsOf, 'call', _53 => _53(l), 'optionalAccess', _54 => _54.join, 'call', _55 => _55("|")]) !== sequence.join("|") || !alignedLabels(l, v, sequence.length)) continue;
662
725
  if (++peers >= 2) return true;
663
726
  }
664
727
  return false;
@@ -667,13 +730,13 @@ function matchesIndependentRowPair(table, owner, first) {
667
730
  const norm = (cell) => textOf(cell).replace(/\s+/g, "");
668
731
  const pairs = [];
669
732
  for (let c = 0; c < table.cols; ) {
670
- const u = _optionalChain([owner, 'access', _30 => _30[first - 1], 'optionalAccess', _31 => _31[c]]), d = _optionalChain([owner, 'access', _32 => _32[first], 'optionalAccess', _33 => _33[c]]);
733
+ const u = _optionalChain([owner, 'access', _56 => _56[first - 1], 'optionalAccess', _57 => _57[c]]), d = _optionalChain([owner, 'access', _58 => _58[first], 'optionalAccess', _59 => _59[c]]);
671
734
  if (u && u === d) {
672
735
  c = u.c + u.cs;
673
736
  continue;
674
737
  }
675
738
  const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
676
- if (!_optionalChain([upper, 'optionalAccess', _34 => _34.text, 'access', _35 => _35.trim, 'call', _36 => _36()]) && !_optionalChain([lower, 'optionalAccess', _37 => _37.text, 'access', _38 => _38.trim, 'call', _39 => _39()])) {
739
+ if (!_optionalChain([upper, 'optionalAccess', _60 => _60.text, 'access', _61 => _61.trim, 'call', _62 => _62()]) && !_optionalChain([lower, 'optionalAccess', _63 => _63.text, 'access', _64 => _64.trim, 'call', _65 => _65()])) {
677
740
  c++;
678
741
  continue;
679
742
  }
@@ -685,8 +748,8 @@ function matchesIndependentRowPair(table, owner, first) {
685
748
  return table.cells.some((_, r) => {
686
749
  if (r + 1 >= table.rows || r + 1 >= first - 1 && r <= first) return false;
687
750
  return pairs.every((p) => [p.upper, p.lower].every((text, i) => {
688
- const a = _optionalChain([owner, 'access', _40 => _40[r + i], 'optionalAccess', _41 => _41[p.c]]), cell = _optionalChain([table, 'access', _42 => _42.cells, 'access', _43 => _43[r + i], 'optionalAccess', _44 => _44[p.c]]);
689
- return _optionalChain([a, 'optionalAccess', _45 => _45.r]) === r + i && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(cell) === text;
751
+ const a = _optionalChain([owner, 'access', _66 => _66[r + i], 'optionalAccess', _67 => _67[p.c]]), cell = _optionalChain([table, 'access', _68 => _68.cells, 'access', _69 => _69[r + i], 'optionalAccess', _70 => _70[p.c]]);
752
+ return _optionalChain([a, 'optionalAccess', _71 => _71.r]) === r + i && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(cell) === text;
690
753
  }));
691
754
  });
692
755
  }
@@ -695,7 +758,7 @@ function matchesCompleteContextRow(table, owner, first) {
695
758
  const context = [];
696
759
  let value;
697
760
  for (let c = 0; c < table.cols; ) {
698
- const u = _optionalChain([owner, 'access', _46 => _46[first - 1], 'optionalAccess', _47 => _47[c]]), d = _optionalChain([owner, 'access', _48 => _48[first], 'optionalAccess', _49 => _49[c]]);
761
+ const u = _optionalChain([owner, 'access', _72 => _72[first - 1], 'optionalAccess', _73 => _73[c]]), d = _optionalChain([owner, 'access', _74 => _74[first], 'optionalAccess', _75 => _75[c]]);
699
762
  if (u && u === d) {
700
763
  const cell = table.cells[u.r][u.c];
701
764
  if (u.r === first - 1 && u.rs === 2 && plain(cell) && textOf(cell)) context.push({ c, cs: u.cs, text: norm(textOf(cell)) });
@@ -703,7 +766,7 @@ function matchesCompleteContextRow(table, owner, first) {
703
766
  continue;
704
767
  }
705
768
  const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
706
- if (!_optionalChain([upper, 'optionalAccess', _50 => _50.text, 'access', _51 => _51.trim, 'call', _52 => _52()]) && !_optionalChain([lower, 'optionalAccess', _53 => _53.text, 'access', _54 => _54.trim, 'call', _55 => _55()])) {
769
+ if (!_optionalChain([upper, 'optionalAccess', _76 => _76.text, 'access', _77 => _77.trim, 'call', _78 => _78()]) && !_optionalChain([lower, 'optionalAccess', _79 => _79.text, 'access', _80 => _80.trim, 'call', _81 => _81()])) {
707
770
  c++;
708
771
  continue;
709
772
  }
@@ -714,8 +777,8 @@ function matchesCompleteContextRow(table, owner, first) {
714
777
  if (!value || !context.length) return false;
715
778
  const proof = [...context, value];
716
779
  return table.cells.some((row, r) => r !== first - 1 && r !== first && proof.every((p) => {
717
- const a = _optionalChain([owner, 'access', _56 => _56[r], 'optionalAccess', _57 => _57[p.c]]), cell = row[p.c];
718
- return _optionalChain([a, 'optionalAccess', _58 => _58.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(textOf(cell)) === p.text;
780
+ const a = _optionalChain([owner, 'access', _82 => _82[r], 'optionalAccess', _83 => _83[p.c]]), cell = row[p.c];
781
+ return _optionalChain([a, 'optionalAccess', _84 => _84.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(textOf(cell)) === p.text;
719
782
  }));
720
783
  }
721
784
  function matchesCompleteSiblingRow(table, owner, first) {
@@ -743,7 +806,7 @@ function matchesCompleteSiblingRow(table, owner, first) {
743
806
  const norm = (s, title) => (title ? s.replace(/^[가-힣]\.\s*/, "") : s).replace(/\s+/g, "");
744
807
  return table.cells.some((row, r) => r !== first - 1 && r !== first && pairs.every((p) => {
745
808
  const anchor = owner[r][p.c], peer = row[p.c];
746
- return _optionalChain([anchor, 'optionalAccess', _59 => _59.r]) === r && anchor.c === p.c && anchor.rs === 1 && anchor.cs === p.cs && plain(peer) && norm(textOf(peer), p === main) === norm(textOf(p.upper) + "\n" + textOf(p.lower), p === main);
809
+ return _optionalChain([anchor, 'optionalAccess', _85 => _85.r]) === r && anchor.c === p.c && anchor.rs === 1 && anchor.cs === p.cs && plain(peer) && norm(textOf(peer), p === main) === norm(textOf(p.upper) + "\n" + textOf(p.lower), p === main);
747
810
  }));
748
811
  }
749
812
  function matchesCompleteRubricRow(table, owner, first) {
@@ -777,7 +840,7 @@ function matchesCompleteRubricRow(table, owner, first) {
777
840
  return table.cells.some((row, r) => {
778
841
  if (r === first - 1 || r === first || !pairs.every((p) => {
779
842
  const a = owner[r][p.c];
780
- return _optionalChain([a, 'optionalAccess', _60 => _60.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && plain(row[p.c]);
843
+ return _optionalChain([a, 'optionalAccess', _86 => _86.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && plain(row[p.c]);
781
844
  })) return false;
782
845
  const peer = textOf(row[main.c]), peerMarks = items(peer);
783
846
  return peerMarks.length === marks.length && peerMarks.every((m, i) => m.n === marks[i].n) && values(row[score.c]).join("|") === scores.join("|") && norm(peer.slice(peerMarks[peerMarks.length - 1].at)) === tail;
@@ -799,11 +862,11 @@ function hasNumberedRowSequence(table, owner, first) {
799
862
  if (first < 3) return false;
800
863
  const rows = [first - 3, first - 2, first - 1, first];
801
864
  const separate = (c, cs) => rows.every((r) => {
802
- const a = _optionalChain([owner, 'access', _61 => _61[r], 'optionalAccess', _62 => _62[c]]), cell = _optionalChain([table, 'access', _63 => _63.cells, 'access', _64 => _64[r], 'optionalAccess', _65 => _65[c]]);
803
- return _optionalChain([a, 'optionalAccess', _66 => _66.r]) === r && a.c === c && a.rs === 1 && a.cs === cs && !!cell && plain(cell) && !!textOf(cell);
865
+ const a = _optionalChain([owner, 'access', _87 => _87[r], 'optionalAccess', _88 => _88[c]]), cell = _optionalChain([table, 'access', _89 => _89.cells, 'access', _90 => _90[r], 'optionalAccess', _91 => _91[c]]);
866
+ return _optionalChain([a, 'optionalAccess', _92 => _92.r]) === r && a.c === c && a.rs === 1 && a.cs === cs && !!cell && plain(cell) && !!textOf(cell);
804
867
  });
805
868
  for (let c = 0; c < table.cols; c++) {
806
- const a = _optionalChain([owner, 'access', _67 => _67[first], 'optionalAccess', _68 => _68[c]]);
869
+ const a = _optionalChain([owner, 'access', _93 => _93[first], 'optionalAccess', _94 => _94[c]]);
807
870
  if (!a || !separate(c, a.cs)) continue;
808
871
  const marks = rows.map((r) => {
809
872
  const lines = textOf(table.cells[r][c]).split("\n"), firstMark = itemMark(lines[0]);
@@ -812,7 +875,7 @@ function hasNumberedRowSequence(table, owner, first) {
812
875
  const head = marks[0];
813
876
  if (!head || marks.some((m, i) => !m || m.style !== head.style || m.n !== head.n + i)) continue;
814
877
  for (let d = 0; d < table.cols; d++) {
815
- const side = _optionalChain([owner, 'access', _69 => _69[first], 'optionalAccess', _70 => _70[d]]);
878
+ const side = _optionalChain([owner, 'access', _95 => _95[first], 'optionalAccess', _96 => _96[d]]);
816
879
  if (side && (d + side.cs <= c || d >= c + a.cs) && separate(d, side.cs)) return true;
817
880
  }
818
881
  }
@@ -885,7 +948,7 @@ var CELL_SPLITS = /* @__PURE__ */ new WeakMap();
885
948
  function relocate(src, dst, from = 0) {
886
949
  const out = [];
887
950
  for (const s of _nullishCoalesce(CELL_SPLITS.get(src), () => ( []))) {
888
- const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access', _71 => _71.at, 'call', _72 => _72(-1), 'optionalAccess', _73 => _73.at]), () => ( 0))));
951
+ const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access', _97 => _97.at, 'call', _98 => _98(-1), 'optionalAccess', _99 => _99.at]), () => ( 0))));
889
952
  if (at >= 0) out.push({ at, page: s.page });
890
953
  }
891
954
  return out;
@@ -909,7 +972,7 @@ function rowStarts(t) {
909
972
  const starts = [];
910
973
  for (let c = 0; c < t.cols; c++) {
911
974
  if (covered.has(r * 1e5 + c)) continue;
912
- const cell = _optionalChain([t, 'access', _74 => _74.cells, 'access', _75 => _75[r], 'optionalAccess', _76 => _76[c]]);
975
+ const cell = _optionalChain([t, 'access', _100 => _100.cells, 'access', _101 => _101[r], 'optionalAccess', _102 => _102[c]]);
913
976
  if (!cell) continue;
914
977
  for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) if (dr || dc) covered.add((r + dr) * 1e5 + c + dc);
915
978
  starts.push({ cell, c });
@@ -920,8 +983,8 @@ function rowStarts(t) {
920
983
  }
921
984
  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));
922
985
  function cellPage(cell) {
923
- const p = _chunkK2NWHLCDcjs.CELL_PAGES.get(cell);
924
- if (p !== void 0 || !_optionalChain([cell, 'access', _77 => _77.blocks, 'optionalAccess', _78 => _78.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
986
+ const p = _chunkYG4GFQB7cjs.CELL_PAGES.get(cell);
987
+ if (p !== void 0 || !_optionalChain([cell, 'access', _103 => _103.blocks, 'optionalAccess', _104 => _104.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
925
988
  return Math.min(...cell.blocks.map((b) => b.pageNumber));
926
989
  }
927
990
  function tableRowPages(t, pageNumber) {
@@ -932,7 +995,7 @@ function tableRowPages(t, pageNumber) {
932
995
  for (const { cell } of starts) {
933
996
  const p = cellPage(cell);
934
997
  if (p !== void 0) mark = Math.max(_nullishCoalesce(mark, () => ( p)), p);
935
- else if (cell.text.trim() || _optionalChain([cell, 'access', _79 => _79.blocks, 'optionalAccess', _80 => _80.length])) text = true;
998
+ else if (cell.text.trim() || _optionalChain([cell, 'access', _105 => _105.blocks, 'optionalAccess', _106 => _106.length])) text = true;
936
999
  }
937
1000
  const page = _nullishCoalesce(mark, () => ( (text ? pageNumber : prev)));
938
1001
  prev = page !== void 0 && prev !== void 0 ? Math.max(prev, page) : _nullishCoalesce(page, () => ( prev));
@@ -949,18 +1012,29 @@ function markJoinedPages(table, prev, curr) {
949
1012
  rows.forEach((starts, r) => {
950
1013
  const page2 = r < pt.rows ? pp[r] : cp[r - off];
951
1014
  for (const { cell } of starts) {
952
- if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkK2NWHLCDcjs.CELL_PAGES.set(cell, page2);
953
- const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _81 => _81.find, 'call', _82 => _82((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
1015
+ if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkYG4GFQB7cjs.CELL_PAGES.set(cell, page2);
1016
+ const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _107 => _107.find, 'call', _108 => _108((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
954
1017
  if (src) setSplits(cell, relocate(src.cell, cell));
955
1018
  }
956
1019
  });
957
1020
  const cr = pt.rows - 1 - off, page = cp[cr];
1021
+ if (cr === -1 && table.cols === pt.cols && pt.cols === ct.cols) {
1022
+ const tailPage = cp[0];
1023
+ if (tailPage === void 0 || tailPage === prev.pageNumber) return;
1024
+ for (let r = 0; r < pt.rows; r++) for (const { cell, c } of rows[r]) {
1025
+ const head = _optionalChain([ptRows, 'access', _109 => _109[r], 'optionalAccess', _110 => _110.find, 'call', _111 => _111((s) => s.c === c), 'optionalAccess', _112 => _112.cell]), tail = _optionalChain([ctRows, 'access', _113 => _113[0], 'optionalAccess', _114 => _114.find, 'call', _115 => _115((s) => s.c === c), 'optionalAccess', _116 => _116.cell]);
1026
+ if (!_optionalChain([head, 'optionalAccess', _117 => _117.text, 'access', _118 => _118.trim, 'call', _119 => _119()]) || !_optionalChain([tail, 'optionalAccess', _120 => _120.text, 'access', _121 => _121.trim, 'call', _122 => _122()]) || _optionalChain([cell, 'access', _123 => _123.blocks, 'optionalAccess', _124 => _124.length]) || cell.colSpan !== head.colSpan || cell.colSpan !== tail.colSpan || cell.rowSpan <= head.rowSpan || r + head.rowSpan !== pt.rows || r + cell.rowSpan <= pt.rows || !cell.text.startsWith(head.text.trimEnd()) || !cell.text.trimEnd().endsWith(tail.text.trimEnd())) continue;
1027
+ const from = head.text.trimEnd().length, at = cell.text.indexOf(tail.text.trim().slice(0, 20), from);
1028
+ if (at >= from) setSplits(cell, [...relocate(head, cell), { at, page: tailPage }, ...relocate(tail, cell, at)]);
1029
+ }
1030
+ return;
1031
+ }
958
1032
  if (cr < 0 || page === void 0 || page === prev.pageNumber) return;
959
1033
  const tails = ctRows[cr].filter((s) => s.cell.text.trim());
960
1034
  for (const { cell } of ctRows[cr]) for (const b of _nullishCoalesce(cell.blocks, () => ( []))) b.pageNumber ??= page;
961
1035
  const heads = covering(pt, pt.rows - 1);
962
1036
  for (const cell of covering(table, pt.rows - 1)) {
963
- if (_optionalChain([cell, 'access', _83 => _83.blocks, 'optionalAccess', _84 => _84.length])) continue;
1037
+ if (_optionalChain([cell, 'access', _125 => _125.blocks, 'optionalAccess', _126 => _126.length])) continue;
964
1038
  const head = heads.filter((h) => h.text.trim() && cell.text.startsWith(h.text.trimEnd()) && cell.text.trim().length > h.text.trim().length).sort((a, b) => b.text.length - a.text.length)[0];
965
1039
  if (!head) continue;
966
1040
  const from = head.text.trimEnd().length;
@@ -971,7 +1045,7 @@ function markJoinedPages(table, prev, curr) {
971
1045
  }
972
1046
  function splitCell(cell, page) {
973
1047
  if (page === void 0) return null;
974
- if (_optionalChain([cell, 'access', _85 => _85.blocks, 'optionalAccess', _86 => _86.length])) {
1048
+ if (_optionalChain([cell, 'access', _127 => _127.blocks, 'optionalAccess', _128 => _128.length])) {
975
1049
  const k2 = cell.blocks.findIndex((b) => (_nullishCoalesce(b.pageNumber, () => ( page))) > page);
976
1050
  if (k2 <= 0) return null;
977
1051
  const head = cell.blocks.slice(0, k2), tail = cell.blocks.slice(k2);
@@ -998,18 +1072,29 @@ function splitCrossPageRows(t, pageNumber) {
998
1072
  if (!splits.length) continue;
999
1073
  const clone = (cell, patch) => {
1000
1074
  const out = { ...cell, ...patch };
1001
- const p = _chunkK2NWHLCDcjs.CELL_PAGES.get(cell);
1002
- if (p !== void 0) _chunkK2NWHLCDcjs.CELL_PAGES.set(out, p);
1075
+ const p = _chunkYG4GFQB7cjs.CELL_PAGES.get(cell);
1076
+ if (p !== void 0) _chunkYG4GFQB7cjs.CELL_PAGES.set(out, p);
1003
1077
  if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
1004
1078
  return out;
1005
1079
  };
1006
1080
  const e = Math.max(...splits.map((s) => r + s.cell.rowSpan - 1));
1007
1081
  const cells = t.cells.map((row2) => row2.slice());
1082
+ const cut = pages.findIndex((p, rr) => rr > r && p !== pages[r]);
1083
+ if (cut > r && splits.every((s) => cut < r + s.cell.rowSpan && pages[cut] === s.split.page)) {
1084
+ for (const { cell, c, split } of splits) {
1085
+ cells[r][c] = clone(cell, { ...split.head, rowSpan: cut - r });
1086
+ const tail = { ...cell, ...split.tail, rowSpan: r + cell.rowSpan - cut };
1087
+ _chunkYG4GFQB7cjs.CELL_PAGES.set(tail, split.page);
1088
+ setSplits(tail, split.rest);
1089
+ cells[cut][c] = tail;
1090
+ }
1091
+ return splitCrossPageRows({ ...t, cells }, pageNumber);
1092
+ }
1008
1093
  const row = Array.from({ length: t.cols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }));
1009
1094
  for (const { cell, c, split } of splits) {
1010
1095
  cells[r][c] = clone(cell, split.head);
1011
1096
  const tail = { ...cell, ...split.tail, rowSpan: 1 };
1012
- _chunkK2NWHLCDcjs.CELL_PAGES.set(tail, split.page);
1097
+ _chunkYG4GFQB7cjs.CELL_PAGES.set(tail, split.page);
1013
1098
  setSplits(tail, split.rest);
1014
1099
  row[c] = tail;
1015
1100
  }
@@ -1051,7 +1136,7 @@ function anchorsOf(table) {
1051
1136
  for (let r = 0; r < table.rows; r++) {
1052
1137
  for (let c = 0; c < table.cols; c++) {
1053
1138
  if (covered.has(r * 1e5 + c)) continue;
1054
- const cell = _optionalChain([table, 'access', _87 => _87.cells, 'access', _88 => _88[r], 'optionalAccess', _89 => _89[c]]);
1139
+ const cell = _optionalChain([table, 'access', _129 => _129.cells, 'access', _130 => _130[r], 'optionalAccess', _131 => _131[c]]);
1055
1140
  if (!cell) continue;
1056
1141
  out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
1057
1142
  for (let dr = 0; dr < cell.rowSpan; dr++) {
@@ -1128,24 +1213,24 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
1128
1213
  if (r + dr < rows) owner[r + dr][dc] = placed;
1129
1214
  }
1130
1215
  grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
1131
- const lines = _chunk4X7AR4EHcjs.CELL_LINES.get(a.cell);
1132
- if (lines) _chunk4X7AR4EHcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
1133
- if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(a.cell)) _chunk4X7AR4EHcjs.IMAGE_CELLS.add(grid[r][c1]);
1134
- const edges = _chunkK2NWHLCDcjs.CELL_EDGES.get(a.cell);
1216
+ const lines = _chunkC6B5GWN7cjs.CELL_LINES.get(a.cell);
1217
+ if (lines) _chunkC6B5GWN7cjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
1218
+ if (_chunkC6B5GWN7cjs.IMAGE_CELLS.has(a.cell)) _chunkC6B5GWN7cjs.IMAGE_CELLS.add(grid[r][c1]);
1219
+ const edges = _chunkYG4GFQB7cjs.CELL_EDGES.get(a.cell);
1135
1220
  if (edges) {
1136
- _chunkK2NWHLCDcjs.CELL_EDGES.set(grid[r][c1], edges);
1221
+ _chunkYG4GFQB7cjs.CELL_EDGES.set(grid[r][c1], edges);
1137
1222
  edged = true;
1138
1223
  }
1139
1224
  return true;
1140
1225
  };
1141
- for (const a of pa) if (!_chunk4X7AR4EHcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
1226
+ for (const a of pa) if (!_chunkC6B5GWN7cjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
1142
1227
  for (const a of ca) {
1143
- if (a.r < skip || _chunk4X7AR4EHcjs.FILLER_CELLS.has(a.cell)) continue;
1228
+ if (a.r < skip || _chunkC6B5GWN7cjs.FILLER_CELLS.has(a.cell)) continue;
1144
1229
  if (!place(a, cxU, prev.rows - skip, dx)) return null;
1145
1230
  }
1146
1231
  const first = prev.rows;
1147
1232
  for (let c = 0; c < cols; c++) {
1148
- const above = _optionalChain([owner, 'access', _90 => _90[first - 1], 'optionalAccess', _91 => _91[c]]);
1233
+ const above = _optionalChain([owner, 'access', _132 => _132[first - 1], 'optionalAccess', _133 => _133[c]]);
1149
1234
  if (!above) continue;
1150
1235
  let r = first;
1151
1236
  while (r < rows && owner[r][c] === null) r++;
@@ -1164,9 +1249,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
1164
1249
  const grown = { ...above, rs: newRs };
1165
1250
  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;
1166
1251
  }
1167
- for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunk4X7AR4EHcjs.FILLER_CELLS.add(grid[r][c]);
1252
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkC6B5GWN7cjs.FILLER_CELLS.add(grid[r][c]);
1168
1253
  if (edged) {
1169
- for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkK2NWHLCDcjs.CELL_EDGES.set(grid[r][c], _chunk4X7AR4EHcjs.NO_EDGES);
1254
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkYG4GFQB7cjs.CELL_EDGES.set(grid[r][c], _chunkC6B5GWN7cjs.NO_EDGES);
1170
1255
  }
1171
1256
  for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
1172
1257
  let r = prev.rows;
@@ -1175,22 +1260,25 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
1175
1260
  for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
1176
1261
  }
1177
1262
  const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
1178
- const pr = _chunk4X7AR4EHcjs.ROW_RULES.get(prev), cr = _chunk4X7AR4EHcjs.ROW_RULES.get(curr);
1263
+ const pr = _chunkC6B5GWN7cjs.ROW_RULES.get(prev), cr = _chunkC6B5GWN7cjs.ROW_RULES.get(curr);
1179
1264
  const shifted = dx !== 0;
1180
1265
  const cut = {
1181
1266
  open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
1182
1267
  ruled: !!pr && !!cr && pr.bottom && cr.top,
1183
1268
  list: !shifted ? "any" : skip > 0 && ca.filter((a) => a.r < skip && a.cell.text.trim()).length < 2 ? "none" : "multi"
1184
1269
  };
1185
- let split = rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
1186
- 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 });
1270
+ let partial = !skip && cols === prev.cols && cols === curr.cols && cut.ruled && prevBottom !== void 0 ? partialAlignedLabelCells(table, owner, first) : void 0;
1271
+ if (partial && (continuesAcross(partial.context.upper, partial.context.lower, U[partial.context.c], U[partial.context.c + partial.context.cs]) || clauseContinues(partial.context.upper, partial.context.lower) || quantityContinues(partial.context.upper, partial.context.lower) || !continuesAcross(partial.value.upper, partial.value.lower, U[partial.value.c], U[partial.value.c + partial.value.cs]) || _chunkC6B5GWN7cjs.startsNewItem.call(void 0, partial.value.upper.text, partial.value.lower.text))) partial = void 0;
1272
+ const selected = partial ? /* @__PURE__ */ new Set([partial.label.c, partial.value.c]) : void 0;
1273
+ let split = !selected && rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
1274
+ if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U, selected) && !selected) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
1187
1275
  if (pr && cr) {
1188
1276
  const cutRuled = pr.bottom || cr.top;
1189
- _chunk4X7AR4EHcjs.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) });
1277
+ _chunkC6B5GWN7cjs.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) });
1190
1278
  }
1191
1279
  return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
1192
1280
  }
1193
- function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
1281
+ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selected) {
1194
1282
  const last = first - 1;
1195
1283
  const straddles = owner[first].some((o, c) => o !== null && o === owner[last][c]);
1196
1284
  let firstNew = table.cols;
@@ -1247,19 +1335,20 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
1247
1335
  c = u.c + u.cs;
1248
1336
  if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
1249
1337
  const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
1250
- const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunk4X7AR4EHcjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
1251
- const openSeam = hasContent(a) && hasContent(b) && _chunk4X7AR4EHcjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
1338
+ if (selected && !selected.has(u.c)) continue;
1339
+ const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkC6B5GWN7cjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
1340
+ const openSeam = hasContent(a) && hasContent(b) && _chunkC6B5GWN7cjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
1252
1341
  if (!r || r === first) return false;
1253
1342
  const up = owner[r - 1][u.c], down = row[u.c];
1254
1343
  if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
1255
- const ue = _chunkK2NWHLCDcjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkK2NWHLCDcjs.CELL_EDGES.get(table.cells[down.r][down.c]);
1344
+ const ue = _chunkYG4GFQB7cjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkYG4GFQB7cjs.CELL_EDGES.get(table.cells[down.r][down.c]);
1256
1345
  return !!ue && !!de && !ue.b && !de.t;
1257
1346
  });
1258
- if (!openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
1347
+ if (!selected && !openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
1259
1348
  if (!straddles && !midWord) continue;
1260
1349
  if (u.r >= last && d.rs < 2) continue;
1261
- const U = _chunk4X7AR4EHcjs.CELL_LINES.get(a);
1262
- if (!_optionalChain([U, 'optionalAccess', _92 => _92.length]) || !hasContent(b)) continue;
1350
+ const U = _chunkC6B5GWN7cjs.CELL_LINES.get(a);
1351
+ if (!_optionalChain([U, 'optionalAccess', _134 => _134.length]) || !hasContent(b)) continue;
1263
1352
  if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
1264
1353
  if (U.length > STRADDLE_MAX_LINES) continue;
1265
1354
  const lu = U[U.length - 1];
@@ -1276,7 +1365,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
1276
1365
  return merged;
1277
1366
  }
1278
1367
  function longLastLine(c) {
1279
- const L = _chunk4X7AR4EHcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _93 => _93[L.length - 1]]);
1368
+ const L = _chunkC6B5GWN7cjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _135 => _135[L.length - 1]]);
1280
1369
  return !!l && l.r - l.l >= 6 * (l.h || 10);
1281
1370
  }
1282
1371
  function filledToBottom(U, bottom) {
@@ -1309,8 +1398,8 @@ function nextItemHead(prev, next) {
1309
1398
  return false;
1310
1399
  }
1311
1400
  function continuesAcross(u, d, x1, x2) {
1312
- const U = _chunk4X7AR4EHcjs.CELL_LINES.get(u), D = _chunk4X7AR4EHcjs.CELL_LINES.get(d);
1313
- if (!_optionalChain([U, 'optionalAccess', _94 => _94.length]) || !_optionalChain([D, 'optionalAccess', _95 => _95.length])) return false;
1401
+ const U = _chunkC6B5GWN7cjs.CELL_LINES.get(u), D = _chunkC6B5GWN7cjs.CELL_LINES.get(d);
1402
+ if (!_optionalChain([U, 'optionalAccess', _136 => _136.length]) || !_optionalChain([D, 'optionalAccess', _137 => _137.length])) return false;
1314
1403
  const last = U[U.length - 1];
1315
1404
  const fs = last.h || 10;
1316
1405
  let minL = Infinity, maxR = -Infinity;
@@ -1327,7 +1416,7 @@ function continuesAcross(u, d, x1, x2) {
1327
1416
  if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
1328
1417
  const indented = last.l - minL >= HANGING_MIN * fs;
1329
1418
  if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
1330
- const newItem = _chunk4X7AR4EHcjs.startsNewItem.call(void 0, u.text, d.text);
1419
+ const newItem = _chunkC6B5GWN7cjs.startsNewItem.call(void 0, u.text, d.text);
1331
1420
  const all = D.length ? U.concat(D) : U;
1332
1421
  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));
1333
1422
  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;
@@ -1344,12 +1433,12 @@ function outlineContinues(u, d) {
1344
1433
  return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
1345
1434
  }
1346
1435
  function lineEnded(c, x1, x2, next) {
1347
- const L = _chunk4X7AR4EHcjs.CELL_LINES.get(c);
1436
+ const L = _chunkC6B5GWN7cjs.CELL_LINES.get(c);
1348
1437
  if (!L || L.length !== 1) return false;
1349
1438
  const l = L[0], h = l.h || 10;
1350
- const d0 = next ? _optionalChain([_chunk4X7AR4EHcjs.CELL_LINES, 'access', _96 => _96.get, 'call', _97 => _97(next), 'optionalAccess', _98 => _98[0]]) : void 0;
1439
+ const d0 = next ? _optionalChain([_chunkC6B5GWN7cjs.CELL_LINES, 'access', _138 => _138.get, 'call', _139 => _139(next), 'optionalAccess', _140 => _140[0]]) : void 0;
1351
1440
  if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
1352
- return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _99 => _99.text]), () => ( "")))) * h;
1441
+ return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _141 => _141.text]), () => ( "")))) * h;
1353
1442
  }
1354
1443
  function firstWordUnits(text) {
1355
1444
  const word = _nullishCoalesce(flowText(text).trim().replace(/^([(\[「『<〈])\s+/, "$1").split(/\s+/)[0], () => ( ""));
@@ -1358,15 +1447,15 @@ function firstWordUnits(text) {
1358
1447
  return units;
1359
1448
  }
1360
1449
  function appendCell(a, b) {
1361
- if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(b)) _chunk4X7AR4EHcjs.IMAGE_CELLS.add(a);
1362
- if (_optionalChain([a, 'access', _100 => _100.blocks, 'optionalAccess', _101 => _101.length]) || _optionalChain([b, 'access', _102 => _102.blocks, 'optionalAccess', _103 => _103.length])) {
1363
- const asBlocks = (c) => _optionalChain([c, 'access', _104 => _104.blocks, 'optionalAccess', _105 => _105.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
1450
+ if (_chunkC6B5GWN7cjs.IMAGE_CELLS.has(b)) _chunkC6B5GWN7cjs.IMAGE_CELLS.add(a);
1451
+ if (_optionalChain([a, 'access', _142 => _142.blocks, 'optionalAccess', _143 => _143.length]) || _optionalChain([b, 'access', _144 => _144.blocks, 'optionalAccess', _145 => _145.length])) {
1452
+ const asBlocks = (c) => _optionalChain([c, 'access', _146 => _146.blocks, 'optionalAccess', _147 => _147.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
1364
1453
  a.blocks = [...asBlocks(a), ...asBlocks(b)];
1365
1454
  }
1366
1455
  if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
1367
- _chunk4X7AR4EHcjs.joinCellEdges.call(void 0, a, b);
1456
+ _chunkC6B5GWN7cjs.joinCellEdges.call(void 0, a, b);
1368
1457
  }
1369
- var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _106 => _106.blocks, 'optionalAccess', _107 => _107.length]) || _chunk4X7AR4EHcjs.IMAGE_CELLS.has(cell);
1458
+ var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _148 => _148.blocks, 'optionalAccess', _149 => _149.length]) || _chunkC6B5GWN7cjs.IMAGE_CELLS.has(cell);
1370
1459
  var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
1371
1460
  var batchim = (ch) => {
1372
1461
  const k = ch.charCodeAt(0) - 44032;
@@ -1374,7 +1463,7 @@ var batchim = (ch) => {
1374
1463
  };
1375
1464
  function clauseContinues(u, d) {
1376
1465
  const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
1377
- if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunk4X7AR4EHcjs.startsNewItem.call(void 0, u.text, head)) return false;
1466
+ if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkC6B5GWN7cjs.startsNewItem.call(void 0, u.text, head)) return false;
1378
1467
  const last = tail[tail.length - 1], before = tail[tail.length - 2];
1379
1468
  return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
1380
1469
  }
@@ -1382,8 +1471,8 @@ function quantityContinues(u, d) {
1382
1471
  return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
1383
1472
  }
1384
1473
  function wordOverflows(u, d, x1, x2) {
1385
- const U = _chunk4X7AR4EHcjs.CELL_LINES.get(u);
1386
- if (!_optionalChain([U, 'optionalAccess', _108 => _108.length]) || _chunk4X7AR4EHcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
1474
+ const U = _chunkC6B5GWN7cjs.CELL_LINES.get(u);
1475
+ if (!_optionalChain([U, 'optionalAccess', _150 => _150.length]) || _chunkC6B5GWN7cjs.startsNewItem.call(void 0, u.text, d.text)) return false;
1387
1476
  const last = U[U.length - 1], units = firstWordUnits(d.text);
1388
1477
  return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
1389
1478
  }
@@ -1393,7 +1482,7 @@ function listContinues(u, d, multi = false) {
1393
1482
  const marks = u.text.split("\n").map((l) => itemMark(l.trim()));
1394
1483
  let last = -1, count = 0;
1395
1484
  marks.forEach((m, i) => {
1396
- if (_optionalChain([m, 'optionalAccess', _109 => _109.style]) === head.style) {
1485
+ if (_optionalChain([m, 'optionalAccess', _151 => _151.style]) === head.style) {
1397
1486
  last = i;
1398
1487
  count++;
1399
1488
  }
@@ -1441,7 +1530,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
1441
1530
  if (!carriedSplit) {
1442
1531
  const norm = (c) => flowText(c.text).replace(/\s+/g, "");
1443
1532
  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;
1444
- const oneLine = (c) => _optionalChain([_chunk4X7AR4EHcjs.CELL_LINES, 'access', _110 => _110.get, 'call', _111 => _111(c), 'optionalAccess', _112 => _112.length]) === 1;
1533
+ const oneLine = (c) => _optionalChain([_chunkC6B5GWN7cjs.CELL_LINES, 'access', _152 => _152.get, 'call', _153 => _153(c), 'optionalAccess', _154 => _154.length]) === 1;
1445
1534
  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;
1446
1535
  const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d)) || quantityContinues(cell(u), cell(d));
1447
1536
  if (!(cut.open && !newCell)) {
@@ -1472,8 +1561,8 @@ function besideOwn(b, p, c) {
1472
1561
  }
1473
1562
  var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
1474
1563
  function pageNumberBetween(b, p, c, pageHeights) {
1475
- if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _113 => _113.text, 'optionalAccess', _114 => _114.trim, 'call', _115 => _115()]), () => ( "")))) return false;
1476
- const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _116 => _116.get, 'call', _117 => _117(b.pageNumber)]) : void 0;
1564
+ if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _155 => _155.text, 'optionalAccess', _156 => _156.trim, 'call', _157 => _157()]), () => ( "")))) return false;
1565
+ const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _158 => _158.get, 'call', _159 => _159(b.pageNumber)]) : void 0;
1477
1566
  if (!h) return false;
1478
1567
  if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
1479
1568
  if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
@@ -1497,7 +1586,7 @@ function insideTable(b, t) {
1497
1586
  return b.bbox.x >= o.x - 1 && b.bbox.x + b.bbox.width <= o.x + o.width + 1 && b.bbox.y >= o.y - 1 && b.bbox.y + b.bbox.height <= o.y + o.height + 1;
1498
1587
  }
1499
1588
  function startsWithUnitRow(table) {
1500
- return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _118 => _118.cells, 'access', _119 => _119[0], 'optionalAccess', _120 => _120[0], 'optionalAccess', _121 => _121.text]), () => ( ""))) && _optionalChain([table, 'access', _122 => _122.cells, 'access', _123 => _123[0], 'optionalAccess', _124 => _124.slice, 'call', _125 => _125(1), 'access', _126 => _126.every, 'call', _127 => _127((c) => !c.text.trim())]);
1589
+ return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _160 => _160.cells, 'access', _161 => _161[0], 'optionalAccess', _162 => _162[0], 'optionalAccess', _163 => _163.text]), () => ( ""))) && _optionalChain([table, 'access', _164 => _164.cells, 'access', _165 => _165[0], 'optionalAccess', _166 => _166.slice, 'call', _167 => _167(1), 'access', _168 => _168.every, 'call', _169 => _169((c) => !c.text.trim())]);
1501
1590
  }
1502
1591
  function sameHeadShape(a, b) {
1503
1592
  if (!a || !b || a.length !== b.length) return false;
@@ -1509,7 +1598,7 @@ function sameHeadShape(a, b) {
1509
1598
  return tall;
1510
1599
  }
1511
1600
  function hasBoxTitle(t) {
1512
- const titles = _nullishCoalesce(_optionalChain([t, 'access', _128 => _128.cells, 'access', _129 => _129[0], 'optionalAccess', _130 => _130.filter, 'call', _131 => _131((c) => c.text.trim())]), () => ( []));
1601
+ const titles = _nullishCoalesce(_optionalChain([t, 'access', _170 => _170.cells, 'access', _171 => _171[0], 'optionalAccess', _172 => _172.filter, 'call', _173 => _173((c) => c.text.trim())]), () => ( []));
1513
1602
  if (titles.length !== 1 || titles[0].rowSpan < 2) return false;
1514
1603
  const body = t.cells[titles[0].rowSpan];
1515
1604
  return !!body && body[0].colSpan === t.cols && !!body[0].text.trim();
@@ -1523,7 +1612,7 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1523
1612
  const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
1524
1613
  while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
1525
1614
  const curr = blocks[j];
1526
- const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _132 => _132.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
1615
+ const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _174 => _174.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
1527
1616
  if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
1528
1617
  if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
1529
1618
  if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
@@ -1533,19 +1622,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1533
1622
  placeJoined(blocks, i, j, joined);
1534
1623
  continue;
1535
1624
  }
1536
- if (_chunk4X7AR4EHcjs.EMPTY_PARTS.has(curr.table)) {
1625
+ if (_chunkC6B5GWN7cjs.EMPTY_PARTS.has(curr.table)) {
1537
1626
  blocks.splice(j, 1);
1538
1627
  i++;
1539
1628
  continue;
1540
1629
  }
1541
1630
  if (joined === null) continue;
1542
- if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunk4X7AR4EHcjs.EMPTY_PARTS.has(prev.table)) continue;
1631
+ if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkC6B5GWN7cjs.EMPTY_PARTS.has(prev.table)) continue;
1543
1632
  const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
1544
1633
  const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
1545
1634
  const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
1546
1635
  if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
1547
- const px = _chunk4X7AR4EHcjs.TABLE_COLXS.get(prev.table), cx = _chunk4X7AR4EHcjs.TABLE_COLXS.get(curr.table);
1548
- if (px && cx && !shiftedSame(px, cx, !_chunk4X7AR4EHcjs.CLIP_TABLES.has(prev.table) && !_chunk4X7AR4EHcjs.CLIP_TABLES.has(curr.table))) continue;
1636
+ const px = _chunkC6B5GWN7cjs.TABLE_COLXS.get(prev.table), cx = _chunkC6B5GWN7cjs.TABLE_COLXS.get(curr.table);
1637
+ if (px && cx && !shiftedSame(px, cx, !_chunkC6B5GWN7cjs.CLIP_TABLES.has(prev.table) && !_chunkC6B5GWN7cjs.CLIP_TABLES.has(curr.table))) continue;
1549
1638
  if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
1550
1639
  let currCells = curr.table.cells;
1551
1640
  const headRows = repeatedHeaderRows(prev.table, curr.table);
@@ -1556,16 +1645,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1556
1645
  blocks.splice(j, 1);
1557
1646
  continue;
1558
1647
  }
1559
- if (px && cx && !_chunk4X7AR4EHcjs.CLIP_TABLES.has(prev.table) && !_chunk4X7AR4EHcjs.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 && _chunk4X7AR4EHcjs.CELL_LINES.has(c))) {
1648
+ if (px && cx && !_chunkC6B5GWN7cjs.CLIP_TABLES.has(prev.table) && !_chunkC6B5GWN7cjs.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 && _chunkC6B5GWN7cjs.CELL_LINES.has(c))) {
1560
1649
  const dx = px[0] - cx[0];
1561
1650
  const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
1562
- if (_optionalChain([part, 'optionalAccess', _133 => _133.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
1651
+ if (_optionalChain([part, 'optionalAccess', _175 => _175.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
1563
1652
  const last = prev.table.rows - 1;
1564
1653
  for (let c = 0; c < part.table.cols; c++) {
1565
- const U = _chunk4X7AR4EHcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunk4X7AR4EHcjs.CELL_LINES.get(currCells[0][c]);
1566
- _chunk4X7AR4EHcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
1654
+ const U = _chunkC6B5GWN7cjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkC6B5GWN7cjs.CELL_LINES.get(currCells[0][c]);
1655
+ _chunkC6B5GWN7cjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
1567
1656
  }
1568
- _chunk4X7AR4EHcjs.TABLE_COLXS.set(part.table, part.colXs);
1657
+ _chunkC6B5GWN7cjs.TABLE_COLXS.set(part.table, part.colXs);
1569
1658
  placeJoined(blocks, i, j, part.table);
1570
1659
  continue;
1571
1660
  }
@@ -1578,20 +1667,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1578
1667
  caption: prev.table.caption,
1579
1668
  ...prev.table.renderAsTable ? { renderAsTable: true } : {}
1580
1669
  };
1581
- if (_nullishCoalesce(px, () => ( cx))) _chunk4X7AR4EHcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
1582
- if (_chunk4X7AR4EHcjs.CLIP_TABLES.has(prev.table) || _chunk4X7AR4EHcjs.CLIP_TABLES.has(curr.table)) _chunk4X7AR4EHcjs.CLIP_TABLES.add(merged);
1670
+ if (_nullishCoalesce(px, () => ( cx))) _chunkC6B5GWN7cjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
1671
+ if (_chunkC6B5GWN7cjs.CLIP_TABLES.has(prev.table) || _chunkC6B5GWN7cjs.CLIP_TABLES.has(curr.table)) _chunkC6B5GWN7cjs.CLIP_TABLES.add(merged);
1583
1672
  placeJoined(blocks, i, j, merged);
1584
1673
  }
1585
1674
  for (let i = blocks.length - 1; i >= 0; i--) {
1586
1675
  const t = blocks[i].table;
1587
- if (blocks[i].type === "table" && t && _chunk4X7AR4EHcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
1676
+ if (blocks[i].type === "table" && t && _chunkC6B5GWN7cjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
1588
1677
  }
1589
1678
  }
1590
1679
  function mergeColumnFlow(blocks, pageHeights, lex) {
1591
1680
  if (!pageHeights) return;
1592
1681
  for (let i = 0; i < blocks.length; i++) {
1593
1682
  const L = blocks[i];
1594
- if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(L.table) || _chunk4X7AR4EHcjs.EMPTY_PARTS.has(L.table)) continue;
1683
+ if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkC6B5GWN7cjs.CLIP_TABLES.has(L.table) || _chunkC6B5GWN7cjs.EMPTY_PARTS.has(L.table)) continue;
1595
1684
  const ph = pageHeights.get(L.pageNumber);
1596
1685
  if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
1597
1686
  let s0 = i, s1 = i;
@@ -1620,12 +1709,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
1620
1709
  }
1621
1710
  function joinClipParts(prev, curr, pageHeights, lex) {
1622
1711
  const pt = prev.table, ct = curr.table;
1623
- if (!_chunk4X7AR4EHcjs.CLIP_TABLES.has(pt) || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(ct)) return null;
1624
- const px = _chunk4X7AR4EHcjs.TABLE_COLXS.get(pt), cx = _chunk4X7AR4EHcjs.TABLE_COLXS.get(ct);
1712
+ if (!_chunkC6B5GWN7cjs.CLIP_TABLES.has(pt) || !_chunkC6B5GWN7cjs.CLIP_TABLES.has(ct)) return null;
1713
+ const px = _chunkC6B5GWN7cjs.TABLE_COLXS.get(pt), cx = _chunkC6B5GWN7cjs.TABLE_COLXS.get(ct);
1625
1714
  if (!px || !cx) return null;
1626
1715
  let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
1627
1716
  if (!shiftedSame(px, cx, false)) {
1628
- if (!_optionalChain([pageHeights, 'optionalAccess', _134 => _134.get, 'call', _135 => _135(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _136 => _136.get, 'call', _137 => _137(curr.pageNumber)])) return null;
1717
+ if (!_optionalChain([pageHeights, 'optionalAccess', _176 => _176.get, 'call', _177 => _177(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _178 => _178.get, 'call', _179 => _179(curr.pageNumber)])) return null;
1629
1718
  dx = px[px.length - 1] - cx[cx.length - 1];
1630
1719
  within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
1631
1720
  if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
@@ -1637,19 +1726,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
1637
1726
  const inner = b.slice(1, -1).map((x) => x + dx);
1638
1727
  return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
1639
1728
  };
1640
- foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunk4X7AR4EHcjs.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);
1729
+ foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkC6B5GWN7cjs.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);
1641
1730
  }
1642
- const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _138 => _138.bbox, 'optionalAccess', _139 => _139.y]), lex);
1731
+ const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _180 => _180.bbox, 'optionalAccess', _181 => _181.y]), lex);
1643
1732
  if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
1644
- _chunk4X7AR4EHcjs.TABLE_COLXS.set(res.table, res.colXs);
1645
- const ys = _chunk4X7AR4EHcjs.TABLE_ROWYS.get(pt);
1646
- if (ys) _chunk4X7AR4EHcjs.TABLE_ROWYS.set(res.table, ys);
1647
- _chunk4X7AR4EHcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunk4X7AR4EHcjs.PART_COLXS.get(pt), () => ( px)));
1648
- _chunk4X7AR4EHcjs.CLIP_TABLES.add(res.table);
1733
+ _chunkC6B5GWN7cjs.TABLE_COLXS.set(res.table, res.colXs);
1734
+ const ys = _chunkC6B5GWN7cjs.TABLE_ROWYS.get(pt);
1735
+ if (ys) _chunkC6B5GWN7cjs.TABLE_ROWYS.set(res.table, ys);
1736
+ _chunkC6B5GWN7cjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkC6B5GWN7cjs.PART_COLXS.get(pt), () => ( px)));
1737
+ _chunkC6B5GWN7cjs.CLIP_TABLES.add(res.table);
1649
1738
  return res.table;
1650
1739
  }
1651
1740
  function prevLacksLeftCols(prev, px, xs, pageHeights) {
1652
- const ph = _optionalChain([pageHeights, 'optionalAccess', _140 => _140.get, 'call', _141 => _141(prev.pageNumber)]);
1741
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _182 => _182.get, 'call', _183 => _183(prev.pageNumber)]);
1653
1742
  if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
1654
1743
  return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
1655
1744
  }
@@ -1660,21 +1749,21 @@ function headingRow(row) {
1660
1749
  }
1661
1750
  var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
1662
1751
  function looksContinued(prev, curr, pageHeights) {
1663
- const ph = _optionalChain([pageHeights, 'optionalAccess', _142 => _142.get, 'call', _143 => _143(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _144 => _144.get, 'call', _145 => _145(curr.pageNumber)]);
1752
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _184 => _184.get, 'call', _185 => _185(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _186 => _186.get, 'call', _187 => _187(curr.pageNumber)]);
1664
1753
  if (ph && ch && (prev.bbox.y > ph * PAGE_EDGE_BAND && !pushedLead(prev, curr) || curr.bbox.y + curr.bbox.height < ch * (1 - PAGE_EDGE_BAND))) return false;
1665
1754
  const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
1666
- const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _146 => _146.find, 'call', _147 => _147((c) => c.text.trim()), 'optionalAccess', _148 => _148.text]), () => ( ""));
1755
+ const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _188 => _188.find, 'call', _189 => _189((c) => c.text.trim()), 'optionalAccess', _190 => _190.text]), () => ( ""));
1667
1756
  if (!ANNEX_HEAD_RE.test(firstText)) return true;
1668
1757
  const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
1669
1758
  return filled.length >= 2 && filled.every((t) => t === filled[0]);
1670
1759
  }
1671
1760
  function pushedLead(prev, curr) {
1672
- if (!_chunk4X7AR4EHcjs.CLIP_TABLES.has(prev.table) || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(curr.table)) return false;
1761
+ if (!_chunkC6B5GWN7cjs.CLIP_TABLES.has(prev.table) || !_chunkC6B5GWN7cjs.CLIP_TABLES.has(curr.table)) return false;
1673
1762
  const lead = leadRows(curr.table);
1674
1763
  return lead.image && lead.height > prev.bbox.y;
1675
1764
  }
1676
1765
  function leadRows(t) {
1677
- const ys = _chunk4X7AR4EHcjs.TABLE_ROWYS.get(t);
1766
+ const ys = _chunkC6B5GWN7cjs.TABLE_ROWYS.get(t);
1678
1767
  if (!ys || ys.length < 2) return { height: 0, image: false };
1679
1768
  const anchors = anchorsOf(t);
1680
1769
  let end = 1, image = false;
@@ -1682,17 +1771,17 @@ function leadRows(t) {
1682
1771
  for (const a of anchors) {
1683
1772
  if (a.r !== r) continue;
1684
1773
  end = Math.max(end, r + a.rs);
1685
- if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(a.cell)) image = true;
1774
+ if (_chunkC6B5GWN7cjs.IMAGE_CELLS.has(a.cell)) image = true;
1686
1775
  }
1687
1776
  }
1688
1777
  return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
1689
1778
  }
1690
1779
  function tailOf(b) {
1691
- const t = b.table && _chunk4X7AR4EHcjs.TABLE_TAIL.get(b.table);
1780
+ const t = b.table && _chunkC6B5GWN7cjs.TABLE_TAIL.get(b.table);
1692
1781
  return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
1693
1782
  }
1694
1783
  function firstRowSig(t) {
1695
- const x = _chunk4X7AR4EHcjs.TABLE_COLXS.get(t);
1784
+ const x = _chunkC6B5GWN7cjs.TABLE_COLXS.get(t);
1696
1785
  if (!x || x.length !== t.cols + 1) return null;
1697
1786
  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, "") }));
1698
1787
  }
@@ -1717,9 +1806,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
1717
1806
  }
1718
1807
  function restartsTitledForm(head, curr) {
1719
1808
  if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
1720
- const full = (t) => _optionalChain([t, 'access', _149 => _149.cells, 'access', _150 => _150[0], 'access', _151 => _151[0], 'optionalAccess', _152 => _152.colSpan]) === t.cols;
1809
+ const full = (t) => _optionalChain([t, 'access', _191 => _191.cells, 'access', _192 => _192[0], 'access', _193 => _193[0], 'optionalAccess', _194 => _194.colSpan]) === t.cols;
1721
1810
  if (!full(head) || !full(curr)) return false;
1722
- const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _153 => _153.text]), () => ( ""))).replace(/\s+/g, "");
1811
+ const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _195 => _195.text]), () => ( ""))).replace(/\s+/g, "");
1723
1812
  const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
1724
1813
  if (!ht || !ct || ht === ct) return false;
1725
1814
  const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
@@ -1745,7 +1834,7 @@ function chainHead(blocks, i, pageHeights) {
1745
1834
  if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
1746
1835
  if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
1747
1836
  if (!looksContinued(pb, cur, pageHeights)) break;
1748
- const px = _chunk4X7AR4EHcjs.TABLE_COLXS.get(pb.table), cx = _chunk4X7AR4EHcjs.TABLE_COLXS.get(cur.table);
1837
+ const px = _chunkC6B5GWN7cjs.TABLE_COLXS.get(pb.table), cx = _chunkC6B5GWN7cjs.TABLE_COLXS.get(cur.table);
1749
1838
  if (!px || !cx) break;
1750
1839
  const dx = px[px.length - 1] - cx[cx.length - 1];
1751
1840
  if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
@@ -1762,7 +1851,7 @@ function continueRowSpans(prevCells, currCells) {
1762
1851
  if (hasContent(cell) || (cell.rowSpan || 1) < 2) continue;
1763
1852
  let anchor;
1764
1853
  for (let r = last - 1; r >= 0 && !anchor; r--) {
1765
- const a = _optionalChain([prevCells, 'access', _154 => _154[r], 'optionalAccess', _155 => _155[c]]);
1854
+ const a = _optionalChain([prevCells, 'access', _196 => _196[r], 'optionalAccess', _197 => _197[c]]);
1766
1855
  if (a && r + (a.rowSpan || 1) === last && (a.colSpan || 1) === (cell.colSpan || 1) && (hasContent(a) || a.rowSpan >= 2)) anchor = a;
1767
1856
  }
1768
1857
  if (!anchor) continue;
@@ -1816,12 +1905,12 @@ var RESTART_LOOKBACK_PAGES = 5;
1816
1905
  var COL_MATCH_TOL = 0.5;
1817
1906
  var CONTINUED_TABLE_PAGE_BAND = 0.16;
1818
1907
  function lastRowCell(t, x1, x2) {
1819
- const xs = _chunk4X7AR4EHcjs.TABLE_COLXS.get(t);
1908
+ const xs = _chunkC6B5GWN7cjs.TABLE_COLXS.get(t);
1820
1909
  const covered = /* @__PURE__ */ new Set();
1821
1910
  for (let r = 0; r < t.rows; r++) {
1822
1911
  for (let c = 0; c < t.cols; c++) {
1823
1912
  if (covered.has(r * 1e5 + c)) continue;
1824
- const cell = _optionalChain([t, 'access', _156 => _156.cells, 'access', _157 => _157[r], 'optionalAccess', _158 => _158[c]]);
1913
+ const cell = _optionalChain([t, 'access', _198 => _198.cells, 'access', _199 => _199[r], 'optionalAccess', _200 => _200[c]]);
1825
1914
  if (!cell) continue;
1826
1915
  for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
1827
1916
  if (r + cell.rowSpan !== t.rows) continue;
@@ -1834,7 +1923,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
1834
1923
  function mergeContinuedCells(blocks, pageHeights) {
1835
1924
  for (let j = blocks.length - 1; j > 0; j--) {
1836
1925
  const part = blocks[j];
1837
- const from = part.table ? _chunk4X7AR4EHcjs.CONT_PARTS.get(part.table) : void 0;
1926
+ const from = part.table ? _chunkC6B5GWN7cjs.CONT_PARTS.get(part.table) : void 0;
1838
1927
  if (!from || !part.table) {
1839
1928
  unwrapContinuedTable(blocks, j, pageHeights, true);
1840
1929
  continue;
@@ -1844,18 +1933,18 @@ function mergeContinuedCells(blocks, pageHeights) {
1844
1933
  const prev = blocks[i];
1845
1934
  if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
1846
1935
  const cell = lastRowCell(prev.table, from.x1, from.x2);
1847
- const add = _optionalChain([part, 'access', _159 => _159.table, 'access', _160 => _160.cells, 'access', _161 => _161[0], 'optionalAccess', _162 => _162[0]]);
1936
+ const add = _optionalChain([part, 'access', _201 => _201.table, 'access', _202 => _202.cells, 'access', _203 => _203[0], 'optionalAccess', _204 => _204[0]]);
1848
1937
  if (!cell || !add) continue;
1849
1938
  const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
1850
1939
  if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
1851
1940
  else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
1852
1941
  cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
1853
- if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(add)) _chunk4X7AR4EHcjs.IMAGE_CELLS.add(cell);
1854
- _chunk4X7AR4EHcjs.joinCellEdges.call(void 0, cell, add);
1855
- const lines = _chunk4X7AR4EHcjs.CELL_LINES.get(add);
1856
- if (_optionalChain([lines, 'optionalAccess', _163 => _163.length])) _chunk4X7AR4EHcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunk4X7AR4EHcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
1857
- if (part.pageNumber && part.bbox) _chunk4X7AR4EHcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunk4X7AR4EHcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
1858
- if (cell.text.trim() || _optionalChain([cell, 'access', _164 => _164.blocks, 'optionalAccess', _165 => _165.length]) || _chunk4X7AR4EHcjs.IMAGE_CELLS.has(cell)) _chunk4X7AR4EHcjs.EMPTY_PARTS.delete(prev.table);
1942
+ if (_chunkC6B5GWN7cjs.IMAGE_CELLS.has(add)) _chunkC6B5GWN7cjs.IMAGE_CELLS.add(cell);
1943
+ _chunkC6B5GWN7cjs.joinCellEdges.call(void 0, cell, add);
1944
+ const lines = _chunkC6B5GWN7cjs.CELL_LINES.get(add);
1945
+ if (_optionalChain([lines, 'optionalAccess', _205 => _205.length])) _chunkC6B5GWN7cjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkC6B5GWN7cjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
1946
+ if (part.pageNumber && part.bbox) _chunkC6B5GWN7cjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkC6B5GWN7cjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
1947
+ if (cell.text.trim() || _optionalChain([cell, 'access', _206 => _206.blocks, 'optionalAccess', _207 => _207.length]) || _chunkC6B5GWN7cjs.IMAGE_CELLS.has(cell)) _chunkC6B5GWN7cjs.EMPTY_PARTS.delete(prev.table);
1859
1948
  blocks.splice(j, 1);
1860
1949
  if (cell.blocks && at > 0) {
1861
1950
  const nextAt = cell.blocks[at];
@@ -1867,34 +1956,58 @@ function mergeContinuedCells(blocks, pageHeights) {
1867
1956
  }
1868
1957
  function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
1869
1958
  const prev = blocks[at - 1], frame = blocks[at];
1870
- if (!_optionalChain([prev, 'optionalAccess', _166 => _166.table]) || !_optionalChain([frame, 'optionalAccess', _167 => _167.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(frame.table)) return;
1871
- const inner = _optionalChain([frame, 'access', _168 => _168.table, 'access', _169 => _169.cells, 'access', _170 => _170[0], 'optionalAccess', _171 => _171[0], 'optionalAccess', _172 => _172.blocks]);
1872
- const next = _optionalChain([inner, 'optionalAccess', _173 => _173[0]]);
1873
- if (!inner || !_optionalChain([next, 'optionalAccess', _174 => _174.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(prev.table) || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
1874
- const px = _chunk4X7AR4EHcjs.TABLE_COLXS.get(prev.table), nx = _chunk4X7AR4EHcjs.TABLE_COLXS.get(next.table);
1959
+ if (!_optionalChain([prev, 'optionalAccess', _208 => _208.table]) || !_optionalChain([frame, 'optionalAccess', _209 => _209.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkC6B5GWN7cjs.CLIP_TABLES.has(frame.table)) return;
1960
+ const inner = _optionalChain([frame, 'access', _210 => _210.table, 'access', _211 => _211.cells, 'access', _212 => _212[0], 'optionalAccess', _213 => _213[0], 'optionalAccess', _214 => _214.blocks]);
1961
+ const next = _optionalChain([inner, 'optionalAccess', _215 => _215[0]]);
1962
+ if (!inner || !_optionalChain([next, 'optionalAccess', _216 => _216.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkC6B5GWN7cjs.CLIP_TABLES.has(prev.table) || !_chunkC6B5GWN7cjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
1963
+ const px = _chunkC6B5GWN7cjs.TABLE_COLXS.get(prev.table), nx = _chunkC6B5GWN7cjs.TABLE_COLXS.get(next.table);
1875
1964
  if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
1876
- const ph = _optionalChain([pageHeights, 'optionalAccess', _175 => _175.get, 'call', _176 => _176(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _177 => _177.get, 'call', _178 => _178(next.pageNumber)]);
1965
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _217 => _217.get, 'call', _218 => _218(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _219 => _219.get, 'call', _220 => _220(next.pageNumber)]);
1877
1966
  if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
1878
- if (splitOnly && (inner.length !== 1 || !_optionalChain([joinSplitParts, 'call', _179 => _179(prev.table, px, next.table, nx, 0, prev.bbox.y), 'optionalAccess', _180 => _180.split]))) return;
1967
+ if (splitOnly && (inner.length !== 1 || !_optionalChain([joinSplitParts, 'call', _221 => _221(prev.table, px, next.table, nx, 0, prev.bbox.y), 'optionalAccess', _222 => _222.split]))) return;
1879
1968
  blocks.splice(at, 1, ...inner);
1880
1969
  }
1881
1970
  function fillNestedContinuation(blocks, at) {
1882
1971
  const prev = blocks[at - 1], next = blocks[at];
1883
- const t = _optionalChain([prev, 'optionalAccess', _181 => _181.table]), u = _optionalChain([next, 'optionalAccess', _182 => _182.table]);
1884
- if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(t) || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
1885
- const xs = _chunk4X7AR4EHcjs.TABLE_COLXS.get(u);
1972
+ const t = _optionalChain([prev, 'optionalAccess', _223 => _223.table]), u = _optionalChain([next, 'optionalAccess', _224 => _224.table]);
1973
+ if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkC6B5GWN7cjs.CLIP_TABLES.has(t) || !_chunkC6B5GWN7cjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
1974
+ const xs = _chunkC6B5GWN7cjs.TABLE_COLXS.get(u);
1886
1975
  const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
1887
- const add = _optionalChain([u, 'access', _183 => _183.cells, 'access', _184 => _184[0], 'optionalAccess', _185 => _185[0]]);
1888
- if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _186 => _186.blocks, 'optionalAccess', _187 => _187.length]) || _chunk4X7AR4EHcjs.IMAGE_CELLS.has(cell)) return;
1976
+ const add = _optionalChain([u, 'access', _225 => _225.cells, 'access', _226 => _226[0], 'optionalAccess', _227 => _227[0]]);
1977
+ if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _228 => _228.blocks, 'optionalAccess', _229 => _229.length]) || _chunkC6B5GWN7cjs.IMAGE_CELLS.has(cell)) return;
1889
1978
  cell.text = add.text;
1890
1979
  if (add.blocks) cell.blocks = add.blocks;
1891
- if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(add)) _chunk4X7AR4EHcjs.IMAGE_CELLS.add(cell);
1892
- _chunk4X7AR4EHcjs.joinCellEdges.call(void 0, cell, add);
1980
+ if (_chunkC6B5GWN7cjs.IMAGE_CELLS.has(add)) _chunkC6B5GWN7cjs.IMAGE_CELLS.add(cell);
1981
+ _chunkC6B5GWN7cjs.joinCellEdges.call(void 0, cell, add);
1893
1982
  blocks.splice(at, 1);
1894
1983
  }
1895
1984
 
1896
1985
  // src/pdf/symbol-glyphs.ts
1897
1986
 
1987
+
1988
+ // src/pdf/known-font-glyphs.ts
1989
+
1990
+ var HCR_DOT = "bb7a2a3ab48d5bfdfd9582c0fb6525401c3a7f1851bb1c1bdb45048be95d1599";
1991
+ var BATANG_NUMBERS = [
1992
+ "8a4af2cf2dfe3238b4e2b35af976746216ade6e89cd3c55ec1e43bca532379b9",
1993
+ "7332dcab9d77002bdb92723a7fa4afa963ad01601f6328fbedd7289798fb77d0",
1994
+ "e7cc725807eae1ae0311898429629931f5924ade91a876c899b0c5bd109b325b",
1995
+ "3956a9db6baa74ef40ff93291ef5c42245cd4b36d613e5c956e307f347705adb",
1996
+ "8340732dc5f6a75a6808e87749ae9e9e7d54f4299f86eabbfaedd95da10ad447",
1997
+ "1412a79bd9ed7fdb34a8f04c29e341230a3bef649fb7b44a58ea6a56da0f3e44"
1998
+ ];
1999
+ function knownFontGlyph(name, outline, width) {
2000
+ const face = _optionalChain([name, 'optionalAccess', _230 => _230.replace, 'call', _231 => _231(/^[A-Z]{6}\+/, "")]);
2001
+ const dot = face === "HCRDotum" && width === 970 && outline.upm === 1e3;
2002
+ const number = (face === "Haansoft Batang" || face === "Haansoft-Batang") && width === 1e3 && outline.upm === 1024;
2003
+ if (!dot && !number) return null;
2004
+ const signature = _crypto.createHash.call(void 0, "sha256").update(JSON.stringify([outline.upm, width, outline.contours])).digest("hex");
2005
+ if (dot) return signature === HCR_DOT ? _chunkYG4GFQB7cjs.mapPuaText.call(void 0, String.fromCodePoint(983791)) : null;
2006
+ const index = BATANG_NUMBERS.indexOf(signature);
2007
+ return index < 0 ? null : _chunkYG4GFQB7cjs.mapPuaText.call(void 0, String.fromCodePoint(983729 + index));
2008
+ }
2009
+
2010
+ // src/pdf/symbol-glyphs.ts
1898
2011
  var NO_UNICODE = "\uF000";
1899
2012
  var u16 = (b, o) => b[o] << 8 | b[o + 1];
1900
2013
  var i16 = (b, o) => {
@@ -2058,14 +2171,14 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
2058
2171
  for (const g2 of args[0]) {
2059
2172
  const glyph = g2;
2060
2173
  if (!glyph || glyph.unicode !== NO_UNICODE || typeof glyph.fontChar !== "string") continue;
2061
- const key = font + "\0" + glyph.fontChar;
2174
+ const key = font + "\0" + glyph.fontChar + "\0" + typeof glyph.width + ":" + String(glyph.width);
2062
2175
  if (!cache.has(key)) {
2063
2176
  let sym = null;
2064
2177
  try {
2065
- const data = _optionalChain([fontObj, 'call', _188 => _188(font), 'optionalAccess', _189 => _189.data]);
2178
+ const source = fontObj(font), data = _optionalChain([source, 'optionalAccess', _232 => _232.data]);
2066
2179
  const code = glyph.fontChar.codePointAt(0);
2067
2180
  const outline = data && code !== void 0 ? readOutline(data, code) : null;
2068
- if (outline) sym = classifyOutline(outline);
2181
+ if (outline) sym = _nullishCoalesce(knownFontGlyph(_optionalChain([source, 'optionalAccess', _233 => _233.name]), outline, glyph.width), () => ( classifyOutline(outline)));
2069
2182
  } catch (e3) {
2070
2183
  }
2071
2184
  cache.set(key, sym);
@@ -2086,7 +2199,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
2086
2199
  }
2087
2200
  for (const [f, list] of byFont) {
2088
2201
  const q = queues.get(f);
2089
- const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access', _190 => _190.str, 'access', _191 => _191.match, 'call', _192 => _192(//g), 'optionalAccess', _193 => _193.length]), () => ( 0))), 0);
2202
+ const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access', _234 => _234.str, 'access', _235 => _235.match, 'call', _236 => _236(//g), 'optionalAccess', _237 => _237.length]), () => ( 0))), 0);
2090
2203
  if (!q || q.length !== want) continue;
2091
2204
  let k = 0;
2092
2205
  for (const it of list) it.str = it.str.replace(//g, () => q[k++]);
@@ -2109,15 +2222,15 @@ function selectionContextPages(selected, pageCount) {
2109
2222
  function marginContextBlocks(raw, page, view) {
2110
2223
  const [x1, y1, x2, y2] = view;
2111
2224
  const width = x2 - x1, height = y2 - y1;
2112
- const items = _chunk4X7AR4EHcjs.filterHiddenText.call(void 0, _chunk4X7AR4EHcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
2225
+ const items = _chunkC6B5GWN7cjs.filterHiddenText.call(void 0, _chunkC6B5GWN7cjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
2113
2226
  for (const item of items) {
2114
2227
  item.x -= x1;
2115
2228
  item.y -= y1;
2116
2229
  }
2117
- return _chunk4X7AR4EHcjs.groupByY.call(void 0, items).flatMap((line) => {
2118
- const bbox = _chunk4X7AR4EHcjs.computeBBox.call(void 0, line, page);
2230
+ return _chunkC6B5GWN7cjs.groupByY.call(void 0, items).flatMap((line) => {
2231
+ const bbox = _chunkC6B5GWN7cjs.computeBBox.call(void 0, line, page);
2119
2232
  if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
2120
- return [{ type: "paragraph", text: _chunk4X7AR4EHcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunk4X7AR4EHcjs.dominantStyle.call(void 0, line) }];
2233
+ return [{ type: "paragraph", text: _chunkC6B5GWN7cjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkC6B5GWN7cjs.dominantStyle.call(void 0, line) }];
2121
2234
  });
2122
2235
  }
2123
2236
 
@@ -2153,7 +2266,7 @@ var WINANSI_REVERSE = {
2153
2266
  };
2154
2267
  function symbolFontTable(fontName) {
2155
2268
  if (!fontName) return void 0;
2156
- if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkK2NWHLCDcjs.WINGDINGS;
2269
+ if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkYG4GFQB7cjs.WINGDINGS;
2157
2270
  return void 0;
2158
2271
  }
2159
2272
  function remapSymbolText(text, table) {
@@ -2281,7 +2394,7 @@ function layout(toks) {
2281
2394
  const bar = rest.find((t) => t.bar && t.x >= rt.x && t.x <= rt.x + rt.w + 2 && Math.abs(t.y - rt.y) <= size * 1.5);
2282
2395
  if (!bar) continue;
2283
2396
  const inner = rest.filter((t) => !t.bar && t !== rt && t.x + t.w / 2 > bar.x && t.x + t.w / 2 < bar.x + bar.w && bar.y - t.y > 0 && bar.y - t.y <= size * 1.4);
2284
- const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _194 => _194[0], 'optionalAccess', _195 => _195.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
2397
+ const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _238 => _238[0], 'optionalAccess', _239 => _239.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
2285
2398
  rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
2286
2399
  }
2287
2400
  const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
@@ -2383,7 +2496,7 @@ function wrapEquationRuns(items, faceName) {
2383
2496
  for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
2384
2497
  const top = [...ys].sort((p, q) => q[1] - p[1]);
2385
2498
  const bar = cur.find(isBarItem);
2386
- const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _196 => _196[0], 'optionalAccess', _197 => _197[0]]), () => ( cur[0].y));
2499
+ const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _240 => _240[0], 'optionalAccess', _241 => _241[0]]), () => ( cur[0].y));
2387
2500
  const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
2388
2501
  const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
2389
2502
  added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
@@ -2740,7 +2853,7 @@ function joinVerticalColumns(items) {
2740
2853
  const groups = [];
2741
2854
  for (const col of columns) {
2742
2855
  const g2 = groups[groups.length - 1];
2743
- const last = _optionalChain([g2, 'optionalAccess', _198 => _198[g2.length - 1]]);
2856
+ const last = _optionalChain([g2, 'optionalAccess', _242 => _242[g2.length - 1]]);
2744
2857
  const fs = col.items[0].fontSize;
2745
2858
  if (last && last.x - col.x >= fs * 1.2 && last.x - col.x <= fs * 4 && Math.abs(last.items[0].y - col.items[0].y) <= fs * 1.2) g2.push(col);
2746
2859
  else groups.push([col]);
@@ -2956,7 +3069,7 @@ function relocateEndnotes(blocks) {
2956
3069
  }
2957
3070
  const shapes = /* @__PURE__ */ new Map();
2958
3071
  for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
2959
- const main = _optionalChain([[...shapes], 'access', _199 => _199.sort, 'call', _200 => _200((a, b) => b[1] - a[1]), 'access', _201 => _201[0], 'optionalAccess', _202 => _202[0]]);
3072
+ const main = _optionalChain([[...shapes], 'access', _243 => _243.sort, 'call', _244 => _244((a, b) => b[1] - a[1]), 'access', _245 => _245[0], 'optionalAccess', _246 => _246[0]]);
2960
3073
  if (!main || !/#/.test(main)) return blocks;
2961
3074
  const lastRun = (hs) => {
2962
3075
  let run2 = [];
@@ -3019,7 +3132,7 @@ function dropTabLeaderDots(items) {
3019
3132
  let run = [];
3020
3133
  const flush = () => {
3021
3134
  const last = run[run.length - 1];
3022
- const tailPage = _optionalChain([DOTS_PAGE, 'access', _203 => _203.exec, 'call', _204 => _204(last.text.trim()), 'optionalAccess', _205 => _205[1]]);
3135
+ const tailPage = _optionalChain([DOTS_PAGE, 'access', _247 => _247.exec, 'call', _248 => _248(last.text.trim()), 'optionalAccess', _249 => _249[1]]);
3023
3136
  const dots = run.reduce((n, d) => n + d.text.trim().replace(/\d+$/, "").length, 0);
3024
3137
  if (dots >= MIN_DOTS && (tailPage ? run.length > 1 : pageNoAfter(last.x + last.w, last))) {
3025
3138
  const body = tailPage ? run.slice(0, -1) : run;
@@ -3107,7 +3220,7 @@ function inlineFootnotes(blocks, pages) {
3107
3220
  open = true;
3108
3221
  continue;
3109
3222
  }
3110
- const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontSize]), () => ( _optionalChain([b, 'access', _208 => _208.bbox, 'optionalAccess', _209 => _209.height]))), () => ( 10))) * 1.5;
3223
+ const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _250 => _250.style, 'optionalAccess', _251 => _251.fontSize]), () => ( _optionalChain([b, 'access', _252 => _252.bbox, 'optionalAccess', _253 => _253.height]))), () => ( 10))) * 1.5;
3111
3224
  if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
3112
3225
  notes[notes.length - 1].text += " " + b.text.trim();
3113
3226
  notes[notes.length - 1].blocks.push(b);
@@ -3130,7 +3243,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
3130
3243
  var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
3131
3244
  var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
3132
3245
  function isRunningHead(block, page, pageHeight) {
3133
- const box = block.bbox, text = _optionalChain([block, 'access', _210 => _210.text, 'optionalAccess', _211 => _211.trim, 'call', _212 => _212()]);
3246
+ const box = block.bbox, text = _optionalChain([block, 'access', _254 => _254.text, 'optionalAccess', _255 => _255.trim, 'call', _256 => _256()]);
3134
3247
  if (!box || !text || !pageHeight) return false;
3135
3248
  const top = box.y + box.height >= pageHeight * 0.9;
3136
3249
  const bottom = box.y <= pageHeight * 0.1;
@@ -3138,7 +3251,7 @@ function isRunningHead(block, page, pageHeight) {
3138
3251
  const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
3139
3252
  if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
3140
3253
  if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
3141
- if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _213 => _213.style, 'optionalAccess', _214 => _214.fontSize]), () => ( 0))) * 1.6) return true;
3254
+ if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _257 => _257.style, 'optionalAccess', _258 => _258.fontSize]), () => ( 0))) * 1.6) return true;
3142
3255
  if (!text.includes(" ")) return false;
3143
3256
  const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
3144
3257
  if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
@@ -3147,7 +3260,7 @@ function isRunningHead(block, page, pageHeight) {
3147
3260
  return right > left && box.width >= (right - left) * 0.6;
3148
3261
  }
3149
3262
  function unbalancedClose(text) {
3150
- return (_nullishCoalesce(_optionalChain([text, 'access', _215 => _215.match, 'call', _216 => _216(/\)/g), 'optionalAccess', _217 => _217.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _218 => _218.match, 'call', _219 => _219(/\(/g), 'optionalAccess', _220 => _220.length]), () => ( 0)));
3263
+ return (_nullishCoalesce(_optionalChain([text, 'access', _259 => _259.match, 'call', _260 => _260(/\)/g), 'optionalAccess', _261 => _261.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _262 => _262.match, 'call', _263 => _263(/\(/g), 'optionalAccess', _264 => _264.length]), () => ( 0)));
3151
3264
  }
3152
3265
  function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
3153
3266
  const byPage = /* @__PURE__ */ new Map();
@@ -3163,7 +3276,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
3163
3276
  const sizes = /* @__PURE__ */ new Map();
3164
3277
  let proseChars = 0;
3165
3278
  for (const b of page) {
3166
- if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _221 => _221.style, 'optionalAccess', _222 => _222.fontName]) || !b.style.fontSize) continue;
3279
+ if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _265 => _265.style, 'optionalAccess', _266 => _266.fontName]) || !b.style.fontSize) continue;
3167
3280
  const key2 = `${b.style.fontName}:${b.style.fontSize}`;
3168
3281
  chars.set(key2, (_nullishCoalesce(chars.get(key2), () => ( 0))) + b.text.length);
3169
3282
  if (b.type === "paragraph" && b.style.fontName === "ocr") {
@@ -3187,13 +3300,13 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
3187
3300
  const citedProse = /* @__PURE__ */ new Set();
3188
3301
  const numberedProse = /* @__PURE__ */ new Set();
3189
3302
  for (const page of byPage.values()) {
3190
- const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access', _223 => _223.text, 'optionalAccess', _224 => _224.trim, 'call', _225 => _225()]), () => ( ""))) && b.bbox && _optionalChain([b, 'access', _226 => _226.style, 'optionalAccess', _227 => _227.fontName]) && b.style.fontSize && !/Bold|Black|Heavy|Semibold/i.test(_nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _228 => _228.get, 'call', _229 => _229(b.style.fontName)]), () => ( ""))));
3303
+ const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access', _267 => _267.text, 'optionalAccess', _268 => _268.trim, 'call', _269 => _269()]), () => ( ""))) && b.bbox && _optionalChain([b, 'access', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) && b.style.fontSize && !/Bold|Black|Heavy|Semibold/i.test(_nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _272 => _272.get, 'call', _273 => _273(b.style.fontName)]), () => ( ""))));
3191
3304
  let chain = [];
3192
3305
  const finish = () => {
3193
- if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access', _230 => _230.text, 'optionalAccess', _231 => _231.length]), () => ( 0))) >= 40 && b.bbox.height >= b.style.fontSize * 2.4)) return;
3306
+ if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access', _274 => _274.text, 'optionalAccess', _275 => _275.length]), () => ( 0))) >= 40 && b.bbox.height >= b.style.fontSize * 2.4)) return;
3194
3307
  for (const b of chain) numberedProse.add(b);
3195
3308
  const first = chain[0], size = first.style.fontSize;
3196
- for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access', _232 => _232.text, 'optionalAccess', _233 => _233.trim, 'call', _234 => _234()]), () => ( ""))) && _optionalChain([b, 'access', _235 => _235.style, 'optionalAccess', _236 => _236.fontName]) === _optionalChain([first, 'access', _237 => _237.style, 'optionalAccess', _238 => _238.fontName]) && _optionalChain([b, 'access', _239 => _239.style, 'optionalAccess', _240 => _240.fontSize]) === size && b.bbox && Math.abs(b.bbox.x - first.bbox.x) <= size * 0.5 && (_nullishCoalesce(_optionalChain([b, 'access', _241 => _241.text, 'optionalAccess', _242 => _242.length]), () => ( 0))) >= 15) numberedProse.add(b);
3309
+ for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access', _276 => _276.text, 'optionalAccess', _277 => _277.trim, 'call', _278 => _278()]), () => ( ""))) && _optionalChain([b, 'access', _279 => _279.style, 'optionalAccess', _280 => _280.fontName]) === _optionalChain([first, 'access', _281 => _281.style, 'optionalAccess', _282 => _282.fontName]) && _optionalChain([b, 'access', _283 => _283.style, 'optionalAccess', _284 => _284.fontSize]) === size && b.bbox && Math.abs(b.bbox.x - first.bbox.x) <= size * 0.5 && (_nullishCoalesce(_optionalChain([b, 'access', _285 => _285.text, 'optionalAccess', _286 => _286.length]), () => ( 0))) >= 15) numberedProse.add(b);
3197
3310
  };
3198
3311
  for (const b of numbered) {
3199
3312
  const prev = chain.at(-1), size = b.style.fontSize;
@@ -3207,9 +3320,9 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
3207
3320
  }
3208
3321
  for (let i = 0; i + 1 < blocks.length; i++) {
3209
3322
  const prose = blocks[i], reference = blocks[i + 1];
3210
- const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _243 => _243.style, 'optionalAccess', _244 => _244.fontSize]), () => ( 0));
3211
- const source = _nullishCoalesce(_optionalChain([reference, 'access', _245 => _245.text, 'optionalAccess', _246 => _246.replace, 'call', _247 => _247(/<[^>]+>/g, ""), 'access', _248 => _248.trim, 'call', _249 => _249()]), () => ( ""));
3212
- if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access', _250 => _250.text, 'optionalAccess', _251 => _251.length]), () => ( 0))) < 40 || !a || !b || size <= 0 || a.height < size * 2.4 || prose.pageNumber !== reference.pageNumber || _optionalChain([prose, 'access', _252 => _252.style, 'optionalAccess', _253 => _253.fontName]) !== _optionalChain([reference, 'access', _254 => _254.style, 'optionalAccess', _255 => _255.fontName]) || _optionalChain([prose, 'access', _256 => _256.style, 'optionalAccess', _257 => _257.fontSize]) !== _optionalChain([reference, 'access', _258 => _258.style, 'optionalAccess', _259 => _259.fontSize]) || Math.abs(a.x - b.x) > size && !(/^[○●•◦]\s/.test(_nullishCoalesce(prose.text, () => ( ""))) && b.x >= a.x && b.x - a.x <= size * 2) || a.y - (b.y + b.height) < 0 || a.y - (b.y + b.height) > size || !/^[((].*(?:제\s*\d+\s*조|(?:Article|Section)\s+\d+).*[))]$/i.test(source)) continue;
3323
+ const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _287 => _287.style, 'optionalAccess', _288 => _288.fontSize]), () => ( 0));
3324
+ const source = _nullishCoalesce(_optionalChain([reference, 'access', _289 => _289.text, 'optionalAccess', _290 => _290.replace, 'call', _291 => _291(/<[^>]+>/g, ""), 'access', _292 => _292.trim, 'call', _293 => _293()]), () => ( ""));
3325
+ if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access', _294 => _294.text, 'optionalAccess', _295 => _295.length]), () => ( 0))) < 40 || !a || !b || size <= 0 || a.height < size * 2.4 || prose.pageNumber !== reference.pageNumber || _optionalChain([prose, 'access', _296 => _296.style, 'optionalAccess', _297 => _297.fontName]) !== _optionalChain([reference, 'access', _298 => _298.style, 'optionalAccess', _299 => _299.fontName]) || _optionalChain([prose, 'access', _300 => _300.style, 'optionalAccess', _301 => _301.fontSize]) !== _optionalChain([reference, 'access', _302 => _302.style, 'optionalAccess', _303 => _303.fontSize]) || Math.abs(a.x - b.x) > size && !(/^[○●•◦]\s/.test(_nullishCoalesce(prose.text, () => ( ""))) && b.x >= a.x && b.x - a.x <= size * 2) || a.y - (b.y + b.height) < 0 || a.y - (b.y + b.height) > size || !/^[((].*(?:제\s*\d+\s*조|(?:Article|Section)\s+\d+).*[))]$/i.test(source)) continue;
3213
3326
  citedProse.add(prose);
3214
3327
  citedProse.add(reference);
3215
3328
  }
@@ -3217,49 +3330,49 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
3217
3330
  const block = blocks[i];
3218
3331
  if (block.type !== "heading" || !block.text) continue;
3219
3332
  const text = block.text.replace(/<[^>]+>/g, "").trim();
3220
- const fsz = _nullishCoalesce(_optionalChain([block, 'access', _260 => _260.style, 'optionalAccess', _261 => _261.fontSize]), () => ( 0));
3221
- const tocEntry = i > 0 && _chunk4X7AR4EHcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunk4X7AR4EHcjs.TOC_BLOCKS.has(blocks[i + 1]);
3333
+ const fsz = _nullishCoalesce(_optionalChain([block, 'access', _304 => _304.style, 'optionalAccess', _305 => _305.fontSize]), () => ( 0));
3334
+ const tocEntry = i > 0 && _chunkC6B5GWN7cjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkC6B5GWN7cjs.TOC_BLOCKS.has(blocks[i + 1]);
3222
3335
  const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
3223
- const proseStyle = _optionalChain([block, 'access', _262 => _262.style, 'optionalAccess', _263 => _263.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
3336
+ const proseStyle = _optionalChain([block, 'access', _306 => _306.style, 'optionalAccess', _307 => _307.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
3224
3337
  const next = blocks[i + 1];
3225
- const nb = _optionalChain([next, 'optionalAccess', _264 => _264.bbox]), bb = block.bbox;
3226
- const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _265 => _265.style, 'optionalAccess', _266 => _266.fontSize]), () => ( 0))) * 1.2 && Math.abs(bb.x - nb.x) > fsz && Math.abs(bb.x + bb.width / 2 - (nb.x + nb.width / 2)) < nb.width * 0.1;
3227
- if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _267 => _267.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
3338
+ const nb = _optionalChain([next, 'optionalAccess', _308 => _308.bbox]), bb = block.bbox;
3339
+ const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _309 => _309.style, 'optionalAccess', _310 => _310.fontSize]), () => ( 0))) * 1.2 && Math.abs(bb.x - nb.x) > fsz && Math.abs(bb.x + bb.width / 2 - (nb.x + nb.width / 2)) < nb.width * 0.1;
3340
+ if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _311 => _311.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
3228
3341
  next.text = `${block.text.trim()} ${next.text.trim()}`;
3229
3342
  blocks.splice(i--, 1);
3230
3343
  continue;
3231
3344
  }
3232
- if ((_optionalChain([next, 'optionalAccess', _268 => _268.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _269 => _269.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) === _optionalChain([block, 'access', _272 => _272.style, 'optionalAccess', _273 => _273.fontName]) && _optionalChain([next, 'access', _274 => _274.style, 'optionalAccess', _275 => _275.fontSize]) === _optionalChain([block, 'access', _276 => _276.style, 'optionalAccess', _277 => _277.fontSize]) && fsz > 0 && /^[a-z]/.test(next.text.trim()) && next.text.trim().length <= 40 && !/[.:;!?]$/.test(next.text.trim()) && block.bbox.y - (next.bbox.y + next.bbox.height) < fsz * 1.2 && Math.abs(next.bbox.x - block.bbox.x) < fsz) {
3345
+ if ((_optionalChain([next, 'optionalAccess', _312 => _312.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _313 => _313.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _314 => _314.style, 'optionalAccess', _315 => _315.fontName]) === _optionalChain([block, 'access', _316 => _316.style, 'optionalAccess', _317 => _317.fontName]) && _optionalChain([next, 'access', _318 => _318.style, 'optionalAccess', _319 => _319.fontSize]) === _optionalChain([block, 'access', _320 => _320.style, 'optionalAccess', _321 => _321.fontSize]) && fsz > 0 && /^[a-z]/.test(next.text.trim()) && next.text.trim().length <= 40 && !/[.:;!?]$/.test(next.text.trim()) && block.bbox.y - (next.bbox.y + next.bbox.height) < fsz * 1.2 && Math.abs(next.bbox.x - block.bbox.x) < fsz) {
3233
3346
  block.text = `${block.text.trim()} ${next.text.trim()}`;
3234
3347
  block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
3235
3348
  blocks.splice(i + 1, 1);
3236
3349
  }
3237
3350
  const after = blocks[i + 2];
3238
- if ((_optionalChain([next, 'optionalAccess', _278 => _278.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _279 => _279.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _280 => _280.text, 'optionalAccess', _281 => _281.trim, 'call', _282 => _282()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _283 => _283.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _284 => _284.style, 'optionalAccess', _285 => _285.fontSize]) === _optionalChain([block, 'access', _286 => _286.style, 'optionalAccess', _287 => _287.fontSize])) {
3351
+ if ((_optionalChain([next, 'optionalAccess', _322 => _322.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _323 => _323.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _324 => _324.text, 'optionalAccess', _325 => _325.trim, 'call', _326 => _326()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _327 => _327.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _328 => _328.style, 'optionalAccess', _329 => _329.fontSize]) === _optionalChain([block, 'access', _330 => _330.style, 'optionalAccess', _331 => _331.fontSize])) {
3239
3352
  block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
3240
3353
  blocks.splice(i + 1, 2);
3241
3354
  }
3242
3355
  const tiny = fsz > 0 && fsz < 7.5;
3243
3356
  const prev = blocks[i - 1];
3244
- if (_optionalChain([prev, 'optionalAccess', _288 => _288.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _289 => _289.text, 'optionalAccess', _290 => _290.trim, 'call', _291 => _291()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
3357
+ if (_optionalChain([prev, 'optionalAccess', _332 => _332.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _333 => _333.text, 'optionalAccess', _334 => _334.trim, 'call', _335 => _335()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
3245
3358
  prev.text = `${prev.text.trim()} ${block.text.trim()}`;
3246
3359
  prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
3247
3360
  blocks.splice(i--, 1);
3248
3361
  continue;
3249
3362
  }
3250
- if (_optionalChain([prev, 'optionalAccess', _292 => _292.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _293 => _293.text, 'optionalAccess', _294 => _294.trim, 'call', _295 => _295()]), () => ( ""))) && prev.bbox && block.bbox && fsz > 0 && (Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x && block.bbox.x - (prev.bbox.x + prev.bbox.width) < fsz * 3 || Math.abs(prev.bbox.x - block.bbox.x) < 2 && (_nullishCoalesce(_optionalChain([prev, 'access', _296 => _296.style, 'optionalAccess', _297 => _297.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
3363
+ if (_optionalChain([prev, 'optionalAccess', _336 => _336.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _337 => _337.text, 'optionalAccess', _338 => _338.trim, 'call', _339 => _339()]), () => ( ""))) && prev.bbox && block.bbox && fsz > 0 && (Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x && block.bbox.x - (prev.bbox.x + prev.bbox.width) < fsz * 3 || Math.abs(prev.bbox.x - block.bbox.x) < 2 && (_nullishCoalesce(_optionalChain([prev, 'access', _340 => _340.style, 'optionalAccess', _341 => _341.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
3251
3364
  block.text = `${prev.text.trim()} ${block.text.trim()}`;
3252
3365
  blocks.splice(i - 1, 1);
3253
3366
  i -= 2;
3254
3367
  continue;
3255
3368
  }
3256
- const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _298 => _298.style, 'optionalAccess', _299 => _299.fontSize]), () => ( 0));
3257
- const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _300 => _300.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _301 => _301.style, 'optionalAccess', _302 => _302.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _303 => _303.style, 'optionalAccess', _304 => _304.fontSize]), () => ( 0))) >= size * 1.3 && box.y - (next.bbox.y + next.bbox.height) <= size * 3 && Math.min(box.x + box.width, next.bbox.x + next.bbox.width) - Math.max(box.x, next.bbox.x) >= Math.min(box.width, next.bbox.width) * 0.5 && !page.some((o) => o !== block && o.bbox && o.bbox.y > box.y + box.height && o.type !== "image");
3258
- const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _305 => _305.get, 'call', _306 => _306(_nullishCoalesce(_optionalChain([block, 'access', _307 => _307.style, 'optionalAccess', _308 => _308.fontName]), () => ( "")))]), () => ( ""));
3369
+ const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _342 => _342.style, 'optionalAccess', _343 => _343.fontSize]), () => ( 0));
3370
+ const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _344 => _344.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _345 => _345.style, 'optionalAccess', _346 => _346.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _347 => _347.style, 'optionalAccess', _348 => _348.fontSize]), () => ( 0))) >= size * 1.3 && box.y - (next.bbox.y + next.bbox.height) <= size * 3 && Math.min(box.x + box.width, next.bbox.x + next.bbox.width) - Math.max(box.x, next.bbox.x) >= Math.min(box.width, next.bbox.width) * 0.5 && !page.some((o) => o !== block && o.bbox && o.bbox.y > box.y + box.height && o.type !== "image");
3371
+ const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _349 => _349.get, 'call', _350 => _350(_nullishCoalesce(_optionalChain([block, 'access', _351 => _351.style, 'optionalAccess', _352 => _352.fontName]), () => ( "")))]), () => ( ""));
3259
3372
  const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
3260
- const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _309 => _309[i - 1], 'optionalAccess', _310 => _310.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
3261
- const ocrFragment = _optionalChain([block, 'access', _311 => _311.style, 'optionalAccess', _312 => _312.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _313 => _313.match, 'call', _314 => _314(/\p{L}/gu), 'optionalAccess', _315 => _315.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
3262
- const crowdedOcr = _optionalChain([block, 'access', _316 => _316.style, 'optionalAccess', _317 => _317.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _318 => _318.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _319 => _319.style, 'optionalAccess', _320 => _320.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _321 => _321.text, 'optionalAccess', _322 => _322.length]), () => ( 0))) >= 15 && Math.abs(o.bbox.x - box.x) <= size * 0.25 && Math.min(o.bbox.y + o.bbox.height, box.y + box.height) - Math.max(o.bbox.y, box.y) >= o.bbox.height * 0.2) && prev.bbox.y > box.y && next.bbox.y < box.y;
3373
+ const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _353 => _353[i - 1], 'optionalAccess', _354 => _354.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
3374
+ const ocrFragment = _optionalChain([block, 'access', _355 => _355.style, 'optionalAccess', _356 => _356.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _357 => _357.match, 'call', _358 => _358(/\p{L}/gu), 'optionalAccess', _359 => _359.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
3375
+ const crowdedOcr = _optionalChain([block, 'access', _360 => _360.style, 'optionalAccess', _361 => _361.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _362 => _362.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _363 => _363.style, 'optionalAccess', _364 => _364.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _365 => _365.text, 'optionalAccess', _366 => _366.length]), () => ( 0))) >= 15 && Math.abs(o.bbox.x - box.x) <= size * 0.25 && Math.min(o.bbox.y + o.bbox.height, box.y + box.height) - Math.max(o.bbox.y, box.y) >= o.bbox.height * 0.2) && prev.bbox.y > box.y && next.bbox.y < box.y;
3263
3376
  if (numberedProse.has(block) || citedProse.has(block) || ocrFragment || crowdedOcr || tocEntry || proseStyle || kicker || byline || tiny || !/\p{L}/u.test(text) && !chapterNumber || /^[a-z]/.test(text) || CAPTION.test(text) || EQUATION_NUMBER.test(block.text) || DISPLAY_MATH.test(text) || // 닫는 괄호가 여는 괄호보다 많으면 앞 줄에서 이어진 문장 조각이다 ("Fact-checking) and is used …") — "1)"·"가)" 앞머리 번호는 빼고 센다
3264
3377
  unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
3265
3378
  block.type = "paragraph";
@@ -3309,34 +3422,34 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
3309
3422
  function captionTableText(t) {
3310
3423
  if (!t || t.rows !== 1 || t.cols !== 2) return null;
3311
3424
  const [label, body] = t.cells[0];
3312
- if (!label || !body || _optionalChain([label, 'access', _323 => _323.blocks, 'optionalAccess', _324 => _324.length]) || _optionalChain([body, 'access', _325 => _325.blocks, 'optionalAccess', _326 => _326.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
3425
+ if (!label || !body || _optionalChain([label, 'access', _367 => _367.blocks, 'optionalAccess', _368 => _368.length]) || _optionalChain([body, 'access', _369 => _369.blocks, 'optionalAccess', _370 => _370.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
3313
3426
  return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
3314
3427
  }
3315
3428
  function splitSingleCellTables(blocks) {
3316
3429
  const out = [];
3317
3430
  for (const b of blocks) {
3318
3431
  const t = b.type === "table" ? b.table : void 0;
3319
- const title = t && _chunk4X7AR4EHcjs.FRAME_TITLE_BLOCKS.get(t);
3432
+ const title = t && _chunkC6B5GWN7cjs.FRAME_TITLE_BLOCKS.get(t);
3320
3433
  if (title) {
3321
3434
  out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
3322
3435
  continue;
3323
3436
  }
3324
- const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _327 => _327.cells, 'access', _328 => _328[0], 'optionalAccess', _329 => _329[0], 'optionalAccess', _330 => _330.blocks, 'optionalAccess', _331 => _331.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
3437
+ const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _371 => _371.cells, 'access', _372 => _372[0], 'optionalAccess', _373 => _373[0], 'optionalAccess', _374 => _374.blocks, 'optionalAccess', _375 => _375.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
3325
3438
  const squash = (s) => s.replace(/\s/g, "");
3326
3439
  const inner = only && (!squash(t.cells[0][0].text) || only.type === "table" && squash(t.cells[0][0].text) === squash(only.table.cells.flat().map((c) => c.text).join(""))) ? only : void 0;
3327
- const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _332 => _332.type]) === "table" ? captionTableText(inner.table) : null)));
3440
+ const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _376 => _376.type]) === "table" ? captionTableText(inner.table) : null)));
3328
3441
  if (caption) {
3329
3442
  out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
3330
3443
  continue;
3331
3444
  }
3332
- const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _333 => _333.cells, 'access', _334 => _334[0], 'optionalAccess', _335 => _335[0]]) : void 0;
3445
+ const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _377 => _377.cells, 'access', _378 => _378[0], 'optionalAccess', _379 => _379[0]]) : void 0;
3333
3446
  if (!cell) {
3334
3447
  out.push(b);
3335
3448
  continue;
3336
3449
  }
3337
3450
  const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
3338
- if (_optionalChain([t, 'optionalAccess', _336 => _336.caption, 'optionalAccess', _337 => _337.trim, 'call', _338 => _338()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
3339
- if (_optionalChain([cell, 'access', _339 => _339.blocks, 'optionalAccess', _340 => _340.length])) {
3451
+ if (_optionalChain([t, 'optionalAccess', _380 => _380.caption, 'optionalAccess', _381 => _381.trim, 'call', _382 => _382()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
3452
+ if (_optionalChain([cell, 'access', _383 => _383.blocks, 'optionalAccess', _384 => _384.length])) {
3340
3453
  out.push(...splitSingleCellTables(cell.blocks));
3341
3454
  continue;
3342
3455
  }
@@ -3352,7 +3465,7 @@ function joinLatinCellWraps(blocks) {
3352
3465
  const lines = cell.text.split("\n");
3353
3466
  const out = [lines[0]];
3354
3467
  for (const line of lines.slice(1)) {
3355
- if (_chunk4X7AR4EHcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
3468
+ if (_chunkC6B5GWN7cjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
3356
3469
  else out.push(line);
3357
3470
  }
3358
3471
  cell.text = out.join("\n");
@@ -3363,19 +3476,19 @@ function joinLatinCellWraps(blocks) {
3363
3476
  }
3364
3477
  function cleanPdfText(text, opts) {
3365
3478
  let clean = normalizeAraea(stripControlChars(text));
3366
- if (!_optionalChain([opts, 'optionalAccess', _341 => _341.keepLoneNumbers])) {
3479
+ if (!_optionalChain([opts, 'optionalAccess', _385 => _385.keepLoneNumbers])) {
3367
3480
  clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
3368
3481
  }
3369
- if (!_optionalChain([opts, 'optionalAccess', _342 => _342.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
3482
+ if (!_optionalChain([opts, 'optionalAccess', _386 => _386.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
3370
3483
  return mergeKoreanLines(
3371
3484
  clean.replace(/^[\s]*[-–—]\s*[-–—]?\d+[-–—]?[\s]*[-–—]?[\s]*$/gm, "").replace(/^\s*\d+\s*\/\s*\d+\s*$/gm, "").replace(/\.(?: \.){3,}/g, (m) => ".".repeat(m.length + 1 >> 1))
3372
3485
  ).replace(/^(?!\| ---).*$/gm, (line) => {
3373
3486
  if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
3374
3487
  if (line.startsWith("|")) {
3375
- return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunk4X7AR4EHcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
3488
+ return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkC6B5GWN7cjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
3376
3489
  }
3377
- const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _343 => _343.exec, 'call', _344 => _344(line), 'optionalAccess', _345 => _345[0]]), () => ( ""));
3378
- return mark + _chunk4X7AR4EHcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
3490
+ const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _387 => _387.exec, 'call', _388 => _388(line), 'optionalAccess', _389 => _389[0]]), () => ( ""));
3491
+ return mark + _chunkC6B5GWN7cjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
3379
3492
  }).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
3380
3493
  }
3381
3494
  function startsWithMarker(line) {
@@ -3407,7 +3520,7 @@ function mergeKoreanLines(text) {
3407
3520
  continue;
3408
3521
  }
3409
3522
  if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
3410
- result[result.length - 1] = prev + _chunk4X7AR4EHcjs.wrapJoiner.call(void 0, prev, curr) + curr;
3523
+ result[result.length - 1] = prev + _chunkC6B5GWN7cjs.wrapJoiner.call(void 0, prev, curr) + curr;
3411
3524
  } else {
3412
3525
  result.push(curr);
3413
3526
  }
@@ -3423,7 +3536,7 @@ function applyLinkAnnotations(items, annots) {
3423
3536
  const wrapped = /* @__PURE__ */ new Set();
3424
3537
  for (const a of annots) {
3425
3538
  if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
3426
- const url = _chunkMJSHXESKcjs.sanitizeHref.call(void 0, a.url);
3539
+ const url = _chunkAS25R4EUcjs.sanitizeHref.call(void 0, a.url);
3427
3540
  if (!url) continue;
3428
3541
  const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
3429
3542
  const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
@@ -3475,7 +3588,7 @@ function mergeLinkRuns(markdown) {
3475
3588
 
3476
3589
  // src/pdf/formula-ocr.ts
3477
3590
  async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
3478
- const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-JGFYGFYX.cjs")));
3591
+ const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-QZGTF3DZ.cjs")));
3479
3592
  const { FormulaPipeline, ensureFormulaModels } = formulaMod;
3480
3593
  await ensureFormulaModels((p) => {
3481
3594
  if (p.phase === "download" && p.total) {
@@ -3666,13 +3779,13 @@ async function loadPdfWithTimeout(buffer) {
3666
3779
  try {
3667
3780
  return await Promise.race([
3668
3781
  loadingTask.promise.catch((e) => {
3669
- if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkMJSHXESKcjs.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)");
3782
+ if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkAS25R4EUcjs.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)");
3670
3783
  throw e;
3671
3784
  }),
3672
3785
  new Promise((_, reject) => {
3673
3786
  timer = setTimeout(() => {
3674
3787
  loadingTask.destroy();
3675
- reject(new (0, _chunkMJSHXESKcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
3788
+ reject(new (0, _chunkAS25R4EUcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
3676
3789
  }, PDF_LOAD_TIMEOUT_MS);
3677
3790
  })
3678
3791
  ]);
@@ -3681,15 +3794,15 @@ async function loadPdfWithTimeout(buffer) {
3681
3794
  }
3682
3795
  }
3683
3796
  async function parsePdfDocument(buffer, options) {
3684
- const formulaBuffer = _optionalChain([options, 'optionalAccess', _346 => _346.formulaOcr]) ? buffer : null;
3685
- const ocrOptionError = _chunkK2NWHLCDcjs.validateOcrOptions.call(void 0, options);
3686
- if (ocrOptionError) throw new (0, _chunkMJSHXESKcjs.KordocError)(ocrOptionError);
3687
- const autoOcr = _optionalChain([options, 'optionalAccess', _347 => _347.ocr]) === void 0 && await _chunk4X7AR4EHcjs.ocrModelsCached.call(void 0, _chunk4X7AR4EHcjs.resolveOcrModels.call(void 0, options));
3688
- const ocrBuffer = _optionalChain([options, 'optionalAccess', _348 => _348.ocr]) || autoOcr ? buffer : null;
3797
+ const formulaBuffer = _optionalChain([options, 'optionalAccess', _390 => _390.formulaOcr]) ? buffer : null;
3798
+ const ocrOptionError = _chunkYG4GFQB7cjs.validateOcrOptions.call(void 0, options);
3799
+ if (ocrOptionError) throw new (0, _chunkAS25R4EUcjs.KordocError)(ocrOptionError);
3800
+ const autoOcr = _optionalChain([options, 'optionalAccess', _391 => _391.ocr]) === void 0 && await _chunkC6B5GWN7cjs.ocrModelsCached.call(void 0, _chunkC6B5GWN7cjs.resolveOcrModels.call(void 0, options));
3801
+ const ocrBuffer = _optionalChain([options, 'optionalAccess', _392 => _392.ocr]) || autoOcr ? buffer : null;
3689
3802
  const doc = await loadPdfWithTimeout(buffer);
3690
3803
  try {
3691
3804
  const pageCount = doc.numPages;
3692
- if (pageCount === 0) throw new (0, _chunkMJSHXESKcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
3805
+ if (pageCount === 0) throw new (0, _chunkAS25R4EUcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
3693
3806
  const metadata = { pageCount, pageMode: "layout" };
3694
3807
  await extractPdfMetadata(doc, metadata);
3695
3808
  const blocks = [];
@@ -3698,8 +3811,8 @@ async function parsePdfDocument(buffer, options) {
3698
3811
  let totalChars = 0;
3699
3812
  let totalTextBytes = 0;
3700
3813
  const effectivePageCount = Math.min(pageCount, MAX_PAGES);
3701
- const pageFilter = _optionalChain([options, 'optionalAccess', _349 => _349.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
3702
- if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _350 => _350.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
3814
+ const pageFilter = _optionalChain([options, 'optionalAccess', _393 => _393.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
3815
+ if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _394 => _394.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
3703
3816
  warnings.push({ message: `${pageCount}\uCABD \uC911 \uC55E ${MAX_PAGES}\uCABD\uB9CC \uD30C\uC2F1\uD588\uC2B5\uB2C8\uB2E4 (\uCABD \uC218 \uC0C1\uD55C)`, code: "PARTIAL_PARSE" });
3704
3817
  }
3705
3818
  const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
@@ -3718,10 +3831,10 @@ async function parsePdfDocument(buffer, options) {
3718
3831
  const pageImageBlocks = /* @__PURE__ */ new Map();
3719
3832
  const carry = {};
3720
3833
  const vectorPageOps = /* @__PURE__ */ new Map();
3721
- const wrapLexicon = new (0, _chunk4X7AR4EHcjs.WrapLexicon)();
3834
+ const wrapLexicon = new (0, _chunkC6B5GWN7cjs.WrapLexicon)();
3722
3835
  const noteMarks = /* @__PURE__ */ new Map();
3723
3836
  const headerContext = [];
3724
- if (pageFilter && _optionalChain([options, 'optionalAccess', _351 => _351.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
3837
+ if (pageFilter && _optionalChain([options, 'optionalAccess', _395 => _395.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
3725
3838
  for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
3726
3839
  let contextPage;
3727
3840
  try {
@@ -3731,7 +3844,7 @@ async function parsePdfDocument(buffer, options) {
3731
3844
  headerContext.push(...marginContextBlocks(content.items, number, contextPage.view));
3732
3845
  } catch (e6) {
3733
3846
  } finally {
3734
- _optionalChain([contextPage, 'optionalAccess', _352 => _352.cleanup, 'call', _353 => _353()]);
3847
+ _optionalChain([contextPage, 'optionalAccess', _396 => _396.cleanup, 'call', _397 => _397()]);
3735
3848
  }
3736
3849
  }
3737
3850
  }
@@ -3758,15 +3871,15 @@ async function parsePdfDocument(buffer, options) {
3758
3871
  return void 0;
3759
3872
  }
3760
3873
  };
3761
- const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _354 => _354(loadedName), 'optionalAccess', _355 => _355.differences]);
3874
+ const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _398 => _398(loadedName), 'optionalAccess', _399 => _399.differences]);
3762
3875
  const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
3763
3876
  markTrailingSpaceGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray);
3764
- restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _356 => _356(n), 'optionalAccess', _357 => _357.name]));
3877
+ restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _400 => _400(n), 'optionalAccess', _401 => _401.name]));
3765
3878
  restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
3766
3879
  restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
3767
3880
  markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
3768
- const items = _chunk4X7AR4EHcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
3769
- const filtered = _chunk4X7AR4EHcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
3881
+ const items = _chunkC6B5GWN7cjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
3882
+ const filtered = _chunkC6B5GWN7cjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
3770
3883
  const joined = joinVerticalColumns(filtered.visible);
3771
3884
  const visible = dropTabLeaderDots(joined);
3772
3885
  const hiddenCount = filtered.hiddenCount + occluded.size;
@@ -3790,27 +3903,27 @@ async function parsePdfDocument(buffer, options) {
3790
3903
  fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
3791
3904
  argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
3792
3905
  } : rawOps;
3793
- remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _358 => _358(loadedName), 'optionalAccess', _359 => _359.name]));
3906
+ remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _402 => _402(loadedName), 'optionalAccess', _403 => _403.name]));
3794
3907
  remapControlGlyphs(visible, differencesOf);
3795
- await _chunk4X7AR4EHcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
3908
+ await _chunkC6B5GWN7cjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
3796
3909
  const faces = /* @__PURE__ */ new Map();
3797
3910
  for (const it of visible) {
3798
3911
  if (!it.fontName) continue;
3799
3912
  let face = faces.get(it.fontName);
3800
3913
  if (face === void 0) {
3801
3914
  const obj = fontObj(it.fontName);
3802
- face = _optionalChain([obj, 'optionalAccess', _360 => _360.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
3915
+ face = _optionalChain([obj, 'optionalAccess', _404 => _404.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
3803
3916
  faces.set(it.fontName, face);
3804
3917
  }
3805
3918
  it.fontName = face;
3806
- if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _361 => _361(face), 'optionalAccess', _362 => _362.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
3919
+ if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _405 => _405(face), 'optionalAccess', _406 => _406.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
3807
3920
  }
3808
- for (const it of visible) if (it.text.includes("$")) it.text = _chunkK2NWHLCDcjs.escapeLiteralDollar.call(void 0, it.text);
3809
- for (const it of visible) if (it.text.includes("<")) it.text = _chunkK2NWHLCDcjs.escapeLiteralTags.call(void 0, it.text);
3921
+ for (const it of visible) if (it.text.includes("$")) it.text = _chunkYG4GFQB7cjs.escapeLiteralDollar.call(void 0, it.text);
3922
+ for (const it of visible) if (it.text.includes("<")) it.text = _chunkYG4GFQB7cjs.escapeLiteralTags.call(void 0, it.text);
3810
3923
  wrapEquationRuns(visible, (face) => faceNames.get(face));
3811
3924
  const pageArea = pageW * pageH;
3812
3925
  if (pageArea > 0) {
3813
- const imageRegions = _chunk4X7AR4EHcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
3926
+ const imageRegions = _chunkC6B5GWN7cjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
3814
3927
  let uncovered = 0;
3815
3928
  for (const r of imageRegions) {
3816
3929
  const area = (r.x2 - r.x1) * (r.y2 - r.y1);
@@ -3836,15 +3949,15 @@ async function parsePdfDocument(buffer, options) {
3836
3949
  if (uncovered > 0) skippedImagePages.set(i, uncovered);
3837
3950
  }
3838
3951
  const marks = superscriptNoteMarks(visible);
3839
- if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunk4X7AR4EHcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
3952
+ if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkC6B5GWN7cjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
3840
3953
  const stamp = marginStamp(visible);
3841
3954
  const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
3842
- const rightArrows = _optionalChain([options, 'optionalAccess', _363 => _363.tables]) !== false ? await _chunk4X7AR4EHcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
3843
- const pageBlocks = orderTwoUpPage(_chunk4X7AR4EHcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _364 => _364.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
3955
+ const rightArrows = _optionalChain([options, 'optionalAccess', _407 => _407.tables]) !== false ? await _chunkC6B5GWN7cjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
3956
+ const pageBlocks = orderTwoUpPage(_chunkC6B5GWN7cjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _408 => _408.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
3844
3957
  if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
3845
3958
  for (const b of pageBlocks) blocks.push(b);
3846
3959
  try {
3847
- const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _365 => _365.images]) !== false);
3960
+ const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _409 => _409.images]) !== false);
3848
3961
  if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
3849
3962
  extractedImages.push(...pageImages);
3850
3963
  } catch (e9) {
@@ -3863,17 +3976,17 @@ async function parsePdfDocument(buffer, options) {
3863
3976
  const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
3864
3977
  const quality = computePageQuality(i, pageText, vector.glyphs);
3865
3978
  pageQuality.push(quality);
3866
- if (_optionalChain([options, 'optionalAccess', _366 => _366.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
3979
+ if (_optionalChain([options, 'optionalAccess', _410 => _410.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
3867
3980
  vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
3868
3981
  }
3869
- if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkMJSHXESKcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
3982
+ if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkAS25R4EUcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
3870
3983
  parsedPages++;
3871
- _optionalChain([options, 'optionalAccess', _367 => _367.onProgress, 'optionalCall', _368 => _368(parsedPages, totalTarget)]);
3984
+ _optionalChain([options, 'optionalAccess', _411 => _411.onProgress, 'optionalCall', _412 => _412(parsedPages, totalTarget)]);
3872
3985
  } catch (pageErr) {
3873
- if (pageErr instanceof _chunkMJSHXESKcjs.KordocError) throw pageErr;
3986
+ if (pageErr instanceof _chunkAS25R4EUcjs.KordocError) throw pageErr;
3874
3987
  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" });
3875
3988
  } finally {
3876
- _optionalChain([loadedPage, 'optionalAccess', _369 => _369.cleanup, 'call', _370 => _370()]);
3989
+ _optionalChain([loadedPage, 'optionalAccess', _413 => _413.cleanup, 'call', _414 => _414()]);
3877
3990
  }
3878
3991
  if (loadedFonts.size > FONT_CACHE_LIMIT) {
3879
3992
  await doc.cleanup();
@@ -3881,14 +3994,14 @@ async function parsePdfDocument(buffer, options) {
3881
3994
  }
3882
3995
  }
3883
3996
  const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
3884
- const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _371 => _371.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
3997
+ const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _415 => _415.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
3885
3998
  const ocrDone = /* @__PURE__ */ new Set();
3886
3999
  const ocrLinesOut = /* @__PURE__ */ new Map();
3887
- const ocrRegions = _optionalChain([options, 'optionalAccess', _372 => _372.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _373 => _373.ocr]) === true) : /* @__PURE__ */ new Map();
4000
+ const ocrRegions = _optionalChain([options, 'optionalAccess', _416 => _416.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _417 => _417.ocr]) === true) : /* @__PURE__ */ new Map();
3888
4001
  if (ocrBuffer) {
3889
4002
  const inScope = (p) => !pageFilter || pageFilter.has(p);
3890
4003
  const targets = /* @__PURE__ */ new Set();
3891
- if (_optionalChain([options, 'optionalAccess', _374 => _374.ocr]) === "force" || isImageBased) {
4004
+ if (_optionalChain([options, 'optionalAccess', _418 => _418.ocr]) === "force" || isImageBased) {
3892
4005
  for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
3893
4006
  } else {
3894
4007
  for (const pq of pageQuality) {
@@ -3901,25 +4014,25 @@ async function parsePdfDocument(buffer, options) {
3901
4014
  }
3902
4015
  if (targets.size > 0) {
3903
4016
  try {
3904
- const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-QWTGWYQT.cjs")));
3905
- const mode = typeof _optionalChain([options, 'optionalAccess', _375 => _375.ocr]) === "function" ? options.ocr : "builtin";
3906
- const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _376 => _376.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _377 => _377.find, 'call', _378 => _378((q) => q.page === p), 'optionalAccess', _379 => _379.needsOcr])));
3907
- const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-QWTGWYQT.cjs")));
3908
- const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _380 => _380.onProgress]), _optionalChain([options, 'optionalAccess', _381 => _381.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
3909
- for (const obs of ocrPageBlocks.values()) _chunkK2NWHLCDcjs.stripScriptTags.call(void 0, { blocks: obs });
4017
+ const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-IOUZTPPH.cjs")));
4018
+ const mode = typeof _optionalChain([options, 'optionalAccess', _419 => _419.ocr]) === "function" ? options.ocr : "builtin";
4019
+ const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _420 => _420.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _421 => _421.find, 'call', _422 => _422((q) => q.page === p), 'optionalAccess', _423 => _423.needsOcr])));
4020
+ const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-IOUZTPPH.cjs")));
4021
+ const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _424 => _424.onProgress]), _optionalChain([options, 'optionalAccess', _425 => _425.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
4022
+ for (const obs of ocrPageBlocks.values()) _chunkYG4GFQB7cjs.stripScriptTags.call(void 0, { blocks: obs });
3910
4023
  if (ocrPageBlocks.size > 0) {
3911
4024
  const replacePages = /* @__PURE__ */ new Set();
3912
4025
  for (const [p, obs] of ocrPageBlocks) {
3913
- const needsOcr = _optionalChain([pageQuality, 'access', _382 => _382.find, 'call', _383 => _383((q) => q.page === p), 'optionalAccess', _384 => _384.needsOcr]);
3914
- if (_optionalChain([options, 'optionalAccess', _385 => _385.ocr]) === "force" || isImageBased || needsOcr) {
4026
+ const needsOcr = _optionalChain([pageQuality, 'access', _426 => _426.find, 'call', _427 => _427((q) => q.page === p), 'optionalAccess', _428 => _428.needsOcr]);
4027
+ if (_optionalChain([options, 'optionalAccess', _429 => _429.ocr]) === "force" || isImageBased || needsOcr) {
3915
4028
  replacePages.add(p);
3916
4029
  ocrDone.add(p);
3917
4030
  continue;
3918
4031
  }
3919
4032
  const regions = ocrRegions.get(p);
3920
- if (!regions || _chunk4X7AR4EHcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
4033
+ if (!regions || _chunkC6B5GWN7cjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
3921
4034
  ocrDone.add(p);
3922
- if (_optionalChain([pageImageBlocks, 'access', _386 => _386.get, 'call', _387 => _387(p), 'optionalAccess', _388 => _388.length]) === 1) pageImageBlocks.delete(p);
4035
+ if (_optionalChain([pageImageBlocks, 'access', _430 => _430.get, 'call', _431 => _431(p), 'optionalAccess', _432 => _432.length]) === 1) pageImageBlocks.delete(p);
3923
4036
  }
3924
4037
  if (replacePages.size) {
3925
4038
  const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
@@ -3969,18 +4082,18 @@ async function parsePdfDocument(buffer, options) {
3969
4082
  warnings.push({ page, message: `${count}\uAC1C \uC774\uBBF8\uC9C0 \uC601\uC5ED\uC5D0 \uCD94\uCD9C \uAC00\uB2A5\uD55C \uD14D\uC2A4\uD2B8 \uC5C6\uC74C (\uADF8\uB9BC/\uCC28\uD2B8/\uB3C4\uC7A5 \uB0B4\uC6A9 \uB204\uB77D \uAC00\uB2A5 \u2014 \uADF8\uB9BC \uC18D \uAE00\uC740 ocr: true / CLI --ocr \uB85C \uC77D\uC2B5\uB2C8\uB2E4)`, code: "SKIPPED_IMAGE" });
3970
4083
  }
3971
4084
  }
3972
- if (_optionalChain([options, 'optionalAccess', _389 => _389.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
3973
- const removed = _chunk4X7AR4EHcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
3974
- const running = _chunk4X7AR4EHcjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
4085
+ if (_optionalChain([options, 'optionalAccess', _433 => _433.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
4086
+ const removed = _chunkC6B5GWN7cjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
4087
+ const running = _chunkC6B5GWN7cjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
3975
4088
  for (let ri = removed.length - 1; ri >= 0; ri--) {
3976
4089
  blocks.splice(removed[ri], 1);
3977
4090
  }
3978
- const stripped = _chunk4X7AR4EHcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
4091
+ const stripped = _chunkC6B5GWN7cjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
3979
4092
  if (stripped !== blocks) {
3980
4093
  blocks.length = 0;
3981
4094
  blocks.push(...stripped);
3982
4095
  }
3983
- const kept = _chunk4X7AR4EHcjs.removeSideTabs.call(void 0, blocks, pageWidths);
4096
+ const kept = _chunkC6B5GWN7cjs.removeSideTabs.call(void 0, blocks, pageWidths);
3984
4097
  if (kept !== blocks) {
3985
4098
  blocks.length = 0;
3986
4099
  blocks.push(...kept);
@@ -3988,15 +4101,15 @@ async function parsePdfDocument(buffer, options) {
3988
4101
  }
3989
4102
  mergeContinuedCells(blocks, pageHeights);
3990
4103
  mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
3991
- if (_optionalChain([options, 'optionalAccess', _390 => _390.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
3992
- const boxes = _chunk4X7AR4EHcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
4104
+ if (_optionalChain([options, 'optionalAccess', _434 => _434.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
4105
+ const boxes = _chunkC6B5GWN7cjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
3993
4106
  for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
3994
4107
  }
3995
4108
  splitContactTables(blocks);
3996
- if (!_optionalChain([options, 'optionalAccess', _391 => _391.keepTrailingEmptyCols])) _chunk4X7AR4EHcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
3997
- _chunk4X7AR4EHcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
4109
+ if (!_optionalChain([options, 'optionalAccess', _435 => _435.keepTrailingEmptyCols])) _chunkC6B5GWN7cjs.trimTrailingEmptyTableCols.call(void 0, blocks);
4110
+ _chunkC6B5GWN7cjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
3998
4111
  injectPageImageBlocks(blocks, pageImageBlocks);
3999
- if (_optionalChain([options, 'optionalAccess', _392 => _392.formulaOcr]) && formulaBuffer) {
4112
+ if (_optionalChain([options, 'optionalAccess', _436 => _436.formulaOcr]) && formulaBuffer) {
4000
4113
  try {
4001
4114
  await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
4002
4115
  } catch (e) {
@@ -4006,54 +4119,54 @@ async function parsePdfDocument(buffer, options) {
4006
4119
  });
4007
4120
  }
4008
4121
  }
4009
- const medianFontSize = _chunk4X7AR4EHcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
4122
+ const medianFontSize = _chunkC6B5GWN7cjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
4010
4123
  if (medianFontSize > 0) {
4011
- _chunk4X7AR4EHcjs.detectHeadings.call(void 0, blocks, medianFontSize);
4012
- }
4013
- _chunk4X7AR4EHcjs.detectDocumentStyleHeadings.call(void 0, blocks);
4014
- _chunk4X7AR4EHcjs.detectTypographyHeadings.call(void 0, blocks);
4015
- _chunk4X7AR4EHcjs.detectSiblingStyleHeadings.call(void 0, blocks);
4016
- _chunk4X7AR4EHcjs.detectRepeatedPageLabels.call(void 0, blocks);
4017
- _chunk4X7AR4EHcjs.detectPageLeadHeadings.call(void 0, blocks);
4018
- _chunk4X7AR4EHcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
4019
- _chunk4X7AR4EHcjs.refineDocumentStyleHeadings.call(void 0, blocks);
4020
- _chunk4X7AR4EHcjs.detectMarkerHeadings.call(void 0, blocks);
4124
+ _chunkC6B5GWN7cjs.detectHeadings.call(void 0, blocks, medianFontSize);
4125
+ }
4126
+ _chunkC6B5GWN7cjs.detectDocumentStyleHeadings.call(void 0, blocks);
4127
+ _chunkC6B5GWN7cjs.detectTypographyHeadings.call(void 0, blocks);
4128
+ _chunkC6B5GWN7cjs.detectSiblingStyleHeadings.call(void 0, blocks);
4129
+ _chunkC6B5GWN7cjs.detectRepeatedPageLabels.call(void 0, blocks);
4130
+ _chunkC6B5GWN7cjs.detectPageLeadHeadings.call(void 0, blocks);
4131
+ _chunkC6B5GWN7cjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
4132
+ _chunkC6B5GWN7cjs.refineDocumentStyleHeadings.call(void 0, blocks);
4133
+ _chunkC6B5GWN7cjs.detectMarkerHeadings.call(void 0, blocks);
4021
4134
  demoteNonHeadingRoles(blocks, pageHeights, faceNames);
4022
- _chunk4X7AR4EHcjs.detectTableCaptions.call(void 0, blocks);
4023
- _chunk4X7AR4EHcjs.detectKoreanListBlocks.call(void 0, blocks);
4135
+ _chunkC6B5GWN7cjs.detectTableCaptions.call(void 0, blocks);
4136
+ _chunkC6B5GWN7cjs.detectKoreanListBlocks.call(void 0, blocks);
4024
4137
  sanitizeBlockControlChars(blocks);
4025
4138
  let outBlocks = splitSingleCellTables(blocks);
4026
- if (_optionalChain([options, 'optionalAccess', _393 => _393.layoutTables]) !== "keep") {
4139
+ if (_optionalChain([options, 'optionalAccess', _437 => _437.layoutTables]) !== "keep") {
4027
4140
  blocks.length = 0;
4028
4141
  for (const block of outBlocks) blocks.push(block);
4029
4142
  }
4030
4143
  outBlocks = inlineFootnotes(outBlocks, noteMarks);
4031
4144
  outBlocks = relocateEndnotes(outBlocks);
4032
- if (_optionalChain([options, 'optionalAccess', _394 => _394.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
4145
+ if (_optionalChain([options, 'optionalAccess', _438 => _438.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
4033
4146
  if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
4034
4147
  const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
4035
4148
  if (!b.bbox || !h) return false;
4036
4149
  return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
4037
4150
  });
4038
4151
  joinLatinCellWraps(outBlocks);
4039
- if (_optionalChain([options, 'optionalAccess', _395 => _395.layoutTables]) !== "keep") {
4152
+ if (_optionalChain([options, 'optionalAccess', _439 => _439.layoutTables]) !== "keep") {
4040
4153
  const hancom = await isHancomPdf(doc);
4041
4154
  const shown = /* @__PURE__ */ new Map();
4042
4155
  const markContent = (bs) => {
4043
4156
  for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
4044
- if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(c)) _chunkK2NWHLCDcjs.CONTENT_CELLS.add(c);
4045
- const lines = _chunk4X7AR4EHcjs.CELL_LINES.get(c);
4046
- if (lines) _chunkK2NWHLCDcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
4157
+ if (_chunkC6B5GWN7cjs.IMAGE_CELLS.has(c)) _chunkYG4GFQB7cjs.CONTENT_CELLS.add(c);
4158
+ const lines = _chunkC6B5GWN7cjs.CELL_LINES.get(c);
4159
+ if (lines) _chunkYG4GFQB7cjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
4047
4160
  markContent(c.blocks);
4048
4161
  }
4049
4162
  };
4050
4163
  const visual = (bs) => bs.flatMap((b) => {
4051
4164
  if (b.type !== "table") return [b];
4052
- if (!hancom && b.table && _chunk4X7AR4EHcjs.CLIP_TABLES.has(b.table)) return [b];
4165
+ if (!hancom && b.table && _chunkC6B5GWN7cjs.CLIP_TABLES.has(b.table)) return [b];
4053
4166
  let v = shown.get(b);
4054
4167
  if (!v) {
4055
4168
  markContent([b]);
4056
- shown.set(b, v = _chunkK2NWHLCDcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _396 => _396.keepTrailingEmptyCols])));
4169
+ shown.set(b, v = _chunkYG4GFQB7cjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _440 => _440.keepTrailingEmptyCols])));
4057
4170
  }
4058
4171
  return v;
4059
4172
  });
@@ -4062,13 +4175,13 @@ async function parsePdfDocument(buffer, options) {
4062
4175
  blocks.length = 0;
4063
4176
  for (const b of kept) blocks.push(b);
4064
4177
  }
4065
- const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkK2NWHLCDcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _397 => _397.tableFormat]) }), { keepLoneNumbers: true }));
4066
- if (_optionalChain([options, 'optionalAccess', _398 => _398.tableFormat]) === "gfm") _chunkK2NWHLCDcjs.assignTableIds.call(void 0, blocks);
4178
+ const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkYG4GFQB7cjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _441 => _441.tableFormat]) }), { keepLoneNumbers: true }));
4179
+ if (_optionalChain([options, 'optionalAccess', _442 => _442.tableFormat]) === "gfm") _chunkYG4GFQB7cjs.assignTableIds.call(void 0, blocks);
4067
4180
  let markdown = finishMarkdown(outBlocks);
4068
4181
  const outline = collectPdfOutline(outBlocks);
4069
4182
  return {
4070
4183
  markdown,
4071
- pages: _chunkVXQWAPC6cjs.blocksToPages.call(void 0, splitPageTables(_chunk4X7AR4EHcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
4184
+ pages: _chunkN6KXGIINcjs.blocksToPages.call(void 0, splitPageTables(_chunkC6B5GWN7cjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
4072
4185
  blocks,
4073
4186
  metadata,
4074
4187
  outline: outline.length > 0 ? outline : void 0,
@@ -4077,7 +4190,7 @@ async function parsePdfDocument(buffer, options) {
4077
4190
  pageQuality,
4078
4191
  qualitySummary: summarizeDocumentQuality(pageQuality),
4079
4192
  images: extractedImages.length > 0 ? extractedImages : void 0,
4080
- ..._optionalChain([options, 'optionalAccess', _399 => _399.ocrLines]) ? { ocrLines: [...ocrLinesOut.values()].sort((a, b) => a.pageNumber - b.pageNumber) } : {}
4193
+ ..._optionalChain([options, 'optionalAccess', _443 => _443.ocrLines]) ? { ocrLines: [...ocrLinesOut.values()].sort((a, b) => a.pageNumber - b.pageNumber) } : {}
4081
4194
  };
4082
4195
  } finally {
4083
4196
  await doc.destroy().catch(() => {
@@ -4087,7 +4200,7 @@ async function parsePdfDocument(buffer, options) {
4087
4200
  async function extractPdfMetadata(doc, metadata) {
4088
4201
  try {
4089
4202
  const result = await doc.getMetadata();
4090
- if (!_optionalChain([result, 'optionalAccess', _400 => _400.info])) return;
4203
+ if (!_optionalChain([result, 'optionalAccess', _444 => _444.info])) return;
4091
4204
  const info = result.info;
4092
4205
  if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
4093
4206
  if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
@@ -4103,8 +4216,8 @@ async function extractPdfMetadata(doc, metadata) {
4103
4216
  }
4104
4217
  async function isHancomPdf(doc) {
4105
4218
  try {
4106
- const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _401 => _401.info]);
4107
- return [_optionalChain([info, 'optionalAccess', _402 => _402.Producer]), _optionalChain([info, 'optionalAccess', _403 => _403.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
4219
+ const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _445 => _445.info]);
4220
+ return [_optionalChain([info, 'optionalAccess', _446 => _446.Producer]), _optionalChain([info, 'optionalAccess', _447 => _447.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
4108
4221
  } catch (e11) {
4109
4222
  return false;
4110
4223
  }
@@ -4148,5 +4261,5 @@ function marginStamp(items) {
4148
4261
 
4149
4262
 
4150
4263
 
4151
- exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunk4X7AR4EHcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunk4X7AR4EHcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunk4X7AR4EHcjs.removeHeaderFooterBlocks;
4152
- //# sourceMappingURL=parser-ZFXVZZKQ.cjs.map
4264
+ exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkC6B5GWN7cjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkC6B5GWN7cjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkC6B5GWN7cjs.removeHeaderFooterBlocks;
4265
+ //# sourceMappingURL=parser-WNDH2X6N.cjs.map