@harbour-enterprises/superdoc 0.20.2 → 0.21.0-RC1

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 (96) hide show
  1. package/dist/chunks/{PdfViewer-BhwyCIho.cjs → PdfViewer-BdrjIRpr.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BceCsygM.es.js → PdfViewer-DK1etjvu.es.js} +1 -1
  3. package/dist/chunks/{index-B6tAKGVb.cjs → index-C_zTr1ZR.cjs} +14 -33
  4. package/dist/chunks/{index-C0kV6dM8.es.js → index-ucP9WQ5I.es.js} +14 -33
  5. package/dist/chunks/{super-editor.es-BollA_Sr.es.js → super-editor.es-KKA9G1l1.es.js} +1851 -434
  6. package/dist/chunks/{super-editor.es-Dzt_HBkR.cjs → super-editor.es-XC168Mlw.cjs} +1851 -434
  7. package/dist/core/SuperDoc.d.ts.map +1 -1
  8. package/dist/stores/comments-store.d.ts.map +1 -1
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-DyzbfydS.js → converter-B61ZUb-V.js} +1405 -339
  11. package/dist/super-editor/chunks/{docx-zipper-Bk9SAmal.js → docx-zipper-B8nhsVFW.js} +2 -2
  12. package/dist/super-editor/chunks/{editor-BWE7oMgS.js → editor-CQ0o4v54.js} +420 -65
  13. package/dist/super-editor/chunks/{toolbar-BmHEsvA1.js → toolbar-DWzoslZk.js} +11 -21
  14. package/dist/super-editor/converter.es.js +1 -1
  15. package/dist/super-editor/docx-zipper.es.js +2 -2
  16. package/dist/super-editor/editor.es.js +3 -3
  17. package/dist/super-editor/file-zipper.es.js +1 -1
  18. package/dist/super-editor/src/core/commands/index.d.ts +1 -0
  19. package/dist/super-editor/src/core/commands/toggleMarkCascade.d.ts +41 -0
  20. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +5 -0
  21. package/dist/super-editor/src/core/super-converter/helpers.d.ts +2 -0
  22. package/dist/super-editor/src/core/super-converter/v2/importer/markImporter.d.ts +12 -0
  23. package/dist/super-editor/src/core/super-converter/v2/importer/runNodeImporter.d.ts +6 -6
  24. package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +20 -4
  25. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/index.d.ts +3 -0
  26. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/w-val.d.ts +4 -0
  27. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/b-translator.d.ts +7 -0
  28. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/index.d.ts +1 -0
  29. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/index.d.ts +2 -0
  30. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-color.d.ts +4 -0
  31. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-shade.d.ts +4 -0
  32. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-tint.d.ts +4 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-val.d.ts +4 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/color-translator.d.ts +7 -0
  35. package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/attributes/index.d.ts +2 -0
  36. package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/attributes/w-val.d.ts +4 -0
  37. package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/highlight-translator.d.ts +4 -0
  38. package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/index.d.ts +2 -0
  39. package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/w-val.d.ts +4 -0
  40. package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/i-translator.d.ts +7 -0
  41. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/index.d.ts +2 -0
  42. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-del.d.ts +4 -0
  43. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-r-pr.d.ts +4 -0
  44. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-r.d.ts +4 -0
  45. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/helpers.d.ts +40 -0
  46. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/index.d.ts +2 -0
  47. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/split-run-properties.d.ts +9 -0
  48. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/index.d.ts +1 -0
  49. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/r-translator.d.ts +4 -0
  50. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/index.d.ts +2 -0
  51. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-ascii.d.ts +4 -0
  52. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-cs.d.ts +4 -0
  53. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-east-asia.d.ts +4 -0
  54. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-hansi.d.ts +4 -0
  55. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-val.d.ts +4 -0
  56. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/index.d.ts +1 -0
  57. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/rFonts-translator.d.ts +5 -0
  58. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/index.d.ts +2 -0
  59. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/w-val.d.ts +4 -0
  60. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/index.d.ts +1 -0
  61. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/rstyle-translator.d.ts +7 -0
  62. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/index.d.ts +1 -0
  63. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/rpr-translator.d.ts +5 -0
  64. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/run-property-translators.d.ts +11 -0
  65. package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/index.d.ts +2 -0
  66. package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/w-val.d.ts +4 -0
  67. package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/strike-translator.d.ts +7 -0
  68. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/index.d.ts +2 -0
  69. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/w-val.d.ts +4 -0
  70. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/sz-translator.d.ts +4 -0
  71. package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/attributes/index.d.ts +2 -0
  72. package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/attributes/w-val.d.ts +4 -0
  73. package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/szcs-translator.d.ts +4 -0
  74. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/index.d.ts +2 -0
  75. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-color.d.ts +4 -0
  76. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-color.d.ts +4 -0
  77. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-shade.d.ts +4 -0
  78. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-tint.d.ts +4 -0
  79. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-val.d.ts +4 -0
  80. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/u-translator.d.ts +7 -0
  81. package/dist/super-editor/src/extensions/index.d.ts +2 -2
  82. package/dist/super-editor/src/extensions/linked-styles/index.d.ts +1 -0
  83. package/dist/super-editor/src/extensions/linked-styles/underline-css.d.ts +17 -0
  84. package/dist/super-editor/src/extensions/run/index.d.ts +1 -0
  85. package/dist/super-editor/src/extensions/run/run.d.ts +6 -0
  86. package/dist/super-editor/src/extensions/shared/cascade-toggle.d.ts +8 -0
  87. package/dist/super-editor/super-editor.es.js +49 -23
  88. package/dist/super-editor/toolbar.es.js +2 -2
  89. package/dist/super-editor.cjs +1 -1
  90. package/dist/super-editor.es.js +1 -1
  91. package/dist/superdoc.cjs +2 -2
  92. package/dist/superdoc.es.js +2 -2
  93. package/dist/superdoc.umd.js +1865 -467
  94. package/dist/superdoc.umd.js.map +1 -1
  95. package/package.json +1 -1
  96. package/dist/super-editor/src/core/super-converter/helpers/mediaHelpers.d.ts +0 -2
@@ -14875,25 +14875,47 @@ const getContentTypesFromXml = (contentTypesXml) => {
14875
14875
  const defaults = xmlDoc.querySelectorAll("Default");
14876
14876
  return Array.from(defaults).map((item) => item.getAttribute("Extension"));
14877
14877
  };
14878
+ const DOCX_HIGHLIGHT_KEYWORD_MAP = /* @__PURE__ */ new Map([
14879
+ ["yellow", "FFFF00"],
14880
+ ["green", "00FF00"],
14881
+ ["blue", "0000FF"],
14882
+ ["cyan", "00FFFF"],
14883
+ ["magenta", "FF00FF"],
14884
+ ["red", "FF0000"],
14885
+ ["darkYellow", "808000"],
14886
+ ["darkGreen", "008000"],
14887
+ ["darkBlue", "000080"],
14888
+ ["darkCyan", "008080"],
14889
+ ["darkMagenta", "800080"],
14890
+ ["darkGray", "808080"],
14891
+ ["darkRed", "800000"],
14892
+ ["lightGray", "C0C0C0"],
14893
+ ["black", "000000"],
14894
+ ["white", "FFFFFF"]
14895
+ ]);
14896
+ const normalizeHexColor = (hex) => {
14897
+ if (!hex) return null;
14898
+ let value = hex.replace("#", "").trim();
14899
+ if (!value) return null;
14900
+ value = value.toUpperCase();
14901
+ if (value.length === 3)
14902
+ value = value.split("").map((c) => c + c).join("");
14903
+ if (value.length === 8) value = value.slice(0, 6);
14904
+ return value;
14905
+ };
14878
14906
  const getHexColorFromDocxSystem = (docxColor) => {
14879
- const colorMap = /* @__PURE__ */ new Map([
14880
- ["yellow", "#ffff00"],
14881
- ["green", "#00ff00"],
14882
- ["blue", "#0000FFFF"],
14883
- ["cyan", "#00ffff"],
14884
- ["magenta", "#ff00ff"],
14885
- ["red", "#ff0000"],
14886
- ["darkYellow", "#808000FF"],
14887
- ["darkGreen", "#008000FF"],
14888
- ["darkBlue", "#000080"],
14889
- ["darkCyan", "#008080FF"],
14890
- ["darkMagenta", "#800080FF"],
14891
- ["darkGray", "#808080FF"],
14892
- ["darkRed", "#800000FF"],
14893
- ["lightGray", "#C0C0C0FF"],
14894
- ["black", "#000"]
14895
- ]);
14896
- return colorMap.get(docxColor) || null;
14907
+ const hex = DOCX_HIGHLIGHT_KEYWORD_MAP.get(docxColor);
14908
+ return hex ? `#${hex}` : null;
14909
+ };
14910
+ const getDocxHighlightKeywordFromHex = (hexColor) => {
14911
+ if (!hexColor) return null;
14912
+ if (DOCX_HIGHLIGHT_KEYWORD_MAP.has(hexColor)) return hexColor;
14913
+ const normalized = normalizeHexColor(hexColor);
14914
+ if (!normalized) return null;
14915
+ for (const [keyword, hex] of DOCX_HIGHLIGHT_KEYWORD_MAP.entries()) {
14916
+ if (hex === normalized) return keyword;
14917
+ }
14918
+ return null;
14897
14919
  };
14898
14920
  function isValidHexColor(color) {
14899
14921
  if (!color || typeof color !== "string") return false;
@@ -24174,18 +24196,6 @@ const baseNumbering = {
24174
24196
  }
24175
24197
  ]
24176
24198
  };
24177
- const sanitizeDocxMediaName = (value, fallback = "image") => {
24178
- if (!value) return fallback;
24179
- const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
24180
- return sanitized || fallback;
24181
- };
24182
- const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
24183
- if (!src || typeof src !== "string") return fallback;
24184
- const [prefix] = src.split(";");
24185
- const [, maybeType] = prefix.split("/");
24186
- const extension = maybeType?.toLowerCase();
24187
- return extension ? `${fallback}.${extension}` : fallback;
24188
- };
24189
24199
  const TranslatorTypes = Object.freeze({
24190
24200
  NODE: "node",
24191
24201
  ATTRIBUTE: "attribute"
@@ -24315,37 +24325,37 @@ const _NodeTranslator = class _NodeTranslator {
24315
24325
  /** @type {typeof TranslatorTypes} */
24316
24326
  __publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
24317
24327
  let NodeTranslator = _NodeTranslator;
24318
- const encode$j = (attributes) => {
24328
+ const encode$T = (attributes) => {
24319
24329
  return attributes["w:type"];
24320
24330
  };
24321
- const decode$j = (attrs) => {
24331
+ const decode$K = (attrs) => {
24322
24332
  const { lineBreakType } = attrs;
24323
24333
  return lineBreakType;
24324
24334
  };
24325
- const attrConfig$b = Object.freeze({
24335
+ const attrConfig$z = Object.freeze({
24326
24336
  xmlName: "w:type",
24327
24337
  sdName: "lineBreakType",
24328
- encode: encode$j,
24329
- decode: decode$j
24338
+ encode: encode$T,
24339
+ decode: decode$K
24330
24340
  });
24331
- const encode$i = (attributes) => {
24341
+ const encode$S = (attributes) => {
24332
24342
  const xmlAttrValue = attributes["w:clear"];
24333
24343
  return xmlAttrValue;
24334
24344
  };
24335
- const decode$i = (attrs) => {
24345
+ const decode$J = (attrs) => {
24336
24346
  const { clear } = attrs;
24337
24347
  return clear;
24338
24348
  };
24339
- const attrConfig$a = Object.freeze({
24349
+ const attrConfig$y = Object.freeze({
24340
24350
  xmlName: "w:clear",
24341
24351
  sdName: "clear",
24342
- encode: encode$i,
24343
- decode: decode$i
24352
+ encode: encode$S,
24353
+ decode: decode$J
24344
24354
  });
24345
- const validXmlAttributes$6 = [attrConfig$b, attrConfig$a];
24346
- const XML_NODE_NAME$7 = "w:br";
24355
+ const validXmlAttributes$h = [attrConfig$z, attrConfig$y];
24356
+ const XML_NODE_NAME$j = "w:br";
24347
24357
  const SD_NODE_NAME$6 = "lineBreak";
24348
- const encode$h = (_2, encodedAttrs) => {
24358
+ const encode$R = (_2, encodedAttrs) => {
24349
24359
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24350
24360
  const translated = {
24351
24361
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24355,7 +24365,7 @@ const encode$h = (_2, encodedAttrs) => {
24355
24365
  }
24356
24366
  return translated;
24357
24367
  };
24358
- const decode$h = (params, decodedAttrs) => {
24368
+ const decode$I = (params, decodedAttrs) => {
24359
24369
  const { node } = params;
24360
24370
  if (!node) return;
24361
24371
  const wBreak = { name: "w:br" };
@@ -24372,63 +24382,120 @@ const decode$h = (params, decodedAttrs) => {
24372
24382
  };
24373
24383
  return translated;
24374
24384
  };
24375
- const config$7 = {
24376
- xmlName: XML_NODE_NAME$7,
24385
+ const config$j = {
24386
+ xmlName: XML_NODE_NAME$j,
24377
24387
  sdNodeOrKeyName: SD_NODE_NAME$6,
24378
24388
  type: NodeTranslator.translatorTypes.NODE,
24379
- encode: encode$h,
24380
- decode: decode$h,
24381
- attributes: validXmlAttributes$6
24389
+ encode: encode$R,
24390
+ decode: decode$I,
24391
+ attributes: validXmlAttributes$h
24392
+ };
24393
+ const translator$v = NodeTranslator.from(config$j);
24394
+ const encode$Q = (attributes) => attributes?.["w:val"];
24395
+ const decode$H = (attrs) => attrs?.highlight;
24396
+ const attrConfig$x = Object.freeze({
24397
+ xmlName: "w:val",
24398
+ sdName: "highlight",
24399
+ encode: encode$Q,
24400
+ decode: decode$H
24401
+ });
24402
+ const validXmlAttributes$g = [attrConfig$x];
24403
+ const XML_NODE_NAME$i = "w:highlight";
24404
+ const SD_ATTR_KEY$b = "highlight";
24405
+ const encode$P = (params, encodedAttrs = {}) => {
24406
+ const { nodes } = params;
24407
+ const node = nodes?.[0];
24408
+ const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
24409
+ return {
24410
+ type: "attr",
24411
+ xmlName: XML_NODE_NAME$i,
24412
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
24413
+ attributes: { "w:val": value ?? null }
24414
+ };
24415
+ };
24416
+ const decode$G = (params) => {
24417
+ const attrs = params?.node?.attrs || {};
24418
+ const highlightValue = attrs.highlight ?? attrs.color ?? null;
24419
+ if (!highlightValue) return void 0;
24420
+ const normalizedValue = String(highlightValue).trim().toLowerCase();
24421
+ if (!normalizedValue || normalizedValue === "transparent" || normalizedValue === "none") {
24422
+ return void 0;
24423
+ }
24424
+ const keyword = getDocxHighlightKeywordFromHex(highlightValue);
24425
+ if (keyword) {
24426
+ return {
24427
+ name: XML_NODE_NAME$i,
24428
+ attributes: { "w:val": keyword }
24429
+ };
24430
+ }
24431
+ const fill = normalizeHexColor(highlightValue);
24432
+ if (!fill) return void 0;
24433
+ return {
24434
+ name: "w:shd",
24435
+ attributes: {
24436
+ "w:color": "auto",
24437
+ "w:val": "clear",
24438
+ "w:fill": fill
24439
+ }
24440
+ };
24382
24441
  };
24383
- const translator$j = NodeTranslator.from(config$7);
24384
- const encode$g = (attributes) => {
24442
+ const config$i = {
24443
+ xmlName: XML_NODE_NAME$i,
24444
+ sdNodeOrKeyName: SD_ATTR_KEY$b,
24445
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
24446
+ encode: encode$P,
24447
+ decode: decode$G,
24448
+ attributes: validXmlAttributes$g
24449
+ };
24450
+ const translator$u = NodeTranslator.from(config$i);
24451
+ const encode$O = (attributes) => {
24385
24452
  return attributes["w:val"];
24386
24453
  };
24387
- const decode$g = (attrs) => {
24454
+ const decode$F = (attrs) => {
24388
24455
  const { tabSize } = attrs || {};
24389
24456
  return tabSize;
24390
24457
  };
24391
- const attrConfig$9 = Object.freeze({
24458
+ const attrConfig$w = Object.freeze({
24392
24459
  xmlName: "w:val",
24393
24460
  sdName: "tabSize",
24394
- encode: encode$g,
24395
- decode: decode$g
24461
+ encode: encode$O,
24462
+ decode: decode$F
24396
24463
  });
24397
- const encode$f = (attributes) => {
24464
+ const encode$N = (attributes) => {
24398
24465
  return attributes["w:leader"];
24399
24466
  };
24400
- const decode$f = (attrs) => {
24467
+ const decode$E = (attrs) => {
24401
24468
  const { leader } = attrs || {};
24402
24469
  return leader;
24403
24470
  };
24404
- const attrConfig$8 = Object.freeze({
24471
+ const attrConfig$v = Object.freeze({
24405
24472
  xmlName: "w:leader",
24406
24473
  sdName: "leader",
24407
- encode: encode$f,
24408
- decode: decode$f
24474
+ encode: encode$N,
24475
+ decode: decode$E
24409
24476
  });
24410
- const encode$e = (attributes) => {
24477
+ const encode$M = (attributes) => {
24411
24478
  return attributes["w:pos"];
24412
24479
  };
24413
- const decode$e = (attrs) => {
24480
+ const decode$D = (attrs) => {
24414
24481
  const { pos } = attrs || {};
24415
24482
  return pos;
24416
24483
  };
24417
- const attrConfig$7 = Object.freeze({
24484
+ const attrConfig$u = Object.freeze({
24418
24485
  xmlName: "w:pos",
24419
24486
  sdName: "pos",
24420
- encode: encode$e,
24421
- decode: decode$e
24487
+ encode: encode$M,
24488
+ decode: decode$D
24422
24489
  });
24423
- const validXmlAttributes$5 = [attrConfig$9, attrConfig$7, attrConfig$8];
24424
- const XML_NODE_NAME$6 = "w:tab";
24490
+ const validXmlAttributes$f = [attrConfig$w, attrConfig$u, attrConfig$v];
24491
+ const XML_NODE_NAME$h = "w:tab";
24425
24492
  const SD_NODE_NAME$5 = "tab";
24426
- const encode$d = (_2, encodedAttrs = {}) => {
24493
+ const encode$L = (_2, encodedAttrs = {}) => {
24427
24494
  const translated = { type: "tab" };
24428
24495
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24429
24496
  return translated;
24430
24497
  };
24431
- const decode$d = (params, decodedAttrs = {}) => {
24498
+ const decode$C = (params, decodedAttrs = {}) => {
24432
24499
  const { node } = params || {};
24433
24500
  if (!node) return;
24434
24501
  const wTab = { name: "w:tab" };
@@ -24444,15 +24511,15 @@ const decode$d = (params, decodedAttrs = {}) => {
24444
24511
  }
24445
24512
  return translated;
24446
24513
  };
24447
- const config$6 = {
24448
- xmlName: XML_NODE_NAME$6,
24514
+ const config$h = {
24515
+ xmlName: XML_NODE_NAME$h,
24449
24516
  sdNodeOrKeyName: SD_NODE_NAME$5,
24450
24517
  type: NodeTranslator.translatorTypes.NODE,
24451
- encode: encode$d,
24452
- decode: decode$d,
24453
- attributes: validXmlAttributes$5
24518
+ encode: encode$L,
24519
+ decode: decode$C,
24520
+ attributes: validXmlAttributes$f
24454
24521
  };
24455
- const translator$i = NodeTranslator.from(config$6);
24522
+ const translator$t = NodeTranslator.from(config$h);
24456
24523
  const mergeTextNodes = (nodes) => {
24457
24524
  if (!nodes || !Array.isArray(nodes)) {
24458
24525
  return nodes;
@@ -24627,17 +24694,21 @@ function getMarkValue(markType, attributes, docx) {
24627
24694
  function getFontFamilyValue(attributes, docx) {
24628
24695
  const ascii = attributes["w:ascii"];
24629
24696
  const themeAscii = attributes["w:asciiTheme"];
24630
- if (!docx || !themeAscii) return ascii;
24631
- const theme = docx["word/theme/theme1.xml"];
24632
- if (!theme) return ascii;
24633
- const { elements: topElements } = theme;
24634
- const { elements } = topElements[0];
24635
- const themeElements = elements.find((el) => el.name === "a:themeElements");
24636
- const fontScheme = themeElements.elements.find((el) => el.name === "a:fontScheme");
24637
- const majorFont = fontScheme.elements.find((el) => el.name === "a:majorFont");
24638
- const latin = majorFont.elements.find((el) => el.name === "a:latin");
24639
- const typeface = latin.attributes["typeface"];
24640
- return typeface;
24697
+ let resolved = ascii;
24698
+ if (docx && themeAscii) {
24699
+ const theme = docx["word/theme/theme1.xml"];
24700
+ if (theme?.elements?.length) {
24701
+ const { elements: topElements } = theme;
24702
+ const { elements } = topElements[0] || {};
24703
+ const themeElements = elements?.find((el) => el.name === "a:themeElements");
24704
+ const fontScheme = themeElements?.elements?.find((el) => el.name === "a:fontScheme");
24705
+ const majorFont = fontScheme?.elements?.find((el) => el.name === "a:majorFont");
24706
+ const latin = majorFont?.elements?.find((el) => el.name === "a:latin");
24707
+ resolved = latin?.attributes?.typeface || resolved;
24708
+ }
24709
+ }
24710
+ if (!resolved) return null;
24711
+ return SuperConverter.toCssFontFamily(resolved, docx);
24641
24712
  }
24642
24713
  function getIndentValue(attributes) {
24643
24714
  let value = attributes["w:left"];
@@ -24658,7 +24729,11 @@ function getHighLightValue(attributes) {
24658
24729
  return getHexColorFromDocxSystem(attributes?.["w:val"]) || null;
24659
24730
  }
24660
24731
  function getStrikeValue(attributes) {
24661
- return attributes?.["w:val"] === "1" ? attributes["w:val"] : null;
24732
+ const raw = attributes?.["w:val"];
24733
+ if (raw === void 0 || raw === null) return "1";
24734
+ const value = String(raw).trim().toLowerCase();
24735
+ if (value === "1" || value === "true" || value === "on") return "1";
24736
+ return null;
24662
24737
  }
24663
24738
  const parseParagraphBorders = (pBdr) => {
24664
24739
  if (!pBdr || !pBdr.elements) return {};
@@ -25022,102 +25097,102 @@ const handleParagraphNode$1 = (params) => {
25022
25097
  }
25023
25098
  return schemaNode;
25024
25099
  };
25025
- const encode$c = (attributes) => {
25100
+ const encode$K = (attributes) => {
25026
25101
  return attributes["w:rsidDel"];
25027
25102
  };
25028
- const decode$c = (attrs) => {
25103
+ const decode$B = (attrs) => {
25029
25104
  return attrs.rsidDel;
25030
25105
  };
25031
- const attrConfig$6 = Object.freeze({
25106
+ const attrConfig$t = Object.freeze({
25032
25107
  xmlName: "w:rsidDel",
25033
25108
  sdName: "rsidDel",
25034
- encode: encode$c,
25035
- decode: decode$c
25109
+ encode: encode$K,
25110
+ decode: decode$B
25036
25111
  });
25037
- const encode$b = (attributes) => {
25112
+ const encode$J = (attributes) => {
25038
25113
  return attributes["w:rsidP"];
25039
25114
  };
25040
- const decode$b = (attrs) => {
25115
+ const decode$A = (attrs) => {
25041
25116
  return attrs.rsidP;
25042
25117
  };
25043
- const attrConfig$5 = Object.freeze({
25118
+ const attrConfig$s = Object.freeze({
25044
25119
  xmlName: "w:rsidP",
25045
25120
  sdName: "rsidP",
25046
- encode: encode$b,
25047
- decode: decode$b
25121
+ encode: encode$J,
25122
+ decode: decode$A
25048
25123
  });
25049
- const encode$a = (attributes) => {
25124
+ const encode$I = (attributes) => {
25050
25125
  return attributes["w:rsidR"];
25051
25126
  };
25052
- const decode$a = (attrs) => {
25127
+ const decode$z = (attrs) => {
25053
25128
  return attrs.rsidR;
25054
25129
  };
25055
- const attrConfig$4 = Object.freeze({
25130
+ const attrConfig$r = Object.freeze({
25056
25131
  xmlName: "w:rsidR",
25057
25132
  sdName: "rsidR",
25058
- encode: encode$a,
25059
- decode: decode$a
25133
+ encode: encode$I,
25134
+ decode: decode$z
25060
25135
  });
25061
- const encode$9 = (attributes) => {
25136
+ const encode$H = (attributes) => {
25062
25137
  return attributes["w:rsidRPr"];
25063
25138
  };
25064
- const decode$9 = (attrs) => {
25139
+ const decode$y = (attrs) => {
25065
25140
  return attrs.rsidRPr;
25066
25141
  };
25067
- const attrConfig$3 = Object.freeze({
25142
+ const attrConfig$q = Object.freeze({
25068
25143
  xmlName: "w:rsidRPr",
25069
25144
  sdName: "rsidRPr",
25070
- encode: encode$9,
25071
- decode: decode$9
25145
+ encode: encode$H,
25146
+ decode: decode$y
25072
25147
  });
25073
- const encode$8 = (attributes) => {
25148
+ const encode$G = (attributes) => {
25074
25149
  return attributes["w:rsidRDefault"];
25075
25150
  };
25076
- const decode$8 = (attrs) => {
25151
+ const decode$x = (attrs) => {
25077
25152
  return attrs.rsidRDefault;
25078
25153
  };
25079
- const attrConfig$2 = Object.freeze({
25154
+ const attrConfig$p = Object.freeze({
25080
25155
  xmlName: "w:rsidRDefault",
25081
25156
  sdName: "rsidRDefault",
25082
- encode: encode$8,
25083
- decode: decode$8
25157
+ encode: encode$G,
25158
+ decode: decode$x
25084
25159
  });
25085
- const encode$7 = (attributes) => {
25160
+ const encode$F = (attributes) => {
25086
25161
  return attributes["w14:paraId"];
25087
25162
  };
25088
- const decode$7 = (attrs) => {
25163
+ const decode$w = (attrs) => {
25089
25164
  return attrs.paraId;
25090
25165
  };
25091
- const attrConfig$1 = Object.freeze({
25166
+ const attrConfig$o = Object.freeze({
25092
25167
  xmlName: "w14:paraId",
25093
25168
  sdName: "paraId",
25094
- encode: encode$7,
25095
- decode: decode$7
25169
+ encode: encode$F,
25170
+ decode: decode$w
25096
25171
  });
25097
- const encode$6 = (attributes) => {
25172
+ const encode$E = (attributes) => {
25098
25173
  return attributes["w14:textId"];
25099
25174
  };
25100
- const decode$6 = (attrs) => {
25175
+ const decode$v = (attrs) => {
25101
25176
  return attrs.textId;
25102
25177
  };
25103
- const attrConfig = Object.freeze({
25178
+ const attrConfig$n = Object.freeze({
25104
25179
  xmlName: "w14:textId",
25105
25180
  sdName: "textId",
25106
- encode: encode$6,
25107
- decode: decode$6
25181
+ encode: encode$E,
25182
+ decode: decode$v
25108
25183
  });
25109
- const validXmlAttributes$4 = [
25110
- attrConfig$1,
25111
- attrConfig,
25112
- attrConfig$4,
25113
- attrConfig$2,
25114
- attrConfig$5,
25115
- attrConfig$3,
25116
- attrConfig$6
25184
+ const validXmlAttributes$e = [
25185
+ attrConfig$o,
25186
+ attrConfig$n,
25187
+ attrConfig$r,
25188
+ attrConfig$p,
25189
+ attrConfig$s,
25190
+ attrConfig$q,
25191
+ attrConfig$t
25117
25192
  ];
25118
- const XML_NODE_NAME$5 = "w:p";
25193
+ const XML_NODE_NAME$g = "w:p";
25119
25194
  const SD_NODE_NAME$4 = "paragraph";
25120
- const encode$5 = (params, encodedAttrs = {}) => {
25195
+ const encode$D = (params, encodedAttrs = {}) => {
25121
25196
  const node = handleParagraphNode$1(params);
25122
25197
  if (!node) return void 0;
25123
25198
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25125,7 +25200,7 @@ const encode$5 = (params, encodedAttrs = {}) => {
25125
25200
  }
25126
25201
  return node;
25127
25202
  };
25128
- const decode$5 = (params, decodedAttrs = {}) => {
25203
+ const decode$u = (params, decodedAttrs = {}) => {
25129
25204
  const translated = translateParagraphNode(params);
25130
25205
  if (!translated) return void 0;
25131
25206
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25133,15 +25208,15 @@ const decode$5 = (params, decodedAttrs = {}) => {
25133
25208
  }
25134
25209
  return translated;
25135
25210
  };
25136
- const config$5 = {
25137
- xmlName: XML_NODE_NAME$5,
25211
+ const config$g = {
25212
+ xmlName: XML_NODE_NAME$g,
25138
25213
  sdNodeOrKeyName: SD_NODE_NAME$4,
25139
25214
  type: NodeTranslator.translatorTypes.NODE,
25140
- encode: encode$5,
25141
- decode: decode$5,
25142
- attributes: validXmlAttributes$4
25215
+ encode: encode$D,
25216
+ decode: decode$u,
25217
+ attributes: validXmlAttributes$e
25143
25218
  };
25144
- const translator$h = NodeTranslator.from(config$5);
25219
+ const translator$s = NodeTranslator.from(config$g);
25145
25220
  const generateV2HandlerEntity = (handlerName, translator2) => ({
25146
25221
  handlerName,
25147
25222
  handler: (params) => {
@@ -25248,13 +25323,13 @@ const integerToString = (value) => {
25248
25323
  const intValue = parseInteger(value);
25249
25324
  return intValue != void 0 ? String(intValue) : void 0;
25250
25325
  };
25251
- const translator$g = NodeTranslator.from({
25326
+ const translator$r = NodeTranslator.from({
25252
25327
  xmlName: "w:cantSplit",
25253
25328
  sdNodeOrKeyName: "cantSplit",
25254
25329
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
25255
25330
  decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
25256
25331
  });
25257
- const translator$f = NodeTranslator.from({
25332
+ const translator$q = NodeTranslator.from({
25258
25333
  xmlName: "w:cnfStyle",
25259
25334
  sdNodeOrKeyName: "cnfStyle",
25260
25335
  attributes: [
@@ -25287,8 +25362,8 @@ const translator$f = NodeTranslator.from({
25287
25362
  return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
25288
25363
  }
25289
25364
  });
25290
- const translator$e = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
25291
- const translator$d = NodeTranslator.from(
25365
+ const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
25366
+ const translator$o = NodeTranslator.from(
25292
25367
  createSingleAttrPropertyHandler(
25293
25368
  "w:gridAfter",
25294
25369
  null,
@@ -25297,7 +25372,7 @@ const translator$d = NodeTranslator.from(
25297
25372
  (v2) => integerToString(v2)
25298
25373
  )
25299
25374
  );
25300
- const translator$c = NodeTranslator.from(
25375
+ const translator$n = NodeTranslator.from(
25301
25376
  createSingleAttrPropertyHandler(
25302
25377
  "w:gridBefore",
25303
25378
  null,
@@ -25306,21 +25381,21 @@ const translator$c = NodeTranslator.from(
25306
25381
  (v2) => integerToString(v2)
25307
25382
  )
25308
25383
  );
25309
- const translator$b = NodeTranslator.from({
25384
+ const translator$m = NodeTranslator.from({
25310
25385
  xmlName: "w:hidden",
25311
25386
  sdNodeOrKeyName: "hidden",
25312
25387
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25313
25388
  decode: ({ node }) => node.attrs.hidden ? {} : void 0
25314
25389
  });
25315
- const translator$a = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
25316
- const translator$9 = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
25317
- const translator$8 = NodeTranslator.from({
25390
+ const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
25391
+ const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
25392
+ const translator$j = NodeTranslator.from({
25318
25393
  xmlName: "w:tblHeader",
25319
25394
  sdNodeOrKeyName: "repeatHeader",
25320
25395
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25321
25396
  decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
25322
25397
  });
25323
- const translator$7 = NodeTranslator.from({
25398
+ const translator$i = NodeTranslator.from({
25324
25399
  xmlName: "w:trHeight",
25325
25400
  sdNodeOrKeyName: "rowHeight",
25326
25401
  encode: ({ nodes }) => {
@@ -25347,11 +25422,11 @@ const translator$7 = NodeTranslator.from({
25347
25422
  return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
25348
25423
  }
25349
25424
  });
25350
- const translator$6 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
25351
- const translator$5 = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
25352
- const XML_NODE_NAME$4 = "w:trPr";
25353
- const SD_ATTR_KEY = "tableRowProperties";
25354
- const encode$4 = (params) => {
25425
+ const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
25426
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
25427
+ const XML_NODE_NAME$f = "w:trPr";
25428
+ const SD_ATTR_KEY$a = "tableRowProperties";
25429
+ const encode$C = (params) => {
25355
25430
  const { nodes } = params;
25356
25431
  const node = nodes[0];
25357
25432
  let attributes = {
@@ -25365,12 +25440,12 @@ const encode$4 = (params) => {
25365
25440
  };
25366
25441
  return {
25367
25442
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25368
- xmlName: XML_NODE_NAME$4,
25369
- sdNodeOrKeyName: SD_ATTR_KEY,
25443
+ xmlName: XML_NODE_NAME$f,
25444
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25370
25445
  attributes
25371
25446
  };
25372
25447
  };
25373
- const decode$4 = (params) => {
25448
+ const decode$t = (params) => {
25374
25449
  const { tableRowProperties = {} } = params.node.attrs || {};
25375
25450
  const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
25376
25451
  const newNode = {
@@ -25382,18 +25457,18 @@ const decode$4 = (params) => {
25382
25457
  return newNode;
25383
25458
  };
25384
25459
  const propertyTranslators = [
25385
- translator$g,
25386
- translator$f,
25387
- translator$e,
25388
- translator$d,
25389
- translator$c,
25390
- translator$b,
25391
- translator$a,
25392
- translator$9,
25393
- translator$8,
25394
- translator$7,
25395
- translator$6,
25396
- translator$5
25460
+ translator$r,
25461
+ translator$q,
25462
+ translator$p,
25463
+ translator$o,
25464
+ translator$n,
25465
+ translator$m,
25466
+ translator$l,
25467
+ translator$k,
25468
+ translator$j,
25469
+ translator$i,
25470
+ translator$h,
25471
+ translator$g
25397
25472
  ];
25398
25473
  const propertyTranslatorsByXmlName = {};
25399
25474
  propertyTranslators.forEach((translator2) => {
@@ -25403,25 +25478,25 @@ const propertyTranslatorsBySdName = {};
25403
25478
  propertyTranslators.forEach((translator2) => {
25404
25479
  propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
25405
25480
  });
25406
- const config$4 = {
25407
- xmlName: XML_NODE_NAME$4,
25408
- sdNodeOrKeyName: SD_ATTR_KEY,
25481
+ const config$f = {
25482
+ xmlName: XML_NODE_NAME$f,
25483
+ sdNodeOrKeyName: SD_ATTR_KEY$a,
25409
25484
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25410
- encode: encode$4,
25411
- decode: decode$4
25485
+ encode: encode$C,
25486
+ decode: decode$t
25412
25487
  };
25413
- const translator$4 = NodeTranslator.from(config$4);
25414
- const XML_NODE_NAME$3 = "w:tr";
25488
+ const translator$f = NodeTranslator.from(config$f);
25489
+ const XML_NODE_NAME$e = "w:tr";
25415
25490
  const SD_NODE_NAME$3 = "tableRow";
25416
- const validXmlAttributes$3 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
25491
+ const validXmlAttributes$d = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
25417
25492
  (xmlName) => createAttributeHandler(xmlName)
25418
25493
  );
25419
- const encode$3 = (params, encodedAttrs) => {
25494
+ const encode$B = (params, encodedAttrs) => {
25420
25495
  const { row, table } = params.extraParams;
25421
25496
  let tableRowProperties = {};
25422
25497
  const tPr = row.elements.find((el) => el.name === "w:trPr");
25423
25498
  if (tPr) {
25424
- ({ attributes: tableRowProperties } = translator$4.encode({
25499
+ ({ attributes: tableRowProperties } = translator$f.encode({
25425
25500
  ...params,
25426
25501
  nodes: [tPr]
25427
25502
  }));
@@ -25434,7 +25509,7 @@ const encode$3 = (params, encodedAttrs) => {
25434
25509
  let currentColumnIndex = 0;
25435
25510
  const content = cellNodes?.map((n) => {
25436
25511
  let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
25437
- const result = translator$2.encode({
25512
+ const result = translator$d.encode({
25438
25513
  ...params,
25439
25514
  extraParams: {
25440
25515
  ...params.extraParams,
@@ -25465,7 +25540,7 @@ const _getGridColumnWidths = (tableNode) => {
25465
25540
  }) || [];
25466
25541
  return columnWidths;
25467
25542
  };
25468
- const decode$3 = (params, decodedAttrs) => {
25543
+ const decode$s = (params, decodedAttrs) => {
25469
25544
  const { node } = params;
25470
25545
  const elements = translateChildNodes(params);
25471
25546
  if (node.attrs?.tableRowProperties) {
@@ -25477,7 +25552,7 @@ const decode$3 = (params, decodedAttrs) => {
25477
25552
  }
25478
25553
  }
25479
25554
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
25480
- const trPr = translator$4.decode({
25555
+ const trPr = translator$f.decode({
25481
25556
  ...params,
25482
25557
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
25483
25558
  });
@@ -25489,15 +25564,15 @@ const decode$3 = (params, decodedAttrs) => {
25489
25564
  elements
25490
25565
  };
25491
25566
  };
25492
- const config$3 = {
25493
- xmlName: XML_NODE_NAME$3,
25567
+ const config$e = {
25568
+ xmlName: XML_NODE_NAME$e,
25494
25569
  sdNodeOrKeyName: SD_NODE_NAME$3,
25495
25570
  type: NodeTranslator.translatorTypes.NODE,
25496
- encode: encode$3,
25497
- decode: decode$3,
25498
- attributes: validXmlAttributes$3
25571
+ encode: encode$B,
25572
+ decode: decode$s,
25573
+ attributes: validXmlAttributes$d
25499
25574
  };
25500
- const translator$3 = NodeTranslator.from(config$3);
25575
+ const translator$e = NodeTranslator.from(config$e);
25501
25576
  const handleAllTableNodes = (params) => {
25502
25577
  const { nodes } = params;
25503
25578
  if (nodes.length === 0) {
@@ -25561,7 +25636,7 @@ function handleTableNode(node, params) {
25561
25636
  attrs["borders"] = borderData;
25562
25637
  const content = [];
25563
25638
  rows.forEach((row) => {
25564
- const result = translator$3.encode({
25639
+ const result = translator$e.encode({
25565
25640
  ...params,
25566
25641
  nodes: [row],
25567
25642
  extraParams: {
@@ -25942,10 +26017,10 @@ function generateCellMargins(cellMargins) {
25942
26017
  if (left != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left) } });
25943
26018
  return elements;
25944
26019
  }
25945
- const XML_NODE_NAME$2 = "w:tc";
26020
+ const XML_NODE_NAME$d = "w:tc";
25946
26021
  const SD_NODE_NAME$2 = "tableCell";
25947
- const validXmlAttributes$2 = [];
25948
- function encode$2(params, encodedAttrs) {
26022
+ const validXmlAttributes$c = [];
26023
+ function encode$A(params, encodedAttrs) {
25949
26024
  const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params.extraParams;
25950
26025
  const schemaNode = handleTableCellNode({
25951
26026
  params,
@@ -25962,23 +26037,23 @@ function encode$2(params, encodedAttrs) {
25962
26037
  }
25963
26038
  return schemaNode;
25964
26039
  }
25965
- function decode$2(params, decodedAttrs) {
26040
+ function decode$r(params, decodedAttrs) {
25966
26041
  const translated = translateTableCell(params);
25967
26042
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
25968
26043
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
25969
26044
  }
25970
26045
  return translated;
25971
26046
  }
25972
- const config$2 = {
25973
- xmlName: XML_NODE_NAME$2,
26047
+ const config$d = {
26048
+ xmlName: XML_NODE_NAME$d,
25974
26049
  sdNodeOrKeyName: SD_NODE_NAME$2,
25975
26050
  type: NodeTranslator.translatorTypes.NODE,
25976
- encode: encode$2,
25977
- decode: decode$2,
25978
- attributes: validXmlAttributes$2
26051
+ encode: encode$A,
26052
+ decode: decode$r,
26053
+ attributes: validXmlAttributes$c
25979
26054
  };
25980
- const translator$2 = NodeTranslator.from(config$2);
25981
- const XML_NODE_NAME$1 = "w:hyperlink";
26055
+ const translator$d = NodeTranslator.from(config$d);
26056
+ const XML_NODE_NAME$c = "w:hyperlink";
25982
26057
  const SD_NODE_NAME$1 = "link";
25983
26058
  const _createAttributeHandler = (xmlName, sdName) => ({
25984
26059
  xmlName,
@@ -25986,7 +26061,7 @@ const _createAttributeHandler = (xmlName, sdName) => ({
25986
26061
  encode: (attributes) => attributes[xmlName],
25987
26062
  decode: (attributes) => attributes[sdName]
25988
26063
  });
25989
- const validXmlAttributes$1 = [
26064
+ const validXmlAttributes$b = [
25990
26065
  _createAttributeHandler("w:anchor", "anchor"),
25991
26066
  _createAttributeHandler("w:docLocation", "docLocation"),
25992
26067
  {
@@ -25999,7 +26074,7 @@ const validXmlAttributes$1 = [
25999
26074
  _createAttributeHandler("r:id", "rId"),
26000
26075
  _createAttributeHandler("w:tgtFrame", "target")
26001
26076
  ];
26002
- const encode$1 = (params, encodedAttrs) => {
26077
+ const encode$z = (params, encodedAttrs) => {
26003
26078
  const { nodes, docx, nodeListHandler } = params;
26004
26079
  const node = nodes[0];
26005
26080
  let href = _resolveHref(docx, encodedAttrs);
@@ -26013,7 +26088,16 @@ const encode$1 = (params, encodedAttrs) => {
26013
26088
  nodes: runNodes,
26014
26089
  path: [...params.path || [], node]
26015
26090
  });
26016
- return updatedNode;
26091
+ const ensureLinkMark = (child) => {
26092
+ if (!child || typeof child !== "object") return child;
26093
+ const existingMarks = Array.isArray(child.marks) ? child.marks : [];
26094
+ const hasLink = existingMarks.some((mark) => mark?.type === "link");
26095
+ if (hasLink) return child;
26096
+ const linkClone = { type: "link", attrs: { ...linkMark.attrs } };
26097
+ return { ...child, marks: [...existingMarks, linkClone] };
26098
+ };
26099
+ if (!Array.isArray(updatedNode)) return updatedNode;
26100
+ return updatedNode.map((child) => ensureLinkMark(child));
26017
26101
  };
26018
26102
  const _resolveHref = (docx, encodedAttrs) => {
26019
26103
  const rels = docx["word/_rels/document.xml.rels"];
@@ -26030,7 +26114,7 @@ const _resolveHref = (docx, encodedAttrs) => {
26030
26114
  }
26031
26115
  return href;
26032
26116
  };
26033
- function decode$1(params) {
26117
+ function decode$q(params) {
26034
26118
  const { node } = params;
26035
26119
  const linkMark = node.marks.find((m2) => m2.type === "link");
26036
26120
  const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
@@ -26074,15 +26158,15 @@ function _addNewLinkRelationship(params, link, rId) {
26074
26158
  });
26075
26159
  return rId;
26076
26160
  }
26077
- const config$1 = {
26078
- xmlName: XML_NODE_NAME$1,
26161
+ const config$c = {
26162
+ xmlName: XML_NODE_NAME$c,
26079
26163
  sdNodeOrKeyName: SD_NODE_NAME$1,
26080
26164
  type: NodeTranslator.translatorTypes.NODE,
26081
- encode: encode$1,
26082
- decode: decode$1,
26083
- attributes: validXmlAttributes$1
26165
+ encode: encode$z,
26166
+ decode: decode$q,
26167
+ attributes: validXmlAttributes$b
26084
26168
  };
26085
- const translator$1 = NodeTranslator.from(config$1);
26169
+ const translator$c = NodeTranslator.from(config$c);
26086
26170
  function parseTagValueJSON(json) {
26087
26171
  if (typeof json !== "string") {
26088
26172
  return {};
@@ -26093,7 +26177,7 @@ function parseTagValueJSON(json) {
26093
26177
  }
26094
26178
  try {
26095
26179
  return JSON.parse(trimmed);
26096
- } catch (err) {
26180
+ } catch {
26097
26181
  return {};
26098
26182
  }
26099
26183
  }
@@ -27895,10 +27979,10 @@ function translateStructuredContent(params) {
27895
27979
  };
27896
27980
  return result;
27897
27981
  }
27898
- const XML_NODE_NAME = "w:sdt";
27982
+ const XML_NODE_NAME$b = "w:sdt";
27899
27983
  const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
27900
- const validXmlAttributes = [];
27901
- function encode(params, encodedAttrs) {
27984
+ const validXmlAttributes$a = [];
27985
+ function encode$y(params) {
27902
27986
  const nodes = params.nodes;
27903
27987
  const node = nodes[0];
27904
27988
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -27908,7 +27992,7 @@ function encode(params, encodedAttrs) {
27908
27992
  const result = handler2(params);
27909
27993
  return result;
27910
27994
  }
27911
- function decode(params, decodedAttrs) {
27995
+ function decode$p(params) {
27912
27996
  const { node } = params;
27913
27997
  if (!node || !node.type) {
27914
27998
  return null;
@@ -27924,43 +28008,138 @@ function decode(params, decodedAttrs) {
27924
28008
  const result = decoder();
27925
28009
  return result;
27926
28010
  }
27927
- const config = {
27928
- xmlName: XML_NODE_NAME,
28011
+ const config$b = {
28012
+ xmlName: XML_NODE_NAME$b,
27929
28013
  sdNodeOrKeyName: SD_NODE_NAME,
27930
28014
  type: NodeTranslator.translatorTypes.NODE,
27931
- encode,
27932
- decode,
27933
- attributes: validXmlAttributes
28015
+ encode: encode$y,
28016
+ decode: decode$p,
28017
+ attributes: validXmlAttributes$a
28018
+ };
28019
+ const translator$b = NodeTranslator.from(config$b);
28020
+ const encode$x = (attributes) => attributes?.["w:val"];
28021
+ const decode$o = (attrs) => attrs?.underline;
28022
+ const attrConfig$m = Object.freeze({
28023
+ xmlName: "w:val",
28024
+ sdName: "underline",
28025
+ encode: encode$x,
28026
+ decode: decode$o
28027
+ });
28028
+ const encode$w = (attributes) => attributes?.["w:color"];
28029
+ const decode$n = (attrs) => attrs?.color;
28030
+ const attrConfig$l = Object.freeze({
28031
+ xmlName: "w:color",
28032
+ sdName: "color",
28033
+ encode: encode$w,
28034
+ decode: decode$n
28035
+ });
28036
+ const encode$v = (attributes) => attributes?.["w:themeColor"];
28037
+ const decode$m = (attrs) => attrs?.themeColor;
28038
+ const attrConfig$k = Object.freeze({
28039
+ xmlName: "w:themeColor",
28040
+ sdName: "themeColor",
28041
+ encode: encode$v,
28042
+ decode: decode$m
28043
+ });
28044
+ const encode$u = (attributes) => attributes?.["w:themeTint"];
28045
+ const decode$l = (attrs) => attrs?.themeTint;
28046
+ const attrConfig$j = Object.freeze({
28047
+ xmlName: "w:themeTint",
28048
+ sdName: "themeTint",
28049
+ encode: encode$u,
28050
+ decode: decode$l
28051
+ });
28052
+ const encode$t = (attributes) => attributes?.["w:themeShade"];
28053
+ const decode$k = (attrs) => attrs?.themeShade;
28054
+ const attrConfig$i = Object.freeze({
28055
+ xmlName: "w:themeShade",
28056
+ sdName: "themeShade",
28057
+ encode: encode$t,
28058
+ decode: decode$k
28059
+ });
28060
+ const validXmlAttributes$9 = [attrConfig$m, attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
28061
+ const XML_NODE_NAME$a = "w:u";
28062
+ const SD_ATTR_KEY$9 = "underline";
28063
+ const encode$s = (params, encodedAttrs = {}) => {
28064
+ const { nodes } = params;
28065
+ const node = nodes?.[0];
28066
+ const sourceAttrs = node?.attributes || {};
28067
+ const underlineType = encodedAttrs.underline ?? sourceAttrs["w:val"];
28068
+ const color = encodedAttrs.color ?? sourceAttrs["w:color"];
28069
+ const themeColor = encodedAttrs.themeColor ?? sourceAttrs["w:themeColor"];
28070
+ const themeTint = encodedAttrs.themeTint ?? sourceAttrs["w:themeTint"];
28071
+ const themeShade = encodedAttrs.themeShade ?? sourceAttrs["w:themeShade"];
28072
+ const attributes = { "w:val": underlineType ?? null };
28073
+ if (color !== void 0 && color !== null) attributes["w:color"] = color;
28074
+ if (themeColor !== void 0 && themeColor !== null) attributes["w:themeColor"] = themeColor;
28075
+ if (themeTint !== void 0 && themeTint !== null) attributes["w:themeTint"] = themeTint;
28076
+ if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
28077
+ return {
28078
+ type: "attr",
28079
+ xmlName: XML_NODE_NAME$a,
28080
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
28081
+ attributes
28082
+ };
27934
28083
  };
27935
- const translator = NodeTranslator.from(config);
28084
+ const decode$j = (params) => {
28085
+ const attrs = params?.node?.attrs || {};
28086
+ const underlineType = attrs.underlineType ?? attrs.underline ?? null;
28087
+ const color = attrs.underlineColor ?? attrs.color ?? null;
28088
+ const themeColor = attrs.underlineThemeColor ?? attrs.themeColor ?? null;
28089
+ const themeTint = attrs.underlineThemeTint ?? attrs.themeTint ?? null;
28090
+ const themeShade = attrs.underlineThemeShade ?? attrs.themeShade ?? null;
28091
+ if (!underlineType && !color && !themeColor && !themeTint && !themeShade) return void 0;
28092
+ const attributes = {};
28093
+ if (underlineType) attributes["w:val"] = underlineType;
28094
+ if (color) {
28095
+ const normalized = normalizeHexColor(color);
28096
+ if (normalized) attributes["w:color"] = normalized;
28097
+ }
28098
+ if (themeColor) attributes["w:themeColor"] = themeColor;
28099
+ if (themeTint) attributes["w:themeTint"] = themeTint;
28100
+ if (themeShade) attributes["w:themeShade"] = themeShade;
28101
+ return {
28102
+ name: XML_NODE_NAME$a,
28103
+ attributes
28104
+ };
28105
+ };
28106
+ const config$a = {
28107
+ xmlName: XML_NODE_NAME$a,
28108
+ sdNodeOrKeyName: SD_ATTR_KEY$9,
28109
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
28110
+ encode: encode$s,
28111
+ decode: decode$j,
28112
+ attributes: validXmlAttributes$9
28113
+ };
28114
+ const translator$a = NodeTranslator.from(config$a);
27936
28115
  function exportSchemaToJson(params) {
27937
28116
  const { type: type2 } = params.node || {};
27938
28117
  const router = {
27939
28118
  doc: translateDocumentNode,
27940
28119
  body: translateBodyNode,
27941
28120
  heading: translateHeadingNode,
27942
- paragraph: translator$h,
28121
+ paragraph: translator$s,
27943
28122
  text: translateTextNode,
27944
28123
  bulletList: translateList,
27945
28124
  orderedList: translateList,
27946
- lineBreak: translator$j,
28125
+ lineBreak: translator$v,
27947
28126
  table: translateTable,
27948
- tableRow: translator$3,
27949
- tableCell: translator$2,
28127
+ tableRow: translator$e,
28128
+ tableCell: translator$d,
27950
28129
  bookmarkStart: translateBookmarkStart,
27951
- fieldAnnotation: translator,
27952
- tab: translator$i,
28130
+ fieldAnnotation: translator$b,
28131
+ tab: translator$t,
27953
28132
  image: translateImageNode,
27954
- hardBreak: translator$j,
28133
+ hardBreak: translator$v,
27955
28134
  commentRangeStart: () => translateCommentNode(params, "Start"),
27956
28135
  commentRangeEnd: () => translateCommentNode(params, "End"),
27957
28136
  commentReference: () => null,
27958
28137
  shapeContainer: translateShapeContainer,
27959
28138
  shapeTextbox: translateShapeTextbox,
27960
28139
  contentBlock: translateContentBlock,
27961
- structuredContent: translator,
27962
- structuredContentBlock: translator,
27963
- documentSection: translator,
28140
+ structuredContent: translator$b,
28141
+ structuredContentBlock: translator$b,
28142
+ documentSection: translator$b,
27964
28143
  "page-number": translatePageNumberNode,
27965
28144
  "total-page-number": translateTotalPageNumberNode
27966
28145
  };
@@ -28283,7 +28462,7 @@ function translateTextNode(params) {
28283
28462
  const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
28284
28463
  if (isTrackedNode) return translateTrackedNode(params);
28285
28464
  const isLinkNode = node.marks?.some((m2) => m2.type === "link");
28286
- if (isLinkNode) return translator$1.decode(params);
28465
+ if (isLinkNode) return translator$c.decode(params);
28287
28466
  const { text, marks = [] } = node;
28288
28467
  return getTextNodeForExport(text, marks, params);
28289
28468
  }
@@ -28768,10 +28947,20 @@ function translateMark(mark) {
28768
28947
  delete markElement.attributes;
28769
28948
  markElement.type = "element";
28770
28949
  break;
28771
- case "underline":
28772
- markElement.type = "element";
28773
- markElement.attributes["w:val"] = attrs.underlineType;
28774
- break;
28950
+ case "underline": {
28951
+ const translated = translator$a.decode({
28952
+ node: {
28953
+ attrs: {
28954
+ underlineType: attrs.underlineType ?? attrs.underline ?? null,
28955
+ underlineColor: attrs.underlineColor ?? attrs.color ?? null,
28956
+ underlineThemeColor: attrs.underlineThemeColor ?? attrs.themeColor ?? null,
28957
+ underlineThemeTint: attrs.underlineThemeTint ?? attrs.themeTint ?? null,
28958
+ underlineThemeShade: attrs.underlineThemeShade ?? attrs.themeShade ?? null
28959
+ }
28960
+ }
28961
+ });
28962
+ return translated || {};
28963
+ }
28775
28964
  // Text style cases
28776
28965
  case "fontSize":
28777
28966
  value = attrs.fontSize;
@@ -28813,12 +29002,11 @@ function translateMark(mark) {
28813
29002
  case "lineHeight":
28814
29003
  markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
28815
29004
  break;
28816
- case "highlight":
28817
- markElement.attributes["w:fill"] = attrs.color?.substring(1);
28818
- markElement.attributes["w:color"] = "auto";
28819
- markElement.attributes["w:val"] = "clear";
28820
- markElement.name = "w:shd";
28821
- break;
29005
+ case "highlight": {
29006
+ const highlightValue = attrs.color ?? attrs.highlight ?? null;
29007
+ const translated = translator$u.decode({ node: { attrs: { highlight: highlightValue } } });
29008
+ return translated || {};
29009
+ }
28822
29010
  }
28823
29011
  return markElement;
28824
29012
  }
@@ -28855,17 +29043,7 @@ function translateImageNode(params, imageSize) {
28855
29043
  let imageId = attrs.rId;
28856
29044
  const src = attrs.src || attrs.imageSrc;
28857
29045
  const { originalWidth, originalHeight } = getPngDimensions(src);
28858
- let imageName;
28859
- if (params.node.type === "image") {
28860
- if (src?.startsWith("data:")) {
28861
- imageName = getFallbackImageNameFromDataUri(src);
28862
- } else {
28863
- imageName = src?.split("/").pop();
28864
- }
28865
- } else {
28866
- imageName = attrs.fieldId;
28867
- }
28868
- imageName = sanitizeDocxMediaName(imageName);
29046
+ const imageName = params.node.type === "image" ? src.split("/").pop() : attrs.fieldId?.replace("-", "_");
28869
29047
  let size = attrs.size ? {
28870
29048
  w: pixelsToEmu(attrs.size.width),
28871
29049
  h: pixelsToEmu(attrs.size.height)
@@ -28895,12 +29073,9 @@ function translateImageNode(params, imageSize) {
28895
29073
  if (!type2) {
28896
29074
  return prepareTextAnnotation(params);
28897
29075
  }
28898
- const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
28899
- const fileName = `${imageName}_${sanitizedHash}.${type2}`;
28900
- const relationshipTarget = `media/${fileName}`;
28901
- const packagePath = `word/${relationshipTarget}`;
28902
- imageId = addNewImageRelationship(params, relationshipTarget);
28903
- params.media[packagePath] = src;
29076
+ const imageUrl = `media/${imageName}_${attrs.hash}.${type2}`;
29077
+ imageId = addNewImageRelationship(params, imageUrl);
29078
+ params.media[`${imageName}_${attrs.hash}.${type2}`] = src;
28904
29079
  }
28905
29080
  let inlineAttrs = attrs.originalPadding || {
28906
29081
  distT: 0,
@@ -29699,82 +29874,912 @@ const trackChangeNodeHandlerEntity = {
29699
29874
  handlerName: "trackChangeNodeHandler",
29700
29875
  handler: handleTrackChangeNode
29701
29876
  };
29702
- const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$1);
29703
- const handleRunNode = (params) => {
29704
- const { nodes, nodeListHandler, parentStyleId, docx } = params;
29705
- if (nodes.length === 0 || nodes[0].name !== "w:r") {
29706
- return { nodes: [], consumed: 0 };
29707
- }
29877
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$c);
29878
+ const encode$r = (attributes) => {
29879
+ const raw = attributes?.["w:val"];
29880
+ if (raw === void 0 || raw === null) return void 0;
29881
+ if (typeof raw === "boolean") return raw;
29882
+ if (typeof raw === "number") return raw !== 0;
29883
+ const val = String(raw).trim().toLowerCase();
29884
+ if (val === "0" || val === "false" || val === "off") return false;
29885
+ if (val === "1" || val === "true" || val === "on") return true;
29886
+ return void 0;
29887
+ };
29888
+ const decode$i = (runProps) => {
29889
+ if (runProps?.bold === false) return "0";
29890
+ return void 0;
29891
+ };
29892
+ const attrConfig$h = Object.freeze({
29893
+ xmlName: "w:val",
29894
+ sdName: "bold",
29895
+ encode: encode$r,
29896
+ decode: decode$i
29897
+ });
29898
+ const validXmlAttributes$8 = [attrConfig$h];
29899
+ const XML_NODE_NAME$9 = "w:b";
29900
+ const SD_ATTR_KEY$8 = "bold";
29901
+ const encode$q = (params, encodedAttrs = {}) => {
29902
+ const { nodes } = params;
29708
29903
  const node = nodes[0];
29709
- const childParams = { ...params, nodes: node.elements, path: [...params.path || [], node] };
29710
- let processedRun = nodeListHandler.handler(childParams)?.filter((n) => n) || [];
29711
- const hasRunProperties = node.elements?.some((el) => el.name === "w:rPr");
29712
- const defaultNodeStyles = getMarksFromStyles(docx, parentStyleId);
29713
- if (hasRunProperties) {
29714
- const { marks = [] } = parseProperties(node);
29715
- let runStyleAttributes = [];
29716
- const runStyleElement = node.elements?.find((el) => el.name === "w:rPr")?.elements?.find((el) => el.name === "w:rStyle");
29717
- let runStyleId;
29718
- if (runStyleElement && runStyleElement.attributes?.["w:val"] && docx) {
29719
- runStyleId = runStyleElement.attributes["w:val"];
29720
- const runStyleDefinition = getMarksFromStyles(docx, runStyleId);
29721
- if (runStyleDefinition.marks && runStyleDefinition.marks.length > 0) {
29722
- runStyleAttributes = runStyleDefinition.marks;
29723
- }
29724
- }
29725
- let paragraphStyleAttributes = [];
29726
- if (defaultNodeStyles.marks) {
29727
- paragraphStyleAttributes = defaultNodeStyles.marks.filter((mark) => {
29728
- if (["bold"].includes(mark.type) && marks.find((m2) => m2.type === "bold")?.attrs?.value === "0") {
29729
- return false;
29730
- }
29731
- return true;
29732
- });
29733
- }
29734
- const combinedMarks = [...paragraphStyleAttributes];
29735
- runStyleAttributes.forEach((runStyle) => {
29736
- const exists = combinedMarks.some(
29737
- (mark) => mark.type === runStyle.type && JSON.stringify(mark.attrs || {}) === JSON.stringify(runStyle.attrs || {})
29738
- );
29739
- if (!exists) {
29740
- combinedMarks.push(runStyle);
29904
+ if (!node) return void 0;
29905
+ const val = encodedAttrs?.[SD_ATTR_KEY$8];
29906
+ let attributes;
29907
+ if (val === false) attributes = { "w:val": "0" };
29908
+ else if (val === true)
29909
+ attributes = {};
29910
+ else attributes = node.attributes || {};
29911
+ return {
29912
+ type: "attr",
29913
+ xmlName: XML_NODE_NAME$9,
29914
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
29915
+ attributes
29916
+ };
29917
+ };
29918
+ const config$9 = {
29919
+ xmlName: XML_NODE_NAME$9,
29920
+ sdNodeOrKeyName: SD_ATTR_KEY$8,
29921
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
29922
+ encode: encode$q,
29923
+ attributes: validXmlAttributes$8
29924
+ };
29925
+ const translator$9 = NodeTranslator.from(config$9);
29926
+ const encode$p = (attributes) => {
29927
+ const raw = attributes?.["w:val"];
29928
+ if (raw === void 0 || raw === null) return void 0;
29929
+ if (typeof raw === "boolean") return raw;
29930
+ if (typeof raw === "number") return raw !== 0;
29931
+ const val = String(raw).trim().toLowerCase();
29932
+ if (val === "0" || val === "false" || val === "off") return false;
29933
+ if (val === "1" || val === "true" || val === "on") return true;
29934
+ return void 0;
29935
+ };
29936
+ const decode$h = (attrs) => {
29937
+ if (attrs?.italic === false) return "0";
29938
+ return void 0;
29939
+ };
29940
+ const attrConfig$g = Object.freeze({
29941
+ xmlName: "w:val",
29942
+ sdName: "italic",
29943
+ encode: encode$p,
29944
+ decode: decode$h
29945
+ });
29946
+ const validXmlAttributes$7 = [attrConfig$g];
29947
+ const XML_NODE_NAME$8 = "w:i";
29948
+ const SD_ATTR_KEY$7 = "italic";
29949
+ const encode$o = (params, encodedAttrs = {}) => {
29950
+ const { nodes } = params;
29951
+ const node = nodes?.[0];
29952
+ if (!node) return void 0;
29953
+ const val = encodedAttrs?.[SD_ATTR_KEY$7];
29954
+ let attributes;
29955
+ if (val === false) attributes = { "w:val": "0" };
29956
+ else if (val === true) attributes = {};
29957
+ else attributes = { ...node.attributes || {} };
29958
+ if (attributes["w:val"] === void 0 && val !== true) attributes["w:val"] = null;
29959
+ else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
29960
+ return {
29961
+ type: "attr",
29962
+ xmlName: XML_NODE_NAME$8,
29963
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
29964
+ attributes
29965
+ };
29966
+ };
29967
+ const config$8 = {
29968
+ xmlName: XML_NODE_NAME$8,
29969
+ sdNodeOrKeyName: SD_ATTR_KEY$7,
29970
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
29971
+ encode: encode$o,
29972
+ attributes: validXmlAttributes$7
29973
+ };
29974
+ const translator$8 = NodeTranslator.from(config$8);
29975
+ const encode$n = (attributes) => {
29976
+ const raw = attributes?.["w:val"];
29977
+ if (raw === void 0 || raw === null) return void 0;
29978
+ if (typeof raw === "boolean") return raw;
29979
+ if (typeof raw === "number") return raw !== 0;
29980
+ const val = String(raw).trim().toLowerCase();
29981
+ if (val === "0" || val === "false" || val === "off") return false;
29982
+ if (val === "1" || val === "true" || val === "on") return true;
29983
+ return void 0;
29984
+ };
29985
+ const decode$g = (attrs) => {
29986
+ if (attrs?.strike === false) return "0";
29987
+ return void 0;
29988
+ };
29989
+ const attrConfig$f = Object.freeze({
29990
+ xmlName: "w:val",
29991
+ sdName: "strike",
29992
+ encode: encode$n,
29993
+ decode: decode$g
29994
+ });
29995
+ const validXmlAttributes$6 = [attrConfig$f];
29996
+ const XML_NODE_NAME$7 = "w:strike";
29997
+ const SD_ATTR_KEY$6 = "strike";
29998
+ const encode$m = (params, encodedAttrs = {}) => {
29999
+ const { nodes } = params;
30000
+ const node = nodes?.[0];
30001
+ if (!node) return void 0;
30002
+ const val = encodedAttrs?.[SD_ATTR_KEY$6];
30003
+ let attributes;
30004
+ if (val === false) attributes = { "w:val": "0" };
30005
+ else if (val === true) attributes = {};
30006
+ else attributes = { ...node.attributes || {} };
30007
+ if (attributes["w:val"] === void 0 && val !== true) attributes["w:val"] = null;
30008
+ else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
30009
+ return {
30010
+ type: "attr",
30011
+ xmlName: XML_NODE_NAME$7,
30012
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
30013
+ attributes
30014
+ };
30015
+ };
30016
+ const config$7 = {
30017
+ xmlName: XML_NODE_NAME$7,
30018
+ sdNodeOrKeyName: SD_ATTR_KEY$6,
30019
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30020
+ encode: encode$m,
30021
+ attributes: validXmlAttributes$6
30022
+ };
30023
+ const translator$7 = NodeTranslator.from(config$7);
30024
+ const encode$l = (attributes) => attributes?.["w:val"];
30025
+ const decode$f = (attrs) => attrs?.color;
30026
+ const attrConfig$e = Object.freeze({
30027
+ xmlName: "w:val",
30028
+ sdName: "color",
30029
+ encode: encode$l,
30030
+ decode: decode$f
30031
+ });
30032
+ const encode$k = (attributes) => attributes?.["w:themeColor"];
30033
+ const decode$e = (attrs) => attrs?.themeColor;
30034
+ const attrConfig$d = Object.freeze({
30035
+ xmlName: "w:themeColor",
30036
+ sdName: "themeColor",
30037
+ encode: encode$k,
30038
+ decode: decode$e
30039
+ });
30040
+ const encode$j = (attributes) => attributes?.["w:themeTint"];
30041
+ const decode$d = (attrs) => attrs?.themeTint;
30042
+ const attrConfig$c = Object.freeze({
30043
+ xmlName: "w:themeTint",
30044
+ sdName: "themeTint",
30045
+ encode: encode$j,
30046
+ decode: decode$d
30047
+ });
30048
+ const encode$i = (attributes) => attributes?.["w:themeShade"];
30049
+ const decode$c = (attrs) => attrs?.themeShade;
30050
+ const attrConfig$b = Object.freeze({
30051
+ xmlName: "w:themeShade",
30052
+ sdName: "themeShade",
30053
+ encode: encode$i,
30054
+ decode: decode$c
30055
+ });
30056
+ const validXmlAttributes$5 = [attrConfig$e, attrConfig$d, attrConfig$c, attrConfig$b];
30057
+ const XML_NODE_NAME$6 = "w:color";
30058
+ const SD_ATTR_KEY$5 = "color";
30059
+ const encode$h = (params, encodedAttrs = {}) => {
30060
+ const { nodes } = params;
30061
+ const node = nodes?.[0];
30062
+ const sourceAttrs = node?.attributes || {};
30063
+ const value = encodedAttrs.color ?? sourceAttrs["w:val"];
30064
+ const themeColor = encodedAttrs.themeColor ?? sourceAttrs["w:themeColor"];
30065
+ const themeTint = encodedAttrs.themeTint ?? sourceAttrs["w:themeTint"];
30066
+ const themeShade = encodedAttrs.themeShade ?? sourceAttrs["w:themeShade"];
30067
+ const attributes = {};
30068
+ attributes["w:val"] = value ?? null;
30069
+ if (themeColor !== void 0 && themeColor !== null) attributes["w:themeColor"] = themeColor;
30070
+ if (themeTint !== void 0 && themeTint !== null) attributes["w:themeTint"] = themeTint;
30071
+ if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
30072
+ return {
30073
+ type: "attr",
30074
+ xmlName: XML_NODE_NAME$6,
30075
+ sdNodeOrKeyName: SD_ATTR_KEY$5,
30076
+ attributes
30077
+ };
30078
+ };
30079
+ const config$6 = {
30080
+ xmlName: XML_NODE_NAME$6,
30081
+ sdNodeOrKeyName: SD_ATTR_KEY$5,
30082
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30083
+ encode: encode$h,
30084
+ attributes: validXmlAttributes$5
30085
+ };
30086
+ const translator$6 = NodeTranslator.from(config$6);
30087
+ const encode$g = (attributes) => attributes?.["w:eastAsia"];
30088
+ const decode$b = (attrs) => attrs?.eastAsia;
30089
+ const attrConfig$a = Object.freeze({
30090
+ xmlName: "w:eastAsia",
30091
+ sdName: "eastAsia",
30092
+ encode: encode$g,
30093
+ decode: decode$b
30094
+ });
30095
+ const encode$f = (attributes) => attributes?.["w:ascii"];
30096
+ const decode$a = (attrs) => attrs?.ascii;
30097
+ const attrConfig$9 = Object.freeze({
30098
+ xmlName: "w:ascii",
30099
+ sdName: "ascii",
30100
+ encode: encode$f,
30101
+ decode: decode$a
30102
+ });
30103
+ const encode$e = (attributes) => attributes?.["w:hAnsi"];
30104
+ const decode$9 = (attrs) => attrs?.hAnsi;
30105
+ const attrConfig$8 = Object.freeze({
30106
+ xmlName: "w:hAnsi",
30107
+ sdName: "hAnsi",
30108
+ encode: encode$e,
30109
+ decode: decode$9
30110
+ });
30111
+ const encode$d = (attributes) => attributes?.["w:cs"];
30112
+ const decode$8 = (attrs) => attrs?.cs;
30113
+ const attrConfig$7 = Object.freeze({
30114
+ xmlName: "w:cs",
30115
+ sdName: "cs",
30116
+ encode: encode$d,
30117
+ decode: decode$8
30118
+ });
30119
+ const encode$c = (attributes) => attributes?.["w:val"];
30120
+ const decode$7 = (attrs) => attrs?.value;
30121
+ const attrConfig$6 = Object.freeze({
30122
+ xmlName: "w:val",
30123
+ sdName: "value",
30124
+ encode: encode$c,
30125
+ decode: decode$7
30126
+ });
30127
+ const validXmlAttributes$4 = [attrConfig$a, attrConfig$9, attrConfig$8, attrConfig$7, attrConfig$6];
30128
+ const XML_NODE_NAME$5 = "w:rFonts";
30129
+ const SD_ATTR_KEY$4 = "fontFamily";
30130
+ const encode$b = (params, encodedAttrs = {}) => {
30131
+ const { nodes } = params;
30132
+ const node = nodes?.[0];
30133
+ const sourceAttrs = node?.attributes || {};
30134
+ const attributes = {};
30135
+ const setAttr = (xmlName, sdName) => {
30136
+ if (encodedAttrs[sdName] !== void 0 && encodedAttrs[sdName] !== null) {
30137
+ attributes[xmlName] = encodedAttrs[sdName];
30138
+ } else if (sourceAttrs[xmlName] !== void 0) {
30139
+ attributes[xmlName] = sourceAttrs[xmlName];
30140
+ }
30141
+ };
30142
+ setAttr("w:eastAsia", "eastAsia");
30143
+ setAttr("w:ascii", "ascii");
30144
+ setAttr("w:hAnsi", "hAnsi");
30145
+ setAttr("w:cs", "cs");
30146
+ setAttr("w:val", "value");
30147
+ Object.keys(sourceAttrs).forEach((key) => {
30148
+ if (attributes[key] === void 0) attributes[key] = sourceAttrs[key];
30149
+ });
30150
+ if (attributes["w:val"] === void 0 && attributes["w:eastAsia"]) {
30151
+ attributes["w:val"] = attributes["w:eastAsia"];
30152
+ }
30153
+ if (attributes["w:val"] === void 0) delete attributes["w:val"];
30154
+ return {
30155
+ type: "attr",
30156
+ xmlName: XML_NODE_NAME$5,
30157
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
30158
+ attributes
30159
+ };
30160
+ };
30161
+ const config$5 = {
30162
+ xmlName: XML_NODE_NAME$5,
30163
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
30164
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30165
+ encode: encode$b,
30166
+ attributes: validXmlAttributes$4
30167
+ };
30168
+ const translator$5 = NodeTranslator.from(config$5);
30169
+ const encode$a = (attributes) => attributes?.["w:val"];
30170
+ const decode$6 = (attrs) => attrs?.styleId;
30171
+ const attrConfig$5 = Object.freeze({
30172
+ xmlName: "w:val",
30173
+ sdName: "styleId",
30174
+ encode: encode$a,
30175
+ decode: decode$6
30176
+ });
30177
+ const validXmlAttributes$3 = [attrConfig$5];
30178
+ const XML_NODE_NAME$4 = "w:rStyle";
30179
+ const SD_ATTR_KEY$3 = "styleId";
30180
+ const encode$9 = (params, encodedAttrs = {}) => {
30181
+ const { nodes } = params;
30182
+ const node = nodes?.[0];
30183
+ const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
30184
+ return {
30185
+ type: "attr",
30186
+ xmlName: XML_NODE_NAME$4,
30187
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
30188
+ attributes: { "w:val": value ?? null }
30189
+ };
30190
+ };
30191
+ const config$4 = {
30192
+ xmlName: XML_NODE_NAME$4,
30193
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
30194
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30195
+ encode: encode$9,
30196
+ attributes: validXmlAttributes$3
30197
+ };
30198
+ const translator$4 = NodeTranslator.from(config$4);
30199
+ const encode$8 = (attributes) => attributes?.["w:val"];
30200
+ const decode$5 = (attrs) => attrs?.fontSize;
30201
+ const attrConfig$4 = Object.freeze({
30202
+ xmlName: "w:val",
30203
+ sdName: "fontSize",
30204
+ encode: encode$8,
30205
+ decode: decode$5
30206
+ });
30207
+ const validXmlAttributes$2 = [attrConfig$4];
30208
+ const XML_NODE_NAME$3 = "w:sz";
30209
+ const SD_ATTR_KEY$2 = "fontSize";
30210
+ const encode$7 = (params, encodedAttrs = {}) => {
30211
+ const { nodes } = params;
30212
+ const node = nodes?.[0];
30213
+ const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
30214
+ return {
30215
+ type: "attr",
30216
+ xmlName: XML_NODE_NAME$3,
30217
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
30218
+ attributes: { "w:val": value ?? null }
30219
+ };
30220
+ };
30221
+ const config$3 = {
30222
+ xmlName: XML_NODE_NAME$3,
30223
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
30224
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30225
+ encode: encode$7,
30226
+ attributes: validXmlAttributes$2
30227
+ };
30228
+ const translator$3 = NodeTranslator.from(config$3);
30229
+ const encode$6 = (attributes) => attributes?.["w:val"];
30230
+ const decode$4 = (attrs) => attrs?.fontSizeCs;
30231
+ const attrConfig$3 = Object.freeze({
30232
+ xmlName: "w:val",
30233
+ sdName: "fontSizeCs",
30234
+ encode: encode$6,
30235
+ decode: decode$4
30236
+ });
30237
+ const validXmlAttributes$1 = [attrConfig$3];
30238
+ const XML_NODE_NAME$2 = "w:szCs";
30239
+ const SD_ATTR_KEY$1 = "fontSizeCs";
30240
+ const encode$5 = (params, encodedAttrs = {}) => {
30241
+ const { nodes } = params;
30242
+ const node = nodes?.[0];
30243
+ const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
30244
+ return {
30245
+ type: "attr",
30246
+ xmlName: XML_NODE_NAME$2,
30247
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
30248
+ attributes: { "w:val": value ?? null }
30249
+ };
30250
+ };
30251
+ const config$2 = {
30252
+ xmlName: XML_NODE_NAME$2,
30253
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
30254
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30255
+ encode: encode$5,
30256
+ attributes: validXmlAttributes$1
30257
+ };
30258
+ const translator$2 = NodeTranslator.from(config$2);
30259
+ const runPropertyTranslators = Object.freeze({
30260
+ "w:b": translator$9,
30261
+ "w:i": translator$8,
30262
+ "w:u": translator$a,
30263
+ "w:strike": translator$7,
30264
+ "w:color": translator$6,
30265
+ "w:highlight": translator$u,
30266
+ "w:rFonts": translator$5,
30267
+ "w:rStyle": translator$4,
30268
+ "w:sz": translator$3,
30269
+ "w:szCs": translator$2
30270
+ });
30271
+ const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
30272
+ const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
30273
+ const KNOWN_CHILD_XML_NAMES = /* @__PURE__ */ new Set([...Object.keys(runPropertyTranslators), ...RAW_CHILD_NAME_SET]);
30274
+ const toRunPropertyEntry = (candidate) => {
30275
+ if (!candidate || candidate.type !== "attr") return null;
30276
+ const xmlName = candidate.xmlName || candidate.name;
30277
+ if (!xmlName) return null;
30278
+ return {
30279
+ xmlName,
30280
+ attributes: { ...candidate.attributes || {} }
30281
+ };
30282
+ };
30283
+ const XML_NODE_NAME$1 = "w:rPr";
30284
+ const SD_ATTR_KEY = "runProperties";
30285
+ const encode$4 = (params) => {
30286
+ const { nodes } = params;
30287
+ const node = nodes?.[0] || {};
30288
+ const contents = Array.isArray(node.elements) ? node.elements : [];
30289
+ const runPropsArray = contents.reduce(
30290
+ (acc, child) => {
30291
+ if (!child || typeof child !== "object") return acc;
30292
+ const xmlName = child.name;
30293
+ if (!KNOWN_CHILD_XML_NAMES.has(xmlName)) return acc;
30294
+ const translator2 = runPropertyTranslators[xmlName];
30295
+ let entry = null;
30296
+ if (translator2) {
30297
+ const encoded = translator2.encode({ ...params, nodes: [child] }) || null;
30298
+ entry = toRunPropertyEntry(encoded);
30299
+ } else if (RAW_CHILD_NAME_SET.has(xmlName)) {
30300
+ entry = toRunPropertyEntry({
30301
+ type: "attr",
30302
+ xmlName,
30303
+ attributes: { ...child.attributes || {} }
30304
+ });
29741
30305
  }
30306
+ if (entry) acc.push(entry);
30307
+ return acc;
30308
+ },
30309
+ /** @type {{ xmlName: string, attributes: Record<string, any> }[]} */
30310
+ []
30311
+ );
30312
+ return {
30313
+ type: "attr",
30314
+ xmlName: "w:rPr",
30315
+ sdNodeOrKeyName: "runProperties",
30316
+ attributes: runPropsArray
30317
+ };
30318
+ };
30319
+ const config$1 = {
30320
+ xmlName: XML_NODE_NAME$1,
30321
+ sdNodeOrKeyName: SD_ATTR_KEY,
30322
+ type: NodeTranslator.translatorTypes.ATTRIBUTE,
30323
+ encode: encode$4
30324
+ };
30325
+ const translator$1 = NodeTranslator.from(config$1);
30326
+ const collectRunProperties = (params, rPrNode, translator2 = translator$1) => {
30327
+ if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
30328
+ const result = translator2.encode({ ...params, nodes: [rPrNode] }) || {};
30329
+ let entries = [];
30330
+ if (Array.isArray(result.attributes) && result.attributes.length) {
30331
+ entries = result.attributes.map((attr) => ({
30332
+ xmlName: attr?.xmlName,
30333
+ attributes: { ...attr?.attributes || {} }
30334
+ }));
30335
+ } else if (Array.isArray(rPrNode.elements) && rPrNode.elements.length) {
30336
+ entries = rPrNode.elements.filter((el) => el && typeof el === "object").map((el) => ({
30337
+ xmlName: el.name,
30338
+ attributes: { ...el.attributes || {} }
30339
+ }));
30340
+ }
30341
+ const legacyMarks = parseMarks(rPrNode, [], params?.docx) || [];
30342
+ const styleChangeMarks = handleStyleChangeMarks(rPrNode, legacyMarks) || [];
30343
+ return { entries, hadRPr: true, styleChangeMarks };
30344
+ };
30345
+ const buildRunAttrs = (encodedAttrs = {}, hadRPr, runProps) => {
30346
+ const base = { ...encodedAttrs || {} };
30347
+ if (hadRPr) {
30348
+ base.runProperties = runProps.length ? runProps : null;
30349
+ }
30350
+ return base;
30351
+ };
30352
+ const ensureRunMark = (marks, runAttrs) => {
30353
+ if (!runAttrs) return;
30354
+ const runMark = createRunMark(runAttrs);
30355
+ const runMarkIndex = marks.findIndex((mark) => mark?.type === "run");
30356
+ if (runMarkIndex >= 0) {
30357
+ const existing = marks[runMarkIndex];
30358
+ if (runMark.attrs) {
30359
+ marks[runMarkIndex] = { ...existing, attrs: mergeRunAttrs(existing?.attrs, runMark.attrs) };
30360
+ }
30361
+ return;
30362
+ }
30363
+ marks.push(runMark);
30364
+ };
30365
+ const ensureInlineMarks = (marks, inlineMarks = []) => {
30366
+ inlineMarks.forEach(({ type: type2, attrs }) => {
30367
+ if (!type2) return;
30368
+ if (marks.some((mark) => mark?.type === type2)) return;
30369
+ marks.push(attrs ? { type: type2, attrs: { ...attrs } } : { type: type2 });
30370
+ });
30371
+ };
30372
+ const ensureTextStyleMark = (marks, textStyleAttrs) => {
30373
+ if (!textStyleAttrs) return;
30374
+ const existingTextStyle = marks.find((mark) => mark?.type === "textStyle");
30375
+ if (existingTextStyle) {
30376
+ existingTextStyle.attrs = { ...existingTextStyle.attrs || {}, ...textStyleAttrs };
30377
+ return;
30378
+ }
30379
+ marks.push({ type: "textStyle", attrs: { ...textStyleAttrs } });
30380
+ };
30381
+ const applyRunMarks = (node, runAttrs, inlineMarks, textStyleAttrs) => {
30382
+ if (!node || typeof node !== "object") return node;
30383
+ const baseMarks = Array.isArray(node.marks) ? node.marks : [];
30384
+ const marks = baseMarks.map((mark) => cloneMark(mark));
30385
+ ensureRunMark(marks, runAttrs);
30386
+ ensureInlineMarks(marks, inlineMarks);
30387
+ if (node.type === "text") {
30388
+ ensureTextStyleMark(marks, textStyleAttrs);
30389
+ }
30390
+ return { ...node, marks };
30391
+ };
30392
+ const createRunMark = (attrs = {}) => {
30393
+ const hasAttrs = attrs && Object.keys(attrs).length > 0;
30394
+ return hasAttrs ? { type: "run", attrs: cloneRunAttrs(attrs) } : { type: "run" };
30395
+ };
30396
+ const deriveStyleMarks = ({ docx, paragraphStyleId, runStyleId }) => {
30397
+ const paragraphStyleMarks = collectStyleMarks(paragraphStyleId, docx);
30398
+ const runStyleMarks = collectStyleMarks(runStyleId, docx);
30399
+ const inlineMarks = mergeInlineMarkSets(paragraphStyleMarks.inlineMarks, runStyleMarks.inlineMarks);
30400
+ const textStyleAttrs = mergeTextStyleAttrs(paragraphStyleMarks.textStyleAttrs, runStyleMarks.textStyleAttrs);
30401
+ return { inlineMarks, textStyleAttrs };
30402
+ };
30403
+ const collectStyleMarks = (styleId, docx, seen = /* @__PURE__ */ new Set()) => {
30404
+ if (!styleId || !docx || seen.has(styleId)) return { inlineMarks: [], textStyleAttrs: null };
30405
+ seen.add(styleId);
30406
+ const chain = collectStyleChain(styleId, docx, seen);
30407
+ if (!chain.length) return { inlineMarks: [], textStyleAttrs: null };
30408
+ const inlineMap = /* @__PURE__ */ new Map();
30409
+ let textStyleAttrs = {};
30410
+ chain.forEach((styleTag) => {
30411
+ const marks = extractMarksFromStyle(styleTag, docx);
30412
+ marks.inlineMarks.forEach((mark) => {
30413
+ inlineMap.set(mark.type, mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
29742
30414
  });
30415
+ if (marks.textStyleAttrs) textStyleAttrs = { ...textStyleAttrs, ...marks.textStyleAttrs };
30416
+ });
30417
+ return {
30418
+ inlineMarks: Array.from(inlineMap.values()),
30419
+ textStyleAttrs: Object.keys(textStyleAttrs).length ? textStyleAttrs : null
30420
+ };
30421
+ };
30422
+ const collectStyleChain = (styleId, docx, seen) => {
30423
+ if (!styleId || !docx) return [];
30424
+ const styleTag = findStyleTag(docx, styleId);
30425
+ if (!styleTag || !styleTag.elements) return [];
30426
+ const basedOn = styleTag.elements?.find((el) => el.name === "w:basedOn")?.attributes?.["w:val"];
30427
+ let chain = [];
30428
+ if (basedOn && !seen.has(basedOn)) {
30429
+ seen.add(basedOn);
30430
+ chain = collectStyleChain(basedOn, docx, seen);
30431
+ }
30432
+ chain.push(styleTag);
30433
+ return chain;
30434
+ };
30435
+ const findStyleTag = (docx, styleId) => {
30436
+ const stylesFile = docx?.["word/styles.xml"];
30437
+ if (!stylesFile?.elements?.length) return null;
30438
+ const candidates = [];
30439
+ stylesFile.elements.forEach((el) => {
30440
+ if (!el) return;
30441
+ if (el.name === "w:styles" && Array.isArray(el.elements)) {
30442
+ el.elements.forEach((child) => {
30443
+ if (child?.name === "w:style") candidates.push(child);
30444
+ });
30445
+ return;
30446
+ }
30447
+ if (el.name === "w:style") {
30448
+ candidates.push(el);
30449
+ return;
30450
+ }
30451
+ if (Array.isArray(el.elements)) {
30452
+ el.elements.forEach((child) => {
30453
+ if (child?.name === "w:style") candidates.push(child);
30454
+ });
30455
+ }
30456
+ });
30457
+ return candidates.find((tag) => tag?.attributes?.["w:styleId"] === styleId) || null;
30458
+ };
30459
+ const extractMarksFromStyle = (styleTag, docx) => {
30460
+ const rPr = styleTag?.elements?.find((el) => el.name === "w:rPr");
30461
+ if (!rPr) return { inlineMarks: [], textStyleAttrs: null };
30462
+ const marks = parseMarks(rPr, [], docx) || [];
30463
+ const inlineMarks = [];
30464
+ let textStyleAttrs = {};
30465
+ marks.forEach((mark) => {
30466
+ if (!mark) return;
30467
+ if (mark.type === "textStyle") {
30468
+ const attrs = mark.attrs || {};
30469
+ if (Object.keys(attrs).length) textStyleAttrs = { ...textStyleAttrs, ...attrs };
30470
+ return;
30471
+ }
30472
+ if (mark.type) inlineMarks.push(mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
30473
+ });
30474
+ return {
30475
+ inlineMarks,
30476
+ textStyleAttrs: Object.keys(textStyleAttrs).length ? textStyleAttrs : null
30477
+ };
30478
+ };
30479
+ const mergeInlineMarkSets = (...markSets) => {
30480
+ const map = /* @__PURE__ */ new Map();
30481
+ markSets.filter(Boolean).forEach((marks) => {
29743
30482
  marks.forEach((mark) => {
29744
- const exists = combinedMarks.some(
29745
- (existing) => existing.type === mark.type && JSON.stringify(existing.attrs || {}) === JSON.stringify(mark.attrs || {})
29746
- );
29747
- if (!exists) {
29748
- combinedMarks.push(mark);
29749
- }
30483
+ if (!mark || !mark.type) return;
30484
+ map.set(mark.type, mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
29750
30485
  });
29751
- if (runStyleId) combinedMarks.push({ type: "textStyle", attrs: { styleId: runStyleId } });
29752
- if (node.marks) combinedMarks.push(...node.marks);
29753
- const newMarks = createImportMarks(combinedMarks);
29754
- processedRun = processedRun.map((n) => {
29755
- const existingMarks = n.marks || [];
29756
- return {
29757
- ...n,
29758
- marks: [...newMarks, ...existingMarks]
29759
- };
30486
+ });
30487
+ return Array.from(map.values());
30488
+ };
30489
+ const mergeTextStyleAttrs = (...attrsList) => {
30490
+ const merged = attrsList.filter((attrs) => attrs && Object.keys(attrs).length).reduce((acc, attrs) => ({ ...acc, ...attrs }), {});
30491
+ return Object.keys(merged).length ? merged : null;
30492
+ };
30493
+ const cloneRunAttrs = (attrs) => {
30494
+ const clone = { ...attrs };
30495
+ if (Array.isArray(attrs?.runProperties)) {
30496
+ clone.runProperties = attrs.runProperties.map((entry) => ({
30497
+ xmlName: entry?.xmlName,
30498
+ attributes: { ...entry?.attributes || {} }
30499
+ }));
30500
+ }
30501
+ return clone;
30502
+ };
30503
+ const cloneMark = (mark) => {
30504
+ if (!mark || typeof mark !== "object") return mark;
30505
+ const cloned = { ...mark };
30506
+ if (mark.attrs && typeof mark.attrs === "object") {
30507
+ cloned.attrs = { ...mark.attrs };
30508
+ if (Array.isArray(mark.attrs.runProperties)) {
30509
+ cloned.attrs.runProperties = mark.attrs.runProperties.map((entry) => ({
30510
+ xmlName: entry?.xmlName,
30511
+ attributes: { ...entry?.attributes || {} }
30512
+ }));
30513
+ }
30514
+ }
30515
+ return cloned;
30516
+ };
30517
+ const mergeRunAttrs = (existing = {}, incoming = {}) => {
30518
+ const merged = { ...existing, ...cloneRunAttrs(incoming) };
30519
+ if (Array.isArray(existing?.runProperties) && Array.isArray(incoming?.runProperties)) {
30520
+ const seen = /* @__PURE__ */ new Set();
30521
+ const combined = [...existing.runProperties, ...incoming.runProperties];
30522
+ merged.runProperties = combined.filter((entry) => {
30523
+ const key = entry?.xmlName;
30524
+ if (!key || seen.has(key)) return false;
30525
+ seen.add(key);
30526
+ return true;
29760
30527
  });
29761
30528
  }
29762
- return { nodes: processedRun, consumed: 1 };
30529
+ return merged;
29763
30530
  };
29764
- const getMarksFromStyles = (docx, styleId) => {
29765
- const styles = docx?.["word/styles.xml"];
29766
- if (!styles) {
29767
- return {};
30531
+ const normalizeBool = (value) => {
30532
+ if (value === void 0 || value === null) return true;
30533
+ if (typeof value === "boolean") return value;
30534
+ if (typeof value === "number") return value !== 0;
30535
+ const normalized = String(value).trim().toLowerCase();
30536
+ if (normalized === "0" || normalized === "false" || normalized === "off") return false;
30537
+ if (normalized === "1" || normalized === "true" || normalized === "on") return true;
30538
+ return true;
30539
+ };
30540
+ const resolveRunElement = (node) => {
30541
+ if (!node) return null;
30542
+ if (node.name === "w:r") return node;
30543
+ return (node.elements || []).find((el) => el.name === "w:r") || null;
30544
+ };
30545
+ const ensureRunPropertiesContainer = (runElement) => {
30546
+ if (!Array.isArray(runElement.elements)) runElement.elements = [];
30547
+ let rPr = runElement.elements.find((el) => el.name === "w:rPr");
30548
+ if (!rPr) {
30549
+ rPr = { name: "w:rPr", elements: [] };
30550
+ runElement.elements.unshift(rPr);
30551
+ }
30552
+ if (!Array.isArray(rPr.elements)) rPr.elements = [];
30553
+ return rPr;
30554
+ };
30555
+ const splitRunProperties = (entries = [], docx = null) => {
30556
+ const remainingProps = [];
30557
+ const inlineMarks = [];
30558
+ const textStyleAttrs = {};
30559
+ let hasTextStyle = false;
30560
+ let highlightColor = null;
30561
+ let runStyleId = null;
30562
+ entries.forEach((entry) => {
30563
+ if (!entry || !entry.xmlName) return;
30564
+ const attributes = entry.attributes || {};
30565
+ switch (entry.xmlName) {
30566
+ case "w:b": {
30567
+ const val = normalizeBool(attributes["w:val"]);
30568
+ inlineMarks.push(val ? { type: "bold" } : { type: "bold", attrs: { value: "0" } });
30569
+ break;
30570
+ }
30571
+ case "w:i": {
30572
+ const val = normalizeBool(attributes["w:val"]);
30573
+ inlineMarks.push(val ? { type: "italic" } : { type: "italic", attrs: { value: "0" } });
30574
+ break;
30575
+ }
30576
+ case "w:u": {
30577
+ const rawVal = attributes["w:val"];
30578
+ const underlineType = rawVal == null || rawVal === "" ? "single" : String(rawVal);
30579
+ const attrs = {};
30580
+ if (underlineType.toLowerCase() === "none" || underlineType === "0") {
30581
+ attrs.underlineType = "none";
30582
+ } else {
30583
+ attrs.underlineType = underlineType;
30584
+ const colorRaw = attributes["w:color"];
30585
+ if (typeof colorRaw === "string" && colorRaw.toLowerCase() !== "auto") {
30586
+ const normalizedColor = normalizeHexColor(colorRaw);
30587
+ if (normalizedColor) attrs.underlineColor = `#${normalizedColor}`;
30588
+ }
30589
+ }
30590
+ if (attributes["w:themeColor"]) attrs.underlineThemeColor = attributes["w:themeColor"];
30591
+ if (attributes["w:themeTint"]) attrs.underlineThemeTint = attributes["w:themeTint"];
30592
+ if (attributes["w:themeShade"]) attrs.underlineThemeShade = attributes["w:themeShade"];
30593
+ inlineMarks.push({ type: "underline", attrs });
30594
+ break;
30595
+ }
30596
+ case "w:color": {
30597
+ const raw = attributes["w:val"];
30598
+ if (typeof raw === "string" && raw) {
30599
+ hasTextStyle = true;
30600
+ textStyleAttrs.color = `#${raw.replace("#", "").toUpperCase()}`;
30601
+ }
30602
+ break;
30603
+ }
30604
+ case "w:rFonts": {
30605
+ const family = attributes["w:ascii"] || attributes["w:eastAsia"] || attributes["w:hAnsi"] || attributes["w:val"];
30606
+ if (family) {
30607
+ hasTextStyle = true;
30608
+ textStyleAttrs.fontFamily = SuperConverter.toCssFontFamily(family, docx);
30609
+ }
30610
+ break;
30611
+ }
30612
+ case "w:sz":
30613
+ case "w:szCs": {
30614
+ const rawSize = Number(attributes["w:val"]);
30615
+ if (Number.isFinite(rawSize) && rawSize > 0) {
30616
+ hasTextStyle = true;
30617
+ textStyleAttrs.fontSize = `${rawSize / 2}pt`;
30618
+ }
30619
+ break;
30620
+ }
30621
+ case "w:strike": {
30622
+ const val = normalizeBool(attributes["w:val"]);
30623
+ inlineMarks.push(val ? { type: "strike" } : { type: "strike", attrs: { value: "0" } });
30624
+ break;
30625
+ }
30626
+ case "w:highlight": {
30627
+ const color = attributes["w:val"];
30628
+ if (typeof color === "string" && color) {
30629
+ highlightColor = color.toLowerCase() === "none" ? "transparent" : color;
30630
+ }
30631
+ break;
30632
+ }
30633
+ case "w:shd": {
30634
+ const fill = attributes["w:fill"];
30635
+ const shdVal = attributes["w:val"];
30636
+ if (fill && String(fill).toLowerCase() !== "auto") {
30637
+ highlightColor = `#${String(fill).replace("#", "")}`;
30638
+ } else if (typeof shdVal === "string") {
30639
+ const normalized = shdVal.toLowerCase();
30640
+ if (normalized === "clear" || normalized === "nil" || normalized === "none") {
30641
+ highlightColor = "transparent";
30642
+ }
30643
+ }
30644
+ break;
30645
+ }
30646
+ case "w:rStyle": {
30647
+ if (typeof attributes["w:val"] === "string") runStyleId = attributes["w:val"];
30648
+ remainingProps.push({ xmlName: entry.xmlName, attributes: { ...attributes } });
30649
+ break;
30650
+ }
30651
+ default: {
30652
+ remainingProps.push({ xmlName: entry.xmlName, attributes: { ...attributes } });
30653
+ }
30654
+ }
30655
+ });
30656
+ if (highlightColor) inlineMarks.push({ type: "highlight", attrs: { color: highlightColor } });
30657
+ return {
30658
+ remainingProps,
30659
+ inlineMarks,
30660
+ textStyleAttrs: hasTextStyle ? textStyleAttrs : null,
30661
+ runStyleId
30662
+ };
30663
+ };
30664
+ const encode$3 = (attributes) => {
30665
+ return attributes["w:rsidR"];
30666
+ };
30667
+ const decode$3 = (attrs) => {
30668
+ return attrs.rsidR;
30669
+ };
30670
+ const attrConfig$2 = Object.freeze({
30671
+ xmlName: "w:rsidR",
30672
+ sdName: "rsidR",
30673
+ encode: encode$3,
30674
+ decode: decode$3
30675
+ });
30676
+ const encode$2 = (attributes) => {
30677
+ return attributes["w:rsidRPr"];
30678
+ };
30679
+ const decode$2 = (attrs) => {
30680
+ return attrs.rsidRPr;
30681
+ };
30682
+ const attrConfig$1 = Object.freeze({
30683
+ xmlName: "w:rsidRPr",
30684
+ sdName: "rsidRPr",
30685
+ encode: encode$2,
30686
+ decode: decode$2
30687
+ });
30688
+ const encode$1 = (attributes) => {
30689
+ return attributes["w:rsidDel"];
30690
+ };
30691
+ const decode$1 = (attrs) => {
30692
+ return attrs.rsidDel;
30693
+ };
30694
+ const attrConfig = Object.freeze({
30695
+ xmlName: "w:rsidDel",
30696
+ sdName: "rsidDel",
30697
+ encode: encode$1,
30698
+ decode: decode$1
30699
+ });
30700
+ const validXmlAttributes = [attrConfig$2, attrConfig$1, attrConfig];
30701
+ const XML_NODE_NAME = "w:r";
30702
+ const SD_KEY_NAME = "run";
30703
+ const encode = (params, encodedAttrs = {}) => {
30704
+ const { nodes = [], nodeListHandler } = params || {};
30705
+ const runNode = nodes[0];
30706
+ if (!runNode) return void 0;
30707
+ const elements = Array.isArray(runNode.elements) ? runNode.elements : [];
30708
+ const rPrNode = elements.find((child) => child?.name === "w:rPr");
30709
+ const contentElements = rPrNode ? elements.filter((el) => el !== rPrNode) : elements;
30710
+ const { entries: runPropEntries, hadRPr, styleChangeMarks } = collectRunProperties(params, rPrNode);
30711
+ const { remainingProps, inlineMarks, textStyleAttrs, runStyleId } = splitRunProperties(runPropEntries, params?.docx);
30712
+ const styleMarks = deriveStyleMarks({
30713
+ docx: params?.docx,
30714
+ paragraphStyleId: params?.parentStyleId,
30715
+ runStyleId
30716
+ });
30717
+ const mergedInlineMarks = mergeInlineMarkSets(styleMarks.inlineMarks, inlineMarks);
30718
+ let mergedTextStyleAttrs = mergeTextStyleAttrs(styleMarks.textStyleAttrs, textStyleAttrs);
30719
+ if (runStyleId) {
30720
+ mergedTextStyleAttrs = mergedTextStyleAttrs ? { ...mergedTextStyleAttrs, styleId: runStyleId } : { styleId: runStyleId };
30721
+ }
30722
+ const runAttrs = buildRunAttrs(encodedAttrs, hadRPr, remainingProps);
30723
+ let runLevelMarks = Array.isArray(runNode.marks) ? runNode.marks.map((mark) => cloneMark(mark)) : [];
30724
+ if (styleChangeMarks?.length) {
30725
+ runLevelMarks = [...runLevelMarks, ...styleChangeMarks.map((mark) => cloneMark(mark))];
30726
+ }
30727
+ const childParams = { ...params, nodes: contentElements };
30728
+ const content = nodeListHandler?.handler(childParams) || [];
30729
+ const contentWithRunMarks = content.map((child) => {
30730
+ if (!child || typeof child !== "object") return child;
30731
+ const baseMarks = Array.isArray(child.marks) ? child.marks.map((mark) => cloneMark(mark)) : [];
30732
+ if (!runLevelMarks.length) return child;
30733
+ return { ...child, marks: [...baseMarks, ...runLevelMarks.map((mark) => cloneMark(mark))] };
30734
+ });
30735
+ const marked = contentWithRunMarks.map(
30736
+ (child) => applyRunMarks(child, runAttrs, mergedInlineMarks, mergedTextStyleAttrs)
30737
+ );
30738
+ const filtered = marked.filter(Boolean);
30739
+ if (!filtered.length) return [];
30740
+ if (filtered.length === 1) return filtered[0];
30741
+ return filtered;
30742
+ };
30743
+ const decode = (params, decodedAttrs = {}) => {
30744
+ const { node } = params || {};
30745
+ if (!node) return void 0;
30746
+ const marks = Array.isArray(node.marks) ? node.marks : [];
30747
+ const runMarkIndex = marks.findIndex((mark) => mark?.type === SD_KEY_NAME);
30748
+ const runMark = runMarkIndex >= 0 ? marks[runMarkIndex] : void 0;
30749
+ const strippedMarks = marks.filter((_2, idx) => idx !== runMarkIndex);
30750
+ const exportNode = { ...node, marks: strippedMarks };
30751
+ const exportParams = { ...params, node: exportNode };
30752
+ if (!exportParams.editor) {
30753
+ exportParams.editor = { extensionService: { extensions: [] } };
30754
+ }
30755
+ const translated = exportSchemaToJson(exportParams);
30756
+ if (!translated) return void 0;
30757
+ const runElement = resolveRunElement(translated);
30758
+ if (!runElement) return translated;
30759
+ runElement.attributes = { ...runElement.attributes || {}, ...decodedAttrs };
30760
+ const runProperties = Array.isArray(runMark?.attrs?.runProperties) ? runMark.attrs.runProperties : null;
30761
+ if (runProperties && runProperties.length) {
30762
+ const rPr = ensureRunPropertiesContainer(runElement);
30763
+ const existingNames = new Set((rPr.elements || []).map((el) => el.name));
30764
+ runProperties.forEach((entry) => {
30765
+ if (!entry || !entry.xmlName || entry.xmlName === "w:b") return;
30766
+ if (existingNames.has(entry.xmlName)) return;
30767
+ rPr.elements.push({ name: entry.xmlName, attributes: { ...entry.attributes || {} } });
30768
+ existingNames.add(entry.xmlName);
30769
+ });
29768
30770
  }
29769
- const styleTags = styles.elements[0].elements.filter((style2) => style2.name === "w:style");
29770
- const style = styleTags.find((tag) => tag.attributes["w:styleId"] === styleId) || {};
29771
- if (!style) return {};
29772
- return parseProperties(style);
30771
+ return translated;
29773
30772
  };
29774
- const runNodeHandlerEntity = {
29775
- handlerName: "runNodeHandler",
29776
- handler: handleRunNode
30773
+ const config = {
30774
+ xmlName: XML_NODE_NAME,
30775
+ sdNodeOrKeyName: SD_KEY_NAME,
30776
+ type: NodeTranslator.translatorTypes.NODE,
30777
+ encode,
30778
+ decode,
30779
+ attributes: validXmlAttributes
29777
30780
  };
30781
+ const translator = NodeTranslator.from(config);
30782
+ const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator);
29778
30783
  const handleTextNode = (params) => {
29779
30784
  const { nodes, insideTrackChange } = params;
29780
30785
  if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
@@ -29811,7 +30816,7 @@ const handleParagraphNode = (params) => {
29811
30816
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
29812
30817
  return { nodes: [], consumed: 0 };
29813
30818
  }
29814
- const schemaNode = translator$h.encode(params);
30819
+ const schemaNode = translator$s.encode(params);
29815
30820
  const newNodes = schemaNode ? [schemaNode] : [];
29816
30821
  return { nodes: newNodes, consumed: 1 };
29817
30822
  };
@@ -29824,7 +30829,7 @@ const handleSdtNode = (params) => {
29824
30829
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
29825
30830
  return { nodes: [], consumed: 0 };
29826
30831
  }
29827
- const result = translator.encode(params);
30832
+ const result = translator$b.encode(params);
29828
30833
  if (!result) {
29829
30834
  return { nodes: [], consumed: 0 };
29830
30835
  }
@@ -29914,7 +30919,7 @@ const handler = (params) => {
29914
30919
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
29915
30920
  return { nodes: [], consumed: 0 };
29916
30921
  }
29917
- const result = translator$j.encode(params);
30922
+ const result = translator$v.encode(params);
29918
30923
  if (!result) return { nodes: [], consumed: 0 };
29919
30924
  return {
29920
30925
  nodes: [result],
@@ -30610,7 +31615,7 @@ const handleTabNode = (params) => {
30610
31615
  if (!nodes.length || nodes[0].name !== "w:tab") {
30611
31616
  return { nodes: [], consumed: 0 };
30612
31617
  }
30613
- const node = translator$i.encode(params);
31618
+ const node = translator$t.encode(params);
30614
31619
  return { nodes: [node], consumed: 1 };
30615
31620
  };
30616
31621
  const tabNodeEntityHandler = {
@@ -31057,6 +32062,16 @@ const isAlternatingHeadersOddEven = (docx) => {
31057
32062
  };
31058
32063
  const HYPERLINK_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
31059
32064
  const HEADER_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
32065
+ const FONT_FAMILY_FALLBACKS = Object.freeze({
32066
+ swiss: "Arial, sans-serif",
32067
+ roman: "Times New Roman, serif",
32068
+ modern: "Courier New, monospace",
32069
+ script: "cursive",
32070
+ decorative: "fantasy",
32071
+ system: "system-ui",
32072
+ auto: "sans-serif"
32073
+ });
32074
+ const DEFAULT_GENERIC_FALLBACK = "sans-serif";
31060
32075
  const _SuperConverter = class _SuperConverter {
31061
32076
  constructor(params = null) {
31062
32077
  __privateAdd(this, _SuperConverter_instances);
@@ -31092,6 +32107,31 @@ const _SuperConverter = class _SuperConverter {
31092
32107
  this.documentId = params?.documentId || null;
31093
32108
  if (this.docx.length || this.xml) this.parseFromXml();
31094
32109
  }
32110
+ static getFontTableEntry(docx, fontName) {
32111
+ if (!docx || !fontName) return null;
32112
+ const fontTable = docx["word/fontTable.xml"];
32113
+ if (!fontTable?.elements?.length) return null;
32114
+ const fontsNode = fontTable.elements.find((el) => el.name === "w:fonts");
32115
+ if (!fontsNode?.elements?.length) return null;
32116
+ return fontsNode.elements.find((el) => el?.attributes?.["w:name"] === fontName) || null;
32117
+ }
32118
+ static getFallbackFromFontTable(docx, fontName) {
32119
+ const fontEntry = _SuperConverter.getFontTableEntry(docx, fontName);
32120
+ const family = fontEntry?.elements?.find((child) => child.name === "w:family")?.attributes?.["w:val"];
32121
+ if (!family) return null;
32122
+ const mapped = FONT_FAMILY_FALLBACKS[family.toLowerCase()];
32123
+ return mapped || DEFAULT_GENERIC_FALLBACK;
32124
+ }
32125
+ static toCssFontFamily(fontName, docx) {
32126
+ if (!fontName) return fontName;
32127
+ if (fontName.includes(",")) return fontName;
32128
+ const fallback = _SuperConverter.getFallbackFromFontTable(docx, fontName) || DEFAULT_GENERIC_FALLBACK;
32129
+ const normalizedFallbackParts = fallback.split(",").map((part) => part.trim().toLowerCase()).filter(Boolean);
32130
+ if (normalizedFallbackParts.includes(fontName.trim().toLowerCase())) {
32131
+ return fallback;
32132
+ }
32133
+ return `${fontName}, ${fallback}`;
32134
+ }
31095
32135
  /**
31096
32136
  * Get the DocxHelpers object that contains utility functions for working with docx files.
31097
32137
  * @returns {import('./docx-helpers/docx-helpers.js').DocxHelpers} The DocxHelpers object.
@@ -31137,7 +32177,7 @@ const _SuperConverter = class _SuperConverter {
31137
32177
  return;
31138
32178
  }
31139
32179
  }
31140
- static updateDocumentVersion(docx = this.convertedXml, version = "0.20.1") {
32180
+ static updateDocumentVersion(docx = this.convertedXml, version = "0.21.0-RC1") {
31141
32181
  const customLocation = "docProps/custom.xml";
31142
32182
  if (!docx[customLocation]) {
31143
32183
  docx[customLocation] = generateCustomXml();
@@ -31188,13 +32228,19 @@ const _SuperConverter = class _SuperConverter {
31188
32228
  if (rPrDefaults) {
31189
32229
  const rPr = rPrDefaults.elements?.find((el) => el.name === "w:rPr");
31190
32230
  const fonts = rPr?.elements?.find((el) => el.name === "w:rFonts");
31191
- typeface = fonts?.attributes["w:ascii"];
31192
- const fontSize = typeface ?? rPr?.elements?.find((el) => el.name === "w:sz")?.attributes["w:val"];
31193
- fontSizeNormal = !fontSizeNormal && fontSize ? Number(fontSize) / 2 : null;
32231
+ if (fonts?.attributes?.["w:ascii"]) {
32232
+ typeface = fonts.attributes["w:ascii"];
32233
+ }
32234
+ const fontSizeRaw = rPr?.elements?.find((el) => el.name === "w:sz")?.attributes?.["w:val"];
32235
+ if (!fontSizeNormal && fontSizeRaw) {
32236
+ fontSizeNormal = Number(fontSizeRaw) / 2;
32237
+ }
31194
32238
  }
31195
- const fontSizePt = fontSizeNormal || Number(rElements.find((el) => el.name === "w:sz")?.attributes["w:val"]) / 2 || 10;
32239
+ const fallbackSz = Number(rElements.find((el) => el.name === "w:sz")?.attributes?.["w:val"]);
32240
+ const fontSizePt = fontSizeNormal ?? (Number.isFinite(fallbackSz) ? fallbackSz / 2 : void 0) ?? 10;
31196
32241
  const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
31197
- return { fontSizePt, kern, typeface, panose };
32242
+ const fontFamilyCss = _SuperConverter.toCssFontFamily(typeface, this.convertedXml);
32243
+ return { fontSizePt, kern, typeface, panose, fontFamilyCss };
31198
32244
  }
31199
32245
  }
31200
32246
  getDocumentFonts() {
@@ -31627,7 +32673,7 @@ function storeSuperdocVersion(docx) {
31627
32673
  function generateCustomXml() {
31628
32674
  return DEFAULT_CUSTOM_XML;
31629
32675
  }
31630
- function generateSuperdocVersion(pid = 2, version = "0.20.1") {
32676
+ function generateSuperdocVersion(pid = 2, version = "0.21.0-RC1") {
31631
32677
  return {
31632
32678
  type: "element",
31633
32679
  name: "property",
@@ -31680,6 +32726,7 @@ export {
31680
32726
  objectIncludes as Z,
31681
32727
  AddMarkStep as _,
31682
32728
  Plugin as a,
32729
+ translator$v as a$,
31683
32730
  twipsToLines as a0,
31684
32731
  pixelsToTwips as a1,
31685
32732
  helpers as a2,
@@ -31695,10 +32742,28 @@ export {
31695
32742
  readFromClipboard as aC,
31696
32743
  handleClipboardPaste as aD,
31697
32744
  getFileObject as aE,
31698
- translator$h as aF,
31699
- translator$i as aG,
31700
- translator$j as aH,
31701
- _sfc_main as aI,
32745
+ runPropertyTranslators as aF,
32746
+ translator$g as aG,
32747
+ translator$h as aH,
32748
+ translator$f as aI,
32749
+ translator$i as aJ,
32750
+ translator$e as aK,
32751
+ translator$d as aL,
32752
+ translator$j as aM,
32753
+ translator$k as aN,
32754
+ translator$t as aO,
32755
+ translator$b as aP,
32756
+ translator$1 as aQ,
32757
+ translator as aR,
32758
+ translator$s as aS,
32759
+ translator$l as aT,
32760
+ translator$c as aU,
32761
+ translator$m as aV,
32762
+ translator$n as aW,
32763
+ translator$o as aX,
32764
+ translator$p as aY,
32765
+ translator$q as aZ,
32766
+ translator$r as a_,
31702
32767
  hasSomeParentWithClass as aa,
31703
32768
  isActive as ab,
31704
32769
  unflattenListsInHtml as ac,
@@ -31726,6 +32791,7 @@ export {
31726
32791
  getContentTypesFromXml as ay,
31727
32792
  xmljs as az,
31728
32793
  Slice as b,
32794
+ _sfc_main as b0,
31729
32795
  DOMParser$1 as c,
31730
32796
  Mark as d,
31731
32797
  dropPoint as e,