kordoc 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +590 -584
  3. package/dist/{-56JCPGII.js → -GKNSTVEZ.js} +9 -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-YYKQN7SA.cjs → chunk-4JLD2IT7.cjs} +2 -2
  7. package/dist/chunk-4JLD2IT7.cjs.map +1 -0
  8. package/dist/{chunk-MHYDBT2Q.js → chunk-A4LSWJEC.js} +2 -2
  9. package/dist/chunk-A4LSWJEC.js.map +1 -0
  10. package/dist/{chunk-ZPLRG2SJ.js → chunk-AHDNELBR.js} +2 -2
  11. package/dist/chunk-AHDNELBR.js.map +1 -0
  12. package/dist/{chunk-GE43BE46.js → chunk-AIQ3ISQU.js} +1 -1
  13. package/dist/chunk-AIQ3ISQU.js.map +1 -0
  14. package/dist/{chunk-MEPHGCPQ.js → chunk-CFQLK3LM.js} +1 -1
  15. package/dist/chunk-CFQLK3LM.js.map +1 -0
  16. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  17. package/dist/{chunk-YFNBHLLM.js → chunk-GTCJQANY.js} +199 -30
  18. package/dist/chunk-GTCJQANY.js.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 +10 -27
  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 +368 -199
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +9 -3
  33. package/dist/index.d.ts +9 -3
  34. package/dist/index.js +197 -28
  35. package/dist/index.js.map +1 -1
  36. package/dist/mcp.js +42 -6
  37. package/dist/mcp.js.map +1 -1
  38. package/dist/page-range-CIRRJPXJ.js +7 -0
  39. package/dist/page-range-OF5I4PQY.js +8 -0
  40. package/dist/page-range-TPIRSA3J.cjs +8 -0
  41. package/dist/page-range-TPIRSA3J.cjs.map +1 -0
  42. package/dist/{parser-XDW6I25C.cjs → parser-25ISHR7Q.cjs} +18 -18
  43. package/dist/parser-25ISHR7Q.cjs.map +1 -0
  44. package/dist/{parser-VZL3MK5X.js → parser-LBLPN3KY.js} +5 -5
  45. package/dist/parser-LBLPN3KY.js.map +1 -0
  46. package/dist/{parser-PQDICHD5.js → parser-LMBDB7RM.js} +5 -5
  47. package/dist/parser-LMBDB7RM.js.map +1 -0
  48. package/dist/{provider-G4C2V2PD.cjs → provider-5K7O3Z2O.cjs} +1 -1
  49. package/dist/provider-5K7O3Z2O.cjs.map +1 -0
  50. package/dist/{provider-AKROB7WQ.js → provider-7H4CPZYS.js} +1 -1
  51. package/dist/provider-7H4CPZYS.js.map +1 -0
  52. package/dist/{provider-4ZJKV3DC.js → provider-H4WWSPOV.js} +1 -1
  53. package/dist/provider-H4WWSPOV.js.map +1 -0
  54. package/dist/{setup-57FB3LSP.js → setup-QSJ2INNS.js} +1 -1
  55. package/dist/setup-QSJ2INNS.js.map +1 -0
  56. package/dist/{watch-KERZCCNR.js → watch-77CYT54V.js} +5 -5
  57. package/dist/watch-77CYT54V.js.map +1 -0
  58. package/package.json +98 -98
  59. package/dist/chunk-DCZVOIEO.cjs.map +0 -1
  60. package/dist/chunk-GE43BE46.js.map +0 -1
  61. package/dist/chunk-MEPHGCPQ.js.map +0 -1
  62. package/dist/chunk-MHYDBT2Q.js.map +0 -1
  63. package/dist/chunk-MOL7MDBG.js.map +0 -1
  64. package/dist/chunk-YFNBHLLM.js.map +0 -1
  65. package/dist/chunk-YYKQN7SA.cjs.map +0 -1
  66. package/dist/chunk-ZPLRG2SJ.js.map +0 -1
  67. package/dist/formula-5NKVS2LR.cjs.map +0 -1
  68. package/dist/formula-JCNF43NE.js.map +0 -1
  69. package/dist/formula-RXVSQPXI.js.map +0 -1
  70. package/dist/page-range-737B4EZW.js +0 -8
  71. package/dist/page-range-LNMXJU6W.js +0 -7
  72. package/dist/page-range-P7SDW6LR.cjs +0 -8
  73. package/dist/page-range-P7SDW6LR.cjs.map +0 -1
  74. package/dist/parser-PQDICHD5.js.map +0 -1
  75. package/dist/parser-VZL3MK5X.js.map +0 -1
  76. package/dist/parser-XDW6I25C.cjs.map +0 -1
  77. package/dist/provider-4ZJKV3DC.js.map +0 -1
  78. package/dist/provider-AKROB7WQ.js.map +0 -1
  79. package/dist/provider-G4C2V2PD.cjs.map +0 -1
  80. package/dist/setup-57FB3LSP.js.map +0 -1
  81. package/dist/watch-KERZCCNR.js.map +0 -1
  82. /package/dist/{-56JCPGII.js.map → -GKNSTVEZ.js.map} +0 -0
  83. /package/dist/{detect-RI2MQ33K.js.map → detect-NTR2FUEG.js.map} +0 -0
  84. /package/dist/{page-range-737B4EZW.js.map → page-range-CIRRJPXJ.js.map} +0 -0
  85. /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 _chunkYYKQN7SAcjs = require('./chunk-YYKQN7SA.cjs');
20
+ var _chunk4JLD2IT7cjs = require('./chunk-4JLD2IT7.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, _chunkYYKQN7SAcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
831
+ if (level === "fatalError") throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
853
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk4JLD2IT7cjs.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(_chunkYYKQN7SAcjs.stripDtd.call(void 0, xml), "text/xml");
856
+ const doc = parser.parseFromString(_chunk4JLD2IT7cjs.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
- _chunkYYKQN7SAcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
1078
+ _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1087
+ throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.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, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1108
+ if (sectionPaths.length === 0) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1122
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk4JLD2IT7cjs.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 _chunkYYKQN7SAcjs.KordocError) throw secErr;
1127
+ if (secErr instanceof _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, blocks);
1135
+ const markdown = _chunk4JLD2IT7cjs.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 (_chunkYYKQN7SAcjs.isPathTraversal.call(void 0, path)) continue;
1224
+ if (_chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1230
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk4JLD2IT7cjs.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 _chunkYYKQN7SAcjs.KordocError) throw err;
1243
+ if (err instanceof _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1264
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk4JLD2IT7cjs.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(_chunkYYKQN7SAcjs.stripDtd.call(void 0, xml), "text/xml");
1274
+ const doc = parser.parseFromString(_chunk4JLD2IT7cjs.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 (_chunkYYKQN7SAcjs.isPathTraversal.call(void 0, name)) {
1334
+ if (_chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1352
+ if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.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, _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, blocks);
1361
+ const markdown = _chunk4JLD2IT7cjs.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(_chunkYYKQN7SAcjs.stripDtd.call(void 0, xml), "text/xml");
1379
+ const doc = parser.parseFromString(_chunk4JLD2IT7cjs.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 >= _chunkYYKQN7SAcjs.HEADING_RATIO_H1) level = 1;
1428
- else if (ratio >= _chunkYYKQN7SAcjs.HEADING_RATIO_H2) level = 2;
1429
- else if (ratio >= _chunkYYKQN7SAcjs.HEADING_RATIO_H3) level = 3;
1427
+ if (ratio >= _chunk4JLD2IT7cjs.HEADING_RATIO_H1) level = 1;
1428
+ else if (ratio >= _chunk4JLD2IT7cjs.HEADING_RATIO_H2) level = 2;
1429
+ else if (ratio >= _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.buildTable.call(void 0, state.rows);
1442
+ const table = _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.convertTableToText.call(void 0, newTable.rows);
1485
+ let flat = _chunk4JLD2IT7cjs.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(_chunkYYKQN7SAcjs.stripDtd.call(void 0, xml), "text/xml");
1495
+ const doc = parser.parseFromString(_chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.MAX_COLS);
1587
- tableCtx.cell.rowSpan = clampSpan(rs, _chunkYYKQN7SAcjs.MAX_ROWS);
1586
+ tableCtx.cell.colSpan = clampSpan(cs, _chunk4JLD2IT7cjs.MAX_COLS);
1587
+ tableCtx.cell.rowSpan = clampSpan(rs, _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.sanitizeHref.call(void 0, url);
1809
+ const safe = _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.sanitizeHref.call(void 0, url);
1944
+ const safe = _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2134
+ if (data.length < 40) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3658
+ throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3669
+ if (!headerData) throw new (0, _chunk4JLD2IT7cjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3670
3670
  const header = parseFileHeader(headerData);
3671
- if (header.signature !== "HWP Document File") throw new (0, _chunkYYKQN7SAcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3672
- if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkYYKQN7SAcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3673
- if (header.flags & FLAG_DRM) throw new (0, _chunkYYKQN7SAcjs.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, _chunk4JLD2IT7cjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3672
+ if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunk4JLD2IT7cjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3673
+ if (header.flags & FLAG_DRM) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3682
+ if (sections.length === 0) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3696
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk4JLD2IT7cjs.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 _chunkYYKQN7SAcjs.KordocError) throw secErr;
3703
+ if (secErr instanceof _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.flattenLayoutTables.call(void 0, blocks);
3709
+ const flatBlocks = _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, flatBlocks);
3714
+ const markdown = _chunk4JLD2IT7cjs.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 >= _chunkYYKQN7SAcjs.HEADING_RATIO_H1) level = 1;
3775
- else if (ratio >= _chunkYYKQN7SAcjs.HEADING_RATIO_H2) level = 2;
3776
- else if (ratio >= _chunkYYKQN7SAcjs.HEADING_RATIO_H3) level = 3;
3774
+ if (ratio >= _chunk4JLD2IT7cjs.HEADING_RATIO_H1) level = 1;
3775
+ else if (ratio >= _chunk4JLD2IT7cjs.HEADING_RATIO_H2) level = 2;
3776
+ else if (ratio >= _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3861
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3873
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3890
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.sanitizeHref.call(void 0, ctrl.href);
3993
+ const href = _chunk4JLD2IT7cjs.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), _chunkYYKQN7SAcjs.MAX_ROWS);
4227
- cols = Math.min(records[i2].data.readUInt16LE(6), _chunkYYKQN7SAcjs.MAX_COLS);
4226
+ rows = Math.min(records[i2].data.readUInt16LE(4), _chunk4JLD2IT7cjs.MAX_ROWS);
4227
+ cols = Math.min(records[i2].data.readUInt16LE(6), _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.buildTable.call(void 0, cellRows);
4276
+ const table = _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.MAX_COLS);
4294
- if (rs > 0) rowSpan = Math.min(rs, _chunkYYKQN7SAcjs.MAX_ROWS);
4293
+ if (cs > 0) colSpan = Math.min(cs, _chunk4JLD2IT7cjs.MAX_COLS);
4294
+ if (rs > 0) rowSpan = Math.min(rs, _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.convertTableToText.call(void 0, b.table.cells);
4304
+ const flat = _chunk4JLD2IT7cjs.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(_chunkYYKQN7SAcjs.stripDtd.call(void 0, text), "text/xml");
16738
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.buildTable.call(void 0, cellRows);
16882
+ const table = _chunk4JLD2IT7cjs.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
- _chunkYYKQN7SAcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16890
+ _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16895
+ throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16904
+ throw new (0, _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, blocks);
16976
+ const markdown = _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17383
+ throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17387
+ throw new (0, _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.buildTable.call(void 0, cellRows);
17502
+ const table = _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)(
17515
+ throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17521
+ throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17525
+ throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)(
17529
+ throw new (0, _chunk4JLD2IT7cjs.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: _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, allBlocks),
17589
+ markdown: _chunk4JLD2IT7cjs.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(_chunkYYKQN7SAcjs.stripDtd.call(void 0, text), "text/xml");
18027
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunk4JLD2IT7cjs.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
- _chunkYYKQN7SAcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18346
+ _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18351
+ throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18386
+ throw new (0, _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, blocks);
18423
+ const markdown = _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.stripDtd.call(void 0, normalized);
18446
+ const xml = _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, blocks);
18486
+ const markdown = _chunk4JLD2IT7cjs.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 = _chunkYYKQN7SAcjs.buildTable.call(void 0, cellRows);
18628
+ const table = _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19655
+ if (eocdOffset < 0) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19659
+ if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19661
+ throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
19667
+ if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19678
+ throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
19707
+ if (!entries.some((e) => e.name === name)) throw new (0, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.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, _chunk4JLD2IT7cjs.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, _chunkYYKQN7SAcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19780
+ throw new (0, _chunk4JLD2IT7cjs.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);
@@ -20000,8 +20013,30 @@ var PRESET_DEFAULTS = {
20000
20013
  notice: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
20001
20014
  minutes: { bodyPt: 14, lineSpacing: 130, numbering: "standard" }
20002
20015
  };
20016
+ var PRESET_ALIAS = {
20017
+ official: "official",
20018
+ \uAE30\uC548\uBB38: "official",
20019
+ \uC2DC\uD589\uBB38: "official",
20020
+ \uACF5\uBB38: "official",
20021
+ \uACF5\uBB38\uC11C: "official",
20022
+ report: "report",
20023
+ \uBCF4\uACE0\uC11C: "report",
20024
+ plan: "plan",
20025
+ \uACC4\uD68D\uC11C: "plan",
20026
+ \uACC4\uD68D: "plan",
20027
+ notice: "notice",
20028
+ \uD1B5\uC9C0: "notice",
20029
+ \uC54C\uB9BC: "notice",
20030
+ \uC548\uB0B4: "notice",
20031
+ minutes: "minutes",
20032
+ \uD68C\uC758\uB85D: "minutes"
20033
+ };
20034
+ function normalizeGongmunPreset(preset) {
20035
+ if (!preset) return "official";
20036
+ return _nullishCoalesce(PRESET_ALIAS[preset.trim()], () => ( "official"));
20037
+ }
20003
20038
  function resolveGongmun(opts) {
20004
- const preset = _nullishCoalesce(opts.preset, () => ( "official"));
20039
+ const preset = normalizeGongmunPreset(opts.preset);
20005
20040
  const d = PRESET_DEFAULTS[preset];
20006
20041
  const bodyPt = _nullishCoalesce(opts.bodyPt, () => ( d.bodyPt));
20007
20042
  return {
@@ -20124,21 +20159,21 @@ var PARA_LIST = 7;
20124
20159
  var DEFAULT_TEXT_COLOR = "#000000";
20125
20160
  function resolveTheme(theme) {
20126
20161
  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)),
20162
+ h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _151 => _151.headingColors, 'optionalAccess', _152 => _152[1]]), () => ( DEFAULT_TEXT_COLOR)),
20163
+ h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _153 => _153.headingColors, 'optionalAccess', _154 => _154[2]]), () => ( DEFAULT_TEXT_COLOR)),
20164
+ h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _155 => _155.headingColors, 'optionalAccess', _156 => _156[3]]), () => ( DEFAULT_TEXT_COLOR)),
20165
+ 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)),
20166
+ body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _161 => _161.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
20167
+ quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _162 => _162.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
20133
20168
  /** 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])
20169
+ hasQuoteOption: _optionalChain([theme, 'optionalAccess', _163 => _163.quoteColor]) !== void 0,
20170
+ tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _164 => _164.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _165 => _165.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
20171
+ tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _166 => _166.tableHeaderBold])
20137
20172
  };
20138
20173
  }
20139
20174
  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;
20175
+ const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _167 => _167.theme]));
20176
+ const gongmun = _optionalChain([options, 'optionalAccess', _168 => _168.gongmun]) ? resolveGongmun(options.gongmun) : null;
20142
20177
  const blocks = parseMarkdownToBlocks(markdown);
20143
20178
  const sectionXml = blocksToSectionXml(blocks, theme, gongmun);
20144
20179
  const zip = new (0, _jszip2.default)();
@@ -20417,7 +20452,7 @@ ${base.join("\n")}
20417
20452
  </hh:paraProperties>`;
20418
20453
  }
20419
20454
  function generateHeaderXml(theme, gongmun) {
20420
- const bodyFace = _optionalChain([gongmun, 'optionalAccess', _150 => _150.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
20455
+ const bodyFace = _optionalChain([gongmun, 'optionalAccess', _169 => _169.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
20421
20456
  const charPropsXml = buildCharProperties(theme, gongmun);
20422
20457
  const paraPropsXml = buildParaProperties(gongmun);
20423
20458
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
@@ -20616,8 +20651,8 @@ function blocksToSectionXml(blocks, theme, gongmun) {
20616
20651
  case "list_item": {
20617
20652
  if (gongmun && gongmunList) {
20618
20653
  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]), () => ( ""));
20654
+ const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _170 => _170.depth]), () => ( 0));
20655
+ const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _171 => _171.marker]), () => ( ""));
20621
20656
  const content = block.text || "";
20622
20657
  const text = marker2 ? `${marker2} ${content}` : content;
20623
20658
  xml = generateParagraph(text, GONGMUN_LIST_BASE + depth);
@@ -20914,7 +20949,7 @@ function escapeGfm(text) {
20914
20949
  }
20915
20950
  var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
20916
20951
  function sanitizeText(text) {
20917
- let result = _chunkYYKQN7SAcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
20952
+ let result = _chunk4JLD2IT7cjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
20918
20953
  if (result.length <= 30 && result.includes(" ")) {
20919
20954
  const tokens = result.split(" ");
20920
20955
  const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-힯ㄱ-ㆎ]/.test(t)).length;
@@ -20944,7 +20979,7 @@ function replicateGfmTable(table) {
20944
20979
  for (let r = 0; r < numRows; r++) {
20945
20980
  for (let c = 0; c < numCols; c++) {
20946
20981
  if (skip.has(`${r},${c}`)) continue;
20947
- const cell = _optionalChain([cells, 'access', _153 => _153[r], 'optionalAccess', _154 => _154[c]]);
20982
+ const cell = _optionalChain([cells, 'access', _172 => _172[r], 'optionalAccess', _173 => _173[c]]);
20948
20983
  if (!cell) continue;
20949
20984
  display[r][c] = {
20950
20985
  text: escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
@@ -20998,7 +21033,7 @@ function unescapeGfmCell(text) {
20998
21033
  return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\~/g, "~");
20999
21034
  }
21000
21035
  function replicateCellInnerHtml(cell) {
21001
- if (_optionalChain([cell, 'access', _155 => _155.blocks, 'optionalAccess', _156 => _156.length])) {
21036
+ if (_optionalChain([cell, 'access', _174 => _174.blocks, 'optionalAccess', _175 => _175.length])) {
21002
21037
  return cell.blocks.map((b) => {
21003
21038
  if (b.type === "table" && b.table) {
21004
21039
  const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
@@ -21037,7 +21072,7 @@ function replicateHtmlTable(table) {
21037
21072
  const rowCells = [];
21038
21073
  for (let c = 0; c < numCols; c++) {
21039
21074
  if (skip.has(`${r},${c}`)) continue;
21040
- const cell = _optionalChain([cells, 'access', _157 => _157[r], 'optionalAccess', _158 => _158[c]]);
21075
+ const cell = _optionalChain([cells, 'access', _176 => _176[r], 'optionalAccess', _177 => _177[c]]);
21041
21076
  if (!cell) continue;
21042
21077
  for (let dr = 0; dr < cell.rowSpan; dr++) {
21043
21078
  for (let dc = 0; dc < cell.colSpan; dc++) {
@@ -21083,8 +21118,8 @@ function parseHtmlTable(raw) {
21083
21118
  }
21084
21119
  } else {
21085
21120
  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);
21121
+ const cs = parseInt(_optionalChain([attrs, 'access', _178 => _178.match, 'call', _179 => _179(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _180 => _180[1]]) || "1", 10);
21122
+ const rs = parseInt(_optionalChain([attrs, 'access', _181 => _181.match, 'call', _182 => _182(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _183 => _183[1]]) || "1", 10);
21088
21123
  cellStart = m.index + m[0].length;
21089
21124
  cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
21090
21125
  } else if (cellStart >= 0 && cellInfo && currentRow) {
@@ -21246,9 +21281,9 @@ function patchHtmlTableRaw(table, scanTable, origRaw, editedRaw, ctx, skip, dept
21246
21281
  return applied;
21247
21282
  }
21248
21283
  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]]);
21284
+ const irCell = _optionalChain([table, 'access', _184 => _184.cells, 'access', _185 => _185[oc.gridR], 'optionalAccess', _186 => _186[oc.gridC]]);
21250
21285
  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);
21286
+ const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _187 => _187.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
21252
21287
  if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
21253
21288
  return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
21254
21289
  }
@@ -21316,7 +21351,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
21316
21351
  };
21317
21352
  const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
21318
21353
  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]]);
21354
+ const irCell = _optionalChain([table, 'access', _188 => _188.cells, 'access', _189 => _189[gridR], 'optionalAccess', _190 => _190[gridC]]);
21320
21355
  const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
21321
21356
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
21322
21357
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -21339,7 +21374,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
21339
21374
  if (newLines.length === 0) return 0;
21340
21375
  const target = cell.paragraphs[0];
21341
21376
  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]));
21377
+ const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _191 => _191.scans, 'access', _192 => _192[target.sectionIndex], 'optionalAccess', _193 => _193.xml]));
21343
21378
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
21344
21379
  splices.push(...sp);
21345
21380
  sectionIndex = target.sectionIndex;
@@ -21360,7 +21395,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
21360
21395
  }
21361
21396
  for (let i = 0; i < nonEmpty.length; i++) {
21362
21397
  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]));
21398
+ const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _194 => _194.scans, 'access', _195 => _195[nonEmpty[i].sectionIndex], 'optionalAccess', _196 => _196.xml]));
21364
21399
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
21365
21400
  splices.push(...sp);
21366
21401
  sectionIndex = nonEmpty[i].sectionIndex;
@@ -21371,6 +21406,67 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
21371
21406
  return 1;
21372
21407
  }
21373
21408
 
21409
+ // src/roundtrip/table-insert.ts
21410
+ var TABLE_USABLE_WIDTH = 44e3;
21411
+ var TABLE_ROW_HEIGHT = 1500;
21412
+ function collectMaxNumericId(xmls) {
21413
+ let max = -1;
21414
+ for (const xml of xmls) {
21415
+ for (const m of xml.matchAll(/\bid(?:Ref)?="(\d{1,10})"/g)) {
21416
+ const v = parseInt(m[1], 10);
21417
+ if (!isNaN(v) && v > max) max = v;
21418
+ }
21419
+ }
21420
+ return max;
21421
+ }
21422
+ function cellBorderFillXml(id) {
21423
+ return `<hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="0" breakCellSeparateLine="0"><hh:slash type="NONE" Crooked="0" isCounter="0"/><hh:backSlash type="NONE" Crooked="0" isCounter="0"/><hh:leftBorder type="SOLID" width="0.12 mm" color="#000000"/><hh:rightBorder type="SOLID" width="0.12 mm" color="#000000"/><hh:topBorder type="SOLID" width="0.12 mm" color="#000000"/><hh:bottomBorder type="SOLID" width="0.12 mm" color="#000000"/><hh:diagonal type="NONE" width="0.1 mm" color="#000000"/><hh:fillInfo/></hh:borderFill>`;
21424
+ }
21425
+ function injectCellBorderFill(headerXml, newId) {
21426
+ const openM = headerXml.match(/<hh:borderFills\b([^>]*)>/);
21427
+ if (!openM || openM.index === void 0) return null;
21428
+ const closeIdx = headerXml.indexOf("</hh:borderFills>");
21429
+ if (closeIdx < 0) return null;
21430
+ const splices = [];
21431
+ const itemCntM = openM[1].match(/\bitemCnt="(\d+)"/);
21432
+ if (itemCntM && itemCntM.index !== void 0) {
21433
+ const cnt = parseInt(itemCntM[1], 10);
21434
+ const attrStart = openM.index + "<hh:borderFills".length + itemCntM.index;
21435
+ const valStart = attrStart + itemCntM[0].indexOf('"') + 1;
21436
+ const valEnd = valStart + String(cnt).length;
21437
+ splices.push({ start: valStart, end: valEnd, replacement: String(cnt + 1) });
21438
+ }
21439
+ splices.push({ start: closeIdx, end: closeIdx, replacement: cellBorderFillXml(newId) });
21440
+ return { borderFillId: newId, headerSplices: splices };
21441
+ }
21442
+ function cellPlainText(raw) {
21443
+ let t = unescapeGfmCell(raw);
21444
+ t = t.replace(/\*\*\*([^*]+)\*\*\*/g, "$1").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/`([^`]+)`/g, "$1");
21445
+ return t.replace(/\s*\n\s*/g, " ").trim();
21446
+ }
21447
+ function buildTableParagraphXml(rows, opts) {
21448
+ const { borderFillId, outerParaPrId, cellParaPrId, cellCharPrId, tableId } = opts;
21449
+ const rowCnt = rows.length;
21450
+ const colCnt = Math.max(...rows.map((r) => r.length), 1);
21451
+ const cellW = Math.floor(TABLE_USABLE_WIDTH / colCnt);
21452
+ const cellH = TABLE_ROW_HEIGHT;
21453
+ const tblW = cellW * colCnt;
21454
+ const tblH = cellH * rowCnt;
21455
+ const trElements = rows.map((row, rowIdx) => {
21456
+ const cells = row.length < colCnt ? [...row, ...Array(colCnt - row.length).fill("")] : row;
21457
+ const isHeaderRow = rowIdx === 0;
21458
+ const tdElements = cells.map((cell, colIdx) => {
21459
+ const text = escapeXmlText(cellPlainText(cell));
21460
+ const cellP = `<hp:p paraPrIDRef="${cellParaPrId}" styleIDRef="0"><hp:run charPrIDRef="${cellCharPrId}"><hp:t>${text}</hp:t></hp:run></hp:p>`;
21461
+ return `<hp:tc name="" header="${isHeaderRow ? 1 : 0}" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="${borderFillId}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="TOP" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${cellP}</hp:subList><hp:cellAddr colAddr="${colIdx}" rowAddr="${rowIdx}"/><hp:cellSpan colSpan="1" rowSpan="1"/><hp:cellSz width="${cellW}" height="${cellH}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
21462
+ }).join("");
21463
+ return `<hp:tr>${tdElements}</hp:tr>`;
21464
+ }).join("");
21465
+ const tblInner = `<hp:sz width="${tblW}" widthRelTo="ABSOLUTE" height="${tblH}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="0" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:inMargin left="510" right="510" top="141" bottom="141"/>` + trElements;
21466
+ const tbl = `<hp:tbl id="${tableId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="0" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="${borderFillId}" noShading="0">${tblInner}</hp:tbl>`;
21467
+ return `<hp:p paraPrIDRef="${outerParaPrId}" styleIDRef="0"><hp:run charPrIDRef="${cellCharPrId}">${tbl}</hp:run></hp:p>`;
21468
+ }
21469
+
21374
21470
  // src/roundtrip/hwpx-entries.ts
21375
21471
  async function resolveSectionEntryNames(zip) {
21376
21472
  for (const mp of ["Contents/content.hpf", "content.hpf"]) {
@@ -21432,6 +21528,13 @@ async function patchHwpx(original, editedMarkdown, options) {
21432
21528
  const xml = await zip.file(sectionPaths[i]).async("text");
21433
21529
  scans.push(scanSectionXml(xml, i));
21434
21530
  }
21531
+ let tableInsert;
21532
+ const headerEntryName = await resolveHeaderEntryName(zip);
21533
+ if (headerEntryName) {
21534
+ const headerXml = await zip.file(headerEntryName).async("text");
21535
+ const maxId = collectMaxNumericId([...scans.map((s) => s.xml), headerXml]);
21536
+ tableInsert = { headerEntryName, headerXml, headerSplices: [], borderFillId: null, nextId: maxId + 1 };
21537
+ }
21435
21538
  const origUnits = buildOrigUnits(origBlocks);
21436
21539
  const editedUnits = splitMarkdownUnits(editedMarkdown);
21437
21540
  const pairs = alignUnits(origUnits.map((u) => u.raw), editedUnits.map((u) => u.raw));
@@ -21451,7 +21554,8 @@ async function patchHwpx(original, editedMarkdown, options) {
21451
21554
  scanTables,
21452
21555
  obTableOrdinals,
21453
21556
  sectionSplices,
21454
- skipped
21557
+ skipped,
21558
+ tableInsert
21455
21559
  });
21456
21560
  } else if (oi !== null) {
21457
21561
  skipped.push({ reason: "\uBE14\uB85D \uC0AD\uC81C\uB294 \uBBF8\uC9C0\uC6D0 (v1) \u2014 \uC6D0\uBCF8 \uC720\uC9C0", before: summarize(origUnits[oi].raw) });
@@ -21468,6 +21572,10 @@ async function patchHwpx(original, editedMarkdown, options) {
21468
21572
  const newXml = applySplices(scans[i].xml, sectionSplices[i]);
21469
21573
  replacements.set(sectionPaths[i], encoder.encode(newXml));
21470
21574
  }
21575
+ if (tableInsert && tableInsert.headerSplices.length > 0) {
21576
+ const newHeader = applySplices(tableInsert.headerXml, tableInsert.headerSplices);
21577
+ replacements.set(tableInsert.headerEntryName, encoder.encode(newHeader));
21578
+ }
21471
21579
  } catch (err) {
21472
21580
  return { success: false, applied: 0, skipped, error: `\uC18C\uC2A4\uB9F5 splice \uC2E4\uD328: ${err instanceof Error ? err.message : String(err)}` };
21473
21581
  }
@@ -21482,7 +21590,7 @@ async function patchHwpx(original, editedMarkdown, options) {
21482
21590
  }
21483
21591
  }
21484
21592
  let verification;
21485
- if (_optionalChain([options, 'optionalAccess', _178 => _178.verify]) !== false) {
21593
+ if (_optionalChain([options, 'optionalAccess', _197 => _197.verify]) !== false) {
21486
21594
  try {
21487
21595
  const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
21488
21596
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -21500,17 +21608,17 @@ function buildOrigUnits(blocks) {
21500
21608
  let chunk;
21501
21609
  if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
21502
21610
  const next = blocks[i + 1];
21503
- if (_optionalChain([next, 'optionalAccess', _179 => _179.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
21504
- chunk = _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
21611
+ if (_optionalChain([next, 'optionalAccess', _198 => _198.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
21612
+ chunk = _chunk4JLD2IT7cjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
21505
21613
  } else {
21506
- chunk = _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, [block]);
21614
+ chunk = _chunk4JLD2IT7cjs.blocksToMarkdown.call(void 0, [block]);
21507
21615
  }
21508
21616
  if (chunk) {
21509
21617
  const subUnits = splitMarkdownUnits(chunk);
21510
21618
  const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
21511
21619
  for (let s = 0; s < subUnits.length; s++) {
21512
21620
  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("**")) {
21621
+ 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
21622
  u.role = "caption";
21515
21623
  }
21516
21624
  units.push(u);
@@ -21680,14 +21788,52 @@ function handleModifiedUnit(orig, edited, ctx) {
21680
21788
  if (orig.kind === "html-table") return patchHtmlTable(block.table, scanTable, orig, edited, ctx, skip);
21681
21789
  return patchTextChunkTable(block.table, scanTable, orig, edited, ctx, skip);
21682
21790
  }
21683
- if ((block.type === "paragraph" || block.type === "heading") && orig.kind === "text" && edited.kind === "text") {
21684
- return patchParagraphUnit(block, orig, edited, ctx, skip);
21791
+ if ((block.type === "paragraph" || block.type === "heading") && orig.kind === "text") {
21792
+ if (edited.kind === "text") return patchParagraphUnit(block, orig, edited, ctx, skip);
21793
+ if (edited.kind === "gfm-table") return convertParagraphToTable(block, orig, edited, ctx, skip);
21794
+ if (edited.kind === "html-table") return skip("\uBB38\uB2E8\u2192\uBCD1\uD569\uD45C(HTML) \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0 \u2014 GFM \uD45C(| \uD5E4\uB354 | \u2026 |)\uB85C \uC791\uC131\uD558\uC138\uC694");
21685
21795
  }
21686
21796
  return skip("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uBE14\uB85D \uC720\uD615 \uBCC0\uACBD");
21687
21797
  }
21798
+ function extractParaPrIdRef(xml, start) {
21799
+ const gt = xml.indexOf(">", start);
21800
+ if (gt < 0) return null;
21801
+ const m = xml.slice(start, gt + 1).match(/paraPrIDRef="(\d+)"/);
21802
+ return m ? parseInt(m[1], 10) : null;
21803
+ }
21804
+ function convertParagraphToTable(block, orig, edited, ctx, skip) {
21805
+ const ti = ctx.tableInsert;
21806
+ if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
21807
+ const mapping = ctx.paraMap.get(orig.blockIdx);
21808
+ 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) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
21809
+ const para = mapping.para;
21810
+ if (para.kind !== "body") return skip("\uBCF8\uBB38 \uC678 \uC601\uC5ED(\uD45C \uC140/\uAE00\uC0C1\uC790) \uBB38\uB2E8\uC758 \uD45C \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0");
21811
+ const scan = ctx.scans[para.sectionIndex];
21812
+ if (!scan) return skip("\uC139\uC158 \uB9E4\uD551 \uC2E4\uD328");
21813
+ const pEnd = findElementEnd(scan.xml, para.start);
21814
+ if (pEnd < 0) return skip("\uBB38\uB2E8 \uB05D \uC704\uCE58 \uD0D0\uC0C9 \uC2E4\uD328");
21815
+ const rows = parseGfmTable(edited.lines);
21816
+ if (rows.length === 0 || rows.every((r) => r.length === 0)) return skip("\uD45C \uB0B4\uC6A9\uC774 \uBE44\uC5B4 \uC788\uC74C");
21817
+ if (ti.borderFillId === null) {
21818
+ const inj = injectCellBorderFill(ti.headerXml, ti.nextId++);
21819
+ if (!inj) return skip("header <hh:borderFills> \uAD6C\uC870\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4 \uD45C \uD14C\uB450\uB9AC \uC0DD\uC131 \uBD88\uAC00");
21820
+ ti.borderFillId = inj.borderFillId;
21821
+ ti.headerSplices.push(...inj.headerSplices);
21822
+ }
21823
+ const outerParaPrId = _nullishCoalesce(extractParaPrIdRef(scan.xml, para.start), () => ( 0));
21824
+ const tableXml = buildTableParagraphXml(rows, {
21825
+ borderFillId: ti.borderFillId,
21826
+ outerParaPrId,
21827
+ cellParaPrId: 0,
21828
+ cellCharPrId: 0,
21829
+ tableId: ti.nextId++
21830
+ });
21831
+ ctx.sectionSplices[para.sectionIndex].push({ start: para.start, end: pEnd, replacement: tableXml });
21832
+ return 1;
21833
+ }
21688
21834
  function patchParagraphUnit(block, orig, edited, ctx, skip) {
21689
21835
  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)");
21836
+ if (!_optionalChain([mapping, 'optionalAccess', _202 => _202.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
21837
  if (block.text && block.text.includes("\n")) {
21692
21838
  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
21839
  }
@@ -21718,7 +21864,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
21718
21864
  if (sanitizeText(newPlain) !== newPlain) {
21719
21865
  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
21866
  }
21721
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _183 => _183.scans, 'access', _184 => _184[mapping.para.sectionIndex], 'optionalAccess', _185 => _185.xml]));
21867
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _203 => _203.scans, 'access', _204 => _204[mapping.para.sectionIndex], 'optionalAccess', _205 => _205.xml]));
21722
21868
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
21723
21869
  ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
21724
21870
  return 1;
@@ -21765,6 +21911,24 @@ function unitToBlock(u) {
21765
21911
  function u8ToArrayBuffer(u8) {
21766
21912
  return u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength);
21767
21913
  }
21914
+ async function resolveHeaderEntryName(zip) {
21915
+ for (const p of ["Contents/header.xml", "header.xml"]) {
21916
+ if (zip.file(p)) return p;
21917
+ }
21918
+ for (const mp of ["Contents/content.hpf", "content.hpf"]) {
21919
+ const f = zip.file(mp);
21920
+ if (!f) continue;
21921
+ const xml = await f.async("text");
21922
+ const m = xml.match(/<opf:item\b[^>]*\bid="header"[^>]*\bhref="([^"]+)"/i) || xml.match(/<opf:item\b[^>]*\bhref="([^"]*header[^"]*\.xml)"/i);
21923
+ if (m) {
21924
+ let href = m[1];
21925
+ if (!href.startsWith("/") && !href.startsWith("Contents/")) href = "Contents/" + href;
21926
+ if (zip.file(href)) return href;
21927
+ }
21928
+ }
21929
+ const found = Object.keys(zip.files).find((n) => /header\.xml$/i.test(n));
21930
+ return _nullishCoalesce(found, () => ( null));
21931
+ }
21768
21932
 
21769
21933
  // src/roundtrip/hwp5-patch.ts
21770
21934
 
@@ -21886,7 +22050,7 @@ var Surgeon = (_class3 = class {
21886
22050
  /** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
21887
22051
  findEntry(path) {
21888
22052
  const parts = path.replace(/^\//, "").split("/");
21889
- let scope = _nullishCoalesce(_optionalChain([this, 'access', _186 => _186.entries, 'access', _187 => _187[0], 'optionalAccess', _188 => _188.child]), () => ( -1));
22053
+ let scope = _nullishCoalesce(_optionalChain([this, 'access', _206 => _206.entries, 'access', _207 => _207[0], 'optionalAccess', _208 => _208.child]), () => ( -1));
21890
22054
  let current;
21891
22055
  for (const part of parts) {
21892
22056
  const search = (idx) => {
@@ -22092,7 +22256,7 @@ function readRecordsStrict(stream) {
22092
22256
  function serializeRecords(recs, repl) {
22093
22257
  const parts = [];
22094
22258
  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));
22259
+ const data = _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _209 => _209.get, 'call', _210 => _210(i)]), () => ( recs[i].data));
22096
22260
  const ext = data.length >= 4095;
22097
22261
  const header = Buffer.alloc(ext ? 8 : 4);
22098
22262
  header.writeUInt32LE((recs[i].tagId & 1023 | (recs[i].level & 1023) << 10 | (ext ? 4095 : data.length) << 20) >>> 0, 0);
@@ -22215,7 +22379,7 @@ async function patchHwp(original, editedMarkdown, options) {
22215
22379
  return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
22216
22380
  }
22217
22381
  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");
22382
+ if (!_optionalChain([fhEntry, 'optionalAccess', _211 => _211.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
22219
22383
  let flags;
22220
22384
  try {
22221
22385
  flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
@@ -22237,7 +22401,7 @@ async function patchHwp(original, editedMarkdown, options) {
22237
22401
  const scans = [];
22238
22402
  for (let i = 0; i < sectionPaths.length; i++) {
22239
22403
  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]}`);
22404
+ if (!_optionalChain([entry, 'optionalAccess', _212 => _212.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
22241
22405
  let stream;
22242
22406
  try {
22243
22407
  stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
@@ -22288,7 +22452,7 @@ async function patchHwp(original, editedMarkdown, options) {
22288
22452
  }
22289
22453
  }
22290
22454
  let verification;
22291
- if (_optionalChain([options, 'optionalAccess', _193 => _193.verify]) !== false) {
22455
+ if (_optionalChain([options, 'optionalAccess', _213 => _213.verify]) !== false) {
22292
22456
  try {
22293
22457
  const reparsed = parseHwp5Document(Buffer.from(data));
22294
22458
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -22377,7 +22541,7 @@ function tableContentScore(irTable, scanTable) {
22377
22541
  for (const [key, scanCell] of scanTable.cells) {
22378
22542
  const comma = key.indexOf(",");
22379
22543
  const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
22380
- const irCell = _optionalChain([irTable, 'access', _194 => _194.cells, 'access', _195 => _195[r], 'optionalAccess', _196 => _196[c]]);
22544
+ const irCell = _optionalChain([irTable, 'access', _214 => _214.cells, 'access', _215 => _215[r], 'optionalAccess', _216 => _216[c]]);
22381
22545
  if (!irCell) continue;
22382
22546
  const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
22383
22547
  const b = normForMatch(stripCellTokens(irCell.text));
@@ -22403,14 +22567,17 @@ function handleModified(orig, edited, ctx) {
22403
22567
  if (orig.kind === "html-table") return patchHtmlCells5(block.table, scanTable, orig, edited, ctx, skip);
22404
22568
  return patchTextChunk5(block.table, scanTable, orig, edited, ctx, skip);
22405
22569
  }
22406
- if ((block.type === "paragraph" || block.type === "heading") && orig.kind === "text" && edited.kind === "text") {
22407
- return patchParagraph(block, orig, edited, ctx, skip);
22570
+ if ((block.type === "paragraph" || block.type === "heading") && orig.kind === "text") {
22571
+ if (edited.kind === "text") return patchParagraph(block, orig, edited, ctx, skip);
22572
+ if (edited.kind === "gfm-table" || edited.kind === "html-table") {
22573
+ return skip("HWP5(.hwp) \uBC14\uC774\uB108\uB9AC\uB294 \uBB38\uB2E8\u2192\uD45C \uC778\uD50C\uB808\uC774\uC2A4 \uBCC0\uD658 \uBBF8\uC9C0\uC6D0 \u2014 generate\uB85C \uC0C8 \uBB38\uC11C\uB97C \uB9CC\uB4E4\uAC70\uB098, HWPX(.hwpx)\uB85C \uC800\uC7A5 \uD6C4 patch\uD558\uC138\uC694");
22574
+ }
22408
22575
  }
22409
22576
  return skip("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uBE14\uB85D \uC720\uD615 \uBCC0\uACBD");
22410
22577
  }
22411
22578
  function patchParagraph(block, orig, edited, ctx, skip) {
22412
22579
  const mapping = ctx.paraMap.get(orig.blockIdx);
22413
- if (!_optionalChain([mapping, 'optionalAccess', _197 => _197.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)");
22580
+ if (!_optionalChain([mapping, 'optionalAccess', _217 => _217.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)");
22414
22581
  if (block.text && block.text.includes("\n")) {
22415
22582
  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)");
22416
22583
  }
@@ -22589,7 +22756,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
22589
22756
  };
22590
22757
  const cell = scanTable.cells.get(`${gridR},${gridC}`);
22591
22758
  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)");
22592
- const irCell = _optionalChain([table, 'access', _198 => _198.cells, 'access', _199 => _199[gridR], 'optionalAccess', _200 => _200[gridC]]);
22759
+ const irCell = _optionalChain([table, 'access', _218 => _218.cells, 'access', _219 => _219[gridR], 'optionalAccess', _220 => _220[gridC]]);
22593
22760
  const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
22594
22761
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
22595
22762
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -22832,7 +22999,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22832
22999
  const block = st.blocks[blockIndex];
22833
23000
  if (!block) return void 0;
22834
23001
  if (block.type === "paragraph" || block.type === "heading") {
22835
- const para = _optionalChain([st, 'access', _201 => _201.paraMap, 'access', _202 => _202.get, 'call', _203 => _203(blockIndex), 'optionalAccess', _204 => _204.para]);
23002
+ const para = _optionalChain([st, 'access', _221 => _221.paraMap, 'access', _222 => _222.get, 'call', _223 => _223(blockIndex), 'optionalAccess', _224 => _224.para]);
22836
23003
  if (!para) return void 0;
22837
23004
  return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
22838
23005
  }
@@ -22857,7 +23024,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22857
23024
  if (block.text && block.text.includes("\n")) {
22858
23025
  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)" };
22859
23026
  }
22860
- if (!_optionalChain([st, 'access', _205 => _205.paraMap, 'access', _206 => _206.get, 'call', _207 => _207(blockIndex), 'optionalAccess', _208 => _208.para])) {
23027
+ if (!_optionalChain([st, 'access', _225 => _225.paraMap, 'access', _226 => _226.get, 'call', _227 => _227(blockIndex), 'optionalAccess', _228 => _228.para])) {
22861
23028
  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)" };
22862
23029
  }
22863
23030
  return { capability: "text" };
@@ -22923,7 +23090,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22923
23090
  continue;
22924
23091
  }
22925
23092
  if (block.type === "table" && block.table) {
22926
- if (!_optionalChain([edit, 'access', _209 => _209.cells, 'optionalAccess', _210 => _210.length])) {
23093
+ if (!_optionalChain([edit, 'access', _229 => _229.cells, 'optionalAccess', _230 => _230.length])) {
22927
23094
  skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
22928
23095
  continue;
22929
23096
  }
@@ -22943,7 +23110,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22943
23110
  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) });
22944
23111
  continue;
22945
23112
  }
22946
- const irCell = _optionalChain([block, 'access', _211 => _211.table, 'access', _212 => _212.cells, 'access', _213 => _213[cellEdit.row], 'optionalAccess', _214 => _214[cellEdit.col]]);
23113
+ const irCell = _optionalChain([block, 'access', _231 => _231.table, 'access', _232 => _232.cells, 'access', _233 => _233[cellEdit.row], 'optionalAccess', _234 => _234[cellEdit.col]]);
22947
23114
  if (!irCell) {
22948
23115
  skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
22949
23116
  continue;
@@ -22998,7 +23165,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
22998
23165
  }
22999
23166
  if (replacements.size === 0) {
23000
23167
  let changes2;
23001
- if (_optionalChain([options, 'optionalAccess', _215 => _215.verify]) !== false) {
23168
+ if (_optionalChain([options, 'optionalAccess', _235 => _235.verify]) !== false) {
23002
23169
  const units = splitMarkdownUnits(st.markdown);
23003
23170
  changes2 = diffUnitLists(units, units);
23004
23171
  }
@@ -23019,7 +23186,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
23019
23186
  }
23020
23187
  this.state = newState;
23021
23188
  let changes;
23022
- if (_optionalChain([options, 'optionalAccess', _216 => _216.verify]) !== false) {
23189
+ if (_optionalChain([options, 'optionalAccess', _236 => _236.verify]) !== false) {
23023
23190
  changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
23024
23191
  }
23025
23192
  return { success: true, data: new Uint8Array(data), applied, skipped, changes };
@@ -23039,7 +23206,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
23039
23206
  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)");
23040
23207
  }
23041
23208
  const mapping = st.paraMap.get(blockIndex);
23042
- if (!_optionalChain([mapping, 'optionalAccess', _217 => _217.para])) {
23209
+ if (!_optionalChain([mapping, 'optionalAccess', _237 => _237.para])) {
23043
23210
  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)");
23044
23211
  }
23045
23212
  let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
@@ -23059,14 +23226,14 @@ var HwpxSession = (_class4 = class _HwpxSession {
23059
23226
  if (sanitizeText(newPlain) !== newPlain) {
23060
23227
  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");
23061
23228
  }
23062
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _218 => _218.scans, 'access', _219 => _219[mapping.para.sectionIndex], 'optionalAccess', _220 => _220.xml]));
23229
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _238 => _238.scans, 'access', _239 => _239[mapping.para.sectionIndex], 'optionalAccess', _240 => _240.xml]));
23063
23230
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
23064
23231
  sectionSplices[mapping.para.sectionIndex].push(...splices);
23065
23232
  return 1;
23066
23233
  }
23067
23234
  }, _class4);
23068
23235
  function cellStaticCheck(table, scanTable, r, c) {
23069
- const irCell = _optionalChain([table, 'access', _221 => _221.cells, 'access', _222 => _222[r], 'optionalAccess', _223 => _223[c]]);
23236
+ const irCell = _optionalChain([table, 'access', _241 => _241.cells, 'access', _242 => _242[r], 'optionalAccess', _243 => _243[c]]);
23070
23237
  if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
23071
23238
  const cell = scanTable.cellByAnchor.get(`${r},${c}`);
23072
23239
  if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
@@ -23150,11 +23317,11 @@ var md = new (0, _markdownit2.default)({
23150
23317
  breaks: false
23151
23318
  });
23152
23319
  function renderHtml(markdown, options) {
23153
- const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _224 => _224.preset]), () => ( "default"));
23154
- const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _225 => _225.extraCss]), () => ( "")));
23320
+ const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _244 => _244.preset]), () => ( "default"));
23321
+ const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _245 => _245.extraCss]), () => ( "")));
23155
23322
  const body = md.render(markdown);
23156
- const watermark = _optionalChain([options, 'optionalAccess', _226 => _226.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
23157
- const watermarkCss = _optionalChain([options, 'optionalAccess', _227 => _227.watermark]) ? `
23323
+ const watermark = _optionalChain([options, 'optionalAccess', _246 => _246.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
23324
+ const watermarkCss = _optionalChain([options, 'optionalAccess', _247 => _247.watermark]) ? `
23158
23325
  .watermark {
23159
23326
  position: fixed;
23160
23327
  top: 50%; left: 50%;
@@ -23185,13 +23352,13 @@ async function htmlToPdf(html, options) {
23185
23352
  try {
23186
23353
  puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
23187
23354
  } catch (e34) {
23188
- throw new (0, _chunkYYKQN7SAcjs.KordocError)(
23355
+ throw new (0, _chunk4JLD2IT7cjs.KordocError)(
23189
23356
  "PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
23190
23357
  );
23191
23358
  }
23192
23359
  const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
23193
23360
  if (!executablePath) {
23194
- throw new (0, _chunkYYKQN7SAcjs.KordocError)(
23361
+ throw new (0, _chunk4JLD2IT7cjs.KordocError)(
23195
23362
  "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."
23196
23363
  );
23197
23364
  }
@@ -23203,10 +23370,10 @@ async function htmlToPdf(html, options) {
23203
23370
  try {
23204
23371
  const page = await browser.newPage();
23205
23372
  await page.setContent(html, { waitUntil: "networkidle0" });
23206
- const margin = _optionalChain([options, 'optionalAccess', _228 => _228.margin]);
23373
+ const margin = _optionalChain([options, 'optionalAccess', _248 => _248.margin]);
23207
23374
  const pdf = await page.pdf({
23208
- format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _229 => _229.pageSize]), () => ( "A4")),
23209
- landscape: _optionalChain([options, 'optionalAccess', _230 => _230.orientation]) === "landscape",
23375
+ format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _249 => _249.pageSize]), () => ( "A4")),
23376
+ landscape: _optionalChain([options, 'optionalAccess', _250 => _250.orientation]) === "landscape",
23210
23377
  printBackground: true,
23211
23378
  margin: margin ? {
23212
23379
  top: toCss(margin.top),
@@ -23214,9 +23381,9 @@ async function htmlToPdf(html, options) {
23214
23381
  bottom: toCss(margin.bottom),
23215
23382
  left: toCss(margin.left)
23216
23383
  } : void 0,
23217
- displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _231 => _231.header]) || _optionalChain([options, 'optionalAccess', _232 => _232.footer])),
23218
- headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _233 => _233.header]), () => ( "<div></div>")),
23219
- footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _234 => _234.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
23384
+ displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _251 => _251.header]) || _optionalChain([options, 'optionalAccess', _252 => _252.footer])),
23385
+ headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _253 => _253.header]), () => ( "<div></div>")),
23386
+ footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _254 => _254.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
23220
23387
  });
23221
23388
  return Buffer.from(pdf);
23222
23389
  } finally {
@@ -23250,24 +23417,24 @@ async function markdownToPdf(markdown, options) {
23250
23417
  return htmlToPdf(html, options);
23251
23418
  }
23252
23419
  async function blocksToPdf(blocks, options) {
23253
- const markdown = _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, blocks);
23420
+ const markdown = _chunk4JLD2IT7cjs.blocksToMarkdown.call(void 0, blocks);
23254
23421
  return markdownToPdf(markdown, options);
23255
23422
  }
23256
23423
 
23257
23424
  // src/index.ts
23258
23425
  async function parse(input, options) {
23259
23426
  let buffer;
23260
- const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _235 => _235.filePath]) ? { ...options, filePath: input } : options;
23427
+ const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _255 => _255.filePath]) ? { ...options, filePath: input } : options;
23261
23428
  if (typeof input === "string") {
23262
23429
  try {
23263
23430
  const buf = await _promises.readFile.call(void 0, input);
23264
- buffer = _chunkYYKQN7SAcjs.toArrayBuffer.call(void 0, buf);
23431
+ buffer = _chunk4JLD2IT7cjs.toArrayBuffer.call(void 0, buf);
23265
23432
  } catch (err) {
23266
23433
  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}`;
23267
23434
  return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
23268
23435
  }
23269
23436
  } else if (Buffer.isBuffer(input)) {
23270
- buffer = _chunkYYKQN7SAcjs.toArrayBuffer.call(void 0, input);
23437
+ buffer = _chunk4JLD2IT7cjs.toArrayBuffer.call(void 0, input);
23271
23438
  } else {
23272
23439
  buffer = input;
23273
23440
  }
@@ -23302,21 +23469,21 @@ async function parseHwp3(buffer, options) {
23302
23469
  const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
23303
23470
  return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
23304
23471
  } catch (err) {
23305
- return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkYYKQN7SAcjs.classifyError.call(void 0, err) };
23472
+ return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunk4JLD2IT7cjs.classifyError.call(void 0, err) };
23306
23473
  }
23307
23474
  }
23308
23475
  async function parseHwpx(buffer, options) {
23309
23476
  try {
23310
23477
  const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
23311
- return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _236 => _236.length]) ? images : void 0 };
23478
+ return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _256 => _256.length]) ? images : void 0 };
23312
23479
  } catch (err) {
23313
- return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkYYKQN7SAcjs.classifyError.call(void 0, err) };
23480
+ return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk4JLD2IT7cjs.classifyError.call(void 0, err) };
23314
23481
  }
23315
23482
  }
23316
23483
  async function parseHwp(buffer, options) {
23317
23484
  try {
23318
23485
  const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
23319
- if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _237 => _237.filePath])) {
23486
+ if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _257 => _257.filePath])) {
23320
23487
  try {
23321
23488
  const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
23322
23489
  if (pages.some((p) => p && p.trim().length > 0)) {
@@ -23333,15 +23500,15 @@ async function parseHwp(buffer, options) {
23333
23500
  } catch (e35) {
23334
23501
  }
23335
23502
  }
23336
- return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _238 => _238.length]) ? images : void 0 };
23503
+ return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _258 => _258.length]) ? images : void 0 };
23337
23504
  } catch (err) {
23338
- return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkYYKQN7SAcjs.classifyError.call(void 0, err) };
23505
+ return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunk4JLD2IT7cjs.classifyError.call(void 0, err) };
23339
23506
  }
23340
23507
  }
23341
23508
  async function parsePdf(buffer, options) {
23342
23509
  let parsePdfDocument;
23343
23510
  try {
23344
- const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-XDW6I25C.cjs")));
23511
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-25ISHR7Q.cjs")));
23345
23512
  parsePdfDocument = mod.parsePdfDocument;
23346
23513
  } catch (e36) {
23347
23514
  return {
@@ -23356,7 +23523,7 @@ async function parsePdf(buffer, options) {
23356
23523
  return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
23357
23524
  } catch (err) {
23358
23525
  const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
23359
- return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkYYKQN7SAcjs.classifyError.call(void 0, err), isImageBased };
23526
+ return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunk4JLD2IT7cjs.classifyError.call(void 0, err), isImageBased };
23360
23527
  }
23361
23528
  }
23362
23529
  async function parseXlsx(buffer, options) {
@@ -23364,7 +23531,7 @@ async function parseXlsx(buffer, options) {
23364
23531
  const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
23365
23532
  return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
23366
23533
  } catch (err) {
23367
- return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkYYKQN7SAcjs.classifyError.call(void 0, err) };
23534
+ return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk4JLD2IT7cjs.classifyError.call(void 0, err) };
23368
23535
  }
23369
23536
  }
23370
23537
  async function parseXls(buffer, options) {
@@ -23372,15 +23539,15 @@ async function parseXls(buffer, options) {
23372
23539
  const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
23373
23540
  return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
23374
23541
  } catch (err) {
23375
- return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkYYKQN7SAcjs.classifyError.call(void 0, err) };
23542
+ return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunk4JLD2IT7cjs.classifyError.call(void 0, err) };
23376
23543
  }
23377
23544
  }
23378
23545
  async function parseDocx(buffer, options) {
23379
23546
  try {
23380
23547
  const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
23381
- return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _239 => _239.length]) ? images : void 0 };
23548
+ return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _259 => _259.length]) ? images : void 0 };
23382
23549
  } catch (err) {
23383
- return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkYYKQN7SAcjs.classifyError.call(void 0, err) };
23550
+ return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk4JLD2IT7cjs.classifyError.call(void 0, err) };
23384
23551
  }
23385
23552
  }
23386
23553
  async function parseHwpml(buffer, options) {
@@ -23388,16 +23555,16 @@ async function parseHwpml(buffer, options) {
23388
23555
  const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
23389
23556
  return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
23390
23557
  } catch (err) {
23391
- return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkYYKQN7SAcjs.classifyError.call(void 0, err) };
23558
+ return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunk4JLD2IT7cjs.classifyError.call(void 0, err) };
23392
23559
  }
23393
23560
  }
23394
23561
  async function fillForm(input, values, outputFormat = "markdown") {
23395
23562
  let buffer;
23396
23563
  if (typeof input === "string") {
23397
23564
  const buf = await _promises.readFile.call(void 0, input);
23398
- buffer = _chunkYYKQN7SAcjs.toArrayBuffer.call(void 0, buf);
23565
+ buffer = _chunk4JLD2IT7cjs.toArrayBuffer.call(void 0, buf);
23399
23566
  } else if (Buffer.isBuffer(input)) {
23400
- buffer = _chunkYYKQN7SAcjs.toArrayBuffer.call(void 0, input);
23567
+ buffer = _chunk4JLD2IT7cjs.toArrayBuffer.call(void 0, input);
23401
23568
  } else {
23402
23569
  buffer = input;
23403
23570
  }
@@ -23423,7 +23590,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
23423
23590
  throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
23424
23591
  }
23425
23592
  const fill = fillFormFields(parsed.blocks, values);
23426
- const markdown = _chunkYYKQN7SAcjs.blocksToMarkdown.call(void 0, fill.blocks);
23593
+ const markdown = _chunk4JLD2IT7cjs.blocksToMarkdown.call(void 0, fill.blocks);
23427
23594
  if (outputFormat === "hwpx") {
23428
23595
  const hwpxBuffer = await markdownToHwpx(markdown);
23429
23596
  return { output: hwpxBuffer, format: "hwpx", fill };
@@ -23471,5 +23638,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
23471
23638
 
23472
23639
 
23473
23640
 
23474
- exports.HwpxSession = HwpxSession; exports.VERSION = _chunkYYKQN7SAcjs.VERSION; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkYYKQN7SAcjs.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;
23641
+
23642
+
23643
+ exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.VERSION = _chunk4JLD2IT7cjs.VERSION; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunk4JLD2IT7cjs.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.normalizeGongmunPreset = normalizeGongmunPreset; 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;
23475
23644
  //# sourceMappingURL=index.cjs.map