@harbour-enterprises/superdoc 0.22.1 → 0.23.0-next.2

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 (55) hide show
  1. package/dist/chunks/{PdfViewer-D2BPnEBG.cjs → PdfViewer-BItyloFT.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-CBmOiHsj.es.js → PdfViewer-MPmm-SUD.es.js} +1 -1
  3. package/dist/chunks/{index-B0CI50e4.cjs → index-CdJOxoqt.cjs} +2 -2
  4. package/dist/chunks/{index-BSDcfSFc.es.js → index-OVF3JhUR.es.js} +2 -2
  5. package/dist/chunks/{super-editor.es-DOOwW-Iv.cjs → super-editor.es-C7stybby.cjs} +1608 -1032
  6. package/dist/chunks/{super-editor.es-BW1T3N2-.es.js → super-editor.es-DQnqUJZs.es.js} +1608 -1032
  7. package/dist/style.css +3 -0
  8. package/dist/super-editor/ai-writer.es.js +2 -2
  9. package/dist/super-editor/chunks/{converter-UuZxU-p8.js → converter-BVirrB35.js} +1463 -1028
  10. package/dist/super-editor/chunks/{docx-zipper-Bss48sB0.js → docx-zipper-Cpb9d2an.js} +1 -1
  11. package/dist/super-editor/chunks/{editor--v3HbUU0.js → editor-DIINh50j.js} +151 -10
  12. package/dist/super-editor/chunks/{toolbar-BeXlvdV8.js → toolbar-CmDmkPHL.js} +2 -2
  13. package/dist/super-editor/converter.es.js +1 -1
  14. package/dist/super-editor/docx-zipper.es.js +2 -2
  15. package/dist/super-editor/editor.es.js +3 -3
  16. package/dist/super-editor/file-zipper.es.js +1 -1
  17. package/dist/super-editor/src/core/super-converter/exporter.d.ts +4 -4
  18. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/hyperlink-preprocessor.d.ts +9 -0
  19. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/index.d.ts +2 -0
  20. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/num-pages-preprocessor.d.ts +9 -0
  21. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-preprocessor.d.ts +9 -0
  22. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-ref-preprocessor.d.ts +9 -0
  23. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/toc-preprocessor.d.ts +8 -0
  24. package/dist/super-editor/src/core/super-converter/field-references/index.d.ts +1 -0
  25. package/dist/super-editor/src/core/super-converter/field-references/preProcessNodesForFldChar.d.ts +21 -0
  26. package/dist/super-editor/src/core/super-converter/v2/exporter/helpers/translateChildNodes.d.ts +3 -3
  27. package/dist/super-editor/src/core/super-converter/v2/importer/pageReferenceImporter.d.ts +4 -0
  28. package/dist/super-editor/src/core/super-converter/v2/importer/tableOfContentsImporter.d.ts +4 -0
  29. package/dist/super-editor/src/core/super-converter/v2/types/index.d.ts +7 -1
  30. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/index.d.ts +1 -0
  31. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/pageReference-translator.d.ts +7 -0
  32. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/index.d.ts +1 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/tableOfContents-translator.d.ts +10 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/w/caps/caps-translator.d.ts +7 -0
  35. package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +0 -2
  36. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/handle-doc-part-obj.d.ts +9 -1
  37. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/translate-document-part-obj.d.ts +6 -0
  38. package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +2 -2
  39. package/dist/super-editor/src/extensions/page-reference/index.d.ts +1 -0
  40. package/dist/super-editor/src/extensions/page-reference/page-reference.d.ts +2 -0
  41. package/dist/super-editor/src/extensions/structured-content/document-part-object.d.ts +2 -0
  42. package/dist/super-editor/src/extensions/structured-content/index.d.ts +1 -0
  43. package/dist/super-editor/src/extensions/tab/helpers/tabDecorations.d.ts +2 -2
  44. package/dist/super-editor/src/extensions/table-of-contents/index.d.ts +1 -0
  45. package/dist/super-editor/src/extensions/table-of-contents/table-of-contents.d.ts +2 -0
  46. package/dist/super-editor/style.css +3 -0
  47. package/dist/super-editor/super-editor.es.js +10 -8
  48. package/dist/super-editor/toolbar.es.js +2 -2
  49. package/dist/super-editor.cjs +1 -1
  50. package/dist/super-editor.es.js +1 -1
  51. package/dist/superdoc.cjs +2 -2
  52. package/dist/superdoc.es.js +2 -2
  53. package/dist/superdoc.umd.js +1608 -1032
  54. package/dist/superdoc.umd.js.map +1 -1
  55. package/package.json +1 -1
@@ -22966,13 +22966,56 @@ function translateChildNodes(params) {
22966
22966
  const { content: nodes } = params.node;
22967
22967
  if (!nodes) return [];
22968
22968
  const translatedNodes = [];
22969
- nodes.forEach((node) => {
22969
+ const hyperlinkGroup = [];
22970
+ let index = 0;
22971
+ while (index < nodes.length) {
22972
+ const node = nodes[index];
22973
+ const linkMark = _isLinkNode(node);
22974
+ if (linkMark) {
22975
+ hyperlinkGroup.push(node);
22976
+ const nextNode = index + 1 < nodes.length ? nodes[index + 1] : null;
22977
+ const nextIsLink = _isLinkNode(nextNode, linkMark);
22978
+ if (nextIsLink) {
22979
+ index++;
22980
+ continue;
22981
+ } else {
22982
+ let translatedLinkGroup = exportSchemaToJson({
22983
+ ...params,
22984
+ node: hyperlinkGroup[0],
22985
+ extraParams: { ...params.extraParams || {}, hyperlinkGroup: hyperlinkGroup.slice() }
22986
+ });
22987
+ if (translatedLinkGroup instanceof Array) translatedNodes.push(...translatedLinkGroup);
22988
+ else translatedNodes.push(translatedLinkGroup);
22989
+ hyperlinkGroup.length = 0;
22990
+ index++;
22991
+ continue;
22992
+ }
22993
+ }
22970
22994
  let translatedNode = exportSchemaToJson({ ...params, node });
22971
22995
  if (translatedNode instanceof Array) translatedNodes.push(...translatedNode);
22972
22996
  else translatedNodes.push(translatedNode);
22973
- });
22997
+ index++;
22998
+ }
22974
22999
  return translatedNodes.filter((n) => n);
22975
23000
  }
23001
+ function _isLinkNode(node, referenceMark = null) {
23002
+ if (!node || !node.marks && !node.attrs?.marksAsAttrs) return null;
23003
+ const marks = node.marks || node.attrs.marksAsAttrs;
23004
+ const linkMark = marks.find((mark) => mark.type === "link");
23005
+ if (!linkMark) return null;
23006
+ if (referenceMark) {
23007
+ return _isSameLinkMark(linkMark.attrs, referenceMark.attrs) ? linkMark : null;
23008
+ }
23009
+ return linkMark;
23010
+ }
23011
+ function _isSameLinkMark(attrsA, attrsB) {
23012
+ for (let key of ["anchor", "docLocation", "history", "href", "rId", "target"]) {
23013
+ if (attrsA[key] != attrsB[key]) {
23014
+ return false;
23015
+ }
23016
+ }
23017
+ return true;
23018
+ }
22976
23019
  const baseNumbering = {
22977
23020
  declaration: {
22978
23021
  attributes: {
@@ -24328,37 +24371,37 @@ const _NodeTranslator = class _NodeTranslator {
24328
24371
  /** @type {typeof TranslatorTypes} */
24329
24372
  __publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
24330
24373
  let NodeTranslator = _NodeTranslator;
24331
- const encode$18 = (attributes) => {
24374
+ const encode$1b = (attributes) => {
24332
24375
  return attributes["w:type"];
24333
24376
  };
24334
- const decode$$ = (attrs) => {
24377
+ const decode$11 = (attrs) => {
24335
24378
  const { lineBreakType } = attrs;
24336
24379
  return lineBreakType;
24337
24380
  };
24338
24381
  const attrConfig$F = Object.freeze({
24339
24382
  xmlName: "w:type",
24340
24383
  sdName: "lineBreakType",
24341
- encode: encode$18,
24342
- decode: decode$$
24384
+ encode: encode$1b,
24385
+ decode: decode$11
24343
24386
  });
24344
- const encode$17 = (attributes) => {
24387
+ const encode$1a = (attributes) => {
24345
24388
  const xmlAttrValue = attributes["w:clear"];
24346
24389
  return xmlAttrValue;
24347
24390
  };
24348
- const decode$_ = (attrs) => {
24391
+ const decode$10 = (attrs) => {
24349
24392
  const { clear } = attrs;
24350
24393
  return clear;
24351
24394
  };
24352
24395
  const attrConfig$E = Object.freeze({
24353
24396
  xmlName: "w:clear",
24354
24397
  sdName: "clear",
24355
- encode: encode$17,
24356
- decode: decode$_
24398
+ encode: encode$1a,
24399
+ decode: decode$10
24357
24400
  });
24358
24401
  const validXmlAttributes$m = [attrConfig$F, attrConfig$E];
24359
- const XML_NODE_NAME$u = "w:br";
24360
- const SD_NODE_NAME$d = "lineBreak";
24361
- const encode$16 = (_2, encodedAttrs) => {
24402
+ const XML_NODE_NAME$x = "w:br";
24403
+ const SD_NODE_NAME$f = "lineBreak";
24404
+ const encode$19 = (_2, encodedAttrs) => {
24362
24405
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24363
24406
  const translated = {
24364
24407
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24368,7 +24411,7 @@ const encode$16 = (_2, encodedAttrs) => {
24368
24411
  }
24369
24412
  return translated;
24370
24413
  };
24371
- const decode$Z = (params, decodedAttrs) => {
24414
+ const decode$$ = (params, decodedAttrs) => {
24372
24415
  const { node } = params;
24373
24416
  if (!node) return;
24374
24417
  const wBreak = { name: "w:br" };
@@ -24385,39 +24428,39 @@ const decode$Z = (params, decodedAttrs) => {
24385
24428
  };
24386
24429
  return translated;
24387
24430
  };
24388
- const config$s = {
24389
- xmlName: XML_NODE_NAME$u,
24390
- sdNodeOrKeyName: SD_NODE_NAME$d,
24431
+ const config$v = {
24432
+ xmlName: XML_NODE_NAME$x,
24433
+ sdNodeOrKeyName: SD_NODE_NAME$f,
24391
24434
  type: NodeTranslator.translatorTypes.NODE,
24392
- encode: encode$16,
24393
- decode: decode$Z,
24435
+ encode: encode$19,
24436
+ decode: decode$$,
24394
24437
  attributes: validXmlAttributes$m
24395
24438
  };
24396
- const translator$16 = NodeTranslator.from(config$s);
24397
- const encode$15 = (attributes) => attributes?.["w:val"];
24398
- const decode$Y = (attrs) => attrs?.highlight;
24439
+ const translator$19 = NodeTranslator.from(config$v);
24440
+ const encode$18 = (attributes) => attributes?.["w:val"];
24441
+ const decode$_ = (attrs) => attrs?.highlight;
24399
24442
  const attrConfig$D = Object.freeze({
24400
24443
  xmlName: "w:val",
24401
24444
  sdName: "highlight",
24402
- encode: encode$15,
24403
- decode: decode$Y
24445
+ encode: encode$18,
24446
+ decode: decode$_
24404
24447
  });
24405
24448
  const validXmlAttributes$l = [attrConfig$D];
24406
- const XML_NODE_NAME$t = "w:highlight";
24407
- const SD_ATTR_KEY$f = "highlight";
24449
+ const XML_NODE_NAME$w = "w:highlight";
24450
+ const SD_ATTR_KEY$g = "highlight";
24408
24451
  const DISABLED_TOKENS = /* @__PURE__ */ new Set(["transparent", "none", "inherit"]);
24409
- const encode$14 = (params, encodedAttrs = {}) => {
24452
+ const encode$17 = (params, encodedAttrs = {}) => {
24410
24453
  const { nodes } = params;
24411
24454
  const node = nodes?.[0];
24412
24455
  const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
24413
24456
  return {
24414
24457
  type: "attr",
24415
- xmlName: XML_NODE_NAME$t,
24416
- sdNodeOrKeyName: SD_ATTR_KEY$f,
24458
+ xmlName: XML_NODE_NAME$w,
24459
+ sdNodeOrKeyName: SD_ATTR_KEY$g,
24417
24460
  attributes: { "w:val": value ?? null }
24418
24461
  };
24419
24462
  };
24420
- const decode$X = (params) => {
24463
+ const decode$Z = (params) => {
24421
24464
  const attrs = params?.node?.attrs || {};
24422
24465
  const highlightValue = attrs.highlight ?? attrs.color ?? null;
24423
24466
  if (!highlightValue) return void 0;
@@ -24425,14 +24468,14 @@ const decode$X = (params) => {
24425
24468
  if (!normalizedValue) return void 0;
24426
24469
  if (DISABLED_TOKENS.has(normalizedValue)) {
24427
24470
  return {
24428
- name: XML_NODE_NAME$t,
24471
+ name: XML_NODE_NAME$w,
24429
24472
  attributes: { "w:val": "none" }
24430
24473
  };
24431
24474
  }
24432
24475
  const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24433
24476
  if (keyword) {
24434
24477
  return {
24435
- name: XML_NODE_NAME$t,
24478
+ name: XML_NODE_NAME$w,
24436
24479
  attributes: { "w:val": keyword }
24437
24480
  };
24438
24481
  }
@@ -24447,63 +24490,63 @@ const decode$X = (params) => {
24447
24490
  }
24448
24491
  };
24449
24492
  };
24450
- const config$r = {
24451
- xmlName: XML_NODE_NAME$t,
24452
- sdNodeOrKeyName: SD_ATTR_KEY$f,
24493
+ const config$u = {
24494
+ xmlName: XML_NODE_NAME$w,
24495
+ sdNodeOrKeyName: SD_ATTR_KEY$g,
24453
24496
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
24454
- encode: encode$14,
24455
- decode: decode$X,
24497
+ encode: encode$17,
24498
+ decode: decode$Z,
24456
24499
  attributes: validXmlAttributes$l
24457
24500
  };
24458
- const translator$15 = NodeTranslator.from(config$r);
24459
- const encode$13 = (attributes) => {
24501
+ const translator$18 = NodeTranslator.from(config$u);
24502
+ const encode$16 = (attributes) => {
24460
24503
  return attributes["w:val"];
24461
24504
  };
24462
- const decode$W = (attrs) => {
24505
+ const decode$Y = (attrs) => {
24463
24506
  const { tabSize } = attrs || {};
24464
24507
  return tabSize;
24465
24508
  };
24466
24509
  const attrConfig$C = Object.freeze({
24467
24510
  xmlName: "w:val",
24468
24511
  sdName: "tabSize",
24469
- encode: encode$13,
24470
- decode: decode$W
24512
+ encode: encode$16,
24513
+ decode: decode$Y
24471
24514
  });
24472
- const encode$12 = (attributes) => {
24515
+ const encode$15 = (attributes) => {
24473
24516
  return attributes["w:leader"];
24474
24517
  };
24475
- const decode$V = (attrs) => {
24518
+ const decode$X = (attrs) => {
24476
24519
  const { leader } = attrs || {};
24477
24520
  return leader;
24478
24521
  };
24479
24522
  const attrConfig$B = Object.freeze({
24480
24523
  xmlName: "w:leader",
24481
24524
  sdName: "leader",
24482
- encode: encode$12,
24483
- decode: decode$V
24525
+ encode: encode$15,
24526
+ decode: decode$X
24484
24527
  });
24485
- const encode$11 = (attributes) => {
24528
+ const encode$14 = (attributes) => {
24486
24529
  return attributes["w:pos"];
24487
24530
  };
24488
- const decode$U = (attrs) => {
24531
+ const decode$W = (attrs) => {
24489
24532
  const { pos } = attrs || {};
24490
24533
  return pos;
24491
24534
  };
24492
24535
  const attrConfig$A = Object.freeze({
24493
24536
  xmlName: "w:pos",
24494
24537
  sdName: "pos",
24495
- encode: encode$11,
24496
- decode: decode$U
24538
+ encode: encode$14,
24539
+ decode: decode$W
24497
24540
  });
24498
24541
  const validXmlAttributes$k = [attrConfig$C, attrConfig$A, attrConfig$B];
24499
- const XML_NODE_NAME$s = "w:tab";
24500
- const SD_NODE_NAME$c = "tab";
24501
- const encode$10 = (_2, encodedAttrs = {}) => {
24542
+ const XML_NODE_NAME$v = "w:tab";
24543
+ const SD_NODE_NAME$e = "tab";
24544
+ const encode$13 = (_2, encodedAttrs = {}) => {
24502
24545
  const translated = { type: "tab" };
24503
24546
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24504
24547
  return translated;
24505
24548
  };
24506
- const decode$T = (params, decodedAttrs = {}) => {
24549
+ const decode$V = (params, decodedAttrs = {}) => {
24507
24550
  const { node } = params || {};
24508
24551
  if (!node) return;
24509
24552
  const wTab = { name: "w:tab" };
@@ -24519,15 +24562,15 @@ const decode$T = (params, decodedAttrs = {}) => {
24519
24562
  }
24520
24563
  return translated;
24521
24564
  };
24522
- const config$q = {
24523
- xmlName: XML_NODE_NAME$s,
24524
- sdNodeOrKeyName: SD_NODE_NAME$c,
24565
+ const config$t = {
24566
+ xmlName: XML_NODE_NAME$v,
24567
+ sdNodeOrKeyName: SD_NODE_NAME$e,
24525
24568
  type: NodeTranslator.translatorTypes.NODE,
24526
- encode: encode$10,
24527
- decode: decode$T,
24569
+ encode: encode$13,
24570
+ decode: decode$V,
24528
24571
  attributes: validXmlAttributes$k
24529
24572
  };
24530
- const translator$14 = NodeTranslator.from(config$q);
24573
+ const translator$17 = NodeTranslator.from(config$t);
24531
24574
  const mergeTextNodes = (nodes) => {
24532
24575
  if (!nodes || !Array.isArray(nodes)) {
24533
24576
  return nodes;
@@ -24901,104 +24944,10 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
24901
24944
  justify: pPrByIdJcAttr
24902
24945
  };
24903
24946
  };
24904
- const preProcessNodesForFldChar = (nodes = []) => {
24905
- const processedNodes = [];
24906
- let buffer2 = [];
24907
- let collecting = false;
24908
- for (const node of nodes) {
24909
- const fldCharEl = node.elements?.find((el) => el.name === "w:fldChar");
24910
- const fldType = fldCharEl?.attributes?.["w:fldCharType"];
24911
- if (fldType === "begin") {
24912
- buffer2 = [node];
24913
- collecting = true;
24914
- continue;
24915
- }
24916
- if (fldType === "separate" && collecting) {
24917
- buffer2.push(node);
24918
- continue;
24919
- }
24920
- if (fldType === "end" && collecting) {
24921
- buffer2.push(node);
24922
- processedNodes.push(...processCombinedNodesForFldChar(buffer2));
24923
- buffer2 = [];
24924
- collecting = false;
24925
- continue;
24926
- }
24927
- if (collecting) {
24928
- buffer2.push(node);
24929
- } else {
24930
- processedNodes.push(node);
24931
- }
24932
- }
24933
- if (buffer2.length) {
24934
- processedNodes.push(...buffer2);
24935
- }
24936
- return processedNodes;
24937
- };
24938
- const processCombinedNodesForFldChar = (nodesToCombine = []) => {
24939
- let processedNodes = [];
24940
- let hasPageMarker = false;
24941
- let isNumPages = false;
24942
- const textStart = nodesToCombine.findIndex(
24943
- (n) => n.elements?.some((el) => el.name === "w:fldChar" && el.attributes["w:fldCharType"] === "separate")
24944
- );
24945
- const textEnd = nodesToCombine.findIndex(
24946
- (n) => n.elements?.some((el) => el.name === "w:fldChar" && el.attributes["w:fldCharType"] === "end")
24947
- );
24948
- const textNodes = nodesToCombine.slice(textStart + 1, textEnd);
24949
- const instrTextContainer = nodesToCombine.find((n) => n.elements?.some((el) => el.name === "w:instrText"));
24950
- const instrTextNode = instrTextContainer?.elements?.find((el) => el.name === "w:instrText");
24951
- const instrText = instrTextNode?.elements[0].text;
24952
- if (!hasPageMarker) hasPageMarker = instrText?.trim().startsWith("PAGE");
24953
- if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
24954
- const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
24955
- if (hasPageMarker) {
24956
- const pageNumNode = {
24957
- name: "sd:autoPageNumber",
24958
- type: "element"
24959
- };
24960
- nodesToCombine.forEach((n) => {
24961
- const rPrNode = n.elements.find((el) => el.name === "w:rPr");
24962
- if (rPrNode) pageNumNode.elements = [rPrNode];
24963
- });
24964
- processedNodes.push(pageNumNode);
24965
- } else if (isNumPages) {
24966
- const totalPageNumNode = {
24967
- name: "sd:totalPageNumber",
24968
- type: "element"
24969
- };
24970
- nodesToCombine.forEach((n) => {
24971
- const rPrNode = n.elements.find((el) => el.name === "w:rPr");
24972
- if (rPrNode) totalPageNumNode.elements = [rPrNode];
24973
- });
24974
- processedNodes.push(totalPageNumNode);
24975
- } else if (urlMatch && urlMatch?.length >= 2) {
24976
- const url = urlMatch[1];
24977
- const textMarks = [];
24978
- textNodes.forEach((n) => {
24979
- const rPr2 = n.elements.find((el) => el.name === "w:rPr");
24980
- if (!rPr2) return;
24981
- const { elements } = rPr2;
24982
- elements.forEach((el) => {
24983
- textMarks.push(el);
24984
- });
24985
- });
24986
- const linkMark = { name: "link", attributes: { href: url } };
24987
- const rPr = { name: "w:rPr", type: "element", elements: [linkMark, ...textMarks] };
24988
- processedNodes.push({
24989
- name: "w:r",
24990
- type: "element",
24991
- elements: [rPr, ...textNodes]
24992
- });
24993
- }
24994
- return processedNodes;
24995
- };
24996
24947
  const handleParagraphNode$1 = (params) => {
24997
24948
  const { nodes, docx, nodeListHandler, filename } = params;
24998
24949
  const node = carbonCopy(nodes[0]);
24999
24950
  let schemaNode;
25000
- let processedElements = preProcessNodesForFldChar(node.elements);
25001
- node.elements = processedElements;
25002
24951
  const handleStandardNode2 = nodeListHandler.handlerEntities.find(
25003
24952
  (e) => e.handlerName === "standardNodeHandler"
25004
24953
  )?.handler;
@@ -25139,89 +25088,89 @@ const handleParagraphNode$1 = (params) => {
25139
25088
  }
25140
25089
  return schemaNode;
25141
25090
  };
25142
- const encode$$ = (attributes) => {
25091
+ const encode$12 = (attributes) => {
25143
25092
  return attributes["w:rsidDel"];
25144
25093
  };
25145
- const decode$S = (attrs) => {
25094
+ const decode$U = (attrs) => {
25146
25095
  return attrs.rsidDel;
25147
25096
  };
25148
25097
  const attrConfig$z = Object.freeze({
25149
25098
  xmlName: "w:rsidDel",
25150
25099
  sdName: "rsidDel",
25151
- encode: encode$$,
25152
- decode: decode$S
25100
+ encode: encode$12,
25101
+ decode: decode$U
25153
25102
  });
25154
- const encode$_ = (attributes) => {
25103
+ const encode$11 = (attributes) => {
25155
25104
  return attributes["w:rsidP"];
25156
25105
  };
25157
- const decode$R = (attrs) => {
25106
+ const decode$T = (attrs) => {
25158
25107
  return attrs.rsidP;
25159
25108
  };
25160
25109
  const attrConfig$y = Object.freeze({
25161
25110
  xmlName: "w:rsidP",
25162
25111
  sdName: "rsidP",
25163
- encode: encode$_,
25164
- decode: decode$R
25112
+ encode: encode$11,
25113
+ decode: decode$T
25165
25114
  });
25166
- const encode$Z = (attributes) => {
25115
+ const encode$10 = (attributes) => {
25167
25116
  return attributes["w:rsidR"];
25168
25117
  };
25169
- const decode$Q = (attrs) => {
25118
+ const decode$S = (attrs) => {
25170
25119
  return attrs.rsidR;
25171
25120
  };
25172
25121
  const attrConfig$x = Object.freeze({
25173
25122
  xmlName: "w:rsidR",
25174
25123
  sdName: "rsidR",
25175
- encode: encode$Z,
25176
- decode: decode$Q
25124
+ encode: encode$10,
25125
+ decode: decode$S
25177
25126
  });
25178
- const encode$Y = (attributes) => {
25127
+ const encode$$ = (attributes) => {
25179
25128
  return attributes["w:rsidRPr"];
25180
25129
  };
25181
- const decode$P = (attrs) => {
25130
+ const decode$R = (attrs) => {
25182
25131
  return attrs.rsidRPr;
25183
25132
  };
25184
25133
  const attrConfig$w = Object.freeze({
25185
25134
  xmlName: "w:rsidRPr",
25186
25135
  sdName: "rsidRPr",
25187
- encode: encode$Y,
25188
- decode: decode$P
25136
+ encode: encode$$,
25137
+ decode: decode$R
25189
25138
  });
25190
- const encode$X = (attributes) => {
25139
+ const encode$_ = (attributes) => {
25191
25140
  return attributes["w:rsidRDefault"];
25192
25141
  };
25193
- const decode$O = (attrs) => {
25142
+ const decode$Q = (attrs) => {
25194
25143
  return attrs.rsidRDefault;
25195
25144
  };
25196
25145
  const attrConfig$v = Object.freeze({
25197
25146
  xmlName: "w:rsidRDefault",
25198
25147
  sdName: "rsidRDefault",
25199
- encode: encode$X,
25200
- decode: decode$O
25148
+ encode: encode$_,
25149
+ decode: decode$Q
25201
25150
  });
25202
- const encode$W = (attributes) => {
25151
+ const encode$Z = (attributes) => {
25203
25152
  return attributes["w14:paraId"];
25204
25153
  };
25205
- const decode$N = (attrs) => {
25154
+ const decode$P = (attrs) => {
25206
25155
  return attrs.paraId;
25207
25156
  };
25208
25157
  const attrConfig$u = Object.freeze({
25209
25158
  xmlName: "w14:paraId",
25210
25159
  sdName: "paraId",
25211
- encode: encode$W,
25212
- decode: decode$N
25160
+ encode: encode$Z,
25161
+ decode: decode$P
25213
25162
  });
25214
- const encode$V = (attributes) => {
25163
+ const encode$Y = (attributes) => {
25215
25164
  return attributes["w14:textId"];
25216
25165
  };
25217
- const decode$M = (attrs) => {
25166
+ const decode$O = (attrs) => {
25218
25167
  return attrs.textId;
25219
25168
  };
25220
25169
  const attrConfig$t = Object.freeze({
25221
25170
  xmlName: "w14:textId",
25222
25171
  sdName: "textId",
25223
- encode: encode$V,
25224
- decode: decode$M
25172
+ encode: encode$Y,
25173
+ decode: decode$O
25225
25174
  });
25226
25175
  const validXmlAttributes$j = [
25227
25176
  attrConfig$u,
@@ -25232,9 +25181,9 @@ const validXmlAttributes$j = [
25232
25181
  attrConfig$w,
25233
25182
  attrConfig$z
25234
25183
  ];
25235
- const XML_NODE_NAME$r = "w:p";
25236
- const SD_NODE_NAME$b = "paragraph";
25237
- const encode$U = (params, encodedAttrs = {}) => {
25184
+ const XML_NODE_NAME$u = "w:p";
25185
+ const SD_NODE_NAME$d = "paragraph";
25186
+ const encode$X = (params, encodedAttrs = {}) => {
25238
25187
  const node = handleParagraphNode$1(params);
25239
25188
  if (!node) return void 0;
25240
25189
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25242,7 +25191,7 @@ const encode$U = (params, encodedAttrs = {}) => {
25242
25191
  }
25243
25192
  return node;
25244
25193
  };
25245
- const decode$L = (params, decodedAttrs = {}) => {
25194
+ const decode$N = (params, decodedAttrs = {}) => {
25246
25195
  const translated = translateParagraphNode(params);
25247
25196
  if (!translated) return void 0;
25248
25197
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25250,16 +25199,16 @@ const decode$L = (params, decodedAttrs = {}) => {
25250
25199
  }
25251
25200
  return translated;
25252
25201
  };
25253
- const config$p = {
25254
- xmlName: XML_NODE_NAME$r,
25255
- sdNodeOrKeyName: SD_NODE_NAME$b,
25202
+ const config$s = {
25203
+ xmlName: XML_NODE_NAME$u,
25204
+ sdNodeOrKeyName: SD_NODE_NAME$d,
25256
25205
  type: NodeTranslator.translatorTypes.NODE,
25257
- encode: encode$U,
25258
- decode: decode$L,
25206
+ encode: encode$X,
25207
+ decode: decode$N,
25259
25208
  attributes: validXmlAttributes$j
25260
25209
  };
25261
- const translator$13 = NodeTranslator.from(config$p);
25262
- const encode$T = (attributes) => {
25210
+ const translator$16 = NodeTranslator.from(config$s);
25211
+ const encode$W = (attributes) => {
25263
25212
  const raw = attributes?.["w:val"];
25264
25213
  if (raw === void 0 || raw === null) return void 0;
25265
25214
  if (typeof raw === "boolean") return raw;
@@ -25269,24 +25218,24 @@ const encode$T = (attributes) => {
25269
25218
  if (val === "1" || val === "true" || val === "on") return true;
25270
25219
  return void 0;
25271
25220
  };
25272
- const decode$K = (runProps) => {
25221
+ const decode$M = (runProps) => {
25273
25222
  if (runProps?.bold === false) return "0";
25274
25223
  return void 0;
25275
25224
  };
25276
25225
  const attrConfig$s = Object.freeze({
25277
25226
  xmlName: "w:val",
25278
25227
  sdName: "bold",
25279
- encode: encode$T,
25280
- decode: decode$K
25228
+ encode: encode$W,
25229
+ decode: decode$M
25281
25230
  });
25282
25231
  const validXmlAttributes$i = [attrConfig$s];
25283
- const XML_NODE_NAME$q = "w:b";
25284
- const SD_ATTR_KEY$e = "bold";
25285
- const encode$S = (params, encodedAttrs = {}) => {
25232
+ const XML_NODE_NAME$t = "w:b";
25233
+ const SD_ATTR_KEY$f = "bold";
25234
+ const encode$V = (params, encodedAttrs = {}) => {
25286
25235
  const { nodes } = params;
25287
25236
  const node = nodes[0];
25288
25237
  if (!node) return void 0;
25289
- const val = encodedAttrs?.[SD_ATTR_KEY$e];
25238
+ const val = encodedAttrs?.[SD_ATTR_KEY$f];
25290
25239
  let attributes;
25291
25240
  if (val === false) attributes = { "w:val": "0" };
25292
25241
  else if (val === true)
@@ -25294,85 +25243,85 @@ const encode$S = (params, encodedAttrs = {}) => {
25294
25243
  else attributes = node.attributes || {};
25295
25244
  return {
25296
25245
  type: "attr",
25297
- xmlName: XML_NODE_NAME$q,
25298
- sdNodeOrKeyName: SD_ATTR_KEY$e,
25246
+ xmlName: XML_NODE_NAME$t,
25247
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
25299
25248
  attributes
25300
25249
  };
25301
25250
  };
25302
- const config$o = {
25303
- xmlName: XML_NODE_NAME$q,
25304
- sdNodeOrKeyName: SD_ATTR_KEY$e,
25251
+ const config$r = {
25252
+ xmlName: XML_NODE_NAME$t,
25253
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
25305
25254
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25306
- encode: encode$S,
25255
+ encode: encode$V,
25307
25256
  attributes: validXmlAttributes$i
25308
25257
  };
25309
- const translator$12 = NodeTranslator.from(config$o);
25310
- const XML_NODE_NAME$p = "w:i";
25311
- const SD_ATTR_KEY$d = "italic";
25312
- const encode$R = (params) => {
25258
+ const translator$15 = NodeTranslator.from(config$r);
25259
+ const XML_NODE_NAME$s = "w:i";
25260
+ const SD_ATTR_KEY$e = "italic";
25261
+ const encode$U = (params) => {
25313
25262
  const { nodes } = params;
25314
25263
  const node = nodes?.[0];
25315
25264
  if (!node) return void 0;
25316
25265
  return {
25317
25266
  type: "attr",
25318
- xmlName: XML_NODE_NAME$p,
25319
- sdNodeOrKeyName: SD_ATTR_KEY$d,
25267
+ xmlName: XML_NODE_NAME$s,
25268
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
25320
25269
  attributes: {
25321
25270
  "w:val": node.attributes?.["w:val"] ?? null
25322
25271
  }
25323
25272
  };
25324
25273
  };
25325
- const config$n = {
25326
- xmlName: XML_NODE_NAME$p,
25327
- sdNodeOrKeyName: SD_ATTR_KEY$d,
25274
+ const config$q = {
25275
+ xmlName: XML_NODE_NAME$s,
25276
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
25328
25277
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25329
- encode: encode$R
25278
+ encode: encode$U
25330
25279
  };
25331
- const translator$11 = NodeTranslator.from(config$n);
25332
- const encode$Q = (attributes) => attributes?.["w:val"];
25333
- const decode$J = (attrs) => attrs?.underline;
25280
+ const translator$14 = NodeTranslator.from(config$q);
25281
+ const encode$T = (attributes) => attributes?.["w:val"];
25282
+ const decode$L = (attrs) => attrs?.underline;
25334
25283
  const attrConfig$r = Object.freeze({
25335
25284
  xmlName: "w:val",
25336
25285
  sdName: "underline",
25337
- encode: encode$Q,
25338
- decode: decode$J
25286
+ encode: encode$T,
25287
+ decode: decode$L
25339
25288
  });
25340
- const encode$P = (attributes) => attributes?.["w:color"];
25341
- const decode$I = (attrs) => attrs?.color;
25289
+ const encode$S = (attributes) => attributes?.["w:color"];
25290
+ const decode$K = (attrs) => attrs?.color;
25342
25291
  const attrConfig$q = Object.freeze({
25343
25292
  xmlName: "w:color",
25344
25293
  sdName: "color",
25345
- encode: encode$P,
25346
- decode: decode$I
25294
+ encode: encode$S,
25295
+ decode: decode$K
25347
25296
  });
25348
- const encode$O = (attributes) => attributes?.["w:themeColor"];
25349
- const decode$H = (attrs) => attrs?.themeColor;
25297
+ const encode$R = (attributes) => attributes?.["w:themeColor"];
25298
+ const decode$J = (attrs) => attrs?.themeColor;
25350
25299
  const attrConfig$p = Object.freeze({
25351
25300
  xmlName: "w:themeColor",
25352
25301
  sdName: "themeColor",
25353
- encode: encode$O,
25354
- decode: decode$H
25302
+ encode: encode$R,
25303
+ decode: decode$J
25355
25304
  });
25356
- const encode$N = (attributes) => attributes?.["w:themeTint"];
25357
- const decode$G = (attrs) => attrs?.themeTint;
25305
+ const encode$Q = (attributes) => attributes?.["w:themeTint"];
25306
+ const decode$I = (attrs) => attrs?.themeTint;
25358
25307
  const attrConfig$o = Object.freeze({
25359
25308
  xmlName: "w:themeTint",
25360
25309
  sdName: "themeTint",
25361
- encode: encode$N,
25362
- decode: decode$G
25310
+ encode: encode$Q,
25311
+ decode: decode$I
25363
25312
  });
25364
- const encode$M = (attributes) => attributes?.["w:themeShade"];
25365
- const decode$F = (attrs) => attrs?.themeShade;
25313
+ const encode$P = (attributes) => attributes?.["w:themeShade"];
25314
+ const decode$H = (attrs) => attrs?.themeShade;
25366
25315
  const attrConfig$n = Object.freeze({
25367
25316
  xmlName: "w:themeShade",
25368
25317
  sdName: "themeShade",
25369
- encode: encode$M,
25370
- decode: decode$F
25318
+ encode: encode$P,
25319
+ decode: decode$H
25371
25320
  });
25372
25321
  const validXmlAttributes$h = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
25373
- const XML_NODE_NAME$o = "w:u";
25374
- const SD_ATTR_KEY$c = "underline";
25375
- const encode$L = (params, encodedAttrs = {}) => {
25322
+ const XML_NODE_NAME$r = "w:u";
25323
+ const SD_ATTR_KEY$d = "underline";
25324
+ const encode$O = (params, encodedAttrs = {}) => {
25376
25325
  const { nodes } = params;
25377
25326
  const node = nodes?.[0];
25378
25327
  const sourceAttrs = node?.attributes || {};
@@ -25388,12 +25337,12 @@ const encode$L = (params, encodedAttrs = {}) => {
25388
25337
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25389
25338
  return {
25390
25339
  type: "attr",
25391
- xmlName: XML_NODE_NAME$o,
25392
- sdNodeOrKeyName: SD_ATTR_KEY$c,
25340
+ xmlName: XML_NODE_NAME$r,
25341
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
25393
25342
  attributes
25394
25343
  };
25395
25344
  };
25396
- const decode$E = (params) => {
25345
+ const decode$G = (params) => {
25397
25346
  const attrs = params?.node?.attrs || {};
25398
25347
  const underlineType = attrs.underlineType ?? attrs.underline ?? null;
25399
25348
  const color = attrs.underlineColor ?? attrs.color ?? null;
@@ -25411,20 +25360,20 @@ const decode$E = (params) => {
25411
25360
  if (themeTint) attributes["w:themeTint"] = themeTint;
25412
25361
  if (themeShade) attributes["w:themeShade"] = themeShade;
25413
25362
  return {
25414
- name: XML_NODE_NAME$o,
25363
+ name: XML_NODE_NAME$r,
25415
25364
  attributes
25416
25365
  };
25417
25366
  };
25418
- const config$m = {
25419
- xmlName: XML_NODE_NAME$o,
25420
- sdNodeOrKeyName: SD_ATTR_KEY$c,
25367
+ const config$p = {
25368
+ xmlName: XML_NODE_NAME$r,
25369
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
25421
25370
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25422
- encode: encode$L,
25423
- decode: decode$E,
25371
+ encode: encode$O,
25372
+ decode: decode$G,
25424
25373
  attributes: validXmlAttributes$h
25425
25374
  };
25426
- const translator$10 = NodeTranslator.from(config$m);
25427
- const encode$K = (attributes) => {
25375
+ const translator$13 = NodeTranslator.from(config$p);
25376
+ const encode$N = (attributes) => {
25428
25377
  const raw = attributes?.["w:val"];
25429
25378
  if (raw === void 0 || raw === null) return void 0;
25430
25379
  if (typeof raw === "boolean") return raw;
@@ -25434,24 +25383,24 @@ const encode$K = (attributes) => {
25434
25383
  if (val === "1" || val === "true" || val === "on") return true;
25435
25384
  return void 0;
25436
25385
  };
25437
- const decode$D = (attrs) => {
25386
+ const decode$F = (attrs) => {
25438
25387
  if (attrs?.strike === false) return "0";
25439
25388
  return void 0;
25440
25389
  };
25441
25390
  const attrConfig$m = Object.freeze({
25442
25391
  xmlName: "w:val",
25443
25392
  sdName: "strike",
25444
- encode: encode$K,
25445
- decode: decode$D
25393
+ encode: encode$N,
25394
+ decode: decode$F
25446
25395
  });
25447
25396
  const validXmlAttributes$g = [attrConfig$m];
25448
- const XML_NODE_NAME$n = "w:strike";
25449
- const SD_ATTR_KEY$b = "strike";
25450
- const encode$J = (params, encodedAttrs = {}) => {
25397
+ const XML_NODE_NAME$q = "w:strike";
25398
+ const SD_ATTR_KEY$c = "strike";
25399
+ const encode$M = (params, encodedAttrs = {}) => {
25451
25400
  const { nodes } = params;
25452
25401
  const node = nodes?.[0];
25453
25402
  if (!node) return void 0;
25454
- const val = encodedAttrs?.[SD_ATTR_KEY$b];
25403
+ const val = encodedAttrs?.[SD_ATTR_KEY$c];
25455
25404
  let attributes;
25456
25405
  if (val === false) attributes = { "w:val": "0" };
25457
25406
  else if (val === true) attributes = {};
@@ -25460,55 +25409,55 @@ const encode$J = (params, encodedAttrs = {}) => {
25460
25409
  else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
25461
25410
  return {
25462
25411
  type: "attr",
25463
- xmlName: XML_NODE_NAME$n,
25464
- sdNodeOrKeyName: SD_ATTR_KEY$b,
25412
+ xmlName: XML_NODE_NAME$q,
25413
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
25465
25414
  attributes
25466
25415
  };
25467
25416
  };
25468
- const config$l = {
25469
- xmlName: XML_NODE_NAME$n,
25470
- sdNodeOrKeyName: SD_ATTR_KEY$b,
25417
+ const config$o = {
25418
+ xmlName: XML_NODE_NAME$q,
25419
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
25471
25420
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25472
- encode: encode$J,
25421
+ encode: encode$M,
25473
25422
  attributes: validXmlAttributes$g
25474
25423
  };
25475
- const translator$$ = NodeTranslator.from(config$l);
25476
- const encode$I = (attributes) => attributes?.["w:val"];
25477
- const decode$C = (attrs) => attrs?.color;
25424
+ const translator$12 = NodeTranslator.from(config$o);
25425
+ const encode$L = (attributes) => attributes?.["w:val"];
25426
+ const decode$E = (attrs) => attrs?.color;
25478
25427
  const attrConfig$l = Object.freeze({
25479
25428
  xmlName: "w:val",
25480
25429
  sdName: "color",
25481
- encode: encode$I,
25482
- decode: decode$C
25430
+ encode: encode$L,
25431
+ decode: decode$E
25483
25432
  });
25484
- const encode$H = (attributes) => attributes?.["w:themeColor"];
25485
- const decode$B = (attrs) => attrs?.themeColor;
25433
+ const encode$K = (attributes) => attributes?.["w:themeColor"];
25434
+ const decode$D = (attrs) => attrs?.themeColor;
25486
25435
  const attrConfig$k = Object.freeze({
25487
25436
  xmlName: "w:themeColor",
25488
25437
  sdName: "themeColor",
25489
- encode: encode$H,
25490
- decode: decode$B
25438
+ encode: encode$K,
25439
+ decode: decode$D
25491
25440
  });
25492
- const encode$G = (attributes) => attributes?.["w:themeTint"];
25493
- const decode$A = (attrs) => attrs?.themeTint;
25441
+ const encode$J = (attributes) => attributes?.["w:themeTint"];
25442
+ const decode$C = (attrs) => attrs?.themeTint;
25494
25443
  const attrConfig$j = Object.freeze({
25495
25444
  xmlName: "w:themeTint",
25496
25445
  sdName: "themeTint",
25497
- encode: encode$G,
25498
- decode: decode$A
25446
+ encode: encode$J,
25447
+ decode: decode$C
25499
25448
  });
25500
- const encode$F = (attributes) => attributes?.["w:themeShade"];
25501
- const decode$z = (attrs) => attrs?.themeShade;
25449
+ const encode$I = (attributes) => attributes?.["w:themeShade"];
25450
+ const decode$B = (attrs) => attrs?.themeShade;
25502
25451
  const attrConfig$i = Object.freeze({
25503
25452
  xmlName: "w:themeShade",
25504
25453
  sdName: "themeShade",
25505
- encode: encode$F,
25506
- decode: decode$z
25454
+ encode: encode$I,
25455
+ decode: decode$B
25507
25456
  });
25508
25457
  const validXmlAttributes$f = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
25509
- const XML_NODE_NAME$m = "w:color";
25510
- const SD_ATTR_KEY$a = "color";
25511
- const encode$E = (params, encodedAttrs = {}) => {
25458
+ const XML_NODE_NAME$p = "w:color";
25459
+ const SD_ATTR_KEY$b = "color";
25460
+ const encode$H = (params, encodedAttrs = {}) => {
25512
25461
  const { nodes } = params;
25513
25462
  const node = nodes?.[0];
25514
25463
  const sourceAttrs = node?.attributes || {};
@@ -25523,63 +25472,63 @@ const encode$E = (params, encodedAttrs = {}) => {
25523
25472
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25524
25473
  return {
25525
25474
  type: "attr",
25526
- xmlName: XML_NODE_NAME$m,
25527
- sdNodeOrKeyName: SD_ATTR_KEY$a,
25475
+ xmlName: XML_NODE_NAME$p,
25476
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
25528
25477
  attributes
25529
25478
  };
25530
25479
  };
25531
- const config$k = {
25532
- xmlName: XML_NODE_NAME$m,
25533
- sdNodeOrKeyName: SD_ATTR_KEY$a,
25480
+ const config$n = {
25481
+ xmlName: XML_NODE_NAME$p,
25482
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
25534
25483
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25535
- encode: encode$E,
25484
+ encode: encode$H,
25536
25485
  attributes: validXmlAttributes$f
25537
25486
  };
25538
- const translator$_ = NodeTranslator.from(config$k);
25539
- const encode$D = (attributes) => attributes?.["w:eastAsia"];
25540
- const decode$y = (attrs) => attrs?.eastAsia;
25487
+ const translator$11 = NodeTranslator.from(config$n);
25488
+ const encode$G = (attributes) => attributes?.["w:eastAsia"];
25489
+ const decode$A = (attrs) => attrs?.eastAsia;
25541
25490
  const attrConfig$h = Object.freeze({
25542
25491
  xmlName: "w:eastAsia",
25543
25492
  sdName: "eastAsia",
25544
- encode: encode$D,
25545
- decode: decode$y
25493
+ encode: encode$G,
25494
+ decode: decode$A
25546
25495
  });
25547
- const encode$C = (attributes) => attributes?.["w:ascii"];
25548
- const decode$x = (attrs) => attrs?.ascii;
25496
+ const encode$F = (attributes) => attributes?.["w:ascii"];
25497
+ const decode$z = (attrs) => attrs?.ascii;
25549
25498
  const attrConfig$g = Object.freeze({
25550
25499
  xmlName: "w:ascii",
25551
25500
  sdName: "ascii",
25552
- encode: encode$C,
25553
- decode: decode$x
25501
+ encode: encode$F,
25502
+ decode: decode$z
25554
25503
  });
25555
- const encode$B = (attributes) => attributes?.["w:hAnsi"];
25556
- const decode$w = (attrs) => attrs?.hAnsi;
25504
+ const encode$E = (attributes) => attributes?.["w:hAnsi"];
25505
+ const decode$y = (attrs) => attrs?.hAnsi;
25557
25506
  const attrConfig$f = Object.freeze({
25558
25507
  xmlName: "w:hAnsi",
25559
25508
  sdName: "hAnsi",
25560
- encode: encode$B,
25561
- decode: decode$w
25509
+ encode: encode$E,
25510
+ decode: decode$y
25562
25511
  });
25563
- const encode$A = (attributes) => attributes?.["w:cs"];
25564
- const decode$v = (attrs) => attrs?.cs;
25512
+ const encode$D = (attributes) => attributes?.["w:cs"];
25513
+ const decode$x = (attrs) => attrs?.cs;
25565
25514
  const attrConfig$e = Object.freeze({
25566
25515
  xmlName: "w:cs",
25567
25516
  sdName: "cs",
25568
- encode: encode$A,
25569
- decode: decode$v
25517
+ encode: encode$D,
25518
+ decode: decode$x
25570
25519
  });
25571
- const encode$z = (attributes) => attributes?.["w:val"];
25572
- const decode$u = (attrs) => attrs?.value;
25520
+ const encode$C = (attributes) => attributes?.["w:val"];
25521
+ const decode$w = (attrs) => attrs?.value;
25573
25522
  const attrConfig$d = Object.freeze({
25574
25523
  xmlName: "w:val",
25575
25524
  sdName: "value",
25576
- encode: encode$z,
25577
- decode: decode$u
25525
+ encode: encode$C,
25526
+ decode: decode$w
25578
25527
  });
25579
25528
  const validXmlAttributes$e = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
25580
- const XML_NODE_NAME$l = "w:rFonts";
25581
- const SD_ATTR_KEY$9 = "fontFamily";
25582
- const encode$y = (params, encodedAttrs = {}) => {
25529
+ const XML_NODE_NAME$o = "w:rFonts";
25530
+ const SD_ATTR_KEY$a = "fontFamily";
25531
+ const encode$B = (params, encodedAttrs = {}) => {
25583
25532
  const { nodes } = params;
25584
25533
  const node = nodes?.[0];
25585
25534
  const sourceAttrs = node?.attributes || {};
@@ -25605,120 +25554,281 @@ const encode$y = (params, encodedAttrs = {}) => {
25605
25554
  if (attributes["w:val"] === void 0) delete attributes["w:val"];
25606
25555
  return {
25607
25556
  type: "attr",
25608
- xmlName: XML_NODE_NAME$l,
25609
- sdNodeOrKeyName: SD_ATTR_KEY$9,
25557
+ xmlName: XML_NODE_NAME$o,
25558
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25610
25559
  attributes
25611
25560
  };
25612
25561
  };
25613
- const config$j = {
25614
- xmlName: XML_NODE_NAME$l,
25615
- sdNodeOrKeyName: SD_ATTR_KEY$9,
25562
+ const config$m = {
25563
+ xmlName: XML_NODE_NAME$o,
25564
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25616
25565
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25617
- encode: encode$y,
25566
+ encode: encode$B,
25618
25567
  attributes: validXmlAttributes$e
25619
25568
  };
25620
- const translator$Z = NodeTranslator.from(config$j);
25621
- const encode$x = (attributes) => attributes?.["w:val"];
25622
- const decode$t = (attrs) => attrs?.styleId;
25569
+ const translator$10 = NodeTranslator.from(config$m);
25570
+ const encode$A = (attributes) => attributes?.["w:val"];
25571
+ const decode$v = (attrs) => attrs?.styleId;
25623
25572
  const attrConfig$c = Object.freeze({
25624
25573
  xmlName: "w:val",
25625
25574
  sdName: "styleId",
25626
- encode: encode$x,
25627
- decode: decode$t
25575
+ encode: encode$A,
25576
+ decode: decode$v
25628
25577
  });
25629
25578
  const validXmlAttributes$d = [attrConfig$c];
25630
- const XML_NODE_NAME$k = "w:rStyle";
25631
- const SD_ATTR_KEY$8 = "styleId";
25632
- const encode$w = (params, encodedAttrs = {}) => {
25579
+ const XML_NODE_NAME$n = "w:rStyle";
25580
+ const SD_ATTR_KEY$9 = "styleId";
25581
+ const encode$z = (params, encodedAttrs = {}) => {
25633
25582
  const { nodes } = params;
25634
25583
  const node = nodes?.[0];
25635
25584
  const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
25636
25585
  return {
25637
25586
  type: "attr",
25638
- xmlName: XML_NODE_NAME$k,
25639
- sdNodeOrKeyName: SD_ATTR_KEY$8,
25587
+ xmlName: XML_NODE_NAME$n,
25588
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
25640
25589
  attributes: { "w:val": value ?? null }
25641
25590
  };
25642
25591
  };
25643
- const config$i = {
25644
- xmlName: XML_NODE_NAME$k,
25645
- sdNodeOrKeyName: SD_ATTR_KEY$8,
25592
+ const config$l = {
25593
+ xmlName: XML_NODE_NAME$n,
25594
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
25646
25595
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25647
- encode: encode$w,
25596
+ encode: encode$z,
25648
25597
  attributes: validXmlAttributes$d
25649
25598
  };
25650
- const translator$Y = NodeTranslator.from(config$i);
25651
- const encode$v = (attributes) => attributes?.["w:val"];
25652
- const decode$s = (attrs) => attrs?.fontSize;
25599
+ const translator$$ = NodeTranslator.from(config$l);
25600
+ const encode$y = (attributes) => attributes?.["w:val"];
25601
+ const decode$u = (attrs) => attrs?.fontSize;
25653
25602
  const attrConfig$b = Object.freeze({
25654
25603
  xmlName: "w:val",
25655
25604
  sdName: "fontSize",
25656
- encode: encode$v,
25657
- decode: decode$s
25605
+ encode: encode$y,
25606
+ decode: decode$u
25658
25607
  });
25659
25608
  const validXmlAttributes$c = [attrConfig$b];
25660
- const XML_NODE_NAME$j = "w:sz";
25661
- const SD_ATTR_KEY$7 = "fontSize";
25662
- const encode$u = (params, encodedAttrs = {}) => {
25609
+ const XML_NODE_NAME$m = "w:sz";
25610
+ const SD_ATTR_KEY$8 = "fontSize";
25611
+ const encode$x = (params, encodedAttrs = {}) => {
25663
25612
  const { nodes } = params;
25664
25613
  const node = nodes?.[0];
25665
25614
  const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
25666
25615
  return {
25667
25616
  type: "attr",
25668
- xmlName: XML_NODE_NAME$j,
25669
- sdNodeOrKeyName: SD_ATTR_KEY$7,
25617
+ xmlName: XML_NODE_NAME$m,
25618
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
25670
25619
  attributes: { "w:val": value ?? null }
25671
25620
  };
25672
25621
  };
25673
- const config$h = {
25674
- xmlName: XML_NODE_NAME$j,
25675
- sdNodeOrKeyName: SD_ATTR_KEY$7,
25622
+ const config$k = {
25623
+ xmlName: XML_NODE_NAME$m,
25624
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
25676
25625
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25677
- encode: encode$u,
25626
+ encode: encode$x,
25678
25627
  attributes: validXmlAttributes$c
25679
25628
  };
25680
- const translator$X = NodeTranslator.from(config$h);
25681
- const encode$t = (attributes) => attributes?.["w:val"];
25682
- const decode$r = (attrs) => attrs?.fontSizeCs;
25629
+ const translator$_ = NodeTranslator.from(config$k);
25630
+ const encode$w = (attributes) => attributes?.["w:val"];
25631
+ const decode$t = (attrs) => attrs?.fontSizeCs;
25683
25632
  const attrConfig$a = Object.freeze({
25684
25633
  xmlName: "w:val",
25685
25634
  sdName: "fontSizeCs",
25686
- encode: encode$t,
25687
- decode: decode$r
25635
+ encode: encode$w,
25636
+ decode: decode$t
25688
25637
  });
25689
25638
  const validXmlAttributes$b = [attrConfig$a];
25690
- const XML_NODE_NAME$i = "w:szCs";
25691
- const SD_ATTR_KEY$6 = "fontSizeCs";
25692
- const encode$s = (params, encodedAttrs = {}) => {
25639
+ const XML_NODE_NAME$l = "w:szCs";
25640
+ const SD_ATTR_KEY$7 = "fontSizeCs";
25641
+ const encode$v = (params, encodedAttrs = {}) => {
25693
25642
  const { nodes } = params;
25694
25643
  const node = nodes?.[0];
25695
25644
  const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
25696
25645
  return {
25697
25646
  type: "attr",
25698
- xmlName: XML_NODE_NAME$i,
25699
- sdNodeOrKeyName: SD_ATTR_KEY$6,
25647
+ xmlName: XML_NODE_NAME$l,
25648
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
25700
25649
  attributes: { "w:val": value ?? null }
25701
25650
  };
25702
25651
  };
25703
- const config$g = {
25704
- xmlName: XML_NODE_NAME$i,
25705
- sdNodeOrKeyName: SD_ATTR_KEY$6,
25652
+ const config$j = {
25653
+ xmlName: XML_NODE_NAME$l,
25654
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
25706
25655
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25707
- encode: encode$s,
25656
+ encode: encode$v,
25708
25657
  attributes: validXmlAttributes$b
25709
25658
  };
25710
- const translator$W = NodeTranslator.from(config$g);
25659
+ const translator$Z = NodeTranslator.from(config$j);
25660
+ const generateV2HandlerEntity = (handlerName, translator2) => ({
25661
+ handlerName,
25662
+ handler: (params) => {
25663
+ const { nodes } = params;
25664
+ if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
25665
+ return { nodes: [], consumed: 0 };
25666
+ }
25667
+ const result = translator2.encode(params);
25668
+ if (!result) return { nodes: [], consumed: 0 };
25669
+ return {
25670
+ nodes: Array.isArray(result) ? result : [result],
25671
+ consumed: 1
25672
+ };
25673
+ }
25674
+ });
25675
+ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:val", transformEncode = null, transformDecode = null) {
25676
+ if (!sdName) sdName = xmlName.split(":")[1];
25677
+ if (!transformEncode) transformEncode = (v2) => v2;
25678
+ if (!transformDecode) transformDecode = (v2) => v2;
25679
+ return {
25680
+ xmlName,
25681
+ sdNodeOrKeyName: sdName,
25682
+ encode: ({ nodes }) => {
25683
+ return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
25684
+ },
25685
+ decode: ({ node }) => {
25686
+ const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
25687
+ return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
25688
+ }
25689
+ };
25690
+ }
25691
+ function createMeasurementPropertyHandler(xmlName, sdName = null) {
25692
+ if (!sdName) sdName = xmlName.split(":")[1];
25693
+ return {
25694
+ xmlName,
25695
+ sdNodeOrKeyName: sdName,
25696
+ attributes: [
25697
+ createAttributeHandler("w:w", "value", parseInteger, integerToString),
25698
+ createAttributeHandler("w:type")
25699
+ ],
25700
+ encode: (_2, encodedAttrs) => {
25701
+ return encodedAttrs["value"] != null ? encodedAttrs : void 0;
25702
+ },
25703
+ decode: function({ node }) {
25704
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25705
+ return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
25706
+ }
25707
+ };
25708
+ }
25709
+ function createBorderPropertyHandler(xmlName, sdName = null) {
25710
+ if (!sdName) sdName = xmlName.split(":")[1];
25711
+ return {
25712
+ xmlName,
25713
+ sdNodeOrKeyName: sdName,
25714
+ attributes: [
25715
+ createAttributeHandler("w:val"),
25716
+ createAttributeHandler("w:color"),
25717
+ createAttributeHandler("w:themeColor"),
25718
+ createAttributeHandler("w:themeTint"),
25719
+ createAttributeHandler("w:themeShade"),
25720
+ createAttributeHandler("w:sz", "size", parseInteger, integerToString),
25721
+ createAttributeHandler("w:space", null, parseInteger, integerToString),
25722
+ createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
25723
+ createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
25724
+ ],
25725
+ encode: (params, encodedAttrs) => {
25726
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25727
+ },
25728
+ decode: function({ node }, context) {
25729
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25730
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25731
+ }
25732
+ };
25733
+ }
25734
+ const createAttributeHandler = (xmlName, sdName = null, transformEncode = null, transformDecode = null) => {
25735
+ if (!transformEncode) transformEncode = (v2) => v2;
25736
+ if (!transformDecode) transformDecode = (v2) => v2;
25737
+ if (!sdName) sdName = xmlName.split(":")[1];
25738
+ return {
25739
+ xmlName,
25740
+ sdName,
25741
+ encode: (attributes) => transformEncode(attributes[xmlName]),
25742
+ decode: (attributes) => transformDecode(attributes[sdName])
25743
+ };
25744
+ };
25745
+ function encodeProperties(node, translatorsByXmlName, asArray = false) {
25746
+ if (!node?.elements || node.elements.length === 0) {
25747
+ return asArray ? [] : {};
25748
+ }
25749
+ const attributes = asArray ? [] : {};
25750
+ node.elements.forEach((el) => {
25751
+ const translator2 = translatorsByXmlName[el.name];
25752
+ if (translator2) {
25753
+ const encodedAttr = translator2.encode({ nodes: [el] });
25754
+ if (encodedAttr != null) {
25755
+ if (asArray) {
25756
+ attributes.push({ [translator2.sdNodeOrKeyName]: encodedAttr });
25757
+ } else {
25758
+ attributes[translator2.sdNodeOrKeyName] = encodedAttr;
25759
+ }
25760
+ }
25761
+ }
25762
+ });
25763
+ return attributes;
25764
+ }
25765
+ function decodeProperties(translatorsBySdName, properties) {
25766
+ if (!properties || typeof properties !== "object") {
25767
+ return [];
25768
+ }
25769
+ const elements = [];
25770
+ Object.keys(properties).forEach((key) => {
25771
+ const translator2 = translatorsBySdName[key];
25772
+ if (translator2) {
25773
+ const result = translator2.decode({ node: { attrs: { [key]: properties[key] } } });
25774
+ if (result != null) {
25775
+ result.name = translator2.xmlName;
25776
+ elements.push(result);
25777
+ }
25778
+ }
25779
+ });
25780
+ return elements;
25781
+ }
25782
+ const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
25783
+ const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
25784
+ const parseInteger = (value) => {
25785
+ if (value == null) return void 0;
25786
+ const intValue = parseInt(value, 10);
25787
+ return isNaN(intValue) ? void 0 : intValue;
25788
+ };
25789
+ const integerToString = (value) => {
25790
+ const intValue = parseInteger(value);
25791
+ return intValue != void 0 ? String(intValue) : void 0;
25792
+ };
25793
+ const XML_NODE_NAME$k = "w:caps";
25794
+ const SD_ATTR_KEY$6 = "textTransform";
25795
+ const encode$u = (params, encodedAttrs = {}) => {
25796
+ const { nodes } = params;
25797
+ const node = nodes[0];
25798
+ if (!node) return void 0;
25799
+ let result;
25800
+ if (!["false", "0"].includes(encodedAttrs.val)) {
25801
+ result = "uppercase";
25802
+ } else {
25803
+ return void 0;
25804
+ }
25805
+ return {
25806
+ type: "attr",
25807
+ xmlName: XML_NODE_NAME$k,
25808
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
25809
+ attributes: { [SD_ATTR_KEY$6]: result }
25810
+ };
25811
+ };
25812
+ const config$i = {
25813
+ xmlName: XML_NODE_NAME$k,
25814
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
25815
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
25816
+ encode: encode$u,
25817
+ attributes: [createAttributeHandler("w:val")]
25818
+ };
25819
+ const translator$Y = NodeTranslator.from(config$i);
25711
25820
  const runPropertyTranslators = Object.freeze({
25712
- "w:b": translator$12,
25713
- "w:i": translator$11,
25714
- "w:u": translator$10,
25715
- "w:strike": translator$$,
25716
- "w:color": translator$_,
25717
- "w:highlight": translator$15,
25718
- "w:rFonts": translator$Z,
25719
- "w:rStyle": translator$Y,
25720
- "w:sz": translator$X,
25721
- "w:szCs": translator$W
25821
+ "w:b": translator$15,
25822
+ "w:i": translator$14,
25823
+ "w:u": translator$13,
25824
+ "w:strike": translator$12,
25825
+ "w:color": translator$11,
25826
+ "w:highlight": translator$18,
25827
+ "w:rFonts": translator$10,
25828
+ "w:rStyle": translator$$,
25829
+ "w:sz": translator$_,
25830
+ "w:szCs": translator$Z,
25831
+ "w:caps": translator$Y
25722
25832
  });
25723
25833
  const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
25724
25834
  const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
@@ -25732,9 +25842,9 @@ const toRunPropertyEntry = (candidate) => {
25732
25842
  attributes: { ...candidate.attributes || {} }
25733
25843
  };
25734
25844
  };
25735
- const XML_NODE_NAME$h = "w:rPr";
25845
+ const XML_NODE_NAME$j = "w:rPr";
25736
25846
  const SD_ATTR_KEY$5 = "runProperties";
25737
- const encode$r = (params) => {
25847
+ const encode$t = (params) => {
25738
25848
  const { nodes } = params;
25739
25849
  const node = nodes?.[0] || {};
25740
25850
  const contents = Array.isArray(node.elements) ? node.elements : [];
@@ -25768,16 +25878,16 @@ const encode$r = (params) => {
25768
25878
  attributes: runPropsArray
25769
25879
  };
25770
25880
  };
25771
- const config$f = {
25772
- xmlName: XML_NODE_NAME$h,
25881
+ const config$h = {
25882
+ xmlName: XML_NODE_NAME$j,
25773
25883
  sdNodeOrKeyName: SD_ATTR_KEY$5,
25774
25884
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25775
- encode: encode$r
25885
+ encode: encode$t
25776
25886
  };
25777
- const translator$V = NodeTranslator.from(config$f);
25887
+ const translator$X = NodeTranslator.from(config$h);
25778
25888
  const EAST_ASIAN_CHARACTER_REGEX = /[\u1100-\u11FF\u2E80-\u2EFF\u2F00-\u2FDF\u3040-\u30FF\u3100-\u312F\u3130-\u318F\u31A0-\u31BF\u3400-\u4DBF\u4E00-\u9FFF\uA960-\uA97F\uAC00-\uD7AF\uF900-\uFAFF\uFF00-\uFFEF]/u;
25779
25889
  const containsEastAsianCharacters = (text) => EAST_ASIAN_CHARACTER_REGEX.test(text);
25780
- const collectRunProperties = (params, rPrNode, translator2 = translator$V) => {
25890
+ const collectRunProperties = (params, rPrNode, translator2 = translator$X) => {
25781
25891
  if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
25782
25892
  const result = translator2.encode({ ...params, nodes: [rPrNode] }) || {};
25783
25893
  let entries = [];
@@ -25846,7 +25956,10 @@ const applyRunMarks = (node, inlineMarks, textStyleAttrs) => {
25846
25956
  };
25847
25957
  const deriveStyleMarks = ({ docx, paragraphStyleId, runStyleId }) => {
25848
25958
  const paragraphStyleMarks = collectStyleMarks(paragraphStyleId, docx);
25849
- const runStyleMarks = collectStyleMarks(runStyleId, docx);
25959
+ if (paragraphStyleId?.startsWith("TOC")) {
25960
+ return paragraphStyleMarks;
25961
+ }
25962
+ let runStyleMarks = collectStyleMarks(runStyleId, docx);
25850
25963
  const inlineMarks = mergeInlineMarkSets(paragraphStyleMarks.inlineMarks, runStyleMarks.inlineMarks);
25851
25964
  const textStyleAttrs = mergeTextStyleAttrs(paragraphStyleMarks.textStyleAttrs, runStyleMarks.textStyleAttrs);
25852
25965
  return { inlineMarks, textStyleAttrs };
@@ -26072,6 +26185,13 @@ const splitRunProperties = (entries = [], docx = null) => {
26072
26185
  }
26073
26186
  break;
26074
26187
  }
26188
+ case "w:caps": {
26189
+ if (attributes["textTransform"] != null) {
26190
+ hasTextStyle = true;
26191
+ textStyleAttrs.textTransform = attributes["textTransform"];
26192
+ }
26193
+ break;
26194
+ }
26075
26195
  case "w:rFonts": {
26076
26196
  const asciiFamily = attributes["w:ascii"] || attributes["w:hAnsi"] || (attributes["w:eastAsia"] ? void 0 : attributes["w:val"]);
26077
26197
  const eastAsiaFamily = attributes["w:eastAsia"];
@@ -26091,9 +26211,10 @@ const splitRunProperties = (entries = [], docx = null) => {
26091
26211
  case "w:sz":
26092
26212
  case "w:szCs": {
26093
26213
  const rawSize = Number(attributes["w:val"]);
26214
+ const attrName = entry.xmlName === "w:sz" ? "fontSize" : "fontSizeCs";
26094
26215
  if (Number.isFinite(rawSize) && rawSize > 0) {
26095
26216
  hasTextStyle = true;
26096
- textStyleAttrs.fontSize = `${rawSize / 2}pt`;
26217
+ textStyleAttrs[attrName] = `${rawSize / 2}pt`;
26097
26218
  }
26098
26219
  break;
26099
26220
  }
@@ -26239,46 +26360,166 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
26239
26360
  }
26240
26361
  return runs;
26241
26362
  };
26242
- const encode$q = (attributes) => {
26243
- return attributes["w:rsidR"];
26244
- };
26245
- const decode$q = (attrs) => {
26246
- return attrs.rsidR;
26247
- };
26363
+ const XML_NODE_NAME$i = "w:hyperlink";
26364
+ const SD_NODE_NAME$c = "link";
26365
+ const _createAttributeHandler = (xmlName, sdName) => ({
26366
+ xmlName,
26367
+ sdName,
26368
+ encode: (attributes) => attributes[xmlName],
26369
+ decode: (attributes) => attributes[sdName]
26370
+ });
26371
+ const validXmlAttributes$a = [
26372
+ _createAttributeHandler("w:anchor", "anchor"),
26373
+ _createAttributeHandler("w:docLocation", "docLocation"),
26374
+ {
26375
+ xmlName: "w:history",
26376
+ sdName: "history",
26377
+ encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
26378
+ decode: (attributes) => attributes["history"] ? "1" : "0"
26379
+ },
26380
+ _createAttributeHandler("w:tooltip", "tooltip"),
26381
+ _createAttributeHandler("r:id", "rId"),
26382
+ _createAttributeHandler("w:tgtFrame", "target")
26383
+ ];
26384
+ const encode$s = (params, encodedAttrs) => {
26385
+ const { nodes, docx, nodeListHandler } = params;
26386
+ const node = nodes[0];
26387
+ let href = _resolveHref(docx, encodedAttrs);
26388
+ const linkMark = { type: "link", attrs: { ...encodedAttrs, href } };
26389
+ const referenceNodeTypes = ["sd:pageReference", "sd:autoPageNumber", "sd:totalPageNumber"];
26390
+ const contentNodes = node.elements.filter((el) => el.name === "w:r" || referenceNodeTypes.includes(el.name));
26391
+ contentNodes.forEach((contentNode) => {
26392
+ const existingMarks = Array.isArray(contentNode.marks) ? contentNode.marks : [];
26393
+ const marksWithoutLink = existingMarks.filter((mark) => mark?.type !== "link");
26394
+ contentNode.marks = [...marksWithoutLink, linkMark];
26395
+ });
26396
+ const updatedNode = nodeListHandler.handler({
26397
+ ...params,
26398
+ nodes: contentNodes,
26399
+ path: [...params.path || [], node]
26400
+ });
26401
+ return updatedNode;
26402
+ };
26403
+ const _resolveHref = (docx, encodedAttrs) => {
26404
+ const rels = docx["word/_rels/document.xml.rels"];
26405
+ const relationships = rels.elements.find((el) => el.name === "Relationships");
26406
+ const { elements } = relationships;
26407
+ const { rId, anchor } = encodedAttrs;
26408
+ let href;
26409
+ if (!rId && anchor) {
26410
+ href = `#${anchor}`;
26411
+ } else if (rId) {
26412
+ const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
26413
+ const { attributes: relAttributes = {} } = rel;
26414
+ href = relAttributes["Target"];
26415
+ }
26416
+ return href;
26417
+ };
26418
+ function decode$s(params) {
26419
+ const { hyperlinkGroup = [params.node] } = params.extraParams || {};
26420
+ const node = hyperlinkGroup[0];
26421
+ const linkMark = node.marks.find((m2) => m2.type === "link");
26422
+ const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
26423
+ let { anchor, href: link } = linkMark.attrs;
26424
+ const isExternalLink = !anchor;
26425
+ if (isExternalLink) {
26426
+ linkAttrs["r:id"] = _addNewLinkRelationship(params, link, linkAttrs["r:id"]);
26427
+ }
26428
+ let contentNodes = [];
26429
+ hyperlinkGroup.forEach((linkNode) => {
26430
+ if ("marks" in linkNode) {
26431
+ linkNode.marks = linkNode.marks.filter((m2) => m2.type !== "link");
26432
+ } else {
26433
+ linkNode.attrs.marksAsAttrs = linkNode.attrs.marksAsAttrs.filter((m2) => m2.type !== "link");
26434
+ }
26435
+ const outputNode = exportSchemaToJson({ ...params, node: linkNode });
26436
+ if (outputNode) {
26437
+ if (outputNode instanceof Array) contentNodes.push(...outputNode);
26438
+ else contentNodes.push(outputNode);
26439
+ }
26440
+ });
26441
+ const newNode = {
26442
+ name: "w:hyperlink",
26443
+ type: "element",
26444
+ attributes: {
26445
+ ...linkAttrs
26446
+ },
26447
+ elements: contentNodes
26448
+ };
26449
+ return newNode;
26450
+ }
26451
+ function _addNewLinkRelationship(params, link, rId) {
26452
+ if (!rId) rId = generateDocxRandomId();
26453
+ if (!params.relationships || !Array.isArray(params.relationships)) {
26454
+ params.relationships = [];
26455
+ }
26456
+ const existingRel = params.relationships.find(
26457
+ (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
26458
+ );
26459
+ if (existingRel) {
26460
+ return rId;
26461
+ }
26462
+ params.relationships.push({
26463
+ type: "element",
26464
+ name: "Relationship",
26465
+ attributes: {
26466
+ Id: rId,
26467
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
26468
+ Target: link,
26469
+ TargetMode: "External"
26470
+ }
26471
+ });
26472
+ return rId;
26473
+ }
26474
+ const config$g = {
26475
+ xmlName: XML_NODE_NAME$i,
26476
+ sdNodeOrKeyName: SD_NODE_NAME$c,
26477
+ type: NodeTranslator.translatorTypes.NODE,
26478
+ encode: encode$s,
26479
+ decode: decode$s,
26480
+ attributes: validXmlAttributes$a
26481
+ };
26482
+ const translator$W = NodeTranslator.from(config$g);
26483
+ const encode$r = (attributes) => {
26484
+ return attributes["w:rsidR"];
26485
+ };
26486
+ const decode$r = (attrs) => {
26487
+ return attrs.rsidR;
26488
+ };
26248
26489
  const attrConfig$9 = Object.freeze({
26249
26490
  xmlName: "w:rsidR",
26250
26491
  sdName: "rsidR",
26251
- encode: encode$q,
26252
- decode: decode$q
26492
+ encode: encode$r,
26493
+ decode: decode$r
26253
26494
  });
26254
- const encode$p = (attributes) => {
26495
+ const encode$q = (attributes) => {
26255
26496
  return attributes["w:rsidRPr"];
26256
26497
  };
26257
- const decode$p = (attrs) => {
26498
+ const decode$q = (attrs) => {
26258
26499
  return attrs.rsidRPr;
26259
26500
  };
26260
26501
  const attrConfig$8 = Object.freeze({
26261
26502
  xmlName: "w:rsidRPr",
26262
26503
  sdName: "rsidRPr",
26263
- encode: encode$p,
26264
- decode: decode$p
26504
+ encode: encode$q,
26505
+ decode: decode$q
26265
26506
  });
26266
- const encode$o = (attributes) => {
26507
+ const encode$p = (attributes) => {
26267
26508
  return attributes["w:rsidDel"];
26268
26509
  };
26269
- const decode$o = (attrs) => {
26510
+ const decode$p = (attrs) => {
26270
26511
  return attrs.rsidDel;
26271
26512
  };
26272
26513
  const attrConfig$7 = Object.freeze({
26273
26514
  xmlName: "w:rsidDel",
26274
26515
  sdName: "rsidDel",
26275
- encode: encode$o,
26276
- decode: decode$o
26516
+ encode: encode$p,
26517
+ decode: decode$p
26277
26518
  });
26278
- const validXmlAttributes$a = [attrConfig$9, attrConfig$8, attrConfig$7];
26279
- const XML_NODE_NAME$g = "w:r";
26519
+ const validXmlAttributes$9 = [attrConfig$9, attrConfig$8, attrConfig$7];
26520
+ const XML_NODE_NAME$h = "w:r";
26280
26521
  const SD_KEY_NAME = "run";
26281
- const encode$n = (params, encodedAttrs = {}) => {
26522
+ const encode$o = (params, encodedAttrs = {}) => {
26282
26523
  const { nodes = [], nodeListHandler } = params || {};
26283
26524
  const runNode = nodes[0];
26284
26525
  if (!runNode) return void 0;
@@ -26326,9 +26567,11 @@ const encode$n = (params, encodedAttrs = {}) => {
26326
26567
  }
26327
26568
  return runNodeResult;
26328
26569
  };
26329
- const decode$n = (params, decodedAttrs = {}) => {
26570
+ const decode$o = (params, decodedAttrs = {}) => {
26330
26571
  const { node } = params || {};
26331
26572
  if (!node) return void 0;
26573
+ const isLinkNode = node.marks?.some((m2) => m2.type === "link");
26574
+ if (isLinkNode) return translator$W.decode(params);
26332
26575
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node);
26333
26576
  const runAttrs = runNodeForExport.attrs || {};
26334
26577
  const runProperties = Array.isArray(runAttrs.runProperties) ? runAttrs.runProperties : [];
@@ -26383,7 +26626,7 @@ const decode$n = (params, decodedAttrs = {}) => {
26383
26626
  runs.push(trackedClone);
26384
26627
  return;
26385
26628
  }
26386
- const runWrapper = { name: XML_NODE_NAME$g, elements: [] };
26629
+ const runWrapper = { name: XML_NODE_NAME$h, elements: [] };
26387
26630
  applyBaseRunProps(runWrapper);
26388
26631
  if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
26389
26632
  runWrapper.elements.push(cloneXmlNode(child));
@@ -26391,7 +26634,7 @@ const decode$n = (params, decodedAttrs = {}) => {
26391
26634
  });
26392
26635
  const trackedRuns = ensureTrackedWrapper(runs, trackingMarksByType);
26393
26636
  if (!trackedRuns.length) {
26394
- const emptyRun = { name: XML_NODE_NAME$g, elements: [] };
26637
+ const emptyRun = { name: XML_NODE_NAME$h, elements: [] };
26395
26638
  applyBaseRunProps(emptyRun);
26396
26639
  trackedRuns.push(emptyRun);
26397
26640
  }
@@ -26405,148 +26648,15 @@ const decode$n = (params, decodedAttrs = {}) => {
26405
26648
  }
26406
26649
  return trackedRuns;
26407
26650
  };
26408
- const config$e = {
26409
- xmlName: XML_NODE_NAME$g,
26651
+ const config$f = {
26652
+ xmlName: XML_NODE_NAME$h,
26410
26653
  sdNodeOrKeyName: SD_KEY_NAME,
26411
26654
  type: NodeTranslator.translatorTypes.NODE,
26412
- encode: encode$n,
26413
- decode: decode$n,
26414
- attributes: validXmlAttributes$a
26415
- };
26416
- const translator$U = NodeTranslator.from(config$e);
26417
- const generateV2HandlerEntity = (handlerName, translator2) => ({
26418
- handlerName,
26419
- handler: (params) => {
26420
- const { nodes } = params;
26421
- if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
26422
- return { nodes: [], consumed: 0 };
26423
- }
26424
- const result = translator2.encode(params);
26425
- if (!result) return { nodes: [], consumed: 0 };
26426
- return {
26427
- nodes: Array.isArray(result) ? result : [result],
26428
- consumed: 1
26429
- };
26430
- }
26431
- });
26432
- function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:val", transformEncode = null, transformDecode = null) {
26433
- if (!sdName) sdName = xmlName.split(":")[1];
26434
- if (!transformEncode) transformEncode = (v2) => v2;
26435
- if (!transformDecode) transformDecode = (v2) => v2;
26436
- return {
26437
- xmlName,
26438
- sdNodeOrKeyName: sdName,
26439
- encode: ({ nodes }) => {
26440
- return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
26441
- },
26442
- decode: ({ node }) => {
26443
- const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
26444
- return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
26445
- }
26446
- };
26447
- }
26448
- function createMeasurementPropertyHandler(xmlName, sdName = null) {
26449
- if (!sdName) sdName = xmlName.split(":")[1];
26450
- return {
26451
- xmlName,
26452
- sdNodeOrKeyName: sdName,
26453
- attributes: [
26454
- createAttributeHandler("w:w", "value", parseInteger, integerToString),
26455
- createAttributeHandler("w:type")
26456
- ],
26457
- encode: (_2, encodedAttrs) => {
26458
- return encodedAttrs["value"] != null ? encodedAttrs : void 0;
26459
- },
26460
- decode: function({ node }) {
26461
- const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
26462
- return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
26463
- }
26464
- };
26465
- }
26466
- function createBorderPropertyHandler(xmlName, sdName = null) {
26467
- if (!sdName) sdName = xmlName.split(":")[1];
26468
- return {
26469
- xmlName,
26470
- sdNodeOrKeyName: sdName,
26471
- attributes: [
26472
- createAttributeHandler("w:val"),
26473
- createAttributeHandler("w:color"),
26474
- createAttributeHandler("w:themeColor"),
26475
- createAttributeHandler("w:themeTint"),
26476
- createAttributeHandler("w:themeShade"),
26477
- createAttributeHandler("w:sz", "size", parseInteger, integerToString),
26478
- createAttributeHandler("w:space", null, parseInteger, integerToString),
26479
- createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
26480
- createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
26481
- ],
26482
- encode: (params, encodedAttrs) => {
26483
- return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
26484
- },
26485
- decode: function({ node }, context) {
26486
- const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
26487
- return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26488
- }
26489
- };
26490
- }
26491
- const createAttributeHandler = (xmlName, sdName = null, transformEncode = null, transformDecode = null) => {
26492
- if (!transformEncode) transformEncode = (v2) => v2;
26493
- if (!transformDecode) transformDecode = (v2) => v2;
26494
- if (!sdName) sdName = xmlName.split(":")[1];
26495
- return {
26496
- xmlName,
26497
- sdName,
26498
- encode: (attributes) => transformEncode(attributes[xmlName]),
26499
- decode: (attributes) => transformDecode(attributes[sdName])
26500
- };
26501
- };
26502
- function encodeProperties(node, translatorsByXmlName, asArray = false) {
26503
- if (!node?.elements || node.elements.length === 0) {
26504
- return asArray ? [] : {};
26505
- }
26506
- const attributes = asArray ? [] : {};
26507
- node.elements.forEach((el) => {
26508
- const translator2 = translatorsByXmlName[el.name];
26509
- if (translator2) {
26510
- const encodedAttr = translator2.encode({ nodes: [el] });
26511
- if (encodedAttr != null) {
26512
- if (asArray) {
26513
- attributes.push({ [translator2.sdNodeOrKeyName]: encodedAttr });
26514
- } else {
26515
- attributes[translator2.sdNodeOrKeyName] = encodedAttr;
26516
- }
26517
- }
26518
- }
26519
- });
26520
- return attributes;
26521
- }
26522
- function decodeProperties(translatorsBySdName, properties) {
26523
- if (!properties || typeof properties !== "object") {
26524
- return [];
26525
- }
26526
- const elements = [];
26527
- Object.keys(properties).forEach((key) => {
26528
- const translator2 = translatorsBySdName[key];
26529
- if (translator2) {
26530
- const result = translator2.decode({ node: { attrs: { [key]: properties[key] } } });
26531
- if (result != null) {
26532
- result.name = translator2.xmlName;
26533
- elements.push(result);
26534
- }
26535
- }
26536
- });
26537
- return elements;
26538
- }
26539
- const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
26540
- const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
26541
- const parseInteger = (value) => {
26542
- if (value == null) return void 0;
26543
- const intValue = parseInt(value, 10);
26544
- return isNaN(intValue) ? void 0 : intValue;
26545
- };
26546
- const integerToString = (value) => {
26547
- const intValue = parseInteger(value);
26548
- return intValue != void 0 ? String(intValue) : void 0;
26655
+ encode: encode$o,
26656
+ decode: decode$o,
26657
+ attributes: validXmlAttributes$9
26549
26658
  };
26659
+ const translator$V = NodeTranslator.from(config$f);
26550
26660
  function preProcessVerticalMergeCells(table, { editorSchema }) {
26551
26661
  if (!table || !Array.isArray(table.content)) {
26552
26662
  return table;
@@ -26587,13 +26697,13 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
26587
26697
  }
26588
26698
  return table;
26589
26699
  }
26590
- const translator$T = NodeTranslator.from({
26700
+ const translator$U = NodeTranslator.from({
26591
26701
  xmlName: "w:cantSplit",
26592
26702
  sdNodeOrKeyName: "cantSplit",
26593
26703
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
26594
26704
  decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
26595
26705
  });
26596
- const translator$S = NodeTranslator.from({
26706
+ const translator$T = NodeTranslator.from({
26597
26707
  xmlName: "w:cnfStyle",
26598
26708
  sdNodeOrKeyName: "cnfStyle",
26599
26709
  attributes: [
@@ -26619,8 +26729,8 @@ const translator$S = NodeTranslator.from({
26619
26729
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26620
26730
  }
26621
26731
  });
26622
- const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26623
- const translator$Q = NodeTranslator.from(
26732
+ const translator$S = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26733
+ const translator$R = NodeTranslator.from(
26624
26734
  createSingleAttrPropertyHandler(
26625
26735
  "w:gridAfter",
26626
26736
  null,
@@ -26629,7 +26739,7 @@ const translator$Q = NodeTranslator.from(
26629
26739
  (v2) => integerToString(v2)
26630
26740
  )
26631
26741
  );
26632
- const translator$P = NodeTranslator.from(
26742
+ const translator$Q = NodeTranslator.from(
26633
26743
  createSingleAttrPropertyHandler(
26634
26744
  "w:gridBefore",
26635
26745
  null,
@@ -26638,21 +26748,21 @@ const translator$P = NodeTranslator.from(
26638
26748
  (v2) => integerToString(v2)
26639
26749
  )
26640
26750
  );
26641
- const translator$O = NodeTranslator.from({
26751
+ const translator$P = NodeTranslator.from({
26642
26752
  xmlName: "w:hidden",
26643
26753
  sdNodeOrKeyName: "hidden",
26644
26754
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26645
26755
  decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
26646
26756
  });
26647
- const translator$N = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26648
- const translator$M = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26649
- const translator$L = NodeTranslator.from({
26757
+ const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26758
+ const translator$N = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26759
+ const translator$M = NodeTranslator.from({
26650
26760
  xmlName: "w:tblHeader",
26651
26761
  sdNodeOrKeyName: "repeatHeader",
26652
26762
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26653
26763
  decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
26654
26764
  });
26655
- const translator$K = NodeTranslator.from({
26765
+ const translator$L = NodeTranslator.from({
26656
26766
  xmlName: "w:trHeight",
26657
26767
  sdNodeOrKeyName: "rowHeight",
26658
26768
  encode: ({ nodes }) => {
@@ -26679,11 +26789,11 @@ const translator$K = NodeTranslator.from({
26679
26789
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
26680
26790
  }
26681
26791
  });
26682
- const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26683
- const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26684
- const XML_NODE_NAME$f = "w:trPr";
26792
+ const translator$K = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26793
+ const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26794
+ const XML_NODE_NAME$g = "w:trPr";
26685
26795
  const SD_ATTR_KEY$4 = "tableRowProperties";
26686
- const encode$m = (params) => {
26796
+ const encode$n = (params) => {
26687
26797
  const { nodes } = params;
26688
26798
  const node = nodes[0];
26689
26799
  let attributes = {
@@ -26697,12 +26807,12 @@ const encode$m = (params) => {
26697
26807
  };
26698
26808
  return {
26699
26809
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26700
- xmlName: XML_NODE_NAME$f,
26810
+ xmlName: XML_NODE_NAME$g,
26701
26811
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26702
26812
  attributes
26703
26813
  };
26704
26814
  };
26705
- const decode$m = (params) => {
26815
+ const decode$n = (params) => {
26706
26816
  const { tableRowProperties = {} } = params.node.attrs || {};
26707
26817
  const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
26708
26818
  const newNode = {
@@ -26714,6 +26824,7 @@ const decode$m = (params) => {
26714
26824
  return newNode;
26715
26825
  };
26716
26826
  const propertyTranslators$3 = [
26827
+ translator$U,
26717
26828
  translator$T,
26718
26829
  translator$S,
26719
26830
  translator$R,
@@ -26724,8 +26835,7 @@ const propertyTranslators$3 = [
26724
26835
  translator$M,
26725
26836
  translator$L,
26726
26837
  translator$K,
26727
- translator$J,
26728
- translator$I
26838
+ translator$J
26729
26839
  ];
26730
26840
  const propertyTranslatorsByXmlName$2 = {};
26731
26841
  propertyTranslators$3.forEach((translator2) => {
@@ -26735,25 +26845,25 @@ const propertyTranslatorsBySdName$2 = {};
26735
26845
  propertyTranslators$3.forEach((translator2) => {
26736
26846
  propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
26737
26847
  });
26738
- const config$d = {
26739
- xmlName: XML_NODE_NAME$f,
26848
+ const config$e = {
26849
+ xmlName: XML_NODE_NAME$g,
26740
26850
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26741
26851
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26742
- encode: encode$m,
26743
- decode: decode$m
26852
+ encode: encode$n,
26853
+ decode: decode$n
26744
26854
  };
26745
- const translator$H = NodeTranslator.from(config$d);
26746
- const XML_NODE_NAME$e = "w:tr";
26747
- const SD_NODE_NAME$a = "tableRow";
26748
- const validXmlAttributes$9 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26855
+ const translator$I = NodeTranslator.from(config$e);
26856
+ const XML_NODE_NAME$f = "w:tr";
26857
+ const SD_NODE_NAME$b = "tableRow";
26858
+ const validXmlAttributes$8 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26749
26859
  (xmlName) => createAttributeHandler(xmlName)
26750
26860
  );
26751
- const encode$l = (params, encodedAttrs) => {
26861
+ const encode$m = (params, encodedAttrs) => {
26752
26862
  const { row } = params.extraParams;
26753
26863
  let tableRowProperties = {};
26754
26864
  const tPr = row.elements.find((el) => el.name === "w:trPr");
26755
26865
  if (tPr) {
26756
- ({ attributes: tableRowProperties } = translator$H.encode({
26866
+ ({ attributes: tableRowProperties } = translator$I.encode({
26757
26867
  ...params,
26758
26868
  nodes: [tPr]
26759
26869
  }));
@@ -26766,7 +26876,7 @@ const encode$l = (params, encodedAttrs) => {
26766
26876
  let currentColumnIndex = 0;
26767
26877
  const content = cellNodes?.map((n) => {
26768
26878
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
26769
- const result = translator$8.encode({
26879
+ const result = translator$9.encode({
26770
26880
  ...params,
26771
26881
  extraParams: {
26772
26882
  ...params.extraParams,
@@ -26788,7 +26898,7 @@ const encode$l = (params, encodedAttrs) => {
26788
26898
  };
26789
26899
  return newNode;
26790
26900
  };
26791
- const decode$l = (params, decodedAttrs) => {
26901
+ const decode$m = (params, decodedAttrs) => {
26792
26902
  const { node } = params;
26793
26903
  const elements = translateChildNodes(params);
26794
26904
  if (node.attrs?.tableRowProperties) {
@@ -26800,7 +26910,7 @@ const decode$l = (params, decodedAttrs) => {
26800
26910
  }
26801
26911
  }
26802
26912
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
26803
- const trPr = translator$H.decode({
26913
+ const trPr = translator$I.decode({
26804
26914
  ...params,
26805
26915
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
26806
26916
  });
@@ -26812,22 +26922,22 @@ const decode$l = (params, decodedAttrs) => {
26812
26922
  elements
26813
26923
  };
26814
26924
  };
26815
- const config$c = {
26816
- xmlName: XML_NODE_NAME$e,
26817
- sdNodeOrKeyName: SD_NODE_NAME$a,
26925
+ const config$d = {
26926
+ xmlName: XML_NODE_NAME$f,
26927
+ sdNodeOrKeyName: SD_NODE_NAME$b,
26818
26928
  type: NodeTranslator.translatorTypes.NODE,
26819
- encode: encode$l,
26820
- decode: decode$l,
26821
- attributes: validXmlAttributes$9
26929
+ encode: encode$m,
26930
+ decode: decode$m,
26931
+ attributes: validXmlAttributes$8
26822
26932
  };
26823
- const translator$G = NodeTranslator.from(config$c);
26824
- const translator$F = NodeTranslator.from({
26933
+ const translator$H = NodeTranslator.from(config$d);
26934
+ const translator$G = NodeTranslator.from({
26825
26935
  xmlName: "w:bidiVisual",
26826
26936
  sdNodeOrKeyName: "rightToLeft",
26827
26937
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26828
26938
  decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
26829
26939
  });
26830
- const translator$E = NodeTranslator.from({
26940
+ const translator$F = NodeTranslator.from({
26831
26941
  xmlName: "w:shd",
26832
26942
  sdNodeOrKeyName: "shading",
26833
26943
  attributes: [
@@ -26849,11 +26959,11 @@ const translator$E = NodeTranslator.from({
26849
26959
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26850
26960
  }
26851
26961
  });
26852
- const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26853
- const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26854
- const translator$B = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26855
- const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26856
- const translator$z = NodeTranslator.from({
26962
+ const translator$E = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26963
+ const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26964
+ const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26965
+ const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26966
+ const translator$A = NodeTranslator.from({
26857
26967
  xmlName: "w:tblLook",
26858
26968
  sdNodeOrKeyName: "tblLook",
26859
26969
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -26865,16 +26975,16 @@ const translator$z = NodeTranslator.from({
26865
26975
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26866
26976
  }
26867
26977
  });
26868
- const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26869
- const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26870
- const translator$w = NodeTranslator.from(
26978
+ const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26979
+ const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26980
+ const translator$x = NodeTranslator.from(
26871
26981
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
26872
26982
  );
26873
- const translator$v = NodeTranslator.from(
26983
+ const translator$w = NodeTranslator.from(
26874
26984
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
26875
26985
  );
26876
- const translator$u = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26877
- const translator$t = NodeTranslator.from({
26986
+ const translator$v = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26987
+ const translator$u = NodeTranslator.from({
26878
26988
  xmlName: "w:tblpPr",
26879
26989
  sdNodeOrKeyName: "floatingTableProperties",
26880
26990
  attributes: ["w:leftFromText", "w:rightFromText", "w:topFromText", "w:bottomFromText", "w:tblpX", "w:tblpY"].map((attr) => createAttributeHandler(attr, null, parseInteger, integerToString)).concat(["w:horzAnchor", "w:vertAnchor", "w:tblpXSpec", "w:tblpYSpec"].map((attr) => createAttributeHandler(attr))),
@@ -26886,29 +26996,29 @@ const translator$t = NodeTranslator.from({
26886
26996
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26887
26997
  }
26888
26998
  });
26889
- const translator$s = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
26890
- const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
26891
- const translator$q = NodeTranslator.from(createBorderPropertyHandler("w:end"));
26892
- const translator$p = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
26893
- const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
26894
- const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
26895
- const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:left"));
26896
- const translator$l = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
26897
- const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:right"));
26898
- const translator$j = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
26899
- const translator$i = NodeTranslator.from(createBorderPropertyHandler("w:start"));
26900
- const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
26901
- const translator$g = NodeTranslator.from(createBorderPropertyHandler("w:top"));
26902
- const translator$f = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
26903
- const XML_NODE_NAME$d = "w:tblBorders";
26999
+ const translator$t = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
27000
+ const translator$s = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
27001
+ const translator$r = NodeTranslator.from(createBorderPropertyHandler("w:end"));
27002
+ const translator$q = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
27003
+ const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
27004
+ const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
27005
+ const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:left"));
27006
+ const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
27007
+ const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:right"));
27008
+ const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
27009
+ const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:start"));
27010
+ const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
27011
+ const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:top"));
27012
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
27013
+ const XML_NODE_NAME$e = "w:tblBorders";
26904
27014
  const SD_ATTR_KEY$3 = "borders";
26905
- const encode$k = (params) => {
27015
+ const encode$l = (params) => {
26906
27016
  const { nodes } = params;
26907
27017
  const node = nodes[0];
26908
27018
  const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
26909
27019
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26910
27020
  };
26911
- const decode$k = (params) => {
27021
+ const decode$l = (params) => {
26912
27022
  const { borders = {} } = params.node.attrs || {};
26913
27023
  const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
26914
27024
  const newNode = {
@@ -26920,14 +27030,14 @@ const decode$k = (params) => {
26920
27030
  return newNode;
26921
27031
  };
26922
27032
  const propertyTranslators$2 = [
26923
- translator$s,
26924
- translator$q,
27033
+ translator$t,
27034
+ translator$r,
27035
+ translator$p,
26925
27036
  translator$o,
26926
27037
  translator$n,
26927
- translator$m,
26928
- translator$k,
26929
- translator$i,
26930
- translator$g
27038
+ translator$l,
27039
+ translator$j,
27040
+ translator$h
26931
27041
  ];
26932
27042
  const tblBordersTranslatorsByXmlName = {};
26933
27043
  const tblBordersTranslatorsBySdName = {};
@@ -26935,27 +27045,27 @@ propertyTranslators$2.forEach((translator2) => {
26935
27045
  tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
26936
27046
  tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
26937
27047
  });
26938
- const translator$e = NodeTranslator.from({
26939
- xmlName: XML_NODE_NAME$d,
27048
+ const translator$f = NodeTranslator.from({
27049
+ xmlName: XML_NODE_NAME$e,
26940
27050
  sdNodeOrKeyName: SD_ATTR_KEY$3,
26941
27051
  type: NodeTranslator.translatorTypes.NODE,
26942
27052
  attributes: [],
26943
- encode: encode$k,
26944
- decode: decode$k
27053
+ encode: encode$l,
27054
+ decode: decode$l
26945
27055
  });
26946
- const XML_NODE_NAME$c = "w:tblCellMar";
27056
+ const XML_NODE_NAME$d = "w:tblCellMar";
26947
27057
  const SD_ATTR_KEY$2 = "cellMargins";
26948
- const encode$j = (params) => {
27058
+ const encode$k = (params) => {
26949
27059
  const { nodes } = params;
26950
27060
  const node = nodes[0];
26951
27061
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
26952
27062
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26953
27063
  };
26954
- const decode$j = (params) => {
27064
+ const decode$k = (params) => {
26955
27065
  const { cellMargins = {} } = params.node.attrs || {};
26956
27066
  const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
26957
27067
  const newNode = {
26958
- name: XML_NODE_NAME$c,
27068
+ name: XML_NODE_NAME$d,
26959
27069
  type: "element",
26960
27070
  attributes: {},
26961
27071
  elements
@@ -26963,12 +27073,12 @@ const decode$j = (params) => {
26963
27073
  return newNode;
26964
27074
  };
26965
27075
  const propertyTranslators$1 = [
26966
- translator$r,
26967
- translator$p,
26968
- translator$l,
26969
- translator$j,
26970
- translator$h,
26971
- translator$f
27076
+ translator$s,
27077
+ translator$q,
27078
+ translator$m,
27079
+ translator$k,
27080
+ translator$i,
27081
+ translator$g
26972
27082
  ];
26973
27083
  const propertyTranslatorsByXmlName$1 = {};
26974
27084
  const propertyTranslatorsBySdName$1 = {};
@@ -26976,27 +27086,27 @@ propertyTranslators$1.forEach((translator2) => {
26976
27086
  propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
26977
27087
  propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
26978
27088
  });
26979
- const translator$d = NodeTranslator.from({
26980
- xmlName: XML_NODE_NAME$c,
27089
+ const translator$e = NodeTranslator.from({
27090
+ xmlName: XML_NODE_NAME$d,
26981
27091
  sdNodeOrKeyName: SD_ATTR_KEY$2,
26982
27092
  type: NodeTranslator.translatorTypes.NODE,
26983
27093
  attributes: [],
26984
- encode: encode$j,
26985
- decode: decode$j
27094
+ encode: encode$k,
27095
+ decode: decode$k
26986
27096
  });
26987
- const XML_NODE_NAME$b = "w:tblPr";
27097
+ const XML_NODE_NAME$c = "w:tblPr";
26988
27098
  const SD_ATTR_KEY$1 = "tableProperties";
26989
- const encode$i = (params) => {
27099
+ const encode$j = (params) => {
26990
27100
  const { nodes } = params;
26991
27101
  const node = nodes[0];
26992
27102
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
26993
27103
  return {
26994
- xmlName: XML_NODE_NAME$b,
27104
+ xmlName: XML_NODE_NAME$c,
26995
27105
  sdNodeOrKeyName: SD_ATTR_KEY$1,
26996
27106
  attributes
26997
27107
  };
26998
27108
  };
26999
- const decode$i = (params) => {
27109
+ const decode$j = (params) => {
27000
27110
  const { tableProperties = {} } = params.node.attrs || {};
27001
27111
  const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
27002
27112
  const newNode = {
@@ -27008,11 +27118,12 @@ const decode$i = (params) => {
27008
27118
  return newNode;
27009
27119
  };
27010
27120
  const propertyTranslators = [
27121
+ translator$G,
27122
+ translator$O,
27011
27123
  translator$F,
27012
- translator$N,
27013
27124
  translator$E,
27125
+ translator$N,
27014
27126
  translator$D,
27015
- translator$M,
27016
27127
  translator$C,
27017
27128
  translator$B,
27018
27129
  translator$A,
@@ -27022,24 +27133,23 @@ const propertyTranslators = [
27022
27133
  translator$w,
27023
27134
  translator$v,
27024
27135
  translator$u,
27025
- translator$t,
27026
- translator$e,
27027
- translator$d
27136
+ translator$f,
27137
+ translator$e
27028
27138
  ];
27029
27139
  const propertyTranslatorsByXmlName = {};
27030
27140
  const propertyTranslatorsBySdName = {};
27031
27141
  propertyTranslators.forEach((translator2) => {
27032
27142
  propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
27033
27143
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
27034
- });
27035
- const config$b = {
27036
- xmlName: XML_NODE_NAME$b,
27144
+ });
27145
+ const config$c = {
27146
+ xmlName: XML_NODE_NAME$c,
27037
27147
  sdNodeOrKeyName: SD_ATTR_KEY$1,
27038
- encode: encode$i,
27039
- decode: decode$i
27148
+ encode: encode$j,
27149
+ decode: decode$j
27040
27150
  };
27041
- const translator$c = NodeTranslator.from(config$b);
27042
- const translator$b = NodeTranslator.from(
27151
+ const translator$d = NodeTranslator.from(config$c);
27152
+ const translator$c = NodeTranslator.from(
27043
27153
  createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
27044
27154
  );
27045
27155
  const DEFAULT_COLUMN_WIDTH_PX = 100;
@@ -27089,20 +27199,20 @@ const resolveFallbackColumnWidthTwips = (params, totalColumns, cellMinWidthTwips
27089
27199
  }
27090
27200
  return Math.max(fallbackWidthTwips, cellMinWidthTwips);
27091
27201
  };
27092
- const XML_NODE_NAME$a = "w:tblGrid";
27202
+ const XML_NODE_NAME$b = "w:tblGrid";
27093
27203
  const SD_ATTR_KEY = "grid";
27094
27204
  const cellMinWidth = pixelsToTwips(10);
27095
- const encode$h = (params) => {
27205
+ const encode$i = (params) => {
27096
27206
  const { nodes } = params;
27097
27207
  const node = nodes[0];
27098
- const attributes = encodeProperties(node, { [translator$b.xmlName]: translator$b }, true);
27208
+ const attributes = encodeProperties(node, { [translator$c.xmlName]: translator$c }, true);
27099
27209
  return {
27100
- xmlName: XML_NODE_NAME$a,
27210
+ xmlName: XML_NODE_NAME$b,
27101
27211
  sdNodeOrKeyName: SD_ATTR_KEY,
27102
27212
  attributes
27103
27213
  };
27104
27214
  };
27105
- const decode$h = (params) => {
27215
+ const decode$i = (params) => {
27106
27216
  const { grid: rawGrid } = params.node.attrs || {};
27107
27217
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
27108
27218
  const { firstRow = {} } = params.extraParams || {};
@@ -27121,10 +27231,10 @@ const decode$h = (params) => {
27121
27231
  numericWidth = fallbackColumnWidthTwips;
27122
27232
  }
27123
27233
  numericWidth = Math.max(numericWidth, cellMinWidth);
27124
- const decoded = translator$b.decode({
27234
+ const decoded = translator$c.decode({
27125
27235
  node: { type: (
27126
27236
  /** @type {string} */
27127
- translator$b.sdNodeOrKeyName
27237
+ translator$c.sdNodeOrKeyName
27128
27238
  ), attrs: { col: numericWidth } }
27129
27239
  });
27130
27240
  if (decoded) elements.push(decoded);
@@ -27159,19 +27269,19 @@ const decode$h = (params) => {
27159
27269
  columnIndex++;
27160
27270
  }
27161
27271
  const newNode = {
27162
- name: XML_NODE_NAME$a,
27272
+ name: XML_NODE_NAME$b,
27163
27273
  attributes: {},
27164
27274
  elements
27165
27275
  };
27166
27276
  return newNode;
27167
27277
  };
27168
- const config$a = {
27169
- xmlName: XML_NODE_NAME$a,
27278
+ const config$b = {
27279
+ xmlName: XML_NODE_NAME$b,
27170
27280
  sdNodeOrKeyName: SD_ATTR_KEY,
27171
- encode: encode$h,
27172
- decode: decode$h
27281
+ encode: encode$i,
27282
+ decode: decode$i
27173
27283
  };
27174
- const translator$a = NodeTranslator.from(config$a);
27284
+ const translator$b = NodeTranslator.from(config$b);
27175
27285
  const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
27176
27286
  const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
27177
27287
  const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
@@ -27234,19 +27344,19 @@ const buildFallbackGridForTable = ({ params, rows, tableWidth, tableWidthMeasure
27234
27344
  columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
27235
27345
  };
27236
27346
  };
27237
- const XML_NODE_NAME$9 = "w:tbl";
27238
- const SD_NODE_NAME$9 = "table";
27239
- const encode$g = (params, encodedAttrs) => {
27347
+ const XML_NODE_NAME$a = "w:tbl";
27348
+ const SD_NODE_NAME$a = "table";
27349
+ const encode$h = (params, encodedAttrs) => {
27240
27350
  const { nodes } = params;
27241
27351
  const node = nodes[0];
27242
27352
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
27243
27353
  if (tblPr) {
27244
- const encodedProperties = translator$c.encode({ ...params, nodes: [tblPr] });
27354
+ const encodedProperties = translator$d.encode({ ...params, nodes: [tblPr] });
27245
27355
  encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
27246
27356
  }
27247
27357
  const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
27248
27358
  if (tblGrid) {
27249
- encodedAttrs["grid"] = translator$a.encode({ ...params, nodes: [tblGrid] }).attributes;
27359
+ encodedAttrs["grid"] = translator$b.encode({ ...params, nodes: [tblGrid] }).attributes;
27250
27360
  }
27251
27361
  [
27252
27362
  "tableStyleId",
@@ -27313,7 +27423,7 @@ const encode$g = (params, encodedAttrs) => {
27313
27423
  }
27314
27424
  const content = [];
27315
27425
  rows.forEach((row) => {
27316
- const result = translator$G.encode({
27426
+ const result = translator$H.encode({
27317
27427
  ...params,
27318
27428
  nodes: [row],
27319
27429
  extraParams: {
@@ -27332,13 +27442,13 @@ const encode$g = (params, encodedAttrs) => {
27332
27442
  attrs: encodedAttrs
27333
27443
  };
27334
27444
  };
27335
- const decode$g = (params, decodedAttrs) => {
27445
+ const decode$h = (params, decodedAttrs) => {
27336
27446
  params.node = preProcessVerticalMergeCells(params.node, params);
27337
27447
  const { node } = params;
27338
27448
  const elements = translateChildNodes(params);
27339
27449
  const firstRow = node.content?.find((n) => n.type === "tableRow");
27340
27450
  const properties = node.attrs.grid;
27341
- const element = translator$a.decode({
27451
+ const element = translator$b.decode({
27342
27452
  ...params,
27343
27453
  node: { ...node, attrs: { ...node.attrs, grid: properties } },
27344
27454
  extraParams: {
@@ -27348,7 +27458,7 @@ const decode$g = (params, decodedAttrs) => {
27348
27458
  if (element) elements.unshift(element);
27349
27459
  if (node.attrs?.tableProperties) {
27350
27460
  const properties2 = { ...node.attrs.tableProperties };
27351
- const element2 = translator$c.decode({
27461
+ const element2 = translator$d.decode({
27352
27462
  ...params,
27353
27463
  node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
27354
27464
  });
@@ -27414,7 +27524,7 @@ function _getReferencedTableStyles(tableStyleReference, params) {
27414
27524
  if (baseTblPr && baseTblPr.elements) {
27415
27525
  tblPr.elements.push(...baseTblPr.elements);
27416
27526
  }
27417
- const tableProperties = translator$c.encode({ ...params, nodes: [tblPr] }).attributes;
27527
+ const tableProperties = translator$d.encode({ ...params, nodes: [tblPr] }).attributes;
27418
27528
  const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
27419
27529
  if (borders) stylesToReturn.borders = borders;
27420
27530
  if (rowBorders) stylesToReturn.rowBorders = rowBorders;
@@ -27431,16 +27541,16 @@ function _getReferencedTableStyles(tableStyleReference, params) {
27431
27541
  }
27432
27542
  return stylesToReturn;
27433
27543
  }
27434
- const config$9 = {
27435
- xmlName: XML_NODE_NAME$9,
27436
- sdNodeOrKeyName: SD_NODE_NAME$9,
27544
+ const config$a = {
27545
+ xmlName: XML_NODE_NAME$a,
27546
+ sdNodeOrKeyName: SD_NODE_NAME$a,
27437
27547
  type: NodeTranslator.translatorTypes.NODE,
27438
- encode: encode$g,
27439
- decode: decode$g,
27548
+ encode: encode$h,
27549
+ decode: decode$h,
27440
27550
  attributes: []
27441
27551
  };
27442
- const translator$9 = NodeTranslator.from(config$9);
27443
- const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$9);
27552
+ const translator$a = NodeTranslator.from(config$a);
27553
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$a);
27444
27554
  function getReferencedTableStyles(tblStyleTag, docx) {
27445
27555
  if (!tblStyleTag) return null;
27446
27556
  const stylesToReturn = {};
@@ -27802,10 +27912,10 @@ function generateCellMargins(cellMargins) {
27802
27912
  if (left != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left) } });
27803
27913
  return elements;
27804
27914
  }
27805
- const XML_NODE_NAME$8 = "w:tc";
27806
- const SD_NODE_NAME$8 = "tableCell";
27807
- const validXmlAttributes$8 = [];
27808
- function encode$f(params, encodedAttrs) {
27915
+ const XML_NODE_NAME$9 = "w:tc";
27916
+ const SD_NODE_NAME$9 = "tableCell";
27917
+ const validXmlAttributes$7 = [];
27918
+ function encode$g(params, encodedAttrs) {
27809
27919
  const {
27810
27920
  node,
27811
27921
  table,
@@ -27832,162 +27942,22 @@ function encode$f(params, encodedAttrs) {
27832
27942
  }
27833
27943
  return schemaNode;
27834
27944
  }
27835
- function decode$f(params, decodedAttrs) {
27945
+ function decode$g(params, decodedAttrs) {
27836
27946
  const translated = translateTableCell(params);
27837
27947
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
27838
27948
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
27839
27949
  }
27840
27950
  return translated;
27841
27951
  }
27842
- const config$8 = {
27843
- xmlName: XML_NODE_NAME$8,
27844
- sdNodeOrKeyName: SD_NODE_NAME$8,
27845
- type: NodeTranslator.translatorTypes.NODE,
27846
- encode: encode$f,
27847
- decode: decode$f,
27848
- attributes: validXmlAttributes$8
27849
- };
27850
- const translator$8 = NodeTranslator.from(config$8);
27851
- const XML_NODE_NAME$7 = "w:hyperlink";
27852
- const SD_NODE_NAME$7 = "link";
27853
- const _createAttributeHandler = (xmlName, sdName) => ({
27854
- xmlName,
27855
- sdName,
27856
- encode: (attributes) => attributes[xmlName],
27857
- decode: (attributes) => attributes[sdName]
27858
- });
27859
- const validXmlAttributes$7 = [
27860
- _createAttributeHandler("w:anchor", "anchor"),
27861
- _createAttributeHandler("w:docLocation", "docLocation"),
27862
- {
27863
- xmlName: "w:history",
27864
- sdName: "history",
27865
- encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
27866
- decode: (attributes) => attributes["history"] ? "1" : "0"
27867
- },
27868
- _createAttributeHandler("w:tooltip", "tooltip"),
27869
- _createAttributeHandler("r:id", "rId"),
27870
- _createAttributeHandler("w:tgtFrame", "target")
27871
- ];
27872
- const encode$e = (params, encodedAttrs) => {
27873
- const { nodes, docx, nodeListHandler } = params;
27874
- const node = nodes[0];
27875
- let href = _resolveHref(docx, encodedAttrs);
27876
- const linkMark = { attrs: { ...encodedAttrs, href } };
27877
- const runNodes = node.elements.filter((el) => el.name === "w:r");
27878
- runNodes.forEach((runNode) => {
27879
- const existingRunMarks = Array.isArray(runNode.marks) ? runNode.marks : [];
27880
- const runMarksWithoutLink = existingRunMarks.filter((mark) => mark?.type !== "link");
27881
- runNode.marks = runMarksWithoutLink;
27882
- });
27883
- const updatedNode = nodeListHandler.handler({
27884
- ...params,
27885
- nodes: runNodes,
27886
- path: [...params.path || [], node]
27887
- });
27888
- const cloneMark2 = (mark) => {
27889
- if (!mark || typeof mark !== "object") return mark;
27890
- if (!mark.attrs) return { ...mark };
27891
- return { ...mark, attrs: { ...mark.attrs } };
27892
- };
27893
- const ensureLinkMark = (child) => {
27894
- if (!child || typeof child !== "object") return child;
27895
- if (Array.isArray(child.content)) {
27896
- const updatedContent = child.content.map((item) => ensureLinkMark(item));
27897
- if (updatedContent !== child.content) {
27898
- child = { ...child, content: updatedContent };
27899
- }
27900
- }
27901
- if (child.type === "run") {
27902
- const existingMarks2 = Array.isArray(child.marks) ? child.marks : [];
27903
- const filteredMarks = existingMarks2.filter((mark) => mark?.type !== "link").map((mark) => cloneMark2(mark));
27904
- if (filteredMarks.length !== existingMarks2.length) {
27905
- if (filteredMarks.length) child = { ...child, marks: filteredMarks };
27906
- else {
27907
- const { marks: _removedMarks, ...rest } = child;
27908
- child = rest;
27909
- }
27910
- }
27911
- return child;
27912
- }
27913
- if (child.type !== "text") return child;
27914
- const existingMarks = Array.isArray(child.marks) ? child.marks.map((mark) => cloneMark2(mark)) : [];
27915
- const hasLink = existingMarks.some((mark) => mark?.type === "link");
27916
- if (hasLink) return child;
27917
- const linkClone = { type: "link", attrs: { ...linkMark.attrs } };
27918
- return { ...child, marks: [...existingMarks, linkClone] };
27919
- };
27920
- if (!Array.isArray(updatedNode)) return updatedNode;
27921
- return updatedNode.map((child) => ensureLinkMark(child));
27922
- };
27923
- const _resolveHref = (docx, encodedAttrs) => {
27924
- const rels = docx["word/_rels/document.xml.rels"];
27925
- const relationships = rels.elements.find((el) => el.name === "Relationships");
27926
- const { elements } = relationships;
27927
- const { rId, anchor } = encodedAttrs;
27928
- let href;
27929
- if (!rId && anchor) {
27930
- href = `#${anchor}`;
27931
- } else if (rId) {
27932
- const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
27933
- const { attributes: relAttributes = {} } = rel;
27934
- href = relAttributes["Target"];
27935
- }
27936
- return href;
27937
- };
27938
- function decode$e(params) {
27939
- const { node } = params;
27940
- const linkMark = node.marks.find((m2) => m2.type === "link");
27941
- const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
27942
- let { anchor, href: link } = linkMark.attrs;
27943
- const isExternalLink = !anchor;
27944
- if (isExternalLink) {
27945
- linkAttrs["r:id"] = _addNewLinkRelationship(params, link, linkAttrs["r:id"]);
27946
- }
27947
- node.marks = node.marks.filter((m2) => m2.type !== "link");
27948
- const outputNode = exportSchemaToJson({ ...params, node });
27949
- const newNode = {
27950
- name: "w:hyperlink",
27951
- type: "element",
27952
- attributes: {
27953
- ...linkAttrs
27954
- },
27955
- elements: [outputNode]
27956
- };
27957
- return newNode;
27958
- }
27959
- function _addNewLinkRelationship(params, link, rId) {
27960
- if (!rId) rId = generateDocxRandomId();
27961
- if (!params.relationships || !Array.isArray(params.relationships)) {
27962
- params.relationships = [];
27963
- }
27964
- const existingRel = params.relationships.find(
27965
- (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
27966
- );
27967
- if (existingRel) {
27968
- return rId;
27969
- }
27970
- params.relationships.push({
27971
- type: "element",
27972
- name: "Relationship",
27973
- attributes: {
27974
- Id: rId,
27975
- Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
27976
- Target: link,
27977
- TargetMode: "External"
27978
- }
27979
- });
27980
- return rId;
27981
- }
27982
- const config$7 = {
27983
- xmlName: XML_NODE_NAME$7,
27984
- sdNodeOrKeyName: SD_NODE_NAME$7,
27952
+ const config$9 = {
27953
+ xmlName: XML_NODE_NAME$9,
27954
+ sdNodeOrKeyName: SD_NODE_NAME$9,
27985
27955
  type: NodeTranslator.translatorTypes.NODE,
27986
- encode: encode$e,
27987
- decode: decode$e,
27956
+ encode: encode$g,
27957
+ decode: decode$g,
27988
27958
  attributes: validXmlAttributes$7
27989
27959
  };
27990
- const translator$7 = NodeTranslator.from(config$7);
27960
+ const translator$9 = NodeTranslator.from(config$9);
27991
27961
  function parseTagValueJSON(json) {
27992
27962
  if (typeof json !== "string") {
27993
27963
  return {};
@@ -28123,12 +28093,32 @@ function handleDocPartObj(params) {
28123
28093
  }
28124
28094
  const content = node?.elements.find((el) => el.name === "w:sdtContent");
28125
28095
  const handler2 = validGalleryTypeMap[docPartGalleryType];
28126
- const result = handler2({ ...params, nodes: [content] });
28096
+ const result = handler2({
28097
+ ...params,
28098
+ nodes: [content],
28099
+ extraParams: { ...params.extraParams || {}, sdtPr }
28100
+ });
28127
28101
  return result;
28128
28102
  }
28129
28103
  const tableOfContentsHandler = (params) => {
28130
28104
  const node = params.nodes[0];
28131
- return params.nodeListHandler.handler({ ...params, nodes: node.elements });
28105
+ const translatedContent = params.nodeListHandler.handler({
28106
+ ...params,
28107
+ nodes: node.elements,
28108
+ path: [...params.path || [], node]
28109
+ });
28110
+ const sdtPr = params.extraParams.sdtPr;
28111
+ const id = sdtPr.elements?.find((el) => el.name === "w:id")?.attributes["w:val"] || "";
28112
+ const result = {
28113
+ type: "documentPartObject",
28114
+ content: translatedContent,
28115
+ attrs: {
28116
+ id,
28117
+ docPartGallery: "Table of Contents",
28118
+ docPartUnique: true
28119
+ }
28120
+ };
28121
+ return result;
28132
28122
  };
28133
28123
  const validGalleryTypeMap = {
28134
28124
  "Table of Contents": tableOfContentsHandler
@@ -28786,32 +28776,32 @@ function translateAnchorNode(params) {
28786
28776
  elements: [...anchorElements, ...elementsWithWrap]
28787
28777
  };
28788
28778
  }
28789
- const XML_NODE_NAME$6 = "wp:anchor";
28790
- const SD_NODE_NAME$6 = ["image"];
28779
+ const XML_NODE_NAME$8 = "wp:anchor";
28780
+ const SD_NODE_NAME$8 = ["image"];
28791
28781
  const validXmlAttributes$6 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28792
- function encode$d(params) {
28782
+ function encode$f(params) {
28793
28783
  const { node } = params.extraParams;
28794
28784
  if (!node || !node.type) {
28795
28785
  return null;
28796
28786
  }
28797
28787
  return handleAnchorNode(params);
28798
28788
  }
28799
- function decode$d(params) {
28789
+ function decode$f(params) {
28800
28790
  const { node } = params;
28801
28791
  if (!node || !node.type) {
28802
28792
  return null;
28803
28793
  }
28804
28794
  return translateAnchorNode(params);
28805
28795
  }
28806
- const config$6 = {
28807
- xmlName: XML_NODE_NAME$6,
28808
- sdNodeOrKeyName: SD_NODE_NAME$6,
28796
+ const config$8 = {
28797
+ xmlName: XML_NODE_NAME$8,
28798
+ sdNodeOrKeyName: SD_NODE_NAME$8,
28809
28799
  type: NodeTranslator.translatorTypes.NODE,
28810
- encode: encode$d,
28811
- decode: decode$d,
28800
+ encode: encode$f,
28801
+ decode: decode$f,
28812
28802
  attributes: validXmlAttributes$6
28813
28803
  };
28814
- const translator$6 = NodeTranslator.from(config$6);
28804
+ const translator$8 = NodeTranslator.from(config$8);
28815
28805
  function handleInlineNode(params) {
28816
28806
  const { node } = params.extraParams;
28817
28807
  if (node.name !== "wp:inline") {
@@ -28827,41 +28817,41 @@ function translateInlineNode(params) {
28827
28817
  elements: nodeElements.elements
28828
28818
  };
28829
28819
  }
28830
- const XML_NODE_NAME$5 = "wp:inline";
28831
- const SD_NODE_NAME$5 = ["image"];
28820
+ const XML_NODE_NAME$7 = "wp:inline";
28821
+ const SD_NODE_NAME$7 = ["image"];
28832
28822
  const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28833
- function encode$c(params) {
28823
+ function encode$e(params) {
28834
28824
  const { node } = params.extraParams;
28835
28825
  if (!node || !node.type) {
28836
28826
  return null;
28837
28827
  }
28838
28828
  return handleInlineNode(params);
28839
28829
  }
28840
- function decode$c(params) {
28830
+ function decode$e(params) {
28841
28831
  const { node } = params;
28842
28832
  if (!node || !node.type) {
28843
28833
  return null;
28844
28834
  }
28845
28835
  return translateInlineNode(params);
28846
28836
  }
28847
- const config$5 = {
28848
- xmlName: XML_NODE_NAME$5,
28849
- sdNodeOrKeyName: SD_NODE_NAME$5,
28837
+ const config$7 = {
28838
+ xmlName: XML_NODE_NAME$7,
28839
+ sdNodeOrKeyName: SD_NODE_NAME$7,
28850
28840
  type: NodeTranslator.translatorTypes.NODE,
28851
- encode: encode$c,
28852
- decode: decode$c,
28841
+ encode: encode$e,
28842
+ decode: decode$e,
28853
28843
  attributes: validXmlAttributes$5
28854
28844
  };
28855
- const translator$5 = NodeTranslator.from(config$5);
28856
- const XML_NODE_NAME$4 = "w:drawing";
28857
- const SD_NODE_NAME$4 = [];
28845
+ const translator$7 = NodeTranslator.from(config$7);
28846
+ const XML_NODE_NAME$6 = "w:drawing";
28847
+ const SD_NODE_NAME$6 = [];
28858
28848
  const validXmlAttributes$4 = [];
28859
- function encode$b(params) {
28849
+ function encode$d(params) {
28860
28850
  const nodes = params.nodes;
28861
28851
  const node = nodes[0];
28862
28852
  const translatorByChildName = {
28863
- "wp:anchor": translator$6,
28864
- "wp:inline": translator$5
28853
+ "wp:anchor": translator$8,
28854
+ "wp:inline": translator$7
28865
28855
  };
28866
28856
  return node.elements.reduce((acc, child) => {
28867
28857
  if (acc) return acc;
@@ -28870,12 +28860,12 @@ function encode$b(params) {
28870
28860
  return translator2.encode({ ...params, extraParams: { node: child } }) || acc;
28871
28861
  }, null);
28872
28862
  }
28873
- function decode$b(params) {
28863
+ function decode$d(params) {
28874
28864
  const { node } = params;
28875
28865
  if (!node || !node.type) {
28876
28866
  return null;
28877
28867
  }
28878
- const childTranslator = node.attrs.isAnchor ? translator$6 : translator$5;
28868
+ const childTranslator = node.attrs.isAnchor ? translator$8 : translator$7;
28879
28869
  const resultNode = childTranslator.decode(params);
28880
28870
  return wrapTextInRun(
28881
28871
  {
@@ -28885,15 +28875,15 @@ function decode$b(params) {
28885
28875
  []
28886
28876
  );
28887
28877
  }
28888
- const config$4 = {
28889
- xmlName: XML_NODE_NAME$4,
28890
- sdNodeOrKeyName: SD_NODE_NAME$4,
28878
+ const config$6 = {
28879
+ xmlName: XML_NODE_NAME$6,
28880
+ sdNodeOrKeyName: SD_NODE_NAME$6,
28891
28881
  type: NodeTranslator.translatorTypes.NODE,
28892
- encode: encode$b,
28893
- decode: decode$b,
28882
+ encode: encode$d,
28883
+ decode: decode$d,
28894
28884
  attributes: validXmlAttributes$4
28895
28885
  };
28896
- const translator$4 = NodeTranslator.from(config$4);
28886
+ const translator$6 = NodeTranslator.from(config$6);
28897
28887
  class CommandService {
28898
28888
  /**
28899
28889
  * @param {import('./commands/types/index.js').CommandServiceOptions} props
@@ -30231,7 +30221,7 @@ function prepareTextAnnotation(params) {
30231
30221
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params);
30232
30222
  }
30233
30223
  function prepareImageAnnotation(params, imageSize) {
30234
- return translator$4.decode({
30224
+ return translator$6.decode({
30235
30225
  ...params,
30236
30226
  imageSize
30237
30227
  });
@@ -30451,6 +30441,49 @@ const generateSdtPrTagForDocumentSection = (id, title, tag) => {
30451
30441
  ]
30452
30442
  };
30453
30443
  };
30444
+ function translateDocumentPartObj(params) {
30445
+ const { node } = params;
30446
+ const { attrs = {} } = node;
30447
+ const childContent = translateChildNodes({ ...params, nodes: node.content });
30448
+ const nodeElements = [
30449
+ {
30450
+ name: "w:sdtPr",
30451
+ elements: [
30452
+ {
30453
+ name: "w:id",
30454
+ attributes: {
30455
+ "w:val": attrs.id
30456
+ }
30457
+ },
30458
+ {
30459
+ name: "w:docPartObj",
30460
+ elements: [
30461
+ {
30462
+ name: "w:docPartGallery",
30463
+ attributes: {
30464
+ "w:val": attrs.docPartGallery
30465
+ }
30466
+ },
30467
+ ...attrs.docPartUnique ? [
30468
+ {
30469
+ name: "w:docPartUnique"
30470
+ }
30471
+ ] : []
30472
+ ]
30473
+ }
30474
+ ]
30475
+ },
30476
+ {
30477
+ name: "w:sdtContent",
30478
+ elements: childContent
30479
+ }
30480
+ ];
30481
+ const result = {
30482
+ name: "w:sdt",
30483
+ elements: nodeElements
30484
+ };
30485
+ return result;
30486
+ }
30454
30487
  function translateStructuredContent(params) {
30455
30488
  const { node } = params;
30456
30489
  const childContent = translateChildNodes({ ...params, nodes: node.content });
@@ -30502,10 +30535,10 @@ function generateSdtPrTagForStructuredContent({ node }) {
30502
30535
  };
30503
30536
  return result;
30504
30537
  }
30505
- const XML_NODE_NAME$3 = "w:sdt";
30506
- const SD_NODE_NAME$3 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30538
+ const XML_NODE_NAME$5 = "w:sdt";
30539
+ const SD_NODE_NAME$5 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30507
30540
  const validXmlAttributes$3 = [];
30508
- function encode$a(params) {
30541
+ function encode$c(params) {
30509
30542
  const nodes = params.nodes;
30510
30543
  const node = nodes[0];
30511
30544
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -30515,7 +30548,7 @@ function encode$a(params) {
30515
30548
  const result = handler2(params);
30516
30549
  return result;
30517
30550
  }
30518
- function decode$a(params) {
30551
+ function decode$c(params) {
30519
30552
  const { node } = params;
30520
30553
  if (!node || !node.type) {
30521
30554
  return null;
@@ -30525,91 +30558,93 @@ function decode$a(params) {
30525
30558
  structuredContent: () => translateStructuredContent(params),
30526
30559
  structuredContentBlock: () => translateStructuredContent(params),
30527
30560
  documentSection: () => translateDocumentSection(params),
30561
+ documentPartObject: () => translateDocumentPartObj(params),
30562
+ // Handled in doc-part-obj translator
30528
30563
  default: () => null
30529
30564
  };
30530
30565
  const decoder = types2[node.type] ?? types2.default;
30531
30566
  const result = decoder();
30532
30567
  return result;
30533
30568
  }
30534
- const config$3 = {
30535
- xmlName: XML_NODE_NAME$3,
30536
- sdNodeOrKeyName: SD_NODE_NAME$3,
30569
+ const config$5 = {
30570
+ xmlName: XML_NODE_NAME$5,
30571
+ sdNodeOrKeyName: SD_NODE_NAME$5,
30537
30572
  type: NodeTranslator.translatorTypes.NODE,
30538
- encode: encode$a,
30539
- decode: decode$a,
30573
+ encode: encode$c,
30574
+ decode: decode$c,
30540
30575
  attributes: validXmlAttributes$3
30541
30576
  };
30542
- const translator$3 = NodeTranslator.from(config$3);
30543
- const encode$9 = (attributes) => {
30577
+ const translator$5 = NodeTranslator.from(config$5);
30578
+ const encode$b = (attributes) => {
30544
30579
  return attributes["w:id"];
30545
30580
  };
30546
- const decode$9 = (attrs) => {
30581
+ const decode$b = (attrs) => {
30547
30582
  return attrs.id;
30548
30583
  };
30549
30584
  const attrConfig$6 = Object.freeze({
30550
30585
  xmlName: "w:id",
30551
30586
  sdName: "id",
30552
- encode: encode$9,
30553
- decode: decode$9
30587
+ encode: encode$b,
30588
+ decode: decode$b
30554
30589
  });
30555
- const encode$8 = (attributes) => {
30590
+ const encode$a = (attributes) => {
30556
30591
  return attributes["w:name"];
30557
30592
  };
30558
- const decode$8 = (attrs) => {
30593
+ const decode$a = (attrs) => {
30559
30594
  return attrs.name;
30560
30595
  };
30561
30596
  const attrConfig$5 = Object.freeze({
30562
30597
  xmlName: "w:name",
30563
30598
  sdName: "name",
30564
- encode: encode$8,
30565
- decode: decode$8
30599
+ encode: encode$a,
30600
+ decode: decode$a
30566
30601
  });
30567
- const encode$7 = (attributes) => {
30602
+ const encode$9 = (attributes) => {
30568
30603
  return attributes["w:colFirst"];
30569
30604
  };
30570
- const decode$7 = (attrs) => {
30605
+ const decode$9 = (attrs) => {
30571
30606
  return attrs.colFirst;
30572
30607
  };
30573
30608
  const attrConfig$4 = Object.freeze({
30574
30609
  xmlName: "w:colFirst",
30575
30610
  sdName: "colFirst",
30576
- encode: encode$7,
30577
- decode: decode$7
30611
+ encode: encode$9,
30612
+ decode: decode$9
30578
30613
  });
30579
- const encode$6 = (attributes) => {
30614
+ const encode$8 = (attributes) => {
30580
30615
  return attributes["w:colLast"];
30581
30616
  };
30582
- const decode$6 = (attrs) => {
30617
+ const decode$8 = (attrs) => {
30583
30618
  return attrs.colLast;
30584
30619
  };
30585
30620
  const attrConfig$3 = Object.freeze({
30586
30621
  xmlName: "w:colLast",
30587
30622
  sdName: "colLast",
30588
- encode: encode$6,
30589
- decode: decode$6
30623
+ encode: encode$8,
30624
+ decode: decode$8
30590
30625
  });
30591
- const encode$5 = (attributes) => {
30626
+ const encode$7 = (attributes) => {
30592
30627
  return attributes["w:displacedByCustomXml"];
30593
30628
  };
30594
- const decode$5 = (attrs) => {
30629
+ const decode$7 = (attrs) => {
30595
30630
  return attrs.displacedByCustomXml;
30596
30631
  };
30597
30632
  const attrConfig$2 = Object.freeze({
30598
30633
  xmlName: "w:displacedByCustomXml",
30599
30634
  sdName: "displacedByCustomXml",
30600
- encode: encode$5,
30601
- decode: decode$5
30635
+ encode: encode$7,
30636
+ decode: decode$7
30602
30637
  });
30603
30638
  const validXmlAttributes$2 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
30604
- const XML_NODE_NAME$2 = "w:bookmarkStart";
30605
- const SD_NODE_NAME$2 = "bookmarkStart";
30606
- const encode$4 = (params, encodedAttrs = {}) => {
30639
+ const XML_NODE_NAME$4 = "w:bookmarkStart";
30640
+ const SD_NODE_NAME$4 = "bookmarkStart";
30641
+ const encode$6 = (params, encodedAttrs = {}) => {
30607
30642
  return {
30608
30643
  type: "bookmarkStart",
30609
30644
  attrs: encodedAttrs
30610
30645
  };
30611
30646
  };
30612
- const decode$4 = (params, decodedAttrs = {}) => {
30647
+ const decode$6 = (params, decodedAttrs = {}) => {
30613
30648
  const result = {
30614
30649
  name: "w:bookmarkStart",
30615
30650
  elements: []
@@ -30619,49 +30654,49 @@ const decode$4 = (params, decodedAttrs = {}) => {
30619
30654
  }
30620
30655
  return result;
30621
30656
  };
30622
- const config$2 = {
30623
- xmlName: XML_NODE_NAME$2,
30624
- sdNodeOrKeyName: SD_NODE_NAME$2,
30657
+ const config$4 = {
30658
+ xmlName: XML_NODE_NAME$4,
30659
+ sdNodeOrKeyName: SD_NODE_NAME$4,
30625
30660
  type: NodeTranslator.translatorTypes.NODE,
30626
- encode: encode$4,
30627
- decode: decode$4,
30661
+ encode: encode$6,
30662
+ decode: decode$6,
30628
30663
  attributes: validXmlAttributes$2
30629
30664
  };
30630
- const translator$2 = NodeTranslator.from(config$2);
30631
- const encode$3 = (attributes) => {
30665
+ const translator$4 = NodeTranslator.from(config$4);
30666
+ const encode$5 = (attributes) => {
30632
30667
  return attributes["w:id"];
30633
30668
  };
30634
- const decode$3 = (attrs) => {
30669
+ const decode$5 = (attrs) => {
30635
30670
  return attrs.id;
30636
30671
  };
30637
30672
  const attrConfig$1 = Object.freeze({
30638
30673
  xmlName: "w:id",
30639
30674
  sdName: "id",
30640
- encode: encode$3,
30641
- decode: decode$3
30675
+ encode: encode$5,
30676
+ decode: decode$5
30642
30677
  });
30643
- const encode$2 = (attributes) => {
30678
+ const encode$4 = (attributes) => {
30644
30679
  return attributes["w:displacedByCustomXml"];
30645
30680
  };
30646
- const decode$2 = (attrs) => {
30681
+ const decode$4 = (attrs) => {
30647
30682
  return attrs.displacedByCustomXml;
30648
30683
  };
30649
30684
  const attrConfig = Object.freeze({
30650
30685
  xmlName: "w:displacedByCustomXml",
30651
30686
  sdName: "displacedByCustomXml",
30652
- encode: encode$2,
30653
- decode: decode$2
30687
+ encode: encode$4,
30688
+ decode: decode$4
30654
30689
  });
30655
30690
  const validXmlAttributes$1 = [attrConfig$1, attrConfig];
30656
- const XML_NODE_NAME$1 = "w:bookmarkEnd";
30657
- const SD_NODE_NAME$1 = "bookmarkEnd";
30658
- const encode$1 = (params, encodedAttrs = {}) => {
30691
+ const XML_NODE_NAME$3 = "w:bookmarkEnd";
30692
+ const SD_NODE_NAME$3 = "bookmarkEnd";
30693
+ const encode$3 = (params, encodedAttrs = {}) => {
30659
30694
  return {
30660
30695
  type: "bookmarkEnd",
30661
30696
  attrs: encodedAttrs
30662
30697
  };
30663
30698
  };
30664
- const decode$1 = (params, decodedAttrs = {}) => {
30699
+ const decode$3 = (params, decodedAttrs = {}) => {
30665
30700
  const result = {
30666
30701
  name: "w:bookmarkEnd",
30667
30702
  elements: []
@@ -30671,19 +30706,19 @@ const decode$1 = (params, decodedAttrs = {}) => {
30671
30706
  }
30672
30707
  return result;
30673
30708
  };
30674
- const config$1 = {
30675
- xmlName: XML_NODE_NAME$1,
30676
- sdNodeOrKeyName: SD_NODE_NAME$1,
30709
+ const config$3 = {
30710
+ xmlName: XML_NODE_NAME$3,
30711
+ sdNodeOrKeyName: SD_NODE_NAME$3,
30677
30712
  type: NodeTranslator.translatorTypes.NODE,
30678
- encode: encode$1,
30679
- decode: decode$1,
30713
+ encode: encode$3,
30714
+ decode: decode$3,
30680
30715
  attributes: validXmlAttributes$1
30681
30716
  };
30682
- const translator$1 = NodeTranslator.from(config$1);
30683
- const XML_NODE_NAME = "mc:AlternateContent";
30684
- const SD_NODE_NAME = [];
30717
+ const translator$3 = NodeTranslator.from(config$3);
30718
+ const XML_NODE_NAME$2 = "mc:AlternateContent";
30719
+ const SD_NODE_NAME$2 = [];
30685
30720
  const validXmlAttributes = [];
30686
- function encode(params) {
30721
+ function encode$2(params) {
30687
30722
  const { nodeListHandler } = params;
30688
30723
  const { node } = params.extraParams;
30689
30724
  if (!node || !node.type) {
@@ -30703,7 +30738,7 @@ function encode(params) {
30703
30738
  path: [...params.path || [], wpsNode]
30704
30739
  });
30705
30740
  }
30706
- function decode(params) {
30741
+ function decode$2(params) {
30707
30742
  const { node } = params;
30708
30743
  const { drawingContent } = node.attrs;
30709
30744
  const drawing = {
@@ -30720,13 +30755,186 @@ function decode(params) {
30720
30755
  elements: [choice]
30721
30756
  };
30722
30757
  }
30758
+ const config$2 = {
30759
+ xmlName: XML_NODE_NAME$2,
30760
+ sdNodeOrKeyName: SD_NODE_NAME$2,
30761
+ type: NodeTranslator.translatorTypes.NODE,
30762
+ encode: encode$2,
30763
+ decode: decode$2,
30764
+ attributes: validXmlAttributes
30765
+ };
30766
+ const translator$2 = NodeTranslator.from(config$2);
30767
+ const XML_NODE_NAME$1 = "sd:pageReference";
30768
+ const SD_NODE_NAME$1 = "pageReference";
30769
+ const encode$1 = (params, _2) => {
30770
+ const { nodes = [], nodeListHandler } = params || {};
30771
+ const node = nodes[0];
30772
+ const processedText = nodeListHandler.handler({
30773
+ ...params,
30774
+ nodes: node.elements
30775
+ });
30776
+ const processedNode = {
30777
+ type: "pageReference",
30778
+ attrs: {
30779
+ instruction: node.attributes?.instruction || "",
30780
+ marksAsAttrs: node.marks || []
30781
+ },
30782
+ content: processedText
30783
+ };
30784
+ return processedNode;
30785
+ };
30786
+ const decode$1 = (params, _2) => {
30787
+ const { node } = params;
30788
+ const outputMarks = processOutputMarks(node.attrs?.marksAsAttrs || []);
30789
+ const contentNodes = (node.content ?? []).flatMap((n) => exportSchemaToJson({ ...params, node: n }));
30790
+ const translated = [
30791
+ {
30792
+ name: "w:r",
30793
+ elements: [
30794
+ {
30795
+ name: "w:rPr",
30796
+ elements: outputMarks
30797
+ },
30798
+ {
30799
+ name: "w:fldChar",
30800
+ attributes: {
30801
+ "w:fldCharType": "begin"
30802
+ }
30803
+ }
30804
+ ]
30805
+ },
30806
+ {
30807
+ name: "w:r",
30808
+ elements: [
30809
+ {
30810
+ name: "w:rPr",
30811
+ elements: outputMarks
30812
+ },
30813
+ {
30814
+ name: "w:instrText",
30815
+ attributes: { "xml:space": "preserve" },
30816
+ elements: [
30817
+ {
30818
+ type: "text",
30819
+ text: `${node.attrs.instruction}`
30820
+ }
30821
+ ]
30822
+ }
30823
+ ]
30824
+ },
30825
+ {
30826
+ name: "w:r",
30827
+ elements: [
30828
+ {
30829
+ name: "w:rPr",
30830
+ elements: outputMarks
30831
+ },
30832
+ {
30833
+ name: "w:fldChar",
30834
+ attributes: {
30835
+ "w:fldCharType": "separate"
30836
+ }
30837
+ }
30838
+ ]
30839
+ },
30840
+ ...contentNodes,
30841
+ {
30842
+ name: "w:r",
30843
+ elements: [
30844
+ {
30845
+ name: "w:rPr",
30846
+ elements: outputMarks
30847
+ },
30848
+ {
30849
+ name: "w:fldChar",
30850
+ attributes: {
30851
+ "w:fldCharType": "end"
30852
+ }
30853
+ }
30854
+ ]
30855
+ }
30856
+ ];
30857
+ return translated;
30858
+ };
30859
+ const config$1 = {
30860
+ xmlName: XML_NODE_NAME$1,
30861
+ sdNodeOrKeyName: SD_NODE_NAME$1,
30862
+ type: NodeTranslator.translatorTypes.NODE,
30863
+ encode: encode$1,
30864
+ decode: decode$1
30865
+ };
30866
+ const translator$1 = NodeTranslator.from(config$1);
30867
+ const XML_NODE_NAME = "sd:tableOfContents";
30868
+ const SD_NODE_NAME = "tableOfContents";
30869
+ const encode = (params, _2) => {
30870
+ const { nodes = [], nodeListHandler } = params || {};
30871
+ const node = nodes[0];
30872
+ const processedContent = nodeListHandler.handler({
30873
+ ...params,
30874
+ nodes: node.elements || []
30875
+ });
30876
+ const processedNode = {
30877
+ type: "tableOfContents",
30878
+ attrs: {
30879
+ instruction: node.attributes?.instruction || ""
30880
+ },
30881
+ content: processedContent
30882
+ };
30883
+ return processedNode;
30884
+ };
30885
+ const decode = (params, _2) => {
30886
+ const { node } = params;
30887
+ const contentNodes = node.content.map((n) => exportSchemaToJson({ ...params, node: n }));
30888
+ const tocBeginElements = [
30889
+ {
30890
+ name: "w:r",
30891
+ elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "begin" }, elements: [] }]
30892
+ },
30893
+ {
30894
+ name: "w:r",
30895
+ elements: [
30896
+ {
30897
+ name: "w:instrText",
30898
+ attributes: { "xml:space": "preserve" },
30899
+ elements: [{ text: node.attrs?.instruction || "", type: "text", name: "#text", elements: [] }]
30900
+ }
30901
+ ]
30902
+ },
30903
+ { name: "w:r", elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "separate" }, elements: [] }] }
30904
+ ];
30905
+ if (contentNodes.length > 0) {
30906
+ const firstParagraph = contentNodes[0];
30907
+ let insertIndex = 0;
30908
+ if (firstParagraph.elements) {
30909
+ const pPrIndex = firstParagraph.elements.findIndex((el) => el.name === "w:pPr");
30910
+ insertIndex = pPrIndex >= 0 ? pPrIndex + 1 : 0;
30911
+ } else {
30912
+ firstParagraph.elements = [];
30913
+ }
30914
+ firstParagraph.elements.splice(insertIndex, 0, ...tocBeginElements);
30915
+ } else {
30916
+ contentNodes.push({
30917
+ name: "w:p",
30918
+ elements: tocBeginElements
30919
+ });
30920
+ }
30921
+ const tocEndElements = [
30922
+ { name: "w:r", elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "end" }, elements: [] }] }
30923
+ ];
30924
+ const lastParagraph = contentNodes[contentNodes.length - 1];
30925
+ if (lastParagraph.elements) {
30926
+ lastParagraph.elements.push(...tocEndElements);
30927
+ } else {
30928
+ lastParagraph.elements = [...tocEndElements];
30929
+ }
30930
+ return contentNodes;
30931
+ };
30723
30932
  const config = {
30724
30933
  xmlName: XML_NODE_NAME,
30725
30934
  sdNodeOrKeyName: SD_NODE_NAME,
30726
30935
  type: NodeTranslator.translatorTypes.NODE,
30727
30936
  encode,
30728
- decode,
30729
- attributes: validXmlAttributes
30937
+ decode
30730
30938
  };
30731
30939
  const translator = NodeTranslator.from(config);
30732
30940
  const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
@@ -30800,32 +31008,35 @@ function exportSchemaToJson(params) {
30800
31008
  doc: translateDocumentNode,
30801
31009
  body: translateBodyNode,
30802
31010
  heading: translateHeadingNode,
30803
- paragraph: translator$13,
30804
- run: translator$U,
31011
+ paragraph: translator$16,
31012
+ run: translator$V,
30805
31013
  text: translateTextNode,
30806
31014
  bulletList: translateList,
30807
31015
  orderedList: translateList,
30808
- lineBreak: translator$16,
30809
- table: translator$9,
30810
- tableRow: translator$G,
30811
- tableCell: translator$8,
30812
- bookmarkStart: translator$2,
30813
- bookmarkEnd: translator$1,
30814
- fieldAnnotation: translator$3,
30815
- tab: translator$14,
30816
- image: translator$4,
30817
- hardBreak: translator$16,
31016
+ lineBreak: translator$19,
31017
+ table: translator$a,
31018
+ tableRow: translator$H,
31019
+ tableCell: translator$9,
31020
+ bookmarkStart: translator$4,
31021
+ bookmarkEnd: translator$3,
31022
+ fieldAnnotation: translator$5,
31023
+ tab: translator$17,
31024
+ image: translator$6,
31025
+ hardBreak: translator$19,
30818
31026
  commentRangeStart: () => translateCommentNode(params, "Start"),
30819
31027
  commentRangeEnd: () => translateCommentNode(params, "End"),
30820
31028
  commentReference: () => null,
30821
31029
  shapeContainer: translateShapeContainer,
30822
31030
  shapeTextbox: translateShapeTextbox,
30823
31031
  contentBlock: translateContentBlock,
30824
- structuredContent: translator$3,
30825
- structuredContentBlock: translator$3,
30826
- documentSection: translator$3,
31032
+ structuredContent: translator$5,
31033
+ structuredContentBlock: translator$5,
31034
+ documentPartObject: translator$5,
31035
+ documentSection: translator$5,
30827
31036
  "page-number": translatePageNumberNode,
30828
- "total-page-number": translateTotalPageNumberNode
31037
+ "total-page-number": translateTotalPageNumberNode,
31038
+ pageReference: translator$1,
31039
+ tableOfContents: translator
30829
31040
  };
30830
31041
  let handler2 = router[type2];
30831
31042
  if (handler2 && "decode" in handler2 && typeof handler2.decode === "function") {
@@ -31163,8 +31374,6 @@ function translateTextNode(params) {
31163
31374
  const trackedMarks = [TrackInsertMarkName, TrackDeleteMarkName];
31164
31375
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
31165
31376
  if (isTrackedNode) return translateTrackedNode(params);
31166
- const isLinkNode = node.marks?.some((m2) => m2.type === "link");
31167
- if (isLinkNode) return translator$7.decode(params);
31168
31377
  const { text, marks = [] } = node;
31169
31378
  return getTextNodeForExport(text, marks, params);
31170
31379
  }
@@ -31470,7 +31679,7 @@ function translateMark(mark) {
31470
31679
  markElement.type = "element";
31471
31680
  break;
31472
31681
  case "underline": {
31473
- const translated = translator$10.decode({
31682
+ const translated = translator$13.decode({
31474
31683
  node: {
31475
31684
  attrs: {
31476
31685
  underlineType: attrs.underlineType ?? attrs.underline ?? null,
@@ -31534,7 +31743,7 @@ function translateMark(mark) {
31534
31743
  break;
31535
31744
  case "highlight": {
31536
31745
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
31537
- const translated = translator$15.decode({ node: { attrs: { highlight: highlightValue } } });
31746
+ const translated = translator$18.decode({ node: { attrs: { highlight: highlightValue } } });
31538
31747
  return translated || {};
31539
31748
  }
31540
31749
  }
@@ -31594,7 +31803,7 @@ function translateContentBlock(params) {
31594
31803
  if (vmlAttributes || horizontalRule) {
31595
31804
  return translateVRectContentBlock(params);
31596
31805
  }
31597
- const alternateContent = translator.decode(params);
31806
+ const alternateContent = translator$2.decode(params);
31598
31807
  return wrapTextInRun(alternateContent);
31599
31808
  }
31600
31809
  function translateVRectContentBlock(params) {
@@ -31740,6 +31949,7 @@ const getAutoPageJson = (type2, outputMarks = []) => {
31740
31949
  },
31741
31950
  {
31742
31951
  name: "w:instrText",
31952
+ attributes: { "xml:space": "preserve" },
31743
31953
  elements: [
31744
31954
  {
31745
31955
  type: "text",
@@ -31799,7 +32009,7 @@ const handleDrawingNode = (params) => {
31799
32009
  if (mainNode.name === "w:drawing") node = mainNode;
31800
32010
  else node = mainNode.elements.find((el) => el.name === "w:drawing");
31801
32011
  if (!node) return { nodes: [], consumed: 0 };
31802
- const schemaNode = translator$4.encode(params);
32012
+ const schemaNode = translator$6.encode(params);
31803
32013
  const newNodes = schemaNode ? [schemaNode] : [];
31804
32014
  return { nodes: newNodes, consumed: 1 };
31805
32015
  };
@@ -31901,8 +32111,8 @@ const trackChangeNodeHandlerEntity = {
31901
32111
  handlerName: "trackChangeNodeHandler",
31902
32112
  handler: handleTrackChangeNode
31903
32113
  };
31904
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$7);
31905
- const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$U);
32114
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$W);
32115
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$V);
31906
32116
  const handleTextNode = (params) => {
31907
32117
  const { nodes, insideTrackChange } = params;
31908
32118
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -31943,7 +32153,7 @@ const handleParagraphNode = (params) => {
31943
32153
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
31944
32154
  return { nodes: [], consumed: 0 };
31945
32155
  }
31946
- const schemaNode = translator$13.encode(params);
32156
+ const schemaNode = translator$16.encode(params);
31947
32157
  const newNodes = schemaNode ? [schemaNode] : [];
31948
32158
  return { nodes: newNodes, consumed: 1 };
31949
32159
  };
@@ -31956,7 +32166,7 @@ const handleSdtNode = (params) => {
31956
32166
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
31957
32167
  return { nodes: [], consumed: 0 };
31958
32168
  }
31959
- const result = translator$3.encode(params);
32169
+ const result = translator$5.encode(params);
31960
32170
  if (!result) {
31961
32171
  return { nodes: [], consumed: 0 };
31962
32172
  }
@@ -32046,7 +32256,7 @@ const handler = (params) => {
32046
32256
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
32047
32257
  return { nodes: [], consumed: 0 };
32048
32258
  }
32049
- const result = translator$16.encode(params);
32259
+ const result = translator$19.encode(params);
32050
32260
  if (!result) return { nodes: [], consumed: 0 };
32051
32261
  return {
32052
32262
  nodes: [result],
@@ -32118,7 +32328,7 @@ const handleBookmarkStartNode = (params) => {
32118
32328
  if (isCustomMarkBookmark(nodes[0], params.editor)) {
32119
32329
  return handleBookmarkNode(params);
32120
32330
  }
32121
- const node = translator$2.encode(params);
32331
+ const node = translator$4.encode(params);
32122
32332
  if (!node) return { nodes: [], consumed: 0 };
32123
32333
  return { nodes: [node], consumed: 1 };
32124
32334
  };
@@ -32150,7 +32360,7 @@ const handleBookmarkEndNode = (params) => {
32150
32360
  if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
32151
32361
  return { nodes: [], consumed: 0 };
32152
32362
  }
32153
- const node = translator$1.encode(params);
32363
+ const node = translator$3.encode(params);
32154
32364
  if (!node) return { nodes: [], consumed: 0 };
32155
32365
  return { nodes: [node], consumed: 1 };
32156
32366
  };
@@ -32283,6 +32493,7 @@ const autoTotalPageCountEntity = {
32283
32493
  handlerName: "autoTotalPageCountEntity",
32284
32494
  handler: handleAutoTotalPageNumber
32285
32495
  };
32496
+ const pageReferenceEntity = generateV2HandlerEntity("pageReferenceNodeHandler", translator$1);
32286
32497
  const handlePictNode = (params) => {
32287
32498
  const { nodes } = params;
32288
32499
  if (!nodes.length || nodes[0].name !== "w:p") {
@@ -32781,6 +32992,7 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32781
32992
  const spacing = pPr?.elements?.find((el) => el.name === "w:spacing");
32782
32993
  const justify = pPr?.elements?.find((el) => el.name === "w:jc");
32783
32994
  const indent = pPr?.elements?.find((el) => el.name === "w:ind");
32995
+ const tabs = pPr?.elements?.find((el) => el.name === "w:tabs");
32784
32996
  let lineSpaceBefore, lineSpaceAfter, line;
32785
32997
  if (spacing) {
32786
32998
  lineSpaceBefore = twipsToPixels(spacing?.attributes["w:before"]);
@@ -32794,6 +33006,22 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32794
33006
  rightIndent = twipsToPixels(indent?.attributes["w:right"]);
32795
33007
  firstLine = twipsToPixels(indent?.attributes["w:firstLine"]);
32796
33008
  }
33009
+ let tabStops = [];
33010
+ if (tabs) {
33011
+ tabStops = (tabs.elements || []).filter((el) => el.name === "w:tab").map((tab) => {
33012
+ let val = tab.attributes["w:val"];
33013
+ if (val == "left") {
33014
+ val = "start";
33015
+ } else if (val == "right") {
33016
+ val = "end";
33017
+ }
33018
+ return {
33019
+ val,
33020
+ pos: twipsToPixels(tab.attributes["w:pos"]),
33021
+ leader: tab.attributes["w:leader"]
33022
+ };
33023
+ });
33024
+ }
32797
33025
  const keepNext = pPr?.elements?.find((el) => el.name === "w:keepNext");
32798
33026
  const keepLines = pPr?.elements?.find((el) => el.name === "w:keepLines");
32799
33027
  const outlineLevel = pPr?.elements?.find((el) => el.name === "w:outlineLvl");
@@ -32826,7 +33054,8 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32826
33054
  const parsedStyles = {
32827
33055
  spacing: { lineSpaceAfter, lineSpaceBefore, line },
32828
33056
  textAlign,
32829
- indent: { leftIndent, rightIndent, firstLine }
33057
+ indent: { leftIndent, rightIndent, firstLine },
33058
+ tabStops: tabStops.length > 0 ? tabStops : null
32830
33059
  };
32831
33060
  parsedMarks.forEach((mark) => {
32832
33061
  const { type: type2, attrs } = mark;
@@ -32850,13 +33079,213 @@ const handleTabNode = (params) => {
32850
33079
  if (!nodes.length || nodes[0].name !== "w:tab") {
32851
33080
  return { nodes: [], consumed: 0 };
32852
33081
  }
32853
- const node = translator$14.encode(params);
33082
+ const node = translator$17.encode(params);
32854
33083
  return { nodes: [node], consumed: 1 };
32855
33084
  };
32856
33085
  const tabNodeEntityHandler = {
32857
33086
  handlerName: "w:tabTranslator",
32858
33087
  handler: handleTabNode
32859
33088
  };
33089
+ const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator);
33090
+ function preProcessPageInstruction(nodesToCombine, _2, __) {
33091
+ const pageNumNode = {
33092
+ name: "sd:autoPageNumber",
33093
+ type: "element"
33094
+ };
33095
+ nodesToCombine.forEach((n) => {
33096
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
33097
+ if (rPrNode) pageNumNode.elements = [rPrNode];
33098
+ });
33099
+ return [pageNumNode];
33100
+ }
33101
+ function preProcessNumPagesInstruction(nodesToCombine, _2, __) {
33102
+ const totalPageNumNode = {
33103
+ name: "sd:totalPageNumber",
33104
+ type: "element"
33105
+ };
33106
+ nodesToCombine.forEach((n) => {
33107
+ const rPrNode = n.elements?.find((el) => el.name === "w:rPr");
33108
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
33109
+ });
33110
+ return [totalPageNumNode];
33111
+ }
33112
+ function preProcessPageRefInstruction(nodesToCombine, instrText, _2) {
33113
+ const pageRefNode = {
33114
+ name: "sd:pageReference",
33115
+ type: "element",
33116
+ attributes: {
33117
+ instruction: instrText
33118
+ },
33119
+ elements: nodesToCombine
33120
+ };
33121
+ return [pageRefNode];
33122
+ }
33123
+ function preProcessHyperlinkInstruction(nodesToCombine, instruction, docx) {
33124
+ const urlMatch = instruction.match(/HYPERLINK\s+"([^"]+)"/);
33125
+ let linkAttributes;
33126
+ if (urlMatch && urlMatch.length >= 2) {
33127
+ const url = urlMatch[1];
33128
+ const rels = docx["word/_rels/document.xml.rels"];
33129
+ const relationships = rels?.elements.find((el) => el.name === "Relationships");
33130
+ if (relationships) {
33131
+ const rId = generateDocxRandomId();
33132
+ relationships.elements.push({
33133
+ type: "element",
33134
+ name: "Relationship",
33135
+ attributes: {
33136
+ Id: rId,
33137
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
33138
+ Target: url,
33139
+ TargetMode: "External"
33140
+ }
33141
+ });
33142
+ linkAttributes = { "r:id": rId };
33143
+ } else {
33144
+ linkAttributes = { "w:anchor": url };
33145
+ }
33146
+ } else {
33147
+ const availableSwitches = {
33148
+ "w:anchor": `l "(?<value>[^"]+)"`,
33149
+ new_window: `
33150
+ `,
33151
+ "w:tgtFrame": ` "(?<value>[^"]+)"`,
33152
+ "w:tooltip": `o "(?<value>[^"]+)"`
33153
+ };
33154
+ const parsedSwitches = {};
33155
+ for (const [key, regex] of Object.entries(availableSwitches)) {
33156
+ const match = instruction.match(new RegExp(regex));
33157
+ if (match) {
33158
+ parsedSwitches[key] = match.groups?.value || true;
33159
+ }
33160
+ }
33161
+ if (parsedSwitches.new_window) {
33162
+ parsedSwitches["w:tgtFrame"] = "_blank";
33163
+ delete parsedSwitches.new_window;
33164
+ }
33165
+ linkAttributes = { ...parsedSwitches };
33166
+ }
33167
+ return [
33168
+ {
33169
+ name: "w:hyperlink",
33170
+ type: "element",
33171
+ attributes: linkAttributes,
33172
+ elements: nodesToCombine
33173
+ }
33174
+ ];
33175
+ }
33176
+ function preProcessTocInstruction(nodesToCombine, instrText) {
33177
+ return [
33178
+ {
33179
+ name: "sd:tableOfContents",
33180
+ type: "element",
33181
+ attributes: {
33182
+ instruction: instrText
33183
+ },
33184
+ elements: nodesToCombine
33185
+ }
33186
+ ];
33187
+ }
33188
+ const getInstructionPreProcessor = (instruction) => {
33189
+ const instructionType = instruction.split(" ")[0];
33190
+ switch (instructionType) {
33191
+ case "PAGE":
33192
+ return preProcessPageInstruction;
33193
+ case "NUMPAGES":
33194
+ return preProcessNumPagesInstruction;
33195
+ case "PAGEREF":
33196
+ return preProcessPageRefInstruction;
33197
+ case "HYPERLINK":
33198
+ return preProcessHyperlinkInstruction;
33199
+ case "TOC":
33200
+ return preProcessTocInstruction;
33201
+ default:
33202
+ return null;
33203
+ }
33204
+ };
33205
+ const preProcessNodesForFldChar = (nodes = [], docx) => {
33206
+ const processedNodes = [];
33207
+ let collectedNodesStack = [];
33208
+ let currentFieldStack = [];
33209
+ let unpairedEnd = null;
33210
+ let collecting = false;
33211
+ const finalizeField = () => {
33212
+ if (collecting) {
33213
+ const collectedNodes = collectedNodesStack.pop().filter((n) => n !== null);
33214
+ const currentField = currentFieldStack.pop();
33215
+ const combined = _processCombinedNodesForFldChar(collectedNodes, currentField.instrText.trim(), docx);
33216
+ if (collectedNodesStack.length === 0) {
33217
+ processedNodes.push(...combined);
33218
+ } else {
33219
+ collectedNodesStack[collectedNodesStack.length - 1].push(...combined);
33220
+ }
33221
+ } else {
33222
+ unpairedEnd = true;
33223
+ }
33224
+ };
33225
+ for (const node of nodes) {
33226
+ const fldCharEl = node.elements?.find((el) => el.name === "w:fldChar");
33227
+ const fldType = fldCharEl?.attributes?.["w:fldCharType"];
33228
+ const instrTextEl = node.elements?.find((el) => el.name === "w:instrText");
33229
+ collecting = collectedNodesStack.length > 0;
33230
+ if (fldType === "begin") {
33231
+ collectedNodesStack.push([null]);
33232
+ currentFieldStack.push({ instrText: "" });
33233
+ continue;
33234
+ }
33235
+ if (instrTextEl && collecting && currentFieldStack.length > 0) {
33236
+ currentFieldStack[currentFieldStack.length - 1].instrText += (instrTextEl.elements?.[0]?.text || "") + " ";
33237
+ continue;
33238
+ }
33239
+ if (fldType === "end") {
33240
+ finalizeField();
33241
+ continue;
33242
+ } else if (fldType === "separate") {
33243
+ continue;
33244
+ }
33245
+ if (Array.isArray(node.elements)) {
33246
+ const childResult = preProcessNodesForFldChar(node.elements, docx);
33247
+ node.elements = childResult.processedNodes;
33248
+ if (childResult.unpairedBegin) {
33249
+ childResult.unpairedBegin.forEach((pendingField) => {
33250
+ currentFieldStack.push(pendingField.fieldInfo);
33251
+ collectedNodesStack.push([node]);
33252
+ });
33253
+ } else if (childResult.unpairedEnd) {
33254
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33255
+ finalizeField();
33256
+ } else if (collecting) {
33257
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33258
+ } else {
33259
+ processedNodes.push(node);
33260
+ }
33261
+ } else if (collecting) {
33262
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33263
+ } else {
33264
+ processedNodes.push(node);
33265
+ }
33266
+ }
33267
+ let unpairedBegin = null;
33268
+ if (collectedNodesStack.length > 0) {
33269
+ unpairedBegin = [];
33270
+ for (let i = 0; i < collectedNodesStack.length; i++) {
33271
+ processedNodes.push(...collectedNodesStack[i].filter((n) => n !== null));
33272
+ unpairedBegin.push({
33273
+ nodes: collectedNodesStack[i],
33274
+ fieldInfo: currentFieldStack[i]
33275
+ });
33276
+ }
33277
+ }
33278
+ return { processedNodes, unpairedBegin, unpairedEnd };
33279
+ };
33280
+ const _processCombinedNodesForFldChar = (nodesToCombine = [], instrText, docx) => {
33281
+ const instructionType = instrText.trim().split(" ")[0];
33282
+ const instructionPreProcessor = getInstructionPreProcessor(instructionType);
33283
+ if (instructionPreProcessor) {
33284
+ return instructionPreProcessor(nodesToCombine, instrText, docx);
33285
+ } else {
33286
+ return nodesToCombine;
33287
+ }
33288
+ };
32860
33289
  const createDocumentJson = (docx, converter, editor) => {
32861
33290
  const json = carbonCopy(getInitialJSON(docx));
32862
33291
  if (!json) return null;
@@ -32886,6 +33315,8 @@ const createDocumentJson = (docx, converter, editor) => {
32886
33315
  if (bodyNode) {
32887
33316
  ensureSectionProperties(bodyNode);
32888
33317
  const node = bodyNode;
33318
+ const { processedNodes } = preProcessNodesForFldChar(node.elements ?? [], docx);
33319
+ node.elements = processedNodes;
32889
33320
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
32890
33321
  const content = pruneIgnoredNodes(contentElements);
32891
33322
  const comments = importCommentData({ docx, converter, editor });
@@ -32941,8 +33372,10 @@ const defaultNodeListHandler = () => {
32941
33372
  trackChangeNodeHandlerEntity,
32942
33373
  tableNodeHandlerEntity,
32943
33374
  tabNodeEntityHandler,
33375
+ tableOfContentsHandlerEntity,
32944
33376
  autoPageHandlerEntity,
32945
33377
  autoTotalPageCountEntity,
33378
+ pageReferenceEntity,
32946
33379
  standardNodeHandlerEntity
32947
33380
  ];
32948
33381
  const handler2 = createNodeListHandler(entities);
@@ -34043,7 +34476,7 @@ export {
34043
34476
  objectIncludes as Z,
34044
34477
  AddMarkStep as _,
34045
34478
  Plugin as a,
34046
- translator$a as a$,
34479
+ translator$b as a$,
34047
34480
  twipsToLines as a0,
34048
34481
  pixelsToTwips as a1,
34049
34482
  helpers as a2,
@@ -34060,27 +34493,27 @@ export {
34060
34493
  handleClipboardPaste as aD,
34061
34494
  getFileObject as aE,
34062
34495
  runPropertyTranslators as aF,
34063
- translator$5 as aG,
34064
- translator$6 as aH,
34065
- translator$I as aI,
34066
- translator$J as aJ,
34067
- translator$10 as aK,
34068
- translator$H as aL,
34069
- translator$K as aM,
34070
- translator$G as aN,
34071
- translator$g as aO,
34072
- translator$8 as aP,
34073
- translator$t as aQ,
34074
- translator$u as aR,
34075
- translator$v as aS,
34076
- translator$w as aT,
34077
- translator$x as aU,
34078
- translator$c as aV,
34079
- translator$y as aW,
34080
- translator$z as aX,
34081
- translator$A as aY,
34082
- translator$B as aZ,
34083
- translator$L as a_,
34496
+ translator$7 as aG,
34497
+ translator$8 as aH,
34498
+ translator$J as aI,
34499
+ translator$K as aJ,
34500
+ translator$13 as aK,
34501
+ translator$I as aL,
34502
+ translator$L as aM,
34503
+ translator$H as aN,
34504
+ translator$h as aO,
34505
+ translator$9 as aP,
34506
+ translator$u as aQ,
34507
+ translator$v as aR,
34508
+ translator$w as aS,
34509
+ translator$x as aT,
34510
+ translator$y as aU,
34511
+ translator$d as aV,
34512
+ translator$z as aW,
34513
+ translator$A as aX,
34514
+ translator$B as aY,
34515
+ translator$C as aZ,
34516
+ translator$M as a_,
34084
34517
  hasSomeParentWithClass as aa,
34085
34518
  isActive as ab,
34086
34519
  unflattenListsInHtml as ac,
@@ -34108,50 +34541,52 @@ export {
34108
34541
  getContentTypesFromXml as ay,
34109
34542
  xmljs as az,
34110
34543
  Slice as b,
34111
- translator$C as b0,
34112
- translator$M as b1,
34113
- translator$d as b2,
34114
- translator$D as b3,
34115
- translator$e as b4,
34116
- translator$9 as b5,
34117
- translator$14 as b6,
34118
- translator$W as b7,
34119
- translator$X as b8,
34120
- translator$$ as b9,
34121
- translator$16 as bA,
34122
- translator$s as bB,
34123
- translator$2 as bC,
34124
- translator$1 as bD,
34125
- translator$F as bE,
34126
- translator$12 as bF,
34544
+ translator$D as b0,
34545
+ translator$N as b1,
34546
+ translator$e as b2,
34547
+ translator$E as b3,
34548
+ translator$f as b4,
34549
+ translator$a as b5,
34550
+ translator$17 as b6,
34551
+ translator$Z as b7,
34552
+ translator$_ as b8,
34553
+ translator$12 as b9,
34554
+ translator$19 as bA,
34555
+ translator$t as bB,
34556
+ translator$4 as bC,
34557
+ translator$3 as bD,
34558
+ translator$G as bE,
34559
+ translator$15 as bF,
34127
34560
  translator as bG,
34128
- _sfc_main as bH,
34129
- translator$i as ba,
34130
- translator$E as bb,
34131
- translator$3 as bc,
34132
- translator$k as bd,
34133
- translator$Y as be,
34134
- translator$V as bf,
34135
- translator$Z as bg,
34136
- translator$U as bh,
34137
- translator$13 as bi,
34138
- translator$m as bj,
34139
- translator$N as bk,
34140
- translator$n as bl,
34141
- translator$o as bm,
34142
- translator$11 as bn,
34143
- translator$7 as bo,
34144
- translator$15 as bp,
34145
- translator$O as bq,
34146
- translator$b as br,
34147
- translator$P as bs,
34148
- translator$Q as bt,
34149
- translator$q as bu,
34150
- translator$4 as bv,
34151
- translator$R as bw,
34152
- translator$_ as bx,
34153
- translator$S as by,
34154
- translator$T as bz,
34561
+ translator$1 as bH,
34562
+ translator$2 as bI,
34563
+ _sfc_main as bJ,
34564
+ translator$j as ba,
34565
+ translator$F as bb,
34566
+ translator$5 as bc,
34567
+ translator$l as bd,
34568
+ translator$$ as be,
34569
+ translator$X as bf,
34570
+ translator$10 as bg,
34571
+ translator$V as bh,
34572
+ translator$16 as bi,
34573
+ translator$n as bj,
34574
+ translator$O as bk,
34575
+ translator$o as bl,
34576
+ translator$p as bm,
34577
+ translator$14 as bn,
34578
+ translator$W as bo,
34579
+ translator$18 as bp,
34580
+ translator$P as bq,
34581
+ translator$c as br,
34582
+ translator$Q as bs,
34583
+ translator$R as bt,
34584
+ translator$r as bu,
34585
+ translator$6 as bv,
34586
+ translator$S as bw,
34587
+ translator$11 as bx,
34588
+ translator$T as by,
34589
+ translator$U as bz,
34155
34590
  DOMParser$1 as c,
34156
34591
  Mark as d,
34157
34592
  dropPoint as e,