@office-open/docx 0.9.8 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { DOCX_PARTS, Relationships, TargetModeType, ThemeColor, blipDesc, buildContentTypeOverrides, convertEmuToPixels, convertInchesToTwip, convertPixelsToEmu, convertToEmu, convertToTwip, convertUniversalMeasureToEmu, customGeometryDesc, decimalNumber, derivePasswordHash, effectListDesc, eighthPointMeasureValue, fillDesc, hexColorValue, hpsMeasureValue, measurementOrPercentValue, outlineDesc, parseColorChoice, pointMeasureValue, signedTwipsMeasureValue, toUint8Array, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, xsdVerticalMergeRev } from "@office-open/core";
1
+ import { DOCX_PARTS, Relationships, TargetModeType, ThemeColor, appPropertiesDesc, blipDesc, buildContentTypeOverrides, convertEmuToPixels, convertInchesToTwip, convertPixelsToEmu, convertToEmu, convertToTwip, convertUniversalMeasureToEmu, customGeometryDesc, customPropertiesDesc, decimalNumber, derivePasswordHash, effectListDesc, eighthPointMeasureValue, fillDesc, hexColorValue, hpsMeasureValue, measurementOrPercentValue, outlineDesc, parseColorChoice, pointMeasureValue, signedTwipsMeasureValue, toUint8Array, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, xsdVerticalMergeRev } from "@office-open/core";
2
2
  import { attr, attrBool, attrNum, children, colorAttr, element, escapeXml, findChild, findDeep, stringify, textOf } from "@office-open/xml";
3
3
  import { calculateEffectExtent, createColorElement, createEffectDag, createScene3D, createShape3D, customGeometryDesc as customGeometryDesc$1, effectListDesc as effectListDesc$1, extractBlipFillMedia, fillDesc as fillDesc$1, outlineDesc as outlineDesc$1, scene3DDesc, shape3DDesc, transform2DDesc } from "@office-open/core/drawingml";
4
4
  import { chartSpaceDesc } from "@office-open/core/chart";
@@ -1375,8 +1375,12 @@ function parseRunProperties(el) {
1375
1375
  const eastAsia = attr(font, "w:eastAsia");
1376
1376
  const hAnsi = attr(font, "w:hAnsi");
1377
1377
  const cs = attr(font, "w:cs");
1378
+ const asciiTheme = attr(font, "w:asciiTheme");
1379
+ const eastAsiaTheme = attr(font, "w:eastAsiaTheme");
1380
+ const hAnsiTheme = attr(font, "w:hAnsiTheme");
1381
+ const cstheme = attr(font, "w:cstheme");
1378
1382
  const hint = attr(font, "w:hint");
1379
- if (ascii && !eastAsia && !hAnsi && !cs) opts.font = hint ? {
1383
+ if (ascii && !eastAsia && !hAnsi && !cs && !asciiTheme && !eastAsiaTheme && !hAnsiTheme && !cstheme) opts.font = hint ? {
1380
1384
  name: ascii,
1381
1385
  hint
1382
1386
  } : ascii;
@@ -1386,6 +1390,10 @@ function parseRunProperties(el) {
1386
1390
  if (eastAsia) fontObj.eastAsia = eastAsia;
1387
1391
  if (hAnsi) fontObj.hAnsi = hAnsi;
1388
1392
  if (cs) fontObj.cs = cs;
1393
+ if (asciiTheme) fontObj.asciiTheme = asciiTheme;
1394
+ if (eastAsiaTheme) fontObj.eastAsiaTheme = eastAsiaTheme;
1395
+ if (hAnsiTheme) fontObj.hAnsiTheme = hAnsiTheme;
1396
+ if (cstheme) fontObj.cstheme = cstheme;
1389
1397
  if (hint) fontObj.hint = hint;
1390
1398
  opts.font = fontObj;
1391
1399
  }
@@ -3747,6 +3755,19 @@ function parseSectionPropertiesEl(el) {
3747
3755
  }
3748
3756
  if (Object.keys(headerGroup).length > 0) opts.headerWrapperGroup = headerGroup;
3749
3757
  if (Object.keys(footerGroup).length > 0) opts.footerWrapperGroup = footerGroup;
3758
+ const sectPrChange = findChild(el, "w:sectPrChange");
3759
+ if (sectPrChange) {
3760
+ const rev = {};
3761
+ const author = attr(sectPrChange, "w:author");
3762
+ if (author) rev.author = author;
3763
+ const revDate = attr(sectPrChange, "w:date");
3764
+ if (revDate) rev.date = revDate;
3765
+ const revId = attrNum(sectPrChange, "w:id");
3766
+ if (revId !== void 0) rev.id = revId;
3767
+ const innerSectPr = findChild(sectPrChange, "w:sectPr");
3768
+ if (innerSectPr) Object.assign(rev, parseSectionPropertiesEl(innerSectPr));
3769
+ if (Object.keys(rev).length > 0) opts.revision = rev;
3770
+ }
3750
3771
  return opts;
3751
3772
  }
3752
3773
  function parseNotePropertiesEl(el) {
@@ -4761,12 +4782,25 @@ function parseParagraphProperties(el, ctx) {
4761
4782
  break;
4762
4783
  }
4763
4784
  }
4764
- if (abstractNumId !== void 0) opts.numbering = {
4765
- reference: `list_${numId}`,
4766
- level,
4767
- custom: true
4768
- };
4769
- else opts.bullet = { level };
4785
+ if (abstractNumId !== void 0) {
4786
+ const numberingOpts = {
4787
+ reference: `list_${numId}`,
4788
+ level,
4789
+ custom: true
4790
+ };
4791
+ const numberingChangeEl = findChild(numPr, "w:numberingChange");
4792
+ if (numberingChangeEl) {
4793
+ const nc = {
4794
+ original: attr(numberingChangeEl, "w:original") ?? "",
4795
+ id: attr(numberingChangeEl, "w:id") ?? "",
4796
+ author: attr(numberingChangeEl, "w:author") ?? ""
4797
+ };
4798
+ const ncDate = attr(numberingChangeEl, "w:date");
4799
+ if (ncDate) nc.date = ncDate;
4800
+ numberingOpts.numberingChange = nc;
4801
+ }
4802
+ opts.numbering = numberingOpts;
4803
+ } else opts.bullet = { level };
4770
4804
  } else opts.bullet = { level };
4771
4805
  } else opts.bullet = { level };
4772
4806
  }
@@ -4910,6 +4944,19 @@ function parseParagraphProperties(el, ctx) {
4910
4944
  if (h !== void 0) frame.height = h;
4911
4945
  if (Object.keys(frame).length > 0) opts.frame = frame;
4912
4946
  }
4947
+ const pPrChange = findChild(el, "w:pPrChange");
4948
+ if (pPrChange) {
4949
+ const rev = {};
4950
+ const author = attr(pPrChange, "w:author");
4951
+ if (author) rev.author = author;
4952
+ const revDate = attr(pPrChange, "w:date");
4953
+ if (revDate) rev.date = revDate;
4954
+ const revId = attrNum(pPrChange, "w:id");
4955
+ if (revId !== void 0) rev.id = revId;
4956
+ const innerPPr = findChild(pPrChange, "w:pPr");
4957
+ if (innerPPr) Object.assign(rev, parseParagraphProperties(innerPPr, ctx));
4958
+ if (Object.keys(rev).length > 0) opts.revision = rev;
4959
+ }
4913
4960
  return opts;
4914
4961
  }
4915
4962
  /**
@@ -4919,6 +4966,16 @@ function parseParagraphProperties(el, ctx) {
4919
4966
  * (the runs between the `separate` and `end` fldChars). Only `<w:t>` is read —
4920
4967
  * `<w:tab>`/`<w:br>` in results are ignored as rare for user-entered text.
4921
4968
  */
4969
+ /** Parse the w:r children of a track-change wrapper (w:ins/w:moveFrom/w:moveTo). */
4970
+ function parseTrackChangeRuns(el, ctx) {
4971
+ const runs = [];
4972
+ for (const sub of el.elements ?? []) {
4973
+ if (sub.name !== "w:r") continue;
4974
+ const runOpts = parsedRunToOptions(parseRun(sub, ctx));
4975
+ if (runOpts !== null && typeof runOpts === "object" && !("commentReference" in runOpts)) runs.push(runOpts);
4976
+ }
4977
+ return runs;
4978
+ }
4922
4979
  function collectRunText(el) {
4923
4980
  let text = "";
4924
4981
  for (const c of el.elements ?? []) if (c.name === "w:t") text += textOf(c);
@@ -5201,73 +5258,56 @@ function parseRunLevelChildren(elements, ctx) {
5201
5258
  break;
5202
5259
  }
5203
5260
  case "w:ins": {
5204
- const insRun = findChild(child, "w:r");
5205
- if (insRun) {
5206
- const runOpts = parsedRunToOptions(parseRun(insRun, ctx));
5207
- if (runOpts !== null && typeof runOpts === "object" && !("commentReference" in runOpts)) childList.push({ insertion: {
5208
- id: attrNum(child, "w:id") ?? 0,
5209
- author: attr(child, "w:author") ?? "",
5210
- date: attr(child, "w:date") ?? "",
5211
- ...runOpts
5212
- } });
5213
- }
5261
+ const children = parseTrackChangeRuns(child, ctx);
5262
+ if (children.length > 0) childList.push({ insertion: {
5263
+ id: attrNum(child, "w:id") ?? 0,
5264
+ author: attr(child, "w:author") ?? "",
5265
+ date: attr(child, "w:date") ?? "",
5266
+ children
5267
+ } });
5214
5268
  break;
5215
5269
  }
5216
5270
  case "w:del": {
5217
- let delFieldPlaceholder;
5271
+ const children = [];
5218
5272
  for (const sub of child.elements ?? []) {
5219
5273
  if (sub.name !== "w:r") continue;
5220
5274
  const delInstrEl = findChild(sub, "w:delInstrText");
5221
5275
  if (delInstrEl) {
5222
- delFieldPlaceholder = DELETED_PAGE_FIELD[(textOf(delInstrEl) ?? "").trim()];
5223
- if (delFieldPlaceholder) break;
5276
+ const placeholder = DELETED_PAGE_FIELD[(textOf(delInstrEl) ?? "").trim()];
5277
+ if (placeholder) {
5278
+ children.push(placeholder);
5279
+ continue;
5280
+ }
5224
5281
  }
5282
+ const runOpts = parsedRunToOptions(parseRun(sub, ctx));
5283
+ if (runOpts !== null && typeof runOpts === "object" && !("commentReference" in runOpts)) children.push(runOpts);
5225
5284
  }
5226
- if (delFieldPlaceholder) {
5227
- childList.push({ deletion: {
5228
- id: attrNum(child, "w:id") ?? 0,
5229
- author: attr(child, "w:author") ?? "",
5230
- date: attr(child, "w:date") ?? "",
5231
- children: [delFieldPlaceholder]
5232
- } });
5233
- break;
5234
- }
5235
- const delRun = findChild(child, "w:r");
5236
- if (delRun) {
5237
- const runOpts = parsedRunToOptions(parseRun(delRun, ctx));
5238
- if (runOpts !== null && typeof runOpts === "object" && !("commentReference" in runOpts)) childList.push({ deletion: {
5239
- id: attrNum(child, "w:id") ?? 0,
5240
- author: attr(child, "w:author") ?? "",
5241
- date: attr(child, "w:date") ?? "",
5242
- ...runOpts
5243
- } });
5244
- }
5285
+ if (children.length > 0) childList.push({ deletion: {
5286
+ id: attrNum(child, "w:id") ?? 0,
5287
+ author: attr(child, "w:author") ?? "",
5288
+ date: attr(child, "w:date") ?? "",
5289
+ children
5290
+ } });
5245
5291
  break;
5246
5292
  }
5247
5293
  case "w:moveFrom": {
5248
- const runEl = findChild(child, "w:r");
5249
- if (runEl) {
5250
- const runOpts = parsedRunToOptions(parseRun(runEl, ctx));
5251
- if (runOpts !== null && typeof runOpts === "object" && !("commentReference" in runOpts)) childList.push({ movedFrom: {
5252
- id: attrNum(child, "w:id") ?? 0,
5253
- author: attr(child, "w:author") ?? "",
5254
- date: attr(child, "w:date") ?? "",
5255
- ...runOpts
5256
- } });
5257
- }
5294
+ const children = parseTrackChangeRuns(child, ctx);
5295
+ if (children.length > 0) childList.push({ movedFrom: {
5296
+ id: attrNum(child, "w:id") ?? 0,
5297
+ author: attr(child, "w:author") ?? "",
5298
+ date: attr(child, "w:date") ?? "",
5299
+ children
5300
+ } });
5258
5301
  break;
5259
5302
  }
5260
5303
  case "w:moveTo": {
5261
- const runEl = findChild(child, "w:r");
5262
- if (runEl) {
5263
- const runOpts = parsedRunToOptions(parseRun(runEl, ctx));
5264
- if (runOpts !== null && typeof runOpts === "object" && !("commentReference" in runOpts)) childList.push({ movedTo: {
5265
- id: attrNum(child, "w:id") ?? 0,
5266
- author: attr(child, "w:author") ?? "",
5267
- date: attr(child, "w:date") ?? "",
5268
- ...runOpts
5269
- } });
5270
- }
5304
+ const children = parseTrackChangeRuns(child, ctx);
5305
+ if (children.length > 0) childList.push({ movedTo: {
5306
+ id: attrNum(child, "w:id") ?? 0,
5307
+ author: attr(child, "w:author") ?? "",
5308
+ date: attr(child, "w:date") ?? "",
5309
+ children
5310
+ } });
5271
5311
  break;
5272
5312
  }
5273
5313
  case "w:fldSimple": {
@@ -6864,6 +6904,27 @@ const createEnd = (dirty) => createFieldChar(FieldCharacterType.END, dirty);
6864
6904
  *
6865
6905
  * @module
6866
6906
  */
6907
+ /** Serialize a deleted run: rPr + delText (or field delInstrText). */
6908
+ function stringifyDeletedRun(c) {
6909
+ const opts = typeof c === "string" ? { text: c } : c;
6910
+ const parts = [];
6911
+ const rPr = stringifyRunProperties(opts);
6912
+ if (rPr) parts.push(rPr);
6913
+ if (opts.break) for (let i = 0; i < opts.break; i++) parts.push("<w:br/>");
6914
+ const fieldMap = {
6915
+ CURRENT: "PAGE",
6916
+ TOTAL_PAGES: "NUMPAGES",
6917
+ TOTAL_PAGES_IN_SECTION: "SECTIONPAGES"
6918
+ };
6919
+ if (opts.children) {
6920
+ for (const cc of opts.children) if (typeof cc === "string") {
6921
+ const instrText = fieldMap[cc];
6922
+ if (instrText) parts.push(`<w:fldChar w:fldCharType="begin"/><w:delInstrText xml:space="preserve">${instrText}</w:delInstrText><w:fldChar w:fldCharType="separate"/><w:fldChar w:fldCharType="end"/>`);
6923
+ else parts.push(`<w:delText xml:space="preserve">${escapeXml(cc)}</w:delText>`);
6924
+ }
6925
+ } else if (opts.text) parts.push(`<w:delText xml:space="preserve">${escapeXml(String(opts.text))}</w:delText>`);
6926
+ return `<w:r>${parts.join("")}</w:r>`;
6927
+ }
6867
6928
  function stringifyRunInline(opts, ctx) {
6868
6929
  const parts = [];
6869
6930
  const rPr = stringifyRunProperties(opts);
@@ -7150,29 +7211,14 @@ function stringifyChildDispatch(child, ctx) {
7150
7211
  }
7151
7212
  if ("math" in child && typeof child.math === "object" && child.math !== null) return stringifyMath(child.math.children ?? []);
7152
7213
  if ("insertion" in child) {
7153
- const { id, author, date, ...runOpts } = child.insertion;
7154
- const runXml = stringifyRunInline(runOpts, ctx);
7155
- return `<w:ins w:id="${id}" w:author="${escapeXml(String(author))}" w:date="${date}">${runXml}</w:ins>`;
7214
+ const { id, author, date, children } = child.insertion;
7215
+ const body = children.map((c) => stringifyRunInline(typeof c === "string" ? { text: c } : c, ctx)).join("");
7216
+ return `<w:ins w:id="${id}" w:author="${escapeXml(String(author))}" w:date="${date}">${body}</w:ins>`;
7156
7217
  }
7157
7218
  if ("deletion" in child) {
7158
- const { id, author, date, ...runOpts } = child.deletion;
7159
- const parts = [];
7160
- const rPr = stringifyRunProperties(runOpts);
7161
- if (rPr) parts.push(rPr);
7162
- if (runOpts.break) for (let i = 0; i < runOpts.break; i++) parts.push("<w:br/>");
7163
- if (runOpts.children) {
7164
- for (const c of runOpts.children) if (typeof c === "string") {
7165
- const instrText = {
7166
- CURRENT: "PAGE",
7167
- TOTAL_PAGES: "NUMPAGES",
7168
- TOTAL_PAGES_IN_SECTION: "SECTIONPAGES"
7169
- }[c];
7170
- if (instrText) parts.push(`<w:fldChar w:fldCharType="begin"/><w:delInstrText xml:space="preserve">${instrText}</w:delInstrText><w:fldChar w:fldCharType="separate"/><w:fldChar w:fldCharType="end"/>`);
7171
- else parts.push(`<w:delText xml:space="preserve">${escapeXml(c)}</w:delText>`);
7172
- }
7173
- } else if (runOpts.text) parts.push(`<w:delText xml:space="preserve">${escapeXml(String(runOpts.text))}</w:delText>`);
7174
- const runBody = parts.join("");
7175
- return `<w:del w:id="${id}" w:author="${escapeXml(String(author))}" w:date="${date}"><w:r>${runBody}</w:r></w:del>`;
7219
+ const { id, author, date, children } = child.deletion;
7220
+ const body = children.map((c) => stringifyDeletedRun(c)).join("");
7221
+ return `<w:del w:id="${id}" w:author="${escapeXml(String(author))}" w:date="${date}">${body}</w:del>`;
7176
7222
  }
7177
7223
  if ("hyperlink" in child) {
7178
7224
  const hl = child.hyperlink;
@@ -7228,14 +7274,14 @@ function stringifyChildDispatch(child, ctx) {
7228
7274
  }
7229
7275
  if ("moveToRangeEnd" in child) return `<w:moveToRangeEnd w:id="${child.moveToRangeEnd}"/>`;
7230
7276
  if ("movedFrom" in child) {
7231
- const { id, author, date, ...runOpts } = child.movedFrom;
7232
- const runXml = stringifyRunInline(runOpts, ctx);
7233
- return `<w:moveFrom w:id="${id}" w:author="${escapeXml(String(author))}" w:date="${date}">${runXml}</w:moveFrom>`;
7277
+ const { id, author, date, children } = child.movedFrom;
7278
+ const body = children.map((c) => stringifyRunInline(typeof c === "string" ? { text: c } : c, ctx)).join("");
7279
+ return `<w:moveFrom w:id="${id}" w:author="${escapeXml(String(author))}" w:date="${date}">${body}</w:moveFrom>`;
7234
7280
  }
7235
7281
  if ("movedTo" in child) {
7236
- const { id, author, date, ...runOpts } = child.movedTo;
7237
- const runXml = stringifyRunInline(runOpts, ctx);
7238
- return `<w:moveTo w:id="${id}" w:author="${escapeXml(String(author))}" w:date="${date}">${runXml}</w:moveTo>`;
7282
+ const { id, author, date, children } = child.movedTo;
7283
+ const body = children.map((c) => stringifyRunInline(typeof c === "string" ? { text: c } : c, ctx)).join("");
7284
+ return `<w:moveTo w:id="${id}" w:author="${escapeXml(String(author))}" w:date="${date}">${body}</w:moveTo>`;
7239
7285
  }
7240
7286
  if ("customXmlInsRangeStart" in child) {
7241
7287
  const o = child.customXmlInsRangeStart;
@@ -9483,6 +9529,60 @@ function stringifyCharacterStyle(opts) {
9483
9529
  if (rPr) children.push(rPr);
9484
9530
  return `<w:style w:type="character" w:styleId="${esc(opts.id)}">${children.join("")}</w:style>`;
9485
9531
  }
9532
+ /** Resolve a user override for heading level N (1-9) from default styles options. */
9533
+ function headingOverride(options, level) {
9534
+ switch (level) {
9535
+ case 1: return options.heading1;
9536
+ case 2: return options.heading2;
9537
+ case 3: return options.heading3;
9538
+ case 4: return options.heading4;
9539
+ case 5: return options.heading5;
9540
+ case 6: return options.heading6;
9541
+ case 7: return options.heading7;
9542
+ case 8: return options.heading8;
9543
+ case 9: return options.heading9;
9544
+ default: return;
9545
+ }
9546
+ }
9547
+ /**
9548
+ * Maps DefaultStylesOptions override fields to every built-in styleId the
9549
+ * factory (re)emits when that field is provided — the main style plus its
9550
+ * linked character style (e.g. heading1 -> Heading1 + Heading1Char).
9551
+ */
9552
+ const DEFAULT_STYLE_FIELDS = [
9553
+ ["title", ["Title", "TitleChar"]],
9554
+ ["subtitle", ["Subtitle", "SubtitleChar"]],
9555
+ ["heading1", ["Heading1", "Heading1Char"]],
9556
+ ["heading2", ["Heading2", "Heading2Char"]],
9557
+ ["heading3", ["Heading3", "Heading3Char"]],
9558
+ ["heading4", ["Heading4", "Heading4Char"]],
9559
+ ["heading5", ["Heading5", "Heading5Char"]],
9560
+ ["heading6", ["Heading6", "Heading6Char"]],
9561
+ ["heading7", ["Heading7", "Heading7Char"]],
9562
+ ["heading8", ["Heading8", "Heading8Char"]],
9563
+ ["heading9", ["Heading9", "Heading9Char"]],
9564
+ ["listParagraph", ["ListParagraph"]],
9565
+ ["quote", ["Quote", "QuoteChar"]],
9566
+ ["strong", ["Strong"]],
9567
+ ["emphasis", ["Emphasis"]]
9568
+ ];
9569
+ /**
9570
+ * Reverse map: main built-in styleId -> the DefaultStylesOptions field that
9571
+ * overrides it. Linked char ids (Heading1Char, TitleChar, ...) are excluded —
9572
+ * they ride along with their main style.
9573
+ */
9574
+ const STYLE_ID_TO_DEFAULT_FIELD = Object.fromEntries(DEFAULT_STYLE_FIELDS.map(([field, [mainId]]) => [mainId, field]));
9575
+ /**
9576
+ * Collect every styleId the factory (re)emits for the default-styles fields the
9577
+ * user explicitly provided — including linked character styles, so the
9578
+ * round-trip path drops the matching verbatim entries (no duplicate styleId).
9579
+ */
9580
+ function collectDefaultOverrideIds(defaultOpts) {
9581
+ const ids = /* @__PURE__ */ new Set();
9582
+ if (!defaultOpts) return ids;
9583
+ for (const [field, styleIds] of DEFAULT_STYLE_FIELDS) if (defaultOpts[field] !== void 0) for (const id of styleIds) ids.add(id);
9584
+ return ids;
9585
+ }
9486
9586
  /** Build `<w:docDefaults>` XML matching Word's default settings. */
9487
9587
  function stringifyDocDefaults(opts) {
9488
9588
  const children = [];
@@ -9522,7 +9622,7 @@ var DefaultStylesFactory = class {
9522
9622
  importedStyles.push({ _raw: stringifyDocDefaults(options.document ?? {}) });
9523
9623
  importedStyles.push({ _raw: "<w:latentStyles w:defLockedState=\"0\" w:defUIPriority=\"99\" w:defSemiHidden=\"0\" w:defUnhideWhenUsed=\"0\" w:defQFormat=\"0\" w:count=\"376\"><w:lsdException w:name=\"Normal\" w:uiPriority=\"0\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 1\" w:uiPriority=\"9\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 2\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 3\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 4\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 5\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 6\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 7\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 8\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 9\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"Default Paragraph Font\" w:semiHidden=\"1\" w:uiPriority=\"1\" w:unhideWhenUsed=\"1\"/><w:lsdException w:name=\"Normal Table\" w:semiHidden=\"1\" w:uiPriority=\"99\" w:unhideWhenUsed=\"1\"/><w:lsdException w:name=\"No List\" w:semiHidden=\"1\" w:uiPriority=\"99\" w:unhideWhenUsed=\"1\"/><w:lsdException w:name=\"Subtitle\" w:uiPriority=\"11\" w:qFormat=\"1\"/><w:lsdException w:name=\"Strong\" w:uiPriority=\"22\" w:qFormat=\"1\"/><w:lsdException w:name=\"Emphasis\" w:uiPriority=\"20\" w:qFormat=\"1\"/><w:lsdException w:name=\"Hyperlink\" w:semiHidden=\"1\" w:unhideWhenUsed=\"1\"/><w:lsdException w:name=\"FollowedHyperlink\" w:semiHidden=\"1\" w:unhideWhenUsed=\"1\"/><w:lsdException w:name=\"No Spacing\" w:uiPriority=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"Revision\" w:semiHidden=\"1\"/></w:latentStyles>" });
9524
9624
  importedStyles.push({ _raw: "<w:style w:type=\"paragraph\" w:default=\"1\" w:styleId=\"Normal\"><w:name w:val=\"Normal\"/><w:qFormat/><w:pPr><w:widowControl w:val=\"0\"/></w:pPr></w:style>" });
9525
- for (const h of [
9625
+ const headings = [
9526
9626
  {
9527
9627
  id: "Heading1",
9528
9628
  name: "heading 1",
@@ -9604,7 +9704,36 @@ var DefaultStylesFactory = class {
9604
9704
  after: "0",
9605
9705
  outlineLvl: "8"
9606
9706
  }
9607
- ]) {
9707
+ ];
9708
+ for (let headingIdx = 0; headingIdx < headings.length; headingIdx++) {
9709
+ const h = headings[headingIdx];
9710
+ const headingOverrideOpts = headingOverride(options, headingIdx + 1);
9711
+ if (headingOverrideOpts) {
9712
+ importedStyles.push({ _raw: stringifyParagraphStyle({
9713
+ id: h.id,
9714
+ name: headingOverrideOpts.name ?? h.name,
9715
+ basedOn: headingOverrideOpts.basedOn ?? "Normal",
9716
+ next: headingOverrideOpts.next ?? "Normal",
9717
+ link: headingOverrideOpts.link ?? h.link,
9718
+ uiPriority: headingOverrideOpts.uiPriority ?? 9,
9719
+ quickFormat: headingOverrideOpts.quickFormat ?? true,
9720
+ semiHidden: headingOverrideOpts.semiHidden,
9721
+ unhideWhenUsed: headingOverrideOpts.unhideWhenUsed,
9722
+ paragraph: {
9723
+ outlineLevel: headingIdx,
9724
+ ...headingOverrideOpts.paragraph
9725
+ },
9726
+ run: headingOverrideOpts.run
9727
+ }) });
9728
+ importedStyles.push({ _raw: stringifyCharacterStyle({
9729
+ id: h.link,
9730
+ name: `${h.name} Char`,
9731
+ basedOn: "DefaultParagraphFont",
9732
+ link: h.id,
9733
+ run: headingOverrideOpts.run
9734
+ }) });
9735
+ continue;
9736
+ }
9608
9737
  const pPrParts = [`<w:keepNext/>`, `<w:keepLines/>`];
9609
9738
  if (h.before || h.after) {
9610
9739
  const sp = [];
@@ -9629,13 +9758,103 @@ var DefaultStylesFactory = class {
9629
9758
  importedStyles.push({ _raw: "<w:style w:type=\"character\" w:default=\"1\" w:styleId=\"DefaultParagraphFont\"><w:name w:val=\"Default Paragraph Font\"/><w:uiPriority w:val=\"1\"/><w:semiHidden/><w:unhideWhenUsed/></w:style>" });
9630
9759
  importedStyles.push({ _raw: "<w:style w:type=\"table\" w:default=\"1\" w:styleId=\"NormalTable\"><w:name w:val=\"Normal Table\"/><w:uiPriority w:val=\"99\"/><w:semiHidden/><w:unhideWhenUsed/><w:tblPr><w:tblInd w:w=\"0\" w:type=\"dxa\"/><w:tblCellMar><w:top w:w=\"0\" w:type=\"dxa\"/><w:left w:w=\"108\" w:type=\"dxa\"/><w:bottom w:w=\"0\" w:type=\"dxa\"/><w:right w:w=\"108\" w:type=\"dxa\"/></w:tblCellMar></w:tblPr></w:style>" });
9631
9760
  importedStyles.push({ _raw: "<w:style w:type=\"numbering\" w:default=\"1\" w:styleId=\"NoList\"><w:name w:val=\"No List\"/><w:uiPriority w:val=\"99\"/><w:semiHidden/><w:unhideWhenUsed/></w:style>" });
9632
- importedStyles.push({ _raw: "<w:style w:type=\"paragraph\" w:styleId=\"Title\"><w:name w:val=\"Title\"/><w:basedOn w:val=\"Normal\"/><w:next w:val=\"Normal\"/><w:link w:val=\"TitleChar\"/><w:uiPriority w:val=\"10\"/><w:qFormat/><w:pPr><w:spacing w:after=\"80\" w:line=\"240\" w:lineRule=\"auto\"/><w:contextualSpacing/><w:jc w:val=\"center\"/></w:pPr><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/><w:spacing w:val=\"-10\"/><w:kern w:val=\"28\"/><w:sz w:val=\"56\"/><w:szCs w:val=\"56\"/></w:rPr></w:style>" });
9633
- importedStyles.push({ _raw: "<w:style w:type=\"character\" w:styleId=\"TitleChar\"><w:name w:val=\"Title Char\"/><w:basedOn w:val=\"DefaultParagraphFont\"/><w:link w:val=\"Title\"/><w:uiPriority w:val=\"10\"/><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/><w:spacing w:val=\"-10\"/><w:kern w:val=\"28\"/><w:sz w:val=\"56\"/><w:szCs w:val=\"56\"/></w:rPr></w:style>" });
9634
- importedStyles.push({ _raw: "<w:style w:type=\"paragraph\" w:styleId=\"Subtitle\"><w:name w:val=\"Subtitle\"/><w:basedOn w:val=\"Normal\"/><w:next w:val=\"Normal\"/><w:link w:val=\"SubtitleChar\"/><w:uiPriority w:val=\"11\"/><w:qFormat/><w:pPr><w:jc w:val=\"center\"/></w:pPr><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/><w:color w:val=\"595959\" w:themeColor=\"text1\" w:themeTint=\"A6\"/><w:spacing w:val=\"15\"/><w:sz w:val=\"28\"/><w:szCs w:val=\"28\"/></w:rPr></w:style>" });
9635
- importedStyles.push({ _raw: "<w:style w:type=\"character\" w:styleId=\"SubtitleChar\"><w:name w:val=\"Subtitle Char\"/><w:basedOn w:val=\"DefaultParagraphFont\"/><w:link w:val=\"Subtitle\"/><w:uiPriority w:val=\"11\"/><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/><w:color w:val=\"595959\" w:themeColor=\"text1\" w:themeTint=\"A6\"/><w:spacing w:val=\"15\"/><w:sz w:val=\"28\"/><w:szCs w:val=\"28\"/></w:rPr></w:style>" });
9636
- importedStyles.push({ _raw: "<w:style w:type=\"paragraph\" w:styleId=\"ListParagraph\"><w:name w:val=\"List Paragraph\"/><w:basedOn w:val=\"Normal\"/><w:uiPriority w:val=\"34\"/><w:qFormat/><w:pPr><w:ind w:left=\"720\"/><w:contextualSpacing/></w:pPr></w:style>" });
9637
- importedStyles.push({ _raw: "<w:style w:type=\"paragraph\" w:styleId=\"Quote\"><w:name w:val=\"Quote\"/><w:basedOn w:val=\"Normal\"/><w:next w:val=\"Normal\"/><w:link w:val=\"QuoteChar\"/><w:uiPriority w:val=\"29\"/><w:qFormat/><w:pPr><w:spacing w:before=\"160\"/><w:jc w:val=\"center\"/></w:pPr><w:rPr><w:i/><w:iCs/><w:color w:val=\"404040\" w:themeColor=\"text1\" w:themeTint=\"BF\"/></w:rPr></w:style>" });
9638
- importedStyles.push({ _raw: "<w:style w:type=\"character\" w:styleId=\"QuoteChar\"><w:name w:val=\"Quote Char\"/><w:basedOn w:val=\"DefaultParagraphFont\"/><w:link w:val=\"Quote\"/><w:uiPriority w:val=\"29\"/><w:rPr><w:i/><w:iCs/><w:color w:val=\"404040\" w:themeColor=\"text1\" w:themeTint=\"BF\"/></w:rPr></w:style>" });
9761
+ if (options.title) {
9762
+ importedStyles.push({ _raw: stringifyParagraphStyle({
9763
+ id: "Title",
9764
+ name: options.title.name ?? "Title",
9765
+ basedOn: options.title.basedOn ?? "Normal",
9766
+ next: options.title.next ?? "Normal",
9767
+ link: options.title.link ?? "TitleChar",
9768
+ uiPriority: options.title.uiPriority ?? 10,
9769
+ quickFormat: options.title.quickFormat ?? true,
9770
+ paragraph: options.title.paragraph,
9771
+ run: options.title.run
9772
+ }) });
9773
+ importedStyles.push({ _raw: stringifyCharacterStyle({
9774
+ id: "TitleChar",
9775
+ name: "Title Char",
9776
+ basedOn: "DefaultParagraphFont",
9777
+ link: "Title",
9778
+ run: options.title.run
9779
+ }) });
9780
+ } else {
9781
+ importedStyles.push({ _raw: "<w:style w:type=\"paragraph\" w:styleId=\"Title\"><w:name w:val=\"Title\"/><w:basedOn w:val=\"Normal\"/><w:next w:val=\"Normal\"/><w:link w:val=\"TitleChar\"/><w:uiPriority w:val=\"10\"/><w:qFormat/><w:pPr><w:spacing w:after=\"80\" w:line=\"240\" w:lineRule=\"auto\"/><w:contextualSpacing/><w:jc w:val=\"center\"/></w:pPr><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/><w:spacing w:val=\"-10\"/><w:kern w:val=\"28\"/><w:sz w:val=\"56\"/><w:szCs w:val=\"56\"/></w:rPr></w:style>" });
9782
+ importedStyles.push({ _raw: "<w:style w:type=\"character\" w:styleId=\"TitleChar\"><w:name w:val=\"Title Char\"/><w:basedOn w:val=\"DefaultParagraphFont\"/><w:link w:val=\"Title\"/><w:uiPriority w:val=\"10\"/><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/><w:spacing w:val=\"-10\"/><w:kern w:val=\"28\"/><w:sz w:val=\"56\"/><w:szCs w:val=\"56\"/></w:rPr></w:style>" });
9783
+ }
9784
+ if (options.subtitle) {
9785
+ importedStyles.push({ _raw: stringifyParagraphStyle({
9786
+ id: "Subtitle",
9787
+ name: options.subtitle.name ?? "Subtitle",
9788
+ basedOn: options.subtitle.basedOn ?? "Normal",
9789
+ next: options.subtitle.next ?? "Normal",
9790
+ link: options.subtitle.link ?? "SubtitleChar",
9791
+ uiPriority: options.subtitle.uiPriority ?? 11,
9792
+ quickFormat: options.subtitle.quickFormat ?? true,
9793
+ paragraph: options.subtitle.paragraph,
9794
+ run: options.subtitle.run
9795
+ }) });
9796
+ importedStyles.push({ _raw: stringifyCharacterStyle({
9797
+ id: "SubtitleChar",
9798
+ name: "Subtitle Char",
9799
+ basedOn: "DefaultParagraphFont",
9800
+ link: "Subtitle",
9801
+ run: options.subtitle.run
9802
+ }) });
9803
+ } else {
9804
+ importedStyles.push({ _raw: "<w:style w:type=\"paragraph\" w:styleId=\"Subtitle\"><w:name w:val=\"Subtitle\"/><w:basedOn w:val=\"Normal\"/><w:next w:val=\"Normal\"/><w:link w:val=\"SubtitleChar\"/><w:uiPriority w:val=\"11\"/><w:qFormat/><w:pPr><w:jc w:val=\"center\"/></w:pPr><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/><w:color w:val=\"595959\" w:themeColor=\"text1\" w:themeTint=\"A6\"/><w:spacing w:val=\"15\"/><w:sz w:val=\"28\"/><w:szCs w:val=\"28\"/></w:rPr></w:style>" });
9805
+ importedStyles.push({ _raw: "<w:style w:type=\"character\" w:styleId=\"SubtitleChar\"><w:name w:val=\"Subtitle Char\"/><w:basedOn w:val=\"DefaultParagraphFont\"/><w:link w:val=\"Subtitle\"/><w:uiPriority w:val=\"11\"/><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/><w:color w:val=\"595959\" w:themeColor=\"text1\" w:themeTint=\"A6\"/><w:spacing w:val=\"15\"/><w:sz w:val=\"28\"/><w:szCs w:val=\"28\"/></w:rPr></w:style>" });
9806
+ }
9807
+ if (options.listParagraph) importedStyles.push({ _raw: stringifyParagraphStyle({
9808
+ id: "ListParagraph",
9809
+ name: options.listParagraph.name ?? "List Paragraph",
9810
+ basedOn: options.listParagraph.basedOn ?? "Normal",
9811
+ uiPriority: options.listParagraph.uiPriority ?? 34,
9812
+ quickFormat: options.listParagraph.quickFormat ?? true,
9813
+ paragraph: options.listParagraph.paragraph,
9814
+ run: options.listParagraph.run
9815
+ }) });
9816
+ else importedStyles.push({ _raw: "<w:style w:type=\"paragraph\" w:styleId=\"ListParagraph\"><w:name w:val=\"List Paragraph\"/><w:basedOn w:val=\"Normal\"/><w:uiPriority w:val=\"34\"/><w:qFormat/><w:pPr><w:ind w:left=\"720\"/><w:contextualSpacing/></w:pPr></w:style>" });
9817
+ if (options.strong) importedStyles.push({ _raw: stringifyParagraphStyle({
9818
+ id: "Strong",
9819
+ name: options.strong.name ?? "Strong",
9820
+ basedOn: options.strong.basedOn ?? "Normal",
9821
+ next: options.strong.next ?? "Normal",
9822
+ quickFormat: options.strong.quickFormat ?? true,
9823
+ paragraph: options.strong.paragraph,
9824
+ run: options.strong.run
9825
+ }) });
9826
+ if (options.emphasis) importedStyles.push({ _raw: stringifyParagraphStyle({
9827
+ id: "Emphasis",
9828
+ name: options.emphasis.name ?? "Emphasis",
9829
+ basedOn: options.emphasis.basedOn ?? "Normal",
9830
+ next: options.emphasis.next ?? "Normal",
9831
+ quickFormat: options.emphasis.quickFormat ?? true,
9832
+ paragraph: options.emphasis.paragraph,
9833
+ run: options.emphasis.run
9834
+ }) });
9835
+ if (options.quote) {
9836
+ importedStyles.push({ _raw: stringifyParagraphStyle({
9837
+ id: "Quote",
9838
+ name: options.quote.name ?? "Quote",
9839
+ basedOn: options.quote.basedOn ?? "Normal",
9840
+ next: options.quote.next ?? "Normal",
9841
+ link: options.quote.link ?? "QuoteChar",
9842
+ uiPriority: options.quote.uiPriority ?? 29,
9843
+ quickFormat: options.quote.quickFormat ?? true,
9844
+ paragraph: options.quote.paragraph,
9845
+ run: options.quote.run
9846
+ }) });
9847
+ importedStyles.push({ _raw: stringifyCharacterStyle({
9848
+ id: "QuoteChar",
9849
+ name: "Quote Char",
9850
+ basedOn: "DefaultParagraphFont",
9851
+ link: "Quote",
9852
+ run: options.quote.run
9853
+ }) });
9854
+ } else {
9855
+ importedStyles.push({ _raw: "<w:style w:type=\"paragraph\" w:styleId=\"Quote\"><w:name w:val=\"Quote\"/><w:basedOn w:val=\"Normal\"/><w:next w:val=\"Normal\"/><w:link w:val=\"QuoteChar\"/><w:uiPriority w:val=\"29\"/><w:qFormat/><w:pPr><w:spacing w:before=\"160\"/><w:jc w:val=\"center\"/></w:pPr><w:rPr><w:i/><w:iCs/><w:color w:val=\"404040\" w:themeColor=\"text1\" w:themeTint=\"BF\"/></w:rPr></w:style>" });
9856
+ importedStyles.push({ _raw: "<w:style w:type=\"character\" w:styleId=\"QuoteChar\"><w:name w:val=\"Quote Char\"/><w:basedOn w:val=\"DefaultParagraphFont\"/><w:link w:val=\"Quote\"/><w:uiPriority w:val=\"29\"/><w:rPr><w:i/><w:iCs/><w:color w:val=\"404040\" w:themeColor=\"text1\" w:themeTint=\"BF\"/></w:rPr></w:style>" });
9857
+ }
9639
9858
  importedStyles.push({ _raw: "<w:style w:type=\"paragraph\" w:styleId=\"IntenseQuote\"><w:name w:val=\"Intense Quote\"/><w:basedOn w:val=\"Normal\"/><w:next w:val=\"Normal\"/><w:link w:val=\"IntenseQuoteChar\"/><w:uiPriority w:val=\"30\"/><w:qFormat/><w:pPr><w:pBdr><w:top w:val=\"single\" w:sz=\"4\" w:space=\"10\" w:color=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/><w:bottom w:val=\"single\" w:sz=\"4\" w:space=\"10\" w:color=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/></w:pBdr><w:spacing w:before=\"360\" w:after=\"360\"/><w:ind w:left=\"864\" w:right=\"864\"/><w:jc w:val=\"center\"/></w:pPr><w:rPr><w:i/><w:iCs/><w:color w:val=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/></w:rPr></w:style>" });
9640
9859
  importedStyles.push({ _raw: "<w:style w:type=\"character\" w:styleId=\"IntenseQuoteChar\"><w:name w:val=\"Intense Quote Char\"/><w:basedOn w:val=\"DefaultParagraphFont\"/><w:link w:val=\"IntenseQuote\"/><w:uiPriority w:val=\"30\"/><w:rPr><w:i/><w:iCs/><w:color w:val=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/></w:rPr></w:style>" });
9641
9860
  importedStyles.push({ _raw: stringifyCharacterStyle({
@@ -9738,6 +9957,16 @@ var DefaultStylesFactory = class {
9738
9957
  * @module
9739
9958
  */
9740
9959
  /**
9960
+ * Extract the `w:styleId` from a raw `<w:style>` XML string, if present.
9961
+ *
9962
+ * Returns `undefined` for non-style elements (docDefaults / latentStyles),
9963
+ * whose raw XML carries no `w:styleId` attribute.
9964
+ */
9965
+ function extractStyleId(raw) {
9966
+ const m = raw.match(/w:styleId="([^"]+)"/);
9967
+ return m ? m[1] : void 0;
9968
+ }
9969
+ /**
9741
9970
  * Represents the styles definitions in a WordprocessingML document.
9742
9971
  *
9743
9972
  * Pure collector — no XmlComponent inheritance.
@@ -9748,8 +9977,16 @@ var Styles = class {
9748
9977
  parts = [];
9749
9978
  constructor(options) {
9750
9979
  if (options.initialAttributes) this.attributes = options.initialAttributes;
9751
- if (options.importedStyles) {
9752
- for (const style of options.importedStyles) if (style._raw) this.parts.push(style._raw);
9980
+ const customStyleIds = /* @__PURE__ */ new Set();
9981
+ for (const s of options.paragraphStyles ?? []) customStyleIds.add(s.id);
9982
+ for (const s of options.characterStyles ?? []) customStyleIds.add(s.id);
9983
+ if (options.importedStyles) for (const style of options.importedStyles) {
9984
+ if (!style._raw) continue;
9985
+ if (customStyleIds.size > 0) {
9986
+ const id = extractStyleId(style._raw);
9987
+ if (id && customStyleIds.has(id)) continue;
9988
+ }
9989
+ this.parts.push(style._raw);
9753
9990
  }
9754
9991
  if (options.paragraphStyles) for (const style of options.paragraphStyles) this.parts.push(stringifyParagraphStyle({
9755
9992
  id: style.id,
@@ -9860,6 +10097,13 @@ function parseStyleDefinitions(el, parseParagraphProperties, ctx) {
9860
10097
  const styleOpts = parseStyleElement(child, parseParagraphProperties, ctx);
9861
10098
  if (!styleOpts?._type || !styleOpts.id) continue;
9862
10099
  (opts.importedStyles ??= []).push({ _raw: stringifyElement(child) });
10100
+ const defaultField = STYLE_ID_TO_DEFAULT_FIELD[styleOpts.id];
10101
+ if (defaultField) {
10102
+ const { _type: _omitType, id: _omitId, ...rest } = styleOpts;
10103
+ opts.default ??= {};
10104
+ opts.default[defaultField] = rest;
10105
+ continue;
10106
+ }
9863
10107
  if (BUILTIN_STYLE_IDS.has(styleOpts.id)) continue;
9864
10108
  const type = styleOpts._type;
9865
10109
  delete styleOpts._type;
@@ -10467,17 +10711,9 @@ const settingsDesc = {
10467
10711
  if (val) opts.defaultTabStop = parseInt(val, 10);
10468
10712
  }
10469
10713
  const trackRevEl = findChild(el, "w:trackRevisions");
10470
- if (trackRevEl) {
10471
- const features = opts.features ?? {};
10472
- features.trackRevisions = attrBool(trackRevEl, "w:val") ?? true;
10473
- opts.features = features;
10474
- }
10714
+ if (trackRevEl) opts.trackRevisions = attrBool(trackRevEl, "w:val") ?? true;
10475
10715
  const updateFieldsEl = findChild(el, "w:updateFields");
10476
- if (updateFieldsEl) {
10477
- const features = opts.features ?? {};
10478
- features.updateFields = attrBool(updateFieldsEl, "w:val") ?? true;
10479
- opts.features = features;
10480
- }
10716
+ if (updateFieldsEl) opts.updateFields = attrBool(updateFieldsEl, "w:val") ?? true;
10481
10717
  const compatEl = findChild(el, "w:compat");
10482
10718
  if (compatEl) {
10483
10719
  for (const child of compatEl.elements ?? []) if (child.name === "w:compatSetting") {
@@ -10659,11 +10895,7 @@ const settingsDesc = {
10659
10895
  const formatting = attr(docProtEl, "w:formatting");
10660
10896
  if (formatting !== void 0) prot.formatting = formatting === "1" || formatting === "true";
10661
10897
  }
10662
- if (Object.keys(prot).length > 0) {
10663
- const features = opts.features ?? {};
10664
- features.documentProtection = prot;
10665
- opts.features = features;
10666
- }
10898
+ if (Object.keys(prot).length > 0) opts.documentProtection = prot;
10667
10899
  }
10668
10900
  const noMovesEl = findChild(el, "w:doNotTrackMoves");
10669
10901
  if (noMovesEl) opts.doNotTrackMoves = attrBool(noMovesEl, "w:val") ?? true;
@@ -11371,8 +11603,11 @@ function escapeAttr(s) {
11371
11603
  const COMMENTS_NS = "xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"";
11372
11604
  function stringifyComment(opts, ctx) {
11373
11605
  const dateStr = typeof opts.date === "string" ? opts.date : (opts.date ?? /* @__PURE__ */ new Date()).toISOString();
11374
- const attrs = [`w:id="${opts.id}"`, `w:date="${escapeAttr(dateStr)}"`];
11375
- if (opts.author !== void 0) attrs.push(`w:author="${escapeAttr(opts.author)}"`);
11606
+ const attrs = [
11607
+ `w:id="${opts.id}"`,
11608
+ `w:author="${escapeAttr(opts.author ?? "")}"`,
11609
+ `w:date="${escapeAttr(dateStr)}"`
11610
+ ];
11376
11611
  if (opts.initials !== void 0) attrs.push(`w:initials="${escapeAttr(opts.initials)}"`);
11377
11612
  const parts = [];
11378
11613
  for (const child of opts.children) parts.push(stringifyParagraphInline(child, ctx));
@@ -11396,9 +11631,9 @@ const commentsDesc = {
11396
11631
  const date = attr(child, "w:date");
11397
11632
  if (date) comment.date = date;
11398
11633
  const author = attr(child, "w:author");
11399
- if (author) comment.author = author;
11634
+ if (author !== void 0) comment.author = author;
11400
11635
  const initials = attr(child, "w:initials");
11401
- if (initials) comment.initials = initials;
11636
+ if (initials !== void 0) comment.initials = initials;
11402
11637
  const children = [];
11403
11638
  for (const sub of child.elements ?? []) if (sub.name === "w:p") children.push(parseParagraph(sub, ctx));
11404
11639
  comment.children = children;
@@ -11708,146 +11943,6 @@ const corePropertiesDesc = {
11708
11943
  }
11709
11944
  };
11710
11945
  //#endregion
11711
- //#region src/parts/custom-properties.ts
11712
- const customPropertiesDesc = {
11713
- kind: "custom",
11714
- stringify(opts, _ctx) {
11715
- const p = ["<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">"];
11716
- let pid = 2;
11717
- for (const prop of opts.properties) {
11718
- p.push(`<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="${pid}" name="${escapeXml(prop.name)}"><vt:lpwstr>${escapeXml(prop.value)}</vt:lpwstr></property>`);
11719
- pid++;
11720
- }
11721
- p.push("</Properties>");
11722
- return p.join("");
11723
- },
11724
- parse(el, _ctx) {
11725
- const properties = [];
11726
- for (const child of el.elements ?? []) {
11727
- if (child.name !== "property") continue;
11728
- const name = attr(child, "name");
11729
- if (!name) continue;
11730
- const valueEl = child.elements?.find((e) => e.name?.startsWith("vt:"));
11731
- const value = valueEl ? textOf(valueEl) ?? "" : "";
11732
- properties.push({
11733
- name,
11734
- value
11735
- });
11736
- }
11737
- return { properties };
11738
- }
11739
- };
11740
- //#endregion
11741
- //#region src/parts/app-properties.ts
11742
- /** xsd:boolean lexical form — spec canonical form is "true"/"false" (Word's convention). */
11743
- const xsdBoolean = (value) => value ? "true" : "false";
11744
- const appPropertiesDesc = {
11745
- kind: "custom",
11746
- stringify(opts, _ctx) {
11747
- const p = ["<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">"];
11748
- if (opts.template !== void 0) p.push(`<Template>${escapeXml(opts.template)}</Template>`);
11749
- if (opts.manager !== void 0) p.push(`<Manager>${escapeXml(opts.manager)}</Manager>`);
11750
- if (opts.company !== void 0) p.push(`<Company>${escapeXml(opts.company)}</Company>`);
11751
- if (opts.pages !== void 0) p.push(`<Pages>${opts.pages}</Pages>`);
11752
- if (opts.words !== void 0) p.push(`<Words>${opts.words}</Words>`);
11753
- if (opts.characters !== void 0) p.push(`<Characters>${opts.characters}</Characters>`);
11754
- if (opts.lines !== void 0) p.push(`<Lines>${opts.lines}</Lines>`);
11755
- if (opts.paragraphs !== void 0) p.push(`<Paragraphs>${opts.paragraphs}</Paragraphs>`);
11756
- if (opts.slides !== void 0) p.push(`<Slides>${opts.slides}</Slides>`);
11757
- if (opts.notes !== void 0) p.push(`<Notes>${opts.notes}</Notes>`);
11758
- if (opts.totalTime !== void 0) p.push(`<TotalTime>${opts.totalTime}</TotalTime>`);
11759
- if (opts.hiddenSlides !== void 0) p.push(`<HiddenSlides>${opts.hiddenSlides}</HiddenSlides>`);
11760
- if (opts.mmClips !== void 0) p.push(`<MMClips>${opts.mmClips}</MMClips>`);
11761
- if (opts.scaleCrop !== void 0) p.push(`<ScaleCrop>${xsdBoolean(opts.scaleCrop)}</ScaleCrop>`);
11762
- if (opts.linksUpToDate !== void 0) p.push(`<LinksUpToDate>${xsdBoolean(opts.linksUpToDate)}</LinksUpToDate>`);
11763
- if (opts.charactersWithSpaces !== void 0) p.push(`<CharactersWithSpaces>${opts.charactersWithSpaces}</CharactersWithSpaces>`);
11764
- if (opts.sharedDoc !== void 0) p.push(`<SharedDoc>${xsdBoolean(opts.sharedDoc)}</SharedDoc>`);
11765
- if (opts.hyperlinkBase !== void 0) p.push(`<HyperlinkBase>${escapeXml(opts.hyperlinkBase)}</HyperlinkBase>`);
11766
- if (opts.hyperlinksChanged !== void 0) p.push(`<HyperlinksChanged>${xsdBoolean(opts.hyperlinksChanged)}</HyperlinksChanged>`);
11767
- if (opts.application !== void 0) p.push(`<Application>${escapeXml(opts.application)}</Application>`);
11768
- if (opts.appVersion !== void 0) p.push(`<AppVersion>${escapeXml(opts.appVersion)}</AppVersion>`);
11769
- if (opts.docSecurity !== void 0) p.push(`<DocSecurity>${opts.docSecurity}</DocSecurity>`);
11770
- p.push("</Properties>");
11771
- return p.join("");
11772
- },
11773
- parse(el, _ctx) {
11774
- const result = {};
11775
- for (const child of el.elements ?? []) {
11776
- if (typeof child.name !== "string") continue;
11777
- const text = child.elements?.[0]?.text;
11778
- switch (child.name) {
11779
- case "Template":
11780
- if (typeof text === "string") result.template = text;
11781
- break;
11782
- case "Manager":
11783
- if (typeof text === "string") result.manager = text;
11784
- break;
11785
- case "Company":
11786
- if (typeof text === "string") result.company = text;
11787
- break;
11788
- case "Pages":
11789
- if (typeof text === "string") result.pages = Number(text);
11790
- break;
11791
- case "Words":
11792
- if (typeof text === "string") result.words = Number(text);
11793
- break;
11794
- case "Characters":
11795
- if (typeof text === "string") result.characters = Number(text);
11796
- break;
11797
- case "Lines":
11798
- if (typeof text === "string") result.lines = Number(text);
11799
- break;
11800
- case "Paragraphs":
11801
- if (typeof text === "string") result.paragraphs = Number(text);
11802
- break;
11803
- case "Slides":
11804
- if (typeof text === "string") result.slides = Number(text);
11805
- break;
11806
- case "Notes":
11807
- if (typeof text === "string") result.notes = Number(text);
11808
- break;
11809
- case "TotalTime":
11810
- if (typeof text === "string") result.totalTime = Number(text);
11811
- break;
11812
- case "HiddenSlides":
11813
- if (typeof text === "string") result.hiddenSlides = Number(text);
11814
- break;
11815
- case "MMClips":
11816
- if (typeof text === "string") result.mmClips = Number(text);
11817
- break;
11818
- case "ScaleCrop":
11819
- if (typeof text === "string") result.scaleCrop = text === "1" || text === "true";
11820
- break;
11821
- case "LinksUpToDate":
11822
- if (typeof text === "string") result.linksUpToDate = text === "1" || text === "true";
11823
- break;
11824
- case "CharactersWithSpaces":
11825
- if (typeof text === "string") result.charactersWithSpaces = Number(text);
11826
- break;
11827
- case "SharedDoc":
11828
- if (typeof text === "string") result.sharedDoc = text === "1" || text === "true";
11829
- break;
11830
- case "HyperlinkBase":
11831
- if (typeof text === "string") result.hyperlinkBase = text;
11832
- break;
11833
- case "HyperlinksChanged":
11834
- if (typeof text === "string") result.hyperlinksChanged = text === "1" || text === "true";
11835
- break;
11836
- case "Application":
11837
- if (typeof text === "string") result.application = text;
11838
- break;
11839
- case "AppVersion":
11840
- if (typeof text === "string") result.appVersion = text;
11841
- break;
11842
- case "DocSecurity":
11843
- if (typeof text === "string") result.docSecurity = Number(text);
11844
- break;
11845
- }
11846
- }
11847
- return result;
11848
- }
11849
- };
11850
- //#endregion
11851
11946
  //#region src/parts/web-settings.ts
11852
11947
  /**
11853
11948
  * Screen size types for web settings target.
@@ -12160,6 +12255,6 @@ const webSettingsDesc = {
12160
12255
  }
12161
12256
  };
12162
12257
  //#endregion
12163
- export { tableDesc as $, RelativeVerticalPosition as $t, buildNumberingCache as A, LineRuleType as An, SpaceType as At, createLineNumberType as B, sdtBlockDesc as Bt, footnotesDesc as C, createTransformation as Cn, createPageNumberType as Ct, StyleLevel as D, TextAlignmentType as Dn, VerticalPositionRelativeFrom as Dt, SdtLock as E, PageNumber as En, HorizontalPositionRelativeFrom as Et, HeaderFooterType as F, TextWrappingType as Ft, DocumentGridType as G, subDocDesc as Gt, PageBorderDisplay as H, stringifyCustomXmlShell as Ht, createHeaderFooterReference as I, altChunkDesc as It, Numbering as J, TABLE_BORDERS_NONE as Jt, createDocumentGrid as K, stringifyElement as Kt, SectionType as L, checkboxSymbolRunInner as Lt, parseStyleDefinitions as M, createWrapThrough as Mt, DefaultStylesFactory as N, createWrapTight as Nt, settingsDesc as O, TextboxTightWrapType as On, HorizontalPositionAlign as Ot, HeaderFooterReferenceType as P, TextWrappingSide as Pt, setTableParseChild as Q, RelativeHorizontalPosition as Qt, createSectionType as R, customXmlBlockDesc as Rt, endnotesDesc as S, Media as Sn, PageNumberSeparator as St, SdtDateMappingType as T, TextEffect as Tn, createHorizontalPosition as Tt, PageBorderOffsetFrom as U, stringifySdtPr as Ut, createPageMargin as V, setBodyParseChild as Vt, PageBorderZOrder as W, stringifySdtShell as Wt, LevelFormat as X, TableLayoutType as Xt, parseNumberingDefinitions as Y, BorderStyle as Yt, LevelSuffix as Z, OverlapType as Zt, glossaryDesc as _, VerticalAnchor as _n, sectionMarginDefaults as _t, appPropertiesDesc as a, createFormFieldData as an, parseParagraph as at, CharacterSet as b, createImageData$1 as bn, PageOrientation as bt, relationshipsDesc as c, PositionalTabAlignment as cn, stringifyDocumentXml as ct, withAltChunkOverrides as d, EmphasisMarkType as dn, parseSdtBlock as dt, TableAnchorType as en, stringifyChildDispatch as et, withMediaDefaults as f, UnderlineType as fn, parseSdtProperties as ft, DocPartType as g, TextVerticalType as gn, stringifySectionPropertiesXml as gt, DocPartGallery as h, TextVertOverflowType as hn, sectionPropertiesDesc as ht, webSettingsDesc as i, FormFieldTextType as in, resetDrawingIdGen as it, buildStyleCache as j, AlignmentType as jn, VerticalPositionAlign as jt, Styles as k, HeadingLevel as kn, NumberFormat as kt, buildContentTypesFromRegistry as l, PositionalTabLeader as ln, replaceRelsWithPlaceholders as lt, DocPartBehavior as m, TextHorzOverflowType as mn, parseSectionPropertiesEl as mt, frameXml as n, VerticalMergeType as nn, stringifyRunInline as nt, customPropertiesDesc as o, parseFormFieldData as on, parseParagraphProperties as ot, commentsDesc as p, TextBodyWrappingType as pn, FontWrapper as pt, DocumentAttributeNamespaces as q, WidthType as qt, framesetXml as r, ProofErrorType as rn, drawingDesc as rt, corePropertiesDesc as s, RubyAlign as sn, stringifyBodyChild as st, TargetScreenSize as t, TextDirection as tn, stringifyParagraphInline as tt, contentTypesDesc as u, PositionalTabRelativeTo as un, stringifyTableOfContents as ut, bibliographyDesc as v, createBodyProperties as vn, sectionPageSizeDefaults as vt, parseToc as w, HighlightColor as wn, createVerticalPosition as wt, EditGroupType as x, WORKAROUND2 as xn, createPageSize as xt, fontTableDesc as y, parseBodyProperties as yn, PageTextDirectionType as yt, LineNumberRestartFormat as z, parseCustomXmlProperties as zt };
12258
+ export { LevelSuffix as $, OverlapType as $t, buildNumberingCache as A, TextboxTightWrapType as An, HorizontalPositionAlign as At, createSectionType as B, customXmlBlockDesc as Bt, footnotesDesc as C, WORKAROUND2 as Cn, createPageSize as Ct, StyleLevel as D, TextEffect as Dn, createHorizontalPosition as Dt, SdtLock as E, HighlightColor as En, createVerticalPosition as Et, collectDefaultOverrideIds as F, createWrapTight as Ft, PageBorderOffsetFrom as G, stringifySdtPr as Gt, createLineNumberType as H, sdtBlockDesc as Ht, HeaderFooterReferenceType as I, TextWrappingSide as It, createDocumentGrid as J, stringifyElement as Jt, PageBorderZOrder as K, stringifySdtShell as Kt, HeaderFooterType as L, TextWrappingType as Lt, extractStyleId as M, LineRuleType as Mn, SpaceType as Mt, parseStyleDefinitions as N, AlignmentType as Nn, VerticalPositionAlign as Nt, settingsDesc as O, PageNumber as On, HorizontalPositionRelativeFrom as Ot, DefaultStylesFactory as P, createWrapThrough as Pt, LevelFormat as Q, TableLayoutType as Qt, createHeaderFooterReference as R, altChunkDesc as Rt, endnotesDesc as S, createImageData$1 as Sn, PageOrientation as St, SdtDateMappingType as T, createTransformation as Tn, createPageNumberType as Tt, createPageMargin as U, setBodyParseChild as Ut, LineNumberRestartFormat as V, parseCustomXmlProperties as Vt, PageBorderDisplay as W, stringifyCustomXmlShell as Wt, Numbering as X, TABLE_BORDERS_NONE as Xt, DocumentAttributeNamespaces as Y, WidthType as Yt, parseNumberingDefinitions as Z, BorderStyle as Zt, glossaryDesc as _, TextVertOverflowType as _n, sectionPropertiesDesc as _t, appPropertiesDesc as a, ProofErrorType as an, drawingDesc as at, CharacterSet as b, createBodyProperties as bn, sectionPageSizeDefaults as bt, relationshipsDesc as c, parseFormFieldData as cn, parseParagraphProperties as ct, withAltChunkOverrides as d, PositionalTabLeader as dn, replaceRelsWithPlaceholders as dt, RelativeHorizontalPosition as en, setTableParseChild as et, withMediaDefaults as f, PositionalTabRelativeTo as fn, stringifyTableOfContents as ft, DocPartType as g, TextHorzOverflowType as gn, parseSectionPropertiesEl as gt, DocPartGallery as h, TextBodyWrappingType as hn, FontWrapper as ht, webSettingsDesc as i, VerticalMergeType as in, stringifyRunInline as it, buildStyleCache as j, HeadingLevel as jn, NumberFormat as jt, Styles as k, TextAlignmentType as kn, VerticalPositionRelativeFrom as kt, buildContentTypesFromRegistry as l, RubyAlign as ln, stringifyBodyChild as lt, DocPartBehavior as m, UnderlineType as mn, parseSdtProperties as mt, frameXml as n, TableAnchorType as nn, stringifyChildDispatch as nt, customPropertiesDesc as o, FormFieldTextType as on, resetDrawingIdGen as ot, commentsDesc as p, EmphasisMarkType as pn, parseSdtBlock as pt, DocumentGridType as q, subDocDesc as qt, framesetXml as r, TextDirection as rn, stringifyParagraphInline as rt, corePropertiesDesc as s, createFormFieldData as sn, parseParagraph as st, TargetScreenSize as t, RelativeVerticalPosition as tn, tableDesc as tt, contentTypesDesc as u, PositionalTabAlignment as un, stringifyDocumentXml as ut, bibliographyDesc as v, TextVerticalType as vn, stringifySectionPropertiesXml as vt, parseToc as w, Media as wn, PageNumberSeparator as wt, EditGroupType as x, parseBodyProperties as xn, PageTextDirectionType as xt, fontTableDesc as y, VerticalAnchor as yn, sectionMarginDefaults as yt, SectionType as z, checkboxSymbolRunInner as zt };
12164
12259
 
12165
- //# sourceMappingURL=parts-Cp_NxQFi.mjs.map
12260
+ //# sourceMappingURL=parts-BWmkYaBr.mjs.map