@superdoc-dev/mcp 0.12.0-next.15 → 0.12.0-next.17

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 (2) hide show
  1. package/dist/index.js +2029 -568
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -52172,7 +52172,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
52172
52172
  emptyOptions2 = {};
52173
52173
  });
52174
52174
 
52175
- // ../../packages/superdoc/dist/chunks/SuperConverter-BTGVElJO.es.js
52175
+ // ../../packages/superdoc/dist/chunks/SuperConverter-CUxtXQFf.es.js
52176
52176
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
52177
52177
  const fieldValue = extension$1.config[field];
52178
52178
  if (typeof fieldValue === "function")
@@ -68260,6 +68260,61 @@ function parseStyleId(chartSpace) {
68260
68260
  const val = getAttr(findChild$1(chartSpace, "c:style"), "val");
68261
68261
  return val != null ? Number(val) : undefined;
68262
68262
  }
68263
+ function stripRunNodeMarks(nodes) {
68264
+ if (!Array.isArray(nodes))
68265
+ return nodes;
68266
+ return nodes.map((node2) => {
68267
+ if (!node2 || typeof node2 !== "object")
68268
+ return node2;
68269
+ const stripped = node2.type === "run" && Array.isArray(node2.marks) && node2.marks.length > 0 ? {
68270
+ ...node2,
68271
+ marks: []
68272
+ } : node2;
68273
+ if (Array.isArray(stripped.content))
68274
+ return {
68275
+ ...stripped,
68276
+ content: stripRunNodeMarks(stripped.content)
68277
+ };
68278
+ return stripped;
68279
+ });
68280
+ }
68281
+ function importDrawingMLTextbox({ params, drawingNode, textBoxContent, bodyPr, baseAttrs = {}, paragraphImporter }) {
68282
+ if (!textBoxContent)
68283
+ return null;
68284
+ const textboxParagraphs = collectTextBoxParagraphs(preProcessTextBoxContent(textBoxContent, params)?.elements || []);
68285
+ const importParagraph = typeof paragraphImporter === "function" ? paragraphImporter : (paragraph2) => {
68286
+ return handleParagraphNode$1({
68287
+ ...params,
68288
+ nodes: [paragraph2]
68289
+ })?.nodes || [];
68290
+ };
68291
+ const contentNodes = stripRunNodeMarks(textboxParagraphs.flatMap((paragraph2) => {
68292
+ const imported = importParagraph(paragraph2);
68293
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
68294
+ }));
68295
+ const { verticalAlign, insets } = extractBodyPrProperties(bodyPr);
68296
+ return {
68297
+ type: "shapeContainer",
68298
+ attrs: {
68299
+ ...baseAttrs,
68300
+ drawingContent: drawingNode
68301
+ },
68302
+ content: [{
68303
+ type: "shapeTextbox",
68304
+ attrs: {
68305
+ textInsets: {
68306
+ top: insets.top,
68307
+ right: insets.right,
68308
+ bottom: insets.bottom,
68309
+ left: insets.left
68310
+ },
68311
+ textVerticalAlign: verticalAlign,
68312
+ attributes: {}
68313
+ },
68314
+ content: contentNodes
68315
+ }]
68316
+ };
68317
+ }
68263
68318
  function handleImageNode$1(node2, params, isAnchor) {
68264
68319
  if (!node2)
68265
68320
  return null;
@@ -68731,6 +68786,122 @@ function extractTextFromTextBox(textBoxContent, bodyPr, params = {}) {
68731
68786
  wrap: wrap$1
68732
68787
  };
68733
68788
  }
68789
+ function extractFieldInlineNodes(node2) {
68790
+ if (node2?.name === "sd:autoPageNumber")
68791
+ return [{
68792
+ type: "page-number",
68793
+ attrs: {
68794
+ marksAsAttrs: [],
68795
+ instruction: "PAGE"
68796
+ }
68797
+ }];
68798
+ if (node2?.name === "sd:totalPageNumber")
68799
+ return [{
68800
+ type: "total-page-number",
68801
+ attrs: {
68802
+ marksAsAttrs: [],
68803
+ instruction: "NUMPAGES"
68804
+ }
68805
+ }];
68806
+ if (node2?.name === "sd:sectionPageCount") {
68807
+ const cachedText = node2?.attributes?.resolvedText ?? node2?.attributes?.importedCachedText ?? "";
68808
+ if (!cachedText)
68809
+ return [];
68810
+ return [{
68811
+ type: "text",
68812
+ text: cachedText
68813
+ }];
68814
+ }
68815
+ return [];
68816
+ }
68817
+ function extractInlineNodesFromRun(run$1, params) {
68818
+ if (!run$1?.elements)
68819
+ return [];
68820
+ const nodes = [];
68821
+ run$1.elements.forEach((el) => {
68822
+ if (el.name === "w:t" || el.name === "w:delText") {
68823
+ const textNode = el.elements?.find((n) => n.type === "text");
68824
+ if (!textNode || typeof textNode.text !== "string")
68825
+ return;
68826
+ const cleanedText = textNode.text.replace(/\[\[sdspace\]\]/g, " ");
68827
+ if (cleanedText.length > 0)
68828
+ nodes.push({
68829
+ type: "text",
68830
+ text: cleanedText
68831
+ });
68832
+ } else if (el.name === "w:tab")
68833
+ nodes.push({
68834
+ type: "text",
68835
+ text: "\t"
68836
+ });
68837
+ else if (el.name === "w:br")
68838
+ nodes.push({
68839
+ type: "lineBreak",
68840
+ attrs: {}
68841
+ });
68842
+ else if (el.name === "sd:autoPageNumber" || el.name === "sd:totalPageNumber" || el.name === "sd:sectionPageCount")
68843
+ nodes.push(...extractFieldInlineNodes(el));
68844
+ else if (el.name === "w:drawing") {
68845
+ const inline = el.elements?.find((child) => child?.name === "wp:inline");
68846
+ if (!inline)
68847
+ return;
68848
+ const imagePm = handleImageNode$1(inline, {
68849
+ ...params,
68850
+ nodes: [el]
68851
+ }, false);
68852
+ if (imagePm?.type === "image" && imagePm.attrs?.hidden !== true)
68853
+ nodes.push(imagePm);
68854
+ }
68855
+ });
68856
+ return nodes;
68857
+ }
68858
+ function paragraphToPmParagraph(paragraph2, params) {
68859
+ const paragraphNode = collectTextBoxParagraphs([paragraph2])[0];
68860
+ if (!paragraphNode)
68861
+ return null;
68862
+ const paragraphProperties = resolveParagraphPropertiesForTextBox(paragraphNode, params);
68863
+ const alignment = extractParagraphAlignment(paragraphNode) || "left";
68864
+ const content$2 = [];
68865
+ let pendingRunContent = [];
68866
+ const flushPendingRun = () => {
68867
+ if (pendingRunContent.length === 0)
68868
+ return;
68869
+ content$2.push({
68870
+ type: "run",
68871
+ attrs: {},
68872
+ content: pendingRunContent
68873
+ });
68874
+ pendingRunContent = [];
68875
+ };
68876
+ (paragraphNode.elements || []).forEach((element) => {
68877
+ if (element?.name === "w:r") {
68878
+ extractInlineNodesFromRun(element, params).forEach((part) => {
68879
+ if (part?.type === "image") {
68880
+ flushPendingRun();
68881
+ content$2.push(part);
68882
+ return;
68883
+ }
68884
+ pendingRunContent.push(part);
68885
+ });
68886
+ return;
68887
+ }
68888
+ if (element?.name?.startsWith("sd:")) {
68889
+ const runContent = extractFieldInlineNodes(element);
68890
+ if (runContent.length > 0)
68891
+ pendingRunContent.push(...runContent);
68892
+ }
68893
+ });
68894
+ flushPendingRun();
68895
+ return {
68896
+ type: "paragraph",
68897
+ attrs: {
68898
+ paragraphProperties,
68899
+ textAlign: alignment
68900
+ },
68901
+ content: content$2,
68902
+ marks: []
68903
+ };
68904
+ }
68734
68905
  function getVectorShape({ params, node: node2, graphicData, size, marginOffset, anchorData, wrap: wrap$1, isAnchor, customGeometry }) {
68735
68906
  const schemaAttrs = {};
68736
68907
  const drawingNode = params.nodes?.[0];
@@ -68766,14 +68937,45 @@ function getVectorShape({ params, node: node2, graphicData, size, marginOffset,
68766
68937
  const textBoxContent = wsp.elements?.find((el) => el.name === "wps:txbx")?.elements?.find((el) => el.name === "w:txbxContent");
68767
68938
  const bodyPr = wsp.elements?.find((el) => el.name === "wps:bodyPr");
68768
68939
  const nonVisualShapeProps = wsp.elements?.find((el) => el.name === "wps:cNvSpPr");
68940
+ const isWordArt = bodyPr?.attributes?.["fromWordArt"] === "1";
68941
+ const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
68942
+ if (isTextBox && textBoxContent)
68943
+ return importDrawingMLTextbox({
68944
+ params,
68945
+ drawingNode: drawingNode?.name === "w:drawing" ? drawingNode : null,
68946
+ textBoxContent,
68947
+ bodyPr,
68948
+ baseAttrs: {
68949
+ ...schemaAttrs,
68950
+ width,
68951
+ height,
68952
+ rotation,
68953
+ flipH,
68954
+ flipV,
68955
+ fillColor,
68956
+ strokeColor,
68957
+ strokeWidth,
68958
+ lineEnds,
68959
+ effectExtent,
68960
+ marginOffset,
68961
+ anchorData,
68962
+ wrap: wrap$1,
68963
+ isAnchor,
68964
+ isWordArt,
68965
+ isTextBox,
68966
+ originalAttributes: node2?.attributes
68967
+ },
68968
+ paragraphImporter: params?.nodeListHandler != null ? undefined : (paragraph2) => {
68969
+ const imported = paragraphToPmParagraph(paragraph2, params);
68970
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
68971
+ }
68972
+ });
68769
68973
  let textContent = null;
68770
68974
  let textAlign = "left";
68771
68975
  if (textBoxContent) {
68772
68976
  textContent = extractTextFromTextBox(textBoxContent, bodyPr, params);
68773
68977
  textAlign = textContent?.horizontalAlign || "left";
68774
68978
  }
68775
- const isWordArt = bodyPr?.attributes?.["fromWordArt"] === "1";
68776
- const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
68777
68979
  return {
68778
68980
  type: "vectorShape",
68779
68981
  attrs: {
@@ -84997,9 +85199,15 @@ function handleShapeTextboxImport({ params, pict }) {
84997
85199
  schemaAttrs.attributes = shapeAttrs;
84998
85200
  if (shapeAttrs.fillcolor)
84999
85201
  schemaAttrs.fillcolor = shapeAttrs.fillcolor;
85000
- const shapeStyle = buildStyles(parseInlineStyles(shapeAttrs.style));
85202
+ const parsedStyle = parseInlineStyles(shapeAttrs.style);
85203
+ const shapeStyle = buildStyles(parsedStyle);
85204
+ const positionData = extractPositionData(parsedStyle);
85001
85205
  if (shapeStyle)
85002
85206
  schemaAttrs.style = shapeStyle;
85207
+ if (positionData.anchorData)
85208
+ schemaAttrs.anchorData = positionData.anchorData;
85209
+ if (positionData.marginOffset)
85210
+ schemaAttrs.marginOffset = positionData.marginOffset;
85003
85211
  const textbox = shape.elements?.find((el) => el.name === "v:textbox");
85004
85212
  const wrap$1 = shape.elements?.find((el) => el.name === "w10:wrap");
85005
85213
  if (wrap$1?.attributes)
@@ -85029,6 +85237,38 @@ function buildStyles(styleObject) {
85029
85237
  style += `${prop}: ${value};`;
85030
85238
  return style;
85031
85239
  }
85240
+ function extractPositionData(styleObject) {
85241
+ const anchorData = {};
85242
+ const marginOffset = {};
85243
+ if (styleObject["mso-position-horizontal"])
85244
+ anchorData.alignH = styleObject["mso-position-horizontal"];
85245
+ if (styleObject["mso-position-horizontal-relative"])
85246
+ anchorData.hRelativeFrom = styleObject["mso-position-horizontal-relative"];
85247
+ if (styleObject["mso-position-vertical"])
85248
+ anchorData.alignV = styleObject["mso-position-vertical"];
85249
+ if (styleObject["mso-position-vertical-relative"])
85250
+ anchorData.vRelativeFrom = styleObject["mso-position-vertical-relative"];
85251
+ if (styleObject["margin-left"] != null)
85252
+ marginOffset.horizontal = convertToPixels$2(styleObject["margin-left"]);
85253
+ if (styleObject["margin-top"] != null)
85254
+ marginOffset.top = convertToPixels$2(styleObject["margin-top"]);
85255
+ return {
85256
+ ...Object.keys(anchorData).length > 0 ? { anchorData } : {},
85257
+ ...Object.keys(marginOffset).length > 0 ? { marginOffset } : {}
85258
+ };
85259
+ }
85260
+ function convertToPixels$2(value) {
85261
+ const num = parseFloat(value);
85262
+ if (Number.isNaN(num))
85263
+ return 0;
85264
+ if (value.endsWith("pt"))
85265
+ return num * 96 / 72;
85266
+ if (value.endsWith("in"))
85267
+ return num * 96;
85268
+ if (value.endsWith("px"))
85269
+ return num;
85270
+ return num;
85271
+ }
85032
85272
  function handleShapeImageWatermarkImport({ params, pict }) {
85033
85273
  const shape = pict.elements?.find((el) => el.name === "v:shape");
85034
85274
  if (!shape)
@@ -85549,15 +85789,69 @@ function pictNodeTypeStrategy(node2) {
85549
85789
  handler: null
85550
85790
  };
85551
85791
  }
85792
+ function translateDrawingMLTextbox(params) {
85793
+ const { node: node2 } = params;
85794
+ const drawingContent = node2?.attrs?.drawingContent;
85795
+ const shapeTextbox = node2?.content?.find((child) => child?.type === "shapeTextbox");
85796
+ if (!drawingContent || !shapeTextbox)
85797
+ return null;
85798
+ const drawing = carbonCopy(drawingContent);
85799
+ const liveParagraphs = translateChildNodes({
85800
+ ...params,
85801
+ node: shapeTextbox
85802
+ });
85803
+ const txbxContent = findTextboxContentNode(drawing);
85804
+ if (!txbxContent)
85805
+ return null;
85806
+ txbxContent.elements = liveParagraphs;
85807
+ return wrapTextInRun({
85808
+ name: "mc:AlternateContent",
85809
+ elements: [{
85810
+ name: "mc:Choice",
85811
+ attributes: { Requires: "wps" },
85812
+ elements: [drawing]
85813
+ }]
85814
+ });
85815
+ }
85816
+ function findTextboxContentNode(node2) {
85817
+ if (!node2 || typeof node2 !== "object")
85818
+ return null;
85819
+ if (node2.name === "w:txbxContent")
85820
+ return node2;
85821
+ if (!Array.isArray(node2.elements))
85822
+ return null;
85823
+ for (const child of node2.elements) {
85824
+ const found$1 = findTextboxContentNode(child);
85825
+ if (found$1)
85826
+ return found$1;
85827
+ }
85828
+ return null;
85829
+ }
85552
85830
  function translateShapeContainer(params) {
85553
85831
  const { node: node2 } = params;
85832
+ if (node2?.attrs?.drawingContent) {
85833
+ const run$1 = translateDrawingMLTextbox(params);
85834
+ if (run$1)
85835
+ return {
85836
+ name: "w:p",
85837
+ elements: [run$1]
85838
+ };
85839
+ return {
85840
+ name: "w:p",
85841
+ elements: [wrapTextInRun(node2.attrs.drawingContent)]
85842
+ };
85843
+ }
85554
85844
  const elements = translateChildNodes(params);
85845
+ const shapeAttributes = {
85846
+ ...node2.attrs.attributes,
85847
+ fillcolor: node2.attrs.fillcolor
85848
+ };
85849
+ const style = buildShapeStyle(node2.attrs);
85850
+ if (style)
85851
+ shapeAttributes.style = style;
85555
85852
  const shape = {
85556
85853
  name: "v:shape",
85557
- attributes: {
85558
- ...node2.attrs.attributes,
85559
- fillcolor: node2.attrs.fillcolor
85560
- },
85854
+ attributes: shapeAttributes,
85561
85855
  elements: [...elements, ...node2.attrs.wrapAttributes ? [{
85562
85856
  name: "w10:wrap",
85563
85857
  attributes: { ...node2.attrs.wrapAttributes }
@@ -85572,6 +85866,33 @@ function translateShapeContainer(params) {
85572
85866
  })]
85573
85867
  };
85574
85868
  }
85869
+ function buildShapeStyle(attrs) {
85870
+ const originalStyle = parseInlineStyles(attrs.attributes?.style);
85871
+ const managedStyle = parseInlineStyles(attrs.style);
85872
+ const style = {
85873
+ ...originalStyle,
85874
+ ...managedStyle
85875
+ };
85876
+ if (attrs.marginOffset?.horizontal !== undefined)
85877
+ style["margin-left"] = `${convertToPt$2(attrs.marginOffset.horizontal)}pt`;
85878
+ if (attrs.marginOffset?.top !== undefined)
85879
+ style["margin-top"] = `${convertToPt$2(attrs.marginOffset.top)}pt`;
85880
+ if (attrs.anchorData?.alignH)
85881
+ style["mso-position-horizontal"] = attrs.anchorData.alignH;
85882
+ if (attrs.anchorData?.hRelativeFrom)
85883
+ style["mso-position-horizontal-relative"] = attrs.anchorData.hRelativeFrom;
85884
+ if (attrs.anchorData?.alignV)
85885
+ style["mso-position-vertical"] = attrs.anchorData.alignV;
85886
+ if (attrs.anchorData?.vRelativeFrom)
85887
+ style["mso-position-vertical-relative"] = attrs.anchorData.vRelativeFrom;
85888
+ const entries = Object.entries(style);
85889
+ if (entries.length === 0)
85890
+ return;
85891
+ return entries.map(([prop, value]) => `${prop}:${value}`).join(";");
85892
+ }
85893
+ function convertToPt$2(pixels) {
85894
+ return pixels * 72 / 96;
85895
+ }
85575
85896
  function translateShapeTextbox(params) {
85576
85897
  const { node: node2 } = params;
85577
85898
  const textboxContent = {
@@ -87948,7 +88269,7 @@ function hydrateImageBlocks(blocks, mediaFiles) {
87948
88269
  }
87949
88270
  if (blk.kind === "drawing") {
87950
88271
  const drawingBlock = blk;
87951
- if (drawingBlock.drawingKind === "vectorShape") {
88272
+ if (drawingBlock.drawingKind === "vectorShape" || drawingBlock.drawingKind === "textboxShape") {
87952
88273
  const parts = drawingBlock.textContent?.parts;
87953
88274
  if (!parts || parts.length === 0)
87954
88275
  return blk;
@@ -90003,6 +90324,14 @@ function lineBreakNodeToRun({ node: node2, positions, sdtMetadata }) {
90003
90324
  lineBreakRun.sdt = sdtMetadata;
90004
90325
  return lineBreakRun;
90005
90326
  }
90327
+ function hydrateTextboxDrawingContent(node2, drawingBlock, context) {
90328
+ if (drawingBlock.drawingKind !== "textboxShape")
90329
+ return drawingBlock;
90330
+ return {
90331
+ ...drawingBlock,
90332
+ contentBlocks: toTextboxParagraphBlocks(node2, context)
90333
+ };
90334
+ }
90006
90335
  function vectorShapeNodeToDrawingBlock(node2, nextBlockId, positions) {
90007
90336
  const rawAttrs = getAttrs$2(node2);
90008
90337
  if (isHiddenDrawing$1(rawAttrs))
@@ -90047,25 +90376,43 @@ function shapeContainerNodeToDrawingBlock(node2, nextBlockId, positions) {
90047
90376
  const rawAttrs = getAttrs$2(node2);
90048
90377
  if (isHiddenDrawing$1(rawAttrs))
90049
90378
  return null;
90050
- return buildDrawingBlock(rawAttrs, nextBlockId, positions, node2, {
90379
+ const geometry = {
90051
90380
  width: coercePositiveNumber(rawAttrs.width, 1),
90052
90381
  height: coercePositiveNumber(rawAttrs.height, 1),
90053
90382
  rotation: coerceNumber(rawAttrs.rotation) ?? 0,
90054
90383
  flipH: coerceBoolean(rawAttrs.flipH) ?? false,
90055
90384
  flipV: coerceBoolean(rawAttrs.flipV) ?? false
90056
- }, "vectorShape");
90385
+ };
90386
+ const shapeTextboxNode = resolveNestedShapeTextboxNode(node2);
90387
+ const textboxAttrs = shapeTextboxNode ? getAttrs$2(shapeTextboxNode) : {};
90388
+ const textContent = shapeTextboxNode ? extractTextboxTextContent(shapeTextboxNode) : undefined;
90389
+ return buildDrawingBlock({
90390
+ ...rawAttrs,
90391
+ ...textContent ? { textContent } : {},
90392
+ ...rawAttrs.textAlign == null && textContent?.horizontalAlign ? { textAlign: textContent.horizontalAlign } : {},
90393
+ ...rawAttrs.textInsets == null ? { textInsets: resolveTextboxInsetsFromAttrs(textboxAttrs) } : {},
90394
+ ...rawAttrs.textVerticalAlign == null ? { textVerticalAlign: resolveTextboxVerticalAlignFromAttrs(textboxAttrs) } : {}
90395
+ }, nextBlockId, positions, node2, geometry, "textboxShape", { contentBlocks: [] });
90057
90396
  }
90058
90397
  function shapeTextboxNodeToDrawingBlock(node2, nextBlockId, positions) {
90059
90398
  const rawAttrs = getAttrs$2(node2);
90060
90399
  if (isHiddenDrawing$1(rawAttrs))
90061
90400
  return null;
90062
- return buildDrawingBlock(rawAttrs, nextBlockId, positions, node2, {
90401
+ const geometry = {
90063
90402
  width: coercePositiveNumber(rawAttrs.width, 1),
90064
90403
  height: coercePositiveNumber(rawAttrs.height, 1),
90065
90404
  rotation: coerceNumber(rawAttrs.rotation) ?? 0,
90066
90405
  flipH: coerceBoolean(rawAttrs.flipH) ?? false,
90067
90406
  flipV: coerceBoolean(rawAttrs.flipV) ?? false
90068
- }, "vectorShape");
90407
+ };
90408
+ const textContent = extractTextboxTextContent(node2);
90409
+ return buildDrawingBlock({
90410
+ ...rawAttrs,
90411
+ ...textContent ? { textContent } : {},
90412
+ ...rawAttrs.textAlign == null && textContent?.horizontalAlign ? { textAlign: textContent.horizontalAlign } : {},
90413
+ ...rawAttrs.textInsets == null ? { textInsets: resolveTextboxInsetsFromAttrs(rawAttrs) } : {},
90414
+ ...rawAttrs.textVerticalAlign == null ? { textVerticalAlign: resolveTextboxVerticalAlignFromAttrs(rawAttrs) } : {}
90415
+ }, nextBlockId, positions, node2, geometry, "textboxShape", { contentBlocks: [] });
90069
90416
  }
90070
90417
  function handleVectorShapeNode(node2, context) {
90071
90418
  const { blocks, recordBlockKind, nextBlockId, positions } = context;
@@ -90087,7 +90434,7 @@ function handleShapeContainerNode(node2, context) {
90087
90434
  const { blocks, recordBlockKind, nextBlockId, positions } = context;
90088
90435
  const drawingBlock = shapeContainerNodeToDrawingBlock(node2, nextBlockId, positions);
90089
90436
  if (drawingBlock) {
90090
- blocks.push(drawingBlock);
90437
+ blocks.push(hydrateTextboxDrawingContent(node2, drawingBlock, context));
90091
90438
  recordBlockKind?.(drawingBlock.kind);
90092
90439
  }
90093
90440
  }
@@ -90095,7 +90442,7 @@ function handleShapeTextboxNode(node2, context) {
90095
90442
  const { blocks, recordBlockKind, nextBlockId, positions } = context;
90096
90443
  const drawingBlock = shapeTextboxNodeToDrawingBlock(node2, nextBlockId, positions);
90097
90444
  if (drawingBlock) {
90098
- blocks.push(drawingBlock);
90445
+ blocks.push(hydrateTextboxDrawingContent(node2, drawingBlock, context));
90099
90446
  recordBlockKind?.(drawingBlock.kind);
90100
90447
  }
90101
90448
  }
@@ -90852,8 +91199,14 @@ function paragraphToFlowBlocks({ para, nextBlockId, positions, storyKey, tracked
90852
91199
  const converter = SHAPE_CONVERTERS_REGISTRY[node2.type];
90853
91200
  const drawingBlock = converter(node2, stableNextBlockId, positions);
90854
91201
  if (drawingBlock) {
90855
- attachInlineShapeGroupAlignment(drawingBlock);
90856
- blocks.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
91202
+ const hydratedBlock = hydrateTextboxDrawingContent(node2, drawingBlock, {
91203
+ converterContext,
91204
+ converters: converters$1,
91205
+ nextBlockId: stableNextBlockId,
91206
+ positions
91207
+ });
91208
+ attachInlineShapeGroupAlignment(hydratedBlock);
91209
+ blocks.push(attachAnchorParagraphId(hydratedBlock, anchorParagraphId));
90857
91210
  }
90858
91211
  return;
90859
91212
  }
@@ -100011,7 +100364,7 @@ var isRegExp = (value) => {
100011
100364
  return attributes["w:rsidDel"];
100012
100365
  }, decode$52 = (attrs) => {
100013
100366
  return attrs.rsidDel;
100014
- }, attributes_default$4, STYLES_KEY = "word/styles.xml", XML_NODE_NAME$32 = "w:r", SD_KEY_NAME = "run", REFERENCE_RUN_STYLE_BY_XML_NAME, hasXmlNodeNamed = (node2, targetName) => {
100367
+ }, attributes_default$4, STYLES_KEY = "word/styles.xml", XML_NODE_NAME$32 = "w:r", SD_KEY_NAME = "run", REFERENCE_RUN_STYLE_BY_XML_NAME, BLOCK_HOIST_TYPES, hasXmlNodeNamed = (node2, targetName) => {
100015
100368
  if (!node2 || typeof node2 !== "object")
100016
100369
  return false;
100017
100370
  if (node2.name === targetName)
@@ -100144,6 +100497,11 @@ var isRegExp = (value) => {
100144
100497
  nodes: contentElements
100145
100498
  };
100146
100499
  const content$2 = nodeListHandler?.handler(childParams) || [];
100500
+ if (Array.isArray(content$2) && content$2.length > 0 && content$2.every((child) => BLOCK_HOIST_TYPES.has(child?.type)))
100501
+ return content$2.filter(Boolean).map((child) => ({
100502
+ ...child,
100503
+ marks: Array.isArray(child?.marks) ? child.marks : []
100504
+ }));
100147
100505
  const filtered = (Array.isArray(content$2) ? content$2 : []).map((child) => {
100148
100506
  if (!child || typeof child !== "object")
100149
100507
  return child;
@@ -105846,7 +106204,86 @@ var isRegExp = (value) => {
105846
106204
  i$1++;
105847
106205
  }
105848
106206
  return { processedNodes };
105849
- }, HEADER_FOOTER_FILENAME_PATTERN, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild$1 = (node2, name) => node2?.elements?.find((el) => el.name === name), findChildren$2 = (node2, name) => node2?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node2, attr) => node2?.attributes?.[attr], DRAWING_XML_TAG = "w:drawing", SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", SD_IMAGE_ID_NAMESPACE = "7c9e6679-7425-40de-944b-e07fc1f90ae7", normalizeTargetPath$1 = (targetPath = "") => {
106207
+ }, HEADER_FOOTER_FILENAME_PATTERN, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild$1 = (node2, name) => node2?.elements?.find((el) => el.name === name), findChildren$2 = (node2, name) => node2?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node2, attr) => node2?.attributes?.[attr], PARAGRAPH_PROPERTIES_XML_NAME = "w:pPr", hasMeaningfulParagraphContent = (elements = []) => elements.some((element) => element?.name && element.name !== PARAGRAPH_PROPERTIES_XML_NAME), findParagraphProperties = (elements = []) => elements.find((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME) ?? null, hasParagraphProperties = (elements = []) => elements.some((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME), cloneParagraphPropertiesForRenderedResult = (paragraphProperties) => {
106208
+ const elements = (paragraphProperties.elements || []).filter((element) => element?.name !== "w:sectPr").map((element) => carbonCopy(element));
106209
+ if (elements.length === 0)
106210
+ return null;
106211
+ return {
106212
+ ...carbonCopy(paragraphProperties),
106213
+ elements
106214
+ };
106215
+ }, inheritWrapperParagraphProperties = (blockFieldElement, paragraphProperties) => {
106216
+ if (!paragraphProperties)
106217
+ return blockFieldElement;
106218
+ const fieldElements = Array.isArray(blockFieldElement?.elements) ? blockFieldElement.elements : [];
106219
+ const firstParagraphIndex = fieldElements.findIndex((element) => element?.name === "w:p");
106220
+ if (firstParagraphIndex < 0)
106221
+ return blockFieldElement;
106222
+ const firstParagraph = fieldElements[firstParagraphIndex];
106223
+ const firstParagraphElements = Array.isArray(firstParagraph.elements) ? firstParagraph.elements : [];
106224
+ if (hasParagraphProperties(firstParagraphElements))
106225
+ return blockFieldElement;
106226
+ const renderedParagraphProperties = cloneParagraphPropertiesForRenderedResult(paragraphProperties);
106227
+ const inheritedFirstParagraph = {
106228
+ ...firstParagraph,
106229
+ elements: renderedParagraphProperties ? [renderedParagraphProperties, ...firstParagraphElements] : firstParagraphElements
106230
+ };
106231
+ return {
106232
+ ...blockFieldElement,
106233
+ attributes: {
106234
+ ...blockFieldElement.attributes || {},
106235
+ wrapperParagraphProperties: carbonCopy(paragraphProperties)
106236
+ },
106237
+ elements: fieldElements.map((element, index2) => index2 === firstParagraphIndex ? inheritedFirstParagraph : element)
106238
+ };
106239
+ }, hoistBlockFieldNodes = (params, paragraphNode) => {
106240
+ const paragraphElements = Array.isArray(paragraphNode?.elements) ? paragraphNode.elements : [];
106241
+ const blockFieldElements = paragraphElements.filter((element) => BLOCK_FIELD_XML_NAMES.has(element?.name));
106242
+ if (blockFieldElements.length === 0)
106243
+ return null;
106244
+ const nodes = [];
106245
+ const remainingElements = paragraphElements.filter((element) => !BLOCK_FIELD_XML_NAMES.has(element?.name));
106246
+ const wrapperParagraphProperties = findParagraphProperties(remainingElements);
106247
+ const shouldTransferWrapperProperties = !hasMeaningfulParagraphContent(remainingElements);
106248
+ if (hasMeaningfulParagraphContent(remainingElements)) {
106249
+ const paragraph2 = translator.encode({
106250
+ ...params,
106251
+ nodes: [{
106252
+ ...paragraphNode,
106253
+ elements: remainingElements
106254
+ }]
106255
+ });
106256
+ if (paragraph2)
106257
+ nodes.push(paragraph2);
106258
+ }
106259
+ blockFieldElements.forEach((blockFieldElement) => {
106260
+ const fieldElement = shouldTransferWrapperProperties ? inheritWrapperParagraphProperties(blockFieldElement, wrapperParagraphProperties) : blockFieldElement;
106261
+ nodes.push(...params.nodeListHandler.handler({
106262
+ ...params,
106263
+ nodes: [fieldElement],
106264
+ path: [...params.path || [], paragraphNode]
106265
+ }));
106266
+ });
106267
+ return nodes;
106268
+ }, handleParagraphNode$1 = (params) => {
106269
+ const { nodes } = params;
106270
+ if (nodes.length === 0 || nodes[0].name !== "w:p")
106271
+ return {
106272
+ nodes: [],
106273
+ consumed: 0
106274
+ };
106275
+ const hoistedNodes = hoistBlockFieldNodes(params, nodes[0]);
106276
+ if (hoistedNodes)
106277
+ return {
106278
+ nodes: hoistedNodes,
106279
+ consumed: 1
106280
+ };
106281
+ const schemaNode = translator.encode(params);
106282
+ return {
106283
+ nodes: Array.isArray(schemaNode) ? schemaNode : schemaNode ? [schemaNode] : [],
106284
+ consumed: 1
106285
+ };
106286
+ }, paragraphNodeHandlerEntity, DRAWING_XML_TAG = "w:drawing", SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", SD_IMAGE_ID_NAMESPACE = "7c9e6679-7425-40de-944b-e07fc1f90ae7", normalizeTargetPath$1 = (targetPath = "") => {
105850
106287
  if (!targetPath)
105851
106288
  return targetPath;
105852
106289
  const trimmed = targetPath.replace(/^\/+/, "");
@@ -105949,6 +106386,35 @@ var isRegExp = (value) => {
105949
106386
  if (result)
105950
106387
  return result;
105951
106388
  }
106389
+ if (wsp.elements?.find((el) => el.name === "wps:cNvSpPr")?.attributes?.["txBox"] === "1" && textBoxContent) {
106390
+ const bodyPr = wsp.elements?.find((el) => el.name === "wps:bodyPr");
106391
+ const drawingNode = params.nodes?.[0];
106392
+ const result = importDrawingMLTextbox({
106393
+ params,
106394
+ drawingNode: drawingNode?.name === "w:drawing" ? drawingNode : null,
106395
+ textBoxContent,
106396
+ bodyPr,
106397
+ baseAttrs: {
106398
+ width: size?.width,
106399
+ height: size?.height,
106400
+ marginOffset,
106401
+ anchorData,
106402
+ wrap: wrap$1,
106403
+ isAnchor,
106404
+ isTextBox: true,
106405
+ originalAttributes: node2?.attributes,
106406
+ ...params.nodes?.[0]?.name === "w:drawing" ? { drawingContent: params.nodes[0] } : {}
106407
+ },
106408
+ paragraphImporter: params?.nodeListHandler != null ? undefined : (paragraph2) => {
106409
+ const imported = paragraphToPmParagraph(paragraph2, params);
106410
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
106411
+ }
106412
+ });
106413
+ if (result?.attrs && isHidden)
106414
+ result.attrs.hidden = true;
106415
+ if (result)
106416
+ return result;
106417
+ }
105952
106418
  const placeholder = buildShapePlaceholder(node2, size, padding, marginOffset, textBoxContent ? "textbox" : "drawing");
105953
106419
  if (placeholder?.attrs && isHidden)
105954
106420
  placeholder.attrs.hidden = true;
@@ -111942,86 +112408,7 @@ var isRegExp = (value) => {
111942
112408
  nodes: [resultNode],
111943
112409
  consumed: 1
111944
112410
  };
111945
- }, textNodeHandlerEntity, PARAGRAPH_PROPERTIES_XML_NAME = "w:pPr", hasMeaningfulParagraphContent = (elements = []) => elements.some((element) => element?.name && element.name !== PARAGRAPH_PROPERTIES_XML_NAME), findParagraphProperties = (elements = []) => elements.find((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME) ?? null, hasParagraphProperties = (elements = []) => elements.some((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME), cloneParagraphPropertiesForRenderedResult = (paragraphProperties) => {
111946
- const elements = (paragraphProperties.elements || []).filter((element) => element?.name !== "w:sectPr").map((element) => carbonCopy(element));
111947
- if (elements.length === 0)
111948
- return null;
111949
- return {
111950
- ...carbonCopy(paragraphProperties),
111951
- elements
111952
- };
111953
- }, inheritWrapperParagraphProperties = (blockFieldElement, paragraphProperties) => {
111954
- if (!paragraphProperties)
111955
- return blockFieldElement;
111956
- const fieldElements = Array.isArray(blockFieldElement?.elements) ? blockFieldElement.elements : [];
111957
- const firstParagraphIndex = fieldElements.findIndex((element) => element?.name === "w:p");
111958
- if (firstParagraphIndex < 0)
111959
- return blockFieldElement;
111960
- const firstParagraph = fieldElements[firstParagraphIndex];
111961
- const firstParagraphElements = Array.isArray(firstParagraph.elements) ? firstParagraph.elements : [];
111962
- if (hasParagraphProperties(firstParagraphElements))
111963
- return blockFieldElement;
111964
- const renderedParagraphProperties = cloneParagraphPropertiesForRenderedResult(paragraphProperties);
111965
- const inheritedFirstParagraph = {
111966
- ...firstParagraph,
111967
- elements: renderedParagraphProperties ? [renderedParagraphProperties, ...firstParagraphElements] : firstParagraphElements
111968
- };
111969
- return {
111970
- ...blockFieldElement,
111971
- attributes: {
111972
- ...blockFieldElement.attributes || {},
111973
- wrapperParagraphProperties: carbonCopy(paragraphProperties)
111974
- },
111975
- elements: fieldElements.map((element, index2) => index2 === firstParagraphIndex ? inheritedFirstParagraph : element)
111976
- };
111977
- }, hoistBlockFieldNodes = (params, paragraphNode) => {
111978
- const paragraphElements = Array.isArray(paragraphNode?.elements) ? paragraphNode.elements : [];
111979
- const blockFieldElements = paragraphElements.filter((element) => BLOCK_FIELD_XML_NAMES.has(element?.name));
111980
- if (blockFieldElements.length === 0)
111981
- return null;
111982
- const nodes = [];
111983
- const remainingElements = paragraphElements.filter((element) => !BLOCK_FIELD_XML_NAMES.has(element?.name));
111984
- const wrapperParagraphProperties = findParagraphProperties(remainingElements);
111985
- const shouldTransferWrapperProperties = !hasMeaningfulParagraphContent(remainingElements);
111986
- if (hasMeaningfulParagraphContent(remainingElements)) {
111987
- const paragraph2 = translator.encode({
111988
- ...params,
111989
- nodes: [{
111990
- ...paragraphNode,
111991
- elements: remainingElements
111992
- }]
111993
- });
111994
- if (paragraph2)
111995
- nodes.push(paragraph2);
111996
- }
111997
- blockFieldElements.forEach((blockFieldElement) => {
111998
- const fieldElement = shouldTransferWrapperProperties ? inheritWrapperParagraphProperties(blockFieldElement, wrapperParagraphProperties) : blockFieldElement;
111999
- nodes.push(...params.nodeListHandler.handler({
112000
- ...params,
112001
- nodes: [fieldElement],
112002
- path: [...params.path || [], paragraphNode]
112003
- }));
112004
- });
112005
- return nodes;
112006
- }, handleParagraphNode$1 = (params) => {
112007
- const { nodes } = params;
112008
- if (nodes.length === 0 || nodes[0].name !== "w:p")
112009
- return {
112010
- nodes: [],
112011
- consumed: 0
112012
- };
112013
- const hoistedNodes = hoistBlockFieldNodes(params, nodes[0]);
112014
- if (hoistedNodes)
112015
- return {
112016
- nodes: hoistedNodes,
112017
- consumed: 1
112018
- };
112019
- const schemaNode = translator.encode(params);
112020
- return {
112021
- nodes: Array.isArray(schemaNode) ? schemaNode : schemaNode ? [schemaNode] : [],
112022
- consumed: 1
112023
- };
112024
- }, paragraphNodeHandlerEntity, handleSdtNode = (params) => {
112411
+ }, textNodeHandlerEntity, handleSdtNode = (params) => {
112025
112412
  const { nodes } = params;
112026
112413
  if (nodes.length === 0 || nodes[0].name !== "w:sdt")
112027
112414
  return {
@@ -116889,7 +117276,186 @@ var isRegExp = (value) => {
116889
117276
  if (toBoolean(attrs.hidden) === true)
116890
117277
  return true;
116891
117278
  return typeof attrs.visibility === "string" && attrs.visibility.toLowerCase() === "hidden";
116892
- }, normalizeWrapType$1 = (value) => {
117279
+ }, TEXTBOX_CONTAINER_TYPES, resolveTextFormattingFromMarks = (marks) => {
117280
+ if (!Array.isArray(marks) || marks.length === 0)
117281
+ return;
117282
+ const formatting = {};
117283
+ marks.forEach((mark) => {
117284
+ if (!mark || typeof mark.type !== "string")
117285
+ return;
117286
+ const attrs = isPlainObject4(mark.attrs) ? mark.attrs : {};
117287
+ if (mark.type === "bold")
117288
+ formatting.bold = true;
117289
+ if (mark.type === "italic")
117290
+ formatting.italic = true;
117291
+ const color2 = typeof attrs.color === "string" ? attrs.color.replace(/^#/, "") : undefined;
117292
+ if (color2)
117293
+ formatting.color = color2;
117294
+ const fontFamily = typeof attrs.fontFamily === "string" ? attrs.fontFamily : undefined;
117295
+ if (fontFamily)
117296
+ formatting.fontFamily = fontFamily;
117297
+ const fontSize = pickNumber(attrs.fontSize);
117298
+ if (fontSize != null)
117299
+ formatting.fontSize = fontSize;
117300
+ });
117301
+ return Object.keys(formatting).length > 0 ? formatting : undefined;
117302
+ }, pushTextPart = (parts, part) => {
117303
+ if (!part.text && !part.fieldType && !part.isLineBreak)
117304
+ return;
117305
+ parts.push(part);
117306
+ }, extractTextPartsFromTextboxInline = (node2, parts) => {
117307
+ if (!node2)
117308
+ return;
117309
+ const formatting = resolveTextFormattingFromMarks(node2.marks);
117310
+ if (typeof node2.text === "string") {
117311
+ pushTextPart(parts, {
117312
+ text: node2.text,
117313
+ ...formatting ? { formatting } : {}
117314
+ });
117315
+ return;
117316
+ }
117317
+ switch (node2.type) {
117318
+ case "text":
117319
+ pushTextPart(parts, {
117320
+ text: "",
117321
+ ...formatting ? { formatting } : {}
117322
+ });
117323
+ return;
117324
+ case "tab":
117325
+ pushTextPart(parts, {
117326
+ text: "\t",
117327
+ ...formatting ? { formatting } : {}
117328
+ });
117329
+ return;
117330
+ case "lineBreak":
117331
+ pushTextPart(parts, {
117332
+ text: `
117333
+ `,
117334
+ isLineBreak: true,
117335
+ ...formatting ? { formatting } : {}
117336
+ });
117337
+ return;
117338
+ case "page-number":
117339
+ pushTextPart(parts, {
117340
+ text: "",
117341
+ fieldType: "PAGE",
117342
+ pageNumberFormat: typeof node2.attrs?.pageNumberFormat === "string" ? node2.attrs.pageNumberFormat : undefined,
117343
+ ...formatting ? { formatting } : {}
117344
+ });
117345
+ return;
117346
+ case "total-page-number":
117347
+ pushTextPart(parts, {
117348
+ text: typeof node2.attrs?.resolvedText === "string" ? node2.attrs.resolvedText : typeof node2.attrs?.importedCachedText === "string" ? node2.attrs.importedCachedText : "",
117349
+ fieldType: "NUMPAGES",
117350
+ pageNumberFormat: typeof node2.attrs?.pageNumberFormat === "string" ? node2.attrs.pageNumberFormat : undefined,
117351
+ ...formatting ? { formatting } : {}
117352
+ });
117353
+ return;
117354
+ default:
117355
+ break;
117356
+ }
117357
+ if (Array.isArray(node2.content) && (TEXTBOX_CONTAINER_TYPES.has(node2.type) || node2.content.length > 0))
117358
+ node2.content.forEach((child) => extractTextPartsFromTextboxInline(child, parts));
117359
+ }, extractTextboxTextContent = (node2) => {
117360
+ if (!Array.isArray(node2.content) || node2.content.length === 0)
117361
+ return;
117362
+ const parts = [];
117363
+ let horizontalAlign;
117364
+ const paragraphs = node2.content.filter((child) => child?.type === "paragraph");
117365
+ const paragraphHasRenderableContent = (paragraph2) => Array.isArray(paragraph2.content) && paragraph2.content.length > 0;
117366
+ paragraphs.forEach((paragraph2, paragraphIndex) => {
117367
+ const justification = paragraph2.attrs?.paragraphProperties;
117368
+ if (!horizontalAlign && isPlainObject4(justification)) {
117369
+ const value = justification.justification;
117370
+ if (value === "left" || value === "center" || value === "right")
117371
+ horizontalAlign = value;
117372
+ }
117373
+ paragraph2.content?.forEach((child) => extractTextPartsFromTextboxInline(child, parts));
117374
+ if (paragraphIndex < paragraphs.length - 1) {
117375
+ const nextParagraph = paragraphs[paragraphIndex + 1];
117376
+ parts.push({
117377
+ text: `
117378
+ `,
117379
+ isLineBreak: true,
117380
+ isEmptyParagraph: !paragraphHasRenderableContent(paragraph2) || !paragraphHasRenderableContent(nextParagraph)
117381
+ });
117382
+ }
117383
+ });
117384
+ return parts.length > 0 ? {
117385
+ parts,
117386
+ ...horizontalAlign ? { horizontalAlign } : {}
117387
+ } : undefined;
117388
+ }, isParagraphNode = (node2) => node2?.type === "paragraph", toTextboxParagraphBlocks = (node2, context) => {
117389
+ const shapeTextboxNode = node2.type === "shapeTextbox" ? node2 : resolveNestedShapeTextboxNode(node2);
117390
+ const paragraphToFlowBlocks$1 = context.converters?.paragraphToFlowBlocks;
117391
+ if (!shapeTextboxNode || !paragraphToFlowBlocks$1 || !Array.isArray(shapeTextboxNode.content))
117392
+ return [];
117393
+ const textboxBlocks = [];
117394
+ for (const child of shapeTextboxNode.content) {
117395
+ if (!isParagraphNode(child))
117396
+ continue;
117397
+ const convertedBlocks = paragraphToFlowBlocks$1({
117398
+ para: child,
117399
+ nextBlockId: context.nextBlockId,
117400
+ positions: context.positions,
117401
+ storyKey: context.storyKey,
117402
+ trackedChangesConfig: context.trackedChangesConfig,
117403
+ bookmarks: context.bookmarks,
117404
+ hyperlinkConfig: context.hyperlinkConfig,
117405
+ themeColors: context.themeColors,
117406
+ converters: context.converters,
117407
+ converterContext: context.converterContext,
117408
+ enableComments: context.enableComments,
117409
+ previousParagraphFont: getLastParagraphFont(textboxBlocks)
117410
+ });
117411
+ textboxBlocks.push(...convertedBlocks);
117412
+ }
117413
+ return textboxBlocks.filter((block) => block.kind === "paragraph");
117414
+ }, parseTextboxInsetValue = (value) => {
117415
+ const trimmed = value.trim();
117416
+ if (!trimmed)
117417
+ return;
117418
+ if (trimmed.endsWith("pt"))
117419
+ return ptToPx(parseFloat(trimmed.slice(0, -2)));
117420
+ if (trimmed.endsWith("px"))
117421
+ return pickNumber(trimmed.slice(0, -2));
117422
+ if (trimmed.endsWith("in")) {
117423
+ const inches = parseFloat(trimmed.slice(0, -2));
117424
+ return Number.isFinite(inches) ? inches * 96 : undefined;
117425
+ }
117426
+ return pickNumber(trimmed);
117427
+ }, resolveTextboxInsetsFromAttrs = (attrs) => {
117428
+ const explicitInsets = normalizeTextInsets(attrs.textInsets);
117429
+ if (explicitInsets)
117430
+ return explicitInsets;
117431
+ const textboxAttrs = isPlainObject4(attrs.attributes) ? attrs.attributes : undefined;
117432
+ const inset = typeof textboxAttrs?.inset === "string" ? textboxAttrs.inset : undefined;
117433
+ if (!inset)
117434
+ return;
117435
+ const values = inset.split(",").map((entry) => parseTextboxInsetValue(entry));
117436
+ if (values.length !== 4 || values.some((entry) => entry == null))
117437
+ return;
117438
+ return {
117439
+ top: values[1],
117440
+ right: values[2],
117441
+ bottom: values[3],
117442
+ left: values[0]
117443
+ };
117444
+ }, resolveTextboxVerticalAlignFromAttrs = (attrs) => {
117445
+ const explicitAlign = normalizeTextVerticalAlign(attrs.textVerticalAlign);
117446
+ if (explicitAlign)
117447
+ return explicitAlign;
117448
+ const textboxAttrs = isPlainObject4(attrs.attributes) ? attrs.attributes : undefined;
117449
+ const style = typeof textboxAttrs?.style === "string" ? textboxAttrs.style : undefined;
117450
+ if (!style)
117451
+ return;
117452
+ const match = style.match(/v-text-anchor\s*:\s*(top|middle|bottom)/i);
117453
+ if (!match)
117454
+ return;
117455
+ if (match[1].toLowerCase() === "middle")
117456
+ return "center";
117457
+ return match[1].toLowerCase();
117458
+ }, resolveNestedShapeTextboxNode = (node2) => Array.isArray(node2.content) ? node2.content.find((child) => child?.type === "shapeTextbox") : undefined, normalizeWrapType$1 = (value) => {
116893
117459
  if (typeof value !== "string")
116894
117460
  return;
116895
117461
  return WRAP_TYPES$2.has(value) ? value : undefined;
@@ -117606,13 +118172,13 @@ var isRegExp = (value) => {
117606
118172
  if (childNode.type === "shapeContainer" && context.converters?.shapeContainerNodeToDrawingBlock) {
117607
118173
  const drawingBlock = context.converters.shapeContainerNodeToDrawingBlock(childNode, context.nextBlockId, context.positions);
117608
118174
  if (drawingBlock && drawingBlock.kind === "drawing")
117609
- blocks.push(drawingBlock);
118175
+ blocks.push(hydrateTextboxDrawingContent(childNode, drawingBlock, context));
117610
118176
  continue;
117611
118177
  }
117612
118178
  if (childNode.type === "shapeTextbox" && context.converters?.shapeTextboxNodeToDrawingBlock) {
117613
118179
  const drawingBlock = context.converters.shapeTextboxNodeToDrawingBlock(childNode, context.nextBlockId, context.positions);
117614
118180
  if (drawingBlock && drawingBlock.kind === "drawing")
117615
- blocks.push(drawingBlock);
118181
+ blocks.push(hydrateTextboxDrawingContent(childNode, drawingBlock, context));
117616
118182
  continue;
117617
118183
  }
117618
118184
  }
@@ -118172,7 +118738,7 @@ var isRegExp = (value) => {
118172
118738
  state.kern = kernNode.attributes["w:val"];
118173
118739
  }
118174
118740
  }, SuperConverter;
118175
- var init_SuperConverter_BTGVElJO_es = __esm(() => {
118741
+ var init_SuperConverter_CUxtXQFf_es = __esm(() => {
118176
118742
  init_rolldown_runtime_Bg48TavK_es();
118177
118743
  init_jszip_C49i9kUs_es();
118178
118744
  init_xml_js_CqGKpaft_es();
@@ -134933,6 +135499,7 @@ var init_SuperConverter_BTGVElJO_es = __esm(() => {
134933
135499
  "w:footnoteReference": "FootnoteReference",
134934
135500
  "w:endnoteReference": "EndnoteReference"
134935
135501
  };
135502
+ BLOCK_HOIST_TYPES = new Set(["shapeContainer"]);
134936
135503
  COMPLEX_SCRIPT_CODEPOINT_RANGES = [
134937
135504
  [1424, 2303],
134938
135505
  [2304, 4255],
@@ -147018,6 +147585,10 @@ var init_SuperConverter_BTGVElJO_es = __esm(() => {
147018
147585
  "c:surface3DChart": "surfaceChart"
147019
147586
  };
147020
147587
  CHART_TYPE_NAMES = new Set(Object.keys(CHART_TYPE_MAP));
147588
+ paragraphNodeHandlerEntity = {
147589
+ handlerName: "paragraphNodeHandler",
147590
+ handler: handleParagraphNode$1
147591
+ };
147021
147592
  atomElements = /^(img|br|input|textarea|hr)$/i;
147022
147593
  nav = typeof navigator != "undefined" ? navigator : null;
147023
147594
  doc2 = typeof document != "undefined" ? document : null;
@@ -154754,10 +155325,6 @@ var init_SuperConverter_BTGVElJO_es = __esm(() => {
154754
155325
  handlerName: "textNodeHandler",
154755
155326
  handler: handleTextNode
154756
155327
  };
154757
- paragraphNodeHandlerEntity = {
154758
- handlerName: "paragraphNodeHandler",
154759
- handler: handleParagraphNode$1
154760
- };
154761
155328
  sdtNodeHandlerEntity = {
154762
155329
  handlerName: "sdtNodeHandler",
154763
155330
  handler: handleSdtNode
@@ -156455,6 +157022,11 @@ var init_SuperConverter_BTGVElJO_es = __esm(() => {
156455
157022
  style: "normal",
156456
157023
  file: "Caprasimo-Regular.woff2"
156457
157024
  }]),
157025
+ familyWithFaces("Archivo Black", "OFL-1.1", [{
157026
+ weight: "normal",
157027
+ style: "normal",
157028
+ file: "ArchivoBlack-Regular.woff2"
157029
+ }]),
156458
157030
  familyWithFaces("C059", "AGPL-3.0-only WITH PS-or-PDF-font-exception-20170817", [
156459
157031
  {
156460
157032
  weight: "normal",
@@ -156524,7 +157096,16 @@ var init_SuperConverter_BTGVElJO_es = __esm(() => {
156524
157096
  style: "normal",
156525
157097
  file: "NotoSansMono-Bold.woff2"
156526
157098
  }]),
156527
- family("PT Sans", "PTSans", "OFL-1.1")
157099
+ family("PT Sans", "PTSans", "OFL-1.1"),
157100
+ familyWithFaces("PT Sans Narrow", "OFL-1.1", [{
157101
+ weight: "normal",
157102
+ style: "normal",
157103
+ file: "PTSansNarrow-Regular.woff2"
157104
+ }, {
157105
+ weight: "bold",
157106
+ style: "normal",
157107
+ file: "PTSansNarrow-Bold.woff2"
157108
+ }])
156528
157109
  ]);
156529
157110
  SUBSTITUTION_EVIDENCE = SUBSTITUTION_EVIDENCE$1;
156530
157111
  bundledFamilies = new Set(BUNDLED_MANIFEST.map((f2) => f2.family));
@@ -156541,6 +157122,7 @@ var init_SuperConverter_BTGVElJO_es = __esm(() => {
156541
157122
  registriesByFontSet = /* @__PURE__ */ new WeakMap;
156542
157123
  BUNDLED_FAMILIES = new Set(BUNDLED_MANIFEST.map((f2) => f2.family));
156543
157124
  ADVERTISED_BUILT_IN_TOOLBAR_FAMILIES = new Set([
157125
+ "Arial Black",
156544
157126
  "Arial Narrow",
156545
157127
  "Baskerville Old Face",
156546
157128
  "Brush Script MT",
@@ -156549,6 +157131,7 @@ var init_SuperConverter_BTGVElJO_es = __esm(() => {
156549
157131
  "Comic Sans MS",
156550
157132
  "Garamond",
156551
157133
  "Georgia",
157134
+ "Gill Sans MT Condensed",
156552
157135
  "Lucida Console",
156553
157136
  "Tahoma",
156554
157137
  "Trebuchet MS"
@@ -156838,6 +157421,14 @@ var init_SuperConverter_BTGVElJO_es = __esm(() => {
156838
157421
  "center",
156839
157422
  "bottom"
156840
157423
  ]);
157424
+ TEXTBOX_CONTAINER_TYPES = new Set([
157425
+ "run",
157426
+ "link",
157427
+ "hyperlink",
157428
+ "structuredContent",
157429
+ "fieldAnnotation",
157430
+ "smartTag"
157431
+ ]);
156841
157432
  WRAP_TYPES$1 = new Set([
156842
157433
  "None",
156843
157434
  "Square",
@@ -158340,7 +158931,7 @@ var init_SuperConverter_BTGVElJO_es = __esm(() => {
158340
158931
  };
158341
158932
  });
158342
158933
 
158343
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DYbkX05s.es.js
158934
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DutCjfp2.es.js
158344
158935
  function parseSizeUnit(val = "0") {
158345
158936
  const length = val.toString() || "0";
158346
158937
  const value = Number.parseFloat(length);
@@ -168735,8 +169326,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
168735
169326
  }
168736
169327
  };
168737
169328
  };
168738
- var init_create_headless_toolbar_DYbkX05s_es = __esm(() => {
168739
- init_SuperConverter_BTGVElJO_es();
169329
+ var init_create_headless_toolbar_DutCjfp2_es = __esm(() => {
169330
+ init_SuperConverter_CUxtXQFf_es();
168740
169331
  init_uuid_B2wVPhPi_es();
168741
169332
  init_constants_D9qj59G2_es();
168742
169333
  init_dist_B8HfvhaK_es();
@@ -223426,7 +224017,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
223426
224017
  init_remark_gfm_BhnWr3yf_es();
223427
224018
  });
223428
224019
 
223429
- // ../../packages/superdoc/dist/chunks/src-CRJcfbIa.es.js
224020
+ // ../../packages/superdoc/dist/chunks/src-BBtIMpLJ.es.js
223430
224021
  function deleteProps(obj, propOrProps) {
223431
224022
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
223432
224023
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -264408,7 +264999,7 @@ function hasPageContextTokenInBlock(block) {
264408
264999
  return true;
264409
265000
  } else if (block.kind === "drawing") {
264410
265001
  const drawing = block;
264411
- if (drawing.drawingKind === "vectorShape")
265002
+ if (drawing.drawingKind === "vectorShape" || drawing.drawingKind === "textboxShape")
264412
265003
  return hasPageContextTokenInShapeText(drawing.textContent);
264413
265004
  if (drawing.drawingKind === "shapeGroup")
264414
265005
  return hasPageContextTokenInShapeGroup(drawing.shapes);
@@ -266065,6 +266656,18 @@ function computeParagraphLayoutStartY(input2) {
266065
266656
  const effectiveSpacingBefore = input2.suppressSpacingBefore ? 0 : input2.spacingBefore;
266066
266657
  return computeParagraphContentStartY(y$1, effectiveSpacingBefore, effectiveSpacingBefore === 0, trailingForCollapse);
266067
266658
  }
266659
+ function layoutTextboxContent(block, remeasureParagraph$1) {
266660
+ if (!Array.isArray(block.contentBlocks) || block.contentBlocks.length === 0)
266661
+ return [];
266662
+ const insets = block.textInsets ?? {
266663
+ top: 0,
266664
+ right: 0,
266665
+ bottom: 0,
266666
+ left: 0
266667
+ };
266668
+ const contentWidth = Math.max(1, block.geometry.width - insets.left - insets.right);
266669
+ return block.contentBlocks.map((paragraphBlock) => remeasureParagraph$1(paragraphBlock, contentWidth));
266670
+ }
266068
266671
  function describeCellRenderBlocks(cellMeasure, cellBlock, cellPadding) {
266069
266672
  const measuredBlocks = cellMeasure.blocks;
266070
266673
  const blockDataArray = cellBlock?.blocks;
@@ -267529,6 +268132,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
267529
268132
  fragment.pmEnd = pmRange.pmEnd;
267530
268133
  state.page.fragments.push(fragment);
267531
268134
  } else if (entry.block.kind === "drawing" && entry.measure.kind === "drawing") {
268135
+ const contentMeasures = entry.block.drawingKind === "textboxShape" && typeof remeasureParagraph$1 === "function" ? layoutTextboxContent(entry.block, remeasureParagraph$1) : undefined;
267532
268136
  const fragment = {
267533
268137
  kind: "drawing",
267534
268138
  blockId: entry.block.id,
@@ -267545,6 +268149,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
267545
268149
  drawingContentId: entry.block.drawingContentId,
267546
268150
  sourceAnchor: entry.block.sourceAnchor
267547
268151
  };
268152
+ if (contentMeasures)
268153
+ fragment.contentMeasures = contentMeasures;
267548
268154
  if (pmRange.pmStart != null)
267549
268155
  fragment.pmStart = pmRange.pmStart;
267550
268156
  if (pmRange.pmEnd != null)
@@ -267953,7 +268559,7 @@ function layoutImageBlock({ block, measure, columns, ensurePage, advanceColumn,
267953
268559
  state.cursorY += requiredHeight;
267954
268560
  state.maxCursorY = Math.max(state.maxCursorY, state.cursorY);
267955
268561
  }
267956
- function layoutDrawingBlock({ block, measure, columns, ensurePage, advanceColumn, columnX }) {
268562
+ function layoutDrawingBlock({ block, measure, columns, ensurePage, advanceColumn, columnX, textboxContentMeasures }) {
267957
268563
  if (block.anchor?.isAnchored)
267958
268564
  return;
267959
268565
  const marginTop = Math.max(0, block.margin?.top ?? 0);
@@ -268010,6 +268616,8 @@ function layoutDrawingBlock({ block, measure, columns, ensurePage, advanceColumn
268010
268616
  pmEnd: pmRange.pmEnd,
268011
268617
  sourceAnchor: block.sourceAnchor
268012
268618
  };
268619
+ if (textboxContentMeasures)
268620
+ fragment.contentMeasures = textboxContentMeasures;
268013
268621
  state.page.fragments.push(fragment);
268014
268622
  state.cursorY += requiredHeight;
268015
268623
  state.maxCursorY = Math.max(state.maxCursorY, state.cursorY);
@@ -270443,6 +271051,7 @@ function layoutDocument(blocks2, measures, options = {}) {
270443
271051
  const state = paginator.ensurePage();
270444
271052
  const drawBlock = block;
270445
271053
  const drawMeasure = measure;
271054
+ const contentMeasures = drawBlock.drawingKind === "textboxShape" && typeof options.remeasureParagraph === "function" ? layoutTextboxContent(drawBlock, options.remeasureParagraph) : undefined;
270446
271055
  const fragment = {
270447
271056
  kind: "drawing",
270448
271057
  blockId: drawBlock.id,
@@ -270459,6 +271068,8 @@ function layoutDocument(blocks2, measures, options = {}) {
270459
271068
  drawingContentId: drawBlock.drawingContentId,
270460
271069
  sourceAnchor: drawBlock.sourceAnchor
270461
271070
  };
271071
+ if (contentMeasures)
271072
+ fragment.contentMeasures = contentMeasures;
270462
271073
  const attrs = drawBlock.attrs;
270463
271074
  if (attrs?.pmStart != null)
270464
271075
  fragment.pmStart = attrs.pmStart;
@@ -270474,7 +271085,8 @@ function layoutDocument(blocks2, measures, options = {}) {
270474
271085
  columns: getCurrentColumns(),
270475
271086
  ensurePage: paginator.ensurePage,
270476
271087
  advanceColumn: paginator.advanceColumn,
270477
- columnX
271088
+ columnX,
271089
+ textboxContentMeasures: block.drawingKind === "textboxShape" && typeof options.remeasureParagraph === "function" ? layoutTextboxContent(block, options.remeasureParagraph) : undefined
270478
271090
  });
270479
271091
  continue;
270480
271092
  }
@@ -270750,7 +271362,7 @@ function shouldExcludeFromMeasurement(fragment, block, fragmentBottom, canvasHei
270750
271362
  return true;
270751
271363
  return false;
270752
271364
  }
270753
- function layoutHeaderFooter(blocks2, measures, constraints, kind) {
271365
+ function layoutHeaderFooter(blocks2, measures, constraints, kind, remeasureParagraph$1) {
270754
271366
  if (blocks2.length !== measures.length)
270755
271367
  throw new Error(`layoutHeaderFooter expected measures for every block (blocks=${blocks2.length}, measures=${measures.length})`);
270756
271368
  const width = Number(constraints?.width);
@@ -270774,7 +271386,8 @@ function layoutHeaderFooter(blocks2, measures, constraints, kind) {
270774
271386
  left: 0
270775
271387
  },
270776
271388
  allowParagraphlessAnchoredTableFallback: false,
270777
- allowSectionBreakOnlyPageFallback: false
271389
+ allowSectionBreakOnlyPageFallback: false,
271390
+ remeasureParagraph: remeasureParagraph$1
270778
271391
  });
270779
271392
  if (kind === "footer" && constraints.pageHeight != null)
270780
271393
  normalizeFragmentsForRegion(layout.pages, blocks2, measures, kind, constraints);
@@ -271553,7 +272166,7 @@ function hasPageNumberTokensRequiringPerPageLayout(blocks2) {
271553
272166
  }
271554
272167
  return false;
271555
272168
  }
271556
- async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1, cache$2 = sharedHeaderFooterCache, totalPages, pageResolver, kind, fontSignature = "") {
272169
+ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1, cache$2 = sharedHeaderFooterCache, totalPages, pageResolver, kind, fontSignature = "", remeasureParagraph$1) {
271557
272170
  const result = {};
271558
272171
  if (!pageResolver) {
271559
272172
  const numPages = totalPages ?? 1;
@@ -271566,7 +272179,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
271566
272179
  result[type] = {
271567
272180
  blocks: clonedBlocks,
271568
272181
  measures,
271569
- layout: layoutHeaderFooter(clonedBlocks, measures, constraints, kind)
272182
+ layout: layoutHeaderFooter(clonedBlocks, measures, constraints, kind, remeasureParagraph$1)
271570
272183
  };
271571
272184
  }
271572
272185
  return result;
@@ -271583,7 +272196,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
271583
272196
  result[type] = {
271584
272197
  blocks: blocks2,
271585
272198
  measures,
271586
- layout: layoutHeaderFooter(blocks2, measures, constraints, kind)
272199
+ layout: layoutHeaderFooter(blocks2, measures, constraints, kind, remeasureParagraph$1)
271587
272200
  };
271588
272201
  continue;
271589
272202
  }
@@ -271605,7 +272218,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
271605
272218
  const { displayText, displayNumber, totalPages: totalPagesForPage, sectionPageCount, pageFormat, chapterNumberText, chapterSeparator } = pageResolver(pageNum);
271606
272219
  resolveHeaderFooterTokens(clonedBlocks, pageNum, totalPagesForPage, displayText, displayNumber, sectionPageCount, pageFormat, chapterNumberText, chapterSeparator);
271607
272220
  const measures = await cache$2.measureBlocks(clonedBlocks, constraints, measureBlock$1, fontSignature);
271608
- const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints, kind);
272221
+ const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints, kind, remeasureParagraph$1);
271609
272222
  const measuresById = /* @__PURE__ */ new Map;
271610
272223
  for (let i4 = 0;i4 < clonedBlocks.length; i4 += 1)
271611
272224
  measuresById.set(clonedBlocks[i4].id, measures[i4]);
@@ -272468,7 +273081,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
272468
273081
  const blocks2 = blocksByRId.get(group.rId);
272469
273082
  if (!blocks2 || blocks2.length === 0)
272470
273083
  continue;
272471
- const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, measureFn, headerMeasureCache, 1, pageResolver, kind)).default?.layout;
273084
+ const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, measureFn, headerMeasureCache, 1, pageResolver, kind, undefined, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent))).default?.layout;
272472
273085
  if (!layout$1 || !(layout$1.height > 0))
272473
273086
  continue;
272474
273087
  const nextHeight = Math.max(0, layout$1.height);
@@ -272485,7 +273098,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
272485
273098
  for (const [rId, blocks2] of blocksByRId) {
272486
273099
  if (!blocks2 || blocks2.length === 0)
272487
273100
  continue;
272488
- const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, measureFn, headerMeasureCache, 1, pageResolver, kind)).default?.layout;
273101
+ const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, measureFn, headerMeasureCache, 1, pageResolver, kind, undefined, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent))).default?.layout;
272489
273102
  if (layout$1 && layout$1.height > 0)
272490
273103
  heightsByRId.set(rId, layout$1.height);
272491
273104
  }
@@ -272507,7 +273120,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
272507
273120
  };
272508
273121
  headerContentHeights = {};
272509
273122
  if (hasHeaderBlocks && headerFooter.headerBlocks) {
272510
- const preHeaderLayouts = await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "header", fontSignature);
273123
+ const preHeaderLayouts = await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "header", fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent));
272511
273124
  for (const [type, value] of Object.entries(preHeaderLayouts)) {
272512
273125
  if (!isValidHeaderType(type))
272513
273126
  continue;
@@ -272548,7 +273161,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
272548
273161
  footerContentHeights = {};
272549
273162
  try {
272550
273163
  if (hasFooterBlocks && headerFooter.footerBlocks) {
272551
- const preFooterLayouts = await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "footer", fontSignature);
273164
+ const preFooterLayouts = await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "footer", fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent));
272552
273165
  for (const [type, value] of Object.entries(preFooterLayouts)) {
272553
273166
  if (!isValidFooterType(type))
272554
273167
  continue;
@@ -272637,6 +273250,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
272637
273250
  console.warn(`[incrementalLayout] Page token resolution did not converge after ${maxIterations} iterations - stopping`);
272638
273251
  }
272639
273252
  }
273253
+ hydrateTableTextboxMeasures(currentBlocks, (block, maxWidth) => remeasureParagraph(block, maxWidth));
272640
273254
  const totalTokenTime = performance.now() - pageTokenStart;
272641
273255
  if (iteration > 0) {
272642
273256
  perfLog$1(`[Perf] 4.3 Total page token resolution time: ${totalTokenTime.toFixed(2)}ms`);
@@ -273648,10 +274262,17 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
273648
274262
  chapterSeparator: displayInfo?.chapterSeparator
273649
274263
  };
273650
274264
  } : undefined;
273651
- if (headerFooter.headerBlocks)
273652
- headers = serializeHeaderFooterResults("header", await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "header", fontSignature));
273653
- if (headerFooter.footerBlocks)
273654
- footers = serializeHeaderFooterResults("footer", await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "footer", fontSignature));
274265
+ const hfRemeasure = (block, maxWidth) => remeasureParagraph(block, maxWidth);
274266
+ if (headerFooter.headerBlocks) {
274267
+ for (const blocks2 of Object.values(headerFooter.headerBlocks))
274268
+ hydrateTableTextboxMeasures(blocks2, hfRemeasure);
274269
+ headers = serializeHeaderFooterResults("header", await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "header", fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)));
274270
+ }
274271
+ if (headerFooter.footerBlocks) {
274272
+ for (const blocks2 of Object.values(headerFooter.footerBlocks))
274273
+ hydrateTableTextboxMeasures(blocks2, hfRemeasure);
274274
+ footers = serializeHeaderFooterResults("footer", await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "footer", fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)));
274275
+ }
273655
274276
  perfLog$1(`[Perf] 4.4 Header/footer layout: ${(performance.now() - hfStart).toFixed(2)}ms`);
273656
274277
  const cacheStats = headerMeasureCache.getStats();
273657
274278
  globalMetrics.recordHeaderFooterCacheMetrics(cacheStats);
@@ -273667,6 +274288,19 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
273667
274288
  extraMeasures
273668
274289
  };
273669
274290
  }
274291
+ function hydrateTableTextboxMeasures(blocks2, remeasure) {
274292
+ for (const block of blocks2) {
274293
+ if (block.kind !== "table")
274294
+ continue;
274295
+ for (const row2 of block.rows ?? [])
274296
+ for (const cell2 of row2.cells ?? [])
274297
+ for (const cellBlock of cell2.blocks ?? [])
274298
+ if (cellBlock.kind === "drawing" && cellBlock.drawingKind === "textboxShape")
274299
+ cellBlock.contentMeasures = layoutTextboxContent(cellBlock, remeasure);
274300
+ else if (cellBlock.kind === "table")
274301
+ hydrateTableTextboxMeasures([cellBlock], remeasure);
274302
+ }
274303
+ }
273670
274304
  function rewriteSectionBreaksForSemanticFlow(blocks2, options) {
273671
274305
  const semanticPageSize = options.pageSize;
273672
274306
  const semanticMargins = options.margins;
@@ -273945,41 +274579,6 @@ async function remeasureAffectedBlocks(blocks2, measures, affectedBlockIds, perB
273945
274579
  }
273946
274580
  return updatedMeasures;
273947
274581
  }
273948
- function calculateSummary(samples) {
273949
- if (samples.length === 0)
273950
- return {
273951
- count: 0,
273952
- min: 0,
273953
- max: 0,
273954
- avg: 0,
273955
- p50: 0,
273956
- p95: 0,
273957
- p99: 0
273958
- };
273959
- const values = samples.map((s2) => s2.value).sort((a2, b$1) => a2 - b$1);
273960
- const count = values.length;
273961
- const sum = values.reduce((acc, v) => acc + v, 0);
273962
- return {
273963
- count,
273964
- min: values[0],
273965
- max: values[count - 1],
273966
- avg: sum / count,
273967
- p50: percentile(values, 0.5),
273968
- p95: percentile(values, 0.95),
273969
- p99: percentile(values, 0.99)
273970
- };
273971
- }
273972
- function percentile(sortedValues, p$12) {
273973
- if (sortedValues.length === 0)
273974
- return 0;
273975
- if (sortedValues.length === 1)
273976
- return sortedValues[0];
273977
- const index2 = (sortedValues.length - 1) * p$12;
273978
- const lower = Math.floor(index2);
273979
- const upper = Math.ceil(index2);
273980
- const weight = index2 - lower;
273981
- return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight;
273982
- }
273983
274582
  function resolveColumnsForHit(layout, page, fragmentY) {
273984
274583
  if (page === undefined)
273985
274584
  return layout.columns;
@@ -274275,6 +274874,54 @@ function clickToPositionGeometry(layout, blocks2, measures, containerPoint, opti
274275
274874
  lineIndex
274276
274875
  };
274277
274876
  }
274877
+ if (fragment.kind === "drawing" && fragment.drawingKind === "textboxShape" && block.kind === "drawing" && block.drawingKind === "textboxShape") {
274878
+ const textboxHit = resolveTextboxContentHit(fragment, block, measure, pageIndex, pageRelativePoint);
274879
+ if (textboxHit) {
274880
+ const { contentBlock, contentMeasure, localX, localY, pageIndex: pageIndex$1, paragraphIndex } = textboxHit;
274881
+ const lineIndex = findLineIndexAtY(contentMeasure.lines, localY, 0, contentMeasure.lines.length);
274882
+ if (lineIndex != null) {
274883
+ const line = contentMeasure.lines[lineIndex];
274884
+ const isRTL = isRtlBlock(contentBlock);
274885
+ const indentLeft = typeof contentBlock.attrs?.indent?.left === "number" ? contentBlock.attrs.indent.left : 0;
274886
+ const indentRight = typeof contentBlock.attrs?.indent?.right === "number" ? contentBlock.attrs.indent.right : 0;
274887
+ const totalIndent = (Number.isFinite(indentLeft) ? indentLeft : 0) + (Number.isFinite(indentRight) ? indentRight : 0);
274888
+ const insets = textboxHit.block.textInsets ?? {
274889
+ top: 0,
274890
+ right: 0,
274891
+ bottom: 0,
274892
+ left: 0
274893
+ };
274894
+ let availableWidth = Math.max(0, textboxHit.fragment.width - insets.left - insets.right - totalIndent);
274895
+ if (totalIndent > textboxHit.fragment.width)
274896
+ console.warn(`[clickToPosition:textbox] Paragraph indents (${totalIndent}px) exceed fragment width (${textboxHit.fragment.width}px) for block ${textboxHit.fragment.blockId}. This may indicate a layout miscalculation. Available width clamped to 0.`);
274897
+ if (lineIndex === 0) {
274898
+ const suppressFLI = contentBlock.attrs?.suppressFirstLineIndent === true;
274899
+ const firstLineOffset = getFirstLineIndentOffset(contentBlock.attrs?.indent, suppressFLI);
274900
+ availableWidth = adjustAvailableWidthForTextIndent(availableWidth, firstLineOffset, line.maxWidth);
274901
+ }
274902
+ const pos = mapPointToPm(contentBlock, line, localX, isRTL, availableWidth);
274903
+ if (pos != null)
274904
+ return {
274905
+ pos,
274906
+ layoutEpoch,
274907
+ blockId: textboxHit.fragment.blockId,
274908
+ pageIndex: pageIndex$1,
274909
+ column: determineColumn(layout, textboxHit.fragment.x, layout.pages[pageIndex$1], textboxHit.fragment.y),
274910
+ lineIndex
274911
+ };
274912
+ }
274913
+ const firstRun = contentBlock.runs?.[0];
274914
+ if (firstRun && firstRun.pmStart != null)
274915
+ return {
274916
+ pos: firstRun.pmStart,
274917
+ layoutEpoch,
274918
+ blockId: textboxHit.fragment.blockId,
274919
+ pageIndex: pageIndex$1,
274920
+ column: determineColumn(layout, textboxHit.fragment.x, layout.pages[pageIndex$1], textboxHit.fragment.y),
274921
+ lineIndex: 0
274922
+ };
274923
+ }
274924
+ }
274278
274925
  if (isAtomicFragment(fragment)) {
274279
274926
  const pmRange = getAtomicPmRange(fragment, block);
274280
274927
  const pos = pmRange.pmStart ?? pmRange.pmEnd ?? null;
@@ -274352,6 +274999,41 @@ function clickToPositionGeometry(layout, blocks2, measures, containerPoint, opti
274352
274999
  }
274353
275000
  return null;
274354
275001
  }
275002
+ function calculateSummary(samples) {
275003
+ if (samples.length === 0)
275004
+ return {
275005
+ count: 0,
275006
+ min: 0,
275007
+ max: 0,
275008
+ avg: 0,
275009
+ p50: 0,
275010
+ p95: 0,
275011
+ p99: 0
275012
+ };
275013
+ const values = samples.map((s2) => s2.value).sort((a2, b$1) => a2 - b$1);
275014
+ const count = values.length;
275015
+ const sum = values.reduce((acc, v) => acc + v, 0);
275016
+ return {
275017
+ count,
275018
+ min: values[0],
275019
+ max: values[count - 1],
275020
+ avg: sum / count,
275021
+ p50: percentile(values, 0.5),
275022
+ p95: percentile(values, 0.95),
275023
+ p99: percentile(values, 0.99)
275024
+ };
275025
+ }
275026
+ function percentile(sortedValues, p$12) {
275027
+ if (sortedValues.length === 0)
275028
+ return 0;
275029
+ if (sortedValues.length === 1)
275030
+ return sortedValues[0];
275031
+ const index2 = (sortedValues.length - 1) * p$12;
275032
+ const lower = Math.floor(index2);
275033
+ const upper = Math.ceil(index2);
275034
+ const weight = index2 - lower;
275035
+ return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight;
275036
+ }
274355
275037
  function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper) {
274356
275038
  if (from$1 === to)
274357
275039
  return [];
@@ -277520,6 +278202,73 @@ function computeTableCaretLayoutRectFromDom({ viewportHost, visibleHost, zoom },
277520
278202
  }
277521
278203
  return null;
277522
278204
  }
278205
+ function findTextboxFragmentElement(viewportHost, blockId, pageIndex) {
278206
+ const pageEl = viewportHost.querySelector(`[data-page-index="${pageIndex}"]`) ?? viewportHost;
278207
+ return Array.from(pageEl.querySelectorAll("[data-block-id]")).find((el) => el.dataset.blockId === blockId) ?? null;
278208
+ }
278209
+ function computeTextboxCaretLayoutRectFromDom({ viewportHost, visibleHost, zoom }, pos, fragment, _block, pageIndex) {
278210
+ const fragmentEl = findTextboxFragmentElement(viewportHost, fragment.blockId, pageIndex);
278211
+ if (!fragmentEl)
278212
+ return null;
278213
+ const lineEls = Array.from(fragmentEl.querySelectorAll(".superdoc-line[data-pm-start][data-pm-end]"));
278214
+ if (lineEls.length === 0)
278215
+ return null;
278216
+ for (let lineIdx = 0;lineIdx < lineEls.length; lineIdx++) {
278217
+ const lineEl = lineEls[lineIdx];
278218
+ const pmStart = Number(lineEl.dataset.pmStart ?? "NaN");
278219
+ const pmEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
278220
+ if (!Number.isFinite(pmStart) || !Number.isFinite(pmEnd))
278221
+ continue;
278222
+ const isLastLine = lineIdx === lineEls.length - 1;
278223
+ if (pos < pmStart || (isLastLine ? pos > pmEnd : pos >= pmEnd))
278224
+ continue;
278225
+ const spanEls = Array.from(lineEl.querySelectorAll("span[data-pm-start][data-pm-end]"));
278226
+ for (let spanIdx = 0;spanIdx < spanEls.length; spanIdx++) {
278227
+ const spanEl = spanEls[spanIdx];
278228
+ const spanStart = Number(spanEl.dataset.pmStart ?? "NaN");
278229
+ const spanEnd = Number(spanEl.dataset.pmEnd ?? "NaN");
278230
+ if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd))
278231
+ continue;
278232
+ const isLastSpan = spanIdx === spanEls.length - 1;
278233
+ if (pos < spanStart || (isLastSpan ? pos > spanEnd : pos >= spanEnd))
278234
+ continue;
278235
+ const textNode = spanEl.firstChild;
278236
+ if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
278237
+ const spanRect = spanEl.getBoundingClientRect();
278238
+ const viewportRect$2 = viewportHost.getBoundingClientRect();
278239
+ return {
278240
+ pageIndex,
278241
+ x: (spanRect.left - viewportRect$2.left + visibleHost.scrollLeft) / zoom,
278242
+ y: (spanRect.top - viewportRect$2.top + visibleHost.scrollTop) / zoom,
278243
+ height: spanRect.height / zoom
278244
+ };
278245
+ }
278246
+ const text5 = textNode.textContent ?? "";
278247
+ const charOffset = Math.max(0, Math.min(text5.length, pos - spanStart));
278248
+ const range = document.createRange();
278249
+ range.setStart(textNode, charOffset);
278250
+ range.setEnd(textNode, charOffset);
278251
+ const rangeRect = range.getBoundingClientRect();
278252
+ const viewportRect$1 = viewportHost.getBoundingClientRect();
278253
+ const lineRect$1 = lineEl.getBoundingClientRect();
278254
+ return {
278255
+ pageIndex,
278256
+ x: (rangeRect.left - viewportRect$1.left + visibleHost.scrollLeft) / zoom,
278257
+ y: (lineRect$1.top - viewportRect$1.top + visibleHost.scrollTop) / zoom,
278258
+ height: lineRect$1.height / zoom
278259
+ };
278260
+ }
278261
+ const lineRect = lineEl.getBoundingClientRect();
278262
+ const viewportRect = viewportHost.getBoundingClientRect();
278263
+ return {
278264
+ pageIndex,
278265
+ x: (lineRect.left - viewportRect.left + visibleHost.scrollLeft) / zoom,
278266
+ y: (lineRect.top - viewportRect.top + visibleHost.scrollTop) / zoom,
278267
+ height: lineRect.height / zoom
278268
+ };
278269
+ }
278270
+ return null;
278271
+ }
277523
278272
  function findLineContainingPos(block, measure, fromLine, toLine, pos) {
277524
278273
  if (measure.kind !== "paragraph" || block.kind !== "paragraph")
277525
278274
  return null;
@@ -277576,6 +278325,12 @@ function computeCaretLayoutRectGeometry({ layout, blocks: blocks2, measures, pai
277576
278325
  visibleHost,
277577
278326
  zoom
277578
278327
  }, effectivePos, hit.fragment, block, measure, hit.pageIndex);
278328
+ if (hit.fragment.kind === "drawing" && block?.kind === "drawing" && block.drawingKind === "textboxShape" && measure?.kind === "drawing")
278329
+ return computeTextboxCaretLayoutRectFromDom({
278330
+ viewportHost,
278331
+ visibleHost,
278332
+ zoom
278333
+ }, effectivePos, hit.fragment, block, hit.pageIndex);
277579
278334
  if (!block || block.kind !== "paragraph" || measure?.kind !== "paragraph")
277580
278335
  return null;
277581
278336
  if (hit.fragment.kind !== "para")
@@ -282197,7 +282952,7 @@ async function layoutBlocksByRId(kind, blocksByRId, referencedRIds, constraints,
282197
282952
  if (!blocks2 || blocks2.length === 0)
282198
282953
  continue;
282199
282954
  try {
282200
- const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature);
282955
+ const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent));
282201
282956
  if (batchResult.default)
282202
282957
  layoutsByRId.set(rId, {
282203
282958
  kind,
@@ -282257,7 +283012,7 @@ async function layoutWithPerSectionConstraints(kind, blocksByRId, sectionMetadat
282257
283012
  if (!blocks2 || blocks2.length === 0)
282258
283013
  continue;
282259
283014
  try {
282260
- const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature);
283015
+ const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent));
282261
283016
  if (batchResult.default)
282262
283017
  for (const sectionIndex of group.sectionIndices) {
282263
283018
  const contentWidth = buildSectionContentWidth(sectionMetadata.find((s2) => s2.sectionIndex === sectionIndex), fallbackConstraints);
@@ -306249,6 +307004,7 @@ menclose::after {
306249
307004
  drawingWrapper.style.flexShrink = "0";
306250
307005
  drawingWrapper.style.maxWidth = "100%";
306251
307006
  drawingWrapper.style.boxSizing = "border-box";
307007
+ drawingWrapper.dataset.blockId = block.id;
306252
307008
  applySdtDataset$1(drawingWrapper, block.attrs);
306253
307009
  const drawingInner = doc$12.createElement("div");
306254
307010
  drawingInner.classList.add("superdoc-table-drawing");
@@ -306418,6 +307174,7 @@ menclose::after {
306418
307174
  drawingWrapper.style.maxWidth = "100%";
306419
307175
  drawingWrapper.style.boxSizing = "border-box";
306420
307176
  drawingWrapper.style.zIndex = String(zIndex);
307177
+ drawingWrapper.dataset.blockId = anchoredBlock.id;
306421
307178
  applySdtDataset$1(drawingWrapper, anchoredBlock.attrs);
306422
307179
  const drawingInner = doc$12.createElement("div");
306423
307180
  drawingInner.classList.add("superdoc-table-drawing");
@@ -310457,17 +311214,19 @@ menclose::after {
310457
311214
  throw new Error("DomPainter: document is not available");
310458
311215
  if (block.drawingKind === "image")
310459
311216
  return createDrawingImageElement(this.doc, block, this.buildImageHyperlinkAnchor.bind(this));
310460
- if (block.drawingKind === "vectorShape")
310461
- return this.createVectorShapeElement(block, fragment.geometry, false, 1, 1, context);
311217
+ if (block.drawingKind === "vectorShape" || block.drawingKind === "textboxShape")
311218
+ return this.createVectorShapeElement(block, fragment.geometry, false, 1, 1, context, fragment);
310462
311219
  if (block.drawingKind === "shapeGroup")
310463
311220
  return this.createShapeGroupElement(block, context);
310464
311221
  if (block.drawingKind === "chart")
310465
311222
  return this.createChartElement(block);
310466
311223
  return this.createDrawingPlaceholder();
310467
311224
  }
310468
- createVectorShapeElement(block, geometry, applyTransforms = false, groupScaleX = 1, groupScaleY = 1, context) {
311225
+ createVectorShapeElement(block, geometry, applyTransforms = false, groupScaleX = 1, groupScaleY = 1, context, fragment) {
310469
311226
  const container = this.doc.createElement("div");
310470
311227
  container.classList.add("superdoc-vector-shape");
311228
+ if (block.drawingKind === "textboxShape")
311229
+ container.classList.add("superdoc-textbox-shape");
310471
311230
  container.style.width = "100%";
310472
311231
  container.style.height = "100%";
310473
311232
  container.style.position = "relative";
@@ -310498,8 +311257,8 @@ menclose::after {
310498
311257
  }
310499
311258
  this.applyLineEnds(svgElement, block);
310500
311259
  contentContainer.appendChild(svgElement);
310501
- if (this.hasShapeTextContent(block.textContent)) {
310502
- const textElement = this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
311260
+ if (block.drawingKind === "textboxShape" || this.hasShapeTextContent(block.textContent)) {
311261
+ const textElement = block.drawingKind === "textboxShape" ? this.createTextboxContentElement(block, fragment, innerWidth, innerHeight2, context) : this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
310503
311262
  contentContainer.appendChild(textElement);
310504
311263
  }
310505
311264
  container.appendChild(contentContainer);
@@ -310507,8 +311266,8 @@ menclose::after {
310507
311266
  }
310508
311267
  }
310509
311268
  this.applyFallbackShapeStyle(contentContainer, block);
310510
- if (this.hasShapeTextContent(block.textContent)) {
310511
- const textElement = this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
311269
+ if (block.drawingKind === "textboxShape" || this.hasShapeTextContent(block.textContent)) {
311270
+ const textElement = block.drawingKind === "textboxShape" ? this.createTextboxContentElement(block, fragment, innerWidth, innerHeight2, context) : this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
310512
311271
  contentContainer.appendChild(textElement);
310513
311272
  }
310514
311273
  container.appendChild(contentContainer);
@@ -310548,6 +311307,47 @@ menclose::after {
310548
311307
  return this.createWordArtTextElement(textContent$1, block.textAlign ?? "center", block.textInsets, width, height, context);
310549
311308
  return this.createFallbackTextElement(textContent$1, block.textAlign ?? "center", block.textVerticalAlign, block.textInsets, groupScaleX, groupScaleY, context);
310550
311309
  }
311310
+ createTextboxContentElement(block, fragment, width, height, context) {
311311
+ const contentMeasures = fragment?.contentMeasures ?? block.contentMeasures;
311312
+ if (!Array.isArray(contentMeasures) || contentMeasures.length === 0)
311313
+ return this.hasShapeTextContent(block.textContent) ? this.createShapeTextElement(block, width, height, 1, 1, context) : this.doc.createElement("div");
311314
+ const contentRoot = this.doc.createElement("div");
311315
+ contentRoot.style.position = "absolute";
311316
+ contentRoot.style.top = "0";
311317
+ contentRoot.style.left = "0";
311318
+ contentRoot.style.width = "100%";
311319
+ contentRoot.style.height = "100%";
311320
+ contentRoot.style.display = "flex";
311321
+ contentRoot.style.flexDirection = "column";
311322
+ contentRoot.style.boxSizing = "border-box";
311323
+ contentRoot.style.overflow = "hidden";
311324
+ const insets = block.textInsets ?? {
311325
+ top: 0,
311326
+ right: 0,
311327
+ bottom: 0,
311328
+ left: 0
311329
+ };
311330
+ contentRoot.style.padding = `${insets.top}px ${insets.right}px ${insets.bottom}px ${insets.left}px`;
311331
+ const verticalAlign = block.textVerticalAlign ?? "top";
311332
+ contentRoot.style.justifyContent = verticalAlign === "bottom" ? "flex-end" : verticalAlign === "center" ? "center" : "flex-start";
311333
+ const linesHost = this.doc.createElement("div");
311334
+ linesHost.style.display = "flex";
311335
+ linesHost.style.flexDirection = "column";
311336
+ linesHost.style.minWidth = "0";
311337
+ linesHost.style.width = "100%";
311338
+ const renderContext = context ?? this.defaultFragmentRenderContext();
311339
+ const availableWidth = Math.max(1, width - insets.left - insets.right);
311340
+ block.contentBlocks.forEach((paragraphBlock, paragraphIndex) => {
311341
+ const measure = contentMeasures[paragraphIndex];
311342
+ if (!measure?.lines)
311343
+ return;
311344
+ measure.lines.forEach((line, lineIndex) => {
311345
+ linesHost.appendChild(this.renderLine(paragraphBlock, line, renderContext, availableWidth, lineIndex));
311346
+ });
311347
+ });
311348
+ contentRoot.appendChild(linesHost);
311349
+ return contentRoot;
311350
+ }
310551
311351
  shouldUseWordArtTextRenderer(block) {
310552
311352
  return block.attrs?.isWordArt === true && this.hasShapeTextContent(block.textContent);
310553
311353
  }
@@ -311100,7 +311900,7 @@ menclose::after {
311100
311900
  return createDrawingImageElement(this.doc, block, this.buildImageHyperlinkAnchor.bind(this));
311101
311901
  if (block.drawingKind === "shapeGroup")
311102
311902
  return this.createShapeGroupElement(block, context);
311103
- if (block.drawingKind === "vectorShape")
311903
+ if (block.drawingKind === "vectorShape" || block.drawingKind === "textboxShape")
311104
311904
  return this.createVectorShapeElement(block, block.geometry, false, 1, 1, context);
311105
311905
  if (block.drawingKind === "chart")
311106
311906
  return this.createChartElement(block);
@@ -311185,6 +311985,13 @@ menclose::after {
311185
311985
  };
311186
311986
  return runContext;
311187
311987
  }
311988
+ defaultFragmentRenderContext() {
311989
+ return {
311990
+ pageNumber: 1,
311991
+ totalPages: 1,
311992
+ section: "body"
311993
+ };
311994
+ }
311188
311995
  updateFragmentElement(el, fragment, section, resolvedItem) {
311189
311996
  const fragmentItem = resolvedItem?.kind === "fragment" ? resolvedItem : undefined;
311190
311997
  const story = resolveSectionStory(section);
@@ -311681,6 +312488,15 @@ menclose::after {
311681
312488
  if (!lum)
311682
312489
  return "";
311683
312490
  return [lum.bright ?? "", lum.contrast ?? ""].join(":");
312491
+ }, drawingTextVersion = (block) => {
312492
+ const textboxContentBlocks = "contentBlocks" in block && Array.isArray(block.contentBlocks) ? block.contentBlocks.map((contentBlock) => deriveBlockVersion(contentBlock)).join(";") : "";
312493
+ return JSON.stringify([
312494
+ block.textAlign ?? "",
312495
+ block.textVerticalAlign ?? "",
312496
+ block.textInsets ?? null,
312497
+ block.textContent ?? null,
312498
+ textboxContentBlocks
312499
+ ]);
311684
312500
  }, renderedBlockImageVersion = (image2) => [
311685
312501
  image2.src ?? "",
311686
312502
  image2.width ?? "",
@@ -311888,10 +312704,10 @@ menclose::after {
311888
312704
  if (block.kind === "drawing") {
311889
312705
  if (block.drawingKind === "image")
311890
312706
  return ["drawing:image", renderedBlockImageVersion(block)].join("|");
311891
- if (block.drawingKind === "vectorShape") {
312707
+ if (block.drawingKind === "vectorShape" || block.drawingKind === "textboxShape") {
311892
312708
  const vector = block;
311893
312709
  return [
311894
- "drawing:vector",
312710
+ block.drawingKind === "textboxShape" ? "drawing:textbox" : "drawing:vector",
311895
312711
  vector.shapeKind ?? "",
311896
312712
  vector.fillColor ?? "",
311897
312713
  vector.strokeColor ?? "",
@@ -311900,7 +312716,8 @@ menclose::after {
311900
312716
  vector.geometry.height,
311901
312717
  vector.geometry.rotation ?? 0,
311902
312718
  vector.geometry.flipH ? 1 : 0,
311903
- vector.geometry.flipV ? 1 : 0
312719
+ vector.geometry.flipV ? 1 : 0,
312720
+ drawingTextVersion(vector)
311904
312721
  ].join("|");
311905
312722
  }
311906
312723
  if (block.drawingKind === "shapeGroup") {
@@ -312596,6 +313413,23 @@ menclose::after {
312596
313413
  block.textVerticalAlign ?? "",
312597
313414
  JSON.stringify(block.textInsets ?? null)
312598
313415
  ].join(":");
313416
+ if (block.drawingKind === "textboxShape")
313417
+ return [
313418
+ "drawing:textbox",
313419
+ hashDrawingGeometry(block.geometry),
313420
+ block.shapeKind ?? "",
313421
+ JSON.stringify(block.fillColor ?? null),
313422
+ JSON.stringify(block.strokeColor ?? null),
313423
+ block.strokeWidth ?? "",
313424
+ JSON.stringify(block.customGeometry ?? null),
313425
+ JSON.stringify(block.lineEnds ?? null),
313426
+ JSON.stringify(block.effectExtent ?? null),
313427
+ JSON.stringify(block.textContent ?? null),
313428
+ block.textAlign ?? "",
313429
+ block.textVerticalAlign ?? "",
313430
+ JSON.stringify(block.textInsets ?? null),
313431
+ block.contentBlocks.map((contentBlock) => `${contentBlock.id}:${hashRuns(contentBlock)}`).join("|")
313432
+ ].join(":");
312599
313433
  if (block.drawingKind === "shapeGroup")
312600
313434
  return [
312601
313435
  "drawing:shapeGroup",
@@ -313630,8 +314464,10 @@ menclose::after {
313630
314464
  return false;
313631
314465
  if (a2.drawingKind === "image" && b$1.drawingKind === "image")
313632
314466
  return imageBlocksEqual(a2, b$1);
313633
- if (a2.drawingKind === "vectorShape" && b$1.drawingKind === "vectorShape")
313634
- return drawingGeometryEqual(a2.geometry, b$1.geometry) && a2.shapeKind === b$1.shapeKind && a2.fillColor === b$1.fillColor && a2.strokeColor === b$1.strokeColor && a2.strokeWidth === b$1.strokeWidth;
314467
+ if ((a2.drawingKind === "vectorShape" || a2.drawingKind === "textboxShape") && (b$1.drawingKind === "vectorShape" || b$1.drawingKind === "textboxShape")) {
314468
+ const textboxContentEqual = a2.drawingKind !== "textboxShape" || b$1.drawingKind !== "textboxShape" || jsonEqual(a2.contentBlocks, b$1.contentBlocks);
314469
+ return drawingGeometryEqual(a2.geometry, b$1.geometry) && a2.shapeKind === b$1.shapeKind && a2.fillColor === b$1.fillColor && a2.strokeColor === b$1.strokeColor && a2.strokeWidth === b$1.strokeWidth && a2.textAlign === b$1.textAlign && a2.textVerticalAlign === b$1.textVerticalAlign && jsonEqual(a2.textInsets, b$1.textInsets) && jsonEqual(a2.textContent, b$1.textContent) && jsonEqual(a2.customGeometry, b$1.customGeometry) && jsonEqual(a2.lineEnds, b$1.lineEnds) && jsonEqual(a2.effectExtent, b$1.effectExtent) && textboxContentEqual;
314470
+ }
313635
314471
  if (a2.drawingKind === "shapeGroup" && b$1.drawingKind === "shapeGroup")
313636
314472
  return drawingGeometryEqual(a2.geometry, b$1.geometry) && shapeGroupTransformEqual(a2.groupTransform, b$1.groupTransform) && shapeGroupSizeEqual(a2.size, b$1.size) && shapeGroupChildrenEqual(a2.shapes, b$1.shapes);
313637
314473
  if (a2.drawingKind === "chart" && b$1.drawingKind === "chart")
@@ -314455,7 +315291,329 @@ menclose::after {
314455
315291
  });
314456
315292
  });
314457
315293
  return results;
314458
- }, PRELAYOUT_CHAPTER_MARKER_SEPARATOR_RE, PRELAYOUT_MIN_PAGE_COMPONENT = 10, PageGeometryHelper = class {
315294
+ }, PRELAYOUT_CHAPTER_MARKER_SEPARATOR_RE, PRELAYOUT_MIN_PAGE_COMPONENT = 10, isAtomicFragment = (fragment) => {
315295
+ return fragment.kind === "drawing" || fragment.kind === "image";
315296
+ }, blockPmRangeFromAttrs = (block) => {
315297
+ const attrs = block?.attrs;
315298
+ const pmStart = typeof attrs?.pmStart === "number" ? attrs.pmStart : undefined;
315299
+ return {
315300
+ pmStart,
315301
+ pmEnd: typeof attrs?.pmEnd === "number" ? attrs.pmEnd : pmStart != null ? pmStart + 1 : undefined
315302
+ };
315303
+ }, getAtomicPmRange = (fragment, block) => {
315304
+ return {
315305
+ pmStart: typeof fragment.pmStart === "number" ? fragment.pmStart : blockPmRangeFromAttrs(block).pmStart,
315306
+ pmEnd: typeof fragment.pmEnd === "number" ? fragment.pmEnd : blockPmRangeFromAttrs(block).pmEnd
315307
+ };
315308
+ }, isRtlBlock = (block) => {
315309
+ if (block.kind !== "paragraph")
315310
+ return false;
315311
+ return getParagraphInlineDirection(block.attrs) === "rtl";
315312
+ }, determineColumn = (layout, fragmentX, page, fragmentY) => {
315313
+ const columns = resolveColumnsForHit(layout, page, fragmentY);
315314
+ if (!columns || columns.count <= 1)
315315
+ return 0;
315316
+ const pageWidth = page?.size?.w ?? layout.pageSize.w;
315317
+ const margins = page?.margins ?? layout.pages[0]?.margins;
315318
+ const marginLeft = Math.max(0, margins?.left ?? 0);
315319
+ const marginRight = Math.max(0, margins?.right ?? 0);
315320
+ return getColumnAtX(getColumnGeometry(normalizeColumnLayout(columns, Math.max(1, pageWidth - (marginLeft + marginRight)))), fragmentX, marginLeft);
315321
+ }, determineTableColumn = (layout, fragment, page) => {
315322
+ if (typeof fragment.columnIndex === "number") {
315323
+ const count = resolveColumnsForHit(layout, page, fragment.y)?.count ?? 1;
315324
+ return Math.max(0, Math.min(Math.max(0, count - 1), fragment.columnIndex));
315325
+ }
315326
+ return determineColumn(layout, fragment.x, page, fragment.y);
315327
+ }, findLineIndexAtY = (lines, offsetY, fromLine, toLine) => {
315328
+ if (!lines || lines.length === 0)
315329
+ return null;
315330
+ const lineCount = lines.length;
315331
+ if (fromLine < 0 || toLine > lineCount || fromLine >= toLine)
315332
+ return null;
315333
+ let cursor = 0;
315334
+ for (let i4 = fromLine;i4 < toLine; i4 += 1) {
315335
+ const line = lines[i4];
315336
+ if (!line)
315337
+ return null;
315338
+ const next2 = cursor + line.lineHeight;
315339
+ if (offsetY >= cursor && offsetY < next2)
315340
+ return i4;
315341
+ cursor = next2;
315342
+ }
315343
+ return toLine - 1;
315344
+ }, mapPointToPm = (block, line, x, isRTL, availableWidthOverride, alignmentOverride) => {
315345
+ if (block.kind !== "paragraph")
315346
+ return null;
315347
+ const range = computeLinePmRange(block, line);
315348
+ if (range.pmStart == null || range.pmEnd == null)
315349
+ return null;
315350
+ const result = findCharacterAtX(block, line, x, range.pmStart, availableWidthOverride, alignmentOverride);
315351
+ let pmPosition = result.pmPosition;
315352
+ if (isRTL) {
315353
+ const charOffset = result.charOffset;
315354
+ const charsInLine = Math.max(1, line.toChar - line.fromChar);
315355
+ pmPosition = charOffsetToPm(block, line, Math.max(0, Math.min(charsInLine, charsInLine - charOffset)), range.pmStart);
315356
+ }
315357
+ return pmPosition;
315358
+ }, calculatePageTopFallback = (layout, pageIndex) => {
315359
+ const pageGap = layout.pageGap ?? 0;
315360
+ let y$1 = 0;
315361
+ for (let i4 = 0;i4 < pageIndex; i4++) {
315362
+ const pageHeight = layout.pages[i4]?.size?.h ?? layout.pageSize.h;
315363
+ y$1 += pageHeight + pageGap;
315364
+ }
315365
+ return y$1;
315366
+ }, hitTestAtomicFragment = (pageHit, blocks2, measures, point5) => {
315367
+ for (const fragment of pageHit.page.fragments) {
315368
+ if (!isAtomicFragment(fragment))
315369
+ continue;
315370
+ const withinX = point5.x >= fragment.x && point5.x <= fragment.x + fragment.width;
315371
+ const withinY = point5.y >= fragment.y && point5.y <= fragment.y + fragment.height;
315372
+ if (!withinX || !withinY)
315373
+ continue;
315374
+ const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId);
315375
+ if (blockIndex === -1)
315376
+ continue;
315377
+ const block = blocks2[blockIndex];
315378
+ const measure = measures[blockIndex];
315379
+ if (!block || !measure)
315380
+ continue;
315381
+ return {
315382
+ fragment,
315383
+ block,
315384
+ measure,
315385
+ pageIndex: pageHit.pageIndex,
315386
+ pageY: 0
315387
+ };
315388
+ }
315389
+ return null;
315390
+ }, hitTestTableFragment = (pageHit, blocks2, measures, point5) => {
315391
+ for (const fragment of pageHit.page.fragments) {
315392
+ if (fragment.kind !== "table")
315393
+ continue;
315394
+ const tableFragment = fragment;
315395
+ const withinX = point5.x >= tableFragment.x && point5.x <= tableFragment.x + tableFragment.width;
315396
+ const withinY = point5.y >= tableFragment.y && point5.y <= tableFragment.y + tableFragment.height;
315397
+ if (!withinX || !withinY)
315398
+ continue;
315399
+ const blockIndex = blocks2.findIndex((block$1) => block$1.id === tableFragment.blockId);
315400
+ if (blockIndex === -1)
315401
+ continue;
315402
+ const block = blocks2[blockIndex];
315403
+ const measure = measures[blockIndex];
315404
+ if (!block || block.kind !== "table" || !measure || measure.kind !== "table")
315405
+ continue;
315406
+ const tableBlock = block;
315407
+ const tableMeasure = measure;
315408
+ const localX = point5.x - tableFragment.x;
315409
+ const localY = point5.y - tableFragment.y;
315410
+ let rowY = 0;
315411
+ let rowIndex = -1;
315412
+ if (tableMeasure.rows.length === 0 || tableBlock.rows.length === 0)
315413
+ continue;
315414
+ for (let r$1 = tableFragment.fromRow;r$1 < tableFragment.toRow && r$1 < tableMeasure.rows.length; r$1++) {
315415
+ const rowMeasure$1 = tableMeasure.rows[r$1];
315416
+ if (localY >= rowY && localY < rowY + rowMeasure$1.height) {
315417
+ rowIndex = r$1;
315418
+ break;
315419
+ }
315420
+ rowY += rowMeasure$1.height;
315421
+ }
315422
+ if (rowIndex === -1) {
315423
+ rowIndex = Math.min(tableFragment.toRow - 1, tableMeasure.rows.length - 1);
315424
+ if (rowIndex < tableFragment.fromRow)
315425
+ continue;
315426
+ }
315427
+ const rowMeasure = tableMeasure.rows[rowIndex];
315428
+ const row2 = tableBlock.rows[rowIndex];
315429
+ if (!rowMeasure || !row2)
315430
+ continue;
315431
+ const firstCellGridStart = rowMeasure.cells[0]?.gridColumnStart ?? 0;
315432
+ let colX = 0;
315433
+ if (firstCellGridStart > 0 && tableMeasure.columnWidths)
315434
+ for (let col = 0;col < firstCellGridStart && col < tableMeasure.columnWidths.length; col++)
315435
+ colX += tableMeasure.columnWidths[col];
315436
+ const initialColX = colX;
315437
+ let colIndex = -1;
315438
+ if (rowMeasure.cells.length === 0 || row2.cells.length === 0)
315439
+ continue;
315440
+ for (let c = 0;c < rowMeasure.cells.length; c++) {
315441
+ const cellMeasure$1 = rowMeasure.cells[c];
315442
+ if (localX >= colX && localX < colX + cellMeasure$1.width) {
315443
+ colIndex = c;
315444
+ break;
315445
+ }
315446
+ colX += cellMeasure$1.width;
315447
+ }
315448
+ if (colIndex === -1) {
315449
+ if (localX < initialColX)
315450
+ colIndex = 0;
315451
+ else
315452
+ colIndex = rowMeasure.cells.length - 1;
315453
+ if (colIndex < 0)
315454
+ continue;
315455
+ }
315456
+ const cellMeasure = rowMeasure.cells[colIndex];
315457
+ const cell2 = row2.cells[colIndex];
315458
+ if (!cellMeasure || !cell2)
315459
+ continue;
315460
+ const cellBlocks = cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : []);
315461
+ const rawMeasures = cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : []);
315462
+ const cellBlockMeasures = (Array.isArray(rawMeasures) ? rawMeasures : []).filter((m$1) => m$1 != null && typeof m$1 === "object" && ("kind" in m$1));
315463
+ let blockStartY = 0;
315464
+ let blockStartGlobalLines = 0;
315465
+ const getBlockHeight = (m$1) => {
315466
+ if (!m$1)
315467
+ return 0;
315468
+ if ("totalHeight" in m$1 && typeof m$1.totalHeight === "number")
315469
+ return m$1.totalHeight;
315470
+ if ("height" in m$1 && typeof m$1.height === "number")
315471
+ return m$1.height;
315472
+ return 0;
315473
+ };
315474
+ let nearestParagraphHit = null;
315475
+ for (let i4 = 0;i4 < cellBlocks.length && i4 < cellBlockMeasures.length; i4++) {
315476
+ const cellBlock = cellBlocks[i4];
315477
+ const cellBlockMeasure = cellBlockMeasures[i4];
315478
+ if (cellBlock?.kind !== "paragraph" || cellBlockMeasure?.kind !== "paragraph") {
315479
+ blockStartY += getBlockHeight(cellBlockMeasure);
315480
+ continue;
315481
+ }
315482
+ const blockHeight = getBlockHeight(cellBlockMeasure);
315483
+ const blockEndY = blockStartY + blockHeight;
315484
+ const padding = cell2.attrs?.padding ?? {
315485
+ top: 0,
315486
+ left: 4,
315487
+ right: 4,
315488
+ bottom: 0
315489
+ };
315490
+ const cellLocalX = localX - colX - (padding.left ?? 4);
315491
+ const cellLocalY = localY - rowY - (padding.top ?? 0);
315492
+ const paragraphBlock = cellBlock;
315493
+ const paragraphMeasure = cellBlockMeasure;
315494
+ if (cellLocalY >= blockStartY && cellLocalY < blockEndY) {
315495
+ const unclampedLocalY = cellLocalY - blockStartY;
315496
+ const localYWithinBlock = Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0)));
315497
+ return {
315498
+ fragment: tableFragment,
315499
+ block: tableBlock,
315500
+ measure: tableMeasure,
315501
+ pageIndex: pageHit.pageIndex,
315502
+ cellRowIndex: rowIndex,
315503
+ cellColIndex: colIndex,
315504
+ cellBlock: paragraphBlock,
315505
+ cellMeasure: paragraphMeasure,
315506
+ localX: Math.max(0, cellLocalX),
315507
+ localY: Math.max(0, localYWithinBlock),
315508
+ blockStartGlobal: blockStartGlobalLines
315509
+ };
315510
+ }
315511
+ const distanceToBlock = cellLocalY < blockStartY ? blockStartY - cellLocalY : Math.max(0, cellLocalY - blockEndY);
315512
+ if (!nearestParagraphHit || distanceToBlock < nearestParagraphHit.distance) {
315513
+ const unclampedLocalY = cellLocalY - blockStartY;
315514
+ nearestParagraphHit = {
315515
+ cellBlock: paragraphBlock,
315516
+ cellMeasure: paragraphMeasure,
315517
+ localX: Math.max(0, cellLocalX),
315518
+ localY: Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0))),
315519
+ blockStartGlobal: blockStartGlobalLines,
315520
+ distance: distanceToBlock
315521
+ };
315522
+ }
315523
+ blockStartY = blockEndY;
315524
+ blockStartGlobalLines += paragraphMeasure.lines.length;
315525
+ }
315526
+ if (nearestParagraphHit)
315527
+ return {
315528
+ fragment: tableFragment,
315529
+ block: tableBlock,
315530
+ measure: tableMeasure,
315531
+ pageIndex: pageHit.pageIndex,
315532
+ cellRowIndex: rowIndex,
315533
+ cellColIndex: colIndex,
315534
+ cellBlock: nearestParagraphHit.cellBlock,
315535
+ cellMeasure: nearestParagraphHit.cellMeasure,
315536
+ localX: nearestParagraphHit.localX,
315537
+ localY: nearestParagraphHit.localY,
315538
+ blockStartGlobal: nearestParagraphHit.blockStartGlobal
315539
+ };
315540
+ }
315541
+ return null;
315542
+ }, resolveTextboxContentHit = (fragment, block, measure, pageIndex, point5) => {
315543
+ const fragmentWithContent = fragment;
315544
+ const contentMeasures = Array.isArray(fragmentWithContent.contentMeasures) ? fragmentWithContent.contentMeasures : Array.isArray(block.contentMeasures) ? block.contentMeasures : [];
315545
+ const contentBlocks = Array.isArray(block.contentBlocks) ? block.contentBlocks : [];
315546
+ if (contentMeasures.length === 0 || contentBlocks.length === 0)
315547
+ return null;
315548
+ const insets = block.textInsets ?? {
315549
+ top: 0,
315550
+ right: 0,
315551
+ bottom: 0,
315552
+ left: 0
315553
+ };
315554
+ const localX = Math.max(0, point5.x - fragment.x - insets.left);
315555
+ const rawLocalY = point5.y - fragment.y - insets.top;
315556
+ const totalContentHeight = contentMeasures.reduce((sum, m$1) => sum + (m$1?.kind === "paragraph" ? m$1.totalHeight ?? 0 : 0), 0);
315557
+ const availableHeight = Math.max(0, fragment.height - insets.top - insets.bottom);
315558
+ const verticalAlign = block.textVerticalAlign ?? "top";
315559
+ let contentOffset = 0;
315560
+ if (verticalAlign === "center")
315561
+ contentOffset = Math.max(0, (availableHeight - totalContentHeight) / 2);
315562
+ else if (verticalAlign === "bottom")
315563
+ contentOffset = Math.max(0, availableHeight - totalContentHeight);
315564
+ const localY = rawLocalY - contentOffset;
315565
+ let paragraphStartY = 0;
315566
+ let blockStartGlobal = 0;
315567
+ let nearestParagraphHit = null;
315568
+ for (let i4 = 0;i4 < contentBlocks.length && i4 < contentMeasures.length; i4 += 1) {
315569
+ const contentBlock = contentBlocks[i4];
315570
+ const contentMeasure = contentMeasures[i4];
315571
+ if (contentBlock?.kind !== "paragraph" || contentMeasure?.kind !== "paragraph")
315572
+ continue;
315573
+ const paragraphHeight = contentMeasure.totalHeight;
315574
+ const paragraphEndY = paragraphStartY + paragraphHeight;
315575
+ if (localY >= paragraphStartY && localY < paragraphEndY)
315576
+ return {
315577
+ fragment,
315578
+ block,
315579
+ measure,
315580
+ pageIndex,
315581
+ contentBlock,
315582
+ contentMeasure,
315583
+ paragraphIndex: i4,
315584
+ localX,
315585
+ localY: Math.max(0, Math.min(localY - paragraphStartY, Math.max(paragraphHeight, 0))),
315586
+ blockStartGlobal
315587
+ };
315588
+ const distanceToParagraph = localY < paragraphStartY ? paragraphStartY - localY : Math.max(0, localY - paragraphEndY);
315589
+ if (!nearestParagraphHit || distanceToParagraph < nearestParagraphHit.distance)
315590
+ nearestParagraphHit = {
315591
+ contentBlock,
315592
+ contentMeasure,
315593
+ paragraphIndex: i4,
315594
+ localX,
315595
+ localY: Math.max(0, Math.min(localY - paragraphStartY, Math.max(paragraphHeight, 0))),
315596
+ blockStartGlobal,
315597
+ distance: distanceToParagraph
315598
+ };
315599
+ paragraphStartY = paragraphEndY;
315600
+ blockStartGlobal += contentMeasure.lines.length;
315601
+ }
315602
+ if (nearestParagraphHit)
315603
+ return {
315604
+ fragment,
315605
+ block,
315606
+ measure,
315607
+ pageIndex,
315608
+ contentBlock: nearestParagraphHit.contentBlock,
315609
+ contentMeasure: nearestParagraphHit.contentMeasure,
315610
+ paragraphIndex: nearestParagraphHit.paragraphIndex,
315611
+ localX: nearestParagraphHit.localX,
315612
+ localY: nearestParagraphHit.localY,
315613
+ blockStartGlobal: nearestParagraphHit.blockStartGlobal
315614
+ };
315615
+ return null;
315616
+ }, PageGeometryHelper = class {
314459
315617
  constructor(config3) {
314460
315618
  this.cache = null;
314461
315619
  this.config = config3;
@@ -314670,254 +315828,6 @@ menclose::after {
314670
315828
  for (const metric of Object.keys(this.metrics))
314671
315829
  this.metrics[metric] = [];
314672
315830
  }
314673
- }, isAtomicFragment = (fragment) => {
314674
- return fragment.kind === "drawing" || fragment.kind === "image";
314675
- }, blockPmRangeFromAttrs = (block) => {
314676
- const attrs = block?.attrs;
314677
- const pmStart = typeof attrs?.pmStart === "number" ? attrs.pmStart : undefined;
314678
- return {
314679
- pmStart,
314680
- pmEnd: typeof attrs?.pmEnd === "number" ? attrs.pmEnd : pmStart != null ? pmStart + 1 : undefined
314681
- };
314682
- }, getAtomicPmRange = (fragment, block) => {
314683
- return {
314684
- pmStart: typeof fragment.pmStart === "number" ? fragment.pmStart : blockPmRangeFromAttrs(block).pmStart,
314685
- pmEnd: typeof fragment.pmEnd === "number" ? fragment.pmEnd : blockPmRangeFromAttrs(block).pmEnd
314686
- };
314687
- }, isRtlBlock = (block) => {
314688
- if (block.kind !== "paragraph")
314689
- return false;
314690
- return getParagraphInlineDirection(block.attrs) === "rtl";
314691
- }, determineColumn = (layout, fragmentX, page, fragmentY) => {
314692
- const columns = resolveColumnsForHit(layout, page, fragmentY);
314693
- if (!columns || columns.count <= 1)
314694
- return 0;
314695
- const pageWidth = page?.size?.w ?? layout.pageSize.w;
314696
- const margins = page?.margins ?? layout.pages[0]?.margins;
314697
- const marginLeft = Math.max(0, margins?.left ?? 0);
314698
- const marginRight = Math.max(0, margins?.right ?? 0);
314699
- return getColumnAtX(getColumnGeometry(normalizeColumnLayout(columns, Math.max(1, pageWidth - (marginLeft + marginRight)))), fragmentX, marginLeft);
314700
- }, determineTableColumn = (layout, fragment, page) => {
314701
- if (typeof fragment.columnIndex === "number") {
314702
- const count = resolveColumnsForHit(layout, page, fragment.y)?.count ?? 1;
314703
- return Math.max(0, Math.min(Math.max(0, count - 1), fragment.columnIndex));
314704
- }
314705
- return determineColumn(layout, fragment.x, page, fragment.y);
314706
- }, findLineIndexAtY = (lines, offsetY, fromLine, toLine) => {
314707
- if (!lines || lines.length === 0)
314708
- return null;
314709
- const lineCount = lines.length;
314710
- if (fromLine < 0 || toLine > lineCount || fromLine >= toLine)
314711
- return null;
314712
- let cursor = 0;
314713
- for (let i4 = fromLine;i4 < toLine; i4 += 1) {
314714
- const line = lines[i4];
314715
- if (!line)
314716
- return null;
314717
- const next2 = cursor + line.lineHeight;
314718
- if (offsetY >= cursor && offsetY < next2)
314719
- return i4;
314720
- cursor = next2;
314721
- }
314722
- return toLine - 1;
314723
- }, mapPointToPm = (block, line, x, isRTL, availableWidthOverride, alignmentOverride) => {
314724
- if (block.kind !== "paragraph")
314725
- return null;
314726
- const range = computeLinePmRange(block, line);
314727
- if (range.pmStart == null || range.pmEnd == null)
314728
- return null;
314729
- const result = findCharacterAtX(block, line, x, range.pmStart, availableWidthOverride, alignmentOverride);
314730
- let pmPosition = result.pmPosition;
314731
- if (isRTL) {
314732
- const charOffset = result.charOffset;
314733
- const charsInLine = Math.max(1, line.toChar - line.fromChar);
314734
- pmPosition = charOffsetToPm(block, line, Math.max(0, Math.min(charsInLine, charsInLine - charOffset)), range.pmStart);
314735
- }
314736
- return pmPosition;
314737
- }, calculatePageTopFallback = (layout, pageIndex) => {
314738
- const pageGap = layout.pageGap ?? 0;
314739
- let y$1 = 0;
314740
- for (let i4 = 0;i4 < pageIndex; i4++) {
314741
- const pageHeight = layout.pages[i4]?.size?.h ?? layout.pageSize.h;
314742
- y$1 += pageHeight + pageGap;
314743
- }
314744
- return y$1;
314745
- }, hitTestAtomicFragment = (pageHit, blocks2, measures, point5) => {
314746
- for (const fragment of pageHit.page.fragments) {
314747
- if (!isAtomicFragment(fragment))
314748
- continue;
314749
- const withinX = point5.x >= fragment.x && point5.x <= fragment.x + fragment.width;
314750
- const withinY = point5.y >= fragment.y && point5.y <= fragment.y + fragment.height;
314751
- if (!withinX || !withinY)
314752
- continue;
314753
- const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId);
314754
- if (blockIndex === -1)
314755
- continue;
314756
- const block = blocks2[blockIndex];
314757
- const measure = measures[blockIndex];
314758
- if (!block || !measure)
314759
- continue;
314760
- return {
314761
- fragment,
314762
- block,
314763
- measure,
314764
- pageIndex: pageHit.pageIndex,
314765
- pageY: 0
314766
- };
314767
- }
314768
- return null;
314769
- }, hitTestTableFragment = (pageHit, blocks2, measures, point5) => {
314770
- for (const fragment of pageHit.page.fragments) {
314771
- if (fragment.kind !== "table")
314772
- continue;
314773
- const tableFragment = fragment;
314774
- const withinX = point5.x >= tableFragment.x && point5.x <= tableFragment.x + tableFragment.width;
314775
- const withinY = point5.y >= tableFragment.y && point5.y <= tableFragment.y + tableFragment.height;
314776
- if (!withinX || !withinY)
314777
- continue;
314778
- const blockIndex = blocks2.findIndex((block$1) => block$1.id === tableFragment.blockId);
314779
- if (blockIndex === -1)
314780
- continue;
314781
- const block = blocks2[blockIndex];
314782
- const measure = measures[blockIndex];
314783
- if (!block || block.kind !== "table" || !measure || measure.kind !== "table")
314784
- continue;
314785
- const tableBlock = block;
314786
- const tableMeasure = measure;
314787
- const localX = point5.x - tableFragment.x;
314788
- const localY = point5.y - tableFragment.y;
314789
- let rowY = 0;
314790
- let rowIndex = -1;
314791
- if (tableMeasure.rows.length === 0 || tableBlock.rows.length === 0)
314792
- continue;
314793
- for (let r$1 = tableFragment.fromRow;r$1 < tableFragment.toRow && r$1 < tableMeasure.rows.length; r$1++) {
314794
- const rowMeasure$1 = tableMeasure.rows[r$1];
314795
- if (localY >= rowY && localY < rowY + rowMeasure$1.height) {
314796
- rowIndex = r$1;
314797
- break;
314798
- }
314799
- rowY += rowMeasure$1.height;
314800
- }
314801
- if (rowIndex === -1) {
314802
- rowIndex = Math.min(tableFragment.toRow - 1, tableMeasure.rows.length - 1);
314803
- if (rowIndex < tableFragment.fromRow)
314804
- continue;
314805
- }
314806
- const rowMeasure = tableMeasure.rows[rowIndex];
314807
- const row2 = tableBlock.rows[rowIndex];
314808
- if (!rowMeasure || !row2)
314809
- continue;
314810
- const firstCellGridStart = rowMeasure.cells[0]?.gridColumnStart ?? 0;
314811
- let colX = 0;
314812
- if (firstCellGridStart > 0 && tableMeasure.columnWidths)
314813
- for (let col = 0;col < firstCellGridStart && col < tableMeasure.columnWidths.length; col++)
314814
- colX += tableMeasure.columnWidths[col];
314815
- const initialColX = colX;
314816
- let colIndex = -1;
314817
- if (rowMeasure.cells.length === 0 || row2.cells.length === 0)
314818
- continue;
314819
- for (let c = 0;c < rowMeasure.cells.length; c++) {
314820
- const cellMeasure$1 = rowMeasure.cells[c];
314821
- if (localX >= colX && localX < colX + cellMeasure$1.width) {
314822
- colIndex = c;
314823
- break;
314824
- }
314825
- colX += cellMeasure$1.width;
314826
- }
314827
- if (colIndex === -1) {
314828
- if (localX < initialColX)
314829
- colIndex = 0;
314830
- else
314831
- colIndex = rowMeasure.cells.length - 1;
314832
- if (colIndex < 0)
314833
- continue;
314834
- }
314835
- const cellMeasure = rowMeasure.cells[colIndex];
314836
- const cell2 = row2.cells[colIndex];
314837
- if (!cellMeasure || !cell2)
314838
- continue;
314839
- const cellBlocks = cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : []);
314840
- const rawMeasures = cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : []);
314841
- const cellBlockMeasures = (Array.isArray(rawMeasures) ? rawMeasures : []).filter((m$1) => m$1 != null && typeof m$1 === "object" && ("kind" in m$1));
314842
- let blockStartY = 0;
314843
- let blockStartGlobalLines = 0;
314844
- const getBlockHeight = (m$1) => {
314845
- if (!m$1)
314846
- return 0;
314847
- if ("totalHeight" in m$1 && typeof m$1.totalHeight === "number")
314848
- return m$1.totalHeight;
314849
- if ("height" in m$1 && typeof m$1.height === "number")
314850
- return m$1.height;
314851
- return 0;
314852
- };
314853
- let nearestParagraphHit = null;
314854
- for (let i4 = 0;i4 < cellBlocks.length && i4 < cellBlockMeasures.length; i4++) {
314855
- const cellBlock = cellBlocks[i4];
314856
- const cellBlockMeasure = cellBlockMeasures[i4];
314857
- if (cellBlock?.kind !== "paragraph" || cellBlockMeasure?.kind !== "paragraph") {
314858
- blockStartY += getBlockHeight(cellBlockMeasure);
314859
- continue;
314860
- }
314861
- const blockHeight = getBlockHeight(cellBlockMeasure);
314862
- const blockEndY = blockStartY + blockHeight;
314863
- const padding = cell2.attrs?.padding ?? {
314864
- top: 0,
314865
- left: 4,
314866
- right: 4,
314867
- bottom: 0
314868
- };
314869
- const cellLocalX = localX - colX - (padding.left ?? 4);
314870
- const cellLocalY = localY - rowY - (padding.top ?? 0);
314871
- const paragraphBlock = cellBlock;
314872
- const paragraphMeasure = cellBlockMeasure;
314873
- if (cellLocalY >= blockStartY && cellLocalY < blockEndY) {
314874
- const unclampedLocalY = cellLocalY - blockStartY;
314875
- const localYWithinBlock = Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0)));
314876
- return {
314877
- fragment: tableFragment,
314878
- block: tableBlock,
314879
- measure: tableMeasure,
314880
- pageIndex: pageHit.pageIndex,
314881
- cellRowIndex: rowIndex,
314882
- cellColIndex: colIndex,
314883
- cellBlock: paragraphBlock,
314884
- cellMeasure: paragraphMeasure,
314885
- localX: Math.max(0, cellLocalX),
314886
- localY: Math.max(0, localYWithinBlock),
314887
- blockStartGlobal: blockStartGlobalLines
314888
- };
314889
- }
314890
- const distanceToBlock = cellLocalY < blockStartY ? blockStartY - cellLocalY : Math.max(0, cellLocalY - blockEndY);
314891
- if (!nearestParagraphHit || distanceToBlock < nearestParagraphHit.distance) {
314892
- const unclampedLocalY = cellLocalY - blockStartY;
314893
- nearestParagraphHit = {
314894
- cellBlock: paragraphBlock,
314895
- cellMeasure: paragraphMeasure,
314896
- localX: Math.max(0, cellLocalX),
314897
- localY: Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0))),
314898
- blockStartGlobal: blockStartGlobalLines,
314899
- distance: distanceToBlock
314900
- };
314901
- }
314902
- blockStartY = blockEndY;
314903
- blockStartGlobalLines += paragraphMeasure.lines.length;
314904
- }
314905
- if (nearestParagraphHit)
314906
- return {
314907
- fragment: tableFragment,
314908
- block: tableBlock,
314909
- measure: tableMeasure,
314910
- pageIndex: pageHit.pageIndex,
314911
- cellRowIndex: rowIndex,
314912
- cellColIndex: colIndex,
314913
- cellBlock: nearestParagraphHit.cellBlock,
314914
- cellMeasure: nearestParagraphHit.cellMeasure,
314915
- localX: nearestParagraphHit.localX,
314916
- localY: nearestParagraphHit.localY,
314917
- blockStartGlobal: nearestParagraphHit.blockStartGlobal
314918
- };
314919
- }
314920
- return null;
314921
315831
  }, logSelectionMapDebug = (payload) => {}, rangesOverlap2 = (startA, endA, startB, endB) => {
314922
315832
  if (startA == null)
314923
315833
  return false;
@@ -316835,10 +317745,15 @@ menclose::after {
316835
317745
  this.#focusEditorAtFirstPosition();
316836
317746
  }
316837
317747
  #handleClickInHeaderFooterMode(event, x, y$1, pageIndex, pageLocalY) {
316838
- const activeSurfaceSelector = this.#deps?.getHeaderFooterSession()?.session?.mode === "footer" ? ".superdoc-page-footer" : ".superdoc-page-header";
317748
+ const session = this.#deps?.getHeaderFooterSession();
317749
+ const activeSurfaceSelector = session?.session?.mode === "footer" ? ".superdoc-page-footer" : ".superdoc-page-header";
316839
317750
  const visiblePointerSurface = resolveVisibleSurfaceAtPointer(event.target, event.clientX, event.clientY);
316840
317751
  const clickedInsideVisibleActiveSurface = visiblePointerSurface?.kind === "headerFooter" && visiblePointerSurface.surface.closest(activeSurfaceSelector) != null;
316841
317752
  if (visiblePointerSurface?.kind === "bodyContent") {
317753
+ const behindDocSection = (event.target instanceof Element ? event.target.closest("[data-behind-doc-section]") : null)?.dataset.behindDocSection;
317754
+ const sessionMode = session?.session?.mode;
317755
+ if (behindDocSection && behindDocSection === sessionMode)
317756
+ return false;
316842
317757
  this.#callbacks.exitHeaderFooterMode?.();
316843
317758
  return false;
316844
317759
  }
@@ -316934,6 +317849,8 @@ menclose::after {
316934
317849
  return false;
316935
317850
  if (fragmentHit.fragment.kind !== "image" && fragmentHit.fragment.kind !== "drawing")
316936
317851
  return false;
317852
+ if (fragmentHit.fragment.kind === "drawing" && fragmentHit.fragment.drawingKind === "textboxShape")
317853
+ return false;
316937
317854
  const editor = this.#deps?.getEditor();
316938
317855
  try {
316939
317856
  const tr = editor.state.tr.setSelection(NodeSelection.create(doc$12, hit.pos));
@@ -319787,7 +320704,8 @@ menclose::after {
319787
320704
  const surfaceElement = pageElement.querySelector(surfaceSelector);
319788
320705
  if (!surfaceElement)
319789
320706
  return null;
319790
- const entry = findSurfaceEntryAtPos(buildSurfacePmEntries(surfaceElement), pos);
320707
+ const behindDocFragments = Array.from(pageElement.querySelectorAll(`[data-behind-doc-section="${this.#session.mode}"]`));
320708
+ const entry = findSurfaceEntryAtPos([...buildSurfacePmEntries(surfaceElement), ...behindDocFragments.flatMap((frag) => buildSurfacePmEntries(frag))].sort((a2, b$1) => a2.pmStart - b$1.pmStart || a2.pmEnd - b$1.pmEnd), pos);
319791
320709
  if (!entry)
319792
320710
  return null;
319793
320711
  const pageRect = pageElement.getBoundingClientRect();
@@ -320951,13 +321869,13 @@ menclose::after {
320951
321869
  return;
320952
321870
  console.log(...args$1);
320953
321871
  }, 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;
320954
- var init_src_CRJcfbIa_es = __esm(() => {
321872
+ var init_src_BBtIMpLJ_es = __esm(() => {
320955
321873
  init_rolldown_runtime_Bg48TavK_es();
320956
- init_SuperConverter_BTGVElJO_es();
321874
+ init_SuperConverter_CUxtXQFf_es();
320957
321875
  init_jszip_C49i9kUs_es();
320958
321876
  init_xml_js_CqGKpaft_es();
320959
321877
  init_uuid_B2wVPhPi_es();
320960
- init_create_headless_toolbar_DYbkX05s_es();
321878
+ init_create_headless_toolbar_DutCjfp2_es();
320961
321879
  init_constants_D9qj59G2_es();
320962
321880
  init_dist_B8HfvhaK_es();
320963
321881
  init_unified_Dsuw2be5_es();
@@ -328208,7 +329126,89 @@ ${err.toString()}`);
328208
329126
  return { style: attrs.style };
328209
329127
  } },
328210
329128
  wrapAttributes: { rendered: false },
328211
- attributes: { rendered: false }
329129
+ anchorData: { rendered: false },
329130
+ marginOffset: { rendered: false },
329131
+ attributes: { rendered: false },
329132
+ kind: {
329133
+ default: null,
329134
+ rendered: false
329135
+ },
329136
+ width: {
329137
+ default: null,
329138
+ renderDOM: (attrs) => {
329139
+ if (attrs.width == null)
329140
+ return {};
329141
+ return { "data-width": attrs.width };
329142
+ }
329143
+ },
329144
+ height: {
329145
+ default: null,
329146
+ renderDOM: (attrs) => {
329147
+ if (attrs.height == null)
329148
+ return {};
329149
+ return { "data-height": attrs.height };
329150
+ }
329151
+ },
329152
+ fillColor: {
329153
+ default: null,
329154
+ rendered: false
329155
+ },
329156
+ strokeColor: {
329157
+ default: null,
329158
+ rendered: false
329159
+ },
329160
+ strokeWidth: {
329161
+ default: null,
329162
+ rendered: false
329163
+ },
329164
+ rotation: {
329165
+ default: 0,
329166
+ rendered: false
329167
+ },
329168
+ flipH: {
329169
+ default: false,
329170
+ rendered: false
329171
+ },
329172
+ flipV: {
329173
+ default: false,
329174
+ rendered: false
329175
+ },
329176
+ wrap: {
329177
+ default: null,
329178
+ rendered: false
329179
+ },
329180
+ isAnchor: {
329181
+ default: false,
329182
+ rendered: false
329183
+ },
329184
+ drawingContent: {
329185
+ default: null,
329186
+ rendered: false
329187
+ },
329188
+ originalAttributes: {
329189
+ default: null,
329190
+ rendered: false
329191
+ },
329192
+ effectExtent: {
329193
+ default: null,
329194
+ rendered: false
329195
+ },
329196
+ lineEnds: {
329197
+ default: null,
329198
+ rendered: false
329199
+ },
329200
+ hidden: {
329201
+ default: false,
329202
+ rendered: false
329203
+ },
329204
+ isTextBox: {
329205
+ default: false,
329206
+ rendered: false
329207
+ },
329208
+ isWordArt: {
329209
+ default: false,
329210
+ rendered: false
329211
+ }
328212
329212
  };
328213
329213
  },
328214
329214
  parseDOM() {
@@ -328243,7 +329243,15 @@ ${err.toString()}`);
328243
329243
  return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
328244
329244
  }
328245
329245
  },
328246
- attributes: { rendered: false }
329246
+ attributes: { rendered: false },
329247
+ textInsets: {
329248
+ default: null,
329249
+ rendered: false
329250
+ },
329251
+ textVerticalAlign: {
329252
+ default: null,
329253
+ rendered: false
329254
+ }
328247
329255
  };
328248
329256
  },
328249
329257
  parseDOM() {
@@ -351650,14 +352658,21 @@ function print() { __p += __j.call(arguments, '') }
351650
352658
  return null;
351651
352659
  const localX = normalized.x - context.region.localX;
351652
352660
  const localY = (normalized.pageLocalY ?? normalized.y - context.region.pageIndex * (bodyPageHeight + pageGap)) - context.region.localY;
352661
+ const domHit = this.#resolveHeaderFooterDomHit(context, clientX, clientY);
352662
+ if (domHit) {
352663
+ const doc$3 = this.getActiveEditor().state?.doc;
352664
+ return {
352665
+ ...domHit,
352666
+ pos: doc$3 ? Math.max(0, Math.min(domHit.pos, doc$3.content.size)) : domHit.pos
352667
+ };
352668
+ }
351653
352669
  if (localX < 0 || localY < 0 || localX > context.region.width || localY > context.region.height)
351654
352670
  return null;
351655
352671
  const headerPoint = {
351656
352672
  x: localX,
351657
352673
  y: localY
351658
352674
  };
351659
- const geometryHit = clickToPositionGeometry(context.layout, context.blocks, context.measures, headerPoint) ?? null;
351660
- const hit = this.#resolveHeaderFooterDomHit(context, clientX, clientY) ?? geometryHit;
352675
+ const hit = clickToPositionGeometry(context.layout, context.blocks, context.measures, headerPoint) ?? null;
351661
352676
  if (!hit)
351662
352677
  return null;
351663
352678
  const doc$2 = this.getActiveEditor().state?.doc;
@@ -356628,11 +357643,11 @@ function print() { __p += __j.call(arguments, '') }
356628
357643
  ]);
356629
357644
  });
356630
357645
 
356631
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DUYQPx-V.es.js
357646
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-e_ogmxkt.es.js
356632
357647
  var DEFAULT_TEXT_ALIGN_OPTIONS, DEFAULT_LINE_HEIGHT_OPTIONS, DEFAULT_ZOOM_OPTIONS, DEFAULT_DOCUMENT_MODE_OPTIONS, DEFAULT_FONT_SIZE_OPTIONS, headlessToolbarConstants, 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, FONT_SIZE_OPTIONS;
356633
- var init_create_super_doc_ui_DUYQPx_V_es = __esm(() => {
356634
- init_SuperConverter_BTGVElJO_es();
356635
- init_create_headless_toolbar_DYbkX05s_es();
357648
+ var init_create_super_doc_ui_e_ogmxkt_es = __esm(() => {
357649
+ init_SuperConverter_CUxtXQFf_es();
357650
+ init_create_headless_toolbar_DutCjfp2_es();
356636
357651
  DEFAULT_TEXT_ALIGN_OPTIONS = [
356637
357652
  {
356638
357653
  label: "Left",
@@ -356923,16 +357938,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
356923
357938
 
356924
357939
  // ../../packages/superdoc/dist/super-editor.es.js
356925
357940
  var init_super_editor_es = __esm(() => {
356926
- init_src_CRJcfbIa_es();
356927
- init_SuperConverter_BTGVElJO_es();
357941
+ init_src_BBtIMpLJ_es();
357942
+ init_SuperConverter_CUxtXQFf_es();
356928
357943
  init_jszip_C49i9kUs_es();
356929
357944
  init_xml_js_CqGKpaft_es();
356930
- init_create_headless_toolbar_DYbkX05s_es();
357945
+ init_create_headless_toolbar_DutCjfp2_es();
356931
357946
  init_constants_D9qj59G2_es();
356932
357947
  init_dist_B8HfvhaK_es();
356933
357948
  init_unified_Dsuw2be5_es();
356934
357949
  init_DocxZipper_FUsfThjV_es();
356935
- init_create_super_doc_ui_DUYQPx_V_es();
357950
+ init_create_super_doc_ui_e_ogmxkt_es();
356936
357951
  init_ui_C5PAS9hY_es();
356937
357952
  init_eventemitter3_BnGqBE_Q_es();
356938
357953
  init_errors_CNaD6vcg_es();
@@ -388451,7 +389466,43 @@ var lineBreakNodeToBreakBlock2 = (node3, { nextBlockId }) => {
388451
389466
  };
388452
389467
 
388453
389468
  // ../../packages/super-editor/src/editors/v1/core/layout-adapter/converters/shapes.ts
388454
- var WRAP_TYPES2, WRAP_TEXT_VALUES2, H_RELATIVE_VALUES2, V_RELATIVE_VALUES2, H_ALIGN_VALUES2, V_ALIGN_VALUES2, normalizeWrapType2 = (value) => {
389469
+ function hydrateTextboxDrawingContent2(node3, drawingBlock, context) {
389470
+ if (drawingBlock.drawingKind !== "textboxShape") {
389471
+ return drawingBlock;
389472
+ }
389473
+ return {
389474
+ ...drawingBlock,
389475
+ contentBlocks: toTextboxParagraphBlocks2(node3, context)
389476
+ };
389477
+ }
389478
+ var WRAP_TYPES2, WRAP_TEXT_VALUES2, H_RELATIVE_VALUES2, V_RELATIVE_VALUES2, H_ALIGN_VALUES2, V_ALIGN_VALUES2, TEXTBOX_CONTAINER_TYPES2, isParagraphNode2 = (node3) => node3?.type === "paragraph", toTextboxParagraphBlocks2 = (node3, context) => {
389479
+ const shapeTextboxNode = node3.type === "shapeTextbox" ? node3 : resolveNestedShapeTextboxNode2(node3);
389480
+ const paragraphToFlowBlocks2 = context.converters?.paragraphToFlowBlocks;
389481
+ if (!shapeTextboxNode || !paragraphToFlowBlocks2 || !Array.isArray(shapeTextboxNode.content)) {
389482
+ return [];
389483
+ }
389484
+ const textboxBlocks = [];
389485
+ for (const child of shapeTextboxNode.content) {
389486
+ if (!isParagraphNode2(child))
389487
+ continue;
389488
+ const convertedBlocks = paragraphToFlowBlocks2({
389489
+ para: child,
389490
+ nextBlockId: context.nextBlockId,
389491
+ positions: context.positions,
389492
+ storyKey: context.storyKey,
389493
+ trackedChangesConfig: context.trackedChangesConfig,
389494
+ bookmarks: context.bookmarks,
389495
+ hyperlinkConfig: context.hyperlinkConfig,
389496
+ themeColors: context.themeColors,
389497
+ converters: context.converters,
389498
+ converterContext: context.converterContext,
389499
+ enableComments: context.enableComments,
389500
+ previousParagraphFont: getLastParagraphFont2(textboxBlocks)
389501
+ });
389502
+ textboxBlocks.push(...convertedBlocks);
389503
+ }
389504
+ return textboxBlocks.filter((block) => block.kind === "paragraph");
389505
+ }, resolveNestedShapeTextboxNode2 = (node3) => Array.isArray(node3.content) ? node3.content.find((child) => child?.type === "shapeTextbox") : undefined, normalizeWrapType2 = (value) => {
388455
389506
  if (typeof value !== "string")
388456
389507
  return;
388457
389508
  return WRAP_TYPES2.has(value) ? value : undefined;
@@ -388593,12 +389644,21 @@ var WRAP_TYPES2, WRAP_TEXT_VALUES2, H_RELATIVE_VALUES2, V_RELATIVE_VALUES2, H_AL
388593
389644
  };
388594
389645
  var init_shapes = __esm(() => {
388595
389646
  init_utilities();
389647
+ init_paragraph2();
388596
389648
  WRAP_TYPES2 = new Set(["None", "Square", "Tight", "Through", "TopAndBottom", "Inline"]);
388597
389649
  WRAP_TEXT_VALUES2 = new Set(["bothSides", "left", "right", "largest"]);
388598
389650
  H_RELATIVE_VALUES2 = new Set(["column", "page", "margin"]);
388599
389651
  V_RELATIVE_VALUES2 = new Set(["paragraph", "page", "margin"]);
388600
389652
  H_ALIGN_VALUES2 = new Set(["left", "center", "right"]);
388601
389653
  V_ALIGN_VALUES2 = new Set(["top", "center", "bottom"]);
389654
+ TEXTBOX_CONTAINER_TYPES2 = new Set([
389655
+ "run",
389656
+ "link",
389657
+ "hyperlink",
389658
+ "structuredContent",
389659
+ "fieldAnnotation",
389660
+ "smartTag"
389661
+ ]);
388602
389662
  });
388603
389663
 
388604
389664
  // ../../packages/super-editor/src/editors/v1/core/layout-adapter/converters/content-block.ts
@@ -389641,14 +390701,14 @@ var isTableRowNode2 = (node3) => node3.type === "tableRow" || node3.type === "ta
389641
390701
  if (childNode.type === "shapeContainer" && context.converters?.shapeContainerNodeToDrawingBlock) {
389642
390702
  const drawingBlock = context.converters.shapeContainerNodeToDrawingBlock(childNode, context.nextBlockId, context.positions);
389643
390703
  if (drawingBlock && drawingBlock.kind === "drawing") {
389644
- blocks2.push(drawingBlock);
390704
+ blocks2.push(hydrateTextboxDrawingContent2(childNode, drawingBlock, context));
389645
390705
  }
389646
390706
  continue;
389647
390707
  }
389648
390708
  if (childNode.type === "shapeTextbox" && context.converters?.shapeTextboxNodeToDrawingBlock) {
389649
390709
  const drawingBlock = context.converters.shapeTextboxNodeToDrawingBlock(childNode, context.nextBlockId, context.positions);
389650
390710
  if (drawingBlock && drawingBlock.kind === "drawing") {
389651
- blocks2.push(drawingBlock);
390711
+ blocks2.push(hydrateTextboxDrawingContent2(childNode, drawingBlock, context));
389652
390712
  }
389653
390713
  continue;
389654
390714
  }
@@ -389805,9 +390865,31 @@ var init_table = __esm(() => {
389805
390865
  init_sdt();
389806
390866
  init_ooxml();
389807
390867
  init_direction();
390868
+ init_shapes();
389808
390869
  });
389809
390870
 
389810
390871
  // ../../packages/super-editor/src/editors/v1/core/layout-adapter/converters/paragraph.ts
390872
+ function getLastParagraphFont2(blocks2) {
390873
+ for (let i4 = blocks2.length - 1;i4 >= 0; i4--) {
390874
+ const block = blocks2[i4];
390875
+ if (block.kind === "paragraph") {
390876
+ const para = block;
390877
+ const firstRun = para.runs?.[0];
390878
+ if (!firstRun)
390879
+ continue;
390880
+ const run2 = firstRun;
390881
+ if (typeof run2.text === "string" && run2.text.length === 0) {
390882
+ continue;
390883
+ }
390884
+ const fontFamily = typeof run2.fontFamily === "string" ? run2.fontFamily.trim() : "";
390885
+ const fontSize = typeof run2.fontSize === "number" && Number.isFinite(run2.fontSize) ? run2.fontSize : NaN;
390886
+ if (fontFamily.length > 0 && fontSize > 0) {
390887
+ return { fontFamily, fontSize };
390888
+ }
390889
+ }
390890
+ }
390891
+ return;
390892
+ }
389811
390893
  var INLINE_CONVERTERS_REGISTRY2;
389812
390894
  var init_paragraph2 = __esm(() => {
389813
390895
  init_src2();
@@ -426837,7 +427919,7 @@ var init_run_properties_export = __esm(() => {
426837
427919
  });
426838
427920
 
426839
427921
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/r/r-translator.js
426840
- var XML_NODE_NAME13 = "w:r", SD_KEY_NAME2 = "run", REFERENCE_RUN_STYLE_BY_XML_NAME2, hasXmlNodeNamed2 = (node4, targetName) => {
427922
+ var XML_NODE_NAME13 = "w:r", SD_KEY_NAME2 = "run", REFERENCE_RUN_STYLE_BY_XML_NAME2, BLOCK_HOIST_TYPES2, hasXmlNodeNamed2 = (node4, targetName) => {
426841
427923
  if (!node4 || typeof node4 !== "object")
426842
427924
  return false;
426843
427925
  if (node4.name === targetName)
@@ -426960,6 +428042,12 @@ var XML_NODE_NAME13 = "w:r", SD_KEY_NAME2 = "run", REFERENCE_RUN_STYLE_BY_XML_NA
426960
428042
  const contentElements = rPrNode ? elements.filter((el) => el !== rPrNode) : elements;
426961
428043
  const childParams = { ...params3, nodes: contentElements };
426962
428044
  const content4 = nodeListHandler?.handler(childParams) || [];
428045
+ if (Array.isArray(content4) && content4.length > 0 && content4.every((child) => BLOCK_HOIST_TYPES2.has(child?.type))) {
428046
+ return content4.filter(Boolean).map((child) => ({
428047
+ ...child,
428048
+ marks: Array.isArray(child?.marks) ? child.marks : []
428049
+ }));
428050
+ }
426963
428051
  const contentWithRunMarks = (Array.isArray(content4) ? content4 : []).map((child) => {
426964
428052
  if (!child || typeof child !== "object")
426965
428053
  return child;
@@ -427182,6 +428270,7 @@ var init_r_translator = __esm(() => {
427182
428270
  "w:footnoteReference": "FootnoteReference",
427183
428271
  "w:endnoteReference": "EndnoteReference"
427184
428272
  };
428273
+ BLOCK_HOIST_TYPES2 = new Set(["shapeContainer"]);
427185
428274
  COMPLEX_SCRIPT_CODEPOINT_RANGES2 = [
427186
428275
  [1424, 2303],
427187
428276
  [2304, 4255],
@@ -445177,6 +446266,162 @@ var init_chart_helpers = __esm(() => {
445177
446266
  CHART_TYPE_NAMES2 = new Set(Object.keys(CHART_TYPE_MAP2));
445178
446267
  });
445179
446268
 
446269
+ // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/p/index.js
446270
+ var init_p = __esm(() => {
446271
+ init_p_translator();
446272
+ });
446273
+
446274
+ // ../../packages/super-editor/src/editors/v1/core/super-converter/v2/importer/paragraphNodeImporter.js
446275
+ var PARAGRAPH_PROPERTIES_XML_NAME3 = "w:pPr", hasMeaningfulParagraphContent3 = (elements = []) => elements.some((element3) => element3?.name && element3.name !== PARAGRAPH_PROPERTIES_XML_NAME3), findParagraphProperties2 = (elements = []) => elements.find((element3) => element3?.name === PARAGRAPH_PROPERTIES_XML_NAME3) ?? null, hasParagraphProperties2 = (elements = []) => elements.some((element3) => element3?.name === PARAGRAPH_PROPERTIES_XML_NAME3), cloneParagraphPropertiesForRenderedResult2 = (paragraphProperties) => {
446276
+ const elements = (paragraphProperties.elements || []).filter((element3) => element3?.name !== "w:sectPr").map((element3) => carbonCopy2(element3));
446277
+ if (elements.length === 0)
446278
+ return null;
446279
+ return {
446280
+ ...carbonCopy2(paragraphProperties),
446281
+ elements
446282
+ };
446283
+ }, inheritWrapperParagraphProperties2 = (blockFieldElement, paragraphProperties) => {
446284
+ if (!paragraphProperties)
446285
+ return blockFieldElement;
446286
+ const fieldElements = Array.isArray(blockFieldElement?.elements) ? blockFieldElement.elements : [];
446287
+ const firstParagraphIndex = fieldElements.findIndex((element3) => element3?.name === "w:p");
446288
+ if (firstParagraphIndex < 0)
446289
+ return blockFieldElement;
446290
+ const firstParagraph = fieldElements[firstParagraphIndex];
446291
+ const firstParagraphElements = Array.isArray(firstParagraph.elements) ? firstParagraph.elements : [];
446292
+ if (hasParagraphProperties2(firstParagraphElements))
446293
+ return blockFieldElement;
446294
+ const renderedParagraphProperties = cloneParagraphPropertiesForRenderedResult2(paragraphProperties);
446295
+ const inheritedFirstParagraph = {
446296
+ ...firstParagraph,
446297
+ elements: renderedParagraphProperties ? [renderedParagraphProperties, ...firstParagraphElements] : firstParagraphElements
446298
+ };
446299
+ return {
446300
+ ...blockFieldElement,
446301
+ attributes: {
446302
+ ...blockFieldElement.attributes || {},
446303
+ wrapperParagraphProperties: carbonCopy2(paragraphProperties)
446304
+ },
446305
+ elements: fieldElements.map((element3, index3) => index3 === firstParagraphIndex ? inheritedFirstParagraph : element3)
446306
+ };
446307
+ }, hoistBlockFieldNodes2 = (params3, paragraphNode) => {
446308
+ const paragraphElements = Array.isArray(paragraphNode?.elements) ? paragraphNode.elements : [];
446309
+ const blockFieldElements = paragraphElements.filter((element3) => BLOCK_FIELD_XML_NAMES2.has(element3?.name));
446310
+ if (blockFieldElements.length === 0)
446311
+ return null;
446312
+ const nodes = [];
446313
+ const remainingElements = paragraphElements.filter((element3) => !BLOCK_FIELD_XML_NAMES2.has(element3?.name));
446314
+ const wrapperParagraphProperties = findParagraphProperties2(remainingElements);
446315
+ const shouldTransferWrapperProperties = !hasMeaningfulParagraphContent3(remainingElements);
446316
+ if (hasMeaningfulParagraphContent3(remainingElements)) {
446317
+ const paragraph4 = translator121.encode({
446318
+ ...params3,
446319
+ nodes: [
446320
+ {
446321
+ ...paragraphNode,
446322
+ elements: remainingElements
446323
+ }
446324
+ ]
446325
+ });
446326
+ if (paragraph4) {
446327
+ nodes.push(paragraph4);
446328
+ }
446329
+ }
446330
+ blockFieldElements.forEach((blockFieldElement) => {
446331
+ const fieldElement = shouldTransferWrapperProperties ? inheritWrapperParagraphProperties2(blockFieldElement, wrapperParagraphProperties) : blockFieldElement;
446332
+ nodes.push(...params3.nodeListHandler.handler({
446333
+ ...params3,
446334
+ nodes: [fieldElement],
446335
+ path: [...params3.path || [], paragraphNode]
446336
+ }));
446337
+ });
446338
+ return nodes;
446339
+ }, handleParagraphNode4 = (params3) => {
446340
+ const { nodes } = params3;
446341
+ if (nodes.length === 0 || nodes[0].name !== "w:p") {
446342
+ return { nodes: [], consumed: 0 };
446343
+ }
446344
+ const hoistedNodes = hoistBlockFieldNodes2(params3, nodes[0]);
446345
+ if (hoistedNodes) {
446346
+ return { nodes: hoistedNodes, consumed: 1 };
446347
+ }
446348
+ const schemaNode = translator121.encode(params3);
446349
+ const newNodes = Array.isArray(schemaNode) ? schemaNode : schemaNode ? [schemaNode] : [];
446350
+ return { nodes: newNodes, consumed: 1 };
446351
+ }, paragraphNodeHandlerEntity2;
446352
+ var init_paragraphNodeImporter = __esm(() => {
446353
+ init_p();
446354
+ init_block_field_xml_names();
446355
+ paragraphNodeHandlerEntity2 = {
446356
+ handlerName: "paragraphNodeHandler",
446357
+ handler: handleParagraphNode4
446358
+ };
446359
+ });
446360
+
446361
+ // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/helpers/import-drawingml-textbox.js
446362
+ function stripRunNodeMarks2(nodes) {
446363
+ if (!Array.isArray(nodes))
446364
+ return nodes;
446365
+ return nodes.map((node4) => {
446366
+ if (!node4 || typeof node4 !== "object")
446367
+ return node4;
446368
+ const stripped = node4.type === "run" && Array.isArray(node4.marks) && node4.marks.length > 0 ? { ...node4, marks: [] } : node4;
446369
+ if (Array.isArray(stripped.content)) {
446370
+ return { ...stripped, content: stripRunNodeMarks2(stripped.content) };
446371
+ }
446372
+ return stripped;
446373
+ });
446374
+ }
446375
+ function importDrawingMLTextbox2({
446376
+ params: params3,
446377
+ drawingNode,
446378
+ textBoxContent,
446379
+ bodyPr,
446380
+ baseAttrs = {},
446381
+ paragraphImporter
446382
+ }) {
446383
+ if (!textBoxContent) {
446384
+ return null;
446385
+ }
446386
+ const processedContent = preProcessTextBoxContent2(textBoxContent, params3);
446387
+ const textboxParagraphs = collectTextBoxParagraphs2(processedContent?.elements || []);
446388
+ const importParagraph = typeof paragraphImporter === "function" ? paragraphImporter : (paragraph4) => {
446389
+ const imported = handleParagraphNode4({
446390
+ ...params3,
446391
+ nodes: [paragraph4]
446392
+ });
446393
+ return imported?.nodes || [];
446394
+ };
446395
+ const rawNodes = textboxParagraphs.flatMap((paragraph4) => {
446396
+ const imported = importParagraph(paragraph4);
446397
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
446398
+ });
446399
+ const contentNodes = stripRunNodeMarks2(rawNodes);
446400
+ const { verticalAlign, insets } = extractBodyPrProperties2(bodyPr);
446401
+ return {
446402
+ type: "shapeContainer",
446403
+ attrs: {
446404
+ ...baseAttrs,
446405
+ drawingContent: drawingNode
446406
+ },
446407
+ content: [
446408
+ {
446409
+ type: "shapeTextbox",
446410
+ attrs: {
446411
+ textInsets: { top: insets.top, right: insets.right, bottom: insets.bottom, left: insets.left },
446412
+ textVerticalAlign: verticalAlign,
446413
+ attributes: {}
446414
+ },
446415
+ content: contentNodes
446416
+ }
446417
+ ]
446418
+ };
446419
+ }
446420
+ var init_import_drawingml_textbox = __esm(() => {
446421
+ init_textbox_content_helpers();
446422
+ init_paragraphNodeImporter();
446423
+ });
446424
+
445180
446425
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.js
445181
446426
  function handleImageNode3(node4, params3, isAnchor) {
445182
446427
  if (!node4)
@@ -445663,6 +446908,94 @@ function extractTextFromTextBox2(textBoxContent, bodyPr, params3 = {}) {
445663
446908
  wrap: wrap6
445664
446909
  };
445665
446910
  }
446911
+ function extractFieldInlineNodes2(node4) {
446912
+ if (node4?.name === "sd:autoPageNumber") {
446913
+ return [{ type: "page-number", attrs: { marksAsAttrs: [], instruction: "PAGE" } }];
446914
+ }
446915
+ if (node4?.name === "sd:totalPageNumber") {
446916
+ return [{ type: "total-page-number", attrs: { marksAsAttrs: [], instruction: "NUMPAGES" } }];
446917
+ }
446918
+ if (node4?.name === "sd:sectionPageCount") {
446919
+ const cachedText = node4?.attributes?.resolvedText ?? node4?.attributes?.importedCachedText ?? "";
446920
+ if (!cachedText)
446921
+ return [];
446922
+ return [{ type: "text", text: cachedText }];
446923
+ }
446924
+ return [];
446925
+ }
446926
+ function extractInlineNodesFromRun2(run2, params3) {
446927
+ if (!run2?.elements)
446928
+ return [];
446929
+ const nodes = [];
446930
+ run2.elements.forEach((el) => {
446931
+ if (el.name === "w:t" || el.name === "w:delText") {
446932
+ const textNode = el.elements?.find((n) => n.type === "text");
446933
+ if (!textNode || typeof textNode.text !== "string")
446934
+ return;
446935
+ const cleanedText = textNode.text.replace(/\[\[sdspace\]\]/g, " ");
446936
+ if (cleanedText.length > 0) {
446937
+ nodes.push({ type: "text", text: cleanedText });
446938
+ }
446939
+ } else if (el.name === "w:tab") {
446940
+ nodes.push({ type: "text", text: "\t" });
446941
+ } else if (el.name === "w:br") {
446942
+ nodes.push({ type: "lineBreak", attrs: {} });
446943
+ } else if (el.name === "sd:autoPageNumber" || el.name === "sd:totalPageNumber" || el.name === "sd:sectionPageCount") {
446944
+ nodes.push(...extractFieldInlineNodes2(el));
446945
+ } else if (el.name === "w:drawing") {
446946
+ const inline = el.elements?.find((child) => child?.name === "wp:inline");
446947
+ if (!inline)
446948
+ return;
446949
+ const imagePm = handleImageNode3(inline, { ...params3, nodes: [el] }, false);
446950
+ if (imagePm?.type === "image" && imagePm.attrs?.hidden !== true) {
446951
+ nodes.push(imagePm);
446952
+ }
446953
+ }
446954
+ });
446955
+ return nodes;
446956
+ }
446957
+ function paragraphToPmParagraph2(paragraph4, params3) {
446958
+ const paragraphNode = collectTextBoxParagraphs2([paragraph4])[0];
446959
+ if (!paragraphNode)
446960
+ return null;
446961
+ const paragraphProperties = resolveParagraphPropertiesForTextBox2(paragraphNode, params3);
446962
+ const alignment = extractParagraphAlignment2(paragraphNode) || "left";
446963
+ const content4 = [];
446964
+ let pendingRunContent = [];
446965
+ const flushPendingRun = () => {
446966
+ if (pendingRunContent.length === 0)
446967
+ return;
446968
+ content4.push({ type: "run", attrs: {}, content: pendingRunContent });
446969
+ pendingRunContent = [];
446970
+ };
446971
+ (paragraphNode.elements || []).forEach((element3) => {
446972
+ if (element3?.name === "w:r") {
446973
+ const inlineParts = extractInlineNodesFromRun2(element3, params3);
446974
+ inlineParts.forEach((part) => {
446975
+ if (part?.type === "image") {
446976
+ flushPendingRun();
446977
+ content4.push(part);
446978
+ return;
446979
+ }
446980
+ pendingRunContent.push(part);
446981
+ });
446982
+ return;
446983
+ }
446984
+ if (element3?.name?.startsWith("sd:")) {
446985
+ const runContent = extractFieldInlineNodes2(element3);
446986
+ if (runContent.length > 0) {
446987
+ pendingRunContent.push(...runContent);
446988
+ }
446989
+ }
446990
+ });
446991
+ flushPendingRun();
446992
+ return {
446993
+ type: "paragraph",
446994
+ attrs: { paragraphProperties, textAlign: alignment },
446995
+ content: content4,
446996
+ marks: []
446997
+ };
446998
+ }
445666
446999
  function getVectorShape2({
445667
447000
  params: params3,
445668
447001
  node: node4,
@@ -445714,14 +447047,46 @@ function getVectorShape2({
445714
447047
  const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
445715
447048
  const bodyPr = wsp.elements?.find((el) => el.name === "wps:bodyPr");
445716
447049
  const nonVisualShapeProps = wsp.elements?.find((el) => el.name === "wps:cNvSpPr");
447050
+ const isWordArt = bodyPr?.attributes?.["fromWordArt"] === "1";
447051
+ const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
447052
+ if (isTextBox && textBoxContent) {
447053
+ return importDrawingMLTextbox2({
447054
+ params: params3,
447055
+ drawingNode: drawingNode?.name === "w:drawing" ? drawingNode : null,
447056
+ textBoxContent,
447057
+ bodyPr,
447058
+ baseAttrs: {
447059
+ ...schemaAttrs,
447060
+ width,
447061
+ height,
447062
+ rotation,
447063
+ flipH,
447064
+ flipV,
447065
+ fillColor,
447066
+ strokeColor,
447067
+ strokeWidth,
447068
+ lineEnds,
447069
+ effectExtent,
447070
+ marginOffset,
447071
+ anchorData,
447072
+ wrap: wrap6,
447073
+ isAnchor,
447074
+ isWordArt,
447075
+ isTextBox,
447076
+ originalAttributes: node4?.attributes
447077
+ },
447078
+ paragraphImporter: params3?.nodeListHandler != null ? undefined : (paragraph4) => {
447079
+ const imported = paragraphToPmParagraph2(paragraph4, params3);
447080
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
447081
+ }
447082
+ });
447083
+ }
445717
447084
  let textContent2 = null;
445718
447085
  let textAlign = "left";
445719
447086
  if (textBoxContent) {
445720
447087
  textContent2 = extractTextFromTextBox2(textBoxContent, bodyPr, params3);
445721
447088
  textAlign = textContent2?.horizontalAlign || "left";
445722
447089
  }
445723
- const isWordArt = bodyPr?.attributes?.["fromWordArt"] === "1";
445724
- const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
445725
447090
  return {
445726
447091
  type: "vectorShape",
445727
447092
  attrs: {
@@ -445860,6 +447225,38 @@ var DRAWING_XML_TAG2 = "w:drawing", SHAPE_URI2 = "http://schemas.microsoft.com/o
445860
447225
  if (result)
445861
447226
  return result;
445862
447227
  }
447228
+ const nonVisualShapeProps = wsp.elements?.find((el) => el.name === "wps:cNvSpPr");
447229
+ const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
447230
+ if (isTextBox && textBoxContent) {
447231
+ const bodyPr = wsp.elements?.find((el) => el.name === "wps:bodyPr");
447232
+ const drawingNode = params3.nodes?.[0];
447233
+ const result = importDrawingMLTextbox2({
447234
+ params: params3,
447235
+ drawingNode: drawingNode?.name === "w:drawing" ? drawingNode : null,
447236
+ textBoxContent,
447237
+ bodyPr,
447238
+ baseAttrs: {
447239
+ width: size3?.width,
447240
+ height: size3?.height,
447241
+ marginOffset,
447242
+ anchorData,
447243
+ wrap: wrap6,
447244
+ isAnchor,
447245
+ isTextBox: true,
447246
+ originalAttributes: node4?.attributes,
447247
+ ...params3.nodes?.[0]?.name === "w:drawing" ? { drawingContent: params3.nodes[0] } : {}
447248
+ },
447249
+ paragraphImporter: params3?.nodeListHandler != null ? undefined : (paragraph4) => {
447250
+ const imported = paragraphToPmParagraph2(paragraph4, params3);
447251
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
447252
+ }
447253
+ });
447254
+ if (result?.attrs && isHidden) {
447255
+ result.attrs.hidden = true;
447256
+ }
447257
+ if (result)
447258
+ return result;
447259
+ }
445863
447260
  const fallbackType = textBoxContent ? "textbox" : "drawing";
445864
447261
  const placeholder = buildShapePlaceholder2(node4, size3, padding, marginOffset, fallbackType);
445865
447262
  if (placeholder?.attrs && isHidden) {
@@ -446156,6 +447553,7 @@ var init_encode_image_node_helpers = __esm(() => {
446156
447553
  init_tiff_converter();
446157
447554
  init_textbox_content_helpers();
446158
447555
  init_chart_helpers();
447556
+ init_import_drawingml_textbox();
446159
447557
  });
446160
447558
 
446161
447559
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.js
@@ -448495,11 +449893,6 @@ var init_translate_document_section = __esm(() => {
448495
449893
  init_translateChildNodes();
448496
449894
  });
448497
449895
 
448498
- // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/p/index.js
448499
- var init_p = __esm(() => {
448500
- init_p_translator();
448501
- });
448502
-
448503
449896
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/sdt/helpers/translate-document-part-obj.js
448504
449897
  function translateDocumentPartObj2(params3) {
448505
449898
  const { node: node4 } = params3;
@@ -452199,93 +453592,6 @@ var init_textNodeImporter = __esm(() => {
452199
453592
  };
452200
453593
  });
452201
453594
 
452202
- // ../../packages/super-editor/src/editors/v1/core/super-converter/v2/importer/paragraphNodeImporter.js
452203
- var PARAGRAPH_PROPERTIES_XML_NAME3 = "w:pPr", hasMeaningfulParagraphContent3 = (elements = []) => elements.some((element3) => element3?.name && element3.name !== PARAGRAPH_PROPERTIES_XML_NAME3), findParagraphProperties2 = (elements = []) => elements.find((element3) => element3?.name === PARAGRAPH_PROPERTIES_XML_NAME3) ?? null, hasParagraphProperties2 = (elements = []) => elements.some((element3) => element3?.name === PARAGRAPH_PROPERTIES_XML_NAME3), cloneParagraphPropertiesForRenderedResult2 = (paragraphProperties) => {
452204
- const elements = (paragraphProperties.elements || []).filter((element3) => element3?.name !== "w:sectPr").map((element3) => carbonCopy2(element3));
452205
- if (elements.length === 0)
452206
- return null;
452207
- return {
452208
- ...carbonCopy2(paragraphProperties),
452209
- elements
452210
- };
452211
- }, inheritWrapperParagraphProperties2 = (blockFieldElement, paragraphProperties) => {
452212
- if (!paragraphProperties)
452213
- return blockFieldElement;
452214
- const fieldElements = Array.isArray(blockFieldElement?.elements) ? blockFieldElement.elements : [];
452215
- const firstParagraphIndex = fieldElements.findIndex((element3) => element3?.name === "w:p");
452216
- if (firstParagraphIndex < 0)
452217
- return blockFieldElement;
452218
- const firstParagraph = fieldElements[firstParagraphIndex];
452219
- const firstParagraphElements = Array.isArray(firstParagraph.elements) ? firstParagraph.elements : [];
452220
- if (hasParagraphProperties2(firstParagraphElements))
452221
- return blockFieldElement;
452222
- const renderedParagraphProperties = cloneParagraphPropertiesForRenderedResult2(paragraphProperties);
452223
- const inheritedFirstParagraph = {
452224
- ...firstParagraph,
452225
- elements: renderedParagraphProperties ? [renderedParagraphProperties, ...firstParagraphElements] : firstParagraphElements
452226
- };
452227
- return {
452228
- ...blockFieldElement,
452229
- attributes: {
452230
- ...blockFieldElement.attributes || {},
452231
- wrapperParagraphProperties: carbonCopy2(paragraphProperties)
452232
- },
452233
- elements: fieldElements.map((element3, index3) => index3 === firstParagraphIndex ? inheritedFirstParagraph : element3)
452234
- };
452235
- }, hoistBlockFieldNodes2 = (params3, paragraphNode) => {
452236
- const paragraphElements = Array.isArray(paragraphNode?.elements) ? paragraphNode.elements : [];
452237
- const blockFieldElements = paragraphElements.filter((element3) => BLOCK_FIELD_XML_NAMES2.has(element3?.name));
452238
- if (blockFieldElements.length === 0)
452239
- return null;
452240
- const nodes = [];
452241
- const remainingElements = paragraphElements.filter((element3) => !BLOCK_FIELD_XML_NAMES2.has(element3?.name));
452242
- const wrapperParagraphProperties = findParagraphProperties2(remainingElements);
452243
- const shouldTransferWrapperProperties = !hasMeaningfulParagraphContent3(remainingElements);
452244
- if (hasMeaningfulParagraphContent3(remainingElements)) {
452245
- const paragraph4 = translator121.encode({
452246
- ...params3,
452247
- nodes: [
452248
- {
452249
- ...paragraphNode,
452250
- elements: remainingElements
452251
- }
452252
- ]
452253
- });
452254
- if (paragraph4) {
452255
- nodes.push(paragraph4);
452256
- }
452257
- }
452258
- blockFieldElements.forEach((blockFieldElement) => {
452259
- const fieldElement = shouldTransferWrapperProperties ? inheritWrapperParagraphProperties2(blockFieldElement, wrapperParagraphProperties) : blockFieldElement;
452260
- nodes.push(...params3.nodeListHandler.handler({
452261
- ...params3,
452262
- nodes: [fieldElement],
452263
- path: [...params3.path || [], paragraphNode]
452264
- }));
452265
- });
452266
- return nodes;
452267
- }, handleParagraphNode4 = (params3) => {
452268
- const { nodes } = params3;
452269
- if (nodes.length === 0 || nodes[0].name !== "w:p") {
452270
- return { nodes: [], consumed: 0 };
452271
- }
452272
- const hoistedNodes = hoistBlockFieldNodes2(params3, nodes[0]);
452273
- if (hoistedNodes) {
452274
- return { nodes: hoistedNodes, consumed: 1 };
452275
- }
452276
- const schemaNode = translator121.encode(params3);
452277
- const newNodes = Array.isArray(schemaNode) ? schemaNode : schemaNode ? [schemaNode] : [];
452278
- return { nodes: newNodes, consumed: 1 };
452279
- }, paragraphNodeHandlerEntity2;
452280
- var init_paragraphNodeImporter = __esm(() => {
452281
- init_p();
452282
- init_block_field_xml_names();
452283
- paragraphNodeHandlerEntity2 = {
452284
- handlerName: "paragraphNodeHandler",
452285
- handler: handleParagraphNode4
452286
- };
452287
- });
452288
-
452289
453595
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v2/importer/sdtNodeImporter.js
452290
453596
  var handleSdtNode2 = (params3) => {
452291
453597
  const { nodes } = params3;
@@ -456370,9 +457676,16 @@ function handleShapeTextboxImport2({ params: params3, pict }) {
456370
457676
  }
456371
457677
  const parsedStyle = parseInlineStyles2(shapeAttrs.style);
456372
457678
  const shapeStyle = buildStyles2(parsedStyle);
457679
+ const positionData = extractPositionData2(parsedStyle);
456373
457680
  if (shapeStyle) {
456374
457681
  schemaAttrs.style = shapeStyle;
456375
457682
  }
457683
+ if (positionData.anchorData) {
457684
+ schemaAttrs.anchorData = positionData.anchorData;
457685
+ }
457686
+ if (positionData.marginOffset) {
457687
+ schemaAttrs.marginOffset = positionData.marginOffset;
457688
+ }
456376
457689
  const textbox = shape.elements?.find((el) => el.name === "v:textbox");
456377
457690
  const wrap6 = shape.elements?.find((el) => el.name === "w10:wrap");
456378
457691
  if (wrap6?.attributes) {
@@ -456415,6 +457728,44 @@ function buildStyles2(styleObject) {
456415
457728
  }
456416
457729
  return style2;
456417
457730
  }
457731
+ function extractPositionData2(styleObject) {
457732
+ const anchorData = {};
457733
+ const marginOffset = {};
457734
+ if (styleObject["mso-position-horizontal"]) {
457735
+ anchorData.alignH = styleObject["mso-position-horizontal"];
457736
+ }
457737
+ if (styleObject["mso-position-horizontal-relative"]) {
457738
+ anchorData.hRelativeFrom = styleObject["mso-position-horizontal-relative"];
457739
+ }
457740
+ if (styleObject["mso-position-vertical"]) {
457741
+ anchorData.alignV = styleObject["mso-position-vertical"];
457742
+ }
457743
+ if (styleObject["mso-position-vertical-relative"]) {
457744
+ anchorData.vRelativeFrom = styleObject["mso-position-vertical-relative"];
457745
+ }
457746
+ if (styleObject["margin-left"] != null) {
457747
+ marginOffset.horizontal = convertToPixels2(styleObject["margin-left"]);
457748
+ }
457749
+ if (styleObject["margin-top"] != null) {
457750
+ marginOffset.top = convertToPixels2(styleObject["margin-top"]);
457751
+ }
457752
+ return {
457753
+ ...Object.keys(anchorData).length > 0 ? { anchorData } : {},
457754
+ ...Object.keys(marginOffset).length > 0 ? { marginOffset } : {}
457755
+ };
457756
+ }
457757
+ function convertToPixels2(value) {
457758
+ const num = parseFloat(value);
457759
+ if (Number.isNaN(num))
457760
+ return 0;
457761
+ if (value.endsWith("pt"))
457762
+ return num * 96 / 72;
457763
+ if (value.endsWith("in"))
457764
+ return num * 96;
457765
+ if (value.endsWith("px"))
457766
+ return num;
457767
+ return num;
457768
+ }
456418
457769
  var init_handle_shape_textbox_import = __esm(() => {
456419
457770
  init_docxImporter();
456420
457771
  init_paragraphNodeImporter();
@@ -456496,12 +457847,12 @@ function handleShapeImageWatermarkImport2({ params: params3, pict }) {
456496
457847
  alignV: vPosition
456497
457848
  },
456498
457849
  size: {
456499
- width: convertToPixels2(width),
456500
- height: convertToPixels2(height)
457850
+ width: convertToPixels3(width),
457851
+ height: convertToPixels3(height)
456501
457852
  },
456502
457853
  marginOffset: {
456503
- horizontal: convertToPixels2(position5.marginLeft),
456504
- top: convertToPixels2(position5.marginTop)
457854
+ horizontal: convertToPixels3(position5.marginLeft),
457855
+ top: convertToPixels3(position5.marginTop)
456505
457856
  },
456506
457857
  ...gain && { gain },
456507
457858
  ...blacklevel && { blacklevel }
@@ -456535,7 +457886,7 @@ function parseVmlStyle2(style2) {
456535
457886
  }
456536
457887
  return result;
456537
457888
  }
456538
- function convertToPixels2(value) {
457889
+ function convertToPixels3(value) {
456539
457890
  if (typeof value === "number")
456540
457891
  return value;
456541
457892
  if (!value || typeof value !== "string")
@@ -456627,8 +457978,8 @@ function handleShapeTextWatermarkImport2({ pict }) {
456627
457978
  const wrap6 = shape.elements?.find((el) => el.name === "w10:wrap");
456628
457979
  const wrapAttrs = wrap6?.attributes || {};
456629
457980
  const wrapType = wrapAttrs.type || "none";
456630
- const widthPx = convertToPixels3(width);
456631
- const heightPx = convertToPixels3(height);
457981
+ const widthPx = convertToPixels4(width);
457982
+ const heightPx = convertToPixels4(height);
456632
457983
  const sanitizedOpacity = sanitizeNumeric2(parseVmlOpacity2(opacity), DEFAULT_VML_TEXT_WATERMARK_OPACITY2, 0, 1);
456633
457984
  const sanitizedRotation = sanitizeNumeric2(rotation, 0, -360, 360);
456634
457985
  const svgResult = generateTextWatermarkSVG2({
@@ -456660,8 +458011,8 @@ function handleShapeTextWatermarkImport2({ pict }) {
456660
458011
  vPosition,
456661
458012
  hRelativeTo,
456662
458013
  vRelativeTo,
456663
- marginLeft: convertToPixels3(position5.marginLeft),
456664
- marginTop: convertToPixels3(position5.marginTop),
458014
+ marginLeft: convertToPixels4(position5.marginLeft),
458015
+ marginTop: convertToPixels4(position5.marginTop),
456665
458016
  width: widthPx,
456666
458017
  height: heightPx,
456667
458018
  svgWidth: svgResult.svgWidth,
@@ -456926,7 +458277,7 @@ function parseVmlStyle3(style2) {
456926
458277
  }
456927
458278
  return result;
456928
458279
  }
456929
- function convertToPixels3(value) {
458280
+ function convertToPixels4(value) {
456930
458281
  if (typeof value === "number")
456931
458282
  return value;
456932
458283
  if (!value || typeof value !== "string")
@@ -456993,16 +458344,83 @@ var init_pict_node_type_strategy = __esm(() => {
456993
458344
  init_handle_shape_text_watermark_import();
456994
458345
  });
456995
458346
 
458347
+ // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/helpers/translate-drawingml-textbox.js
458348
+ function translateDrawingMLTextbox2(params3) {
458349
+ const { node: node4 } = params3;
458350
+ const drawingContent = node4?.attrs?.drawingContent;
458351
+ const shapeTextbox = node4?.content?.find((child) => child?.type === "shapeTextbox");
458352
+ if (!drawingContent || !shapeTextbox) {
458353
+ return null;
458354
+ }
458355
+ const drawing = carbonCopy2(drawingContent);
458356
+ const liveParagraphs = translateChildNodes2({
458357
+ ...params3,
458358
+ node: shapeTextbox
458359
+ });
458360
+ const txbxContent = findTextboxContentNode2(drawing);
458361
+ if (!txbxContent) {
458362
+ return null;
458363
+ }
458364
+ txbxContent.elements = liveParagraphs;
458365
+ const alternateContent = {
458366
+ name: "mc:AlternateContent",
458367
+ elements: [
458368
+ {
458369
+ name: "mc:Choice",
458370
+ attributes: { Requires: "wps" },
458371
+ elements: [drawing]
458372
+ }
458373
+ ]
458374
+ };
458375
+ return wrapTextInRun2(alternateContent);
458376
+ }
458377
+ function findTextboxContentNode2(node4) {
458378
+ if (!node4 || typeof node4 !== "object")
458379
+ return null;
458380
+ if (node4.name === "w:txbxContent")
458381
+ return node4;
458382
+ if (!Array.isArray(node4.elements))
458383
+ return null;
458384
+ for (const child of node4.elements) {
458385
+ const found3 = findTextboxContentNode2(child);
458386
+ if (found3)
458387
+ return found3;
458388
+ }
458389
+ return null;
458390
+ }
458391
+ var init_translate_drawingml_textbox = __esm(() => {
458392
+ init_translateChildNodes();
458393
+ init_exporter();
458394
+ });
458395
+
456996
458396
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/pict/helpers/translate-shape-container.js
456997
458397
  function translateShapeContainer2(params3) {
456998
458398
  const { node: node4 } = params3;
458399
+ if (node4?.attrs?.drawingContent) {
458400
+ const run2 = translateDrawingMLTextbox2(params3);
458401
+ if (run2) {
458402
+ return {
458403
+ name: "w:p",
458404
+ elements: [run2]
458405
+ };
458406
+ }
458407
+ return {
458408
+ name: "w:p",
458409
+ elements: [wrapTextInRun2(node4.attrs.drawingContent)]
458410
+ };
458411
+ }
456999
458412
  const elements = translateChildNodes2(params3);
458413
+ const shapeAttributes = {
458414
+ ...node4.attrs.attributes,
458415
+ fillcolor: node4.attrs.fillcolor
458416
+ };
458417
+ const style2 = buildShapeStyle2(node4.attrs);
458418
+ if (style2) {
458419
+ shapeAttributes.style = style2;
458420
+ }
457000
458421
  const shape = {
457001
458422
  name: "v:shape",
457002
- attributes: {
457003
- ...node4.attrs.attributes,
457004
- fillcolor: node4.attrs.fillcolor
457005
- },
458423
+ attributes: shapeAttributes,
457006
458424
  elements: [
457007
458425
  ...elements,
457008
458426
  ...node4.attrs.wrapAttributes ? [
@@ -457025,9 +458443,43 @@ function translateShapeContainer2(params3) {
457025
458443
  elements: [wrapTextInRun2(pict)]
457026
458444
  };
457027
458445
  }
458446
+ function buildShapeStyle2(attrs) {
458447
+ const originalStyle = parseInlineStyles2(attrs.attributes?.style);
458448
+ const managedStyle = parseInlineStyles2(attrs.style);
458449
+ const style2 = {
458450
+ ...originalStyle,
458451
+ ...managedStyle
458452
+ };
458453
+ if (attrs.marginOffset?.horizontal !== undefined) {
458454
+ style2["margin-left"] = `${convertToPt2(attrs.marginOffset.horizontal)}pt`;
458455
+ }
458456
+ if (attrs.marginOffset?.top !== undefined) {
458457
+ style2["margin-top"] = `${convertToPt2(attrs.marginOffset.top)}pt`;
458458
+ }
458459
+ if (attrs.anchorData?.alignH) {
458460
+ style2["mso-position-horizontal"] = attrs.anchorData.alignH;
458461
+ }
458462
+ if (attrs.anchorData?.hRelativeFrom) {
458463
+ style2["mso-position-horizontal-relative"] = attrs.anchorData.hRelativeFrom;
458464
+ }
458465
+ if (attrs.anchorData?.alignV) {
458466
+ style2["mso-position-vertical"] = attrs.anchorData.alignV;
458467
+ }
458468
+ if (attrs.anchorData?.vRelativeFrom) {
458469
+ style2["mso-position-vertical-relative"] = attrs.anchorData.vRelativeFrom;
458470
+ }
458471
+ const entries = Object.entries(style2);
458472
+ if (entries.length === 0)
458473
+ return;
458474
+ return entries.map(([prop, value]) => `${prop}:${value}`).join(";");
458475
+ }
458476
+ function convertToPt2(pixels) {
458477
+ return pixels * 72 / 96;
458478
+ }
457028
458479
  var init_translate_shape_container = __esm(() => {
457029
458480
  init_translateChildNodes();
457030
458481
  init_exporter();
458482
+ init_translate_drawingml_textbox();
457031
458483
  });
457032
458484
 
457033
458485
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/pict/helpers/translate-shape-textbox.js
@@ -457252,18 +458704,18 @@ function buildVmlStyle2(attrs) {
457252
458704
  styles.push("position:absolute");
457253
458705
  if (attrs.size) {
457254
458706
  if (attrs.size.width) {
457255
- styles.push(`width:${convertToPt2(attrs.size.width)}pt`);
458707
+ styles.push(`width:${convertToPt3(attrs.size.width)}pt`);
457256
458708
  }
457257
458709
  if (attrs.size.height) {
457258
- styles.push(`height:${convertToPt2(attrs.size.height)}pt`);
458710
+ styles.push(`height:${convertToPt3(attrs.size.height)}pt`);
457259
458711
  }
457260
458712
  }
457261
458713
  if (attrs.marginOffset) {
457262
458714
  if (attrs.marginOffset.horizontal !== undefined) {
457263
- styles.push(`margin-left:${convertToPt2(attrs.marginOffset.horizontal)}pt`);
458715
+ styles.push(`margin-left:${convertToPt3(attrs.marginOffset.horizontal)}pt`);
457264
458716
  }
457265
458717
  if (attrs.marginOffset.top !== undefined) {
457266
- styles.push(`margin-top:${convertToPt2(attrs.marginOffset.top)}pt`);
458718
+ styles.push(`margin-top:${convertToPt3(attrs.marginOffset.top)}pt`);
457267
458719
  }
457268
458720
  }
457269
458721
  if (attrs.wrap?.attrs?.behindDoc) {
@@ -457287,7 +458739,7 @@ function buildVmlStyle2(attrs) {
457287
458739
  styles.push("mso-height-percent:0");
457288
458740
  return styles.join(";");
457289
458741
  }
457290
- function convertToPt2(pixels) {
458742
+ function convertToPt3(pixels) {
457291
458743
  return pixels * 72 / 96;
457292
458744
  }
457293
458745
  var init_translate_image_watermark = () => {};
@@ -457427,10 +458879,10 @@ function buildVmlStyle3(attrs, wmData) {
457427
458879
  styles.push("position:absolute");
457428
458880
  if (attrs.marginOffset) {
457429
458881
  if (attrs.marginOffset.horizontal !== undefined) {
457430
- styles.push(`margin-left:${convertToPt3(attrs.marginOffset.horizontal)}pt`);
458882
+ styles.push(`margin-left:${convertToPt4(attrs.marginOffset.horizontal)}pt`);
457431
458883
  }
457432
458884
  if (attrs.marginOffset.top !== undefined) {
457433
- styles.push(`margin-top:${convertToPt3(attrs.marginOffset.top)}pt`);
458885
+ styles.push(`margin-top:${convertToPt4(attrs.marginOffset.top)}pt`);
457434
458886
  }
457435
458887
  } else {
457436
458888
  styles.push("margin-left:0.05pt");
@@ -457438,10 +458890,10 @@ function buildVmlStyle3(attrs, wmData) {
457438
458890
  }
457439
458891
  if (attrs.size) {
457440
458892
  if (attrs.size.width) {
457441
- styles.push(`width:${convertToPt3(attrs.size.width)}pt`);
458893
+ styles.push(`width:${convertToPt4(attrs.size.width)}pt`);
457442
458894
  }
457443
458895
  if (attrs.size.height) {
457444
- styles.push(`height:${convertToPt3(attrs.size.height)}pt`);
458896
+ styles.push(`height:${convertToPt4(attrs.size.height)}pt`);
457445
458897
  }
457446
458898
  }
457447
458899
  const wrapType = attrs.wrap?.type;
@@ -457491,7 +458943,7 @@ function buildTextpathStyle2(wmData) {
457491
458943
  }
457492
458944
  return styles.join(";");
457493
458945
  }
457494
- function convertToPt3(pixels) {
458946
+ function convertToPt4(pixels) {
457495
458947
  if (typeof pixels === "number") {
457496
458948
  return pixels * 72 / 96;
457497
458949
  }
@@ -459310,6 +460762,9 @@ var init_bundled_manifest = __esm(() => {
459310
460762
  family2("Liberation Serif", "LiberationSerif", "OFL-1.1"),
459311
460763
  family2("Liberation Mono", "LiberationMono", "OFL-1.1"),
459312
460764
  familyWithFaces2("Caprasimo", "OFL-1.1", [{ weight: "normal", style: "normal", file: "Caprasimo-Regular.woff2" }]),
460765
+ familyWithFaces2("Archivo Black", "OFL-1.1", [
460766
+ { weight: "normal", style: "normal", file: "ArchivoBlack-Regular.woff2" }
460767
+ ]),
459313
460768
  familyWithFaces2("C059", "AGPL-3.0-only WITH PS-or-PDF-font-exception-20170817", [
459314
460769
  { weight: "normal", style: "normal", file: "C059-Roman.woff2" },
459315
460770
  { weight: "bold", style: "normal", file: "C059-Bold.woff2" },
@@ -459337,7 +460792,11 @@ var init_bundled_manifest = __esm(() => {
459337
460792
  { weight: "normal", style: "normal", file: "NotoSansMono-Regular.woff2" },
459338
460793
  { weight: "bold", style: "normal", file: "NotoSansMono-Bold.woff2" }
459339
460794
  ]),
459340
- family2("PT Sans", "PTSans", "OFL-1.1")
460795
+ family2("PT Sans", "PTSans", "OFL-1.1"),
460796
+ familyWithFaces2("PT Sans Narrow", "OFL-1.1", [
460797
+ { weight: "normal", style: "normal", file: "PTSansNarrow-Regular.woff2" },
460798
+ { weight: "bold", style: "normal", file: "PTSansNarrow-Bold.woff2" }
460799
+ ])
459341
460800
  ]);
459342
460801
  });
459343
460802
 
@@ -460030,6 +461489,7 @@ var init_font_offerings = __esm(() => {
460030
461489
  init_substitution_evidence();
460031
461490
  BUNDLED_FAMILIES2 = new Set(BUNDLED_MANIFEST2.map((f2) => f2.family));
460032
461491
  ADVERTISED_BUILT_IN_TOOLBAR_FAMILIES2 = new Set([
461492
+ "Arial Black",
460033
461493
  "Arial Narrow",
460034
461494
  "Baskerville Old Face",
460035
461495
  "Brush Script MT",
@@ -460038,6 +461498,7 @@ var init_font_offerings = __esm(() => {
460038
461498
  "Comic Sans MS",
460039
461499
  "Garamond",
460040
461500
  "Georgia",
461501
+ "Gill Sans MT Condensed",
460041
461502
  "Lucida Console",
460042
461503
  "Tahoma",
460043
461504
  "Trebuchet MS"