@superdoc-dev/mcp 0.11.0-next.5 → 0.11.0-next.7

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +625 -308
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -43580,7 +43580,7 @@ var init_uuid_qzgm05fK_es = __esm(() => {
43580
43580
  v5_default = v35("v5", 80, sha1);
43581
43581
  });
43582
43582
 
43583
- // ../../packages/superdoc/dist/chunks/constants-D-X7xF4s.es.js
43583
+ // ../../packages/superdoc/dist/chunks/constants-D9qj59G2.es.js
43584
43584
  function toProtocolSet(values) {
43585
43585
  const result = /* @__PURE__ */ new Set;
43586
43586
  if (!values)
@@ -44166,7 +44166,7 @@ var DEFAULT_ALLOWED_PROTOCOLS, OPTIONAL_PROTOCOLS, BLOCKED_PROTOCOLS, DEFAULT_MA
44166
44166
  return a.length === 1 ? "0" + a : a;
44167
44167
  }, rgbToHex = (rgb) => {
44168
44168
  return "#" + rgb.match(/\d+/g).map(componentToHex).join("");
44169
- }, DEFAULT_SHADING_FOREGROUND_COLOR = "#000000", hexToRgb = (hex3) => {
44169
+ }, DEFAULT_SHADING_FOREGROUND_COLOR = "#000000", DEFAULT_SHADING_FILL_COLOR = "#FFFFFF", hexToRgb = (hex3) => {
44170
44170
  const normalized = normalizeHexColor(hex3);
44171
44171
  if (!normalized)
44172
44172
  return null;
@@ -44193,16 +44193,19 @@ var DEFAULT_ALLOWED_PROTOCOLS, OPTIONAL_PROTOCOLS, BLOCKED_PROTOCOLS, DEFAULT_MA
44193
44193
  }, resolveShadingFillColor = (shading) => {
44194
44194
  if (!shading || typeof shading !== "object")
44195
44195
  return null;
44196
- const fill = normalizeHexColor(shading.fill);
44197
- if (!fill)
44196
+ const val = typeof shading.val === "string" ? shading.val.trim().toLowerCase() : "";
44197
+ if (val === "nil" || val === "none")
44198
44198
  return null;
44199
- const pctMatch = (typeof shading.val === "string" ? shading.val.trim().toLowerCase() : "").match(/^pct(\d{1,3})$/);
44200
- if (!pctMatch)
44201
- return fill;
44202
- const pct = Number.parseInt(pctMatch[1], 10);
44199
+ const fillHex = typeof shading.fill === "string" && shading.fill.trim().toLowerCase() === "auto" ? null : normalizeHexColor(shading.fill);
44200
+ const pctMatch = val.match(/^pct(\d{1,3})$/);
44201
+ if (!(Boolean(pctMatch) || val === "solid"))
44202
+ return fillHex;
44203
+ const baseHex = fillHex ?? DEFAULT_SHADING_FILL_COLOR;
44204
+ const foregroundHex = typeof shading.color !== "string" || shading.color.trim() === "" || shading.color.trim().toLowerCase() === "auto" ? DEFAULT_SHADING_FOREGROUND_COLOR : normalizeHexColor(shading.color) ?? DEFAULT_SHADING_FOREGROUND_COLOR;
44205
+ const pct = pctMatch ? Number.parseInt(pctMatch[1], 10) : 100;
44203
44206
  if (!Number.isFinite(pct) || pct < 0 || pct > 100)
44204
- return fill;
44205
- return blendHexColors(fill, normalizeHexColor(shading.color) ?? DEFAULT_SHADING_FOREGROUND_COLOR, pct / 100) ?? fill;
44207
+ return fillHex;
44208
+ return blendHexColors(baseHex, foregroundHex, pct / 100) ?? fillHex;
44206
44209
  }, deobfuscateFont = (arrayBuffer, guidHex) => {
44207
44210
  const dta = new Uint8Array(arrayBuffer);
44208
44211
  const guidStr = guidHex.replace(/[-{}]/g, "");
@@ -44248,7 +44251,7 @@ var DEFAULT_ALLOWED_PROTOCOLS, OPTIONAL_PROTOCOLS, BLOCKED_PROTOCOLS, DEFAULT_MA
44248
44251
  return "webp";
44249
44252
  return null;
44250
44253
  }, COMMENT_FILE_BASENAMES, DEFAULT_XML_DECLARATION, COMMENT_RELATIONSHIP_TYPES;
44251
- var init_constants_D_X7xF4s_es = __esm(() => {
44254
+ var init_constants_D9qj59G2_es = __esm(() => {
44252
44255
  init_jszip_C49i9kUs_es();
44253
44256
  init_xml_js_CqGKpaft_es();
44254
44257
  init_dist();
@@ -52208,7 +52211,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
52208
52211
  emptyOptions2 = {};
52209
52212
  });
52210
52213
 
52211
- // ../../packages/superdoc/dist/chunks/SuperConverter-B9mZiCO9.es.js
52214
+ // ../../packages/superdoc/dist/chunks/SuperConverter-7JlFliK8.es.js
52212
52215
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
52213
52216
  const fieldValue = extension$1.config[field];
52214
52217
  if (typeof fieldValue === "function")
@@ -62157,6 +62160,70 @@ function computeFragmentPmRange(block, lines, fromLine, toLine) {
62157
62160
  pmEnd
62158
62161
  };
62159
62162
  }
62163
+ function resolveAnchoredGraphicY(input) {
62164
+ const { anchor, objectHeight, contentTop, contentBottom, pageBottomMargin = 0, anchorParagraphY = contentTop, firstLineHeight = 0, preRegisteredFallbackToContentTop = false } = input;
62165
+ const offsetV = anchor?.offsetV ?? 0;
62166
+ const vRelativeFrom = anchor?.vRelativeFrom;
62167
+ const alignV = anchor?.alignV;
62168
+ const contentHeight = Math.max(0, contentBottom - contentTop);
62169
+ if (vRelativeFrom === "margin") {
62170
+ if (alignV === "bottom")
62171
+ return contentBottom - objectHeight + offsetV;
62172
+ if (alignV === "center")
62173
+ return contentTop + (contentHeight - objectHeight) / 2 + offsetV;
62174
+ return contentTop + offsetV;
62175
+ }
62176
+ if (vRelativeFrom === "page") {
62177
+ const pageHeight = contentBottom + pageBottomMargin;
62178
+ if (alignV === "bottom")
62179
+ return pageHeight - objectHeight + offsetV;
62180
+ if (alignV === "center")
62181
+ return (pageHeight - objectHeight) / 2 + offsetV;
62182
+ return offsetV;
62183
+ }
62184
+ if (vRelativeFrom === "paragraph") {
62185
+ if (preRegisteredFallbackToContentTop)
62186
+ return contentTop + offsetV;
62187
+ const baseAnchorY = anchorParagraphY;
62188
+ if (alignV === "bottom")
62189
+ return baseAnchorY + firstLineHeight - objectHeight + offsetV;
62190
+ if (alignV === "center")
62191
+ return baseAnchorY + (firstLineHeight - objectHeight) / 2 + offsetV;
62192
+ return baseAnchorY + offsetV;
62193
+ }
62194
+ if (preRegisteredFallbackToContentTop)
62195
+ return contentTop + offsetV;
62196
+ return anchorParagraphY + offsetV;
62197
+ }
62198
+ function resolveAnchoredGraphicX(anchor, columnIndex, columns, objectWidth, margins, pageWidth) {
62199
+ const alignH = anchor.alignH ?? "left";
62200
+ const offsetH = anchor.offsetH ?? 0;
62201
+ const marginLeft = Math.max(0, margins?.left ?? 0);
62202
+ const marginRight = Math.max(0, margins?.right ?? 0);
62203
+ const contentWidth = pageWidth != null ? Math.max(1, pageWidth - (marginLeft + marginRight)) : columns.width;
62204
+ const contentLeft = marginLeft;
62205
+ const columnLeft = contentLeft + columnIndex * (columns.width + columns.gap);
62206
+ const relativeFrom = anchor.hRelativeFrom ?? "column";
62207
+ let baseX;
62208
+ let availableWidth;
62209
+ if (relativeFrom === "page") {
62210
+ baseX = 0;
62211
+ availableWidth = pageWidth != null ? pageWidth : contentWidth + marginLeft + marginRight;
62212
+ } else if (relativeFrom === "margin") {
62213
+ baseX = contentLeft;
62214
+ availableWidth = contentWidth;
62215
+ } else {
62216
+ baseX = columnLeft;
62217
+ availableWidth = columns.width;
62218
+ }
62219
+ if (alignH === "left")
62220
+ return baseX + offsetH;
62221
+ if (alignH === "right")
62222
+ return baseX + availableWidth - objectWidth - offsetH;
62223
+ if (alignH === "center")
62224
+ return baseX + (availableWidth - objectWidth) / 2 + offsetH;
62225
+ return baseX;
62226
+ }
62160
62227
  function widthsEqual(a, b) {
62161
62228
  if (!a && !b)
62162
62229
  return true;
@@ -62183,10 +62250,12 @@ function cloneColumnLayout(columns) {
62183
62250
  }
62184
62251
  function normalizeColumnLayout(input, contentWidth, epsilon = 0.0001) {
62185
62252
  const rawCount = input && Number.isFinite(input.count) ? Math.floor(input.count) : 1;
62186
- const count = Math.max(1, rawCount || 1);
62253
+ let count = Math.max(1, rawCount || 1);
62187
62254
  const gap = Math.max(0, input?.gap ?? 0);
62255
+ const explicitWidths = input?.equalWidth === false && Array.isArray(input?.widths) && input.widths.length > 0 ? input.widths.filter((width$1) => typeof width$1 === "number" && Number.isFinite(width$1) && width$1 > 0) : [];
62256
+ if (explicitWidths.length > 0 && explicitWidths.length < count)
62257
+ count = explicitWidths.length;
62188
62258
  const availableWidth = contentWidth - gap * (count - 1);
62189
- const explicitWidths = Array.isArray(input?.widths) && input.widths.length > 0 ? input.widths.filter((width$1) => typeof width$1 === "number" && Number.isFinite(width$1) && width$1 > 0) : [];
62190
62259
  let widths = explicitWidths.length > 0 ? explicitWidths.slice(0, count) : Array.from({ length: count }, () => availableWidth > 0 ? availableWidth / count : contentWidth);
62191
62260
  if (widths.length < count) {
62192
62261
  const remaining = Math.max(0, availableWidth - widths.reduce((sum, width$1) => sum + width$1, 0));
@@ -67621,6 +67690,8 @@ function handleImageNode$1(node2, params, isAnchor) {
67621
67690
  default:
67622
67691
  break;
67623
67692
  }
67693
+ if (wrap$1.type === "Square" || wrap$1.type === "Tight" || wrap$1.type === "Through" || wrap$1.type === "TopAndBottom")
67694
+ mergeAnchorPaddingIntoWrapDistances(wrap$1, padding);
67624
67695
  const docPr = node2.elements.find((el) => el.name === "wp:docPr");
67625
67696
  const isHidden = isDocPrHidden(docPr);
67626
67697
  let anchorData = null;
@@ -85691,18 +85762,22 @@ function extractColumns(elements) {
85691
85762
  const cols = elements.find((el) => el?.name === "w:cols");
85692
85763
  if (!cols?.attributes)
85693
85764
  return;
85694
- const count = parseColumnCount(cols.attributes["w:num"]);
85765
+ let count = parseColumnCount(cols.attributes["w:num"]);
85695
85766
  const withSeparator = parseColumnSeparator(cols.attributes["w:sep"]);
85696
85767
  const equalWidthRaw = cols.attributes["w:equalWidth"];
85697
85768
  const equalWidth = equalWidthRaw === "0" || equalWidthRaw === 0 || equalWidthRaw === false ? false : equalWidthRaw === "1" || equalWidthRaw === 1 || equalWidthRaw === true ? true : undefined;
85698
85769
  const columnChildren = Array.isArray(cols.elements) ? cols.elements.filter((child) => child?.name === "w:col") : [];
85699
- const gapInches = parseColumnGap(cols.attributes["w:space"] ?? columnChildren.find((child) => child?.attributes?.["w:space"] != null)?.attributes?.["w:space"]);
85770
+ const isExplicit = equalWidth === false;
85771
+ const firstChildSpace = columnChildren.find((child) => child?.attributes?.["w:space"] != null)?.attributes?.["w:space"];
85772
+ const gapInches = parseColumnGap(isExplicit ? firstChildSpace ?? 0 : cols.attributes["w:space"]);
85700
85773
  const widths = columnChildren.map((child) => Number(child.attributes?.["w:w"])).filter((widthTwips) => Number.isFinite(widthTwips) && widthTwips > 0).map((widthTwips) => widthTwips / 1440 * PX_PER_INCH$1);
85774
+ if (isExplicit && widths.length > 0)
85775
+ count = Math.min(count, widths.length);
85701
85776
  return {
85702
85777
  count,
85703
85778
  gap: gapInches * PX_PER_INCH$1,
85704
85779
  withSeparator,
85705
- ...widths.length > 0 ? { widths } : {},
85780
+ ...isExplicit && widths.length > 0 ? { widths } : {},
85706
85781
  ...equalWidth !== undefined ? { equalWidth } : {}
85707
85782
  };
85708
85783
  }
@@ -88546,6 +88621,8 @@ function imageNodeToBlock(node2, nextBlockId, positions, _trackedMeta, _trackedC
88546
88621
  const height = typeof size.height === "number" && Number.isFinite(size.height) ? size.height : undefined;
88547
88622
  const explicitDisplay = typeof attrs.display === "string" ? attrs.display : undefined;
88548
88623
  const normalizedWrap = normalizeWrap$1(attrs.wrap);
88624
+ if (normalizedWrap)
88625
+ mergeWrapDistancesFromPadding(normalizedWrap, toBoxSpacing$1(attrs.padding));
88549
88626
  let anchor = normalizeAnchorData(attrs.anchorData, attrs, normalizedWrap?.behindDoc);
88550
88627
  if (!anchor && normalizedWrap) {
88551
88628
  anchor = { isAnchored: true };
@@ -104019,6 +104096,17 @@ var isRegExp = (value) => {
104019
104096
  if (!hasValue || !hasPositive)
104020
104097
  return null;
104021
104098
  return `inset(${percentEdges.top ?? 0}% ${percentEdges.right ?? 0}% ${percentEdges.bottom ?? 0}% ${percentEdges.left ?? 0}%)`;
104099
+ }, mergeAnchorPaddingIntoWrapDistances = (wrap$1, padding) => {
104100
+ if (!wrap$1?.attrs || !padding)
104101
+ return;
104102
+ if (wrap$1.attrs.distTop == null && Number.isFinite(padding.top) && padding.top !== 0)
104103
+ wrap$1.attrs.distTop = padding.top;
104104
+ if (wrap$1.attrs.distBottom == null && Number.isFinite(padding.bottom) && padding.bottom !== 0)
104105
+ wrap$1.attrs.distBottom = padding.bottom;
104106
+ if (wrap$1.attrs.distLeft == null && Number.isFinite(padding.left) && padding.left !== 0)
104107
+ wrap$1.attrs.distLeft = padding.left;
104108
+ if (wrap$1.attrs.distRight == null && Number.isFinite(padding.right) && padding.right !== 0)
104109
+ wrap$1.attrs.distRight = padding.right;
104022
104110
  }, handleShapeDrawing = (params, node2, graphicData, size, padding, marginOffset, anchorData, wrap$1, isAnchor, isHidden) => {
104023
104111
  const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
104024
104112
  const textBoxContent = wsp.elements.find((el) => el.name === "wps:txbx")?.elements?.find((el) => el.name === "w:txbxContent");
@@ -112583,6 +112671,17 @@ var isRegExp = (value) => {
112583
112671
  const parsed = parseFloat(value);
112584
112672
  return Number.isFinite(parsed) ? parsed : undefined;
112585
112673
  }
112674
+ }, mergeWrapDistancesFromPadding = (wrap$1, padding) => {
112675
+ if (!padding || wrap$1.type === "None" || wrap$1.type === "Inline")
112676
+ return;
112677
+ if (wrap$1.distTop == null && padding.top != null)
112678
+ wrap$1.distTop = padding.top;
112679
+ if (wrap$1.distBottom == null && padding.bottom != null)
112680
+ wrap$1.distBottom = padding.bottom;
112681
+ if (wrap$1.distLeft == null && padding.left != null)
112682
+ wrap$1.distLeft = padding.left;
112683
+ if (wrap$1.distRight == null && padding.right != null)
112684
+ wrap$1.distRight = padding.right;
112586
112685
  }, normalizeColor = (value) => {
112587
112686
  if (typeof value !== "string")
112588
112687
  return;
@@ -114391,6 +114490,8 @@ var isRegExp = (value) => {
114391
114490
  return anchor.isAnchored || anchor.hRelativeFrom != null || anchor.vRelativeFrom != null || anchor.alignH != null || anchor.alignV != null || anchor.offsetH != null || anchor.offsetV != null || anchor.behindDoc != null ? anchor : undefined;
114392
114491
  }, buildDrawingBlock = (rawAttrs, nextBlockId, positions, node2, geometry, drawingKind, extraProps) => {
114393
114492
  const normalizedWrap = normalizeWrap$2(rawAttrs.wrap);
114493
+ if (normalizedWrap)
114494
+ mergeWrapDistancesFromPadding(normalizedWrap, toBoxSpacing(rawAttrs.padding));
114394
114495
  const sourceAnchor = isPlainObject4(rawAttrs.sourceAnchor) ? rawAttrs.sourceAnchor : undefined;
114395
114496
  const baseAnchor = normalizeAnchorData$1(rawAttrs.anchorData, rawAttrs, normalizedWrap?.behindDoc);
114396
114497
  const pos = positions.get(node2);
@@ -114864,15 +114965,17 @@ var isRegExp = (value) => {
114864
114965
  }
114865
114966
  }
114866
114967
  if (!cellBackgroundColor && resolvedTcProps?.shading) {
114867
- const { fill, themeFill, themeFillTint, themeFillShade } = resolvedTcProps.shading;
114868
- const normalizedFill = normalizeShadingColor(fill);
114869
- if (normalizedFill)
114870
- cellBackgroundColor = normalizedFill;
114871
- else if (themeFill && context.themeColors) {
114872
- const normalizedTheme = normalizeShadingColor(resolveThemeColorValue(themeFill, themeFillTint, themeFillShade, context.themeColors));
114873
- if (normalizedTheme)
114874
- cellBackgroundColor = normalizedTheme;
114875
- }
114968
+ const { fill, color: color2, val, themeFill, themeFillTint, themeFillShade } = resolvedTcProps.shading;
114969
+ let fillBase = normalizeShadingColor(fill);
114970
+ if (!fillBase && themeFill && context.themeColors)
114971
+ fillBase = normalizeShadingColor(resolveThemeColorValue(themeFill, themeFillTint, themeFillShade, context.themeColors));
114972
+ const resolved = resolveShadingFillColor({
114973
+ val,
114974
+ color: color2,
114975
+ fill: fillBase ?? fill
114976
+ });
114977
+ if (resolved)
114978
+ cellBackgroundColor = resolved.startsWith("#") ? resolved : `#${resolved}`;
114876
114979
  }
114877
114980
  const cellConverterContext = tableInfo || cellBackgroundColor ? {
114878
114981
  ...context.converterContext,
@@ -115126,9 +115229,12 @@ var isRegExp = (value) => {
115126
115229
  return null;
115127
115230
  const rowProps = rowNode.attrs?.tableRowProperties;
115128
115231
  const rowHeight = normalizeRowHeight(rowProps);
115232
+ const tblPrExBordersRaw = rowProps?.tblPrExBorders;
115233
+ const rowBorders = tblPrExBordersRaw && typeof tblPrExBordersRaw === "object" ? extractTableBorders(tblPrExBordersRaw, { unit: "eighthPoints" }) : undefined;
115129
115234
  const attrs = rowProps && typeof rowProps === "object" ? {
115130
115235
  tableRowProperties: rowProps,
115131
- ...rowHeight ? { rowHeight } : {}
115236
+ ...rowHeight ? { rowHeight } : {},
115237
+ ...rowBorders ? { borders: rowBorders } : {}
115132
115238
  } : rowHeight ? { rowHeight } : undefined;
115133
115239
  return {
115134
115240
  id: context.nextBlockId(`row-${rowIndex}`),
@@ -115445,12 +115551,12 @@ var isRegExp = (value) => {
115445
115551
  state.kern = kernNode.attributes["w:val"];
115446
115552
  }
115447
115553
  }, SuperConverter;
115448
- var init_SuperConverter_B9mZiCO9_es = __esm(() => {
115554
+ var init_SuperConverter_7JlFliK8_es = __esm(() => {
115449
115555
  init_rolldown_runtime_Bg48TavK_es();
115450
115556
  init_jszip_C49i9kUs_es();
115451
115557
  init_xml_js_CqGKpaft_es();
115452
115558
  init_uuid_qzgm05fK_es();
115453
- init_constants_D_X7xF4s_es();
115559
+ init_constants_D9qj59G2_es();
115454
115560
  init_dist_B8HfvhaK_es();
115455
115561
  init_unified_Dsuw2be5_es();
115456
115562
  init_lib_CYqLdG4z_es();
@@ -154480,7 +154586,7 @@ var init_SuperConverter_B9mZiCO9_es = __esm(() => {
154480
154586
  };
154481
154587
  });
154482
154588
 
154483
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-pn-wKqsL.es.js
154589
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-ByZquSqc.es.js
154484
154590
  function parseSizeUnit(val = "0") {
154485
154591
  const length = val.toString() || "0";
154486
154592
  const value = Number.parseFloat(length);
@@ -164813,10 +164919,10 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
164813
164919
  }
164814
164920
  };
164815
164921
  };
164816
- var init_create_headless_toolbar_pn_wKqsL_es = __esm(() => {
164817
- init_SuperConverter_B9mZiCO9_es();
164922
+ var init_create_headless_toolbar_ByZquSqc_es = __esm(() => {
164923
+ init_SuperConverter_7JlFliK8_es();
164818
164924
  init_uuid_qzgm05fK_es();
164819
- init_constants_D_X7xF4s_es();
164925
+ init_constants_D9qj59G2_es();
164820
164926
  init_dist_B8HfvhaK_es();
164821
164927
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
164822
164928
  DOM_SIZE_UNITS = [
@@ -166713,7 +166819,7 @@ var init_decrypt_docx_G2a7hkiV_es = __esm(() => {
166713
166819
  ]);
166714
166820
  });
166715
166821
 
166716
- // ../../packages/superdoc/dist/chunks/DocxZipper-VodIk8WL.es.js
166822
+ // ../../packages/superdoc/dist/chunks/DocxZipper-Bu2Fhqkw.es.js
166717
166823
  function sniffEncoding(u8) {
166718
166824
  if (u8.length >= 2) {
166719
166825
  const b0 = u8[0], b1 = u8[1];
@@ -167386,11 +167492,11 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
167386
167492
  return `image/${MIME_TYPE_FOR_EXT[detectedType] || detectedType}`;
167387
167493
  }
167388
167494
  }, DocxZipper_default;
167389
- var init_DocxZipper_VodIk8WL_es = __esm(() => {
167495
+ var init_DocxZipper_Bu2Fhqkw_es = __esm(() => {
167390
167496
  init_rolldown_runtime_Bg48TavK_es();
167391
167497
  init_jszip_C49i9kUs_es();
167392
167498
  init_xml_js_CqGKpaft_es();
167393
- init_constants_D_X7xF4s_es();
167499
+ init_constants_D9qj59G2_es();
167394
167500
  init_dist_B8HfvhaK_es();
167395
167501
  MANAGED_PACKAGE_PARTS = [
167396
167502
  {
@@ -219498,7 +219604,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
219498
219604
  init_remark_gfm_BhnWr3yf_es();
219499
219605
  });
219500
219606
 
219501
- // ../../packages/superdoc/dist/chunks/src-DvgAvHbj.es.js
219607
+ // ../../packages/superdoc/dist/chunks/src-BjC0MGkm.es.js
219502
219608
  function deleteProps(obj, propOrProps) {
219503
219609
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
219504
219610
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -259649,6 +259755,9 @@ function isSettled(status) {
259649
259755
  function normalizeFamilyKey$2(family$1) {
259650
259756
  return family$1.trim().replace(/^["']|["']$/g, "").toLowerCase();
259651
259757
  }
259758
+ function stripFamilyQuotes(family$1) {
259759
+ return family$1.trim().replace(/^["']|["']$/g, "");
259760
+ }
259652
259761
  function splitStack(cssFontFamily) {
259653
259762
  return cssFontFamily.split(",").map((part) => part.trim()).filter(Boolean);
259654
259763
  }
@@ -261258,7 +261367,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
261258
261367
  let currentPageWidth = pageWidth;
261259
261368
  let marginLeft = Math.max(0, currentMargins?.left ?? 0);
261260
261369
  return {
261261
- registerDrawing(drawingBlock, measure, anchorY, columnIndex, pageNumber) {
261370
+ registerDrawing(drawingBlock, measure, resolvedAnchorY, columnIndex, pageNumber) {
261262
261371
  if (!drawingBlock.anchor?.isAnchored)
261263
261372
  return;
261264
261373
  const { wrap: wrap4, anchor } = drawingBlock;
@@ -261268,14 +261377,13 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
261268
261377
  const objectWidth = measure.width ?? 0;
261269
261378
  const objectHeight = measure.height ?? 0;
261270
261379
  const x = computeAnchorX(anchor, columnIndex, currentColumns, objectWidth, currentMargins, currentPageWidth);
261271
- const y$1 = anchorY + (anchor.offsetV ?? 0);
261272
261380
  const zone = {
261273
261381
  imageBlockId: drawingBlock.id,
261274
261382
  pageNumber,
261275
261383
  columnIndex,
261276
261384
  bounds: {
261277
261385
  x,
261278
- y: y$1,
261386
+ y: resolvedAnchorY,
261279
261387
  width: objectWidth,
261280
261388
  height: objectHeight
261281
261389
  },
@@ -261290,7 +261398,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
261290
261398
  };
261291
261399
  zones.push(zone);
261292
261400
  },
261293
- registerTable(tableBlock, measure, anchorY, columnIndex, pageNumber) {
261401
+ registerTable(tableBlock, measure, resolvedAnchorY, columnIndex, pageNumber) {
261294
261402
  if (!tableBlock.anchor?.isAnchored)
261295
261403
  return;
261296
261404
  const { wrap: wrap4, anchor } = tableBlock;
@@ -261299,14 +261407,13 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
261299
261407
  const tableWidth = measure.totalWidth ?? 0;
261300
261408
  const tableHeight = measure.totalHeight ?? 0;
261301
261409
  const x = computeTableAnchorX(anchor, columnIndex, currentColumns, tableWidth, currentMargins, currentPageWidth);
261302
- const y$1 = anchorY + (anchor.offsetV ?? 0);
261303
261410
  const zone = {
261304
261411
  imageBlockId: tableBlock.id,
261305
261412
  pageNumber,
261306
261413
  columnIndex,
261307
261414
  bounds: {
261308
261415
  x,
261309
- y: y$1,
261416
+ y: resolvedAnchorY,
261310
261417
  width: tableWidth,
261311
261418
  height: tableHeight
261312
261419
  },
@@ -261360,12 +261467,12 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
261360
261467
  rightFloats.push(zone);
261361
261468
  let leftBoundary = 0;
261362
261469
  for (const zone of leftFloats) {
261363
- const boundary = zone.bounds.x + zone.bounds.width + zone.distances.left + zone.distances.right;
261470
+ const boundary = zone.bounds.x + zone.bounds.width + zone.distances.right;
261364
261471
  leftBoundary = Math.max(leftBoundary, boundary);
261365
261472
  }
261366
261473
  let rightBoundary = columnOrigin + baseWidth;
261367
261474
  for (const zone of rightFloats) {
261368
- const boundary = zone.bounds.x - zone.distances.left - zone.distances.right;
261475
+ const boundary = zone.bounds.x - zone.distances.left;
261369
261476
  rightBoundary = Math.min(rightBoundary, boundary);
261370
261477
  }
261371
261478
  const availableWidth = rightBoundary - leftBoundary;
@@ -261395,27 +261502,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
261395
261502
  };
261396
261503
  }
261397
261504
  function computeAnchorX(anchor, columnIndex, columns, imageWidth, margins, pageWidth) {
261398
- const alignH = anchor.alignH ?? "left";
261399
- const offsetH = anchor.offsetH ?? 0;
261400
- const marginLeft = Math.max(0, margins?.left ?? 0);
261401
- const marginRight = Math.max(0, margins?.right ?? 0);
261402
- const contentWidth = pageWidth != null ? Math.max(1, pageWidth - (marginLeft + marginRight)) : columns.width;
261403
- const contentLeft = marginLeft;
261404
- const columnLeft = contentLeft + columnIndex * (columns.width + columns.gap);
261405
- const relativeFrom = anchor.hRelativeFrom ?? "column";
261406
- let baseX;
261407
- let availableWidth;
261408
- if (relativeFrom === "page") {
261409
- baseX = 0;
261410
- availableWidth = pageWidth != null ? pageWidth : contentWidth + marginLeft + marginRight;
261411
- } else if (relativeFrom === "margin") {
261412
- baseX = contentLeft;
261413
- availableWidth = contentWidth;
261414
- } else {
261415
- baseX = columnLeft;
261416
- availableWidth = columns.width;
261417
- }
261418
- return alignH === "left" ? baseX + offsetH : alignH === "right" ? baseX + availableWidth - imageWidth - offsetH : alignH === "center" ? baseX + (availableWidth - imageWidth) / 2 + offsetH : baseX;
261505
+ return resolveAnchoredGraphicX(anchor, columnIndex, columns, imageWidth, margins, pageWidth);
261419
261506
  }
261420
261507
  function computeWrapMode(wrap4, _anchor) {
261421
261508
  if (!wrap4)
@@ -261750,6 +261837,30 @@ function normalizeLines(measure) {
261750
261837
  function shouldSuppressOwnSpacing(ownStyleId, ownContextualSpacing, adjacentStyleId) {
261751
261838
  return ownContextualSpacing && !!ownStyleId && !!adjacentStyleId && ownStyleId === adjacentStyleId;
261752
261839
  }
261840
+ function collapseSpacingBefore(spacingBefore, trailingSpacing) {
261841
+ const prevTrailing = trailingSpacing ?? 0;
261842
+ return Math.max(spacingBefore - prevTrailing, 0);
261843
+ }
261844
+ function rewindPreviousParagraphTrailing(cursorY, trailingSpacing) {
261845
+ const prevTrailing = trailingSpacing ?? 0;
261846
+ return prevTrailing > 0 ? cursorY - prevTrailing : cursorY;
261847
+ }
261848
+ function computeParagraphContentStartY(cursorY, spacingBefore, appliedSpacingBefore, trailingSpacing) {
261849
+ if (appliedSpacingBefore || spacingBefore <= 0)
261850
+ return cursorY;
261851
+ return cursorY + collapseSpacingBefore(spacingBefore, trailingSpacing);
261852
+ }
261853
+ function computeParagraphLayoutStartY(input2) {
261854
+ let y$1 = input2.cursorY;
261855
+ let trailingForCollapse = input2.trailingSpacing;
261856
+ if (input2.rewindTrailingFromPrevious) {
261857
+ y$1 = rewindPreviousParagraphTrailing(y$1, input2.trailingSpacing);
261858
+ if ((input2.trailingSpacing ?? 0) > 0)
261859
+ trailingForCollapse = 0;
261860
+ }
261861
+ const effectiveSpacingBefore = input2.suppressSpacingBefore ? 0 : input2.spacingBefore;
261862
+ return computeParagraphContentStartY(y$1, effectiveSpacingBefore, effectiveSpacingBefore === 0, trailingForCollapse);
261863
+ }
261753
261864
  function calculateFirstLineIndent(block, measure) {
261754
261865
  const wordLayout = block.attrs?.wordLayout;
261755
261866
  if (!wordLayout?.firstLineIndentMode)
@@ -261765,52 +261876,75 @@ function layoutParagraphBlock(ctx$1, anchors) {
261765
261876
  const { block, measure, columnWidth, ensurePage, advanceColumn, columnX, floatManager } = ctx$1;
261766
261877
  const remeasureParagraph$1 = ctx$1.remeasureParagraph;
261767
261878
  const frame = getParagraphAttrs(block)?.frame;
261768
- if (anchors?.anchoredDrawings?.length)
261879
+ let lines = normalizeLines(measure);
261880
+ const measurementWidth = lines[0]?.maxWidth;
261881
+ const paraIndent = block.attrs?.indent;
261882
+ const indentLeft = typeof paraIndent?.left === "number" && Number.isFinite(paraIndent.left) ? paraIndent.left : 0;
261883
+ const indentRight = typeof paraIndent?.right === "number" && Number.isFinite(paraIndent.right) ? paraIndent.right : 0;
261884
+ const negativeLeftIndent = indentLeft < 0 ? indentLeft : 0;
261885
+ const negativeRightIndent = indentRight < 0 ? indentRight : 0;
261886
+ const remeasureWidth = Math.max(1, columnWidth - indentLeft - indentRight);
261887
+ let didRemeasureForColumnWidth = false;
261888
+ let remeasuredMarkerInfo;
261889
+ if (typeof remeasureParagraph$1 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
261890
+ const newMeasure = remeasureParagraph$1(block, columnWidth, calculateFirstLineIndent(block, measure));
261891
+ lines = normalizeLines(newMeasure);
261892
+ didRemeasureForColumnWidth = true;
261893
+ if (newMeasure.marker)
261894
+ remeasuredMarkerInfo = newMeasure.marker;
261895
+ }
261896
+ let fromLine = 0;
261897
+ const attrs = getParagraphAttrs(block);
261898
+ const spacing = attrs?.spacing ?? {};
261899
+ const spacingExplicit = attrs?.spacingExplicit;
261900
+ const styleId$1 = asString2(attrs?.styleId);
261901
+ const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
261902
+ let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
261903
+ let spacingAfter = ctx$1.overrideSpacingAfter ?? Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
261904
+ if (isEmptyTextParagraph(block) && spacingExplicit) {
261905
+ if (!spacingExplicit.before)
261906
+ spacingBefore = 0;
261907
+ if (!spacingExplicit.after)
261908
+ spacingAfter = 0;
261909
+ }
261910
+ const baseSpacingBefore = spacingBefore;
261911
+ let appliedSpacingBefore = spacingBefore === 0;
261912
+ let lastState = null;
261913
+ const previewState = ensurePage();
261914
+ const rawBorderExpansion = computeBorderVerticalExpansion(attrs?.borders);
261915
+ const currentBorderHash = hashBorders(attrs?.borders);
261916
+ const inBorderGroup = currentBorderHash != null && currentBorderHash === previewState.lastParagraphBorderHash;
261917
+ const borderExpansion = {
261918
+ top: inBorderGroup ? 0 : rawBorderExpansion.top,
261919
+ bottom: rawBorderExpansion.bottom
261920
+ };
261921
+ const paragraphAnchorBaseY = computeParagraphLayoutStartY({
261922
+ cursorY: previewState.cursorY,
261923
+ spacingBefore,
261924
+ trailingSpacing: previewState.trailingSpacing,
261925
+ suppressSpacingBefore: shouldSuppressOwnSpacing(styleId$1, contextualSpacing, previewState.lastParagraphStyleId),
261926
+ rewindTrailingFromPrevious: shouldSuppressOwnSpacing(previewState.lastParagraphStyleId, previewState.lastParagraphContextualSpacing, styleId$1)
261927
+ }) + borderExpansion.top - (inBorderGroup ? rawBorderExpansion.bottom : 0);
261928
+ const registerAnchoredDrawingsAt = (paragraphContentStartY) => {
261929
+ if (!anchors?.anchoredDrawings?.length)
261930
+ return;
261769
261931
  for (const entry of anchors.anchoredDrawings) {
261770
261932
  if (anchors.placedAnchoredIds.has(entry.block.id))
261771
261933
  continue;
261772
261934
  const state = ensurePage();
261773
- const vRelativeFrom = entry.block.anchor?.vRelativeFrom;
261774
- const alignV = entry.block.anchor?.alignV;
261775
- const offsetV = entry.block.anchor?.offsetV ?? 0;
261776
- const imageHeight = entry.measure.height;
261777
261935
  const contentTop = state.topMargin;
261778
261936
  const contentBottom = state.contentBottom;
261779
- const contentHeight = Math.max(0, contentBottom - contentTop);
261780
- let anchorY;
261781
- if (vRelativeFrom === "margin")
261782
- if (alignV === "top")
261783
- anchorY = contentTop + offsetV;
261784
- else if (alignV === "bottom")
261785
- anchorY = contentBottom - imageHeight + offsetV;
261786
- else if (alignV === "center")
261787
- anchorY = contentTop + (contentHeight - imageHeight) / 2 + offsetV;
261788
- else
261789
- anchorY = contentTop + offsetV;
261790
- else if (vRelativeFrom === "page")
261791
- if (alignV === "top")
261792
- anchorY = offsetV;
261793
- else if (alignV === "bottom")
261794
- anchorY = contentBottom + (anchors.pageMargins.bottom ?? 0) - imageHeight + offsetV;
261795
- else if (alignV === "center")
261796
- anchorY = (contentBottom + (anchors.pageMargins.bottom ?? 0) - imageHeight) / 2 + offsetV;
261797
- else
261798
- anchorY = offsetV;
261799
- else if (vRelativeFrom === "paragraph") {
261800
- const baseAnchorY = state.cursorY;
261801
- const firstLineHeight = measure.lines?.[0]?.lineHeight ?? 0;
261802
- if (alignV === "top")
261803
- anchorY = baseAnchorY + offsetV;
261804
- else if (alignV === "bottom")
261805
- anchorY = baseAnchorY + firstLineHeight - imageHeight + offsetV;
261806
- else if (alignV === "center")
261807
- anchorY = baseAnchorY + (firstLineHeight - imageHeight) / 2 + offsetV;
261808
- else
261809
- anchorY = baseAnchorY + offsetV;
261810
- } else
261811
- anchorY = state.cursorY + offsetV;
261937
+ const anchorY = resolveAnchoredGraphicY({
261938
+ anchor: entry.block.anchor,
261939
+ objectHeight: entry.measure.height,
261940
+ contentTop,
261941
+ contentBottom,
261942
+ pageBottomMargin: anchors.pageMargins.bottom ?? 0,
261943
+ anchorParagraphY: paragraphContentStartY,
261944
+ firstLineHeight: measure.lines?.[0]?.lineHeight ?? 0
261945
+ });
261812
261946
  floatManager.registerDrawing(entry.block, entry.measure, anchorY, state.columnIndex, state.page.number);
261813
- const anchorX = entry.block.anchor ? computeAnchorX(entry.block.anchor, state.columnIndex, anchors.columns, entry.measure.width, {
261947
+ const anchorX = entry.block.anchor ? resolveAnchoredGraphicX(entry.block.anchor, state.columnIndex, anchors.columns, entry.measure.width, {
261814
261948
  left: anchors.pageMargins.left,
261815
261949
  right: anchors.pageMargins.right
261816
261950
  }, anchors.pageWidth) : columnX(state.columnIndex);
@@ -261882,40 +262016,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
261882
262016
  }
261883
262017
  anchors.placedAnchoredIds.add(entry.block.id);
261884
262018
  }
261885
- let lines = normalizeLines(measure);
261886
- const measurementWidth = lines[0]?.maxWidth;
261887
- const paraIndent = block.attrs?.indent;
261888
- const indentLeft = typeof paraIndent?.left === "number" && Number.isFinite(paraIndent.left) ? paraIndent.left : 0;
261889
- const indentRight = typeof paraIndent?.right === "number" && Number.isFinite(paraIndent.right) ? paraIndent.right : 0;
261890
- const negativeLeftIndent = indentLeft < 0 ? indentLeft : 0;
261891
- const negativeRightIndent = indentRight < 0 ? indentRight : 0;
261892
- const remeasureWidth = Math.max(1, columnWidth - indentLeft - indentRight);
261893
- let didRemeasureForColumnWidth = false;
261894
- let remeasuredMarkerInfo;
261895
- if (typeof remeasureParagraph$1 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
261896
- const newMeasure = remeasureParagraph$1(block, columnWidth, calculateFirstLineIndent(block, measure));
261897
- lines = normalizeLines(newMeasure);
261898
- didRemeasureForColumnWidth = true;
261899
- if (newMeasure.marker)
261900
- remeasuredMarkerInfo = newMeasure.marker;
261901
- }
261902
- let fromLine = 0;
261903
- const attrs = getParagraphAttrs(block);
261904
- const spacing = attrs?.spacing ?? {};
261905
- const spacingExplicit = attrs?.spacingExplicit;
261906
- const styleId$1 = asString2(attrs?.styleId);
261907
- const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
261908
- let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
261909
- let spacingAfter = ctx$1.overrideSpacingAfter ?? Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
261910
- if (isEmptyTextParagraph(block) && spacingExplicit) {
261911
- if (!spacingExplicit.before)
261912
- spacingBefore = 0;
261913
- if (!spacingExplicit.after)
261914
- spacingAfter = 0;
261915
- }
261916
- const baseSpacingBefore = spacingBefore;
261917
- let appliedSpacingBefore = spacingBefore === 0;
261918
- let lastState = null;
262019
+ };
262020
+ registerAnchoredDrawingsAt(paragraphAnchorBaseY);
261919
262021
  if (frame?.wrap === "none") {
261920
262022
  let state = ensurePage();
261921
262023
  if (state.cursorY >= state.contentBottom)
@@ -261957,12 +262059,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
261957
262059
  let didRemeasureForFloats = false;
261958
262060
  if (typeof remeasureParagraph$1 === "function") {
261959
262061
  const tempState = ensurePage();
261960
- let tempY = tempState.cursorY;
261961
- if (!appliedSpacingBefore && spacingBefore > 0) {
261962
- const prevTrailing = tempState.trailingSpacing ?? 0;
261963
- const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
261964
- tempY += neededSpacingBefore;
261965
- }
262062
+ let tempY = paragraphAnchorBaseY;
261966
262063
  for (let i4 = 0;i4 < lines.length; i4++) {
261967
262064
  const lineY = tempY;
261968
262065
  const lineHeight = lines[i4]?.lineHeight || 0;
@@ -261973,8 +262070,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
261973
262070
  }
261974
262071
  tempY += lineHeight;
261975
262072
  }
261976
- const narrowestRemeasureWidth = Math.max(1, narrowestWidth - indentLeft - indentRight);
261977
- if (narrowestRemeasureWidth < remeasureWidth) {
262073
+ const narrowestRemeasureWidth = narrowestWidth < columnWidth || narrowestOffsetX > 0 ? Math.max(1, narrowestWidth - Math.max(indentLeft, 0) - Math.max(indentRight, 0)) : Math.max(1, narrowestWidth - indentLeft - indentRight);
262074
+ if (narrowestRemeasureWidth < remeasureWidth || narrowestOffsetX > 0) {
261978
262075
  const newMeasure = remeasureParagraph$1(block, narrowestRemeasureWidth, calculateFirstLineIndent(block, measure));
261979
262076
  lines = normalizeLines(newMeasure);
261980
262077
  didRemeasureForFloats = true;
@@ -261982,13 +262079,6 @@ function layoutParagraphBlock(ctx$1, anchors) {
261982
262079
  remeasuredMarkerInfo = newMeasure.marker;
261983
262080
  }
261984
262081
  }
261985
- const rawBorderExpansion = computeBorderVerticalExpansion(attrs?.borders);
261986
- const currentBorderHash = hashBorders(attrs?.borders);
261987
- const inBorderGroup = currentBorderHash != null && currentBorderHash === ensurePage().lastParagraphBorderHash;
261988
- const borderExpansion = {
261989
- top: inBorderGroup ? 0 : rawBorderExpansion.top,
261990
- bottom: rawBorderExpansion.bottom
261991
- };
261992
262082
  while (fromLine < lines.length) {
261993
262083
  let state = ensurePage();
261994
262084
  if (state.trailingSpacing == null)
@@ -262000,13 +262090,12 @@ function layoutParagraphBlock(ctx$1, anchors) {
262000
262090
  if (shouldSuppressOwnSpacing(state.lastParagraphStyleId, state.lastParagraphContextualSpacing, styleId$1)) {
262001
262091
  const prevTrailing = asSafeNumber(state.trailingSpacing);
262002
262092
  if (prevTrailing > 0) {
262003
- state.cursorY -= prevTrailing;
262093
+ state.cursorY = rewindPreviousParagraphTrailing(state.cursorY, prevTrailing);
262004
262094
  state.trailingSpacing = 0;
262005
262095
  }
262006
262096
  }
262007
262097
  if (attrs?.keepLines === true && fromLine === 0) {
262008
- const prevTrailing = state.trailingSpacing ?? 0;
262009
- const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
262098
+ const neededSpacingBefore = collapseSpacingBefore(spacingBefore, state.trailingSpacing);
262010
262099
  const pageContentHeight = state.contentBottom - state.topMargin;
262011
262100
  const fullHeight = lines.reduce((sum, line) => sum + (line.lineHeight || 0), 0) + borderExpansion.top + borderExpansion.bottom;
262012
262101
  const fitsOnBlankPage = fullHeight + baseSpacingBefore <= pageContentHeight;
@@ -262020,8 +262109,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
262020
262109
  }
262021
262110
  if (!appliedSpacingBefore && spacingBefore > 0)
262022
262111
  while (!appliedSpacingBefore) {
262023
- const prevTrailing = state.trailingSpacing ?? 0;
262024
- const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
262112
+ state.trailingSpacing;
262113
+ const neededSpacingBefore = collapseSpacingBefore(spacingBefore, state.trailingSpacing);
262025
262114
  if (state.cursorY + neededSpacingBefore > state.contentBottom) {
262026
262115
  if (state.cursorY <= state.topMargin) {
262027
262116
  state.trailingSpacing = 0;
@@ -262143,8 +262232,12 @@ function layoutParagraphBlock(ctx$1, anchors) {
262143
262232
  state.footnoteAnchorsThisPage.push(a2);
262144
262233
  }
262145
262234
  }
262146
- const adjustedX = columnX(state.columnIndex) + offsetX + negativeLeftIndent;
262147
- const adjustedWidth = effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
262235
+ const floatAdjustedX = columnX(state.columnIndex) + offsetX;
262236
+ const adjustedX = didRemeasureForFloats ? floatAdjustedX + Math.max(negativeLeftIndent, 0) : floatAdjustedX + negativeLeftIndent;
262237
+ const columnRight = columnX(state.columnIndex) + columnWidth;
262238
+ let adjustedWidth = didRemeasureForFloats ? effectiveColumnWidth : effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
262239
+ if (didRemeasureForFloats)
262240
+ adjustedWidth = Math.min(adjustedWidth, Math.max(1, columnRight - adjustedX));
262148
262241
  const fragment = {
262149
262242
  kind: "para",
262150
262243
  blockId: block.id,
@@ -262156,7 +262249,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
262156
262249
  sourceAnchor: block.sourceAnchor,
262157
262250
  ...computeFragmentPmRange2(block, lines, fromLine, slice2.toLine)
262158
262251
  };
262159
- if (didRemeasureForColumnWidth)
262252
+ if (didRemeasureForColumnWidth || didRemeasureForFloats)
262160
262253
  fragment.lines = lines.slice(fromLine, slice2.toLine);
262161
262254
  if ((measure.marker || remeasuredMarkerInfo) && fromLine === 0) {
262162
262255
  fragment.markerWidth = (remeasuredMarkerInfo ?? measure.marker)?.markerWidth ?? measure.marker?.markerWidth ?? 0;
@@ -264007,13 +264100,19 @@ function getBalancingHeight(fragment, measureMap, sectPrMarkerBlockIds) {
264007
264100
  return 0;
264008
264101
  return getFragmentHeight(fragment, measureMap);
264009
264102
  }
264103
+ function allColumnWidthsEqual(widths) {
264104
+ if (widths.length <= 1)
264105
+ return true;
264106
+ const first$1 = widths[0];
264107
+ return widths.every((w) => Math.abs(w - first$1) <= 0.5);
264108
+ }
264010
264109
  function balanceSectionOnPage(args$1) {
264011
264110
  const { sectionColumns, sectionHasExplicitColumnBreak, sectionIndex, blockSectionMap, fragments } = args$1;
264012
264111
  if (sectionColumns.count <= 1)
264013
264112
  return null;
264014
264113
  if (sectionHasExplicitColumnBreak)
264015
264114
  return null;
264016
- if (sectionColumns.equalWidth === false && Array.isArray(sectionColumns.widths) && sectionColumns.widths.length > 0)
264115
+ if (sectionColumns.equalWidth === false && Array.isArray(sectionColumns.widths) && sectionColumns.widths.length > 0 && !allColumnWidthsEqual(sectionColumns.widths))
264017
264116
  return null;
264018
264117
  const sectionFragments = fragments.filter((f2) => blockSectionMap.get(f2.blockId) === sectionIndex);
264019
264118
  if (sectionFragments.length === 0)
@@ -264452,8 +264551,15 @@ function calculateChainHeight(chain, blocks2, measures, state) {
264452
264551
  const firstLineHeight = anchorMeasure.lines[0]?.lineHeight;
264453
264552
  const anchorHeight = typeof firstLineHeight === "number" && Number.isFinite(firstLineHeight) && firstLineHeight > 0 ? firstLineHeight : getMeasureHeight(anchorBlock, anchorMeasure);
264454
264553
  totalHeight += interParagraphSpacing + anchorHeight;
264455
- } else if (!(anchorBlock.kind === "table" && anchorBlock.anchor?.isAnchored === true))
264456
- totalHeight += prevSpacingAfter + getMeasureHeight(anchorBlock, anchorMeasure);
264554
+ } else if (!(anchorBlock.kind === "table" && anchorBlock.anchor?.isAnchored === true)) {
264555
+ let anchorHeight = getMeasureHeight(anchorBlock, anchorMeasure);
264556
+ if (anchorBlock.kind === "table" && anchorMeasure.kind === "table" && anchorMeasure.rows.length > 0) {
264557
+ const firstRowHeight = anchorMeasure.rows[0]?.height;
264558
+ if (typeof firstRowHeight === "number" && Number.isFinite(firstRowHeight) && firstRowHeight > 0)
264559
+ anchorHeight = firstRowHeight;
264560
+ }
264561
+ totalHeight += prevSpacingAfter + anchorHeight;
264562
+ }
264457
264563
  }
264458
264564
  }
264459
264565
  return totalHeight;
@@ -265266,58 +265372,28 @@ function layoutDocument(blocks2, measures, options = {}) {
265266
265372
  const resolveParagraphlessAnchoredTableY = (block, measure, state) => {
265267
265373
  const contentTop = state.topMargin;
265268
265374
  const contentBottom = state.contentBottom;
265269
- const contentHeight = Math.max(0, contentBottom - contentTop);
265270
265375
  const tableHeight = measure.totalHeight ?? 0;
265271
- const anchor = block.anchor;
265272
- const offsetV = anchor?.offsetV ?? 0;
265273
- const vRelativeFrom = anchor?.vRelativeFrom;
265274
- const alignV = anchor?.alignV;
265275
- if (vRelativeFrom === "margin") {
265276
- if (alignV === "bottom")
265277
- return contentBottom - tableHeight + offsetV;
265278
- if (alignV === "center")
265279
- return contentTop + (contentHeight - tableHeight) / 2 + offsetV;
265280
- return contentTop + offsetV;
265281
- }
265282
- if (vRelativeFrom === "page") {
265283
- if (alignV === "bottom")
265284
- return contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - tableHeight + offsetV;
265285
- if (alignV === "center")
265286
- return (contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - tableHeight) / 2 + offsetV;
265287
- return offsetV;
265288
- }
265289
- return contentTop + offsetV;
265376
+ return resolveAnchoredGraphicY({
265377
+ anchor: block.anchor,
265378
+ objectHeight: tableHeight,
265379
+ contentTop,
265380
+ contentBottom,
265381
+ pageBottomMargin: state.page.margins?.bottom ?? activeBottomMargin,
265382
+ preRegisteredFallbackToContentTop: true
265383
+ });
265290
265384
  };
265291
265385
  for (const entry of preRegisteredAnchors) {
265292
265386
  const state = paginator.ensurePage();
265293
- const vRelativeFrom = entry.block.anchor?.vRelativeFrom ?? "paragraph";
265294
- const alignV = entry.block.anchor?.alignV ?? "top";
265295
- const offsetV = entry.block.anchor?.offsetV ?? 0;
265296
- const imageHeight = entry.measure.height ?? 0;
265297
265387
  const contentTop = state.topMargin;
265298
265388
  const contentBottom = state.contentBottom;
265299
- const contentHeight = Math.max(0, contentBottom - contentTop);
265300
- let anchorY;
265301
- if (vRelativeFrom === "margin")
265302
- if (alignV === "top")
265303
- anchorY = contentTop + offsetV;
265304
- else if (alignV === "bottom")
265305
- anchorY = contentBottom - imageHeight + offsetV;
265306
- else if (alignV === "center")
265307
- anchorY = contentTop + (contentHeight - imageHeight) / 2 + offsetV;
265308
- else
265309
- anchorY = contentTop + offsetV;
265310
- else if (vRelativeFrom === "page")
265311
- if (alignV === "top")
265312
- anchorY = offsetV;
265313
- else if (alignV === "bottom")
265314
- anchorY = contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - imageHeight + offsetV;
265315
- else if (alignV === "center")
265316
- anchorY = (contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - imageHeight) / 2 + offsetV;
265317
- else
265318
- anchorY = offsetV;
265319
- else
265320
- anchorY = contentTop + offsetV;
265389
+ const anchorY = resolveAnchoredGraphicY({
265390
+ anchor: entry.block.anchor,
265391
+ objectHeight: entry.measure.height ?? 0,
265392
+ contentTop,
265393
+ contentBottom,
265394
+ pageBottomMargin: state.page.margins?.bottom ?? activeBottomMargin,
265395
+ preRegisteredFallbackToContentTop: true
265396
+ });
265321
265397
  const anchorX = entry.block.anchor ? computeAnchorX(entry.block.anchor, state.columnIndex, normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)), entry.measure.width, {
265322
265398
  left: activeLeftMargin,
265323
265399
  right: activeRightMargin
@@ -265628,7 +265704,6 @@ function layoutDocument(blocks2, measures, options = {}) {
265628
265704
  overrideSpacingAfter = 0;
265629
265705
  }
265630
265706
  }
265631
- const paragraphStartY = paginator.ensurePage().cursorY;
265632
265707
  layoutParagraphBlock({
265633
265708
  block,
265634
265709
  measure,
@@ -265658,7 +265733,12 @@ function layoutDocument(blocks2, measures, options = {}) {
265658
265733
  if (tablesForPara) {
265659
265734
  const state = paginator.ensurePage();
265660
265735
  const columnWidthForTable = getCurrentColumnWidth();
265736
+ let anchorParagraphTopY = state.cursorY;
265737
+ for (const fragment of state.page.fragments)
265738
+ if (fragment.kind === "para" && fragment.blockId === block.id)
265739
+ anchorParagraphTopY = Math.min(anchorParagraphTopY, fragment.y);
265661
265740
  let tableBottomY = state.cursorY;
265741
+ let nextStackY = state.cursorY;
265662
265742
  for (const { block: tableBlock, measure: tableMeasure } of tablesForPara) {
265663
265743
  if (placedAnchoredTableIds.has(tableBlock.id))
265664
265744
  continue;
@@ -265666,15 +265746,17 @@ function layoutDocument(blocks2, measures, options = {}) {
265666
265746
  if (columnWidthForTable > 0 && totalWidth >= columnWidthForTable * 0.99)
265667
265747
  continue;
265668
265748
  const offsetV = tableBlock.anchor?.offsetV ?? 0;
265669
- const anchorY = Math.max(paragraphStartY, state.cursorY) + offsetV;
265749
+ const anchorY = Math.max(anchorParagraphTopY, nextStackY) + offsetV;
265670
265750
  floatManager.registerTable(tableBlock, tableMeasure, anchorY, state.columnIndex, state.page.number);
265671
265751
  const tableFragment = createAnchoredTableFragment(tableBlock, tableMeasure, tableBlock.anchor?.offsetH ?? columnX(state.columnIndex), anchorY);
265672
265752
  state.page.fragments.push(tableFragment);
265673
265753
  placedAnchoredTableIds.add(tableBlock.id);
265674
265754
  if ((tableBlock.wrap?.type ?? "None") !== "None") {
265675
265755
  const bottom$1 = anchorY + (tableMeasure.totalHeight ?? 0);
265756
+ const distBottom = tableBlock.wrap?.distBottom ?? 0;
265676
265757
  if (bottom$1 > tableBottomY)
265677
265758
  tableBottomY = bottom$1;
265759
+ nextStackY = bottom$1 + distBottom;
265678
265760
  }
265679
265761
  }
265680
265762
  state.cursorY = tableBottomY;
@@ -299314,6 +299396,45 @@ menclose::after {
299314
299396
  if (explicitSpec)
299315
299397
  return explicitSpec;
299316
299398
  return borderValueToSpec(fallback);
299399
+ }, BORDER_STYLE_NUMBER, BORDER_STYLE_LINES, isPresentBorder = (b$1) => !!b$1 && b$1.style !== undefined && b$1.style !== "none" && (b$1.width === undefined || b$1.width > 0), isExplicitNoneBorder = (b$1) => {
299400
+ if (!b$1 || typeof b$1 !== "object")
299401
+ return false;
299402
+ const r$1 = b$1;
299403
+ return r$1.style === "none" || r$1.none === true;
299404
+ }, borderWeight = (b$1) => (BORDER_STYLE_LINES[b$1.style] ?? 1) * (BORDER_STYLE_NUMBER[b$1.style] ?? 1), colorBrightness = (color2, formula) => {
299405
+ const hex3 = (color2 ?? "#000000").replace("#", "");
299406
+ if (hex3.length < 6)
299407
+ return 0;
299408
+ return formula(parseInt(hex3.slice(0, 2), 16), parseInt(hex3.slice(2, 4), 16), parseInt(hex3.slice(4, 6), 16));
299409
+ }, resolveBorderConflict = (a2, b$1) => {
299410
+ const pa = isPresentBorder(a2);
299411
+ const pb = isPresentBorder(b$1);
299412
+ if (!pa && !pb)
299413
+ return;
299414
+ if (!pa)
299415
+ return b$1;
299416
+ if (!pb)
299417
+ return a2;
299418
+ const wa = borderWeight(a2);
299419
+ const wb = borderWeight(b$1);
299420
+ if (wa !== wb)
299421
+ return wa > wb ? a2 : b$1;
299422
+ const na = BORDER_STYLE_NUMBER[a2.style] ?? 99;
299423
+ const nb = BORDER_STYLE_NUMBER[b$1.style] ?? 99;
299424
+ if (na !== nb)
299425
+ return na < nb ? a2 : b$1;
299426
+ const formulas = [
299427
+ (r$1, g$1, bl) => r$1 + bl + 2 * g$1,
299428
+ (_r, g$1, bl) => bl + 2 * g$1,
299429
+ (_r, g$1) => g$1
299430
+ ];
299431
+ for (const f2 of formulas) {
299432
+ const ba = colorBrightness(a2.color, f2);
299433
+ const bb = colorBrightness(b$1.color, f2);
299434
+ if (ba !== bb)
299435
+ return ba < bb ? a2 : b$1;
299436
+ }
299437
+ return a2;
299317
299438
  }, hasExplicitCellBorders = (cellBorders) => Boolean(cellBorders && (cellBorders.top !== undefined || cellBorders.right !== undefined || cellBorders.bottom !== undefined || cellBorders.left !== undefined)), resolveTableCellBorders = (tableBorders, cellPosition) => {
299318
299439
  const cellBounds = getTableCellGridBounds(cellPosition);
299319
299440
  return {
@@ -299393,7 +299514,7 @@ menclose::after {
299393
299514
  return;
299394
299515
  if (this.#overrides.get(key2) === physical)
299395
299516
  return;
299396
- if ((BUNDLED_SUBSTITUTES[key2] ?? logicalFamily.trim()) === physical) {
299517
+ if (key2 === normalizeFamilyKey$2(physical)) {
299397
299518
  if (this.#overrides.delete(key2)) {
299398
299519
  this.#version += 1;
299399
299520
  this.#cachedSignature = null;
@@ -299445,12 +299566,41 @@ menclose::after {
299445
299566
  reason: "as_requested"
299446
299567
  };
299447
299568
  }
299569
+ #resolveFaceLadder(primary, face, hasFace) {
299570
+ const key2 = normalizeFamilyKey$2(primary);
299571
+ const override = this.#overrides.get(key2);
299572
+ if (override && hasFace(override, face.weight, face.style))
299573
+ return {
299574
+ physical: override,
299575
+ reason: "custom_mapping"
299576
+ };
299577
+ if (hasFace(primary, face.weight, face.style))
299578
+ return {
299579
+ physical: primary,
299580
+ reason: "registered_face"
299581
+ };
299582
+ const bundled = BUNDLED_SUBSTITUTES[key2];
299583
+ if (bundled && hasFace(bundled, face.weight, face.style))
299584
+ return {
299585
+ physical: bundled,
299586
+ reason: "bundled_substitute"
299587
+ };
299588
+ if (override || bundled)
299589
+ return {
299590
+ physical: primary,
299591
+ reason: "fallback_face_absent"
299592
+ };
299593
+ return {
299594
+ physical: primary,
299595
+ reason: "as_requested"
299596
+ };
299597
+ }
299448
299598
  resolveFontFamily(logicalFamily) {
299449
299599
  const primary = splitStack(logicalFamily)[0] ?? logicalFamily;
299450
299600
  const { physical, reason } = this.#physicalFor(primary);
299451
299601
  return {
299452
299602
  logicalFamily,
299453
- physicalFamily: physical,
299603
+ physicalFamily: stripFamilyQuotes(physical),
299454
299604
  reason
299455
299605
  };
299456
299606
  }
@@ -299467,23 +299617,11 @@ menclose::after {
299467
299617
  }
299468
299618
  resolveFace(logicalFamily, face, hasFace) {
299469
299619
  const primary = splitStack(logicalFamily)[0] ?? logicalFamily;
299470
- const { physical, reason } = this.#physicalFor(primary);
299471
- if (reason === "as_requested")
299472
- return {
299473
- logicalFamily,
299474
- physicalFamily: physical,
299475
- reason
299476
- };
299477
- if (hasFace(physical, face.weight, face.style))
299478
- return {
299479
- logicalFamily,
299480
- physicalFamily: physical,
299481
- reason
299482
- };
299620
+ const { physical, reason } = this.#resolveFaceLadder(primary, face, hasFace);
299483
299621
  return {
299484
299622
  logicalFamily,
299485
- physicalFamily: primary,
299486
- reason: "fallback_face_absent"
299623
+ physicalFamily: stripFamilyQuotes(physical),
299624
+ reason
299487
299625
  };
299488
299626
  }
299489
299627
  resolvePhysicalFamilyForFace(cssFontFamily, face, hasFace) {
@@ -299492,12 +299630,10 @@ menclose::after {
299492
299630
  const parts = splitStack(cssFontFamily);
299493
299631
  if (parts.length === 0)
299494
299632
  return cssFontFamily;
299495
- const { physical, reason } = this.#physicalFor(parts[0]);
299496
- if (reason === "as_requested")
299497
- return cssFontFamily;
299498
- if (!hasFace(physical, face.weight, face.style))
299499
- return cssFontFamily;
299500
- return [physical, ...parts.slice(1)].join(", ");
299633
+ const { physical, reason } = this.#resolveFaceLadder(parts[0], face, hasFace);
299634
+ if (reason === "custom_mapping" || reason === "bundled_substitute")
299635
+ return [physical, ...parts.slice(1)].join(", ");
299636
+ return cssFontFamily;
299501
299637
  }
299502
299638
  resolvePrimaryPhysicalFamily(family$1) {
299503
299639
  const primary = splitStack(family$1)[0] ?? family$1;
@@ -299525,6 +299661,7 @@ menclose::after {
299525
299661
  #faceInflight = /* @__PURE__ */ new Map;
299526
299662
  #faceSources = /* @__PURE__ */ new Map;
299527
299663
  #facesByFamily = /* @__PURE__ */ new Map;
299664
+ #providerFaceKeys = /* @__PURE__ */ new Set;
299528
299665
  #warnedFaceFailures = /* @__PURE__ */ new Set;
299529
299666
  constructor(options = {}) {
299530
299667
  this.#fontSet = options.fontSet ?? null;
@@ -299536,7 +299673,9 @@ menclose::after {
299536
299673
  register(descriptor) {
299537
299674
  const { family: family$1, source, descriptors: descriptors2 } = descriptor;
299538
299675
  const identitySource = typeof source === "string" ? canonicalizeFontSource(source) : source;
299539
- const key2 = faceKeyOf$1(family$1, normalizeWeight(descriptors2?.weight), normalizeStyle$1(descriptors2?.style));
299676
+ const weight = normalizeWeight(descriptors2?.weight);
299677
+ const style2 = normalizeStyle$1(descriptors2?.style);
299678
+ const key2 = faceKeyOf$1(family$1, weight, style2);
299540
299679
  if (typeof identitySource === "string") {
299541
299680
  const existingSource = this.#faceSources.get(key2);
299542
299681
  if (existingSource === identitySource)
@@ -299549,7 +299688,11 @@ menclose::after {
299549
299688
  throw new Error(`[superdoc] font face "${key2}" is already registered from a different source ("${existingSource}"); a registered face's source cannot be replaced`);
299550
299689
  }
299551
299690
  if (this.#FontFaceCtor && this.#fontSet) {
299552
- const face = new this.#FontFaceCtor(family$1, source, descriptors2);
299691
+ const face = new this.#FontFaceCtor(family$1, source, {
299692
+ ...descriptors2,
299693
+ weight,
299694
+ style: style2
299695
+ });
299553
299696
  this.#fontSet.add(face);
299554
299697
  this.#managed.set(family$1, face);
299555
299698
  }
@@ -299561,6 +299704,7 @@ menclose::after {
299561
299704
  }
299562
299705
  if (!this.#status.has(family$1))
299563
299706
  this.#status.set(family$1, "unloaded");
299707
+ this.#providerFaceKeys.add(key2);
299564
299708
  this.#trackFace(family$1, key2);
299565
299709
  if (!this.#faceStatus.has(key2))
299566
299710
  this.#faceStatus.set(key2, "unloaded");
@@ -299605,7 +299749,8 @@ menclose::after {
299605
299749
  return "unloaded";
299606
299750
  }
299607
299751
  hasFace(family$1, weight, style2) {
299608
- return this.#facesByFamily.get(normalizeFamilyKey$1(family$1))?.has(faceKeyOf$1(family$1, weight, style2)) ?? false;
299752
+ const key2 = faceKeyOf$1(family$1, weight, style2);
299753
+ return this.#providerFaceKeys.has(key2) && this.#faceStatus.get(key2) !== "failed";
299609
299754
  }
299610
299755
  isAvailable(family$1) {
299611
299756
  if (!this.#fontSet)
@@ -301129,8 +301274,21 @@ menclose::after {
301129
301274
  }
301130
301275
  }
301131
301276
  return { cellElement: cellEl };
301132
- }, hasAnyResolvedBorder = (borders) => Boolean(borders.top || borders.right || borders.bottom || borders.left), resolveRenderedCellBorders = ({ cellBorders, hasBordersAttribute, tableBorders, cellPosition, cellSpacingPx, continuesFromPrev, continuesOnNext }) => {
301277
+ }, hasAnyResolvedBorder = (borders) => Boolean(borders.top || borders.right || borders.bottom || borders.left), resolveRenderedCellBorders = ({ cellBorders, hasBordersAttribute, tableBorders, cellPosition, cellSpacingPx, continuesFromPrev, continuesOnNext, aboveCellBorders, leftCellBorders, rightCellBorders, nextRowLeavesRightGap, deferTopToAboveCell, nextRowSuppressesSharedTop }) => {
301133
301278
  const hasExplicitBorders = hasExplicitCellBorders(cellBorders);
301279
+ const cellBounds = getTableCellGridBounds(cellPosition);
301280
+ const touchesTopBoundary = cellBounds.touchesTopEdge || continuesFromPrev;
301281
+ const touchesBottomBoundary = cellBounds.touchesBottomEdge || continuesOnNext || nextRowLeavesRightGap === true;
301282
+ const hasInteriorNeighborBorder = !touchesTopBoundary && !deferTopToAboveCell && isPresentBorder(aboveCellBorders?.bottom) || !cellBounds.touchesLeftEdge && isPresentBorder(leftCellBorders?.right);
301283
+ if (cellSpacingPx === 0 && (hasExplicitBorders || hasInteriorNeighborBorder)) {
301284
+ const cb = cellBorders ?? {};
301285
+ return {
301286
+ top: touchesTopBoundary ? resolveTableBorderValue(cb.top, tableBorders?.top) : deferTopToAboveCell ? undefined : resolveBorderConflict(cb.top, aboveCellBorders?.bottom) ?? (isExplicitNoneBorder(cb.top) && isExplicitNoneBorder(aboveCellBorders?.bottom) ? undefined : borderValueToSpec(tableBorders?.insideH)),
301287
+ left: cellBounds.touchesLeftEdge ? resolveTableBorderValue(cb.left, tableBorders?.left) : isPresentBorder(cb.left) ? resolveBorderConflict(cb.left, leftCellBorders?.right) ?? borderValueToSpec(tableBorders?.insideV) : isPresentBorder(leftCellBorders?.right) ? undefined : isExplicitNoneBorder(cb.left) && isExplicitNoneBorder(leftCellBorders?.right) ? undefined : borderValueToSpec(tableBorders?.insideV),
301288
+ right: cellBounds.touchesRightEdge ? resolveTableBorderValue(cb.right, tableBorders?.right) : isPresentBorder(cb.right) && !isPresentBorder(rightCellBorders?.left) ? cb.right : undefined,
301289
+ bottom: touchesBottomBoundary ? resolveTableBorderValue(cb.bottom, tableBorders?.bottom) : undefined
301290
+ };
301291
+ }
301134
301292
  if (hasBordersAttribute && !hasExplicitBorders)
301135
301293
  return;
301136
301294
  if (!tableBorders)
@@ -301140,24 +301298,13 @@ menclose::after {
301140
301298
  bottom: cellBorders.bottom,
301141
301299
  left: cellBorders.left
301142
301300
  } : undefined;
301143
- const cellBounds = getTableCellGridBounds(cellPosition);
301144
- const touchesTopBoundary = cellBounds.touchesTopEdge || continuesFromPrev;
301145
- const touchesBottomBoundary = cellBounds.touchesBottomEdge || continuesOnNext;
301146
- if (hasExplicitBorders) {
301147
- if (cellSpacingPx === 0)
301148
- return {
301149
- top: resolveTableBorderValue(cellBorders.top, touchesTopBoundary ? tableBorders.top : tableBorders.insideH),
301150
- right: cellBounds.touchesRightEdge ? resolveTableBorderValue(cellBorders.right, tableBorders.right) : undefined,
301151
- bottom: touchesBottomBoundary ? resolveTableBorderValue(cellBorders.bottom, tableBorders.bottom) : undefined,
301152
- left: resolveTableBorderValue(cellBorders.left, cellBounds.touchesLeftEdge ? tableBorders.left : tableBorders.insideV)
301153
- };
301301
+ if (hasExplicitBorders)
301154
301302
  return {
301155
301303
  top: resolveTableBorderValue(cellBorders.top, touchesTopBoundary ? tableBorders.top : tableBorders.insideH),
301156
301304
  right: resolveTableBorderValue(cellBorders.right, cellBounds.touchesRightEdge ? tableBorders.right : undefined),
301157
301305
  bottom: resolveTableBorderValue(cellBorders.bottom, touchesBottomBoundary ? tableBorders.bottom : undefined),
301158
301306
  left: resolveTableBorderValue(cellBorders.left, cellBounds.touchesLeftEdge ? tableBorders.left : tableBorders.insideV)
301159
301307
  };
301160
- }
301161
301308
  if (cellSpacingPx > 0) {
301162
301309
  const interiorBorders = {
301163
301310
  top: touchesTopBoundary ? undefined : borderValueToSpec(tableBorders.insideH),
@@ -301168,15 +301315,29 @@ menclose::after {
301168
301315
  return hasAnyResolvedBorder(interiorBorders) ? interiorBorders : undefined;
301169
301316
  }
301170
301317
  const baseBorders = resolveTableCellBorders(tableBorders, cellPosition);
301318
+ const insideHSpec = borderValueToSpec(tableBorders.insideH);
301319
+ const interiorBottom = nextRowSuppressesSharedTop && isPresentBorder(insideHSpec) ? insideHSpec : baseBorders.bottom;
301171
301320
  return {
301172
301321
  top: touchesTopBoundary ? borderValueToSpec(tableBorders.top) : baseBorders.top,
301173
301322
  right: baseBorders.right,
301174
- bottom: touchesBottomBoundary ? borderValueToSpec(tableBorders.bottom) : baseBorders.bottom,
301323
+ bottom: touchesBottomBoundary ? borderValueToSpec(tableBorders.bottom) : interiorBottom,
301175
301324
  left: baseBorders.left
301176
301325
  };
301177
301326
  }, renderTableRow = (deps) => {
301178
- const { doc: doc$12, container, rowIndex, y: y$1, rowMeasure, row: row2, totalRows, tableBorders, columnWidths, allRowHeights, tableIndent, isRtl, context, renderLine: renderLine$1, captureLineSnapshot, renderDrawingContent, applySdtDataset: applySdtDataset$1, ancestorContainerKey, ancestorContainerSdt, ancestorContainerKeys, ancestorContainerSdts, onSdtContainerChrome, continuesFromPrev, continuesOnNext, partialRow, cellSpacingPx = 0, chrome: chrome2, resolvePhysical } = deps;
301327
+ const { doc: doc$12, container, rowIndex, y: y$1, rowMeasure, row: row2, prevRow, prevRowMeasure, nextRow, nextRowMeasure, rowOccupiedRightCol, nextRowOccupiedRightCol, totalRows, tableBorders, columnWidths, allRowHeights, tableIndent, isRtl, context, renderLine: renderLine$1, captureLineSnapshot, renderDrawingContent, applySdtDataset: applySdtDataset$1, ancestorContainerKey, ancestorContainerSdt, ancestorContainerKeys, ancestorContainerSdts, onSdtContainerChrome, continuesFromPrev, continuesOnNext, partialRow, cellSpacingPx = 0, chrome: chrome2, resolvePhysical } = deps;
301179
301328
  const totalCols = columnWidths.length;
301329
+ const rowRightEdgeCol = rowOccupiedRightCol != null && rowOccupiedRightCol > 0 ? Math.min(totalCols, rowOccupiedRightCol) : rowMeasure.cells.length ? Math.min(totalCols, Math.max(...rowMeasure.cells.map((c) => (c.gridColumnStart ?? 0) + (c.colSpan ?? 1)))) : totalCols;
301330
+ const rowBorderOverride = row2?.attrs?.borders;
301331
+ const effectiveTableBorders = rowBorderOverride ? {
301332
+ ...tableBorders ?? {},
301333
+ ...rowBorderOverride
301334
+ } : tableBorders;
301335
+ const nextRowBorderOverride = nextRow?.attrs?.borders;
301336
+ const nextRowEffectiveInsideH = nextRowBorderOverride ? {
301337
+ ...tableBorders ?? {},
301338
+ ...nextRowBorderOverride
301339
+ }.insideH : undefined;
301340
+ const nextRowSuppressesSharedTop = nextRowBorderOverride !== undefined && !isPresentBorder(borderValueToSpec(nextRowEffectiveInsideH));
301180
301341
  const calculateXPosition = (gridColumnStart) => {
301181
301342
  let x = cellSpacingPx;
301182
301343
  for (let i4 = 0;i4 < gridColumnStart && i4 < columnWidths.length; i4++)
@@ -301201,6 +301362,27 @@ menclose::after {
301201
301362
  width += columnWidths[i4];
301202
301363
  return width;
301203
301364
  };
301365
+ const findCellBordersAtColumn = (cells, measureCells, gridCol) => {
301366
+ if (!cells || !measureCells)
301367
+ return;
301368
+ for (let i4 = 0;i4 < measureCells.length; i4++) {
301369
+ const start$1 = measureCells[i4].gridColumnStart ?? i4;
301370
+ const span = measureCells[i4].colSpan ?? 1;
301371
+ if (gridCol >= start$1 && gridCol < start$1 + span)
301372
+ return cells[i4]?.attrs?.borders;
301373
+ }
301374
+ };
301375
+ const findCellRightEdgeAtColumn = (measureCells, gridCol) => {
301376
+ if (!measureCells)
301377
+ return;
301378
+ for (let i4 = 0;i4 < measureCells.length; i4++) {
301379
+ const start$1 = measureCells[i4].gridColumnStart ?? i4;
301380
+ const span = measureCells[i4].colSpan ?? 1;
301381
+ if (gridCol >= start$1 && gridCol < start$1 + span)
301382
+ return start$1 + span;
301383
+ }
301384
+ };
301385
+ const nextRowMaxCol = nextRowOccupiedRightCol != null && nextRowOccupiedRightCol > 0 ? nextRowOccupiedRightCol : nextRowMeasure?.cells?.length ? Math.max(...nextRowMeasure.cells.map((c) => (c.gridColumnStart ?? 0) + (c.colSpan ?? 1))) : Infinity;
301204
301386
  for (let cellIndex = 0;cellIndex < rowMeasure.cells.length; cellIndex += 1) {
301205
301387
  const cellMeasure = rowMeasure.cells[cellIndex];
301206
301388
  const cell2 = row2?.cells?.[cellIndex];
@@ -301209,21 +301391,34 @@ menclose::after {
301209
301391
  const colSpan = cellMeasure.colSpan ?? 1;
301210
301392
  let x = calculateXPosition(gridColumnStart);
301211
301393
  const cellBordersAttr = cell2?.attrs?.borders;
301394
+ const hasBordersAttribute = cellBordersAttr !== undefined;
301395
+ const cellPosition = {
301396
+ rowIndex,
301397
+ rowSpan,
301398
+ gridColumnStart,
301399
+ colSpan,
301400
+ totalRows,
301401
+ totalCols: rowRightEdgeCol
301402
+ };
301403
+ const aboveCellBorders = findCellBordersAtColumn(prevRow?.cells, prevRowMeasure?.cells, gridColumnStart);
301404
+ const leftCellBorders = gridColumnStart > 0 ? findCellBordersAtColumn(row2?.cells, rowMeasure.cells, gridColumnStart - 1) : undefined;
301405
+ const rightCellBorders = findCellBordersAtColumn(row2?.cells, rowMeasure.cells, gridColumnStart + colSpan);
301406
+ const nextRowLeavesRightGap = gridColumnStart + colSpan > nextRowMaxCol;
301407
+ const aboveCellRightEdge = findCellRightEdgeAtColumn(prevRowMeasure?.cells, gridColumnStart);
301212
301408
  const resolvedBorders = resolveRenderedCellBorders({
301213
301409
  cellBorders: cellBordersAttr,
301214
- hasBordersAttribute: cellBordersAttr !== undefined,
301215
- tableBorders,
301216
- cellPosition: {
301217
- rowIndex,
301218
- rowSpan,
301219
- gridColumnStart,
301220
- colSpan,
301221
- totalRows,
301222
- totalCols
301223
- },
301410
+ hasBordersAttribute,
301411
+ tableBorders: effectiveTableBorders,
301412
+ cellPosition,
301224
301413
  cellSpacingPx,
301225
301414
  continuesFromPrev: continuesFromPrev === true,
301226
- continuesOnNext: continuesOnNext === true
301415
+ continuesOnNext: continuesOnNext === true,
301416
+ aboveCellBorders,
301417
+ leftCellBorders,
301418
+ rightCellBorders,
301419
+ nextRowLeavesRightGap,
301420
+ deferTopToAboveCell: aboveCellRightEdge !== undefined && aboveCellRightEdge > rowRightEdgeCol,
301421
+ nextRowSuppressesSharedTop
301227
301422
  });
301228
301423
  const finalBorders = isRtl && resolvedBorders ? swapCellBordersLR(resolvedBorders) : resolvedBorders;
301229
301424
  let cellHeight;
@@ -301356,12 +301551,22 @@ menclose::after {
301356
301551
  if (!rowMeasure)
301357
301552
  continue;
301358
301553
  const boundariesInRow = /* @__PURE__ */ new Set;
301554
+ const occupiedCols = /* @__PURE__ */ new Set;
301555
+ for (const cellMeasure of rowMeasure.cells) {
301556
+ const s2 = cellMeasure.gridColumnStart ?? 0;
301557
+ const sp = cellMeasure.colSpan ?? 1;
301558
+ for (let c = s2;c < s2 + sp; c++)
301559
+ occupiedCols.add(c);
301560
+ }
301561
+ const lastColIndex = columnCount - 1;
301562
+ const lastColMeta = fragment.metadata.columnBoundaries[lastColIndex];
301563
+ const skipTrailingSpacerBoundary = lastColIndex > 0 && !occupiedCols.has(lastColIndex) && !!lastColMeta && typeof lastColMeta.width === "number" && typeof lastColMeta.minWidth === "number" && lastColMeta.width < lastColMeta.minWidth;
301359
301564
  for (const cellMeasure of rowMeasure.cells) {
301360
301565
  const startCol = cellMeasure.gridColumnStart ?? 0;
301361
301566
  const endCol = startCol + (cellMeasure.colSpan ?? 1);
301362
301567
  if (startCol > 0)
301363
301568
  boundariesInRow.add(startCol);
301364
- if (endCol < columnCount)
301569
+ if (endCol < columnCount && !(skipTrailingSpacerBoundary && endCol === lastColIndex))
301365
301570
  boundariesInRow.add(endCol);
301366
301571
  }
301367
301572
  for (const boundaryCol of boundariesInRow) {
@@ -301418,6 +301623,16 @@ menclose::after {
301418
301623
  return fragment.partialRow.partialHeight;
301419
301624
  return r$1?.height ?? 0;
301420
301625
  });
301626
+ const rowOccupiedRightCols = new Array(measure.rows.length).fill(0);
301627
+ measure.rows.forEach((rowM, r$1) => {
301628
+ for (const c of rowM?.cells ?? []) {
301629
+ const right$1 = (c.gridColumnStart ?? 0) + (c.colSpan ?? 1);
301630
+ const lastRow = Math.min(measure.rows.length - 1, r$1 + (c.rowSpan ?? 1) - 1);
301631
+ for (let rr = r$1;rr <= lastRow; rr += 1)
301632
+ if (right$1 > rowOccupiedRightCols[rr])
301633
+ rowOccupiedRightCols[rr] = right$1;
301634
+ }
301635
+ });
301421
301636
  let y$1 = cellSpacingPx;
301422
301637
  if (fragment.repeatHeaderCount && fragment.repeatHeaderCount > 0)
301423
301638
  for (let r$1 = 0;r$1 < fragment.repeatHeaderCount; r$1 += 1) {
@@ -301431,6 +301646,12 @@ menclose::after {
301431
301646
  y: y$1,
301432
301647
  rowMeasure,
301433
301648
  row: block.rows[r$1],
301649
+ prevRow: r$1 > 0 ? block.rows[r$1 - 1] : undefined,
301650
+ prevRowMeasure: r$1 > 0 ? measure.rows[r$1 - 1] : undefined,
301651
+ nextRow: r$1 < block.rows.length - 1 ? block.rows[r$1 + 1] : undefined,
301652
+ nextRowMeasure: r$1 < block.rows.length - 1 ? measure.rows[r$1 + 1] : undefined,
301653
+ rowOccupiedRightCol: rowOccupiedRightCols[r$1],
301654
+ nextRowOccupiedRightCol: rowOccupiedRightCols[r$1 + 1],
301434
301655
  totalRows: block.rows.length,
301435
301656
  tableBorders,
301436
301657
  columnWidths: effectiveColumnWidths,
@@ -301549,6 +301770,12 @@ menclose::after {
301549
301770
  y: y$1,
301550
301771
  rowMeasure,
301551
301772
  row: block.rows[r$1],
301773
+ prevRow: r$1 > 0 ? block.rows[r$1 - 1] : undefined,
301774
+ prevRowMeasure: r$1 > 0 ? measure.rows[r$1 - 1] : undefined,
301775
+ nextRow: r$1 < block.rows.length - 1 ? block.rows[r$1 + 1] : undefined,
301776
+ nextRowMeasure: r$1 < block.rows.length - 1 ? measure.rows[r$1 + 1] : undefined,
301777
+ rowOccupiedRightCol: rowOccupiedRightCols[r$1],
301778
+ nextRowOccupiedRightCol: rowOccupiedRightCols[r$1 + 1],
301552
301779
  totalRows: block.rows.length,
301553
301780
  tableBorders,
301554
301781
  columnWidths: effectiveColumnWidths,
@@ -314991,6 +315218,7 @@ menclose::after {
314991
315218
  #requiredFaceKeys = /* @__PURE__ */ new Set;
314992
315219
  #seenAvailable = /* @__PURE__ */ new Set;
314993
315220
  #seenAvailableFaces = /* @__PURE__ */ new Set;
315221
+ #seenFailedFaces = /* @__PURE__ */ new Set;
314994
315222
  #lastSummary = null;
314995
315223
  #loadingDoneHandler = null;
314996
315224
  #lateLoadScheduler;
@@ -315066,9 +315294,18 @@ menclose::after {
315066
315294
  } catch {
315067
315295
  results = [];
315068
315296
  }
315069
- for (const result of results)
315297
+ const failedKeys = [];
315298
+ for (const result of results) {
315299
+ const key2 = faceKeyOf(result.request.family, result.request.weight, result.request.style);
315070
315300
  if (result.status === "loaded")
315071
- this.#seenAvailableFaces.add(faceKeyOf(result.request.family, result.request.weight, result.request.style));
315301
+ this.#seenAvailableFaces.add(key2);
315302
+ else if (result.status === "failed" && !this.#seenFailedFaces.has(key2)) {
315303
+ this.#seenFailedFaces.add(key2);
315304
+ failedKeys.push(key2);
315305
+ }
315306
+ }
315307
+ if (failedKeys.length > 0)
315308
+ this.#scheduleAvailabilityReflow(failedKeys);
315072
315309
  this.#lastSummary = summarizeFaces(results);
315073
315310
  return this.#lastSummary;
315074
315311
  }
@@ -315125,6 +315362,7 @@ menclose::after {
315125
315362
  this.#requiredFamilies = /* @__PURE__ */ new Set;
315126
315363
  this.#seenAvailable.clear();
315127
315364
  this.#seenAvailableFaces.clear();
315365
+ this.#seenFailedFaces.clear();
315128
315366
  this.#lastSummary = null;
315129
315367
  }
315130
315368
  dispose() {
@@ -315190,6 +315428,9 @@ menclose::after {
315190
315428
  }
315191
315429
  if (changedKeys.length === 0)
315192
315430
  return;
315431
+ this.#scheduleAvailabilityReflow(changedKeys);
315432
+ }
315433
+ #scheduleAvailabilityReflow(changedKeys) {
315193
315434
  this.#fontConfigVersion += 1;
315194
315435
  bumpFontConfigVersion();
315195
315436
  this.#invalidateCaches();
@@ -315289,8 +315530,13 @@ menclose::after {
315289
315530
  const registry3 = this.#getGate()?.resolveRegistry();
315290
315531
  if (!registry3)
315291
315532
  throw new Error("[superdoc] fonts.preload: the font registry is not ready yet");
315533
+ const hasFace = (family$1, weight, style2) => registry3.hasFace(family$1, weight, style2);
315534
+ const face = {
315535
+ weight: "400",
315536
+ style: "normal"
315537
+ };
315292
315538
  const requests = families.map((logical) => ({
315293
- family: this.#resolver.resolvePrimaryPhysicalFamily(logical),
315539
+ family: this.#resolver.resolveFace(logical, face, hasFace).physicalFamily,
315294
315540
  weight: "400",
315295
315541
  style: "normal"
315296
315542
  }));
@@ -315407,19 +315653,19 @@ menclose::after {
315407
315653
  return;
315408
315654
  console.log(...args$1);
315409
315655
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions, TRACKED_MARK_NAMES;
315410
- var init_src_DvgAvHbj_es = __esm(() => {
315656
+ var init_src_BjC0MGkm_es = __esm(() => {
315411
315657
  init_rolldown_runtime_Bg48TavK_es();
315412
- init_SuperConverter_B9mZiCO9_es();
315658
+ init_SuperConverter_7JlFliK8_es();
315413
315659
  init_jszip_C49i9kUs_es();
315414
315660
  init_xml_js_CqGKpaft_es();
315415
315661
  init_uuid_qzgm05fK_es();
315416
- init_create_headless_toolbar_pn_wKqsL_es();
315417
- init_constants_D_X7xF4s_es();
315662
+ init_create_headless_toolbar_ByZquSqc_es();
315663
+ init_constants_D9qj59G2_es();
315418
315664
  init_dist_B8HfvhaK_es();
315419
315665
  init_unified_Dsuw2be5_es();
315420
315666
  init_remark_gfm_BhnWr3yf_es();
315421
315667
  init_remark_stringify_6MMJfY0k_es();
315422
- init_DocxZipper_VodIk8WL_es();
315668
+ init_DocxZipper_Bu2Fhqkw_es();
315423
315669
  init__plugin_vue_export_helper_5t5P5NuM_es();
315424
315670
  init_eventemitter3_BnGqBE_Q_es();
315425
315671
  init_errors_CNaD6vcg_es();
@@ -342282,6 +342528,30 @@ function print() { __p += __j.call(arguments, '') }
342282
342528
  "wave",
342283
342529
  "doubleWave"
342284
342530
  ]);
342531
+ BORDER_STYLE_NUMBER = {
342532
+ single: 1,
342533
+ thick: 2,
342534
+ double: 3,
342535
+ dotted: 4,
342536
+ dashed: 5,
342537
+ dotDash: 6,
342538
+ dotDotDash: 7,
342539
+ triple: 8,
342540
+ wave: 18,
342541
+ doubleWave: 19
342542
+ };
342543
+ BORDER_STYLE_LINES = {
342544
+ single: 1,
342545
+ thick: 1,
342546
+ double: 2,
342547
+ dotted: 1,
342548
+ dashed: 1,
342549
+ dotDash: 1,
342550
+ dotDotDash: 1,
342551
+ triple: 3,
342552
+ wave: 1,
342553
+ doubleWave: 2
342554
+ };
342285
342555
  SETTLED_STATUSES = [
342286
342556
  "loaded",
342287
342557
  "failed",
@@ -350122,11 +350392,11 @@ function print() { __p += __j.call(arguments, '') }
350122
350392
  ]);
350123
350393
  });
350124
350394
 
350125
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CxQcY_QQ.es.js
350395
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CYY3yxUs.es.js
350126
350396
  var MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS;
350127
- var init_create_super_doc_ui_CxQcY_QQ_es = __esm(() => {
350128
- init_SuperConverter_B9mZiCO9_es();
350129
- init_create_headless_toolbar_pn_wKqsL_es();
350397
+ var init_create_super_doc_ui_CYY3yxUs_es = __esm(() => {
350398
+ init_SuperConverter_7JlFliK8_es();
350399
+ init_create_headless_toolbar_ByZquSqc_es();
350130
350400
  MOD_ALIASES = new Set([
350131
350401
  "Mod",
350132
350402
  "Meta",
@@ -350168,16 +350438,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
350168
350438
 
350169
350439
  // ../../packages/superdoc/dist/super-editor.es.js
350170
350440
  var init_super_editor_es = __esm(() => {
350171
- init_src_DvgAvHbj_es();
350172
- init_SuperConverter_B9mZiCO9_es();
350441
+ init_src_BjC0MGkm_es();
350442
+ init_SuperConverter_7JlFliK8_es();
350173
350443
  init_jszip_C49i9kUs_es();
350174
350444
  init_xml_js_CqGKpaft_es();
350175
- init_create_headless_toolbar_pn_wKqsL_es();
350176
- init_constants_D_X7xF4s_es();
350445
+ init_create_headless_toolbar_ByZquSqc_es();
350446
+ init_constants_D9qj59G2_es();
350177
350447
  init_dist_B8HfvhaK_es();
350178
350448
  init_unified_Dsuw2be5_es();
350179
- init_DocxZipper_VodIk8WL_es();
350180
- init_create_super_doc_ui_CxQcY_QQ_es();
350449
+ init_DocxZipper_Bu2Fhqkw_es();
350450
+ init_create_super_doc_ui_CYY3yxUs_es();
350181
350451
  init_ui_C5PAS9hY_es();
350182
350452
  init_eventemitter3_BnGqBE_Q_es();
350183
350453
  init_errors_CNaD6vcg_es();
@@ -371557,19 +371827,24 @@ function extractColumns2(elements) {
371557
371827
  const cols = elements.find((el) => el?.name === "w:cols");
371558
371828
  if (!cols?.attributes)
371559
371829
  return;
371560
- const count = parseColumnCount2(cols.attributes["w:num"]);
371830
+ let count = parseColumnCount2(cols.attributes["w:num"]);
371561
371831
  const withSeparator = parseColumnSeparator2(cols.attributes["w:sep"]);
371562
371832
  const equalWidthRaw = cols.attributes["w:equalWidth"];
371563
371833
  const equalWidth = equalWidthRaw === "0" || equalWidthRaw === 0 || equalWidthRaw === false ? false : equalWidthRaw === "1" || equalWidthRaw === 1 || equalWidthRaw === true ? true : undefined;
371564
371834
  const columnChildren = Array.isArray(cols.elements) ? cols.elements.filter((child) => child?.name === "w:col") : [];
371565
- const gapTwips = cols.attributes["w:space"] ?? columnChildren.find((child) => child?.attributes?.["w:space"] != null)?.attributes?.["w:space"];
371835
+ const isExplicit = equalWidth === false;
371836
+ const firstChildSpace = columnChildren.find((child) => child?.attributes?.["w:space"] != null)?.attributes?.["w:space"];
371837
+ const gapTwips = isExplicit ? firstChildSpace ?? 0 : cols.attributes["w:space"];
371566
371838
  const gapInches = parseColumnGap2(gapTwips);
371567
371839
  const widths = columnChildren.map((child) => Number(child.attributes?.["w:w"])).filter((widthTwips) => Number.isFinite(widthTwips) && widthTwips > 0).map((widthTwips) => widthTwips / 1440 * PX_PER_INCH);
371840
+ if (isExplicit && widths.length > 0) {
371841
+ count = Math.min(count, widths.length);
371842
+ }
371568
371843
  const result = {
371569
371844
  count,
371570
371845
  gap: gapInches * PX_PER_INCH,
371571
371846
  withSeparator,
371572
- ...widths.length > 0 ? { widths } : {},
371847
+ ...isExplicit && widths.length > 0 ? { widths } : {},
371573
371848
  ...equalWidth !== undefined ? { equalWidth } : {}
371574
371849
  };
371575
371850
  return result;
@@ -372296,6 +372571,17 @@ var twipsToPx3 = (value) => value / TWIPS_PER_INCH2 * PX_PER_INCH2, ptToPx2 = (p
372296
372571
  return Number.isFinite(parsed) ? parsed : undefined;
372297
372572
  }
372298
372573
  return;
372574
+ }, mergeWrapDistancesFromPadding2 = (wrap4, padding) => {
372575
+ if (!padding || wrap4.type === "None" || wrap4.type === "Inline")
372576
+ return;
372577
+ if (wrap4.distTop == null && padding.top != null)
372578
+ wrap4.distTop = padding.top;
372579
+ if (wrap4.distBottom == null && padding.bottom != null)
372580
+ wrap4.distBottom = padding.bottom;
372581
+ if (wrap4.distLeft == null && padding.left != null)
372582
+ wrap4.distLeft = padding.left;
372583
+ if (wrap4.distRight == null && padding.right != null)
372584
+ wrap4.distRight = padding.right;
372299
372585
  }, normalizeColor2 = (value) => {
372300
372586
  if (typeof value !== "string")
372301
372587
  return;
@@ -377609,7 +377895,7 @@ var import_xml_js, CRC32_TABLE2, PIXELS_PER_INCH3 = 96, EIGHTHS_PER_POINT2 = 8,
377609
377895
  return a2.length === 1 ? "0" + a2 : a2;
377610
377896
  }, rgbToHex3 = (rgb) => {
377611
377897
  return "#" + rgb.match(/\d+/g).map(componentToHex2).join("");
377612
- }, DEFAULT_SHADING_FOREGROUND_COLOR2 = "#000000", hexToRgb3 = (hex3) => {
377898
+ }, DEFAULT_SHADING_FOREGROUND_COLOR2 = "#000000", DEFAULT_SHADING_FILL_COLOR2 = "#FFFFFF", hexToRgb3 = (hex3) => {
377613
377899
  const normalized = normalizeHexColor4(hex3);
377614
377900
  if (!normalized)
377615
377901
  return null;
@@ -377636,18 +377922,22 @@ var import_xml_js, CRC32_TABLE2, PIXELS_PER_INCH3 = 96, EIGHTHS_PER_POINT2 = 8,
377636
377922
  }, resolveShadingFillColor2 = (shading) => {
377637
377923
  if (!shading || typeof shading !== "object")
377638
377924
  return null;
377639
- const fill = normalizeHexColor4(shading.fill);
377640
- if (!fill)
377641
- return null;
377642
377925
  const val = typeof shading.val === "string" ? shading.val.trim().toLowerCase() : "";
377926
+ if (val === "nil" || val === "none")
377927
+ return null;
377928
+ const fillIsAuto = typeof shading.fill === "string" && shading.fill.trim().toLowerCase() === "auto";
377929
+ const fillHex = fillIsAuto ? null : normalizeHexColor4(shading.fill);
377643
377930
  const pctMatch = val.match(/^pct(\d{1,3})$/);
377644
- if (!pctMatch)
377645
- return fill;
377646
- const pct = Number.parseInt(pctMatch[1], 10);
377931
+ const isPattern = Boolean(pctMatch) || val === "solid";
377932
+ if (!isPattern)
377933
+ return fillHex;
377934
+ const baseHex = fillHex ?? DEFAULT_SHADING_FILL_COLOR2;
377935
+ const colorIsAuto = typeof shading.color !== "string" || shading.color.trim() === "" || shading.color.trim().toLowerCase() === "auto";
377936
+ const foregroundHex = colorIsAuto ? DEFAULT_SHADING_FOREGROUND_COLOR2 : normalizeHexColor4(shading.color) ?? DEFAULT_SHADING_FOREGROUND_COLOR2;
377937
+ const pct = pctMatch ? Number.parseInt(pctMatch[1], 10) : 100;
377647
377938
  if (!Number.isFinite(pct) || pct < 0 || pct > 100)
377648
- return fill;
377649
- const foreground = normalizeHexColor4(shading.color) ?? DEFAULT_SHADING_FOREGROUND_COLOR2;
377650
- return blendHexColors2(fill, foreground, pct / 100) ?? fill;
377939
+ return fillHex;
377940
+ return blendHexColors2(baseHex, foregroundHex, pct / 100) ?? fillHex;
377651
377941
  }, deobfuscateFont2 = (arrayBuffer, guidHex) => {
377652
377942
  const dta = new Uint8Array(arrayBuffer);
377653
377943
  const guidStr = guidHex.replace(/[-{}]/g, "");
@@ -381023,6 +381313,9 @@ var WRAP_TYPES2, WRAP_TEXT_VALUES2, H_RELATIVE_VALUES2, V_RELATIVE_VALUES2, H_AL
381023
381313
  return hasData ? anchor : undefined;
381024
381314
  }, buildDrawingBlock2 = (rawAttrs, nextBlockId, positions, node3, geometry, drawingKind, extraProps) => {
381025
381315
  const normalizedWrap = normalizeWrap3(rawAttrs.wrap);
381316
+ if (normalizedWrap) {
381317
+ mergeWrapDistancesFromPadding2(normalizedWrap, toBoxSpacing2(rawAttrs.padding));
381318
+ }
381026
381319
  const sourceAnchor = isPlainObject8(rawAttrs.sourceAnchor) ? rawAttrs.sourceAnchor : undefined;
381027
381320
  const baseAnchor = normalizeAnchorData2(rawAttrs.anchorData, rawAttrs, normalizedWrap?.behindDoc);
381028
381321
  const pos = positions.get(node3);
@@ -381176,6 +381469,9 @@ function imageNodeToBlock2(node3, nextBlockId, positions, _trackedMeta, _tracked
381176
381469
  const height = typeof size3.height === "number" && Number.isFinite(size3.height) ? size3.height : undefined;
381177
381470
  const explicitDisplay = typeof attrs.display === "string" ? attrs.display : undefined;
381178
381471
  const normalizedWrap = normalizeWrap4(attrs.wrap);
381472
+ if (normalizedWrap) {
381473
+ mergeWrapDistancesFromPadding2(normalizedWrap, toBoxSpacing3(attrs.padding));
381474
+ }
381179
381475
  let anchor = normalizeAnchorData3(attrs.anchorData, attrs, normalizedWrap?.behindDoc);
381180
381476
  if (!anchor && normalizedWrap) {
381181
381477
  anchor = { isAnchored: true };
@@ -381925,16 +382221,15 @@ var isTableRowNode2 = (node3) => node3.type === "tableRow" || node3.type === "ta
381925
382221
  }
381926
382222
  }
381927
382223
  if (!cellBackgroundColor && resolvedTcProps?.shading) {
381928
- const { fill, themeFill, themeFillTint, themeFillShade } = resolvedTcProps.shading;
381929
- const normalizedFill = normalizeShadingColor2(fill);
381930
- if (normalizedFill) {
381931
- cellBackgroundColor = normalizedFill;
381932
- } else if (themeFill && context.themeColors) {
381933
- const resolved = resolveThemeColorValue2(themeFill, themeFillTint, themeFillShade, context.themeColors);
381934
- const normalizedTheme = normalizeShadingColor2(resolved);
381935
- if (normalizedTheme) {
381936
- cellBackgroundColor = normalizedTheme;
381937
- }
382224
+ const { fill, color: color2, val, themeFill, themeFillTint, themeFillShade } = resolvedTcProps.shading;
382225
+ let fillBase = normalizeShadingColor2(fill);
382226
+ if (!fillBase && themeFill && context.themeColors) {
382227
+ const resolvedTheme = resolveThemeColorValue2(themeFill, themeFillTint, themeFillShade, context.themeColors);
382228
+ fillBase = normalizeShadingColor2(resolvedTheme);
382229
+ }
382230
+ const resolved = resolveShadingFillColor2({ val, color: color2, fill: fillBase ?? fill });
382231
+ if (resolved) {
382232
+ cellBackgroundColor = resolved.startsWith("#") ? resolved : `#${resolved}`;
381938
382233
  }
381939
382234
  }
381940
382235
  const cellConverterContext = tableInfo || cellBackgroundColor ? {
@@ -382196,9 +382491,12 @@ var isTableRowNode2 = (node3) => node3.type === "tableRow" || node3.type === "ta
382196
382491
  return null;
382197
382492
  const rowProps = rowNode.attrs?.tableRowProperties;
382198
382493
  const rowHeight = normalizeRowHeight2(rowProps);
382494
+ const tblPrExBordersRaw = rowProps?.tblPrExBorders;
382495
+ const rowBorders = tblPrExBordersRaw && typeof tblPrExBordersRaw === "object" ? extractTableBorders2(tblPrExBordersRaw, { unit: "eighthPoints" }) : undefined;
382199
382496
  const attrs = rowProps && typeof rowProps === "object" ? {
382200
382497
  tableRowProperties: rowProps,
382201
- ...rowHeight ? { rowHeight } : {}
382498
+ ...rowHeight ? { rowHeight } : {},
382499
+ ...rowBorders ? { borders: rowBorders } : {}
382202
382500
  } : rowHeight ? { rowHeight } : undefined;
382203
382501
  return {
382204
382502
  id: context.nextBlockId(`row-${rowIndex}`),
@@ -382211,6 +382509,7 @@ var init_table = __esm(() => {
382211
382509
  init_attributes();
382212
382510
  init_utilities();
382213
382511
  init_table_styles();
382512
+ init_helpers();
382214
382513
  init_marks();
382215
382514
  init_tracked_changes();
382216
382515
  init_sdt();
@@ -437834,6 +438133,9 @@ function handleImageNode3(node4, params3, isAnchor) {
437834
438133
  default:
437835
438134
  break;
437836
438135
  }
438136
+ if (wrap6.type === "Square" || wrap6.type === "Tight" || wrap6.type === "Through" || wrap6.type === "TopAndBottom") {
438137
+ mergeAnchorPaddingIntoWrapDistances2(wrap6, padding);
438138
+ }
437837
438139
  const docPr = node4.elements.find((el) => el.name === "wp:docPr");
437838
438140
  const isHidden = isDocPrHidden2(docPr);
437839
438141
  let anchorData = null;
@@ -438358,6 +438660,21 @@ var DRAWING_XML_TAG2 = "w:drawing", SHAPE_URI2 = "http://schemas.microsoft.com/o
438358
438660
  const bottom2 = percentEdges.bottom ?? 0;
438359
438661
  const left2 = percentEdges.left ?? 0;
438360
438662
  return `inset(${top}% ${right2}% ${bottom2}% ${left2}%)`;
438663
+ }, mergeAnchorPaddingIntoWrapDistances2 = (wrap6, padding) => {
438664
+ if (!wrap6?.attrs || !padding)
438665
+ return;
438666
+ if (wrap6.attrs.distTop == null && Number.isFinite(padding.top) && padding.top !== 0) {
438667
+ wrap6.attrs.distTop = padding.top;
438668
+ }
438669
+ if (wrap6.attrs.distBottom == null && Number.isFinite(padding.bottom) && padding.bottom !== 0) {
438670
+ wrap6.attrs.distBottom = padding.bottom;
438671
+ }
438672
+ if (wrap6.attrs.distLeft == null && Number.isFinite(padding.left) && padding.left !== 0) {
438673
+ wrap6.attrs.distLeft = padding.left;
438674
+ }
438675
+ if (wrap6.attrs.distRight == null && Number.isFinite(padding.right) && padding.right !== 0) {
438676
+ wrap6.attrs.distRight = padding.right;
438677
+ }
438361
438678
  }, handleShapeDrawing2 = (params3, node4, graphicData, size3, padding, marginOffset, anchorData, wrap6, isAnchor, isHidden) => {
438362
438679
  const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
438363
438680
  const textBox = wsp.elements.find((el) => el.name === "wps:txbx");