kordoc 3.3.0 → 3.4.1

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 (83) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +584 -584
  3. package/dist/{-RAVJL5UK.js → -YOQGQ22S.js} +5 -5
  4. package/dist/{chunk-MOL7MDBG.js → chunk-3TBUDJDE.js} +1 -1
  5. package/dist/chunk-3TBUDJDE.js.map +1 -0
  6. package/dist/{chunk-GE43BE46.js → chunk-AIQ3ISQU.js} +1 -1
  7. package/dist/chunk-AIQ3ISQU.js.map +1 -0
  8. package/dist/{chunk-MEPHGCPQ.js → chunk-CFQLK3LM.js} +1 -1
  9. package/dist/chunk-CFQLK3LM.js.map +1 -0
  10. package/dist/{chunk-J72F7FIT.js → chunk-CGHPBI3X.js} +256 -84
  11. package/dist/chunk-CGHPBI3X.js.map +1 -0
  12. package/dist/{chunk-HNUFTEV5.js → chunk-FPFB7AFX.js} +2 -2
  13. package/dist/chunk-FPFB7AFX.js.map +1 -0
  14. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  15. package/dist/{chunk-ESBGMBRF.js → chunk-SE3KEL4G.js} +2 -2
  16. package/dist/chunk-SE3KEL4G.js.map +1 -0
  17. package/dist/{chunk-FUB2BGXV.cjs → chunk-W7JHJQ2O.cjs} +2 -2
  18. package/dist/chunk-W7JHJQ2O.cjs.map +1 -0
  19. package/dist/{chunk-DCZVOIEO.cjs → chunk-X34YWRL5.cjs} +1 -1
  20. package/dist/chunk-X34YWRL5.cjs.map +1 -0
  21. package/dist/cli.js +8 -8
  22. package/dist/cli.js.map +1 -1
  23. package/dist/{detect-RI2MQ33K.js → detect-NTR2FUEG.js} +2 -2
  24. package/dist/{formula-JCNF43NE.js → formula-KOQV353G.js} +1 -1
  25. package/dist/formula-KOQV353G.js.map +1 -0
  26. package/dist/{formula-RXVSQPXI.js → formula-MEDGYQXS.js} +1 -1
  27. package/dist/formula-MEDGYQXS.js.map +1 -0
  28. package/dist/{formula-5NKVS2LR.cjs → formula-ZYUDQHD3.cjs} +1 -1
  29. package/dist/formula-ZYUDQHD3.cjs.map +1 -0
  30. package/dist/index.cjs +424 -252
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.js +254 -82
  33. package/dist/index.js.map +1 -1
  34. package/dist/mcp.js +6 -6
  35. package/dist/mcp.js.map +1 -1
  36. package/dist/page-range-CIRRJPXJ.js +7 -0
  37. package/dist/page-range-OF5I4PQY.js +8 -0
  38. package/dist/page-range-TPIRSA3J.cjs +8 -0
  39. package/dist/page-range-TPIRSA3J.cjs.map +1 -0
  40. package/dist/{parser-FLE2ZPAW.js → parser-5HDZZWDH.js} +5 -5
  41. package/dist/parser-5HDZZWDH.js.map +1 -0
  42. package/dist/{parser-DADWQYCQ.js → parser-ET64VEEX.js} +5 -5
  43. package/dist/parser-ET64VEEX.js.map +1 -0
  44. package/dist/{parser-YWKNDGKI.cjs → parser-JAZCZJI6.cjs} +18 -18
  45. package/dist/parser-JAZCZJI6.cjs.map +1 -0
  46. package/dist/{provider-G4C2V2PD.cjs → provider-5K7O3Z2O.cjs} +1 -1
  47. package/dist/provider-5K7O3Z2O.cjs.map +1 -0
  48. package/dist/{provider-AKROB7WQ.js → provider-7H4CPZYS.js} +1 -1
  49. package/dist/provider-7H4CPZYS.js.map +1 -0
  50. package/dist/{provider-4ZJKV3DC.js → provider-H4WWSPOV.js} +1 -1
  51. package/dist/provider-H4WWSPOV.js.map +1 -0
  52. package/dist/{setup-57FB3LSP.js → setup-QSJ2INNS.js} +1 -1
  53. package/dist/setup-QSJ2INNS.js.map +1 -0
  54. package/dist/{watch-6QPQU277.js → watch-56GNC2YN.js} +5 -5
  55. package/dist/watch-56GNC2YN.js.map +1 -0
  56. package/package.json +98 -98
  57. package/dist/chunk-DCZVOIEO.cjs.map +0 -1
  58. package/dist/chunk-ESBGMBRF.js.map +0 -1
  59. package/dist/chunk-FUB2BGXV.cjs.map +0 -1
  60. package/dist/chunk-GE43BE46.js.map +0 -1
  61. package/dist/chunk-HNUFTEV5.js.map +0 -1
  62. package/dist/chunk-J72F7FIT.js.map +0 -1
  63. package/dist/chunk-MEPHGCPQ.js.map +0 -1
  64. package/dist/chunk-MOL7MDBG.js.map +0 -1
  65. package/dist/formula-5NKVS2LR.cjs.map +0 -1
  66. package/dist/formula-JCNF43NE.js.map +0 -1
  67. package/dist/formula-RXVSQPXI.js.map +0 -1
  68. package/dist/page-range-737B4EZW.js +0 -8
  69. package/dist/page-range-LNMXJU6W.js +0 -7
  70. package/dist/page-range-P7SDW6LR.cjs +0 -8
  71. package/dist/page-range-P7SDW6LR.cjs.map +0 -1
  72. package/dist/parser-DADWQYCQ.js.map +0 -1
  73. package/dist/parser-FLE2ZPAW.js.map +0 -1
  74. package/dist/parser-YWKNDGKI.cjs.map +0 -1
  75. package/dist/provider-4ZJKV3DC.js.map +0 -1
  76. package/dist/provider-AKROB7WQ.js.map +0 -1
  77. package/dist/provider-G4C2V2PD.cjs.map +0 -1
  78. package/dist/setup-57FB3LSP.js.map +0 -1
  79. package/dist/watch-6QPQU277.js.map +0 -1
  80. /package/dist/{-RAVJL5UK.js.map → -YOQGQ22S.js.map} +0 -0
  81. /package/dist/{detect-RI2MQ33K.js.map → detect-NTR2FUEG.js.map} +0 -0
  82. /package/dist/{page-range-737B4EZW.js.map → page-range-CIRRJPXJ.js.map} +0 -0
  83. /package/dist/{page-range-LNMXJU6W.js.map → page-range-OF5I4PQY.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -17,10 +17,10 @@
17
17
 
18
18
 
19
19
 
20
- var _chunkFUB2BGXVcjs = require('./chunk-FUB2BGXV.cjs');
20
+ var _chunkW7JHJQ2Ocjs = require('./chunk-W7JHJQ2O.cjs');
21
21
 
22
22
 
23
- var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
23
+ var _chunkX34YWRL5cjs = require('./chunk-X34YWRL5.cjs');
24
24
 
25
25
 
26
26
  var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
@@ -828,7 +828,7 @@ function createSectionShared() {
828
828
  function createXmlParser(warnings) {
829
829
  return new (0, _xmldom.DOMParser)({
830
830
  onError(level, msg2) {
831
- if (level === "fatalError") throw new (0, _chunkFUB2BGXVcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
831
+ if (level === "fatalError") throw new (0, _chunkW7JHJQ2Ocjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
832
832
  _optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
833
833
  }
834
834
  });
@@ -850,10 +850,10 @@ async function extractHwpxStyles(zip, decompressed) {
850
850
  const xml = await file.async("text");
851
851
  if (decompressed) {
852
852
  decompressed.total += xml.length * 2;
853
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
853
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
854
854
  }
855
855
  const parser = createXmlParser();
856
- const doc = parser.parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, xml), "text/xml");
856
+ const doc = parser.parseFromString(_chunkW7JHJQ2Ocjs.stripDtd.call(void 0, xml), "text/xml");
857
857
  if (!doc.documentElement) continue;
858
858
  parseCharProperties(doc, result.charProperties);
859
859
  parseStyleElements(doc, result.styles);
@@ -1075,7 +1075,7 @@ function resolveParaHeading(paraEl, ctx) {
1075
1075
  return { prefix, headingLevel };
1076
1076
  }
1077
1077
  async function parseHwpxDocument(buffer, options) {
1078
- _chunkFUB2BGXVcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
1078
+ _chunkW7JHJQ2Ocjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
1079
1079
  let zip;
1080
1080
  try {
1081
1081
  zip = await _jszip2.default.loadAsync(buffer);
@@ -1084,7 +1084,7 @@ async function parseHwpxDocument(buffer, options) {
1084
1084
  }
1085
1085
  const actualEntryCount = Object.keys(zip.files).length;
1086
1086
  if (actualEntryCount > MAX_ZIP_ENTRIES) {
1087
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1087
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1088
1088
  }
1089
1089
  const manifestFile = zip.file("META-INF/manifest.xml");
1090
1090
  if (manifestFile) {
@@ -1096,7 +1096,7 @@ async function parseHwpxDocument(buffer, options) {
1096
1096
  return comResultToParseResult(pages, pageCount, warnings2);
1097
1097
  }
1098
1098
  }
1099
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
1099
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
1100
1100
  }
1101
1101
  }
1102
1102
  const decompressed = { total: 0 };
@@ -1105,9 +1105,9 @@ async function parseHwpxDocument(buffer, options) {
1105
1105
  const styleMap = await extractHwpxStyles(zip, decompressed);
1106
1106
  const warnings = [];
1107
1107
  const sectionPaths = await resolveSectionPaths(zip);
1108
- if (sectionPaths.length === 0) throw new (0, _chunkFUB2BGXVcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1108
+ if (sectionPaths.length === 0) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1109
1109
  metadata.pageCount = sectionPaths.length;
1110
- const pageFilter = _optionalChain([options, 'optionalAccess', _12 => _12.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
1110
+ const pageFilter = _optionalChain([options, 'optionalAccess', _12 => _12.pages]) ? _chunkX34YWRL5cjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
1111
1111
  const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
1112
1112
  const blocks = [];
1113
1113
  const shared = createSectionShared();
@@ -1119,12 +1119,12 @@ async function parseHwpxDocument(buffer, options) {
1119
1119
  try {
1120
1120
  const xml = await file.async("text");
1121
1121
  decompressed.total += xml.length * 2;
1122
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1122
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1123
1123
  blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
1124
1124
  parsedSections++;
1125
1125
  _optionalChain([options, 'optionalAccess', _13 => _13.onProgress, 'optionalCall', _14 => _14(parsedSections, totalTarget)]);
1126
1126
  } catch (secErr) {
1127
- if (secErr instanceof _chunkFUB2BGXVcjs.KordocError) throw secErr;
1127
+ if (secErr instanceof _chunkW7JHJQ2Ocjs.KordocError) throw secErr;
1128
1128
  warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
1129
1129
  }
1130
1130
  }
@@ -1132,7 +1132,7 @@ async function parseHwpxDocument(buffer, options) {
1132
1132
  const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
1133
1133
  detectHwpxHeadings(blocks, styleMap);
1134
1134
  const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
1135
- const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
1135
+ const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks);
1136
1136
  return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
1137
1137
  }
1138
1138
  function applyPageText(blocks, shared) {
@@ -1221,13 +1221,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1221
1221
  let found = false;
1222
1222
  const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
1223
1223
  for (const path of allCandidates) {
1224
- if (_chunkFUB2BGXVcjs.isPathTraversal.call(void 0, path)) continue;
1224
+ if (_chunkW7JHJQ2Ocjs.isPathTraversal.call(void 0, path)) continue;
1225
1225
  const file = zip.file(path);
1226
1226
  if (!file) continue;
1227
1227
  try {
1228
1228
  const data = await file.async("uint8array");
1229
1229
  decompressed.total += data.length;
1230
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1230
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1231
1231
  const actualPath = path;
1232
1232
  const ext = actualPath.includes(".") ? actualPath.split(".").pop() || "png" : "png";
1233
1233
  const mimeType = imageExtToMime(ext);
@@ -1240,7 +1240,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1240
1240
  found = true;
1241
1241
  break;
1242
1242
  } catch (err) {
1243
- if (err instanceof _chunkFUB2BGXVcjs.KordocError) throw err;
1243
+ if (err instanceof _chunkW7JHJQ2Ocjs.KordocError) throw err;
1244
1244
  }
1245
1245
  }
1246
1246
  if (!found) {
@@ -1261,7 +1261,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
1261
1261
  const xml = await file.async("text");
1262
1262
  if (decompressed) {
1263
1263
  decompressed.total += xml.length * 2;
1264
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1264
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1265
1265
  }
1266
1266
  parseDublinCoreMetadata(xml, metadata);
1267
1267
  if (metadata.title || metadata.author) return;
@@ -1271,7 +1271,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
1271
1271
  }
1272
1272
  function parseDublinCoreMetadata(xml, metadata) {
1273
1273
  const parser = createXmlParser();
1274
- const doc = parser.parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, xml), "text/xml");
1274
+ const doc = parser.parseFromString(_chunkW7JHJQ2Ocjs.stripDtd.call(void 0, xml), "text/xml");
1275
1275
  if (!doc.documentElement) return;
1276
1276
  const getText = (tagNames) => {
1277
1277
  for (const tag of tagNames) {
@@ -1331,7 +1331,7 @@ function extractFromBrokenZip(buffer) {
1331
1331
  }
1332
1332
  const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
1333
1333
  const name = new TextDecoder().decode(nameBytes);
1334
- if (_chunkFUB2BGXVcjs.isPathTraversal.call(void 0, name)) {
1334
+ if (_chunkW7JHJQ2Ocjs.isPathTraversal.call(void 0, name)) {
1335
1335
  pos = fileStart + compSize;
1336
1336
  continue;
1337
1337
  }
@@ -1349,16 +1349,16 @@ function extractFromBrokenZip(buffer) {
1349
1349
  continue;
1350
1350
  }
1351
1351
  totalDecompressed += content.length * 2;
1352
- if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1352
+ if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1353
1353
  sectionNum++;
1354
1354
  blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
1355
1355
  } catch (e13) {
1356
1356
  continue;
1357
1357
  }
1358
1358
  }
1359
- if (blocks.length === 0) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1359
+ if (blocks.length === 0) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1360
1360
  applyPageText(blocks, shared);
1361
- const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
1361
+ const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks);
1362
1362
  return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
1363
1363
  }
1364
1364
  async function resolveSectionPaths(zip) {
@@ -1376,7 +1376,7 @@ async function resolveSectionPaths(zip) {
1376
1376
  }
1377
1377
  function parseSectionPathsFromManifest(xml) {
1378
1378
  const parser = createXmlParser();
1379
- const doc = parser.parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, xml), "text/xml");
1379
+ const doc = parser.parseFromString(_chunkW7JHJQ2Ocjs.stripDtd.call(void 0, xml), "text/xml");
1380
1380
  const items = doc.getElementsByTagName("opf:item");
1381
1381
  const spine = doc.getElementsByTagName("opf:itemref");
1382
1382
  const isSectionId = (id) => /^s/i.test(id) || id.toLowerCase().includes("section");
@@ -1424,9 +1424,9 @@ function detectHwpxHeadings(blocks, styleMap) {
1424
1424
  let level = 0;
1425
1425
  if (baseFontSize > 0 && _optionalChain([block, 'access', _25 => _25.style, 'optionalAccess', _26 => _26.fontSize])) {
1426
1426
  const ratio = block.style.fontSize / baseFontSize;
1427
- if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H1) level = 1;
1428
- else if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H2) level = 2;
1429
- else if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H3) level = 3;
1427
+ if (ratio >= _chunkW7JHJQ2Ocjs.HEADING_RATIO_H1) level = 1;
1428
+ else if (ratio >= _chunkW7JHJQ2Ocjs.HEADING_RATIO_H2) level = 2;
1429
+ else if (ratio >= _chunkW7JHJQ2Ocjs.HEADING_RATIO_H3) level = 3;
1430
1430
  }
1431
1431
  const compactText = text.replace(/\s+/g, "");
1432
1432
  if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
@@ -1439,7 +1439,7 @@ function detectHwpxHeadings(blocks, styleMap) {
1439
1439
  }
1440
1440
  }
1441
1441
  function buildTableWithCellMeta(state) {
1442
- const table = _chunkFUB2BGXVcjs.buildTable.call(void 0, state.rows);
1442
+ const table = _chunkW7JHJQ2Ocjs.buildTable.call(void 0, state.rows);
1443
1443
  if (state.caption) table.caption = state.caption;
1444
1444
  const claimed = /* @__PURE__ */ new Set();
1445
1445
  for (const row of state.rows) {
@@ -1482,7 +1482,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1482
1482
  const cell = parentTable.cell;
1483
1483
  (cell.blocks ??= []).push(block);
1484
1484
  cell.hasStructure = true;
1485
- let flat = _chunkFUB2BGXVcjs.convertTableToText.call(void 0, newTable.rows);
1485
+ let flat = _chunkW7JHJQ2Ocjs.convertTableToText.call(void 0, newTable.rows);
1486
1486
  if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
1487
1487
  if (flat) cell.text += (cell.text ? "\n" : "") + flat;
1488
1488
  } else {
@@ -1492,7 +1492,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1492
1492
  }
1493
1493
  function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
1494
1494
  const parser = createXmlParser(warnings);
1495
- const doc = parser.parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, xml), "text/xml");
1495
+ const doc = parser.parseFromString(_chunkW7JHJQ2Ocjs.stripDtd.call(void 0, xml), "text/xml");
1496
1496
  if (!doc.documentElement) return [];
1497
1497
  const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
1498
1498
  ctx.shared.track.deleteDepth = 0;
@@ -1583,8 +1583,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
1583
1583
  const cs = isNaN(rawCs) ? 1 : rawCs;
1584
1584
  const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
1585
1585
  const rs = isNaN(rawRs) ? 1 : rawRs;
1586
- tableCtx.cell.colSpan = clampSpan(cs, _chunkFUB2BGXVcjs.MAX_COLS);
1587
- tableCtx.cell.rowSpan = clampSpan(rs, _chunkFUB2BGXVcjs.MAX_ROWS);
1586
+ tableCtx.cell.colSpan = clampSpan(cs, _chunkW7JHJQ2Ocjs.MAX_COLS);
1587
+ tableCtx.cell.rowSpan = clampSpan(rs, _chunkW7JHJQ2Ocjs.MAX_ROWS);
1588
1588
  }
1589
1589
  break;
1590
1590
  case "p": {
@@ -1806,7 +1806,7 @@ function extractHyperlinkHref(fieldBegin) {
1806
1806
  let url = (ch.textContent || "").trim();
1807
1807
  if (!url) continue;
1808
1808
  url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
1809
- const safe = _chunkFUB2BGXVcjs.sanitizeHref.call(void 0, url);
1809
+ const safe = _chunkW7JHJQ2Ocjs.sanitizeHref.call(void 0, url);
1810
1810
  if (safe) return safe;
1811
1811
  }
1812
1812
  return void 0;
@@ -1941,7 +1941,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
1941
1941
  case "hyperlink": {
1942
1942
  const url = child.getAttribute("url") || child.getAttribute("href") || "";
1943
1943
  if (url) {
1944
- const safe = _chunkFUB2BGXVcjs.sanitizeHref.call(void 0, url);
1944
+ const safe = _chunkW7JHJQ2Ocjs.sanitizeHref.call(void 0, url);
1945
1945
  if (safe) href = safe;
1946
1946
  }
1947
1947
  walk(child);
@@ -2131,7 +2131,7 @@ function decompressStream(data) {
2131
2131
  return _zlib.inflateRawSync.call(void 0, data, opts);
2132
2132
  }
2133
2133
  function parseFileHeader(data) {
2134
- if (data.length < 40) throw new (0, _chunkFUB2BGXVcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2134
+ if (data.length < 40) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2135
2135
  const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
2136
2136
  return {
2137
2137
  signature: sig,
@@ -3655,7 +3655,7 @@ function parseHwp5Document(buffer, options) {
3655
3655
  lenientCfb = parseLenientCfb(buffer);
3656
3656
  warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
3657
3657
  } catch (e20) {
3658
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3658
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3659
3659
  }
3660
3660
  }
3661
3661
  const findStream = (path) => {
@@ -3666,11 +3666,11 @@ function parseHwp5Document(buffer, options) {
3666
3666
  return lenientCfb.findStream(path);
3667
3667
  };
3668
3668
  const headerData = findStream("/FileHeader");
3669
- if (!headerData) throw new (0, _chunkFUB2BGXVcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3669
+ if (!headerData) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3670
3670
  const header = parseFileHeader(headerData);
3671
- if (header.signature !== "HWP Document File") throw new (0, _chunkFUB2BGXVcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3672
- if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3673
- if (header.flags & FLAG_DRM) throw new (0, _chunkFUB2BGXVcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3671
+ if (header.signature !== "HWP Document File") throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3672
+ if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3673
+ if (header.flags & FLAG_DRM) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3674
3674
  const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
3675
3675
  const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
3676
3676
  const metadata = {
@@ -3679,9 +3679,9 @@ function parseHwp5Document(buffer, options) {
3679
3679
  if (cfb) extractHwp5Metadata(cfb, metadata);
3680
3680
  const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
3681
3681
  const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
3682
- if (sections.length === 0) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3682
+ if (sections.length === 0) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3683
3683
  metadata.pageCount = sections.length;
3684
- const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
3684
+ const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkX34YWRL5cjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
3685
3685
  const totalTarget = pageFilter ? pageFilter.size : sections.length;
3686
3686
  const bodyBlocks = [];
3687
3687
  const doc = createHwp5DocState();
@@ -3693,25 +3693,25 @@ function parseHwp5Document(buffer, options) {
3693
3693
  const sectionData = sections[si];
3694
3694
  const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
3695
3695
  totalDecompressed += data.length;
3696
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3696
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3697
3697
  const records = readRecords(data);
3698
3698
  const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
3699
3699
  bodyBlocks.push(...sectionBlocks);
3700
3700
  parsedSections++;
3701
3701
  _optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
3702
3702
  } catch (secErr) {
3703
- if (secErr instanceof _chunkFUB2BGXVcjs.KordocError) throw secErr;
3703
+ if (secErr instanceof _chunkW7JHJQ2Ocjs.KordocError) throw secErr;
3704
3704
  warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
3705
3705
  }
3706
3706
  }
3707
3707
  const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
3708
3708
  const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
3709
- const flatBlocks = _chunkFUB2BGXVcjs.flattenLayoutTables.call(void 0, blocks);
3709
+ const flatBlocks = _chunkW7JHJQ2Ocjs.flattenLayoutTables.call(void 0, blocks);
3710
3710
  if (docInfo) {
3711
3711
  detectHwp5Headings(flatBlocks, docInfo);
3712
3712
  }
3713
3713
  const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
3714
- const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, flatBlocks);
3714
+ const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, flatBlocks);
3715
3715
  return { markdown, blocks: flatBlocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
3716
3716
  }
3717
3717
  function parseDocInfoStream(cfb, compressed) {
@@ -3771,9 +3771,9 @@ function detectHwp5Headings(blocks, docInfo) {
3771
3771
  let level = 0;
3772
3772
  if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
3773
3773
  const ratio = block.style.fontSize / baseFontSize;
3774
- if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H1) level = 1;
3775
- else if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H2) level = 2;
3776
- else if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H3) level = 3;
3774
+ if (ratio >= _chunkW7JHJQ2Ocjs.HEADING_RATIO_H1) level = 1;
3775
+ else if (ratio >= _chunkW7JHJQ2Ocjs.HEADING_RATIO_H2) level = 2;
3776
+ else if (ratio >= _chunkW7JHJQ2Ocjs.HEADING_RATIO_H3) level = 3;
3777
3777
  }
3778
3778
  if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
3779
3779
  if (level === 0) level = 2;
@@ -3858,7 +3858,7 @@ function findSectionsLenient(lcfb, compressed) {
3858
3858
  if (!raw) break;
3859
3859
  const content = compressed ? decompressStream(raw) : raw;
3860
3860
  totalDecompressed += content.length;
3861
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3861
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3862
3862
  sections.push({ idx: i, content });
3863
3863
  }
3864
3864
  if (sections.length === 0) {
@@ -3870,7 +3870,7 @@ function findSectionsLenient(lcfb, compressed) {
3870
3870
  if (raw) {
3871
3871
  const content = compressed ? decompressStream(raw) : raw;
3872
3872
  totalDecompressed += content.length;
3873
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3873
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3874
3874
  sections.push({ idx, content });
3875
3875
  }
3876
3876
  }
@@ -3887,7 +3887,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
3887
3887
  try {
3888
3888
  const content = decryptViewText(raw, compressed);
3889
3889
  totalDecompressed += content.length;
3890
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3890
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3891
3891
  sections.push({ idx: i, content });
3892
3892
  } catch (e25) {
3893
3893
  break;
@@ -3990,7 +3990,7 @@ function parseParagraph(records, start, end, ctx) {
3990
3990
  const ctrl = ctrls[r.ctrlIdx];
3991
3991
  if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
3992
3992
  if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
3993
- const href = _chunkFUB2BGXVcjs.sanitizeHref.call(void 0, ctrl.href);
3993
+ const href = _chunkW7JHJQ2Ocjs.sanitizeHref.call(void 0, ctrl.href);
3994
3994
  if (!href) continue;
3995
3995
  const anchor = text.slice(r.start, r.end);
3996
3996
  if (!anchor.trim()) continue;
@@ -4223,8 +4223,8 @@ function parseTableControl(ctrl, records, ctx) {
4223
4223
  let tableIdx = -1;
4224
4224
  for (let i2 = childStart; i2 < childEnd; i2++) {
4225
4225
  if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
4226
- rows = Math.min(records[i2].data.readUInt16LE(4), _chunkFUB2BGXVcjs.MAX_ROWS);
4227
- cols = Math.min(records[i2].data.readUInt16LE(6), _chunkFUB2BGXVcjs.MAX_COLS);
4226
+ rows = Math.min(records[i2].data.readUInt16LE(4), _chunkW7JHJQ2Ocjs.MAX_ROWS);
4227
+ cols = Math.min(records[i2].data.readUInt16LE(6), _chunkW7JHJQ2Ocjs.MAX_COLS);
4228
4228
  tableIdx = i2;
4229
4229
  break;
4230
4230
  }
@@ -4273,7 +4273,7 @@ function parseTableControl(ctrl, records, ctx) {
4273
4273
  return table2;
4274
4274
  }
4275
4275
  const cellRows = arrangeCells(rows, cols, cells);
4276
- const table = _chunkFUB2BGXVcjs.buildTable.call(void 0, cellRows);
4276
+ const table = _chunkW7JHJQ2Ocjs.buildTable.call(void 0, cellRows);
4277
4277
  if (caption && table.rows > 0) table.caption = caption;
4278
4278
  return table.rows > 0 ? table : null;
4279
4279
  }
@@ -4290,8 +4290,8 @@ function parseCell(records, lhIdx, end, ctx) {
4290
4290
  rowAddr = rec.data.readUInt16LE(10);
4291
4291
  const cs = rec.data.readUInt16LE(12);
4292
4292
  const rs = rec.data.readUInt16LE(14);
4293
- if (cs > 0) colSpan = Math.min(cs, _chunkFUB2BGXVcjs.MAX_COLS);
4294
- if (rs > 0) rowSpan = Math.min(rs, _chunkFUB2BGXVcjs.MAX_ROWS);
4293
+ if (cs > 0) colSpan = Math.min(cs, _chunkW7JHJQ2Ocjs.MAX_COLS);
4294
+ if (rs > 0) rowSpan = Math.min(rs, _chunkW7JHJQ2Ocjs.MAX_ROWS);
4295
4295
  }
4296
4296
  const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
4297
4297
  const parts = [];
@@ -4301,7 +4301,7 @@ function parseCell(records, lhIdx, end, ctx) {
4301
4301
  parts.push(`![image](hwp5bin:${b.text})`);
4302
4302
  hasStructure = true;
4303
4303
  } else if (b.type === "table" && b.table) {
4304
- const flat = _chunkFUB2BGXVcjs.convertTableToText.call(void 0, b.table.cells);
4304
+ const flat = _chunkW7JHJQ2Ocjs.convertTableToText.call(void 0, b.table.cells);
4305
4305
  if (flat) parts.push(flat);
4306
4306
  hasStructure = true;
4307
4307
  } else if (b.text) {
@@ -16735,7 +16735,7 @@ function getTextContent(el) {
16735
16735
  return _nullishCoalesce(_optionalChain([el, 'access', _79 => _79.textContent, 'optionalAccess', _80 => _80.trim, 'call', _81 => _81()]), () => ( ""));
16736
16736
  }
16737
16737
  function parseXml(text) {
16738
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, text), "text/xml");
16738
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkW7JHJQ2Ocjs.stripDtd.call(void 0, text), "text/xml");
16739
16739
  }
16740
16740
  function parseSharedStrings(xml) {
16741
16741
  const doc = parseXml(xml);
@@ -16879,7 +16879,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16879
16879
  cellRows.push(row);
16880
16880
  }
16881
16881
  if (cellRows.length > 0) {
16882
- const table = _chunkFUB2BGXVcjs.buildTable.call(void 0, cellRows);
16882
+ const table = _chunkW7JHJQ2Ocjs.buildTable.call(void 0, cellRows);
16883
16883
  if (table.rows > 0) {
16884
16884
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
16885
16885
  }
@@ -16887,12 +16887,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16887
16887
  return blocks;
16888
16888
  }
16889
16889
  async function parseXlsxDocument(buffer, options) {
16890
- _chunkFUB2BGXVcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16890
+ _chunkW7JHJQ2Ocjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16891
16891
  const zip = await _jszip2.default.loadAsync(buffer);
16892
16892
  const warnings = [];
16893
16893
  const workbookFile = zip.file("xl/workbook.xml");
16894
16894
  if (!workbookFile) {
16895
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16895
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16896
16896
  }
16897
16897
  let sharedStrings = [];
16898
16898
  const ssFile = zip.file("xl/sharedStrings.xml");
@@ -16901,7 +16901,7 @@ async function parseXlsxDocument(buffer, options) {
16901
16901
  }
16902
16902
  const sheets = parseWorkbook(await workbookFile.async("text"));
16903
16903
  if (sheets.length === 0) {
16904
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16904
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16905
16905
  }
16906
16906
  let relsMap = /* @__PURE__ */ new Map();
16907
16907
  const relsFile = zip.file("xl/_rels/workbook.xml.rels");
@@ -16910,7 +16910,7 @@ async function parseXlsxDocument(buffer, options) {
16910
16910
  }
16911
16911
  let pageFilter = null;
16912
16912
  if (_optionalChain([options, 'optionalAccess', _84 => _84.pages])) {
16913
- const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
16913
+ const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-TPIRSA3J.cjs")));
16914
16914
  pageFilter = parsePageRange2(options.pages, sheets.length);
16915
16915
  }
16916
16916
  const blocks = [];
@@ -16973,7 +16973,7 @@ async function parseXlsxDocument(buffer, options) {
16973
16973
  } catch (e26) {
16974
16974
  }
16975
16975
  }
16976
- const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
16976
+ const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks);
16977
16977
  return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
16978
16978
  }
16979
16979
 
@@ -17380,11 +17380,11 @@ function processGlobals(records) {
17380
17380
  let encrypted = false;
17381
17381
  const firstBof = records[0];
17382
17382
  if (!firstBof || firstBof.opcode !== OP_BOF) {
17383
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17383
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17384
17384
  }
17385
17385
  const bof = decodeBof(firstBof.data);
17386
17386
  if (!bof || bof.dt !== DT_GLOBALS) {
17387
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17387
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17388
17388
  }
17389
17389
  let i = 1;
17390
17390
  while (i < records.length) {
@@ -17499,7 +17499,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
17499
17499
  cellRows.push(row);
17500
17500
  }
17501
17501
  if (cellRows.length > 0) {
17502
- const table = _chunkFUB2BGXVcjs.buildTable.call(void 0, cellRows);
17502
+ const table = _chunkW7JHJQ2Ocjs.buildTable.call(void 0, cellRows);
17503
17503
  if (table.rows > 0) {
17504
17504
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
17505
17505
  }
@@ -17512,21 +17512,21 @@ async function parseXlsDocument(buffer, options) {
17512
17512
  try {
17513
17513
  cfb = parseLenientCfb(buf);
17514
17514
  } catch (e) {
17515
- throw new (0, _chunkFUB2BGXVcjs.KordocError)(
17515
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)(
17516
17516
  `XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
17517
17517
  );
17518
17518
  }
17519
17519
  const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
17520
17520
  if (!wb) {
17521
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17521
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17522
17522
  }
17523
17523
  const records = readRecords2(wb);
17524
17524
  if (records.length === 0) {
17525
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17525
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17526
17526
  }
17527
17527
  const firstBof = decodeBof(records[0].data);
17528
17528
  if (firstBof && firstBof.vers !== 1536) {
17529
- throw new (0, _chunkFUB2BGXVcjs.KordocError)(
17529
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)(
17530
17530
  `XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
17531
17531
  );
17532
17532
  }
@@ -17548,7 +17548,7 @@ async function parseXlsDocument(buffer, options) {
17548
17548
  const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
17549
17549
  let pageFilter = null;
17550
17550
  if (_optionalChain([options, 'optionalAccess', _89 => _89.pages])) {
17551
- const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
17551
+ const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-TPIRSA3J.cjs")));
17552
17552
  pageFilter = parsePageRange2(options.pages, totalSheets);
17553
17553
  }
17554
17554
  const allBlocks = [];
@@ -17586,7 +17586,7 @@ async function parseXlsDocument(buffer, options) {
17586
17586
  pageCount: totalSheets
17587
17587
  };
17588
17588
  return {
17589
- markdown: _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, allBlocks),
17589
+ markdown: _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, allBlocks),
17590
17590
  blocks: allBlocks,
17591
17591
  metadata,
17592
17592
  warnings: warnings.length > 0 ? warnings : void 0
@@ -17971,20 +17971,32 @@ function isDisplayMath(el) {
17971
17971
 
17972
17972
  // src/docx/parser.ts
17973
17973
  var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
17974
- function getChildElements(parent, localName2) {
17974
+ function matchesLocal(el, localName2) {
17975
+ return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _95 => _95.tagName, 'optionalAccess', _96 => _96.endsWith, 'call', _97 => _97(`:${localName2}`)]), () => ( false)));
17976
+ }
17977
+ function effectiveChildElements(parent) {
17975
17978
  const result = [];
17976
17979
  const children = parent.childNodes;
17977
17980
  for (let i = 0; i < children.length; i++) {
17978
17981
  const node = children[i];
17979
- if (node.nodeType === 1) {
17980
- const el = node;
17981
- if (el.localName === localName2 || _optionalChain([el, 'access', _95 => _95.tagName, 'optionalAccess', _96 => _96.endsWith, 'call', _97 => _97(`:${localName2}`)])) {
17982
- result.push(el);
17982
+ if (node.nodeType !== 1) continue;
17983
+ const el = node;
17984
+ if (matchesLocal(el, "sdt")) {
17985
+ for (let j = 0; j < el.childNodes.length; j++) {
17986
+ const c = el.childNodes[j];
17987
+ if (c.nodeType === 1 && matchesLocal(c, "sdtContent")) {
17988
+ result.push(...effectiveChildElements(c));
17989
+ }
17983
17990
  }
17991
+ } else {
17992
+ result.push(el);
17984
17993
  }
17985
17994
  }
17986
17995
  return result;
17987
17996
  }
17997
+ function getChildElements(parent, localName2) {
17998
+ return effectiveChildElements(parent).filter((el) => matchesLocal(el, localName2));
17999
+ }
17988
18000
  function findElements(parent, localName2) {
17989
18001
  const result = [];
17990
18002
  const walk = (node) => {
@@ -18012,7 +18024,7 @@ function getAttr(el, localName2) {
18012
18024
  return null;
18013
18025
  }
18014
18026
  function parseXml2(text) {
18015
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, text), "text/xml");
18027
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkW7JHJQ2Ocjs.stripDtd.call(void 0, text), "text/xml");
18016
18028
  }
18017
18029
  function parseStyles(xml) {
18018
18030
  const doc = parseXml2(xml);
@@ -18331,12 +18343,12 @@ async function extractImages(zip, rels, doc) {
18331
18343
  return { blocks, images };
18332
18344
  }
18333
18345
  async function parseDocxDocument(buffer, options) {
18334
- _chunkFUB2BGXVcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18346
+ _chunkW7JHJQ2Ocjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18335
18347
  const zip = await _jszip2.default.loadAsync(buffer);
18336
18348
  const warnings = [];
18337
18349
  const docFile = zip.file("word/document.xml");
18338
18350
  if (!docFile) {
18339
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18351
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18340
18352
  }
18341
18353
  let rels = /* @__PURE__ */ new Map();
18342
18354
  const relsFile = zip.file("word/_rels/document.xml.rels");
@@ -18371,15 +18383,12 @@ async function parseDocxDocument(buffer, options) {
18371
18383
  const doc = parseXml2(docXml);
18372
18384
  const body = findElements(doc, "body");
18373
18385
  if (body.length === 0) {
18374
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18386
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18375
18387
  }
18376
18388
  const blocks = [];
18377
18389
  const bodyEl = body[0];
18378
- const children = bodyEl.childNodes;
18379
- for (let i = 0; i < children.length; i++) {
18380
- const node = children[i];
18381
- if (node.nodeType !== 1) continue;
18382
- const el = node;
18390
+ const topLevel = effectiveChildElements(bodyEl);
18391
+ for (const el of topLevel) {
18383
18392
  const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _118 => _118.tagName, 'optionalAccess', _119 => _119.split, 'call', _120 => _120(":"), 'access', _121 => _121.pop, 'call', _122 => _122()])));
18384
18393
  if (localName2 === "p") {
18385
18394
  const block = parseParagraph2(el, styles, numbering, footnotes, rels);
@@ -18411,7 +18420,7 @@ async function parseDocxDocument(buffer, options) {
18411
18420
  }
18412
18421
  }
18413
18422
  const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
18414
- const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
18423
+ const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks);
18415
18424
  return {
18416
18425
  markdown,
18417
18426
  blocks,
@@ -18434,7 +18443,7 @@ function parseHwpmlDocument(buffer, options) {
18434
18443
  }
18435
18444
  const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
18436
18445
  const normalized = text.replace(/&nbsp;/g, "&#160;");
18437
- const xml = _chunkFUB2BGXVcjs.stripDtd.call(void 0, normalized);
18446
+ const xml = _chunkW7JHJQ2Ocjs.stripDtd.call(void 0, normalized);
18438
18447
  const warnings = [];
18439
18448
  const parser = new (0, _xmldom.DOMParser)({
18440
18449
  onError: (_level, msg2) => {
@@ -18462,7 +18471,7 @@ function parseHwpmlDocument(buffer, options) {
18462
18471
  return { markdown: "", blocks: [], metadata, warnings };
18463
18472
  }
18464
18473
  const blocks = [];
18465
- const pageFilter = _optionalChain([options, 'optionalAccess', _123 => _123.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
18474
+ const pageFilter = _optionalChain([options, 'optionalAccess', _123 => _123.pages]) ? _chunkX34YWRL5cjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
18466
18475
  let sectionIdx = 0;
18467
18476
  const children = body.childNodes;
18468
18477
  for (let i = 0; i < children.length; i++) {
@@ -18474,7 +18483,7 @@ function parseHwpmlDocument(buffer, options) {
18474
18483
  parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
18475
18484
  }
18476
18485
  const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
18477
- const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
18486
+ const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks);
18478
18487
  return {
18479
18488
  markdown,
18480
18489
  blocks,
@@ -18616,7 +18625,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
18616
18625
  const cellRows = grid.map(
18617
18626
  (row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
18618
18627
  );
18619
- const table = _chunkFUB2BGXVcjs.buildTable.call(void 0, cellRows);
18628
+ const table = _chunkW7JHJQ2Ocjs.buildTable.call(void 0, cellRows);
18620
18629
  blocks.push({ type: "table", table, pageNumber: sectionNum });
18621
18630
  }
18622
18631
  function extractCellText(cellEl) {
@@ -18885,8 +18894,9 @@ function extractFromTable(table) {
18885
18894
  if (table.cols >= 2) {
18886
18895
  for (let r = 0; r < table.rows; r++) {
18887
18896
  for (let c = 0; c < table.cols - 1; c++) {
18888
- const labelCell = table.cells[r][c];
18889
- const valueCell = table.cells[r][c + 1];
18897
+ const labelCell = _optionalChain([table, 'access', _125 => _125.cells, 'access', _126 => _126[r], 'optionalAccess', _127 => _127[c]]);
18898
+ const valueCell = _optionalChain([table, 'access', _128 => _128.cells, 'access', _129 => _129[r], 'optionalAccess', _130 => _130[c + 1]]);
18899
+ if (!labelCell || !valueCell) continue;
18890
18900
  if (isLabelCell(labelCell.text)) {
18891
18901
  fields.push({
18892
18902
  label: labelCell.text.trim().replace(/[::]\s*$/, ""),
@@ -18907,8 +18917,8 @@ function extractFromTable(table) {
18907
18917
  if (allLabels) {
18908
18918
  for (let r = 1; r < table.rows; r++) {
18909
18919
  for (let c = 0; c < table.cols; c++) {
18910
- const label = headerRow[c].text.trim();
18911
- const value = table.cells[r][c].text.trim();
18920
+ const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _131 => _131[c], 'optionalAccess', _132 => _132.text, 'access', _133 => _133.trim, 'call', _134 => _134()]), () => ( ""));
18921
+ const value = _nullishCoalesce(_optionalChain([table, 'access', _135 => _135.cells, 'access', _136 => _136[r], 'optionalAccess', _137 => _137[c], 'optionalAccess', _138 => _138.text, 'access', _139 => _139.trim, 'call', _140 => _140()]), () => ( ""));
18912
18922
  if (label && value) {
18913
18923
  fields.push({ label, value, row: r, col: c });
18914
18924
  }
@@ -19000,7 +19010,7 @@ function fillFormFields(blocks, values) {
19000
19010
  if (block.type !== "table" || !block.table) continue;
19001
19011
  for (let r = 0; r < block.table.rows; r++) {
19002
19012
  for (let c = 0; c < block.table.cols; c++) {
19003
- const cell = _optionalChain([block, 'access', _125 => _125.table, 'access', _126 => _126.cells, 'access', _127 => _127[r], 'optionalAccess', _128 => _128[c]]);
19013
+ const cell = _optionalChain([block, 'access', _141 => _141.table, 'access', _142 => _142.cells, 'access', _143 => _143[r], 'optionalAccess', _144 => _144[c]]);
19004
19014
  if (!cell) continue;
19005
19015
  const result = fillInCellPatterns(cell.text, normalizedValues, matchedLabels);
19006
19016
  if (result) {
@@ -19039,7 +19049,7 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
19039
19049
  const matchKey = findMatchingKey(normalizedCellLabel, values);
19040
19050
  if (matchKey === void 0) continue;
19041
19051
  const newValue = values.get(matchKey);
19042
- if (_optionalChain([patternFilledCells, 'optionalAccess', _129 => _129.has, 'call', _130 => _130(`${r},${c + 1}`)])) {
19052
+ if (_optionalChain([patternFilledCells, 'optionalAccess', _145 => _145.has, 'call', _146 => _146(`${r},${c + 1}`)])) {
19043
19053
  valueCell.text = newValue + " " + valueCell.text;
19044
19054
  } else {
19045
19055
  valueCell.text = newValue;
@@ -19062,15 +19072,18 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
19062
19072
  if (!allLabels) return;
19063
19073
  for (let r = 1; r < table.rows; r++) {
19064
19074
  for (let c = 0; c < table.cols; c++) {
19065
- const headerLabel = normalizeLabel(headerRow[c].text);
19075
+ const headerCell = headerRow[c];
19076
+ const valueCell = _optionalChain([table, 'access', _147 => _147.cells, 'access', _148 => _148[r], 'optionalAccess', _149 => _149[c]]);
19077
+ if (!headerCell || !valueCell) continue;
19078
+ const headerLabel = normalizeLabel(headerCell.text);
19066
19079
  const matchKey = findMatchingKey(headerLabel, values);
19067
19080
  if (matchKey === void 0) continue;
19068
19081
  if (matchedLabels.has(matchKey)) continue;
19069
19082
  const newValue = values.get(matchKey);
19070
- table.cells[r][c].text = newValue;
19083
+ valueCell.text = newValue;
19071
19084
  matchedLabels.add(matchKey);
19072
19085
  filled.push({
19073
- label: headerRow[c].text.trim(),
19086
+ label: headerCell.text.trim(),
19074
19087
  value: newValue,
19075
19088
  row: r,
19076
19089
  col: c
@@ -19639,19 +19652,19 @@ function parseCentralDirectory(buf) {
19639
19652
  }
19640
19653
  }
19641
19654
  }
19642
- if (eocdOffset < 0) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19655
+ if (eocdOffset < 0) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19643
19656
  const totalEntries = view.getUint16(eocdOffset + 10, true);
19644
19657
  const cdSize = view.getUint32(eocdOffset + 12, true);
19645
19658
  const cdOffset = view.getUint32(eocdOffset + 16, true);
19646
- if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19659
+ if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19647
19660
  if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
19648
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19661
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19649
19662
  }
19650
19663
  const decoder = new TextDecoder("utf-8");
19651
19664
  const entries = [];
19652
19665
  let pos = cdOffset;
19653
19666
  for (let i = 0; i < totalEntries; i++) {
19654
- if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
19667
+ if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
19655
19668
  const flags = view.getUint16(pos + 8, true);
19656
19669
  const method = view.getUint16(pos + 10, true);
19657
19670
  const crc = view.getUint32(pos + 16, true);
@@ -19662,7 +19675,7 @@ function parseCentralDirectory(buf) {
19662
19675
  const commentLen = view.getUint16(pos + 32, true);
19663
19676
  const localOffset = view.getUint32(pos + 42, true);
19664
19677
  if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
19665
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19678
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19666
19679
  }
19667
19680
  const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
19668
19681
  const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
@@ -19691,7 +19704,7 @@ function patchZipEntries(original, replacements) {
19691
19704
  const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
19692
19705
  const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
19693
19706
  for (const name of replacements.keys()) {
19694
- if (!entries.some((e) => e.name === name)) throw new (0, _chunkFUB2BGXVcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
19707
+ if (!entries.some((e) => e.name === name)) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
19695
19708
  }
19696
19709
  const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
19697
19710
  const segments = [];
@@ -19709,7 +19722,7 @@ function patchZipEntries(original, replacements) {
19709
19722
  offset += seg.length;
19710
19723
  continue;
19711
19724
  }
19712
- if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
19725
+ if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
19713
19726
  const nameLen = view.getUint16(e.localOffset + 26, true);
19714
19727
  const extraLen = view.getUint16(e.localOffset + 28, true);
19715
19728
  const headerLen = 30 + nameLen + extraLen;
@@ -19764,7 +19777,7 @@ async function fillHwpx(hwpxBuffer, values) {
19764
19777
  const zip = await _jszip2.default.loadAsync(hwpxBuffer);
19765
19778
  const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
19766
19779
  if (sectionPaths.length === 0) {
19767
- throw new (0, _chunkFUB2BGXVcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19780
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19768
19781
  }
19769
19782
  const normalizedValues = normalizeValues(values);
19770
19783
  const matchedLabels = /* @__PURE__ */ new Set();
@@ -19912,7 +19925,7 @@ async function fillHwpx(hwpxBuffer, values) {
19912
19925
  }
19913
19926
  for (const para of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
19914
19927
  const existing = ledger.get(para);
19915
- if (_optionalChain([existing, 'optionalAccess', _131 => _131.fullText]) !== void 0) continue;
19928
+ if (_optionalChain([existing, 'optionalAccess', _150 => _150.fullText]) !== void 0) continue;
19916
19929
  const text = matchText(para);
19917
19930
  for (const seg of scanInlineSegments(text)) {
19918
19931
  const matchKey = findMatchingKey(normalizeLabel(seg.label), normalizedValues);
@@ -20124,21 +20137,21 @@ var PARA_LIST = 7;
20124
20137
  var DEFAULT_TEXT_COLOR = "#000000";
20125
20138
  function resolveTheme(theme) {
20126
20139
  return {
20127
- h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _132 => _132.headingColors, 'optionalAccess', _133 => _133[1]]), () => ( DEFAULT_TEXT_COLOR)),
20128
- h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _134 => _134.headingColors, 'optionalAccess', _135 => _135[2]]), () => ( DEFAULT_TEXT_COLOR)),
20129
- h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _136 => _136.headingColors, 'optionalAccess', _137 => _137[3]]), () => ( DEFAULT_TEXT_COLOR)),
20130
- h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _138 => _138.headingColors, 'optionalAccess', _139 => _139[4]]), () => ( _optionalChain([theme, 'optionalAccess', _140 => _140.headingColors, 'optionalAccess', _141 => _141[3]]))), () => ( DEFAULT_TEXT_COLOR)),
20131
- body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _142 => _142.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
20132
- quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _143 => _143.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
20140
+ h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _151 => _151.headingColors, 'optionalAccess', _152 => _152[1]]), () => ( DEFAULT_TEXT_COLOR)),
20141
+ h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _153 => _153.headingColors, 'optionalAccess', _154 => _154[2]]), () => ( DEFAULT_TEXT_COLOR)),
20142
+ h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _155 => _155.headingColors, 'optionalAccess', _156 => _156[3]]), () => ( DEFAULT_TEXT_COLOR)),
20143
+ h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _157 => _157.headingColors, 'optionalAccess', _158 => _158[4]]), () => ( _optionalChain([theme, 'optionalAccess', _159 => _159.headingColors, 'optionalAccess', _160 => _160[3]]))), () => ( DEFAULT_TEXT_COLOR)),
20144
+ body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _161 => _161.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
20145
+ quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _162 => _162.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
20133
20146
  /** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
20134
- hasQuoteOption: _optionalChain([theme, 'optionalAccess', _144 => _144.quoteColor]) !== void 0,
20135
- tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _145 => _145.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _146 => _146.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
20136
- tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _147 => _147.tableHeaderBold])
20147
+ hasQuoteOption: _optionalChain([theme, 'optionalAccess', _163 => _163.quoteColor]) !== void 0,
20148
+ tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _164 => _164.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _165 => _165.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
20149
+ tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _166 => _166.tableHeaderBold])
20137
20150
  };
20138
20151
  }
20139
20152
  async function markdownToHwpx(markdown, options) {
20140
- const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _148 => _148.theme]));
20141
- const gongmun = _optionalChain([options, 'optionalAccess', _149 => _149.gongmun]) ? resolveGongmun(options.gongmun) : null;
20153
+ const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _167 => _167.theme]));
20154
+ const gongmun = _optionalChain([options, 'optionalAccess', _168 => _168.gongmun]) ? resolveGongmun(options.gongmun) : null;
20142
20155
  const blocks = parseMarkdownToBlocks(markdown);
20143
20156
  const sectionXml = blocksToSectionXml(blocks, theme, gongmun);
20144
20157
  const zip = new (0, _jszip2.default)();
@@ -20417,7 +20430,7 @@ ${base.join("\n")}
20417
20430
  </hh:paraProperties>`;
20418
20431
  }
20419
20432
  function generateHeaderXml(theme, gongmun) {
20420
- const bodyFace = _optionalChain([gongmun, 'optionalAccess', _150 => _150.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
20433
+ const bodyFace = _optionalChain([gongmun, 'optionalAccess', _169 => _169.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
20421
20434
  const charPropsXml = buildCharProperties(theme, gongmun);
20422
20435
  const paraPropsXml = buildParaProperties(gongmun);
20423
20436
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
@@ -20616,8 +20629,8 @@ function blocksToSectionXml(blocks, theme, gongmun) {
20616
20629
  case "list_item": {
20617
20630
  if (gongmun && gongmunList) {
20618
20631
  const info = gongmunList.get(blockIdx);
20619
- const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _151 => _151.depth]), () => ( 0));
20620
- const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _152 => _152.marker]), () => ( ""));
20632
+ const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _170 => _170.depth]), () => ( 0));
20633
+ const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _171 => _171.marker]), () => ( ""));
20621
20634
  const content = block.text || "";
20622
20635
  const text = marker2 ? `${marker2} ${content}` : content;
20623
20636
  xml = generateParagraph(text, GONGMUN_LIST_BASE + depth);
@@ -20914,7 +20927,7 @@ function escapeGfm(text) {
20914
20927
  }
20915
20928
  var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
20916
20929
  function sanitizeText(text) {
20917
- let result = _chunkFUB2BGXVcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
20930
+ let result = _chunkW7JHJQ2Ocjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
20918
20931
  if (result.length <= 30 && result.includes(" ")) {
20919
20932
  const tokens = result.split(" ");
20920
20933
  const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-힯ㄱ-ㆎ]/.test(t)).length;
@@ -20944,7 +20957,7 @@ function replicateGfmTable(table) {
20944
20957
  for (let r = 0; r < numRows; r++) {
20945
20958
  for (let c = 0; c < numCols; c++) {
20946
20959
  if (skip.has(`${r},${c}`)) continue;
20947
- const cell = _optionalChain([cells, 'access', _153 => _153[r], 'optionalAccess', _154 => _154[c]]);
20960
+ const cell = _optionalChain([cells, 'access', _172 => _172[r], 'optionalAccess', _173 => _173[c]]);
20948
20961
  if (!cell) continue;
20949
20962
  display[r][c] = {
20950
20963
  text: escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
@@ -20998,7 +21011,7 @@ function unescapeGfmCell(text) {
20998
21011
  return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\~/g, "~");
20999
21012
  }
21000
21013
  function replicateCellInnerHtml(cell) {
21001
- if (_optionalChain([cell, 'access', _155 => _155.blocks, 'optionalAccess', _156 => _156.length])) {
21014
+ if (_optionalChain([cell, 'access', _174 => _174.blocks, 'optionalAccess', _175 => _175.length])) {
21002
21015
  return cell.blocks.map((b) => {
21003
21016
  if (b.type === "table" && b.table) {
21004
21017
  const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
@@ -21037,7 +21050,7 @@ function replicateHtmlTable(table) {
21037
21050
  const rowCells = [];
21038
21051
  for (let c = 0; c < numCols; c++) {
21039
21052
  if (skip.has(`${r},${c}`)) continue;
21040
- const cell = _optionalChain([cells, 'access', _157 => _157[r], 'optionalAccess', _158 => _158[c]]);
21053
+ const cell = _optionalChain([cells, 'access', _176 => _176[r], 'optionalAccess', _177 => _177[c]]);
21041
21054
  if (!cell) continue;
21042
21055
  for (let dr = 0; dr < cell.rowSpan; dr++) {
21043
21056
  for (let dc = 0; dc < cell.colSpan; dc++) {
@@ -21083,8 +21096,8 @@ function parseHtmlTable(raw) {
21083
21096
  }
21084
21097
  } else {
21085
21098
  if (!isClose) {
21086
- const cs = parseInt(_optionalChain([attrs, 'access', _159 => _159.match, 'call', _160 => _160(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _161 => _161[1]]) || "1", 10);
21087
- const rs = parseInt(_optionalChain([attrs, 'access', _162 => _162.match, 'call', _163 => _163(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _164 => _164[1]]) || "1", 10);
21099
+ const cs = parseInt(_optionalChain([attrs, 'access', _178 => _178.match, 'call', _179 => _179(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _180 => _180[1]]) || "1", 10);
21100
+ const rs = parseInt(_optionalChain([attrs, 'access', _181 => _181.match, 'call', _182 => _182(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _183 => _183[1]]) || "1", 10);
21088
21101
  cellStart = m.index + m[0].length;
21089
21102
  cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
21090
21103
  } else if (cellStart >= 0 && cellInfo && currentRow) {
@@ -21246,9 +21259,9 @@ function patchHtmlTableRaw(table, scanTable, origRaw, editedRaw, ctx, skip, dept
21246
21259
  return applied;
21247
21260
  }
21248
21261
  function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
21249
- const irCell = _optionalChain([table, 'access', _165 => _165.cells, 'access', _166 => _166[oc.gridR], 'optionalAccess', _167 => _167[oc.gridC]]);
21262
+ const irCell = _optionalChain([table, 'access', _184 => _184.cells, 'access', _185 => _185[oc.gridR], 'optionalAccess', _186 => _186[oc.gridC]]);
21250
21263
  const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
21251
- const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _168 => _168.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
21264
+ const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _187 => _187.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
21252
21265
  if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
21253
21266
  return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
21254
21267
  }
@@ -21316,7 +21329,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
21316
21329
  };
21317
21330
  const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
21318
21331
  if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
21319
- const irCell = _optionalChain([table, 'access', _169 => _169.cells, 'access', _170 => _170[gridR], 'optionalAccess', _171 => _171[gridC]]);
21332
+ const irCell = _optionalChain([table, 'access', _188 => _188.cells, 'access', _189 => _189[gridR], 'optionalAccess', _190 => _190[gridC]]);
21320
21333
  const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
21321
21334
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
21322
21335
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -21339,7 +21352,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
21339
21352
  if (newLines.length === 0) return 0;
21340
21353
  const target = cell.paragraphs[0];
21341
21354
  if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
21342
- const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _172 => _172.scans, 'access', _173 => _173[target.sectionIndex], 'optionalAccess', _174 => _174.xml]));
21355
+ const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _191 => _191.scans, 'access', _192 => _192[target.sectionIndex], 'optionalAccess', _193 => _193.xml]));
21343
21356
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
21344
21357
  splices.push(...sp);
21345
21358
  sectionIndex = target.sectionIndex;
@@ -21360,7 +21373,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
21360
21373
  }
21361
21374
  for (let i = 0; i < nonEmpty.length; i++) {
21362
21375
  if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
21363
- const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _175 => _175.scans, 'access', _176 => _176[nonEmpty[i].sectionIndex], 'optionalAccess', _177 => _177.xml]));
21376
+ const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _194 => _194.scans, 'access', _195 => _195[nonEmpty[i].sectionIndex], 'optionalAccess', _196 => _196.xml]));
21364
21377
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
21365
21378
  splices.push(...sp);
21366
21379
  sectionIndex = nonEmpty[i].sectionIndex;
@@ -21482,7 +21495,7 @@ async function patchHwpx(original, editedMarkdown, options) {
21482
21495
  }
21483
21496
  }
21484
21497
  let verification;
21485
- if (_optionalChain([options, 'optionalAccess', _178 => _178.verify]) !== false) {
21498
+ if (_optionalChain([options, 'optionalAccess', _197 => _197.verify]) !== false) {
21486
21499
  try {
21487
21500
  const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
21488
21501
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -21500,17 +21513,17 @@ function buildOrigUnits(blocks) {
21500
21513
  let chunk;
21501
21514
  if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
21502
21515
  const next = blocks[i + 1];
21503
- if (_optionalChain([next, 'optionalAccess', _179 => _179.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
21504
- chunk = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
21516
+ if (_optionalChain([next, 'optionalAccess', _198 => _198.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
21517
+ chunk = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
21505
21518
  } else {
21506
- chunk = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, [block]);
21519
+ chunk = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, [block]);
21507
21520
  }
21508
21521
  if (chunk) {
21509
21522
  const subUnits = splitMarkdownUnits(chunk);
21510
21523
  const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
21511
21524
  for (let s = 0; s < subUnits.length; s++) {
21512
21525
  const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
21513
- if (block.type === "table" && _optionalChain([block, 'access', _180 => _180.table, 'optionalAccess', _181 => _181.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
21526
+ if (block.type === "table" && _optionalChain([block, 'access', _199 => _199.table, 'optionalAccess', _200 => _200.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
21514
21527
  u.role = "caption";
21515
21528
  }
21516
21529
  units.push(u);
@@ -21687,7 +21700,7 @@ function handleModifiedUnit(orig, edited, ctx) {
21687
21700
  }
21688
21701
  function patchParagraphUnit(block, orig, edited, ctx, skip) {
21689
21702
  const mapping = ctx.paraMap.get(orig.blockIdx);
21690
- if (!_optionalChain([mapping, 'optionalAccess', _182 => _182.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
21703
+ if (!_optionalChain([mapping, 'optionalAccess', _201 => _201.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
21691
21704
  if (block.text && block.text.includes("\n")) {
21692
21705
  return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
21693
21706
  }
@@ -21718,7 +21731,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
21718
21731
  if (sanitizeText(newPlain) !== newPlain) {
21719
21732
  return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
21720
21733
  }
21721
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _183 => _183.scans, 'access', _184 => _184[mapping.para.sectionIndex], 'optionalAccess', _185 => _185.xml]));
21734
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _202 => _202.scans, 'access', _203 => _203[mapping.para.sectionIndex], 'optionalAccess', _204 => _204.xml]));
21722
21735
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
21723
21736
  ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
21724
21737
  return 1;
@@ -21886,7 +21899,7 @@ var Surgeon = (_class3 = class {
21886
21899
  /** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
21887
21900
  findEntry(path) {
21888
21901
  const parts = path.replace(/^\//, "").split("/");
21889
- let scope = _nullishCoalesce(_optionalChain([this, 'access', _186 => _186.entries, 'access', _187 => _187[0], 'optionalAccess', _188 => _188.child]), () => ( -1));
21902
+ let scope = _nullishCoalesce(_optionalChain([this, 'access', _205 => _205.entries, 'access', _206 => _206[0], 'optionalAccess', _207 => _207.child]), () => ( -1));
21890
21903
  let current;
21891
21904
  for (const part of parts) {
21892
21905
  const search = (idx) => {
@@ -22092,7 +22105,7 @@ function readRecordsStrict(stream) {
22092
22105
  function serializeRecords(recs, repl) {
22093
22106
  const parts = [];
22094
22107
  for (let i = 0; i < recs.length; i++) {
22095
- const data = _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _189 => _189.get, 'call', _190 => _190(i)]), () => ( recs[i].data));
22108
+ const data = _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _208 => _208.get, 'call', _209 => _209(i)]), () => ( recs[i].data));
22096
22109
  const ext = data.length >= 4095;
22097
22110
  const header = Buffer.alloc(ext ? 8 : 4);
22098
22111
  header.writeUInt32LE((recs[i].tagId & 1023 | (recs[i].level & 1023) << 10 | (ext ? 4095 : data.length) << 20) >>> 0, 0);
@@ -22215,7 +22228,7 @@ async function patchHwp(original, editedMarkdown, options) {
22215
22228
  return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
22216
22229
  }
22217
22230
  const fhEntry = CFB2.find(cfb, "/FileHeader");
22218
- if (!_optionalChain([fhEntry, 'optionalAccess', _191 => _191.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
22231
+ if (!_optionalChain([fhEntry, 'optionalAccess', _210 => _210.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
22219
22232
  let flags;
22220
22233
  try {
22221
22234
  flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
@@ -22237,7 +22250,7 @@ async function patchHwp(original, editedMarkdown, options) {
22237
22250
  const scans = [];
22238
22251
  for (let i = 0; i < sectionPaths.length; i++) {
22239
22252
  const entry = CFB2.find(cfb, sectionPaths[i]);
22240
- if (!_optionalChain([entry, 'optionalAccess', _192 => _192.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
22253
+ if (!_optionalChain([entry, 'optionalAccess', _211 => _211.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
22241
22254
  let stream;
22242
22255
  try {
22243
22256
  stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
@@ -22250,14 +22263,7 @@ async function patchHwp(original, editedMarkdown, options) {
22250
22263
  const editedUnits = splitMarkdownUnits(editedMarkdown);
22251
22264
  const pairs = alignUnits(origUnits.map((u) => u.raw), editedUnits.map((u) => u.raw));
22252
22265
  const paraMap = resolveParaMappings(origBlocks, scans);
22253
- const scanTables = scans.flatMap((s) => s.tables);
22254
- const obTableOrdinals = /* @__PURE__ */ new Map();
22255
- {
22256
- let ordinal = 0;
22257
- for (let i = 0; i < origBlocks.length; i++) {
22258
- if (origBlocks[i].type === "table" && origBlocks[i].table) obTableOrdinals.set(i, ordinal++);
22259
- }
22260
- }
22266
+ const tableMap = resolveTableMappings(origBlocks, scans.flatMap((s) => s.tables));
22261
22267
  for (const [oi, ei] of pairs) {
22262
22268
  if (oi !== null && ei !== null) {
22263
22269
  const orig = origUnits[oi];
@@ -22267,8 +22273,7 @@ async function patchHwp(original, editedMarkdown, options) {
22267
22273
  origBlocks,
22268
22274
  paraMap,
22269
22275
  scans,
22270
- scanTables,
22271
- obTableOrdinals,
22276
+ tableMap,
22272
22277
  skipped
22273
22278
  });
22274
22279
  } else if (oi !== null) {
@@ -22296,7 +22301,7 @@ async function patchHwp(original, editedMarkdown, options) {
22296
22301
  }
22297
22302
  }
22298
22303
  let verification;
22299
- if (_optionalChain([options, 'optionalAccess', _193 => _193.verify]) !== false) {
22304
+ if (_optionalChain([options, 'optionalAccess', _212 => _212.verify]) !== false) {
22300
22305
  try {
22301
22306
  const reparsed = parseHwp5Document(Buffer.from(data));
22302
22307
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -22353,6 +22358,46 @@ function resolveParaMappings(blocks, scans) {
22353
22358
  }
22354
22359
  return result;
22355
22360
  }
22361
+ function resolveTableMappings(blocks, scanTables) {
22362
+ const result = /* @__PURE__ */ new Map();
22363
+ let si = 0;
22364
+ for (let i = 0; i < blocks.length; i++) {
22365
+ const table = blocks[i].table;
22366
+ if (blocks[i].type !== "table" || !table) continue;
22367
+ const cands = [];
22368
+ for (let k = si; k < scanTables.length; k++) {
22369
+ if (scanTables[k].rows === table.rows && scanTables[k].cols === table.cols) cands.push(k);
22370
+ }
22371
+ if (cands.length === 0) continue;
22372
+ let pick = cands[0];
22373
+ if (cands.length > 1) {
22374
+ let best = tableContentScore(table, scanTables[cands[0]]);
22375
+ for (let ci = 1; ci < cands.length; ci++) {
22376
+ const sc = tableContentScore(table, scanTables[cands[ci]]);
22377
+ if (sc > best) {
22378
+ best = sc;
22379
+ pick = cands[ci];
22380
+ }
22381
+ }
22382
+ }
22383
+ result.set(i, scanTables[pick]);
22384
+ si = pick + 1;
22385
+ }
22386
+ return result;
22387
+ }
22388
+ function tableContentScore(irTable, scanTable) {
22389
+ let matched = 0;
22390
+ for (const [key, scanCell] of scanTable.cells) {
22391
+ const comma = key.indexOf(",");
22392
+ const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
22393
+ const irCell = _optionalChain([irTable, 'access', _213 => _213.cells, 'access', _214 => _214[r], 'optionalAccess', _215 => _215[c]]);
22394
+ if (!irCell) continue;
22395
+ const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
22396
+ const b = normForMatch(stripCellTokens(irCell.text));
22397
+ if (a && a === b) matched++;
22398
+ }
22399
+ return matched;
22400
+ }
22356
22401
  function handleModified(orig, edited, ctx) {
22357
22402
  const block = ctx.origBlocks[orig.blockIdx];
22358
22403
  const skip = (reason) => {
@@ -22365,12 +22410,10 @@ function handleModified(orig, edited, ctx) {
22365
22410
  if (orig.fragment) return skip("\uBB38\uB2E8 \uBD84\uC808(\uAC15\uC81C \uC904\uBC14\uAFC8/\uBCD1\uD569 \uC720\uB2DB) \u2014 \uBD80\uBD84 \uC218\uC815\uC740 \uBBF8\uC9C0\uC6D0 (v1)");
22366
22411
  if (block.type === "table" && block.table) {
22367
22412
  if (orig.kind !== edited.kind) return skip("\uD45C \u2194 \uBE44\uD45C \uBCC0\uACBD\uC740 \uBBF8\uC9C0\uC6D0 (\uD45C \uAD6C\uC870 \uBCC0\uACBD)");
22368
- if (ctx.obTableOrdinals.size !== ctx.scanTables.length) return skip("\uD45C \uAC1C\uC218 \uBD88\uC77C\uCE58 \u2014 \uC18C\uC2A4\uB9F5 \uC2E0\uB8B0 \uBD88\uAC00");
22369
- const ordinal = ctx.obTableOrdinals.get(orig.blockIdx);
22370
- const scanTable = ordinal !== void 0 ? ctx.scanTables[ordinal] : void 0;
22371
- if (!scanTable) return skip("\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
22413
+ const scanTable = ctx.tableMap.get(orig.blockIdx);
22414
+ if (!scanTable) return skip("\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 \u2014 \uD45C \uAC1C\uC218/\uAD6C\uC870 \uBD88\uC77C\uCE58\uB85C \uC2E0\uB8B0 \uBD88\uAC00");
22372
22415
  if (orig.kind === "gfm-table") return patchGfmCells(scanTable, orig, edited, ctx, skip);
22373
- if (orig.kind === "html-table") return skip("HTML \uD45C(\uBCD1\uD569/\uC904\uBC14\uAFC8 \uC140) \uC218\uC815\uC740 HWP5 \uBBF8\uC9C0\uC6D0 (v1)");
22416
+ if (orig.kind === "html-table") return patchHtmlCells5(block.table, scanTable, orig, edited, ctx, skip);
22374
22417
  return patchTextChunk5(block.table, scanTable, orig, edited, ctx, skip);
22375
22418
  }
22376
22419
  if ((block.type === "paragraph" || block.type === "heading") && orig.kind === "text" && edited.kind === "text") {
@@ -22380,7 +22423,7 @@ function handleModified(orig, edited, ctx) {
22380
22423
  }
22381
22424
  function patchParagraph(block, orig, edited, ctx, skip) {
22382
22425
  const mapping = ctx.paraMap.get(orig.blockIdx);
22383
- if (!_optionalChain([mapping, 'optionalAccess', _194 => _194.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
22426
+ if (!_optionalChain([mapping, 'optionalAccess', _216 => _216.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
22384
22427
  if (block.text && block.text.includes("\n")) {
22385
22428
  return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
22386
22429
  }
@@ -22427,35 +22470,87 @@ function patchGfmCells(scanTable, orig, edited, ctx, skip) {
22427
22470
  ctx.skipped.push({ reason, before: summarize(origRows[r][c]), after: summarize(editedRows[r][c]) });
22428
22471
  return 0;
22429
22472
  };
22430
- const before = gfmCellToPlain(origRows[r][c]);
22431
- const after = gfmCellToPlain(editedRows[r][c]);
22432
- if (before === null || after === null) {
22433
- cellSkip("\uC11C\uC2DD/\uB9C1\uD06C/\uC774\uBBF8\uC9C0 \uD3EC\uD568 \uC140 \uC218\uC815\uC740 \uBBF8\uC9C0\uC6D0 (v1)");
22434
- continue;
22435
- }
22436
- if (after.includes("\n")) {
22437
- cellSkip("\uC140 \uB0B4 \uC904\uBC14\uAFC8 \uCD94\uAC00\uB294 \uBBF8\uC9C0\uC6D0 (v1)");
22438
- continue;
22439
- }
22440
22473
  const cell = scanTable.cells.get(`${r},${c}`);
22441
22474
  if (!cell) {
22442
22475
  cellSkip("\uBCD1\uD569 \uC601\uC5ED \uC140 \u2014 \uC575\uCEE4 \uC140\uC774 \uC544\uB2C8\uBBC0\uB85C \uBBF8\uC9C0\uC6D0");
22443
22476
  continue;
22444
22477
  }
22445
- if (cell.paras.length !== 1) {
22446
- cellSkip("\uBCF5\uC218 \uBB38\uB2E8 \uC140 \uC218\uC815\uC740 \uBBF8\uC9C0\uC6D0 (v1)");
22478
+ const beforeParts = origRows[r][c].split(/<br\s*\/?>/i);
22479
+ const afterParts = editedRows[r][c].split(/<br\s*\/?>/i);
22480
+ if (beforeParts.length !== cell.paras.length || afterParts.length !== cell.paras.length) {
22481
+ cellSkip("\uC140 \uBB38\uB2E8 \uC218 \uBCC0\uACBD \u2014 \uBBF8\uC9C0\uC6D0 (\uBB38\uB2E8 \uCD94\uAC00/\uC0AD\uC81C)");
22447
22482
  continue;
22448
22483
  }
22449
- const para = cell.paras[0];
22450
- if (normForMatch(para.rawText) !== normForMatch(before)) {
22451
- cellSkip("\uC140 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58 \u2014 \uC18C\uC2A4\uB9F5 \uC2E0\uB8B0 \uBD88\uAC00");
22452
- continue;
22484
+ for (let k = 0; k < cell.paras.length; k++) {
22485
+ const before = gfmCellToPlain(beforeParts[k]);
22486
+ const after = gfmCellToPlain(afterParts[k]);
22487
+ if (before === null || after === null) {
22488
+ cellSkip("\uC11C\uC2DD/\uB9C1\uD06C/\uC774\uBBF8\uC9C0 \uD3EC\uD568 \uC140 \uC218\uC815\uC740 \uBBF8\uC9C0\uC6D0 (v1)");
22489
+ break;
22490
+ }
22491
+ if (before === after) continue;
22492
+ if (after.includes("\n")) {
22493
+ cellSkip("\uC140 \uB0B4 \uC904\uBC14\uAFC8 \uCD94\uAC00\uB294 \uBBF8\uC9C0\uC6D0 (v1)");
22494
+ break;
22495
+ }
22496
+ const para = cell.paras[k];
22497
+ if (normForMatch(para.rawText) !== normForMatch(before)) {
22498
+ cellSkip("\uC140 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58 \u2014 \uC18C\uC2A4\uB9F5 \uC2E0\uB8B0 \uBD88\uAC00");
22499
+ break;
22500
+ }
22501
+ if (sanitizeText(after) !== after) {
22502
+ cellSkip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uBBF8\uC9C0\uC6D0");
22503
+ break;
22504
+ }
22505
+ applied += stageParaPatch(ctx.scans[para.sectionIndex], para, after, cellSkip);
22453
22506
  }
22454
- if (sanitizeText(after) !== after) {
22455
- cellSkip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uBBF8\uC9C0\uC6D0");
22507
+ }
22508
+ }
22509
+ return applied;
22510
+ }
22511
+ function extractImgTags5(inner) {
22512
+ return (inner.match(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi) || []).join(" ");
22513
+ }
22514
+ function patchHtmlCells5(table, scanTable, orig, edited, ctx, skip) {
22515
+ if (replicateTableToHtml(table) !== orig.raw) return skip("\uD45C \uC88C\uD45C \uC7AC\uD604 \uBD88\uC77C\uCE58 \u2014 \uB9E4\uD551 \uC2E0\uB8B0 \uBD88\uAC00");
22516
+ const replica = replicateHtmlTable(table);
22517
+ const origRows = parseHtmlTable(orig.raw);
22518
+ if (!origRows || origRows.length !== replica.length || origRows.some((r, i) => r.cells.length !== replica[i].cells.length || r.cells.some((c, j) => c.inner !== replica[i].cells[j].inner))) {
22519
+ return skip("\uC140 \uACBD\uACC4 \uBAA8\uD638 (\uB9AC\uD130\uB7F4 \uD0DC\uADF8 \uC758\uC2EC) \u2014 \uB9E4\uD551 \uC2E0\uB8B0 \uBD88\uAC00");
22520
+ }
22521
+ const editedRows = parseHtmlTable(edited.raw);
22522
+ if (!editedRows) return skip("\uD3B8\uC9D1\uB41C HTML \uD45C \uD30C\uC2F1 \uC2E4\uD328");
22523
+ if (editedRows.length !== replica.length) return skip("\uD45C \uD589 \uCD94\uAC00/\uC0AD\uC81C\uB294 \uBBF8\uC9C0\uC6D0 (\uD45C \uAD6C\uC870 \uBCC0\uACBD)");
22524
+ let applied = 0;
22525
+ for (let r = 0; r < replica.length; r++) {
22526
+ if (editedRows[r].cells.length !== replica[r].cells.length) {
22527
+ skip(`\uD45C ${r + 1}\uD589 \uC140 \uC218 \uBCC0\uACBD\uC740 \uBBF8\uC9C0\uC6D0`);
22528
+ continue;
22529
+ }
22530
+ for (let c = 0; c < replica[r].cells.length; c++) {
22531
+ const oc = replica[r].cells[c];
22532
+ const ec = editedRows[r].cells[c];
22533
+ if (oc.colSpan !== ec.colSpan || oc.rowSpan !== ec.rowSpan) {
22534
+ skip("\uC140 \uBCD1\uD569(colspan/rowspan) \uBCC0\uACBD\uC740 \uBBF8\uC9C0\uC6D0");
22456
22535
  continue;
22457
22536
  }
22458
- applied += stageParaPatch(ctx.scans[para.sectionIndex], para, after, cellSkip);
22537
+ if (oc.inner === ec.inner) continue;
22538
+ const origContent = htmlCellInnerToLines(oc.inner);
22539
+ const editedContent = htmlCellInnerToLines(ec.inner);
22540
+ if (origContent.hadNonText || editedContent.hadNonText) {
22541
+ if (extractImgTags5(oc.inner) !== extractImgTags5(ec.inner)) {
22542
+ skip("\uC140 \uB0B4 \uC774\uBBF8\uC9C0 \uBCC0\uACBD\uC740 \uBBF8\uC9C0\uC6D0");
22543
+ continue;
22544
+ }
22545
+ if (extractTopLevelTables(oc.inner).join("\n") !== extractTopLevelTables(ec.inner).join("\n")) {
22546
+ skip("\uC140 \uB0B4 \uC911\uCCA9\uD45C \uC218\uC815\uC740 HWP5 \uBBF8\uC9C0\uC6D0 (v1)");
22547
+ continue;
22548
+ }
22549
+ }
22550
+ if (origContent.lines.join("\n") !== editedContent.lines.join("\n")) {
22551
+ const newLines = editedContent.lines.map((l) => unescapeGfm(l));
22552
+ applied += applyCellEdit5(table, scanTable, oc.gridR, oc.gridC, newLines, ctx, oc.inner, ec.inner, origContent.lines.length);
22553
+ }
22459
22554
  }
22460
22555
  }
22461
22556
  return applied;
@@ -22507,7 +22602,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
22507
22602
  };
22508
22603
  const cell = scanTable.cells.get(`${gridR},${gridC}`);
22509
22604
  if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
22510
- const irCell = _optionalChain([table, 'access', _195 => _195.cells, 'access', _196 => _196[gridR], 'optionalAccess', _197 => _197[gridC]]);
22605
+ const irCell = _optionalChain([table, 'access', _217 => _217.cells, 'access', _218 => _218[gridR], 'optionalAccess', _219 => _219[gridC]]);
22511
22606
  const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
22512
22607
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
22513
22608
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -22547,15 +22642,103 @@ function gfmCellToPlain(md2) {
22547
22642
  let t = md2.trim();
22548
22643
  const bold = t.match(/^\*\*([\s\S]+)\*\*$/);
22549
22644
  if (bold) t = bold[1];
22550
- if (/[*`]|!\[|\]\(|<(?!br\s*\/?>)/i.test(t)) return null;
22645
+ if (/[*`]|!\[|\]\(/.test(t)) return null;
22646
+ if (/<(?!br\s*\/?>)[a-zA-Z/]/i.test(t)) return null;
22551
22647
  return unescapeGfm(unescapeGfmCell(t));
22552
22648
  }
22553
- var PARA_BREAK = Buffer.from([13, 0]);
22649
+ function splitParaText(data) {
22650
+ const toks = [];
22651
+ let i = 0;
22652
+ while (i + 1 < data.length) {
22653
+ const ch = data.readUInt16LE(i);
22654
+ const start = i;
22655
+ i += 2;
22656
+ if (ch >= 32) {
22657
+ let units = 1;
22658
+ if (ch >= 55296 && ch <= 56319 && i + 1 < data.length) {
22659
+ const lo = data.readUInt16LE(i);
22660
+ if (lo >= 56320 && lo <= 57343) {
22661
+ i += 2;
22662
+ units = 2;
22663
+ }
22664
+ }
22665
+ toks.push({ start, end: i, units, plain: true, visible: true });
22666
+ continue;
22667
+ }
22668
+ switch (ch) {
22669
+ case 0:
22670
+ case 24:
22671
+ case 25:
22672
+ case 30:
22673
+ case 31:
22674
+ toks.push({ start, end: i, units: 1, plain: false, visible: true });
22675
+ break;
22676
+ case 9:
22677
+ if (i + 14 <= data.length) i += 14;
22678
+ toks.push({ start, end: i, units: 1, plain: false, visible: true });
22679
+ break;
22680
+ case 13:
22681
+ toks.push({ start, end: i, units: 1, plain: false, visible: false });
22682
+ break;
22683
+ case 10:
22684
+ if (i + 16 <= data.length && data.readUInt16LE(i) === 11) {
22685
+ i += 16;
22686
+ toks.push({ start, end: i, units: 1, plain: false, visible: false });
22687
+ } else {
22688
+ if (i + 14 <= data.length) i += 14;
22689
+ toks.push({ start, end: i, units: 1, plain: false, visible: true });
22690
+ }
22691
+ break;
22692
+ default: {
22693
+ const ext = isExtendedOnlyCtrlChar(ch);
22694
+ const inl = ch >= 4 && ch <= 9 || ch >= 19 && ch <= 20;
22695
+ if ((ext || inl) && i + 14 <= data.length) i += 14;
22696
+ toks.push({ start, end: i, units: 1, plain: false, visible: false });
22697
+ break;
22698
+ }
22699
+ }
22700
+ }
22701
+ if (i !== data.length) return null;
22702
+ let firstP = -1, lastP = -1;
22703
+ for (let k = 0; k < toks.length; k++) if (toks[k].plain) {
22704
+ if (firstP < 0) firstP = k;
22705
+ lastP = k;
22706
+ }
22707
+ if (firstP < 0) return null;
22708
+ for (let k = firstP; k <= lastP; k++) if (!toks[k].plain) return null;
22709
+ for (let k = 0; k < firstP; k++) if (toks[k].visible) return null;
22710
+ for (let k = lastP + 1; k < toks.length; k++) if (toks[k].visible) return null;
22711
+ const prefixEnd = toks[firstP].start;
22712
+ const coreEnd = toks[lastP].end;
22713
+ const prefixUnits = prefixEnd / 2;
22714
+ const suffixUnits = (data.length - coreEnd) / 2;
22715
+ return {
22716
+ prefix: data.subarray(0, prefixEnd),
22717
+ prefixUnits,
22718
+ core: data.subarray(prefixEnd, coreEnd).toString("utf16le"),
22719
+ suffix: data.subarray(coreEnd),
22720
+ suffixUnits
22721
+ };
22722
+ }
22723
+ function rebuildCharShape(csData, coreStartUnit) {
22724
+ const pairs = [];
22725
+ for (let o = 0; o + 8 <= csData.length; o += 8) pairs.push([csData.readUInt32LE(o), csData.readUInt32LE(o + 4)]);
22726
+ if (pairs.length === 0) return { buf: Buffer.from(csData.subarray(0, 8)), count: 1 };
22727
+ let coreId = pairs[0][1];
22728
+ for (const [p, id] of pairs) if (p <= coreStartUnit) coreId = id;
22729
+ const kept = pairs.filter(([p]) => p < coreStartUnit);
22730
+ if (kept.length === 0 || kept[kept.length - 1][1] !== coreId) kept.push([coreStartUnit, coreId]);
22731
+ const buf = Buffer.alloc(kept.length * 8);
22732
+ kept.forEach(([p, id], k) => {
22733
+ buf.writeUInt32LE(p >>> 0, k * 8);
22734
+ buf.writeUInt32LE(id >>> 0, k * 8 + 4);
22735
+ });
22736
+ return { buf, count: kept.length };
22737
+ }
22554
22738
  function stageParaPatch(scan, para, newPlain, skip) {
22555
22739
  if (!scan.safe) return skip("\uC139\uC158 \uB808\uCF54\uB4DC \uC7AC\uC9C1\uB82C\uD654 \uBD88\uC77C\uCE58 \u2014 \uC548\uC804\uC744 \uC704\uD574 \uC774 \uC139\uC158\uC740 \uBBF8\uC9C0\uC6D0");
22556
22740
  if (para.textIdx === -1) return skip("\uBE48 \uBB38\uB2E8 \uD14D\uC2A4\uD2B8 \uCD94\uAC00\uB294 \uBBF8\uC9C0\uC6D0 (v1)");
22557
22741
  if (para.textIdx === -2) return skip("\uBCF5\uC218 PARA_TEXT \uB808\uCF54\uB4DC \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)");
22558
- if (para.ctrlMask !== 0) return skip("\uCEE8\uD2B8\uB864 \uBB38\uC790 \uD3EC\uD568 \uBB38\uB2E8(\uD0ED/\uAC1C\uCCB4/\uD544\uB4DC/\uD2B9\uC218\uACF5\uBC31) \u2014 \uBBF8\uC9C0\uC6D0 (v1)");
22559
22742
  if (para.rangeTagCount > 0) return skip("\uBC94\uC704 \uD0DC\uADF8(\uD615\uAD11\uD39C/\uAD50\uC815\uBD80\uD638) \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)");
22560
22743
  if (para.charShapeIdx < 0 || para.lineSegIdx < 0) return skip("\uBB38\uB2E8 \uB808\uCF54\uB4DC \uAD6C\uC131 \uBE44\uC815\uD615 \u2014 \uBBF8\uC9C0\uC6D0");
22561
22744
  if (scan.repl.has(para.headerIdx)) return skip("\uB3D9\uC77C \uBB38\uB2E8 \uC911\uBCF5 \uC218\uC815 \u2014 \uCCAB \uC218\uC815\uB9CC \uC801\uC6A9");
@@ -22564,36 +22747,25 @@ function stageParaPatch(scan, para, newPlain, skip) {
22564
22747
  const headerRec = records[para.headerIdx];
22565
22748
  const textRec = records[para.textIdx];
22566
22749
  const charShapeRec = records[para.charShapeIdx];
22567
- const lineSegRec = records[para.lineSegIdx];
22568
- if (charShapeRec.data.length < 8 || lineSegRec.data.length < 36) {
22569
- return skip("CHAR_SHAPE/LINE_SEG \uB808\uCF54\uB4DC \uBE44\uC815\uD615 \u2014 \uBBF8\uC9C0\uC6D0");
22750
+ if (charShapeRec.data.length < 8) {
22751
+ return skip("CHAR_SHAPE \uB808\uCF54\uB4DC \uBE44\uC815\uD615 \u2014 \uBBF8\uC9C0\uC6D0");
22752
+ }
22753
+ const seg = splitParaText(textRec.data);
22754
+ if (!seg) {
22755
+ return skip(para.ctrlMask !== 0 ? "\uCEE8\uD2B8\uB864 \uBB38\uC790(\uD0ED/\uD544\uB4DC/\uD2B9\uC218\uACF5\uBC31 \uB4F1 \uD14D\uC2A4\uD2B8 \uC911\uAC04) \uD3EC\uD568 \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)" : "PARA_TEXT \uC7AC\uAD6C\uC131 \uBD88\uC77C\uCE58 \u2014 \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
22570
22756
  }
22571
- const hadBreak = textRec.data.length >= 2 && textRec.data.readUInt16LE(textRec.data.length - 2) === 13;
22572
- const expect = hadBreak ? Buffer.concat([Buffer.from(para.rawText, "utf16le"), PARA_BREAK]) : Buffer.from(para.rawText, "utf16le");
22573
- if (!expect.equals(textRec.data)) return skip("PARA_TEXT \uC7AC\uAD6C\uC131 \uBD88\uC77C\uCE58 \u2014 \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
22757
+ if (seg.core !== para.rawText) return skip("PARA_TEXT \uC7AC\uAD6C\uC131 \uBD88\uC77C\uCE58 \u2014 \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
22574
22758
  const lead = para.rawText.match(/^\s*/)[0];
22575
22759
  const trail = para.rawText.match(/\s*$/)[0];
22576
22760
  const newRaw = para.rawText.trim() === para.rawText ? newPlain : lead + newPlain + trail;
22577
- const newText = hadBreak ? Buffer.concat([Buffer.from(newRaw, "utf16le"), PARA_BREAK]) : Buffer.from(newRaw, "utf16le");
22761
+ const newText = Buffer.concat([seg.prefix, Buffer.from(newRaw, "utf16le"), seg.suffix]);
22578
22762
  scan.repl.set(para.textIdx, newText);
22579
22763
  const newHeader = Buffer.from(headerRec.data);
22580
- const nChars = newRaw.length + (hadBreak ? 1 : 0);
22764
+ const nChars = seg.prefixUnits + newRaw.length + seg.suffixUnits;
22581
22765
  newHeader.writeUInt32LE((para.nCharsRaw & 2147483648 | nChars) >>> 0, 0);
22582
- if (charShapeRec.data.length > 8) {
22583
- newHeader.writeUInt16LE(1, 12);
22584
- scan.repl.set(para.charShapeIdx, Buffer.from(charShapeRec.data.subarray(0, 8)));
22585
- }
22586
- const csData = _nullishCoalesce(scan.repl.get(para.charShapeIdx), () => ( Buffer.from(charShapeRec.data)));
22587
- if (csData.readUInt32LE(0) !== 0) {
22588
- csData.writeUInt32LE(0, 0);
22589
- scan.repl.set(para.charShapeIdx, csData);
22590
- }
22591
- if (lineSegRec.data.length > 36 || lineSegRec.data.readUInt32LE(0) !== 0) {
22592
- const seg = Buffer.from(lineSegRec.data.subarray(0, 36));
22593
- seg.writeUInt32LE(0, 0);
22594
- newHeader.writeUInt16LE(1, 16);
22595
- scan.repl.set(para.lineSegIdx, seg);
22596
- }
22766
+ const cs = rebuildCharShape(charShapeRec.data, seg.prefixUnits);
22767
+ scan.repl.set(para.charShapeIdx, cs.buf);
22768
+ newHeader.writeUInt16LE(cs.count, 12);
22597
22769
  scan.repl.set(para.headerIdx, newHeader);
22598
22770
  return 1;
22599
22771
  }
@@ -22673,7 +22845,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22673
22845
  const block = st.blocks[blockIndex];
22674
22846
  if (!block) return void 0;
22675
22847
  if (block.type === "paragraph" || block.type === "heading") {
22676
- const para = _optionalChain([st, 'access', _198 => _198.paraMap, 'access', _199 => _199.get, 'call', _200 => _200(blockIndex), 'optionalAccess', _201 => _201.para]);
22848
+ const para = _optionalChain([st, 'access', _220 => _220.paraMap, 'access', _221 => _221.get, 'call', _222 => _222(blockIndex), 'optionalAccess', _223 => _223.para]);
22677
22849
  if (!para) return void 0;
22678
22850
  return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
22679
22851
  }
@@ -22698,7 +22870,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22698
22870
  if (block.text && block.text.includes("\n")) {
22699
22871
  return { capability: "locked", reason: "\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)" };
22700
22872
  }
22701
- if (!_optionalChain([st, 'access', _202 => _202.paraMap, 'access', _203 => _203.get, 'call', _204 => _204(blockIndex), 'optionalAccess', _205 => _205.para])) {
22873
+ if (!_optionalChain([st, 'access', _224 => _224.paraMap, 'access', _225 => _225.get, 'call', _226 => _226(blockIndex), 'optionalAccess', _227 => _227.para])) {
22702
22874
  return { capability: "locked", reason: "\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)" };
22703
22875
  }
22704
22876
  return { capability: "text" };
@@ -22764,7 +22936,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22764
22936
  continue;
22765
22937
  }
22766
22938
  if (block.type === "table" && block.table) {
22767
- if (!_optionalChain([edit, 'access', _206 => _206.cells, 'optionalAccess', _207 => _207.length])) {
22939
+ if (!_optionalChain([edit, 'access', _228 => _228.cells, 'optionalAccess', _229 => _229.length])) {
22768
22940
  skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
22769
22941
  continue;
22770
22942
  }
@@ -22784,7 +22956,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22784
22956
  skipped.push({ reason: "\uAC19\uC740 \uC140\uC5D0 \uC911\uBCF5 \uD3B8\uC9D1 \u2014 \uBA3C\uC800 \uC801\uC6A9\uB41C \uD3B8\uC9D1 \uC720\uC9C0", after: summarize(cellEdit.text) });
22785
22957
  continue;
22786
22958
  }
22787
- const irCell = _optionalChain([block, 'access', _208 => _208.table, 'access', _209 => _209.cells, 'access', _210 => _210[cellEdit.row], 'optionalAccess', _211 => _211[cellEdit.col]]);
22959
+ const irCell = _optionalChain([block, 'access', _230 => _230.table, 'access', _231 => _231.cells, 'access', _232 => _232[cellEdit.row], 'optionalAccess', _233 => _233[cellEdit.col]]);
22788
22960
  if (!irCell) {
22789
22961
  skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
22790
22962
  continue;
@@ -22839,7 +23011,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22839
23011
  }
22840
23012
  if (replacements.size === 0) {
22841
23013
  let changes2;
22842
- if (_optionalChain([options, 'optionalAccess', _212 => _212.verify]) !== false) {
23014
+ if (_optionalChain([options, 'optionalAccess', _234 => _234.verify]) !== false) {
22843
23015
  const units = splitMarkdownUnits(st.markdown);
22844
23016
  changes2 = diffUnitLists(units, units);
22845
23017
  }
@@ -22860,7 +23032,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22860
23032
  }
22861
23033
  this.state = newState;
22862
23034
  let changes;
22863
- if (_optionalChain([options, 'optionalAccess', _213 => _213.verify]) !== false) {
23035
+ if (_optionalChain([options, 'optionalAccess', _235 => _235.verify]) !== false) {
22864
23036
  changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
22865
23037
  }
22866
23038
  return { success: true, data: new Uint8Array(data), applied, skipped, changes };
@@ -22880,7 +23052,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22880
23052
  return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
22881
23053
  }
22882
23054
  const mapping = st.paraMap.get(blockIndex);
22883
- if (!_optionalChain([mapping, 'optionalAccess', _214 => _214.para])) {
23055
+ if (!_optionalChain([mapping, 'optionalAccess', _236 => _236.para])) {
22884
23056
  return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
22885
23057
  }
22886
23058
  let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
@@ -22900,14 +23072,14 @@ var HwpxSession = (_class4 = class _HwpxSession {
22900
23072
  if (sanitizeText(newPlain) !== newPlain) {
22901
23073
  return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
22902
23074
  }
22903
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _215 => _215.scans, 'access', _216 => _216[mapping.para.sectionIndex], 'optionalAccess', _217 => _217.xml]));
23075
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _237 => _237.scans, 'access', _238 => _238[mapping.para.sectionIndex], 'optionalAccess', _239 => _239.xml]));
22904
23076
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
22905
23077
  sectionSplices[mapping.para.sectionIndex].push(...splices);
22906
23078
  return 1;
22907
23079
  }
22908
23080
  }, _class4);
22909
23081
  function cellStaticCheck(table, scanTable, r, c) {
22910
- const irCell = _optionalChain([table, 'access', _218 => _218.cells, 'access', _219 => _219[r], 'optionalAccess', _220 => _220[c]]);
23082
+ const irCell = _optionalChain([table, 'access', _240 => _240.cells, 'access', _241 => _241[r], 'optionalAccess', _242 => _242[c]]);
22911
23083
  if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
22912
23084
  const cell = scanTable.cellByAnchor.get(`${r},${c}`);
22913
23085
  if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
@@ -22991,11 +23163,11 @@ var md = new (0, _markdownit2.default)({
22991
23163
  breaks: false
22992
23164
  });
22993
23165
  function renderHtml(markdown, options) {
22994
- const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _221 => _221.preset]), () => ( "default"));
22995
- const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _222 => _222.extraCss]), () => ( "")));
23166
+ const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _243 => _243.preset]), () => ( "default"));
23167
+ const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _244 => _244.extraCss]), () => ( "")));
22996
23168
  const body = md.render(markdown);
22997
- const watermark = _optionalChain([options, 'optionalAccess', _223 => _223.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
22998
- const watermarkCss = _optionalChain([options, 'optionalAccess', _224 => _224.watermark]) ? `
23169
+ const watermark = _optionalChain([options, 'optionalAccess', _245 => _245.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
23170
+ const watermarkCss = _optionalChain([options, 'optionalAccess', _246 => _246.watermark]) ? `
22999
23171
  .watermark {
23000
23172
  position: fixed;
23001
23173
  top: 50%; left: 50%;
@@ -23026,13 +23198,13 @@ async function htmlToPdf(html, options) {
23026
23198
  try {
23027
23199
  puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
23028
23200
  } catch (e34) {
23029
- throw new (0, _chunkFUB2BGXVcjs.KordocError)(
23201
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)(
23030
23202
  "PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
23031
23203
  );
23032
23204
  }
23033
23205
  const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
23034
23206
  if (!executablePath) {
23035
- throw new (0, _chunkFUB2BGXVcjs.KordocError)(
23207
+ throw new (0, _chunkW7JHJQ2Ocjs.KordocError)(
23036
23208
  "Chromium \uC2E4\uD589 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. PUPPETEER_EXECUTABLE_PATH \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694."
23037
23209
  );
23038
23210
  }
@@ -23044,10 +23216,10 @@ async function htmlToPdf(html, options) {
23044
23216
  try {
23045
23217
  const page = await browser.newPage();
23046
23218
  await page.setContent(html, { waitUntil: "networkidle0" });
23047
- const margin = _optionalChain([options, 'optionalAccess', _225 => _225.margin]);
23219
+ const margin = _optionalChain([options, 'optionalAccess', _247 => _247.margin]);
23048
23220
  const pdf = await page.pdf({
23049
- format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _226 => _226.pageSize]), () => ( "A4")),
23050
- landscape: _optionalChain([options, 'optionalAccess', _227 => _227.orientation]) === "landscape",
23221
+ format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _248 => _248.pageSize]), () => ( "A4")),
23222
+ landscape: _optionalChain([options, 'optionalAccess', _249 => _249.orientation]) === "landscape",
23051
23223
  printBackground: true,
23052
23224
  margin: margin ? {
23053
23225
  top: toCss(margin.top),
@@ -23055,9 +23227,9 @@ async function htmlToPdf(html, options) {
23055
23227
  bottom: toCss(margin.bottom),
23056
23228
  left: toCss(margin.left)
23057
23229
  } : void 0,
23058
- displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _228 => _228.header]) || _optionalChain([options, 'optionalAccess', _229 => _229.footer])),
23059
- headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _230 => _230.header]), () => ( "<div></div>")),
23060
- footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _231 => _231.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
23230
+ displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _250 => _250.header]) || _optionalChain([options, 'optionalAccess', _251 => _251.footer])),
23231
+ headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _252 => _252.header]), () => ( "<div></div>")),
23232
+ footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _253 => _253.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
23061
23233
  });
23062
23234
  return Buffer.from(pdf);
23063
23235
  } finally {
@@ -23091,24 +23263,24 @@ async function markdownToPdf(markdown, options) {
23091
23263
  return htmlToPdf(html, options);
23092
23264
  }
23093
23265
  async function blocksToPdf(blocks, options) {
23094
- const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
23266
+ const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks);
23095
23267
  return markdownToPdf(markdown, options);
23096
23268
  }
23097
23269
 
23098
23270
  // src/index.ts
23099
23271
  async function parse(input, options) {
23100
23272
  let buffer;
23101
- const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _232 => _232.filePath]) ? { ...options, filePath: input } : options;
23273
+ const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _254 => _254.filePath]) ? { ...options, filePath: input } : options;
23102
23274
  if (typeof input === "string") {
23103
23275
  try {
23104
23276
  const buf = await _promises.readFile.call(void 0, input);
23105
- buffer = _chunkFUB2BGXVcjs.toArrayBuffer.call(void 0, buf);
23277
+ buffer = _chunkW7JHJQ2Ocjs.toArrayBuffer.call(void 0, buf);
23106
23278
  } catch (err) {
23107
23279
  const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
23108
23280
  return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
23109
23281
  }
23110
23282
  } else if (Buffer.isBuffer(input)) {
23111
- buffer = _chunkFUB2BGXVcjs.toArrayBuffer.call(void 0, input);
23283
+ buffer = _chunkW7JHJQ2Ocjs.toArrayBuffer.call(void 0, input);
23112
23284
  } else {
23113
23285
  buffer = input;
23114
23286
  }
@@ -23143,21 +23315,21 @@ async function parseHwp3(buffer, options) {
23143
23315
  const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
23144
23316
  return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
23145
23317
  } catch (err) {
23146
- return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
23318
+ return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
23147
23319
  }
23148
23320
  }
23149
23321
  async function parseHwpx(buffer, options) {
23150
23322
  try {
23151
23323
  const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
23152
- return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _233 => _233.length]) ? images : void 0 };
23324
+ return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _255 => _255.length]) ? images : void 0 };
23153
23325
  } catch (err) {
23154
- return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
23326
+ return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
23155
23327
  }
23156
23328
  }
23157
23329
  async function parseHwp(buffer, options) {
23158
23330
  try {
23159
23331
  const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
23160
- if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _234 => _234.filePath])) {
23332
+ if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _256 => _256.filePath])) {
23161
23333
  try {
23162
23334
  const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
23163
23335
  if (pages.some((p) => p && p.trim().length > 0)) {
@@ -23174,15 +23346,15 @@ async function parseHwp(buffer, options) {
23174
23346
  } catch (e35) {
23175
23347
  }
23176
23348
  }
23177
- return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _235 => _235.length]) ? images : void 0 };
23349
+ return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _257 => _257.length]) ? images : void 0 };
23178
23350
  } catch (err) {
23179
- return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
23351
+ return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
23180
23352
  }
23181
23353
  }
23182
23354
  async function parsePdf(buffer, options) {
23183
23355
  let parsePdfDocument;
23184
23356
  try {
23185
- const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-YWKNDGKI.cjs")));
23357
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-JAZCZJI6.cjs")));
23186
23358
  parsePdfDocument = mod.parsePdfDocument;
23187
23359
  } catch (e36) {
23188
23360
  return {
@@ -23197,7 +23369,7 @@ async function parsePdf(buffer, options) {
23197
23369
  return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
23198
23370
  } catch (err) {
23199
23371
  const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
23200
- return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err), isImageBased };
23372
+ return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err), isImageBased };
23201
23373
  }
23202
23374
  }
23203
23375
  async function parseXlsx(buffer, options) {
@@ -23205,7 +23377,7 @@ async function parseXlsx(buffer, options) {
23205
23377
  const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
23206
23378
  return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
23207
23379
  } catch (err) {
23208
- return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
23380
+ return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
23209
23381
  }
23210
23382
  }
23211
23383
  async function parseXls(buffer, options) {
@@ -23213,15 +23385,15 @@ async function parseXls(buffer, options) {
23213
23385
  const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
23214
23386
  return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
23215
23387
  } catch (err) {
23216
- return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
23388
+ return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
23217
23389
  }
23218
23390
  }
23219
23391
  async function parseDocx(buffer, options) {
23220
23392
  try {
23221
23393
  const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
23222
- return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _236 => _236.length]) ? images : void 0 };
23394
+ return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _258 => _258.length]) ? images : void 0 };
23223
23395
  } catch (err) {
23224
- return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
23396
+ return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
23225
23397
  }
23226
23398
  }
23227
23399
  async function parseHwpml(buffer, options) {
@@ -23229,16 +23401,16 @@ async function parseHwpml(buffer, options) {
23229
23401
  const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
23230
23402
  return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
23231
23403
  } catch (err) {
23232
- return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
23404
+ return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
23233
23405
  }
23234
23406
  }
23235
23407
  async function fillForm(input, values, outputFormat = "markdown") {
23236
23408
  let buffer;
23237
23409
  if (typeof input === "string") {
23238
23410
  const buf = await _promises.readFile.call(void 0, input);
23239
- buffer = _chunkFUB2BGXVcjs.toArrayBuffer.call(void 0, buf);
23411
+ buffer = _chunkW7JHJQ2Ocjs.toArrayBuffer.call(void 0, buf);
23240
23412
  } else if (Buffer.isBuffer(input)) {
23241
- buffer = _chunkFUB2BGXVcjs.toArrayBuffer.call(void 0, input);
23413
+ buffer = _chunkW7JHJQ2Ocjs.toArrayBuffer.call(void 0, input);
23242
23414
  } else {
23243
23415
  buffer = input;
23244
23416
  }
@@ -23264,7 +23436,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
23264
23436
  throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
23265
23437
  }
23266
23438
  const fill = fillFormFields(parsed.blocks, values);
23267
- const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, fill.blocks);
23439
+ const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, fill.blocks);
23268
23440
  if (outputFormat === "hwpx") {
23269
23441
  const hwpxBuffer = await markdownToHwpx(markdown);
23270
23442
  return { output: hwpxBuffer, format: "hwpx", fill };
@@ -23312,5 +23484,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
23312
23484
 
23313
23485
 
23314
23486
 
23315
- exports.HwpxSession = HwpxSession; exports.VERSION = _chunkFUB2BGXVcjs.VERSION; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkFUB2BGXVcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.renderHtml = renderHtml; exports.scanSectionXml = scanSectionXml;
23487
+ exports.HwpxSession = HwpxSession; exports.VERSION = _chunkW7JHJQ2Ocjs.VERSION; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.renderHtml = renderHtml; exports.scanSectionXml = scanSectionXml;
23316
23488
  //# sourceMappingURL=index.cjs.map