oasis-editor 0.0.107 → 0.0.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageContentWidth, b as getPageBodyTop, c as getPageBodyBottom, l as listReferencedEndnotes, f as getFootnoteDisplayMarker, s as setActiveHyphenation, h as getDocumentSections, i as buildFootnoteReservations, M as MAX_FOOTNOTE_LAYOUT_ITERATIONS, r as reservationSignature, j as applyFootnotesToPages, k as getRunField, m as projectBlocksLayout, v as visitRun, n as assertNever, o as createSignal, q as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getParagraphText, C as getActiveZone, D as getActiveSectionIndex, E as getParagraphs, F as normalizeSelection, G as positionToParagraphOffset, H as paragraphOffsetToPosition, I as clampPosition, J as findParagraphIndex, K as createCollapsedSelection, L as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as getBlockParagraphs, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as underlineStyleToCssDecorationStyle, Z as resolveImageSrc, _ as listKindForTag, $ as isParagraphTag, a0 as collectInlineRuns, a1 as parseParagraphStyle, a2 as getRunImage, a3 as InlineShell, a4 as BalloonShell, a5 as DocumentShell, a6 as createMemo, a7 as getCaretRectFromSnapshot, a8 as getParagraphRectFromSnapshot, a9 as createComponent, aa as CaretOverlay, ab as Show, ac as createRenderEffect, ad as style, ae as setAttribute, af as setStyleProperty, ag as memo, ah as template, ai as useI18n, aj as createEffect, ak as insert, al as use, am as addEventListener, an as Dialog, ao as delegateEvents, ap as className, aq as For, ar as UNDERLINE_STYLE_OPTIONS, as as Tabs, at as onMount, au as onCleanup, av as PluginUiHost, aw as OasisEditorEditor, ax as OasisBrandMark, ay as setPreciseFontPreference, az as setWelcomeSeen, aA as enablePreciseFontMode, aB as TWIPS_PER_POINT, aC as PX_PER_INCH, aD as TWIPS_PER_INCH, aE as resolveEffectiveParagraphStyle, aF as resolveEffectiveTextStyleForParagraph, aG as EMU_PER_PX, aH as EMU_PER_PT, aI as getRunFootnoteReference, aJ as getRunEndnoteReference, aK as iterateFootnoteReferenceRuns, aL as iterateEndnoteReferenceRuns, aM as imageContentTypeDefaults, aN as getRunFieldChar, aO as getRunFieldInstruction, aP as createEditorRun, aQ as JSZip, aR as imageExtensionFromMime, aS as pxToPt$1, aT as resolveFloatingObjectRect, aU as getTextBoxFloatingGeometry, aV as getPresetPathSegments, aW as buildListLabels, aX as getImageFloatingGeometry, aY as textStyleToFontSizePt, aZ as PX_PER_POINT, a_ as resolveOpenTypeFeatureTags, a$ as DEFAULT_FONT_SIZE_PX, b0 as isDoubleUnderlineStyle, b1 as isWavyUnderlineStyle, b2 as underlineStyleLineWidthPx, b3 as underlineStyleDashArray, b4 as resolveListLabel, b5 as getListLabelInset, b6 as getAlignedListLabelInset, b7 as getParagraphBorderInsets, b8 as buildSegmentTable, b9 as buildCanvasTableLayout, ba as resolveCanvasTableWidth, bb as resolveFloatingTableRect, bc as normalizeFamily, bd as ROBOTO_FONT_FILES, be as loadFontAsset, bf as OFFICE_COMPAT_FONT_FAMILIES, bg as BinaryReader, bh as buildSfnt, bi as defaultFontDecoderRegistry, bj as SfntFontProgram, bk as collectPdfFontFamilies, bl as getPageHeaderZoneTop, bm as getPageColumnRects, bn as findFootnoteReference, bo as FOOTNOTE_MARKER_GUTTER_PX, bp as resolveImporterForFile, bq as getDocumentSectionsCanonical, br as getDocumentParagraphsCanonical, bs as getDocumentParagraphs, bt as getDocumentPageSettings, bu as getTableCellContentWidthForParagraph, bv as layoutMetricsEpoch, bw as bumpLayoutMetricsEpoch, bx as createCanvasLayoutSnapshotProvider, by as on, bz as debounce, bA as unwrap, bB as perfTimer, bC as getRunTextBox, bD as createEditorDocument, bE as resolveResizedDimensions, bF as resolveTextBoxRenderHeight, bG as getToolbarStyleState, bH as getCachedCanvasImage, bI as measureParagraphMinContentWidthPx, bJ as getEditableBlocksForZone, bK as findParagraphLocation, bL as createSectionBoundaryParagraph, bM as normalizePageSettings, bN as DEFAULT_EDITOR_PAGE_SETTINGS, bO as markStart, bP as markEnd, bQ as getParagraphEntries, bR as getParagraphById, bS as createEditorFootnote, bT as createFootnoteReferenceRun, bU as renumberFootnotes, bV as getHeadingLevel, bW as preciseFontModeVersion, bX as isPreciseFontModeEnabled, bY as resolveNamedTextStyle, bZ as togglePreciseFontMode, b_ as nextFontSizePt, b$ as previousFontSizePt, c0 as fontSizePtToPx, c1 as createDefaultToolbarPreset, c2 as MenuRegistry, c3 as createToolbarRegistry, c4 as Editor, c5 as resolveCommandRef, c6 as commandRefName, c7 as createOasisEditorClient, c8 as createEditorZoom, c9 as startLongTaskObserver, ca as installGlobalReport, cb as applyStoredPreciseFontPreference, cc as getWelcomeSeen, cd as isLocalFontAccessSupported, ce as EDITOR_SCROLL_PADDING_PX, cf as Toolbar, cg as OasisEditorLoading, ch as I18nProvider, ci as createTranslator, cj as createEditorLogger, ck as registerDomStatsSurface } from "./index-4uLtMJwI.js";
4
+ import { d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageContentWidth, b as getPageBodyTop, c as getPageBodyBottom, l as listReferencedEndnotes, f as getFootnoteDisplayMarker, s as setActiveHyphenation, h as getDocumentSections, i as buildFootnoteReservations, M as MAX_FOOTNOTE_LAYOUT_ITERATIONS, r as reservationSignature, j as applyFootnotesToPages, k as getRunField, m as projectBlocksLayout, v as visitRun, n as assertNever, o as createSignal, q as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getParagraphText, C as getActiveZone, D as getActiveSectionIndex, E as getParagraphs, F as normalizeSelection, G as positionToParagraphOffset, H as paragraphOffsetToPosition, I as clampPosition, J as findParagraphIndex, K as createCollapsedSelection, L as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as getBlockParagraphs, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as underlineStyleToCssDecorationStyle, Z as resolveImageSrc, _ as listKindForTag, $ as isParagraphTag, a0 as collectInlineRuns, a1 as parseParagraphStyle, a2 as getRunImage, a3 as InlineShell, a4 as BalloonShell, a5 as DocumentShell, a6 as createMemo, a7 as getCaretRectFromSnapshot, a8 as getParagraphRectFromSnapshot, a9 as createComponent, aa as CaretOverlay, ab as Show, ac as createRenderEffect, ad as style, ae as setAttribute, af as setStyleProperty, ag as memo, ah as template, ai as useI18n, aj as createEffect, ak as insert, al as use, am as addEventListener, an as Dialog, ao as delegateEvents, ap as className, aq as For, ar as UNDERLINE_STYLE_OPTIONS, as as Tabs, at as onMount, au as onCleanup, av as PluginUiHost, aw as OasisEditorEditor, ax as OasisBrandMark, ay as setPreciseFontPreference, az as setWelcomeSeen, aA as enablePreciseFontMode, aB as TWIPS_PER_POINT, aC as PX_PER_INCH, aD as TWIPS_PER_INCH, aE as resolveEffectiveParagraphStyle, aF as resolveEffectiveTextStyleForParagraph, aG as EMU_PER_PT, aH as EMU_PER_PX, aI as getRunFootnoteReference, aJ as getRunEndnoteReference, aK as iterateFootnoteReferenceRuns, aL as iterateEndnoteReferenceRuns, aM as imageContentTypeDefaults, aN as getRunFieldChar, aO as getRunFieldInstruction, aP as createEditorRun, aQ as JSZip, aR as imageExtensionFromMime, aS as pxToPt$1, aT as resolveFloatingObjectRect, aU as getTextBoxFloatingGeometry, aV as getPresetPathSegments, aW as buildListLabels, aX as getImageFloatingGeometry, aY as textStyleToFontSizePt, aZ as PX_PER_POINT, a_ as DEFAULT_FONT_SIZE_PX, a$ as resolveOpenTypeFeatureTags, b0 as isDoubleUnderlineStyle, b1 as isWavyUnderlineStyle, b2 as underlineStyleLineWidthPx, b3 as underlineStyleDashArray, b4 as resolveListLabel, b5 as getListLabelInset, b6 as getAlignedListLabelInset, b7 as getParagraphBorderInsets, b8 as buildSegmentTable, b9 as buildCanvasTableLayout, ba as resolveCanvasTableWidth, bb as resolveFloatingTableRect, bc as normalizeFamily, bd as ROBOTO_FONT_FILES, be as loadFontAsset, bf as OFFICE_COMPAT_FONT_FAMILIES, bg as BinaryReader, bh as buildSfnt, bi as defaultFontDecoderRegistry, bj as SfntFontProgram, bk as collectPdfFontFamilies, bl as outlineFrom, bm as getPageHeaderZoneTop, bn as getPageColumnRects, bo as findFootnoteReference, bp as FOOTNOTE_MARKER_GUTTER_PX, bq as resolveImporterForFile, br as getDocumentSectionsCanonical, bs as getDocumentParagraphsCanonical, bt as getDocumentParagraphs, bu as getDocumentPageSettings, bv as getTableCellContentWidthForParagraph, bw as layoutMetricsEpoch, bx as bumpLayoutMetricsEpoch, by as createCanvasLayoutSnapshotProvider, bz as on, bA as debounce, bB as unwrap, bC as perfTimer, bD as getRunTextBox, bE as createEditorDocument, bF as resolveResizedDimensions, bG as resolveTextBoxRenderHeight, bH as getToolbarStyleState, bI as getCachedCanvasImage, bJ as measureParagraphMinContentWidthPx, bK as getEditableBlocksForZone, bL as findParagraphLocation, bM as createSectionBoundaryParagraph, bN as normalizePageSettings, bO as DEFAULT_EDITOR_PAGE_SETTINGS, bP as markStart, bQ as markEnd, bR as getParagraphEntries, bS as getParagraphById, bT as createEditorFootnote, bU as createFootnoteReferenceRun, bV as renumberFootnotes, bW as getHeadingLevel, bX as preciseFontModeVersion, bY as isPreciseFontModeEnabled, bZ as resolveNamedTextStyle, b_ as togglePreciseFontMode, b$ as nextFontSizePt, c0 as previousFontSizePt, c1 as fontSizePtToPx, c2 as createDefaultToolbarPreset, c3 as MenuRegistry, c4 as createToolbarRegistry, c5 as Editor, c6 as resolveCommandRef, c7 as commandRefName, c8 as createOasisEditorClient, c9 as createEditorZoom, ca as startLongTaskObserver, cb as installGlobalReport, cc as applyStoredPreciseFontPreference, cd as getWelcomeSeen, ce as isLocalFontAccessSupported, cf as EDITOR_SCROLL_PADDING_PX, cg as Toolbar, ch as OasisEditorLoading, ci as I18nProvider, cj as createTranslator, ck as createEditorLogger, cl as registerDomStatsSurface } from "./index-9yDGAODt.js";
5
5
  function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
6
6
  const {
7
7
  pageIndex,
@@ -13,7 +13,7 @@ function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
13
13
  defaultTabStop
14
14
  } = context;
15
15
  return blocks.map((block, index) => {
16
- var _a, _b;
16
+ var _a2, _b2;
17
17
  if (block.type === "paragraph") {
18
18
  const layout = deps.projectParagraphLayout(
19
19
  block,
@@ -47,8 +47,8 @@ function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
47
47
  sourceBlockId: block.id,
48
48
  blockType: block.type,
49
49
  globalIndex: index,
50
- estimatedHeight: ((_a = block.style) == null ? void 0 : _a.floating) ? 0 : tableHeight,
51
- floatingTableHeight: ((_b = block.style) == null ? void 0 : _b.floating) ? tableHeight : void 0,
50
+ estimatedHeight: ((_a2 = block.style) == null ? void 0 : _a2.floating) ? 0 : tableHeight,
51
+ floatingTableHeight: ((_b2 = block.style) == null ? void 0 : _b2.floating) ? tableHeight : void 0,
52
52
  sourceBlock: block
53
53
  };
54
54
  });
@@ -326,13 +326,13 @@ function spacerParagraph() {
326
326
  };
327
327
  }
328
328
  function buildEndnoteFlowBlocks(document2) {
329
- var _a, _b, _c;
329
+ var _a2, _b2, _c;
330
330
  const referenced = listReferencedEndnotes(document2);
331
- const items = (_a = document2.endnotes) == null ? void 0 : _a.items;
331
+ const items = (_a2 = document2.endnotes) == null ? void 0 : _a2.items;
332
332
  if (!items || referenced.length === 0) {
333
333
  return [];
334
334
  }
335
- const format = ((_c = (_b = document2.endnotes) == null ? void 0 : _b.settings) == null ? void 0 : _c.numberFormat) ?? "decimal";
335
+ const format = ((_c = (_b2 = document2.endnotes) == null ? void 0 : _b2.settings) == null ? void 0 : _c.numberFormat) ?? "decimal";
336
336
  const out = [spacerParagraph()];
337
337
  for (const ref of referenced) {
338
338
  const endnote = items[ref.endnoteId];
@@ -374,8 +374,8 @@ function injectEndnotesIntoDocument(document2) {
374
374
  function blockContainsNumPagesField(block) {
375
375
  if (block.type === "paragraph") {
376
376
  return block.runs.some((run) => {
377
- var _a;
378
- return ((_a = getRunField(run)) == null ? void 0 : _a.type) === "NUMPAGES";
377
+ var _a2;
378
+ return ((_a2 = getRunField(run)) == null ? void 0 : _a2.type) === "NUMPAGES";
379
379
  });
380
380
  }
381
381
  return block.rows.some(
@@ -396,10 +396,10 @@ function documentContainsNumPagesField(document2) {
396
396
  );
397
397
  }
398
398
  function projectDocumentLayout(document2, maxPageHeightOverride, measuredHeights, measuredParagraphLayouts, options = {}) {
399
- var _a, _b;
399
+ var _a2, _b2;
400
400
  const measurer = options.measurer ?? domTextMeasurer;
401
401
  setActiveHyphenation(
402
- ((_a = document2.settings) == null ? void 0 : _a.autoHyphenation) ? {
402
+ ((_a2 = document2.settings) == null ? void 0 : _a2.autoHyphenation) ? {
403
403
  enabled: true,
404
404
  zone: document2.settings.hyphenationZone,
405
405
  consecutiveLimit: document2.settings.consecutiveHyphenLimit,
@@ -416,7 +416,7 @@ function projectDocumentLayout(document2, maxPageHeightOverride, measuredHeights
416
416
  measuredHeights,
417
417
  measuredParagraphLayouts,
418
418
  measurer,
419
- defaultTabStop: (_b = document2.settings) == null ? void 0 : _b.defaultTabStop,
419
+ defaultTabStop: (_b2 = document2.settings) == null ? void 0 : _b2.defaultTabStop,
420
420
  needsTotalPages,
421
421
  projectBlocks: projectBlocksLayout,
422
422
  projectHeaderFooterBlocks
@@ -696,12 +696,12 @@ function cloneBlock(block) {
696
696
  }
697
697
  }
698
698
  function cloneSection(section) {
699
- var _a, _b, _c, _d, _e, _f;
699
+ var _a2, _b2, _c, _d, _e, _f;
700
700
  return {
701
701
  ...section,
702
702
  blocks: section.blocks.map(cloneBlock),
703
- header: (_a = section.header) == null ? void 0 : _a.map(cloneBlock),
704
- firstPageHeader: (_b = section.firstPageHeader) == null ? void 0 : _b.map(cloneBlock),
703
+ header: (_a2 = section.header) == null ? void 0 : _a2.map(cloneBlock),
704
+ firstPageHeader: (_b2 = section.firstPageHeader) == null ? void 0 : _b2.map(cloneBlock),
705
705
  evenPageHeader: (_c = section.evenPageHeader) == null ? void 0 : _c.map(cloneBlock),
706
706
  footer: (_d = section.footer) == null ? void 0 : _d.map(cloneBlock),
707
707
  firstPageFooter: (_e = section.firstPageFooter) == null ? void 0 : _e.map(cloneBlock),
@@ -715,7 +715,7 @@ function cloneFootnote(footnote) {
715
715
  };
716
716
  }
717
717
  function cloneFootnotes(footnotes) {
718
- var _a, _b;
718
+ var _a2, _b2;
719
719
  if (!footnotes) return void 0;
720
720
  const nextItems = {};
721
721
  for (const [id, footnote] of Object.entries(footnotes.items)) {
@@ -724,8 +724,8 @@ function cloneFootnotes(footnotes) {
724
724
  return {
725
725
  items: nextItems,
726
726
  settings: footnotes.settings ? { ...footnotes.settings } : void 0,
727
- separator: (_a = footnotes.separator) == null ? void 0 : _a.map(cloneBlock),
728
- continuationSeparator: (_b = footnotes.continuationSeparator) == null ? void 0 : _b.map(cloneBlock)
727
+ separator: (_a2 = footnotes.separator) == null ? void 0 : _a2.map(cloneBlock),
728
+ continuationSeparator: (_b2 = footnotes.continuationSeparator) == null ? void 0 : _b2.map(cloneBlock)
729
729
  };
730
730
  }
731
731
  function cloneEndnote(endnote) {
@@ -735,7 +735,7 @@ function cloneEndnote(endnote) {
735
735
  };
736
736
  }
737
737
  function cloneEndnotes(endnotes) {
738
- var _a, _b;
738
+ var _a2, _b2;
739
739
  if (!endnotes) return void 0;
740
740
  const nextItems = {};
741
741
  for (const [id, endnote] of Object.entries(endnotes.items)) {
@@ -744,17 +744,17 @@ function cloneEndnotes(endnotes) {
744
744
  return {
745
745
  items: nextItems,
746
746
  settings: endnotes.settings ? { ...endnotes.settings } : void 0,
747
- separator: (_a = endnotes.separator) == null ? void 0 : _a.map(cloneBlock),
748
- continuationSeparator: (_b = endnotes.continuationSeparator) == null ? void 0 : _b.map(cloneBlock)
747
+ separator: (_a2 = endnotes.separator) == null ? void 0 : _a2.map(cloneBlock),
748
+ continuationSeparator: (_b2 = endnotes.continuationSeparator) == null ? void 0 : _b2.map(cloneBlock)
749
749
  };
750
750
  }
751
751
  function cloneEditorState(source) {
752
- var _a;
752
+ var _a2;
753
753
  return {
754
754
  ...source,
755
755
  document: {
756
756
  ...source.document,
757
- sections: (_a = source.document.sections) == null ? void 0 : _a.map(cloneSection),
757
+ sections: (_a2 = source.document.sections) == null ? void 0 : _a2.map(cloneSection),
758
758
  footnotes: cloneFootnotes(source.document.footnotes),
759
759
  endnotes: cloneEndnotes(source.document.endnotes)
760
760
  },
@@ -876,7 +876,7 @@ const getClassNames = (attrs) => {
876
876
  return "";
877
877
  };
878
878
  const replaceElement = (element, { nameAttr, icons: icons2, attrs }) => {
879
- var _a;
879
+ var _a2;
880
880
  const iconName = element.getAttribute(nameAttr);
881
881
  if (iconName == null) return;
882
882
  const ComponentName = toPascalCase(iconName);
@@ -909,7 +909,7 @@ const replaceElement = (element, { nameAttr, icons: icons2, attrs }) => {
909
909
  });
910
910
  }
911
911
  const svgElement = createElement(iconNode, iconAttrs);
912
- return (_a = element.parentNode) == null ? void 0 : _a.replaceChild(svgElement, element);
912
+ return (_a2 = element.parentNode) == null ? void 0 : _a2.replaceChild(svgElement, element);
913
913
  };
914
914
  /**
915
915
  * @license lucide v1.11.0 - ISC
@@ -26835,9 +26835,9 @@ function cloneLayoutSnapshot(snapshot) {
26835
26835
  };
26836
26836
  }
26837
26837
  function isCanvasDebugEnabled() {
26838
- var _a;
26838
+ var _a2;
26839
26839
  const viteEnv = __vite_import_meta_env__ ?? {};
26840
- const processEnv = ((_a = globalThis.process) == null ? void 0 : _a.env) ?? {};
26840
+ const processEnv = ((_a2 = globalThis.process) == null ? void 0 : _a2.env) ?? {};
26841
26841
  return viteEnv.DEV === true || viteEnv.MODE === "test" || processEnv.NODE_ENV === "test" || viteEnv.VITE_OASIS_CANVAS_DEBUG === "1";
26842
26842
  }
26843
26843
  function buildApi() {
@@ -27233,12 +27233,12 @@ function addFontFamily(target, seen, value) {
27233
27233
  target.push(family);
27234
27234
  }
27235
27235
  function computeFontFamilyOptions(document2, toolbarStyleState, localFontFamilies = []) {
27236
- var _a;
27236
+ var _a2;
27237
27237
  const seen = /* @__PURE__ */ new Set();
27238
27238
  const documentFonts = [];
27239
27239
  const fallbackFonts = [];
27240
27240
  for (const style2 of Object.values((document2 == null ? void 0 : document2.styles) ?? {})) {
27241
- addFontFamily(documentFonts, seen, (_a = style2.textStyle) == null ? void 0 : _a.fontFamily);
27241
+ addFontFamily(documentFonts, seen, (_a2 = style2.textStyle) == null ? void 0 : _a2.fontFamily);
27242
27242
  }
27243
27243
  addFontFamily(documentFonts, seen, toolbarStyleState.fontFamily);
27244
27244
  for (const family of localFontFamilies) {
@@ -27253,10 +27253,10 @@ function computeFontFamilyOptions(document2, toolbarStyleState, localFontFamilie
27253
27253
  ];
27254
27254
  }
27255
27255
  function computeFontSizeOptions(document2, toolbarStyleState) {
27256
- var _a;
27256
+ var _a2;
27257
27257
  const values = new Set(STANDARD_FONT_SIZES_PT);
27258
27258
  for (const style2 of Object.values((document2 == null ? void 0 : document2.styles) ?? {})) {
27259
- const fontSize = (_a = style2.textStyle) == null ? void 0 : _a.fontSize;
27259
+ const fontSize = (_a2 = style2.textStyle) == null ? void 0 : _a2.fontSize;
27260
27260
  if (typeof fontSize === "number" && Number.isFinite(fontSize)) {
27261
27261
  values.add(fontSizePxToPt(fontSize));
27262
27262
  }
@@ -27376,7 +27376,7 @@ function clearParagraphList(paragraph) {
27376
27376
  return nextParagraph;
27377
27377
  }
27378
27378
  function getStyleAtOffset(paragraph, offset) {
27379
- var _a;
27379
+ var _a2;
27380
27380
  if (paragraph.runs.length === 0) {
27381
27381
  return void 0;
27382
27382
  }
@@ -27396,7 +27396,7 @@ function getStyleAtOffset(paragraph, offset) {
27396
27396
  }
27397
27397
  consumed = nextConsumed;
27398
27398
  }
27399
- return cloneStyle((_a = paragraph.runs[paragraph.runs.length - 1]) == null ? void 0 : _a.styles);
27399
+ return cloneStyle((_a2 = paragraph.runs[paragraph.runs.length - 1]) == null ? void 0 : _a2.styles);
27400
27400
  }
27401
27401
  function getRunAtOffset(paragraph, offset) {
27402
27402
  let consumed = 0;
@@ -27426,9 +27426,9 @@ function getRunAtOffset(paragraph, offset) {
27426
27426
  return null;
27427
27427
  }
27428
27428
  function expandLinkRangeInParagraph(paragraph, offset) {
27429
- var _a, _b, _c;
27429
+ var _a2, _b2, _c;
27430
27430
  const resolved = getRunAtOffset(paragraph, offset);
27431
- const href = (_a = resolved == null ? void 0 : resolved.run.styles) == null ? void 0 : _a.link;
27431
+ const href = (_a2 = resolved == null ? void 0 : resolved.run.styles) == null ? void 0 : _a2.link;
27432
27432
  if (!resolved || !href || resolved.run.kind === "image") {
27433
27433
  return null;
27434
27434
  }
@@ -27447,7 +27447,7 @@ function expandLinkRangeInParagraph(paragraph, offset) {
27447
27447
  endOffset = consumed + resolved.run.text.length;
27448
27448
  for (let index = runIndex - 1; index >= 0; index -= 1) {
27449
27449
  const run = runs[index];
27450
- if (run.kind === "image" || ((_b = run.styles) == null ? void 0 : _b.link) !== href) {
27450
+ if (run.kind === "image" || ((_b2 = run.styles) == null ? void 0 : _b2.link) !== href) {
27451
27451
  break;
27452
27452
  }
27453
27453
  startOffset -= run.text.length;
@@ -27801,8 +27801,8 @@ function deleteSelectionRange(state) {
27801
27801
  const startOffset2 = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
27802
27802
  const endOffset2 = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
27803
27803
  return mapRunsInRange(paragraph, startOffset2, endOffset2, (run) => {
27804
- var _a;
27805
- if (((_a = run.revision) == null ? void 0 : _a.type) === "insert") {
27804
+ var _a2;
27805
+ if (((_a2 = run.revision) == null ? void 0 : _a2.type) === "insert") {
27806
27806
  return { ...run, text: "" };
27807
27807
  }
27808
27808
  return {
@@ -28122,7 +28122,7 @@ function insertPlainTextAtSelection(state, text, styleOverride) {
28122
28122
  );
28123
28123
  }
28124
28124
  function deleteBackward(state) {
28125
- var _a;
28125
+ var _a2;
28126
28126
  if (!isSelectionCollapsed(state.selection)) {
28127
28127
  return deleteSelectionRange(state);
28128
28128
  }
@@ -28145,7 +28145,7 @@ function deleteBackward(state) {
28145
28145
  }
28146
28146
  if (targetRunIndex !== -1) {
28147
28147
  const targetRun = runs[targetRunIndex];
28148
- if (((_a = targetRun.revision) == null ? void 0 : _a.type) === "insert") {
28148
+ if (((_a2 = targetRun.revision) == null ? void 0 : _a2.type) === "insert") {
28149
28149
  const nextRuns2 = [
28150
28150
  ...sliceRuns(paragraph, 0, offset - 1),
28151
28151
  ...sliceRuns(paragraph, offset, getParagraphLength(paragraph))
@@ -28231,7 +28231,7 @@ function deleteBackward(state) {
28231
28231
  );
28232
28232
  }
28233
28233
  function deleteForward(state) {
28234
- var _a;
28234
+ var _a2;
28235
28235
  if (!isSelectionCollapsed(state.selection)) {
28236
28236
  return deleteSelectionRange(state);
28237
28237
  }
@@ -28254,7 +28254,7 @@ function deleteForward(state) {
28254
28254
  }
28255
28255
  if (targetRunIndex !== -1) {
28256
28256
  const targetRun = runs[targetRunIndex];
28257
- if (((_a = targetRun.revision) == null ? void 0 : _a.type) === "insert") {
28257
+ if (((_a2 = targetRun.revision) == null ? void 0 : _a2.type) === "insert") {
28258
28258
  const nextRuns2 = [
28259
28259
  ...sliceRuns(paragraph, 0, offset),
28260
28260
  ...sliceRuns(paragraph, offset + 1, getParagraphLength(paragraph))
@@ -28354,8 +28354,8 @@ function toggleTextStyle(state, key) {
28354
28354
  return state;
28355
28355
  }
28356
28356
  const shouldEnable = !touchedRuns.every((run) => {
28357
- var _a;
28358
- return Boolean((_a = run.styles) == null ? void 0 : _a[key]);
28357
+ var _a2;
28358
+ return Boolean((_a2 = run.styles) == null ? void 0 : _a2[key]);
28359
28359
  });
28360
28360
  const nextParagraphs = paragraphs.map((paragraph, paragraphIndex) => {
28361
28361
  if (paragraphIndex < normalized.startIndex || paragraphIndex > normalized.endIndex) {
@@ -28387,8 +28387,8 @@ function clearSelectedTextFormatting(state) {
28387
28387
  const startOffset = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
28388
28388
  const endOffset = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
28389
28389
  return mapRunsInRange(paragraph, startOffset, endOffset, (run) => {
28390
- var _a;
28391
- const link = (_a = run.styles) == null ? void 0 : _a.link;
28390
+ var _a2;
28391
+ const link = (_a2 = run.styles) == null ? void 0 : _a2.link;
28392
28392
  const styles = link != null && link !== "" ? { link } : {};
28393
28393
  return { ...run, styles };
28394
28394
  });
@@ -28691,7 +28691,7 @@ function createFontDialogBridge(deps) {
28691
28691
  };
28692
28692
  }
28693
28693
  function moveBlockToPosition(state, blockId, targetPosition) {
28694
- var _a;
28694
+ var _a2;
28695
28695
  let movedBlock;
28696
28696
  const removeFromBlocks = (blocks) => {
28697
28697
  const idx = blocks.findIndex((b) => b.id === blockId);
@@ -28741,7 +28741,7 @@ function moveBlockToPosition(state, blockId, targetPosition) {
28741
28741
  };
28742
28742
  const activeIdx = getActiveSectionIndex(state);
28743
28743
  const zone = getActiveZone(state);
28744
- const activeSection = (_a = nextDocument.sections) == null ? void 0 : _a[activeIdx];
28744
+ const activeSection = (_a2 = nextDocument.sections) == null ? void 0 : _a2[activeIdx];
28745
28745
  const section = { ...activeSection };
28746
28746
  let found = false;
28747
28747
  if (zone === "header") {
@@ -28914,7 +28914,7 @@ function insertSectionBreakAtSelection(state, breakType) {
28914
28914
  };
28915
28915
  }
28916
28916
  function updateSectionSettings(state, sectionIndex, settings) {
28917
- var _a;
28917
+ var _a2;
28918
28918
  const sections = getDocumentSections(state.document);
28919
28919
  if (sectionIndex < 0 || sectionIndex >= sections.length) {
28920
28920
  return state;
@@ -28928,7 +28928,7 @@ function updateSectionSettings(state, sectionIndex, settings) {
28928
28928
  ...settings.pageSettings ?? {},
28929
28929
  margins: {
28930
28930
  ...nextSections[sectionIndex].pageSettings.margins,
28931
- ...((_a = settings.pageSettings) == null ? void 0 : _a.margins) ?? {}
28931
+ ...((_a2 = settings.pageSettings) == null ? void 0 : _a2.margins) ?? {}
28932
28932
  }
28933
28933
  }
28934
28934
  };
@@ -29480,7 +29480,7 @@ function parseWidthToPt(value) {
29480
29480
  }
29481
29481
  function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableIndentLeft) {
29482
29482
  const updateTable = (table) => {
29483
- var _a;
29483
+ var _a2;
29484
29484
  if (table.id !== tableId) return table;
29485
29485
  const tableLayout = buildTableCellLayout(table);
29486
29486
  const visualColumnCount = Math.max(
@@ -29499,7 +29499,7 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
29499
29499
  hasGridOverride = true;
29500
29500
  continue;
29501
29501
  }
29502
- const existing = (_a = table.gridCols) == null ? void 0 : _a[columnIndex];
29502
+ const existing = (_a2 = table.gridCols) == null ? void 0 : _a2[columnIndex];
29503
29503
  if (typeof existing === "number" && Number.isFinite(existing) && existing > 0) {
29504
29504
  nextGridCols[columnIndex] = existing;
29505
29505
  continue;
@@ -29509,7 +29509,7 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
29509
29509
  }
29510
29510
  const nextRows = table.rows.map((row, rowIndex) => {
29511
29511
  const nextCells = row.cells.map((cell, cellIndex) => {
29512
- var _a2, _b;
29512
+ var _a3, _b2;
29513
29513
  const entry = tableLayout.find(
29514
29514
  (item) => item.rowIndex === rowIndex && item.cellIndex === cellIndex
29515
29515
  );
@@ -29517,11 +29517,11 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
29517
29517
  const rightVisualColumnIndex = entry.visualColumnIndex + entry.colSpan - 1;
29518
29518
  const newWidth = columnWidths[rightVisualColumnIndex];
29519
29519
  if (newWidth !== void 0 && entry.colSpan === 1) {
29520
- const propertyRevision = state.trackChangesEnabled && !((_a2 = cell.style) == null ? void 0 : _a2.propertyRevision) ? {
29520
+ const propertyRevision = state.trackChangesEnabled && !((_a3 = cell.style) == null ? void 0 : _a3.propertyRevision) ? {
29521
29521
  ...createTableRevisionMetadata(),
29522
29522
  type: "property",
29523
29523
  previous: { ...cell.style ?? {} }
29524
- } : (_b = cell.style) == null ? void 0 : _b.propertyRevision;
29524
+ } : (_b2 = cell.style) == null ? void 0 : _b2.propertyRevision;
29525
29525
  return {
29526
29526
  ...cell,
29527
29527
  style: {
@@ -29745,17 +29745,17 @@ function isVisibleBorder(border) {
29745
29745
  return !!border && border.type !== "none" && border.width > 0;
29746
29746
  }
29747
29747
  function buildFloatingSummary(table) {
29748
- var _a;
29749
- const floating = (_a = table.style) == null ? void 0 : _a.floating;
29748
+ var _a2;
29749
+ const floating = (_a2 = table.style) == null ? void 0 : _a2.floating;
29750
29750
  if (!floating || Object.keys(floating).length === 0) return "";
29751
29751
  return Object.entries(floating).map(([key, value]) => `${key}=${value}`).join(", ");
29752
29752
  }
29753
29753
  function buildInitialValues(ctx, activeTab = "table") {
29754
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
29755
- const tableWidth = serializeWidth((_a = ctx.table.style) == null ? void 0 : _a.width);
29754
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
29755
+ const tableWidth = serializeWidth((_a2 = ctx.table.style) == null ? void 0 : _a2.width);
29756
29756
  const row = ctx.table.rows[ctx.rowIndex];
29757
29757
  const cell = row == null ? void 0 : row.cells[ctx.cellIndex];
29758
- const rowHeight = serializeWidth((_b = row == null ? void 0 : row.style) == null ? void 0 : _b.height);
29758
+ const rowHeight = serializeWidth((_b2 = row == null ? void 0 : row.style) == null ? void 0 : _b2.height);
29759
29759
  const cellWidth = serializeWidth((_c = cell == null ? void 0 : cell.style) == null ? void 0 : _c.width);
29760
29760
  const gridWidth = (_d = ctx.table.gridCols) == null ? void 0 : _d[ctx.visualColumnIndex];
29761
29761
  const columnWidth = serializeWidth(gridWidth);
@@ -30183,14 +30183,14 @@ function textLanguageToHtmlAttributes(language) {
30183
30183
  return attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
30184
30184
  }
30185
30185
  function serializeImageRunToHtml(run, document2) {
30186
- var _a;
30186
+ var _a2;
30187
30187
  if (run.kind !== "image") {
30188
30188
  return "";
30189
30189
  }
30190
30190
  const resolvedSrc = resolveImageSrc(document2, run.image.src);
30191
30191
  const altAttr = run.image.alt !== void 0 ? ` alt="${escapeHtml(run.image.alt)}"` : "";
30192
30192
  const img = `<img src="${escapeHtml(resolvedSrc)}" width="${Math.max(1, Math.round(run.image.width))}" height="${Math.max(1, Math.round(run.image.height))}"${altAttr}>`;
30193
- if ((_a = run.styles) == null ? void 0 : _a.link) {
30193
+ if ((_a2 = run.styles) == null ? void 0 : _a2.link) {
30194
30194
  return `<a href="${escapeHtml(run.styles.link)}">${img}</a>`;
30195
30195
  }
30196
30196
  return img;
@@ -30234,7 +30234,7 @@ function serializeParagraphRunsToHtml(runs, document2) {
30234
30234
  return runs.map((run) => serializeTextRunToHtml(run, document2)).join("") || "<br>";
30235
30235
  }
30236
30236
  function serializeEditorSelectionToHtml(state) {
30237
- var _a;
30237
+ var _a2;
30238
30238
  const normalized = normalizeSelection(state);
30239
30239
  if (normalized.isCollapsed) {
30240
30240
  return "";
@@ -30259,7 +30259,7 @@ function serializeEditorSelectionToHtml(state) {
30259
30259
  const css = paragraphStyleToCssText(paragraph.style);
30260
30260
  const attrs = css.length > 0 ? ` style="${css}"` : "";
30261
30261
  const paragraphHtml = serializeParagraphRunsToHtml(runs, state.document);
30262
- if ((_a = paragraph.list) == null ? void 0 : _a.kind) {
30262
+ if ((_a2 = paragraph.list) == null ? void 0 : _a2.kind) {
30263
30263
  const wrapperTag = paragraph.list.kind === "bullet" ? "ul" : "ol";
30264
30264
  if (activeListKind !== paragraph.list.kind) {
30265
30265
  closeList();
@@ -30622,13 +30622,13 @@ function parseEditorClipboardHtmlWithDom(html) {
30622
30622
  function createEditorContextMenuClipboard(deps) {
30623
30623
  const t = deps.t;
30624
30624
  const programmaticCopy = async () => {
30625
- var _a;
30625
+ var _a2;
30626
30626
  const state = deps.state();
30627
30627
  const text = getSelectedText(state);
30628
30628
  if (!text) return;
30629
30629
  const html = serializeEditorSelectionToHtml(state);
30630
30630
  try {
30631
- if (typeof ClipboardItem !== "undefined" && ((_a = navigator.clipboard) == null ? void 0 : _a.write)) {
30631
+ if (typeof ClipboardItem !== "undefined" && ((_a2 = navigator.clipboard) == null ? void 0 : _a2.write)) {
30632
30632
  await navigator.clipboard.write([
30633
30633
  new ClipboardItem({
30634
30634
  "text/plain": new Blob([text], { type: "text/plain" }),
@@ -30662,12 +30662,12 @@ function createEditorContextMenuClipboard(deps) {
30662
30662
  deps.focusInput();
30663
30663
  };
30664
30664
  const programmaticPaste = async () => {
30665
- var _a, _b;
30665
+ var _a2, _b2;
30666
30666
  if (deps.isReadOnly()) return;
30667
30667
  let html = "";
30668
30668
  let text = "";
30669
30669
  try {
30670
- if ((_a = navigator.clipboard) == null ? void 0 : _a.read) {
30670
+ if ((_a2 = navigator.clipboard) == null ? void 0 : _a2.read) {
30671
30671
  const items = await navigator.clipboard.read();
30672
30672
  for (const item of items) {
30673
30673
  if (item.types.includes("text/html")) {
@@ -30679,7 +30679,7 @@ function createEditorContextMenuClipboard(deps) {
30679
30679
  text = await blob.text();
30680
30680
  }
30681
30681
  }
30682
- } else if ((_b = navigator.clipboard) == null ? void 0 : _b.readText) {
30682
+ } else if ((_b2 = navigator.clipboard) == null ? void 0 : _b2.readText) {
30683
30683
  text = await navigator.clipboard.readText();
30684
30684
  }
30685
30685
  } catch (err) {
@@ -31020,19 +31020,19 @@ function createEditorUiOptions(ctx) {
31020
31020
  showToolbar: () => ui().showToolbar ?? true,
31021
31021
  showOutline: () => ui().showOutline ?? true,
31022
31022
  toolbarView: () => {
31023
- var _a;
31024
- return ((_a = ui().toolbar) == null ? void 0 : _a.view) ?? "ribbon";
31023
+ var _a2;
31024
+ return ((_a2 = ui().toolbar) == null ? void 0 : _a2.view) ?? "ribbon";
31025
31025
  },
31026
31026
  toolbarLayout: () => {
31027
- var _a;
31028
- return ((_a = ui().toolbar) == null ? void 0 : _a.layout) ?? "overflow";
31027
+ var _a2;
31028
+ return ((_a2 = ui().toolbar) == null ? void 0 : _a2.layout) ?? "overflow";
31029
31029
  },
31030
31030
  isReadOnly: () => documentOptions().readOnly ?? false,
31031
31031
  useComposedShell: () => ui().uiVariant === "docs" || (ui().shell ?? "document") !== "document",
31032
31032
  loadingOptions,
31033
31033
  loadingLabel: () => {
31034
- var _a;
31035
- return ((_a = loadingOptions()) == null ? void 0 : _a.label) ?? "Loading oasis-editor...";
31034
+ var _a2;
31035
+ return ((_a2 = loadingOptions()) == null ? void 0 : _a2.label) ?? "Loading oasis-editor...";
31036
31036
  },
31037
31037
  shellComponent: () => {
31038
31038
  const s = ui().shell ?? "document";
@@ -31062,7 +31062,7 @@ function computeShouldShowCaret(state, caretBox) {
31062
31062
  }
31063
31063
  function DropCaret(props) {
31064
31064
  const layout = createMemo(() => {
31065
- var _a, _b, _c;
31065
+ var _a2, _b2, _c;
31066
31066
  const pos = props.targetPos();
31067
31067
  const surfaceRef = props.surfaceRef;
31068
31068
  if (!surfaceRef) return null;
@@ -31070,7 +31070,7 @@ function DropCaret(props) {
31070
31070
  surface: surfaceRef,
31071
31071
  state: props.state,
31072
31072
  documentLayout: props.documentLayout(),
31073
- zoomFactor: (_a = props.zoomFactor) == null ? void 0 : _a.call(props)
31073
+ zoomFactor: (_a2 = props.zoomFactor) == null ? void 0 : _a2.call(props)
31074
31074
  });
31075
31075
  let viewportLeft = 0;
31076
31076
  let viewportTop = 0;
@@ -31095,7 +31095,7 @@ function DropCaret(props) {
31095
31095
  };
31096
31096
  }
31097
31097
  }
31098
- const caret = ((_b = props.caretViewport) == null ? void 0 : _b.call(props)) ?? null;
31098
+ const caret = ((_b2 = props.caretViewport) == null ? void 0 : _b2.call(props)) ?? null;
31099
31099
  if (caret) {
31100
31100
  viewportLeft = caret.left;
31101
31101
  viewportTop = caret.top;
@@ -33013,9 +33013,9 @@ function ContextMenu(props) {
33013
33013
  get children() {
33014
33014
  var _el$2 = _tmpl$4(), _el$4 = _el$2.firstChild;
33015
33015
  _el$2.$$click = () => {
33016
- var _a;
33016
+ var _a2;
33017
33017
  if (item.disabled) return;
33018
- (_a = item.onSelect) == null ? void 0 : _a.call(item);
33018
+ (_a2 = item.onSelect) == null ? void 0 : _a2.call(item);
33019
33019
  props.onClose();
33020
33020
  };
33021
33021
  insert(_el$2, createComponent(Show, {
@@ -33259,12 +33259,12 @@ function buildEditorViewProps(ctx) {
33259
33259
  };
33260
33260
  const fileHandlers = {
33261
33261
  onImportInputChange: (e) => {
33262
- var _a;
33263
- return files.handleImportFile(((_a = e.currentTarget.files) == null ? void 0 : _a[0]) ?? null);
33262
+ var _a2;
33263
+ return files.handleImportFile(((_a2 = e.currentTarget.files) == null ? void 0 : _a2[0]) ?? null);
33264
33264
  },
33265
33265
  onImageInputChange: (e) => {
33266
- var _a;
33267
- return files.handleInsertImage(((_a = e.currentTarget.files) == null ? void 0 : _a[0]) ?? null);
33266
+ var _a2;
33267
+ return files.handleInsertImage(((_a2 = e.currentTarget.files) == null ? void 0 : _a2[0]) ?? null);
33268
33268
  }
33269
33269
  };
33270
33270
  const surfaceHandlers = {
@@ -33790,10 +33790,10 @@ function serializeBorder(border) {
33790
33790
  return serializeDocxBorderAttrs(resolved, DEFAULT_TABLE_BORDER_COLOR);
33791
33791
  }
33792
33792
  function serializeTableCellBorders(cell) {
33793
- var _a, _b, _c, _d, _e, _f, _g, _h;
33793
+ var _a2, _b2, _c, _d, _e, _f, _g, _h;
33794
33794
  const borders = [
33795
- `<w:top ${serializeBorder((_a = cell.style) == null ? void 0 : _a.borderTop)}`,
33796
- `<w:left ${serializeBorder((_b = cell.style) == null ? void 0 : _b.borderLeft)}`,
33795
+ `<w:top ${serializeBorder((_a2 = cell.style) == null ? void 0 : _a2.borderTop)}`,
33796
+ `<w:left ${serializeBorder((_b2 = cell.style) == null ? void 0 : _b2.borderLeft)}`,
33797
33797
  `<w:bottom ${serializeBorder((_c = cell.style) == null ? void 0 : _c.borderBottom)}`,
33798
33798
  `<w:right ${serializeBorder((_d = cell.style) == null ? void 0 : _d.borderRight)}`
33799
33799
  ];
@@ -33851,12 +33851,12 @@ function serializeTableDefaultCellMargins(margins) {
33851
33851
  return parts.length > 0 ? `<w:tblCellMar>${parts.join("")}</w:tblCellMar>` : "";
33852
33852
  }
33853
33853
  function serializeTableCellProperties(cell, fallbackWidthPt) {
33854
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
33854
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
33855
33855
  const colSpan = Math.max(1, Math.floor(cell.colSpan ?? 1));
33856
33856
  const parts = [];
33857
33857
  const conditional = serializeConditionalFlags(cell.conditionalStyle);
33858
33858
  if (conditional) parts.push(conditional);
33859
- const widthXml = serializeCellWidth(((_a = cell.style) == null ? void 0 : _a.width) ?? fallbackWidthPt);
33859
+ const widthXml = serializeCellWidth(((_a2 = cell.style) == null ? void 0 : _a2.width) ?? fallbackWidthPt);
33860
33860
  if (widthXml) {
33861
33861
  parts.push(widthXml);
33862
33862
  }
@@ -33868,7 +33868,7 @@ function serializeTableCellProperties(cell, fallbackWidthPt) {
33868
33868
  } else if (cell.vMerge === "continue") {
33869
33869
  parts.push("<w:vMerge/>");
33870
33870
  }
33871
- if ((_b = cell.style) == null ? void 0 : _b.shading) {
33871
+ if ((_b2 = cell.style) == null ? void 0 : _b2.shading) {
33872
33872
  parts.push(
33873
33873
  `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(cell.style.shading, "FFFFFF")}"/>`
33874
33874
  );
@@ -33945,10 +33945,10 @@ function serializeTableRowHeightFromStyle(heightValue, heightRule) {
33945
33945
  return `<w:trHeight ${attrs.join(" ")}/>`;
33946
33946
  }
33947
33947
  function serializeTableRowHeight(row) {
33948
- var _a, _b;
33948
+ var _a2, _b2;
33949
33949
  return serializeTableRowHeightFromStyle(
33950
- (_a = row.style) == null ? void 0 : _a.height,
33951
- (_b = row.style) == null ? void 0 : _b.heightRule
33950
+ (_a2 = row.style) == null ? void 0 : _a2.height,
33951
+ (_b2 = row.style) == null ? void 0 : _b2.heightRule
33952
33952
  );
33953
33953
  }
33954
33954
  function serializeTableRowStyleXml(style2) {
@@ -33982,13 +33982,13 @@ function serializeTableRowStyleXml(style2) {
33982
33982
  return parts.length > 0 ? `<w:trPr>${parts.join("")}</w:trPr>` : "";
33983
33983
  }
33984
33984
  function serializeTableRowProperties(row) {
33985
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
33985
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
33986
33986
  const parts = [];
33987
33987
  const conditional = serializeConditionalFlags(row.conditionalStyle);
33988
33988
  if (conditional) parts.push(conditional);
33989
- const gridBefore = serializeGridSkip("gridBefore", (_a = row.style) == null ? void 0 : _a.gridBefore);
33989
+ const gridBefore = serializeGridSkip("gridBefore", (_a2 = row.style) == null ? void 0 : _a2.gridBefore);
33990
33990
  if (gridBefore) parts.push(gridBefore);
33991
- const gridAfter = serializeGridSkip("gridAfter", (_b = row.style) == null ? void 0 : _b.gridAfter);
33991
+ const gridAfter = serializeGridSkip("gridAfter", (_b2 = row.style) == null ? void 0 : _b2.gridAfter);
33992
33992
  if (gridAfter) parts.push(gridAfter);
33993
33993
  const widthBefore = serializeDocxWidthElement(
33994
33994
  "wBefore",
@@ -34061,12 +34061,12 @@ function serializeTableBorders(style2) {
34061
34061
  return xml ? `<w:tblBorders>${xml}</w:tblBorders>` : "";
34062
34062
  }
34063
34063
  function serializeTableProperties(table) {
34064
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
34064
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
34065
34065
  const parts = [];
34066
- if ((_a = table.style) == null ? void 0 : _a.styleId) {
34066
+ if ((_a2 = table.style) == null ? void 0 : _a2.styleId) {
34067
34067
  parts.push(`<w:tblStyle w:val="${escapeXml(table.style.styleId)}"/>`);
34068
34068
  }
34069
- if ((_b = table.style) == null ? void 0 : _b.tblLook) {
34069
+ if ((_b2 = table.style) == null ? void 0 : _b2.tblLook) {
34070
34070
  const l = table.style.tblLook;
34071
34071
  parts.push(
34072
34072
  `<w:tblLook w:firstRow="${l.firstRow ? "1" : "0"}" w:lastRow="${l.lastRow ? "1" : "0"}" w:firstColumn="${l.firstCol ? "1" : "0"}" w:lastColumn="${l.lastCol ? "1" : "0"}" w:noHBand="${l.noHBand ? "1" : "0"}" w:noVBand="${l.noVBand ? "1" : "0"}"/>`
@@ -34232,7 +34232,7 @@ function materializeParagraphStyle(paragraph, styles) {
34232
34232
  };
34233
34233
  }
34234
34234
  function materializeRunStyle(run, paragraphStyleId, styles) {
34235
- var _a;
34235
+ var _a2;
34236
34236
  const effective = resolveEffectiveTextStyleForParagraph(
34237
34237
  run.styles,
34238
34238
  paragraphStyleId,
@@ -34288,7 +34288,7 @@ function materializeRunStyle(run, paragraphStyleId, styles) {
34288
34288
  shading: effective.shading,
34289
34289
  language: effective.language
34290
34290
  };
34291
- if ((_a = run.styles) == null ? void 0 : _a.link) {
34291
+ if ((_a2 = run.styles) == null ? void 0 : _a2.link) {
34292
34292
  materialized.link = run.styles.link;
34293
34293
  }
34294
34294
  return materialized;
@@ -34371,11 +34371,11 @@ function serializeParagraphStyleXml(style2) {
34371
34371
  return parts.length > 0 ? `<w:pPr>${parts.join("")}</w:pPr>` : "";
34372
34372
  }
34373
34373
  function serializeParagraphProperties(paragraph, numberingInfo, styles, overrides) {
34374
- var _a, _b;
34374
+ var _a2, _b2;
34375
34375
  const parts = [];
34376
34376
  const style2 = materializeParagraphStyle(paragraph, styles);
34377
- const align = ((_a = paragraph.style) == null ? void 0 : _a.align) ?? (overrides == null ? void 0 : overrides.align) ?? style2.align;
34378
- if ((_b = paragraph.style) == null ? void 0 : _b.styleId) {
34377
+ const align = ((_a2 = paragraph.style) == null ? void 0 : _a2.align) ?? (overrides == null ? void 0 : overrides.align) ?? style2.align;
34378
+ if ((_b2 = paragraph.style) == null ? void 0 : _b2.styleId) {
34379
34379
  parts.push(`<w:pStyle w:val="${escapeXml(paragraph.style.styleId)}"/>`);
34380
34380
  }
34381
34381
  if (align) {
@@ -34471,6 +34471,28 @@ const DOCX_HIGHLIGHT_HEX_ALIASES = {
34471
34471
  };
34472
34472
  const OOXML_PERCENT_DENOMINATOR = 1e5;
34473
34473
  const OOXML_ROTATION_UNITS = 6e4;
34474
+ const HEX6_PATTERN = /^[0-9a-fA-F]{6}$/;
34475
+ function stripHashPrefix(color) {
34476
+ return color.trim().replace(/^#/, "");
34477
+ }
34478
+ function parseHexColorToRgb255(color) {
34479
+ if (!color) {
34480
+ return null;
34481
+ }
34482
+ const normalized = stripHashPrefix(color);
34483
+ if (!HEX6_PATTERN.test(normalized)) {
34484
+ return null;
34485
+ }
34486
+ return [
34487
+ Number.parseInt(normalized.slice(0, 2), 16),
34488
+ Number.parseInt(normalized.slice(2, 4), 16),
34489
+ Number.parseInt(normalized.slice(4, 6), 16)
34490
+ ];
34491
+ }
34492
+ function rgb255ToHex(r, g, b) {
34493
+ const toHex = (value) => Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, "0");
34494
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
34495
+ }
34474
34496
  const MC_NS = "http://schemas.openxmlformats.org/markup-compatibility/2006";
34475
34497
  function serializeW14SolidFillXml(color) {
34476
34498
  const hex = normalizeDocxColor(color);
@@ -34482,11 +34504,11 @@ function serializeW14FillXml(fill) {
34482
34504
  }
34483
34505
  const gsXml = fill.stops.map((s) => {
34484
34506
  const hex = normalizeDocxColor(s.color);
34485
- const pos = Math.round(s.position * 1e5);
34486
- const alphaXml = s.alpha !== void 0 ? `<w14:alpha w14:val="${Math.round(s.alpha * 1e5)}"/>` : "";
34507
+ const pos = Math.round(s.position * OOXML_PERCENT_DENOMINATOR);
34508
+ const alphaXml = s.alpha !== void 0 ? `<w14:alpha w14:val="${Math.round(s.alpha * OOXML_PERCENT_DENOMINATOR)}"/>` : "";
34487
34509
  return `<w14:gs w14:pos="${pos}"><w14:srgbClr w14:val="${hex}">${alphaXml}</w14:srgbClr></w14:gs>`;
34488
34510
  }).join("");
34489
- const angVal = Math.round((fill.angle ?? 0) * 6e4);
34511
+ const angVal = Math.round((fill.angle ?? 0) * OOXML_ROTATION_UNITS);
34490
34512
  return `<w14:gradFill><w14:gsLst>${gsXml}</w14:gsLst><w14:lin w14:ang="${angVal}" w14:scaled="0"/></w14:gradFill>`;
34491
34513
  }
34492
34514
  function serializeTextFillMC(fill, fallbackColor) {
@@ -34495,34 +34517,34 @@ function serializeTextFillMC(fill, fallbackColor) {
34495
34517
  return `<mc:AlternateContent xmlns:mc="${MC_NS}"><mc:Choice Requires="w14"><w14:textFill>${fillXml}</w14:textFill></mc:Choice><mc:Fallback><w:color w:val="${fbHex}"/></mc:Fallback></mc:AlternateContent>`;
34496
34518
  }
34497
34519
  function serializeTextOutlineMC(outline) {
34498
- const widthEmu = Math.round(Math.max(0, outline.widthPt) * 12700);
34520
+ const widthEmu = Math.round(Math.max(0, outline.widthPt) * EMU_PER_PT);
34499
34521
  const fillXml = outline.fill ? serializeW14FillXml(outline.fill) : outline.color ? serializeW14SolidFillXml(outline.color) : "";
34500
34522
  return `<mc:AlternateContent xmlns:mc="${MC_NS}"><mc:Choice Requires="w14"><w14:textOutline w14:w="${widthEmu}" w14:cap="flat" w14:cmpd="sng" w14:algn="ctr">` + fillXml + `</w14:textOutline></mc:Choice><mc:Fallback><w:outline/></mc:Fallback></mc:AlternateContent>`;
34501
34523
  }
34502
34524
  function serializeW14ColorEl(color, alpha) {
34503
34525
  const hex = normalizeDocxColor(color);
34504
- const alphaXml = alpha !== void 0 ? `<w14:alpha w14:val="${Math.round(alpha * 1e5)}"/>` : "";
34526
+ const alphaXml = alpha !== void 0 ? `<w14:alpha w14:val="${Math.round(alpha * OOXML_PERCENT_DENOMINATOR)}"/>` : "";
34505
34527
  return `<w14:srgbClr w14:val="${hex}">${alphaXml}</w14:srgbClr>`;
34506
34528
  }
34507
34529
  function serializeTextShadowMC(shadow) {
34508
- const blurEmu = Math.round(Math.max(0, shadow.blurPt) * 12700);
34509
- const distEmu = Math.round(Math.max(0, shadow.distPt) * 12700);
34510
- const dirVal = Math.round(shadow.dirDeg * 6e4);
34530
+ const blurEmu = Math.round(Math.max(0, shadow.blurPt) * EMU_PER_PT);
34531
+ const distEmu = Math.round(Math.max(0, shadow.distPt) * EMU_PER_PT);
34532
+ const dirVal = Math.round(shadow.dirDeg * OOXML_ROTATION_UNITS);
34511
34533
  const colorXml = serializeW14ColorEl(shadow.color, shadow.alpha);
34512
34534
  return `<mc:AlternateContent xmlns:mc="${MC_NS}"><mc:Choice Requires="w14"><w14:shadow w14:blurRad="${blurEmu}" w14:dist="${distEmu}" w14:dir="${dirVal}" w14:sx="100000" w14:sy="100000" w14:kx="0" w14:ky="0" w14:algn="ctr">` + colorXml + `</w14:shadow></mc:Choice><mc:Fallback><w:shadow/></mc:Fallback></mc:AlternateContent>`;
34513
34535
  }
34514
34536
  function serializeGlowMC(glow) {
34515
- const radEmu = Math.round(Math.max(0, glow.radiusPt) * 12700);
34537
+ const radEmu = Math.round(Math.max(0, glow.radiusPt) * EMU_PER_PT);
34516
34538
  const colorXml = serializeW14ColorEl(glow.color, glow.alpha);
34517
34539
  return `<mc:AlternateContent xmlns:mc="${MC_NS}"><mc:Choice Requires="w14"><w14:glow w14:rad="${radEmu}">${colorXml}</w14:glow></mc:Choice><mc:Fallback/></mc:AlternateContent>`;
34518
34540
  }
34519
34541
  function serializeReflectionMC(reflection) {
34520
- const blurEmu = Math.round(Math.max(0, reflection.blurPt) * 12700);
34521
- const stA = Math.round(reflection.startAlpha * 1e5);
34522
- const stPos = Math.round(reflection.startPos * 1e5);
34523
- const endA = Math.round(reflection.endAlpha * 1e5);
34524
- const endPos = Math.round(reflection.endPos * 1e5);
34525
- const distEmu = Math.round(Math.max(0, reflection.distPt) * 12700);
34542
+ const blurEmu = Math.round(Math.max(0, reflection.blurPt) * EMU_PER_PT);
34543
+ const stA = Math.round(reflection.startAlpha * OOXML_PERCENT_DENOMINATOR);
34544
+ const stPos = Math.round(reflection.startPos * OOXML_PERCENT_DENOMINATOR);
34545
+ const endA = Math.round(reflection.endAlpha * OOXML_PERCENT_DENOMINATOR);
34546
+ const endPos = Math.round(reflection.endPos * OOXML_PERCENT_DENOMINATOR);
34547
+ const distEmu = Math.round(Math.max(0, reflection.distPt) * EMU_PER_PT);
34526
34548
  return `<mc:AlternateContent xmlns:mc="${MC_NS}"><mc:Choice Requires="w14"><w14:reflection w14:blurRad="${blurEmu}" w14:stA="${stA}" w14:stPos="${stPos}" w14:endA="${endA}" w14:endPos="${endPos}" w14:dist="${distEmu}" w14:dir="5400000" w14:fadeDir="5400000" w14:sx="100000" w14:sy="-100000" w14:kx="0" w14:ky="0" w14:algn="bl"/></mc:Choice><mc:Fallback/></mc:AlternateContent>`;
34527
34549
  }
34528
34550
  function serialize3dBlobMC(blob) {
@@ -34576,17 +34598,7 @@ function stylisticSetToDocx(value) {
34576
34598
  }
34577
34599
  return (1 << value - 1).toString(16).toUpperCase().padStart(8, "0");
34578
34600
  }
34579
- function parseHexColor(color) {
34580
- const normalized = color.trim().replace(/^#/, "");
34581
- if (!/^[0-9a-fA-F]{6}$/.test(normalized)) {
34582
- return null;
34583
- }
34584
- return [
34585
- Number.parseInt(normalized.slice(0, 2), 16),
34586
- Number.parseInt(normalized.slice(2, 4), 16),
34587
- Number.parseInt(normalized.slice(4, 6), 16)
34588
- ];
34589
- }
34601
+ const parseHexColor = parseHexColorToRgb255;
34590
34602
  function normalizeHighlightForDocx(highlight) {
34591
34603
  if (highlight in DOCX_HIGHLIGHT_COLORS) {
34592
34604
  return highlight;
@@ -35110,7 +35122,7 @@ function serializeRun(run, context, paragraphStyleId, styles, serializeBlocksXml
35110
35122
  });
35111
35123
  }
35112
35124
  function serializeRunWithRelationships(run, context, paragraphStyleId, styles, serializeBlocksXml2) {
35113
- var _a;
35125
+ var _a2;
35114
35126
  const runXml = serializeRun(
35115
35127
  run,
35116
35128
  context,
@@ -35118,7 +35130,7 @@ function serializeRunWithRelationships(run, context, paragraphStyleId, styles, s
35118
35130
  styles,
35119
35131
  serializeBlocksXml2
35120
35132
  );
35121
- const href = (_a = run.styles) == null ? void 0 : _a.link;
35133
+ const href = (_a2 = run.styles) == null ? void 0 : _a2.link;
35122
35134
  if (!href) {
35123
35135
  return runXml;
35124
35136
  }
@@ -35197,18 +35209,18 @@ function serializeRunsWithBoundaries(runs, tokens, context, paragraphStyleId, st
35197
35209
  return out;
35198
35210
  }
35199
35211
  function serializeSingleBlockXml(block, context, styles) {
35200
- var _a;
35212
+ var _a2;
35201
35213
  switch (block.type) {
35202
35214
  case "paragraph":
35203
35215
  return serializeParagraphXml(block, context, styles);
35204
35216
  case "table": {
35205
- const pageBreakXml = ((_a = block.style) == null ? void 0 : _a.pageBreakBefore) ? '<w:p><w:r><w:br w:type="page"/></w:r></w:p>' : "";
35217
+ const pageBreakXml = ((_a2 = block.style) == null ? void 0 : _a2.pageBreakBefore) ? '<w:p><w:r><w:br w:type="page"/></w:r></w:p>' : "";
35206
35218
  return pageBreakXml + serializeTableXml(
35207
35219
  block,
35208
35220
  (paragraph, cell) => {
35209
- var _a2;
35221
+ var _a3;
35210
35222
  return serializeParagraphXml(paragraph, context, styles, {
35211
- align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
35223
+ align: (_a3 = cell.style) == null ? void 0 : _a3.horizontalAlign
35212
35224
  });
35213
35225
  }
35214
35226
  );
@@ -35218,12 +35230,12 @@ function serializeSingleBlockXml(block, context, styles) {
35218
35230
  }
35219
35231
  }
35220
35232
  function serializeBlocksXml(blocks, context, styles) {
35221
- var _a, _b, _c;
35233
+ var _a2, _b2, _c;
35222
35234
  let out = "";
35223
35235
  let i = 0;
35224
35236
  while (i < blocks.length) {
35225
35237
  const block = blocks[i];
35226
- const wrapper = (_a = block.sdtWrappers) == null ? void 0 : _a[0];
35238
+ const wrapper = (_a2 = block.sdtWrappers) == null ? void 0 : _a2[0];
35227
35239
  if (!wrapper) {
35228
35240
  out += serializeSingleBlockXml(block, context, styles);
35229
35241
  i += 1;
@@ -35231,7 +35243,7 @@ function serializeBlocksXml(blocks, context, styles) {
35231
35243
  }
35232
35244
  const group = [];
35233
35245
  let j = i;
35234
- while (j < blocks.length && ((_c = (_b = blocks[j].sdtWrappers) == null ? void 0 : _b[0]) == null ? void 0 : _c.groupId) === wrapper.groupId) {
35246
+ while (j < blocks.length && ((_c = (_b2 = blocks[j].sdtWrappers) == null ? void 0 : _b2[0]) == null ? void 0 : _c.groupId) === wrapper.groupId) {
35235
35247
  const rest = blocks[j].sdtWrappers.slice(1);
35236
35248
  group.push({
35237
35249
  ...blocks[j],
@@ -35246,11 +35258,11 @@ function serializeBlocksXml(blocks, context, styles) {
35246
35258
  return out;
35247
35259
  }
35248
35260
  function serializeParagraphXml(paragraph, context, styles, overrides) {
35249
- var _a, _b, _c;
35261
+ var _a2, _b2, _c;
35250
35262
  const runs = paragraph.runs.length > 0 ? paragraph.runs : [{ id: "", text: "", kind: "text" }];
35251
35263
  const dropCapFrame = paragraph.dropCap ? serializeDropCapFrameParagraph(paragraph.dropCap) : "";
35252
- const bookmarkEvents = (_a = context.bookmarkEventsByParagraph) == null ? void 0 : _a.get(paragraph.id);
35253
- const commentEvents = (_b = context.commentEventsByParagraph) == null ? void 0 : _b.get(paragraph.id);
35264
+ const bookmarkEvents = (_a2 = context.bookmarkEventsByParagraph) == null ? void 0 : _a2.get(paragraph.id);
35265
+ const commentEvents = (_b2 = context.commentEventsByParagraph) == null ? void 0 : _b2.get(paragraph.id);
35254
35266
  const boundaryTokens = [
35255
35267
  ...(bookmarkEvents ?? []).map((e) => ({
35256
35268
  offset: e.offset,
@@ -35271,11 +35283,11 @@ function serializeParagraphXml(paragraph, context, styles, overrides) {
35271
35283
  styles
35272
35284
  ) : runs.map(
35273
35285
  (run) => {
35274
- var _a2;
35286
+ var _a3;
35275
35287
  return serializeRunWithRelationships(
35276
35288
  run,
35277
35289
  context,
35278
- (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
35290
+ (_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
35279
35291
  styles,
35280
35292
  serializeBlocksXml
35281
35293
  );
@@ -35290,8 +35302,8 @@ function serializeParagraphXml(paragraph, context, styles, overrides) {
35290
35302
  }
35291
35303
  const FIRST_FOOTNOTE_DOCX_ID = 1;
35292
35304
  function collectReferencedFootnotesForExport(document2) {
35293
- var _a;
35294
- const items = (_a = document2.footnotes) == null ? void 0 : _a.items;
35305
+ var _a2;
35306
+ const items = (_a2 = document2.footnotes) == null ? void 0 : _a2.items;
35295
35307
  if (!items) return [];
35296
35308
  const seen = /* @__PURE__ */ new Map();
35297
35309
  let nextDocxId = FIRST_FOOTNOTE_DOCX_ID;
@@ -35339,11 +35351,11 @@ function createEmptyFootnoteBodyParagraph(withMarker = true) {
35339
35351
  };
35340
35352
  }
35341
35353
  function prependFootnoteRefMarker(paragraph) {
35342
- var _a;
35354
+ var _a2;
35343
35355
  return {
35344
35356
  ...paragraph,
35345
35357
  runs: [makeFootnoteRefMarkerRun(), ...paragraph.runs],
35346
- style: ((_a = paragraph.style) == null ? void 0 : _a.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "FootnoteText" }
35358
+ style: ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "FootnoteText" }
35347
35359
  };
35348
35360
  }
35349
35361
  function makeFootnoteRefMarkerRun() {
@@ -35372,9 +35384,9 @@ function buildFootnotesXml(document2, referenced, numberingContext, state, build
35372
35384
  return serializeTableXml(
35373
35385
  block,
35374
35386
  (paragraph, cell) => {
35375
- var _a;
35387
+ var _a2;
35376
35388
  return serializeParagraphXml(paragraph, partContext, styles, {
35377
- align: (_a = cell.style) == null ? void 0 : _a.horizontalAlign
35389
+ align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
35378
35390
  });
35379
35391
  }
35380
35392
  );
@@ -35386,8 +35398,8 @@ function buildFootnotesXml(document2, referenced, numberingContext, state, build
35386
35398
  }
35387
35399
  const FIRST_ENDNOTE_DOCX_ID = 1;
35388
35400
  function collectReferencedEndnotesForExport(document2) {
35389
- var _a;
35390
- const items = (_a = document2.endnotes) == null ? void 0 : _a.items;
35401
+ var _a2;
35402
+ const items = (_a2 = document2.endnotes) == null ? void 0 : _a2.items;
35391
35403
  if (!items) return [];
35392
35404
  const seen = /* @__PURE__ */ new Map();
35393
35405
  let nextDocxId = FIRST_ENDNOTE_DOCX_ID;
@@ -35435,11 +35447,11 @@ function createEmptyEndnoteBodyParagraph(withMarker = true) {
35435
35447
  };
35436
35448
  }
35437
35449
  function prependEndnoteRefMarker(paragraph) {
35438
- var _a;
35450
+ var _a2;
35439
35451
  return {
35440
35452
  ...paragraph,
35441
35453
  runs: [makeEndnoteRefMarkerRun(), ...paragraph.runs],
35442
- style: ((_a = paragraph.style) == null ? void 0 : _a.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "EndnoteText" }
35454
+ style: ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "EndnoteText" }
35443
35455
  };
35444
35456
  }
35445
35457
  function makeEndnoteRefMarkerRun() {
@@ -35467,9 +35479,9 @@ function buildEndnotesXml(_document, referenced, _numberingContext, _state, buil
35467
35479
  return serializeTableXml(
35468
35480
  block,
35469
35481
  (paragraph, cell) => {
35470
- var _a;
35482
+ var _a2;
35471
35483
  return serializeParagraphXml(paragraph, partContext, styles, {
35472
- align: (_a = cell.style) == null ? void 0 : _a.horizontalAlign
35484
+ align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
35473
35485
  });
35474
35486
  }
35475
35487
  );
@@ -35901,14 +35913,14 @@ function buildNumberingXml(definitions) {
35901
35913
  }
35902
35914
  const DOCUMENT_XMLNS = `xmlns:w="${WORD_NS$1}" xmlns:w14="${WORD14_NS}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:r="${OFFICE_REL_NS}"`;
35903
35915
  function serializeSectionPropertiesWithReferences(pageSettings, references) {
35904
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
35916
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
35905
35917
  const width = pxToTwips(pageSettings.width, 12240);
35906
35918
  const height = pxToTwips(pageSettings.height, 15840);
35907
35919
  const margins = pageSettings.margins;
35908
35920
  const orientationAttr = pageSettings.orientation === "landscape" ? ' w:orient="landscape"' : "";
35909
35921
  const referencesXml = [
35910
- ((_a = references == null ? void 0 : references.header) == null ? void 0 : _a.first) ? `<w:headerReference w:type="first" r:id="${references.header.first.relId}"/>` : "",
35911
- ((_b = references == null ? void 0 : references.header) == null ? void 0 : _b.even) ? `<w:headerReference w:type="even" r:id="${references.header.even.relId}"/>` : "",
35922
+ ((_a2 = references == null ? void 0 : references.header) == null ? void 0 : _a2.first) ? `<w:headerReference w:type="first" r:id="${references.header.first.relId}"/>` : "",
35923
+ ((_b2 = references == null ? void 0 : references.header) == null ? void 0 : _b2.even) ? `<w:headerReference w:type="even" r:id="${references.header.even.relId}"/>` : "",
35912
35924
  ((_c = references == null ? void 0 : references.header) == null ? void 0 : _c.default) ? `<w:headerReference w:type="default" r:id="${references.header.default.relId}"/>` : "",
35913
35925
  ((_d = references == null ? void 0 : references.footer) == null ? void 0 : _d.first) ? `<w:footerReference w:type="first" r:id="${references.footer.first.relId}"/>` : "",
35914
35926
  ((_e = references == null ? void 0 : references.footer) == null ? void 0 : _e.even) ? `<w:footerReference w:type="even" r:id="${references.footer.even.relId}"/>` : "",
@@ -35989,11 +36001,11 @@ function createImageCaptionParagraph(captionText, label, sequenceNumber) {
35989
36001
  return paragraph;
35990
36002
  }
35991
36003
  function isImageCaptionParagraph(paragraph) {
35992
- var _a, _b;
36004
+ var _a2, _b2;
35993
36005
  if (!paragraph) {
35994
36006
  return false;
35995
36007
  }
35996
- const styleId = (_b = (_a = paragraph.style) == null ? void 0 : _a.styleId) == null ? void 0 : _b.toLowerCase();
36008
+ const styleId = (_b2 = (_a2 = paragraph.style) == null ? void 0 : _a2.styleId) == null ? void 0 : _b2.toLowerCase();
35997
36009
  if (styleId !== "caption") {
35998
36010
  return false;
35999
36011
  }
@@ -36005,7 +36017,7 @@ function isImageCaptionParagraph(paragraph) {
36005
36017
  });
36006
36018
  }
36007
36019
  function getImageCaptionText(paragraph) {
36008
- var _a;
36020
+ var _a2;
36009
36021
  if (!isImageCaptionParagraph(paragraph)) {
36010
36022
  return "";
36011
36023
  }
@@ -36016,15 +36028,15 @@ function getImageCaptionText(paragraph) {
36016
36028
  value += run.text;
36017
36029
  continue;
36018
36030
  }
36019
- if (((_a = getRunFieldChar(run)) == null ? void 0 : _a.kind) === "end") {
36031
+ if (((_a2 = getRunFieldChar(run)) == null ? void 0 : _a2.kind) === "end") {
36020
36032
  afterField = true;
36021
36033
  }
36022
36034
  }
36023
36035
  return value.replace(/^[:\-\s]+/, "");
36024
36036
  }
36025
36037
  function updateImageCaptionParagraph(paragraph, captionText, label) {
36026
- var _a;
36027
- const currentNumber = ((_a = paragraph.runs.find((run) => /^\d+$/.test(run.text))) == null ? void 0 : _a.text) ?? "1";
36038
+ var _a2;
36039
+ const currentNumber = ((_a2 = paragraph.runs.find((run) => /^\d+$/.test(run.text))) == null ? void 0 : _a2.text) ?? "1";
36028
36040
  const next = createImageCaptionParagraph(
36029
36041
  captionText,
36030
36042
  label,
@@ -36123,9 +36135,9 @@ function buildPartContext(blocks, numberingContext, state, document2) {
36123
36135
  const hyperlinks = [];
36124
36136
  const hyperlinkMap = /* @__PURE__ */ new Map();
36125
36137
  visitBlocks(blocks, (paragraph) => {
36126
- var _a;
36138
+ var _a2;
36127
36139
  for (const run of paragraph.runs) {
36128
- const link = (_a = run.styles) == null ? void 0 : _a.link;
36140
+ const link = (_a2 = run.styles) == null ? void 0 : _a2.link;
36129
36141
  if (link && !link.startsWith("#") && !hyperlinkMap.has(link)) {
36130
36142
  const rId2 = `rIdLink${hyperlinks.length + 1}`;
36131
36143
  hyperlinkMap.set(link, rId2);
@@ -36196,7 +36208,7 @@ function buildPartContext(blocks, numberingContext, state, document2) {
36196
36208
  };
36197
36209
  }
36198
36210
  async function exportEditorDocumentToDocx(document2) {
36199
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
36211
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
36200
36212
  document2 = renumberImageCaptionsInDocument(document2);
36201
36213
  const zip = new JSZip();
36202
36214
  const numberingContext = buildNumberingContext(document2);
@@ -36233,7 +36245,7 @@ async function exportEditorDocumentToDocx(document2) {
36233
36245
  let nextFooterIndex = 1;
36234
36246
  sections.forEach((section, sectionIndex) => {
36235
36247
  const addPart = (kind, type, blocks) => {
36236
- var _a2;
36248
+ var _a3;
36237
36249
  if (!blocks || blocks.length === 0) {
36238
36250
  return;
36239
36251
  }
@@ -36260,7 +36272,7 @@ async function exportEditorDocumentToDocx(document2) {
36260
36272
  context
36261
36273
  });
36262
36274
  const referenceKey = kind === "header" ? "header" : "footer";
36263
- ((_a2 = sectionReferences[sectionIndex])[referenceKey] ?? (_a2[referenceKey] = {}))[type] = { relId };
36275
+ ((_a3 = sectionReferences[sectionIndex])[referenceKey] ?? (_a3[referenceKey] = {}))[type] = { relId };
36264
36276
  if (kind === "header") {
36265
36277
  nextHeaderIndex += 1;
36266
36278
  } else {
@@ -36277,11 +36289,11 @@ async function exportEditorDocumentToDocx(document2) {
36277
36289
  const hasNumbering = numberingContext.definitions.length > 0;
36278
36290
  const hasEvenAndOddHeaders = sections.some(
36279
36291
  (section) => {
36280
- var _a2, _b2;
36281
- return (((_a2 = section.evenPageHeader) == null ? void 0 : _a2.length) ?? 0) > 0 || (((_b2 = section.evenPageFooter) == null ? void 0 : _b2.length) ?? 0) > 0;
36292
+ var _a3, _b3;
36293
+ return (((_a3 = section.evenPageHeader) == null ? void 0 : _a3.length) ?? 0) > 0 || (((_b3 = section.evenPageFooter) == null ? void 0 : _b3.length) ?? 0) > 0;
36282
36294
  }
36283
36295
  );
36284
- const hasDocumentSettings = hasEvenAndOddHeaders || ((_a = document2.settings) == null ? void 0 : _a.defaultTabStop) !== void 0 || ((_b = document2.settings) == null ? void 0 : _b.allowSpaceOfSameStyleInTable) !== void 0 || ((_c = document2.settings) == null ? void 0 : _c.autoHyphenation) !== void 0 || ((_d = document2.settings) == null ? void 0 : _d.consecutiveHyphenLimit) !== void 0 || ((_e = document2.settings) == null ? void 0 : _e.hyphenationZone) !== void 0 || ((_f = document2.settings) == null ? void 0 : _f.doNotHyphenateCaps) !== void 0 || ((_g = document2.footnotes) == null ? void 0 : _g.settings) !== void 0 || ((_h = document2.endnotes) == null ? void 0 : _h.settings) !== void 0;
36296
+ const hasDocumentSettings = hasEvenAndOddHeaders || ((_a2 = document2.settings) == null ? void 0 : _a2.defaultTabStop) !== void 0 || ((_b2 = document2.settings) == null ? void 0 : _b2.allowSpaceOfSameStyleInTable) !== void 0 || ((_c = document2.settings) == null ? void 0 : _c.autoHyphenation) !== void 0 || ((_d = document2.settings) == null ? void 0 : _d.consecutiveHyphenLimit) !== void 0 || ((_e = document2.settings) == null ? void 0 : _e.hyphenationZone) !== void 0 || ((_f = document2.settings) == null ? void 0 : _f.doNotHyphenateCaps) !== void 0 || ((_g = document2.footnotes) == null ? void 0 : _g.settings) !== void 0 || ((_h = document2.endnotes) == null ? void 0 : _h.settings) !== void 0;
36285
36297
  const allImages = [
36286
36298
  ...bodyContext.images,
36287
36299
  ...parts.flatMap((part) => part.context.images)
@@ -36311,8 +36323,8 @@ async function exportEditorDocumentToDocx(document2) {
36311
36323
  allImages.push(...endnotesPart.partContext.images);
36312
36324
  }
36313
36325
  const imageExtensions = allImages.filter((img) => img.kind === "embedded").map((img) => {
36314
- var _a2;
36315
- return (_a2 = img.target.split(".").pop()) == null ? void 0 : _a2.toLowerCase();
36326
+ var _a3;
36327
+ return (_a3 = img.target.split(".").pop()) == null ? void 0 : _a3.toLowerCase();
36316
36328
  }).filter((ext) => Boolean(ext));
36317
36329
  const hasStyles = document2.styles != null && Object.keys(document2.styles).length > 0;
36318
36330
  const hasFontTable = (((_i = document2.fontTable) == null ? void 0 : _i.length) ?? 0) > 0;
@@ -36454,24 +36466,24 @@ function borderDashArray(type) {
36454
36466
  }
36455
36467
  }
36456
36468
  function getPadding(textBox) {
36457
- var _a, _b, _c, _d;
36469
+ var _a2, _b2, _c, _d;
36458
36470
  return {
36459
- left: ((_a = textBox.body) == null ? void 0 : _a.paddingLeft) ?? 0,
36460
- top: ((_b = textBox.body) == null ? void 0 : _b.paddingTop) ?? 0,
36471
+ left: ((_a2 = textBox.body) == null ? void 0 : _a2.paddingLeft) ?? 0,
36472
+ top: ((_b2 = textBox.body) == null ? void 0 : _b2.paddingTop) ?? 0,
36461
36473
  right: ((_c = textBox.body) == null ? void 0 : _c.paddingRight) ?? 0,
36462
36474
  bottom: ((_d = textBox.body) == null ? void 0 : _d.paddingBottom) ?? 0
36463
36475
  };
36464
36476
  }
36465
36477
  function drawShapeGeometry(writer, pageIndex, textBox, xPx, yPx, widthPx, heightPx) {
36466
- var _a, _b, _c, _d;
36478
+ var _a2, _b2, _c, _d;
36467
36479
  const segments = getPresetPathSegments(
36468
- (_a = textBox.shape) == null ? void 0 : _a.preset,
36480
+ (_a2 = textBox.shape) == null ? void 0 : _a2.preset,
36469
36481
  pxToPt$1(xPx),
36470
36482
  pxToPt$1(yPx),
36471
36483
  pxToPt$1(widthPx),
36472
36484
  pxToPt$1(heightPx)
36473
36485
  );
36474
- const fill = (_b = textBox.shape) == null ? void 0 : _b.fill;
36486
+ const fill = (_b2 = textBox.shape) == null ? void 0 : _b2.fill;
36475
36487
  const borderColor = (_c = textBox.shape) == null ? void 0 : _c.borderColor;
36476
36488
  const borderWidthPt = ((_d = textBox.shape) == null ? void 0 : _d.borderWidthPt) ?? (borderColor ? 0.75 : 0);
36477
36489
  writer.drawPath(pageIndex, {
@@ -36482,7 +36494,7 @@ function drawShapeGeometry(writer, pageIndex, textBox, xPx, yPx, widthPx, height
36482
36494
  });
36483
36495
  }
36484
36496
  async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heightPx, drawers) {
36485
- var _a;
36497
+ var _a2;
36486
36498
  if (textBox.blocks.length === 0) {
36487
36499
  return;
36488
36500
  }
@@ -36511,7 +36523,7 @@ async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heigh
36511
36523
  styles: ctx.document.styles,
36512
36524
  pageOffset: ctx.pageIndex
36513
36525
  });
36514
- const blocks = ((_a = pages[0]) == null ? void 0 : _a.blocks) ?? [];
36526
+ const blocks = ((_a2 = pages[0]) == null ? void 0 : _a2.blocks) ?? [];
36515
36527
  if (blocks.length === 0) {
36516
36528
  return;
36517
36529
  }
@@ -36851,11 +36863,16 @@ async function drawFloatingImagesForParagraph(options) {
36851
36863
  }
36852
36864
  }
36853
36865
  function blendColorWithWhite(hex, alpha) {
36866
+ const rgb = parseHexColorToRgb255(hex);
36867
+ if (!rgb) {
36868
+ return hex;
36869
+ }
36854
36870
  const a = Math.max(0, Math.min(1, alpha));
36855
- const r = Math.round(255 + (Number.parseInt(hex.slice(1, 3), 16) - 255) * a);
36856
- const g = Math.round(255 + (Number.parseInt(hex.slice(3, 5), 16) - 255) * a);
36857
- const b = Math.round(255 + (Number.parseInt(hex.slice(5, 7), 16) - 255) * a);
36858
- return `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`;
36871
+ return rgb255ToHex(
36872
+ 255 + (rgb[0] - 255) * a,
36873
+ 255 + (rgb[1] - 255) * a,
36874
+ 255 + (rgb[2] - 255) * a
36875
+ );
36859
36876
  }
36860
36877
  function drawFragmentHighlight(writer, pageIndex, line, fragment, originX, originY, styles) {
36861
36878
  if (!styles.highlight) {
@@ -37120,7 +37137,7 @@ function groupSlotChunksByOffsetGaps(chars) {
37120
37137
  return chunks;
37121
37138
  }
37122
37139
  function resolveTabLeader(paragraph, line, tabLeft, document2) {
37123
- var _a;
37140
+ var _a2;
37124
37141
  const paragraphStyle = resolveEffectiveParagraphStyle(
37125
37142
  paragraph.style,
37126
37143
  document2.styles
@@ -37129,7 +37146,7 @@ function resolveTabLeader(paragraph, line, tabLeft, document2) {
37129
37146
  if (tabs.length === 0) {
37130
37147
  return void 0;
37131
37148
  }
37132
- const lineStart = ((_a = line.slots[0]) == null ? void 0 : _a.left) ?? 0;
37149
+ const lineStart = ((_a2 = line.slots[0]) == null ? void 0 : _a2.left) ?? 0;
37133
37150
  const relativeLeft = tabLeft - lineStart;
37134
37151
  const stop = tabs.filter((tab) => tab.type !== "clear").map((tab) => ({ ...tab, positionPx: tab.position * PX_PER_POINT })).filter((tab) => tab.positionPx > relativeLeft + 0.01).sort((a, b) => a.positionPx - b.positionPx)[0];
37135
37152
  return (stop == null ? void 0 : stop.leader) && stop.leader !== "none" ? stop.leader : void 0;
@@ -37184,7 +37201,7 @@ async function drawInlineTextBoxFragment(writer, pageIndex, line, fragment, docu
37184
37201
  );
37185
37202
  }
37186
37203
  async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, document2, originX, originY, fontRegistry, drawers) {
37187
- var _a, _b, _c;
37204
+ var _a2, _b2, _c;
37188
37205
  if (fragment.image) {
37189
37206
  if (fragment.image.floating) {
37190
37207
  return;
@@ -37229,7 +37246,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37229
37246
  }
37230
37247
  const styles = resolveEffectiveTextStyleForParagraph(
37231
37248
  fragment.styles,
37232
- (_a = paragraph.style) == null ? void 0 : _a.styleId,
37249
+ (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
37233
37250
  document2.styles
37234
37251
  );
37235
37252
  if (styles.hidden) {
@@ -37249,6 +37266,23 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37249
37266
  if (!firstChar || text.length === 0) {
37250
37267
  return;
37251
37268
  }
37269
+ if (styles.link) {
37270
+ const linkBounds = resolveFragmentBounds(
37271
+ line,
37272
+ fragment,
37273
+ styles.fontSize ?? DEFAULT_FONT_SIZE_PX
37274
+ );
37275
+ if (linkBounds && linkBounds.right > linkBounds.left) {
37276
+ const isInternal = styles.link.startsWith("#");
37277
+ writer.addLinkAnnotation(pageIndex, {
37278
+ x: pxToPt$1(originX + linkBounds.left),
37279
+ y: pxToPt$1(originY + line.top),
37280
+ width: pxToPt$1(linkBounds.right - linkBounds.left),
37281
+ height: pxToPt$1(line.height),
37282
+ ...isInternal ? { destName: styles.link.slice(1) } : { uri: styles.link }
37283
+ });
37284
+ }
37285
+ }
37252
37286
  drawFragmentShading(
37253
37287
  writer,
37254
37288
  pageIndex,
@@ -37301,7 +37335,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
37301
37335
  horizontalScale: styles.characterScale ?? 100,
37302
37336
  fontFeatures
37303
37337
  };
37304
- const mainColor = ((_b = styles.textFill) == null ? void 0 : _b.type) === "solid" ? styles.textFill.color : ((_c = styles.textFill) == null ? void 0 : _c.type) === "gradient" && styles.textFill.stops[0] ? styles.textFill.stops[0].color : styles.color ?? "#000000";
37338
+ const mainColor = ((_b2 = styles.textFill) == null ? void 0 : _b2.type) === "solid" ? styles.textFill.color : ((_c = styles.textFill) == null ? void 0 : _c.type) === "gradient" && styles.textFill.stops[0] ? styles.textFill.stops[0].color : styles.color ?? "#000000";
37305
37339
  const gradientShadingName = resolveGradientShadingName(
37306
37340
  writer,
37307
37341
  pageIndex,
@@ -37459,7 +37493,7 @@ function getListOrdinals(document2) {
37459
37493
  return buildListLabels(document2);
37460
37494
  }
37461
37495
  function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX, originY, fontRegistry, listOrdinals) {
37462
- var _a;
37496
+ var _a2;
37463
37497
  if (line.index !== 0) {
37464
37498
  return;
37465
37499
  }
@@ -37473,7 +37507,7 @@ function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX,
37473
37507
  }
37474
37508
  const styles = resolveEffectiveTextStyleForParagraph(
37475
37509
  void 0,
37476
- (_a = paragraph.style) == null ? void 0 : _a.styleId,
37510
+ (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
37477
37511
  document2.styles
37478
37512
  );
37479
37513
  const fontFace = fontRegistry.resolveFontFace({
@@ -37703,8 +37737,8 @@ async function drawTableBlock(writer, pageIndex, block, document2, originX, orig
37703
37737
  }
37704
37738
  }
37705
37739
  const blockDrawers = { drawParagraph, drawTableBlock };
37706
- async function drawBlockList(writer, pageIndex, blocks, document2, originX, originY, contentWidth, fontRegistry, listOrdinals, pageSettings) {
37707
- var _a;
37740
+ async function drawBlockList(writer, pageIndex, blocks, document2, originX, originY, contentWidth, fontRegistry, listOrdinals, pageSettings, onParagraphDrawn) {
37741
+ var _a2;
37708
37742
  if (!blocks || blocks.length === 0) {
37709
37743
  return;
37710
37744
  }
@@ -37722,6 +37756,7 @@ async function drawBlockList(writer, pageIndex, blocks, document2, originX, orig
37722
37756
  );
37723
37757
  const spacingBefore = block.layout.startOffset === 0 && cursorY > originY ? paragraphStyle.spacingBefore ?? 0 : 0;
37724
37758
  const boxTop = cursorY + spacingBefore;
37759
+ onParagraphDrawn == null ? void 0 : onParagraphDrawn(block.sourceBlock.id, boxTop);
37725
37760
  const textTop = boxTop + getParagraphBorderInsets(paragraphStyle).top;
37726
37761
  drawParagraphDecorations(
37727
37762
  writer,
@@ -37803,7 +37838,7 @@ async function drawBlockList(writer, pageIndex, blocks, document2, originX, orig
37803
37838
  break;
37804
37839
  }
37805
37840
  case "table":
37806
- if (((_a = block.sourceBlock.style) == null ? void 0 : _a.floating) && pageSettings) {
37841
+ if (((_a2 = block.sourceBlock.style) == null ? void 0 : _a2.floating) && pageSettings) {
37807
37842
  const width = resolveCanvasTableWidth(
37808
37843
  block.sourceBlock,
37809
37844
  contentWidth
@@ -38051,15 +38086,11 @@ function colorToRgb(color, fallback) {
38051
38086
  if (!color) {
38052
38087
  return fallback;
38053
38088
  }
38054
- const normalized = color.trim().replace(/^#/, "");
38055
- if (!/^[0-9a-fA-F]{6}$/.test(normalized)) {
38089
+ const rgb = parseHexColorToRgb255(color);
38090
+ if (!rgb) {
38056
38091
  return fallback;
38057
38092
  }
38058
- return [
38059
- Number.parseInt(normalized.slice(0, 2), 16) / 255,
38060
- Number.parseInt(normalized.slice(2, 4), 16) / 255,
38061
- Number.parseInt(normalized.slice(4, 6), 16) / 255
38062
- ];
38093
+ return [rgb[0] / 255, rgb[1] / 255, rgb[2] / 255];
38063
38094
  }
38064
38095
  function colorCommand(color, operator, fallback) {
38065
38096
  const [r, g, b] = colorToRgb(color, fallback);
@@ -39455,7 +39486,7 @@ class SimpleTextLayouter {
39455
39486
  function view(bytes) {
39456
39487
  return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
39457
39488
  }
39458
- function u16(bytes, offset) {
39489
+ function u16$1(bytes, offset) {
39459
39490
  return view(bytes).getUint16(offset);
39460
39491
  }
39461
39492
  function i16(bytes, offset) {
@@ -39507,8 +39538,8 @@ function collectCompositeGlyphs(glyph, addGlyph) {
39507
39538
  let flags = 0;
39508
39539
  do {
39509
39540
  if (offset + 4 > glyph.byteLength) return;
39510
- flags = u16(glyph, offset);
39511
- addGlyph(u16(glyph, offset + 2));
39541
+ flags = u16$1(glyph, offset);
39542
+ addGlyph(u16$1(glyph, offset + 2));
39512
39543
  offset += 4;
39513
39544
  offset += flags & 1 ? 4 : 2;
39514
39545
  if (flags & 8) offset += 2;
@@ -39523,7 +39554,7 @@ function subsetClosure(font, initialGlyphs) {
39523
39554
  if (!glyf || !loca || !head) {
39524
39555
  return Array.from(/* @__PURE__ */ new Set([0, ...initialGlyphs])).sort((a, b) => a - b);
39525
39556
  }
39526
- const offsets = readLoca(loca, u16(head, 50));
39557
+ const offsets = readLoca(loca, u16$1(head, 50));
39527
39558
  const used = /* @__PURE__ */ new Set([0, ...initialGlyphs]);
39528
39559
  const stack = Array.from(used);
39529
39560
  while (stack.length > 0) {
@@ -39567,7 +39598,7 @@ function buildSubsetTables(font, glyphIds) {
39567
39598
  }
39568
39599
  const maxGlyphId = Math.max(0, ...glyphIds);
39569
39600
  const used = new Set(glyphIds);
39570
- const sourceOffsets = readLoca(loca, u16(head, 50));
39601
+ const sourceOffsets = readLoca(loca, u16$1(head, 50));
39571
39602
  const locaOffsets = [];
39572
39603
  const glyfChunks = [];
39573
39604
  let glyfOffset = 0;
@@ -39962,11 +39993,609 @@ function buildFunctionObject(stops) {
39962
39993
  ">>"
39963
39994
  ].join("\n");
39964
39995
  }
39965
- function serializePdfDocument(pages, fonts, images, shadings) {
39996
+ var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
39997
+ var fleb = new u8([
39998
+ 0,
39999
+ 0,
40000
+ 0,
40001
+ 0,
40002
+ 0,
40003
+ 0,
40004
+ 0,
40005
+ 0,
40006
+ 1,
40007
+ 1,
40008
+ 1,
40009
+ 1,
40010
+ 2,
40011
+ 2,
40012
+ 2,
40013
+ 2,
40014
+ 3,
40015
+ 3,
40016
+ 3,
40017
+ 3,
40018
+ 4,
40019
+ 4,
40020
+ 4,
40021
+ 4,
40022
+ 5,
40023
+ 5,
40024
+ 5,
40025
+ 5,
40026
+ 0,
40027
+ /* unused */
40028
+ 0,
40029
+ 0,
40030
+ /* impossible */
40031
+ 0
40032
+ ]);
40033
+ var fdeb = new u8([
40034
+ 0,
40035
+ 0,
40036
+ 0,
40037
+ 0,
40038
+ 1,
40039
+ 1,
40040
+ 2,
40041
+ 2,
40042
+ 3,
40043
+ 3,
40044
+ 4,
40045
+ 4,
40046
+ 5,
40047
+ 5,
40048
+ 6,
40049
+ 6,
40050
+ 7,
40051
+ 7,
40052
+ 8,
40053
+ 8,
40054
+ 9,
40055
+ 9,
40056
+ 10,
40057
+ 10,
40058
+ 11,
40059
+ 11,
40060
+ 12,
40061
+ 12,
40062
+ 13,
40063
+ 13,
40064
+ /* unused */
40065
+ 0,
40066
+ 0
40067
+ ]);
40068
+ var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
40069
+ var freb = function(eb, start) {
40070
+ var b = new u16(31);
40071
+ for (var i = 0; i < 31; ++i) {
40072
+ b[i] = start += 1 << eb[i - 1];
40073
+ }
40074
+ var r = new i32(b[30]);
40075
+ for (var i = 1; i < 30; ++i) {
40076
+ for (var j = b[i]; j < b[i + 1]; ++j) {
40077
+ r[j] = j - b[i] << 5 | i;
40078
+ }
40079
+ }
40080
+ return { b, r };
40081
+ };
40082
+ var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;
40083
+ fl[28] = 258, revfl[258] = 28;
40084
+ var _b = freb(fdeb, 0), revfd = _b.r;
40085
+ var rev = new u16(32768);
40086
+ for (var i = 0; i < 32768; ++i) {
40087
+ var x = (i & 43690) >> 1 | (i & 21845) << 1;
40088
+ x = (x & 52428) >> 2 | (x & 13107) << 2;
40089
+ x = (x & 61680) >> 4 | (x & 3855) << 4;
40090
+ rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
40091
+ }
40092
+ var hMap = function(cd, mb, r) {
40093
+ var s = cd.length;
40094
+ var i = 0;
40095
+ var l = new u16(mb);
40096
+ for (; i < s; ++i) {
40097
+ if (cd[i])
40098
+ ++l[cd[i] - 1];
40099
+ }
40100
+ var le = new u16(mb);
40101
+ for (i = 1; i < mb; ++i) {
40102
+ le[i] = le[i - 1] + l[i - 1] << 1;
40103
+ }
40104
+ var co;
40105
+ if (r) {
40106
+ co = new u16(1 << mb);
40107
+ var rvb = 15 - mb;
40108
+ for (i = 0; i < s; ++i) {
40109
+ if (cd[i]) {
40110
+ var sv = i << 4 | cd[i];
40111
+ var r_1 = mb - cd[i];
40112
+ var v = le[cd[i] - 1]++ << r_1;
40113
+ for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
40114
+ co[rev[v] >> rvb] = sv;
40115
+ }
40116
+ }
40117
+ }
40118
+ } else {
40119
+ co = new u16(s);
40120
+ for (i = 0; i < s; ++i) {
40121
+ if (cd[i]) {
40122
+ co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i];
40123
+ }
40124
+ }
40125
+ }
40126
+ return co;
40127
+ };
40128
+ var flt = new u8(288);
40129
+ for (var i = 0; i < 144; ++i)
40130
+ flt[i] = 8;
40131
+ for (var i = 144; i < 256; ++i)
40132
+ flt[i] = 9;
40133
+ for (var i = 256; i < 280; ++i)
40134
+ flt[i] = 7;
40135
+ for (var i = 280; i < 288; ++i)
40136
+ flt[i] = 8;
40137
+ var fdt = new u8(32);
40138
+ for (var i = 0; i < 32; ++i)
40139
+ fdt[i] = 5;
40140
+ var flm = /* @__PURE__ */ hMap(flt, 9, 0);
40141
+ var fdm = /* @__PURE__ */ hMap(fdt, 5, 0);
40142
+ var shft = function(p) {
40143
+ return (p + 7) / 8 | 0;
40144
+ };
40145
+ var slc = function(v, s, e) {
40146
+ if (e == null || e > v.length)
40147
+ e = v.length;
40148
+ return new u8(v.subarray(s, e));
40149
+ };
40150
+ var wbits = function(d, p, v) {
40151
+ v <<= p & 7;
40152
+ var o = p / 8 | 0;
40153
+ d[o] |= v;
40154
+ d[o + 1] |= v >> 8;
40155
+ };
40156
+ var wbits16 = function(d, p, v) {
40157
+ v <<= p & 7;
40158
+ var o = p / 8 | 0;
40159
+ d[o] |= v;
40160
+ d[o + 1] |= v >> 8;
40161
+ d[o + 2] |= v >> 16;
40162
+ };
40163
+ var hTree = function(d, mb) {
40164
+ var t = [];
40165
+ for (var i = 0; i < d.length; ++i) {
40166
+ if (d[i])
40167
+ t.push({ s: i, f: d[i] });
40168
+ }
40169
+ var s = t.length;
40170
+ var t2 = t.slice();
40171
+ if (!s)
40172
+ return { t: et, l: 0 };
40173
+ if (s == 1) {
40174
+ var v = new u8(t[0].s + 1);
40175
+ v[t[0].s] = 1;
40176
+ return { t: v, l: 1 };
40177
+ }
40178
+ t.sort(function(a, b) {
40179
+ return a.f - b.f;
40180
+ });
40181
+ t.push({ s: -1, f: 25001 });
40182
+ var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;
40183
+ t[0] = { s: -1, f: l.f + r.f, l, r };
40184
+ while (i1 != s - 1) {
40185
+ l = t[t[i0].f < t[i2].f ? i0++ : i2++];
40186
+ r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];
40187
+ t[i1++] = { s: -1, f: l.f + r.f, l, r };
40188
+ }
40189
+ var maxSym = t2[0].s;
40190
+ for (var i = 1; i < s; ++i) {
40191
+ if (t2[i].s > maxSym)
40192
+ maxSym = t2[i].s;
40193
+ }
40194
+ var tr = new u16(maxSym + 1);
40195
+ var mbt = ln(t[i1 - 1], tr, 0);
40196
+ if (mbt > mb) {
40197
+ var i = 0, dt = 0;
40198
+ var lft = mbt - mb, cst = 1 << lft;
40199
+ t2.sort(function(a, b) {
40200
+ return tr[b.s] - tr[a.s] || a.f - b.f;
40201
+ });
40202
+ for (; i < s; ++i) {
40203
+ var i2_1 = t2[i].s;
40204
+ if (tr[i2_1] > mb) {
40205
+ dt += cst - (1 << mbt - tr[i2_1]);
40206
+ tr[i2_1] = mb;
40207
+ } else
40208
+ break;
40209
+ }
40210
+ dt >>= lft;
40211
+ while (dt > 0) {
40212
+ var i2_2 = t2[i].s;
40213
+ if (tr[i2_2] < mb)
40214
+ dt -= 1 << mb - tr[i2_2]++ - 1;
40215
+ else
40216
+ ++i;
40217
+ }
40218
+ for (; i >= 0 && dt; --i) {
40219
+ var i2_3 = t2[i].s;
40220
+ if (tr[i2_3] == mb) {
40221
+ --tr[i2_3];
40222
+ ++dt;
40223
+ }
40224
+ }
40225
+ mbt = mb;
40226
+ }
40227
+ return { t: new u8(tr), l: mbt };
40228
+ };
40229
+ var ln = function(n, l, d) {
40230
+ return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
40231
+ };
40232
+ var lc = function(c) {
40233
+ var s = c.length;
40234
+ while (s && !c[--s])
40235
+ ;
40236
+ var cl = new u16(++s);
40237
+ var cli = 0, cln = c[0], cls = 1;
40238
+ var w = function(v) {
40239
+ cl[cli++] = v;
40240
+ };
40241
+ for (var i = 1; i <= s; ++i) {
40242
+ if (c[i] == cln && i != s)
40243
+ ++cls;
40244
+ else {
40245
+ if (!cln && cls > 2) {
40246
+ for (; cls > 138; cls -= 138)
40247
+ w(32754);
40248
+ if (cls > 2) {
40249
+ w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
40250
+ cls = 0;
40251
+ }
40252
+ } else if (cls > 3) {
40253
+ w(cln), --cls;
40254
+ for (; cls > 6; cls -= 6)
40255
+ w(8304);
40256
+ if (cls > 2)
40257
+ w(cls - 3 << 5 | 8208), cls = 0;
40258
+ }
40259
+ while (cls--)
40260
+ w(cln);
40261
+ cls = 1;
40262
+ cln = c[i];
40263
+ }
40264
+ }
40265
+ return { c: cl.subarray(0, cli), n: s };
40266
+ };
40267
+ var clen = function(cf, cl) {
40268
+ var l = 0;
40269
+ for (var i = 0; i < cl.length; ++i)
40270
+ l += cf[i] * cl[i];
40271
+ return l;
40272
+ };
40273
+ var wfblk = function(out, pos, dat) {
40274
+ var s = dat.length;
40275
+ var o = shft(pos + 2);
40276
+ out[o] = s & 255;
40277
+ out[o + 1] = s >> 8;
40278
+ out[o + 2] = out[o] ^ 255;
40279
+ out[o + 3] = out[o + 1] ^ 255;
40280
+ for (var i = 0; i < s; ++i)
40281
+ out[o + i + 4] = dat[i];
40282
+ return (o + 4 + s) * 8;
40283
+ };
40284
+ var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
40285
+ wbits(out, p++, final);
40286
+ ++lf[256];
40287
+ var _a2 = hTree(lf, 15), dlt = _a2.t, mlb = _a2.l;
40288
+ var _b2 = hTree(df, 15), ddt = _b2.t, mdb = _b2.l;
40289
+ var _c = lc(dlt), lclt = _c.c, nlc = _c.n;
40290
+ var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;
40291
+ var lcfreq = new u16(19);
40292
+ for (var i = 0; i < lclt.length; ++i)
40293
+ ++lcfreq[lclt[i] & 31];
40294
+ for (var i = 0; i < lcdt.length; ++i)
40295
+ ++lcfreq[lcdt[i] & 31];
40296
+ var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;
40297
+ var nlcc = 19;
40298
+ for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)
40299
+ ;
40300
+ var flen = bl + 5 << 3;
40301
+ var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
40302
+ var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
40303
+ if (bs >= 0 && flen <= ftlen && flen <= dtlen)
40304
+ return wfblk(out, p, dat.subarray(bs, bs + bl));
40305
+ var lm, ll, dm, dl;
40306
+ wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
40307
+ if (dtlen < ftlen) {
40308
+ lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
40309
+ var llm = hMap(lct, mlcb, 0);
40310
+ wbits(out, p, nlc - 257);
40311
+ wbits(out, p + 5, ndc - 1);
40312
+ wbits(out, p + 10, nlcc - 4);
40313
+ p += 14;
40314
+ for (var i = 0; i < nlcc; ++i)
40315
+ wbits(out, p + 3 * i, lct[clim[i]]);
40316
+ p += 3 * nlcc;
40317
+ var lcts = [lclt, lcdt];
40318
+ for (var it = 0; it < 2; ++it) {
40319
+ var clct = lcts[it];
40320
+ for (var i = 0; i < clct.length; ++i) {
40321
+ var len = clct[i] & 31;
40322
+ wbits(out, p, llm[len]), p += lct[len];
40323
+ if (len > 15)
40324
+ wbits(out, p, clct[i] >> 5 & 127), p += clct[i] >> 12;
40325
+ }
40326
+ }
40327
+ } else {
40328
+ lm = flm, ll = flt, dm = fdm, dl = fdt;
40329
+ }
40330
+ for (var i = 0; i < li; ++i) {
40331
+ var sym = syms[i];
40332
+ if (sym > 255) {
40333
+ var len = sym >> 18 & 31;
40334
+ wbits16(out, p, lm[len + 257]), p += ll[len + 257];
40335
+ if (len > 7)
40336
+ wbits(out, p, sym >> 23 & 31), p += fleb[len];
40337
+ var dst = sym & 31;
40338
+ wbits16(out, p, dm[dst]), p += dl[dst];
40339
+ if (dst > 3)
40340
+ wbits16(out, p, sym >> 5 & 8191), p += fdeb[dst];
40341
+ } else {
40342
+ wbits16(out, p, lm[sym]), p += ll[sym];
40343
+ }
40344
+ }
40345
+ wbits16(out, p, lm[256]);
40346
+ return p + ll[256];
40347
+ };
40348
+ var deo = /* @__PURE__ */ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
40349
+ var et = /* @__PURE__ */ new u8(0);
40350
+ var dflt = function(dat, lvl, plvl, pre, post, st) {
40351
+ var s = st.z || dat.length;
40352
+ var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
40353
+ var w = o.subarray(pre, o.length - post);
40354
+ var lst = st.l;
40355
+ var pos = (st.r || 0) & 7;
40356
+ if (lvl) {
40357
+ if (pos)
40358
+ w[0] = st.r >> 3;
40359
+ var opt = deo[lvl - 1];
40360
+ var n = opt >> 13, c = opt & 8191;
40361
+ var msk_1 = (1 << plvl) - 1;
40362
+ var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);
40363
+ var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
40364
+ var hsh = function(i2) {
40365
+ return (dat[i2] ^ dat[i2 + 1] << bs1_1 ^ dat[i2 + 2] << bs2_1) & msk_1;
40366
+ };
40367
+ var syms = new i32(25e3);
40368
+ var lf = new u16(288), df = new u16(32);
40369
+ var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
40370
+ for (; i + 2 < s; ++i) {
40371
+ var hv = hsh(i);
40372
+ var imod = i & 32767, pimod = head[hv];
40373
+ prev[imod] = pimod;
40374
+ head[hv] = imod;
40375
+ if (wi <= i) {
40376
+ var rem = s - i;
40377
+ if ((lc_1 > 7e3 || li > 24576) && (rem > 423 || !lst)) {
40378
+ pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
40379
+ li = lc_1 = eb = 0, bs = i;
40380
+ for (var j = 0; j < 286; ++j)
40381
+ lf[j] = 0;
40382
+ for (var j = 0; j < 30; ++j)
40383
+ df[j] = 0;
40384
+ }
40385
+ var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
40386
+ if (rem > 2 && hv == hsh(i - dif)) {
40387
+ var maxn = Math.min(n, rem) - 1;
40388
+ var maxd = Math.min(32767, i);
40389
+ var ml = Math.min(258, rem);
40390
+ while (dif <= maxd && --ch_1 && imod != pimod) {
40391
+ if (dat[i + l] == dat[i + l - dif]) {
40392
+ var nl = 0;
40393
+ for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)
40394
+ ;
40395
+ if (nl > l) {
40396
+ l = nl, d = dif;
40397
+ if (nl > maxn)
40398
+ break;
40399
+ var mmd = Math.min(dif, nl - 2);
40400
+ var md = 0;
40401
+ for (var j = 0; j < mmd; ++j) {
40402
+ var ti = i - dif + j & 32767;
40403
+ var pti = prev[ti];
40404
+ var cd = ti - pti & 32767;
40405
+ if (cd > md)
40406
+ md = cd, pimod = ti;
40407
+ }
40408
+ }
40409
+ }
40410
+ imod = pimod, pimod = prev[imod];
40411
+ dif += imod - pimod & 32767;
40412
+ }
40413
+ }
40414
+ if (d) {
40415
+ syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
40416
+ var lin = revfl[l] & 31, din = revfd[d] & 31;
40417
+ eb += fleb[lin] + fdeb[din];
40418
+ ++lf[257 + lin];
40419
+ ++df[din];
40420
+ wi = i + l;
40421
+ ++lc_1;
40422
+ } else {
40423
+ syms[li++] = dat[i];
40424
+ ++lf[dat[i]];
40425
+ }
40426
+ }
40427
+ }
40428
+ for (i = Math.max(i, wi); i < s; ++i) {
40429
+ syms[li++] = dat[i];
40430
+ ++lf[dat[i]];
40431
+ }
40432
+ pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
40433
+ if (!lst) {
40434
+ st.r = pos & 7 | w[pos / 8 | 0] << 3;
40435
+ pos -= 7;
40436
+ st.h = head, st.p = prev, st.i = i, st.w = wi;
40437
+ }
40438
+ } else {
40439
+ for (var i = st.w || 0; i < s + lst; i += 65535) {
40440
+ var e = i + 65535;
40441
+ if (e >= s) {
40442
+ w[pos / 8 | 0] = lst;
40443
+ e = s;
40444
+ }
40445
+ pos = wfblk(w, pos + 1, dat.subarray(i, e));
40446
+ }
40447
+ st.i = s;
40448
+ }
40449
+ return slc(o, 0, pre + shft(pos) + post);
40450
+ };
40451
+ var adler = function() {
40452
+ var a = 1, b = 0;
40453
+ return {
40454
+ p: function(d) {
40455
+ var n = a, m = b;
40456
+ var l = d.length | 0;
40457
+ for (var i = 0; i != l; ) {
40458
+ var e = Math.min(i + 2655, l);
40459
+ for (; i < e; ++i)
40460
+ m += n += d[i];
40461
+ n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);
40462
+ }
40463
+ a = n, b = m;
40464
+ },
40465
+ d: function() {
40466
+ a %= 65521, b %= 65521;
40467
+ return (a & 255) << 24 | (a & 65280) << 8 | (b & 255) << 8 | b >> 8;
40468
+ }
40469
+ };
40470
+ };
40471
+ var dopt = function(dat, opt, pre, post, st) {
40472
+ if (!st) {
40473
+ st = { l: 1 };
40474
+ if (opt.dictionary) {
40475
+ var dict = opt.dictionary.subarray(-32768);
40476
+ var newDat = new u8(dict.length + dat.length);
40477
+ newDat.set(dict);
40478
+ newDat.set(dat, dict.length);
40479
+ dat = newDat;
40480
+ st.w = dict.length;
40481
+ }
40482
+ }
40483
+ return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post, st);
40484
+ };
40485
+ var wbytes = function(d, b, v) {
40486
+ for (; v; ++b)
40487
+ d[b] = v, v >>>= 8;
40488
+ };
40489
+ var zlh = function(c, o) {
40490
+ var lv = o.level, fl2 = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;
40491
+ c[0] = 120, c[1] = fl2 << 6 | (o.dictionary && 32);
40492
+ c[1] |= 31 - (c[0] << 8 | c[1]) % 31;
40493
+ if (o.dictionary) {
40494
+ var h = adler();
40495
+ h.p(o.dictionary);
40496
+ wbytes(c, 2, h.d());
40497
+ }
40498
+ };
40499
+ function zlibSync(data, opts) {
40500
+ if (!opts)
40501
+ opts = {};
40502
+ var a = adler();
40503
+ a.p(data);
40504
+ var d = dopt(data, opts, opts.dictionary ? 6 : 2, 4);
40505
+ return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;
40506
+ }
40507
+ var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
40508
+ var tds = 0;
40509
+ try {
40510
+ td.decode(et, { stream: true });
40511
+ tds = 1;
40512
+ } catch (e) {
40513
+ }
40514
+ const utf8 = new TextEncoder();
40515
+ function chunkByteLength(chunk) {
40516
+ return typeof chunk === "string" ? byteLength(chunk) : chunk.length;
40517
+ }
40518
+ function concatChunks(chunks) {
40519
+ const total = chunks.reduce((sum, chunk) => sum + chunkByteLength(chunk), 0);
40520
+ const out = new Uint8Array(total);
40521
+ let offset = 0;
40522
+ for (const chunk of chunks) {
40523
+ const bytes = typeof chunk === "string" ? utf8.encode(chunk) : chunk;
40524
+ out.set(bytes, offset);
40525
+ offset += bytes.length;
40526
+ }
40527
+ return out;
40528
+ }
40529
+ function buildContentStreamObject(streamText) {
40530
+ const compressed = zlibSync(utf8.encode(streamText));
40531
+ return concatChunks([
40532
+ `<< /Length ${compressed.length} /Filter /FlateDecode >>
40533
+ stream
40534
+ `,
40535
+ compressed,
40536
+ "\nendstream"
40537
+ ]);
40538
+ }
40539
+ function encodePdfLiteralString(value) {
40540
+ return value.replace(/[\\()]/g, (char) => `\\${char}`);
40541
+ }
40542
+ function encodePdfTextString(value) {
40543
+ const codePoints = Array.from(value).map((ch) => ch.codePointAt(0) ?? 63);
40544
+ return `<FEFF${encodePdfUtf16Hex(codePoints)}>`;
40545
+ }
40546
+ function formatPdfDate(date) {
40547
+ const pad = (n, width = 2) => String(n).padStart(width, "0");
40548
+ return `D:${date.getUTCFullYear()}${pad(date.getUTCMonth() + 1)}${pad(date.getUTCDate())}${pad(date.getUTCHours())}${pad(date.getUTCMinutes())}${pad(date.getUTCSeconds())}+00'00'`;
40549
+ }
40550
+ function buildDocumentInfoBody(info) {
40551
+ const entries = [];
40552
+ if (info.title) entries.push(`/Title ${encodePdfTextString(info.title)}`);
40553
+ if (info.author) entries.push(`/Author ${encodePdfTextString(info.author)}`);
40554
+ if (info.subject)
40555
+ entries.push(`/Subject ${encodePdfTextString(info.subject)}`);
40556
+ if (info.keywords)
40557
+ entries.push(`/Keywords ${encodePdfTextString(info.keywords)}`);
40558
+ if (info.producer)
40559
+ entries.push(`/Producer (${encodePdfLiteralString(info.producer)})`);
40560
+ if (info.creationDate)
40561
+ entries.push(`/CreationDate (${formatPdfDate(info.creationDate)})`);
40562
+ if (entries.length === 0) {
40563
+ return void 0;
40564
+ }
40565
+ return `<< ${entries.join(" ")} >>`;
40566
+ }
40567
+ function buildOutlineTree(items) {
40568
+ const roots = [];
40569
+ const stack = [];
40570
+ for (const item of items) {
40571
+ const node = {
40572
+ title: item.title,
40573
+ destName: item.destName,
40574
+ children: []
40575
+ };
40576
+ while (stack.length > 0 && stack[stack.length - 1].level >= item.level) {
40577
+ stack.pop();
40578
+ }
40579
+ if (stack.length === 0) {
40580
+ roots.push(node);
40581
+ } else {
40582
+ stack[stack.length - 1].node.children.push(node);
40583
+ }
40584
+ stack.push({ node, level: item.level });
40585
+ }
40586
+ return roots;
40587
+ }
40588
+ function countOutlineDescendants(node) {
40589
+ return node.children.reduce(
40590
+ (total, child) => total + 1 + countOutlineDescendants(child),
40591
+ 0
40592
+ );
40593
+ }
40594
+ function serializePdfDocument(pages, fonts, images, shadings, namedDestinations = [], outlineItems = [], documentInfo) {
39966
40595
  const objects = [];
39967
- const addObject = (body2) => {
40596
+ const addObject = (body) => {
39968
40597
  const id = objects.length + 1;
39969
- objects.push({ id, body: body2 });
40598
+ objects.push({ id, body });
39970
40599
  return id;
39971
40600
  };
39972
40601
  const catalogObjectId = addObject("");
@@ -39978,11 +40607,7 @@ function serializePdfDocument(pages, fonts, images, shadings) {
39978
40607
  for (const page of pages) {
39979
40608
  const stream = `${page.commands.join("\n")}
39980
40609
  `;
39981
- const contentObjectId = addObject(
39982
- `<< /Length ${byteLength(stream)} >>
39983
- stream
39984
- ${stream}endstream`
39985
- );
40610
+ const contentObjectId = addObject(buildContentStreamObject(stream));
39986
40611
  const imageResourceXml = Array.from(page.imageResourceNames).map((resourceName) => {
39987
40612
  const objectId = imageObjectIds.get(resourceName);
39988
40613
  return objectId ? `/${resourceName} ${objectId} 0 R` : "";
@@ -39993,52 +40618,153 @@ ${stream}endstream`
39993
40618
  return objectId ? `/${resourceName} ${objectId} 0 R` : "";
39994
40619
  }).filter(Boolean).join(" ");
39995
40620
  const shadingResourceDictXml = shadingResourceXml ? ` /Shading << ${shadingResourceXml} >>` : "";
40621
+ const annotationObjectIds = page.annotations.map((annotation) => {
40622
+ const x1 = annotation.x;
40623
+ const x2 = annotation.x + annotation.width;
40624
+ const y1 = page.height - annotation.y - annotation.height;
40625
+ const y2 = page.height - annotation.y;
40626
+ const action = annotation.destName !== void 0 ? `/A << /Type /Action /S /GoTo /D (${encodePdfLiteralString(annotation.destName)}) >>` : `/A << /Type /Action /S /URI /URI (${encodePdfLiteralString(annotation.uri ?? "")}) >>`;
40627
+ return addObject(
40628
+ [
40629
+ "<< /Type /Annot /Subtype /Link",
40630
+ `/Rect [${formatNumber(x1)} ${formatNumber(y1)} ${formatNumber(x2)} ${formatNumber(y2)}]`,
40631
+ "/Border [0 0 0]",
40632
+ action,
40633
+ ">>"
40634
+ ].join("\n")
40635
+ );
40636
+ });
40637
+ const annotsXml = annotationObjectIds.length > 0 ? `
40638
+ /Annots [${annotationObjectIds.map((id) => `${id} 0 R`).join(" ")}]` : "";
39996
40639
  const pageObjectId = addObject(
39997
40640
  [
39998
40641
  "<< /Type /Page",
39999
40642
  `/Parent ${pagesObjectId} 0 R`,
40000
40643
  `/MediaBox [0 0 ${formatNumber(page.width)} ${formatNumber(page.height)}]`,
40001
40644
  `/Resources << /Font << ${fontResourceXml} >>${xObjectResourceXml}${shadingResourceDictXml} >>`,
40002
- `/Contents ${contentObjectId} 0 R`,
40645
+ `/Contents ${contentObjectId} 0 R${annotsXml}`,
40003
40646
  ">>"
40004
40647
  ].join("\n")
40005
40648
  );
40006
40649
  pageObjectIds.push(pageObjectId);
40007
40650
  }
40008
- objects[catalogObjectId - 1].body = `<< /Type /Catalog /Pages ${pagesObjectId} 0 R >>`;
40651
+ let namesObjectId;
40652
+ const resolvedDestinations = namedDestinations.filter((dest) => pageObjectIds[dest.pageIndex] !== void 0).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
40653
+ if (resolvedDestinations.length > 0) {
40654
+ const namesArray = resolvedDestinations.map((dest) => {
40655
+ const pageObjectId = pageObjectIds[dest.pageIndex];
40656
+ const pageHeight = pages[dest.pageIndex].height;
40657
+ const top = pageHeight - dest.y;
40658
+ return `(${encodePdfLiteralString(dest.name)}) [${pageObjectId} 0 R /XYZ ${formatNumber(dest.x)} ${formatNumber(top)} null]`;
40659
+ }).join(" ");
40660
+ const destsObjectId = addObject(`<< /Names [${namesArray}] >>`);
40661
+ namesObjectId = addObject(`<< /Dests ${destsObjectId} 0 R >>`);
40662
+ }
40663
+ let outlineRootId;
40664
+ const resolvedNames = new Set(resolvedDestinations.map((dest) => dest.name));
40665
+ const outlineRoots = buildOutlineTree(
40666
+ outlineItems.filter((item) => resolvedNames.has(item.destName))
40667
+ );
40668
+ if (outlineRoots.length > 0) {
40669
+ outlineRootId = addObject("");
40670
+ const assignIds = (nodes) => nodes.map((node) => {
40671
+ const id = addObject("");
40672
+ node.id = id;
40673
+ node.childIds = assignIds(node.children);
40674
+ return id;
40675
+ });
40676
+ const rootIds = assignIds(outlineRoots);
40677
+ const emit = (nodes, parentId) => {
40678
+ nodes.forEach((node, index) => {
40679
+ const self = node;
40680
+ const prev = index > 0 ? nodes[index - 1] : void 0;
40681
+ const next = index < nodes.length - 1 ? nodes[index + 1] : void 0;
40682
+ const lines = [
40683
+ "<< /Title " + encodePdfTextString(node.title),
40684
+ `/Parent ${parentId} 0 R`,
40685
+ prev ? `/Prev ${prev.id} 0 R` : "",
40686
+ next ? `/Next ${next.id} 0 R` : "",
40687
+ `/Dest (${encodePdfLiteralString(node.destName)})`
40688
+ ];
40689
+ if (self.childIds.length > 0) {
40690
+ lines.push(`/First ${self.childIds[0]} 0 R`);
40691
+ lines.push(`/Last ${self.childIds[self.childIds.length - 1]} 0 R`);
40692
+ lines.push(`/Count ${countOutlineDescendants(node)}`);
40693
+ }
40694
+ lines.push(">>");
40695
+ objects[self.id - 1].body = lines.filter(Boolean).join("\n");
40696
+ emit(node.children, self.id);
40697
+ });
40698
+ };
40699
+ emit(outlineRoots, outlineRootId);
40700
+ const totalItems = outlineItems.filter(
40701
+ (item) => resolvedNames.has(item.destName)
40702
+ ).length;
40703
+ objects[outlineRootId - 1].body = [
40704
+ "<< /Type /Outlines",
40705
+ `/First ${rootIds[0]} 0 R`,
40706
+ `/Last ${rootIds[rootIds.length - 1]} 0 R`,
40707
+ `/Count ${totalItems}`,
40708
+ ">>"
40709
+ ].join("\n");
40710
+ }
40711
+ objects[catalogObjectId - 1].body = [
40712
+ "<< /Type /Catalog",
40713
+ `/Pages ${pagesObjectId} 0 R`,
40714
+ namesObjectId !== void 0 ? `/Names ${namesObjectId} 0 R` : "",
40715
+ outlineRootId !== void 0 ? `/Outlines ${outlineRootId} 0 R` : "",
40716
+ outlineRootId !== void 0 ? "/PageMode /UseOutlines" : "",
40717
+ ">>"
40718
+ ].filter(Boolean).join("\n");
40009
40719
  objects[pagesObjectId - 1].body = [
40010
40720
  "<< /Type /Pages",
40011
40721
  `/Kids [${pageObjectIds.map((id) => `${id} 0 R`).join(" ")}]`,
40012
40722
  `/Count ${pageObjectIds.length}`,
40013
40723
  ">>"
40014
40724
  ].join("\n");
40015
- let body = PDF_HEADER;
40725
+ let infoObjectId;
40726
+ if (documentInfo) {
40727
+ const infoBody = buildDocumentInfoBody(documentInfo);
40728
+ if (infoBody) {
40729
+ infoObjectId = addObject(infoBody);
40730
+ }
40731
+ }
40732
+ const chunks = [PDF_HEADER];
40733
+ let offset = chunkByteLength(PDF_HEADER);
40016
40734
  const offsets = [0];
40735
+ const push = (chunk) => {
40736
+ chunks.push(chunk);
40737
+ offset += chunkByteLength(chunk);
40738
+ };
40017
40739
  for (const object of objects) {
40018
- offsets[object.id] = byteLength(body);
40019
- body += `${object.id} 0 obj
40020
- ${object.body}
40021
- endobj
40022
- `;
40023
- }
40024
- const xrefOffset = byteLength(body);
40025
- body += `xref
40740
+ offsets[object.id] = offset;
40741
+ push(`${object.id} 0 obj
40742
+ `);
40743
+ push(object.body);
40744
+ push("\nendobj\n");
40745
+ }
40746
+ const xrefOffset = offset;
40747
+ let xref = `xref
40026
40748
  0 ${objects.length + 1}
40027
40749
  `;
40028
- body += "0000000000 65535 f \n";
40750
+ xref += "0000000000 65535 f \n";
40029
40751
  for (const object of objects) {
40030
- body += `${String(offsets[object.id] ?? 0).padStart(10, "0")} 00000 n
40752
+ xref += `${String(offsets[object.id] ?? 0).padStart(10, "0")} 00000 n
40031
40753
  `;
40032
40754
  }
40033
- body += [
40034
- "trailer",
40035
- `<< /Size ${objects.length + 1} /Root ${catalogObjectId} 0 R >>`,
40036
- "startxref",
40037
- String(xrefOffset),
40038
- "%%EOF",
40039
- ""
40040
- ].join("\n");
40041
- return new TextEncoder().encode(body);
40755
+ push(xref);
40756
+ const infoTrailerXml = infoObjectId !== void 0 ? ` /Info ${infoObjectId} 0 R` : "";
40757
+ push(
40758
+ [
40759
+ "trailer",
40760
+ `<< /Size ${objects.length + 1} /Root ${catalogObjectId} 0 R${infoTrailerXml} >>`,
40761
+ "startxref",
40762
+ String(xrefOffset),
40763
+ "%%EOF",
40764
+ ""
40765
+ ].join("\n")
40766
+ );
40767
+ return concatChunks(chunks);
40042
40768
  }
40043
40769
  class OasisPdfWriter {
40044
40770
  constructor(fontResources = DEFAULT_PDF_FONT_RESOURCES) {
@@ -40047,6 +40773,9 @@ class OasisPdfWriter {
40047
40773
  __publicField(this, "fonts");
40048
40774
  __publicField(this, "images", new PdfImageTable());
40049
40775
  __publicField(this, "shadings", new PdfShadingTable());
40776
+ __publicField(this, "namedDestinations", []);
40777
+ __publicField(this, "outlineItems", []);
40778
+ __publicField(this, "documentInfo");
40050
40779
  this.fonts = new PdfFontTable(fontResources);
40051
40780
  }
40052
40781
  registerFontResource(resource) {
@@ -40058,7 +40787,8 @@ class OasisPdfWriter {
40058
40787
  height: Math.max(1, size.height),
40059
40788
  commands: [],
40060
40789
  imageResourceNames: /* @__PURE__ */ new Set(),
40061
- shadingResourceNames: /* @__PURE__ */ new Set()
40790
+ shadingResourceNames: /* @__PURE__ */ new Set(),
40791
+ annotations: []
40062
40792
  };
40063
40793
  this.pages.push(page);
40064
40794
  this.streams.push(
@@ -40070,36 +40800,36 @@ class OasisPdfWriter {
40070
40800
  return this.pages.length;
40071
40801
  }
40072
40802
  drawRect(pageIndex, options) {
40073
- var _a;
40074
- (_a = this.streams[pageIndex]) == null ? void 0 : _a.drawRect(options);
40803
+ var _a2;
40804
+ (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawRect(options);
40075
40805
  }
40076
40806
  drawLine(pageIndex, options) {
40077
- var _a;
40078
- (_a = this.streams[pageIndex]) == null ? void 0 : _a.drawLine(options);
40807
+ var _a2;
40808
+ (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawLine(options);
40079
40809
  }
40080
40810
  drawPath(pageIndex, options) {
40081
- var _a;
40082
- (_a = this.streams[pageIndex]) == null ? void 0 : _a.drawPath(options);
40811
+ var _a2;
40812
+ (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawPath(options);
40083
40813
  }
40084
40814
  saveGraphicsState(pageIndex) {
40085
- var _a;
40086
- (_a = this.streams[pageIndex]) == null ? void 0 : _a.saveGraphicsState();
40815
+ var _a2;
40816
+ (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.saveGraphicsState();
40087
40817
  }
40088
40818
  restoreGraphicsState(pageIndex) {
40089
- var _a;
40090
- (_a = this.streams[pageIndex]) == null ? void 0 : _a.restoreGraphicsState();
40819
+ var _a2;
40820
+ (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.restoreGraphicsState();
40091
40821
  }
40092
40822
  rotateAbout(pageIndex, centerX, centerY, degrees) {
40093
- var _a;
40094
- (_a = this.streams[pageIndex]) == null ? void 0 : _a.rotateAbout(centerX, centerY, degrees);
40823
+ var _a2;
40824
+ (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.rotateAbout(centerX, centerY, degrees);
40095
40825
  }
40096
40826
  clipRect(pageIndex, x, y, width, height) {
40097
- var _a;
40098
- (_a = this.streams[pageIndex]) == null ? void 0 : _a.clipRect(x, y, width, height);
40827
+ var _a2;
40828
+ (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.clipRect(x, y, width, height);
40099
40829
  }
40100
40830
  drawText(pageIndex, options) {
40101
- var _a;
40102
- (_a = this.streams[pageIndex]) == null ? void 0 : _a.drawText(options);
40831
+ var _a2;
40832
+ (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawText(options);
40103
40833
  }
40104
40834
  /**
40105
40835
  * Registers an axial (linear) gradient on a page for use as a glyph fill, and
@@ -40107,15 +40837,45 @@ class OasisPdfWriter {
40107
40837
  * subsequent `drawText`. Coordinates are in the writer's top-left point space.
40108
40838
  */
40109
40839
  registerAxialGradient(pageIndex, gradient) {
40110
- var _a;
40111
- return ((_a = this.streams[pageIndex]) == null ? void 0 : _a.registerAxialGradient(gradient)) ?? null;
40840
+ var _a2;
40841
+ return ((_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.registerAxialGradient(gradient)) ?? null;
40112
40842
  }
40113
40843
  registerImageResource(resource) {
40114
40844
  return this.images.registerImageResource(resource);
40115
40845
  }
40116
40846
  drawImage(pageIndex, options) {
40117
- var _a;
40118
- (_a = this.streams[pageIndex]) == null ? void 0 : _a.drawImage(options);
40847
+ var _a2;
40848
+ (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawImage(options);
40849
+ }
40850
+ /**
40851
+ * Attaches a clickable external link annotation to a page. The rect is in the
40852
+ * writer's top-left point space; the serializer flips it to PDF space.
40853
+ */
40854
+ addLinkAnnotation(pageIndex, annotation) {
40855
+ var _a2;
40856
+ (_a2 = this.pages[pageIndex]) == null ? void 0 : _a2.annotations.push(annotation);
40857
+ }
40858
+ /**
40859
+ * Registers a named destination (jump target). Position is in the writer's
40860
+ * top-left point space. The first registration of a given name wins; later
40861
+ * duplicates are ignored so destinations stay unique in the names tree.
40862
+ */
40863
+ addNamedDestination(destination) {
40864
+ if (this.namedDestinations.some((d) => d.name === destination.name)) {
40865
+ return;
40866
+ }
40867
+ this.namedDestinations.push(destination);
40868
+ }
40869
+ /**
40870
+ * Appends an outline (bookmarks-panel) entry. Call in document order; the
40871
+ * serializer nests entries by `level`.
40872
+ */
40873
+ addOutlineItem(item) {
40874
+ this.outlineItems.push(item);
40875
+ }
40876
+ /** Sets the document information dictionary (`/Info`). */
40877
+ setDocumentInfo(info) {
40878
+ this.documentInfo = info;
40119
40879
  }
40120
40880
  toArrayBuffer() {
40121
40881
  const bytes = this.toUint8Array();
@@ -40132,11 +40892,69 @@ class OasisPdfWriter {
40132
40892
  this.pages,
40133
40893
  this.fonts,
40134
40894
  this.images,
40135
- this.shadings
40895
+ this.shadings,
40896
+ this.namedDestinations,
40897
+ this.outlineItems,
40898
+ this.documentInfo
40136
40899
  );
40137
40900
  }
40138
40901
  }
40139
40902
  const FOOTNOTE_BLOCK_GAP_PX = 2;
40903
+ const PDF_PRODUCER = "Oasis Editor";
40904
+ function resolveDocumentInfo(document2) {
40905
+ const metadata = document2.metadata ?? {};
40906
+ const asString = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
40907
+ return {
40908
+ title: asString(metadata.title),
40909
+ author: asString(metadata.author),
40910
+ subject: asString(metadata.subject),
40911
+ keywords: asString(metadata.keywords),
40912
+ producer: PDF_PRODUCER,
40913
+ creationDate: /* @__PURE__ */ new Date()
40914
+ };
40915
+ }
40916
+ function collectBookmarkNamesByParagraph(document2) {
40917
+ var _a2;
40918
+ const byParagraph = /* @__PURE__ */ new Map();
40919
+ const bookmarks = document2.bookmarks;
40920
+ if (!bookmarks) {
40921
+ return byParagraph;
40922
+ }
40923
+ for (const id of bookmarks.order) {
40924
+ const bookmark = bookmarks.items[id];
40925
+ const paragraphId = (_a2 = bookmark == null ? void 0 : bookmark.start) == null ? void 0 : _a2.paragraphId;
40926
+ if (!bookmark || !paragraphId) {
40927
+ continue;
40928
+ }
40929
+ const names = byParagraph.get(paragraphId) ?? [];
40930
+ names.push(bookmark.name);
40931
+ byParagraph.set(paragraphId, names);
40932
+ }
40933
+ return byParagraph;
40934
+ }
40935
+ const HEADING_DEST_PREFIX = "__oasis_heading_";
40936
+ function registerBookmarkDestinations(writer, pageIndex, originX, bookmarkNamesByParagraph, headingByParagraph) {
40937
+ if (bookmarkNamesByParagraph.size === 0 && headingByParagraph.size === 0) {
40938
+ return void 0;
40939
+ }
40940
+ return (paragraphId, topPx) => {
40941
+ const y = pxToPt$1(topPx);
40942
+ const x = pxToPt$1(originX);
40943
+ for (const name of bookmarkNamesByParagraph.get(paragraphId) ?? []) {
40944
+ writer.addNamedDestination({ name, pageIndex, x, y });
40945
+ }
40946
+ const heading = headingByParagraph.get(paragraphId);
40947
+ if (heading) {
40948
+ const destName = `${HEADING_DEST_PREFIX}${paragraphId}`;
40949
+ writer.addNamedDestination({ name: destName, pageIndex, x, y });
40950
+ writer.addOutlineItem({
40951
+ title: heading.title,
40952
+ level: heading.level,
40953
+ destName
40954
+ });
40955
+ }
40956
+ };
40957
+ }
40140
40958
  async function exportEditorDocumentToPdf(document2) {
40141
40959
  document2 = renumberImageCaptionsInDocument(document2);
40142
40960
  const fontRegistry = new PdfFontRegistry();
@@ -40144,8 +40962,16 @@ async function exportEditorDocumentToPdf(document2) {
40144
40962
  families: collectPdfFontFamilies(document2)
40145
40963
  });
40146
40964
  const writer = new OasisPdfWriter(fontRegistry.getPdfFontResources());
40965
+ writer.setDocumentInfo(resolveDocumentInfo(document2));
40147
40966
  const layout = projectDocumentLayout(document2);
40148
40967
  const listOrdinals = getListOrdinals(document2);
40968
+ const bookmarkNamesByParagraph = collectBookmarkNamesByParagraph(document2);
40969
+ const headingByParagraph = new Map(
40970
+ outlineFrom(document2).map((item) => [
40971
+ item.id,
40972
+ { level: item.level, title: item.text }
40973
+ ])
40974
+ );
40149
40975
  for (const page of layout.pages) {
40150
40976
  const width = Math.max(1, pxToPt$1(page.pageSettings.width));
40151
40977
  const height = Math.max(1, pxToPt$1(page.pageSettings.height));
@@ -40190,7 +41016,14 @@ async function exportEditorDocumentToPdf(document2) {
40190
41016
  rect.width,
40191
41017
  fontRegistry,
40192
41018
  listOrdinals,
40193
- page.pageSettings
41019
+ page.pageSettings,
41020
+ registerBookmarkDestinations(
41021
+ writer,
41022
+ pageIndex,
41023
+ rect.left,
41024
+ bookmarkNamesByParagraph,
41025
+ headingByParagraph
41026
+ )
40194
41027
  );
40195
41028
  }
40196
41029
  } else {
@@ -40204,7 +41037,14 @@ async function exportEditorDocumentToPdf(document2) {
40204
41037
  contentWidth,
40205
41038
  fontRegistry,
40206
41039
  listOrdinals,
40207
- page.pageSettings
41040
+ page.pageSettings,
41041
+ registerBookmarkDestinations(
41042
+ writer,
41043
+ pageIndex,
41044
+ originX,
41045
+ bookmarkNamesByParagraph,
41046
+ headingByParagraph
41047
+ )
40208
41048
  );
40209
41049
  }
40210
41050
  await drawBlockList(
@@ -40255,15 +41095,15 @@ async function exportEditorDocumentToPdfBlob(document2) {
40255
41095
  return new Blob([buffer], { type: "application/pdf" });
40256
41096
  }
40257
41097
  async function drawFootnoteBlockList(writer, pageIndex, blocks, footnoteReferenceIds, document2, originX, originY, contentWidth, fontRegistry, listOrdinals) {
40258
- var _a;
41098
+ var _a2;
40259
41099
  let cursorY = originY;
40260
41100
  const markerDrawn = /* @__PURE__ */ new Set();
40261
41101
  const markerByFootnoteId = new Map(
40262
41102
  footnoteReferenceIds.map((footnoteId) => {
40263
- var _a2;
41103
+ var _a3;
40264
41104
  return [
40265
41105
  footnoteId,
40266
- ((_a2 = findFootnoteReference(document2, footnoteId)) == null ? void 0 : _a2.run.text) ?? ""
41106
+ ((_a3 = findFootnoteReference(document2, footnoteId)) == null ? void 0 : _a3.run.text) ?? ""
40267
41107
  ];
40268
41108
  })
40269
41109
  );
@@ -40277,7 +41117,7 @@ async function drawFootnoteBlockList(writer, pageIndex, blocks, footnoteReferenc
40277
41117
  const firstParagraph = block.sourceBlock.type === "paragraph" ? block.sourceBlock : void 0;
40278
41118
  const styles = resolveEffectiveTextStyleForParagraph(
40279
41119
  void 0,
40280
- (_a = firstParagraph == null ? void 0 : firstParagraph.style) == null ? void 0 : _a.styleId,
41120
+ (_a2 = firstParagraph == null ? void 0 : firstParagraph.style) == null ? void 0 : _a2.styleId,
40281
41121
  document2.styles
40282
41122
  );
40283
41123
  const fontFace = fontRegistry.resolveFontFace({
@@ -40376,7 +41216,7 @@ function findImageFileFromTransfer(transfer) {
40376
41216
  return null;
40377
41217
  }
40378
41218
  function buildImportedDocumentDiagnostics(document2) {
40379
- var _a;
41219
+ var _a2;
40380
41220
  const paragraphs = getDocumentParagraphs(document2);
40381
41221
  const fontCounts = /* @__PURE__ */ new Map();
40382
41222
  const alignCounts = /* @__PURE__ */ new Map();
@@ -40394,7 +41234,7 @@ function buildImportedDocumentDiagnostics(document2) {
40394
41234
  for (const run of paragraph.runs) {
40395
41235
  const textStyle = resolveEffectiveTextStyleForParagraph(
40396
41236
  run.styles,
40397
- (_a = paragraph.style) == null ? void 0 : _a.styleId,
41237
+ (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
40398
41238
  document2.styles
40399
41239
  );
40400
41240
  const fontFamily = textStyle.fontFamily ?? "<null>";
@@ -40414,7 +41254,7 @@ function buildImportedDocumentDiagnostics(document2) {
40414
41254
  characterSpacingRuns,
40415
41255
  characterScaleRuns,
40416
41256
  firstParagraphs: paragraphs.slice(0, 30).map((paragraph, index) => {
40417
- var _a2;
41257
+ var _a3;
40418
41258
  const paragraphStyle = resolveEffectiveParagraphStyle(
40419
41259
  paragraph.style,
40420
41260
  document2.styles
@@ -40422,7 +41262,7 @@ function buildImportedDocumentDiagnostics(document2) {
40422
41262
  const firstRun = paragraph.runs[0];
40423
41263
  const textStyle = resolveEffectiveTextStyleForParagraph(
40424
41264
  firstRun == null ? void 0 : firstRun.styles,
40425
- (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
41265
+ (_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
40426
41266
  document2.styles
40427
41267
  );
40428
41268
  return {
@@ -40513,8 +41353,8 @@ function createDocumentImporter(deps) {
40513
41353
  const sections = getDocumentSectionsCanonical(document2);
40514
41354
  const canonicalBlocks = sections.reduce(
40515
41355
  (total, section) => {
40516
- var _a, _b;
40517
- return total + (((_a = section.header) == null ? void 0 : _a.length) ?? 0) + section.blocks.length + (((_b = section.footer) == null ? void 0 : _b.length) ?? 0);
41356
+ var _a2, _b2;
41357
+ return total + (((_a2 = section.header) == null ? void 0 : _a2.length) ?? 0) + section.blocks.length + (((_b2 = section.footer) == null ? void 0 : _b2.length) ?? 0);
40518
41358
  },
40519
41359
  0
40520
41360
  );
@@ -40615,8 +41455,8 @@ function applyMoveWithText(floating, fixed) {
40615
41455
  };
40616
41456
  }
40617
41457
  function isFloatingFixedPosition(floating) {
40618
- var _a;
40619
- return ((_a = floating == null ? void 0 : floating.positionV) == null ? void 0 : _a.relativeFrom) === "page";
41458
+ var _a2;
41459
+ return ((_a2 = floating == null ? void 0 : floating.positionV) == null ? void 0 : _a2.relativeFrom) === "page";
40620
41460
  }
40621
41461
  function getSelectedImageRun(state) {
40622
41462
  return getSelectedObjectRun(state, (run) => run.kind === "image");
@@ -41182,7 +42022,7 @@ function resolveCaretSlot(paragraphs, focusOffset) {
41182
42022
  };
41183
42023
  }
41184
42024
  function computeCanvasSelectionGeometry(snapshot, state) {
41185
- var _a, _b, _c, _d;
42025
+ var _a2, _b2, _c, _d;
41186
42026
  const normalized = normalizeSelection(state);
41187
42027
  const selectionBoxes = [];
41188
42028
  const surfaceRect = snapshot.surfaceRect;
@@ -41245,9 +42085,9 @@ function computeCanvasSelectionGeometry(snapshot, state) {
41245
42085
  const section = sections[activeSectionIndex];
41246
42086
  let tableBlock;
41247
42087
  if (anchorLoc.zone === "header") {
41248
- tableBlock = (_a = section == null ? void 0 : section.header) == null ? void 0 : _a[anchorLoc.blockIndex];
42088
+ tableBlock = (_a2 = section == null ? void 0 : section.header) == null ? void 0 : _a2[anchorLoc.blockIndex];
41249
42089
  } else if (anchorLoc.zone === "footer") {
41250
- tableBlock = (_b = section == null ? void 0 : section.footer) == null ? void 0 : _b[anchorLoc.blockIndex];
42090
+ tableBlock = (_b2 = section == null ? void 0 : section.footer) == null ? void 0 : _b2[anchorLoc.blockIndex];
41251
42091
  } else {
41252
42092
  tableBlock = (_c = section == null ? void 0 : section.blocks) == null ? void 0 : _c[anchorLoc.blockIndex];
41253
42093
  }
@@ -41452,9 +42292,9 @@ function areLayoutParagraphsEquivalentForRender(previous, next) {
41452
42292
  });
41453
42293
  }
41454
42294
  function canReuseLayoutBlock(previous, next) {
41455
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
42295
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
41456
42296
  return Boolean(
41457
- previous && previous.blockId === next.blockId && previous.sourceBlock === next.sourceBlock && previous.estimatedHeight === next.estimatedHeight && ((_a = previous.tableSegment) == null ? void 0 : _a.startRowIndex) === ((_b = next.tableSegment) == null ? void 0 : _b.startRowIndex) && ((_c = previous.tableSegment) == null ? void 0 : _c.endRowIndex) === ((_d = next.tableSegment) == null ? void 0 : _d.endRowIndex) && ((_e = previous.tableSegment) == null ? void 0 : _e.repeatedHeaderRowCount) === ((_f = next.tableSegment) == null ? void 0 : _f.repeatedHeaderRowCount) && sameNumberArray(
42297
+ previous && previous.blockId === next.blockId && previous.sourceBlock === next.sourceBlock && previous.estimatedHeight === next.estimatedHeight && ((_a2 = previous.tableSegment) == null ? void 0 : _a2.startRowIndex) === ((_b2 = next.tableSegment) == null ? void 0 : _b2.startRowIndex) && ((_c = previous.tableSegment) == null ? void 0 : _c.endRowIndex) === ((_d = next.tableSegment) == null ? void 0 : _d.endRowIndex) && ((_e = previous.tableSegment) == null ? void 0 : _e.repeatedHeaderRowCount) === ((_f = next.tableSegment) == null ? void 0 : _f.repeatedHeaderRowCount) && sameNumberArray(
41458
42298
  (_g = previous.tableSegment) == null ? void 0 : _g.startRowCellBlockStarts,
41459
42299
  (_h = next.tableSegment) == null ? void 0 : _h.startRowCellBlockStarts
41460
42300
  ) && sameNumberArray(
@@ -41594,7 +42434,7 @@ function useEditorLayout(props) {
41594
42434
  const canvasSnapshotProvider = createCanvasLayoutSnapshotProvider();
41595
42435
  let syncRequestId = 0;
41596
42436
  const syncInputBox = (_reason = "selection") => {
41597
- var _a;
42437
+ var _a2;
41598
42438
  const surface = props.surfaceRef();
41599
42439
  if (!surface) {
41600
42440
  setSelectionBoxes([]);
@@ -41608,7 +42448,7 @@ function useEditorLayout(props) {
41608
42448
  surface,
41609
42449
  state: props.state,
41610
42450
  documentLayout: documentLayout(),
41611
- zoomFactor: (_a = props.zoomFactor) == null ? void 0 : _a.call(props)
42451
+ zoomFactor: (_a2 = props.zoomFactor) == null ? void 0 : _a2.call(props)
41612
42452
  });
41613
42453
  if (!snapshot) {
41614
42454
  setSelectionBoxes([]);
@@ -41650,15 +42490,15 @@ function useEditorLayout(props) {
41650
42490
  return options.resolveWhenDone ? Promise.resolve() : null;
41651
42491
  };
41652
42492
  const applyInvalidation = (invalidation) => {
41653
- var _a, _b;
41654
- if ((_a = props.isImporting) == null ? void 0 : _a.call(props)) {
42493
+ var _a2, _b2;
42494
+ if ((_a2 = props.isImporting) == null ? void 0 : _a2.call(props)) {
41655
42495
  return;
41656
42496
  }
41657
42497
  if (invalidation.dirtyAll || invalidation.structureChanged) {
41658
42498
  setMeasuredBlockHeights({});
41659
42499
  setMeasuredParagraphLayouts({});
41660
42500
  bumpLayoutMetricsEpoch();
41661
- } else if ((((_b = invalidation.dirtyParagraphIds) == null ? void 0 : _b.length) ?? 0) > 0) {
42501
+ } else if ((((_b2 = invalidation.dirtyParagraphIds) == null ? void 0 : _b2.length) ?? 0) > 0) {
41662
42502
  const dirtyIds = invalidation.dirtyParagraphIds ?? [];
41663
42503
  setMeasuredParagraphLayouts(
41664
42504
  (current) => normalizeParagraphLayouts(current, dirtyIds)
@@ -41686,11 +42526,11 @@ function useEditorLayout(props) {
41686
42526
  requestInputBoxSync("selection");
41687
42527
  });
41688
42528
  createEffect(() => {
41689
- var _a;
42529
+ var _a2;
41690
42530
  props.state.document;
41691
42531
  props.state.activeSectionIndex;
41692
42532
  props.state.activeZone;
41693
- if ((_a = props.isImporting) == null ? void 0 : _a.call(props)) {
42533
+ if ((_a2 = props.isImporting) == null ? void 0 : _a2.call(props)) {
41694
42534
  return;
41695
42535
  }
41696
42536
  requestInputBoxSync("content-change");
@@ -41751,7 +42591,7 @@ function useEditorPersistence(state, onLoaded, options) {
41751
42591
  const isEnabled = () => options.enabled ?? false;
41752
42592
  const persistence = options.persistence;
41753
42593
  const debouncedSave = debounce(async (doc) => {
41754
- var _a;
42594
+ var _a2;
41755
42595
  if (!isEnabled() || !isInitialized()) return;
41756
42596
  setStatus("Saving...");
41757
42597
  try {
@@ -41759,7 +42599,7 @@ function useEditorPersistence(state, onLoaded, options) {
41759
42599
  await persistence.saveDocument(rawDoc);
41760
42600
  setStatus("Saved");
41761
42601
  } catch (err) {
41762
- (_a = options.logger) == null ? void 0 : _a.error("persistence:autosave failed", err);
42602
+ (_a2 = options.logger) == null ? void 0 : _a2.error("persistence:autosave failed", err);
41763
42603
  setStatus("Error");
41764
42604
  }
41765
42605
  }, 1e3);
@@ -41775,7 +42615,7 @@ function useEditorPersistence(state, onLoaded, options) {
41775
42615
  )
41776
42616
  );
41777
42617
  onMount(async () => {
41778
- var _a;
42618
+ var _a2;
41779
42619
  if (!isEnabled()) {
41780
42620
  setIsInitialized(true);
41781
42621
  setStatus("Saved");
@@ -41787,7 +42627,7 @@ function useEditorPersistence(state, onLoaded, options) {
41787
42627
  onLoaded(loadedDoc);
41788
42628
  }
41789
42629
  } catch (err) {
41790
- (_a = options.logger) == null ? void 0 : _a.error("persistence:load failed", err);
42630
+ (_a2 = options.logger) == null ? void 0 : _a2.error("persistence:load failed", err);
41791
42631
  } finally {
41792
42632
  setIsInitialized(true);
41793
42633
  setStatus("Saved");
@@ -41803,8 +42643,8 @@ function createEmptyEditorHistoryState() {
41803
42643
  };
41804
42644
  }
41805
42645
  function applyEditorHistoryTransaction(history, previous, next, options, now = Date.now()) {
41806
- var _a;
41807
- const canMerge = (options == null ? void 0 : options.mergeKey) !== void 0 && ((_a = history.lastTransactionMeta) == null ? void 0 : _a.mergeKey) === options.mergeKey && now - history.lastTransactionMeta.timestamp < 1e3;
42646
+ var _a2;
42647
+ const canMerge = (options == null ? void 0 : options.mergeKey) !== void 0 && ((_a2 = history.lastTransactionMeta) == null ? void 0 : _a2.mergeKey) === options.mergeKey && now - history.lastTransactionMeta.timestamp < 1e3;
41808
42648
  return {
41809
42649
  undoStack: canMerge ? history.undoStack : [...history.undoStack, previous],
41810
42650
  redoStack: [],
@@ -41965,13 +42805,13 @@ function createEditorHistoryActions(deps) {
41965
42805
  return true;
41966
42806
  };
41967
42807
  const applySelectionPreservingStructure = (nextSelection) => {
41968
- var _a;
42808
+ var _a2;
41969
42809
  const snapshot = deps.stateSnapshot();
41970
42810
  deps.applyHistoryState({
41971
42811
  ...snapshot,
41972
42812
  document: {
41973
42813
  ...snapshot.document,
41974
- sections: (_a = snapshot.document.sections) == null ? void 0 : _a.map(cloneSection)
42814
+ sections: (_a2 = snapshot.document.sections) == null ? void 0 : _a2.map(cloneSection)
41975
42815
  },
41976
42816
  selection: {
41977
42817
  anchor: { ...nextSelection.anchor },
@@ -41990,8 +42830,8 @@ function openDB(options) {
41990
42830
  return new Promise((resolve, reject) => {
41991
42831
  const request = indexedDB.open(options.name, options.version);
41992
42832
  request.onerror = () => {
41993
- var _a;
41994
- reject(new Error(`Failed to open IndexedDB: ${(_a = request.error) == null ? void 0 : _a.message}`));
42833
+ var _a2;
42834
+ reject(new Error(`Failed to open IndexedDB: ${(_a2 = request.error) == null ? void 0 : _a2.message}`));
41995
42835
  };
41996
42836
  request.onsuccess = () => {
41997
42837
  resolve(request.result);
@@ -42009,10 +42849,10 @@ function putItem(db, storeName, key, value) {
42009
42849
  const store = transaction.objectStore(storeName);
42010
42850
  const request = store.put(value, key);
42011
42851
  request.onerror = () => {
42012
- var _a;
42852
+ var _a2;
42013
42853
  reject(
42014
42854
  new Error(
42015
- `Failed to put item in ${storeName}: ${(_a = request.error) == null ? void 0 : _a.message}`
42855
+ `Failed to put item in ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
42016
42856
  )
42017
42857
  );
42018
42858
  };
@@ -42031,10 +42871,10 @@ function getItem(db, storeName, key) {
42031
42871
  const store = transaction.objectStore(storeName);
42032
42872
  const request = store.get(key);
42033
42873
  request.onerror = () => {
42034
- var _a;
42874
+ var _a2;
42035
42875
  reject(
42036
42876
  new Error(
42037
- `Failed to get item from ${storeName}: ${(_a = request.error) == null ? void 0 : _a.message}`
42877
+ `Failed to get item from ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
42038
42878
  )
42039
42879
  );
42040
42880
  };
@@ -42053,10 +42893,10 @@ function deleteItem(db, storeName, key) {
42053
42893
  const store = transaction.objectStore(storeName);
42054
42894
  const request = store.delete(key);
42055
42895
  request.onerror = () => {
42056
- var _a;
42896
+ var _a2;
42057
42897
  reject(
42058
42898
  new Error(
42059
- `Failed to delete item from ${storeName}: ${(_a = request.error) == null ? void 0 : _a.message}`
42899
+ `Failed to delete item from ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
42060
42900
  )
42061
42901
  );
42062
42902
  };
@@ -42111,7 +42951,7 @@ function createIndexedDbPersistence(options = {}) {
42111
42951
  };
42112
42952
  }
42113
42953
  function computeLayoutInvalidationFromTransaction(prev, next) {
42114
- var _a, _b, _c, _d, _e, _f;
42954
+ var _a2, _b2, _c, _d, _e, _f;
42115
42955
  if (prev === next || prev.document === next.document) {
42116
42956
  return {};
42117
42957
  }
@@ -42155,7 +42995,7 @@ function computeLayoutInvalidationFromTransaction(prev, next) {
42155
42995
  }
42156
42996
  const aImage = getRunImage(a);
42157
42997
  const bImage = getRunImage(b);
42158
- if (Boolean(aImage) !== Boolean(bImage) || ((aImage == null ? void 0 : aImage.width) ?? -1) !== ((bImage == null ? void 0 : bImage.width) ?? -1) || ((aImage == null ? void 0 : aImage.height) ?? -1) !== ((bImage == null ? void 0 : bImage.height) ?? -1) || (((_a = aImage == null ? void 0 : aImage.floating) == null ? void 0 : _a.wrap) ?? "") !== (((_b = bImage == null ? void 0 : bImage.floating) == null ? void 0 : _b.wrap) ?? "") || Boolean((_c = aImage == null ? void 0 : aImage.floating) == null ? void 0 : _c.behindDoc) !== Boolean((_d = bImage == null ? void 0 : bImage.floating) == null ? void 0 : _d.behindDoc) || (((_e = aImage == null ? void 0 : aImage.wrapPolygon) == null ? void 0 : _e.length) ?? -1) !== (((_f = bImage == null ? void 0 : bImage.wrapPolygon) == null ? void 0 : _f.length) ?? -1)) {
42998
+ if (Boolean(aImage) !== Boolean(bImage) || ((aImage == null ? void 0 : aImage.width) ?? -1) !== ((bImage == null ? void 0 : bImage.width) ?? -1) || ((aImage == null ? void 0 : aImage.height) ?? -1) !== ((bImage == null ? void 0 : bImage.height) ?? -1) || (((_a2 = aImage == null ? void 0 : aImage.floating) == null ? void 0 : _a2.wrap) ?? "") !== (((_b2 = bImage == null ? void 0 : bImage.floating) == null ? void 0 : _b2.wrap) ?? "") || Boolean((_c = aImage == null ? void 0 : aImage.floating) == null ? void 0 : _c.behindDoc) !== Boolean((_d = bImage == null ? void 0 : bImage.floating) == null ? void 0 : _d.behindDoc) || (((_e = aImage == null ? void 0 : aImage.wrapPolygon) == null ? void 0 : _e.length) ?? -1) !== (((_f = bImage == null ? void 0 : bImage.wrapPolygon) == null ? void 0 : _f.length) ?? -1)) {
42159
42999
  changed = true;
42160
43000
  break;
42161
43001
  }
@@ -42222,7 +43062,7 @@ function useEditorTransactions(ctx) {
42222
43062
  }
42223
43063
  function createEditorChangeBroadcast(deps) {
42224
43064
  createEffect(() => {
42225
- var _a;
43065
+ var _a2;
42226
43066
  deps.state.document;
42227
43067
  deps.state.selection;
42228
43068
  deps.state.activeSectionIndex;
@@ -42232,7 +43072,7 @@ function createEditorChangeBroadcast(deps) {
42232
43072
  return;
42233
43073
  }
42234
43074
  const snapshot = deps.cloneState(deps.getStateSnapshot());
42235
- (_a = deps.getOnStateChange()) == null ? void 0 : _a(snapshot);
43075
+ (_a2 = deps.getOnStateChange()) == null ? void 0 : _a2(snapshot);
42236
43076
  deps.emit("change", snapshot);
42237
43077
  deps.emit("documentChange", snapshot.document);
42238
43078
  deps.emit("selectionChange", snapshot.selection);
@@ -42269,8 +43109,8 @@ function createEditorDocumentRuntime(deps) {
42269
43109
  logger
42270
43110
  });
42271
43111
  const isImportInProgress = () => {
42272
- var _a, _b;
42273
- return ((_a = docIO.importProgress()) == null ? void 0 : _a.phase) !== "done" && ((_b = docIO.importProgress()) == null ? void 0 : _b.phase) !== "error" && docIO.importProgress() !== null;
43112
+ var _a2, _b2;
43113
+ return ((_a2 = docIO.importProgress()) == null ? void 0 : _a2.phase) !== "done" && ((_b2 = docIO.importProgress()) == null ? void 0 : _b2.phase) !== "error" && docIO.importProgress() !== null;
42274
43114
  };
42275
43115
  const {
42276
43116
  measuredBlockHeights,
@@ -42548,7 +43388,7 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
42548
43388
  return {
42549
43389
  ...cloneParagraph(candidate),
42550
43390
  runs: candidate.runs.map((run) => {
42551
- var _a;
43391
+ var _a2;
42552
43392
  if (run.id !== targetRun.id || run.kind !== "textBox") {
42553
43393
  return cloneRun(run);
42554
43394
  }
@@ -42558,7 +43398,7 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
42558
43398
  width: nextWidth,
42559
43399
  height: nextHeight
42560
43400
  };
42561
- if (changesHeight && ((_a = textBox.body) == null ? void 0 : _a.autoFit)) {
43401
+ if (changesHeight && ((_a2 = textBox.body) == null ? void 0 : _a2.autoFit)) {
42562
43402
  nextTextBox.body = { ...textBox.body, autoFit: false };
42563
43403
  }
42564
43404
  if (textBox.floating) {
@@ -42656,7 +43496,7 @@ const updateBlocksInCurrentSection = (current, blocks, zone = "main") => {
42656
43496
  };
42657
43497
  };
42658
43498
  const applyTableAwareParagraphEdit = (current, getTargetBlocks, edit) => {
42659
- var _a;
43499
+ var _a2;
42660
43500
  const location = findParagraphTableLocation(
42661
43501
  current.document,
42662
43502
  current.selection.focus.paragraphId,
@@ -42677,7 +43517,7 @@ const applyTableAwareParagraphEdit = (current, getTargetBlocks, edit) => {
42677
43517
  (block, i) => i === location.blockIndex ? clonedTable : block
42678
43518
  );
42679
43519
  const tableBlock = clonedTable;
42680
- const targetCell = (_a = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a.cells[location.cellIndex];
43520
+ const targetCell = (_a2 = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
42681
43521
  if (!targetCell) {
42682
43522
  return edit(current);
42683
43523
  }
@@ -42717,7 +43557,7 @@ function createTableOpsGuards(deps) {
42717
43557
  return Boolean(range && range.endCellIndex > range.startCellIndex);
42718
43558
  };
42719
43559
  const canSplitSelectedTableCell = (current) => {
42720
- var _a;
43560
+ var _a2;
42721
43561
  const location = findParagraphTableLocation(
42722
43562
  current.document,
42723
43563
  current.selection.focus.paragraphId,
@@ -42731,11 +43571,11 @@ function createTableOpsGuards(deps) {
42731
43571
  if (!block || block.type !== "table") {
42732
43572
  return false;
42733
43573
  }
42734
- const cell = (_a = block.rows[location.rowIndex]) == null ? void 0 : _a.cells[location.cellIndex];
43574
+ const cell = (_a2 = block.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
42735
43575
  return Boolean(((cell == null ? void 0 : cell.colSpan) ?? 1) > 1);
42736
43576
  };
42737
43577
  const canMergeSelectedTableRows = (current) => {
42738
- var _a;
43578
+ var _a2;
42739
43579
  const range = deps.resolveVerticalTableCellRange(current);
42740
43580
  if (!range) {
42741
43581
  return false;
@@ -42746,7 +43586,7 @@ function createTableOpsGuards(deps) {
42746
43586
  return false;
42747
43587
  }
42748
43588
  for (let rowIndex = range.startRowIndex; rowIndex <= range.endRowIndex; rowIndex += 1) {
42749
- const cell = (_a = tableBlock.rows[rowIndex]) == null ? void 0 : _a.cells[range.cellIndex];
43589
+ const cell = (_a2 = tableBlock.rows[rowIndex]) == null ? void 0 : _a2.cells[range.cellIndex];
42750
43590
  if (!cell || cell.vMerge === "continue" || cell.blocks.length !== 1) {
42751
43591
  return false;
42752
43592
  }
@@ -42757,7 +43597,7 @@ function createTableOpsGuards(deps) {
42757
43597
  return canMergeSelectedTableCells(current) || canMergeSelectedTableRows(current);
42758
43598
  };
42759
43599
  const canSplitSelectedTableCellVertically = (current) => {
42760
- var _a;
43600
+ var _a2;
42761
43601
  const location = findParagraphTableLocation(
42762
43602
  current.document,
42763
43603
  current.selection.focus.paragraphId,
@@ -42771,7 +43611,7 @@ function createTableOpsGuards(deps) {
42771
43611
  if (!block || block.type !== "table") {
42772
43612
  return false;
42773
43613
  }
42774
- const cell = (_a = block.rows[location.rowIndex]) == null ? void 0 : _a.cells[location.cellIndex];
43614
+ const cell = (_a2 = block.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
42775
43615
  return Boolean(((cell == null ? void 0 : cell.rowSpan) ?? 1) > 1 && (cell == null ? void 0 : cell.vMerge) === "restart");
42776
43616
  };
42777
43617
  const canSplitSelectedTable = (current) => {
@@ -42868,11 +43708,11 @@ function getSelectionTableContext(current, deps) {
42868
43708
  }
42869
43709
  function createTableSelectionResolvers(deps) {
42870
43710
  const resolveTableCellRangeSelection = (current) => {
42871
- var _a, _b, _c, _d, _e;
43711
+ var _a2, _b2, _c, _d, _e;
42872
43712
  const selection = current.selection;
42873
43713
  const context = getSelectionTableContext(current, deps);
42874
43714
  if (!context || context.anchorLocation.rowIndex === context.focusLocation.rowIndex && context.anchorLocation.cellIndex === context.focusLocation.cellIndex) {
42875
- (_a = deps.logger) == null ? void 0 : _a.debug(
43715
+ (_a2 = deps.logger) == null ? void 0 : _a2.debug(
42876
43716
  `resolveTableCellRangeSelection: no expansion (anchor=${selection.anchor.paragraphId} focus=${selection.focus.paragraphId})`
42877
43717
  );
42878
43718
  return null;
@@ -42893,7 +43733,7 @@ function createTableSelectionResolvers(deps) {
42893
43733
  context.anchorLocation.cellIndex,
42894
43734
  context.focusLocation.cellIndex
42895
43735
  );
42896
- (_b = deps.logger) == null ? void 0 : _b.info(
43736
+ (_b2 = deps.logger) == null ? void 0 : _b2.info(
42897
43737
  `resolveTableCellRangeSelection: expanding r${context.anchorLocation.rowIndex}:c${context.anchorLocation.cellIndex}->r${context.focusLocation.rowIndex}:c${context.focusLocation.cellIndex} (anchor=${selection.anchor.paragraphId} focus=${selection.focus.paragraphId}) range=[rows ${rangeStartRow}..${rangeEndRow}, cells ${rangeStartCell}..${rangeEndCell}]`
42898
43738
  );
42899
43739
  const startLocation = compareCellLocations(context.anchorCell, context.focusCell) <= 0 ? context.anchorLocation : context.focusLocation;
@@ -43169,7 +44009,7 @@ function createTableCellSpanOperations(deps) {
43169
44009
  return current;
43170
44010
  };
43171
44011
  const splitSelectedTableCellVertically = (current) => {
43172
- var _a;
44012
+ var _a2;
43173
44013
  const location = findParagraphTableLocation(
43174
44014
  current.document,
43175
44015
  current.selection.focus.paragraphId,
@@ -43183,7 +44023,7 @@ function createTableCellSpanOperations(deps) {
43183
44023
  if (!tableBlock || tableBlock.type !== "table") {
43184
44024
  return current;
43185
44025
  }
43186
- const cell = (_a = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a.cells[location.cellIndex];
44026
+ const cell = (_a2 = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
43187
44027
  const span = Math.max(1, (cell == null ? void 0 : cell.rowSpan) ?? 1);
43188
44028
  if (!cell || span <= 1 || cell.vMerge !== "restart") {
43189
44029
  return current;
@@ -43213,8 +44053,8 @@ function createTableCellSpanOperations(deps) {
43213
44053
  previousCells: [
43214
44054
  previousCell,
43215
44055
  ...Array.from({ length: span - 1 }, (_, offset) => {
43216
- var _a2;
43217
- const prior = (_a2 = tableBlock.rows[location.rowIndex + offset + 1]) == null ? void 0 : _a2.cells[location.cellIndex];
44056
+ var _a3;
44057
+ const prior = (_a3 = tableBlock.rows[location.rowIndex + offset + 1]) == null ? void 0 : _a3.cells[location.cellIndex];
43218
44058
  return prior ? cloneCellSnapshot(prior) : createEditorTableCell([], preservedColSpan);
43219
44059
  })
43220
44060
  ]
@@ -43249,7 +44089,7 @@ function createTableCellSpanOperations(deps) {
43249
44089
  };
43250
44090
  };
43251
44091
  const splitSelectedTableCell = (current) => {
43252
- var _a;
44092
+ var _a2;
43253
44093
  const location = findParagraphTableLocation(
43254
44094
  current.document,
43255
44095
  current.selection.focus.paragraphId,
@@ -43305,7 +44145,7 @@ function createTableCellSpanOperations(deps) {
43305
44145
  )
43306
44146
  ];
43307
44147
  row.cells.splice(location.cellIndex, 1, ...nextCells);
43308
- const nextParagraph = (_a = nextCells[0]) == null ? void 0 : _a.blocks[0];
44148
+ const nextParagraph = (_a2 = nextCells[0]) == null ? void 0 : _a2.blocks[0];
43309
44149
  if (!nextParagraph) {
43310
44150
  return current;
43311
44151
  }
@@ -43342,7 +44182,7 @@ function createTableCellSpanOperations(deps) {
43342
44182
  }
43343
44183
  function createTableRowColumnOperations(deps) {
43344
44184
  const insertSelectedTableRow = (current, direction) => {
43345
- var _a, _b;
44185
+ var _a2, _b2;
43346
44186
  const location = findParagraphTableLocation(
43347
44187
  current.document,
43348
44188
  current.selection.focus.paragraphId,
@@ -43418,9 +44258,9 @@ function createTableRowColumnOperations(deps) {
43418
44258
  tableBlock.rows.splice(insertIndex, 0, blankRow);
43419
44259
  const targetVisualColumn = (selectedEntry == null ? void 0 : selectedEntry.visualColumnIndex) ?? location.cellIndex;
43420
44260
  const targetCell2 = findCellAtVisualColumn(blankRow, targetVisualColumn);
43421
- const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? ((_a = blankRow.cells.find(
44261
+ const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? ((_a2 = blankRow.cells.find(
43422
44262
  (cell) => cell.vMerge !== "continue" && cell.blocks[0]
43423
- )) == null ? void 0 : _a.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
44263
+ )) == null ? void 0 : _a2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
43424
44264
  if (!nextParagraph2) {
43425
44265
  return updateBlocksInCurrentSection(
43426
44266
  current,
@@ -43460,9 +44300,9 @@ function createTableRowColumnOperations(deps) {
43460
44300
  }
43461
44301
  tableBlock.rows.splice(insertIndex, 0, blankRow);
43462
44302
  const targetCell = blankRow.cells[Math.min(location.cellIndex, blankRow.cells.length - 1)];
43463
- const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_b = blankRow.cells.find(
44303
+ const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_b2 = blankRow.cells.find(
43464
44304
  (cell) => cell.vMerge !== "continue" && cell.blocks[0]
43465
- )) == null ? void 0 : _b.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
44305
+ )) == null ? void 0 : _b2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
43466
44306
  if (!nextParagraph) {
43467
44307
  return updateBlocksInCurrentSection(current, targetBlocks, location.zone);
43468
44308
  }
@@ -43565,7 +44405,7 @@ function createTableRowColumnOperations(deps) {
43565
44405
  };
43566
44406
  };
43567
44407
  const insertSelectedTableColumn = (current, direction) => {
43568
- var _a;
44408
+ var _a2;
43569
44409
  const location = findParagraphTableLocation(
43570
44410
  current.document,
43571
44411
  current.selection.focus.paragraphId,
@@ -43672,7 +44512,7 @@ function createTableRowColumnOperations(deps) {
43672
44512
  const insertIndex = Math.max(
43673
44513
  0,
43674
44514
  Math.min(
43675
- ((_a = tableBlock.rows[0]) == null ? void 0 : _a.cells.length) ?? 0,
44515
+ ((_a2 = tableBlock.rows[0]) == null ? void 0 : _a2.cells.length) ?? 0,
43676
44516
  location.cellIndex + (direction > 0 ? 1 : 0)
43677
44517
  )
43678
44518
  );
@@ -43708,7 +44548,7 @@ function createTableRowColumnOperations(deps) {
43708
44548
  };
43709
44549
  };
43710
44550
  const deleteSelectedTableColumn = (current) => {
43711
- var _a;
44551
+ var _a2;
43712
44552
  const location = findParagraphTableLocation(
43713
44553
  current.document,
43714
44554
  current.selection.focus.paragraphId,
@@ -43802,7 +44642,7 @@ function createTableRowColumnOperations(deps) {
43802
44642
  }
43803
44643
  };
43804
44644
  }
43805
- if (((_a = tableBlock.rows[0]) == null ? void 0 : _a.cells.length) <= 1) {
44645
+ if (((_a2 = tableBlock.rows[0]) == null ? void 0 : _a2.cells.length) <= 1) {
43806
44646
  return current;
43807
44647
  }
43808
44648
  for (const row of tableBlock.rows) {
@@ -43847,19 +44687,19 @@ function createTableSelectionAwareCommands(deps) {
43847
44687
  };
43848
44688
  const applySelectionAwareCommand = (command, logPrefix) => {
43849
44689
  deps.applyTransactionalState((current) => {
43850
- var _a, _b, _c;
44690
+ var _a2, _b2, _c;
43851
44691
  const selection = deps.resolveSelectedTableCells(current);
43852
44692
  if (!selection || selection.cells.length <= 1) {
43853
44693
  const expanded = withExpandedTableCellSelection(current);
43854
44694
  if (expanded !== current) {
43855
- (_a = deps.logger) == null ? void 0 : _a.info(
44695
+ (_a2 = deps.logger) == null ? void 0 : _a2.info(
43856
44696
  `${logPrefix}: expanded selection to ${expanded.selection.anchor.paragraphId}[${expanded.selection.anchor.offset}]..${expanded.selection.focus.paragraphId}[${expanded.selection.focus.offset}]`
43857
44697
  );
43858
44698
  }
43859
44699
  return command(expanded);
43860
44700
  }
43861
44701
  const { blockIndex, cells, zone } = selection;
43862
- (_b = deps.logger) == null ? void 0 : _b.info(
44702
+ (_b2 = deps.logger) == null ? void 0 : _b2.info(
43863
44703
  `${logPrefix}: multi-cell selection in table block ${blockIndex} (${cells.length} cells) in zone ${zone}`
43864
44704
  );
43865
44705
  const allParagraphs = [];
@@ -44004,8 +44844,8 @@ function createEditorTableOperations(deps) {
44004
44844
  logger: deps.logger
44005
44845
  });
44006
44846
  const insertTableCommand = (rows, cols) => {
44007
- var _a;
44008
- (_a = deps.logger) == null ? void 0 : _a.info(`insertTableCommand: ${rows}x${cols}`);
44847
+ var _a2;
44848
+ (_a2 = deps.logger) == null ? void 0 : _a2.info(`insertTableCommand: ${rows}x${cols}`);
44009
44849
  deps.applyTransactionalState(
44010
44850
  (current) => insertTableAtSelection(current, rows, cols),
44011
44851
  {
@@ -44069,12 +44909,12 @@ function createResizeSession(adapter, deps) {
44069
44909
  }
44070
44910
  });
44071
44911
  const handleMouseMove = (event) => {
44072
- var _a;
44912
+ var _a2;
44073
44913
  const resize = active;
44074
44914
  if (!resize) {
44075
44915
  return;
44076
44916
  }
44077
- const z = ((_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)) ?? 1;
44917
+ const z = ((_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)) ?? 1;
44078
44918
  const deltaX = (event.clientX - resize.startClientX) / z;
44079
44919
  const deltaY = (event.clientY - resize.startClientY) / z;
44080
44920
  const maxWidth = adapter.getMaxWidth(deps.state, resize.paragraphId);
@@ -44973,7 +45813,7 @@ function resolveImageAtPoint(snapshot, pageIndex, zone, clientX, clientY, pierce
44973
45813
  return null;
44974
45814
  }
44975
45815
  function resolveCanvasSurfaceHitAtPoint(options) {
44976
- var _a, _b, _c;
45816
+ var _a2, _b2, _c;
44977
45817
  const { snapshot, state } = options;
44978
45818
  const pierce = options.pierce ?? false;
44979
45819
  const zoomFactor = options.zoomFactor && options.zoomFactor > 0 ? options.zoomFactor : 1;
@@ -45015,7 +45855,7 @@ function resolveCanvasSurfaceHitAtPoint(options) {
45015
45855
  position: position2,
45016
45856
  source: "canvas-layout",
45017
45857
  resolvedFromParagraph: true,
45018
- tableCellAnchorPosition: (_a = paragraphSegment.tableCell) == null ? void 0 : _a.anchorPosition,
45858
+ tableCellAnchorPosition: (_a2 = paragraphSegment.tableCell) == null ? void 0 : _a2.anchorPosition,
45019
45859
  caretViewport: {
45020
45860
  left: textBoxHit.left,
45021
45861
  top: textBoxHit.top,
@@ -45064,7 +45904,7 @@ function resolveCanvasSurfaceHitAtPoint(options) {
45064
45904
  position: position2,
45065
45905
  source: "canvas-layout",
45066
45906
  resolvedFromParagraph: true,
45067
- tableCellAnchorPosition: (_b = paragraphSegment.tableCell) == null ? void 0 : _b.anchorPosition,
45907
+ tableCellAnchorPosition: (_b2 = paragraphSegment.tableCell) == null ? void 0 : _b2.anchorPosition,
45068
45908
  caretViewport: {
45069
45909
  left: imageHit.left,
45070
45910
  top: imageHit.top,
@@ -45407,20 +46247,20 @@ function createEditorLayoutOptionsController(deps) {
45407
46247
  }
45408
46248
  function createEditorClipboardController(deps) {
45409
46249
  const handleCopy = (event) => {
45410
- var _a, _b;
46250
+ var _a2, _b2;
45411
46251
  const text = getSelectedText(deps.state());
45412
46252
  if (text.length === 0) {
45413
46253
  return;
45414
46254
  }
45415
46255
  event.preventDefault();
45416
- (_a = event.clipboardData) == null ? void 0 : _a.setData("text/plain", text);
45417
- (_b = event.clipboardData) == null ? void 0 : _b.setData(
46256
+ (_a2 = event.clipboardData) == null ? void 0 : _a2.setData("text/plain", text);
46257
+ (_b2 = event.clipboardData) == null ? void 0 : _b2.setData(
45418
46258
  "text/html",
45419
46259
  serializeEditorSelectionToHtml(deps.state())
45420
46260
  );
45421
46261
  };
45422
46262
  const handleCut = (event) => {
45423
- var _a, _b;
46263
+ var _a2, _b2;
45424
46264
  if (deps.isReadOnly()) {
45425
46265
  event.preventDefault();
45426
46266
  return;
@@ -45430,8 +46270,8 @@ function createEditorClipboardController(deps) {
45430
46270
  return;
45431
46271
  }
45432
46272
  event.preventDefault();
45433
- (_a = event.clipboardData) == null ? void 0 : _a.setData("text/plain", text);
45434
- (_b = event.clipboardData) == null ? void 0 : _b.setData(
46273
+ (_a2 = event.clipboardData) == null ? void 0 : _a2.setData("text/plain", text);
46274
+ (_b2 = event.clipboardData) == null ? void 0 : _b2.setData(
45435
46275
  "text/html",
45436
46276
  serializeEditorSelectionToHtml(deps.state())
45437
46277
  );
@@ -45446,14 +46286,14 @@ function createEditorClipboardController(deps) {
45446
46286
  deps.focusInput();
45447
46287
  };
45448
46288
  const handlePaste = (event) => {
45449
- var _a, _b, _c;
46289
+ var _a2, _b2, _c;
45450
46290
  if (deps.isReadOnly()) {
45451
46291
  event.preventDefault();
45452
46292
  return;
45453
46293
  }
45454
46294
  if (deps.forcePlainTextPaste()) {
45455
46295
  deps.setForcePlainTextPaste(false);
45456
- const text2 = ((_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain")) ?? "";
46296
+ const text2 = ((_a2 = event.clipboardData) == null ? void 0 : _a2.getData("text/plain")) ?? "";
45457
46297
  if (text2.length === 0) {
45458
46298
  event.preventDefault();
45459
46299
  return;
@@ -45481,7 +46321,7 @@ function createEditorClipboardController(deps) {
45481
46321
  deps.focusInput();
45482
46322
  return;
45483
46323
  }
45484
- const html = ((_b = event.clipboardData) == null ? void 0 : _b.getData("text/html")) ?? "";
46324
+ const html = ((_b2 = event.clipboardData) == null ? void 0 : _b2.getData("text/html")) ?? "";
45485
46325
  const paragraphs = parseEditorClipboardHtmlWithDom(html);
45486
46326
  if (paragraphs.length > 0) {
45487
46327
  event.preventDefault();
@@ -45754,17 +46594,17 @@ const CONTENT_MIN_WIDTH_GUARD_PX = 12;
45754
46594
  const CONTENT_MIN_HEIGHT_GUARD_PX = 4;
45755
46595
  const DEFAULT_CELL_PADDING_LEFT_RIGHT_PX = 7.2;
45756
46596
  function resolveHorizontalCellChromePx(cell) {
45757
- var _a, _b, _c, _d, _e;
45758
- const padding = typeof ((_a = cell.style) == null ? void 0 : _a.padding) === "number" && Number.isFinite(cell.style.padding) ? Math.max(0, ptToPx(cell.style.padding)) * 2 : Math.max(
46597
+ var _a2, _b2, _c, _d, _e;
46598
+ const padding = typeof ((_a2 = cell.style) == null ? void 0 : _a2.padding) === "number" && Number.isFinite(cell.style.padding) ? Math.max(0, ptToPx(cell.style.padding)) * 2 : Math.max(
45759
46599
  0,
45760
- (((_b = cell.style) == null ? void 0 : _b.paddingLeft) !== void 0 ? ptToPx(cell.style.paddingLeft) : DEFAULT_CELL_PADDING_LEFT_RIGHT_PX) + (((_c = cell.style) == null ? void 0 : _c.paddingRight) !== void 0 ? ptToPx(cell.style.paddingRight) : DEFAULT_CELL_PADDING_LEFT_RIGHT_PX)
46600
+ (((_b2 = cell.style) == null ? void 0 : _b2.paddingLeft) !== void 0 ? ptToPx(cell.style.paddingLeft) : DEFAULT_CELL_PADDING_LEFT_RIGHT_PX) + (((_c = cell.style) == null ? void 0 : _c.paddingRight) !== void 0 ? ptToPx(cell.style.paddingRight) : DEFAULT_CELL_PADDING_LEFT_RIGHT_PX)
45761
46601
  );
45762
46602
  const borderLeft = ((_d = cell.style) == null ? void 0 : _d.borderLeft) ? Math.max(0, ptToPx(cell.style.borderLeft.width)) : 1;
45763
46603
  const borderRight = ((_e = cell.style) == null ? void 0 : _e.borderRight) ? Math.max(0, ptToPx(cell.style.borderRight.width)) : 1;
45764
46604
  return padding + borderLeft + borderRight;
45765
46605
  }
45766
46606
  function resolveRowHeightsPx(tableNode, tableLayout, geometry) {
45767
- var _a, _b;
46607
+ var _a2, _b2;
45768
46608
  const rowCount = Math.max(1, tableNode.rows.length);
45769
46609
  const baseRowHeight = geometry.bounds.height / rowCount;
45770
46610
  const rowHeights = Array(rowCount).fill(baseRowHeight);
@@ -45774,7 +46614,7 @@ function resolveRowHeightsPx(tableNode, tableLayout, geometry) {
45774
46614
  )
45775
46615
  );
45776
46616
  for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) {
45777
- const explicitPt = parseSizeToPt((_b = (_a = tableNode.rows[rowIndex]) == null ? void 0 : _a.style) == null ? void 0 : _b.height);
46617
+ const explicitPt = parseSizeToPt((_b2 = (_a2 = tableNode.rows[rowIndex]) == null ? void 0 : _a2.style) == null ? void 0 : _b2.height);
45778
46618
  if (explicitPt !== null) {
45779
46619
  rowHeights[rowIndex] = Math.max(1, ptToPx(explicitPt));
45780
46620
  continue;
@@ -45864,7 +46704,7 @@ function resolveMinRowHeightPx(tableNode, tableLayout, geometry, targetRowIndex)
45864
46704
  return Math.max(minFloor, minHeight);
45865
46705
  }
45866
46706
  function resolveMinColumnWidthsPx(state, tableNode, tableLayout, geometry) {
45867
- var _a;
46707
+ var _a2;
45868
46708
  const minFloor = ptToPx(MIN_TABLE_SIZE_PT);
45869
46709
  const result = {};
45870
46710
  const geometryByKey = new Map(
@@ -45878,7 +46718,7 @@ function resolveMinColumnWidthsPx(state, tableNode, tableLayout, geometry) {
45878
46718
  `${entry.rowIndex}:${entry.cellIndex}`
45879
46719
  );
45880
46720
  if (!geometryCell) continue;
45881
- const cell = (_a = tableNode.rows[entry.rowIndex]) == null ? void 0 : _a.cells[entry.cellIndex];
46721
+ const cell = (_a2 = tableNode.rows[entry.rowIndex]) == null ? void 0 : _a2.cells[entry.cellIndex];
45882
46722
  if (!cell) continue;
45883
46723
  const visualCol = entry.visualColumnIndex;
45884
46724
  const currentMin = result[visualCol] ?? minFloor;
@@ -45910,7 +46750,7 @@ function applyRowResize(state, resize, delta) {
45910
46750
  return setTableRowHeight(state, resize.tableId, resize.index, newSizePt);
45911
46751
  }
45912
46752
  function applyColumnResize(state, resize, delta) {
45913
- var _a;
46753
+ var _a2;
45914
46754
  if (resize.type !== "column") return state;
45915
46755
  const deltaPt = pxToPt(delta);
45916
46756
  const maxColumnIndex = resize.maxColumnIndex ?? resize.index;
@@ -45976,7 +46816,7 @@ function applyColumnResize(state, resize, delta) {
45976
46816
  0
45977
46817
  );
45978
46818
  const tableNode = getTableById(state, resize.tableId);
45979
- const currentTableWidthPt = parseSizeToPt((_a = tableNode == null ? void 0 : tableNode.style) == null ? void 0 : _a.width);
46819
+ const currentTableWidthPt = parseSizeToPt((_a2 = tableNode == null ? void 0 : tableNode.style) == null ? void 0 : _a2.width);
45980
46820
  const tableWidthToPersist = isLastColumn ? tableWidthPt : currentTableWidthPt !== null ? currentTableWidthPt : void 0;
45981
46821
  return setTableColumnWidths(
45982
46822
  state,
@@ -46026,7 +46866,7 @@ const DRAG_THRESHOLD_PX = 2;
46026
46866
  function createEditorTableResize(deps) {
46027
46867
  const [resizing, setResizing] = createSignal(null);
46028
46868
  const handleMouseMove = (event) => {
46029
- var _a;
46869
+ var _a2;
46030
46870
  if (resizing()) {
46031
46871
  setActiveCursorClass(resizing().type === "column");
46032
46872
  return;
@@ -46042,7 +46882,7 @@ function createEditorTableResize(deps) {
46042
46882
  deps.state(),
46043
46883
  deps.documentLayout(),
46044
46884
  deps.canvasSnapshotProvider,
46045
- (_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)
46885
+ (_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
46046
46886
  );
46047
46887
  if (!info) {
46048
46888
  clearResizeCursorClasses();
@@ -46051,7 +46891,7 @@ function createEditorTableResize(deps) {
46051
46891
  setHoverCursorClass(info.side === "left" || info.side === "right");
46052
46892
  };
46053
46893
  const handleMouseDown = (event) => {
46054
- var _a, _b;
46894
+ var _a2, _b2;
46055
46895
  const surface = deps.surfaceRef();
46056
46896
  if (!surface) return false;
46057
46897
  const info = findTableResizeHoverInfo(
@@ -46060,7 +46900,7 @@ function createEditorTableResize(deps) {
46060
46900
  deps.state(),
46061
46901
  deps.documentLayout(),
46062
46902
  deps.canvasSnapshotProvider,
46063
- (_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)
46903
+ (_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
46064
46904
  );
46065
46905
  if (!info) return false;
46066
46906
  const state = deps.state();
@@ -46092,7 +46932,7 @@ function createEditorTableResize(deps) {
46092
46932
  maxColumnIndex,
46093
46933
  minColumnWidthsPx,
46094
46934
  resizeFromLeftEdge: isLeftTableEdge,
46095
- initialTableIndentLeftPt: parseSizeToPt((_b = info.tableNode.style) == null ? void 0 : _b.indentLeft) ?? 0,
46935
+ initialTableIndentLeftPt: parseSizeToPt((_b2 = info.tableNode.style) == null ? void 0 : _b2.indentLeft) ?? 0,
46096
46936
  guideBounds: getGuideBounds(deps.viewportRef)
46097
46937
  });
46098
46938
  setActiveCursorClass(true);
@@ -46146,10 +46986,10 @@ function createEditorTableResize(deps) {
46146
46986
  setActiveCursorClass(currentResizing.type === "column");
46147
46987
  };
46148
46988
  const handleWindowMouseUp = (event) => {
46149
- var _a;
46989
+ var _a2;
46150
46990
  const currentResizing = resizing();
46151
46991
  if (!currentResizing) return;
46152
- const z = ((_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)) ?? 1;
46992
+ const z = ((_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)) ?? 1;
46153
46993
  const delta = ((currentResizing.type === "column" ? event.clientX : event.clientY) - currentResizing.initialPos) / z;
46154
46994
  if (Math.abs(delta) >= DRAG_THRESHOLD_PX) {
46155
46995
  deps.applyTransactionalState((current) => {
@@ -46188,7 +47028,7 @@ function createEditorTableDrag(deps) {
46188
47028
  document.body.style.cursor = "";
46189
47029
  };
46190
47030
  const handleMouseMove = (event) => {
46191
- var _a;
47031
+ var _a2;
46192
47032
  setMousePos({ x: event.clientX, y: event.clientY });
46193
47033
  if (!dragging()) {
46194
47034
  const delta = Math.abs(event.clientY - startClientY());
@@ -46204,7 +47044,7 @@ function createEditorTableDrag(deps) {
46204
47044
  event.clientX,
46205
47045
  event.clientY
46206
47046
  );
46207
- const tableId = (_a = draggedTableInfo()) == null ? void 0 : _a.tableId;
47047
+ const tableId = (_a2 = draggedTableInfo()) == null ? void 0 : _a2.tableId;
46208
47048
  if (pos && tableId) {
46209
47049
  const state = deps.state();
46210
47050
  const location = findParagraphTableLocation(
@@ -46233,7 +47073,7 @@ function createEditorTableDrag(deps) {
46233
47073
  const tableId = info == null ? void 0 : info.tableId;
46234
47074
  if (tableId) {
46235
47075
  deps.applyTransactionalState((current) => {
46236
- var _a;
47076
+ var _a2;
46237
47077
  const findTable = () => {
46238
47078
  for (const zone of ["main", "header", "footer"]) {
46239
47079
  const blocks = getEditableBlocksForZone(current, zone);
@@ -46245,7 +47085,7 @@ function createEditorTableDrag(deps) {
46245
47085
  return void 0;
46246
47086
  };
46247
47087
  const table = findTable();
46248
- if ((table == null ? void 0 : table.type) === "table" && ((_a = table.style) == null ? void 0 : _a.floating)) {
47088
+ if ((table == null ? void 0 : table.type) === "table" && ((_a2 = table.style) == null ? void 0 : _a2.floating)) {
46249
47089
  const floating = table.style.floating;
46250
47090
  const pointsPerPixel = 72 / 96;
46251
47091
  return setActiveTableStyleValue(current, tableId, "floating", {
@@ -46362,6 +47202,8 @@ function findNextWordBoundary(text, offset) {
46362
47202
  }
46363
47203
  return index;
46364
47204
  }
47205
+ const REUSE_MOUSE_DOWN_HIT_MAX_AGE_MS = 600;
47206
+ const REUSE_MOUSE_DOWN_HIT_MAX_DISTANCE_PX = 8;
46365
47207
  function resolveTripleClickParagraphRange(state, paragraph, targetZone) {
46366
47208
  const zoneParagraphs = getDocumentParagraphs(state.document).filter(
46367
47209
  (candidate) => {
@@ -46404,9 +47246,9 @@ function createEditorSurfaceEvents(deps) {
46404
47246
  globalThis.clearTimeout(handle);
46405
47247
  };
46406
47248
  const applyWithZone = (state, targetZone, newState, targetPosition) => {
46407
- var _a;
47249
+ var _a2;
46408
47250
  const isZoneTransition = targetZone !== (state.activeZone ?? "main");
46409
- const targetFootnoteId = targetZone === "footnote" && targetPosition ? (_a = findParagraphLocation(newState.document, targetPosition.paragraphId)) == null ? void 0 : _a.footnoteId : void 0;
47251
+ const targetFootnoteId = targetZone === "footnote" && targetPosition ? (_a2 = findParagraphLocation(newState.document, targetPosition.paragraphId)) == null ? void 0 : _a2.footnoteId : void 0;
46410
47252
  const isFootnoteTransition = targetZone === "footnote" && targetFootnoteId !== state.activeFootnoteId;
46411
47253
  if (!isZoneTransition && !isFootnoteTransition) {
46412
47254
  deps.applyState(newState);
@@ -46541,7 +47383,7 @@ function createEditorSurfaceEvents(deps) {
46541
47383
  deps.focusInputAfterPointerSelection();
46542
47384
  };
46543
47385
  const handleSurfaceMouseDown = (event) => {
46544
- var _a;
47386
+ var _a2;
46545
47387
  if (event.button !== 0) {
46546
47388
  return;
46547
47389
  }
@@ -46576,7 +47418,7 @@ function createEditorSurfaceEvents(deps) {
46576
47418
  deps.focusInputAfterPointerSelection();
46577
47419
  return;
46578
47420
  }
46579
- if ((_a = deps.textDrag) == null ? void 0 : _a.tryStartTextDrag(event, hit)) {
47421
+ if ((_a2 = deps.textDrag) == null ? void 0 : _a2.tryStartTextDrag(event, hit)) {
46580
47422
  dragAnchor = null;
46581
47423
  stopDragging();
46582
47424
  deps.focusInputAfterPointerSelection();
@@ -46770,7 +47612,7 @@ function createEditorSurfaceEvents(deps) {
46770
47612
  event.clientX - lastMouseDownX,
46771
47613
  event.clientY - lastMouseDownY
46772
47614
  );
46773
- const useMouseDownHit = Date.now() - lastMouseDownAt <= 600 && distanceFromMouseDown <= 8;
47615
+ const useMouseDownHit = Date.now() - lastMouseDownAt <= REUSE_MOUSE_DOWN_HIT_MAX_AGE_MS && distanceFromMouseDown <= REUSE_MOUSE_DOWN_HIT_MAX_DISTANCE_PX;
46774
47616
  const hit = useMouseDownHit ? lastMouseDownHit : deps.resolveSurfaceHitAtPoint(event.clientX, event.clientY);
46775
47617
  if (!(hit == null ? void 0 : hit.resolvedFromParagraph)) {
46776
47618
  deps.focusInputAfterPointerSelection();
@@ -46811,7 +47653,7 @@ function createEditorTextInput(deps) {
46811
47653
  const [composing, setComposing] = createSignal(false);
46812
47654
  let suppressedInputText = null;
46813
47655
  const handleTextInput = (event) => {
46814
- var _a, _b, _c, _d;
47656
+ var _a2, _b2, _c, _d;
46815
47657
  markStart("input:text");
46816
47658
  if (deps.isReadOnly()) {
46817
47659
  deps.logger.debug(
@@ -46836,9 +47678,9 @@ function createEditorTextInput(deps) {
46836
47678
  }
46837
47679
  const state = deps.state();
46838
47680
  const sel = state.selection;
46839
- const currentRun = (_a = getParagraphs(state).find((p) => p.id === sel.anchor.paragraphId)) == null ? void 0 : _a.runs.find((r) => r.id === sel.anchor.runId);
47681
+ const currentRun = (_a2 = getParagraphs(state).find((p) => p.id === sel.anchor.paragraphId)) == null ? void 0 : _a2.runs.find((r) => r.id === sel.anchor.runId);
46840
47682
  const runStyle = currentRun ? {
46841
- bold: (_b = currentRun.styles) == null ? void 0 : _b.bold,
47683
+ bold: (_b2 = currentRun.styles) == null ? void 0 : _b2.bold,
46842
47684
  italic: (_c = currentRun.styles) == null ? void 0 : _c.italic,
46843
47685
  underline: (_d = currentRun.styles) == null ? void 0 : _d.underline
46844
47686
  } : null;
@@ -46954,8 +47796,8 @@ function createEditorTextDrag(deps) {
46954
47796
  document.head.appendChild(cursorStyleEl);
46955
47797
  };
46956
47798
  const stopDrag = () => {
46957
- var _a;
46958
- (_a = deps.logger) == null ? void 0 : _a.info("text-drag:stop", {
47799
+ var _a2;
47800
+ (_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:stop", {
46959
47801
  dragging: dragging(),
46960
47802
  dropTarget: dropTargetPos() ? `${dropTargetPos().paragraphId}:${dropTargetPos().runId}[${dropTargetPos().offset}]` : null,
46961
47803
  copyMode: copyMode()
@@ -46972,7 +47814,7 @@ function createEditorTextDrag(deps) {
46972
47814
  window.removeEventListener("mouseup", handleWindowMouseUp);
46973
47815
  };
46974
47816
  const handleWindowMouseMove = (event) => {
46975
- var _a, _b, _c;
47817
+ var _a2, _b2, _c;
46976
47818
  if (!pendingStart) {
46977
47819
  return;
46978
47820
  }
@@ -46984,7 +47826,7 @@ function createEditorTextDrag(deps) {
46984
47826
  if (deltaX + deltaY < 4) {
46985
47827
  return;
46986
47828
  }
46987
- (_a = deps.logger) == null ? void 0 : _a.info("text-drag:activate", {
47829
+ (_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:activate", {
46988
47830
  start: pendingStart,
46989
47831
  at: { x: event.clientX, y: event.clientY },
46990
47832
  deltaX,
@@ -46996,7 +47838,7 @@ function createEditorTextDrag(deps) {
46996
47838
  setPointerPos({ x: event.clientX, y: event.clientY });
46997
47839
  const hit = deps.resolveSurfaceHitAtPoint(event.clientX, event.clientY);
46998
47840
  if (!(hit == null ? void 0 : hit.resolvedFromParagraph)) {
46999
- (_b = deps.logger) == null ? void 0 : _b.debug("text-drag:hit-miss", {
47841
+ (_b2 = deps.logger) == null ? void 0 : _b2.debug("text-drag:hit-miss", {
47000
47842
  x: event.clientX,
47001
47843
  y: event.clientY
47002
47844
  });
@@ -47024,8 +47866,8 @@ function createEditorTextDrag(deps) {
47024
47866
  setCaretViewport(hit.caretViewport ?? null);
47025
47867
  };
47026
47868
  const handleWindowMouseUp = (event) => {
47027
- var _a, _b, _c;
47028
- (_a = deps.logger) == null ? void 0 : _a.info("text-drag:mouseup", {
47869
+ var _a2, _b2, _c;
47870
+ (_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:mouseup", {
47029
47871
  x: event.clientX,
47030
47872
  y: event.clientY,
47031
47873
  dragging: dragging(),
@@ -47046,7 +47888,7 @@ function createEditorTextDrag(deps) {
47046
47888
  mergeKey: copy ? MERGE_KEYS.copyTextByDrag : MERGE_KEYS.moveTextByDrag
47047
47889
  }
47048
47890
  );
47049
- (_b = deps.logger) == null ? void 0 : _b.info("text-drag:apply", {
47891
+ (_b2 = deps.logger) == null ? void 0 : _b2.info("text-drag:apply", {
47050
47892
  mode: copy ? "copy" : "move",
47051
47893
  destination: `${destination.paragraphId}:${destination.runId}[${destination.offset}]`
47052
47894
  });
@@ -47072,9 +47914,9 @@ function createEditorTextDrag(deps) {
47072
47914
  deps.focusInputAfterPointerSelection();
47073
47915
  };
47074
47916
  const tryStartTextDrag = (event, hit) => {
47075
- var _a, _b, _c;
47917
+ var _a2, _b2, _c;
47076
47918
  if (deps.isReadOnly() || !(hit == null ? void 0 : hit.resolvedFromParagraph)) {
47077
- (_a = deps.logger) == null ? void 0 : _a.debug("text-drag:skip-start", {
47919
+ (_a2 = deps.logger) == null ? void 0 : _a2.debug("text-drag:skip-start", {
47078
47920
  reason: deps.isReadOnly() ? "readonly" : "no-hit",
47079
47921
  x: event.clientX,
47080
47922
  y: event.clientY
@@ -47083,7 +47925,7 @@ function createEditorTextDrag(deps) {
47083
47925
  }
47084
47926
  const current = deps.state();
47085
47927
  if (!isPositionInsideSelection(current, hit.position)) {
47086
- (_b = deps.logger) == null ? void 0 : _b.debug("text-drag:skip-start", {
47928
+ (_b2 = deps.logger) == null ? void 0 : _b2.debug("text-drag:skip-start", {
47087
47929
  reason: "outside-selection",
47088
47930
  x: event.clientX,
47089
47931
  y: event.clientY,
@@ -47219,7 +48061,7 @@ function createEditorNavigation(deps) {
47219
48061
  return moveVerticalSelection(direction, false);
47220
48062
  };
47221
48063
  const moveVerticalSelection = (direction, extend) => {
47222
- var _a, _b, _c, _d, _e, _f;
48064
+ var _a2, _b2, _c, _d, _e, _f;
47223
48065
  const state = deps.state();
47224
48066
  const paragraphs = getParagraphs(state);
47225
48067
  const currentIndex = paragraphs.findIndex(
@@ -47236,7 +48078,7 @@ function createEditorNavigation(deps) {
47236
48078
  surface: surfaceRef,
47237
48079
  state,
47238
48080
  documentLayout: deps.documentLayout(),
47239
- zoomFactor: (_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)
48081
+ zoomFactor: (_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
47240
48082
  }) : null;
47241
48083
  let targetIndex = currentIndex + direction;
47242
48084
  const tableLocation = findParagraphTableLocation(
@@ -47268,17 +48110,17 @@ function createEditorNavigation(deps) {
47268
48110
  continue;
47269
48111
  }
47270
48112
  const scoredCandidates = rowCandidates.map((entry) => {
47271
- var _a2, _b2;
47272
- const paragraphId = (_a2 = entry.cell.blocks[0]) == null ? void 0 : _a2.id;
47273
- const cellRect = paragraphId ? (_b2 = snapshot == null ? void 0 : snapshot.paragraphs.find(
48113
+ var _a3, _b3;
48114
+ const paragraphId = (_a3 = entry.cell.blocks[0]) == null ? void 0 : _a3.id;
48115
+ const cellRect = paragraphId ? (_b3 = snapshot == null ? void 0 : snapshot.paragraphs.find(
47274
48116
  (paragraph) => paragraph.paragraphId === paragraphId && paragraph.tableCell && paragraph.tableCell.tableId === block.id
47275
- )) == null ? void 0 : _b2.tableCell : null;
48117
+ )) == null ? void 0 : _b3.tableCell : null;
47276
48118
  const left = (cellRect == null ? void 0 : cellRect.left) ?? desiredX;
47277
48119
  const right = cellRect ? cellRect.left + cellRect.width : desiredX;
47278
48120
  const distance = desiredX < left ? left - desiredX : desiredX > right ? desiredX - right : 0;
47279
48121
  return { entry, distance };
47280
48122
  }).sort((left, right) => left.distance - right.distance);
47281
- const candidate = (_b = scoredCandidates[0]) == null ? void 0 : _b.entry;
48123
+ const candidate = (_b2 = scoredCandidates[0]) == null ? void 0 : _b2.entry;
47282
48124
  if (!candidate) {
47283
48125
  continue;
47284
48126
  }
@@ -47345,12 +48187,12 @@ function createEditorNavigation(deps) {
47345
48187
  function createEditorRevisionController(deps) {
47346
48188
  const [hoveredRevision, setHoveredRevision] = createSignal(null);
47347
48189
  const handleRevisionMouseEnter = (revisionId, event) => {
47348
- var _a, _b, _c;
48190
+ var _a2, _b2, _c;
47349
48191
  const paragraphs = getParagraphs(deps.state());
47350
48192
  let foundRevision;
47351
48193
  for (const p of paragraphs) {
47352
48194
  for (const run of p.runs) {
47353
- if (((_a = run.revision) == null ? void 0 : _a.id) === revisionId) {
48195
+ if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId) {
47354
48196
  foundRevision = run.revision;
47355
48197
  break;
47356
48198
  }
@@ -47358,10 +48200,10 @@ function createEditorRevisionController(deps) {
47358
48200
  if (foundRevision) break;
47359
48201
  }
47360
48202
  const findInBlocks = (blocks) => {
47361
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
48203
+ var _a3, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
47362
48204
  for (const block of blocks) {
47363
48205
  if (block.type === "paragraph") continue;
47364
- if (((_b2 = (_a2 = block.style) == null ? void 0 : _a2.revision) == null ? void 0 : _b2.id) === revisionId) {
48206
+ if (((_b3 = (_a3 = block.style) == null ? void 0 : _a3.revision) == null ? void 0 : _b3.id) === revisionId) {
47365
48207
  return block.style.revision;
47366
48208
  }
47367
48209
  if (((_c2 = block.gridRevision) == null ? void 0 : _c2.id) === revisionId) return block.gridRevision;
@@ -47404,7 +48246,7 @@ function createEditorRevisionController(deps) {
47404
48246
  }
47405
48247
  if (!foundRevision) return;
47406
48248
  const rect = event.currentTarget.getBoundingClientRect();
47407
- const surfaceRect = (_b = deps.surfaceRef()) == null ? void 0 : _b.getBoundingClientRect();
48249
+ const surfaceRect = (_b2 = deps.surfaceRef()) == null ? void 0 : _b2.getBoundingClientRect();
47408
48250
  if (!surfaceRect) return;
47409
48251
  const z = ((_c = deps.zoomFactor) == null ? void 0 : _c.call(deps)) ?? 1;
47410
48252
  setHoveredRevision({
@@ -47586,8 +48428,8 @@ function createEditorInteractionRuntime(deps) {
47586
48428
  logger
47587
48429
  });
47588
48430
  const resolvePositionAtSurfacePoint = (clientX, clientY) => {
47589
- var _a;
47590
- return ((_a = resolveSurfaceHitAtPoint(clientX, clientY)) == null ? void 0 : _a.position) ?? null;
48431
+ var _a2;
48432
+ return ((_a2 = resolveSurfaceHitAtPoint(clientX, clientY)) == null ? void 0 : _a2.position) ?? null;
47591
48433
  };
47592
48434
  const imageOps = createEditorImageOperations({
47593
48435
  state,
@@ -47685,10 +48527,10 @@ function ensureFootnotes(footnotes) {
47685
48527
  return { items: {} };
47686
48528
  }
47687
48529
  function nextAutoMarker(document2) {
47688
- var _a, _b;
48530
+ var _a2, _b2;
47689
48531
  const footnotes = document2.footnotes;
47690
- const format = ((_a = footnotes == null ? void 0 : footnotes.settings) == null ? void 0 : _a.numberFormat) ?? "decimal";
47691
- const startAt = ((_b = footnotes == null ? void 0 : footnotes.settings) == null ? void 0 : _b.startAt) ?? 1;
48532
+ const format = ((_a2 = footnotes == null ? void 0 : footnotes.settings) == null ? void 0 : _a2.numberFormat) ?? "decimal";
48533
+ const startAt = ((_b2 = footnotes == null ? void 0 : footnotes.settings) == null ? void 0 : _b2.startAt) ?? 1;
47692
48534
  let autoCount = startAt - 1;
47693
48535
  const seen = /* @__PURE__ */ new Set();
47694
48536
  for (const { run } of iterateFootnoteReferenceRuns(document2)) {
@@ -47763,10 +48605,10 @@ function toggleTrackChanges(state) {
47763
48605
  }
47764
48606
  function transformTableRevisionBlocks(blocks, revisionId, accept) {
47765
48607
  return blocks.flatMap((block) => {
47766
- var _a;
48608
+ var _a2;
47767
48609
  if (block.type === "paragraph") return [block];
47768
48610
  let style2 = block.style;
47769
- if (((_a = style2 == null ? void 0 : style2.revision) == null ? void 0 : _a.id) === revisionId) {
48611
+ if (((_a2 = style2 == null ? void 0 : style2.revision) == null ? void 0 : _a2.id) === revisionId) {
47770
48612
  if (accept) {
47771
48613
  const { revision: _revision, ...current } = style2;
47772
48614
  style2 = current;
@@ -47810,8 +48652,8 @@ function transformTableRevisionBlocks(blocks, revisionId, accept) {
47810
48652
  }
47811
48653
  }
47812
48654
  const rows = sourceRows.flatMap((row) => {
47813
- var _a2, _b, _c, _d;
47814
- if (((_b = (_a2 = row.style) == null ? void 0 : _a2.revision) == null ? void 0 : _b.id) === revisionId) {
48655
+ var _a3, _b2, _c, _d;
48656
+ if (((_b2 = (_a3 = row.style) == null ? void 0 : _a3.revision) == null ? void 0 : _b2.id) === revisionId) {
47815
48657
  const remove = accept && row.style.revision.type === "delete" || !accept && row.style.revision.type === "insert";
47816
48658
  if (remove) return [];
47817
48659
  }
@@ -47832,8 +48674,8 @@ function transformTableRevisionBlocks(blocks, revisionId, accept) {
47832
48674
  rowStyle = current;
47833
48675
  }
47834
48676
  const cells = row.cells.flatMap((cell) => {
47835
- var _a3, _b2, _c2, _d2, _e;
47836
- if (((_b2 = (_a3 = cell.style) == null ? void 0 : _a3.revision) == null ? void 0 : _b2.id) === revisionId) {
48677
+ var _a4, _b3, _c2, _d2, _e;
48678
+ if (((_b3 = (_a4 = cell.style) == null ? void 0 : _a4.revision) == null ? void 0 : _b3.id) === revisionId) {
47837
48679
  const remove = accept && cell.style.revision.type === "delete" || !accept && cell.style.revision.type === "insert";
47838
48680
  if (remove) return [];
47839
48681
  }
@@ -47908,12 +48750,12 @@ function acceptRevision(state, revisionId) {
47908
48750
  const nextParagraphs = paragraphs.map((paragraph) => {
47909
48751
  const nextRuns = paragraph.runs.filter(
47910
48752
  (run) => {
47911
- var _a;
47912
- return !(((_a = run.revision) == null ? void 0 : _a.id) === revisionId && run.revision.type === "delete");
48753
+ var _a2;
48754
+ return !(((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "delete");
47913
48755
  }
47914
48756
  ).map((run) => {
47915
- var _a;
47916
- if (((_a = run.revision) == null ? void 0 : _a.id) === revisionId && run.revision.type === "insert") {
48757
+ var _a2;
48758
+ if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "insert") {
47917
48759
  const nextRun = { ...run };
47918
48760
  delete nextRun.revision;
47919
48761
  return nextRun;
@@ -47940,12 +48782,12 @@ function rejectRevision(state, revisionId) {
47940
48782
  const nextParagraphs = paragraphs.map((paragraph) => {
47941
48783
  const nextRuns = paragraph.runs.filter(
47942
48784
  (run) => {
47943
- var _a;
47944
- return !(((_a = run.revision) == null ? void 0 : _a.id) === revisionId && run.revision.type === "insert");
48785
+ var _a2;
48786
+ return !(((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "insert");
47945
48787
  }
47946
48788
  ).map((run) => {
47947
- var _a;
47948
- if (((_a = run.revision) == null ? void 0 : _a.id) === revisionId && run.revision.type === "delete") {
48789
+ var _a2;
48790
+ if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "delete") {
47949
48791
  const nextRun = { ...run };
47950
48792
  delete nextRun.revision;
47951
48793
  return nextRun;
@@ -47968,7 +48810,7 @@ function rejectRevision(state, revisionId) {
47968
48810
  return transformTableRevision(textState, revisionId, false);
47969
48811
  }
47970
48812
  function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
47971
- var _a, _b, _c, _d, _e;
48813
+ var _a2, _b2, _c, _d, _e;
47972
48814
  for (const block of blocks) {
47973
48815
  if (block.type === "paragraph") continue;
47974
48816
  const tableSelected = block.rows.some(
@@ -47977,7 +48819,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
47977
48819
  )
47978
48820
  );
47979
48821
  if (tableSelected) {
47980
- if ((_a = block.style) == null ? void 0 : _a.revision) revisionIds.add(block.style.revision.id);
48822
+ if ((_a2 = block.style) == null ? void 0 : _a2.revision) revisionIds.add(block.style.revision.id);
47981
48823
  if (block.gridRevision) revisionIds.add(block.gridRevision.id);
47982
48824
  }
47983
48825
  for (const row of block.rows) {
@@ -47985,7 +48827,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
47985
48827
  (cell) => cell.blocks.some((paragraph) => selectedParagraphIds.has(paragraph.id))
47986
48828
  );
47987
48829
  if (selectedCells.length > 0) {
47988
- if ((_b = row.style) == null ? void 0 : _b.revision) revisionIds.add(row.style.revision.id);
48830
+ if ((_b2 = row.style) == null ? void 0 : _b2.revision) revisionIds.add(row.style.revision.id);
47989
48831
  if ((_c = row.style) == null ? void 0 : _c.propertyRevision) {
47990
48832
  revisionIds.add(row.style.propertyRevision.id);
47991
48833
  }
@@ -48001,7 +48843,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
48001
48843
  }
48002
48844
  }
48003
48845
  function acceptRevisionsInSelection(state) {
48004
- var _a;
48846
+ var _a2;
48005
48847
  const normalized = normalizeSelection(state);
48006
48848
  const paragraphs = getParagraphs(state);
48007
48849
  const revisionIds = /* @__PURE__ */ new Set();
@@ -48011,7 +48853,7 @@ function acceptRevisionsInSelection(state) {
48011
48853
  const endOffset = i === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
48012
48854
  const runs = sliceRuns(paragraph, startOffset, endOffset);
48013
48855
  for (const run of runs) {
48014
- if ((_a = run.revision) == null ? void 0 : _a.id) {
48856
+ if ((_a2 = run.revision) == null ? void 0 : _a2.id) {
48015
48857
  revisionIds.add(run.revision.id);
48016
48858
  }
48017
48859
  }
@@ -48041,7 +48883,7 @@ function acceptRevisionsInSelection(state) {
48041
48883
  return nextState;
48042
48884
  }
48043
48885
  function rejectRevisionsInSelection(state) {
48044
- var _a;
48886
+ var _a2;
48045
48887
  const normalized = normalizeSelection(state);
48046
48888
  const paragraphs = getParagraphs(state);
48047
48889
  const revisionIds = /* @__PURE__ */ new Set();
@@ -48051,7 +48893,7 @@ function rejectRevisionsInSelection(state) {
48051
48893
  const endOffset = i === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
48052
48894
  const runs = sliceRuns(paragraph, startOffset, endOffset);
48053
48895
  for (const run of runs) {
48054
- if ((_a = run.revision) == null ? void 0 : _a.id) {
48896
+ if ((_a2 = run.revision) == null ? void 0 : _a2.id) {
48055
48897
  revisionIds.add(run.revision.id);
48056
48898
  }
48057
48899
  }
@@ -48081,7 +48923,7 @@ function rejectRevisionsInSelection(state) {
48081
48923
  return nextState;
48082
48924
  }
48083
48925
  function getLinkAtSelection(state) {
48084
- var _a, _b, _c;
48926
+ var _a2, _b2, _c;
48085
48927
  const normalized = normalizeSelection(state);
48086
48928
  const paragraphs = getParagraphs(state);
48087
48929
  if (normalized.isCollapsed) {
@@ -48089,7 +48931,7 @@ function getLinkAtSelection(state) {
48089
48931
  if (!paragraph) {
48090
48932
  return null;
48091
48933
  }
48092
- return ((_a = expandLinkRangeInParagraph(paragraph, normalized.startParagraphOffset)) == null ? void 0 : _a.href) ?? null;
48934
+ return ((_a2 = expandLinkRangeInParagraph(paragraph, normalized.startParagraphOffset)) == null ? void 0 : _a2.href) ?? null;
48093
48935
  }
48094
48936
  const touchedRuns = paragraphs.slice(normalized.startIndex, normalized.endIndex + 1).flatMap((paragraph, relativeIndex) => {
48095
48937
  const paragraphIndex = normalized.startIndex + relativeIndex;
@@ -48100,13 +48942,13 @@ function getLinkAtSelection(state) {
48100
48942
  if (touchedRuns.length === 0) {
48101
48943
  return null;
48102
48944
  }
48103
- const href = (_c = (_b = touchedRuns[0]) == null ? void 0 : _b.styles) == null ? void 0 : _c.link;
48945
+ const href = (_c = (_b2 = touchedRuns[0]) == null ? void 0 : _b2.styles) == null ? void 0 : _c.link;
48104
48946
  if (!href) {
48105
48947
  return null;
48106
48948
  }
48107
48949
  return touchedRuns.every((run) => {
48108
- var _a2;
48109
- return ((_a2 = run.styles) == null ? void 0 : _a2.link) === href;
48950
+ var _a3;
48951
+ return ((_a3 = run.styles) == null ? void 0 : _a3.link) === href;
48110
48952
  }) ? href : null;
48111
48953
  }
48112
48954
  function setLinkAtSelection(state, href) {
@@ -48244,11 +49086,11 @@ function toggleParagraphList(state, kind) {
48244
49086
  const endIndex = normalized.endIndex;
48245
49087
  const targetedParagraphs = paragraphs.slice(startIndex, endIndex + 1);
48246
49088
  const shouldClear = targetedParagraphs.length > 0 && targetedParagraphs.every((paragraph) => {
48247
- var _a;
48248
- return ((_a = paragraph.list) == null ? void 0 : _a.kind) === kind;
49089
+ var _a2;
49090
+ return ((_a2 = paragraph.list) == null ? void 0 : _a2.kind) === kind;
48249
49091
  });
48250
49092
  const nextParagraphs = paragraphs.map((paragraph, paragraphIndex) => {
48251
- var _a, _b, _c;
49093
+ var _a2, _b2, _c;
48252
49094
  if (paragraphIndex < startIndex || paragraphIndex > endIndex) {
48253
49095
  return cloneParagraph(paragraph);
48254
49096
  }
@@ -48259,8 +49101,8 @@ function toggleParagraphList(state, kind) {
48259
49101
  }
48260
49102
  nextParagraph.list = {
48261
49103
  kind,
48262
- level: ((_a = paragraph.list) == null ? void 0 : _a.level) ?? 0,
48263
- format: (_b = paragraph.list) == null ? void 0 : _b.format,
49104
+ level: ((_a2 = paragraph.list) == null ? void 0 : _a2.level) ?? 0,
49105
+ format: (_b2 = paragraph.list) == null ? void 0 : _b2.format,
48264
49106
  startAt: (_c = paragraph.list) == null ? void 0 : _c.startAt
48265
49107
  };
48266
49108
  return nextParagraph;
@@ -48618,12 +49460,12 @@ function createEditorCommandsController(deps) {
48618
49460
  focusInput();
48619
49461
  };
48620
49462
  const promptForImageAlt = () => {
48621
- var _a;
49463
+ var _a2;
48622
49464
  const run = selectedImageRun();
48623
49465
  if (!run) {
48624
49466
  return;
48625
49467
  }
48626
- const currentAlt = ((_a = getRunImage(run.run)) == null ? void 0 : _a.alt) ?? "";
49468
+ const currentAlt = ((_a2 = getRunImage(run.run)) == null ? void 0 : _a2.alt) ?? "";
48627
49469
  deps.openImageAltDialog(currentAlt);
48628
49470
  };
48629
49471
  const applyImageCaptionCommand = (caption) => {
@@ -48719,13 +49561,13 @@ class EditorCommandRegistry {
48719
49561
  return Array.from(this.bindings.values());
48720
49562
  }
48721
49563
  execute(event, deps, commandExecutor) {
48722
- var _a;
49564
+ var _a2;
48723
49565
  const isCtrlOrMeta = event.ctrlKey || event.metaKey;
48724
49566
  const lowerKey = event.key.toLowerCase();
48725
49567
  for (const binding of this.bindings.values()) {
48726
49568
  if (binding.key.toLowerCase() === lowerKey && Boolean(binding.ctrlOrMeta) === isCtrlOrMeta && Boolean(binding.shift) === event.shiftKey && Boolean(binding.alt) === event.altKey) {
48727
49569
  if (binding.command && commandExecutor) {
48728
- const canExecute = ((_a = commandExecutor.canExecuteCommand) == null ? void 0 : _a.call(commandExecutor, binding.command)) ?? true;
49570
+ const canExecute = ((_a2 = commandExecutor.canExecuteCommand) == null ? void 0 : _a2.call(commandExecutor, binding.command)) ?? true;
48729
49571
  if (canExecute) {
48730
49572
  commandExecutor.executeCommand(binding.command);
48731
49573
  event.preventDefault();
@@ -48994,12 +49836,12 @@ function createEditorKeyboardController(deps) {
48994
49836
  }
48995
49837
  const commandExecutor = deps.executeCommand ? {
48996
49838
  executeCommand: (commandName, payload) => {
48997
- var _a;
48998
- return (_a = deps.executeCommand) == null ? void 0 : _a.call(deps, commandName, payload);
49839
+ var _a2;
49840
+ return (_a2 = deps.executeCommand) == null ? void 0 : _a2.call(deps, commandName, payload);
48999
49841
  },
49000
49842
  canExecuteCommand: (commandName, payload) => {
49001
- var _a;
49002
- return (_a = deps.canExecuteCommand) == null ? void 0 : _a.call(deps, commandName, payload);
49843
+ var _a2;
49844
+ return (_a2 = deps.canExecuteCommand) == null ? void 0 : _a2.call(deps, commandName, payload);
49003
49845
  }
49004
49846
  } : void 0;
49005
49847
  if (registry.execute(event, deps, commandExecutor)) {
@@ -49411,10 +50253,10 @@ const DEFAULT_TOC_MAX_LEVEL = 3;
49411
50253
  const TOC_INSTRUCTION = ' TOC \\o "1-3" \\h \\z \\u ';
49412
50254
  const twipsToPx = (twips) => Math.round(twips / TWIPS_PER_INCH * PX_PER_INCH);
49413
50255
  function collectTocHeadings(state, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
49414
- var _a;
50256
+ var _a2;
49415
50257
  const headings = [];
49416
50258
  for (const paragraph of getDocumentParagraphs(state.document)) {
49417
- const level = getHeadingLevel((_a = paragraph.style) == null ? void 0 : _a.styleId);
50259
+ const level = getHeadingLevel((_a2 = paragraph.style) == null ? void 0 : _a2.styleId);
49418
50260
  if (level === null || level > maxLevel) continue;
49419
50261
  const text = getParagraphText(paragraph).trim();
49420
50262
  if (!text) continue;
@@ -50266,18 +51108,18 @@ function createEditorEssentialsRuntimePlugin(options) {
50266
51108
  };
50267
51109
  const essentialsDocument = {
50268
51110
  documentStyles: () => {
50269
- var _a, _b;
51111
+ var _a2, _b2;
50270
51112
  const document2 = options.state().document;
50271
51113
  const styles = (document2 == null ? void 0 : document2.styles) ?? {};
50272
51114
  const usedStyleIds = /* @__PURE__ */ new Set();
50273
51115
  for (const paragraph of getDocumentParagraphs(document2)) {
50274
- if ((_a = paragraph.style) == null ? void 0 : _a.styleId) usedStyleIds.add(paragraph.style.styleId);
51116
+ if ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) usedStyleIds.add(paragraph.style.styleId);
50275
51117
  for (const run of paragraph.runs) {
50276
- if ((_b = run.styles) == null ? void 0 : _b.styleId) usedStyleIds.add(run.styles.styleId);
51118
+ if ((_b2 = run.styles) == null ? void 0 : _b2.styleId) usedStyleIds.add(run.styles.styleId);
50277
51119
  }
50278
51120
  }
50279
51121
  return Object.values(styles).map((style2) => {
50280
- var _a2;
51122
+ var _a3;
50281
51123
  const preview = resolveNamedTextStyle(style2.id, styles);
50282
51124
  return {
50283
51125
  id: style2.id,
@@ -50288,7 +51130,7 @@ function createEditorEssentialsRuntimePlugin(options) {
50288
51130
  semiHidden: style2.semiHidden,
50289
51131
  unhideWhenUsed: style2.unhideWhenUsed,
50290
51132
  isUsed: usedStyleIds.has(style2.id),
50291
- fontFamily: ((_a2 = preview.fontFamily) == null ? void 0 : _a2.trim()) || void 0,
51133
+ fontFamily: ((_a3 = preview.fontFamily) == null ? void 0 : _a3.trim()) || void 0,
50292
51134
  fontSize: typeof preview.fontSize === "number" ? preview.fontSize : void 0,
50293
51135
  color: preview.color ?? void 0,
50294
51136
  bold: preview.bold ?? void 0,
@@ -50299,12 +51141,12 @@ function createEditorEssentialsRuntimePlugin(options) {
50299
51141
  exportDocx: () => void options.docIO.handleExportDocx(),
50300
51142
  exportPdf: () => void options.docIO.handleExportPdf(),
50301
51143
  importDocument: () => {
50302
- var _a;
50303
- return (_a = options.importInputRef()) == null ? void 0 : _a.click();
51144
+ var _a2;
51145
+ return (_a2 = options.importInputRef()) == null ? void 0 : _a2.click();
50304
51146
  },
50305
51147
  insertImage: () => {
50306
- var _a;
50307
- return (_a = options.imageInputRef()) == null ? void 0 : _a.click();
51148
+ var _a2;
51149
+ return (_a2 = options.imageInputRef()) == null ? void 0 : _a2.click();
50308
51150
  },
50309
51151
  insertShape: (preset) => options.applyTransactionalState(
50310
51152
  (current) => insertShapeAtSelection(current, preset)
@@ -50402,15 +51244,15 @@ function createEditorEssentialsRuntimePlugin(options) {
50402
51244
  };
50403
51245
  const essentialsSection = {
50404
51246
  isLandscape: () => {
50405
- var _a, _b;
51247
+ var _a2, _b2;
50406
51248
  const idx = getActiveSectionIndex(options.state());
50407
- const section = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
50408
- return ((_b = section == null ? void 0 : section.pageSettings) == null ? void 0 : _b.orientation) === "landscape";
51249
+ const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
51250
+ return ((_b2 = section == null ? void 0 : section.pageSettings) == null ? void 0 : _b2.orientation) === "landscape";
50409
51251
  },
50410
51252
  setOrientation: (orientation) => {
50411
- var _a;
51253
+ var _a2;
50412
51254
  const idx = getActiveSectionIndex(options.state());
50413
- const section = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
51255
+ const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
50414
51256
  if (!section) return;
50415
51257
  options.commandsController.applyUpdateSectionSettingsCommand(idx, {
50416
51258
  pageSettings: {
@@ -50420,11 +51262,11 @@ function createEditorEssentialsRuntimePlugin(options) {
50420
51262
  });
50421
51263
  },
50422
51264
  toggleOrientation: () => {
50423
- var _a, _b;
51265
+ var _a2, _b2;
50424
51266
  const idx = getActiveSectionIndex(options.state());
50425
- const section = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
51267
+ const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
50426
51268
  if (!section) return;
50427
- const current = ((_b = section.pageSettings) == null ? void 0 : _b.orientation) ?? "portrait";
51269
+ const current = ((_b2 = section.pageSettings) == null ? void 0 : _b2.orientation) ?? "portrait";
50428
51270
  essentialsSection.setOrientation(
50429
51271
  current === "portrait" ? "landscape" : "portrait"
50430
51272
  );
@@ -50432,15 +51274,15 @@ function createEditorEssentialsRuntimePlugin(options) {
50432
51274
  breakNextPage: () => options.commandsController.applyInsertSectionBreakCommand("nextPage"),
50433
51275
  breakContinuous: () => options.commandsController.applyInsertSectionBreakCommand("continuous"),
50434
51276
  getMargins: () => {
50435
- var _a, _b;
51277
+ var _a2, _b2;
50436
51278
  const idx = getActiveSectionIndex(options.state());
50437
- const section = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
50438
- return (_b = section == null ? void 0 : section.pageSettings) == null ? void 0 : _b.margins;
51279
+ const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
51280
+ return (_b2 = section == null ? void 0 : section.pageSettings) == null ? void 0 : _b2.margins;
50439
51281
  },
50440
51282
  setPageMargins: (margins) => {
50441
- var _a;
51283
+ var _a2;
50442
51284
  const idx = getActiveSectionIndex(options.state());
50443
- const section = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
51285
+ const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
50444
51286
  if (!(section == null ? void 0 : section.pageSettings)) return;
50445
51287
  options.commandsController.applyUpdateSectionSettingsCommand(idx, {
50446
51288
  pageSettings: {
@@ -50939,7 +51781,7 @@ const defaultMenuItems = [
50939
51781
  }
50940
51782
  ];
50941
51783
  function useEditorRuntimePlugins(options) {
50942
- var _a, _b;
51784
+ var _a2, _b2;
50943
51785
  const runtimePlugins = [
50944
51786
  options.essentialsPlugin,
50945
51787
  ...options.externalPlugins ?? []
@@ -50983,8 +51825,8 @@ function useEditorRuntimePlugins(options) {
50983
51825
  contributedMenuIds.push(item.id);
50984
51826
  }
50985
51827
  }
50986
- (_a = options.customizeToolbar) == null ? void 0 : _a.call(options, toolbarRegistry);
50987
- (_b = options.customizeMenubar) == null ? void 0 : _b.call(options, menuRegistry);
51828
+ (_a2 = options.customizeToolbar) == null ? void 0 : _a2.call(options, toolbarRegistry);
51829
+ (_b2 = options.customizeMenubar) == null ? void 0 : _b2.call(options, menuRegistry);
50988
51830
  return {
50989
51831
  runtimePlugins,
50990
51832
  toolbarRegistry,
@@ -51008,13 +51850,13 @@ function createRuntimeCommandHost(options) {
51008
51850
  );
51009
51851
  let disposed = false;
51010
51852
  const commandStateOf = (commandRef) => {
51011
- var _a;
51853
+ var _a2;
51012
51854
  const commandName = commandRefName(commandRef);
51013
51855
  const cmd = runtimeEditor().commands.get(commandName);
51014
51856
  if (!cmd) {
51015
51857
  return { isEnabled: false, isActive: false, value: void 0 };
51016
51858
  }
51017
- const refreshed = ((_a = cmd.refresh) == null ? void 0 : _a.call(cmd)) ?? { isEnabled: true };
51859
+ const refreshed = ((_a2 = cmd.refresh) == null ? void 0 : _a2.call(cmd)) ?? { isEnabled: true };
51018
51860
  return {
51019
51861
  isEnabled: refreshed.isEnabled !== false,
51020
51862
  isActive: Boolean(refreshed.isActive),
@@ -51042,7 +51884,7 @@ function createRuntimeCommandHost(options) {
51042
51884
  focusEditor: options.focusEditor
51043
51885
  });
51044
51886
  const initialize = async () => {
51045
- var _a, _b;
51887
+ var _a2, _b2;
51046
51888
  try {
51047
51889
  const initializedRuntimeEditor = await Editor.create({
51048
51890
  doc: options.initialDocument,
@@ -51057,14 +51899,14 @@ function createRuntimeCommandHost(options) {
51057
51899
  await previousRuntimeEditor.destroy();
51058
51900
  setRuntimeReady(true);
51059
51901
  requestAnimationFrame(() => {
51060
- var _a2, _b2;
51061
- (_a2 = options.onSettled) == null ? void 0 : _a2.call(options);
51062
- (_b2 = options.onReady) == null ? void 0 : _b2.call(options, initializedRuntimeEditor);
51902
+ var _a3, _b3;
51903
+ (_a3 = options.onSettled) == null ? void 0 : _a3.call(options);
51904
+ (_b3 = options.onReady) == null ? void 0 : _b3.call(options, initializedRuntimeEditor);
51063
51905
  });
51064
51906
  } catch (error) {
51065
51907
  options.logger.error("runtime:init failed", error);
51066
- (_a = options.onError) == null ? void 0 : _a.call(options, error);
51067
- (_b = options.onSettled) == null ? void 0 : _b.call(options);
51908
+ (_a2 = options.onError) == null ? void 0 : _a2.call(options, error);
51909
+ (_b2 = options.onSettled) == null ? void 0 : _b2.call(options);
51068
51910
  }
51069
51911
  };
51070
51912
  const dispose = async () => {
@@ -51180,9 +52022,9 @@ function createEditorCommandRuntime(deps) {
51180
52022
  focusEditor: deps.focusInput,
51181
52023
  logger: deps.logger,
51182
52024
  onReady: (editor) => {
51183
- var _a, _b;
52025
+ var _a2, _b2;
51184
52026
  runtimeClient.resolveReady(editor);
51185
- (_b = (_a = deps.runtimeOptions()).onReady) == null ? void 0 : _b.call(_a, runtimeClient);
52027
+ (_b2 = (_a2 = deps.runtimeOptions()).onReady) == null ? void 0 : _b2.call(_a2, runtimeClient);
51186
52028
  },
51187
52029
  onSettled: () => {
51188
52030
  deps.setInitialLoading(false);
@@ -51243,8 +52085,8 @@ function createEditorCommandRuntime(deps) {
51243
52085
  }
51244
52086
  var _tmpl$ = /* @__PURE__ */ template(`<div class="oasis-editor-shell oasis-editor-app">`);
51245
52087
  function OasisEditorApp(props = {}) {
51246
- var _a;
51247
- const runtimeClient = ((_a = props.runtime) == null ? void 0 : _a.client) ?? createOasisEditorClient();
52088
+ var _a2;
52089
+ const runtimeClient = ((_a2 = props.runtime) == null ? void 0 : _a2.client) ?? createOasisEditorClient();
51248
52090
  const ui = () => props.ui ?? {};
51249
52091
  const documentOptions = () => props.document ?? {};
51250
52092
  const runtimeOptions = () => props.runtime ?? {};
@@ -51659,12 +52501,12 @@ function OasisEditorApp(props = {}) {
51659
52501
  return loadingLabel();
51660
52502
  },
51661
52503
  get ["class"]() {
51662
- var _a2;
51663
- return (_a2 = loadingOptions()) == null ? void 0 : _a2.class;
52504
+ var _a3;
52505
+ return (_a3 = loadingOptions()) == null ? void 0 : _a3.class;
51664
52506
  },
51665
52507
  get style() {
51666
- var _a2;
51667
- return (_a2 = loadingOptions()) == null ? void 0 : _a2.style;
52508
+ var _a3;
52509
+ return (_a3 = loadingOptions()) == null ? void 0 : _a3.style;
51668
52510
  }
51669
52511
  });
51670
52512
  }