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

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 (59) hide show
  1. package/dist/chunks/{PdfViewer-D3zo7tPo.es.js → PdfViewer-CJdQmuIm.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-OZDJ7gwT.cjs → PdfViewer-DE1NR4Ve.cjs} +1 -1
  3. package/dist/chunks/{index-MzW5BVNd.es.js → index-B9sHxXr_.es.js} +55 -27
  4. package/dist/chunks/{index-CfYf4T_z.cjs → index-nfoifSpX.cjs} +55 -27
  5. package/dist/chunks/{super-editor.es-U-GVCd_F.cjs → super-editor.es-DAP-fnHo.cjs} +3469 -2438
  6. package/dist/chunks/{super-editor.es-Bntob7Wd.es.js → super-editor.es-_iVPQ8J8.es.js} +3469 -2438
  7. package/dist/core/SuperDoc.d.ts +5 -0
  8. package/dist/core/SuperDoc.d.ts.map +1 -1
  9. package/dist/core/types/index.d.ts +12 -4
  10. package/dist/core/types/index.d.ts.map +1 -1
  11. package/dist/stores/comments-store.d.ts +4 -1
  12. package/dist/stores/comments-store.d.ts.map +1 -1
  13. package/dist/style.css +53 -44
  14. package/dist/super-editor/ai-writer.es.js +2 -2
  15. package/dist/super-editor/chunks/{converter-3xnF_NHq.js → converter-DK1NMJZB.js} +1148 -748
  16. package/dist/super-editor/chunks/{docx-zipper-CZdELYi-.js → docx-zipper-CmK8TyNb.js} +73 -12
  17. package/dist/super-editor/chunks/{editor-BqYH4kDD.js → editor-YR4uV-dp.js} +1917 -1606
  18. package/dist/super-editor/chunks/{toolbar-TkaE2kKM.js → toolbar-DzJyRvb0.js} +2 -2
  19. package/dist/super-editor/converter.es.js +1 -1
  20. package/dist/super-editor/docx-zipper.es.js +2 -2
  21. package/dist/super-editor/editor.es.js +3 -3
  22. package/dist/super-editor/file-zipper.es.js +1 -1
  23. package/dist/super-editor/src/components/slash-menu/menuItems.d.ts +5 -1
  24. package/dist/super-editor/src/components/slash-menu/tests/testHelpers.d.ts +466 -0
  25. package/dist/super-editor/src/components/slash-menu/utils.d.ts +9 -2
  26. package/dist/super-editor/src/core/DocxZipper.d.ts +1 -1
  27. package/dist/super-editor/src/core/commands/__tests__/schemaWithLists.d.ts +2 -0
  28. package/dist/super-editor/src/core/commands/__tests__/testHelpers.d.ts +4 -0
  29. package/dist/super-editor/src/core/commands/__tests__/testSchema.d.ts +2 -0
  30. package/dist/super-editor/src/core/commands/tests/commandTestUtils.d.ts +7 -0
  31. package/dist/super-editor/src/core/commands/tests/test-schema.d.ts +2 -0
  32. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +1 -13
  33. package/dist/super-editor/src/core/super-converter/exporter.d.ts +1 -0
  34. package/dist/super-editor/src/core/super-converter/helpers/tableFallbackHelpers.d.ts +24 -0
  35. package/dist/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/alternate-content-translator.d.ts +6 -0
  36. package/dist/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/index.d.ts +1 -0
  37. package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +5 -0
  38. package/dist/super-editor/src/extensions/index.d.ts +2 -1
  39. package/dist/super-editor/src/extensions/structured-content/index.d.ts +1 -0
  40. package/dist/super-editor/src/extensions/structured-content/structured-content-commands.d.ts +67 -0
  41. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentBlockTags.d.ts +7 -0
  42. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentInlineTags.d.ts +7 -0
  43. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTags.d.ts +7 -0
  44. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsById.d.ts +8 -0
  45. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +4 -0
  46. package/dist/super-editor/src/tests/helpers/helpers.d.ts +1 -0
  47. package/dist/super-editor/src/utils/contextmenu-helpers.d.ts +24 -0
  48. package/dist/super-editor/style.css +9 -0
  49. package/dist/super-editor/super-editor.es.js +454 -154
  50. package/dist/super-editor/toolbar.es.js +2 -2
  51. package/dist/super-editor.cjs +1 -1
  52. package/dist/super-editor.es.js +1 -1
  53. package/dist/superdoc.cjs +2 -2
  54. package/dist/superdoc.es.js +2 -2
  55. package/dist/superdoc.umd.js +3528 -2469
  56. package/dist/superdoc.umd.js.map +1 -1
  57. package/package.json +1 -1
  58. package/dist/super-editor/src/extensions/run-item/index.d.ts +0 -1
  59. package/dist/super-editor/src/extensions/run-item/run-item.d.ts +0 -26
@@ -24323,37 +24323,37 @@ const _NodeTranslator = class _NodeTranslator {
24323
24323
  /** @type {typeof TranslatorTypes} */
24324
24324
  __publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
24325
24325
  let NodeTranslator = _NodeTranslator;
24326
- const encode$17 = (attributes) => {
24326
+ const encode$18 = (attributes) => {
24327
24327
  return attributes["w:type"];
24328
24328
  };
24329
- const decode$_ = (attrs) => {
24329
+ const decode$$ = (attrs) => {
24330
24330
  const { lineBreakType } = attrs;
24331
24331
  return lineBreakType;
24332
24332
  };
24333
24333
  const attrConfig$F = Object.freeze({
24334
24334
  xmlName: "w:type",
24335
24335
  sdName: "lineBreakType",
24336
- encode: encode$17,
24337
- decode: decode$_
24336
+ encode: encode$18,
24337
+ decode: decode$$
24338
24338
  });
24339
- const encode$16 = (attributes) => {
24339
+ const encode$17 = (attributes) => {
24340
24340
  const xmlAttrValue = attributes["w:clear"];
24341
24341
  return xmlAttrValue;
24342
24342
  };
24343
- const decode$Z = (attrs) => {
24343
+ const decode$_ = (attrs) => {
24344
24344
  const { clear } = attrs;
24345
24345
  return clear;
24346
24346
  };
24347
24347
  const attrConfig$E = Object.freeze({
24348
24348
  xmlName: "w:clear",
24349
24349
  sdName: "clear",
24350
- encode: encode$16,
24351
- decode: decode$Z
24350
+ encode: encode$17,
24351
+ decode: decode$_
24352
24352
  });
24353
- const validXmlAttributes$l = [attrConfig$F, attrConfig$E];
24354
- const XML_NODE_NAME$t = "w:br";
24355
- const SD_NODE_NAME$c = "lineBreak";
24356
- const encode$15 = (_2, encodedAttrs) => {
24353
+ const validXmlAttributes$m = [attrConfig$F, attrConfig$E];
24354
+ const XML_NODE_NAME$u = "w:br";
24355
+ const SD_NODE_NAME$d = "lineBreak";
24356
+ const encode$16 = (_2, encodedAttrs) => {
24357
24357
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24358
24358
  const translated = {
24359
24359
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24363,7 +24363,7 @@ const encode$15 = (_2, encodedAttrs) => {
24363
24363
  }
24364
24364
  return translated;
24365
24365
  };
24366
- const decode$Y = (params, decodedAttrs) => {
24366
+ const decode$Z = (params, decodedAttrs) => {
24367
24367
  const { node } = params;
24368
24368
  if (!node) return;
24369
24369
  const wBreak = { name: "w:br" };
@@ -24380,39 +24380,39 @@ const decode$Y = (params, decodedAttrs) => {
24380
24380
  };
24381
24381
  return translated;
24382
24382
  };
24383
- const config$r = {
24384
- xmlName: XML_NODE_NAME$t,
24385
- sdNodeOrKeyName: SD_NODE_NAME$c,
24383
+ const config$s = {
24384
+ xmlName: XML_NODE_NAME$u,
24385
+ sdNodeOrKeyName: SD_NODE_NAME$d,
24386
24386
  type: NodeTranslator.translatorTypes.NODE,
24387
- encode: encode$15,
24388
- decode: decode$Y,
24389
- attributes: validXmlAttributes$l
24387
+ encode: encode$16,
24388
+ decode: decode$Z,
24389
+ attributes: validXmlAttributes$m
24390
24390
  };
24391
- const translator$15 = NodeTranslator.from(config$r);
24392
- const encode$14 = (attributes) => attributes?.["w:val"];
24393
- const decode$X = (attrs) => attrs?.highlight;
24391
+ const translator$16 = NodeTranslator.from(config$s);
24392
+ const encode$15 = (attributes) => attributes?.["w:val"];
24393
+ const decode$Y = (attrs) => attrs?.highlight;
24394
24394
  const attrConfig$D = Object.freeze({
24395
24395
  xmlName: "w:val",
24396
24396
  sdName: "highlight",
24397
- encode: encode$14,
24398
- decode: decode$X
24397
+ encode: encode$15,
24398
+ decode: decode$Y
24399
24399
  });
24400
- const validXmlAttributes$k = [attrConfig$D];
24401
- const XML_NODE_NAME$s = "w:highlight";
24400
+ const validXmlAttributes$l = [attrConfig$D];
24401
+ const XML_NODE_NAME$t = "w:highlight";
24402
24402
  const SD_ATTR_KEY$f = "highlight";
24403
24403
  const DISABLED_TOKENS = /* @__PURE__ */ new Set(["transparent", "none", "inherit"]);
24404
- const encode$13 = (params, encodedAttrs = {}) => {
24404
+ const encode$14 = (params, encodedAttrs = {}) => {
24405
24405
  const { nodes } = params;
24406
24406
  const node = nodes?.[0];
24407
24407
  const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
24408
24408
  return {
24409
24409
  type: "attr",
24410
- xmlName: XML_NODE_NAME$s,
24410
+ xmlName: XML_NODE_NAME$t,
24411
24411
  sdNodeOrKeyName: SD_ATTR_KEY$f,
24412
24412
  attributes: { "w:val": value ?? null }
24413
24413
  };
24414
24414
  };
24415
- const decode$W = (params) => {
24415
+ const decode$X = (params) => {
24416
24416
  const attrs = params?.node?.attrs || {};
24417
24417
  const highlightValue = attrs.highlight ?? attrs.color ?? null;
24418
24418
  if (!highlightValue) return void 0;
@@ -24420,14 +24420,14 @@ const decode$W = (params) => {
24420
24420
  if (!normalizedValue) return void 0;
24421
24421
  if (DISABLED_TOKENS.has(normalizedValue)) {
24422
24422
  return {
24423
- name: XML_NODE_NAME$s,
24423
+ name: XML_NODE_NAME$t,
24424
24424
  attributes: { "w:val": "none" }
24425
24425
  };
24426
24426
  }
24427
24427
  const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24428
24428
  if (keyword) {
24429
24429
  return {
24430
- name: XML_NODE_NAME$s,
24430
+ name: XML_NODE_NAME$t,
24431
24431
  attributes: { "w:val": keyword }
24432
24432
  };
24433
24433
  }
@@ -24442,63 +24442,63 @@ const decode$W = (params) => {
24442
24442
  }
24443
24443
  };
24444
24444
  };
24445
- const config$q = {
24446
- xmlName: XML_NODE_NAME$s,
24445
+ const config$r = {
24446
+ xmlName: XML_NODE_NAME$t,
24447
24447
  sdNodeOrKeyName: SD_ATTR_KEY$f,
24448
24448
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
24449
- encode: encode$13,
24450
- decode: decode$W,
24451
- attributes: validXmlAttributes$k
24449
+ encode: encode$14,
24450
+ decode: decode$X,
24451
+ attributes: validXmlAttributes$l
24452
24452
  };
24453
- const translator$14 = NodeTranslator.from(config$q);
24454
- const encode$12 = (attributes) => {
24453
+ const translator$15 = NodeTranslator.from(config$r);
24454
+ const encode$13 = (attributes) => {
24455
24455
  return attributes["w:val"];
24456
24456
  };
24457
- const decode$V = (attrs) => {
24457
+ const decode$W = (attrs) => {
24458
24458
  const { tabSize } = attrs || {};
24459
24459
  return tabSize;
24460
24460
  };
24461
24461
  const attrConfig$C = Object.freeze({
24462
24462
  xmlName: "w:val",
24463
24463
  sdName: "tabSize",
24464
- encode: encode$12,
24465
- decode: decode$V
24464
+ encode: encode$13,
24465
+ decode: decode$W
24466
24466
  });
24467
- const encode$11 = (attributes) => {
24467
+ const encode$12 = (attributes) => {
24468
24468
  return attributes["w:leader"];
24469
24469
  };
24470
- const decode$U = (attrs) => {
24470
+ const decode$V = (attrs) => {
24471
24471
  const { leader } = attrs || {};
24472
24472
  return leader;
24473
24473
  };
24474
24474
  const attrConfig$B = Object.freeze({
24475
24475
  xmlName: "w:leader",
24476
24476
  sdName: "leader",
24477
- encode: encode$11,
24478
- decode: decode$U
24477
+ encode: encode$12,
24478
+ decode: decode$V
24479
24479
  });
24480
- const encode$10 = (attributes) => {
24480
+ const encode$11 = (attributes) => {
24481
24481
  return attributes["w:pos"];
24482
24482
  };
24483
- const decode$T = (attrs) => {
24483
+ const decode$U = (attrs) => {
24484
24484
  const { pos } = attrs || {};
24485
24485
  return pos;
24486
24486
  };
24487
24487
  const attrConfig$A = Object.freeze({
24488
24488
  xmlName: "w:pos",
24489
24489
  sdName: "pos",
24490
- encode: encode$10,
24491
- decode: decode$T
24490
+ encode: encode$11,
24491
+ decode: decode$U
24492
24492
  });
24493
- const validXmlAttributes$j = [attrConfig$C, attrConfig$A, attrConfig$B];
24494
- const XML_NODE_NAME$r = "w:tab";
24495
- const SD_NODE_NAME$b = "tab";
24496
- const encode$$ = (_2, encodedAttrs = {}) => {
24493
+ const validXmlAttributes$k = [attrConfig$C, attrConfig$A, attrConfig$B];
24494
+ const XML_NODE_NAME$s = "w:tab";
24495
+ const SD_NODE_NAME$c = "tab";
24496
+ const encode$10 = (_2, encodedAttrs = {}) => {
24497
24497
  const translated = { type: "tab" };
24498
24498
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24499
24499
  return translated;
24500
24500
  };
24501
- const decode$S = (params, decodedAttrs = {}) => {
24501
+ const decode$T = (params, decodedAttrs = {}) => {
24502
24502
  const { node } = params || {};
24503
24503
  if (!node) return;
24504
24504
  const wTab = { name: "w:tab" };
@@ -24514,15 +24514,15 @@ const decode$S = (params, decodedAttrs = {}) => {
24514
24514
  }
24515
24515
  return translated;
24516
24516
  };
24517
- const config$p = {
24518
- xmlName: XML_NODE_NAME$r,
24519
- sdNodeOrKeyName: SD_NODE_NAME$b,
24517
+ const config$q = {
24518
+ xmlName: XML_NODE_NAME$s,
24519
+ sdNodeOrKeyName: SD_NODE_NAME$c,
24520
24520
  type: NodeTranslator.translatorTypes.NODE,
24521
- encode: encode$$,
24522
- decode: decode$S,
24523
- attributes: validXmlAttributes$j
24521
+ encode: encode$10,
24522
+ decode: decode$T,
24523
+ attributes: validXmlAttributes$k
24524
24524
  };
24525
- const translator$13 = NodeTranslator.from(config$p);
24525
+ const translator$14 = NodeTranslator.from(config$q);
24526
24526
  const mergeTextNodes = (nodes) => {
24527
24527
  if (!nodes || !Array.isArray(nodes)) {
24528
24528
  return nodes;
@@ -24846,17 +24846,16 @@ const getParagraphSpacing = (node, docx, styleId = "", marks = [], options = {})
24846
24846
  };
24847
24847
  const getDefaultParagraphStyle = (docx, styleId = "") => {
24848
24848
  const styles = docx["word/styles.xml"];
24849
- if (!styles) {
24849
+ const rootElements = styles?.elements?.[0]?.elements;
24850
+ if (!rootElements?.length) {
24850
24851
  return {};
24851
24852
  }
24852
- const defaults = styles.elements[0].elements?.find((el) => el.name === "w:docDefaults");
24853
- const pDefault = defaults.elements.find((el) => el.name === "w:pPrDefault");
24853
+ const defaults = rootElements.find((el) => el.name === "w:docDefaults");
24854
+ const pDefault = defaults?.elements?.find((el) => el.name === "w:pPrDefault") || {};
24854
24855
  const pPrDefault = pDefault?.elements?.find((el) => el.name === "w:pPr");
24855
24856
  const pPrDefaultSpacingTag = pPrDefault?.elements?.find((el) => el.name === "w:spacing") || {};
24856
24857
  const pPrDefaultIndentTag = pPrDefault?.elements?.find((el) => el.name === "w:ind") || {};
24857
- const stylesNormal = styles.elements[0].elements?.find(
24858
- (el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal"
24859
- );
24858
+ const stylesNormal = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal");
24860
24859
  const pPrNormal = stylesNormal?.elements?.find((el) => el.name === "w:pPr");
24861
24860
  const pPrNormalSpacingTag = pPrNormal?.elements?.find((el) => el.name === "w:spacing") || {};
24862
24861
  const pPrNormalIndentTag = pPrNormal?.elements?.find((el) => el.name === "w:ind") || {};
@@ -24865,9 +24864,7 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
24865
24864
  let pPrStyleIdIndentTag = {};
24866
24865
  let pPrStyleJc = {};
24867
24866
  if (styleId) {
24868
- const stylesById = styles.elements[0].elements?.find(
24869
- (el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId
24870
- );
24867
+ const stylesById = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId);
24871
24868
  const pPrById = stylesById?.elements?.find((el) => el.name === "w:pPr");
24872
24869
  pPrStyleIdSpacingTag = pPrById?.elements?.find((el) => el.name === "w:spacing") || {};
24873
24870
  pPrStyleIdIndentTag = pPrById?.elements?.find((el) => el.name === "w:ind") || {};
@@ -25137,91 +25134,91 @@ const handleParagraphNode$1 = (params) => {
25137
25134
  }
25138
25135
  return schemaNode;
25139
25136
  };
25140
- const encode$_ = (attributes) => {
25137
+ const encode$$ = (attributes) => {
25141
25138
  return attributes["w:rsidDel"];
25142
25139
  };
25143
- const decode$R = (attrs) => {
25140
+ const decode$S = (attrs) => {
25144
25141
  return attrs.rsidDel;
25145
25142
  };
25146
25143
  const attrConfig$z = Object.freeze({
25147
25144
  xmlName: "w:rsidDel",
25148
25145
  sdName: "rsidDel",
25149
- encode: encode$_,
25150
- decode: decode$R
25146
+ encode: encode$$,
25147
+ decode: decode$S
25151
25148
  });
25152
- const encode$Z = (attributes) => {
25149
+ const encode$_ = (attributes) => {
25153
25150
  return attributes["w:rsidP"];
25154
25151
  };
25155
- const decode$Q = (attrs) => {
25152
+ const decode$R = (attrs) => {
25156
25153
  return attrs.rsidP;
25157
25154
  };
25158
25155
  const attrConfig$y = Object.freeze({
25159
25156
  xmlName: "w:rsidP",
25160
25157
  sdName: "rsidP",
25161
- encode: encode$Z,
25162
- decode: decode$Q
25158
+ encode: encode$_,
25159
+ decode: decode$R
25163
25160
  });
25164
- const encode$Y = (attributes) => {
25161
+ const encode$Z = (attributes) => {
25165
25162
  return attributes["w:rsidR"];
25166
25163
  };
25167
- const decode$P = (attrs) => {
25164
+ const decode$Q = (attrs) => {
25168
25165
  return attrs.rsidR;
25169
25166
  };
25170
25167
  const attrConfig$x = Object.freeze({
25171
25168
  xmlName: "w:rsidR",
25172
25169
  sdName: "rsidR",
25173
- encode: encode$Y,
25174
- decode: decode$P
25170
+ encode: encode$Z,
25171
+ decode: decode$Q
25175
25172
  });
25176
- const encode$X = (attributes) => {
25173
+ const encode$Y = (attributes) => {
25177
25174
  return attributes["w:rsidRPr"];
25178
25175
  };
25179
- const decode$O = (attrs) => {
25176
+ const decode$P = (attrs) => {
25180
25177
  return attrs.rsidRPr;
25181
25178
  };
25182
25179
  const attrConfig$w = Object.freeze({
25183
25180
  xmlName: "w:rsidRPr",
25184
25181
  sdName: "rsidRPr",
25185
- encode: encode$X,
25186
- decode: decode$O
25182
+ encode: encode$Y,
25183
+ decode: decode$P
25187
25184
  });
25188
- const encode$W = (attributes) => {
25185
+ const encode$X = (attributes) => {
25189
25186
  return attributes["w:rsidRDefault"];
25190
25187
  };
25191
- const decode$N = (attrs) => {
25188
+ const decode$O = (attrs) => {
25192
25189
  return attrs.rsidRDefault;
25193
25190
  };
25194
25191
  const attrConfig$v = Object.freeze({
25195
25192
  xmlName: "w:rsidRDefault",
25196
25193
  sdName: "rsidRDefault",
25197
- encode: encode$W,
25198
- decode: decode$N
25194
+ encode: encode$X,
25195
+ decode: decode$O
25199
25196
  });
25200
- const encode$V = (attributes) => {
25197
+ const encode$W = (attributes) => {
25201
25198
  return attributes["w14:paraId"];
25202
25199
  };
25203
- const decode$M = (attrs) => {
25200
+ const decode$N = (attrs) => {
25204
25201
  return attrs.paraId;
25205
25202
  };
25206
25203
  const attrConfig$u = Object.freeze({
25207
25204
  xmlName: "w14:paraId",
25208
25205
  sdName: "paraId",
25209
- encode: encode$V,
25210
- decode: decode$M
25206
+ encode: encode$W,
25207
+ decode: decode$N
25211
25208
  });
25212
- const encode$U = (attributes) => {
25209
+ const encode$V = (attributes) => {
25213
25210
  return attributes["w14:textId"];
25214
25211
  };
25215
- const decode$L = (attrs) => {
25212
+ const decode$M = (attrs) => {
25216
25213
  return attrs.textId;
25217
25214
  };
25218
25215
  const attrConfig$t = Object.freeze({
25219
25216
  xmlName: "w14:textId",
25220
25217
  sdName: "textId",
25221
- encode: encode$U,
25222
- decode: decode$L
25218
+ encode: encode$V,
25219
+ decode: decode$M
25223
25220
  });
25224
- const validXmlAttributes$i = [
25221
+ const validXmlAttributes$j = [
25225
25222
  attrConfig$u,
25226
25223
  attrConfig$t,
25227
25224
  attrConfig$x,
@@ -25230,9 +25227,9 @@ const validXmlAttributes$i = [
25230
25227
  attrConfig$w,
25231
25228
  attrConfig$z
25232
25229
  ];
25233
- const XML_NODE_NAME$q = "w:p";
25234
- const SD_NODE_NAME$a = "paragraph";
25235
- const encode$T = (params, encodedAttrs = {}) => {
25230
+ const XML_NODE_NAME$r = "w:p";
25231
+ const SD_NODE_NAME$b = "paragraph";
25232
+ const encode$U = (params, encodedAttrs = {}) => {
25236
25233
  const node = handleParagraphNode$1(params);
25237
25234
  if (!node) return void 0;
25238
25235
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25240,7 +25237,7 @@ const encode$T = (params, encodedAttrs = {}) => {
25240
25237
  }
25241
25238
  return node;
25242
25239
  };
25243
- const decode$K = (params, decodedAttrs = {}) => {
25240
+ const decode$L = (params, decodedAttrs = {}) => {
25244
25241
  const translated = translateParagraphNode(params);
25245
25242
  if (!translated) return void 0;
25246
25243
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25248,16 +25245,16 @@ const decode$K = (params, decodedAttrs = {}) => {
25248
25245
  }
25249
25246
  return translated;
25250
25247
  };
25251
- const config$o = {
25252
- xmlName: XML_NODE_NAME$q,
25253
- sdNodeOrKeyName: SD_NODE_NAME$a,
25248
+ const config$p = {
25249
+ xmlName: XML_NODE_NAME$r,
25250
+ sdNodeOrKeyName: SD_NODE_NAME$b,
25254
25251
  type: NodeTranslator.translatorTypes.NODE,
25255
- encode: encode$T,
25256
- decode: decode$K,
25257
- attributes: validXmlAttributes$i
25252
+ encode: encode$U,
25253
+ decode: decode$L,
25254
+ attributes: validXmlAttributes$j
25258
25255
  };
25259
- const translator$12 = NodeTranslator.from(config$o);
25260
- const encode$S = (attributes) => {
25256
+ const translator$13 = NodeTranslator.from(config$p);
25257
+ const encode$T = (attributes) => {
25261
25258
  const raw = attributes?.["w:val"];
25262
25259
  if (raw === void 0 || raw === null) return void 0;
25263
25260
  if (typeof raw === "boolean") return raw;
@@ -25267,20 +25264,20 @@ const encode$S = (attributes) => {
25267
25264
  if (val === "1" || val === "true" || val === "on") return true;
25268
25265
  return void 0;
25269
25266
  };
25270
- const decode$J = (runProps) => {
25267
+ const decode$K = (runProps) => {
25271
25268
  if (runProps?.bold === false) return "0";
25272
25269
  return void 0;
25273
25270
  };
25274
25271
  const attrConfig$s = Object.freeze({
25275
25272
  xmlName: "w:val",
25276
25273
  sdName: "bold",
25277
- encode: encode$S,
25278
- decode: decode$J
25274
+ encode: encode$T,
25275
+ decode: decode$K
25279
25276
  });
25280
- const validXmlAttributes$h = [attrConfig$s];
25281
- const XML_NODE_NAME$p = "w:b";
25277
+ const validXmlAttributes$i = [attrConfig$s];
25278
+ const XML_NODE_NAME$q = "w:b";
25282
25279
  const SD_ATTR_KEY$e = "bold";
25283
- const encode$R = (params, encodedAttrs = {}) => {
25280
+ const encode$S = (params, encodedAttrs = {}) => {
25284
25281
  const { nodes } = params;
25285
25282
  const node = nodes[0];
25286
25283
  if (!node) return void 0;
@@ -25292,85 +25289,85 @@ const encode$R = (params, encodedAttrs = {}) => {
25292
25289
  else attributes = node.attributes || {};
25293
25290
  return {
25294
25291
  type: "attr",
25295
- xmlName: XML_NODE_NAME$p,
25292
+ xmlName: XML_NODE_NAME$q,
25296
25293
  sdNodeOrKeyName: SD_ATTR_KEY$e,
25297
25294
  attributes
25298
25295
  };
25299
25296
  };
25300
- const config$n = {
25301
- xmlName: XML_NODE_NAME$p,
25297
+ const config$o = {
25298
+ xmlName: XML_NODE_NAME$q,
25302
25299
  sdNodeOrKeyName: SD_ATTR_KEY$e,
25303
25300
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25304
- encode: encode$R,
25305
- attributes: validXmlAttributes$h
25301
+ encode: encode$S,
25302
+ attributes: validXmlAttributes$i
25306
25303
  };
25307
- const translator$11 = NodeTranslator.from(config$n);
25308
- const XML_NODE_NAME$o = "w:i";
25304
+ const translator$12 = NodeTranslator.from(config$o);
25305
+ const XML_NODE_NAME$p = "w:i";
25309
25306
  const SD_ATTR_KEY$d = "italic";
25310
- const encode$Q = (params) => {
25307
+ const encode$R = (params) => {
25311
25308
  const { nodes } = params;
25312
25309
  const node = nodes?.[0];
25313
25310
  if (!node) return void 0;
25314
25311
  return {
25315
25312
  type: "attr",
25316
- xmlName: XML_NODE_NAME$o,
25313
+ xmlName: XML_NODE_NAME$p,
25317
25314
  sdNodeOrKeyName: SD_ATTR_KEY$d,
25318
25315
  attributes: {
25319
25316
  "w:val": node.attributes?.["w:val"] ?? null
25320
25317
  }
25321
25318
  };
25322
25319
  };
25323
- const config$m = {
25324
- xmlName: XML_NODE_NAME$o,
25320
+ const config$n = {
25321
+ xmlName: XML_NODE_NAME$p,
25325
25322
  sdNodeOrKeyName: SD_ATTR_KEY$d,
25326
25323
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25327
- encode: encode$Q
25324
+ encode: encode$R
25328
25325
  };
25329
- const translator$10 = NodeTranslator.from(config$m);
25330
- const encode$P = (attributes) => attributes?.["w:val"];
25331
- const decode$I = (attrs) => attrs?.underline;
25326
+ const translator$11 = NodeTranslator.from(config$n);
25327
+ const encode$Q = (attributes) => attributes?.["w:val"];
25328
+ const decode$J = (attrs) => attrs?.underline;
25332
25329
  const attrConfig$r = Object.freeze({
25333
25330
  xmlName: "w:val",
25334
25331
  sdName: "underline",
25335
- encode: encode$P,
25336
- decode: decode$I
25332
+ encode: encode$Q,
25333
+ decode: decode$J
25337
25334
  });
25338
- const encode$O = (attributes) => attributes?.["w:color"];
25339
- const decode$H = (attrs) => attrs?.color;
25335
+ const encode$P = (attributes) => attributes?.["w:color"];
25336
+ const decode$I = (attrs) => attrs?.color;
25340
25337
  const attrConfig$q = Object.freeze({
25341
25338
  xmlName: "w:color",
25342
25339
  sdName: "color",
25343
- encode: encode$O,
25344
- decode: decode$H
25340
+ encode: encode$P,
25341
+ decode: decode$I
25345
25342
  });
25346
- const encode$N = (attributes) => attributes?.["w:themeColor"];
25347
- const decode$G = (attrs) => attrs?.themeColor;
25343
+ const encode$O = (attributes) => attributes?.["w:themeColor"];
25344
+ const decode$H = (attrs) => attrs?.themeColor;
25348
25345
  const attrConfig$p = Object.freeze({
25349
25346
  xmlName: "w:themeColor",
25350
25347
  sdName: "themeColor",
25351
- encode: encode$N,
25352
- decode: decode$G
25348
+ encode: encode$O,
25349
+ decode: decode$H
25353
25350
  });
25354
- const encode$M = (attributes) => attributes?.["w:themeTint"];
25355
- const decode$F = (attrs) => attrs?.themeTint;
25351
+ const encode$N = (attributes) => attributes?.["w:themeTint"];
25352
+ const decode$G = (attrs) => attrs?.themeTint;
25356
25353
  const attrConfig$o = Object.freeze({
25357
25354
  xmlName: "w:themeTint",
25358
25355
  sdName: "themeTint",
25359
- encode: encode$M,
25360
- decode: decode$F
25356
+ encode: encode$N,
25357
+ decode: decode$G
25361
25358
  });
25362
- const encode$L = (attributes) => attributes?.["w:themeShade"];
25363
- const decode$E = (attrs) => attrs?.themeShade;
25359
+ const encode$M = (attributes) => attributes?.["w:themeShade"];
25360
+ const decode$F = (attrs) => attrs?.themeShade;
25364
25361
  const attrConfig$n = Object.freeze({
25365
25362
  xmlName: "w:themeShade",
25366
25363
  sdName: "themeShade",
25367
- encode: encode$L,
25368
- decode: decode$E
25364
+ encode: encode$M,
25365
+ decode: decode$F
25369
25366
  });
25370
- const validXmlAttributes$g = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
25371
- const XML_NODE_NAME$n = "w:u";
25367
+ const validXmlAttributes$h = [attrConfig$r, attrConfig$q, attrConfig$p, attrConfig$o, attrConfig$n];
25368
+ const XML_NODE_NAME$o = "w:u";
25372
25369
  const SD_ATTR_KEY$c = "underline";
25373
- const encode$K = (params, encodedAttrs = {}) => {
25370
+ const encode$L = (params, encodedAttrs = {}) => {
25374
25371
  const { nodes } = params;
25375
25372
  const node = nodes?.[0];
25376
25373
  const sourceAttrs = node?.attributes || {};
@@ -25386,12 +25383,12 @@ const encode$K = (params, encodedAttrs = {}) => {
25386
25383
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25387
25384
  return {
25388
25385
  type: "attr",
25389
- xmlName: XML_NODE_NAME$n,
25386
+ xmlName: XML_NODE_NAME$o,
25390
25387
  sdNodeOrKeyName: SD_ATTR_KEY$c,
25391
25388
  attributes
25392
25389
  };
25393
25390
  };
25394
- const decode$D = (params) => {
25391
+ const decode$E = (params) => {
25395
25392
  const attrs = params?.node?.attrs || {};
25396
25393
  const underlineType = attrs.underlineType ?? attrs.underline ?? null;
25397
25394
  const color = attrs.underlineColor ?? attrs.color ?? null;
@@ -25409,20 +25406,20 @@ const decode$D = (params) => {
25409
25406
  if (themeTint) attributes["w:themeTint"] = themeTint;
25410
25407
  if (themeShade) attributes["w:themeShade"] = themeShade;
25411
25408
  return {
25412
- name: XML_NODE_NAME$n,
25409
+ name: XML_NODE_NAME$o,
25413
25410
  attributes
25414
25411
  };
25415
25412
  };
25416
- const config$l = {
25417
- xmlName: XML_NODE_NAME$n,
25413
+ const config$m = {
25414
+ xmlName: XML_NODE_NAME$o,
25418
25415
  sdNodeOrKeyName: SD_ATTR_KEY$c,
25419
25416
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25420
- encode: encode$K,
25421
- decode: decode$D,
25422
- attributes: validXmlAttributes$g
25417
+ encode: encode$L,
25418
+ decode: decode$E,
25419
+ attributes: validXmlAttributes$h
25423
25420
  };
25424
- const translator$$ = NodeTranslator.from(config$l);
25425
- const encode$J = (attributes) => {
25421
+ const translator$10 = NodeTranslator.from(config$m);
25422
+ const encode$K = (attributes) => {
25426
25423
  const raw = attributes?.["w:val"];
25427
25424
  if (raw === void 0 || raw === null) return void 0;
25428
25425
  if (typeof raw === "boolean") return raw;
@@ -25432,20 +25429,20 @@ const encode$J = (attributes) => {
25432
25429
  if (val === "1" || val === "true" || val === "on") return true;
25433
25430
  return void 0;
25434
25431
  };
25435
- const decode$C = (attrs) => {
25432
+ const decode$D = (attrs) => {
25436
25433
  if (attrs?.strike === false) return "0";
25437
25434
  return void 0;
25438
25435
  };
25439
25436
  const attrConfig$m = Object.freeze({
25440
25437
  xmlName: "w:val",
25441
25438
  sdName: "strike",
25442
- encode: encode$J,
25443
- decode: decode$C
25439
+ encode: encode$K,
25440
+ decode: decode$D
25444
25441
  });
25445
- const validXmlAttributes$f = [attrConfig$m];
25446
- const XML_NODE_NAME$m = "w:strike";
25442
+ const validXmlAttributes$g = [attrConfig$m];
25443
+ const XML_NODE_NAME$n = "w:strike";
25447
25444
  const SD_ATTR_KEY$b = "strike";
25448
- const encode$I = (params, encodedAttrs = {}) => {
25445
+ const encode$J = (params, encodedAttrs = {}) => {
25449
25446
  const { nodes } = params;
25450
25447
  const node = nodes?.[0];
25451
25448
  if (!node) return void 0;
@@ -25458,55 +25455,55 @@ const encode$I = (params, encodedAttrs = {}) => {
25458
25455
  else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
25459
25456
  return {
25460
25457
  type: "attr",
25461
- xmlName: XML_NODE_NAME$m,
25458
+ xmlName: XML_NODE_NAME$n,
25462
25459
  sdNodeOrKeyName: SD_ATTR_KEY$b,
25463
25460
  attributes
25464
25461
  };
25465
25462
  };
25466
- const config$k = {
25467
- xmlName: XML_NODE_NAME$m,
25463
+ const config$l = {
25464
+ xmlName: XML_NODE_NAME$n,
25468
25465
  sdNodeOrKeyName: SD_ATTR_KEY$b,
25469
25466
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25470
- encode: encode$I,
25471
- attributes: validXmlAttributes$f
25467
+ encode: encode$J,
25468
+ attributes: validXmlAttributes$g
25472
25469
  };
25473
- const translator$_ = NodeTranslator.from(config$k);
25474
- const encode$H = (attributes) => attributes?.["w:val"];
25475
- const decode$B = (attrs) => attrs?.color;
25470
+ const translator$$ = NodeTranslator.from(config$l);
25471
+ const encode$I = (attributes) => attributes?.["w:val"];
25472
+ const decode$C = (attrs) => attrs?.color;
25476
25473
  const attrConfig$l = Object.freeze({
25477
25474
  xmlName: "w:val",
25478
25475
  sdName: "color",
25479
- encode: encode$H,
25480
- decode: decode$B
25476
+ encode: encode$I,
25477
+ decode: decode$C
25481
25478
  });
25482
- const encode$G = (attributes) => attributes?.["w:themeColor"];
25483
- const decode$A = (attrs) => attrs?.themeColor;
25479
+ const encode$H = (attributes) => attributes?.["w:themeColor"];
25480
+ const decode$B = (attrs) => attrs?.themeColor;
25484
25481
  const attrConfig$k = Object.freeze({
25485
25482
  xmlName: "w:themeColor",
25486
25483
  sdName: "themeColor",
25487
- encode: encode$G,
25488
- decode: decode$A
25484
+ encode: encode$H,
25485
+ decode: decode$B
25489
25486
  });
25490
- const encode$F = (attributes) => attributes?.["w:themeTint"];
25491
- const decode$z = (attrs) => attrs?.themeTint;
25487
+ const encode$G = (attributes) => attributes?.["w:themeTint"];
25488
+ const decode$A = (attrs) => attrs?.themeTint;
25492
25489
  const attrConfig$j = Object.freeze({
25493
25490
  xmlName: "w:themeTint",
25494
25491
  sdName: "themeTint",
25495
- encode: encode$F,
25496
- decode: decode$z
25492
+ encode: encode$G,
25493
+ decode: decode$A
25497
25494
  });
25498
- const encode$E = (attributes) => attributes?.["w:themeShade"];
25499
- const decode$y = (attrs) => attrs?.themeShade;
25495
+ const encode$F = (attributes) => attributes?.["w:themeShade"];
25496
+ const decode$z = (attrs) => attrs?.themeShade;
25500
25497
  const attrConfig$i = Object.freeze({
25501
25498
  xmlName: "w:themeShade",
25502
25499
  sdName: "themeShade",
25503
- encode: encode$E,
25504
- decode: decode$y
25500
+ encode: encode$F,
25501
+ decode: decode$z
25505
25502
  });
25506
- const validXmlAttributes$e = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
25507
- const XML_NODE_NAME$l = "w:color";
25503
+ const validXmlAttributes$f = [attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
25504
+ const XML_NODE_NAME$m = "w:color";
25508
25505
  const SD_ATTR_KEY$a = "color";
25509
- const encode$D = (params, encodedAttrs = {}) => {
25506
+ const encode$E = (params, encodedAttrs = {}) => {
25510
25507
  const { nodes } = params;
25511
25508
  const node = nodes?.[0];
25512
25509
  const sourceAttrs = node?.attributes || {};
@@ -25521,63 +25518,63 @@ const encode$D = (params, encodedAttrs = {}) => {
25521
25518
  if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
25522
25519
  return {
25523
25520
  type: "attr",
25524
- xmlName: XML_NODE_NAME$l,
25521
+ xmlName: XML_NODE_NAME$m,
25525
25522
  sdNodeOrKeyName: SD_ATTR_KEY$a,
25526
25523
  attributes
25527
25524
  };
25528
25525
  };
25529
- const config$j = {
25530
- xmlName: XML_NODE_NAME$l,
25526
+ const config$k = {
25527
+ xmlName: XML_NODE_NAME$m,
25531
25528
  sdNodeOrKeyName: SD_ATTR_KEY$a,
25532
25529
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25533
- encode: encode$D,
25534
- attributes: validXmlAttributes$e
25530
+ encode: encode$E,
25531
+ attributes: validXmlAttributes$f
25535
25532
  };
25536
- const translator$Z = NodeTranslator.from(config$j);
25537
- const encode$C = (attributes) => attributes?.["w:eastAsia"];
25538
- const decode$x = (attrs) => attrs?.eastAsia;
25533
+ const translator$_ = NodeTranslator.from(config$k);
25534
+ const encode$D = (attributes) => attributes?.["w:eastAsia"];
25535
+ const decode$y = (attrs) => attrs?.eastAsia;
25539
25536
  const attrConfig$h = Object.freeze({
25540
25537
  xmlName: "w:eastAsia",
25541
25538
  sdName: "eastAsia",
25542
- encode: encode$C,
25543
- decode: decode$x
25539
+ encode: encode$D,
25540
+ decode: decode$y
25544
25541
  });
25545
- const encode$B = (attributes) => attributes?.["w:ascii"];
25546
- const decode$w = (attrs) => attrs?.ascii;
25542
+ const encode$C = (attributes) => attributes?.["w:ascii"];
25543
+ const decode$x = (attrs) => attrs?.ascii;
25547
25544
  const attrConfig$g = Object.freeze({
25548
25545
  xmlName: "w:ascii",
25549
25546
  sdName: "ascii",
25550
- encode: encode$B,
25551
- decode: decode$w
25547
+ encode: encode$C,
25548
+ decode: decode$x
25552
25549
  });
25553
- const encode$A = (attributes) => attributes?.["w:hAnsi"];
25554
- const decode$v = (attrs) => attrs?.hAnsi;
25550
+ const encode$B = (attributes) => attributes?.["w:hAnsi"];
25551
+ const decode$w = (attrs) => attrs?.hAnsi;
25555
25552
  const attrConfig$f = Object.freeze({
25556
25553
  xmlName: "w:hAnsi",
25557
25554
  sdName: "hAnsi",
25558
- encode: encode$A,
25559
- decode: decode$v
25555
+ encode: encode$B,
25556
+ decode: decode$w
25560
25557
  });
25561
- const encode$z = (attributes) => attributes?.["w:cs"];
25562
- const decode$u = (attrs) => attrs?.cs;
25558
+ const encode$A = (attributes) => attributes?.["w:cs"];
25559
+ const decode$v = (attrs) => attrs?.cs;
25563
25560
  const attrConfig$e = Object.freeze({
25564
25561
  xmlName: "w:cs",
25565
25562
  sdName: "cs",
25566
- encode: encode$z,
25567
- decode: decode$u
25563
+ encode: encode$A,
25564
+ decode: decode$v
25568
25565
  });
25569
- const encode$y = (attributes) => attributes?.["w:val"];
25570
- const decode$t = (attrs) => attrs?.value;
25566
+ const encode$z = (attributes) => attributes?.["w:val"];
25567
+ const decode$u = (attrs) => attrs?.value;
25571
25568
  const attrConfig$d = Object.freeze({
25572
25569
  xmlName: "w:val",
25573
25570
  sdName: "value",
25574
- encode: encode$y,
25575
- decode: decode$t
25571
+ encode: encode$z,
25572
+ decode: decode$u
25576
25573
  });
25577
- const validXmlAttributes$d = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
25578
- const XML_NODE_NAME$k = "w:rFonts";
25574
+ const validXmlAttributes$e = [attrConfig$h, attrConfig$g, attrConfig$f, attrConfig$e, attrConfig$d];
25575
+ const XML_NODE_NAME$l = "w:rFonts";
25579
25576
  const SD_ATTR_KEY$9 = "fontFamily";
25580
- const encode$x = (params, encodedAttrs = {}) => {
25577
+ const encode$y = (params, encodedAttrs = {}) => {
25581
25578
  const { nodes } = params;
25582
25579
  const node = nodes?.[0];
25583
25580
  const sourceAttrs = node?.attributes || {};
@@ -25603,120 +25600,120 @@ const encode$x = (params, encodedAttrs = {}) => {
25603
25600
  if (attributes["w:val"] === void 0) delete attributes["w:val"];
25604
25601
  return {
25605
25602
  type: "attr",
25606
- xmlName: XML_NODE_NAME$k,
25603
+ xmlName: XML_NODE_NAME$l,
25607
25604
  sdNodeOrKeyName: SD_ATTR_KEY$9,
25608
25605
  attributes
25609
25606
  };
25610
25607
  };
25611
- const config$i = {
25612
- xmlName: XML_NODE_NAME$k,
25608
+ const config$j = {
25609
+ xmlName: XML_NODE_NAME$l,
25613
25610
  sdNodeOrKeyName: SD_ATTR_KEY$9,
25614
25611
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25615
- encode: encode$x,
25616
- attributes: validXmlAttributes$d
25612
+ encode: encode$y,
25613
+ attributes: validXmlAttributes$e
25617
25614
  };
25618
- const translator$Y = NodeTranslator.from(config$i);
25619
- const encode$w = (attributes) => attributes?.["w:val"];
25620
- const decode$s = (attrs) => attrs?.styleId;
25615
+ const translator$Z = NodeTranslator.from(config$j);
25616
+ const encode$x = (attributes) => attributes?.["w:val"];
25617
+ const decode$t = (attrs) => attrs?.styleId;
25621
25618
  const attrConfig$c = Object.freeze({
25622
25619
  xmlName: "w:val",
25623
25620
  sdName: "styleId",
25624
- encode: encode$w,
25625
- decode: decode$s
25621
+ encode: encode$x,
25622
+ decode: decode$t
25626
25623
  });
25627
- const validXmlAttributes$c = [attrConfig$c];
25628
- const XML_NODE_NAME$j = "w:rStyle";
25624
+ const validXmlAttributes$d = [attrConfig$c];
25625
+ const XML_NODE_NAME$k = "w:rStyle";
25629
25626
  const SD_ATTR_KEY$8 = "styleId";
25630
- const encode$v = (params, encodedAttrs = {}) => {
25627
+ const encode$w = (params, encodedAttrs = {}) => {
25631
25628
  const { nodes } = params;
25632
25629
  const node = nodes?.[0];
25633
25630
  const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
25634
25631
  return {
25635
25632
  type: "attr",
25636
- xmlName: XML_NODE_NAME$j,
25633
+ xmlName: XML_NODE_NAME$k,
25637
25634
  sdNodeOrKeyName: SD_ATTR_KEY$8,
25638
25635
  attributes: { "w:val": value ?? null }
25639
25636
  };
25640
25637
  };
25641
- const config$h = {
25642
- xmlName: XML_NODE_NAME$j,
25638
+ const config$i = {
25639
+ xmlName: XML_NODE_NAME$k,
25643
25640
  sdNodeOrKeyName: SD_ATTR_KEY$8,
25644
25641
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25645
- encode: encode$v,
25646
- attributes: validXmlAttributes$c
25642
+ encode: encode$w,
25643
+ attributes: validXmlAttributes$d
25647
25644
  };
25648
- const translator$X = NodeTranslator.from(config$h);
25649
- const encode$u = (attributes) => attributes?.["w:val"];
25650
- const decode$r = (attrs) => attrs?.fontSize;
25645
+ const translator$Y = NodeTranslator.from(config$i);
25646
+ const encode$v = (attributes) => attributes?.["w:val"];
25647
+ const decode$s = (attrs) => attrs?.fontSize;
25651
25648
  const attrConfig$b = Object.freeze({
25652
25649
  xmlName: "w:val",
25653
25650
  sdName: "fontSize",
25654
- encode: encode$u,
25655
- decode: decode$r
25651
+ encode: encode$v,
25652
+ decode: decode$s
25656
25653
  });
25657
- const validXmlAttributes$b = [attrConfig$b];
25658
- const XML_NODE_NAME$i = "w:sz";
25654
+ const validXmlAttributes$c = [attrConfig$b];
25655
+ const XML_NODE_NAME$j = "w:sz";
25659
25656
  const SD_ATTR_KEY$7 = "fontSize";
25660
- const encode$t = (params, encodedAttrs = {}) => {
25657
+ const encode$u = (params, encodedAttrs = {}) => {
25661
25658
  const { nodes } = params;
25662
25659
  const node = nodes?.[0];
25663
25660
  const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
25664
25661
  return {
25665
25662
  type: "attr",
25666
- xmlName: XML_NODE_NAME$i,
25663
+ xmlName: XML_NODE_NAME$j,
25667
25664
  sdNodeOrKeyName: SD_ATTR_KEY$7,
25668
25665
  attributes: { "w:val": value ?? null }
25669
25666
  };
25670
25667
  };
25671
- const config$g = {
25672
- xmlName: XML_NODE_NAME$i,
25668
+ const config$h = {
25669
+ xmlName: XML_NODE_NAME$j,
25673
25670
  sdNodeOrKeyName: SD_ATTR_KEY$7,
25674
25671
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25675
- encode: encode$t,
25676
- attributes: validXmlAttributes$b
25672
+ encode: encode$u,
25673
+ attributes: validXmlAttributes$c
25677
25674
  };
25678
- const translator$W = NodeTranslator.from(config$g);
25679
- const encode$s = (attributes) => attributes?.["w:val"];
25680
- const decode$q = (attrs) => attrs?.fontSizeCs;
25675
+ const translator$X = NodeTranslator.from(config$h);
25676
+ const encode$t = (attributes) => attributes?.["w:val"];
25677
+ const decode$r = (attrs) => attrs?.fontSizeCs;
25681
25678
  const attrConfig$a = Object.freeze({
25682
25679
  xmlName: "w:val",
25683
25680
  sdName: "fontSizeCs",
25684
- encode: encode$s,
25685
- decode: decode$q
25681
+ encode: encode$t,
25682
+ decode: decode$r
25686
25683
  });
25687
- const validXmlAttributes$a = [attrConfig$a];
25688
- const XML_NODE_NAME$h = "w:szCs";
25684
+ const validXmlAttributes$b = [attrConfig$a];
25685
+ const XML_NODE_NAME$i = "w:szCs";
25689
25686
  const SD_ATTR_KEY$6 = "fontSizeCs";
25690
- const encode$r = (params, encodedAttrs = {}) => {
25687
+ const encode$s = (params, encodedAttrs = {}) => {
25691
25688
  const { nodes } = params;
25692
25689
  const node = nodes?.[0];
25693
25690
  const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
25694
25691
  return {
25695
25692
  type: "attr",
25696
- xmlName: XML_NODE_NAME$h,
25693
+ xmlName: XML_NODE_NAME$i,
25697
25694
  sdNodeOrKeyName: SD_ATTR_KEY$6,
25698
25695
  attributes: { "w:val": value ?? null }
25699
25696
  };
25700
25697
  };
25701
- const config$f = {
25702
- xmlName: XML_NODE_NAME$h,
25698
+ const config$g = {
25699
+ xmlName: XML_NODE_NAME$i,
25703
25700
  sdNodeOrKeyName: SD_ATTR_KEY$6,
25704
25701
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25705
- encode: encode$r,
25706
- attributes: validXmlAttributes$a
25702
+ encode: encode$s,
25703
+ attributes: validXmlAttributes$b
25707
25704
  };
25708
- const translator$V = NodeTranslator.from(config$f);
25705
+ const translator$W = NodeTranslator.from(config$g);
25709
25706
  const runPropertyTranslators = Object.freeze({
25710
- "w:b": translator$11,
25711
- "w:i": translator$10,
25712
- "w:u": translator$$,
25713
- "w:strike": translator$_,
25714
- "w:color": translator$Z,
25715
- "w:highlight": translator$14,
25716
- "w:rFonts": translator$Y,
25717
- "w:rStyle": translator$X,
25718
- "w:sz": translator$W,
25719
- "w:szCs": translator$V
25707
+ "w:b": translator$12,
25708
+ "w:i": translator$11,
25709
+ "w:u": translator$10,
25710
+ "w:strike": translator$$,
25711
+ "w:color": translator$_,
25712
+ "w:highlight": translator$15,
25713
+ "w:rFonts": translator$Z,
25714
+ "w:rStyle": translator$Y,
25715
+ "w:sz": translator$X,
25716
+ "w:szCs": translator$W
25720
25717
  });
25721
25718
  const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
25722
25719
  const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
@@ -25730,9 +25727,9 @@ const toRunPropertyEntry = (candidate) => {
25730
25727
  attributes: { ...candidate.attributes || {} }
25731
25728
  };
25732
25729
  };
25733
- const XML_NODE_NAME$g = "w:rPr";
25730
+ const XML_NODE_NAME$h = "w:rPr";
25734
25731
  const SD_ATTR_KEY$5 = "runProperties";
25735
- const encode$q = (params) => {
25732
+ const encode$r = (params) => {
25736
25733
  const { nodes } = params;
25737
25734
  const node = nodes?.[0] || {};
25738
25735
  const contents = Array.isArray(node.elements) ? node.elements : [];
@@ -25766,16 +25763,16 @@ const encode$q = (params) => {
25766
25763
  attributes: runPropsArray
25767
25764
  };
25768
25765
  };
25769
- const config$e = {
25770
- xmlName: XML_NODE_NAME$g,
25766
+ const config$f = {
25767
+ xmlName: XML_NODE_NAME$h,
25771
25768
  sdNodeOrKeyName: SD_ATTR_KEY$5,
25772
25769
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25773
- encode: encode$q
25770
+ encode: encode$r
25774
25771
  };
25775
- const translator$U = NodeTranslator.from(config$e);
25772
+ const translator$V = NodeTranslator.from(config$f);
25776
25773
  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;
25777
25774
  const containsEastAsianCharacters = (text) => EAST_ASIAN_CHARACTER_REGEX.test(text);
25778
- const collectRunProperties = (params, rPrNode, translator2 = translator$U) => {
25775
+ const collectRunProperties = (params, rPrNode, translator2 = translator$V) => {
25779
25776
  if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
25780
25777
  const result = translator2.encode({ ...params, nodes: [rPrNode] }) || {};
25781
25778
  let entries = [];
@@ -26237,46 +26234,46 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
26237
26234
  }
26238
26235
  return runs;
26239
26236
  };
26240
- const encode$p = (attributes) => {
26237
+ const encode$q = (attributes) => {
26241
26238
  return attributes["w:rsidR"];
26242
26239
  };
26243
- const decode$p = (attrs) => {
26240
+ const decode$q = (attrs) => {
26244
26241
  return attrs.rsidR;
26245
26242
  };
26246
26243
  const attrConfig$9 = Object.freeze({
26247
26244
  xmlName: "w:rsidR",
26248
26245
  sdName: "rsidR",
26249
- encode: encode$p,
26250
- decode: decode$p
26246
+ encode: encode$q,
26247
+ decode: decode$q
26251
26248
  });
26252
- const encode$o = (attributes) => {
26249
+ const encode$p = (attributes) => {
26253
26250
  return attributes["w:rsidRPr"];
26254
26251
  };
26255
- const decode$o = (attrs) => {
26252
+ const decode$p = (attrs) => {
26256
26253
  return attrs.rsidRPr;
26257
26254
  };
26258
26255
  const attrConfig$8 = Object.freeze({
26259
26256
  xmlName: "w:rsidRPr",
26260
26257
  sdName: "rsidRPr",
26261
- encode: encode$o,
26262
- decode: decode$o
26258
+ encode: encode$p,
26259
+ decode: decode$p
26263
26260
  });
26264
- const encode$n = (attributes) => {
26261
+ const encode$o = (attributes) => {
26265
26262
  return attributes["w:rsidDel"];
26266
26263
  };
26267
- const decode$n = (attrs) => {
26264
+ const decode$o = (attrs) => {
26268
26265
  return attrs.rsidDel;
26269
26266
  };
26270
26267
  const attrConfig$7 = Object.freeze({
26271
26268
  xmlName: "w:rsidDel",
26272
26269
  sdName: "rsidDel",
26273
- encode: encode$n,
26274
- decode: decode$n
26270
+ encode: encode$o,
26271
+ decode: decode$o
26275
26272
  });
26276
- const validXmlAttributes$9 = [attrConfig$9, attrConfig$8, attrConfig$7];
26277
- const XML_NODE_NAME$f = "w:r";
26273
+ const validXmlAttributes$a = [attrConfig$9, attrConfig$8, attrConfig$7];
26274
+ const XML_NODE_NAME$g = "w:r";
26278
26275
  const SD_KEY_NAME = "run";
26279
- const encode$m = (params, encodedAttrs = {}) => {
26276
+ const encode$n = (params, encodedAttrs = {}) => {
26280
26277
  const { nodes = [], nodeListHandler } = params || {};
26281
26278
  const runNode = nodes[0];
26282
26279
  if (!runNode) return void 0;
@@ -26324,7 +26321,7 @@ const encode$m = (params, encodedAttrs = {}) => {
26324
26321
  }
26325
26322
  return runNodeResult;
26326
26323
  };
26327
- const decode$m = (params, decodedAttrs = {}) => {
26324
+ const decode$n = (params, decodedAttrs = {}) => {
26328
26325
  const { node } = params || {};
26329
26326
  if (!node) return void 0;
26330
26327
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node);
@@ -26381,7 +26378,7 @@ const decode$m = (params, decodedAttrs = {}) => {
26381
26378
  runs.push(trackedClone);
26382
26379
  return;
26383
26380
  }
26384
- const runWrapper = { name: XML_NODE_NAME$f, elements: [] };
26381
+ const runWrapper = { name: XML_NODE_NAME$g, elements: [] };
26385
26382
  applyBaseRunProps(runWrapper);
26386
26383
  if (!Array.isArray(runWrapper.elements)) runWrapper.elements = [];
26387
26384
  runWrapper.elements.push(cloneXmlNode(child));
@@ -26389,7 +26386,7 @@ const decode$m = (params, decodedAttrs = {}) => {
26389
26386
  });
26390
26387
  const trackedRuns = ensureTrackedWrapper(runs, trackingMarksByType);
26391
26388
  if (!trackedRuns.length) {
26392
- const emptyRun = { name: XML_NODE_NAME$f, elements: [] };
26389
+ const emptyRun = { name: XML_NODE_NAME$g, elements: [] };
26393
26390
  applyBaseRunProps(emptyRun);
26394
26391
  trackedRuns.push(emptyRun);
26395
26392
  }
@@ -26403,15 +26400,15 @@ const decode$m = (params, decodedAttrs = {}) => {
26403
26400
  }
26404
26401
  return trackedRuns;
26405
26402
  };
26406
- const config$d = {
26407
- xmlName: XML_NODE_NAME$f,
26403
+ const config$e = {
26404
+ xmlName: XML_NODE_NAME$g,
26408
26405
  sdNodeOrKeyName: SD_KEY_NAME,
26409
26406
  type: NodeTranslator.translatorTypes.NODE,
26410
- encode: encode$m,
26411
- decode: decode$m,
26412
- attributes: validXmlAttributes$9
26407
+ encode: encode$n,
26408
+ decode: decode$n,
26409
+ attributes: validXmlAttributes$a
26413
26410
  };
26414
- const translator$T = NodeTranslator.from(config$d);
26411
+ const translator$U = NodeTranslator.from(config$e);
26415
26412
  const generateV2HandlerEntity = (handlerName, translator2) => ({
26416
26413
  handlerName,
26417
26414
  handler: (params) => {
@@ -26585,13 +26582,13 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
26585
26582
  }
26586
26583
  return table;
26587
26584
  }
26588
- const translator$S = NodeTranslator.from({
26585
+ const translator$T = NodeTranslator.from({
26589
26586
  xmlName: "w:cantSplit",
26590
26587
  sdNodeOrKeyName: "cantSplit",
26591
26588
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
26592
26589
  decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
26593
26590
  });
26594
- const translator$R = NodeTranslator.from({
26591
+ const translator$S = NodeTranslator.from({
26595
26592
  xmlName: "w:cnfStyle",
26596
26593
  sdNodeOrKeyName: "cnfStyle",
26597
26594
  attributes: [
@@ -26617,8 +26614,8 @@ const translator$R = NodeTranslator.from({
26617
26614
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26618
26615
  }
26619
26616
  });
26620
- const translator$Q = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26621
- const translator$P = NodeTranslator.from(
26617
+ const translator$R = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
26618
+ const translator$Q = NodeTranslator.from(
26622
26619
  createSingleAttrPropertyHandler(
26623
26620
  "w:gridAfter",
26624
26621
  null,
@@ -26627,7 +26624,7 @@ const translator$P = NodeTranslator.from(
26627
26624
  (v2) => integerToString(v2)
26628
26625
  )
26629
26626
  );
26630
- const translator$O = NodeTranslator.from(
26627
+ const translator$P = NodeTranslator.from(
26631
26628
  createSingleAttrPropertyHandler(
26632
26629
  "w:gridBefore",
26633
26630
  null,
@@ -26636,21 +26633,21 @@ const translator$O = NodeTranslator.from(
26636
26633
  (v2) => integerToString(v2)
26637
26634
  )
26638
26635
  );
26639
- const translator$N = NodeTranslator.from({
26636
+ const translator$O = NodeTranslator.from({
26640
26637
  xmlName: "w:hidden",
26641
26638
  sdNodeOrKeyName: "hidden",
26642
26639
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26643
26640
  decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
26644
26641
  });
26645
- const translator$M = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26646
- const translator$L = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26647
- const translator$K = NodeTranslator.from({
26642
+ const translator$N = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
26643
+ const translator$M = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
26644
+ const translator$L = NodeTranslator.from({
26648
26645
  xmlName: "w:tblHeader",
26649
26646
  sdNodeOrKeyName: "repeatHeader",
26650
26647
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26651
26648
  decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
26652
26649
  });
26653
- const translator$J = NodeTranslator.from({
26650
+ const translator$K = NodeTranslator.from({
26654
26651
  xmlName: "w:trHeight",
26655
26652
  sdNodeOrKeyName: "rowHeight",
26656
26653
  encode: ({ nodes }) => {
@@ -26677,11 +26674,11 @@ const translator$J = NodeTranslator.from({
26677
26674
  return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
26678
26675
  }
26679
26676
  });
26680
- const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26681
- const translator$H = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26682
- const XML_NODE_NAME$e = "w:trPr";
26677
+ const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
26678
+ const translator$I = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
26679
+ const XML_NODE_NAME$f = "w:trPr";
26683
26680
  const SD_ATTR_KEY$4 = "tableRowProperties";
26684
- const encode$l = (params) => {
26681
+ const encode$m = (params) => {
26685
26682
  const { nodes } = params;
26686
26683
  const node = nodes[0];
26687
26684
  let attributes = {
@@ -26695,12 +26692,12 @@ const encode$l = (params) => {
26695
26692
  };
26696
26693
  return {
26697
26694
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26698
- xmlName: XML_NODE_NAME$e,
26695
+ xmlName: XML_NODE_NAME$f,
26699
26696
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26700
26697
  attributes
26701
26698
  };
26702
26699
  };
26703
- const decode$l = (params) => {
26700
+ const decode$m = (params) => {
26704
26701
  const { tableRowProperties = {} } = params.node.attrs || {};
26705
26702
  const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
26706
26703
  const newNode = {
@@ -26712,6 +26709,7 @@ const decode$l = (params) => {
26712
26709
  return newNode;
26713
26710
  };
26714
26711
  const propertyTranslators$3 = [
26712
+ translator$T,
26715
26713
  translator$S,
26716
26714
  translator$R,
26717
26715
  translator$Q,
@@ -26722,8 +26720,7 @@ const propertyTranslators$3 = [
26722
26720
  translator$L,
26723
26721
  translator$K,
26724
26722
  translator$J,
26725
- translator$I,
26726
- translator$H
26723
+ translator$I
26727
26724
  ];
26728
26725
  const propertyTranslatorsByXmlName$2 = {};
26729
26726
  propertyTranslators$3.forEach((translator2) => {
@@ -26733,25 +26730,25 @@ const propertyTranslatorsBySdName$2 = {};
26733
26730
  propertyTranslators$3.forEach((translator2) => {
26734
26731
  propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
26735
26732
  });
26736
- const config$c = {
26737
- xmlName: XML_NODE_NAME$e,
26733
+ const config$d = {
26734
+ xmlName: XML_NODE_NAME$f,
26738
26735
  sdNodeOrKeyName: SD_ATTR_KEY$4,
26739
26736
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
26740
- encode: encode$l,
26741
- decode: decode$l
26737
+ encode: encode$m,
26738
+ decode: decode$m
26742
26739
  };
26743
- const translator$G = NodeTranslator.from(config$c);
26744
- const XML_NODE_NAME$d = "w:tr";
26745
- const SD_NODE_NAME$9 = "tableRow";
26746
- const validXmlAttributes$8 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26740
+ const translator$H = NodeTranslator.from(config$d);
26741
+ const XML_NODE_NAME$e = "w:tr";
26742
+ const SD_NODE_NAME$a = "tableRow";
26743
+ const validXmlAttributes$9 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
26747
26744
  (xmlName) => createAttributeHandler(xmlName)
26748
26745
  );
26749
- const encode$k = (params, encodedAttrs) => {
26746
+ const encode$l = (params, encodedAttrs) => {
26750
26747
  const { row } = params.extraParams;
26751
26748
  let tableRowProperties = {};
26752
26749
  const tPr = row.elements.find((el) => el.name === "w:trPr");
26753
26750
  if (tPr) {
26754
- ({ attributes: tableRowProperties } = translator$G.encode({
26751
+ ({ attributes: tableRowProperties } = translator$H.encode({
26755
26752
  ...params,
26756
26753
  nodes: [tPr]
26757
26754
  }));
@@ -26764,7 +26761,7 @@ const encode$k = (params, encodedAttrs) => {
26764
26761
  let currentColumnIndex = 0;
26765
26762
  const content = cellNodes?.map((n) => {
26766
26763
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
26767
- const result = translator$7.encode({
26764
+ const result = translator$8.encode({
26768
26765
  ...params,
26769
26766
  extraParams: {
26770
26767
  ...params.extraParams,
@@ -26786,7 +26783,7 @@ const encode$k = (params, encodedAttrs) => {
26786
26783
  };
26787
26784
  return newNode;
26788
26785
  };
26789
- const decode$k = (params, decodedAttrs) => {
26786
+ const decode$l = (params, decodedAttrs) => {
26790
26787
  const { node } = params;
26791
26788
  const elements = translateChildNodes(params);
26792
26789
  if (node.attrs?.tableRowProperties) {
@@ -26798,7 +26795,7 @@ const decode$k = (params, decodedAttrs) => {
26798
26795
  }
26799
26796
  }
26800
26797
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
26801
- const trPr = translator$G.decode({
26798
+ const trPr = translator$H.decode({
26802
26799
  ...params,
26803
26800
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
26804
26801
  });
@@ -26810,22 +26807,22 @@ const decode$k = (params, decodedAttrs) => {
26810
26807
  elements
26811
26808
  };
26812
26809
  };
26813
- const config$b = {
26814
- xmlName: XML_NODE_NAME$d,
26815
- sdNodeOrKeyName: SD_NODE_NAME$9,
26810
+ const config$c = {
26811
+ xmlName: XML_NODE_NAME$e,
26812
+ sdNodeOrKeyName: SD_NODE_NAME$a,
26816
26813
  type: NodeTranslator.translatorTypes.NODE,
26817
- encode: encode$k,
26818
- decode: decode$k,
26819
- attributes: validXmlAttributes$8
26814
+ encode: encode$l,
26815
+ decode: decode$l,
26816
+ attributes: validXmlAttributes$9
26820
26817
  };
26821
- const translator$F = NodeTranslator.from(config$b);
26822
- const translator$E = NodeTranslator.from({
26818
+ const translator$G = NodeTranslator.from(config$c);
26819
+ const translator$F = NodeTranslator.from({
26823
26820
  xmlName: "w:bidiVisual",
26824
26821
  sdNodeOrKeyName: "rightToLeft",
26825
26822
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
26826
26823
  decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
26827
26824
  });
26828
- const translator$D = NodeTranslator.from({
26825
+ const translator$E = NodeTranslator.from({
26829
26826
  xmlName: "w:shd",
26830
26827
  sdNodeOrKeyName: "shading",
26831
26828
  attributes: [
@@ -26847,11 +26844,11 @@ const translator$D = NodeTranslator.from({
26847
26844
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26848
26845
  }
26849
26846
  });
26850
- const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26851
- const translator$B = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26852
- const translator$A = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26853
- const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26854
- const translator$y = NodeTranslator.from({
26847
+ const translator$D = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
26848
+ const translator$C = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
26849
+ const translator$B = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
26850
+ const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
26851
+ const translator$z = NodeTranslator.from({
26855
26852
  xmlName: "w:tblLook",
26856
26853
  sdNodeOrKeyName: "tblLook",
26857
26854
  attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
@@ -26863,16 +26860,16 @@ const translator$y = NodeTranslator.from({
26863
26860
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26864
26861
  }
26865
26862
  });
26866
- const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26867
- const translator$w = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26868
- const translator$v = NodeTranslator.from(
26863
+ const translator$y = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
26864
+ const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
26865
+ const translator$w = NodeTranslator.from(
26869
26866
  createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
26870
26867
  );
26871
- const translator$u = NodeTranslator.from(
26868
+ const translator$v = NodeTranslator.from(
26872
26869
  createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
26873
26870
  );
26874
- const translator$t = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26875
- const translator$s = NodeTranslator.from({
26871
+ const translator$u = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
26872
+ const translator$t = NodeTranslator.from({
26876
26873
  xmlName: "w:tblpPr",
26877
26874
  sdNodeOrKeyName: "floatingTableProperties",
26878
26875
  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))),
@@ -26884,29 +26881,29 @@ const translator$s = NodeTranslator.from({
26884
26881
  return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
26885
26882
  }
26886
26883
  });
26887
- const translator$r = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
26888
- const translator$q = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
26889
- const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:end"));
26890
- const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
26891
- const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
26892
- const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
26893
- const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:left"));
26894
- const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
26895
- const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:right"));
26896
- const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
26897
- const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:start"));
26898
- const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
26899
- const translator$f = NodeTranslator.from(createBorderPropertyHandler("w:top"));
26900
- const translator$e = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
26901
- const XML_NODE_NAME$c = "w:tblBorders";
26884
+ const translator$s = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
26885
+ const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
26886
+ const translator$q = NodeTranslator.from(createBorderPropertyHandler("w:end"));
26887
+ const translator$p = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
26888
+ const translator$o = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
26889
+ const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
26890
+ const translator$m = NodeTranslator.from(createBorderPropertyHandler("w:left"));
26891
+ const translator$l = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
26892
+ const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:right"));
26893
+ const translator$j = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
26894
+ const translator$i = NodeTranslator.from(createBorderPropertyHandler("w:start"));
26895
+ const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
26896
+ const translator$g = NodeTranslator.from(createBorderPropertyHandler("w:top"));
26897
+ const translator$f = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
26898
+ const XML_NODE_NAME$d = "w:tblBorders";
26902
26899
  const SD_ATTR_KEY$3 = "borders";
26903
- const encode$j = (params) => {
26900
+ const encode$k = (params) => {
26904
26901
  const { nodes } = params;
26905
26902
  const node = nodes[0];
26906
26903
  const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
26907
26904
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26908
26905
  };
26909
- const decode$j = (params) => {
26906
+ const decode$k = (params) => {
26910
26907
  const { borders = {} } = params.node.attrs || {};
26911
26908
  const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
26912
26909
  const newNode = {
@@ -26918,14 +26915,14 @@ const decode$j = (params) => {
26918
26915
  return newNode;
26919
26916
  };
26920
26917
  const propertyTranslators$2 = [
26921
- translator$r,
26922
- translator$p,
26918
+ translator$s,
26919
+ translator$q,
26920
+ translator$o,
26923
26921
  translator$n,
26924
26922
  translator$m,
26925
- translator$l,
26926
- translator$j,
26927
- translator$h,
26928
- translator$f
26923
+ translator$k,
26924
+ translator$i,
26925
+ translator$g
26929
26926
  ];
26930
26927
  const tblBordersTranslatorsByXmlName = {};
26931
26928
  const tblBordersTranslatorsBySdName = {};
@@ -26933,27 +26930,27 @@ propertyTranslators$2.forEach((translator2) => {
26933
26930
  tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
26934
26931
  tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
26935
26932
  });
26936
- const translator$d = NodeTranslator.from({
26937
- xmlName: XML_NODE_NAME$c,
26933
+ const translator$e = NodeTranslator.from({
26934
+ xmlName: XML_NODE_NAME$d,
26938
26935
  sdNodeOrKeyName: SD_ATTR_KEY$3,
26939
26936
  type: NodeTranslator.translatorTypes.NODE,
26940
26937
  attributes: [],
26941
- encode: encode$j,
26942
- decode: decode$j
26938
+ encode: encode$k,
26939
+ decode: decode$k
26943
26940
  });
26944
- const XML_NODE_NAME$b = "w:tblCellMar";
26941
+ const XML_NODE_NAME$c = "w:tblCellMar";
26945
26942
  const SD_ATTR_KEY$2 = "cellMargins";
26946
- const encode$i = (params) => {
26943
+ const encode$j = (params) => {
26947
26944
  const { nodes } = params;
26948
26945
  const node = nodes[0];
26949
26946
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
26950
26947
  return Object.keys(attributes).length > 0 ? attributes : void 0;
26951
26948
  };
26952
- const decode$i = (params) => {
26949
+ const decode$j = (params) => {
26953
26950
  const { cellMargins = {} } = params.node.attrs || {};
26954
26951
  const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
26955
26952
  const newNode = {
26956
- name: XML_NODE_NAME$b,
26953
+ name: XML_NODE_NAME$c,
26957
26954
  type: "element",
26958
26955
  attributes: {},
26959
26956
  elements
@@ -26961,12 +26958,12 @@ const decode$i = (params) => {
26961
26958
  return newNode;
26962
26959
  };
26963
26960
  const propertyTranslators$1 = [
26964
- translator$q,
26965
- translator$o,
26966
- translator$k,
26967
- translator$i,
26968
- translator$g,
26969
- translator$e
26961
+ translator$r,
26962
+ translator$p,
26963
+ translator$l,
26964
+ translator$j,
26965
+ translator$h,
26966
+ translator$f
26970
26967
  ];
26971
26968
  const propertyTranslatorsByXmlName$1 = {};
26972
26969
  const propertyTranslatorsBySdName$1 = {};
@@ -26974,27 +26971,27 @@ propertyTranslators$1.forEach((translator2) => {
26974
26971
  propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
26975
26972
  propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
26976
26973
  });
26977
- const translator$c = NodeTranslator.from({
26978
- xmlName: XML_NODE_NAME$b,
26974
+ const translator$d = NodeTranslator.from({
26975
+ xmlName: XML_NODE_NAME$c,
26979
26976
  sdNodeOrKeyName: SD_ATTR_KEY$2,
26980
26977
  type: NodeTranslator.translatorTypes.NODE,
26981
26978
  attributes: [],
26982
- encode: encode$i,
26983
- decode: decode$i
26979
+ encode: encode$j,
26980
+ decode: decode$j
26984
26981
  });
26985
- const XML_NODE_NAME$a = "w:tblPr";
26982
+ const XML_NODE_NAME$b = "w:tblPr";
26986
26983
  const SD_ATTR_KEY$1 = "tableProperties";
26987
- const encode$h = (params) => {
26984
+ const encode$i = (params) => {
26988
26985
  const { nodes } = params;
26989
26986
  const node = nodes[0];
26990
26987
  const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
26991
26988
  return {
26992
- xmlName: XML_NODE_NAME$a,
26989
+ xmlName: XML_NODE_NAME$b,
26993
26990
  sdNodeOrKeyName: SD_ATTR_KEY$1,
26994
26991
  attributes
26995
26992
  };
26996
26993
  };
26997
- const decode$h = (params) => {
26994
+ const decode$i = (params) => {
26998
26995
  const { tableProperties = {} } = params.node.attrs || {};
26999
26996
  const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
27000
26997
  const newNode = {
@@ -27006,11 +27003,12 @@ const decode$h = (params) => {
27006
27003
  return newNode;
27007
27004
  };
27008
27005
  const propertyTranslators = [
27006
+ translator$F,
27007
+ translator$N,
27009
27008
  translator$E,
27010
- translator$M,
27011
27009
  translator$D,
27010
+ translator$M,
27012
27011
  translator$C,
27013
- translator$L,
27014
27012
  translator$B,
27015
27013
  translator$A,
27016
27014
  translator$z,
@@ -27020,9 +27018,8 @@ const propertyTranslators = [
27020
27018
  translator$v,
27021
27019
  translator$u,
27022
27020
  translator$t,
27023
- translator$s,
27024
- translator$d,
27025
- translator$c
27021
+ translator$e,
27022
+ translator$d
27026
27023
  ];
27027
27024
  const propertyTranslatorsByXmlName = {};
27028
27025
  const propertyTranslatorsBySdName = {};
@@ -27030,14 +27027,14 @@ propertyTranslators.forEach((translator2) => {
27030
27027
  propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
27031
27028
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
27032
27029
  });
27033
- const config$a = {
27034
- xmlName: XML_NODE_NAME$a,
27030
+ const config$b = {
27031
+ xmlName: XML_NODE_NAME$b,
27035
27032
  sdNodeOrKeyName: SD_ATTR_KEY$1,
27036
- encode: encode$h,
27037
- decode: decode$h
27033
+ encode: encode$i,
27034
+ decode: decode$i
27038
27035
  };
27039
- const translator$b = NodeTranslator.from(config$a);
27040
- const translator$a = NodeTranslator.from(
27036
+ const translator$c = NodeTranslator.from(config$b);
27037
+ const translator$b = NodeTranslator.from(
27041
27038
  createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
27042
27039
  );
27043
27040
  const DEFAULT_COLUMN_WIDTH_PX = 100;
@@ -27087,20 +27084,20 @@ const resolveFallbackColumnWidthTwips = (params, totalColumns, cellMinWidthTwips
27087
27084
  }
27088
27085
  return Math.max(fallbackWidthTwips, cellMinWidthTwips);
27089
27086
  };
27090
- const XML_NODE_NAME$9 = "w:tblGrid";
27087
+ const XML_NODE_NAME$a = "w:tblGrid";
27091
27088
  const SD_ATTR_KEY = "grid";
27092
27089
  const cellMinWidth = pixelsToTwips(10);
27093
- const encode$g = (params) => {
27090
+ const encode$h = (params) => {
27094
27091
  const { nodes } = params;
27095
27092
  const node = nodes[0];
27096
- const attributes = encodeProperties(node, { [translator$a.xmlName]: translator$a }, true);
27093
+ const attributes = encodeProperties(node, { [translator$b.xmlName]: translator$b }, true);
27097
27094
  return {
27098
- xmlName: XML_NODE_NAME$9,
27095
+ xmlName: XML_NODE_NAME$a,
27099
27096
  sdNodeOrKeyName: SD_ATTR_KEY,
27100
27097
  attributes
27101
27098
  };
27102
27099
  };
27103
- const decode$g = (params) => {
27100
+ const decode$h = (params) => {
27104
27101
  const { grid: rawGrid } = params.node.attrs || {};
27105
27102
  const grid = Array.isArray(rawGrid) ? rawGrid : [];
27106
27103
  const { firstRow = {} } = params.extraParams || {};
@@ -27119,10 +27116,10 @@ const decode$g = (params) => {
27119
27116
  numericWidth = fallbackColumnWidthTwips;
27120
27117
  }
27121
27118
  numericWidth = Math.max(numericWidth, cellMinWidth);
27122
- const decoded = translator$a.decode({
27119
+ const decoded = translator$b.decode({
27123
27120
  node: { type: (
27124
27121
  /** @type {string} */
27125
- translator$a.sdNodeOrKeyName
27122
+ translator$b.sdNodeOrKeyName
27126
27123
  ), attrs: { col: numericWidth } }
27127
27124
  });
27128
27125
  if (decoded) elements.push(decoded);
@@ -27157,39 +27154,100 @@ const decode$g = (params) => {
27157
27154
  columnIndex++;
27158
27155
  }
27159
27156
  const newNode = {
27160
- name: XML_NODE_NAME$9,
27157
+ name: XML_NODE_NAME$a,
27161
27158
  attributes: {},
27162
27159
  elements
27163
27160
  };
27164
27161
  return newNode;
27165
27162
  };
27166
- const config$9 = {
27167
- xmlName: XML_NODE_NAME$9,
27163
+ const config$a = {
27164
+ xmlName: XML_NODE_NAME$a,
27168
27165
  sdNodeOrKeyName: SD_ATTR_KEY,
27169
- encode: encode$g,
27170
- decode: decode$g
27166
+ encode: encode$h,
27167
+ decode: decode$h
27171
27168
  };
27172
- const translator$9 = NodeTranslator.from(config$9);
27173
- const XML_NODE_NAME$8 = "w:tbl";
27174
- const SD_NODE_NAME$8 = "table";
27175
- const encode$f = (params, encodedAttrs) => {
27169
+ const translator$a = NodeTranslator.from(config$a);
27170
+ const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
27171
+ const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
27172
+ const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
27173
+ const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
27174
+ const pctToPercent = (value) => {
27175
+ if (value == null) return null;
27176
+ return value / 50;
27177
+ };
27178
+ const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
27179
+ const resolveMeasurementWidthPx = (measurement) => {
27180
+ if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
27181
+ const { value, type: type2 } = measurement;
27182
+ if (!type2 || type2 === "auto") return null;
27183
+ if (type2 === "dxa") return twipsToPixels(value);
27184
+ if (type2 === "pct") {
27185
+ const percent = pctToPercent(value);
27186
+ if (percent == null || percent <= 0) return null;
27187
+ const widthTwips = resolveContentWidthTwips() * percent / 100;
27188
+ return twipsToPixels(widthTwips);
27189
+ }
27190
+ return null;
27191
+ };
27192
+ const countColumnsInRow = (row) => {
27193
+ if (!row?.elements?.length) return 0;
27194
+ return row.elements.reduce((count, element) => {
27195
+ if (element.name !== "w:tc") return count;
27196
+ const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
27197
+ const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
27198
+ const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
27199
+ return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
27200
+ }, 0);
27201
+ };
27202
+ const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
27203
+ const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
27204
+ const buildFallbackGridForTable = ({ params, rows, tableWidth, tableWidthMeasurement }) => {
27205
+ const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
27206
+ const columnCount = countColumnsInRow(firstRow);
27207
+ if (!columnCount) return null;
27208
+ const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
27209
+ /** @type {any} */
27210
+ params
27211
+ );
27212
+ const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
27213
+ let totalWidthPx;
27214
+ if (tableWidthMeasurement) {
27215
+ const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
27216
+ if (resolved != null) totalWidthPx = resolved;
27217
+ }
27218
+ if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
27219
+ totalWidthPx = tableWidth.width;
27220
+ }
27221
+ if (totalWidthPx == null) {
27222
+ totalWidthPx = minimumColumnWidthPx * columnCount;
27223
+ }
27224
+ const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
27225
+ const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
27226
+ const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
27227
+ return {
27228
+ grid: createFallbackGrid(columnCount, columnWidthTwips),
27229
+ columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
27230
+ };
27231
+ };
27232
+ const XML_NODE_NAME$9 = "w:tbl";
27233
+ const SD_NODE_NAME$9 = "table";
27234
+ const encode$g = (params, encodedAttrs) => {
27176
27235
  const { nodes } = params;
27177
27236
  const node = nodes[0];
27178
27237
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
27179
27238
  if (tblPr) {
27180
- const encodedProperties = translator$b.encode({ ...params, nodes: [tblPr] });
27239
+ const encodedProperties = translator$c.encode({ ...params, nodes: [tblPr] });
27181
27240
  encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
27182
27241
  }
27183
27242
  const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
27184
27243
  if (tblGrid) {
27185
- encodedAttrs["grid"] = translator$9.encode({ ...params, nodes: [tblGrid] }).attributes;
27244
+ encodedAttrs["grid"] = translator$a.encode({ ...params, nodes: [tblGrid] }).attributes;
27186
27245
  }
27187
27246
  [
27188
27247
  "tableStyleId",
27189
27248
  "justification",
27190
27249
  "tableLayout",
27191
27250
  ["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
27192
- ["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
27193
27251
  ["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
27194
27252
  ].forEach((prop) => {
27195
27253
  let key;
@@ -27207,6 +27265,21 @@ const encode$f = (params, encodedAttrs) => {
27207
27265
  if (encodedAttrs.tableCellSpacing) {
27208
27266
  encodedAttrs["borderCollapse"] = "separate";
27209
27267
  }
27268
+ if (encodedAttrs.tableProperties?.tableWidth) {
27269
+ const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
27270
+ const widthPx = twipsToPixels(tableWidthMeasurement.value);
27271
+ if (widthPx != null) {
27272
+ encodedAttrs.tableWidth = {
27273
+ width: widthPx,
27274
+ type: tableWidthMeasurement.type
27275
+ };
27276
+ } else if (tableWidthMeasurement.type === "auto") {
27277
+ encodedAttrs.tableWidth = {
27278
+ width: 0,
27279
+ type: tableWidthMeasurement.type
27280
+ };
27281
+ }
27282
+ }
27210
27283
  const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
27211
27284
  const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params);
27212
27285
  if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
@@ -27220,10 +27293,22 @@ const encode$f = (params, encodedAttrs) => {
27220
27293
  const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
27221
27294
  encodedAttrs["borders"] = borderData;
27222
27295
  const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
27223
- const columnWidths = (encodedAttrs["grid"] ?? []).map((item) => twipsToPixels(item.col));
27296
+ let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
27297
+ if (!columnWidths.length) {
27298
+ const fallback = buildFallbackGridForTable({
27299
+ params,
27300
+ rows,
27301
+ tableWidth: encodedAttrs.tableWidth,
27302
+ tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
27303
+ });
27304
+ if (fallback) {
27305
+ encodedAttrs.grid = fallback.grid;
27306
+ columnWidths = fallback.columnWidths;
27307
+ }
27308
+ }
27224
27309
  const content = [];
27225
27310
  rows.forEach((row) => {
27226
- const result = translator$F.encode({
27311
+ const result = translator$G.encode({
27227
27312
  ...params,
27228
27313
  nodes: [row],
27229
27314
  extraParams: {
@@ -27242,13 +27327,13 @@ const encode$f = (params, encodedAttrs) => {
27242
27327
  attrs: encodedAttrs
27243
27328
  };
27244
27329
  };
27245
- const decode$f = (params, decodedAttrs) => {
27330
+ const decode$g = (params, decodedAttrs) => {
27246
27331
  params.node = preProcessVerticalMergeCells(params.node, params);
27247
27332
  const { node } = params;
27248
27333
  const elements = translateChildNodes(params);
27249
27334
  const firstRow = node.content?.find((n) => n.type === "tableRow");
27250
27335
  const properties = node.attrs.grid;
27251
- const element = translator$9.decode({
27336
+ const element = translator$a.decode({
27252
27337
  ...params,
27253
27338
  node: { ...node, attrs: { ...node.attrs, grid: properties } },
27254
27339
  extraParams: {
@@ -27258,7 +27343,7 @@ const decode$f = (params, decodedAttrs) => {
27258
27343
  if (element) elements.unshift(element);
27259
27344
  if (node.attrs?.tableProperties) {
27260
27345
  const properties2 = { ...node.attrs.tableProperties };
27261
- const element2 = translator$b.decode({
27346
+ const element2 = translator$c.decode({
27262
27347
  ...params,
27263
27348
  node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
27264
27349
  });
@@ -27324,7 +27409,7 @@ function _getReferencedTableStyles(tableStyleReference, params) {
27324
27409
  if (baseTblPr && baseTblPr.elements) {
27325
27410
  tblPr.elements.push(...baseTblPr.elements);
27326
27411
  }
27327
- const tableProperties = translator$b.encode({ ...params, nodes: [tblPr] }).attributes;
27412
+ const tableProperties = translator$c.encode({ ...params, nodes: [tblPr] }).attributes;
27328
27413
  const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
27329
27414
  if (borders) stylesToReturn.borders = borders;
27330
27415
  if (rowBorders) stylesToReturn.rowBorders = rowBorders;
@@ -27341,16 +27426,16 @@ function _getReferencedTableStyles(tableStyleReference, params) {
27341
27426
  }
27342
27427
  return stylesToReturn;
27343
27428
  }
27344
- const config$8 = {
27345
- xmlName: XML_NODE_NAME$8,
27346
- sdNodeOrKeyName: SD_NODE_NAME$8,
27429
+ const config$9 = {
27430
+ xmlName: XML_NODE_NAME$9,
27431
+ sdNodeOrKeyName: SD_NODE_NAME$9,
27347
27432
  type: NodeTranslator.translatorTypes.NODE,
27348
- encode: encode$f,
27349
- decode: decode$f,
27433
+ encode: encode$g,
27434
+ decode: decode$g,
27350
27435
  attributes: []
27351
27436
  };
27352
- const translator$8 = NodeTranslator.from(config$8);
27353
- const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$8);
27437
+ const translator$9 = NodeTranslator.from(config$9);
27438
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$9);
27354
27439
  function getReferencedTableStyles(tblStyleTag, docx) {
27355
27440
  if (!tblStyleTag) return null;
27356
27441
  const stylesToReturn = {};
@@ -27712,10 +27797,10 @@ function generateCellMargins(cellMargins) {
27712
27797
  if (left != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left) } });
27713
27798
  return elements;
27714
27799
  }
27715
- const XML_NODE_NAME$7 = "w:tc";
27716
- const SD_NODE_NAME$7 = "tableCell";
27717
- const validXmlAttributes$7 = [];
27718
- function encode$e(params, encodedAttrs) {
27800
+ const XML_NODE_NAME$8 = "w:tc";
27801
+ const SD_NODE_NAME$8 = "tableCell";
27802
+ const validXmlAttributes$8 = [];
27803
+ function encode$f(params, encodedAttrs) {
27719
27804
  const {
27720
27805
  node,
27721
27806
  table,
@@ -27742,31 +27827,31 @@ function encode$e(params, encodedAttrs) {
27742
27827
  }
27743
27828
  return schemaNode;
27744
27829
  }
27745
- function decode$e(params, decodedAttrs) {
27830
+ function decode$f(params, decodedAttrs) {
27746
27831
  const translated = translateTableCell(params);
27747
27832
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
27748
27833
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
27749
27834
  }
27750
27835
  return translated;
27751
27836
  }
27752
- const config$7 = {
27753
- xmlName: XML_NODE_NAME$7,
27754
- sdNodeOrKeyName: SD_NODE_NAME$7,
27837
+ const config$8 = {
27838
+ xmlName: XML_NODE_NAME$8,
27839
+ sdNodeOrKeyName: SD_NODE_NAME$8,
27755
27840
  type: NodeTranslator.translatorTypes.NODE,
27756
- encode: encode$e,
27757
- decode: decode$e,
27758
- attributes: validXmlAttributes$7
27841
+ encode: encode$f,
27842
+ decode: decode$f,
27843
+ attributes: validXmlAttributes$8
27759
27844
  };
27760
- const translator$7 = NodeTranslator.from(config$7);
27761
- const XML_NODE_NAME$6 = "w:hyperlink";
27762
- const SD_NODE_NAME$6 = "link";
27845
+ const translator$8 = NodeTranslator.from(config$8);
27846
+ const XML_NODE_NAME$7 = "w:hyperlink";
27847
+ const SD_NODE_NAME$7 = "link";
27763
27848
  const _createAttributeHandler = (xmlName, sdName) => ({
27764
27849
  xmlName,
27765
27850
  sdName,
27766
27851
  encode: (attributes) => attributes[xmlName],
27767
27852
  decode: (attributes) => attributes[sdName]
27768
27853
  });
27769
- const validXmlAttributes$6 = [
27854
+ const validXmlAttributes$7 = [
27770
27855
  _createAttributeHandler("w:anchor", "anchor"),
27771
27856
  _createAttributeHandler("w:docLocation", "docLocation"),
27772
27857
  {
@@ -27779,7 +27864,7 @@ const validXmlAttributes$6 = [
27779
27864
  _createAttributeHandler("r:id", "rId"),
27780
27865
  _createAttributeHandler("w:tgtFrame", "target")
27781
27866
  ];
27782
- const encode$d = (params, encodedAttrs) => {
27867
+ const encode$e = (params, encodedAttrs) => {
27783
27868
  const { nodes, docx, nodeListHandler } = params;
27784
27869
  const node = nodes[0];
27785
27870
  let href = _resolveHref(docx, encodedAttrs);
@@ -27845,7 +27930,7 @@ const _resolveHref = (docx, encodedAttrs) => {
27845
27930
  }
27846
27931
  return href;
27847
27932
  };
27848
- function decode$d(params) {
27933
+ function decode$e(params) {
27849
27934
  const { node } = params;
27850
27935
  const linkMark = node.marks.find((m2) => m2.type === "link");
27851
27936
  const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
@@ -27889,15 +27974,15 @@ function _addNewLinkRelationship(params, link, rId) {
27889
27974
  });
27890
27975
  return rId;
27891
27976
  }
27892
- const config$6 = {
27893
- xmlName: XML_NODE_NAME$6,
27894
- sdNodeOrKeyName: SD_NODE_NAME$6,
27977
+ const config$7 = {
27978
+ xmlName: XML_NODE_NAME$7,
27979
+ sdNodeOrKeyName: SD_NODE_NAME$7,
27895
27980
  type: NodeTranslator.translatorTypes.NODE,
27896
- encode: encode$d,
27897
- decode: decode$d,
27898
- attributes: validXmlAttributes$6
27981
+ encode: encode$e,
27982
+ decode: decode$e,
27983
+ attributes: validXmlAttributes$7
27899
27984
  };
27900
- const translator$6 = NodeTranslator.from(config$6);
27985
+ const translator$7 = NodeTranslator.from(config$7);
27901
27986
  function parseTagValueJSON(json) {
27902
27987
  if (typeof json !== "string") {
27903
27988
  return {};
@@ -28082,6 +28167,9 @@ function handleStructuredContentNode(params) {
28082
28167
  const node = nodes[0];
28083
28168
  const sdtPr = node.elements.find((el) => el.name === "w:sdtPr");
28084
28169
  const sdtContent = node.elements.find((el) => el.name === "w:sdtContent");
28170
+ const id = sdtPr?.elements?.find((el) => el.name === "w:id");
28171
+ const tag = sdtPr?.elements?.find((el) => el.name === "w:tag");
28172
+ const alias = sdtPr?.elements?.find((el) => el.name === "w:alias");
28085
28173
  if (!sdtContent) {
28086
28174
  return null;
28087
28175
  }
@@ -28093,15 +28181,16 @@ function handleStructuredContentNode(params) {
28093
28181
  nodes: sdtContent.elements,
28094
28182
  path: [...params.path || [], sdtContent]
28095
28183
  });
28096
- let sdtContentType = "structuredContent";
28097
- if (paragraph || table) {
28098
- sdtContentType = "structuredContentBlock";
28099
- }
28184
+ const isBlockNode = paragraph || table;
28185
+ const sdtContentType = isBlockNode ? "structuredContentBlock" : "structuredContent";
28100
28186
  let result = {
28101
28187
  type: sdtContentType,
28102
28188
  content: translatedContent,
28103
28189
  marks,
28104
28190
  attrs: {
28191
+ id: id?.attributes?.["w:val"] || null,
28192
+ tag: tag?.attributes?.["w:val"] || null,
28193
+ alias: alias?.attributes?.["w:val"] || null,
28105
28194
  sdtPr
28106
28195
  }
28107
28196
  };
@@ -28692,32 +28781,32 @@ function translateAnchorNode(params) {
28692
28781
  elements: [...anchorElements, ...elementsWithWrap]
28693
28782
  };
28694
28783
  }
28695
- const XML_NODE_NAME$5 = "wp:anchor";
28696
- const SD_NODE_NAME$5 = ["image"];
28697
- const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28698
- function encode$c(params) {
28784
+ const XML_NODE_NAME$6 = "wp:anchor";
28785
+ const SD_NODE_NAME$6 = ["image"];
28786
+ const validXmlAttributes$6 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28787
+ function encode$d(params) {
28699
28788
  const { node } = params.extraParams;
28700
28789
  if (!node || !node.type) {
28701
28790
  return null;
28702
28791
  }
28703
28792
  return handleAnchorNode(params);
28704
28793
  }
28705
- function decode$c(params) {
28794
+ function decode$d(params) {
28706
28795
  const { node } = params;
28707
28796
  if (!node || !node.type) {
28708
28797
  return null;
28709
28798
  }
28710
28799
  return translateAnchorNode(params);
28711
28800
  }
28712
- const config$5 = {
28713
- xmlName: XML_NODE_NAME$5,
28714
- sdNodeOrKeyName: SD_NODE_NAME$5,
28801
+ const config$6 = {
28802
+ xmlName: XML_NODE_NAME$6,
28803
+ sdNodeOrKeyName: SD_NODE_NAME$6,
28715
28804
  type: NodeTranslator.translatorTypes.NODE,
28716
- encode: encode$c,
28717
- decode: decode$c,
28718
- attributes: validXmlAttributes$5
28805
+ encode: encode$d,
28806
+ decode: decode$d,
28807
+ attributes: validXmlAttributes$6
28719
28808
  };
28720
- const translator$5 = NodeTranslator.from(config$5);
28809
+ const translator$6 = NodeTranslator.from(config$6);
28721
28810
  function handleInlineNode(params) {
28722
28811
  const { node } = params.extraParams;
28723
28812
  if (node.name !== "wp:inline") {
@@ -28733,41 +28822,41 @@ function translateInlineNode(params) {
28733
28822
  elements: nodeElements.elements
28734
28823
  };
28735
28824
  }
28736
- const XML_NODE_NAME$4 = "wp:inline";
28737
- const SD_NODE_NAME$4 = ["image"];
28738
- const validXmlAttributes$4 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28739
- function encode$b(params) {
28825
+ const XML_NODE_NAME$5 = "wp:inline";
28826
+ const SD_NODE_NAME$5 = ["image"];
28827
+ const validXmlAttributes$5 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
28828
+ function encode$c(params) {
28740
28829
  const { node } = params.extraParams;
28741
28830
  if (!node || !node.type) {
28742
28831
  return null;
28743
28832
  }
28744
28833
  return handleInlineNode(params);
28745
28834
  }
28746
- function decode$b(params) {
28835
+ function decode$c(params) {
28747
28836
  const { node } = params;
28748
28837
  if (!node || !node.type) {
28749
28838
  return null;
28750
28839
  }
28751
28840
  return translateInlineNode(params);
28752
28841
  }
28753
- const config$4 = {
28754
- xmlName: XML_NODE_NAME$4,
28755
- sdNodeOrKeyName: SD_NODE_NAME$4,
28842
+ const config$5 = {
28843
+ xmlName: XML_NODE_NAME$5,
28844
+ sdNodeOrKeyName: SD_NODE_NAME$5,
28756
28845
  type: NodeTranslator.translatorTypes.NODE,
28757
- encode: encode$b,
28758
- decode: decode$b,
28759
- attributes: validXmlAttributes$4
28846
+ encode: encode$c,
28847
+ decode: decode$c,
28848
+ attributes: validXmlAttributes$5
28760
28849
  };
28761
- const translator$4 = NodeTranslator.from(config$4);
28762
- const XML_NODE_NAME$3 = "w:drawing";
28763
- const SD_NODE_NAME$3 = [];
28764
- const validXmlAttributes$3 = [];
28765
- function encode$a(params) {
28850
+ const translator$5 = NodeTranslator.from(config$5);
28851
+ const XML_NODE_NAME$4 = "w:drawing";
28852
+ const SD_NODE_NAME$4 = [];
28853
+ const validXmlAttributes$4 = [];
28854
+ function encode$b(params) {
28766
28855
  const nodes = params.nodes;
28767
28856
  const node = nodes[0];
28768
28857
  const translatorByChildName = {
28769
- "wp:anchor": translator$5,
28770
- "wp:inline": translator$4
28858
+ "wp:anchor": translator$6,
28859
+ "wp:inline": translator$5
28771
28860
  };
28772
28861
  return node.elements.reduce((acc, child) => {
28773
28862
  if (acc) return acc;
@@ -28776,12 +28865,12 @@ function encode$a(params) {
28776
28865
  return translator2.encode({ ...params, extraParams: { node: child } }) || acc;
28777
28866
  }, null);
28778
28867
  }
28779
- function decode$a(params) {
28868
+ function decode$b(params) {
28780
28869
  const { node } = params;
28781
28870
  if (!node || !node.type) {
28782
28871
  return null;
28783
28872
  }
28784
- const childTranslator = node.attrs.isAnchor ? translator$5 : translator$4;
28873
+ const childTranslator = node.attrs.isAnchor ? translator$6 : translator$5;
28785
28874
  const resultNode = childTranslator.decode(params);
28786
28875
  return wrapTextInRun(
28787
28876
  {
@@ -28791,15 +28880,15 @@ function decode$a(params) {
28791
28880
  []
28792
28881
  );
28793
28882
  }
28794
- const config$3 = {
28795
- xmlName: XML_NODE_NAME$3,
28796
- sdNodeOrKeyName: SD_NODE_NAME$3,
28883
+ const config$4 = {
28884
+ xmlName: XML_NODE_NAME$4,
28885
+ sdNodeOrKeyName: SD_NODE_NAME$4,
28797
28886
  type: NodeTranslator.translatorTypes.NODE,
28798
- encode: encode$a,
28799
- decode: decode$a,
28800
- attributes: validXmlAttributes$3
28887
+ encode: encode$b,
28888
+ decode: decode$b,
28889
+ attributes: validXmlAttributes$4
28801
28890
  };
28802
- const translator$3 = NodeTranslator.from(config$3);
28891
+ const translator$4 = NodeTranslator.from(config$4);
28803
28892
  class CommandService {
28804
28893
  /**
28805
28894
  * @param {import('./commands/types/index.js').CommandServiceOptions} props
@@ -30137,7 +30226,7 @@ function prepareTextAnnotation(params) {
30137
30226
  return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params);
30138
30227
  }
30139
30228
  function prepareImageAnnotation(params, imageSize) {
30140
- return translator$3.decode({
30229
+ return translator$4.decode({
30141
30230
  ...params,
30142
30231
  imageSize
30143
30232
  });
@@ -30359,25 +30448,59 @@ const generateSdtPrTagForDocumentSection = (id, title, tag) => {
30359
30448
  };
30360
30449
  function translateStructuredContent(params) {
30361
30450
  const { node } = params;
30362
- const { attrs = {} } = node;
30363
30451
  const childContent = translateChildNodes({ ...params, nodes: node.content });
30364
- const nodeElements = [
30365
- {
30366
- name: "w:sdtContent",
30367
- elements: childContent
30368
- }
30369
- ];
30370
- nodeElements.unshift(attrs.sdtPr);
30452
+ const sdtContent = { name: "w:sdtContent", elements: childContent };
30453
+ const sdtPr = generateSdtPrTagForStructuredContent({ node });
30454
+ const nodeElements = [sdtPr, sdtContent];
30371
30455
  const result = {
30372
30456
  name: "w:sdt",
30373
30457
  elements: nodeElements
30374
30458
  };
30375
30459
  return result;
30376
30460
  }
30377
- const XML_NODE_NAME$2 = "w:sdt";
30378
- const SD_NODE_NAME$2 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30379
- const validXmlAttributes$2 = [];
30380
- function encode$9(params) {
30461
+ function generateSdtPrTagForStructuredContent({ node }) {
30462
+ const { attrs = {} } = node;
30463
+ const id = {
30464
+ name: "w:id",
30465
+ type: "element",
30466
+ attributes: { "w:val": attrs.id }
30467
+ };
30468
+ const alias = {
30469
+ name: "w:alias",
30470
+ type: "element",
30471
+ attributes: { "w:val": attrs.alias }
30472
+ };
30473
+ const tag = {
30474
+ name: "w:tag",
30475
+ type: "element",
30476
+ attributes: { "w:val": attrs.tag }
30477
+ };
30478
+ const resultElements = [];
30479
+ if (attrs.id) resultElements.push(id);
30480
+ if (attrs.alias) resultElements.push(alias);
30481
+ if (attrs.tag) resultElements.push(tag);
30482
+ if (attrs.sdtPr) {
30483
+ const elements = attrs.sdtPr.elements || [];
30484
+ const elementsToExclude = ["w:id", "w:alias", "w:tag"];
30485
+ const restElements = elements.filter((el) => !elementsToExclude.includes(el.name));
30486
+ const result2 = {
30487
+ name: "w:sdtPr",
30488
+ type: "element",
30489
+ elements: [...resultElements, ...restElements]
30490
+ };
30491
+ return result2;
30492
+ }
30493
+ const result = {
30494
+ name: "w:sdtPr",
30495
+ type: "element",
30496
+ elements: resultElements
30497
+ };
30498
+ return result;
30499
+ }
30500
+ const XML_NODE_NAME$3 = "w:sdt";
30501
+ const SD_NODE_NAME$3 = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
30502
+ const validXmlAttributes$3 = [];
30503
+ function encode$a(params) {
30381
30504
  const nodes = params.nodes;
30382
30505
  const node = nodes[0];
30383
30506
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -30387,7 +30510,7 @@ function encode$9(params) {
30387
30510
  const result = handler2(params);
30388
30511
  return result;
30389
30512
  }
30390
- function decode$9(params) {
30513
+ function decode$a(params) {
30391
30514
  const { node } = params;
30392
30515
  if (!node || !node.type) {
30393
30516
  return null;
@@ -30403,85 +30526,85 @@ function decode$9(params) {
30403
30526
  const result = decoder();
30404
30527
  return result;
30405
30528
  }
30406
- const config$2 = {
30407
- xmlName: XML_NODE_NAME$2,
30408
- sdNodeOrKeyName: SD_NODE_NAME$2,
30529
+ const config$3 = {
30530
+ xmlName: XML_NODE_NAME$3,
30531
+ sdNodeOrKeyName: SD_NODE_NAME$3,
30409
30532
  type: NodeTranslator.translatorTypes.NODE,
30410
- encode: encode$9,
30411
- decode: decode$9,
30412
- attributes: validXmlAttributes$2
30533
+ encode: encode$a,
30534
+ decode: decode$a,
30535
+ attributes: validXmlAttributes$3
30413
30536
  };
30414
- const translator$2 = NodeTranslator.from(config$2);
30415
- const encode$8 = (attributes) => {
30537
+ const translator$3 = NodeTranslator.from(config$3);
30538
+ const encode$9 = (attributes) => {
30416
30539
  return attributes["w:id"];
30417
30540
  };
30418
- const decode$8 = (attrs) => {
30541
+ const decode$9 = (attrs) => {
30419
30542
  return attrs.id;
30420
30543
  };
30421
30544
  const attrConfig$6 = Object.freeze({
30422
30545
  xmlName: "w:id",
30423
30546
  sdName: "id",
30424
- encode: encode$8,
30425
- decode: decode$8
30547
+ encode: encode$9,
30548
+ decode: decode$9
30426
30549
  });
30427
- const encode$7 = (attributes) => {
30550
+ const encode$8 = (attributes) => {
30428
30551
  return attributes["w:name"];
30429
30552
  };
30430
- const decode$7 = (attrs) => {
30553
+ const decode$8 = (attrs) => {
30431
30554
  return attrs.name;
30432
30555
  };
30433
30556
  const attrConfig$5 = Object.freeze({
30434
30557
  xmlName: "w:name",
30435
30558
  sdName: "name",
30436
- encode: encode$7,
30437
- decode: decode$7
30559
+ encode: encode$8,
30560
+ decode: decode$8
30438
30561
  });
30439
- const encode$6 = (attributes) => {
30562
+ const encode$7 = (attributes) => {
30440
30563
  return attributes["w:colFirst"];
30441
30564
  };
30442
- const decode$6 = (attrs) => {
30565
+ const decode$7 = (attrs) => {
30443
30566
  return attrs.colFirst;
30444
30567
  };
30445
30568
  const attrConfig$4 = Object.freeze({
30446
30569
  xmlName: "w:colFirst",
30447
30570
  sdName: "colFirst",
30448
- encode: encode$6,
30449
- decode: decode$6
30571
+ encode: encode$7,
30572
+ decode: decode$7
30450
30573
  });
30451
- const encode$5 = (attributes) => {
30574
+ const encode$6 = (attributes) => {
30452
30575
  return attributes["w:colLast"];
30453
30576
  };
30454
- const decode$5 = (attrs) => {
30577
+ const decode$6 = (attrs) => {
30455
30578
  return attrs.colLast;
30456
30579
  };
30457
30580
  const attrConfig$3 = Object.freeze({
30458
30581
  xmlName: "w:colLast",
30459
30582
  sdName: "colLast",
30460
- encode: encode$5,
30461
- decode: decode$5
30583
+ encode: encode$6,
30584
+ decode: decode$6
30462
30585
  });
30463
- const encode$4 = (attributes) => {
30586
+ const encode$5 = (attributes) => {
30464
30587
  return attributes["w:displacedByCustomXml"];
30465
30588
  };
30466
- const decode$4 = (attrs) => {
30589
+ const decode$5 = (attrs) => {
30467
30590
  return attrs.displacedByCustomXml;
30468
30591
  };
30469
30592
  const attrConfig$2 = Object.freeze({
30470
30593
  xmlName: "w:displacedByCustomXml",
30471
30594
  sdName: "displacedByCustomXml",
30472
- encode: encode$4,
30473
- decode: decode$4
30595
+ encode: encode$5,
30596
+ decode: decode$5
30474
30597
  });
30475
- const validXmlAttributes$1 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
30476
- const XML_NODE_NAME$1 = "w:bookmarkStart";
30477
- const SD_NODE_NAME$1 = "bookmarkStart";
30478
- const encode$3 = (params, encodedAttrs = {}) => {
30598
+ const validXmlAttributes$2 = [attrConfig$6, attrConfig$5, attrConfig$4, attrConfig$3, attrConfig$2];
30599
+ const XML_NODE_NAME$2 = "w:bookmarkStart";
30600
+ const SD_NODE_NAME$2 = "bookmarkStart";
30601
+ const encode$4 = (params, encodedAttrs = {}) => {
30479
30602
  return {
30480
30603
  type: "bookmarkStart",
30481
30604
  attrs: encodedAttrs
30482
30605
  };
30483
30606
  };
30484
- const decode$3 = (params, decodedAttrs = {}) => {
30607
+ const decode$4 = (params, decodedAttrs = {}) => {
30485
30608
  const result = {
30486
30609
  name: "w:bookmarkStart",
30487
30610
  elements: []
@@ -30491,49 +30614,49 @@ const decode$3 = (params, decodedAttrs = {}) => {
30491
30614
  }
30492
30615
  return result;
30493
30616
  };
30494
- const config$1 = {
30495
- xmlName: XML_NODE_NAME$1,
30496
- sdNodeOrKeyName: SD_NODE_NAME$1,
30617
+ const config$2 = {
30618
+ xmlName: XML_NODE_NAME$2,
30619
+ sdNodeOrKeyName: SD_NODE_NAME$2,
30497
30620
  type: NodeTranslator.translatorTypes.NODE,
30498
- encode: encode$3,
30499
- decode: decode$3,
30500
- attributes: validXmlAttributes$1
30621
+ encode: encode$4,
30622
+ decode: decode$4,
30623
+ attributes: validXmlAttributes$2
30501
30624
  };
30502
- const translator$1 = NodeTranslator.from(config$1);
30503
- const encode$2 = (attributes) => {
30625
+ const translator$2 = NodeTranslator.from(config$2);
30626
+ const encode$3 = (attributes) => {
30504
30627
  return attributes["w:id"];
30505
30628
  };
30506
- const decode$2 = (attrs) => {
30629
+ const decode$3 = (attrs) => {
30507
30630
  return attrs.id;
30508
30631
  };
30509
30632
  const attrConfig$1 = Object.freeze({
30510
30633
  xmlName: "w:id",
30511
30634
  sdName: "id",
30512
- encode: encode$2,
30513
- decode: decode$2
30635
+ encode: encode$3,
30636
+ decode: decode$3
30514
30637
  });
30515
- const encode$1 = (attributes) => {
30638
+ const encode$2 = (attributes) => {
30516
30639
  return attributes["w:displacedByCustomXml"];
30517
30640
  };
30518
- const decode$1 = (attrs) => {
30641
+ const decode$2 = (attrs) => {
30519
30642
  return attrs.displacedByCustomXml;
30520
30643
  };
30521
30644
  const attrConfig = Object.freeze({
30522
30645
  xmlName: "w:displacedByCustomXml",
30523
30646
  sdName: "displacedByCustomXml",
30524
- encode: encode$1,
30525
- decode: decode$1
30647
+ encode: encode$2,
30648
+ decode: decode$2
30526
30649
  });
30527
- const validXmlAttributes = [attrConfig$1, attrConfig];
30528
- const XML_NODE_NAME = "w:bookmarkEnd";
30529
- const SD_NODE_NAME = "bookmarkEnd";
30530
- const encode = (params, encodedAttrs = {}) => {
30650
+ const validXmlAttributes$1 = [attrConfig$1, attrConfig];
30651
+ const XML_NODE_NAME$1 = "w:bookmarkEnd";
30652
+ const SD_NODE_NAME$1 = "bookmarkEnd";
30653
+ const encode$1 = (params, encodedAttrs = {}) => {
30531
30654
  return {
30532
30655
  type: "bookmarkEnd",
30533
30656
  attrs: encodedAttrs
30534
30657
  };
30535
30658
  };
30536
- const decode = (params, decodedAttrs = {}) => {
30659
+ const decode$1 = (params, decodedAttrs = {}) => {
30537
30660
  const result = {
30538
30661
  name: "w:bookmarkEnd",
30539
30662
  elements: []
@@ -30543,6 +30666,55 @@ const decode = (params, decodedAttrs = {}) => {
30543
30666
  }
30544
30667
  return result;
30545
30668
  };
30669
+ const config$1 = {
30670
+ xmlName: XML_NODE_NAME$1,
30671
+ sdNodeOrKeyName: SD_NODE_NAME$1,
30672
+ type: NodeTranslator.translatorTypes.NODE,
30673
+ encode: encode$1,
30674
+ decode: decode$1,
30675
+ attributes: validXmlAttributes$1
30676
+ };
30677
+ const translator$1 = NodeTranslator.from(config$1);
30678
+ const XML_NODE_NAME = "mc:AlternateContent";
30679
+ const SD_NODE_NAME = [];
30680
+ const validXmlAttributes = [];
30681
+ function encode(params) {
30682
+ const { nodeListHandler } = params;
30683
+ const { node } = params.extraParams;
30684
+ if (!node || !node.type) {
30685
+ return null;
30686
+ }
30687
+ const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
30688
+ const wpsNode = node.elements.find(
30689
+ (el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
30690
+ );
30691
+ if (!wpsNode) {
30692
+ return null;
30693
+ }
30694
+ const contents = wpsNode.elements;
30695
+ return nodeListHandler.handler({
30696
+ ...params,
30697
+ nodes: contents,
30698
+ path: [...params.path || [], wpsNode]
30699
+ });
30700
+ }
30701
+ function decode(params) {
30702
+ const { node } = params;
30703
+ const { drawingContent } = node.attrs;
30704
+ const drawing = {
30705
+ name: "w:drawing",
30706
+ elements: [...drawingContent ? [...drawingContent.elements || []] : []]
30707
+ };
30708
+ const choice = {
30709
+ name: "mc:Choice",
30710
+ attributes: { Requires: "wps" },
30711
+ elements: [drawing]
30712
+ };
30713
+ return {
30714
+ name: "mc:AlternateContent",
30715
+ elements: [choice]
30716
+ };
30717
+ }
30546
30718
  const config = {
30547
30719
  xmlName: XML_NODE_NAME,
30548
30720
  sdNodeOrKeyName: SD_NODE_NAME,
@@ -30552,6 +30724,63 @@ const config = {
30552
30724
  attributes: validXmlAttributes
30553
30725
  };
30554
30726
  const translator = NodeTranslator.from(config);
30727
+ const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
30728
+ pageSize: Object.freeze({ width: "12240", height: "15840" }),
30729
+ pageMargins: Object.freeze({
30730
+ top: "1440",
30731
+ right: "1440",
30732
+ bottom: "1440",
30733
+ left: "1440",
30734
+ header: "720",
30735
+ footer: "720",
30736
+ gutter: "0"
30737
+ })
30738
+ });
30739
+ const ensureSectionLayoutDefaults = (sectPr, converter) => {
30740
+ if (!sectPr) {
30741
+ return {
30742
+ type: "element",
30743
+ name: "w:sectPr",
30744
+ elements: []
30745
+ };
30746
+ }
30747
+ if (!sectPr.elements) sectPr.elements = [];
30748
+ const ensureChild = (name) => {
30749
+ let child = sectPr.elements.find((n) => n.name === name);
30750
+ if (!child) {
30751
+ child = {
30752
+ type: "element",
30753
+ name,
30754
+ elements: [],
30755
+ attributes: {}
30756
+ };
30757
+ sectPr.elements.push(child);
30758
+ } else {
30759
+ if (!child.elements) child.elements = [];
30760
+ if (!child.attributes) child.attributes = {};
30761
+ }
30762
+ return child;
30763
+ };
30764
+ const pageSize = converter?.pageStyles?.pageSize;
30765
+ const pgSz = ensureChild("w:pgSz");
30766
+ if (pageSize?.width != null) pgSz.attributes["w:w"] = String(inchesToTwips(pageSize.width));
30767
+ if (pageSize?.height != null) pgSz.attributes["w:h"] = String(inchesToTwips(pageSize.height));
30768
+ if (pgSz.attributes["w:w"] == null) pgSz.attributes["w:w"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
30769
+ if (pgSz.attributes["w:h"] == null) pgSz.attributes["w:h"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
30770
+ const pageMargins = converter?.pageStyles?.pageMargins;
30771
+ const pgMar = ensureChild("w:pgMar");
30772
+ if (pageMargins) {
30773
+ Object.entries(pageMargins).forEach(([key, value]) => {
30774
+ const converted = inchesToTwips(value);
30775
+ if (converted != null) pgMar.attributes[`w:${key}`] = String(converted);
30776
+ });
30777
+ }
30778
+ Object.entries(DEFAULT_SECTION_PROPS_TWIPS.pageMargins).forEach(([key, value]) => {
30779
+ const attrKey = `w:${key}`;
30780
+ if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
30781
+ });
30782
+ return sectPr;
30783
+ };
30555
30784
  const isLineBreakOnlyRun = (node) => {
30556
30785
  if (!node) return false;
30557
30786
  if (node.type === "lineBreak" || node.type === "hardBreak") return true;
@@ -30566,30 +30795,30 @@ function exportSchemaToJson(params) {
30566
30795
  doc: translateDocumentNode,
30567
30796
  body: translateBodyNode,
30568
30797
  heading: translateHeadingNode,
30569
- paragraph: translator$12,
30570
- run: translator$T,
30798
+ paragraph: translator$13,
30799
+ run: translator$U,
30571
30800
  text: translateTextNode,
30572
30801
  bulletList: translateList,
30573
30802
  orderedList: translateList,
30574
- lineBreak: translator$15,
30575
- table: translator$8,
30576
- tableRow: translator$F,
30577
- tableCell: translator$7,
30578
- bookmarkStart: translator$1,
30579
- bookmarkEnd: translator,
30580
- fieldAnnotation: translator$2,
30581
- tab: translator$13,
30582
- image: translator$3,
30583
- hardBreak: translator$15,
30803
+ lineBreak: translator$16,
30804
+ table: translator$9,
30805
+ tableRow: translator$G,
30806
+ tableCell: translator$8,
30807
+ bookmarkStart: translator$2,
30808
+ bookmarkEnd: translator$1,
30809
+ fieldAnnotation: translator$3,
30810
+ tab: translator$14,
30811
+ image: translator$4,
30812
+ hardBreak: translator$16,
30584
30813
  commentRangeStart: () => translateCommentNode(params, "Start"),
30585
30814
  commentRangeEnd: () => translateCommentNode(params, "End"),
30586
30815
  commentReference: () => null,
30587
30816
  shapeContainer: translateShapeContainer,
30588
30817
  shapeTextbox: translateShapeTextbox,
30589
30818
  contentBlock: translateContentBlock,
30590
- structuredContent: translator$2,
30591
- structuredContentBlock: translator$2,
30592
- documentSection: translator$2,
30819
+ structuredContent: translator$3,
30820
+ structuredContentBlock: translator$3,
30821
+ documentSection: translator$3,
30593
30822
  "page-number": translatePageNumberNode,
30594
30823
  "total-page-number": translateTotalPageNumberNode
30595
30824
  };
@@ -30604,28 +30833,30 @@ function exportSchemaToJson(params) {
30604
30833
  return handler2(params);
30605
30834
  }
30606
30835
  function translateBodyNode(params) {
30607
- let sectPr = params.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
30836
+ let sectPr = params.bodyNode?.elements?.find((n) => n.name === "w:sectPr");
30837
+ if (!sectPr) {
30838
+ sectPr = {
30839
+ type: "element",
30840
+ name: "w:sectPr",
30841
+ elements: []
30842
+ };
30843
+ } else if (!sectPr.elements) {
30844
+ sectPr = { ...sectPr, elements: [] };
30845
+ }
30846
+ sectPr = ensureSectionLayoutDefaults(sectPr, params.converter);
30608
30847
  if (params.converter) {
30609
- const hasHeader = sectPr?.elements?.some((n) => n.name === "w:headerReference");
30848
+ const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
30610
30849
  const hasDefaultHeader = params.converter.headerIds?.default;
30611
30850
  if (!hasHeader && hasDefaultHeader && !params.editor.options.isHeaderOrFooter) {
30612
30851
  const defaultHeader = generateDefaultHeaderFooter("header", params.converter.headerIds?.default);
30613
30852
  sectPr.elements.push(defaultHeader);
30614
30853
  }
30615
- const hasFooter = sectPr?.elements?.some((n) => n.name === "w:footerReference");
30854
+ const hasFooter = sectPr.elements?.some((n) => n.name === "w:footerReference");
30616
30855
  const hasDefaultFooter = params.converter.footerIds?.default;
30617
30856
  if (!hasFooter && hasDefaultFooter && !params.editor.options.isHeaderOrFooter) {
30618
30857
  const defaultFooter = generateDefaultHeaderFooter("footer", params.converter.footerIds?.default);
30619
30858
  sectPr.elements.push(defaultFooter);
30620
30859
  }
30621
- const newMargins = params.converter.pageStyles.pageMargins;
30622
- const sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
30623
- const { attributes } = sectPrMargins;
30624
- Object.entries(newMargins).forEach(([key, value]) => {
30625
- const convertedValue = inchesToTwips(value);
30626
- attributes[`w:${key}`] = convertedValue;
30627
- });
30628
- sectPrMargins.attributes = attributes;
30629
30860
  }
30630
30861
  const elements = translateChildNodes(params);
30631
30862
  if (params.isHeaderFooter) {
@@ -30928,7 +31159,7 @@ function translateTextNode(params) {
30928
31159
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
30929
31160
  if (isTrackedNode) return translateTrackedNode(params);
30930
31161
  const isLinkNode = node.marks?.some((m2) => m2.type === "link");
30931
- if (isLinkNode) return translator$6.decode(params);
31162
+ if (isLinkNode) return translator$7.decode(params);
30932
31163
  const { text, marks = [] } = node;
30933
31164
  return getTextNodeForExport(text, marks, params);
30934
31165
  }
@@ -31234,7 +31465,7 @@ function translateMark(mark) {
31234
31465
  markElement.type = "element";
31235
31466
  break;
31236
31467
  case "underline": {
31237
- const translated = translator$$.decode({
31468
+ const translated = translator$10.decode({
31238
31469
  node: {
31239
31470
  attrs: {
31240
31471
  underlineType: attrs.underlineType ?? attrs.underline ?? null,
@@ -31298,7 +31529,7 @@ function translateMark(mark) {
31298
31529
  break;
31299
31530
  case "highlight": {
31300
31531
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
31301
- const translated = translator$14.decode({ node: { attrs: { highlight: highlightValue } } });
31532
+ const translated = translator$15.decode({ node: { attrs: { highlight: highlightValue } } });
31302
31533
  return translated || {};
31303
31534
  }
31304
31535
  }
@@ -31354,23 +31585,11 @@ function translateShapeTextbox(params) {
31354
31585
  }
31355
31586
  function translateContentBlock(params) {
31356
31587
  const { node } = params;
31357
- const { drawingContent, vmlAttributes, horizontalRule } = node.attrs;
31588
+ const { vmlAttributes, horizontalRule } = node.attrs;
31358
31589
  if (vmlAttributes || horizontalRule) {
31359
31590
  return translateVRectContentBlock(params);
31360
31591
  }
31361
- const drawing = {
31362
- name: "w:drawing",
31363
- elements: [...drawingContent ? [...drawingContent.elements || []] : []]
31364
- };
31365
- const choice = {
31366
- name: "mc:Choice",
31367
- attributes: { Requires: "wps" },
31368
- elements: [drawing]
31369
- };
31370
- const alternateContent = {
31371
- name: "mc:AlternateContent",
31372
- elements: [choice]
31373
- };
31592
+ const alternateContent = translator.decode(params);
31374
31593
  return wrapTextInRun(alternateContent);
31375
31594
  }
31376
31595
  function translateVRectContentBlock(params) {
@@ -31574,7 +31793,7 @@ const handleDrawingNode = (params) => {
31574
31793
  if (mainNode.name === "w:drawing") node = mainNode;
31575
31794
  else node = mainNode.elements.find((el) => el.name === "w:drawing");
31576
31795
  if (!node) return { nodes: [], consumed: 0 };
31577
- const schemaNode = translator$3.encode(params);
31796
+ const schemaNode = translator$4.encode(params);
31578
31797
  const newNodes = schemaNode ? [schemaNode] : [];
31579
31798
  return { nodes: newNodes, consumed: 1 };
31580
31799
  };
@@ -31676,8 +31895,8 @@ const trackChangeNodeHandlerEntity = {
31676
31895
  handlerName: "trackChangeNodeHandler",
31677
31896
  handler: handleTrackChangeNode
31678
31897
  };
31679
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$6);
31680
- const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$T);
31898
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$7);
31899
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator$U);
31681
31900
  const handleTextNode = (params) => {
31682
31901
  const { nodes, insideTrackChange } = params;
31683
31902
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -31718,7 +31937,7 @@ const handleParagraphNode = (params) => {
31718
31937
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
31719
31938
  return { nodes: [], consumed: 0 };
31720
31939
  }
31721
- const schemaNode = translator$12.encode(params);
31940
+ const schemaNode = translator$13.encode(params);
31722
31941
  const newNodes = schemaNode ? [schemaNode] : [];
31723
31942
  return { nodes: newNodes, consumed: 1 };
31724
31943
  };
@@ -31731,7 +31950,7 @@ const handleSdtNode = (params) => {
31731
31950
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
31732
31951
  return { nodes: [], consumed: 0 };
31733
31952
  }
31734
- const result = translator$2.encode(params);
31953
+ const result = translator$3.encode(params);
31735
31954
  if (!result) {
31736
31955
  return { nodes: [], consumed: 0 };
31737
31956
  }
@@ -31821,7 +32040,7 @@ const handler = (params) => {
31821
32040
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
31822
32041
  return { nodes: [], consumed: 0 };
31823
32042
  }
31824
- const result = translator$15.encode(params);
32043
+ const result = translator$16.encode(params);
31825
32044
  if (!result) return { nodes: [], consumed: 0 };
31826
32045
  return {
31827
32046
  nodes: [result],
@@ -31893,7 +32112,7 @@ const handleBookmarkStartNode = (params) => {
31893
32112
  if (isCustomMarkBookmark(nodes[0], params.editor)) {
31894
32113
  return handleBookmarkNode(params);
31895
32114
  }
31896
- const node = translator$1.encode(params);
32115
+ const node = translator$2.encode(params);
31897
32116
  if (!node) return { nodes: [], consumed: 0 };
31898
32117
  return { nodes: [node], consumed: 1 };
31899
32118
  };
@@ -31925,7 +32144,7 @@ const handleBookmarkEndNode = (params) => {
31925
32144
  if (!nodes.length || nodes[0].name !== "w:bookmarkEnd") {
31926
32145
  return { nodes: [], consumed: 0 };
31927
32146
  }
31928
- const node = translator.encode(params);
32147
+ const node = translator$1.encode(params);
31929
32148
  if (!node) return { nodes: [], consumed: 0 };
31930
32149
  return { nodes: [node], consumed: 1 };
31931
32150
  };
@@ -31933,32 +32152,86 @@ const bookmarkEndNodeHandlerEntity = {
31933
32152
  handlerName: "w:bookmarkEndTranslator",
31934
32153
  handler: handleBookmarkEndNode
31935
32154
  };
32155
+ const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
32156
+ const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
32157
+ "wps",
32158
+ "wp14",
32159
+ "w14",
32160
+ "w15",
32161
+ "w16",
32162
+ "w16cex",
32163
+ "w16cid",
32164
+ "w16du",
32165
+ "w16sdtdh",
32166
+ "w16sdtfl",
32167
+ "w16se"
32168
+ ]);
32169
+ const skipHandlerResponse = { nodes: [], consumed: 0 };
32170
+ const isAlternateContentNode = (node) => node?.name === ALTERNATE_CONTENT_NODE;
32171
+ const isSupportedChoice = (choice) => {
32172
+ if (!choice?.attributes) return false;
32173
+ const requires = choice.attributes.Requires || choice.attributes.requires;
32174
+ if (!requires) return false;
32175
+ return requires.split(/\s+/).filter(Boolean).some((namespace) => SUPPORTED_REQUIRES.has(namespace));
32176
+ };
32177
+ const resolveAlternateContentElements = (alternateContent) => {
32178
+ if (!alternateContent?.elements?.length) return null;
32179
+ const choices = alternateContent.elements.filter((el) => el.name === "mc:Choice");
32180
+ const fallback = alternateContent.elements.find((el) => el.name === "mc:Fallback");
32181
+ const supportedChoice = choices.find(isSupportedChoice);
32182
+ const selectedElements = supportedChoice?.elements || fallback?.elements || choices[0]?.elements;
32183
+ if (!selectedElements) return null;
32184
+ return carbonCopy(selectedElements);
32185
+ };
32186
+ const buildNodeWithoutAlternateContent = (node) => {
32187
+ const { elements } = node || {};
32188
+ if (!elements?.length) return null;
32189
+ let replaced = false;
32190
+ const updatedElements = [];
32191
+ elements.forEach((element) => {
32192
+ if (isAlternateContentNode(element)) {
32193
+ const resolved = resolveAlternateContentElements(element);
32194
+ if (resolved) {
32195
+ updatedElements.push(...resolved);
32196
+ replaced = true;
32197
+ return;
32198
+ }
32199
+ updatedElements.push(carbonCopy(element));
32200
+ return;
32201
+ }
32202
+ updatedElements.push(carbonCopy(element));
32203
+ });
32204
+ if (!replaced) return null;
32205
+ const clone = carbonCopy(node);
32206
+ clone.elements = updatedElements;
32207
+ return clone;
32208
+ };
31936
32209
  const handleAlternateChoice = (params) => {
31937
- const skipHandlerResponse = { nodes: [], consumed: 0 };
31938
32210
  const { nodes, nodeListHandler } = params;
31939
- if (nodes.length === 0 || nodes[0].name !== "w:p") {
32211
+ if (!nodes?.length) {
31940
32212
  return skipHandlerResponse;
31941
32213
  }
31942
- const mainNode = nodes[0];
31943
- const node = mainNode?.elements?.find((el) => el.name === "w:r");
31944
- const hasAltChoice = node?.elements?.some((el) => el.name === "mc:AlternateContent");
31945
- if (!hasAltChoice) {
31946
- return skipHandlerResponse;
32214
+ const [currentNode] = nodes;
32215
+ if (isAlternateContentNode(currentNode)) {
32216
+ const resolvedElements = resolveAlternateContentElements(currentNode);
32217
+ if (!resolvedElements) {
32218
+ return skipHandlerResponse;
32219
+ }
32220
+ const result2 = nodeListHandler.handler({
32221
+ ...params,
32222
+ nodes: resolvedElements,
32223
+ path: [...params.path || [], currentNode]
32224
+ });
32225
+ return { nodes: result2, consumed: 1 };
31947
32226
  }
31948
- const altChoiceNode = node.elements.find((el) => el.name === "mc:AlternateContent");
31949
- node.elements.findIndex((el) => el.name === "mc:AlternateContent");
31950
- const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
31951
- const wpsNode = altChoiceNode.elements.find(
31952
- (el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
31953
- );
31954
- if (!wpsNode) {
32227
+ const sanitizedNode = buildNodeWithoutAlternateContent(currentNode);
32228
+ if (!sanitizedNode) {
31955
32229
  return skipHandlerResponse;
31956
32230
  }
31957
- const contents = wpsNode.elements;
31958
32231
  const result = nodeListHandler.handler({
31959
32232
  ...params,
31960
- nodes: contents,
31961
- path: [...params.path || [], wpsNode]
32233
+ nodes: [sanitizedNode],
32234
+ path: [...params.path || [], sanitizedNode]
31962
32235
  });
31963
32236
  return { nodes: result, consumed: 1 };
31964
32237
  };
@@ -32010,8 +32283,15 @@ const handlePictNode = (params) => {
32010
32283
  return { nodes: [], consumed: 0 };
32011
32284
  }
32012
32285
  const [pNode] = nodes;
32013
- const run2 = pNode.elements?.find((el) => el.name === "w:r");
32014
- const pict = run2?.elements?.find((el) => el.name === "w:pict");
32286
+ const runs = pNode.elements?.filter((el) => el.name === "w:r") || [];
32287
+ let pict = null;
32288
+ for (const run2 of runs) {
32289
+ const foundPict = run2.elements?.find((el) => el.name === "w:pict");
32290
+ if (foundPict) {
32291
+ pict = foundPict;
32292
+ break;
32293
+ }
32294
+ }
32015
32295
  if (!pict) {
32016
32296
  return { nodes: [], consumed: 0 };
32017
32297
  }
@@ -32564,7 +32844,7 @@ const handleTabNode = (params) => {
32564
32844
  if (!nodes.length || nodes[0].name !== "w:tab") {
32565
32845
  return { nodes: [], consumed: 0 };
32566
32846
  }
32567
- const node = translator$13.encode(params);
32847
+ const node = translator$14.encode(params);
32568
32848
  return { nodes: [node], consumed: 1 };
32569
32849
  };
32570
32850
  const tabNodeEntityHandler = {
@@ -32598,6 +32878,7 @@ const createDocumentJson = (docx, converter, editor) => {
32598
32878
  const nodeListHandler = defaultNodeListHandler();
32599
32879
  const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
32600
32880
  if (bodyNode) {
32881
+ ensureSectionProperties(bodyNode);
32601
32882
  const node = bodyNode;
32602
32883
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
32603
32884
  const content = pruneIgnoredNodes(contentElements);
@@ -32831,6 +33112,59 @@ function getDocumentStyles(node, docx, converter, editor) {
32831
33112
  styles.alternateHeaders = isAlternatingHeadersOddEven(docx);
32832
33113
  return styles;
32833
33114
  }
33115
+ const DEFAULT_SECTION_PROPS = Object.freeze({
33116
+ pageSize: Object.freeze({ width: "12240", height: "15840" }),
33117
+ pageMargins: Object.freeze({
33118
+ top: "1440",
33119
+ right: "1440",
33120
+ bottom: "1440",
33121
+ left: "1440",
33122
+ header: "720",
33123
+ footer: "720",
33124
+ gutter: "0"
33125
+ })
33126
+ });
33127
+ function ensureSectionProperties(bodyNode, converter) {
33128
+ if (!bodyNode.elements) bodyNode.elements = [];
33129
+ let sectPr = bodyNode.elements.find((el) => el.name === "w:sectPr");
33130
+ if (!sectPr) {
33131
+ sectPr = {
33132
+ type: "element",
33133
+ name: "w:sectPr",
33134
+ elements: []
33135
+ };
33136
+ bodyNode.elements.push(sectPr);
33137
+ } else if (!sectPr.elements) {
33138
+ sectPr.elements = [];
33139
+ }
33140
+ const ensureChild = (name, factory) => {
33141
+ let child = sectPr.elements.find((el) => el.name === name);
33142
+ if (!child) {
33143
+ child = factory();
33144
+ sectPr.elements.push(child);
33145
+ } else if (!child.attributes) {
33146
+ child.attributes = {};
33147
+ }
33148
+ return child;
33149
+ };
33150
+ const pgSz = ensureChild("w:pgSz", () => ({
33151
+ type: "element",
33152
+ name: "w:pgSz",
33153
+ attributes: {}
33154
+ }));
33155
+ pgSz.attributes["w:w"] = pgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS.pageSize.width;
33156
+ pgSz.attributes["w:h"] = pgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS.pageSize.height;
33157
+ const pgMar = ensureChild("w:pgMar", () => ({
33158
+ type: "element",
33159
+ name: "w:pgMar",
33160
+ attributes: {}
33161
+ }));
33162
+ Object.entries(DEFAULT_SECTION_PROPS.pageMargins).forEach(([key, value]) => {
33163
+ const attrKey = `w:${key}`;
33164
+ if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
33165
+ });
33166
+ return sectPr;
33167
+ }
32834
33168
  function getStyleDefinitions(docx) {
32835
33169
  const styles = docx["word/styles.xml"];
32836
33170
  if (!styles) return [];
@@ -33023,6 +33357,36 @@ const FONT_FAMILY_FALLBACKS = Object.freeze({
33023
33357
  auto: "sans-serif"
33024
33358
  });
33025
33359
  const DEFAULT_GENERIC_FALLBACK = "sans-serif";
33360
+ const DEFAULT_FONT_SIZE_PT = 10;
33361
+ const collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state: state2 }) => {
33362
+ if (!runProps?.elements?.length || !state2) return;
33363
+ const fontsNode = runProps.elements.find((el) => el.name === "w:rFonts");
33364
+ if (fontsNode?.attributes) {
33365
+ const themeName = fontsNode.attributes["w:asciiTheme"];
33366
+ if (themeName) {
33367
+ const themeInfo = themeResolver?.(themeName) || {};
33368
+ if ((allowOverrideTypeface || !state2.typeface) && themeInfo.typeface) state2.typeface = themeInfo.typeface;
33369
+ if ((allowOverrideTypeface || !state2.panose) && themeInfo.panose) state2.panose = themeInfo.panose;
33370
+ }
33371
+ const ascii = fontsNode.attributes["w:ascii"];
33372
+ if ((allowOverrideTypeface || !state2.typeface) && ascii) {
33373
+ state2.typeface = ascii;
33374
+ }
33375
+ }
33376
+ const sizeNode = runProps.elements.find((el) => el.name === "w:sz");
33377
+ if (sizeNode?.attributes?.["w:val"]) {
33378
+ const sizeTwips = Number(sizeNode.attributes["w:val"]);
33379
+ if (Number.isFinite(sizeTwips)) {
33380
+ if (state2.fallbackSzTwips === void 0) state2.fallbackSzTwips = sizeTwips;
33381
+ const sizePt = sizeTwips / 2;
33382
+ if (allowOverrideSize || state2.fontSizePt === void 0) state2.fontSizePt = sizePt;
33383
+ }
33384
+ }
33385
+ const kernNode = runProps.elements.find((el) => el.name === "w:kern");
33386
+ if (kernNode?.attributes?.["w:val"]) {
33387
+ if (allowOverrideSize || state2.kern === void 0) state2.kern = kernNode.attributes["w:val"];
33388
+ }
33389
+ };
33026
33390
  const _SuperConverter = class _SuperConverter {
33027
33391
  constructor(params = null) {
33028
33392
  __privateAdd(this, _SuperConverter_instances);
@@ -33128,7 +33492,7 @@ const _SuperConverter = class _SuperConverter {
33128
33492
  return;
33129
33493
  }
33130
33494
  }
33131
- static updateDocumentVersion(docx = this.convertedXml, version = "0.20.2") {
33495
+ static updateDocumentVersion(docx = this.convertedXml, version = "0.21.0") {
33132
33496
  const customLocation = "docProps/custom.xml";
33133
33497
  if (!docx[customLocation]) {
33134
33498
  docx[customLocation] = generateCustomXml();
@@ -33150,49 +33514,45 @@ const _SuperConverter = class _SuperConverter {
33150
33514
  }
33151
33515
  getDocumentDefaultStyles() {
33152
33516
  const styles = this.convertedXml["word/styles.xml"];
33153
- if (!styles) return {};
33154
- const defaults = styles.elements[0].elements.find((el) => el.name === "w:docDefaults");
33155
- const rDefault = defaults.elements.find((el) => el.name === "w:rPrDefault");
33156
- if (!rDefault.elements) return {};
33157
- const rElements = rDefault.elements[0].elements;
33158
- const rFonts = rElements?.find((el) => el.name === "w:rFonts");
33159
- if ("elements" in rDefault) {
33160
- const fontThemeName = rElements.find((el) => el.name === "w:rFonts")?.attributes["w:asciiTheme"];
33161
- let typeface, panose, fontSizeNormal;
33162
- if (fontThemeName) {
33163
- const fontInfo = this.getThemeInfo(fontThemeName);
33164
- typeface = fontInfo.typeface;
33165
- panose = fontInfo.panose;
33166
- } else if (rFonts) {
33167
- typeface = rFonts?.attributes["w:ascii"];
33168
- }
33169
- const paragraphDefaults = styles.elements[0].elements.filter((el) => {
33170
- return el.name === "w:style" && el.attributes["w:styleId"] === "Normal";
33171
- }) || [];
33172
- paragraphDefaults.forEach((el) => {
33173
- const rPr = el.elements.find((el2) => el2.name === "w:rPr");
33174
- const fonts = rPr?.elements?.find((el2) => el2.name === "w:rFonts");
33175
- typeface = fonts?.attributes["w:ascii"];
33176
- fontSizeNormal = Number(rPr?.elements?.find((el2) => el2.name === "w:sz")?.attributes["w:val"]) / 2;
33177
- });
33178
- const rPrDefaults = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
33179
- if (rPrDefaults) {
33180
- const rPr = rPrDefaults.elements?.find((el) => el.name === "w:rPr");
33181
- const fonts = rPr?.elements?.find((el) => el.name === "w:rFonts");
33182
- if (fonts?.attributes?.["w:ascii"]) {
33183
- typeface = fonts.attributes["w:ascii"];
33184
- }
33185
- const fontSizeRaw = rPr?.elements?.find((el) => el.name === "w:sz")?.attributes?.["w:val"];
33186
- if (!fontSizeNormal && fontSizeRaw) {
33187
- fontSizeNormal = Number(fontSizeRaw) / 2;
33188
- }
33189
- }
33190
- const fallbackSz = Number(rElements.find((el) => el.name === "w:sz")?.attributes?.["w:val"]);
33191
- const fontSizePt = fontSizeNormal ?? (Number.isFinite(fallbackSz) ? fallbackSz / 2 : void 0) ?? 10;
33192
- const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
33193
- const fontFamilyCss = _SuperConverter.toCssFontFamily(typeface, this.convertedXml);
33194
- return { fontSizePt, kern, typeface, panose, fontFamilyCss };
33195
- }
33517
+ const styleRoot = styles?.elements?.[0];
33518
+ const styleElements = styleRoot?.elements || [];
33519
+ if (!styleElements.length) return {};
33520
+ const defaults = styleElements.find((el) => el.name === "w:docDefaults");
33521
+ const normalStyle = styleElements.find((el) => el.name === "w:style" && el.attributes?.["w:styleId"] === "Normal");
33522
+ const defaultsState = {
33523
+ typeface: void 0,
33524
+ panose: void 0,
33525
+ fontSizePt: void 0,
33526
+ kern: void 0,
33527
+ fallbackSzTwips: void 0
33528
+ };
33529
+ const docDefaultRun = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
33530
+ const docDefaultProps = docDefaultRun?.elements?.find((el) => el.name === "w:rPr") ?? docDefaultRun;
33531
+ collectRunDefaultProperties(docDefaultProps, {
33532
+ allowOverrideTypeface: true,
33533
+ allowOverrideSize: true,
33534
+ themeResolver: (theme) => this.getThemeInfo(theme),
33535
+ state: defaultsState
33536
+ });
33537
+ const normalRunProps = normalStyle?.elements?.find((el) => el.name === "w:rPr") ?? null;
33538
+ collectRunDefaultProperties(normalRunProps, {
33539
+ allowOverrideTypeface: true,
33540
+ allowOverrideSize: true,
33541
+ themeResolver: (theme) => this.getThemeInfo(theme),
33542
+ state: defaultsState
33543
+ });
33544
+ if (defaultsState.fontSizePt === void 0) {
33545
+ if (Number.isFinite(defaultsState.fallbackSzTwips)) defaultsState.fontSizePt = defaultsState.fallbackSzTwips / 2;
33546
+ else defaultsState.fontSizePt = DEFAULT_FONT_SIZE_PT;
33547
+ }
33548
+ const fontFamilyCss = defaultsState.typeface ? _SuperConverter.toCssFontFamily(defaultsState.typeface, this.convertedXml) : void 0;
33549
+ const result = {};
33550
+ if (defaultsState.fontSizePt !== void 0) result.fontSizePt = defaultsState.fontSizePt;
33551
+ if (defaultsState.kern !== void 0) result.kern = defaultsState.kern;
33552
+ if (defaultsState.typeface) result.typeface = defaultsState.typeface;
33553
+ if (defaultsState.panose) result.panose = defaultsState.panose;
33554
+ if (fontFamilyCss) result.fontFamilyCss = fontFamilyCss;
33555
+ return result;
33196
33556
  }
33197
33557
  getDocumentFonts() {
33198
33558
  const fontTable = this.convertedXml["word/fontTable.xml"];
@@ -33624,7 +33984,7 @@ function storeSuperdocVersion(docx) {
33624
33984
  function generateCustomXml() {
33625
33985
  return DEFAULT_CUSTOM_XML;
33626
33986
  }
33627
- function generateSuperdocVersion(pid = 2, version = "0.20.2") {
33987
+ function generateSuperdocVersion(pid = 2, version = "0.21.0") {
33628
33988
  return {
33629
33989
  type: "element",
33630
33990
  name: "property",
@@ -33677,7 +34037,7 @@ export {
33677
34037
  objectIncludes as Z,
33678
34038
  AddMarkStep as _,
33679
34039
  Plugin as a,
33680
- translator$R as a$,
34040
+ translator$C as a$,
33681
34041
  twipsToLines as a0,
33682
34042
  pixelsToTwips as a1,
33683
34043
  helpers as a2,
@@ -33688,63 +34048,103 @@ export {
33688
34048
  createDocFromMarkdown as a7,
33689
34049
  createDocFromHTML as a8,
33690
34050
  EditorState as a9,
33691
- readFromClipboard as aA,
33692
- handleClipboardPaste as aB,
33693
- getFileObject as aC,
33694
- runPropertyTranslators as aD,
33695
- translator as aE,
33696
- translator$1 as aF,
33697
- translator$4 as aG,
33698
- translator$5 as aH,
33699
- translator$H as aI,
33700
- translator$I as aJ,
33701
- translator$G as aK,
33702
- translator$J as aL,
33703
- translator$F as aM,
33704
- translator$7 as aN,
33705
- translator$K as aO,
33706
- translator$L as aP,
33707
- translator$13 as aQ,
33708
- translator$2 as aR,
33709
- translator$U as aS,
33710
- translator$T as aT,
33711
- translator$12 as aU,
33712
- translator$M as aV,
33713
- translator$6 as aW,
33714
- translator$N as aX,
33715
- translator$O as aY,
33716
- translator$P as aZ,
33717
- translator$Q as a_,
34051
+ getActiveFormatting as aA,
34052
+ readFromClipboard as aB,
34053
+ handleClipboardPaste as aC,
34054
+ getFileObject as aD,
34055
+ runPropertyTranslators as aE,
34056
+ translator$5 as aF,
34057
+ translator$6 as aG,
34058
+ translator$I as aH,
34059
+ translator$J as aI,
34060
+ translator$10 as aJ,
34061
+ translator$H as aK,
34062
+ translator$K as aL,
34063
+ translator$G as aM,
34064
+ translator$g as aN,
34065
+ translator$8 as aO,
34066
+ translator$t as aP,
34067
+ translator$u as aQ,
34068
+ translator$v as aR,
34069
+ translator$w as aS,
34070
+ translator$x as aT,
34071
+ translator$c as aU,
34072
+ translator$y as aV,
34073
+ translator$z as aW,
34074
+ translator$A as aX,
34075
+ translator$B as aY,
34076
+ translator$L as aZ,
34077
+ translator$a as a_,
33718
34078
  hasSomeParentWithClass as aa,
33719
34079
  isActive as ab,
33720
34080
  unflattenListsInHtml as ac,
33721
34081
  parseSizeUnit as ad,
33722
34082
  minMax as ae,
33723
34083
  getLineHeightValueString as af,
33724
- InputRule as ag,
33725
- kebabCase as ah,
33726
- findParentNodeClosestToPos as ai,
33727
- getListItemStyleDefinitions as aj,
33728
- docxNumberigHelpers as ak,
33729
- parseIndentElement as al,
33730
- combineIndents as am,
33731
- SelectionRange as an,
33732
- Transform as ao,
33733
- isInTable as ap,
33734
- generateDocxRandomId as aq,
33735
- insertNewRelationship as ar,
33736
- updateDOMAttributes as as,
33737
- htmlHandler as at,
33738
- commonjsGlobal as au,
33739
- getDefaultExportFromCjs$1 as av,
33740
- getContentTypesFromXml as aw,
33741
- xmljs as ax,
33742
- vClickOutside as ay,
33743
- getActiveFormatting as az,
34084
+ updateDOMAttributes as ag,
34085
+ findChildren as ah,
34086
+ htmlHandler as ai,
34087
+ InputRule as aj,
34088
+ kebabCase as ak,
34089
+ findParentNodeClosestToPos as al,
34090
+ getListItemStyleDefinitions as am,
34091
+ docxNumberigHelpers as an,
34092
+ parseIndentElement as ao,
34093
+ combineIndents as ap,
34094
+ SelectionRange as aq,
34095
+ Transform as ar,
34096
+ isInTable as as,
34097
+ generateDocxRandomId as at,
34098
+ insertNewRelationship as au,
34099
+ commonjsGlobal as av,
34100
+ getDefaultExportFromCjs$1 as aw,
34101
+ getContentTypesFromXml as ax,
34102
+ xmljs as ay,
34103
+ vClickOutside as az,
33744
34104
  Slice as b,
33745
- translator$S as b0,
33746
- translator$15 as b1,
33747
- _sfc_main as b2,
34105
+ translator$M as b0,
34106
+ translator$d as b1,
34107
+ translator$D as b2,
34108
+ translator$e as b3,
34109
+ translator$9 as b4,
34110
+ translator$14 as b5,
34111
+ translator$W as b6,
34112
+ translator$X as b7,
34113
+ translator$$ as b8,
34114
+ translator$i as b9,
34115
+ translator$s as bA,
34116
+ translator$2 as bB,
34117
+ translator$1 as bC,
34118
+ translator$F as bD,
34119
+ translator$12 as bE,
34120
+ translator as bF,
34121
+ _sfc_main as bG,
34122
+ translator$E as ba,
34123
+ translator$3 as bb,
34124
+ translator$k as bc,
34125
+ translator$Y as bd,
34126
+ translator$V as be,
34127
+ translator$Z as bf,
34128
+ translator$U as bg,
34129
+ translator$13 as bh,
34130
+ translator$m as bi,
34131
+ translator$N as bj,
34132
+ translator$n as bk,
34133
+ translator$o as bl,
34134
+ translator$11 as bm,
34135
+ translator$7 as bn,
34136
+ translator$15 as bo,
34137
+ translator$O as bp,
34138
+ translator$b as bq,
34139
+ translator$P as br,
34140
+ translator$Q as bs,
34141
+ translator$q as bt,
34142
+ translator$4 as bu,
34143
+ translator$R as bv,
34144
+ translator$_ as bw,
34145
+ translator$S as bx,
34146
+ translator$T as by,
34147
+ translator$16 as bz,
33748
34148
  DOMParser$1 as c,
33749
34149
  Mark as d,
33750
34150
  dropPoint as e,