@harbour-enterprises/superdoc 0.22.0-next.10 → 0.22.0-next.11

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 (61) hide show
  1. package/dist/chunks/{PdfViewer-CJdQmuIm.es.js → PdfViewer-CS3pY_UR.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-DE1NR4Ve.cjs → PdfViewer-Cz3fT1qt.cjs} +1 -1
  3. package/dist/chunks/{index-B9sHxXr_.es.js → index-Bbqhu9ev.es.js} +2 -2
  4. package/dist/chunks/{index-nfoifSpX.cjs → index-p73XAt11.cjs} +2 -2
  5. package/dist/chunks/{super-editor.es-DAP-fnHo.cjs → super-editor.es-CFD0lcOY.cjs} +1620 -1044
  6. package/dist/chunks/{super-editor.es-_iVPQ8J8.es.js → super-editor.es-DK3l03fz.es.js} +1620 -1044
  7. package/dist/core/types/index.d.ts.map +1 -1
  8. package/dist/style.css +3 -0
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-DK1NMJZB.js → converter-DFDRdFEB.js} +1482 -1041
  11. package/dist/super-editor/chunks/{docx-zipper-CmK8TyNb.js → docx-zipper-CplUdgI9.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-YR4uV-dp.js → editor-BnpIdTLI.js} +155 -19
  13. package/dist/super-editor/chunks/{toolbar-DzJyRvb0.js → toolbar-5h-ljJ_h.js} +2 -2
  14. package/dist/super-editor/converter.es.js +1 -1
  15. package/dist/super-editor/docx-zipper.es.js +2 -2
  16. package/dist/super-editor/editor.es.js +3 -3
  17. package/dist/super-editor/file-zipper.es.js +1 -1
  18. package/dist/super-editor/src/core/helpers/generateDocxRandomId.d.ts +5 -0
  19. package/dist/super-editor/src/core/super-converter/exporter.d.ts +4 -4
  20. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/hyperlink-preprocessor.d.ts +9 -0
  21. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/index.d.ts +2 -0
  22. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/num-pages-preprocessor.d.ts +9 -0
  23. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-preprocessor.d.ts +9 -0
  24. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-ref-preprocessor.d.ts +9 -0
  25. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/toc-preprocessor.d.ts +8 -0
  26. package/dist/super-editor/src/core/super-converter/field-references/index.d.ts +1 -0
  27. package/dist/super-editor/src/core/super-converter/field-references/preProcessNodesForFldChar.d.ts +21 -0
  28. package/dist/super-editor/src/core/super-converter/v2/exporter/helpers/translateChildNodes.d.ts +3 -3
  29. package/dist/super-editor/src/core/super-converter/v2/importer/pageReferenceImporter.d.ts +4 -0
  30. package/dist/super-editor/src/core/super-converter/v2/importer/tableOfContentsImporter.d.ts +4 -0
  31. package/dist/super-editor/src/core/super-converter/v2/types/index.d.ts +7 -1
  32. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/index.d.ts +1 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/pageReference-translator.d.ts +7 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/index.d.ts +1 -0
  35. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/tableOfContents-translator.d.ts +10 -0
  36. package/dist/super-editor/src/core/super-converter/v3/handlers/w/caps/caps-translator.d.ts +7 -0
  37. package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +0 -2
  38. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/handle-doc-part-obj.d.ts +9 -1
  39. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/translate-document-part-obj.d.ts +6 -0
  40. package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +2 -2
  41. package/dist/super-editor/src/extensions/page-reference/index.d.ts +1 -0
  42. package/dist/super-editor/src/extensions/page-reference/page-reference.d.ts +2 -0
  43. package/dist/super-editor/src/extensions/structured-content/document-part-object.d.ts +2 -0
  44. package/dist/super-editor/src/extensions/structured-content/index.d.ts +1 -0
  45. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentBlockTags.d.ts +2 -3
  46. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentInlineTags.d.ts +2 -3
  47. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTags.d.ts +2 -3
  48. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsById.d.ts +2 -3
  49. package/dist/super-editor/src/extensions/tab/helpers/tabDecorations.d.ts +2 -2
  50. package/dist/super-editor/src/extensions/table-of-contents/index.d.ts +1 -0
  51. package/dist/super-editor/src/extensions/table-of-contents/table-of-contents.d.ts +2 -0
  52. package/dist/super-editor/style.css +3 -0
  53. package/dist/super-editor/super-editor.es.js +10 -8
  54. package/dist/super-editor/toolbar.es.js +2 -2
  55. package/dist/super-editor.cjs +1 -1
  56. package/dist/super-editor.es.js +1 -1
  57. package/dist/superdoc.cjs +2 -2
  58. package/dist/superdoc.es.js +2 -2
  59. package/dist/superdoc.umd.js +1620 -1044
  60. package/dist/superdoc.umd.js.map +1 -1
  61. package/package.json +1 -1
@@ -15005,6 +15005,10 @@ function generateDocxRandomId(length2 = 8) {
15005
15005
  }
15006
15006
  return id.join("");
15007
15007
  }
15008
+ function generateRandomSigned32BitIntStrId() {
15009
+ const val = Math.floor(Math.random() * 2147483647);
15010
+ return val.toString();
15011
+ }
15008
15012
  function generateRandom32BitHex() {
15009
15013
  const val = Math.floor(Math.random() * 2147483647);
15010
15014
  return val.toString(16).toUpperCase().padStart(8, "0");
@@ -22583,6 +22587,7 @@ const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
22583
22587
  generateDocxListAttributes,
22584
22588
  generateDocxRandomId,
22585
22589
  generateRandom32BitHex,
22590
+ generateRandomSigned32BitIntStrId,
22586
22591
  getActiveFormatting,
22587
22592
  getExtensionConfigField,
22588
22593
  getMarkRange,
@@ -22980,13 +22985,56 @@ function translateChildNodes(params2) {
22980
22985
  const { content: nodes } = params2.node;
22981
22986
  if (!nodes) return [];
22982
22987
  const translatedNodes = [];
22983
- nodes.forEach((node) => {
22988
+ const hyperlinkGroup = [];
22989
+ let index2 = 0;
22990
+ while (index2 < nodes.length) {
22991
+ const node = nodes[index2];
22992
+ const linkMark = _isLinkNode(node);
22993
+ if (linkMark) {
22994
+ hyperlinkGroup.push(node);
22995
+ const nextNode = index2 + 1 < nodes.length ? nodes[index2 + 1] : null;
22996
+ const nextIsLink = _isLinkNode(nextNode, linkMark);
22997
+ if (nextIsLink) {
22998
+ index2++;
22999
+ continue;
23000
+ } else {
23001
+ let translatedLinkGroup = exportSchemaToJson({
23002
+ ...params2,
23003
+ node: hyperlinkGroup[0],
23004
+ extraParams: { ...params2.extraParams || {}, hyperlinkGroup: hyperlinkGroup.slice() }
23005
+ });
23006
+ if (translatedLinkGroup instanceof Array) translatedNodes.push(...translatedLinkGroup);
23007
+ else translatedNodes.push(translatedLinkGroup);
23008
+ hyperlinkGroup.length = 0;
23009
+ index2++;
23010
+ continue;
23011
+ }
23012
+ }
22984
23013
  let translatedNode = exportSchemaToJson({ ...params2, node });
22985
23014
  if (translatedNode instanceof Array) translatedNodes.push(...translatedNode);
22986
23015
  else translatedNodes.push(translatedNode);
22987
- });
23016
+ index2++;
23017
+ }
22988
23018
  return translatedNodes.filter((n) => n);
22989
23019
  }
23020
+ function _isLinkNode(node, referenceMark = null) {
23021
+ if (!node || !node.marks && !node.attrs?.marksAsAttrs) return null;
23022
+ const marks = node.marks || node.attrs.marksAsAttrs;
23023
+ const linkMark = marks.find((mark) => mark.type === "link");
23024
+ if (!linkMark) return null;
23025
+ if (referenceMark) {
23026
+ return _isSameLinkMark(linkMark.attrs, referenceMark.attrs) ? linkMark : null;
23027
+ }
23028
+ return linkMark;
23029
+ }
23030
+ function _isSameLinkMark(attrsA, attrsB) {
23031
+ for (let key2 of ["anchor", "docLocation", "history", "href", "rId", "target"]) {
23032
+ if (attrsA[key2] != attrsB[key2]) {
23033
+ return false;
23034
+ }
23035
+ }
23036
+ return true;
23037
+ }
22990
23038
  const baseNumbering = {
22991
23039
  declaration: {
22992
23040
  attributes: {
@@ -24333,37 +24381,37 @@ const _NodeTranslator = class _NodeTranslator2 {
24333
24381
  };
24334
24382
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
24335
24383
  let NodeTranslator = _NodeTranslator;
24336
- const encode$18 = (attributes) => {
24384
+ const encode$1b = (attributes) => {
24337
24385
  return attributes["w:type"];
24338
24386
  };
24339
- const decode$$ = (attrs) => {
24387
+ const decode$11 = (attrs) => {
24340
24388
  const { lineBreakType } = attrs;
24341
24389
  return lineBreakType;
24342
24390
  };
24343
24391
  const attrConfig$F = Object.freeze({
24344
24392
  xmlName: "w:type",
24345
24393
  sdName: "lineBreakType",
24346
- encode: encode$18,
24347
- decode: decode$$
24394
+ encode: encode$1b,
24395
+ decode: decode$11
24348
24396
  });
24349
- const encode$17 = (attributes) => {
24397
+ const encode$1a = (attributes) => {
24350
24398
  const xmlAttrValue = attributes["w:clear"];
24351
24399
  return xmlAttrValue;
24352
24400
  };
24353
- const decode$_ = (attrs) => {
24401
+ const decode$10 = (attrs) => {
24354
24402
  const { clear } = attrs;
24355
24403
  return clear;
24356
24404
  };
24357
24405
  const attrConfig$E = Object.freeze({
24358
24406
  xmlName: "w:clear",
24359
24407
  sdName: "clear",
24360
- encode: encode$17,
24361
- decode: decode$_
24408
+ encode: encode$1a,
24409
+ decode: decode$10
24362
24410
  });
24363
24411
  const validXmlAttributes$m = [attrConfig$F, attrConfig$E];
24364
- const XML_NODE_NAME$u = "w:br";
24365
- const SD_NODE_NAME$d = "lineBreak";
24366
- const encode$16 = (_2, encodedAttrs) => {
24412
+ const XML_NODE_NAME$x = "w:br";
24413
+ const SD_NODE_NAME$f = "lineBreak";
24414
+ const encode$19 = (_2, encodedAttrs) => {
24367
24415
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24368
24416
  const translated = {
24369
24417
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24373,7 +24421,7 @@ const encode$16 = (_2, encodedAttrs) => {
24373
24421
  }
24374
24422
  return translated;
24375
24423
  };
24376
- const decode$Z = (params2, decodedAttrs) => {
24424
+ const decode$$ = (params2, decodedAttrs) => {
24377
24425
  const { node } = params2;
24378
24426
  if (!node) return;
24379
24427
  const wBreak = { name: "w:br" };
@@ -24390,39 +24438,39 @@ const decode$Z = (params2, decodedAttrs) => {
24390
24438
  };
24391
24439
  return translated;
24392
24440
  };
24393
- const config$s = {
24394
- xmlName: XML_NODE_NAME$u,
24395
- sdNodeOrKeyName: SD_NODE_NAME$d,
24441
+ const config$v = {
24442
+ xmlName: XML_NODE_NAME$x,
24443
+ sdNodeOrKeyName: SD_NODE_NAME$f,
24396
24444
  type: NodeTranslator.translatorTypes.NODE,
24397
- encode: encode$16,
24398
- decode: decode$Z,
24445
+ encode: encode$19,
24446
+ decode: decode$$,
24399
24447
  attributes: validXmlAttributes$m
24400
24448
  };
24401
- const translator$16 = NodeTranslator.from(config$s);
24402
- const encode$15 = (attributes) => attributes?.["w:val"];
24403
- const decode$Y = (attrs) => attrs?.highlight;
24449
+ const translator$19 = NodeTranslator.from(config$v);
24450
+ const encode$18 = (attributes) => attributes?.["w:val"];
24451
+ const decode$_ = (attrs) => attrs?.highlight;
24404
24452
  const attrConfig$D = Object.freeze({
24405
24453
  xmlName: "w:val",
24406
24454
  sdName: "highlight",
24407
- encode: encode$15,
24408
- decode: decode$Y
24455
+ encode: encode$18,
24456
+ decode: decode$_
24409
24457
  });
24410
24458
  const validXmlAttributes$l = [attrConfig$D];
24411
- const XML_NODE_NAME$t = "w:highlight";
24412
- const SD_ATTR_KEY$f = "highlight";
24459
+ const XML_NODE_NAME$w = "w:highlight";
24460
+ const SD_ATTR_KEY$g = "highlight";
24413
24461
  const DISABLED_TOKENS = /* @__PURE__ */ new Set(["transparent", "none", "inherit"]);
24414
- const encode$14 = (params2, encodedAttrs = {}) => {
24462
+ const encode$17 = (params2, encodedAttrs = {}) => {
24415
24463
  const { nodes } = params2;
24416
24464
  const node = nodes?.[0];
24417
24465
  const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
24418
24466
  return {
24419
24467
  type: "attr",
24420
- xmlName: XML_NODE_NAME$t,
24421
- sdNodeOrKeyName: SD_ATTR_KEY$f,
24468
+ xmlName: XML_NODE_NAME$w,
24469
+ sdNodeOrKeyName: SD_ATTR_KEY$g,
24422
24470
  attributes: { "w:val": value ?? null }
24423
24471
  };
24424
24472
  };
24425
- const decode$X = (params2) => {
24473
+ const decode$Z = (params2) => {
24426
24474
  const attrs = params2?.node?.attrs || {};
24427
24475
  const highlightValue = attrs.highlight ?? attrs.color ?? null;
24428
24476
  if (!highlightValue) return void 0;
@@ -24430,14 +24478,14 @@ const decode$X = (params2) => {
24430
24478
  if (!normalizedValue) return void 0;
24431
24479
  if (DISABLED_TOKENS.has(normalizedValue)) {
24432
24480
  return {
24433
- name: XML_NODE_NAME$t,
24481
+ name: XML_NODE_NAME$w,
24434
24482
  attributes: { "w:val": "none" }
24435
24483
  };
24436
24484
  }
24437
24485
  const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24438
24486
  if (keyword) {
24439
24487
  return {
24440
- name: XML_NODE_NAME$t,
24488
+ name: XML_NODE_NAME$w,
24441
24489
  attributes: { "w:val": keyword }
24442
24490
  };
24443
24491
  }
@@ -24452,63 +24500,63 @@ const decode$X = (params2) => {
24452
24500
  }
24453
24501
  };
24454
24502
  };
24455
- const config$r = {
24456
- xmlName: XML_NODE_NAME$t,
24457
- sdNodeOrKeyName: SD_ATTR_KEY$f,
24503
+ const config$u = {
24504
+ xmlName: XML_NODE_NAME$w,
24505
+ sdNodeOrKeyName: SD_ATTR_KEY$g,
24458
24506
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
24459
- encode: encode$14,
24460
- decode: decode$X,
24507
+ encode: encode$17,
24508
+ decode: decode$Z,
24461
24509
  attributes: validXmlAttributes$l
24462
24510
  };
24463
- const translator$15 = NodeTranslator.from(config$r);
24464
- const encode$13 = (attributes) => {
24511
+ const translator$18 = NodeTranslator.from(config$u);
24512
+ const encode$16 = (attributes) => {
24465
24513
  return attributes["w:val"];
24466
24514
  };
24467
- const decode$W = (attrs) => {
24515
+ const decode$Y = (attrs) => {
24468
24516
  const { tabSize } = attrs || {};
24469
24517
  return tabSize;
24470
24518
  };
24471
24519
  const attrConfig$C = Object.freeze({
24472
24520
  xmlName: "w:val",
24473
24521
  sdName: "tabSize",
24474
- encode: encode$13,
24475
- decode: decode$W
24522
+ encode: encode$16,
24523
+ decode: decode$Y
24476
24524
  });
24477
- const encode$12 = (attributes) => {
24525
+ const encode$15 = (attributes) => {
24478
24526
  return attributes["w:leader"];
24479
24527
  };
24480
- const decode$V = (attrs) => {
24528
+ const decode$X = (attrs) => {
24481
24529
  const { leader } = attrs || {};
24482
24530
  return leader;
24483
24531
  };
24484
24532
  const attrConfig$B = Object.freeze({
24485
24533
  xmlName: "w:leader",
24486
24534
  sdName: "leader",
24487
- encode: encode$12,
24488
- decode: decode$V
24535
+ encode: encode$15,
24536
+ decode: decode$X
24489
24537
  });
24490
- const encode$11 = (attributes) => {
24538
+ const encode$14 = (attributes) => {
24491
24539
  return attributes["w:pos"];
24492
24540
  };
24493
- const decode$U = (attrs) => {
24541
+ const decode$W = (attrs) => {
24494
24542
  const { pos } = attrs || {};
24495
24543
  return pos;
24496
24544
  };
24497
24545
  const attrConfig$A = Object.freeze({
24498
24546
  xmlName: "w:pos",
24499
24547
  sdName: "pos",
24500
- encode: encode$11,
24501
- decode: decode$U
24548
+ encode: encode$14,
24549
+ decode: decode$W
24502
24550
  });
24503
24551
  const validXmlAttributes$k = [attrConfig$C, attrConfig$A, attrConfig$B];
24504
- const XML_NODE_NAME$s = "w:tab";
24505
- const SD_NODE_NAME$c = "tab";
24506
- const encode$10 = (_2, encodedAttrs = {}) => {
24552
+ const XML_NODE_NAME$v = "w:tab";
24553
+ const SD_NODE_NAME$e = "tab";
24554
+ const encode$13 = (_2, encodedAttrs = {}) => {
24507
24555
  const translated = { type: "tab" };
24508
24556
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24509
24557
  return translated;
24510
24558
  };
24511
- const decode$T = (params2, decodedAttrs = {}) => {
24559
+ const decode$V = (params2, decodedAttrs = {}) => {
24512
24560
  const { node } = params2 || {};
24513
24561
  if (!node) return;
24514
24562
  const wTab = { name: "w:tab" };
@@ -24524,15 +24572,15 @@ const decode$T = (params2, decodedAttrs = {}) => {
24524
24572
  }
24525
24573
  return translated;
24526
24574
  };
24527
- const config$q = {
24528
- xmlName: XML_NODE_NAME$s,
24529
- sdNodeOrKeyName: SD_NODE_NAME$c,
24575
+ const config$t = {
24576
+ xmlName: XML_NODE_NAME$v,
24577
+ sdNodeOrKeyName: SD_NODE_NAME$e,
24530
24578
  type: NodeTranslator.translatorTypes.NODE,
24531
- encode: encode$10,
24532
- decode: decode$T,
24579
+ encode: encode$13,
24580
+ decode: decode$V,
24533
24581
  attributes: validXmlAttributes$k
24534
24582
  };
24535
- const translator$14 = NodeTranslator.from(config$q);
24583
+ const translator$17 = NodeTranslator.from(config$t);
24536
24584
  const mergeTextNodes = (nodes) => {
24537
24585
  if (!nodes || !Array.isArray(nodes)) {
24538
24586
  return nodes;
@@ -24906,104 +24954,10 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
24906
24954
  justify: pPrByIdJcAttr
24907
24955
  };
24908
24956
  };
24909
- const preProcessNodesForFldChar = (nodes = []) => {
24910
- const processedNodes = [];
24911
- let buffer2 = [];
24912
- let collecting = false;
24913
- for (const node of nodes) {
24914
- const fldCharEl = node.elements?.find((el) => el.name === "w:fldChar");
24915
- const fldType = fldCharEl?.attributes?.["w:fldCharType"];
24916
- if (fldType === "begin") {
24917
- buffer2 = [node];
24918
- collecting = true;
24919
- continue;
24920
- }
24921
- if (fldType === "separate" && collecting) {
24922
- buffer2.push(node);
24923
- continue;
24924
- }
24925
- if (fldType === "end" && collecting) {
24926
- buffer2.push(node);
24927
- processedNodes.push(...processCombinedNodesForFldChar(buffer2));
24928
- buffer2 = [];
24929
- collecting = false;
24930
- continue;
24931
- }
24932
- if (collecting) {
24933
- buffer2.push(node);
24934
- } else {
24935
- processedNodes.push(node);
24936
- }
24937
- }
24938
- if (buffer2.length) {
24939
- processedNodes.push(...buffer2);
24940
- }
24941
- return processedNodes;
24942
- };
24943
- const processCombinedNodesForFldChar = (nodesToCombine = []) => {
24944
- let processedNodes = [];
24945
- let hasPageMarker = false;
24946
- let isNumPages = false;
24947
- const textStart = nodesToCombine.findIndex(
24948
- (n) => n.elements?.some((el) => el.name === "w:fldChar" && el.attributes["w:fldCharType"] === "separate")
24949
- );
24950
- const textEnd = nodesToCombine.findIndex(
24951
- (n) => n.elements?.some((el) => el.name === "w:fldChar" && el.attributes["w:fldCharType"] === "end")
24952
- );
24953
- const textNodes = nodesToCombine.slice(textStart + 1, textEnd);
24954
- const instrTextContainer = nodesToCombine.find((n) => n.elements?.some((el) => el.name === "w:instrText"));
24955
- const instrTextNode = instrTextContainer?.elements?.find((el) => el.name === "w:instrText");
24956
- const instrText = instrTextNode?.elements[0].text;
24957
- if (!hasPageMarker) hasPageMarker = instrText?.trim().startsWith("PAGE");
24958
- if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
24959
- const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
24960
- if (hasPageMarker) {
24961
- const pageNumNode = {
24962
- name: "sd:autoPageNumber",
24963
- type: "element"
24964
- };
24965
- nodesToCombine.forEach((n) => {
24966
- const rPrNode = n.elements.find((el) => el.name === "w:rPr");
24967
- if (rPrNode) pageNumNode.elements = [rPrNode];
24968
- });
24969
- processedNodes.push(pageNumNode);
24970
- } else if (isNumPages) {
24971
- const totalPageNumNode = {
24972
- name: "sd:totalPageNumber",
24973
- type: "element"
24974
- };
24975
- nodesToCombine.forEach((n) => {
24976
- const rPrNode = n.elements.find((el) => el.name === "w:rPr");
24977
- if (rPrNode) totalPageNumNode.elements = [rPrNode];
24978
- });
24979
- processedNodes.push(totalPageNumNode);
24980
- } else if (urlMatch && urlMatch?.length >= 2) {
24981
- const url = urlMatch[1];
24982
- const textMarks = [];
24983
- textNodes.forEach((n) => {
24984
- const rPr2 = n.elements.find((el) => el.name === "w:rPr");
24985
- if (!rPr2) return;
24986
- const { elements } = rPr2;
24987
- elements.forEach((el) => {
24988
- textMarks.push(el);
24989
- });
24990
- });
24991
- const linkMark = { name: "link", attributes: { href: url } };
24992
- const rPr = { name: "w:rPr", type: "element", elements: [linkMark, ...textMarks] };
24993
- processedNodes.push({
24994
- name: "w:r",
24995
- type: "element",
24996
- elements: [rPr, ...textNodes]
24997
- });
24998
- }
24999
- return processedNodes;
25000
- };
25001
24957
  const handleParagraphNode$1 = (params2) => {
25002
24958
  const { nodes, docx, nodeListHandler, filename } = params2;
25003
24959
  const node = carbonCopy(nodes[0]);
25004
24960
  let schemaNode;
25005
- let processedElements = preProcessNodesForFldChar(node.elements);
25006
- node.elements = processedElements;
25007
24961
  const handleStandardNode2 = nodeListHandler.handlerEntities.find(
25008
24962
  (e) => e.handlerName === "standardNodeHandler"
25009
24963
  )?.handler;
@@ -25144,89 +25098,89 @@ const handleParagraphNode$1 = (params2) => {
25144
25098
  }
25145
25099
  return schemaNode;
25146
25100
  };
25147
- const encode$$ = (attributes) => {
25101
+ const encode$12 = (attributes) => {
25148
25102
  return attributes["w:rsidDel"];
25149
25103
  };
25150
- const decode$S = (attrs) => {
25104
+ const decode$U = (attrs) => {
25151
25105
  return attrs.rsidDel;
25152
25106
  };
25153
25107
  const attrConfig$z = Object.freeze({
25154
25108
  xmlName: "w:rsidDel",
25155
25109
  sdName: "rsidDel",
25156
- encode: encode$$,
25157
- decode: decode$S
25110
+ encode: encode$12,
25111
+ decode: decode$U
25158
25112
  });
25159
- const encode$_ = (attributes) => {
25113
+ const encode$11 = (attributes) => {
25160
25114
  return attributes["w:rsidP"];
25161
25115
  };
25162
- const decode$R = (attrs) => {
25116
+ const decode$T = (attrs) => {
25163
25117
  return attrs.rsidP;
25164
25118
  };
25165
25119
  const attrConfig$y = Object.freeze({
25166
25120
  xmlName: "w:rsidP",
25167
25121
  sdName: "rsidP",
25168
- encode: encode$_,
25169
- decode: decode$R
25122
+ encode: encode$11,
25123
+ decode: decode$T
25170
25124
  });
25171
- const encode$Z = (attributes) => {
25125
+ const encode$10 = (attributes) => {
25172
25126
  return attributes["w:rsidR"];
25173
25127
  };
25174
- const decode$Q = (attrs) => {
25128
+ const decode$S = (attrs) => {
25175
25129
  return attrs.rsidR;
25176
25130
  };
25177
25131
  const attrConfig$x = Object.freeze({
25178
25132
  xmlName: "w:rsidR",
25179
25133
  sdName: "rsidR",
25180
- encode: encode$Z,
25181
- decode: decode$Q
25134
+ encode: encode$10,
25135
+ decode: decode$S
25182
25136
  });
25183
- const encode$Y = (attributes) => {
25137
+ const encode$$ = (attributes) => {
25184
25138
  return attributes["w:rsidRPr"];
25185
25139
  };
25186
- const decode$P = (attrs) => {
25140
+ const decode$R = (attrs) => {
25187
25141
  return attrs.rsidRPr;
25188
25142
  };
25189
25143
  const attrConfig$w = Object.freeze({
25190
25144
  xmlName: "w:rsidRPr",
25191
25145
  sdName: "rsidRPr",
25192
- encode: encode$Y,
25193
- decode: decode$P
25146
+ encode: encode$$,
25147
+ decode: decode$R
25194
25148
  });
25195
- const encode$X = (attributes) => {
25149
+ const encode$_ = (attributes) => {
25196
25150
  return attributes["w:rsidRDefault"];
25197
25151
  };
25198
- const decode$O = (attrs) => {
25152
+ const decode$Q = (attrs) => {
25199
25153
  return attrs.rsidRDefault;
25200
25154
  };
25201
25155
  const attrConfig$v = Object.freeze({
25202
25156
  xmlName: "w:rsidRDefault",
25203
25157
  sdName: "rsidRDefault",
25204
- encode: encode$X,
25205
- decode: decode$O
25158
+ encode: encode$_,
25159
+ decode: decode$Q
25206
25160
  });
25207
- const encode$W = (attributes) => {
25161
+ const encode$Z = (attributes) => {
25208
25162
  return attributes["w14:paraId"];
25209
25163
  };
25210
- const decode$N = (attrs) => {
25164
+ const decode$P = (attrs) => {
25211
25165
  return attrs.paraId;
25212
25166
  };
25213
25167
  const attrConfig$u = Object.freeze({
25214
25168
  xmlName: "w14:paraId",
25215
25169
  sdName: "paraId",
25216
- encode: encode$W,
25217
- decode: decode$N
25170
+ encode: encode$Z,
25171
+ decode: decode$P
25218
25172
  });
25219
- const encode$V = (attributes) => {
25173
+ const encode$Y = (attributes) => {
25220
25174
  return attributes["w14:textId"];
25221
25175
  };
25222
- const decode$M = (attrs) => {
25176
+ const decode$O = (attrs) => {
25223
25177
  return attrs.textId;
25224
25178
  };
25225
25179
  const attrConfig$t = Object.freeze({
25226
25180
  xmlName: "w14:textId",
25227
25181
  sdName: "textId",
25228
- encode: encode$V,
25229
- decode: decode$M
25182
+ encode: encode$Y,
25183
+ decode: decode$O
25230
25184
  });
25231
25185
  const validXmlAttributes$j = [
25232
25186
  attrConfig$u,
@@ -25237,9 +25191,9 @@ const validXmlAttributes$j = [
25237
25191
  attrConfig$w,
25238
25192
  attrConfig$z
25239
25193
  ];
25240
- const XML_NODE_NAME$r = "w:p";
25241
- const SD_NODE_NAME$b = "paragraph";
25242
- const encode$U = (params2, encodedAttrs = {}) => {
25194
+ const XML_NODE_NAME$u = "w:p";
25195
+ const SD_NODE_NAME$d = "paragraph";
25196
+ const encode$X = (params2, encodedAttrs = {}) => {
25243
25197
  const node = handleParagraphNode$1(params2);
25244
25198
  if (!node) return void 0;
25245
25199
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25247,7 +25201,7 @@ const encode$U = (params2, encodedAttrs = {}) => {
25247
25201
  }
25248
25202
  return node;
25249
25203
  };
25250
- const decode$L = (params2, decodedAttrs = {}) => {
25204
+ const decode$N = (params2, decodedAttrs = {}) => {
25251
25205
  const translated = translateParagraphNode(params2);
25252
25206
  if (!translated) return void 0;
25253
25207
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25255,16 +25209,16 @@ const decode$L = (params2, decodedAttrs = {}) => {
25255
25209
  }
25256
25210
  return translated;
25257
25211
  };
25258
- const config$p = {
25259
- xmlName: XML_NODE_NAME$r,
25260
- sdNodeOrKeyName: SD_NODE_NAME$b,
25212
+ const config$s = {
25213
+ xmlName: XML_NODE_NAME$u,
25214
+ sdNodeOrKeyName: SD_NODE_NAME$d,
25261
25215
  type: NodeTranslator.translatorTypes.NODE,
25262
- encode: encode$U,
25263
- decode: decode$L,
25216
+ encode: encode$X,
25217
+ decode: decode$N,
25264
25218
  attributes: validXmlAttributes$j
25265
25219
  };
25266
- const translator$13 = NodeTranslator.from(config$p);
25267
- const encode$T = (attributes) => {
25220
+ const translator$16 = NodeTranslator.from(config$s);
25221
+ const encode$W = (attributes) => {
25268
25222
  const raw = attributes?.["w:val"];
25269
25223
  if (raw === void 0 || raw === null) return void 0;
25270
25224
  if (typeof raw === "boolean") return raw;
@@ -25274,24 +25228,24 @@ const encode$T = (attributes) => {
25274
25228
  if (val === "1" || val === "true" || val === "on") return true;
25275
25229
  return void 0;
25276
25230
  };
25277
- const decode$K = (runProps) => {
25231
+ const decode$M = (runProps) => {
25278
25232
  if (runProps?.bold === false) return "0";
25279
25233
  return void 0;
25280
25234
  };
25281
25235
  const attrConfig$s = Object.freeze({
25282
25236
  xmlName: "w:val",
25283
25237
  sdName: "bold",
25284
- encode: encode$T,
25285
- decode: decode$K
25238
+ encode: encode$W,
25239
+ decode: decode$M
25286
25240
  });
25287
25241
  const validXmlAttributes$i = [attrConfig$s];
25288
- const XML_NODE_NAME$q = "w:b";
25289
- const SD_ATTR_KEY$e = "bold";
25290
- const encode$S = (params2, encodedAttrs = {}) => {
25242
+ const XML_NODE_NAME$t = "w:b";
25243
+ const SD_ATTR_KEY$f = "bold";
25244
+ const encode$V = (params2, encodedAttrs = {}) => {
25291
25245
  const { nodes } = params2;
25292
25246
  const node = nodes[0];
25293
25247
  if (!node) return void 0;
25294
- const val = encodedAttrs?.[SD_ATTR_KEY$e];
25248
+ const val = encodedAttrs?.[SD_ATTR_KEY$f];
25295
25249
  let attributes;
25296
25250
  if (val === false) attributes = { "w:val": "0" };
25297
25251
  else if (val === true)
@@ -25299,85 +25253,85 @@ const encode$S = (params2, encodedAttrs = {}) => {
25299
25253
  else attributes = node.attributes || {};
25300
25254
  return {
25301
25255
  type: "attr",
25302
- xmlName: XML_NODE_NAME$q,
25303
- sdNodeOrKeyName: SD_ATTR_KEY$e,
25256
+ xmlName: XML_NODE_NAME$t,
25257
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
25304
25258
  attributes
25305
25259
  };
25306
25260
  };
25307
- const config$o = {
25308
- xmlName: XML_NODE_NAME$q,
25309
- sdNodeOrKeyName: SD_ATTR_KEY$e,
25261
+ const config$r = {
25262
+ xmlName: XML_NODE_NAME$t,
25263
+ sdNodeOrKeyName: SD_ATTR_KEY$f,
25310
25264
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25311
- encode: encode$S,
25265
+ encode: encode$V,
25312
25266
  attributes: validXmlAttributes$i
25313
25267
  };
25314
- const translator$12 = NodeTranslator.from(config$o);
25315
- const XML_NODE_NAME$p = "w:i";
25316
- const SD_ATTR_KEY$d = "italic";
25317
- const encode$R = (params2) => {
25268
+ const translator$15 = NodeTranslator.from(config$r);
25269
+ const XML_NODE_NAME$s = "w:i";
25270
+ const SD_ATTR_KEY$e = "italic";
25271
+ const encode$U = (params2) => {
25318
25272
  const { nodes } = params2;
25319
25273
  const node = nodes?.[0];
25320
25274
  if (!node) return void 0;
25321
25275
  return {
25322
25276
  type: "attr",
25323
- xmlName: XML_NODE_NAME$p,
25324
- sdNodeOrKeyName: SD_ATTR_KEY$d,
25277
+ xmlName: XML_NODE_NAME$s,
25278
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
25325
25279
  attributes: {
25326
25280
  "w:val": node.attributes?.["w:val"] ?? null
25327
25281
  }
25328
25282
  };
25329
25283
  };
25330
- const config$n = {
25331
- xmlName: XML_NODE_NAME$p,
25332
- sdNodeOrKeyName: SD_ATTR_KEY$d,
25284
+ const config$q = {
25285
+ xmlName: XML_NODE_NAME$s,
25286
+ sdNodeOrKeyName: SD_ATTR_KEY$e,
25333
25287
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25334
- encode: encode$R
25288
+ encode: encode$U
25335
25289
  };
25336
- const translator$11 = NodeTranslator.from(config$n);
25337
- const encode$Q = (attributes) => attributes?.["w:val"];
25338
- const decode$J = (attrs) => attrs?.underline;
25290
+ const translator$14 = NodeTranslator.from(config$q);
25291
+ const encode$T = (attributes) => attributes?.["w:val"];
25292
+ const decode$L = (attrs) => attrs?.underline;
25339
25293
  const attrConfig$r = Object.freeze({
25340
25294
  xmlName: "w:val",
25341
25295
  sdName: "underline",
25342
- encode: encode$Q,
25343
- decode: decode$J
25296
+ encode: encode$T,
25297
+ decode: decode$L
25344
25298
  });
25345
- const encode$P = (attributes) => attributes?.["w:color"];
25346
- const decode$I = (attrs) => attrs?.color;
25299
+ const encode$S = (attributes) => attributes?.["w:color"];
25300
+ const decode$K = (attrs) => attrs?.color;
25347
25301
  const attrConfig$q = Object.freeze({
25348
25302
  xmlName: "w:color",
25349
25303
  sdName: "color",
25350
- encode: encode$P,
25351
- decode: decode$I
25304
+ encode: encode$S,
25305
+ decode: decode$K
25352
25306
  });
25353
- const encode$O = (attributes) => attributes?.["w:themeColor"];
25354
- const decode$H = (attrs) => attrs?.themeColor;
25307
+ const encode$R = (attributes) => attributes?.["w:themeColor"];
25308
+ const decode$J = (attrs) => attrs?.themeColor;
25355
25309
  const attrConfig$p = Object.freeze({
25356
25310
  xmlName: "w:themeColor",
25357
25311
  sdName: "themeColor",
25358
- encode: encode$O,
25359
- decode: decode$H
25312
+ encode: encode$R,
25313
+ decode: decode$J
25360
25314
  });
25361
- const encode$N = (attributes) => attributes?.["w:themeTint"];
25362
- const decode$G = (attrs) => attrs?.themeTint;
25315
+ const encode$Q = (attributes) => attributes?.["w:themeTint"];
25316
+ const decode$I = (attrs) => attrs?.themeTint;
25363
25317
  const attrConfig$o = Object.freeze({
25364
25318
  xmlName: "w:themeTint",
25365
25319
  sdName: "themeTint",
25366
- encode: encode$N,
25367
- decode: decode$G
25320
+ encode: encode$Q,
25321
+ decode: decode$I
25368
25322
  });
25369
- const encode$M = (attributes) => attributes?.["w:themeShade"];
25370
- const decode$F = (attrs) => attrs?.themeShade;
25323
+ const encode$P = (attributes) => attributes?.["w:themeShade"];
25324
+ const decode$H = (attrs) => attrs?.themeShade;
25371
25325
  const attrConfig$n = Object.freeze({
25372
25326
  xmlName: "w:themeShade",
25373
25327
  sdName: "themeShade",
25374
- encode: encode$M,
25375
- decode: decode$F
25328
+ encode: encode$P,
25329
+ decode: decode$H
25376
25330
  });
25377
25331
  const validXmlAttributes$h = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
25378
- const XML_NODE_NAME$o = "w:u";
25379
- const SD_ATTR_KEY$c = "underline";
25380
- const encode$L = (params2, encodedAttrs = {}) => {
25332
+ const XML_NODE_NAME$r = "w:u";
25333
+ const SD_ATTR_KEY$d = "underline";
25334
+ const encode$O = (params2, encodedAttrs = {}) => {
25381
25335
  const { nodes } = params2;
25382
25336
  const node = nodes?.[0];
25383
25337
  const sourceAttrs = node?.attributes || {};
@@ -25393,12 +25347,12 @@ const encode$L = (params2, encodedAttrs = {}) => {
25393
25347
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25394
25348
  return {
25395
25349
  type: "attr",
25396
- xmlName: XML_NODE_NAME$o,
25397
- sdNodeOrKeyName: SD_ATTR_KEY$c,
25350
+ xmlName: XML_NODE_NAME$r,
25351
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
25398
25352
  attributes
25399
25353
  };
25400
25354
  };
25401
- const decode$E = (params2) => {
25355
+ const decode$G = (params2) => {
25402
25356
  const attrs = params2?.node?.attrs || {};
25403
25357
  const underlineType = attrs.underlineType ?? attrs.underline ?? null;
25404
25358
  const color = attrs.underlineColor ?? attrs.color ?? null;
@@ -25416,20 +25370,20 @@ const decode$E = (params2) => {
25416
25370
  if (themeTint) attributes["w:themeTint"] = themeTint;
25417
25371
  if (themeShade) attributes["w:themeShade"] = themeShade;
25418
25372
  return {
25419
- name: XML_NODE_NAME$o,
25373
+ name: XML_NODE_NAME$r,
25420
25374
  attributes
25421
25375
  };
25422
25376
  };
25423
- const config$m = {
25424
- xmlName: XML_NODE_NAME$o,
25425
- sdNodeOrKeyName: SD_ATTR_KEY$c,
25377
+ const config$p = {
25378
+ xmlName: XML_NODE_NAME$r,
25379
+ sdNodeOrKeyName: SD_ATTR_KEY$d,
25426
25380
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25427
- encode: encode$L,
25428
- decode: decode$E,
25381
+ encode: encode$O,
25382
+ decode: decode$G,
25429
25383
  attributes: validXmlAttributes$h
25430
25384
  };
25431
- const translator$10 = NodeTranslator.from(config$m);
25432
- const encode$K = (attributes) => {
25385
+ const translator$13 = NodeTranslator.from(config$p);
25386
+ const encode$N = (attributes) => {
25433
25387
  const raw = attributes?.["w:val"];
25434
25388
  if (raw === void 0 || raw === null) return void 0;
25435
25389
  if (typeof raw === "boolean") return raw;
@@ -25439,24 +25393,24 @@ const encode$K = (attributes) => {
25439
25393
  if (val === "1" || val === "true" || val === "on") return true;
25440
25394
  return void 0;
25441
25395
  };
25442
- const decode$D = (attrs) => {
25396
+ const decode$F = (attrs) => {
25443
25397
  if (attrs?.strike === false) return "0";
25444
25398
  return void 0;
25445
25399
  };
25446
25400
  const attrConfig$m = Object.freeze({
25447
25401
  xmlName: "w:val",
25448
25402
  sdName: "strike",
25449
- encode: encode$K,
25450
- decode: decode$D
25403
+ encode: encode$N,
25404
+ decode: decode$F
25451
25405
  });
25452
25406
  const validXmlAttributes$g = [attrConfig$m];
25453
- const XML_NODE_NAME$n = "w:strike";
25454
- const SD_ATTR_KEY$b = "strike";
25455
- const encode$J = (params2, encodedAttrs = {}) => {
25407
+ const XML_NODE_NAME$q = "w:strike";
25408
+ const SD_ATTR_KEY$c = "strike";
25409
+ const encode$M = (params2, encodedAttrs = {}) => {
25456
25410
  const { nodes } = params2;
25457
25411
  const node = nodes?.[0];
25458
25412
  if (!node) return void 0;
25459
- const val = encodedAttrs?.[SD_ATTR_KEY$b];
25413
+ const val = encodedAttrs?.[SD_ATTR_KEY$c];
25460
25414
  let attributes;
25461
25415
  if (val === false) attributes = { "w:val": "0" };
25462
25416
  else if (val === true) attributes = {};
@@ -25465,55 +25419,55 @@ const encode$J = (params2, encodedAttrs = {}) => {
25465
25419
  else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
25466
25420
  return {
25467
25421
  type: "attr",
25468
- xmlName: XML_NODE_NAME$n,
25469
- sdNodeOrKeyName: SD_ATTR_KEY$b,
25422
+ xmlName: XML_NODE_NAME$q,
25423
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
25470
25424
  attributes
25471
25425
  };
25472
25426
  };
25473
- const config$l = {
25474
- xmlName: XML_NODE_NAME$n,
25475
- sdNodeOrKeyName: SD_ATTR_KEY$b,
25427
+ const config$o = {
25428
+ xmlName: XML_NODE_NAME$q,
25429
+ sdNodeOrKeyName: SD_ATTR_KEY$c,
25476
25430
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25477
- encode: encode$J,
25431
+ encode: encode$M,
25478
25432
  attributes: validXmlAttributes$g
25479
25433
  };
25480
- const translator$$ = NodeTranslator.from(config$l);
25481
- const encode$I = (attributes) => attributes?.["w:val"];
25482
- const decode$C = (attrs) => attrs?.color;
25434
+ const translator$12 = NodeTranslator.from(config$o);
25435
+ const encode$L = (attributes) => attributes?.["w:val"];
25436
+ const decode$E = (attrs) => attrs?.color;
25483
25437
  const attrConfig$l = Object.freeze({
25484
25438
  xmlName: "w:val",
25485
25439
  sdName: "color",
25486
- encode: encode$I,
25487
- decode: decode$C
25440
+ encode: encode$L,
25441
+ decode: decode$E
25488
25442
  });
25489
- const encode$H = (attributes) => attributes?.["w:themeColor"];
25490
- const decode$B = (attrs) => attrs?.themeColor;
25443
+ const encode$K = (attributes) => attributes?.["w:themeColor"];
25444
+ const decode$D = (attrs) => attrs?.themeColor;
25491
25445
  const attrConfig$k = Object.freeze({
25492
25446
  xmlName: "w:themeColor",
25493
25447
  sdName: "themeColor",
25494
- encode: encode$H,
25495
- decode: decode$B
25448
+ encode: encode$K,
25449
+ decode: decode$D
25496
25450
  });
25497
- const encode$G = (attributes) => attributes?.["w:themeTint"];
25498
- const decode$A = (attrs) => attrs?.themeTint;
25451
+ const encode$J = (attributes) => attributes?.["w:themeTint"];
25452
+ const decode$C = (attrs) => attrs?.themeTint;
25499
25453
  const attrConfig$j = Object.freeze({
25500
25454
  xmlName: "w:themeTint",
25501
25455
  sdName: "themeTint",
25502
- encode: encode$G,
25503
- decode: decode$A
25456
+ encode: encode$J,
25457
+ decode: decode$C
25504
25458
  });
25505
- const encode$F = (attributes) => attributes?.["w:themeShade"];
25506
- const decode$z = (attrs) => attrs?.themeShade;
25459
+ const encode$I = (attributes) => attributes?.["w:themeShade"];
25460
+ const decode$B = (attrs) => attrs?.themeShade;
25507
25461
  const attrConfig$i = Object.freeze({
25508
25462
  xmlName: "w:themeShade",
25509
25463
  sdName: "themeShade",
25510
- encode: encode$F,
25511
- decode: decode$z
25464
+ encode: encode$I,
25465
+ decode: decode$B
25512
25466
  });
25513
25467
  const validXmlAttributes$f = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
25514
- const XML_NODE_NAME$m = "w:color";
25515
- const SD_ATTR_KEY$a = "color";
25516
- const encode$E = (params2, encodedAttrs = {}) => {
25468
+ const XML_NODE_NAME$p = "w:color";
25469
+ const SD_ATTR_KEY$b = "color";
25470
+ const encode$H = (params2, encodedAttrs = {}) => {
25517
25471
  const { nodes } = params2;
25518
25472
  const node = nodes?.[0];
25519
25473
  const sourceAttrs = node?.attributes || {};
@@ -25528,63 +25482,63 @@ const encode$E = (params2, encodedAttrs = {}) => {
25528
25482
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25529
25483
  return {
25530
25484
  type: "attr",
25531
- xmlName: XML_NODE_NAME$m,
25532
- sdNodeOrKeyName: SD_ATTR_KEY$a,
25485
+ xmlName: XML_NODE_NAME$p,
25486
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
25533
25487
  attributes
25534
25488
  };
25535
25489
  };
25536
- const config$k = {
25537
- xmlName: XML_NODE_NAME$m,
25538
- sdNodeOrKeyName: SD_ATTR_KEY$a,
25490
+ const config$n = {
25491
+ xmlName: XML_NODE_NAME$p,
25492
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
25539
25493
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25540
- encode: encode$E,
25494
+ encode: encode$H,
25541
25495
  attributes: validXmlAttributes$f
25542
25496
  };
25543
- const translator$_ = NodeTranslator.from(config$k);
25544
- const encode$D = (attributes) => attributes?.["w:eastAsia"];
25545
- const decode$y = (attrs) => attrs?.eastAsia;
25497
+ const translator$11 = NodeTranslator.from(config$n);
25498
+ const encode$G = (attributes) => attributes?.["w:eastAsia"];
25499
+ const decode$A = (attrs) => attrs?.eastAsia;
25546
25500
  const attrConfig$h = Object.freeze({
25547
25501
  xmlName: "w:eastAsia",
25548
25502
  sdName: "eastAsia",
25549
- encode: encode$D,
25550
- decode: decode$y
25503
+ encode: encode$G,
25504
+ decode: decode$A
25551
25505
  });
25552
- const encode$C = (attributes) => attributes?.["w:ascii"];
25553
- const decode$x = (attrs) => attrs?.ascii;
25506
+ const encode$F = (attributes) => attributes?.["w:ascii"];
25507
+ const decode$z = (attrs) => attrs?.ascii;
25554
25508
  const attrConfig$g = Object.freeze({
25555
25509
  xmlName: "w:ascii",
25556
25510
  sdName: "ascii",
25557
- encode: encode$C,
25558
- decode: decode$x
25511
+ encode: encode$F,
25512
+ decode: decode$z
25559
25513
  });
25560
- const encode$B = (attributes) => attributes?.["w:hAnsi"];
25561
- const decode$w = (attrs) => attrs?.hAnsi;
25514
+ const encode$E = (attributes) => attributes?.["w:hAnsi"];
25515
+ const decode$y = (attrs) => attrs?.hAnsi;
25562
25516
  const attrConfig$f = Object.freeze({
25563
25517
  xmlName: "w:hAnsi",
25564
25518
  sdName: "hAnsi",
25565
- encode: encode$B,
25566
- decode: decode$w
25519
+ encode: encode$E,
25520
+ decode: decode$y
25567
25521
  });
25568
- const encode$A = (attributes) => attributes?.["w:cs"];
25569
- const decode$v = (attrs) => attrs?.cs;
25522
+ const encode$D = (attributes) => attributes?.["w:cs"];
25523
+ const decode$x = (attrs) => attrs?.cs;
25570
25524
  const attrConfig$e = Object.freeze({
25571
25525
  xmlName: "w:cs",
25572
25526
  sdName: "cs",
25573
- encode: encode$A,
25574
- decode: decode$v
25527
+ encode: encode$D,
25528
+ decode: decode$x
25575
25529
  });
25576
- const encode$z = (attributes) => attributes?.["w:val"];
25577
- const decode$u = (attrs) => attrs?.value;
25530
+ const encode$C = (attributes) => attributes?.["w:val"];
25531
+ const decode$w = (attrs) => attrs?.value;
25578
25532
  const attrConfig$d = Object.freeze({
25579
25533
  xmlName: "w:val",
25580
25534
  sdName: "value",
25581
- encode: encode$z,
25582
- decode: decode$u
25535
+ encode: encode$C,
25536
+ decode: decode$w
25583
25537
  });
25584
25538
  const validXmlAttributes$e = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
25585
- const XML_NODE_NAME$l = "w:rFonts";
25586
- const SD_ATTR_KEY$9 = "fontFamily";
25587
- const encode$y = (params2, encodedAttrs = {}) => {
25539
+ const XML_NODE_NAME$o = "w:rFonts";
25540
+ const SD_ATTR_KEY$a = "fontFamily";
25541
+ const encode$B = (params2, encodedAttrs = {}) => {
25588
25542
  const { nodes } = params2;
25589
25543
  const node = nodes?.[0];
25590
25544
  const sourceAttrs = node?.attributes || {};
@@ -25610,120 +25564,281 @@ const encode$y = (params2, encodedAttrs = {}) => {
25610
25564
  if (attributes["w:val"] === void 0) delete attributes["w:val"];
25611
25565
  return {
25612
25566
  type: "attr",
25613
- xmlName: XML_NODE_NAME$l,
25614
- sdNodeOrKeyName: SD_ATTR_KEY$9,
25567
+ xmlName: XML_NODE_NAME$o,
25568
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25615
25569
  attributes
25616
25570
  };
25617
25571
  };
25618
- const config$j = {
25619
- xmlName: XML_NODE_NAME$l,
25620
- sdNodeOrKeyName: SD_ATTR_KEY$9,
25572
+ const config$m = {
25573
+ xmlName: XML_NODE_NAME$o,
25574
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25621
25575
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25622
- encode: encode$y,
25576
+ encode: encode$B,
25623
25577
  attributes: validXmlAttributes$e
25624
25578
  };
25625
- const translator$Z = NodeTranslator.from(config$j);
25626
- const encode$x = (attributes) => attributes?.["w:val"];
25627
- const decode$t = (attrs) => attrs?.styleId;
25579
+ const translator$10 = NodeTranslator.from(config$m);
25580
+ const encode$A = (attributes) => attributes?.["w:val"];
25581
+ const decode$v = (attrs) => attrs?.styleId;
25628
25582
  const attrConfig$c = Object.freeze({
25629
25583
  xmlName: "w:val",
25630
25584
  sdName: "styleId",
25631
- encode: encode$x,
25632
- decode: decode$t
25585
+ encode: encode$A,
25586
+ decode: decode$v
25633
25587
  });
25634
25588
  const validXmlAttributes$d = [attrConfig$c];
25635
- const XML_NODE_NAME$k = "w:rStyle";
25636
- const SD_ATTR_KEY$8 = "styleId";
25637
- const encode$w = (params2, encodedAttrs = {}) => {
25589
+ const XML_NODE_NAME$n = "w:rStyle";
25590
+ const SD_ATTR_KEY$9 = "styleId";
25591
+ const encode$z = (params2, encodedAttrs = {}) => {
25638
25592
  const { nodes } = params2;
25639
25593
  const node = nodes?.[0];
25640
25594
  const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
25641
25595
  return {
25642
25596
  type: "attr",
25643
- xmlName: XML_NODE_NAME$k,
25644
- sdNodeOrKeyName: SD_ATTR_KEY$8,
25597
+ xmlName: XML_NODE_NAME$n,
25598
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
25645
25599
  attributes: { "w:val": value ?? null }
25646
25600
  };
25647
25601
  };
25648
- const config$i = {
25649
- xmlName: XML_NODE_NAME$k,
25650
- sdNodeOrKeyName: SD_ATTR_KEY$8,
25602
+ const config$l = {
25603
+ xmlName: XML_NODE_NAME$n,
25604
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
25651
25605
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25652
- encode: encode$w,
25606
+ encode: encode$z,
25653
25607
  attributes: validXmlAttributes$d
25654
25608
  };
25655
- const translator$Y = NodeTranslator.from(config$i);
25656
- const encode$v = (attributes) => attributes?.["w:val"];
25657
- const decode$s = (attrs) => attrs?.fontSize;
25609
+ const translator$$ = NodeTranslator.from(config$l);
25610
+ const encode$y = (attributes) => attributes?.["w:val"];
25611
+ const decode$u = (attrs) => attrs?.fontSize;
25658
25612
  const attrConfig$b = Object.freeze({
25659
25613
  xmlName: "w:val",
25660
25614
  sdName: "fontSize",
25661
- encode: encode$v,
25662
- decode: decode$s
25615
+ encode: encode$y,
25616
+ decode: decode$u
25663
25617
  });
25664
25618
  const validXmlAttributes$c = [attrConfig$b];
25665
- const XML_NODE_NAME$j = "w:sz";
25666
- const SD_ATTR_KEY$7 = "fontSize";
25667
- const encode$u = (params2, encodedAttrs = {}) => {
25619
+ const XML_NODE_NAME$m = "w:sz";
25620
+ const SD_ATTR_KEY$8 = "fontSize";
25621
+ const encode$x = (params2, encodedAttrs = {}) => {
25668
25622
  const { nodes } = params2;
25669
25623
  const node = nodes?.[0];
25670
25624
  const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
25671
25625
  return {
25672
25626
  type: "attr",
25673
- xmlName: XML_NODE_NAME$j,
25674
- sdNodeOrKeyName: SD_ATTR_KEY$7,
25627
+ xmlName: XML_NODE_NAME$m,
25628
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
25675
25629
  attributes: { "w:val": value ?? null }
25676
25630
  };
25677
25631
  };
25678
- const config$h = {
25679
- xmlName: XML_NODE_NAME$j,
25680
- sdNodeOrKeyName: SD_ATTR_KEY$7,
25632
+ const config$k = {
25633
+ xmlName: XML_NODE_NAME$m,
25634
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
25681
25635
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25682
- encode: encode$u,
25636
+ encode: encode$x,
25683
25637
  attributes: validXmlAttributes$c
25684
25638
  };
25685
- const translator$X = NodeTranslator.from(config$h);
25686
- const encode$t = (attributes) => attributes?.["w:val"];
25687
- const decode$r = (attrs) => attrs?.fontSizeCs;
25639
+ const translator$_ = NodeTranslator.from(config$k);
25640
+ const encode$w = (attributes) => attributes?.["w:val"];
25641
+ const decode$t = (attrs) => attrs?.fontSizeCs;
25688
25642
  const attrConfig$a = Object.freeze({
25689
25643
  xmlName: "w:val",
25690
25644
  sdName: "fontSizeCs",
25691
- encode: encode$t,
25692
- decode: decode$r
25645
+ encode: encode$w,
25646
+ decode: decode$t
25693
25647
  });
25694
25648
  const validXmlAttributes$b = [attrConfig$a];
25695
- const XML_NODE_NAME$i = "w:szCs";
25696
- const SD_ATTR_KEY$6 = "fontSizeCs";
25697
- const encode$s = (params2, encodedAttrs = {}) => {
25649
+ const XML_NODE_NAME$l = "w:szCs";
25650
+ const SD_ATTR_KEY$7 = "fontSizeCs";
25651
+ const encode$v = (params2, encodedAttrs = {}) => {
25698
25652
  const { nodes } = params2;
25699
25653
  const node = nodes?.[0];
25700
25654
  const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
25701
25655
  return {
25702
25656
  type: "attr",
25703
- xmlName: XML_NODE_NAME$i,
25704
- sdNodeOrKeyName: SD_ATTR_KEY$6,
25657
+ xmlName: XML_NODE_NAME$l,
25658
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
25705
25659
  attributes: { "w:val": value ?? null }
25706
25660
  };
25707
25661
  };
25708
- const config$g = {
25709
- xmlName: XML_NODE_NAME$i,
25710
- sdNodeOrKeyName: SD_ATTR_KEY$6,
25662
+ const config$j = {
25663
+ xmlName: XML_NODE_NAME$l,
25664
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
25711
25665
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25712
- encode: encode$s,
25666
+ encode: encode$v,
25713
25667
  attributes: validXmlAttributes$b
25714
25668
  };
25715
- const translator$W = NodeTranslator.from(config$g);
25669
+ const translator$Z = NodeTranslator.from(config$j);
25670
+ const generateV2HandlerEntity = (handlerName, translator2) => ({
25671
+ handlerName,
25672
+ handler: (params2) => {
25673
+ const { nodes } = params2;
25674
+ if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
25675
+ return { nodes: [], consumed: 0 };
25676
+ }
25677
+ const result = translator2.encode(params2);
25678
+ if (!result) return { nodes: [], consumed: 0 };
25679
+ return {
25680
+ nodes: Array.isArray(result) ? result : [result],
25681
+ consumed: 1
25682
+ };
25683
+ }
25684
+ });
25685
+ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:val", transformEncode = null, transformDecode = null) {
25686
+ if (!sdName) sdName = xmlName.split(":")[1];
25687
+ if (!transformEncode) transformEncode = (v2) => v2;
25688
+ if (!transformDecode) transformDecode = (v2) => v2;
25689
+ return {
25690
+ xmlName,
25691
+ sdNodeOrKeyName: sdName,
25692
+ encode: ({ nodes }) => {
25693
+ return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
25694
+ },
25695
+ decode: ({ node }) => {
25696
+ const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
25697
+ return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
25698
+ }
25699
+ };
25700
+ }
25701
+ function createMeasurementPropertyHandler(xmlName, sdName = null) {
25702
+ if (!sdName) sdName = xmlName.split(":")[1];
25703
+ return {
25704
+ xmlName,
25705
+ sdNodeOrKeyName: sdName,
25706
+ attributes: [
25707
+ createAttributeHandler("w:w", "value", parseInteger, integerToString),
25708
+ createAttributeHandler("w:type")
25709
+ ],
25710
+ encode: (_2, encodedAttrs) => {
25711
+ return encodedAttrs["value"] != null ? encodedAttrs : void 0;
25712
+ },
25713
+ decode: function({ node }) {
25714
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25715
+ return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
25716
+ }
25717
+ };
25718
+ }
25719
+ function createBorderPropertyHandler(xmlName, sdName = null) {
25720
+ if (!sdName) sdName = xmlName.split(":")[1];
25721
+ return {
25722
+ xmlName,
25723
+ sdNodeOrKeyName: sdName,
25724
+ attributes: [
25725
+ createAttributeHandler("w:val"),
25726
+ createAttributeHandler("w:color"),
25727
+ createAttributeHandler("w:themeColor"),
25728
+ createAttributeHandler("w:themeTint"),
25729
+ createAttributeHandler("w:themeShade"),
25730
+ createAttributeHandler("w:sz", "size", parseInteger, integerToString),
25731
+ createAttributeHandler("w:space", null, parseInteger, integerToString),
25732
+ createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
25733
+ createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
25734
+ ],
25735
+ encode: (params2, encodedAttrs) => {
25736
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25737
+ },
25738
+ decode: function({ node }, context) {
25739
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25740
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25741
+ }
25742
+ };
25743
+ }
25744
+ const createAttributeHandler = (xmlName, sdName = null, transformEncode = null, transformDecode = null) => {
25745
+ if (!transformEncode) transformEncode = (v2) => v2;
25746
+ if (!transformDecode) transformDecode = (v2) => v2;
25747
+ if (!sdName) sdName = xmlName.split(":")[1];
25748
+ return {
25749
+ xmlName,
25750
+ sdName,
25751
+ encode: (attributes) => transformEncode(attributes[xmlName]),
25752
+ decode: (attributes) => transformDecode(attributes[sdName])
25753
+ };
25754
+ };
25755
+ function encodeProperties(node, translatorsByXmlName, asArray = false) {
25756
+ if (!node?.elements || node.elements.length === 0) {
25757
+ return asArray ? [] : {};
25758
+ }
25759
+ const attributes = asArray ? [] : {};
25760
+ node.elements.forEach((el) => {
25761
+ const translator2 = translatorsByXmlName[el.name];
25762
+ if (translator2) {
25763
+ const encodedAttr = translator2.encode({ nodes: [el] });
25764
+ if (encodedAttr != null) {
25765
+ if (asArray) {
25766
+ attributes.push({ [translator2.sdNodeOrKeyName]: encodedAttr });
25767
+ } else {
25768
+ attributes[translator2.sdNodeOrKeyName] = encodedAttr;
25769
+ }
25770
+ }
25771
+ }
25772
+ });
25773
+ return attributes;
25774
+ }
25775
+ function decodeProperties(translatorsBySdName, properties) {
25776
+ if (!properties || typeof properties !== "object") {
25777
+ return [];
25778
+ }
25779
+ const elements = [];
25780
+ Object.keys(properties).forEach((key2) => {
25781
+ const translator2 = translatorsBySdName[key2];
25782
+ if (translator2) {
25783
+ const result = translator2.decode({ node: { attrs: { [key2]: properties[key2] } } });
25784
+ if (result != null) {
25785
+ result.name = translator2.xmlName;
25786
+ elements.push(result);
25787
+ }
25788
+ }
25789
+ });
25790
+ return elements;
25791
+ }
25792
+ const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
25793
+ const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
25794
+ const parseInteger = (value) => {
25795
+ if (value == null) return void 0;
25796
+ const intValue = parseInt(value, 10);
25797
+ return isNaN(intValue) ? void 0 : intValue;
25798
+ };
25799
+ const integerToString = (value) => {
25800
+ const intValue = parseInteger(value);
25801
+ return intValue != void 0 ? String(intValue) : void 0;
25802
+ };
25803
+ const XML_NODE_NAME$k = "w:caps";
25804
+ const SD_ATTR_KEY$6 = "textTransform";
25805
+ const encode$u = (params2, encodedAttrs = {}) => {
25806
+ const { nodes } = params2;
25807
+ const node = nodes[0];
25808
+ if (!node) return void 0;
25809
+ let result;
25810
+ if (!["false", "0"].includes(encodedAttrs.val)) {
25811
+ result = "uppercase";
25812
+ } else {
25813
+ return void 0;
25814
+ }
25815
+ return {
25816
+ type: "attr",
25817
+ xmlName: XML_NODE_NAME$k,
25818
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
25819
+ attributes: { [SD_ATTR_KEY$6]: result }
25820
+ };
25821
+ };
25822
+ const config$i = {
25823
+ xmlName: XML_NODE_NAME$k,
25824
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
25825
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
25826
+ encode: encode$u,
25827
+ attributes: [createAttributeHandler("w:val")]
25828
+ };
25829
+ const translator$Y = NodeTranslator.from(config$i);
25716
25830
  const runPropertyTranslators = Object.freeze({
25717
- "w:b": translator$12,
25718
- "w:i": translator$11,
25719
- "w:u": translator$10,
25720
- "w:strike": translator$$,
25721
- "w:color": translator$_,
25722
- "w:highlight": translator$15,
25723
- "w:rFonts": translator$Z,
25724
- "w:rStyle": translator$Y,
25725
- "w:sz": translator$X,
25726
- "w:szCs": translator$W
25831
+ "w:b": translator$15,
25832
+ "w:i": translator$14,
25833
+ "w:u": translator$13,
25834
+ "w:strike": translator$12,
25835
+ "w:color": translator$11,
25836
+ "w:highlight": translator$18,
25837
+ "w:rFonts": translator$10,
25838
+ "w:rStyle": translator$$,
25839
+ "w:sz": translator$_,
25840
+ "w:szCs": translator$Z,
25841
+ "w:caps": translator$Y
25727
25842
  });
25728
25843
  const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
25729
25844
  const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
@@ -25737,9 +25852,9 @@ const toRunPropertyEntry = (candidate) => {
25737
25852
  attributes: { ...candidate.attributes || {} }
25738
25853
  };
25739
25854
  };
25740
- const XML_NODE_NAME$h = "w:rPr";
25855
+ const XML_NODE_NAME$j = "w:rPr";
25741
25856
  const SD_ATTR_KEY$5 = "runProperties";
25742
- const encode$r = (params2) => {
25857
+ const encode$t = (params2) => {
25743
25858
  const { nodes } = params2;
25744
25859
  const node = nodes?.[0] || {};
25745
25860
  const contents = Array.isArray(node.elements) ? node.elements : [];
@@ -25773,16 +25888,16 @@ const encode$r = (params2) => {
25773
25888
  attributes: runPropsArray
25774
25889
  };
25775
25890
  };
25776
- const config$f = {
25777
- xmlName: XML_NODE_NAME$h,
25891
+ const config$h = {
25892
+ xmlName: XML_NODE_NAME$j,
25778
25893
  sdNodeOrKeyName: SD_ATTR_KEY$5,
25779
25894
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25780
- encode: encode$r
25895
+ encode: encode$t
25781
25896
  };
25782
- const translator$V = NodeTranslator.from(config$f);
25897
+ const translator$X = NodeTranslator.from(config$h);
25783
25898
  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;
25784
25899
  const containsEastAsianCharacters = (text) => EAST_ASIAN_CHARACTER_REGEX.test(text);
25785
- const collectRunProperties = (params2, rPrNode, translator2 = translator$V) => {
25900
+ const collectRunProperties = (params2, rPrNode, translator2 = translator$X) => {
25786
25901
  if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
25787
25902
  const result = translator2.encode({ ...params2, nodes: [rPrNode] }) || {};
25788
25903
  let entries = [];
@@ -25851,7 +25966,10 @@ const applyRunMarks = (node, inlineMarks, textStyleAttrs) => {
25851
25966
  };
25852
25967
  const deriveStyleMarks = ({ docx, paragraphStyleId, runStyleId }) => {
25853
25968
  const paragraphStyleMarks = collectStyleMarks(paragraphStyleId, docx);
25854
- const runStyleMarks = collectStyleMarks(runStyleId, docx);
25969
+ if (paragraphStyleId?.startsWith("TOC")) {
25970
+ return paragraphStyleMarks;
25971
+ }
25972
+ let runStyleMarks = collectStyleMarks(runStyleId, docx);
25855
25973
  const inlineMarks = mergeInlineMarkSets(paragraphStyleMarks.inlineMarks, runStyleMarks.inlineMarks);
25856
25974
  const textStyleAttrs = mergeTextStyleAttrs(paragraphStyleMarks.textStyleAttrs, runStyleMarks.textStyleAttrs);
25857
25975
  return { inlineMarks, textStyleAttrs };
@@ -26077,6 +26195,13 @@ const splitRunProperties = (entries = [], docx = null) => {
26077
26195
  }
26078
26196
  break;
26079
26197
  }
26198
+ case "w:caps": {
26199
+ if (attributes["textTransform"] != null) {
26200
+ hasTextStyle = true;
26201
+ textStyleAttrs.textTransform = attributes["textTransform"];
26202
+ }
26203
+ break;
26204
+ }
26080
26205
  case "w:rFonts": {
26081
26206
  const asciiFamily = attributes["w:ascii"] || attributes["w:hAnsi"] || (attributes["w:eastAsia"] ? void 0 : attributes["w:val"]);
26082
26207
  const eastAsiaFamily = attributes["w:eastAsia"];
@@ -26096,9 +26221,10 @@ const splitRunProperties = (entries = [], docx = null) => {
26096
26221
  case "w:sz":
26097
26222
  case "w:szCs": {
26098
26223
  const rawSize = Number(attributes["w:val"]);
26224
+ const attrName = entry.xmlName === "w:sz" ? "fontSize" : "fontSizeCs";
26099
26225
  if (Number.isFinite(rawSize) && rawSize > 0) {
26100
26226
  hasTextStyle = true;
26101
- textStyleAttrs.fontSize = `${rawSize / 2}pt`;
26227
+ textStyleAttrs[attrName] = `${rawSize / 2}pt`;
26102
26228
  }
26103
26229
  break;
26104
26230
  }
@@ -26244,46 +26370,166 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
26244
26370
  }
26245
26371
  return runs;
26246
26372
  };
26247
- const encode$q = (attributes) => {
26373
+ const XML_NODE_NAME$i = "w:hyperlink";
26374
+ const SD_NODE_NAME$c = "link";
26375
+ const _createAttributeHandler = (xmlName, sdName) => ({
26376
+ xmlName,
26377
+ sdName,
26378
+ encode: (attributes) => attributes[xmlName],
26379
+ decode: (attributes) => attributes[sdName]
26380
+ });
26381
+ const validXmlAttributes$a = [
26382
+ _createAttributeHandler("w:anchor", "anchor"),
26383
+ _createAttributeHandler("w:docLocation", "docLocation"),
26384
+ {
26385
+ xmlName: "w:history",
26386
+ sdName: "history",
26387
+ encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
26388
+ decode: (attributes) => attributes["history"] ? "1" : "0"
26389
+ },
26390
+ _createAttributeHandler("w:tooltip", "tooltip"),
26391
+ _createAttributeHandler("r:id", "rId"),
26392
+ _createAttributeHandler("w:tgtFrame", "target")
26393
+ ];
26394
+ const encode$s = (params2, encodedAttrs) => {
26395
+ const { nodes, docx, nodeListHandler } = params2;
26396
+ const node = nodes[0];
26397
+ let href = _resolveHref(docx, encodedAttrs);
26398
+ const linkMark = { type: "link", attrs: { ...encodedAttrs, href } };
26399
+ const referenceNodeTypes = ["sd:pageReference", "sd:autoPageNumber", "sd:totalPageNumber"];
26400
+ const contentNodes = node.elements.filter((el) => el.name === "w:r" || referenceNodeTypes.includes(el.name));
26401
+ contentNodes.forEach((contentNode) => {
26402
+ const existingMarks = Array.isArray(contentNode.marks) ? contentNode.marks : [];
26403
+ const marksWithoutLink = existingMarks.filter((mark) => mark?.type !== "link");
26404
+ contentNode.marks = [...marksWithoutLink, linkMark];
26405
+ });
26406
+ const updatedNode = nodeListHandler.handler({
26407
+ ...params2,
26408
+ nodes: contentNodes,
26409
+ path: [...params2.path || [], node]
26410
+ });
26411
+ return updatedNode;
26412
+ };
26413
+ const _resolveHref = (docx, encodedAttrs) => {
26414
+ const rels = docx["word/_rels/document.xml.rels"];
26415
+ const relationships = rels.elements.find((el) => el.name === "Relationships");
26416
+ const { elements } = relationships;
26417
+ const { rId, anchor } = encodedAttrs;
26418
+ let href;
26419
+ if (!rId && anchor) {
26420
+ href = `#${anchor}`;
26421
+ } else if (rId) {
26422
+ const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
26423
+ const { attributes: relAttributes = {} } = rel;
26424
+ href = relAttributes["Target"];
26425
+ }
26426
+ return href;
26427
+ };
26428
+ function decode$s(params2) {
26429
+ const { hyperlinkGroup = [params2.node] } = params2.extraParams || {};
26430
+ const node = hyperlinkGroup[0];
26431
+ const linkMark = node.marks.find((m2) => m2.type === "link");
26432
+ const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
26433
+ let { anchor, href: link } = linkMark.attrs;
26434
+ const isExternalLink = !anchor;
26435
+ if (isExternalLink) {
26436
+ linkAttrs["r:id"] = _addNewLinkRelationship(params2, link, linkAttrs["r:id"]);
26437
+ }
26438
+ let contentNodes = [];
26439
+ hyperlinkGroup.forEach((linkNode) => {
26440
+ if ("marks" in linkNode) {
26441
+ linkNode.marks = linkNode.marks.filter((m2) => m2.type !== "link");
26442
+ } else {
26443
+ linkNode.attrs.marksAsAttrs = linkNode.attrs.marksAsAttrs.filter((m2) => m2.type !== "link");
26444
+ }
26445
+ const outputNode = exportSchemaToJson({ ...params2, node: linkNode });
26446
+ if (outputNode) {
26447
+ if (outputNode instanceof Array) contentNodes.push(...outputNode);
26448
+ else contentNodes.push(outputNode);
26449
+ }
26450
+ });
26451
+ const newNode = {
26452
+ name: "w:hyperlink",
26453
+ type: "element",
26454
+ attributes: {
26455
+ ...linkAttrs
26456
+ },
26457
+ elements: contentNodes
26458
+ };
26459
+ return newNode;
26460
+ }
26461
+ function _addNewLinkRelationship(params2, link, rId) {
26462
+ if (!rId) rId = generateDocxRandomId();
26463
+ if (!params2.relationships || !Array.isArray(params2.relationships)) {
26464
+ params2.relationships = [];
26465
+ }
26466
+ const existingRel = params2.relationships.find(
26467
+ (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
26468
+ );
26469
+ if (existingRel) {
26470
+ return rId;
26471
+ }
26472
+ params2.relationships.push({
26473
+ type: "element",
26474
+ name: "Relationship",
26475
+ attributes: {
26476
+ Id: rId,
26477
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
26478
+ Target: link,
26479
+ TargetMode: "External"
26480
+ }
26481
+ });
26482
+ return rId;
26483
+ }
26484
+ const config$g = {
26485
+ xmlName: XML_NODE_NAME$i,
26486
+ sdNodeOrKeyName: SD_NODE_NAME$c,
26487
+ type: NodeTranslator.translatorTypes.NODE,
26488
+ encode: encode$s,
26489
+ decode: decode$s,
26490
+ attributes: validXmlAttributes$a
26491
+ };
26492
+ const translator$W = NodeTranslator.from(config$g);
26493
+ const encode$r = (attributes) => {
26248
26494
  return attributes["w:rsidR"];
26249
26495
  };
26250
- const decode$q = (attrs) => {
26496
+ const decode$r = (attrs) => {
26251
26497
  return attrs.rsidR;
26252
26498
  };
26253
26499
  const attrConfig$9 = Object.freeze({
26254
26500
  xmlName: "w:rsidR",
26255
26501
  sdName: "rsidR",
26256
- encode: encode$q,
26257
- decode: decode$q
26502
+ encode: encode$r,
26503
+ decode: decode$r
26258
26504
  });
26259
- const encode$p = (attributes) => {
26505
+ const encode$q = (attributes) => {
26260
26506
  return attributes["w:rsidRPr"];
26261
26507
  };
26262
- const decode$p = (attrs) => {
26508
+ const decode$q = (attrs) => {
26263
26509
  return attrs.rsidRPr;
26264
26510
  };
26265
26511
  const attrConfig$8 = Object.freeze({
26266
26512
  xmlName: "w:rsidRPr",
26267
26513
  sdName: "rsidRPr",
26268
- encode: encode$p,
26269
- decode: decode$p
26514
+ encode: encode$q,
26515
+ decode: decode$q
26270
26516
  });
26271
- const encode$o = (attributes) => {
26517
+ const encode$p = (attributes) => {
26272
26518
  return attributes["w:rsidDel"];
26273
26519
  };
26274
- const decode$o = (attrs) => {
26520
+ const decode$p = (attrs) => {
26275
26521
  return attrs.rsidDel;
26276
26522
  };
26277
26523
  const attrConfig$7 = Object.freeze({
26278
26524
  xmlName: "w:rsidDel",
26279
26525
  sdName: "rsidDel",
26280
- encode: encode$o,
26281
- decode: decode$o
26526
+ encode: encode$p,
26527
+ decode: decode$p
26282
26528
  });
26283
- const validXmlAttributes$a = [attrConfig$9, attrConfig$8, attrConfig$7];
26284
- const XML_NODE_NAME$g = "w:r";
26529
+ const validXmlAttributes$9 = [attrConfig$9, attrConfig$8, attrConfig$7];
26530
+ const XML_NODE_NAME$h = "w:r";
26285
26531
  const SD_KEY_NAME = "run";
26286
- const encode$n = (params2, encodedAttrs = {}) => {
26532
+ const encode$o = (params2, encodedAttrs = {}) => {
26287
26533
  const { nodes = [], nodeListHandler } = params2 || {};
26288
26534
  const runNode = nodes[0];
26289
26535
  if (!runNode) return void 0;
@@ -26331,9 +26577,11 @@ const encode$n = (params2, encodedAttrs = {}) => {
26331
26577
  }
26332
26578
  return runNodeResult;
26333
26579
  };
26334
- const decode$n = (params2, decodedAttrs = {}) => {
26580
+ const decode$o = (params2, decodedAttrs = {}) => {
26335
26581
  const { node } = params2 || {};
26336
26582
  if (!node) return void 0;
26583
+ const isLinkNode = node.marks?.some((m2) => m2.type === "link");
26584
+ if (isLinkNode) return translator$W.decode(params2);
26337
26585
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node);
26338
26586
  const runAttrs = runNodeForExport.attrs || {};
26339
26587
  const runProperties = Array.isArray(runAttrs.runProperties) ? runAttrs.runProperties : [];
@@ -26388,7 +26636,7 @@ const decode$n = (params2, decodedAttrs = {}) => {
26388
26636
  runs.push(trackedClone);
26389
26637
  return;
26390
26638
  }
26391
- const runWrapper = { name: XML_NODE_NAME$g, elements: [] };
26639
+ const runWrapper = { name: XML_NODE_NAME$h, elements: [] };
26392
26640
  applyBaseRunProps(runWrapper);
26393
26641
  if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
26394
26642
  runWrapper.elements.push(cloneXmlNode(child));
@@ -26396,7 +26644,7 @@ const decode$n = (params2, decodedAttrs = {}) => {
26396
26644
  });
26397
26645
  const trackedRuns = ensureTrackedWrapper(runs, trackingMarksByType);
26398
26646
  if (!trackedRuns.length) {
26399
- const emptyRun = { name: XML_NODE_NAME$g, elements: [] };
26647
+ const emptyRun = { name: XML_NODE_NAME$h, elements: [] };
26400
26648
  applyBaseRunProps(emptyRun);
26401
26649
  trackedRuns.push(emptyRun);
26402
26650
  }
@@ -26410,148 +26658,15 @@ const decode$n = (params2, decodedAttrs = {}) => {
26410
26658
  }
26411
26659
  return trackedRuns;
26412
26660
  };
26413
- const config$e = {
26414
- xmlName: XML_NODE_NAME$g,
26661
+ const config$f = {
26662
+ xmlName: XML_NODE_NAME$h,
26415
26663
  sdNodeOrKeyName: SD_KEY_NAME,
26416
26664
  type: NodeTranslator.translatorTypes.NODE,
26417
- encode: encode$n,
26418
- decode: decode$n,
26419
- attributes: validXmlAttributes$a
26420
- };
26421
- const translator$U = NodeTranslator.from(config$e);
26422
- const generateV2HandlerEntity = (handlerName, translator2) => ({
26423
- handlerName,
26424
- handler: (params2) => {
26425
- const { nodes } = params2;
26426
- if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
26427
- return { nodes: [], consumed: 0 };
26428
- }
26429
- const result = translator2.encode(params2);
26430
- if (!result) return { nodes: [], consumed: 0 };
26431
- return {
26432
- nodes: Array.isArray(result) ? result : [result],
26433
- consumed: 1
26434
- };
26435
- }
26436
- });
26437
- function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:val", transformEncode = null, transformDecode = null) {
26438
- if (!sdName) sdName = xmlName.split(":")[1];
26439
- if (!transformEncode) transformEncode = (v2) => v2;
26440
- if (!transformDecode) transformDecode = (v2) => v2;
26441
- return {
26442
- xmlName,
26443
- sdNodeOrKeyName: sdName,
26444
- encode: ({ nodes }) => {
26445
- return transformEncode(nodes[0].attributes[attrName]) ?? void 0;
26446
- },
26447
- decode: ({ node }) => {
26448
- const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
26449
- return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
26450
- }
26451
- };
26452
- }
26453
- function createMeasurementPropertyHandler(xmlName, sdName = null) {
26454
- if (!sdName) sdName = xmlName.split(":")[1];
26455
- return {
26456
- xmlName,
26457
- sdNodeOrKeyName: sdName,
26458
- attributes: [
26459
- createAttributeHandler("w:w", "value", parseInteger, integerToString),
26460
- createAttributeHandler("w:type")
26461
- ],
26462
- encode: (_2, encodedAttrs) => {
26463
- return encodedAttrs["value"] != null ? encodedAttrs : void 0;
26464
- },
26465
- decode: function({ node }) {
26466
- const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
26467
- return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
26468
- }
26469
- };
26470
- }
26471
- function createBorderPropertyHandler(xmlName, sdName = null) {
26472
- if (!sdName) sdName = xmlName.split(":")[1];
26473
- return {
26474
- xmlName,
26475
- sdNodeOrKeyName: sdName,
26476
- attributes: [
26477
- createAttributeHandler("w:val"),
26478
- createAttributeHandler("w:color"),
26479
- createAttributeHandler("w:themeColor"),
26480
- createAttributeHandler("w:themeTint"),
26481
- createAttributeHandler("w:themeShade"),
26482
- createAttributeHandler("w:sz", "size", parseInteger, integerToString),
26483
- createAttributeHandler("w:space", null, parseInteger, integerToString),
26484
- createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
26485
- createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
26486
- ],
26487
- encode: (params2, encodedAttrs) => {
26488
- return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
26489
- },
26490
- decode: function({ node }, context) {
26491
- const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
26492
- return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26493
- }
26494
- };
26495
- }
26496
- const createAttributeHandler = (xmlName, sdName = null, transformEncode = null, transformDecode = null) => {
26497
- if (!transformEncode) transformEncode = (v2) => v2;
26498
- if (!transformDecode) transformDecode = (v2) => v2;
26499
- if (!sdName) sdName = xmlName.split(":")[1];
26500
- return {
26501
- xmlName,
26502
- sdName,
26503
- encode: (attributes) => transformEncode(attributes[xmlName]),
26504
- decode: (attributes) => transformDecode(attributes[sdName])
26505
- };
26506
- };
26507
- function encodeProperties(node, translatorsByXmlName, asArray = false) {
26508
- if (!node?.elements || node.elements.length === 0) {
26509
- return asArray ? [] : {};
26510
- }
26511
- const attributes = asArray ? [] : {};
26512
- node.elements.forEach((el) => {
26513
- const translator2 = translatorsByXmlName[el.name];
26514
- if (translator2) {
26515
- const encodedAttr = translator2.encode({ nodes: [el] });
26516
- if (encodedAttr != null) {
26517
- if (asArray) {
26518
- attributes.push({ [translator2.sdNodeOrKeyName]: encodedAttr });
26519
- } else {
26520
- attributes[translator2.sdNodeOrKeyName] = encodedAttr;
26521
- }
26522
- }
26523
- }
26524
- });
26525
- return attributes;
26526
- }
26527
- function decodeProperties(translatorsBySdName, properties) {
26528
- if (!properties || typeof properties !== "object") {
26529
- return [];
26530
- }
26531
- const elements = [];
26532
- Object.keys(properties).forEach((key2) => {
26533
- const translator2 = translatorsBySdName[key2];
26534
- if (translator2) {
26535
- const result = translator2.decode({ node: { attrs: { [key2]: properties[key2] } } });
26536
- if (result != null) {
26537
- result.name = translator2.xmlName;
26538
- elements.push(result);
26539
- }
26540
- }
26541
- });
26542
- return elements;
26543
- }
26544
- const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
26545
- const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
26546
- const parseInteger = (value) => {
26547
- if (value == null) return void 0;
26548
- const intValue = parseInt(value, 10);
26549
- return isNaN(intValue) ? void 0 : intValue;
26550
- };
26551
- const integerToString = (value) => {
26552
- const intValue = parseInteger(value);
26553
- return intValue != void 0 ? String(intValue) : void 0;
26665
+ encode: encode$o,
26666
+ decode: decode$o,
26667
+ attributes: validXmlAttributes$9
26554
26668
  };
26669
+ const translator$V = NodeTranslator.from(config$f);
26555
26670
  function preProcessVerticalMergeCells(table, { editorSchema }) {
26556
26671
  if (!table || !Array.isArray(table.content)) {
26557
26672
  return table;
@@ -26592,13 +26707,13 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
26592
26707
  }
26593
26708
  return table;
26594
26709
  }
26595
- const translator$T = NodeTranslator.from({
26710
+ const translator$U = NodeTranslator.from({
26596
26711
  xmlName: "w:cantSplit",
26597
26712
  sdNodeOrKeyName: "cantSplit",
26598
26713
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
26599
26714
  decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
26600
26715
  });
26601
- const translator$S = NodeTranslator.from({
26716
+ const translator$T = NodeTranslator.from({
26602
26717
  xmlName: "w:cnfStyle",
26603
26718
  sdNodeOrKeyName: "cnfStyle",
26604
26719
  attributes: [
@@ -26624,8 +26739,8 @@ const translator$S = NodeTranslator.from({
26624
26739
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26625
26740
  }
26626
26741
  });
26627
- const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26628
- const translator$Q = NodeTranslator.from(
26742
+ const translator$S = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26743
+ const translator$R = NodeTranslator.from(
26629
26744
  createSingleAttrPropertyHandler(
26630
26745
  "w:gridAfter",
26631
26746
  null,
@@ -26634,7 +26749,7 @@ const translator$Q = NodeTranslator.from(
26634
26749
  (v2) => integerToString(v2)
26635
26750
  )
26636
26751
  );
26637
- const translator$P = NodeTranslator.from(
26752
+ const translator$Q = NodeTranslator.from(
26638
26753
  createSingleAttrPropertyHandler(
26639
26754
  "w:gridBefore",
26640
26755
  null,
@@ -26643,21 +26758,21 @@ const translator$P = NodeTranslator.from(
26643
26758
  (v2) => integerToString(v2)
26644
26759
  )
26645
26760
  );
26646
- const translator$O = NodeTranslator.from({
26761
+ const translator$P = NodeTranslator.from({
26647
26762
  xmlName: "w:hidden",
26648
26763
  sdNodeOrKeyName: "hidden",
26649
26764
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26650
26765
  decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
26651
26766
  });
26652
- const translator$N = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26653
- const translator$M = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26654
- const translator$L = NodeTranslator.from({
26767
+ const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26768
+ const translator$N = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26769
+ const translator$M = NodeTranslator.from({
26655
26770
  xmlName: "w:tblHeader",
26656
26771
  sdNodeOrKeyName: "repeatHeader",
26657
26772
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26658
26773
  decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
26659
26774
  });
26660
- const translator$K = NodeTranslator.from({
26775
+ const translator$L = NodeTranslator.from({
26661
26776
  xmlName: "w:trHeight",
26662
26777
  sdNodeOrKeyName: "rowHeight",
26663
26778
  encode: ({ nodes }) => {
@@ -26684,11 +26799,11 @@ const translator$K = NodeTranslator.from({
26684
26799
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
26685
26800
  }
26686
26801
  });
26687
- const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26688
- const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26689
- const XML_NODE_NAME$f = "w:trPr";
26802
+ const translator$K = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26803
+ const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26804
+ const XML_NODE_NAME$g = "w:trPr";
26690
26805
  const SD_ATTR_KEY$4 = "tableRowProperties";
26691
- const encode$m = (params2) => {
26806
+ const encode$n = (params2) => {
26692
26807
  const { nodes } = params2;
26693
26808
  const node = nodes[0];
26694
26809
  let attributes = {
@@ -26702,12 +26817,12 @@ const encode$m = (params2) => {
26702
26817
  };
26703
26818
  return {
26704
26819
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26705
- xmlName: XML_NODE_NAME$f,
26820
+ xmlName: XML_NODE_NAME$g,
26706
26821
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26707
26822
  attributes
26708
26823
  };
26709
26824
  };
26710
- const decode$m = (params2) => {
26825
+ const decode$n = (params2) => {
26711
26826
  const { tableRowProperties = {} } = params2.node.attrs || {};
26712
26827
  const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
26713
26828
  const newNode = {
@@ -26719,6 +26834,7 @@ const decode$m = (params2) => {
26719
26834
  return newNode;
26720
26835
  };
26721
26836
  const propertyTranslators$3 = [
26837
+ translator$U,
26722
26838
  translator$T,
26723
26839
  translator$S,
26724
26840
  translator$R,
@@ -26729,8 +26845,7 @@ const propertyTranslators$3 = [
26729
26845
  translator$M,
26730
26846
  translator$L,
26731
26847
  translator$K,
26732
- translator$J,
26733
- translator$I
26848
+ translator$J
26734
26849
  ];
26735
26850
  const propertyTranslatorsByXmlName$2 = {};
26736
26851
  propertyTranslators$3.forEach((translator2) => {
@@ -26740,25 +26855,25 @@ const propertyTranslatorsBySdName$2 = {};
26740
26855
  propertyTranslators$3.forEach((translator2) => {
26741
26856
  propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
26742
26857
  });
26743
- const config$d = {
26744
- xmlName: XML_NODE_NAME$f,
26858
+ const config$e = {
26859
+ xmlName: XML_NODE_NAME$g,
26745
26860
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26746
26861
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26747
- encode: encode$m,
26748
- decode: decode$m
26862
+ encode: encode$n,
26863
+ decode: decode$n
26749
26864
  };
26750
- const translator$H = NodeTranslator.from(config$d);
26751
- const XML_NODE_NAME$e = "w:tr";
26752
- const SD_NODE_NAME$a = "tableRow";
26753
- const validXmlAttributes$9 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26865
+ const translator$I = NodeTranslator.from(config$e);
26866
+ const XML_NODE_NAME$f = "w:tr";
26867
+ const SD_NODE_NAME$b = "tableRow";
26868
+ const validXmlAttributes$8 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26754
26869
  (xmlName) => createAttributeHandler(xmlName)
26755
26870
  );
26756
- const encode$l = (params2, encodedAttrs) => {
26871
+ const encode$m = (params2, encodedAttrs) => {
26757
26872
  const { row } = params2.extraParams;
26758
26873
  let tableRowProperties = {};
26759
26874
  const tPr = row.elements.find((el) => el.name === "w:trPr");
26760
26875
  if (tPr) {
26761
- ({ attributes: tableRowProperties } = translator$H.encode({
26876
+ ({ attributes: tableRowProperties } = translator$I.encode({
26762
26877
  ...params2,
26763
26878
  nodes: [tPr]
26764
26879
  }));
@@ -26771,7 +26886,7 @@ const encode$l = (params2, encodedAttrs) => {
26771
26886
  let currentColumnIndex = 0;
26772
26887
  const content = cellNodes?.map((n) => {
26773
26888
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
26774
- const result = translator$8.encode({
26889
+ const result = translator$9.encode({
26775
26890
  ...params2,
26776
26891
  extraParams: {
26777
26892
  ...params2.extraParams,
@@ -26793,7 +26908,7 @@ const encode$l = (params2, encodedAttrs) => {
26793
26908
  };
26794
26909
  return newNode;
26795
26910
  };
26796
- const decode$l = (params2, decodedAttrs) => {
26911
+ const decode$m = (params2, decodedAttrs) => {
26797
26912
  const { node } = params2;
26798
26913
  const elements = translateChildNodes(params2);
26799
26914
  if (node.attrs?.tableRowProperties) {
@@ -26805,7 +26920,7 @@ const decode$l = (params2, decodedAttrs) => {
26805
26920
  }
26806
26921
  }
26807
26922
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
26808
- const trPr = translator$H.decode({
26923
+ const trPr = translator$I.decode({
26809
26924
  ...params2,
26810
26925
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
26811
26926
  });
@@ -26817,22 +26932,22 @@ const decode$l = (params2, decodedAttrs) => {
26817
26932
  elements
26818
26933
  };
26819
26934
  };
26820
- const config$c = {
26821
- xmlName: XML_NODE_NAME$e,
26822
- sdNodeOrKeyName: SD_NODE_NAME$a,
26935
+ const config$d = {
26936
+ xmlName: XML_NODE_NAME$f,
26937
+ sdNodeOrKeyName: SD_NODE_NAME$b,
26823
26938
  type: NodeTranslator.translatorTypes.NODE,
26824
- encode: encode$l,
26825
- decode: decode$l,
26826
- attributes: validXmlAttributes$9
26939
+ encode: encode$m,
26940
+ decode: decode$m,
26941
+ attributes: validXmlAttributes$8
26827
26942
  };
26828
- const translator$G = NodeTranslator.from(config$c);
26829
- const translator$F = NodeTranslator.from({
26943
+ const translator$H = NodeTranslator.from(config$d);
26944
+ const translator$G = NodeTranslator.from({
26830
26945
  xmlName: "w:bidiVisual",
26831
26946
  sdNodeOrKeyName: "rightToLeft",
26832
26947
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26833
26948
  decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
26834
26949
  });
26835
- const translator$E = NodeTranslator.from({
26950
+ const translator$F = NodeTranslator.from({
26836
26951
  xmlName: "w:shd",
26837
26952
  sdNodeOrKeyName: "shading",
26838
26953
  attributes: [
@@ -26854,11 +26969,11 @@ const translator$E = NodeTranslator.from({
26854
26969
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26855
26970
  }
26856
26971
  });
26857
- const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26858
- const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26859
- const translator$B = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26860
- const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26861
- const translator$z = NodeTranslator.from({
26972
+ const translator$E = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26973
+ const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26974
+ const translator$C = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26975
+ const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26976
+ const translator$A = NodeTranslator.from({
26862
26977
  xmlName: "w:tblLook",
26863
26978
  sdNodeOrKeyName: "tblLook",
26864
26979
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -26870,16 +26985,16 @@ const translator$z = NodeTranslator.from({
26870
26985
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26871
26986
  }
26872
26987
  });
26873
- const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26874
- const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26875
- const translator$w = NodeTranslator.from(
26988
+ const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26989
+ const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26990
+ const translator$x = NodeTranslator.from(
26876
26991
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
26877
26992
  );
26878
- const translator$v = NodeTranslator.from(
26993
+ const translator$w = NodeTranslator.from(
26879
26994
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
26880
26995
  );
26881
- const translator$u = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26882
- const translator$t = NodeTranslator.from({
26996
+ const translator$v = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26997
+ const translator$u = NodeTranslator.from({
26883
26998
  xmlName: "w:tblpPr",
26884
26999
  sdNodeOrKeyName: "floatingTableProperties",
26885
27000
  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))),
@@ -26891,29 +27006,29 @@ const translator$t = NodeTranslator.from({
26891
27006
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26892
27007
  }
26893
27008
  });
26894
- const translator$s = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
26895
- const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
26896
- const translator$q = NodeTranslator.from(createBorderPropertyHandler("w:end"));
26897
- const translator$p = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
26898
- const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
26899
- const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
26900
- const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:left"));
26901
- const translator$l = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
26902
- const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:right"));
26903
- const translator$j = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
26904
- const translator$i = NodeTranslator.from(createBorderPropertyHandler("w:start"));
26905
- const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
26906
- const translator$g = NodeTranslator.from(createBorderPropertyHandler("w:top"));
26907
- const translator$f = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
26908
- const XML_NODE_NAME$d = "w:tblBorders";
27009
+ const translator$t = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
27010
+ const translator$s = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
27011
+ const translator$r = NodeTranslator.from(createBorderPropertyHandler("w:end"));
27012
+ const translator$q = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
27013
+ const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
27014
+ const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
27015
+ const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:left"));
27016
+ const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
27017
+ const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:right"));
27018
+ const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
27019
+ const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:start"));
27020
+ const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
27021
+ const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:top"));
27022
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
27023
+ const XML_NODE_NAME$e = "w:tblBorders";
26909
27024
  const SD_ATTR_KEY$3 = "borders";
26910
- const encode$k = (params2) => {
27025
+ const encode$l = (params2) => {
26911
27026
  const { nodes } = params2;
26912
27027
  const node = nodes[0];
26913
27028
  const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
26914
27029
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26915
27030
  };
26916
- const decode$k = (params2) => {
27031
+ const decode$l = (params2) => {
26917
27032
  const { borders = {} } = params2.node.attrs || {};
26918
27033
  const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
26919
27034
  const newNode = {
@@ -26925,14 +27040,14 @@ const decode$k = (params2) => {
26925
27040
  return newNode;
26926
27041
  };
26927
27042
  const propertyTranslators$2 = [
26928
- translator$s,
26929
- translator$q,
27043
+ translator$t,
27044
+ translator$r,
27045
+ translator$p,
26930
27046
  translator$o,
26931
27047
  translator$n,
26932
- translator$m,
26933
- translator$k,
26934
- translator$i,
26935
- translator$g
27048
+ translator$l,
27049
+ translator$j,
27050
+ translator$h
26936
27051
  ];
26937
27052
  const tblBordersTranslatorsByXmlName = {};
26938
27053
  const tblBordersTranslatorsBySdName = {};
@@ -26940,27 +27055,27 @@ propertyTranslators$2.forEach((translator2) => {
26940
27055
  tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
26941
27056
  tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
26942
27057
  });
26943
- const translator$e = NodeTranslator.from({
26944
- xmlName: XML_NODE_NAME$d,
27058
+ const translator$f = NodeTranslator.from({
27059
+ xmlName: XML_NODE_NAME$e,
26945
27060
  sdNodeOrKeyName: SD_ATTR_KEY$3,
26946
27061
  type: NodeTranslator.translatorTypes.NODE,
26947
27062
  attributes: [],
26948
- encode: encode$k,
26949
- decode: decode$k
27063
+ encode: encode$l,
27064
+ decode: decode$l
26950
27065
  });
26951
- const XML_NODE_NAME$c = "w:tblCellMar";
27066
+ const XML_NODE_NAME$d = "w:tblCellMar";
26952
27067
  const SD_ATTR_KEY$2 = "cellMargins";
26953
- const encode$j = (params2) => {
27068
+ const encode$k = (params2) => {
26954
27069
  const { nodes } = params2;
26955
27070
  const node = nodes[0];
26956
27071
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
26957
27072
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26958
27073
  };
26959
- const decode$j = (params2) => {
27074
+ const decode$k = (params2) => {
26960
27075
  const { cellMargins = {} } = params2.node.attrs || {};
26961
27076
  const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
26962
27077
  const newNode = {
26963
- name: XML_NODE_NAME$c,
27078
+ name: XML_NODE_NAME$d,
26964
27079
  type: "element",
26965
27080
  attributes: {},
26966
27081
  elements
@@ -26968,12 +27083,12 @@ const decode$j = (params2) => {
26968
27083
  return newNode;
26969
27084
  };
26970
27085
  const propertyTranslators$1 = [
26971
- translator$r,
26972
- translator$p,
26973
- translator$l,
26974
- translator$j,
26975
- translator$h,
26976
- translator$f
27086
+ translator$s,
27087
+ translator$q,
27088
+ translator$m,
27089
+ translator$k,
27090
+ translator$i,
27091
+ translator$g
26977
27092
  ];
26978
27093
  const propertyTranslatorsByXmlName$1 = {};
26979
27094
  const propertyTranslatorsBySdName$1 = {};
@@ -26981,27 +27096,27 @@ propertyTranslators$1.forEach((translator2) => {
26981
27096
  propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
26982
27097
  propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
26983
27098
  });
26984
- const translator$d = NodeTranslator.from({
26985
- xmlName: XML_NODE_NAME$c,
27099
+ const translator$e = NodeTranslator.from({
27100
+ xmlName: XML_NODE_NAME$d,
26986
27101
  sdNodeOrKeyName: SD_ATTR_KEY$2,
26987
27102
  type: NodeTranslator.translatorTypes.NODE,
26988
27103
  attributes: [],
26989
- encode: encode$j,
26990
- decode: decode$j
27104
+ encode: encode$k,
27105
+ decode: decode$k
26991
27106
  });
26992
- const XML_NODE_NAME$b = "w:tblPr";
27107
+ const XML_NODE_NAME$c = "w:tblPr";
26993
27108
  const SD_ATTR_KEY$1 = "tableProperties";
26994
- const encode$i = (params2) => {
27109
+ const encode$j = (params2) => {
26995
27110
  const { nodes } = params2;
26996
27111
  const node = nodes[0];
26997
27112
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
26998
27113
  return {
26999
- xmlName: XML_NODE_NAME$b,
27114
+ xmlName: XML_NODE_NAME$c,
27000
27115
  sdNodeOrKeyName: SD_ATTR_KEY$1,
27001
27116
  attributes
27002
27117
  };
27003
27118
  };
27004
- const decode$i = (params2) => {
27119
+ const decode$j = (params2) => {
27005
27120
  const { tableProperties = {} } = params2.node.attrs || {};
27006
27121
  const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
27007
27122
  const newNode = {
@@ -27013,11 +27128,12 @@ const decode$i = (params2) => {
27013
27128
  return newNode;
27014
27129
  };
27015
27130
  const propertyTranslators = [
27131
+ translator$G,
27132
+ translator$O,
27016
27133
  translator$F,
27017
- translator$N,
27018
27134
  translator$E,
27135
+ translator$N,
27019
27136
  translator$D,
27020
- translator$M,
27021
27137
  translator$C,
27022
27138
  translator$B,
27023
27139
  translator$A,
@@ -27027,9 +27143,8 @@ const propertyTranslators = [
27027
27143
  translator$w,
27028
27144
  translator$v,
27029
27145
  translator$u,
27030
- translator$t,
27031
- translator$e,
27032
- translator$d
27146
+ translator$f,
27147
+ translator$e
27033
27148
  ];
27034
27149
  const propertyTranslatorsByXmlName = {};
27035
27150
  const propertyTranslatorsBySdName = {};
@@ -27037,14 +27152,14 @@ propertyTranslators.forEach((translator2) => {
27037
27152
  propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
27038
27153
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
27039
27154
  });
27040
- const config$b = {
27041
- xmlName: XML_NODE_NAME$b,
27155
+ const config$c = {
27156
+ xmlName: XML_NODE_NAME$c,
27042
27157
  sdNodeOrKeyName: SD_ATTR_KEY$1,
27043
- encode: encode$i,
27044
- decode: decode$i
27158
+ encode: encode$j,
27159
+ decode: decode$j
27045
27160
  };
27046
- const translator$c = NodeTranslator.from(config$b);
27047
- const translator$b = NodeTranslator.from(
27161
+ const translator$d = NodeTranslator.from(config$c);
27162
+ const translator$c = NodeTranslator.from(
27048
27163
  createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
27049
27164
  );
27050
27165
  const DEFAULT_COLUMN_WIDTH_PX = 100;
@@ -27094,20 +27209,20 @@ const resolveFallbackColumnWidthTwips = (params2, totalColumns, cellMinWidthTwip
27094
27209
  }
27095
27210
  return Math.max(fallbackWidthTwips, cellMinWidthTwips);
27096
27211
  };
27097
- const XML_NODE_NAME$a = "w:tblGrid";
27212
+ const XML_NODE_NAME$b = "w:tblGrid";
27098
27213
  const SD_ATTR_KEY = "grid";
27099
27214
  const cellMinWidth = pixelsToTwips(10);
27100
- const encode$h = (params2) => {
27215
+ const encode$i = (params2) => {
27101
27216
  const { nodes } = params2;
27102
27217
  const node = nodes[0];
27103
- const attributes = encodeProperties(node, { [translator$b.xmlName]: translator$b }, true);
27218
+ const attributes = encodeProperties(node, { [translator$c.xmlName]: translator$c }, true);
27104
27219
  return {
27105
- xmlName: XML_NODE_NAME$a,
27220
+ xmlName: XML_NODE_NAME$b,
27106
27221
  sdNodeOrKeyName: SD_ATTR_KEY,
27107
27222
  attributes
27108
27223
  };
27109
27224
  };
27110
- const decode$h = (params2) => {
27225
+ const decode$i = (params2) => {
27111
27226
  const { grid: rawGrid } = params2.node.attrs || {};
27112
27227
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
27113
27228
  const { firstRow = {} } = params2.extraParams || {};
@@ -27126,10 +27241,10 @@ const decode$h = (params2) => {
27126
27241
  numericWidth = fallbackColumnWidthTwips;
27127
27242
  }
27128
27243
  numericWidth = Math.max(numericWidth, cellMinWidth);
27129
- const decoded = translator$b.decode({
27244
+ const decoded = translator$c.decode({
27130
27245
  node: { type: (
27131
27246
  /** @type {string} */
27132
- translator$b.sdNodeOrKeyName
27247
+ translator$c.sdNodeOrKeyName
27133
27248
  ), attrs: { col: numericWidth } }
27134
27249
  });
27135
27250
  if (decoded) elements.push(decoded);
@@ -27164,19 +27279,19 @@ const decode$h = (params2) => {
27164
27279
  columnIndex++;
27165
27280
  }
27166
27281
  const newNode = {
27167
- name: XML_NODE_NAME$a,
27282
+ name: XML_NODE_NAME$b,
27168
27283
  attributes: {},
27169
27284
  elements
27170
27285
  };
27171
27286
  return newNode;
27172
27287
  };
27173
- const config$a = {
27174
- xmlName: XML_NODE_NAME$a,
27288
+ const config$b = {
27289
+ xmlName: XML_NODE_NAME$b,
27175
27290
  sdNodeOrKeyName: SD_ATTR_KEY,
27176
- encode: encode$h,
27177
- decode: decode$h
27291
+ encode: encode$i,
27292
+ decode: decode$i
27178
27293
  };
27179
- const translator$a = NodeTranslator.from(config$a);
27294
+ const translator$b = NodeTranslator.from(config$b);
27180
27295
  const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
27181
27296
  const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
27182
27297
  const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
@@ -27239,19 +27354,19 @@ const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWid
27239
27354
  columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
27240
27355
  };
27241
27356
  };
27242
- const XML_NODE_NAME$9 = "w:tbl";
27243
- const SD_NODE_NAME$9 = "table";
27244
- const encode$g = (params2, encodedAttrs) => {
27357
+ const XML_NODE_NAME$a = "w:tbl";
27358
+ const SD_NODE_NAME$a = "table";
27359
+ const encode$h = (params2, encodedAttrs) => {
27245
27360
  const { nodes } = params2;
27246
27361
  const node = nodes[0];
27247
27362
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
27248
27363
  if (tblPr) {
27249
- const encodedProperties = translator$c.encode({ ...params2, nodes: [tblPr] });
27364
+ const encodedProperties = translator$d.encode({ ...params2, nodes: [tblPr] });
27250
27365
  encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
27251
27366
  }
27252
27367
  const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
27253
27368
  if (tblGrid) {
27254
- encodedAttrs["grid"] = translator$a.encode({ ...params2, nodes: [tblGrid] }).attributes;
27369
+ encodedAttrs["grid"] = translator$b.encode({ ...params2, nodes: [tblGrid] }).attributes;
27255
27370
  }
27256
27371
  [
27257
27372
  "tableStyleId",
@@ -27318,7 +27433,7 @@ const encode$g = (params2, encodedAttrs) => {
27318
27433
  }
27319
27434
  const content = [];
27320
27435
  rows.forEach((row) => {
27321
- const result = translator$G.encode({
27436
+ const result = translator$H.encode({
27322
27437
  ...params2,
27323
27438
  nodes: [row],
27324
27439
  extraParams: {
@@ -27337,13 +27452,13 @@ const encode$g = (params2, encodedAttrs) => {
27337
27452
  attrs: encodedAttrs
27338
27453
  };
27339
27454
  };
27340
- const decode$g = (params2, decodedAttrs) => {
27455
+ const decode$h = (params2, decodedAttrs) => {
27341
27456
  params2.node = preProcessVerticalMergeCells(params2.node, params2);
27342
27457
  const { node } = params2;
27343
27458
  const elements = translateChildNodes(params2);
27344
27459
  const firstRow = node.content?.find((n) => n.type === "tableRow");
27345
27460
  const properties = node.attrs.grid;
27346
- const element = translator$a.decode({
27461
+ const element = translator$b.decode({
27347
27462
  ...params2,
27348
27463
  node: { ...node, attrs: { ...node.attrs, grid: properties } },
27349
27464
  extraParams: {
@@ -27353,7 +27468,7 @@ const decode$g = (params2, decodedAttrs) => {
27353
27468
  if (element) elements.unshift(element);
27354
27469
  if (node.attrs?.tableProperties) {
27355
27470
  const properties2 = { ...node.attrs.tableProperties };
27356
- const element2 = translator$c.decode({
27471
+ const element2 = translator$d.decode({
27357
27472
  ...params2,
27358
27473
  node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
27359
27474
  });
@@ -27419,7 +27534,7 @@ function _getReferencedTableStyles(tableStyleReference, params2) {
27419
27534
  if (baseTblPr && baseTblPr.elements) {
27420
27535
  tblPr.elements.push(...baseTblPr.elements);
27421
27536
  }
27422
- const tableProperties = translator$c.encode({ ...params2, nodes: [tblPr] }).attributes;
27537
+ const tableProperties = translator$d.encode({ ...params2, nodes: [tblPr] }).attributes;
27423
27538
  const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
27424
27539
  if (borders) stylesToReturn.borders = borders;
27425
27540
  if (rowBorders) stylesToReturn.rowBorders = rowBorders;
@@ -27436,16 +27551,16 @@ function _getReferencedTableStyles(tableStyleReference, params2) {
27436
27551
  }
27437
27552
  return stylesToReturn;
27438
27553
  }
27439
- const config$9 = {
27440
- xmlName: XML_NODE_NAME$9,
27441
- sdNodeOrKeyName: SD_NODE_NAME$9,
27554
+ const config$a = {
27555
+ xmlName: XML_NODE_NAME$a,
27556
+ sdNodeOrKeyName: SD_NODE_NAME$a,
27442
27557
  type: NodeTranslator.translatorTypes.NODE,
27443
- encode: encode$g,
27444
- decode: decode$g,
27558
+ encode: encode$h,
27559
+ decode: decode$h,
27445
27560
  attributes: []
27446
27561
  };
27447
- const translator$9 = NodeTranslator.from(config$9);
27448
- const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$9);
27562
+ const translator$a = NodeTranslator.from(config$a);
27563
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$a);
27449
27564
  function getReferencedTableStyles(tblStyleTag, docx) {
27450
27565
  if (!tblStyleTag) return null;
27451
27566
  const stylesToReturn = {};
@@ -27807,10 +27922,10 @@ function generateCellMargins(cellMargins) {
27807
27922
  if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
27808
27923
  return elements;
27809
27924
  }
27810
- const XML_NODE_NAME$8 = "w:tc";
27811
- const SD_NODE_NAME$8 = "tableCell";
27812
- const validXmlAttributes$8 = [];
27813
- function encode$f(params2, encodedAttrs) {
27925
+ const XML_NODE_NAME$9 = "w:tc";
27926
+ const SD_NODE_NAME$9 = "tableCell";
27927
+ const validXmlAttributes$7 = [];
27928
+ function encode$g(params2, encodedAttrs) {
27814
27929
  const {
27815
27930
  node,
27816
27931
  table,
@@ -27837,162 +27952,22 @@ function encode$f(params2, encodedAttrs) {
27837
27952
  }
27838
27953
  return schemaNode;
27839
27954
  }
27840
- function decode$f(params2, decodedAttrs) {
27955
+ function decode$g(params2, decodedAttrs) {
27841
27956
  const translated = translateTableCell(params2);
27842
27957
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
27843
27958
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
27844
27959
  }
27845
27960
  return translated;
27846
27961
  }
27847
- const config$8 = {
27848
- xmlName: XML_NODE_NAME$8,
27849
- sdNodeOrKeyName: SD_NODE_NAME$8,
27850
- type: NodeTranslator.translatorTypes.NODE,
27851
- encode: encode$f,
27852
- decode: decode$f,
27853
- attributes: validXmlAttributes$8
27854
- };
27855
- const translator$8 = NodeTranslator.from(config$8);
27856
- const XML_NODE_NAME$7 = "w:hyperlink";
27857
- const SD_NODE_NAME$7 = "link";
27858
- const _createAttributeHandler = (xmlName, sdName) => ({
27859
- xmlName,
27860
- sdName,
27861
- encode: (attributes) => attributes[xmlName],
27862
- decode: (attributes) => attributes[sdName]
27863
- });
27864
- const validXmlAttributes$7 = [
27865
- _createAttributeHandler("w:anchor", "anchor"),
27866
- _createAttributeHandler("w:docLocation", "docLocation"),
27867
- {
27868
- xmlName: "w:history",
27869
- sdName: "history",
27870
- encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
27871
- decode: (attributes) => attributes["history"] ? "1" : "0"
27872
- },
27873
- _createAttributeHandler("w:tooltip", "tooltip"),
27874
- _createAttributeHandler("r:id", "rId"),
27875
- _createAttributeHandler("w:tgtFrame", "target")
27876
- ];
27877
- const encode$e = (params2, encodedAttrs) => {
27878
- const { nodes, docx, nodeListHandler } = params2;
27879
- const node = nodes[0];
27880
- let href = _resolveHref(docx, encodedAttrs);
27881
- const linkMark = { attrs: { ...encodedAttrs, href } };
27882
- const runNodes = node.elements.filter((el) => el.name === "w:r");
27883
- runNodes.forEach((runNode) => {
27884
- const existingRunMarks = Array.isArray(runNode.marks) ? runNode.marks : [];
27885
- const runMarksWithoutLink = existingRunMarks.filter((mark) => mark?.type !== "link");
27886
- runNode.marks = runMarksWithoutLink;
27887
- });
27888
- const updatedNode = nodeListHandler.handler({
27889
- ...params2,
27890
- nodes: runNodes,
27891
- path: [...params2.path || [], node]
27892
- });
27893
- const cloneMark2 = (mark) => {
27894
- if (!mark || typeof mark !== "object") return mark;
27895
- if (!mark.attrs) return { ...mark };
27896
- return { ...mark, attrs: { ...mark.attrs } };
27897
- };
27898
- const ensureLinkMark = (child) => {
27899
- if (!child || typeof child !== "object") return child;
27900
- if (Array.isArray(child.content)) {
27901
- const updatedContent = child.content.map((item) => ensureLinkMark(item));
27902
- if (updatedContent !== child.content) {
27903
- child = { ...child, content: updatedContent };
27904
- }
27905
- }
27906
- if (child.type === "run") {
27907
- const existingMarks2 = Array.isArray(child.marks) ? child.marks : [];
27908
- const filteredMarks = existingMarks2.filter((mark) => mark?.type !== "link").map((mark) => cloneMark2(mark));
27909
- if (filteredMarks.length !== existingMarks2.length) {
27910
- if (filteredMarks.length) child = { ...child, marks: filteredMarks };
27911
- else {
27912
- const { marks: _removedMarks, ...rest } = child;
27913
- child = rest;
27914
- }
27915
- }
27916
- return child;
27917
- }
27918
- if (child.type !== "text") return child;
27919
- const existingMarks = Array.isArray(child.marks) ? child.marks.map((mark) => cloneMark2(mark)) : [];
27920
- const hasLink = existingMarks.some((mark) => mark?.type === "link");
27921
- if (hasLink) return child;
27922
- const linkClone = { type: "link", attrs: { ...linkMark.attrs } };
27923
- return { ...child, marks: [...existingMarks, linkClone] };
27924
- };
27925
- if (!Array.isArray(updatedNode)) return updatedNode;
27926
- return updatedNode.map((child) => ensureLinkMark(child));
27927
- };
27928
- const _resolveHref = (docx, encodedAttrs) => {
27929
- const rels = docx["word/_rels/document.xml.rels"];
27930
- const relationships = rels.elements.find((el) => el.name === "Relationships");
27931
- const { elements } = relationships;
27932
- const { rId, anchor } = encodedAttrs;
27933
- let href;
27934
- if (!rId && anchor) {
27935
- href = `#${anchor}`;
27936
- } else if (rId) {
27937
- const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
27938
- const { attributes: relAttributes = {} } = rel;
27939
- href = relAttributes["Target"];
27940
- }
27941
- return href;
27942
- };
27943
- function decode$e(params2) {
27944
- const { node } = params2;
27945
- const linkMark = node.marks.find((m2) => m2.type === "link");
27946
- const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
27947
- let { anchor, href: link } = linkMark.attrs;
27948
- const isExternalLink = !anchor;
27949
- if (isExternalLink) {
27950
- linkAttrs["r:id"] = _addNewLinkRelationship(params2, link, linkAttrs["r:id"]);
27951
- }
27952
- node.marks = node.marks.filter((m2) => m2.type !== "link");
27953
- const outputNode = exportSchemaToJson({ ...params2, node });
27954
- const newNode = {
27955
- name: "w:hyperlink",
27956
- type: "element",
27957
- attributes: {
27958
- ...linkAttrs
27959
- },
27960
- elements: [outputNode]
27961
- };
27962
- return newNode;
27963
- }
27964
- function _addNewLinkRelationship(params2, link, rId) {
27965
- if (!rId) rId = generateDocxRandomId();
27966
- if (!params2.relationships || !Array.isArray(params2.relationships)) {
27967
- params2.relationships = [];
27968
- }
27969
- const existingRel = params2.relationships.find(
27970
- (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
27971
- );
27972
- if (existingRel) {
27973
- return rId;
27974
- }
27975
- params2.relationships.push({
27976
- type: "element",
27977
- name: "Relationship",
27978
- attributes: {
27979
- Id: rId,
27980
- Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
27981
- Target: link,
27982
- TargetMode: "External"
27983
- }
27984
- });
27985
- return rId;
27986
- }
27987
- const config$7 = {
27988
- xmlName: XML_NODE_NAME$7,
27989
- sdNodeOrKeyName: SD_NODE_NAME$7,
27962
+ const config$9 = {
27963
+ xmlName: XML_NODE_NAME$9,
27964
+ sdNodeOrKeyName: SD_NODE_NAME$9,
27990
27965
  type: NodeTranslator.translatorTypes.NODE,
27991
- encode: encode$e,
27992
- decode: decode$e,
27966
+ encode: encode$g,
27967
+ decode: decode$g,
27993
27968
  attributes: validXmlAttributes$7
27994
27969
  };
27995
- const translator$7 = NodeTranslator.from(config$7);
27970
+ const translator$9 = NodeTranslator.from(config$9);
27996
27971
  function parseTagValueJSON(json) {
27997
27972
  if (typeof json !== "string") {
27998
27973
  return {};
@@ -28128,12 +28103,32 @@ function handleDocPartObj(params2) {
28128
28103
  }
28129
28104
  const content = node?.elements.find((el) => el.name === "w:sdtContent");
28130
28105
  const handler2 = validGalleryTypeMap[docPartGalleryType];
28131
- const result = handler2({ ...params2, nodes: [content] });
28106
+ const result = handler2({
28107
+ ...params2,
28108
+ nodes: [content],
28109
+ extraParams: { ...params2.extraParams || {}, sdtPr }
28110
+ });
28132
28111
  return result;
28133
28112
  }
28134
28113
  const tableOfContentsHandler = (params2) => {
28135
28114
  const node = params2.nodes[0];
28136
- return params2.nodeListHandler.handler({ ...params2, nodes: node.elements });
28115
+ const translatedContent = params2.nodeListHandler.handler({
28116
+ ...params2,
28117
+ nodes: node.elements,
28118
+ path: [...params2.path || [], node]
28119
+ });
28120
+ const sdtPr = params2.extraParams.sdtPr;
28121
+ const id = sdtPr.elements?.find((el) => el.name === "w:id")?.attributes["w:val"] || "";
28122
+ const result = {
28123
+ type: "documentPartObject",
28124
+ content: translatedContent,
28125
+ attrs: {
28126
+ id,
28127
+ docPartGallery: "Table of Contents",
28128
+ docPartUnique: true
28129
+ }
28130
+ };
28131
+ return result;
28137
28132
  };
28138
28133
  const validGalleryTypeMap = {
28139
28134
  "Table of Contents": tableOfContentsHandler
@@ -28791,32 +28786,32 @@ function translateAnchorNode(params2) {
28791
28786
  elements: [...anchorElements, ...elementsWithWrap]
28792
28787
  };
28793
28788
  }
28794
- const XML_NODE_NAME$6 = "wp:anchor";
28795
- const SD_NODE_NAME$6 = ["image"];
28789
+ const XML_NODE_NAME$8 = "wp:anchor";
28790
+ const SD_NODE_NAME$8 = ["image"];
28796
28791
  const validXmlAttributes$6 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28797
- function encode$d(params2) {
28792
+ function encode$f(params2) {
28798
28793
  const { node } = params2.extraParams;
28799
28794
  if (!node || !node.type) {
28800
28795
  return null;
28801
28796
  }
28802
28797
  return handleAnchorNode(params2);
28803
28798
  }
28804
- function decode$d(params2) {
28799
+ function decode$f(params2) {
28805
28800
  const { node } = params2;
28806
28801
  if (!node || !node.type) {
28807
28802
  return null;
28808
28803
  }
28809
28804
  return translateAnchorNode(params2);
28810
28805
  }
28811
- const config$6 = {
28812
- xmlName: XML_NODE_NAME$6,
28813
- sdNodeOrKeyName: SD_NODE_NAME$6,
28806
+ const config$8 = {
28807
+ xmlName: XML_NODE_NAME$8,
28808
+ sdNodeOrKeyName: SD_NODE_NAME$8,
28814
28809
  type: NodeTranslator.translatorTypes.NODE,
28815
- encode: encode$d,
28816
- decode: decode$d,
28810
+ encode: encode$f,
28811
+ decode: decode$f,
28817
28812
  attributes: validXmlAttributes$6
28818
28813
  };
28819
- const translator$6 = NodeTranslator.from(config$6);
28814
+ const translator$8 = NodeTranslator.from(config$8);
28820
28815
  function handleInlineNode(params2) {
28821
28816
  const { node } = params2.extraParams;
28822
28817
  if (node.name !== "wp:inline") {
@@ -28832,41 +28827,41 @@ function translateInlineNode(params2) {
28832
28827
  elements: nodeElements.elements
28833
28828
  };
28834
28829
  }
28835
- const XML_NODE_NAME$5 = "wp:inline";
28836
- const SD_NODE_NAME$5 = ["image"];
28830
+ const XML_NODE_NAME$7 = "wp:inline";
28831
+ const SD_NODE_NAME$7 = ["image"];
28837
28832
  const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28838
- function encode$c(params2) {
28833
+ function encode$e(params2) {
28839
28834
  const { node } = params2.extraParams;
28840
28835
  if (!node || !node.type) {
28841
28836
  return null;
28842
28837
  }
28843
28838
  return handleInlineNode(params2);
28844
28839
  }
28845
- function decode$c(params2) {
28840
+ function decode$e(params2) {
28846
28841
  const { node } = params2;
28847
28842
  if (!node || !node.type) {
28848
28843
  return null;
28849
28844
  }
28850
28845
  return translateInlineNode(params2);
28851
28846
  }
28852
- const config$5 = {
28853
- xmlName: XML_NODE_NAME$5,
28854
- sdNodeOrKeyName: SD_NODE_NAME$5,
28847
+ const config$7 = {
28848
+ xmlName: XML_NODE_NAME$7,
28849
+ sdNodeOrKeyName: SD_NODE_NAME$7,
28855
28850
  type: NodeTranslator.translatorTypes.NODE,
28856
- encode: encode$c,
28857
- decode: decode$c,
28851
+ encode: encode$e,
28852
+ decode: decode$e,
28858
28853
  attributes: validXmlAttributes$5
28859
28854
  };
28860
- const translator$5 = NodeTranslator.from(config$5);
28861
- const XML_NODE_NAME$4 = "w:drawing";
28862
- const SD_NODE_NAME$4 = [];
28855
+ const translator$7 = NodeTranslator.from(config$7);
28856
+ const XML_NODE_NAME$6 = "w:drawing";
28857
+ const SD_NODE_NAME$6 = [];
28863
28858
  const validXmlAttributes$4 = [];
28864
- function encode$b(params2) {
28859
+ function encode$d(params2) {
28865
28860
  const nodes = params2.nodes;
28866
28861
  const node = nodes[0];
28867
28862
  const translatorByChildName = {
28868
- "wp:anchor": translator$6,
28869
- "wp:inline": translator$5
28863
+ "wp:anchor": translator$8,
28864
+ "wp:inline": translator$7
28870
28865
  };
28871
28866
  return node.elements.reduce((acc, child) => {
28872
28867
  if (acc) return acc;
@@ -28875,12 +28870,12 @@ function encode$b(params2) {
28875
28870
  return translator2.encode({ ...params2, extraParams: { node: child } }) || acc;
28876
28871
  }, null);
28877
28872
  }
28878
- function decode$b(params2) {
28873
+ function decode$d(params2) {
28879
28874
  const { node } = params2;
28880
28875
  if (!node || !node.type) {
28881
28876
  return null;
28882
28877
  }
28883
- const childTranslator = node.attrs.isAnchor ? translator$6 : translator$5;
28878
+ const childTranslator = node.attrs.isAnchor ? translator$8 : translator$7;
28884
28879
  const resultNode = childTranslator.decode(params2);
28885
28880
  return wrapTextInRun(
28886
28881
  {
@@ -28890,15 +28885,15 @@ function decode$b(params2) {
28890
28885
  []
28891
28886
  );
28892
28887
  }
28893
- const config$4 = {
28894
- xmlName: XML_NODE_NAME$4,
28895
- sdNodeOrKeyName: SD_NODE_NAME$4,
28888
+ const config$6 = {
28889
+ xmlName: XML_NODE_NAME$6,
28890
+ sdNodeOrKeyName: SD_NODE_NAME$6,
28896
28891
  type: NodeTranslator.translatorTypes.NODE,
28897
- encode: encode$b,
28898
- decode: decode$b,
28892
+ encode: encode$d,
28893
+ decode: decode$d,
28899
28894
  attributes: validXmlAttributes$4
28900
28895
  };
28901
- const translator$4 = NodeTranslator.from(config$4);
28896
+ const translator$6 = NodeTranslator.from(config$6);
28902
28897
  class CommandService {
28903
28898
  /**
28904
28899
  * @param {import('./commands/types/index.js').CommandServiceOptions} props
@@ -30236,7 +30231,7 @@ function prepareTextAnnotation(params2) {
30236
30231
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params2);
30237
30232
  }
30238
30233
  function prepareImageAnnotation(params2, imageSize) {
30239
- return translator$4.decode({
30234
+ return translator$6.decode({
30240
30235
  ...params2,
30241
30236
  imageSize
30242
30237
  });
@@ -30456,6 +30451,49 @@ const generateSdtPrTagForDocumentSection = (id, title, tag) => {
30456
30451
  ]
30457
30452
  };
30458
30453
  };
30454
+ function translateDocumentPartObj(params2) {
30455
+ const { node } = params2;
30456
+ const { attrs = {} } = node;
30457
+ const childContent = translateChildNodes({ ...params2, nodes: node.content });
30458
+ const nodeElements = [
30459
+ {
30460
+ name: "w:sdtPr",
30461
+ elements: [
30462
+ {
30463
+ name: "w:id",
30464
+ attributes: {
30465
+ "w:val": attrs.id
30466
+ }
30467
+ },
30468
+ {
30469
+ name: "w:docPartObj",
30470
+ elements: [
30471
+ {
30472
+ name: "w:docPartGallery",
30473
+ attributes: {
30474
+ "w:val": attrs.docPartGallery
30475
+ }
30476
+ },
30477
+ ...attrs.docPartUnique ? [
30478
+ {
30479
+ name: "w:docPartUnique"
30480
+ }
30481
+ ] : []
30482
+ ]
30483
+ }
30484
+ ]
30485
+ },
30486
+ {
30487
+ name: "w:sdtContent",
30488
+ elements: childContent
30489
+ }
30490
+ ];
30491
+ const result = {
30492
+ name: "w:sdt",
30493
+ elements: nodeElements
30494
+ };
30495
+ return result;
30496
+ }
30459
30497
  function translateStructuredContent(params2) {
30460
30498
  const { node } = params2;
30461
30499
  const childContent = translateChildNodes({ ...params2, nodes: node.content });
@@ -30507,10 +30545,10 @@ function generateSdtPrTagForStructuredContent({ node }) {
30507
30545
  };
30508
30546
  return result;
30509
30547
  }
30510
- const XML_NODE_NAME$3 = "w:sdt";
30511
- const SD_NODE_NAME$3 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30548
+ const XML_NODE_NAME$5 = "w:sdt";
30549
+ const SD_NODE_NAME$5 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30512
30550
  const validXmlAttributes$3 = [];
30513
- function encode$a(params2) {
30551
+ function encode$c(params2) {
30514
30552
  const nodes = params2.nodes;
30515
30553
  const node = nodes[0];
30516
30554
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -30520,7 +30558,7 @@ function encode$a(params2) {
30520
30558
  const result = handler2(params2);
30521
30559
  return result;
30522
30560
  }
30523
- function decode$a(params2) {
30561
+ function decode$c(params2) {
30524
30562
  const { node } = params2;
30525
30563
  if (!node || !node.type) {
30526
30564
  return null;
@@ -30530,91 +30568,93 @@ function decode$a(params2) {
30530
30568
  structuredContent: () => translateStructuredContent(params2),
30531
30569
  structuredContentBlock: () => translateStructuredContent(params2),
30532
30570
  documentSection: () => translateDocumentSection(params2),
30571
+ documentPartObject: () => translateDocumentPartObj(params2),
30572
+ // Handled in doc-part-obj translator
30533
30573
  default: () => null
30534
30574
  };
30535
30575
  const decoder = types2[node.type] ?? types2.default;
30536
30576
  const result = decoder();
30537
30577
  return result;
30538
30578
  }
30539
- const config$3 = {
30540
- xmlName: XML_NODE_NAME$3,
30541
- sdNodeOrKeyName: SD_NODE_NAME$3,
30579
+ const config$5 = {
30580
+ xmlName: XML_NODE_NAME$5,
30581
+ sdNodeOrKeyName: SD_NODE_NAME$5,
30542
30582
  type: NodeTranslator.translatorTypes.NODE,
30543
- encode: encode$a,
30544
- decode: decode$a,
30583
+ encode: encode$c,
30584
+ decode: decode$c,
30545
30585
  attributes: validXmlAttributes$3
30546
30586
  };
30547
- const translator$3 = NodeTranslator.from(config$3);
30548
- const encode$9 = (attributes) => {
30587
+ const translator$5 = NodeTranslator.from(config$5);
30588
+ const encode$b = (attributes) => {
30549
30589
  return attributes["w:id"];
30550
30590
  };
30551
- const decode$9 = (attrs) => {
30591
+ const decode$b = (attrs) => {
30552
30592
  return attrs.id;
30553
30593
  };
30554
30594
  const attrConfig$6 = Object.freeze({
30555
30595
  xmlName: "w:id",
30556
30596
  sdName: "id",
30557
- encode: encode$9,
30558
- decode: decode$9
30597
+ encode: encode$b,
30598
+ decode: decode$b
30559
30599
  });
30560
- const encode$8 = (attributes) => {
30600
+ const encode$a = (attributes) => {
30561
30601
  return attributes["w:name"];
30562
30602
  };
30563
- const decode$8 = (attrs) => {
30603
+ const decode$a = (attrs) => {
30564
30604
  return attrs.name;
30565
30605
  };
30566
30606
  const attrConfig$5 = Object.freeze({
30567
30607
  xmlName: "w:name",
30568
30608
  sdName: "name",
30569
- encode: encode$8,
30570
- decode: decode$8
30609
+ encode: encode$a,
30610
+ decode: decode$a
30571
30611
  });
30572
- const encode$7 = (attributes) => {
30612
+ const encode$9 = (attributes) => {
30573
30613
  return attributes["w:colFirst"];
30574
30614
  };
30575
- const decode$7 = (attrs) => {
30615
+ const decode$9 = (attrs) => {
30576
30616
  return attrs.colFirst;
30577
30617
  };
30578
30618
  const attrConfig$4 = Object.freeze({
30579
30619
  xmlName: "w:colFirst",
30580
30620
  sdName: "colFirst",
30581
- encode: encode$7,
30582
- decode: decode$7
30621
+ encode: encode$9,
30622
+ decode: decode$9
30583
30623
  });
30584
- const encode$6 = (attributes) => {
30624
+ const encode$8 = (attributes) => {
30585
30625
  return attributes["w:colLast"];
30586
30626
  };
30587
- const decode$6 = (attrs) => {
30627
+ const decode$8 = (attrs) => {
30588
30628
  return attrs.colLast;
30589
30629
  };
30590
30630
  const attrConfig$3 = Object.freeze({
30591
30631
  xmlName: "w:colLast",
30592
30632
  sdName: "colLast",
30593
- encode: encode$6,
30594
- decode: decode$6
30633
+ encode: encode$8,
30634
+ decode: decode$8
30595
30635
  });
30596
- const encode$5 = (attributes) => {
30636
+ const encode$7 = (attributes) => {
30597
30637
  return attributes["w:displacedByCustomXml"];
30598
30638
  };
30599
- const decode$5 = (attrs) => {
30639
+ const decode$7 = (attrs) => {
30600
30640
  return attrs.displacedByCustomXml;
30601
30641
  };
30602
30642
  const attrConfig$2 = Object.freeze({
30603
30643
  xmlName: "w:displacedByCustomXml",
30604
30644
  sdName: "displacedByCustomXml",
30605
- encode: encode$5,
30606
- decode: decode$5
30645
+ encode: encode$7,
30646
+ decode: decode$7
30607
30647
  });
30608
30648
  const validXmlAttributes$2 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
30609
- const XML_NODE_NAME$2 = "w:bookmarkStart";
30610
- const SD_NODE_NAME$2 = "bookmarkStart";
30611
- const encode$4 = (params2, encodedAttrs = {}) => {
30649
+ const XML_NODE_NAME$4 = "w:bookmarkStart";
30650
+ const SD_NODE_NAME$4 = "bookmarkStart";
30651
+ const encode$6 = (params2, encodedAttrs = {}) => {
30612
30652
  return {
30613
30653
  type: "bookmarkStart",
30614
30654
  attrs: encodedAttrs
30615
30655
  };
30616
30656
  };
30617
- const decode$4 = (params2, decodedAttrs = {}) => {
30657
+ const decode$6 = (params2, decodedAttrs = {}) => {
30618
30658
  const result = {
30619
30659
  name: "w:bookmarkStart",
30620
30660
  elements: []
@@ -30624,49 +30664,49 @@ const decode$4 = (params2, decodedAttrs = {}) => {
30624
30664
  }
30625
30665
  return result;
30626
30666
  };
30627
- const config$2 = {
30628
- xmlName: XML_NODE_NAME$2,
30629
- sdNodeOrKeyName: SD_NODE_NAME$2,
30667
+ const config$4 = {
30668
+ xmlName: XML_NODE_NAME$4,
30669
+ sdNodeOrKeyName: SD_NODE_NAME$4,
30630
30670
  type: NodeTranslator.translatorTypes.NODE,
30631
- encode: encode$4,
30632
- decode: decode$4,
30671
+ encode: encode$6,
30672
+ decode: decode$6,
30633
30673
  attributes: validXmlAttributes$2
30634
30674
  };
30635
- const translator$2 = NodeTranslator.from(config$2);
30636
- const encode$3 = (attributes) => {
30675
+ const translator$4 = NodeTranslator.from(config$4);
30676
+ const encode$5 = (attributes) => {
30637
30677
  return attributes["w:id"];
30638
30678
  };
30639
- const decode$3 = (attrs) => {
30679
+ const decode$5 = (attrs) => {
30640
30680
  return attrs.id;
30641
30681
  };
30642
30682
  const attrConfig$1 = Object.freeze({
30643
30683
  xmlName: "w:id",
30644
30684
  sdName: "id",
30645
- encode: encode$3,
30646
- decode: decode$3
30685
+ encode: encode$5,
30686
+ decode: decode$5
30647
30687
  });
30648
- const encode$2 = (attributes) => {
30688
+ const encode$4 = (attributes) => {
30649
30689
  return attributes["w:displacedByCustomXml"];
30650
30690
  };
30651
- const decode$2 = (attrs) => {
30691
+ const decode$4 = (attrs) => {
30652
30692
  return attrs.displacedByCustomXml;
30653
30693
  };
30654
30694
  const attrConfig = Object.freeze({
30655
30695
  xmlName: "w:displacedByCustomXml",
30656
30696
  sdName: "displacedByCustomXml",
30657
- encode: encode$2,
30658
- decode: decode$2
30697
+ encode: encode$4,
30698
+ decode: decode$4
30659
30699
  });
30660
30700
  const validXmlAttributes$1 = [attrConfig$1, attrConfig];
30661
- const XML_NODE_NAME$1 = "w:bookmarkEnd";
30662
- const SD_NODE_NAME$1 = "bookmarkEnd";
30663
- const encode$1 = (params2, encodedAttrs = {}) => {
30701
+ const XML_NODE_NAME$3 = "w:bookmarkEnd";
30702
+ const SD_NODE_NAME$3 = "bookmarkEnd";
30703
+ const encode$3 = (params2, encodedAttrs = {}) => {
30664
30704
  return {
30665
30705
  type: "bookmarkEnd",
30666
30706
  attrs: encodedAttrs
30667
30707
  };
30668
30708
  };
30669
- const decode$1 = (params2, decodedAttrs = {}) => {
30709
+ const decode$3 = (params2, decodedAttrs = {}) => {
30670
30710
  const result = {
30671
30711
  name: "w:bookmarkEnd",
30672
30712
  elements: []
@@ -30676,19 +30716,19 @@ const decode$1 = (params2, decodedAttrs = {}) => {
30676
30716
  }
30677
30717
  return result;
30678
30718
  };
30679
- const config$1 = {
30680
- xmlName: XML_NODE_NAME$1,
30681
- sdNodeOrKeyName: SD_NODE_NAME$1,
30719
+ const config$3 = {
30720
+ xmlName: XML_NODE_NAME$3,
30721
+ sdNodeOrKeyName: SD_NODE_NAME$3,
30682
30722
  type: NodeTranslator.translatorTypes.NODE,
30683
- encode: encode$1,
30684
- decode: decode$1,
30723
+ encode: encode$3,
30724
+ decode: decode$3,
30685
30725
  attributes: validXmlAttributes$1
30686
30726
  };
30687
- const translator$1 = NodeTranslator.from(config$1);
30688
- const XML_NODE_NAME = "mc:AlternateContent";
30689
- const SD_NODE_NAME = [];
30727
+ const translator$3 = NodeTranslator.from(config$3);
30728
+ const XML_NODE_NAME$2 = "mc:AlternateContent";
30729
+ const SD_NODE_NAME$2 = [];
30690
30730
  const validXmlAttributes = [];
30691
- function encode$19(params2) {
30731
+ function encode$2(params2) {
30692
30732
  const { nodeListHandler } = params2;
30693
30733
  const { node } = params2.extraParams;
30694
30734
  if (!node || !node.type) {
@@ -30708,7 +30748,7 @@ function encode$19(params2) {
30708
30748
  path: [...params2.path || [], wpsNode]
30709
30749
  });
30710
30750
  }
30711
- function decode(params2) {
30751
+ function decode$2(params2) {
30712
30752
  const { node } = params2;
30713
30753
  const { drawingContent } = node.attrs;
30714
30754
  const drawing = {
@@ -30725,13 +30765,186 @@ function decode(params2) {
30725
30765
  elements: [choice]
30726
30766
  };
30727
30767
  }
30768
+ const config$2 = {
30769
+ xmlName: XML_NODE_NAME$2,
30770
+ sdNodeOrKeyName: SD_NODE_NAME$2,
30771
+ type: NodeTranslator.translatorTypes.NODE,
30772
+ encode: encode$2,
30773
+ decode: decode$2,
30774
+ attributes: validXmlAttributes
30775
+ };
30776
+ const translator$2 = NodeTranslator.from(config$2);
30777
+ const XML_NODE_NAME$1 = "sd:pageReference";
30778
+ const SD_NODE_NAME$1 = "pageReference";
30779
+ const encode$1 = (params2, _2) => {
30780
+ const { nodes = [], nodeListHandler } = params2 || {};
30781
+ const node = nodes[0];
30782
+ const processedText = nodeListHandler.handler({
30783
+ ...params2,
30784
+ nodes: node.elements
30785
+ });
30786
+ const processedNode = {
30787
+ type: "pageReference",
30788
+ attrs: {
30789
+ instruction: node.attributes?.instruction || "",
30790
+ marksAsAttrs: node.marks || []
30791
+ },
30792
+ content: processedText
30793
+ };
30794
+ return processedNode;
30795
+ };
30796
+ const decode$1 = (params2, _2) => {
30797
+ const { node } = params2;
30798
+ const outputMarks = processOutputMarks(node.attrs?.marksAsAttrs || []);
30799
+ const contentNodes = (node.content ?? []).flatMap((n) => exportSchemaToJson({ ...params2, node: n }));
30800
+ const translated = [
30801
+ {
30802
+ name: "w:r",
30803
+ elements: [
30804
+ {
30805
+ name: "w:rPr",
30806
+ elements: outputMarks
30807
+ },
30808
+ {
30809
+ name: "w:fldChar",
30810
+ attributes: {
30811
+ "w:fldCharType": "begin"
30812
+ }
30813
+ }
30814
+ ]
30815
+ },
30816
+ {
30817
+ name: "w:r",
30818
+ elements: [
30819
+ {
30820
+ name: "w:rPr",
30821
+ elements: outputMarks
30822
+ },
30823
+ {
30824
+ name: "w:instrText",
30825
+ attributes: { "xml:space": "preserve" },
30826
+ elements: [
30827
+ {
30828
+ type: "text",
30829
+ text: `${node.attrs.instruction}`
30830
+ }
30831
+ ]
30832
+ }
30833
+ ]
30834
+ },
30835
+ {
30836
+ name: "w:r",
30837
+ elements: [
30838
+ {
30839
+ name: "w:rPr",
30840
+ elements: outputMarks
30841
+ },
30842
+ {
30843
+ name: "w:fldChar",
30844
+ attributes: {
30845
+ "w:fldCharType": "separate"
30846
+ }
30847
+ }
30848
+ ]
30849
+ },
30850
+ ...contentNodes,
30851
+ {
30852
+ name: "w:r",
30853
+ elements: [
30854
+ {
30855
+ name: "w:rPr",
30856
+ elements: outputMarks
30857
+ },
30858
+ {
30859
+ name: "w:fldChar",
30860
+ attributes: {
30861
+ "w:fldCharType": "end"
30862
+ }
30863
+ }
30864
+ ]
30865
+ }
30866
+ ];
30867
+ return translated;
30868
+ };
30869
+ const config$1 = {
30870
+ xmlName: XML_NODE_NAME$1,
30871
+ sdNodeOrKeyName: SD_NODE_NAME$1,
30872
+ type: NodeTranslator.translatorTypes.NODE,
30873
+ encode: encode$1,
30874
+ decode: decode$1
30875
+ };
30876
+ const translator$1 = NodeTranslator.from(config$1);
30877
+ const XML_NODE_NAME = "sd:tableOfContents";
30878
+ const SD_NODE_NAME = "tableOfContents";
30879
+ const encode$1c = (params2, _2) => {
30880
+ const { nodes = [], nodeListHandler } = params2 || {};
30881
+ const node = nodes[0];
30882
+ const processedContent = nodeListHandler.handler({
30883
+ ...params2,
30884
+ nodes: node.elements || []
30885
+ });
30886
+ const processedNode = {
30887
+ type: "tableOfContents",
30888
+ attrs: {
30889
+ instruction: node.attributes?.instruction || ""
30890
+ },
30891
+ content: processedContent
30892
+ };
30893
+ return processedNode;
30894
+ };
30895
+ const decode = (params2, _2) => {
30896
+ const { node } = params2;
30897
+ const contentNodes = node.content.map((n) => exportSchemaToJson({ ...params2, node: n }));
30898
+ const tocBeginElements = [
30899
+ {
30900
+ name: "w:r",
30901
+ elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "begin" }, elements: [] }]
30902
+ },
30903
+ {
30904
+ name: "w:r",
30905
+ elements: [
30906
+ {
30907
+ name: "w:instrText",
30908
+ attributes: { "xml:space": "preserve" },
30909
+ elements: [{ text: node.attrs?.instruction || "", type: "text", name: "#text", elements: [] }]
30910
+ }
30911
+ ]
30912
+ },
30913
+ { name: "w:r", elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "separate" }, elements: [] }] }
30914
+ ];
30915
+ if (contentNodes.length > 0) {
30916
+ const firstParagraph = contentNodes[0];
30917
+ let insertIndex = 0;
30918
+ if (firstParagraph.elements) {
30919
+ const pPrIndex = firstParagraph.elements.findIndex((el) => el.name === "w:pPr");
30920
+ insertIndex = pPrIndex >= 0 ? pPrIndex + 1 : 0;
30921
+ } else {
30922
+ firstParagraph.elements = [];
30923
+ }
30924
+ firstParagraph.elements.splice(insertIndex, 0, ...tocBeginElements);
30925
+ } else {
30926
+ contentNodes.push({
30927
+ name: "w:p",
30928
+ elements: tocBeginElements
30929
+ });
30930
+ }
30931
+ const tocEndElements = [
30932
+ { name: "w:r", elements: [{ name: "w:fldChar", attributes: { "w:fldCharType": "end" }, elements: [] }] }
30933
+ ];
30934
+ const lastParagraph = contentNodes[contentNodes.length - 1];
30935
+ if (lastParagraph.elements) {
30936
+ lastParagraph.elements.push(...tocEndElements);
30937
+ } else {
30938
+ lastParagraph.elements = [...tocEndElements];
30939
+ }
30940
+ return contentNodes;
30941
+ };
30728
30942
  const config = {
30729
30943
  xmlName: XML_NODE_NAME,
30730
30944
  sdNodeOrKeyName: SD_NODE_NAME,
30731
30945
  type: NodeTranslator.translatorTypes.NODE,
30732
- encode: encode$19,
30733
- decode,
30734
- attributes: validXmlAttributes
30946
+ encode: encode$1c,
30947
+ decode
30735
30948
  };
30736
30949
  const translator = NodeTranslator.from(config);
30737
30950
  const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
@@ -30805,32 +31018,35 @@ function exportSchemaToJson(params2) {
30805
31018
  doc: translateDocumentNode,
30806
31019
  body: translateBodyNode,
30807
31020
  heading: translateHeadingNode,
30808
- paragraph: translator$13,
30809
- run: translator$U,
31021
+ paragraph: translator$16,
31022
+ run: translator$V,
30810
31023
  text: translateTextNode,
30811
31024
  bulletList: translateList,
30812
31025
  orderedList: translateList,
30813
- lineBreak: translator$16,
30814
- table: translator$9,
30815
- tableRow: translator$G,
30816
- tableCell: translator$8,
30817
- bookmarkStart: translator$2,
30818
- bookmarkEnd: translator$1,
30819
- fieldAnnotation: translator$3,
30820
- tab: translator$14,
30821
- image: translator$4,
30822
- hardBreak: translator$16,
31026
+ lineBreak: translator$19,
31027
+ table: translator$a,
31028
+ tableRow: translator$H,
31029
+ tableCell: translator$9,
31030
+ bookmarkStart: translator$4,
31031
+ bookmarkEnd: translator$3,
31032
+ fieldAnnotation: translator$5,
31033
+ tab: translator$17,
31034
+ image: translator$6,
31035
+ hardBreak: translator$19,
30823
31036
  commentRangeStart: () => translateCommentNode(params2, "Start"),
30824
31037
  commentRangeEnd: () => translateCommentNode(params2, "End"),
30825
31038
  commentReference: () => null,
30826
31039
  shapeContainer: translateShapeContainer,
30827
31040
  shapeTextbox: translateShapeTextbox,
30828
31041
  contentBlock: translateContentBlock,
30829
- structuredContent: translator$3,
30830
- structuredContentBlock: translator$3,
30831
- documentSection: translator$3,
31042
+ structuredContent: translator$5,
31043
+ structuredContentBlock: translator$5,
31044
+ documentPartObject: translator$5,
31045
+ documentSection: translator$5,
30832
31046
  "page-number": translatePageNumberNode,
30833
- "total-page-number": translateTotalPageNumberNode
31047
+ "total-page-number": translateTotalPageNumberNode,
31048
+ pageReference: translator$1,
31049
+ tableOfContents: translator
30834
31050
  };
30835
31051
  let handler2 = router[type2];
30836
31052
  if (handler2 && "decode" in handler2 && typeof handler2.decode === "function") {
@@ -31168,8 +31384,6 @@ function translateTextNode(params2) {
31168
31384
  const trackedMarks = [TrackInsertMarkName, TrackDeleteMarkName];
31169
31385
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
31170
31386
  if (isTrackedNode) return translateTrackedNode(params2);
31171
- const isLinkNode = node.marks?.some((m2) => m2.type === "link");
31172
- if (isLinkNode) return translator$7.decode(params2);
31173
31387
  const { text, marks = [] } = node;
31174
31388
  return getTextNodeForExport(text, marks, params2);
31175
31389
  }
@@ -31475,7 +31689,7 @@ function translateMark(mark) {
31475
31689
  markElement.type = "element";
31476
31690
  break;
31477
31691
  case "underline": {
31478
- const translated = translator$10.decode({
31692
+ const translated = translator$13.decode({
31479
31693
  node: {
31480
31694
  attrs: {
31481
31695
  underlineType: attrs.underlineType ?? attrs.underline ?? null,
@@ -31539,7 +31753,7 @@ function translateMark(mark) {
31539
31753
  break;
31540
31754
  case "highlight": {
31541
31755
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
31542
- const translated = translator$15.decode({ node: { attrs: { highlight: highlightValue } } });
31756
+ const translated = translator$18.decode({ node: { attrs: { highlight: highlightValue } } });
31543
31757
  return translated || {};
31544
31758
  }
31545
31759
  }
@@ -31567,7 +31781,7 @@ function translateShapeContainer(params2) {
31567
31781
  const pict = {
31568
31782
  name: "w:pict",
31569
31783
  attributes: {
31570
- "w14:anchorId": Math.floor(Math.random() * 4294967295).toString()
31784
+ "w14:anchorId": generateRandomSigned32BitIntStrId()
31571
31785
  },
31572
31786
  elements: [shape]
31573
31787
  };
@@ -31599,7 +31813,7 @@ function translateContentBlock(params2) {
31599
31813
  if (vmlAttributes || horizontalRule) {
31600
31814
  return translateVRectContentBlock(params2);
31601
31815
  }
31602
- const alternateContent = translator.decode(params2);
31816
+ const alternateContent = translator$2.decode(params2);
31603
31817
  return wrapTextInRun(alternateContent);
31604
31818
  }
31605
31819
  function translateVRectContentBlock(params2) {
@@ -31634,7 +31848,7 @@ function translateVRectContentBlock(params2) {
31634
31848
  const pict = {
31635
31849
  name: "w:pict",
31636
31850
  attributes: {
31637
- "w14:anchorId": Math.floor(Math.random() * 4294967295).toString()
31851
+ "w14:anchorId": generateRandomSigned32BitIntStrId()
31638
31852
  },
31639
31853
  elements: [rect]
31640
31854
  };
@@ -31744,6 +31958,7 @@ const getAutoPageJson = (type2, outputMarks = []) => {
31744
31958
  },
31745
31959
  {
31746
31960
  name: "w:instrText",
31961
+ attributes: { "xml:space": "preserve" },
31747
31962
  elements: [
31748
31963
  {
31749
31964
  type: "text",
@@ -31803,7 +32018,7 @@ const handleDrawingNode = (params2) => {
31803
32018
  if (mainNode.name === "w:drawing") node = mainNode;
31804
32019
  else node = mainNode.elements.find((el) => el.name === "w:drawing");
31805
32020
  if (!node) return { nodes: [], consumed: 0 };
31806
- const schemaNode = translator$4.encode(params2);
32021
+ const schemaNode = translator$6.encode(params2);
31807
32022
  const newNodes = schemaNode ? [schemaNode] : [];
31808
32023
  return { nodes: newNodes, consumed: 1 };
31809
32024
  };
@@ -31905,8 +32120,8 @@ const trackChangeNodeHandlerEntity = {
31905
32120
  handlerName: "trackChangeNodeHandler",
31906
32121
  handler: handleTrackChangeNode
31907
32122
  };
31908
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$7);
31909
- const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$U);
32123
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$W);
32124
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$V);
31910
32125
  const handleTextNode = (params2) => {
31911
32126
  const { nodes, insideTrackChange } = params2;
31912
32127
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -31947,7 +32162,7 @@ const handleParagraphNode = (params2) => {
31947
32162
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
31948
32163
  return { nodes: [], consumed: 0 };
31949
32164
  }
31950
- const schemaNode = translator$13.encode(params2);
32165
+ const schemaNode = translator$16.encode(params2);
31951
32166
  const newNodes = schemaNode ? [schemaNode] : [];
31952
32167
  return { nodes: newNodes, consumed: 1 };
31953
32168
  };
@@ -31960,7 +32175,7 @@ const handleSdtNode = (params2) => {
31960
32175
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
31961
32176
  return { nodes: [], consumed: 0 };
31962
32177
  }
31963
- const result = translator$3.encode(params2);
32178
+ const result = translator$5.encode(params2);
31964
32179
  if (!result) {
31965
32180
  return { nodes: [], consumed: 0 };
31966
32181
  }
@@ -32050,7 +32265,7 @@ const handler = (params2) => {
32050
32265
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
32051
32266
  return { nodes: [], consumed: 0 };
32052
32267
  }
32053
- const result = translator$16.encode(params2);
32268
+ const result = translator$19.encode(params2);
32054
32269
  if (!result) return { nodes: [], consumed: 0 };
32055
32270
  return {
32056
32271
  nodes: [result],
@@ -32122,7 +32337,7 @@ const handleBookmarkStartNode = (params2) => {
32122
32337
  if (isCustomMarkBookmark(nodes[0], params2.editor)) {
32123
32338
  return handleBookmarkNode(params2);
32124
32339
  }
32125
- const node = translator$2.encode(params2);
32340
+ const node = translator$4.encode(params2);
32126
32341
  if (!node) return { nodes: [], consumed: 0 };
32127
32342
  return { nodes: [node], consumed: 1 };
32128
32343
  };
@@ -32154,7 +32369,7 @@ const handleBookmarkEndNode = (params2) => {
32154
32369
  if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
32155
32370
  return { nodes: [], consumed: 0 };
32156
32371
  }
32157
- const node = translator$1.encode(params2);
32372
+ const node = translator$3.encode(params2);
32158
32373
  if (!node) return { nodes: [], consumed: 0 };
32159
32374
  return { nodes: [node], consumed: 1 };
32160
32375
  };
@@ -32287,6 +32502,7 @@ const autoTotalPageCountEntity = {
32287
32502
  handlerName: "autoTotalPageCountEntity",
32288
32503
  handler: handleAutoTotalPageNumber
32289
32504
  };
32505
+ const pageReferenceEntity = generateV2HandlerEntity("pageReferenceNodeHandler", translator$1);
32290
32506
  const handlePictNode = (params2) => {
32291
32507
  const { nodes } = params2;
32292
32508
  if (!nodes.length || nodes[0].name !== "w:p") {
@@ -32785,6 +33001,7 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32785
33001
  const spacing = pPr?.elements?.find((el) => el.name === "w:spacing");
32786
33002
  const justify = pPr?.elements?.find((el) => el.name === "w:jc");
32787
33003
  const indent = pPr?.elements?.find((el) => el.name === "w:ind");
33004
+ const tabs = pPr?.elements?.find((el) => el.name === "w:tabs");
32788
33005
  let lineSpaceBefore, lineSpaceAfter, line;
32789
33006
  if (spacing) {
32790
33007
  lineSpaceBefore = twipsToPixels(spacing?.attributes["w:before"]);
@@ -32798,6 +33015,22 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32798
33015
  rightIndent = twipsToPixels(indent?.attributes["w:right"]);
32799
33016
  firstLine = twipsToPixels(indent?.attributes["w:firstLine"]);
32800
33017
  }
33018
+ let tabStops = [];
33019
+ if (tabs) {
33020
+ tabStops = (tabs.elements || []).filter((el) => el.name === "w:tab").map((tab) => {
33021
+ let val = tab.attributes["w:val"];
33022
+ if (val == "left") {
33023
+ val = "start";
33024
+ } else if (val == "right") {
33025
+ val = "end";
33026
+ }
33027
+ return {
33028
+ val,
33029
+ pos: twipsToPixels(tab.attributes["w:pos"]),
33030
+ leader: tab.attributes["w:leader"]
33031
+ };
33032
+ });
33033
+ }
32801
33034
  const keepNext = pPr?.elements?.find((el) => el.name === "w:keepNext");
32802
33035
  const keepLines = pPr?.elements?.find((el) => el.name === "w:keepLines");
32803
33036
  const outlineLevel = pPr?.elements?.find((el) => el.name === "w:outlineLvl");
@@ -32830,7 +33063,8 @@ const getDefaultStyleDefinition = (defaultStyleId, docx) => {
32830
33063
  const parsedStyles = {
32831
33064
  spacing: { lineSpaceAfter, lineSpaceBefore, line },
32832
33065
  textAlign,
32833
- indent: { leftIndent, rightIndent, firstLine }
33066
+ indent: { leftIndent, rightIndent, firstLine },
33067
+ tabStops: tabStops.length > 0 ? tabStops : null
32834
33068
  };
32835
33069
  parsedMarks.forEach((mark) => {
32836
33070
  const { type: type2, attrs } = mark;
@@ -32854,13 +33088,213 @@ const handleTabNode = (params2) => {
32854
33088
  if (!nodes.length || nodes[0].name !== "w:tab") {
32855
33089
  return { nodes: [], consumed: 0 };
32856
33090
  }
32857
- const node = translator$14.encode(params2);
33091
+ const node = translator$17.encode(params2);
32858
33092
  return { nodes: [node], consumed: 1 };
32859
33093
  };
32860
33094
  const tabNodeEntityHandler = {
32861
33095
  handlerName: "w:tabTranslator",
32862
33096
  handler: handleTabNode
32863
33097
  };
33098
+ const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator);
33099
+ function preProcessPageInstruction(nodesToCombine, _2, __) {
33100
+ const pageNumNode = {
33101
+ name: "sd:autoPageNumber",
33102
+ type: "element"
33103
+ };
33104
+ nodesToCombine.forEach((n) => {
33105
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
33106
+ if (rPrNode) pageNumNode.elements = [rPrNode];
33107
+ });
33108
+ return [pageNumNode];
33109
+ }
33110
+ function preProcessNumPagesInstruction(nodesToCombine, _2, __) {
33111
+ const totalPageNumNode = {
33112
+ name: "sd:totalPageNumber",
33113
+ type: "element"
33114
+ };
33115
+ nodesToCombine.forEach((n) => {
33116
+ const rPrNode = n.elements?.find((el) => el.name === "w:rPr");
33117
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
33118
+ });
33119
+ return [totalPageNumNode];
33120
+ }
33121
+ function preProcessPageRefInstruction(nodesToCombine, instrText, _2) {
33122
+ const pageRefNode = {
33123
+ name: "sd:pageReference",
33124
+ type: "element",
33125
+ attributes: {
33126
+ instruction: instrText
33127
+ },
33128
+ elements: nodesToCombine
33129
+ };
33130
+ return [pageRefNode];
33131
+ }
33132
+ function preProcessHyperlinkInstruction(nodesToCombine, instruction, docx) {
33133
+ const urlMatch = instruction.match(/HYPERLINK\s+"([^"]+)"/);
33134
+ let linkAttributes;
33135
+ if (urlMatch && urlMatch.length >= 2) {
33136
+ const url = urlMatch[1];
33137
+ const rels = docx["word/_rels/document.xml.rels"];
33138
+ const relationships = rels?.elements.find((el) => el.name === "Relationships");
33139
+ if (relationships) {
33140
+ const rId = generateDocxRandomId();
33141
+ relationships.elements.push({
33142
+ type: "element",
33143
+ name: "Relationship",
33144
+ attributes: {
33145
+ Id: rId,
33146
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
33147
+ Target: url,
33148
+ TargetMode: "External"
33149
+ }
33150
+ });
33151
+ linkAttributes = { "r:id": rId };
33152
+ } else {
33153
+ linkAttributes = { "w:anchor": url };
33154
+ }
33155
+ } else {
33156
+ const availableSwitches = {
33157
+ "w:anchor": `l "(?<value>[^"]+)"`,
33158
+ new_window: `
33159
+ `,
33160
+ "w:tgtFrame": ` "(?<value>[^"]+)"`,
33161
+ "w:tooltip": `o "(?<value>[^"]+)"`
33162
+ };
33163
+ const parsedSwitches = {};
33164
+ for (const [key2, regex] of Object.entries(availableSwitches)) {
33165
+ const match = instruction.match(new RegExp(regex));
33166
+ if (match) {
33167
+ parsedSwitches[key2] = match.groups?.value || true;
33168
+ }
33169
+ }
33170
+ if (parsedSwitches.new_window) {
33171
+ parsedSwitches["w:tgtFrame"] = "_blank";
33172
+ delete parsedSwitches.new_window;
33173
+ }
33174
+ linkAttributes = { ...parsedSwitches };
33175
+ }
33176
+ return [
33177
+ {
33178
+ name: "w:hyperlink",
33179
+ type: "element",
33180
+ attributes: linkAttributes,
33181
+ elements: nodesToCombine
33182
+ }
33183
+ ];
33184
+ }
33185
+ function preProcessTocInstruction(nodesToCombine, instrText) {
33186
+ return [
33187
+ {
33188
+ name: "sd:tableOfContents",
33189
+ type: "element",
33190
+ attributes: {
33191
+ instruction: instrText
33192
+ },
33193
+ elements: nodesToCombine
33194
+ }
33195
+ ];
33196
+ }
33197
+ const getInstructionPreProcessor = (instruction) => {
33198
+ const instructionType = instruction.split(" ")[0];
33199
+ switch (instructionType) {
33200
+ case "PAGE":
33201
+ return preProcessPageInstruction;
33202
+ case "NUMPAGES":
33203
+ return preProcessNumPagesInstruction;
33204
+ case "PAGEREF":
33205
+ return preProcessPageRefInstruction;
33206
+ case "HYPERLINK":
33207
+ return preProcessHyperlinkInstruction;
33208
+ case "TOC":
33209
+ return preProcessTocInstruction;
33210
+ default:
33211
+ return null;
33212
+ }
33213
+ };
33214
+ const preProcessNodesForFldChar = (nodes = [], docx) => {
33215
+ const processedNodes = [];
33216
+ let collectedNodesStack = [];
33217
+ let currentFieldStack = [];
33218
+ let unpairedEnd = null;
33219
+ let collecting = false;
33220
+ const finalizeField = () => {
33221
+ if (collecting) {
33222
+ const collectedNodes = collectedNodesStack.pop().filter((n) => n !== null);
33223
+ const currentField = currentFieldStack.pop();
33224
+ const combined = _processCombinedNodesForFldChar(collectedNodes, currentField.instrText.trim(), docx);
33225
+ if (collectedNodesStack.length === 0) {
33226
+ processedNodes.push(...combined);
33227
+ } else {
33228
+ collectedNodesStack[collectedNodesStack.length - 1].push(...combined);
33229
+ }
33230
+ } else {
33231
+ unpairedEnd = true;
33232
+ }
33233
+ };
33234
+ for (const node of nodes) {
33235
+ const fldCharEl = node.elements?.find((el) => el.name === "w:fldChar");
33236
+ const fldType = fldCharEl?.attributes?.["w:fldCharType"];
33237
+ const instrTextEl = node.elements?.find((el) => el.name === "w:instrText");
33238
+ collecting = collectedNodesStack.length > 0;
33239
+ if (fldType === "begin") {
33240
+ collectedNodesStack.push([null]);
33241
+ currentFieldStack.push({ instrText: "" });
33242
+ continue;
33243
+ }
33244
+ if (instrTextEl && collecting && currentFieldStack.length > 0) {
33245
+ currentFieldStack[currentFieldStack.length - 1].instrText += (instrTextEl.elements?.[0]?.text || "") + " ";
33246
+ continue;
33247
+ }
33248
+ if (fldType === "end") {
33249
+ finalizeField();
33250
+ continue;
33251
+ } else if (fldType === "separate") {
33252
+ continue;
33253
+ }
33254
+ if (Array.isArray(node.elements)) {
33255
+ const childResult = preProcessNodesForFldChar(node.elements, docx);
33256
+ node.elements = childResult.processedNodes;
33257
+ if (childResult.unpairedBegin) {
33258
+ childResult.unpairedBegin.forEach((pendingField) => {
33259
+ currentFieldStack.push(pendingField.fieldInfo);
33260
+ collectedNodesStack.push([node]);
33261
+ });
33262
+ } else if (childResult.unpairedEnd) {
33263
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33264
+ finalizeField();
33265
+ } else if (collecting) {
33266
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33267
+ } else {
33268
+ processedNodes.push(node);
33269
+ }
33270
+ } else if (collecting) {
33271
+ collectedNodesStack[collectedNodesStack.length - 1].push(node);
33272
+ } else {
33273
+ processedNodes.push(node);
33274
+ }
33275
+ }
33276
+ let unpairedBegin = null;
33277
+ if (collectedNodesStack.length > 0) {
33278
+ unpairedBegin = [];
33279
+ for (let i = 0; i < collectedNodesStack.length; i++) {
33280
+ processedNodes.push(...collectedNodesStack[i].filter((n) => n !== null));
33281
+ unpairedBegin.push({
33282
+ nodes: collectedNodesStack[i],
33283
+ fieldInfo: currentFieldStack[i]
33284
+ });
33285
+ }
33286
+ }
33287
+ return { processedNodes, unpairedBegin, unpairedEnd };
33288
+ };
33289
+ const _processCombinedNodesForFldChar = (nodesToCombine = [], instrText, docx) => {
33290
+ const instructionType = instrText.trim().split(" ")[0];
33291
+ const instructionPreProcessor = getInstructionPreProcessor(instructionType);
33292
+ if (instructionPreProcessor) {
33293
+ return instructionPreProcessor(nodesToCombine, instrText, docx);
33294
+ } else {
33295
+ return nodesToCombine;
33296
+ }
33297
+ };
32864
33298
  const createDocumentJson = (docx, converter, editor) => {
32865
33299
  const json = carbonCopy(getInitialJSON(docx));
32866
33300
  if (!json) return null;
@@ -32890,6 +33324,8 @@ const createDocumentJson = (docx, converter, editor) => {
32890
33324
  if (bodyNode) {
32891
33325
  ensureSectionProperties(bodyNode);
32892
33326
  const node = bodyNode;
33327
+ const { processedNodes } = preProcessNodesForFldChar(node.elements ?? [], docx);
33328
+ node.elements = processedNodes;
32893
33329
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
32894
33330
  const content = pruneIgnoredNodes(contentElements);
32895
33331
  const comments = importCommentData({ docx, converter, editor });
@@ -32945,8 +33381,10 @@ const defaultNodeListHandler = () => {
32945
33381
  trackChangeNodeHandlerEntity,
32946
33382
  tableNodeHandlerEntity,
32947
33383
  tabNodeEntityHandler,
33384
+ tableOfContentsHandlerEntity,
32948
33385
  autoPageHandlerEntity,
32949
33386
  autoTotalPageCountEntity,
33387
+ pageReferenceEntity,
32950
33388
  standardNodeHandlerEntity
32951
33389
  ];
32952
33390
  const handler2 = createNodeListHandler(entities);
@@ -33134,7 +33572,7 @@ const DEFAULT_SECTION_PROPS = Object.freeze({
33134
33572
  gutter: "0"
33135
33573
  })
33136
33574
  });
33137
- function ensureSectionProperties(bodyNode, converter) {
33575
+ function ensureSectionProperties(bodyNode) {
33138
33576
  if (!bodyNode.elements) bodyNode.elements = [];
33139
33577
  let sectPr = bodyNode.elements.find((el) => el.name === "w:sectPr");
33140
33578
  if (!sectPr) {
@@ -48708,7 +49146,7 @@ const handleTrackedChangeTransaction = (trackedChangeMeta, trackedChanges, newEd
48708
49146
  if (emitParams) editor.emit("commentsUpdate", emitParams);
48709
49147
  return newTrackedChanges;
48710
49148
  };
48711
- const getTrackedChangeText = ({ state: state2, nodes, mark, marks, trackedChangeType, isDeletionInsertion }) => {
49149
+ const getTrackedChangeText = ({ nodes, mark, trackedChangeType, isDeletionInsertion }) => {
48712
49150
  let trackedChangeText = "";
48713
49151
  let deletionText = "";
48714
49152
  if (trackedChangeType === TrackInsertMarkName) {
@@ -48750,10 +49188,8 @@ const createOrUpdateTrackedChangeComment = ({ event, marks, deletionNodes, nodes
48750
49188
  if (hasMatchingId) nodesWithMark.push(node2);
48751
49189
  });
48752
49190
  const { deletionText, trackedChangeText } = getTrackedChangeText({
48753
- state: newEditorState,
48754
49191
  nodes: nodesWithMark.length ? nodesWithMark : [node],
48755
49192
  mark: trackedMark,
48756
- marks,
48757
49193
  trackedChangeType,
48758
49194
  isDeletionInsertion
48759
49195
  });
@@ -53851,7 +54287,7 @@ const StructuredContentCommands = Extension.create({
53851
54287
  }
53852
54288
  const attrs = {
53853
54289
  ...options.attrs,
53854
- id: options.attrs?.id || randomId(),
54290
+ id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
53855
54291
  tag: "inline_text_sdt",
53856
54292
  alias: options.attrs?.alias || "Structured content"
53857
54293
  };
@@ -53892,7 +54328,7 @@ const StructuredContentCommands = Extension.create({
53892
54328
  }
53893
54329
  const attrs = {
53894
54330
  ...options.attrs,
53895
- id: options.attrs?.id || randomId(),
54331
+ id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
53896
54332
  tag: "block_table_sdt",
53897
54333
  alias: options.attrs?.alias || "Structured content"
53898
54334
  };
@@ -53999,7 +54435,7 @@ const StructuredContentCommands = Extension.create({
53999
54435
  * Removes a structured content at cursor, preserving its content.
54000
54436
  * @category Command
54001
54437
  */
54002
- deleteStructuredContentAtSelection: () => ({ editor, dispatch, state: state2, tr }) => {
54438
+ deleteStructuredContentAtSelection: () => ({ dispatch, state: state2, tr }) => {
54003
54439
  const predicate = (node) => STRUCTURED_CONTENT_NAMES.includes(node.type.name);
54004
54440
  const structuredContent = findParentNode(predicate)(state2.selection);
54005
54441
  if (!structuredContent) {
@@ -54022,9 +54458,6 @@ const StructuredContentCommands = Extension.create({
54022
54458
  };
54023
54459
  }
54024
54460
  });
54025
- const randomId = () => {
54026
- return Math.floor(Math.random() * 4294967295).toString();
54027
- };
54028
54461
  class DocumentSectionView {
54029
54462
  constructor(node, getPos, decorations, editor) {
54030
54463
  __privateAdd$1(this, _DocumentSectionView_instances);
@@ -54406,6 +54839,48 @@ const DocumentSection = Node$1.create({
54406
54839
  };
54407
54840
  }
54408
54841
  });
54842
+ const DocumentPartObject = Node$1.create({
54843
+ name: "documentPartObject",
54844
+ group: "block",
54845
+ content: "block*",
54846
+ isolating: true,
54847
+ addOptions() {
54848
+ return {
54849
+ htmlAttributes: {
54850
+ class: "sd-document-part-object-block",
54851
+ "aria-label": "Structured document part block"
54852
+ }
54853
+ };
54854
+ },
54855
+ parseDOM() {
54856
+ return [
54857
+ {
54858
+ tag: "div.sd-document-part-object-block",
54859
+ priority: 60
54860
+ }
54861
+ ];
54862
+ },
54863
+ renderDOM({ htmlAttributes }) {
54864
+ return ["div", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
54865
+ },
54866
+ addAttributes() {
54867
+ return {
54868
+ sdBlockId: {
54869
+ default: null,
54870
+ keepOnSplit: false,
54871
+ parseDOM: (elem) => elem.getAttribute("data-sd-block-id"),
54872
+ renderDOM: (attrs) => {
54873
+ return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
54874
+ }
54875
+ },
54876
+ id: {},
54877
+ docPartGallery: {},
54878
+ docPartUnique: {
54879
+ default: true
54880
+ }
54881
+ };
54882
+ }
54883
+ });
54409
54884
  const Document = Node$1.create({
54410
54885
  name: "doc",
54411
54886
  topNode: true,
@@ -55542,7 +56017,12 @@ const generateDecorations = (state2, styles) => {
55542
56017
  return { ...base2, ...linkedStyle.definition?.styles || {} };
55543
56018
  };
55544
56019
  const pMap = buildStyleMap(paragraphStyleId);
55545
- const tMap = buildStyleMap(inlineTextStyleId);
56020
+ let tMap;
56021
+ if (paragraphStyleId?.startsWith("TOC")) {
56022
+ tMap = {};
56023
+ } else {
56024
+ tMap = buildStyleMap(inlineTextStyleId);
56025
+ }
55546
56026
  const rMap = buildStyleMap(runStyleId);
55547
56027
  const finalStyles = { ...pMap, ...tMap, ...rMap };
55548
56028
  if (Object.keys(finalStyles).length === 0) return;
@@ -56839,7 +57319,7 @@ const CommentsMark = Mark2.create({
56839
57319
  });
56840
57320
  const defaultTabDistance = 48;
56841
57321
  const defaultLineLength = 816;
56842
- const getTabDecorations = (doc2, view, from2 = 0, to = null) => {
57322
+ const getTabDecorations = (doc2, view, helpers2, from2 = 0, to = null) => {
56843
57323
  const decorations = [];
56844
57324
  const paragraphCache = /* @__PURE__ */ new Map();
56845
57325
  const end2 = to ?? doc2.content.size;
@@ -56847,7 +57327,7 @@ const getTabDecorations = (doc2, view, from2 = 0, to = null) => {
56847
57327
  if (node.type.name !== "tab") return;
56848
57328
  let extraStyles = "";
56849
57329
  const $pos = doc2.resolve(pos);
56850
- const paragraphContext = getParagraphContext($pos, paragraphCache);
57330
+ const paragraphContext = getParagraphContext($pos, paragraphCache, helpers2);
56851
57331
  if (!paragraphContext) return;
56852
57332
  try {
56853
57333
  const { tabStops, flattened, startPos } = paragraphContext;
@@ -56902,18 +57382,27 @@ const getTabDecorations = (doc2, view, from2 = 0, to = null) => {
56902
57382
  });
56903
57383
  return decorations;
56904
57384
  };
56905
- function getParagraphContext($pos, cache2) {
57385
+ function getParagraphContext($pos, cache2, helpers2) {
56906
57386
  for (let depth = $pos.depth; depth >= 0; depth--) {
56907
57387
  const node = $pos.node(depth);
56908
57388
  if (node?.type?.name === "paragraph") {
56909
57389
  const startPos = $pos.start(depth);
56910
57390
  if (!cache2.has(startPos)) {
57391
+ let tabStops = [];
57392
+ if (Array.isArray(node.attrs?.tabStops)) {
57393
+ tabStops = node.attrs.tabStops;
57394
+ } else {
57395
+ const style2 = helpers2.linkedStyles.getStyleById(node.attrs?.styleId);
57396
+ if (Array.isArray(style2?.definition?.styles?.tabStops)) {
57397
+ tabStops = style2.definition.styles.tabStops;
57398
+ }
57399
+ }
56911
57400
  cache2.set(startPos, {
56912
57401
  paragraph: node,
56913
57402
  paragraphDepth: depth,
56914
57403
  startPos,
56915
57404
  indent: node.attrs?.indent || {},
56916
- tabStops: Array.isArray(node.attrs?.tabStops) ? node.attrs.tabStops : [],
57405
+ tabStops,
56917
57406
  flattened: flattenParagraph(node, startPos),
56918
57407
  accumulatedTabWidth: 0
56919
57408
  });
@@ -57079,7 +57568,7 @@ const TabNode = Node$1.create({
57079
57568
  };
57080
57569
  },
57081
57570
  addPmPlugins() {
57082
- const { view } = this.editor;
57571
+ const { view, helpers: helpers2 } = this.editor;
57083
57572
  const tabPlugin = new Plugin({
57084
57573
  name: "tabPlugin",
57085
57574
  key: new PluginKey("tabPlugin"),
@@ -57089,7 +57578,7 @@ const TabNode = Node$1.create({
57089
57578
  },
57090
57579
  apply(tr, { decorations }, _oldState, newState) {
57091
57580
  if (!decorations) {
57092
- decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view));
57581
+ decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view, helpers2));
57093
57582
  }
57094
57583
  if (!tr.docChanged) {
57095
57584
  return { decorations };
@@ -57129,7 +57618,7 @@ const TabNode = Node$1.create({
57129
57618
  rangesToRecalculate.forEach(([start2, end2]) => {
57130
57619
  const oldDecorations = decorations.find(start2, end2);
57131
57620
  decorations = decorations.remove(oldDecorations);
57132
- const newDecorations = getTabDecorations(newState.doc, view, start2, end2);
57621
+ const newDecorations = getTabDecorations(newState.doc, view, helpers2, start2, end2);
57133
57622
  decorations = decorations.add(newState.doc, newDecorations);
57134
57623
  });
57135
57624
  return { decorations };
@@ -63410,6 +63899,43 @@ const processMarks = (marks) => {
63410
63899
  });
63411
63900
  return styles;
63412
63901
  };
63902
+ const PageReference = Node$1.create({
63903
+ name: "pageReference",
63904
+ group: "inline",
63905
+ inline: true,
63906
+ atom: true,
63907
+ draggable: false,
63908
+ selectable: false,
63909
+ content: "inline*",
63910
+ addOptions() {
63911
+ return {
63912
+ htmlAttributes: {
63913
+ contenteditable: false,
63914
+ "data-id": "auto-page-reference",
63915
+ "aria-label": "Page reference node",
63916
+ class: "sd-editor-page-reference"
63917
+ }
63918
+ };
63919
+ },
63920
+ addAttributes() {
63921
+ return {
63922
+ marksAsAttrs: {
63923
+ default: null,
63924
+ rendered: false
63925
+ },
63926
+ instruction: {
63927
+ default: "",
63928
+ rendered: false
63929
+ }
63930
+ };
63931
+ },
63932
+ parseDOM() {
63933
+ return [{ tag: 'span[data-id="auto-page-reference"]' }];
63934
+ },
63935
+ renderDOM({ htmlAttributes }) {
63936
+ return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
63937
+ }
63938
+ });
63413
63939
  const ShapeContainer = Node$1.create({
63414
63940
  name: "shapeContainer",
63415
63941
  group: "block",
@@ -63823,6 +64349,51 @@ const checkForNewBlockNodesInTrs = (transactions) => {
63823
64349
  });
63824
64350
  });
63825
64351
  };
64352
+ const TableOfContents = Node$1.create({
64353
+ name: "tableOfContents",
64354
+ group: "block",
64355
+ content: "paragraph+",
64356
+ inline: false,
64357
+ addOptions() {
64358
+ return {
64359
+ htmlAttributes: {
64360
+ "data-id": "table-of-contents",
64361
+ "aria-label": "Table of Contents"
64362
+ }
64363
+ };
64364
+ },
64365
+ parseDOM() {
64366
+ return [
64367
+ {
64368
+ tag: 'div[data-id="table-of-contents"]'
64369
+ }
64370
+ ];
64371
+ },
64372
+ renderDOM({ htmlAttributes }) {
64373
+ return ["div", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
64374
+ },
64375
+ addAttributes() {
64376
+ return {
64377
+ instruction: {
64378
+ default: null,
64379
+ rendered: false
64380
+ },
64381
+ /**
64382
+ * @private
64383
+ * @category Attribute
64384
+ * @param {string} [sdBlockId] - Internal block tracking ID (not user-configurable)
64385
+ */
64386
+ sdBlockId: {
64387
+ default: null,
64388
+ keepOnSplit: false,
64389
+ parseDOM: (elem) => elem.getAttribute("data-sd-block-id"),
64390
+ renderDOM: (attrs) => {
64391
+ return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
64392
+ }
64393
+ }
64394
+ };
64395
+ }
64396
+ });
63826
64397
  const TextStyle = Mark2.create({
63827
64398
  name: "textStyle",
63828
64399
  addOptions() {
@@ -70429,6 +71000,7 @@ const getStarterExtensions = () => {
70429
71000
  SlashMenu,
70430
71001
  Strike,
70431
71002
  TabNode,
71003
+ TableOfContents,
70432
71004
  Text,
70433
71005
  TextAlign,
70434
71006
  TextIndent,
@@ -70463,6 +71035,7 @@ const getStarterExtensions = () => {
70463
71035
  AiLoaderNode,
70464
71036
  PageNumber,
70465
71037
  TotalPageCount,
71038
+ PageReference,
70466
71039
  ShapeContainer,
70467
71040
  ShapeTextbox,
70468
71041
  ContentBlock,
@@ -70471,6 +71044,7 @@ const getStarterExtensions = () => {
70471
71044
  StructuredContentBlock,
70472
71045
  StructuredContentCommands,
70473
71046
  DocumentSection,
71047
+ DocumentPartObject,
70474
71048
  NodeResizer,
70475
71049
  CustomSelection,
70476
71050
  TextTransform
@@ -86007,71 +86581,73 @@ const _sfc_main = {
86007
86581
  };
86008
86582
  const SuperInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4d5cff52"]]);
86009
86583
  const additionalHandlers = Object.freeze({
86010
- "mc:AlternateContent": translator,
86011
- "w:b": translator$12,
86012
- "w:bidiVisual": translator$F,
86013
- "w:bookmarkEnd": translator$1,
86014
- "w:bookmarkStart": translator$2,
86015
- "w:bottom": translator$s,
86016
- "w:br": translator$16,
86017
- "w:cantSplit": translator$T,
86018
- "w:cnfStyle": translator$S,
86019
- "w:color": translator$_,
86020
- "w:divId": translator$R,
86021
- "w:drawing": translator$4,
86022
- "w:end": translator$q,
86023
- "w:gridAfter": translator$Q,
86024
- "w:gridBefore": translator$P,
86025
- "w:gridCol": translator$b,
86026
- "w:hidden": translator$O,
86027
- "w:highlight": translator$15,
86028
- "w:hyperlink": translator$7,
86029
- "w:i": translator$11,
86030
- "w:insideH": translator$o,
86031
- "w:insideV": translator$n,
86032
- "w:jc": translator$N,
86033
- "w:left": translator$m,
86034
- "w:p": translator$13,
86035
- "w:r": translator$U,
86036
- "w:rFonts": translator$Z,
86037
- "w:rPr": translator$V,
86038
- "w:rStyle": translator$Y,
86039
- "w:right": translator$k,
86040
- "w:sdt": translator$3,
86041
- "w:shd": translator$E,
86042
- "w:start": translator$i,
86043
- "w:strike": translator$$,
86044
- "w:sz": translator$X,
86045
- "w:szCs": translator$W,
86046
- "w:tab": translator$14,
86047
- "w:tbl": translator$9,
86048
- "w:tblBorders": translator$e,
86049
- "w:tblCaption": translator$D,
86050
- "w:tblCellMar": translator$d,
86051
- "w:tblCellSpacing": translator$M,
86052
- "w:tblDescription": translator$C,
86053
- "w:tblGrid": translator$a,
86054
- "w:tblHeader": translator$L,
86055
- "w:tblInd": translator$B,
86056
- "w:tblLayout": translator$A,
86057
- "w:tblLook": translator$z,
86058
- "w:tblOverlap": translator$y,
86059
- "w:tblPr": translator$c,
86060
- "w:tblStyle": translator$x,
86061
- "w:tblStyleColBandSize": translator$w,
86062
- "w:tblStyleRowBandSize": translator$v,
86063
- "w:tblW": translator$u,
86064
- "w:tblpPr": translator$t,
86065
- "w:tc": translator$8,
86066
- "w:top": translator$g,
86067
- "w:tr": translator$G,
86068
- "w:trHeight": translator$K,
86069
- "w:trPr": translator$H,
86070
- "w:u": translator$10,
86071
- "w:wAfter": translator$J,
86072
- "w:wBefore": translator$I,
86073
- "wp:anchor": translator$6,
86074
- "wp:inline": translator$5
86584
+ "mc:AlternateContent": translator$2,
86585
+ "sd:pageReference": translator$1,
86586
+ "sd:tableOfContents": translator,
86587
+ "w:b": translator$15,
86588
+ "w:bidiVisual": translator$G,
86589
+ "w:bookmarkEnd": translator$3,
86590
+ "w:bookmarkStart": translator$4,
86591
+ "w:bottom": translator$t,
86592
+ "w:br": translator$19,
86593
+ "w:cantSplit": translator$U,
86594
+ "w:cnfStyle": translator$T,
86595
+ "w:color": translator$11,
86596
+ "w:divId": translator$S,
86597
+ "w:drawing": translator$6,
86598
+ "w:end": translator$r,
86599
+ "w:gridAfter": translator$R,
86600
+ "w:gridBefore": translator$Q,
86601
+ "w:gridCol": translator$c,
86602
+ "w:hidden": translator$P,
86603
+ "w:highlight": translator$18,
86604
+ "w:hyperlink": translator$W,
86605
+ "w:i": translator$14,
86606
+ "w:insideH": translator$p,
86607
+ "w:insideV": translator$o,
86608
+ "w:jc": translator$O,
86609
+ "w:left": translator$n,
86610
+ "w:p": translator$16,
86611
+ "w:r": translator$V,
86612
+ "w:rFonts": translator$10,
86613
+ "w:rPr": translator$X,
86614
+ "w:rStyle": translator$$,
86615
+ "w:right": translator$l,
86616
+ "w:sdt": translator$5,
86617
+ "w:shd": translator$F,
86618
+ "w:start": translator$j,
86619
+ "w:strike": translator$12,
86620
+ "w:sz": translator$_,
86621
+ "w:szCs": translator$Z,
86622
+ "w:tab": translator$17,
86623
+ "w:tbl": translator$a,
86624
+ "w:tblBorders": translator$f,
86625
+ "w:tblCaption": translator$E,
86626
+ "w:tblCellMar": translator$e,
86627
+ "w:tblCellSpacing": translator$N,
86628
+ "w:tblDescription": translator$D,
86629
+ "w:tblGrid": translator$b,
86630
+ "w:tblHeader": translator$M,
86631
+ "w:tblInd": translator$C,
86632
+ "w:tblLayout": translator$B,
86633
+ "w:tblLook": translator$A,
86634
+ "w:tblOverlap": translator$z,
86635
+ "w:tblPr": translator$d,
86636
+ "w:tblStyle": translator$y,
86637
+ "w:tblStyleColBandSize": translator$x,
86638
+ "w:tblStyleRowBandSize": translator$w,
86639
+ "w:tblW": translator$v,
86640
+ "w:tblpPr": translator$u,
86641
+ "w:tc": translator$9,
86642
+ "w:top": translator$h,
86643
+ "w:tr": translator$H,
86644
+ "w:trHeight": translator$L,
86645
+ "w:trPr": translator$I,
86646
+ "w:u": translator$13,
86647
+ "w:wAfter": translator$K,
86648
+ "w:wBefore": translator$J,
86649
+ "wp:anchor": translator$8,
86650
+ "wp:inline": translator$7
86075
86651
  });
86076
86652
  const baseHandlers = {
86077
86653
  ...runPropertyTranslators,