oasis-editor 0.0.135 → 0.0.136

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/{OasisEditorApp-207_qEC4.js → OasisEditorApp-DPrjPRTW.js} +650 -1005
  2. package/dist/app/controllers/documentIO/DocumentImporter.d.ts +3 -1
  3. package/dist/app/controllers/documentIO/importProgress.d.ts +1 -1
  4. package/dist/app/controllers/useEditorDocumentIO.d.ts +3 -1
  5. package/dist/core/commands/builtinCommands.d.ts +1 -1
  6. package/dist/core/commands/publicCommandTypes.d.ts +4 -0
  7. package/dist/core/commands/table/tableCellStyleCommands.d.ts +7 -0
  8. package/dist/core/smallCaps.d.ts +7 -0
  9. package/dist/core/tableStyleResolver.d.ts +5 -0
  10. package/dist/export/pdf/fonts/PdfFontRegistry.d.ts +1 -0
  11. package/dist/export/pdf/fonts/officeFontAssets.d.ts +2 -0
  12. package/dist/i18n/locales/en.d.ts +4 -2
  13. package/dist/i18n/locales/pt-BR.d.ts +4 -2
  14. package/dist/{index-CaKZARyM.js → index-Cbwb1bgI.js} +3165 -1540
  15. package/dist/oasis-editor.css +1 -1
  16. package/dist/oasis-editor.js +49 -49
  17. package/dist/oasis-editor.umd.cjs +4 -4
  18. package/dist/plugins/internal/essentialsCapabilities.d.ts +13 -0
  19. package/dist/text/fonts/FontMetricsProvider.d.ts +1 -1
  20. package/dist/text/fonts/core/types.d.ts +1 -1
  21. package/dist/text/fonts/decoders/WoffDecoder.d.ts +8 -0
  22. package/dist/text/fonts/preciseFontMetrics.d.ts +9 -0
  23. package/dist/text/fonts/remoteWebFonts.d.ts +16 -0
  24. package/dist/ui/OasisEditorAppProps.d.ts +4 -0
  25. package/dist/ui/OasisEditorEditorProps.d.ts +1 -0
  26. package/dist/ui/app/buildEditorViewProps.d.ts +1 -0
  27. package/dist/ui/app/documentFontPreparation.d.ts +23 -0
  28. package/dist/ui/canvas/canvasFontResolution.d.ts +2 -2
  29. package/dist/ui/canvas/paragraph/canvasTextEffects.d.ts +1 -0
  30. package/dist/ui/components/Toolbar/TableBordersMenu.d.ts +6 -0
  31. package/dist/ui/components/Toolbar/TableStyleGallery.d.ts +9 -0
  32. package/dist/ui/components/Toolbar/TableStyleOptions.d.ts +6 -0
  33. package/dist/ui/components/Toolbar/presets/defaultToolbar/buttonSpecs.d.ts +1 -0
  34. package/dist/ui/components/Toolbar/schema/items.d.ts +8 -0
  35. package/dist/ui/editorUiTypes.d.ts +1 -0
  36. package/dist/ui/textMeasurement/fontMetrics.d.ts +3 -2
  37. package/package.json +1 -1
@@ -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 { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s 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 getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setStyleProperty, ag as setAttribute, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as parseNumber, aE as createStore, aF as reconcile, aG as RadioGroup, aH as Radio$1, aI as TextAreaField, aJ as Text, aK as SurfaceButton, aL as delegateEvents, aM as onMount, aN as onCleanup, aO as CheckIcon, aP as use, aQ as PluginUiHost, aR as OasisEditorEditor, aS as OasisBrandMark, aT as setPreciseFontPreference, aU as setWelcomeSeen, aV as enablePreciseFontMode, aW as TWIPS_PER_POINT, aX as PX_PER_INCH, aY as TWIPS_PER_INCH, aZ as normalizeHex6, a_ as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, a$ as TABLE_BORDER_EDGE_KEYS, b0 as resolveEffectiveParagraphStyle, b1 as resolveEffectiveTextStyleForParagraph, b2 as EMU_PER_PT, b3 as OOXML_ROTATION_UNITS, b4 as OOXML_PERCENT_DENOMINATOR, b5 as parseHexColorToRgb255, b6 as EMU_PER_PX, b7 as getRunEndnoteReference, b8 as iterateFootnoteReferenceRuns, b9 as iterateEndnoteReferenceRuns, ba as imageContentTypeDefaults, bb as getRunFieldChar, bc as getRunFieldInstruction, bd as createEditorRun, be as JSZip, bf as imageExtensionFromMime, bg as pxToPt$1, bh as resolveFloatingObjectRect, bi as getTextBoxFloatingGeometry, bj as getPresetPathSegments, bk as buildListLabels, bl as lineDashPatternPt, bm as DEFAULT_FONT_SIZE_PX, bn as resolveGradientAxis, bo as isDoubleUnderlineStyle, bp as isWavyUnderlineStyle, bq as underlineStyleLineWidthPx, br as WAVY_UNDERLINE_WAVELENGTH_PX, bs as WAVY_UNDERLINE_AMPLITUDE_PX, bt as DOUBLE_UNDERLINE_OFFSET_PX, bu as underlineStyleDashArray, bv as EMPHASIS_GLYPH, bw as rgb255ToHex, bx as getImageFloatingGeometry, by as textStyleToFontSizePt, bz as resolveTextAlignmentBaselineOffset, bA as TEXT_BASELINE_RATIO, bB as resolveOpenTypeFeatureTags, bC as resolveDecorationLineY, bD as DOUBLE_STRIKE_OFFSET_PX, bE as resolveListLabel, bF as getListLabelInset, bG as getAlignedListLabelInset, bH as getParagraphBorderInsets, bI as buildSegmentTable, bJ as buildCanvasTableLayout, bK as resolveCanvasTableWidth, bL as resolveFloatingTableRect, bM as paragraphBetweenBorderMatches, bN as normalizeFamily, bO as ROBOTO_FONT_FILES, bP as loadFontAsset, bQ as OFFICE_COMPAT_FONT_FAMILIES, bR as BinaryReader, bS as buildSfnt, bT as defaultFontDecoderRegistry, bU as SfntFontProgram, bV as collectPdfFontFamilies, bW as outlineFrom, bX as getPageHeaderZoneTop, bY as getPageColumnRects, bZ as findFootnoteReference, b_ as resolveImporterForFile, b$ as roundTo, c0 as getDocumentSectionsCanonical, c1 as getDocumentParagraphsCanonical, c2 as getDocumentParagraphs, c3 as PX_PER_CM, c4 as getDocumentPageSettings, c5 as getTableCellContentWidthForParagraph, c6 as layoutMetricsEpoch, c7 as bumpLayoutMetricsEpoch, c8 as createCanvasLayoutSnapshotProvider, c9 as on, ca as debounce, cb as unwrap, cc as perfTimer, cd as getRunTextBox, ce as createEditorDocument, cf as resolveResizedDimensions, cg as axisSignForDirection, ch as clamp$1, ci as MIN_RESIZE_SIZE_PX, cj as resolveTextBoxRenderHeight, ck as getToolbarStyleState, cl as VERTICAL_HIT_WEIGHT, cm as getCachedCanvasImage, cn as measureParagraphMinContentWidthPx, co as getEditableBlocksForZone, cp as findParagraphLocation, cq as createSectionBoundaryParagraph, cr as normalizePageSettings, cs as DEFAULT_EDITOR_PAGE_SETTINGS, ct as markStart, cu as markEnd, cv as getParagraphEntries, cw as getParagraphById, cx as createEditorFootnote, cy as createFootnoteReferenceRun, cz as renumberFootnotes, cA as preciseFontModeVersion, cB as isPreciseFontModeEnabled, cC as getHeadingLevel, cD as togglePreciseFontMode, cE as nextFontSizePt, cF as previousFontSizePt, cG as fontSizePtToPx, cH as resolveNamedTextStyle, cI as createDefaultToolbarPreset, cJ as MenuRegistry, cK as createToolbarRegistry, cL as Editor, cM as resolveCommandRef, cN as commandRefName, cO as createOasisEditorClient, cP as createEditorZoom, cQ as startLongTaskObserver, cR as installGlobalReport, cS as applyStoredPreciseFontPreference, cT as getWelcomeSeen, cU as isLocalFontAccessSupported, cV as EDITOR_SCROLL_PADDING_PX, cW as Toolbar, cX as OasisEditorLoading, cY as I18nProvider, cZ as createTranslator, c_ as registerDomStatsSurface, c$ as createEditorLogger } from "./index-CaKZARyM.js";
4
+ import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s 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 getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setStyleProperty, ag as setAttribute, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as parseNumber, aE as createStore, aF as reconcile, aG as RadioGroup, aH as Radio$1, aI as TextAreaField, aJ as Text, aK as SurfaceButton, aL as delegateEvents, aM as onMount, aN as onCleanup, aO as CheckIcon, aP as use, aQ as PluginUiHost, aR as OasisEditorEditor, aS as OasisBrandMark, aT as setPreciseFontPreference, aU as setWelcomeSeen, aV as enablePreciseFontMode, aW as TWIPS_PER_POINT, aX as PX_PER_INCH, aY as TWIPS_PER_INCH, aZ as normalizeHex6, a_ as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, a$ as TABLE_BORDER_EDGE_KEYS, b0 as resolveEffectiveParagraphStyle, b1 as resolveEffectiveTextStyleForParagraph, b2 as EMU_PER_PT, b3 as OOXML_ROTATION_UNITS, b4 as OOXML_PERCENT_DENOMINATOR, b5 as parseHexColorToRgb255, b6 as EMU_PER_PX, b7 as getRunEndnoteReference, b8 as iterateFootnoteReferenceRuns, b9 as iterateEndnoteReferenceRuns, ba as imageContentTypeDefaults, bb as getRunFieldChar, bc as getRunFieldInstruction, bd as createEditorRun, be as JSZip, bf as imageExtensionFromMime, bg as pxToPt$1, bh as resolveFloatingObjectRect, bi as getTextBoxFloatingGeometry, bj as getPresetPathSegments, bk as buildListLabels, bl as lineDashPatternPt, bm as DEFAULT_FONT_SIZE_PX, bn as resolveGradientAxis, bo as isDoubleUnderlineStyle, bp as isWavyUnderlineStyle, bq as underlineStyleLineWidthPx, br as WAVY_UNDERLINE_WAVELENGTH_PX, bs as WAVY_UNDERLINE_AMPLITUDE_PX, bt as DOUBLE_UNDERLINE_OFFSET_PX, bu as underlineStyleDashArray, bv as EMPHASIS_GLYPH, bw as rgb255ToHex, bx as getImageFloatingGeometry, by as textStyleToFontSizePt, bz as resolveTextAlignmentBaselineOffset, bA as TEXT_BASELINE_RATIO, bB as resolveRenderedTextChar, bC as resolveOpenTypeFeatureTags, bD as isLowercaseSmallCapsChar, bE as resolveDecorationLineY, bF as DOUBLE_STRIKE_OFFSET_PX, bG as resolveListLabel, bH as getListLabelInset, bI as getAlignedListLabelInset, bJ as getParagraphBorderInsets, bK as buildSegmentTable, bL as buildCanvasTableLayout, bM as resolveCanvasTableWidth, bN as resolveFloatingTableRect, bO as paragraphBetweenBorderMatches, bP as normalizeFamily, bQ as ROBOTO_FONT_FILES, bR as loadFontAsset, bS as getRemotePdfFontFaces, bT as OFFICE_COMPAT_FONT_FAMILIES, bU as BinaryReader, bV as buildSfnt, bW as defaultFontDecoderRegistry, bX as SfntFontProgram, bY as zlibSync, bZ as collectPdfFontFamilies, b_ as outlineFrom, b$ as getPageHeaderZoneTop, c0 as getPageColumnRects, c1 as findFootnoteReference, c2 as resolveImporterForFile, c3 as roundTo, c4 as getDocumentSectionsCanonical, c5 as getDocumentParagraphsCanonical, c6 as getDocumentParagraphs, c7 as PX_PER_CM, c8 as getDocumentPageSettings, c9 as getTableCellContentWidthForParagraph, ca as layoutMetricsEpoch, cb as bumpLayoutMetricsEpoch, cc as createCanvasLayoutSnapshotProvider, cd as on, ce as debounce, cf as unwrap, cg as perfTimer, ch as prepareDocumentFonts, ci as getRunTextBox, cj as createEditorDocument, ck as resolveResizedDimensions, cl as axisSignForDirection, cm as clamp$1, cn as MIN_RESIZE_SIZE_PX, co as resolveTextBoxRenderHeight, cp as getToolbarStyleState, cq as VERTICAL_HIT_WEIGHT, cr as getCachedCanvasImage, cs as measureParagraphMinContentWidthPx, ct as getEditableBlocksForZone, cu as findParagraphLocation, cv as createSectionBoundaryParagraph, cw as normalizePageSettings, cx as DEFAULT_EDITOR_PAGE_SETTINGS, cy as markStart, cz as markEnd, cA as getParagraphEntries, cB as getParagraphById, cC as createEditorFootnote, cD as createFootnoteReferenceRun, cE as renumberFootnotes, cF as preciseFontModeVersion, cG as isPreciseFontModeEnabled, cH as getHeadingLevel, cI as togglePreciseFontMode, cJ as nextFontSizePt, cK as previousFontSizePt, cL as fontSizePtToPx, cM as resolveNamedTextStyle, cN as resolveNamedTableStyle, cO as createDefaultToolbarPreset, cP as MenuRegistry, cQ as createToolbarRegistry, cR as Editor, cS as resolveCommandRef, cT as commandRefName, cU as createOasisEditorClient, cV as createEditorZoom, cW as startLongTaskObserver, cX as installGlobalReport, cY as applyStoredPreciseFontPreference, cZ as getWelcomeSeen, c_ as isLocalFontAccessSupported, c$ as EDITOR_SCROLL_PADDING_PX, d0 as Toolbar, d1 as OasisEditorLoading, d2 as I18nProvider, d3 as createTranslator, d4 as registerDomStatsSurface, d5 as createEditorLogger } from "./index-Cbwb1bgI.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 _a2, _b2;
16
+ var _a, _b;
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: ((_a2 = block.style) == null ? void 0 : _a2.floating) ? 0 : tableHeight,
51
- floatingTableHeight: ((_b2 = block.style) == null ? void 0 : _b2.floating) ? tableHeight : void 0,
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,
52
52
  sourceBlock: block
53
53
  };
54
54
  });
@@ -87,7 +87,7 @@ function getProjectedBlocksHeight$1(blocks) {
87
87
  return blocks.reduce((sum, block) => sum + block.estimatedHeight, 0);
88
88
  }
89
89
  function collectFootnoteReferencesFromBlock(block) {
90
- var _a2, _b2;
90
+ var _a, _b;
91
91
  const result = [];
92
92
  const appendFromParagraph = (paragraph, startOffset, endOffset) => {
93
93
  let runStart = 0;
@@ -103,8 +103,8 @@ function collectFootnoteReferencesFromBlock(block) {
103
103
  if (block.sourceBlock.type === "paragraph") {
104
104
  appendFromParagraph(
105
105
  block.sourceBlock,
106
- ((_a2 = block.layout) == null ? void 0 : _a2.startOffset) ?? 0,
107
- ((_b2 = block.layout) == null ? void 0 : _b2.endOffset) ?? getParagraphText(block.sourceBlock).length
106
+ ((_a = block.layout) == null ? void 0 : _a.startOffset) ?? 0,
107
+ ((_b = block.layout) == null ? void 0 : _b.endOffset) ?? getParagraphText(block.sourceBlock).length
108
108
  );
109
109
  return result;
110
110
  }
@@ -126,14 +126,14 @@ function collectPageFootnoteReferenceIds(page) {
126
126
  return ids;
127
127
  }
128
128
  function projectFootnoteBlocksForPage(document2, footnoteReferenceIds, page, totalPages, measuredHeights, measuredParagraphLayouts, measurer, projectBlocks) {
129
- var _a2, _b2, _c;
129
+ var _a, _b, _c;
130
130
  const contentWidth = Math.max(
131
131
  24,
132
132
  getPageContentWidth(page.pageSettings) - FOOTNOTE_MARKER_GUTTER_PX
133
133
  );
134
134
  const blocks = [];
135
135
  for (const footnoteId of footnoteReferenceIds) {
136
- const footnote = (_b2 = (_a2 = document2.footnotes) == null ? void 0 : _a2.items) == null ? void 0 : _b2[footnoteId];
136
+ const footnote = (_b = (_a = document2.footnotes) == null ? void 0 : _a.items) == null ? void 0 : _b[footnoteId];
137
137
  if (!footnote) continue;
138
138
  const projected = projectBlocks(footnote.blocks, {
139
139
  pageIndex: page.index,
@@ -485,13 +485,13 @@ function spacerParagraph() {
485
485
  };
486
486
  }
487
487
  function buildEndnoteFlowBlocks(document2) {
488
- var _a2, _b2, _c;
488
+ var _a, _b, _c;
489
489
  const referenced = listReferencedEndnotes(document2);
490
- const items = (_a2 = document2.endnotes) == null ? void 0 : _a2.items;
490
+ const items = (_a = document2.endnotes) == null ? void 0 : _a.items;
491
491
  if (!items || referenced.length === 0) {
492
492
  return [];
493
493
  }
494
- const format = ((_c = (_b2 = document2.endnotes) == null ? void 0 : _b2.settings) == null ? void 0 : _c.numberFormat) ?? "decimal";
494
+ const format = ((_c = (_b = document2.endnotes) == null ? void 0 : _b.settings) == null ? void 0 : _c.numberFormat) ?? "decimal";
495
495
  const out = [spacerParagraph()];
496
496
  for (const ref of referenced) {
497
497
  const endnote = items[ref.endnoteId];
@@ -534,8 +534,8 @@ function blockContainsNumPagesField(block) {
534
534
  if (block.type === "paragraph") {
535
535
  return block.runs.some(
536
536
  (run) => {
537
- var _a2;
538
- return ((_a2 = getRunField(run)) == null ? void 0 : _a2.type) === "NUMPAGES";
537
+ var _a;
538
+ return ((_a = getRunField(run)) == null ? void 0 : _a.type) === "NUMPAGES";
539
539
  }
540
540
  );
541
541
  }
@@ -559,10 +559,10 @@ function documentContainsNumPagesField(document2) {
559
559
  );
560
560
  }
561
561
  function projectDocumentLayout(document2, maxPageHeightOverride, measuredHeights, measuredParagraphLayouts, options = {}) {
562
- var _a2, _b2;
562
+ var _a, _b;
563
563
  const measurer = options.measurer ?? domTextMeasurer;
564
564
  const projectionContext = createProjectionContext(
565
- ((_a2 = document2.settings) == null ? void 0 : _a2.autoHyphenation) ? {
565
+ ((_a = document2.settings) == null ? void 0 : _a.autoHyphenation) ? {
566
566
  enabled: true,
567
567
  zone: document2.settings.hyphenationZone,
568
568
  consecutiveLimit: document2.settings.consecutiveHyphenLimit,
@@ -579,7 +579,7 @@ function projectDocumentLayout(document2, maxPageHeightOverride, measuredHeights
579
579
  measuredHeights,
580
580
  measuredParagraphLayouts,
581
581
  measurer,
582
- defaultTabStop: (_b2 = document2.settings) == null ? void 0 : _b2.defaultTabStop,
582
+ defaultTabStop: (_b = document2.settings) == null ? void 0 : _b.defaultTabStop,
583
583
  needsTotalPages,
584
584
  projectBlocks: projectBlocksLayout,
585
585
  projectHeaderFooterBlocks,
@@ -857,12 +857,12 @@ function cloneBlock(block) {
857
857
  }
858
858
  }
859
859
  function cloneSection(section) {
860
- var _a2, _b2, _c, _d, _e, _f;
860
+ var _a, _b, _c, _d, _e, _f;
861
861
  return {
862
862
  ...section,
863
863
  blocks: section.blocks.map(cloneBlock),
864
- header: (_a2 = section.header) == null ? void 0 : _a2.map(cloneBlock),
865
- firstPageHeader: (_b2 = section.firstPageHeader) == null ? void 0 : _b2.map(cloneBlock),
864
+ header: (_a = section.header) == null ? void 0 : _a.map(cloneBlock),
865
+ firstPageHeader: (_b = section.firstPageHeader) == null ? void 0 : _b.map(cloneBlock),
866
866
  evenPageHeader: (_c = section.evenPageHeader) == null ? void 0 : _c.map(cloneBlock),
867
867
  footer: (_d = section.footer) == null ? void 0 : _d.map(cloneBlock),
868
868
  firstPageFooter: (_e = section.firstPageFooter) == null ? void 0 : _e.map(cloneBlock),
@@ -876,7 +876,7 @@ function cloneFootnote(footnote) {
876
876
  };
877
877
  }
878
878
  function cloneFootnotes(footnotes) {
879
- var _a2, _b2;
879
+ var _a, _b;
880
880
  if (!footnotes) return void 0;
881
881
  const nextItems = {};
882
882
  for (const [id, footnote] of Object.entries(footnotes.items)) {
@@ -885,8 +885,8 @@ function cloneFootnotes(footnotes) {
885
885
  return {
886
886
  items: nextItems,
887
887
  settings: footnotes.settings ? { ...footnotes.settings } : void 0,
888
- separator: (_a2 = footnotes.separator) == null ? void 0 : _a2.map(cloneBlock),
889
- continuationSeparator: (_b2 = footnotes.continuationSeparator) == null ? void 0 : _b2.map(cloneBlock)
888
+ separator: (_a = footnotes.separator) == null ? void 0 : _a.map(cloneBlock),
889
+ continuationSeparator: (_b = footnotes.continuationSeparator) == null ? void 0 : _b.map(cloneBlock)
890
890
  };
891
891
  }
892
892
  function cloneEndnote(endnote) {
@@ -896,7 +896,7 @@ function cloneEndnote(endnote) {
896
896
  };
897
897
  }
898
898
  function cloneEndnotes(endnotes) {
899
- var _a2, _b2;
899
+ var _a, _b;
900
900
  if (!endnotes) return void 0;
901
901
  const nextItems = {};
902
902
  for (const [id, endnote] of Object.entries(endnotes.items)) {
@@ -905,17 +905,17 @@ function cloneEndnotes(endnotes) {
905
905
  return {
906
906
  items: nextItems,
907
907
  settings: endnotes.settings ? { ...endnotes.settings } : void 0,
908
- separator: (_a2 = endnotes.separator) == null ? void 0 : _a2.map(cloneBlock),
909
- continuationSeparator: (_b2 = endnotes.continuationSeparator) == null ? void 0 : _b2.map(cloneBlock)
908
+ separator: (_a = endnotes.separator) == null ? void 0 : _a.map(cloneBlock),
909
+ continuationSeparator: (_b = endnotes.continuationSeparator) == null ? void 0 : _b.map(cloneBlock)
910
910
  };
911
911
  }
912
912
  function cloneEditorState(source) {
913
- var _a2;
913
+ var _a;
914
914
  return {
915
915
  ...source,
916
916
  document: {
917
917
  ...source.document,
918
- sections: (_a2 = source.document.sections) == null ? void 0 : _a2.map(cloneSection),
918
+ sections: (_a = source.document.sections) == null ? void 0 : _a.map(cloneSection),
919
919
  footnotes: cloneFootnotes(source.document.footnotes),
920
920
  endnotes: cloneEndnotes(source.document.endnotes)
921
921
  },
@@ -1037,7 +1037,7 @@ const getClassNames = (attrs) => {
1037
1037
  return "";
1038
1038
  };
1039
1039
  const replaceElement = (element, { nameAttr, icons: icons2, attrs }) => {
1040
- var _a2;
1040
+ var _a;
1041
1041
  const iconName = element.getAttribute(nameAttr);
1042
1042
  if (iconName == null) return;
1043
1043
  const ComponentName = toPascalCase(iconName);
@@ -1070,7 +1070,7 @@ const replaceElement = (element, { nameAttr, icons: icons2, attrs }) => {
1070
1070
  });
1071
1071
  }
1072
1072
  const svgElement = createElement(iconNode, iconAttrs);
1073
- return (_a2 = element.parentNode) == null ? void 0 : _a2.replaceChild(svgElement, element);
1073
+ return (_a = element.parentNode) == null ? void 0 : _a.replaceChild(svgElement, element);
1074
1074
  };
1075
1075
  /**
1076
1076
  * @license lucide v1.11.0 - ISC
@@ -26998,9 +26998,9 @@ function cloneLayoutSnapshot(snapshot) {
26998
26998
  };
26999
26999
  }
27000
27000
  function isCanvasDebugEnabled() {
27001
- var _a2;
27001
+ var _a;
27002
27002
  const viteEnv = __vite_import_meta_env__ ?? {};
27003
- const processEnv = ((_a2 = globalThis.process) == null ? void 0 : _a2.env) ?? {};
27003
+ const processEnv = ((_a = globalThis.process) == null ? void 0 : _a.env) ?? {};
27004
27004
  return viteEnv.DEV === true || viteEnv.MODE === "test" || processEnv.NODE_ENV === "test" || viteEnv.VITE_OASIS_CANVAS_DEBUG === "1";
27005
27005
  }
27006
27006
  function buildApi() {
@@ -27409,12 +27409,12 @@ function addFontFamily(target, seen, value) {
27409
27409
  target.push(family);
27410
27410
  }
27411
27411
  function computeFontFamilyOptions(document2, toolbarStyleState, localFontFamilies = []) {
27412
- var _a2;
27412
+ var _a;
27413
27413
  const seen = /* @__PURE__ */ new Set();
27414
27414
  const documentFonts = [];
27415
27415
  const fallbackFonts = [];
27416
27416
  for (const style2 of Object.values((document2 == null ? void 0 : document2.styles) ?? {})) {
27417
- addFontFamily(documentFonts, seen, (_a2 = style2.textStyle) == null ? void 0 : _a2.fontFamily);
27417
+ addFontFamily(documentFonts, seen, (_a = style2.textStyle) == null ? void 0 : _a.fontFamily);
27418
27418
  }
27419
27419
  addFontFamily(documentFonts, seen, toolbarStyleState.fontFamily);
27420
27420
  for (const family of localFontFamilies) {
@@ -27429,10 +27429,10 @@ function computeFontFamilyOptions(document2, toolbarStyleState, localFontFamilie
27429
27429
  ];
27430
27430
  }
27431
27431
  function computeFontSizeOptions(document2, toolbarStyleState) {
27432
- var _a2;
27432
+ var _a;
27433
27433
  const values = new Set(STANDARD_FONT_SIZES_PT);
27434
27434
  for (const style2 of Object.values((document2 == null ? void 0 : document2.styles) ?? {})) {
27435
- const fontSize = (_a2 = style2.textStyle) == null ? void 0 : _a2.fontSize;
27435
+ const fontSize = (_a = style2.textStyle) == null ? void 0 : _a.fontSize;
27436
27436
  if (typeof fontSize === "number" && Number.isFinite(fontSize)) {
27437
27437
  values.add(fontSizePxToPt(fontSize));
27438
27438
  }
@@ -27559,7 +27559,7 @@ function clearParagraphList(paragraph) {
27559
27559
  return nextParagraph;
27560
27560
  }
27561
27561
  function getStyleAtOffset(paragraph, offset) {
27562
- var _a2;
27562
+ var _a;
27563
27563
  if (paragraph.runs.length === 0) {
27564
27564
  return void 0;
27565
27565
  }
@@ -27579,7 +27579,7 @@ function getStyleAtOffset(paragraph, offset) {
27579
27579
  }
27580
27580
  consumed = nextConsumed;
27581
27581
  }
27582
- return cloneStyle((_a2 = paragraph.runs[paragraph.runs.length - 1]) == null ? void 0 : _a2.styles);
27582
+ return cloneStyle((_a = paragraph.runs[paragraph.runs.length - 1]) == null ? void 0 : _a.styles);
27583
27583
  }
27584
27584
  function getRunAtOffset(paragraph, offset) {
27585
27585
  let consumed = 0;
@@ -27609,9 +27609,9 @@ function getRunAtOffset(paragraph, offset) {
27609
27609
  return null;
27610
27610
  }
27611
27611
  function expandLinkRangeInParagraph(paragraph, offset) {
27612
- var _a2, _b2, _c;
27612
+ var _a, _b, _c;
27613
27613
  const resolved = getRunAtOffset(paragraph, offset);
27614
- const href = (_a2 = resolved == null ? void 0 : resolved.run.styles) == null ? void 0 : _a2.link;
27614
+ const href = (_a = resolved == null ? void 0 : resolved.run.styles) == null ? void 0 : _a.link;
27615
27615
  if (!resolved || !href || resolved.run.kind === "image") {
27616
27616
  return null;
27617
27617
  }
@@ -27630,7 +27630,7 @@ function expandLinkRangeInParagraph(paragraph, offset) {
27630
27630
  endOffset = consumed + resolved.run.text.length;
27631
27631
  for (let index = runIndex - 1; index >= 0; index -= 1) {
27632
27632
  const run = runs[index];
27633
- if (run.kind === "image" || ((_b2 = run.styles) == null ? void 0 : _b2.link) !== href) {
27633
+ if (run.kind === "image" || ((_b = run.styles) == null ? void 0 : _b.link) !== href) {
27634
27634
  break;
27635
27635
  }
27636
27636
  startOffset -= run.text.length;
@@ -27985,8 +27985,8 @@ function deleteSelectionRange(state) {
27985
27985
  const startOffset2 = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
27986
27986
  const endOffset2 = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
27987
27987
  return mapRunsInRange(paragraph, startOffset2, endOffset2, (run) => {
27988
- var _a2;
27989
- if (((_a2 = run.revision) == null ? void 0 : _a2.type) === "insert") {
27988
+ var _a;
27989
+ if (((_a = run.revision) == null ? void 0 : _a.type) === "insert") {
27990
27990
  return { ...run, text: "" };
27991
27991
  }
27992
27992
  return {
@@ -28312,7 +28312,7 @@ function insertPlainTextAtSelection(state, text, styleOverride) {
28312
28312
  );
28313
28313
  }
28314
28314
  function deleteBackward(state) {
28315
- var _a2;
28315
+ var _a;
28316
28316
  if (!isSelectionCollapsed(state.selection)) {
28317
28317
  return deleteSelectionRange(state);
28318
28318
  }
@@ -28335,7 +28335,7 @@ function deleteBackward(state) {
28335
28335
  }
28336
28336
  if (targetRunIndex !== -1) {
28337
28337
  const targetRun = runs[targetRunIndex];
28338
- if (((_a2 = targetRun.revision) == null ? void 0 : _a2.type) === "insert") {
28338
+ if (((_a = targetRun.revision) == null ? void 0 : _a.type) === "insert") {
28339
28339
  const nextRuns2 = [
28340
28340
  ...sliceRuns(paragraph, 0, offset - 1),
28341
28341
  ...sliceRuns(paragraph, offset, getParagraphLength(paragraph))
@@ -28421,7 +28421,7 @@ function deleteBackward(state) {
28421
28421
  );
28422
28422
  }
28423
28423
  function deleteForward(state) {
28424
- var _a2;
28424
+ var _a;
28425
28425
  if (!isSelectionCollapsed(state.selection)) {
28426
28426
  return deleteSelectionRange(state);
28427
28427
  }
@@ -28444,7 +28444,7 @@ function deleteForward(state) {
28444
28444
  }
28445
28445
  if (targetRunIndex !== -1) {
28446
28446
  const targetRun = runs[targetRunIndex];
28447
- if (((_a2 = targetRun.revision) == null ? void 0 : _a2.type) === "insert") {
28447
+ if (((_a = targetRun.revision) == null ? void 0 : _a.type) === "insert") {
28448
28448
  const nextRuns2 = [
28449
28449
  ...sliceRuns(paragraph, 0, offset),
28450
28450
  ...sliceRuns(paragraph, offset + 1, getParagraphLength(paragraph))
@@ -28545,8 +28545,8 @@ function toggleTextStyle(state, key) {
28545
28545
  }
28546
28546
  const shouldEnable = !touchedRuns.every(
28547
28547
  (run) => {
28548
- var _a2;
28549
- return Boolean((_a2 = run.styles) == null ? void 0 : _a2[key]);
28548
+ var _a;
28549
+ return Boolean((_a = run.styles) == null ? void 0 : _a[key]);
28550
28550
  }
28551
28551
  );
28552
28552
  const nextParagraphs = paragraphs.map(
@@ -28582,8 +28582,8 @@ function clearSelectedTextFormatting(state) {
28582
28582
  const startOffset = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
28583
28583
  const endOffset = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
28584
28584
  return mapRunsInRange(paragraph, startOffset, endOffset, (run) => {
28585
- var _a2;
28586
- const link = (_a2 = run.styles) == null ? void 0 : _a2.link;
28585
+ var _a;
28586
+ const link = (_a = run.styles) == null ? void 0 : _a.link;
28587
28587
  const styles = link != null && link !== "" ? { link } : {};
28588
28588
  return { ...run, styles };
28589
28589
  });
@@ -28894,7 +28894,7 @@ function createFontDialogBridge(deps) {
28894
28894
  };
28895
28895
  }
28896
28896
  function moveBlockToPosition(state, blockId, targetPosition) {
28897
- var _a2;
28897
+ var _a;
28898
28898
  let movedBlock;
28899
28899
  const removeFromBlocks = (blocks) => {
28900
28900
  const idx = blocks.findIndex((b) => b.id === blockId);
@@ -28944,7 +28944,7 @@ function moveBlockToPosition(state, blockId, targetPosition) {
28944
28944
  };
28945
28945
  const activeIdx = getActiveSectionIndex(state);
28946
28946
  const zone = getActiveZone(state);
28947
- const activeSection = (_a2 = nextDocument.sections) == null ? void 0 : _a2[activeIdx];
28947
+ const activeSection = (_a = nextDocument.sections) == null ? void 0 : _a[activeIdx];
28948
28948
  const section = { ...activeSection };
28949
28949
  let found = false;
28950
28950
  if (zone === "header") {
@@ -29132,7 +29132,7 @@ function insertSectionBreakAtSelection(state, breakType) {
29132
29132
  };
29133
29133
  }
29134
29134
  function updateSectionSettings(state, sectionIndex, settings) {
29135
- var _a2;
29135
+ var _a;
29136
29136
  const sections = getDocumentSections(state.document);
29137
29137
  if (sectionIndex < 0 || sectionIndex >= sections.length) {
29138
29138
  return state;
@@ -29146,7 +29146,7 @@ function updateSectionSettings(state, sectionIndex, settings) {
29146
29146
  ...settings.pageSettings ?? {},
29147
29147
  margins: {
29148
29148
  ...nextSections[sectionIndex].pageSettings.margins,
29149
- ...((_a2 = settings.pageSettings) == null ? void 0 : _a2.margins) ?? {}
29149
+ ...((_a = settings.pageSettings) == null ? void 0 : _a.margins) ?? {}
29150
29150
  }
29151
29151
  }
29152
29152
  };
@@ -29508,6 +29508,11 @@ function updateActiveTableBlocks(state, updateTable) {
29508
29508
  }
29509
29509
  };
29510
29510
  }
29511
+ const DEFAULT_TABLE_BORDER = {
29512
+ width: 0.5,
29513
+ type: "solid",
29514
+ color: "#000000"
29515
+ };
29511
29516
  function collectTableSelectedParagraphIds(state) {
29512
29517
  const selectedParagraphIds = /* @__PURE__ */ new Set();
29513
29518
  const activeSectionIndex = getActiveSectionIndex(state);
@@ -29635,6 +29640,39 @@ function setTableCellBorders(state, border) {
29635
29640
  nextState = setTableCellStyleValue(nextState, "borderLeft", border);
29636
29641
  return nextState;
29637
29642
  }
29643
+ function applyTableBorderPreset(state, preset, border = DEFAULT_TABLE_BORDER) {
29644
+ const apply = (current, keys, value) => keys.reduce(
29645
+ (next, key) => setTableCellStyleValue(next, key, value),
29646
+ current
29647
+ );
29648
+ const edges = ["borderTop", "borderRight", "borderBottom", "borderLeft"];
29649
+ switch (preset) {
29650
+ case "none":
29651
+ return apply(
29652
+ state,
29653
+ [...edges, "borderTopLeftToBottomRight", "borderTopRightToBottomLeft"],
29654
+ null
29655
+ );
29656
+ case "bottom":
29657
+ return apply(state, ["borderBottom"], border);
29658
+ case "top":
29659
+ return apply(state, ["borderTop"], border);
29660
+ case "left":
29661
+ return apply(state, ["borderLeft"], border);
29662
+ case "right":
29663
+ return apply(state, ["borderRight"], border);
29664
+ case "diagonalDown":
29665
+ return apply(state, ["borderTopLeftToBottomRight"], border);
29666
+ case "diagonalUp":
29667
+ return apply(state, ["borderTopRightToBottomLeft"], border);
29668
+ case "all":
29669
+ case "outside":
29670
+ case "inside":
29671
+ case "insideHorizontal":
29672
+ case "insideVertical":
29673
+ return apply(state, edges, border);
29674
+ }
29675
+ }
29638
29676
  function collectLinearSelectedParagraphIds(state) {
29639
29677
  const normalized = normalizeSelection(state);
29640
29678
  const paragraphs = getParagraphs(state);
@@ -29788,10 +29826,10 @@ function setTableRowHeight(state, tableId, rowIndex, height) {
29788
29826
  const DEFAULT_DISTRIBUTED_ROW_PX = 24;
29789
29827
  function distributeSelectedTableRows(state) {
29790
29828
  return updateActiveTableBlocks(state, (table) => {
29791
- var _a2;
29829
+ var _a;
29792
29830
  let target = 0;
29793
29831
  for (const row of table.rows) {
29794
- const height = (_a2 = row.style) == null ? void 0 : _a2.height;
29832
+ const height = (_a = row.style) == null ? void 0 : _a.height;
29795
29833
  const px = typeof height === "number" ? height : typeof height === "string" ? Number.parseFloat(height) : 0;
29796
29834
  if (Number.isFinite(px) && px > target) target = px;
29797
29835
  }
@@ -29837,7 +29875,7 @@ function parseUnitToPt(value) {
29837
29875
  const DEFAULT_DISTRIBUTED_COLUMN_PT = 120;
29838
29876
  function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableIndentLeft) {
29839
29877
  const updateTable = (table) => {
29840
- var _a2;
29878
+ var _a;
29841
29879
  if (table.id !== tableId) return table;
29842
29880
  const tableLayout = buildTableCellLayout(table);
29843
29881
  const visualColumnCount = Math.max(
@@ -29856,7 +29894,7 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
29856
29894
  hasGridOverride = true;
29857
29895
  continue;
29858
29896
  }
29859
- const existing = (_a2 = table.gridCols) == null ? void 0 : _a2[columnIndex];
29897
+ const existing = (_a = table.gridCols) == null ? void 0 : _a[columnIndex];
29860
29898
  if (typeof existing === "number" && Number.isFinite(existing) && existing > 0) {
29861
29899
  nextGridCols[columnIndex] = existing;
29862
29900
  continue;
@@ -29867,7 +29905,7 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
29867
29905
  const nextRows = table.rows.map((row, rowIndex) => {
29868
29906
  const nextCells = row.cells.map(
29869
29907
  (cell, cellIndex) => {
29870
- var _a3, _b2;
29908
+ var _a2, _b;
29871
29909
  const entry = tableLayout.find(
29872
29910
  (item) => item.rowIndex === rowIndex && item.cellIndex === cellIndex
29873
29911
  );
@@ -29875,11 +29913,11 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
29875
29913
  const rightVisualColumnIndex = entry.visualColumnIndex + entry.colSpan - 1;
29876
29914
  const newWidth = columnWidths[rightVisualColumnIndex];
29877
29915
  if (newWidth !== void 0 && entry.colSpan === 1) {
29878
- const propertyRevision = state.trackChangesEnabled && !((_a3 = cell.style) == null ? void 0 : _a3.propertyRevision) ? {
29916
+ const propertyRevision = state.trackChangesEnabled && !((_a2 = cell.style) == null ? void 0 : _a2.propertyRevision) ? {
29879
29917
  ...createTableRevisionMetadata(),
29880
29918
  type: "property",
29881
29919
  previous: { ...cell.style ?? {} }
29882
- } : (_b2 = cell.style) == null ? void 0 : _b2.propertyRevision;
29920
+ } : (_b = cell.style) == null ? void 0 : _b.propertyRevision;
29883
29921
  return {
29884
29922
  ...cell,
29885
29923
  style: {
@@ -30147,17 +30185,17 @@ function isVisibleBorder(border) {
30147
30185
  return !!border && border.type !== "none" && border.width > 0;
30148
30186
  }
30149
30187
  function buildFloatingSummary(table) {
30150
- var _a2;
30151
- const floating = (_a2 = table.style) == null ? void 0 : _a2.floating;
30188
+ var _a;
30189
+ const floating = (_a = table.style) == null ? void 0 : _a.floating;
30152
30190
  if (!floating || Object.keys(floating).length === 0) return "";
30153
30191
  return Object.entries(floating).map(([key, value]) => `${key}=${value}`).join(", ");
30154
30192
  }
30155
30193
  function buildInitialValues(ctx, activeTab = "table") {
30156
- 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;
30157
- const tableWidth = serializeWidth((_a2 = ctx.table.style) == null ? void 0 : _a2.width);
30194
+ 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;
30195
+ const tableWidth = serializeWidth((_a = ctx.table.style) == null ? void 0 : _a.width);
30158
30196
  const row = ctx.table.rows[ctx.rowIndex];
30159
30197
  const cell = row == null ? void 0 : row.cells[ctx.cellIndex];
30160
- const rowHeight = serializeWidth((_b2 = row == null ? void 0 : row.style) == null ? void 0 : _b2.height);
30198
+ const rowHeight = serializeWidth((_b = row == null ? void 0 : row.style) == null ? void 0 : _b.height);
30161
30199
  const cellWidth = serializeWidth((_c = cell == null ? void 0 : cell.style) == null ? void 0 : _c.width);
30162
30200
  const gridWidth = (_d = ctx.table.gridCols) == null ? void 0 : _d[ctx.visualColumnIndex];
30163
30201
  const columnWidth = serializeWidth(gridWidth);
@@ -30581,14 +30619,14 @@ function textLanguageToHtmlAttributes(language) {
30581
30619
  return attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
30582
30620
  }
30583
30621
  function serializeImageRunToHtml(run, document2) {
30584
- var _a2;
30622
+ var _a;
30585
30623
  if (run.kind !== "image") {
30586
30624
  return "";
30587
30625
  }
30588
30626
  const resolvedSrc = resolveImageSrc(document2, run.image.src);
30589
30627
  const altAttr = run.image.alt !== void 0 ? ` alt="${escapeHtml(run.image.alt)}"` : "";
30590
30628
  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}>`;
30591
- if ((_a2 = run.styles) == null ? void 0 : _a2.link) {
30629
+ if ((_a = run.styles) == null ? void 0 : _a.link) {
30592
30630
  return `<a href="${escapeHtml(run.styles.link)}">${img}</a>`;
30593
30631
  }
30594
30632
  return img;
@@ -30632,7 +30670,7 @@ function serializeParagraphRunsToHtml(runs, document2) {
30632
30670
  return runs.map((run) => serializeTextRunToHtml(run, document2)).join("") || "<br>";
30633
30671
  }
30634
30672
  function serializeEditorSelectionToHtml(state) {
30635
- var _a2;
30673
+ var _a;
30636
30674
  const normalized = normalizeSelection(state);
30637
30675
  if (normalized.isCollapsed) {
30638
30676
  return "";
@@ -30657,7 +30695,7 @@ function serializeEditorSelectionToHtml(state) {
30657
30695
  const css = paragraphStyleToCssText(paragraph.style);
30658
30696
  const attrs = css.length > 0 ? ` style="${css}"` : "";
30659
30697
  const paragraphHtml = serializeParagraphRunsToHtml(runs, state.document);
30660
- if ((_a2 = paragraph.list) == null ? void 0 : _a2.kind) {
30698
+ if ((_a = paragraph.list) == null ? void 0 : _a.kind) {
30661
30699
  const wrapperTag = paragraph.list.kind === "bullet" ? "ul" : "ol";
30662
30700
  if (activeListKind !== paragraph.list.kind) {
30663
30701
  closeList();
@@ -31023,13 +31061,13 @@ function createEditorContextMenuClipboard(deps) {
31023
31061
  function createEditorContextMenuClipboardImpl(deps) {
31024
31062
  const t = deps.t;
31025
31063
  const programmaticCopy = async () => {
31026
- var _a2;
31064
+ var _a;
31027
31065
  const state = deps.state();
31028
31066
  const text = getSelectedText(state);
31029
31067
  if (!text) return;
31030
31068
  const html = serializeEditorSelectionToHtml(state);
31031
31069
  try {
31032
- if (typeof ClipboardItem !== "undefined" && ((_a2 = navigator.clipboard) == null ? void 0 : _a2.write)) {
31070
+ if (typeof ClipboardItem !== "undefined" && ((_a = navigator.clipboard) == null ? void 0 : _a.write)) {
31033
31071
  await navigator.clipboard.write([
31034
31072
  new ClipboardItem({
31035
31073
  "text/plain": new Blob([text], { type: "text/plain" }),
@@ -31063,12 +31101,12 @@ function createEditorContextMenuClipboardImpl(deps) {
31063
31101
  deps.focusInput();
31064
31102
  };
31065
31103
  const programmaticPaste = async () => {
31066
- var _a2, _b2;
31104
+ var _a, _b;
31067
31105
  if (deps.isReadOnly()) return;
31068
31106
  let html = "";
31069
31107
  let text = "";
31070
31108
  try {
31071
- if ((_a2 = navigator.clipboard) == null ? void 0 : _a2.read) {
31109
+ if ((_a = navigator.clipboard) == null ? void 0 : _a.read) {
31072
31110
  const items = await navigator.clipboard.read();
31073
31111
  for (const item of items) {
31074
31112
  if (item.types.includes("text/html")) {
@@ -31080,7 +31118,7 @@ function createEditorContextMenuClipboardImpl(deps) {
31080
31118
  text = await blob.text();
31081
31119
  }
31082
31120
  }
31083
- } else if ((_b2 = navigator.clipboard) == null ? void 0 : _b2.readText) {
31121
+ } else if ((_b = navigator.clipboard) == null ? void 0 : _b.readText) {
31084
31122
  text = await navigator.clipboard.readText();
31085
31123
  }
31086
31124
  } catch (err) {
@@ -31425,19 +31463,19 @@ function createEditorUiOptions(ctx) {
31425
31463
  showToolbar: () => ui().showToolbar ?? true,
31426
31464
  showOutline: () => ui().showOutline ?? true,
31427
31465
  toolbarView: () => {
31428
- var _a2;
31429
- return ((_a2 = ui().toolbar) == null ? void 0 : _a2.view) ?? "ribbon";
31466
+ var _a;
31467
+ return ((_a = ui().toolbar) == null ? void 0 : _a.view) ?? "ribbon";
31430
31468
  },
31431
31469
  toolbarLayout: () => {
31432
- var _a2;
31433
- return ((_a2 = ui().toolbar) == null ? void 0 : _a2.layout) ?? "overflow";
31470
+ var _a;
31471
+ return ((_a = ui().toolbar) == null ? void 0 : _a.layout) ?? "overflow";
31434
31472
  },
31435
31473
  isReadOnly: () => documentOptions().readOnly ?? false,
31436
31474
  useComposedShell: () => ui().uiVariant === "docs" || (ui().shell ?? "document") !== "document",
31437
31475
  loadingOptions,
31438
31476
  loadingLabel: () => {
31439
- var _a2;
31440
- return ((_a2 = loadingOptions()) == null ? void 0 : _a2.label) ?? "Loading oasis-editor...";
31477
+ var _a;
31478
+ return ((_a = loadingOptions()) == null ? void 0 : _a.label) ?? "Loading oasis-editor...";
31441
31479
  },
31442
31480
  shellComponent: () => {
31443
31481
  const s = ui().shell ?? "document";
@@ -31467,7 +31505,7 @@ function computeShouldShowCaret(state, caretBox) {
31467
31505
  }
31468
31506
  function DropCaret(props) {
31469
31507
  const layout = createMemo(() => {
31470
- var _a2, _b2, _c;
31508
+ var _a, _b, _c;
31471
31509
  const pos = props.targetPos();
31472
31510
  const surfaceRef = props.surfaceRef;
31473
31511
  if (!surfaceRef) return null;
@@ -31475,7 +31513,7 @@ function DropCaret(props) {
31475
31513
  surface: surfaceRef,
31476
31514
  state: props.state,
31477
31515
  documentLayout: props.documentLayout(),
31478
- zoomFactor: (_a2 = props.zoomFactor) == null ? void 0 : _a2.call(props)
31516
+ zoomFactor: (_a = props.zoomFactor) == null ? void 0 : _a.call(props)
31479
31517
  });
31480
31518
  let viewportLeft = 0;
31481
31519
  let viewportTop = 0;
@@ -31500,7 +31538,7 @@ function DropCaret(props) {
31500
31538
  };
31501
31539
  }
31502
31540
  }
31503
- const caret = ((_b2 = props.caretViewport) == null ? void 0 : _b2.call(props)) ?? null;
31541
+ const caret = ((_b = props.caretViewport) == null ? void 0 : _b.call(props)) ?? null;
31504
31542
  if (caret) {
31505
31543
  viewportLeft = caret.left;
31506
31544
  viewportTop = caret.top;
@@ -31781,12 +31819,12 @@ function TextInputDialog(props) {
31781
31819
  return props.confirmLabel;
31782
31820
  },
31783
31821
  get cancelTestId() {
31784
- var _a2;
31785
- return (_a2 = props.testIds) == null ? void 0 : _a2.cancel;
31822
+ var _a;
31823
+ return (_a = props.testIds) == null ? void 0 : _a.cancel;
31786
31824
  },
31787
31825
  get confirmTestId() {
31788
- var _a2;
31789
- return (_a2 = props.testIds) == null ? void 0 : _a2.confirm;
31826
+ var _a;
31827
+ return (_a = props.testIds) == null ? void 0 : _a.confirm;
31790
31828
  }
31791
31829
  });
31792
31830
  },
@@ -31808,8 +31846,8 @@ function TextInputDialog(props) {
31808
31846
  return props.placeholder;
31809
31847
  },
31810
31848
  get ["data-testid"]() {
31811
- var _a2;
31812
- return (_a2 = props.testIds) == null ? void 0 : _a2.input;
31849
+ var _a;
31850
+ return (_a = props.testIds) == null ? void 0 : _a.input;
31813
31851
  }
31814
31852
  });
31815
31853
  }
@@ -33517,8 +33555,8 @@ function useParagraphDialogController(props) {
33517
33555
  props.onClose();
33518
33556
  };
33519
33557
  const handleSetDefault = () => {
33520
- var _a2;
33521
- (_a2 = props.onSetDefault) == null ? void 0 : _a2.call(props, collectValues());
33558
+ var _a;
33559
+ (_a = props.onSetDefault) == null ? void 0 : _a.call(props, collectValues());
33522
33560
  props.onClose();
33523
33561
  };
33524
33562
  return {
@@ -35704,9 +35742,9 @@ function ContextMenu(props) {
35704
35742
  get children() {
35705
35743
  var _el$2 = _tmpl$4(), _el$4 = _el$2.firstChild;
35706
35744
  _el$2.$$click = () => {
35707
- var _a2;
35745
+ var _a;
35708
35746
  if (item.disabled) return;
35709
- (_a2 = item.onSelect) == null ? void 0 : _a2.call(item);
35747
+ (_a = item.onSelect) == null ? void 0 : _a.call(item);
35710
35748
  props.onClose();
35711
35749
  };
35712
35750
  insert(_el$2, createComponent(Show, {
@@ -35920,6 +35958,7 @@ function buildEditorViewProps(ctx) {
35920
35958
  } = ctx;
35921
35959
  const layout = {
35922
35960
  documentLayout: layoutInput.documentLayout,
35961
+ remoteWebFonts: layoutInput.remoteWebFonts,
35923
35962
  viewportHeight: layoutInput.viewportHeight,
35924
35963
  class: layoutInput.className,
35925
35964
  style: layoutInput.style,
@@ -35961,12 +36000,12 @@ function buildEditorViewProps(ctx) {
35961
36000
  };
35962
36001
  const fileHandlers = {
35963
36002
  onImportInputChange: (e) => {
35964
- var _a2;
35965
- return files.handleImportFile(((_a2 = e.currentTarget.files) == null ? void 0 : _a2[0]) ?? null);
36003
+ var _a;
36004
+ return files.handleImportFile(((_a = e.currentTarget.files) == null ? void 0 : _a[0]) ?? null);
35966
36005
  },
35967
36006
  onImageInputChange: (e) => {
35968
- var _a2;
35969
- return files.handleInsertImage(((_a2 = e.currentTarget.files) == null ? void 0 : _a2[0]) ?? null);
36007
+ var _a;
36008
+ return files.handleInsertImage(((_a = e.currentTarget.files) == null ? void 0 : _a[0]) ?? null);
35970
36009
  }
35971
36010
  };
35972
36011
  const surfaceHandlers = {
@@ -36499,10 +36538,10 @@ function serializeBorder(border) {
36499
36538
  return serializeDocxBorderAttrs(resolved, DEFAULT_TABLE_BORDER_COLOR);
36500
36539
  }
36501
36540
  function serializeTableCellBorders(cell) {
36502
- var _a2, _b2, _c, _d, _e, _f, _g, _h;
36541
+ var _a, _b, _c, _d, _e, _f, _g, _h;
36503
36542
  const borders = [
36504
- `<w:top ${serializeBorder((_a2 = cell.style) == null ? void 0 : _a2.borderTop)}`,
36505
- `<w:left ${serializeBorder((_b2 = cell.style) == null ? void 0 : _b2.borderLeft)}`,
36543
+ `<w:top ${serializeBorder((_a = cell.style) == null ? void 0 : _a.borderTop)}`,
36544
+ `<w:left ${serializeBorder((_b = cell.style) == null ? void 0 : _b.borderLeft)}`,
36506
36545
  `<w:bottom ${serializeBorder((_c = cell.style) == null ? void 0 : _c.borderBottom)}`,
36507
36546
  `<w:right ${serializeBorder((_d = cell.style) == null ? void 0 : _d.borderRight)}`
36508
36547
  ];
@@ -36560,12 +36599,12 @@ function serializeTableDefaultCellMargins(margins) {
36560
36599
  return parts.length > 0 ? `<w:tblCellMar>${parts.join("")}</w:tblCellMar>` : "";
36561
36600
  }
36562
36601
  function serializeTableCellProperties(cell, fallbackWidthPt) {
36563
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
36602
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
36564
36603
  const colSpan = Math.max(1, Math.floor(cell.colSpan ?? 1));
36565
36604
  const parts = [];
36566
36605
  const conditional = serializeConditionalFlags(cell.conditionalStyle);
36567
36606
  if (conditional) parts.push(conditional);
36568
- const widthXml = serializeCellWidth(((_a2 = cell.style) == null ? void 0 : _a2.width) ?? fallbackWidthPt);
36607
+ const widthXml = serializeCellWidth(((_a = cell.style) == null ? void 0 : _a.width) ?? fallbackWidthPt);
36569
36608
  if (widthXml) {
36570
36609
  parts.push(widthXml);
36571
36610
  }
@@ -36577,7 +36616,7 @@ function serializeTableCellProperties(cell, fallbackWidthPt) {
36577
36616
  } else if (cell.vMerge === "continue") {
36578
36617
  parts.push("<w:vMerge/>");
36579
36618
  }
36580
- if ((_b2 = cell.style) == null ? void 0 : _b2.shading) {
36619
+ if ((_b = cell.style) == null ? void 0 : _b.shading) {
36581
36620
  parts.push(serializeShading(cell.style.shading));
36582
36621
  }
36583
36622
  const noWrap = serializeOnOffElement("noWrap", (_c = cell.style) == null ? void 0 : _c.noWrap);
@@ -36652,10 +36691,10 @@ function serializeTableRowHeightFromStyle(heightValue, heightRule) {
36652
36691
  return `<w:trHeight ${attrs.join(" ")}/>`;
36653
36692
  }
36654
36693
  function serializeTableRowHeight(row) {
36655
- var _a2, _b2;
36694
+ var _a, _b;
36656
36695
  return serializeTableRowHeightFromStyle(
36657
- (_a2 = row.style) == null ? void 0 : _a2.height,
36658
- (_b2 = row.style) == null ? void 0 : _b2.heightRule
36696
+ (_a = row.style) == null ? void 0 : _a.height,
36697
+ (_b = row.style) == null ? void 0 : _b.heightRule
36659
36698
  );
36660
36699
  }
36661
36700
  function serializeTableRowStyleXml(style2) {
@@ -36689,13 +36728,13 @@ function serializeTableRowStyleXml(style2) {
36689
36728
  return parts.length > 0 ? `<w:trPr>${parts.join("")}</w:trPr>` : "";
36690
36729
  }
36691
36730
  function serializeTableRowProperties(row) {
36692
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
36731
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
36693
36732
  const parts = [];
36694
36733
  const conditional = serializeConditionalFlags(row.conditionalStyle);
36695
36734
  if (conditional) parts.push(conditional);
36696
- const gridBefore = serializeGridSkip("gridBefore", (_a2 = row.style) == null ? void 0 : _a2.gridBefore);
36735
+ const gridBefore = serializeGridSkip("gridBefore", (_a = row.style) == null ? void 0 : _a.gridBefore);
36697
36736
  if (gridBefore) parts.push(gridBefore);
36698
- const gridAfter = serializeGridSkip("gridAfter", (_b2 = row.style) == null ? void 0 : _b2.gridAfter);
36737
+ const gridAfter = serializeGridSkip("gridAfter", (_b = row.style) == null ? void 0 : _b.gridAfter);
36699
36738
  if (gridAfter) parts.push(gridAfter);
36700
36739
  const widthBefore = serializeDocxWidthElement(
36701
36740
  "wBefore",
@@ -36764,12 +36803,12 @@ function serializeTableBorders(style2) {
36764
36803
  return xml ? `<w:tblBorders>${xml}</w:tblBorders>` : "";
36765
36804
  }
36766
36805
  function serializeTableProperties(table) {
36767
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
36806
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
36768
36807
  const parts = [];
36769
- if ((_a2 = table.style) == null ? void 0 : _a2.styleId) {
36808
+ if ((_a = table.style) == null ? void 0 : _a.styleId) {
36770
36809
  parts.push(`<w:tblStyle w:val="${escapeXml(table.style.styleId)}"/>`);
36771
36810
  }
36772
- if ((_b2 = table.style) == null ? void 0 : _b2.tblLook) {
36811
+ if ((_b = table.style) == null ? void 0 : _b.tblLook) {
36773
36812
  const l = table.style.tblLook;
36774
36813
  parts.push(
36775
36814
  `<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"}"/>`
@@ -36957,7 +36996,7 @@ function materializeParagraphStyle(paragraph, styles) {
36957
36996
  };
36958
36997
  }
36959
36998
  function materializeRunStyle(run, paragraphStyleId, styles) {
36960
- var _a2;
36999
+ var _a;
36961
37000
  const effective = resolveEffectiveTextStyleForParagraph(
36962
37001
  run.styles,
36963
37002
  paragraphStyleId,
@@ -37013,7 +37052,7 @@ function materializeRunStyle(run, paragraphStyleId, styles) {
37013
37052
  shading: effective.shading,
37014
37053
  language: effective.language
37015
37054
  };
37016
- if ((_a2 = run.styles) == null ? void 0 : _a2.link) {
37055
+ if ((_a = run.styles) == null ? void 0 : _a.link) {
37017
37056
  materialized.link = run.styles.link;
37018
37057
  }
37019
37058
  return materialized;
@@ -37155,11 +37194,11 @@ function serializeParagraphStyleXml(style2) {
37155
37194
  return parts.length > 0 ? `<w:pPr>${parts.join("")}</w:pPr>` : "";
37156
37195
  }
37157
37196
  function serializeParagraphProperties(paragraph, numberingInfo, styles, overrides) {
37158
- var _a2, _b2;
37197
+ var _a, _b;
37159
37198
  const parts = [];
37160
37199
  const style2 = materializeParagraphStyle(paragraph, styles);
37161
- const align = ((_a2 = paragraph.style) == null ? void 0 : _a2.align) ?? (overrides == null ? void 0 : overrides.align) ?? style2.align;
37162
- if ((_b2 = paragraph.style) == null ? void 0 : _b2.styleId) {
37200
+ const align = ((_a = paragraph.style) == null ? void 0 : _a.align) ?? (overrides == null ? void 0 : overrides.align) ?? style2.align;
37201
+ if ((_b = paragraph.style) == null ? void 0 : _b.styleId) {
37163
37202
  parts.push(`<w:pStyle w:val="${escapeXml(paragraph.style.styleId)}"/>`);
37164
37203
  }
37165
37204
  if (align) {
@@ -37890,7 +37929,7 @@ function serializeRun(run, context, paragraphStyleId, styles, serializeBlocksXml
37890
37929
  });
37891
37930
  }
37892
37931
  function serializeRunWithRelationships(run, context, paragraphStyleId, styles, serializeBlocksXml2) {
37893
- var _a2;
37932
+ var _a;
37894
37933
  const runXml = serializeRun(
37895
37934
  run,
37896
37935
  context,
@@ -37898,7 +37937,7 @@ function serializeRunWithRelationships(run, context, paragraphStyleId, styles, s
37898
37937
  styles,
37899
37938
  serializeBlocksXml2
37900
37939
  );
37901
- const href = (_a2 = run.styles) == null ? void 0 : _a2.link;
37940
+ const href = (_a = run.styles) == null ? void 0 : _a.link;
37902
37941
  if (!href) {
37903
37942
  return runXml;
37904
37943
  }
@@ -37977,18 +38016,18 @@ function serializeRunsWithBoundaries(runs, tokens, context, paragraphStyleId, st
37977
38016
  return out;
37978
38017
  }
37979
38018
  function serializeSingleBlockXml(block, context, styles) {
37980
- var _a2;
38019
+ var _a;
37981
38020
  switch (block.type) {
37982
38021
  case "paragraph":
37983
38022
  return serializeParagraphXml(block, context, styles);
37984
38023
  case "table": {
37985
- const pageBreakXml = ((_a2 = block.style) == null ? void 0 : _a2.pageBreakBefore) ? '<w:p><w:r><w:br w:type="page"/></w:r></w:p>' : "";
38024
+ const pageBreakXml = ((_a = block.style) == null ? void 0 : _a.pageBreakBefore) ? '<w:p><w:r><w:br w:type="page"/></w:r></w:p>' : "";
37986
38025
  return pageBreakXml + serializeTableXml(
37987
38026
  block,
37988
38027
  (paragraph, cell) => {
37989
- var _a3;
38028
+ var _a2;
37990
38029
  return serializeParagraphXml(paragraph, context, styles, {
37991
- align: (_a3 = cell.style) == null ? void 0 : _a3.horizontalAlign
38030
+ align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
37992
38031
  });
37993
38032
  }
37994
38033
  );
@@ -37998,12 +38037,12 @@ function serializeSingleBlockXml(block, context, styles) {
37998
38037
  }
37999
38038
  }
38000
38039
  function serializeBlocksXml(blocks, context, styles) {
38001
- var _a2, _b2, _c;
38040
+ var _a, _b, _c;
38002
38041
  let out = "";
38003
38042
  let i = 0;
38004
38043
  while (i < blocks.length) {
38005
38044
  const block = blocks[i];
38006
- const wrapper = (_a2 = block.sdtWrappers) == null ? void 0 : _a2[0];
38045
+ const wrapper = (_a = block.sdtWrappers) == null ? void 0 : _a[0];
38007
38046
  if (!wrapper) {
38008
38047
  out += serializeSingleBlockXml(block, context, styles);
38009
38048
  i += 1;
@@ -38011,7 +38050,7 @@ function serializeBlocksXml(blocks, context, styles) {
38011
38050
  }
38012
38051
  const group = [];
38013
38052
  let j = i;
38014
- while (j < blocks.length && ((_c = (_b2 = blocks[j].sdtWrappers) == null ? void 0 : _b2[0]) == null ? void 0 : _c.groupId) === wrapper.groupId) {
38053
+ while (j < blocks.length && ((_c = (_b = blocks[j].sdtWrappers) == null ? void 0 : _b[0]) == null ? void 0 : _c.groupId) === wrapper.groupId) {
38015
38054
  const rest = blocks[j].sdtWrappers.slice(1);
38016
38055
  group.push({
38017
38056
  ...blocks[j],
@@ -38026,11 +38065,11 @@ function serializeBlocksXml(blocks, context, styles) {
38026
38065
  return out;
38027
38066
  }
38028
38067
  function serializeParagraphXml(paragraph, context, styles, overrides) {
38029
- var _a2, _b2, _c;
38068
+ var _a, _b, _c;
38030
38069
  const runs = paragraph.runs.length > 0 ? paragraph.runs : [{ id: "", text: "", kind: "text" }];
38031
38070
  const dropCapFrame = paragraph.dropCap ? serializeDropCapFrameParagraph(paragraph.dropCap) : "";
38032
- const bookmarkEvents = (_a2 = context.bookmarkEventsByParagraph) == null ? void 0 : _a2.get(paragraph.id);
38033
- const commentEvents = (_b2 = context.commentEventsByParagraph) == null ? void 0 : _b2.get(paragraph.id);
38071
+ const bookmarkEvents = (_a = context.bookmarkEventsByParagraph) == null ? void 0 : _a.get(paragraph.id);
38072
+ const commentEvents = (_b = context.commentEventsByParagraph) == null ? void 0 : _b.get(paragraph.id);
38034
38073
  const boundaryTokens = [
38035
38074
  ...(bookmarkEvents ?? []).map(
38036
38075
  (e) => ({
@@ -38055,11 +38094,11 @@ function serializeParagraphXml(paragraph, context, styles, overrides) {
38055
38094
  styles
38056
38095
  ) : runs.map(
38057
38096
  (run) => {
38058
- var _a3;
38097
+ var _a2;
38059
38098
  return serializeRunWithRelationships(
38060
38099
  run,
38061
38100
  context,
38062
- (_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
38101
+ (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
38063
38102
  styles,
38064
38103
  serializeBlocksXml
38065
38104
  );
@@ -38074,8 +38113,8 @@ function serializeParagraphXml(paragraph, context, styles, overrides) {
38074
38113
  }
38075
38114
  const FIRST_FOOTNOTE_DOCX_ID = 1;
38076
38115
  function collectReferencedFootnotesForExport(document2) {
38077
- var _a2;
38078
- const items = (_a2 = document2.footnotes) == null ? void 0 : _a2.items;
38116
+ var _a;
38117
+ const items = (_a = document2.footnotes) == null ? void 0 : _a.items;
38079
38118
  if (!items) return [];
38080
38119
  const seen = /* @__PURE__ */ new Map();
38081
38120
  let nextDocxId = FIRST_FOOTNOTE_DOCX_ID;
@@ -38123,11 +38162,11 @@ function createEmptyFootnoteBodyParagraph(withMarker = true) {
38123
38162
  };
38124
38163
  }
38125
38164
  function prependFootnoteRefMarker(paragraph) {
38126
- var _a2;
38165
+ var _a;
38127
38166
  return {
38128
38167
  ...paragraph,
38129
38168
  runs: [makeFootnoteRefMarkerRun(), ...paragraph.runs],
38130
- style: ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "FootnoteText" }
38169
+ style: ((_a = paragraph.style) == null ? void 0 : _a.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "FootnoteText" }
38131
38170
  };
38132
38171
  }
38133
38172
  function makeFootnoteRefMarkerRun() {
@@ -38156,9 +38195,9 @@ function buildFootnotesXml(document2, referenced, numberingContext, state, build
38156
38195
  return serializeTableXml(
38157
38196
  block,
38158
38197
  (paragraph, cell) => {
38159
- var _a2;
38198
+ var _a;
38160
38199
  return serializeParagraphXml(paragraph, partContext, styles, {
38161
- align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
38200
+ align: (_a = cell.style) == null ? void 0 : _a.horizontalAlign
38162
38201
  });
38163
38202
  }
38164
38203
  );
@@ -38170,8 +38209,8 @@ function buildFootnotesXml(document2, referenced, numberingContext, state, build
38170
38209
  }
38171
38210
  const FIRST_ENDNOTE_DOCX_ID = 1;
38172
38211
  function collectReferencedEndnotesForExport(document2) {
38173
- var _a2;
38174
- const items = (_a2 = document2.endnotes) == null ? void 0 : _a2.items;
38212
+ var _a;
38213
+ const items = (_a = document2.endnotes) == null ? void 0 : _a.items;
38175
38214
  if (!items) return [];
38176
38215
  const seen = /* @__PURE__ */ new Map();
38177
38216
  let nextDocxId = FIRST_ENDNOTE_DOCX_ID;
@@ -38219,11 +38258,11 @@ function createEmptyEndnoteBodyParagraph(withMarker = true) {
38219
38258
  };
38220
38259
  }
38221
38260
  function prependEndnoteRefMarker(paragraph) {
38222
- var _a2;
38261
+ var _a;
38223
38262
  return {
38224
38263
  ...paragraph,
38225
38264
  runs: [makeEndnoteRefMarkerRun(), ...paragraph.runs],
38226
- style: ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "EndnoteText" }
38265
+ style: ((_a = paragraph.style) == null ? void 0 : _a.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "EndnoteText" }
38227
38266
  };
38228
38267
  }
38229
38268
  function makeEndnoteRefMarkerRun() {
@@ -38251,9 +38290,9 @@ function buildEndnotesXml(_document, referenced, _numberingContext, _state, buil
38251
38290
  return serializeTableXml(
38252
38291
  block,
38253
38292
  (paragraph, cell) => {
38254
- var _a2;
38293
+ var _a;
38255
38294
  return serializeParagraphXml(paragraph, partContext, styles, {
38256
- align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
38295
+ align: (_a = cell.style) == null ? void 0 : _a.horizontalAlign
38257
38296
  });
38258
38297
  }
38259
38298
  );
@@ -38682,14 +38721,14 @@ function buildNumberingXml(definitions) {
38682
38721
  }
38683
38722
  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}"`;
38684
38723
  function serializeSectionPropertiesWithReferences(pageSettings, references, section, nextBreakType) {
38685
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
38724
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
38686
38725
  const width = pxToTwips(pageSettings.width, 12240);
38687
38726
  const height = pxToTwips(pageSettings.height, 15840);
38688
38727
  const margins = pageSettings.margins;
38689
38728
  const orientationAttr = pageSettings.orientation === "landscape" ? ' w:orient="landscape"' : "";
38690
38729
  const referencesXml = [
38691
- ((_a2 = references == null ? void 0 : references.header) == null ? void 0 : _a2.first) ? `<w:headerReference w:type="first" r:id="${references.header.first.relId}"/>` : "",
38692
- ((_b2 = references == null ? void 0 : references.header) == null ? void 0 : _b2.even) ? `<w:headerReference w:type="even" r:id="${references.header.even.relId}"/>` : "",
38730
+ ((_a = references == null ? void 0 : references.header) == null ? void 0 : _a.first) ? `<w:headerReference w:type="first" r:id="${references.header.first.relId}"/>` : "",
38731
+ ((_b = references == null ? void 0 : references.header) == null ? void 0 : _b.even) ? `<w:headerReference w:type="even" r:id="${references.header.even.relId}"/>` : "",
38693
38732
  ((_c = references == null ? void 0 : references.header) == null ? void 0 : _c.default) ? `<w:headerReference w:type="default" r:id="${references.header.default.relId}"/>` : "",
38694
38733
  ((_d = references == null ? void 0 : references.footer) == null ? void 0 : _d.first) ? `<w:footerReference w:type="first" r:id="${references.footer.first.relId}"/>` : "",
38695
38734
  ((_e = references == null ? void 0 : references.footer) == null ? void 0 : _e.even) ? `<w:footerReference w:type="even" r:id="${references.footer.even.relId}"/>` : "",
@@ -38732,7 +38771,7 @@ function serializeSectionPropertiesWithReferences(pageSettings, references, sect
38732
38771
  function buildDocumentXml(document2, context, sectionReferences) {
38733
38772
  const sections = getDocumentSections(document2);
38734
38773
  const sectionsXml = sections.map((section, sectionIndex) => {
38735
- var _a2;
38774
+ var _a;
38736
38775
  const blocksXml = serializeBlocksXml(
38737
38776
  section.blocks,
38738
38777
  context,
@@ -38742,7 +38781,7 @@ function buildDocumentXml(document2, context, sectionReferences) {
38742
38781
  section.pageSettings,
38743
38782
  sectionReferences[sectionIndex],
38744
38783
  section,
38745
- (_a2 = sections[sectionIndex + 1]) == null ? void 0 : _a2.breakType
38784
+ (_a = sections[sectionIndex + 1]) == null ? void 0 : _a.breakType
38746
38785
  );
38747
38786
  return blocksXml + sectionPr;
38748
38787
  }).join("");
@@ -38790,11 +38829,11 @@ function createImageCaptionParagraph(captionText, label, sequenceNumber) {
38790
38829
  return paragraph;
38791
38830
  }
38792
38831
  function isImageCaptionParagraph(paragraph) {
38793
- var _a2, _b2;
38832
+ var _a, _b;
38794
38833
  if (!paragraph) {
38795
38834
  return false;
38796
38835
  }
38797
- const styleId = (_b2 = (_a2 = paragraph.style) == null ? void 0 : _a2.styleId) == null ? void 0 : _b2.toLowerCase();
38836
+ const styleId = (_b = (_a = paragraph.style) == null ? void 0 : _a.styleId) == null ? void 0 : _b.toLowerCase();
38798
38837
  if (styleId !== "caption") {
38799
38838
  return false;
38800
38839
  }
@@ -38806,7 +38845,7 @@ function isImageCaptionParagraph(paragraph) {
38806
38845
  });
38807
38846
  }
38808
38847
  function getImageCaptionText(paragraph) {
38809
- var _a2;
38848
+ var _a;
38810
38849
  if (!isImageCaptionParagraph(paragraph)) {
38811
38850
  return "";
38812
38851
  }
@@ -38817,15 +38856,15 @@ function getImageCaptionText(paragraph) {
38817
38856
  value += run.text;
38818
38857
  continue;
38819
38858
  }
38820
- if (((_a2 = getRunFieldChar(run)) == null ? void 0 : _a2.kind) === "end") {
38859
+ if (((_a = getRunFieldChar(run)) == null ? void 0 : _a.kind) === "end") {
38821
38860
  afterField = true;
38822
38861
  }
38823
38862
  }
38824
38863
  return value.replace(/^[:\-\s]+/, "");
38825
38864
  }
38826
38865
  function updateImageCaptionParagraph(paragraph, captionText, label) {
38827
- var _a2;
38828
- const currentNumber = ((_a2 = paragraph.runs.find((run) => /^\d+$/.test(run.text))) == null ? void 0 : _a2.text) ?? "1";
38866
+ var _a;
38867
+ const currentNumber = ((_a = paragraph.runs.find((run) => /^\d+$/.test(run.text))) == null ? void 0 : _a.text) ?? "1";
38829
38868
  const next = createImageCaptionParagraph(
38830
38869
  captionText,
38831
38870
  label,
@@ -38924,9 +38963,9 @@ function buildPartContext(blocks, numberingContext, state, document2) {
38924
38963
  const hyperlinks = [];
38925
38964
  const hyperlinkMap = /* @__PURE__ */ new Map();
38926
38965
  visitBlocks(blocks, (paragraph) => {
38927
- var _a2;
38966
+ var _a;
38928
38967
  for (const run of paragraph.runs) {
38929
- const link = (_a2 = run.styles) == null ? void 0 : _a2.link;
38968
+ const link = (_a = run.styles) == null ? void 0 : _a.link;
38930
38969
  if (link && !link.startsWith("#") && !hyperlinkMap.has(link)) {
38931
38970
  const rId2 = `rIdLink${hyperlinks.length + 1}`;
38932
38971
  hyperlinkMap.set(link, rId2);
@@ -39011,7 +39050,7 @@ function writeNotePart(zip, partName, part) {
39011
39050
  }
39012
39051
  }
39013
39052
  async function exportEditorDocumentToDocx(document2) {
39014
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
39053
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
39015
39054
  document2 = renumberImageCaptionsInDocument(document2);
39016
39055
  const zip = new JSZip();
39017
39056
  const numberingContext = buildNumberingContext(document2);
@@ -39053,7 +39092,7 @@ async function exportEditorDocumentToDocx(document2) {
39053
39092
  let nextFooterIndex = 1;
39054
39093
  sections.forEach((section, sectionIndex) => {
39055
39094
  const addPart = (kind, type, blocks) => {
39056
- var _a3;
39095
+ var _a2;
39057
39096
  if (!blocks || blocks.length === 0) {
39058
39097
  return;
39059
39098
  }
@@ -39073,7 +39112,7 @@ async function exportEditorDocumentToDocx(document2) {
39073
39112
  context
39074
39113
  });
39075
39114
  const referenceKey = kind === "header" ? "header" : "footer";
39076
- ((_a3 = sectionReferences[sectionIndex])[referenceKey] ?? (_a3[referenceKey] = {}))[type] = { relId };
39115
+ ((_a2 = sectionReferences[sectionIndex])[referenceKey] ?? (_a2[referenceKey] = {}))[type] = { relId };
39077
39116
  if (kind === "header") {
39078
39117
  nextHeaderIndex += 1;
39079
39118
  } else {
@@ -39090,11 +39129,11 @@ async function exportEditorDocumentToDocx(document2) {
39090
39129
  const hasNumbering = numberingContext.definitions.length > 0;
39091
39130
  const hasEvenAndOddHeaders = sections.some(
39092
39131
  (section) => {
39093
- var _a3, _b3;
39094
- return (((_a3 = section.evenPageHeader) == null ? void 0 : _a3.length) ?? 0) > 0 || (((_b3 = section.evenPageFooter) == null ? void 0 : _b3.length) ?? 0) > 0;
39132
+ var _a2, _b2;
39133
+ return (((_a2 = section.evenPageHeader) == null ? void 0 : _a2.length) ?? 0) > 0 || (((_b2 = section.evenPageFooter) == null ? void 0 : _b2.length) ?? 0) > 0;
39095
39134
  }
39096
39135
  );
39097
- 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;
39136
+ 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;
39098
39137
  const allImages = [
39099
39138
  ...bodyContext.images,
39100
39139
  ...parts.flatMap((part) => part.context.images)
@@ -39125,8 +39164,8 @@ async function exportEditorDocumentToDocx(document2) {
39125
39164
  }
39126
39165
  const imageExtensions = allImages.filter((img) => img.kind === "embedded").map(
39127
39166
  (img) => {
39128
- var _a3;
39129
- return (_a3 = img.target.split(".").pop()) == null ? void 0 : _a3.toLowerCase();
39167
+ var _a2;
39168
+ return (_a2 = img.target.split(".").pop()) == null ? void 0 : _a2.toLowerCase();
39130
39169
  }
39131
39170
  ).filter((ext) => Boolean(ext));
39132
39171
  const hasStyles = document2.styles != null && Object.keys(document2.styles).length > 0;
@@ -39247,24 +39286,24 @@ function borderDashArray(type) {
39247
39286
  }
39248
39287
  }
39249
39288
  function getPadding(textBox) {
39250
- var _a2, _b2, _c, _d;
39289
+ var _a, _b, _c, _d;
39251
39290
  return {
39252
- left: ((_a2 = textBox.body) == null ? void 0 : _a2.paddingLeft) ?? 0,
39253
- top: ((_b2 = textBox.body) == null ? void 0 : _b2.paddingTop) ?? 0,
39291
+ left: ((_a = textBox.body) == null ? void 0 : _a.paddingLeft) ?? 0,
39292
+ top: ((_b = textBox.body) == null ? void 0 : _b.paddingTop) ?? 0,
39254
39293
  right: ((_c = textBox.body) == null ? void 0 : _c.paddingRight) ?? 0,
39255
39294
  bottom: ((_d = textBox.body) == null ? void 0 : _d.paddingBottom) ?? 0
39256
39295
  };
39257
39296
  }
39258
39297
  function drawShapeGeometry(writer, pageIndex, textBox, xPx, yPx, widthPx, heightPx) {
39259
- var _a2, _b2, _c, _d;
39298
+ var _a, _b, _c, _d;
39260
39299
  const segments = getPresetPathSegments(
39261
- (_a2 = textBox.shape) == null ? void 0 : _a2.preset,
39300
+ (_a = textBox.shape) == null ? void 0 : _a.preset,
39262
39301
  pxToPt$1(xPx),
39263
39302
  pxToPt$1(yPx),
39264
39303
  pxToPt$1(widthPx),
39265
39304
  pxToPt$1(heightPx)
39266
39305
  );
39267
- const fill = (_b2 = textBox.shape) == null ? void 0 : _b2.fill;
39306
+ const fill = (_b = textBox.shape) == null ? void 0 : _b.fill;
39268
39307
  const borderColor = (_c = textBox.shape) == null ? void 0 : _c.borderColor;
39269
39308
  const borderWidthPt = ((_d = textBox.shape) == null ? void 0 : _d.borderWidthPt) ?? (borderColor ? 0.75 : 0);
39270
39309
  writer.drawPath(pageIndex, {
@@ -39275,7 +39314,7 @@ function drawShapeGeometry(writer, pageIndex, textBox, xPx, yPx, widthPx, height
39275
39314
  });
39276
39315
  }
39277
39316
  async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heightPx, drawers) {
39278
- var _a2;
39317
+ var _a;
39279
39318
  if (textBox.blocks.length === 0) {
39280
39319
  return;
39281
39320
  }
@@ -39304,7 +39343,7 @@ async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heigh
39304
39343
  styles: ctx.document.styles,
39305
39344
  pageOffset: ctx.pageIndex
39306
39345
  });
39307
- const blocks = ((_a2 = pages[0]) == null ? void 0 : _a2.blocks) ?? [];
39346
+ const blocks = ((_a = pages[0]) == null ? void 0 : _a.blocks) ?? [];
39308
39347
  if (blocks.length === 0) {
39309
39348
  return;
39310
39349
  }
@@ -39780,7 +39819,7 @@ function drawFragmentEmphasis(writer, pageIndex, line, fragment, originX, origin
39780
39819
  }
39781
39820
  }
39782
39821
  function drawTabLeaders(writer, pageIndex, paragraph, line, fragment, document2, originX, baselineY, color) {
39783
- var _a2;
39822
+ var _a;
39784
39823
  const slotByOffset = new Map(
39785
39824
  line.slots.map(
39786
39825
  (slot) => [slot.offset, slot]
@@ -39796,7 +39835,7 @@ function drawTabLeaders(writer, pageIndex, paragraph, line, fragment, document2,
39796
39835
  const slot = slotByOffset.get(char.paragraphOffset);
39797
39836
  const nextSlot = slotByOffset.get(char.paragraphOffset + 1);
39798
39837
  if (!slot || !nextSlot) continue;
39799
- const lineStart = ((_a2 = line.slots[0]) == null ? void 0 : _a2.left) ?? 0;
39838
+ const lineStart = ((_a = line.slots[0]) == null ? void 0 : _a.left) ?? 0;
39800
39839
  const relativeLeft = slot.left - lineStart;
39801
39840
  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];
39802
39841
  const leader = (stop == null ? void 0 : stop.leader) && stop.leader !== "none" ? stop.leader : void 0;
@@ -40050,9 +40089,37 @@ function drawLinkAnnotation(writer, pageIndex, line, fragment, originX, originY,
40050
40089
  function emitFragmentGlyphs(chunkCtx, chars, originX, styles, line, fragment, paragraphAlign) {
40051
40090
  const chunks = paragraphAlign === "justify" ? groupSlotChunksByWhitespace(chars) : groupSlotChunksByOffsetGaps(chars);
40052
40091
  for (const chunk of chunks) {
40053
- const chunkText = chunk.map((c) => styles.allCaps ? c.char.toUpperCase() : c.char).join("");
40054
- if (chunkText.length === 0) continue;
40055
- emitTextChunk(chunkCtx, originX + chunk[0].left, chunkText);
40092
+ let segment = [];
40093
+ let segmentReduced = false;
40094
+ const flush = () => {
40095
+ if (segment.length === 0) return;
40096
+ const text = segment.map((char) => resolveRenderedTextChar(char.char, styles)).join("");
40097
+ if (text.length > 0) {
40098
+ const fontSizePt = segmentReduced ? chunkCtx.fontSizePt * 0.8 : chunkCtx.fontSizePt;
40099
+ emitTextChunk(
40100
+ {
40101
+ ...chunkCtx,
40102
+ fontSizePt,
40103
+ baseTextOptions: {
40104
+ ...chunkCtx.baseTextOptions,
40105
+ fontSize: fontSizePt
40106
+ }
40107
+ },
40108
+ originX + segment[0].left,
40109
+ text
40110
+ );
40111
+ }
40112
+ segment = [];
40113
+ };
40114
+ for (const char of chunk) {
40115
+ const reduced = Boolean(
40116
+ styles.smallCaps && isLowercaseSmallCapsChar(char.char)
40117
+ );
40118
+ if (segment.length > 0 && reduced !== segmentReduced) flush();
40119
+ segmentReduced = reduced;
40120
+ segment.push(char);
40121
+ }
40122
+ flush();
40056
40123
  }
40057
40124
  if (line.trailingHyphen && fragment.endOffset >= line.endOffset) {
40058
40125
  const endSlot = line.slots.find((slot) => slot.offset === line.endOffset) ?? line.slots[line.slots.length - 1];
@@ -40060,7 +40127,7 @@ function emitFragmentGlyphs(chunkCtx, chars, originX, styles, line, fragment, pa
40060
40127
  }
40061
40128
  }
40062
40129
  async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, document2, originX, originY, fontRegistry, drawers) {
40063
- var _a2, _b2, _c;
40130
+ var _a, _b, _c;
40064
40131
  if (fragment.image) {
40065
40132
  if (fragment.image.floating) return;
40066
40133
  const slot = line.slots.find((c) => c.offset === fragment.startOffset) ?? line.slots.find((c) => c.offset >= fragment.startOffset);
@@ -40095,7 +40162,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
40095
40162
  }
40096
40163
  const styles = resolveEffectiveTextStyleForParagraph(
40097
40164
  fragment.styles,
40098
- (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
40165
+ (_a = paragraph.style) == null ? void 0 : _a.styleId,
40099
40166
  document2.styles
40100
40167
  );
40101
40168
  if (styles.hidden) return;
@@ -40104,7 +40171,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
40104
40171
  bold: styles.bold,
40105
40172
  italic: styles.italic
40106
40173
  });
40107
- const fontSizePt = styles.smallCaps ? textStyleToFontSizePt(styles) * 0.8 : textStyleToFontSizePt(styles);
40174
+ const fontSizePt = textStyleToFontSizePt(styles);
40108
40175
  const baselineShiftPx = (styles.baselineShift ?? 0) * PX_PER_POINT;
40109
40176
  const paragraphStyle = resolveEffectiveParagraphStyle(
40110
40177
  paragraph.style,
@@ -40117,9 +40184,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
40117
40184
  );
40118
40185
  const baselineY = originY + line.top + line.height * TEXT_BASELINE_RATIO - baselineShiftPx + textAlignOffset;
40119
40186
  const chars = resolveFragmentSlots(line, fragment);
40120
- const text = chars.map(
40121
- (char) => styles.allCaps ? char.char.toUpperCase() : char.char
40122
- ).join("");
40187
+ const text = chars.map((char) => resolveRenderedTextChar(char.char, styles)).join("");
40123
40188
  const firstChar = chars[0];
40124
40189
  if (!firstChar || text.length === 0) return;
40125
40190
  drawLinkAnnotation(
@@ -40183,7 +40248,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
40183
40248
  horizontalScale: styles.characterScale ?? 100,
40184
40249
  fontFeatures
40185
40250
  };
40186
- 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";
40251
+ 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";
40187
40252
  const gradientShadingName = resolveGradientShadingName(
40188
40253
  writer,
40189
40254
  pageIndex,
@@ -40264,7 +40329,7 @@ function getListOrdinals(document2) {
40264
40329
  return buildListLabels(document2);
40265
40330
  }
40266
40331
  function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX, originY, fontRegistry, listOrdinals) {
40267
- var _a2;
40332
+ var _a;
40268
40333
  if (line.index !== 0) {
40269
40334
  return;
40270
40335
  }
@@ -40278,7 +40343,7 @@ function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX,
40278
40343
  }
40279
40344
  const styles = resolveEffectiveTextStyleForParagraph(
40280
40345
  void 0,
40281
- (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
40346
+ (_a = paragraph.style) == null ? void 0 : _a.styleId,
40282
40347
  document2.styles
40283
40348
  );
40284
40349
  const fontFace = fontRegistry.resolveFontFace({
@@ -40521,7 +40586,7 @@ async function drawTableBlock(writer, pageIndex, block, document2, originX, orig
40521
40586
  }
40522
40587
  const blockDrawers = { drawParagraph, drawTableBlock };
40523
40588
  async function drawBlockList(writer, pageIndex, blocks, document2, originX, originY, contentWidth, fontRegistry, listOrdinals, pageSettings, onParagraphDrawn) {
40524
- var _a2;
40589
+ var _a;
40525
40590
  if (!blocks || blocks.length === 0) {
40526
40591
  return;
40527
40592
  }
@@ -40622,7 +40687,7 @@ async function drawBlockList(writer, pageIndex, blocks, document2, originX, orig
40622
40687
  break;
40623
40688
  }
40624
40689
  case "table":
40625
- if (((_a2 = block.sourceBlock.style) == null ? void 0 : _a2.floating) && pageSettings) {
40690
+ if (((_a = block.sourceBlock.style) == null ? void 0 : _a.floating) && pageSettings) {
40626
40691
  const width = resolveCanvasTableWidth(
40627
40692
  block.sourceBlock,
40628
40693
  contentWidth
@@ -40826,6 +40891,29 @@ class PdfFontRegistry {
40826
40891
  this.fallbackFamily = "Roboto";
40827
40892
  }
40828
40893
  }
40894
+ async loadRemoteWebFontFaces(options = {}) {
40895
+ if (!options.families) return;
40896
+ const faces = await getRemotePdfFontFaces(options.families);
40897
+ for (const face of faces) {
40898
+ const resourceName = `Remote${pdfResourceNamePrefix(
40899
+ face.postscriptName || face.family
40900
+ )}`;
40901
+ this.registerFontFace({
40902
+ key: faceKey(face.family, face.bold, face.italic),
40903
+ family: face.family,
40904
+ bold: face.bold,
40905
+ italic: face.italic,
40906
+ writerResourceName: resourceName,
40907
+ pdfResource: {
40908
+ kind: "unicode",
40909
+ resourceName,
40910
+ family: face.family,
40911
+ fontData: face.fontData,
40912
+ postscriptName: face.postscriptName
40913
+ }
40914
+ });
40915
+ }
40916
+ }
40829
40917
  async registerOfficeCompatibleFaces(requestedFamilies) {
40830
40918
  const matchedFamilies = /* @__PURE__ */ new Set();
40831
40919
  for (const familyDefinition of OFFICE_COMPAT_FONT_FAMILIES) {
@@ -42331,7 +42419,7 @@ class SimpleTextLayouter {
42331
42419
  function view(bytes) {
42332
42420
  return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
42333
42421
  }
42334
- function u16$1(bytes, offset) {
42422
+ function u16(bytes, offset) {
42335
42423
  return view(bytes).getUint16(offset);
42336
42424
  }
42337
42425
  function i16(bytes, offset) {
@@ -42386,8 +42474,8 @@ function collectCompositeGlyphs(glyph, addGlyph) {
42386
42474
  let flags = 0;
42387
42475
  do {
42388
42476
  if (offset + 4 > glyph.byteLength) return;
42389
- flags = u16$1(glyph, offset);
42390
- addGlyph(u16$1(glyph, offset + 2));
42477
+ flags = u16(glyph, offset);
42478
+ addGlyph(u16(glyph, offset + 2));
42391
42479
  offset += 4;
42392
42480
  offset += flags & 1 ? 4 : 2;
42393
42481
  if (flags & 8) offset += 2;
@@ -42404,7 +42492,7 @@ function subsetClosure(font, initialGlyphs) {
42404
42492
  (a, b) => a - b
42405
42493
  );
42406
42494
  }
42407
- const offsets = readLoca(loca, u16$1(head, 50));
42495
+ const offsets = readLoca(loca, u16(head, 50));
42408
42496
  const used = /* @__PURE__ */ new Set([0, ...initialGlyphs]);
42409
42497
  const stack = Array.from(used);
42410
42498
  while (stack.length > 0) {
@@ -42448,7 +42536,7 @@ function buildSubsetTables(font, glyphIds) {
42448
42536
  }
42449
42537
  const maxGlyphId = Math.max(0, ...glyphIds);
42450
42538
  const used = new Set(glyphIds);
42451
- const sourceOffsets = readLoca(loca, u16$1(head, 50));
42539
+ const sourceOffsets = readLoca(loca, u16(head, 50));
42452
42540
  const locaOffsets = [];
42453
42541
  const glyfChunks = [];
42454
42542
  let glyfOffset = 0;
@@ -42849,524 +42937,6 @@ function buildFunctionObject(stops) {
42849
42937
  ">>"
42850
42938
  ].join("\n");
42851
42939
  }
42852
- var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
42853
- var fleb = new u8([
42854
- 0,
42855
- 0,
42856
- 0,
42857
- 0,
42858
- 0,
42859
- 0,
42860
- 0,
42861
- 0,
42862
- 1,
42863
- 1,
42864
- 1,
42865
- 1,
42866
- 2,
42867
- 2,
42868
- 2,
42869
- 2,
42870
- 3,
42871
- 3,
42872
- 3,
42873
- 3,
42874
- 4,
42875
- 4,
42876
- 4,
42877
- 4,
42878
- 5,
42879
- 5,
42880
- 5,
42881
- 5,
42882
- 0,
42883
- /* unused */
42884
- 0,
42885
- 0,
42886
- /* impossible */
42887
- 0
42888
- ]);
42889
- var fdeb = new u8([
42890
- 0,
42891
- 0,
42892
- 0,
42893
- 0,
42894
- 1,
42895
- 1,
42896
- 2,
42897
- 2,
42898
- 3,
42899
- 3,
42900
- 4,
42901
- 4,
42902
- 5,
42903
- 5,
42904
- 6,
42905
- 6,
42906
- 7,
42907
- 7,
42908
- 8,
42909
- 8,
42910
- 9,
42911
- 9,
42912
- 10,
42913
- 10,
42914
- 11,
42915
- 11,
42916
- 12,
42917
- 12,
42918
- 13,
42919
- 13,
42920
- /* unused */
42921
- 0,
42922
- 0
42923
- ]);
42924
- var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
42925
- var freb = function(eb, start) {
42926
- var b = new u16(31);
42927
- for (var i = 0; i < 31; ++i) {
42928
- b[i] = start += 1 << eb[i - 1];
42929
- }
42930
- var r = new i32(b[30]);
42931
- for (var i = 1; i < 30; ++i) {
42932
- for (var j = b[i]; j < b[i + 1]; ++j) {
42933
- r[j] = j - b[i] << 5 | i;
42934
- }
42935
- }
42936
- return { b, r };
42937
- };
42938
- var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;
42939
- fl[28] = 258, revfl[258] = 28;
42940
- var _b = freb(fdeb, 0), revfd = _b.r;
42941
- var rev = new u16(32768);
42942
- for (var i = 0; i < 32768; ++i) {
42943
- var x = (i & 43690) >> 1 | (i & 21845) << 1;
42944
- x = (x & 52428) >> 2 | (x & 13107) << 2;
42945
- x = (x & 61680) >> 4 | (x & 3855) << 4;
42946
- rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
42947
- }
42948
- var hMap = function(cd, mb, r) {
42949
- var s = cd.length;
42950
- var i = 0;
42951
- var l = new u16(mb);
42952
- for (; i < s; ++i) {
42953
- if (cd[i])
42954
- ++l[cd[i] - 1];
42955
- }
42956
- var le = new u16(mb);
42957
- for (i = 1; i < mb; ++i) {
42958
- le[i] = le[i - 1] + l[i - 1] << 1;
42959
- }
42960
- var co;
42961
- if (r) {
42962
- co = new u16(1 << mb);
42963
- var rvb = 15 - mb;
42964
- for (i = 0; i < s; ++i) {
42965
- if (cd[i]) {
42966
- var sv = i << 4 | cd[i];
42967
- var r_1 = mb - cd[i];
42968
- var v = le[cd[i] - 1]++ << r_1;
42969
- for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
42970
- co[rev[v] >> rvb] = sv;
42971
- }
42972
- }
42973
- }
42974
- } else {
42975
- co = new u16(s);
42976
- for (i = 0; i < s; ++i) {
42977
- if (cd[i]) {
42978
- co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i];
42979
- }
42980
- }
42981
- }
42982
- return co;
42983
- };
42984
- var flt = new u8(288);
42985
- for (var i = 0; i < 144; ++i)
42986
- flt[i] = 8;
42987
- for (var i = 144; i < 256; ++i)
42988
- flt[i] = 9;
42989
- for (var i = 256; i < 280; ++i)
42990
- flt[i] = 7;
42991
- for (var i = 280; i < 288; ++i)
42992
- flt[i] = 8;
42993
- var fdt = new u8(32);
42994
- for (var i = 0; i < 32; ++i)
42995
- fdt[i] = 5;
42996
- var flm = /* @__PURE__ */ hMap(flt, 9, 0);
42997
- var fdm = /* @__PURE__ */ hMap(fdt, 5, 0);
42998
- var shft = function(p) {
42999
- return (p + 7) / 8 | 0;
43000
- };
43001
- var slc = function(v, s, e) {
43002
- if (e == null || e > v.length)
43003
- e = v.length;
43004
- return new u8(v.subarray(s, e));
43005
- };
43006
- var wbits = function(d, p, v) {
43007
- v <<= p & 7;
43008
- var o = p / 8 | 0;
43009
- d[o] |= v;
43010
- d[o + 1] |= v >> 8;
43011
- };
43012
- var wbits16 = function(d, p, v) {
43013
- v <<= p & 7;
43014
- var o = p / 8 | 0;
43015
- d[o] |= v;
43016
- d[o + 1] |= v >> 8;
43017
- d[o + 2] |= v >> 16;
43018
- };
43019
- var hTree = function(d, mb) {
43020
- var t = [];
43021
- for (var i = 0; i < d.length; ++i) {
43022
- if (d[i])
43023
- t.push({ s: i, f: d[i] });
43024
- }
43025
- var s = t.length;
43026
- var t2 = t.slice();
43027
- if (!s)
43028
- return { t: et, l: 0 };
43029
- if (s == 1) {
43030
- var v = new u8(t[0].s + 1);
43031
- v[t[0].s] = 1;
43032
- return { t: v, l: 1 };
43033
- }
43034
- t.sort(function(a, b) {
43035
- return a.f - b.f;
43036
- });
43037
- t.push({ s: -1, f: 25001 });
43038
- var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;
43039
- t[0] = { s: -1, f: l.f + r.f, l, r };
43040
- while (i1 != s - 1) {
43041
- l = t[t[i0].f < t[i2].f ? i0++ : i2++];
43042
- r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];
43043
- t[i1++] = { s: -1, f: l.f + r.f, l, r };
43044
- }
43045
- var maxSym = t2[0].s;
43046
- for (var i = 1; i < s; ++i) {
43047
- if (t2[i].s > maxSym)
43048
- maxSym = t2[i].s;
43049
- }
43050
- var tr = new u16(maxSym + 1);
43051
- var mbt = ln(t[i1 - 1], tr, 0);
43052
- if (mbt > mb) {
43053
- var i = 0, dt = 0;
43054
- var lft = mbt - mb, cst = 1 << lft;
43055
- t2.sort(function(a, b) {
43056
- return tr[b.s] - tr[a.s] || a.f - b.f;
43057
- });
43058
- for (; i < s; ++i) {
43059
- var i2_1 = t2[i].s;
43060
- if (tr[i2_1] > mb) {
43061
- dt += cst - (1 << mbt - tr[i2_1]);
43062
- tr[i2_1] = mb;
43063
- } else
43064
- break;
43065
- }
43066
- dt >>= lft;
43067
- while (dt > 0) {
43068
- var i2_2 = t2[i].s;
43069
- if (tr[i2_2] < mb)
43070
- dt -= 1 << mb - tr[i2_2]++ - 1;
43071
- else
43072
- ++i;
43073
- }
43074
- for (; i >= 0 && dt; --i) {
43075
- var i2_3 = t2[i].s;
43076
- if (tr[i2_3] == mb) {
43077
- --tr[i2_3];
43078
- ++dt;
43079
- }
43080
- }
43081
- mbt = mb;
43082
- }
43083
- return { t: new u8(tr), l: mbt };
43084
- };
43085
- var ln = function(n, l, d) {
43086
- return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
43087
- };
43088
- var lc = function(c) {
43089
- var s = c.length;
43090
- while (s && !c[--s])
43091
- ;
43092
- var cl = new u16(++s);
43093
- var cli = 0, cln = c[0], cls = 1;
43094
- var w = function(v) {
43095
- cl[cli++] = v;
43096
- };
43097
- for (var i = 1; i <= s; ++i) {
43098
- if (c[i] == cln && i != s)
43099
- ++cls;
43100
- else {
43101
- if (!cln && cls > 2) {
43102
- for (; cls > 138; cls -= 138)
43103
- w(32754);
43104
- if (cls > 2) {
43105
- w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
43106
- cls = 0;
43107
- }
43108
- } else if (cls > 3) {
43109
- w(cln), --cls;
43110
- for (; cls > 6; cls -= 6)
43111
- w(8304);
43112
- if (cls > 2)
43113
- w(cls - 3 << 5 | 8208), cls = 0;
43114
- }
43115
- while (cls--)
43116
- w(cln);
43117
- cls = 1;
43118
- cln = c[i];
43119
- }
43120
- }
43121
- return { c: cl.subarray(0, cli), n: s };
43122
- };
43123
- var clen = function(cf, cl) {
43124
- var l = 0;
43125
- for (var i = 0; i < cl.length; ++i)
43126
- l += cf[i] * cl[i];
43127
- return l;
43128
- };
43129
- var wfblk = function(out, pos, dat) {
43130
- var s = dat.length;
43131
- var o = shft(pos + 2);
43132
- out[o] = s & 255;
43133
- out[o + 1] = s >> 8;
43134
- out[o + 2] = out[o] ^ 255;
43135
- out[o + 3] = out[o + 1] ^ 255;
43136
- for (var i = 0; i < s; ++i)
43137
- out[o + i + 4] = dat[i];
43138
- return (o + 4 + s) * 8;
43139
- };
43140
- var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
43141
- wbits(out, p++, final);
43142
- ++lf[256];
43143
- var _a2 = hTree(lf, 15), dlt = _a2.t, mlb = _a2.l;
43144
- var _b2 = hTree(df, 15), ddt = _b2.t, mdb = _b2.l;
43145
- var _c = lc(dlt), lclt = _c.c, nlc = _c.n;
43146
- var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;
43147
- var lcfreq = new u16(19);
43148
- for (var i = 0; i < lclt.length; ++i)
43149
- ++lcfreq[lclt[i] & 31];
43150
- for (var i = 0; i < lcdt.length; ++i)
43151
- ++lcfreq[lcdt[i] & 31];
43152
- var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;
43153
- var nlcc = 19;
43154
- for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)
43155
- ;
43156
- var flen = bl + 5 << 3;
43157
- var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
43158
- var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
43159
- if (bs >= 0 && flen <= ftlen && flen <= dtlen)
43160
- return wfblk(out, p, dat.subarray(bs, bs + bl));
43161
- var lm, ll, dm, dl;
43162
- wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
43163
- if (dtlen < ftlen) {
43164
- lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
43165
- var llm = hMap(lct, mlcb, 0);
43166
- wbits(out, p, nlc - 257);
43167
- wbits(out, p + 5, ndc - 1);
43168
- wbits(out, p + 10, nlcc - 4);
43169
- p += 14;
43170
- for (var i = 0; i < nlcc; ++i)
43171
- wbits(out, p + 3 * i, lct[clim[i]]);
43172
- p += 3 * nlcc;
43173
- var lcts = [lclt, lcdt];
43174
- for (var it = 0; it < 2; ++it) {
43175
- var clct = lcts[it];
43176
- for (var i = 0; i < clct.length; ++i) {
43177
- var len = clct[i] & 31;
43178
- wbits(out, p, llm[len]), p += lct[len];
43179
- if (len > 15)
43180
- wbits(out, p, clct[i] >> 5 & 127), p += clct[i] >> 12;
43181
- }
43182
- }
43183
- } else {
43184
- lm = flm, ll = flt, dm = fdm, dl = fdt;
43185
- }
43186
- for (var i = 0; i < li; ++i) {
43187
- var sym = syms[i];
43188
- if (sym > 255) {
43189
- var len = sym >> 18 & 31;
43190
- wbits16(out, p, lm[len + 257]), p += ll[len + 257];
43191
- if (len > 7)
43192
- wbits(out, p, sym >> 23 & 31), p += fleb[len];
43193
- var dst = sym & 31;
43194
- wbits16(out, p, dm[dst]), p += dl[dst];
43195
- if (dst > 3)
43196
- wbits16(out, p, sym >> 5 & 8191), p += fdeb[dst];
43197
- } else {
43198
- wbits16(out, p, lm[sym]), p += ll[sym];
43199
- }
43200
- }
43201
- wbits16(out, p, lm[256]);
43202
- return p + ll[256];
43203
- };
43204
- var deo = /* @__PURE__ */ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
43205
- var et = /* @__PURE__ */ new u8(0);
43206
- var dflt = function(dat, lvl, plvl, pre, post, st) {
43207
- var s = st.z || dat.length;
43208
- var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
43209
- var w = o.subarray(pre, o.length - post);
43210
- var lst = st.l;
43211
- var pos = (st.r || 0) & 7;
43212
- if (lvl) {
43213
- if (pos)
43214
- w[0] = st.r >> 3;
43215
- var opt = deo[lvl - 1];
43216
- var n = opt >> 13, c = opt & 8191;
43217
- var msk_1 = (1 << plvl) - 1;
43218
- var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);
43219
- var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
43220
- var hsh = function(i2) {
43221
- return (dat[i2] ^ dat[i2 + 1] << bs1_1 ^ dat[i2 + 2] << bs2_1) & msk_1;
43222
- };
43223
- var syms = new i32(25e3);
43224
- var lf = new u16(288), df = new u16(32);
43225
- var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
43226
- for (; i + 2 < s; ++i) {
43227
- var hv = hsh(i);
43228
- var imod = i & 32767, pimod = head[hv];
43229
- prev[imod] = pimod;
43230
- head[hv] = imod;
43231
- if (wi <= i) {
43232
- var rem = s - i;
43233
- if ((lc_1 > 7e3 || li > 24576) && (rem > 423 || !lst)) {
43234
- pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
43235
- li = lc_1 = eb = 0, bs = i;
43236
- for (var j = 0; j < 286; ++j)
43237
- lf[j] = 0;
43238
- for (var j = 0; j < 30; ++j)
43239
- df[j] = 0;
43240
- }
43241
- var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
43242
- if (rem > 2 && hv == hsh(i - dif)) {
43243
- var maxn = Math.min(n, rem) - 1;
43244
- var maxd = Math.min(32767, i);
43245
- var ml = Math.min(258, rem);
43246
- while (dif <= maxd && --ch_1 && imod != pimod) {
43247
- if (dat[i + l] == dat[i + l - dif]) {
43248
- var nl = 0;
43249
- for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)
43250
- ;
43251
- if (nl > l) {
43252
- l = nl, d = dif;
43253
- if (nl > maxn)
43254
- break;
43255
- var mmd = Math.min(dif, nl - 2);
43256
- var md = 0;
43257
- for (var j = 0; j < mmd; ++j) {
43258
- var ti = i - dif + j & 32767;
43259
- var pti = prev[ti];
43260
- var cd = ti - pti & 32767;
43261
- if (cd > md)
43262
- md = cd, pimod = ti;
43263
- }
43264
- }
43265
- }
43266
- imod = pimod, pimod = prev[imod];
43267
- dif += imod - pimod & 32767;
43268
- }
43269
- }
43270
- if (d) {
43271
- syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
43272
- var lin = revfl[l] & 31, din = revfd[d] & 31;
43273
- eb += fleb[lin] + fdeb[din];
43274
- ++lf[257 + lin];
43275
- ++df[din];
43276
- wi = i + l;
43277
- ++lc_1;
43278
- } else {
43279
- syms[li++] = dat[i];
43280
- ++lf[dat[i]];
43281
- }
43282
- }
43283
- }
43284
- for (i = Math.max(i, wi); i < s; ++i) {
43285
- syms[li++] = dat[i];
43286
- ++lf[dat[i]];
43287
- }
43288
- pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
43289
- if (!lst) {
43290
- st.r = pos & 7 | w[pos / 8 | 0] << 3;
43291
- pos -= 7;
43292
- st.h = head, st.p = prev, st.i = i, st.w = wi;
43293
- }
43294
- } else {
43295
- for (var i = st.w || 0; i < s + lst; i += 65535) {
43296
- var e = i + 65535;
43297
- if (e >= s) {
43298
- w[pos / 8 | 0] = lst;
43299
- e = s;
43300
- }
43301
- pos = wfblk(w, pos + 1, dat.subarray(i, e));
43302
- }
43303
- st.i = s;
43304
- }
43305
- return slc(o, 0, pre + shft(pos) + post);
43306
- };
43307
- var adler = function() {
43308
- var a = 1, b = 0;
43309
- return {
43310
- p: function(d) {
43311
- var n = a, m = b;
43312
- var l = d.length | 0;
43313
- for (var i = 0; i != l; ) {
43314
- var e = Math.min(i + 2655, l);
43315
- for (; i < e; ++i)
43316
- m += n += d[i];
43317
- n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);
43318
- }
43319
- a = n, b = m;
43320
- },
43321
- d: function() {
43322
- a %= 65521, b %= 65521;
43323
- return (a & 255) << 24 | (a & 65280) << 8 | (b & 255) << 8 | b >> 8;
43324
- }
43325
- };
43326
- };
43327
- var dopt = function(dat, opt, pre, post, st) {
43328
- if (!st) {
43329
- st = { l: 1 };
43330
- if (opt.dictionary) {
43331
- var dict = opt.dictionary.subarray(-32768);
43332
- var newDat = new u8(dict.length + dat.length);
43333
- newDat.set(dict);
43334
- newDat.set(dat, dict.length);
43335
- dat = newDat;
43336
- st.w = dict.length;
43337
- }
43338
- }
43339
- 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);
43340
- };
43341
- var wbytes = function(d, b, v) {
43342
- for (; v; ++b)
43343
- d[b] = v, v >>>= 8;
43344
- };
43345
- var zlh = function(c, o) {
43346
- var lv = o.level, fl2 = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;
43347
- c[0] = 120, c[1] = fl2 << 6 | (o.dictionary && 32);
43348
- c[1] |= 31 - (c[0] << 8 | c[1]) % 31;
43349
- if (o.dictionary) {
43350
- var h = adler();
43351
- h.p(o.dictionary);
43352
- wbytes(c, 2, h.d());
43353
- }
43354
- };
43355
- function zlibSync(data, opts) {
43356
- if (!opts)
43357
- opts = {};
43358
- var a = adler();
43359
- a.p(data);
43360
- var d = dopt(data, opts, opts.dictionary ? 6 : 2, 4);
43361
- return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;
43362
- }
43363
- var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
43364
- var tds = 0;
43365
- try {
43366
- td.decode(et, { stream: true });
43367
- tds = 1;
43368
- } catch (e) {
43369
- }
43370
42940
  const utf8 = new TextEncoder();
43371
42941
  function chunkByteLength(chunk) {
43372
42942
  return typeof chunk === "string" ? byteLength(chunk) : chunk.length;
@@ -43665,36 +43235,36 @@ class OasisPdfWriter {
43665
43235
  return this.pages.length;
43666
43236
  }
43667
43237
  drawRect(pageIndex, options) {
43668
- var _a2;
43669
- (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawRect(options);
43238
+ var _a;
43239
+ (_a = this.streams[pageIndex]) == null ? void 0 : _a.drawRect(options);
43670
43240
  }
43671
43241
  drawLine(pageIndex, options) {
43672
- var _a2;
43673
- (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawLine(options);
43242
+ var _a;
43243
+ (_a = this.streams[pageIndex]) == null ? void 0 : _a.drawLine(options);
43674
43244
  }
43675
43245
  drawPath(pageIndex, options) {
43676
- var _a2;
43677
- (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawPath(options);
43246
+ var _a;
43247
+ (_a = this.streams[pageIndex]) == null ? void 0 : _a.drawPath(options);
43678
43248
  }
43679
43249
  saveGraphicsState(pageIndex) {
43680
- var _a2;
43681
- (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.saveGraphicsState();
43250
+ var _a;
43251
+ (_a = this.streams[pageIndex]) == null ? void 0 : _a.saveGraphicsState();
43682
43252
  }
43683
43253
  restoreGraphicsState(pageIndex) {
43684
- var _a2;
43685
- (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.restoreGraphicsState();
43254
+ var _a;
43255
+ (_a = this.streams[pageIndex]) == null ? void 0 : _a.restoreGraphicsState();
43686
43256
  }
43687
43257
  rotateAbout(pageIndex, centerX, centerY, degrees) {
43688
- var _a2;
43689
- (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.rotateAbout(centerX, centerY, degrees);
43258
+ var _a;
43259
+ (_a = this.streams[pageIndex]) == null ? void 0 : _a.rotateAbout(centerX, centerY, degrees);
43690
43260
  }
43691
43261
  clipRect(pageIndex, x, y, width, height) {
43692
- var _a2;
43693
- (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.clipRect(x, y, width, height);
43262
+ var _a;
43263
+ (_a = this.streams[pageIndex]) == null ? void 0 : _a.clipRect(x, y, width, height);
43694
43264
  }
43695
43265
  drawText(pageIndex, options) {
43696
- var _a2;
43697
- (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawText(options);
43266
+ var _a;
43267
+ (_a = this.streams[pageIndex]) == null ? void 0 : _a.drawText(options);
43698
43268
  }
43699
43269
  /**
43700
43270
  * Registers an axial (linear) gradient on a page for use as a glyph fill, and
@@ -43702,23 +43272,23 @@ class OasisPdfWriter {
43702
43272
  * subsequent `drawText`. Coordinates are in the writer's top-left point space.
43703
43273
  */
43704
43274
  registerAxialGradient(pageIndex, gradient) {
43705
- var _a2;
43706
- return ((_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.registerAxialGradient(gradient)) ?? null;
43275
+ var _a;
43276
+ return ((_a = this.streams[pageIndex]) == null ? void 0 : _a.registerAxialGradient(gradient)) ?? null;
43707
43277
  }
43708
43278
  registerImageResource(resource) {
43709
43279
  return this.images.registerImageResource(resource);
43710
43280
  }
43711
43281
  drawImage(pageIndex, options) {
43712
- var _a2;
43713
- (_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawImage(options);
43282
+ var _a;
43283
+ (_a = this.streams[pageIndex]) == null ? void 0 : _a.drawImage(options);
43714
43284
  }
43715
43285
  /**
43716
43286
  * Attaches a clickable external link annotation to a page. The rect is in the
43717
43287
  * writer's top-left point space; the serializer flips it to PDF space.
43718
43288
  */
43719
43289
  addLinkAnnotation(pageIndex, annotation) {
43720
- var _a2;
43721
- (_a2 = this.pages[pageIndex]) == null ? void 0 : _a2.annotations.push(annotation);
43290
+ var _a;
43291
+ (_a = this.pages[pageIndex]) == null ? void 0 : _a.annotations.push(annotation);
43722
43292
  }
43723
43293
  /**
43724
43294
  * Registers a named destination (jump target). Position is in the writer's
@@ -43779,7 +43349,7 @@ function resolveDocumentInfo(document2) {
43779
43349
  };
43780
43350
  }
43781
43351
  function collectBookmarkNamesByParagraph(document2) {
43782
- var _a2;
43352
+ var _a;
43783
43353
  const byParagraph = /* @__PURE__ */ new Map();
43784
43354
  const bookmarks = document2.bookmarks;
43785
43355
  if (!bookmarks) {
@@ -43787,7 +43357,7 @@ function collectBookmarkNamesByParagraph(document2) {
43787
43357
  }
43788
43358
  for (const id of bookmarks.order) {
43789
43359
  const bookmark = bookmarks.items[id];
43790
- const paragraphId = (_a2 = bookmark == null ? void 0 : bookmark.start) == null ? void 0 : _a2.paragraphId;
43360
+ const paragraphId = (_a = bookmark == null ? void 0 : bookmark.start) == null ? void 0 : _a.paragraphId;
43791
43361
  if (!bookmark || !paragraphId) {
43792
43362
  continue;
43793
43363
  }
@@ -43823,8 +43393,12 @@ function registerBookmarkDestinations(writer, pageIndex, originX, bookmarkNamesB
43823
43393
  async function exportEditorDocumentToPdf(document2) {
43824
43394
  document2 = renumberImageCaptionsInDocument(document2);
43825
43395
  const fontRegistry = new PdfFontRegistry();
43396
+ const fontFamilies = collectPdfFontFamilies(document2);
43826
43397
  await fontRegistry.loadBundledUnicodeFaces({
43827
- families: collectPdfFontFamilies(document2)
43398
+ families: fontFamilies
43399
+ });
43400
+ await fontRegistry.loadRemoteWebFontFaces({
43401
+ families: fontFamilies
43828
43402
  });
43829
43403
  const writer = new OasisPdfWriter(fontRegistry.getPdfFontResources());
43830
43404
  writer.setDocumentInfo(resolveDocumentInfo(document2));
@@ -43962,15 +43536,15 @@ async function exportEditorDocumentToPdfBlob(document2) {
43962
43536
  return new Blob([buffer], { type: "application/pdf" });
43963
43537
  }
43964
43538
  async function drawFootnoteBlockList(writer, pageIndex, blocks, footnoteReferenceIds, document2, originX, originY, contentWidth, fontRegistry, listOrdinals) {
43965
- var _a2;
43539
+ var _a;
43966
43540
  let cursorY = originY;
43967
43541
  const markerDrawn = /* @__PURE__ */ new Set();
43968
43542
  const markerByFootnoteId = new Map(
43969
43543
  footnoteReferenceIds.map((footnoteId) => {
43970
- var _a3;
43544
+ var _a2;
43971
43545
  return [
43972
43546
  footnoteId,
43973
- ((_a3 = findFootnoteReference(document2, footnoteId)) == null ? void 0 : _a3.run.text) ?? ""
43547
+ ((_a2 = findFootnoteReference(document2, footnoteId)) == null ? void 0 : _a2.run.text) ?? ""
43974
43548
  ];
43975
43549
  })
43976
43550
  );
@@ -43984,7 +43558,7 @@ async function drawFootnoteBlockList(writer, pageIndex, blocks, footnoteReferenc
43984
43558
  const firstParagraph = block.sourceBlock.type === "paragraph" ? block.sourceBlock : void 0;
43985
43559
  const styles = resolveEffectiveTextStyleForParagraph(
43986
43560
  void 0,
43987
- (_a2 = firstParagraph == null ? void 0 : firstParagraph.style) == null ? void 0 : _a2.styleId,
43561
+ (_a = firstParagraph == null ? void 0 : firstParagraph.style) == null ? void 0 : _a.styleId,
43988
43562
  document2.styles
43989
43563
  );
43990
43564
  const fontFace = fontRegistry.resolveFontFace({
@@ -44086,7 +43660,7 @@ function buildImportedDocumentDiagnostics(document2) {
44086
43660
  return buildImportedDocumentDiagnosticsImpl(document2);
44087
43661
  }
44088
43662
  function buildImportedDocumentDiagnosticsImpl(document2) {
44089
- var _a2;
43663
+ var _a;
44090
43664
  const paragraphs = getDocumentParagraphs(document2);
44091
43665
  const fontCounts = /* @__PURE__ */ new Map();
44092
43666
  const alignCounts = /* @__PURE__ */ new Map();
@@ -44104,7 +43678,7 @@ function buildImportedDocumentDiagnosticsImpl(document2) {
44104
43678
  for (const run of paragraph.runs) {
44105
43679
  const textStyle = resolveEffectiveTextStyleForParagraph(
44106
43680
  run.styles,
44107
- (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
43681
+ (_a = paragraph.style) == null ? void 0 : _a.styleId,
44108
43682
  document2.styles
44109
43683
  );
44110
43684
  const fontFamily = textStyle.fontFamily ?? "<null>";
@@ -44124,7 +43698,7 @@ function buildImportedDocumentDiagnosticsImpl(document2) {
44124
43698
  characterSpacingRuns,
44125
43699
  characterScaleRuns,
44126
43700
  firstParagraphs: paragraphs.slice(0, 30).map((paragraph, index) => {
44127
- var _a3;
43701
+ var _a2;
44128
43702
  const paragraphStyle = resolveEffectiveParagraphStyle(
44129
43703
  paragraph.style,
44130
43704
  document2.styles
@@ -44132,7 +43706,7 @@ function buildImportedDocumentDiagnosticsImpl(document2) {
44132
43706
  const firstRun = paragraph.runs[0];
44133
43707
  const textStyle = resolveEffectiveTextStyleForParagraph(
44134
43708
  firstRun == null ? void 0 : firstRun.styles,
44135
- (_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
43709
+ (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
44136
43710
  document2.styles
44137
43711
  );
44138
43712
  return {
@@ -44173,6 +43747,7 @@ function createDocumentImporter(deps) {
44173
43747
  size: file.size
44174
43748
  });
44175
43749
  deps.setImportPhase("reading-file");
43750
+ const localFontAccess = importer.id === "docx" ? deps.requestLocalFontAccess().catch(() => false) : Promise.resolve(false);
44176
43751
  try {
44177
43752
  const readingStartedAt = deps.now();
44178
43753
  const arrayBuffer = await readFileBuffer(file);
@@ -44210,6 +43785,14 @@ function createDocumentImporter(deps) {
44210
43785
  "import:document-diagnostics",
44211
43786
  buildImportedDocumentDiagnostics(document2)
44212
43787
  );
43788
+ const fontPreparationStartedAt = deps.now();
43789
+ deps.setImportPhase("preparing-fonts");
43790
+ await localFontAccess;
43791
+ await deps.prepareDocumentFonts(document2);
43792
+ deps.logger.info("import:phase", {
43793
+ phase: "preparing-fonts",
43794
+ durationMs: roundTo(deps.now() - fontPreparationStartedAt, 2)
43795
+ });
44213
43796
  deps.setImportPhase("applying-editor-state");
44214
43797
  deps.resetEditorChromeState();
44215
43798
  deps.applyState(createEditorStateFromDocument(document2));
@@ -44223,8 +43806,8 @@ function createDocumentImporter(deps) {
44223
43806
  const sections = getDocumentSectionsCanonical(document2);
44224
43807
  const canonicalBlocks = sections.reduce(
44225
43808
  (total, section) => {
44226
- var _a2, _b2;
44227
- return total + (((_a2 = section.header) == null ? void 0 : _a2.length) ?? 0) + section.blocks.length + (((_b2 = section.footer) == null ? void 0 : _b2.length) ?? 0);
43809
+ var _a, _b;
43810
+ return total + (((_a = section.header) == null ? void 0 : _a.length) ?? 0) + section.blocks.length + (((_b = section.footer) == null ? void 0 : _b.length) ?? 0);
44228
43811
  },
44229
43812
  0
44230
43813
  );
@@ -44325,8 +43908,8 @@ function applyMoveWithText(floating, fixed) {
44325
43908
  };
44326
43909
  }
44327
43910
  function isFloatingFixedPosition(floating) {
44328
- var _a2;
44329
- return ((_a2 = floating == null ? void 0 : floating.positionV) == null ? void 0 : _a2.relativeFrom) === "page";
43911
+ var _a;
43912
+ return ((_a = floating == null ? void 0 : floating.positionV) == null ? void 0 : _a.relativeFrom) === "page";
44330
43913
  }
44331
43914
  function getSelectedImageRun(state) {
44332
43915
  return getSelectedObjectRun(state, (run) => run.kind === "image");
@@ -44797,8 +44380,9 @@ const PHASE_RANGES = {
44797
44380
  opening: [8, 20],
44798
44381
  parsing: [20, 72],
44799
44382
  finishing: [72, 78],
44800
- "applying-editor-state": [78, 88],
44801
- "stabilizing-layout": [88, 98],
44383
+ "preparing-fonts": [78, 90],
44384
+ "applying-editor-state": [90, 94],
44385
+ "stabilizing-layout": [94, 99],
44802
44386
  done: [100, 100],
44803
44387
  error: [100, 100]
44804
44388
  };
@@ -44835,6 +44419,8 @@ function createEditorDocumentIOImpl(deps) {
44835
44419
  stabilizeLayoutAfterImport: deps.stabilizeLayoutAfterImport,
44836
44420
  resetEditorChromeState: deps.resetEditorChromeState,
44837
44421
  focusInput: deps.focusInput,
44422
+ requestLocalFontAccess: deps.requestLocalFontAccess,
44423
+ prepareDocumentFonts: deps.prepareDocumentFonts,
44838
44424
  setImportPhase,
44839
44425
  clearImportProgressSoon,
44840
44426
  now: () => performance.now(),
@@ -44960,7 +44546,7 @@ function resolveCaretSlot(paragraphs, focusOffset) {
44960
44546
  };
44961
44547
  }
44962
44548
  function computeCanvasSelectionGeometry(snapshot, state) {
44963
- var _a2, _b2, _c, _d, _e, _f;
44549
+ var _a, _b, _c, _d, _e, _f;
44964
44550
  const normalized = normalizeSelection(state);
44965
44551
  const selectionBoxes = [];
44966
44552
  const surfaceRect = snapshot.surfaceRect;
@@ -45023,9 +44609,9 @@ function computeCanvasSelectionGeometry(snapshot, state) {
45023
44609
  const section = sections[activeSectionIndex];
45024
44610
  let tableBlock;
45025
44611
  if (anchorLoc.zone === "header") {
45026
- tableBlock = (_a2 = section == null ? void 0 : section.header) == null ? void 0 : _a2[anchorLoc.blockIndex];
44612
+ tableBlock = (_a = section == null ? void 0 : section.header) == null ? void 0 : _a[anchorLoc.blockIndex];
45027
44613
  } else if (anchorLoc.zone === "footer") {
45028
- tableBlock = (_b2 = section == null ? void 0 : section.footer) == null ? void 0 : _b2[anchorLoc.blockIndex];
44614
+ tableBlock = (_b = section == null ? void 0 : section.footer) == null ? void 0 : _b[anchorLoc.blockIndex];
45029
44615
  } else {
45030
44616
  tableBlock = (_c = section == null ? void 0 : section.blocks) == null ? void 0 : _c[anchorLoc.blockIndex];
45031
44617
  }
@@ -45260,9 +44846,9 @@ function areLayoutParagraphsEquivalentForRender(previous, next) {
45260
44846
  });
45261
44847
  }
45262
44848
  function canReuseLayoutBlock(previous, next) {
45263
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
44849
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
45264
44850
  return Boolean(
45265
- 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(
44851
+ 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(
45266
44852
  (_g = previous.tableSegment) == null ? void 0 : _g.startRowCellBlockStarts,
45267
44853
  (_h = next.tableSegment) == null ? void 0 : _h.startRowCellBlockStarts
45268
44854
  ) && sameNumberArray(
@@ -45412,7 +44998,7 @@ function useEditorLayoutImpl(props) {
45412
44998
  const canvasSnapshotProvider = createCanvasLayoutSnapshotProvider();
45413
44999
  let syncRequestId = 0;
45414
45000
  const syncInputBox = (_reason = "selection") => {
45415
- var _a2;
45001
+ var _a;
45416
45002
  const surface = props.surfaceRef();
45417
45003
  if (!surface) {
45418
45004
  setSelectionBoxes([]);
@@ -45432,7 +45018,7 @@ function useEditorLayoutImpl(props) {
45432
45018
  surface,
45433
45019
  state: props.state,
45434
45020
  documentLayout: documentLayout(),
45435
- zoomFactor: (_a2 = props.zoomFactor) == null ? void 0 : _a2.call(props)
45021
+ zoomFactor: (_a = props.zoomFactor) == null ? void 0 : _a.call(props)
45436
45022
  });
45437
45023
  if (!snapshot) {
45438
45024
  setSelectionBoxes([]);
@@ -45481,15 +45067,15 @@ function useEditorLayoutImpl(props) {
45481
45067
  return options.resolveWhenDone ? Promise.resolve() : null;
45482
45068
  };
45483
45069
  const applyInvalidation = (invalidation) => {
45484
- var _a2, _b2;
45485
- if ((_a2 = props.isImporting) == null ? void 0 : _a2.call(props)) {
45070
+ var _a, _b;
45071
+ if ((_a = props.isImporting) == null ? void 0 : _a.call(props)) {
45486
45072
  return;
45487
45073
  }
45488
45074
  if (invalidation.dirtyAll || invalidation.structureChanged) {
45489
45075
  setMeasuredBlockHeights({});
45490
45076
  setMeasuredParagraphLayouts({});
45491
45077
  bumpLayoutMetricsEpoch();
45492
- } else if ((((_b2 = invalidation.dirtyParagraphIds) == null ? void 0 : _b2.length) ?? 0) > 0) {
45078
+ } else if ((((_b = invalidation.dirtyParagraphIds) == null ? void 0 : _b.length) ?? 0) > 0) {
45493
45079
  const dirtyIds = invalidation.dirtyParagraphIds ?? [];
45494
45080
  setMeasuredParagraphLayouts(
45495
45081
  (current) => normalizeParagraphLayouts(current, dirtyIds)
@@ -45517,11 +45103,11 @@ function useEditorLayoutImpl(props) {
45517
45103
  requestInputBoxSync("selection");
45518
45104
  });
45519
45105
  createEffect(() => {
45520
- var _a2;
45106
+ var _a;
45521
45107
  props.state.document;
45522
45108
  props.state.activeSectionIndex;
45523
45109
  props.state.activeZone;
45524
- if ((_a2 = props.isImporting) == null ? void 0 : _a2.call(props)) {
45110
+ if ((_a = props.isImporting) == null ? void 0 : _a.call(props)) {
45525
45111
  return;
45526
45112
  }
45527
45113
  requestInputBoxSync("content-change");
@@ -45583,7 +45169,7 @@ function useEditorPersistence(state, onLoaded, options) {
45583
45169
  const isEnabled = () => options.enabled ?? false;
45584
45170
  const persistence = options.persistence;
45585
45171
  const debouncedSave = debounce(async (doc) => {
45586
- var _a2;
45172
+ var _a;
45587
45173
  if (!isEnabled() || !isInitialized()) return;
45588
45174
  setStatus("Saving...");
45589
45175
  try {
@@ -45591,7 +45177,7 @@ function useEditorPersistence(state, onLoaded, options) {
45591
45177
  await persistence.saveDocument(rawDoc);
45592
45178
  setStatus("Saved");
45593
45179
  } catch (err) {
45594
- (_a2 = options.logger) == null ? void 0 : _a2.error("persistence:autosave failed", err);
45180
+ (_a = options.logger) == null ? void 0 : _a.error("persistence:autosave failed", err);
45595
45181
  setStatus("Error");
45596
45182
  }
45597
45183
  }, 1e3);
@@ -45607,7 +45193,7 @@ function useEditorPersistence(state, onLoaded, options) {
45607
45193
  )
45608
45194
  );
45609
45195
  onMount(async () => {
45610
- var _a2;
45196
+ var _a;
45611
45197
  if (!isEnabled()) {
45612
45198
  setIsInitialized(true);
45613
45199
  setStatus("Saved");
@@ -45619,7 +45205,7 @@ function useEditorPersistence(state, onLoaded, options) {
45619
45205
  onLoaded(loadedDoc);
45620
45206
  }
45621
45207
  } catch (err) {
45622
- (_a2 = options.logger) == null ? void 0 : _a2.error("persistence:load failed", err);
45208
+ (_a = options.logger) == null ? void 0 : _a.error("persistence:load failed", err);
45623
45209
  } finally {
45624
45210
  setIsInitialized(true);
45625
45211
  setStatus("Saved");
@@ -45635,8 +45221,8 @@ function createEmptyEditorHistoryState() {
45635
45221
  };
45636
45222
  }
45637
45223
  function applyEditorHistoryTransaction(history, previous, next, options, now = Date.now()) {
45638
- var _a2;
45639
- 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;
45224
+ var _a;
45225
+ 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;
45640
45226
  return {
45641
45227
  undoStack: canMerge ? history.undoStack : [...history.undoStack, previous],
45642
45228
  redoStack: [],
@@ -45800,13 +45386,13 @@ function createEditorHistoryActionsImpl(deps) {
45800
45386
  return true;
45801
45387
  };
45802
45388
  const applySelectionPreservingStructure = (nextSelection) => {
45803
- var _a2;
45389
+ var _a;
45804
45390
  const snapshot = deps.stateSnapshot();
45805
45391
  deps.applyHistoryState({
45806
45392
  ...snapshot,
45807
45393
  document: {
45808
45394
  ...snapshot.document,
45809
- sections: (_a2 = snapshot.document.sections) == null ? void 0 : _a2.map(cloneSection)
45395
+ sections: (_a = snapshot.document.sections) == null ? void 0 : _a.map(cloneSection)
45810
45396
  },
45811
45397
  selection: {
45812
45398
  anchor: { ...nextSelection.anchor },
@@ -45825,8 +45411,8 @@ function openDB(options) {
45825
45411
  return new Promise((resolve, reject) => {
45826
45412
  const request = indexedDB.open(options.name, options.version);
45827
45413
  request.onerror = () => {
45828
- var _a2;
45829
- reject(new Error(`Failed to open IndexedDB: ${(_a2 = request.error) == null ? void 0 : _a2.message}`));
45414
+ var _a;
45415
+ reject(new Error(`Failed to open IndexedDB: ${(_a = request.error) == null ? void 0 : _a.message}`));
45830
45416
  };
45831
45417
  request.onsuccess = () => {
45832
45418
  resolve(request.result);
@@ -45844,10 +45430,10 @@ function putItem(db, storeName, key, value) {
45844
45430
  const store = transaction.objectStore(storeName);
45845
45431
  const request = store.put(value, key);
45846
45432
  request.onerror = () => {
45847
- var _a2;
45433
+ var _a;
45848
45434
  reject(
45849
45435
  new Error(
45850
- `Failed to put item in ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
45436
+ `Failed to put item in ${storeName}: ${(_a = request.error) == null ? void 0 : _a.message}`
45851
45437
  )
45852
45438
  );
45853
45439
  };
@@ -45855,10 +45441,10 @@ function putItem(db, storeName, key, value) {
45855
45441
  resolve();
45856
45442
  };
45857
45443
  transaction.onabort = transaction.onerror = () => {
45858
- var _a2;
45444
+ var _a;
45859
45445
  reject(
45860
45446
  new Error(
45861
- `Transaction failed putting item in ${storeName}: ${(_a2 = transaction.error) == null ? void 0 : _a2.message}`
45447
+ `Transaction failed putting item in ${storeName}: ${(_a = transaction.error) == null ? void 0 : _a.message}`
45862
45448
  )
45863
45449
  );
45864
45450
  };
@@ -45874,10 +45460,10 @@ function getItem(db, storeName, key) {
45874
45460
  const store = transaction.objectStore(storeName);
45875
45461
  const request = store.get(key);
45876
45462
  request.onerror = () => {
45877
- var _a2;
45463
+ var _a;
45878
45464
  reject(
45879
45465
  new Error(
45880
- `Failed to get item from ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
45466
+ `Failed to get item from ${storeName}: ${(_a = request.error) == null ? void 0 : _a.message}`
45881
45467
  )
45882
45468
  );
45883
45469
  };
@@ -45896,10 +45482,10 @@ function deleteItem(db, storeName, key) {
45896
45482
  const store = transaction.objectStore(storeName);
45897
45483
  const request = store.delete(key);
45898
45484
  request.onerror = () => {
45899
- var _a2;
45485
+ var _a;
45900
45486
  reject(
45901
45487
  new Error(
45902
- `Failed to delete item from ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
45488
+ `Failed to delete item from ${storeName}: ${(_a = request.error) == null ? void 0 : _a.message}`
45903
45489
  )
45904
45490
  );
45905
45491
  };
@@ -45907,10 +45493,10 @@ function deleteItem(db, storeName, key) {
45907
45493
  resolve();
45908
45494
  };
45909
45495
  transaction.onabort = transaction.onerror = () => {
45910
- var _a2;
45496
+ var _a;
45911
45497
  reject(
45912
45498
  new Error(
45913
- `Transaction failed deleting item from ${storeName}: ${(_a2 = transaction.error) == null ? void 0 : _a2.message}`
45499
+ `Transaction failed deleting item from ${storeName}: ${(_a = transaction.error) == null ? void 0 : _a.message}`
45914
45500
  )
45915
45501
  );
45916
45502
  };
@@ -45962,7 +45548,7 @@ function createIndexedDbPersistence(options = {}) {
45962
45548
  };
45963
45549
  }
45964
45550
  function computeLayoutInvalidationFromTransaction(prev, next) {
45965
- var _a2, _b2, _c, _d, _e, _f;
45551
+ var _a, _b, _c, _d, _e, _f;
45966
45552
  if (prev === next || prev.document === next.document) {
45967
45553
  return {};
45968
45554
  }
@@ -46006,7 +45592,7 @@ function computeLayoutInvalidationFromTransaction(prev, next) {
46006
45592
  }
46007
45593
  const aImage = getRunImage(a);
46008
45594
  const bImage = getRunImage(b);
46009
- 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)) {
45595
+ 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)) {
46010
45596
  changed = true;
46011
45597
  break;
46012
45598
  }
@@ -46076,7 +45662,7 @@ function useEditorTransactionsImpl(ctx) {
46076
45662
  }
46077
45663
  function createEditorChangeBroadcast(deps) {
46078
45664
  createEffect(() => {
46079
- var _a2;
45665
+ var _a;
46080
45666
  deps.state.document;
46081
45667
  deps.state.selection;
46082
45668
  deps.state.activeSectionIndex;
@@ -46086,7 +45672,7 @@ function createEditorChangeBroadcast(deps) {
46086
45672
  return;
46087
45673
  }
46088
45674
  const snapshot = deps.cloneState(deps.getStateSnapshot());
46089
- (_a2 = deps.getOnStateChange()) == null ? void 0 : _a2(snapshot);
45675
+ (_a = deps.getOnStateChange()) == null ? void 0 : _a(snapshot);
46090
45676
  deps.emit("change", snapshot);
46091
45677
  deps.emit("documentChange", snapshot.document);
46092
45678
  deps.emit("selectionChange", snapshot.selection);
@@ -46123,11 +45709,17 @@ function createEditorDocumentRuntimeImpl(deps) {
46123
45709
  },
46124
45710
  resetEditorChromeState: () => resetEditorChromeState(),
46125
45711
  focusInput,
45712
+ requestLocalFontAccess: enablePreciseFontMode,
45713
+ prepareDocumentFonts: async (document2) => {
45714
+ await prepareDocumentFonts(document2, {
45715
+ remoteWebFonts: documentOptions().remoteWebFonts
45716
+ });
45717
+ },
46126
45718
  logger
46127
45719
  });
46128
45720
  const isImportInProgress = () => {
46129
- var _a2, _b2;
46130
- return ((_a2 = docIO.importProgress()) == null ? void 0 : _a2.phase) !== "done" && ((_b2 = docIO.importProgress()) == null ? void 0 : _b2.phase) !== "error" && docIO.importProgress() !== null;
45721
+ var _a, _b;
45722
+ return ((_a = docIO.importProgress()) == null ? void 0 : _a.phase) !== "done" && ((_b = docIO.importProgress()) == null ? void 0 : _b.phase) !== "error" && docIO.importProgress() !== null;
46131
45723
  };
46132
45724
  const {
46133
45725
  measuredBlockHeights,
@@ -46412,7 +46004,7 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
46412
46004
  return {
46413
46005
  ...cloneParagraph(candidate),
46414
46006
  runs: candidate.runs.map((run) => {
46415
- var _a2;
46007
+ var _a;
46416
46008
  if (run.id !== targetRun.id || run.kind !== "textBox") {
46417
46009
  return cloneRun(run);
46418
46010
  }
@@ -46422,7 +46014,7 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
46422
46014
  width: nextWidth,
46423
46015
  height: nextHeight
46424
46016
  };
46425
- if (changesHeight && ((_a2 = textBox.body) == null ? void 0 : _a2.autoFit)) {
46017
+ if (changesHeight && ((_a = textBox.body) == null ? void 0 : _a.autoFit)) {
46426
46018
  nextTextBox.body = { ...textBox.body, autoFit: false };
46427
46019
  }
46428
46020
  if (textBox.floating) {
@@ -46527,7 +46119,7 @@ const updateBlocksInCurrentSection = (current, blocks, zone = "main") => {
46527
46119
  };
46528
46120
  };
46529
46121
  const applyTableAwareParagraphEdit = (current, getTargetBlocks, edit) => {
46530
- var _a2;
46122
+ var _a;
46531
46123
  const location = findParagraphTableLocation(
46532
46124
  current.document,
46533
46125
  current.selection.focus.paragraphId,
@@ -46548,7 +46140,7 @@ const applyTableAwareParagraphEdit = (current, getTargetBlocks, edit) => {
46548
46140
  (block, i) => i === location.blockIndex ? clonedTable : block
46549
46141
  );
46550
46142
  const tableBlock = clonedTable;
46551
- const targetCell = (_a2 = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
46143
+ const targetCell = (_a = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a.cells[location.cellIndex];
46552
46144
  if (!targetCell) {
46553
46145
  return edit(current);
46554
46146
  }
@@ -46614,7 +46206,7 @@ function createTableOpsGuardsImpl(deps) {
46614
46206
  return Boolean(range && range.endCellIndex > range.startCellIndex);
46615
46207
  };
46616
46208
  const canSplitSelectedTableCell = (current) => {
46617
- var _a2;
46209
+ var _a;
46618
46210
  const location = findParagraphTableLocation(
46619
46211
  current.document,
46620
46212
  current.selection.focus.paragraphId,
@@ -46628,11 +46220,11 @@ function createTableOpsGuardsImpl(deps) {
46628
46220
  if (!block || block.type !== "table") {
46629
46221
  return false;
46630
46222
  }
46631
- const cell = (_a2 = block.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
46223
+ const cell = (_a = block.rows[location.rowIndex]) == null ? void 0 : _a.cells[location.cellIndex];
46632
46224
  return Boolean(((cell == null ? void 0 : cell.colSpan) ?? 1) > 1);
46633
46225
  };
46634
46226
  const canMergeSelectedTableRows = (current) => {
46635
- var _a2;
46227
+ var _a;
46636
46228
  const range = deps.resolveVerticalTableCellRange(current);
46637
46229
  if (!range) {
46638
46230
  return false;
@@ -46643,7 +46235,7 @@ function createTableOpsGuardsImpl(deps) {
46643
46235
  return false;
46644
46236
  }
46645
46237
  for (let rowIndex = range.startRowIndex; rowIndex <= range.endRowIndex; rowIndex += 1) {
46646
- const cell = (_a2 = tableBlock.rows[rowIndex]) == null ? void 0 : _a2.cells[range.cellIndex];
46238
+ const cell = (_a = tableBlock.rows[rowIndex]) == null ? void 0 : _a.cells[range.cellIndex];
46647
46239
  if (!cell || cell.vMerge === "continue" || cell.blocks.length !== 1) {
46648
46240
  return false;
46649
46241
  }
@@ -46654,7 +46246,7 @@ function createTableOpsGuardsImpl(deps) {
46654
46246
  return canMergeSelectedTableCells(current) || canMergeSelectedTableRows(current);
46655
46247
  };
46656
46248
  const canSplitSelectedTableCellVertically = (current) => {
46657
- var _a2;
46249
+ var _a;
46658
46250
  const location = findParagraphTableLocation(
46659
46251
  current.document,
46660
46252
  current.selection.focus.paragraphId,
@@ -46668,7 +46260,7 @@ function createTableOpsGuardsImpl(deps) {
46668
46260
  if (!block || block.type !== "table") {
46669
46261
  return false;
46670
46262
  }
46671
- const cell = (_a2 = block.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
46263
+ const cell = (_a = block.rows[location.rowIndex]) == null ? void 0 : _a.cells[location.cellIndex];
46672
46264
  return Boolean(((cell == null ? void 0 : cell.rowSpan) ?? 1) > 1 && (cell == null ? void 0 : cell.vMerge) === "restart");
46673
46265
  };
46674
46266
  const canSplitSelectedTable = (current) => {
@@ -46771,11 +46363,11 @@ function createTableSelectionResolvers(deps) {
46771
46363
  }
46772
46364
  function createTableSelectionResolversImpl(deps) {
46773
46365
  const resolveTableCellRangeSelection = (current) => {
46774
- var _a2, _b2, _c, _d, _e;
46366
+ var _a, _b, _c, _d, _e;
46775
46367
  const selection = current.selection;
46776
46368
  const context = getSelectionTableContext(current, deps);
46777
46369
  if (!context || context.anchorLocation.rowIndex === context.focusLocation.rowIndex && context.anchorLocation.cellIndex === context.focusLocation.cellIndex) {
46778
- (_a2 = deps.logger) == null ? void 0 : _a2.debug(
46370
+ (_a = deps.logger) == null ? void 0 : _a.debug(
46779
46371
  `resolveTableCellRangeSelection: no expansion (anchor=${selection.anchor.paragraphId} focus=${selection.focus.paragraphId})`
46780
46372
  );
46781
46373
  return null;
@@ -46796,7 +46388,7 @@ function createTableSelectionResolversImpl(deps) {
46796
46388
  context.anchorLocation.cellIndex,
46797
46389
  context.focusLocation.cellIndex
46798
46390
  );
46799
- (_b2 = deps.logger) == null ? void 0 : _b2.info(
46391
+ (_b = deps.logger) == null ? void 0 : _b.info(
46800
46392
  `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}]`
46801
46393
  );
46802
46394
  const startLocation = compareCellLocations(context.anchorCell, context.focusCell) <= 0 ? context.anchorLocation : context.focusLocation;
@@ -47063,11 +46655,11 @@ function createTableCellSpanOperationsImpl(deps) {
47063
46655
  return current;
47064
46656
  };
47065
46657
  const splitSelectedTableCellVertically = (current) => {
47066
- var _a2;
46658
+ var _a;
47067
46659
  const mut = resolveLocationTableMutation(current, deps.getTargetBlocks);
47068
46660
  if (!mut) return current;
47069
46661
  const { tableBlock, location, targetBlocks } = mut;
47070
- const cell = (_a2 = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
46662
+ const cell = (_a = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a.cells[location.cellIndex];
47071
46663
  const span = Math.max(1, (cell == null ? void 0 : cell.rowSpan) ?? 1);
47072
46664
  if (!cell || span <= 1 || cell.vMerge !== "restart") {
47073
46665
  return current;
@@ -47099,8 +46691,8 @@ function createTableCellSpanOperationsImpl(deps) {
47099
46691
  ...Array.from(
47100
46692
  { length: span - 1 },
47101
46693
  (_, offset) => {
47102
- var _a3;
47103
- const prior = (_a3 = tableBlock.rows[location.rowIndex + offset + 1]) == null ? void 0 : _a3.cells[location.cellIndex];
46694
+ var _a2;
46695
+ const prior = (_a2 = tableBlock.rows[location.rowIndex + offset + 1]) == null ? void 0 : _a2.cells[location.cellIndex];
47104
46696
  return prior ? cloneCellSnapshot(prior) : createEditorTableCell([], preservedColSpan);
47105
46697
  }
47106
46698
  )
@@ -47130,7 +46722,7 @@ function createTableCellSpanOperationsImpl(deps) {
47130
46722
  );
47131
46723
  };
47132
46724
  const splitSelectedTableCell = (current) => {
47133
- var _a2;
46725
+ var _a;
47134
46726
  const mut = resolveLocationTableMutation(current, deps.getTargetBlocks);
47135
46727
  if (!mut) return current;
47136
46728
  const { tableBlock, location, targetBlocks } = mut;
@@ -47176,7 +46768,7 @@ function createTableCellSpanOperationsImpl(deps) {
47176
46768
  )
47177
46769
  ];
47178
46770
  row.cells.splice(location.cellIndex, 1, ...nextCells);
47179
- const nextParagraph = (_a2 = nextCells[0]) == null ? void 0 : _a2.blocks[0];
46771
+ const nextParagraph = (_a = nextCells[0]) == null ? void 0 : _a.blocks[0];
47180
46772
  if (!nextParagraph) {
47181
46773
  return current;
47182
46774
  }
@@ -47212,10 +46804,10 @@ function markTableRevision(target, type) {
47212
46804
  };
47213
46805
  }
47214
46806
  function resolveNextTableParagraph(tableBlock, targetCell, fallbackRow) {
47215
- var _a2;
47216
- return (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_a2 = fallbackRow == null ? void 0 : fallbackRow.cells.find(
46807
+ var _a;
46808
+ return (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_a = fallbackRow == null ? void 0 : fallbackRow.cells.find(
47217
46809
  (cell) => cell.vMerge !== "continue" && cell.blocks[0]
47218
- )) == null ? void 0 : _a2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
46810
+ )) == null ? void 0 : _a.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
47219
46811
  }
47220
46812
  function createTableRowColumnOperations(deps) {
47221
46813
  return createTableRowColumnOperationsImpl(deps);
@@ -47379,7 +46971,7 @@ function createTableRowColumnOperationsImpl(deps) {
47379
46971
  );
47380
46972
  };
47381
46973
  const insertSelectedTableColumn = (current, direction) => {
47382
- var _a2;
46974
+ var _a;
47383
46975
  const mut = resolveLocationTableMutation(current, deps.getTargetBlocks);
47384
46976
  if (!mut) return current;
47385
46977
  const { tableBlock, location, targetBlocks } = mut;
@@ -47453,7 +47045,7 @@ function createTableRowColumnOperationsImpl(deps) {
47453
47045
  const insertIndex = Math.max(
47454
47046
  0,
47455
47047
  Math.min(
47456
- ((_a2 = tableBlock.rows[0]) == null ? void 0 : _a2.cells.length) ?? 0,
47048
+ ((_a = tableBlock.rows[0]) == null ? void 0 : _a.cells.length) ?? 0,
47457
47049
  location.cellIndex + (direction > 0 ? 1 : 0)
47458
47050
  )
47459
47051
  );
@@ -47475,7 +47067,7 @@ function createTableRowColumnOperationsImpl(deps) {
47475
47067
  );
47476
47068
  };
47477
47069
  const deleteSelectedTableColumn = (current) => {
47478
- var _a2;
47070
+ var _a;
47479
47071
  const mut = resolveLocationTableMutation(current, deps.getTargetBlocks);
47480
47072
  if (!mut) return current;
47481
47073
  const { tableBlock, location, targetBlocks } = mut;
@@ -47540,7 +47132,7 @@ function createTableRowColumnOperationsImpl(deps) {
47540
47132
  nextParagraph2
47541
47133
  );
47542
47134
  }
47543
- if (((_a2 = tableBlock.rows[0]) == null ? void 0 : _a2.cells.length) <= 1) {
47135
+ if (((_a = tableBlock.rows[0]) == null ? void 0 : _a.cells.length) <= 1) {
47544
47136
  return current;
47545
47137
  }
47546
47138
  for (const row of tableBlock.rows) {
@@ -47579,19 +47171,19 @@ function createTableSelectionAwareCommandsImpl(deps) {
47579
47171
  };
47580
47172
  const applySelectionAwareCommand = (command, logPrefix) => {
47581
47173
  deps.applyTransactionalState((current) => {
47582
- var _a2, _b2, _c;
47174
+ var _a, _b, _c;
47583
47175
  const selection = deps.resolveSelectedTableCells(current);
47584
47176
  if (!selection || selection.cells.length <= 1) {
47585
47177
  const expanded = withExpandedTableCellSelection(current);
47586
47178
  if (expanded !== current) {
47587
- (_a2 = deps.logger) == null ? void 0 : _a2.info(
47179
+ (_a = deps.logger) == null ? void 0 : _a.info(
47588
47180
  `${logPrefix}: expanded selection to ${expanded.selection.anchor.paragraphId}[${expanded.selection.anchor.offset}]..${expanded.selection.focus.paragraphId}[${expanded.selection.focus.offset}]`
47589
47181
  );
47590
47182
  }
47591
47183
  return command(expanded);
47592
47184
  }
47593
47185
  const { blockIndex, cells, zone } = selection;
47594
- (_b2 = deps.logger) == null ? void 0 : _b2.info(
47186
+ (_b = deps.logger) == null ? void 0 : _b.info(
47595
47187
  `${logPrefix}: multi-cell selection in table block ${blockIndex} (${cells.length} cells) in zone ${zone}`
47596
47188
  );
47597
47189
  const allParagraphs = [];
@@ -47739,8 +47331,8 @@ function createEditorTableOperationsImpl(deps) {
47739
47331
  logger: deps.logger
47740
47332
  });
47741
47333
  const insertTableCommand = (rows, cols) => {
47742
- var _a2;
47743
- (_a2 = deps.logger) == null ? void 0 : _a2.info(`insertTableCommand: ${rows}x${cols}`);
47334
+ var _a;
47335
+ (_a = deps.logger) == null ? void 0 : _a.info(`insertTableCommand: ${rows}x${cols}`);
47744
47336
  deps.applyTransactionalState(
47745
47337
  (current) => insertTableAtSelection(current, rows, cols),
47746
47338
  {
@@ -47806,12 +47398,12 @@ function createResizeSession(adapter, deps) {
47806
47398
  }
47807
47399
  });
47808
47400
  const handleMouseMove = (event) => {
47809
- var _a2;
47401
+ var _a;
47810
47402
  const resize = active;
47811
47403
  if (!resize) {
47812
47404
  return;
47813
47405
  }
47814
- const z = ((_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)) ?? 1;
47406
+ const z = ((_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)) ?? 1;
47815
47407
  const deltaX = (event.clientX - resize.startClientX) / z;
47816
47408
  const deltaY = (event.clientY - resize.startClientY) / z;
47817
47409
  const maxWidth = adapter.getMaxWidth(deps.state, resize.paragraphId);
@@ -48040,12 +47632,12 @@ function createCropSession(deps) {
48040
47632
  }
48041
47633
  });
48042
47634
  const handleMouseMove = (event) => {
48043
- var _a2;
47635
+ var _a;
48044
47636
  const crop = active;
48045
47637
  if (!crop) {
48046
47638
  return;
48047
47639
  }
48048
- const z = ((_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)) ?? 1;
47640
+ const z = ((_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)) ?? 1;
48049
47641
  const deltaX = (event.clientX - crop.startClientX) / z;
48050
47642
  const deltaY = (event.clientY - crop.startClientY) / z;
48051
47643
  const result = resolveCroppedImage(crop, deltaX, deltaY);
@@ -48902,7 +48494,7 @@ function resolveImageAtPoint(snapshot, pageIndex, zone, clientX, clientY, pierce
48902
48494
  return null;
48903
48495
  }
48904
48496
  function resolveCanvasSurfaceHitAtPoint(options) {
48905
- var _a2, _b2, _c;
48497
+ var _a, _b, _c;
48906
48498
  const { snapshot, state } = options;
48907
48499
  const pierce = options.pierce ?? false;
48908
48500
  const zoomFactor = options.zoomFactor && options.zoomFactor > 0 ? options.zoomFactor : 1;
@@ -48944,7 +48536,7 @@ function resolveCanvasSurfaceHitAtPoint(options) {
48944
48536
  position: position2,
48945
48537
  source: "canvas-layout",
48946
48538
  resolvedFromParagraph: true,
48947
- tableCellAnchorPosition: (_a2 = paragraphSegment.tableCell) == null ? void 0 : _a2.anchorPosition,
48539
+ tableCellAnchorPosition: (_a = paragraphSegment.tableCell) == null ? void 0 : _a.anchorPosition,
48948
48540
  caretViewport: {
48949
48541
  left: textBoxHit.left,
48950
48542
  top: textBoxHit.top,
@@ -48993,7 +48585,7 @@ function resolveCanvasSurfaceHitAtPoint(options) {
48993
48585
  position: position2,
48994
48586
  source: "canvas-layout",
48995
48587
  resolvedFromParagraph: true,
48996
- tableCellAnchorPosition: (_b2 = paragraphSegment.tableCell) == null ? void 0 : _b2.anchorPosition,
48588
+ tableCellAnchorPosition: (_b = paragraphSegment.tableCell) == null ? void 0 : _b.anchorPosition,
48997
48589
  caretViewport: {
48998
48590
  left: imageHit.left,
48999
48591
  top: imageHit.top,
@@ -49344,20 +48936,20 @@ function createEditorClipboardController(deps) {
49344
48936
  }
49345
48937
  function createEditorClipboardControllerImpl(deps) {
49346
48938
  const handleCopy = (event) => {
49347
- var _a2, _b2;
48939
+ var _a, _b;
49348
48940
  const text = getSelectedText(deps.state());
49349
48941
  if (text.length === 0) {
49350
48942
  return;
49351
48943
  }
49352
48944
  event.preventDefault();
49353
- (_a2 = event.clipboardData) == null ? void 0 : _a2.setData("text/plain", text);
49354
- (_b2 = event.clipboardData) == null ? void 0 : _b2.setData(
48945
+ (_a = event.clipboardData) == null ? void 0 : _a.setData("text/plain", text);
48946
+ (_b = event.clipboardData) == null ? void 0 : _b.setData(
49355
48947
  "text/html",
49356
48948
  serializeEditorSelectionToHtml(deps.state())
49357
48949
  );
49358
48950
  };
49359
48951
  const handleCut = (event) => {
49360
- var _a2, _b2;
48952
+ var _a, _b;
49361
48953
  if (deps.isReadOnly()) {
49362
48954
  event.preventDefault();
49363
48955
  return;
@@ -49367,8 +48959,8 @@ function createEditorClipboardControllerImpl(deps) {
49367
48959
  return;
49368
48960
  }
49369
48961
  event.preventDefault();
49370
- (_a2 = event.clipboardData) == null ? void 0 : _a2.setData("text/plain", text);
49371
- (_b2 = event.clipboardData) == null ? void 0 : _b2.setData(
48962
+ (_a = event.clipboardData) == null ? void 0 : _a.setData("text/plain", text);
48963
+ (_b = event.clipboardData) == null ? void 0 : _b.setData(
49372
48964
  "text/html",
49373
48965
  serializeEditorSelectionToHtml(deps.state())
49374
48966
  );
@@ -49383,14 +48975,14 @@ function createEditorClipboardControllerImpl(deps) {
49383
48975
  deps.focusInput();
49384
48976
  };
49385
48977
  const handlePaste = (event) => {
49386
- var _a2, _b2, _c;
48978
+ var _a, _b, _c;
49387
48979
  if (deps.isReadOnly()) {
49388
48980
  event.preventDefault();
49389
48981
  return;
49390
48982
  }
49391
48983
  if (deps.forcePlainTextPaste()) {
49392
48984
  deps.setForcePlainTextPaste(false);
49393
- const text2 = ((_a2 = event.clipboardData) == null ? void 0 : _a2.getData("text/plain")) ?? "";
48985
+ const text2 = ((_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain")) ?? "";
49394
48986
  if (text2.length === 0) {
49395
48987
  event.preventDefault();
49396
48988
  return;
@@ -49418,7 +49010,7 @@ function createEditorClipboardControllerImpl(deps) {
49418
49010
  deps.focusInput();
49419
49011
  return;
49420
49012
  }
49421
- const html = ((_b2 = event.clipboardData) == null ? void 0 : _b2.getData("text/html")) ?? "";
49013
+ const html = ((_b = event.clipboardData) == null ? void 0 : _b.getData("text/html")) ?? "";
49422
49014
  const paragraphs = parseEditorClipboardHtmlWithDom(html);
49423
49015
  if (paragraphs.length > 0) {
49424
49016
  event.preventDefault();
@@ -49666,17 +49258,17 @@ const CONTENT_MIN_WIDTH_GUARD_PX = 12;
49666
49258
  const CONTENT_MIN_HEIGHT_GUARD_PX = 4;
49667
49259
  const DEFAULT_CELL_PADDING_LEFT_RIGHT_PX = 7.2;
49668
49260
  function resolveHorizontalCellChromePx(cell) {
49669
- var _a2, _b2, _c, _d, _e;
49670
- 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(
49261
+ var _a, _b, _c, _d, _e;
49262
+ 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(
49671
49263
  0,
49672
- (((_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)
49264
+ (((_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)
49673
49265
  );
49674
49266
  const borderLeft = ((_d = cell.style) == null ? void 0 : _d.borderLeft) ? Math.max(0, ptToPx(cell.style.borderLeft.width)) : 1;
49675
49267
  const borderRight = ((_e = cell.style) == null ? void 0 : _e.borderRight) ? Math.max(0, ptToPx(cell.style.borderRight.width)) : 1;
49676
49268
  return padding + borderLeft + borderRight;
49677
49269
  }
49678
49270
  function resolveRowHeightsPx(tableNode, tableLayout, geometry) {
49679
- var _a2, _b2;
49271
+ var _a, _b;
49680
49272
  const rowCount = Math.max(1, tableNode.rows.length);
49681
49273
  const baseRowHeight = geometry.bounds.height / rowCount;
49682
49274
  const rowHeights = Array(rowCount).fill(baseRowHeight);
@@ -49686,7 +49278,7 @@ function resolveRowHeightsPx(tableNode, tableLayout, geometry) {
49686
49278
  )
49687
49279
  );
49688
49280
  for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) {
49689
- const explicitPt = parseSizeToPt((_b2 = (_a2 = tableNode.rows[rowIndex]) == null ? void 0 : _a2.style) == null ? void 0 : _b2.height);
49281
+ const explicitPt = parseSizeToPt((_b = (_a = tableNode.rows[rowIndex]) == null ? void 0 : _a.style) == null ? void 0 : _b.height);
49690
49282
  if (explicitPt !== null) {
49691
49283
  rowHeights[rowIndex] = Math.max(1, ptToPx(explicitPt));
49692
49284
  continue;
@@ -49776,7 +49368,7 @@ function resolveMinRowHeightPx(tableNode, tableLayout, geometry, targetRowIndex)
49776
49368
  return Math.max(minFloor, minHeight);
49777
49369
  }
49778
49370
  function resolveMinColumnWidthsPx(state, tableNode, tableLayout, geometry) {
49779
- var _a2;
49371
+ var _a;
49780
49372
  const minFloor = ptToPx(MIN_TABLE_SIZE_PT);
49781
49373
  const result = {};
49782
49374
  const geometryByKey = new Map(
@@ -49790,7 +49382,7 @@ function resolveMinColumnWidthsPx(state, tableNode, tableLayout, geometry) {
49790
49382
  `${entry.rowIndex}:${entry.cellIndex}`
49791
49383
  );
49792
49384
  if (!geometryCell) continue;
49793
- const cell = (_a2 = tableNode.rows[entry.rowIndex]) == null ? void 0 : _a2.cells[entry.cellIndex];
49385
+ const cell = (_a = tableNode.rows[entry.rowIndex]) == null ? void 0 : _a.cells[entry.cellIndex];
49794
49386
  if (!cell) continue;
49795
49387
  const visualCol = entry.visualColumnIndex;
49796
49388
  const currentMin = result[visualCol] ?? minFloor;
@@ -49822,7 +49414,7 @@ function applyRowResize(state, resize, delta) {
49822
49414
  return setTableRowHeight(state, resize.tableId, resize.index, newSizePt);
49823
49415
  }
49824
49416
  function applyColumnResize(state, resize, delta) {
49825
- var _a2;
49417
+ var _a;
49826
49418
  if (resize.type !== "column") return state;
49827
49419
  const deltaPt = pxToPt(delta);
49828
49420
  const maxColumnIndex = resize.maxColumnIndex ?? resize.index;
@@ -49888,7 +49480,7 @@ function applyColumnResize(state, resize, delta) {
49888
49480
  0
49889
49481
  );
49890
49482
  const tableNode = getTableById(state, resize.tableId);
49891
- const currentTableWidthPt = parseSizeToPt((_a2 = tableNode == null ? void 0 : tableNode.style) == null ? void 0 : _a2.width);
49483
+ const currentTableWidthPt = parseSizeToPt((_a = tableNode == null ? void 0 : tableNode.style) == null ? void 0 : _a.width);
49892
49484
  const tableWidthToPersist = isLastColumn ? tableWidthPt : currentTableWidthPt !== null ? currentTableWidthPt : void 0;
49893
49485
  return setTableColumnWidths(
49894
49486
  state,
@@ -49938,7 +49530,7 @@ const DRAG_THRESHOLD_PX$1 = 2;
49938
49530
  function createEditorTableResize(deps) {
49939
49531
  const [resizing, setResizing] = createSignal(null);
49940
49532
  const handleMouseMove = (event) => {
49941
- var _a2;
49533
+ var _a;
49942
49534
  if (resizing()) {
49943
49535
  setActiveCursorClass(resizing().type === "column");
49944
49536
  return;
@@ -49954,7 +49546,7 @@ function createEditorTableResize(deps) {
49954
49546
  deps.state(),
49955
49547
  deps.documentLayout(),
49956
49548
  deps.canvasSnapshotProvider,
49957
- (_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
49549
+ (_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)
49958
49550
  );
49959
49551
  if (!info) {
49960
49552
  clearResizeCursorClasses();
@@ -49963,7 +49555,7 @@ function createEditorTableResize(deps) {
49963
49555
  setHoverCursorClass(info.side === "left" || info.side === "right");
49964
49556
  };
49965
49557
  const handleMouseDown = (event) => {
49966
- var _a2, _b2;
49558
+ var _a, _b;
49967
49559
  const surface = deps.surfaceRef();
49968
49560
  if (!surface) return false;
49969
49561
  const info = findTableResizeHoverInfo(
@@ -49972,7 +49564,7 @@ function createEditorTableResize(deps) {
49972
49564
  deps.state(),
49973
49565
  deps.documentLayout(),
49974
49566
  deps.canvasSnapshotProvider,
49975
- (_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
49567
+ (_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)
49976
49568
  );
49977
49569
  if (!info) return false;
49978
49570
  const state = deps.state();
@@ -50004,7 +49596,7 @@ function createEditorTableResize(deps) {
50004
49596
  maxColumnIndex,
50005
49597
  minColumnWidthsPx,
50006
49598
  resizeFromLeftEdge: isLeftTableEdge,
50007
- initialTableIndentLeftPt: parseSizeToPt((_b2 = info.tableNode.style) == null ? void 0 : _b2.indentLeft) ?? 0,
49599
+ initialTableIndentLeftPt: parseSizeToPt((_b = info.tableNode.style) == null ? void 0 : _b.indentLeft) ?? 0,
50008
49600
  guideBounds: getGuideBounds(deps.viewportRef)
50009
49601
  });
50010
49602
  setActiveCursorClass(true);
@@ -50058,10 +49650,10 @@ function createEditorTableResize(deps) {
50058
49650
  setActiveCursorClass(currentResizing.type === "column");
50059
49651
  };
50060
49652
  const handleWindowMouseUp = (event) => {
50061
- var _a2;
49653
+ var _a;
50062
49654
  const currentResizing = resizing();
50063
49655
  if (!currentResizing) return;
50064
- const z = ((_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)) ?? 1;
49656
+ const z = ((_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)) ?? 1;
50065
49657
  const delta = ((currentResizing.type === "column" ? event.clientX : event.clientY) - currentResizing.initialPos) / z;
50066
49658
  if (Math.abs(delta) >= DRAG_THRESHOLD_PX$1) {
50067
49659
  deps.applyTransactionalState((current) => {
@@ -50172,7 +49764,7 @@ function createEditorTableCornerResize(deps) {
50172
49764
  stop();
50173
49765
  };
50174
49766
  const handleMouseDown = (tableId, event) => {
50175
- var _a2;
49767
+ var _a;
50176
49768
  const surface = deps.surfaceRef();
50177
49769
  if (!surface) return;
50178
49770
  const geometries = buildTableGeometries(
@@ -50180,7 +49772,7 @@ function createEditorTableCornerResize(deps) {
50180
49772
  deps.state(),
50181
49773
  deps.documentLayout(),
50182
49774
  deps.canvasSnapshotProvider,
50183
- (_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
49775
+ (_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)
50184
49776
  );
50185
49777
  const geometry = geometries.find(
50186
49778
  (candidate) => candidate.tableId === tableId
@@ -50243,7 +49835,7 @@ function createEditorTableDragImpl(deps) {
50243
49835
  document.body.style.cursor = "";
50244
49836
  };
50245
49837
  const handleMouseMove = (event) => {
50246
- var _a2;
49838
+ var _a;
50247
49839
  setMousePos({ x: event.clientX, y: event.clientY });
50248
49840
  if (!dragging()) {
50249
49841
  const delta = Math.abs(event.clientY - startClientY());
@@ -50259,7 +49851,7 @@ function createEditorTableDragImpl(deps) {
50259
49851
  event.clientX,
50260
49852
  event.clientY
50261
49853
  );
50262
- const tableId = (_a2 = draggedTableInfo()) == null ? void 0 : _a2.tableId;
49854
+ const tableId = (_a = draggedTableInfo()) == null ? void 0 : _a.tableId;
50263
49855
  if (pos && tableId) {
50264
49856
  const state = deps.state();
50265
49857
  const location = findParagraphTableLocation(
@@ -50288,7 +49880,7 @@ function createEditorTableDragImpl(deps) {
50288
49880
  const tableId = info == null ? void 0 : info.tableId;
50289
49881
  if (tableId) {
50290
49882
  deps.applyTransactionalState((current) => {
50291
- var _a2;
49883
+ var _a;
50292
49884
  const findTable = () => {
50293
49885
  for (const zone of ["main", "header", "footer"]) {
50294
49886
  const blocks = getEditableBlocksForZone(current, zone);
@@ -50300,7 +49892,7 @@ function createEditorTableDragImpl(deps) {
50300
49892
  return void 0;
50301
49893
  };
50302
49894
  const table = findTable();
50303
- if ((table == null ? void 0 : table.type) === "table" && ((_a2 = table.style) == null ? void 0 : _a2.floating)) {
49895
+ if ((table == null ? void 0 : table.type) === "table" && ((_a = table.style) == null ? void 0 : _a.floating)) {
50304
49896
  const floating = table.style.floating;
50305
49897
  return setActiveTableStyleValue(current, tableId, "floating", {
50306
49898
  ...floating,
@@ -50472,9 +50064,9 @@ function createEditorSurfaceEventsImpl(deps) {
50472
50064
  globalThis.clearTimeout(handle);
50473
50065
  };
50474
50066
  const applyWithZone = (state, targetZone, newState, targetPosition) => {
50475
- var _a2;
50067
+ var _a;
50476
50068
  const isZoneTransition = targetZone !== (state.activeZone ?? "main");
50477
- const targetFootnoteId = targetZone === "footnote" && targetPosition ? (_a2 = findParagraphLocation(newState.document, targetPosition.paragraphId)) == null ? void 0 : _a2.footnoteId : void 0;
50069
+ const targetFootnoteId = targetZone === "footnote" && targetPosition ? (_a = findParagraphLocation(newState.document, targetPosition.paragraphId)) == null ? void 0 : _a.footnoteId : void 0;
50478
50070
  const isFootnoteTransition = targetZone === "footnote" && targetFootnoteId !== state.activeFootnoteId;
50479
50071
  if (!isZoneTransition && !isFootnoteTransition) {
50480
50072
  deps.applyState(newState);
@@ -50734,7 +50326,7 @@ function createEditorSurfaceEventsImpl(deps) {
50734
50326
  deps.focusInputAfterPointerSelection();
50735
50327
  };
50736
50328
  const handleSurfaceMouseDown = (event) => {
50737
- var _a2;
50329
+ var _a;
50738
50330
  if (event.button !== 0) {
50739
50331
  return;
50740
50332
  }
@@ -50769,7 +50361,7 @@ function createEditorSurfaceEventsImpl(deps) {
50769
50361
  deps.focusInputAfterPointerSelection();
50770
50362
  return;
50771
50363
  }
50772
- if ((_a2 = deps.textDrag) == null ? void 0 : _a2.tryStartTextDrag(event, hit)) {
50364
+ if ((_a = deps.textDrag) == null ? void 0 : _a.tryStartTextDrag(event, hit)) {
50773
50365
  dragAnchor = null;
50774
50366
  stopDragging();
50775
50367
  deps.focusInputAfterPointerSelection();
@@ -50879,7 +50471,7 @@ function createEditorTextInputImpl(deps) {
50879
50471
  const [composing, setComposing] = createSignal(false);
50880
50472
  let suppressedInputText = null;
50881
50473
  const handleTextInput = (event) => {
50882
- var _a2, _b2, _c, _d;
50474
+ var _a, _b, _c, _d;
50883
50475
  markStart("input:text");
50884
50476
  if (deps.isReadOnly()) {
50885
50477
  deps.logger.debug(
@@ -50904,9 +50496,9 @@ function createEditorTextInputImpl(deps) {
50904
50496
  }
50905
50497
  const state = deps.state();
50906
50498
  const sel = state.selection;
50907
- const currentRun = (_a2 = getParagraphs(state).find((p) => p.id === sel.anchor.paragraphId)) == null ? void 0 : _a2.runs.find((r) => r.id === sel.anchor.runId);
50499
+ const currentRun = (_a = getParagraphs(state).find((p) => p.id === sel.anchor.paragraphId)) == null ? void 0 : _a.runs.find((r) => r.id === sel.anchor.runId);
50908
50500
  const runStyle = currentRun ? {
50909
- bold: (_b2 = currentRun.styles) == null ? void 0 : _b2.bold,
50501
+ bold: (_b = currentRun.styles) == null ? void 0 : _b.bold,
50910
50502
  italic: (_c = currentRun.styles) == null ? void 0 : _c.italic,
50911
50503
  underline: (_d = currentRun.styles) == null ? void 0 : _d.underline
50912
50504
  } : null;
@@ -51025,8 +50617,8 @@ function createEditorTextDragImpl(deps) {
51025
50617
  document.head.appendChild(cursorStyleEl);
51026
50618
  };
51027
50619
  const stopDrag = () => {
51028
- var _a2;
51029
- (_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:stop", {
50620
+ var _a;
50621
+ (_a = deps.logger) == null ? void 0 : _a.info("text-drag:stop", {
51030
50622
  dragging: dragging(),
51031
50623
  dropTarget: dropTargetPos() ? `${dropTargetPos().paragraphId}:${dropTargetPos().runId}[${dropTargetPos().offset}]` : null,
51032
50624
  copyMode: copyMode()
@@ -51043,7 +50635,7 @@ function createEditorTextDragImpl(deps) {
51043
50635
  window.removeEventListener("mouseup", handleWindowMouseUp);
51044
50636
  };
51045
50637
  const handleWindowMouseMove = (event) => {
51046
- var _a2, _b2, _c;
50638
+ var _a, _b, _c;
51047
50639
  if (!pendingStart) {
51048
50640
  return;
51049
50641
  }
@@ -51055,7 +50647,7 @@ function createEditorTextDragImpl(deps) {
51055
50647
  if (deltaX + deltaY < 4) {
51056
50648
  return;
51057
50649
  }
51058
- (_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:activate", {
50650
+ (_a = deps.logger) == null ? void 0 : _a.info("text-drag:activate", {
51059
50651
  start: pendingStart,
51060
50652
  at: { x: event.clientX, y: event.clientY },
51061
50653
  deltaX,
@@ -51067,7 +50659,7 @@ function createEditorTextDragImpl(deps) {
51067
50659
  setPointerPos({ x: event.clientX, y: event.clientY });
51068
50660
  const hit = deps.resolveSurfaceHitAtPoint(event.clientX, event.clientY);
51069
50661
  if (!(hit == null ? void 0 : hit.resolvedFromParagraph)) {
51070
- (_b2 = deps.logger) == null ? void 0 : _b2.debug("text-drag:hit-miss", {
50662
+ (_b = deps.logger) == null ? void 0 : _b.debug("text-drag:hit-miss", {
51071
50663
  x: event.clientX,
51072
50664
  y: event.clientY
51073
50665
  });
@@ -51095,8 +50687,8 @@ function createEditorTextDragImpl(deps) {
51095
50687
  setCaretViewport(hit.caretViewport ?? null);
51096
50688
  };
51097
50689
  const handleWindowMouseUp = (event) => {
51098
- var _a2, _b2, _c;
51099
- (_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:mouseup", {
50690
+ var _a, _b, _c;
50691
+ (_a = deps.logger) == null ? void 0 : _a.info("text-drag:mouseup", {
51100
50692
  x: event.clientX,
51101
50693
  y: event.clientY,
51102
50694
  dragging: dragging(),
@@ -51117,7 +50709,7 @@ function createEditorTextDragImpl(deps) {
51117
50709
  mergeKey: copy ? MERGE_KEYS.copyTextByDrag : MERGE_KEYS.moveTextByDrag
51118
50710
  }
51119
50711
  );
51120
- (_b2 = deps.logger) == null ? void 0 : _b2.info("text-drag:apply", {
50712
+ (_b = deps.logger) == null ? void 0 : _b.info("text-drag:apply", {
51121
50713
  mode: copy ? "copy" : "move",
51122
50714
  destination: `${destination.paragraphId}:${destination.runId}[${destination.offset}]`
51123
50715
  });
@@ -51143,9 +50735,9 @@ function createEditorTextDragImpl(deps) {
51143
50735
  deps.focusInputAfterPointerSelection();
51144
50736
  };
51145
50737
  const tryStartTextDrag = (event, hit) => {
51146
- var _a2, _b2, _c;
50738
+ var _a, _b, _c;
51147
50739
  if (deps.isReadOnly() || !(hit == null ? void 0 : hit.resolvedFromParagraph)) {
51148
- (_a2 = deps.logger) == null ? void 0 : _a2.debug("text-drag:skip-start", {
50740
+ (_a = deps.logger) == null ? void 0 : _a.debug("text-drag:skip-start", {
51149
50741
  reason: deps.isReadOnly() ? "readonly" : "no-hit",
51150
50742
  x: event.clientX,
51151
50743
  y: event.clientY
@@ -51154,7 +50746,7 @@ function createEditorTextDragImpl(deps) {
51154
50746
  }
51155
50747
  const current = deps.state();
51156
50748
  if (!isPositionInsideSelection(current, hit.position)) {
51157
- (_b2 = deps.logger) == null ? void 0 : _b2.debug("text-drag:skip-start", {
50749
+ (_b = deps.logger) == null ? void 0 : _b.debug("text-drag:skip-start", {
51158
50750
  reason: "outside-selection",
51159
50751
  x: event.clientX,
51160
50752
  y: event.clientY,
@@ -51293,7 +50885,7 @@ function createEditorNavigationImpl(deps) {
51293
50885
  return moveVerticalSelection(direction, false);
51294
50886
  };
51295
50887
  const moveVerticalSelection = (direction, extend) => {
51296
- var _a2, _b2, _c, _d, _e, _f;
50888
+ var _a, _b, _c, _d, _e, _f;
51297
50889
  const state = deps.state();
51298
50890
  const paragraphs = getParagraphs(state);
51299
50891
  const currentIndex = paragraphs.findIndex(
@@ -51310,7 +50902,7 @@ function createEditorNavigationImpl(deps) {
51310
50902
  surface: surfaceRef,
51311
50903
  state,
51312
50904
  documentLayout: deps.documentLayout(),
51313
- zoomFactor: (_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
50905
+ zoomFactor: (_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)
51314
50906
  }) : null;
51315
50907
  let targetIndex = currentIndex + direction;
51316
50908
  const tableLocation = findParagraphTableLocation(
@@ -51343,18 +50935,18 @@ function createEditorNavigationImpl(deps) {
51343
50935
  }
51344
50936
  const scoredCandidates = rowCandidates.map(
51345
50937
  (entry) => {
51346
- var _a3, _b3;
51347
- const paragraphId = (_a3 = entry.cell.blocks[0]) == null ? void 0 : _a3.id;
51348
- const cellRect = paragraphId ? (_b3 = snapshot == null ? void 0 : snapshot.paragraphs.find(
50938
+ var _a2, _b2;
50939
+ const paragraphId = (_a2 = entry.cell.blocks[0]) == null ? void 0 : _a2.id;
50940
+ const cellRect = paragraphId ? (_b2 = snapshot == null ? void 0 : snapshot.paragraphs.find(
51349
50941
  (paragraph) => paragraph.paragraphId === paragraphId && paragraph.tableCell && paragraph.tableCell.tableId === block.id
51350
- )) == null ? void 0 : _b3.tableCell : null;
50942
+ )) == null ? void 0 : _b2.tableCell : null;
51351
50943
  const left = (cellRect == null ? void 0 : cellRect.left) ?? desiredX;
51352
50944
  const right = cellRect ? cellRect.left + cellRect.width : desiredX;
51353
50945
  const distance = desiredX < left ? left - desiredX : desiredX > right ? desiredX - right : 0;
51354
50946
  return { entry, distance };
51355
50947
  }
51356
50948
  ).sort((left, right) => left.distance - right.distance);
51357
- const candidate = (_b2 = scoredCandidates[0]) == null ? void 0 : _b2.entry;
50949
+ const candidate = (_b = scoredCandidates[0]) == null ? void 0 : _b.entry;
51358
50950
  if (!candidate) {
51359
50951
  continue;
51360
50952
  }
@@ -51426,12 +51018,12 @@ function createEditorRevisionController(deps) {
51426
51018
  function createEditorRevisionControllerImpl(deps) {
51427
51019
  const [hoveredRevision, setHoveredRevision] = createSignal(null);
51428
51020
  const handleRevisionMouseEnter = (revisionId, event) => {
51429
- var _a2, _b2, _c;
51021
+ var _a, _b, _c;
51430
51022
  const paragraphs = getParagraphs(deps.state());
51431
51023
  let foundRevision;
51432
51024
  for (const p of paragraphs) {
51433
51025
  for (const run of p.runs) {
51434
- if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId) {
51026
+ if (((_a = run.revision) == null ? void 0 : _a.id) === revisionId) {
51435
51027
  foundRevision = run.revision;
51436
51028
  break;
51437
51029
  }
@@ -51439,10 +51031,10 @@ function createEditorRevisionControllerImpl(deps) {
51439
51031
  if (foundRevision) break;
51440
51032
  }
51441
51033
  const findInBlocks = (blocks) => {
51442
- var _a3, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
51034
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
51443
51035
  for (const block of blocks) {
51444
51036
  if (block.type === "paragraph") continue;
51445
- if (((_b3 = (_a3 = block.style) == null ? void 0 : _a3.revision) == null ? void 0 : _b3.id) === revisionId) {
51037
+ if (((_b2 = (_a2 = block.style) == null ? void 0 : _a2.revision) == null ? void 0 : _b2.id) === revisionId) {
51446
51038
  return block.style.revision;
51447
51039
  }
51448
51040
  if (((_c2 = block.gridRevision) == null ? void 0 : _c2.id) === revisionId) return block.gridRevision;
@@ -51485,7 +51077,7 @@ function createEditorRevisionControllerImpl(deps) {
51485
51077
  }
51486
51078
  if (!foundRevision) return;
51487
51079
  const rect = event.currentTarget.getBoundingClientRect();
51488
- const surfaceRect = (_b2 = deps.surfaceRef()) == null ? void 0 : _b2.getBoundingClientRect();
51080
+ const surfaceRect = (_b = deps.surfaceRef()) == null ? void 0 : _b.getBoundingClientRect();
51489
51081
  if (!surfaceRect) return;
51490
51082
  const z = ((_c = deps.zoomFactor) == null ? void 0 : _c.call(deps)) ?? 1;
51491
51083
  setHoveredRevision({
@@ -51679,8 +51271,8 @@ function createEditorInteractionRuntimeImpl(deps) {
51679
51271
  logger
51680
51272
  });
51681
51273
  const resolvePositionAtSurfacePoint = (clientX, clientY) => {
51682
- var _a2;
51683
- return ((_a2 = resolveSurfaceHitAtPoint(clientX, clientY)) == null ? void 0 : _a2.position) ?? null;
51274
+ var _a;
51275
+ return ((_a = resolveSurfaceHitAtPoint(clientX, clientY)) == null ? void 0 : _a.position) ?? null;
51684
51276
  };
51685
51277
  const imageOps = createEditorImageOperations({
51686
51278
  state,
@@ -51779,10 +51371,10 @@ function ensureFootnotes(footnotes) {
51779
51371
  return { items: {} };
51780
51372
  }
51781
51373
  function nextAutoMarker(document2) {
51782
- var _a2, _b2;
51374
+ var _a, _b;
51783
51375
  const footnotes = document2.footnotes;
51784
- const format = ((_a2 = footnotes == null ? void 0 : footnotes.settings) == null ? void 0 : _a2.numberFormat) ?? "decimal";
51785
- const startAt = ((_b2 = footnotes == null ? void 0 : footnotes.settings) == null ? void 0 : _b2.startAt) ?? 1;
51376
+ const format = ((_a = footnotes == null ? void 0 : footnotes.settings) == null ? void 0 : _a.numberFormat) ?? "decimal";
51377
+ const startAt = ((_b = footnotes == null ? void 0 : footnotes.settings) == null ? void 0 : _b.startAt) ?? 1;
51786
51378
  let autoCount = startAt - 1;
51787
51379
  const seen = /* @__PURE__ */ new Set();
51788
51380
  for (const { run } of iterateFootnoteReferenceRuns(document2)) {
@@ -51857,10 +51449,10 @@ function toggleTrackChanges(state) {
51857
51449
  }
51858
51450
  function transformTableRevisionBlocks(blocks, revisionId, accept) {
51859
51451
  return blocks.flatMap((block) => {
51860
- var _a2;
51452
+ var _a;
51861
51453
  if (block.type === "paragraph") return [block];
51862
51454
  let style2 = block.style;
51863
- if (((_a2 = style2 == null ? void 0 : style2.revision) == null ? void 0 : _a2.id) === revisionId) {
51455
+ if (((_a = style2 == null ? void 0 : style2.revision) == null ? void 0 : _a.id) === revisionId) {
51864
51456
  if (accept) {
51865
51457
  const { revision: _revision, ...current } = style2;
51866
51458
  style2 = current;
@@ -51904,8 +51496,8 @@ function transformTableRevisionBlocks(blocks, revisionId, accept) {
51904
51496
  }
51905
51497
  }
51906
51498
  const rows = sourceRows.flatMap((row) => {
51907
- var _a3, _b2, _c, _d;
51908
- if (((_b2 = (_a3 = row.style) == null ? void 0 : _a3.revision) == null ? void 0 : _b2.id) === revisionId) {
51499
+ var _a2, _b, _c, _d;
51500
+ if (((_b = (_a2 = row.style) == null ? void 0 : _a2.revision) == null ? void 0 : _b.id) === revisionId) {
51909
51501
  const remove = accept && row.style.revision.type === "delete" || !accept && row.style.revision.type === "insert";
51910
51502
  if (remove) return [];
51911
51503
  }
@@ -51926,8 +51518,8 @@ function transformTableRevisionBlocks(blocks, revisionId, accept) {
51926
51518
  rowStyle = current;
51927
51519
  }
51928
51520
  const cells = row.cells.flatMap((cell) => {
51929
- var _a4, _b3, _c2, _d2, _e;
51930
- if (((_b3 = (_a4 = cell.style) == null ? void 0 : _a4.revision) == null ? void 0 : _b3.id) === revisionId) {
51521
+ var _a3, _b2, _c2, _d2, _e;
51522
+ if (((_b2 = (_a3 = cell.style) == null ? void 0 : _a3.revision) == null ? void 0 : _b2.id) === revisionId) {
51931
51523
  const remove = accept && cell.style.revision.type === "delete" || !accept && cell.style.revision.type === "insert";
51932
51524
  if (remove) return [];
51933
51525
  }
@@ -52002,12 +51594,12 @@ function acceptRevision(state, revisionId) {
52002
51594
  const nextParagraphs = paragraphs.map((paragraph) => {
52003
51595
  const nextRuns = paragraph.runs.filter(
52004
51596
  (run) => {
52005
- var _a2;
52006
- return !(((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "delete");
51597
+ var _a;
51598
+ return !(((_a = run.revision) == null ? void 0 : _a.id) === revisionId && run.revision.type === "delete");
52007
51599
  }
52008
51600
  ).map((run) => {
52009
- var _a2;
52010
- if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "insert") {
51601
+ var _a;
51602
+ if (((_a = run.revision) == null ? void 0 : _a.id) === revisionId && run.revision.type === "insert") {
52011
51603
  const nextRun = { ...run };
52012
51604
  delete nextRun.revision;
52013
51605
  return nextRun;
@@ -52034,12 +51626,12 @@ function rejectRevision(state, revisionId) {
52034
51626
  const nextParagraphs = paragraphs.map((paragraph) => {
52035
51627
  const nextRuns = paragraph.runs.filter(
52036
51628
  (run) => {
52037
- var _a2;
52038
- return !(((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "insert");
51629
+ var _a;
51630
+ return !(((_a = run.revision) == null ? void 0 : _a.id) === revisionId && run.revision.type === "insert");
52039
51631
  }
52040
51632
  ).map((run) => {
52041
- var _a2;
52042
- if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "delete") {
51633
+ var _a;
51634
+ if (((_a = run.revision) == null ? void 0 : _a.id) === revisionId && run.revision.type === "delete") {
52043
51635
  const nextRun = { ...run };
52044
51636
  delete nextRun.revision;
52045
51637
  return nextRun;
@@ -52062,7 +51654,7 @@ function rejectRevision(state, revisionId) {
52062
51654
  return transformTableRevision(textState, revisionId, false);
52063
51655
  }
52064
51656
  function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
52065
- var _a2, _b2, _c, _d, _e;
51657
+ var _a, _b, _c, _d, _e;
52066
51658
  for (const block of blocks) {
52067
51659
  if (block.type === "paragraph") continue;
52068
51660
  const tableSelected = block.rows.some(
@@ -52073,7 +51665,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
52073
51665
  )
52074
51666
  );
52075
51667
  if (tableSelected) {
52076
- if ((_a2 = block.style) == null ? void 0 : _a2.revision) revisionIds.add(block.style.revision.id);
51668
+ if ((_a = block.style) == null ? void 0 : _a.revision) revisionIds.add(block.style.revision.id);
52077
51669
  if (block.gridRevision) revisionIds.add(block.gridRevision.id);
52078
51670
  }
52079
51671
  for (const row of block.rows) {
@@ -52083,7 +51675,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
52083
51675
  )
52084
51676
  );
52085
51677
  if (selectedCells.length > 0) {
52086
- if ((_b2 = row.style) == null ? void 0 : _b2.revision) revisionIds.add(row.style.revision.id);
51678
+ if ((_b = row.style) == null ? void 0 : _b.revision) revisionIds.add(row.style.revision.id);
52087
51679
  if ((_c = row.style) == null ? void 0 : _c.propertyRevision) {
52088
51680
  revisionIds.add(row.style.propertyRevision.id);
52089
51681
  }
@@ -52099,7 +51691,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
52099
51691
  }
52100
51692
  }
52101
51693
  function acceptRevisionsInSelection(state) {
52102
- var _a2;
51694
+ var _a;
52103
51695
  const normalized = normalizeSelection(state);
52104
51696
  const paragraphs = getParagraphs(state);
52105
51697
  const revisionIds = /* @__PURE__ */ new Set();
@@ -52109,7 +51701,7 @@ function acceptRevisionsInSelection(state) {
52109
51701
  const endOffset = i === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
52110
51702
  const runs = sliceRuns(paragraph, startOffset, endOffset);
52111
51703
  for (const run of runs) {
52112
- if ((_a2 = run.revision) == null ? void 0 : _a2.id) {
51704
+ if ((_a = run.revision) == null ? void 0 : _a.id) {
52113
51705
  revisionIds.add(run.revision.id);
52114
51706
  }
52115
51707
  }
@@ -52139,7 +51731,7 @@ function acceptRevisionsInSelection(state) {
52139
51731
  return nextState;
52140
51732
  }
52141
51733
  function rejectRevisionsInSelection(state) {
52142
- var _a2;
51734
+ var _a;
52143
51735
  const normalized = normalizeSelection(state);
52144
51736
  const paragraphs = getParagraphs(state);
52145
51737
  const revisionIds = /* @__PURE__ */ new Set();
@@ -52149,7 +51741,7 @@ function rejectRevisionsInSelection(state) {
52149
51741
  const endOffset = i === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
52150
51742
  const runs = sliceRuns(paragraph, startOffset, endOffset);
52151
51743
  for (const run of runs) {
52152
- if ((_a2 = run.revision) == null ? void 0 : _a2.id) {
51744
+ if ((_a = run.revision) == null ? void 0 : _a.id) {
52153
51745
  revisionIds.add(run.revision.id);
52154
51746
  }
52155
51747
  }
@@ -52179,7 +51771,7 @@ function rejectRevisionsInSelection(state) {
52179
51771
  return nextState;
52180
51772
  }
52181
51773
  function getLinkAtSelection(state) {
52182
- var _a2, _b2, _c;
51774
+ var _a, _b, _c;
52183
51775
  const normalized = normalizeSelection(state);
52184
51776
  const paragraphs = getParagraphs(state);
52185
51777
  if (normalized.isCollapsed) {
@@ -52187,7 +51779,7 @@ function getLinkAtSelection(state) {
52187
51779
  if (!paragraph) {
52188
51780
  return null;
52189
51781
  }
52190
- return ((_a2 = expandLinkRangeInParagraph(paragraph, normalized.startParagraphOffset)) == null ? void 0 : _a2.href) ?? null;
51782
+ return ((_a = expandLinkRangeInParagraph(paragraph, normalized.startParagraphOffset)) == null ? void 0 : _a.href) ?? null;
52191
51783
  }
52192
51784
  const touchedRuns = paragraphs.slice(normalized.startIndex, normalized.endIndex + 1).flatMap((paragraph, relativeIndex) => {
52193
51785
  const paragraphIndex = normalized.startIndex + relativeIndex;
@@ -52198,13 +51790,13 @@ function getLinkAtSelection(state) {
52198
51790
  if (touchedRuns.length === 0) {
52199
51791
  return null;
52200
51792
  }
52201
- const href = (_c = (_b2 = touchedRuns[0]) == null ? void 0 : _b2.styles) == null ? void 0 : _c.link;
51793
+ const href = (_c = (_b = touchedRuns[0]) == null ? void 0 : _b.styles) == null ? void 0 : _c.link;
52202
51794
  if (!href) {
52203
51795
  return null;
52204
51796
  }
52205
51797
  return touchedRuns.every((run) => {
52206
- var _a3;
52207
- return ((_a3 = run.styles) == null ? void 0 : _a3.link) === href;
51798
+ var _a2;
51799
+ return ((_a2 = run.styles) == null ? void 0 : _a2.link) === href;
52208
51800
  }) ? href : null;
52209
51801
  }
52210
51802
  function setLinkAtSelection(state, href) {
@@ -52354,13 +51946,13 @@ function toggleParagraphList(state, kind) {
52354
51946
  const targetedParagraphs = paragraphs.slice(startIndex, endIndex + 1);
52355
51947
  const shouldClear = targetedParagraphs.length > 0 && targetedParagraphs.every(
52356
51948
  (paragraph) => {
52357
- var _a2;
52358
- return ((_a2 = paragraph.list) == null ? void 0 : _a2.kind) === kind;
51949
+ var _a;
51950
+ return ((_a = paragraph.list) == null ? void 0 : _a.kind) === kind;
52359
51951
  }
52360
51952
  );
52361
51953
  const nextParagraphs = paragraphs.map(
52362
51954
  (paragraph, paragraphIndex) => {
52363
- var _a2, _b2, _c;
51955
+ var _a, _b, _c;
52364
51956
  if (paragraphIndex < startIndex || paragraphIndex > endIndex) {
52365
51957
  return cloneParagraph(paragraph);
52366
51958
  }
@@ -52371,8 +51963,8 @@ function toggleParagraphList(state, kind) {
52371
51963
  }
52372
51964
  nextParagraph.list = {
52373
51965
  kind,
52374
- level: ((_a2 = paragraph.list) == null ? void 0 : _a2.level) ?? 0,
52375
- format: (_b2 = paragraph.list) == null ? void 0 : _b2.format,
51966
+ level: ((_a = paragraph.list) == null ? void 0 : _a.level) ?? 0,
51967
+ format: (_b = paragraph.list) == null ? void 0 : _b.format,
52376
51968
  startAt: (_c = paragraph.list) == null ? void 0 : _c.startAt
52377
51969
  };
52378
51970
  return nextParagraph;
@@ -52721,12 +52313,12 @@ function createEditorCommandsControllerImpl(deps) {
52721
52313
  );
52722
52314
  };
52723
52315
  const promptForImageAlt = () => {
52724
- var _a2;
52316
+ var _a;
52725
52317
  const run = selectedImageRun();
52726
52318
  if (!run) {
52727
52319
  return;
52728
52320
  }
52729
- const currentAlt = ((_a2 = getRunImage(run.run)) == null ? void 0 : _a2.alt) ?? "";
52321
+ const currentAlt = ((_a = getRunImage(run.run)) == null ? void 0 : _a.alt) ?? "";
52730
52322
  deps.openImageAltDialog(currentAlt);
52731
52323
  };
52732
52324
  const applyImageCaptionCommand = (caption) => {
@@ -52864,13 +52456,13 @@ class EditorCommandRegistry {
52864
52456
  return Array.from(this.bindings.values());
52865
52457
  }
52866
52458
  execute(event, deps, commandExecutor) {
52867
- var _a2;
52459
+ var _a;
52868
52460
  const isCtrlOrMeta = event.ctrlKey || event.metaKey;
52869
52461
  const lowerKey = event.key.toLowerCase();
52870
52462
  for (const binding of this.bindings.values()) {
52871
52463
  if (binding.key.toLowerCase() === lowerKey && Boolean(binding.ctrlOrMeta) === isCtrlOrMeta && Boolean(binding.shift) === event.shiftKey && Boolean(binding.alt) === event.altKey) {
52872
52464
  if (binding.command && commandExecutor) {
52873
- const canExecute = ((_a2 = commandExecutor.canExecuteCommand) == null ? void 0 : _a2.call(commandExecutor, binding.command)) ?? true;
52465
+ const canExecute = ((_a = commandExecutor.canExecuteCommand) == null ? void 0 : _a.call(commandExecutor, binding.command)) ?? true;
52874
52466
  if (canExecute) {
52875
52467
  commandExecutor.executeCommand(binding.command);
52876
52468
  event.preventDefault();
@@ -53144,12 +52736,12 @@ function createEditorKeyboardControllerImpl(deps) {
53144
52736
  }
53145
52737
  const commandExecutor = deps.executeCommand ? {
53146
52738
  executeCommand: (commandName, payload) => {
53147
- var _a2;
53148
- return (_a2 = deps.executeCommand) == null ? void 0 : _a2.call(deps, commandName, payload);
52739
+ var _a;
52740
+ return (_a = deps.executeCommand) == null ? void 0 : _a.call(deps, commandName, payload);
53149
52741
  },
53150
52742
  canExecuteCommand: (commandName, payload) => {
53151
- var _a2;
53152
- return (_a2 = deps.canExecuteCommand) == null ? void 0 : _a2.call(deps, commandName, payload);
52743
+ var _a;
52744
+ return (_a = deps.canExecuteCommand) == null ? void 0 : _a.call(deps, commandName, payload);
53153
52745
  }
53154
52746
  } : void 0;
53155
52747
  if (registry.execute(event, deps, commandExecutor)) {
@@ -53834,10 +53426,10 @@ function buildDocumentAndBrowserCommands({
53834
53426
  "imageWidthCm",
53835
53427
  (p) => image.setWidthCm(Number(p)),
53836
53428
  () => {
53837
- var _a2;
53429
+ var _a;
53838
53430
  return {
53839
53431
  isEnabled: image.isSelected(),
53840
- value: ((_a2 = image.getSizeCm()) == null ? void 0 : _a2.width) ?? null
53432
+ value: ((_a = image.getSizeCm()) == null ? void 0 : _a.width) ?? null
53841
53433
  };
53842
53434
  }
53843
53435
  ),
@@ -53845,10 +53437,10 @@ function buildDocumentAndBrowserCommands({
53845
53437
  "imageHeightCm",
53846
53438
  (p) => image.setHeightCm(Number(p)),
53847
53439
  () => {
53848
- var _a2;
53440
+ var _a;
53849
53441
  return {
53850
53442
  isEnabled: image.isSelected(),
53851
- value: ((_a2 = image.getSizeCm()) == null ? void 0 : _a2.height) ?? null
53443
+ value: ((_a = image.getSizeCm()) == null ? void 0 : _a.height) ?? null
53852
53444
  };
53853
53445
  }
53854
53446
  ),
@@ -54081,6 +53673,28 @@ function buildTableCommands({
54081
53673
  "tableCellNoBorders",
54082
53674
  () => table.cellNoBorders()
54083
53675
  ),
53676
+ tableApplyBorderPreset: actionCommand(
53677
+ "tableApplyBorderPreset",
53678
+ (p) => table.applyBorderPreset(
53679
+ p
53680
+ )
53681
+ ),
53682
+ toggleTableDrawBorders: actionCommand(
53683
+ "toggleTableDrawBorders",
53684
+ () => table.toggleDrawingBorders(),
53685
+ () => ({
53686
+ isEnabled: table.insideTable(),
53687
+ isActive: table.isDrawingBorders()
53688
+ })
53689
+ ),
53690
+ toggleTableGridlines: actionCommand(
53691
+ "toggleTableGridlines",
53692
+ () => table.toggleGridlines(),
53693
+ () => ({
53694
+ isEnabled: table.insideTable(),
53695
+ isActive: table.isShowingGridlines()
53696
+ })
53697
+ ),
54084
53698
  tableWidth100: actionCommand("tableWidth100", () => table.width100()),
54085
53699
  tableAlignLeft: actionCommand(
54086
53700
  "tableAlignLeft",
@@ -54102,10 +53716,10 @@ function buildTableCommands({
54102
53716
  "tableToggleHeaderRow",
54103
53717
  () => table.toggleTblLook("firstRow"),
54104
53718
  () => {
54105
- var _a2;
53719
+ var _a;
54106
53720
  return {
54107
53721
  isEnabled: table.insideTable(),
54108
- isActive: ((_a2 = table.getTblLook()) == null ? void 0 : _a2.firstRow) ?? false
53722
+ isActive: ((_a = table.getTblLook()) == null ? void 0 : _a.firstRow) ?? false
54109
53723
  };
54110
53724
  }
54111
53725
  ),
@@ -54113,10 +53727,10 @@ function buildTableCommands({
54113
53727
  "tableToggleTotalRow",
54114
53728
  () => table.toggleTblLook("lastRow"),
54115
53729
  () => {
54116
- var _a2;
53730
+ var _a;
54117
53731
  return {
54118
53732
  isEnabled: table.insideTable(),
54119
- isActive: ((_a2 = table.getTblLook()) == null ? void 0 : _a2.lastRow) ?? false
53733
+ isActive: ((_a = table.getTblLook()) == null ? void 0 : _a.lastRow) ?? false
54120
53734
  };
54121
53735
  }
54122
53736
  ),
@@ -54124,10 +53738,10 @@ function buildTableCommands({
54124
53738
  "tableToggleBandedRows",
54125
53739
  () => table.toggleTblLook("bandedRows"),
54126
53740
  () => {
54127
- var _a2;
53741
+ var _a;
54128
53742
  return {
54129
53743
  isEnabled: table.insideTable(),
54130
- isActive: ((_a2 = table.getTblLook()) == null ? void 0 : _a2.bandedRows) ?? false
53744
+ isActive: ((_a = table.getTblLook()) == null ? void 0 : _a.bandedRows) ?? false
54131
53745
  };
54132
53746
  }
54133
53747
  ),
@@ -54135,10 +53749,10 @@ function buildTableCommands({
54135
53749
  "tableToggleFirstColumn",
54136
53750
  () => table.toggleTblLook("firstCol"),
54137
53751
  () => {
54138
- var _a2;
53752
+ var _a;
54139
53753
  return {
54140
53754
  isEnabled: table.insideTable(),
54141
- isActive: ((_a2 = table.getTblLook()) == null ? void 0 : _a2.firstCol) ?? false
53755
+ isActive: ((_a = table.getTblLook()) == null ? void 0 : _a.firstCol) ?? false
54142
53756
  };
54143
53757
  }
54144
53758
  ),
@@ -54146,10 +53760,10 @@ function buildTableCommands({
54146
53760
  "tableToggleLastColumn",
54147
53761
  () => table.toggleTblLook("lastCol"),
54148
53762
  () => {
54149
- var _a2;
53763
+ var _a;
54150
53764
  return {
54151
53765
  isEnabled: table.insideTable(),
54152
- isActive: ((_a2 = table.getTblLook()) == null ? void 0 : _a2.lastCol) ?? false
53766
+ isActive: ((_a = table.getTblLook()) == null ? void 0 : _a.lastCol) ?? false
54153
53767
  };
54154
53768
  }
54155
53769
  ),
@@ -54157,10 +53771,10 @@ function buildTableCommands({
54157
53771
  "tableToggleBandedColumns",
54158
53772
  () => table.toggleTblLook("bandedCols"),
54159
53773
  () => {
54160
- var _a2;
53774
+ var _a;
54161
53775
  return {
54162
53776
  isEnabled: table.insideTable(),
54163
- isActive: ((_a2 = table.getTblLook()) == null ? void 0 : _a2.bandedCols) ?? false
53777
+ isActive: ((_a = table.getTblLook()) == null ? void 0 : _a.bandedCols) ?? false
54164
53778
  };
54165
53779
  }
54166
53780
  ),
@@ -54272,10 +53886,10 @@ const DEFAULT_TOC_MAX_LEVEL = 3;
54272
53886
  const TOC_INSTRUCTION = ' TOC \\o "1-3" \\h \\z \\u ';
54273
53887
  const twipsToPx = (twips) => Math.round(twips / TWIPS_PER_INCH * PX_PER_INCH);
54274
53888
  function collectTocHeadings(state, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
54275
- var _a2;
53889
+ var _a;
54276
53890
  const headings = [];
54277
53891
  for (const paragraph of getDocumentParagraphs(state.document)) {
54278
- const level = getHeadingLevel((_a2 = paragraph.style) == null ? void 0 : _a2.styleId);
53892
+ const level = getHeadingLevel((_a = paragraph.style) == null ? void 0 : _a.styleId);
54279
53893
  if (level === null || level > maxLevel) continue;
54280
53894
  const text = getParagraphText(paragraph).trim();
54281
53895
  if (!text) continue;
@@ -54635,19 +54249,24 @@ function insertShapeAtSelection(state, preset) {
54635
54249
  function buildEssentialsDocument(options) {
54636
54250
  return {
54637
54251
  documentStyles: () => {
54638
- var _a2, _b2;
54252
+ var _a, _b;
54639
54253
  const document2 = options.state().document;
54640
54254
  const styles = (document2 == null ? void 0 : document2.styles) ?? {};
54641
54255
  const usedStyleIds = /* @__PURE__ */ new Set();
54642
54256
  for (const paragraph of getDocumentParagraphs(document2)) {
54643
- if ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) usedStyleIds.add(paragraph.style.styleId);
54257
+ if ((_a = paragraph.style) == null ? void 0 : _a.styleId) usedStyleIds.add(paragraph.style.styleId);
54644
54258
  for (const run of paragraph.runs) {
54645
- if ((_b2 = run.styles) == null ? void 0 : _b2.styleId) usedStyleIds.add(run.styles.styleId);
54259
+ if ((_b = run.styles) == null ? void 0 : _b.styleId) usedStyleIds.add(run.styles.styleId);
54646
54260
  }
54647
54261
  }
54648
54262
  return Object.values(styles).map((style2) => {
54649
- var _a3;
54263
+ var _a2, _b2, _c, _d, _e, _f, _g;
54650
54264
  const preview = resolveNamedTextStyle(style2.id, styles);
54265
+ const tableStyle = style2.type === "table" ? resolveNamedTableStyle(style2.id, styles).tableStyle : void 0;
54266
+ const whole = (_a2 = tableStyle == null ? void 0 : tableStyle.conditionalFormats) == null ? void 0 : _a2.wholeTable;
54267
+ const header = (_b2 = tableStyle == null ? void 0 : tableStyle.conditionalFormats) == null ? void 0 : _b2.firstRow;
54268
+ const band = (_c = tableStyle == null ? void 0 : tableStyle.conditionalFormats) == null ? void 0 : _c.band1Horz;
54269
+ const border = ((_d = whole == null ? void 0 : whole.borders) == null ? void 0 : _d.borderBottom) ?? ((_e = tableStyle == null ? void 0 : tableStyle.borders) == null ? void 0 : _e.borderBottom);
54651
54270
  return {
54652
54271
  id: style2.id,
54653
54272
  name: style2.name,
@@ -54657,23 +54276,30 @@ function buildEssentialsDocument(options) {
54657
54276
  semiHidden: style2.semiHidden,
54658
54277
  unhideWhenUsed: style2.unhideWhenUsed,
54659
54278
  isUsed: usedStyleIds.has(style2.id),
54660
- fontFamily: ((_a3 = preview.fontFamily) == null ? void 0 : _a3.trim()) || void 0,
54279
+ fontFamily: ((_f = preview.fontFamily) == null ? void 0 : _f.trim()) || void 0,
54661
54280
  fontSize: typeof preview.fontSize === "number" ? preview.fontSize : void 0,
54662
54281
  color: preview.color ?? void 0,
54663
54282
  bold: preview.bold ?? void 0,
54664
- italic: preview.italic ?? void 0
54283
+ italic: preview.italic ?? void 0,
54284
+ tablePreview: tableStyle ? {
54285
+ wholeFill: whole == null ? void 0 : whole.shading,
54286
+ headerFill: header == null ? void 0 : header.shading,
54287
+ bandFill: band == null ? void 0 : band.shading,
54288
+ borderColor: border == null ? void 0 : border.color,
54289
+ headerColor: ((_g = header == null ? void 0 : header.textStyle) == null ? void 0 : _g.color) ?? void 0
54290
+ } : void 0
54665
54291
  };
54666
54292
  });
54667
54293
  },
54668
54294
  exportDocx: () => void options.docIO.handleExportDocx(),
54669
54295
  exportPdf: () => void options.docIO.handleExportPdf(),
54670
54296
  importDocument: () => {
54671
- var _a2;
54672
- return (_a2 = options.importInputRef()) == null ? void 0 : _a2.click();
54297
+ var _a;
54298
+ return (_a = options.importInputRef()) == null ? void 0 : _a.click();
54673
54299
  },
54674
54300
  insertImage: () => {
54675
- var _a2;
54676
- return (_a2 = options.imageInputRef()) == null ? void 0 : _a2.click();
54301
+ var _a;
54302
+ return (_a = options.imageInputRef()) == null ? void 0 : _a.click();
54677
54303
  },
54678
54304
  insertShape: (preset) => options.applyTransactionalState(
54679
54305
  (current) => insertShapeAtSelection(current, preset)
@@ -54789,15 +54415,15 @@ function buildEssentialsParagraph(options) {
54789
54415
  function buildEssentialsSection(options) {
54790
54416
  const section = {
54791
54417
  isLandscape: () => {
54792
- var _a2, _b2;
54418
+ var _a, _b;
54793
54419
  const idx = getActiveSectionIndex(options.state());
54794
- const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54795
- return ((_b2 = target == null ? void 0 : target.pageSettings) == null ? void 0 : _b2.orientation) === "landscape";
54420
+ const target = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
54421
+ return ((_b = target == null ? void 0 : target.pageSettings) == null ? void 0 : _b.orientation) === "landscape";
54796
54422
  },
54797
54423
  setOrientation: (orientation) => {
54798
- var _a2;
54424
+ var _a;
54799
54425
  const idx = getActiveSectionIndex(options.state());
54800
- const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54426
+ const target = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
54801
54427
  if (!target) return;
54802
54428
  options.commandsController.applyUpdateSectionSettingsCommand(idx, {
54803
54429
  pageSettings: {
@@ -54807,25 +54433,25 @@ function buildEssentialsSection(options) {
54807
54433
  });
54808
54434
  },
54809
54435
  toggleOrientation: () => {
54810
- var _a2, _b2;
54436
+ var _a, _b;
54811
54437
  const idx = getActiveSectionIndex(options.state());
54812
- const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54438
+ const target = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
54813
54439
  if (!target) return;
54814
- const current = ((_b2 = target.pageSettings) == null ? void 0 : _b2.orientation) ?? "portrait";
54440
+ const current = ((_b = target.pageSettings) == null ? void 0 : _b.orientation) ?? "portrait";
54815
54441
  section.setOrientation(current === "portrait" ? "landscape" : "portrait");
54816
54442
  },
54817
54443
  breakNextPage: () => options.commandsController.applyInsertSectionBreakCommand("nextPage"),
54818
54444
  breakContinuous: () => options.commandsController.applyInsertSectionBreakCommand("continuous"),
54819
54445
  getMargins: () => {
54820
- var _a2, _b2;
54446
+ var _a, _b;
54821
54447
  const idx = getActiveSectionIndex(options.state());
54822
- const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54823
- return (_b2 = target == null ? void 0 : target.pageSettings) == null ? void 0 : _b2.margins;
54448
+ const target = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
54449
+ return (_b = target == null ? void 0 : target.pageSettings) == null ? void 0 : _b.margins;
54824
54450
  },
54825
54451
  setPageMargins: (margins) => {
54826
- var _a2;
54452
+ var _a;
54827
54453
  const idx = getActiveSectionIndex(options.state());
54828
- const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
54454
+ const target = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
54829
54455
  if (!(target == null ? void 0 : target.pageSettings)) return;
54830
54456
  options.commandsController.applyUpdateSectionSettingsCommand(idx, {
54831
54457
  pageSettings: {
@@ -54841,6 +54467,8 @@ function buildEssentialsSection(options) {
54841
54467
  return section;
54842
54468
  }
54843
54469
  function buildEssentialsTable(options) {
54470
+ let drawingBorders = false;
54471
+ let showingGridlines = false;
54844
54472
  const insideTable = () => Boolean(
54845
54473
  findParagraphTableLocation(
54846
54474
  options.state().document,
@@ -54875,10 +54503,10 @@ function buildEssentialsTable(options) {
54875
54503
  return table && table.type === "table" ? table : null;
54876
54504
  };
54877
54505
  const rawTblLookIn = (state) => {
54878
- var _a2;
54506
+ var _a;
54879
54507
  const table = selectedTableIn(state);
54880
54508
  if (!table) return null;
54881
- return { ...RAW_TBL_LOOK_DEFAULTS, ...((_a2 = table.style) == null ? void 0 : _a2.tblLook) ?? {} };
54509
+ return { ...RAW_TBL_LOOK_DEFAULTS, ...((_a = table.style) == null ? void 0 : _a.tblLook) ?? {} };
54882
54510
  };
54883
54511
  const selectionLabel = () => {
54884
54512
  const normalized = normalizeSelection(options.state());
@@ -54944,21 +54572,21 @@ function buildEssentialsTable(options) {
54944
54572
  return setTableStyleValue(current, "tblLook", next);
54945
54573
  }, MERGE_KEYS.tableStyleOptions),
54946
54574
  getStyleId: () => {
54947
- var _a2, _b2;
54948
- return ((_b2 = (_a2 = selectedTableIn(options.state())) == null ? void 0 : _a2.style) == null ? void 0 : _b2.styleId) ?? null;
54575
+ var _a, _b;
54576
+ return ((_b = (_a = selectedTableIn(options.state())) == null ? void 0 : _a.style) == null ? void 0 : _b.styleId) ?? null;
54949
54577
  },
54950
54578
  setStyleId: (styleId) => apply(
54951
54579
  (current) => setTableStyleValue(current, "styleId", styleId || null),
54952
54580
  MERGE_KEYS.tableStyleGallery
54953
54581
  ),
54954
54582
  getLayout: () => {
54955
- var _a2, _b2;
54956
- return ((_b2 = (_a2 = selectedTableIn(options.state())) == null ? void 0 : _a2.style) == null ? void 0 : _b2.layout) ?? null;
54583
+ var _a, _b;
54584
+ return ((_b = (_a = selectedTableIn(options.state())) == null ? void 0 : _a.style) == null ? void 0 : _b.layout) ?? null;
54957
54585
  },
54958
54586
  toggleAutoFit: () => apply((current) => {
54959
- var _a2;
54587
+ var _a;
54960
54588
  const table = selectedTableIn(current);
54961
- const nextLayout = ((_a2 = table == null ? void 0 : table.style) == null ? void 0 : _a2.layout) === "autofit" ? "fixed" : "autofit";
54589
+ const nextLayout = ((_a = table == null ? void 0 : table.style) == null ? void 0 : _a.layout) === "autofit" ? "fixed" : "autofit";
54962
54590
  return setTableStyleValue(current, "layout", nextLayout);
54963
54591
  }, MERGE_KEYS.tableDistribute),
54964
54592
  distributeColumns: () => apply(
@@ -55025,6 +54653,20 @@ function buildEssentialsTable(options) {
55025
54653
  }),
55026
54654
  MERGE_KEYS.tableBorders
55027
54655
  ),
54656
+ applyBorderPreset: (preset) => apply(
54657
+ (current) => applyTableBorderPreset(current, preset),
54658
+ MERGE_KEYS.tableBorders
54659
+ ),
54660
+ isDrawingBorders: () => drawingBorders,
54661
+ toggleDrawingBorders: () => {
54662
+ drawingBorders = !drawingBorders;
54663
+ options.applyState({ ...options.state() });
54664
+ },
54665
+ isShowingGridlines: () => showingGridlines,
54666
+ toggleGridlines: () => {
54667
+ showingGridlines = !showingGridlines;
54668
+ options.applyState({ ...options.state() });
54669
+ },
55028
54670
  width100: () => apply(
55029
54671
  (current) => setTableStyleValue(current, "width", "100%"),
55030
54672
  MERGE_KEYS.tableWidth
@@ -55420,7 +55062,7 @@ const defaultMenuItems = [
55420
55062
  }
55421
55063
  ];
55422
55064
  function useEditorRuntimePlugins(options) {
55423
- var _a2, _b2;
55065
+ var _a, _b;
55424
55066
  const runtimePlugins = [
55425
55067
  options.essentialsPlugin,
55426
55068
  ...options.externalPlugins ?? []
@@ -55464,8 +55106,8 @@ function useEditorRuntimePlugins(options) {
55464
55106
  contributedMenuIds.push(item.id);
55465
55107
  }
55466
55108
  }
55467
- (_a2 = options.customizeToolbar) == null ? void 0 : _a2.call(options, toolbarRegistry);
55468
- (_b2 = options.customizeMenubar) == null ? void 0 : _b2.call(options, menuRegistry);
55109
+ (_a = options.customizeToolbar) == null ? void 0 : _a.call(options, toolbarRegistry);
55110
+ (_b = options.customizeMenubar) == null ? void 0 : _b.call(options, menuRegistry);
55469
55111
  return {
55470
55112
  runtimePlugins,
55471
55113
  toolbarRegistry,
@@ -55489,13 +55131,13 @@ function createRuntimeCommandHost(options) {
55489
55131
  );
55490
55132
  let disposed = false;
55491
55133
  const commandStateOf = (commandRef) => {
55492
- var _a2;
55134
+ var _a;
55493
55135
  const commandName = commandRefName(commandRef);
55494
55136
  const cmd = runtimeEditor().commands.get(commandName);
55495
55137
  if (!cmd) {
55496
55138
  return { isEnabled: false, isActive: false, value: void 0 };
55497
55139
  }
55498
- const refreshed = ((_a2 = cmd.refresh) == null ? void 0 : _a2.call(cmd)) ?? { isEnabled: true };
55140
+ const refreshed = ((_a = cmd.refresh) == null ? void 0 : _a.call(cmd)) ?? { isEnabled: true };
55499
55141
  return {
55500
55142
  isEnabled: refreshed.isEnabled !== false,
55501
55143
  isActive: Boolean(refreshed.isActive),
@@ -55523,7 +55165,7 @@ function createRuntimeCommandHost(options) {
55523
55165
  focusEditor: options.focusEditor
55524
55166
  });
55525
55167
  const initialize = async () => {
55526
- var _a2, _b2;
55168
+ var _a, _b;
55527
55169
  try {
55528
55170
  const initializedRuntimeEditor = await Editor.create({
55529
55171
  doc: options.initialDocument,
@@ -55538,14 +55180,14 @@ function createRuntimeCommandHost(options) {
55538
55180
  await previousRuntimeEditor.destroy();
55539
55181
  setRuntimeReady(true);
55540
55182
  requestAnimationFrame(() => {
55541
- var _a3, _b3;
55542
- (_a3 = options.onSettled) == null ? void 0 : _a3.call(options);
55543
- (_b3 = options.onReady) == null ? void 0 : _b3.call(options, initializedRuntimeEditor);
55183
+ var _a2, _b2;
55184
+ (_a2 = options.onSettled) == null ? void 0 : _a2.call(options);
55185
+ (_b2 = options.onReady) == null ? void 0 : _b2.call(options, initializedRuntimeEditor);
55544
55186
  });
55545
55187
  } catch (error) {
55546
55188
  options.logger.error("runtime:init failed", error);
55547
- (_a2 = options.onError) == null ? void 0 : _a2.call(options, error);
55548
- (_b2 = options.onSettled) == null ? void 0 : _b2.call(options);
55189
+ (_a = options.onError) == null ? void 0 : _a.call(options, error);
55190
+ (_b = options.onSettled) == null ? void 0 : _b.call(options);
55549
55191
  }
55550
55192
  };
55551
55193
  const dispose = async () => {
@@ -55668,9 +55310,9 @@ function createEditorCommandRuntimeImpl(deps) {
55668
55310
  focusEditor: deps.focusInput,
55669
55311
  logger: deps.logger,
55670
55312
  onReady: (editor) => {
55671
- var _a2, _b2;
55313
+ var _a, _b;
55672
55314
  runtimeClient.resolveReady(editor);
55673
- (_b2 = (_a2 = deps.runtimeOptions()).onReady) == null ? void 0 : _b2.call(_a2, runtimeClient);
55315
+ (_b = (_a = deps.runtimeOptions()).onReady) == null ? void 0 : _b.call(_a, runtimeClient);
55674
55316
  },
55675
55317
  onSettled: () => {
55676
55318
  deps.setInitialLoading(false);
@@ -55731,8 +55373,8 @@ function createEditorCommandRuntimeImpl(deps) {
55731
55373
  }
55732
55374
  var _tmpl$ = /* @__PURE__ */ template(`<div class="oasis-editor-shell oasis-editor-app">`);
55733
55375
  function OasisEditorApp(props = {}) {
55734
- var _a2;
55735
- const runtimeClient = ((_a2 = props.runtime) == null ? void 0 : _a2.client) ?? createOasisEditorClient();
55376
+ var _a;
55377
+ const runtimeClient = ((_a = props.runtime) == null ? void 0 : _a.client) ?? createOasisEditorClient();
55736
55378
  const ui = () => props.ui ?? {};
55737
55379
  const documentOptions = () => props.document ?? {};
55738
55380
  const runtimeOptions = () => props.runtime ?? {};
@@ -55959,6 +55601,7 @@ function OasisEditorApp(props = {}) {
55959
55601
  } = buildEditorViewProps({
55960
55602
  layout: {
55961
55603
  documentLayout,
55604
+ remoteWebFonts: documentOptions().remoteWebFonts,
55962
55605
  viewportHeight: ui().viewportHeight,
55963
55606
  className: ui().class,
55964
55607
  style: ui().style,
@@ -56153,12 +55796,12 @@ function OasisEditorApp(props = {}) {
56153
55796
  return loadingLabel();
56154
55797
  },
56155
55798
  get ["class"]() {
56156
- var _a3;
56157
- return (_a3 = loadingOptions()) == null ? void 0 : _a3.class;
55799
+ var _a2;
55800
+ return (_a2 = loadingOptions()) == null ? void 0 : _a2.class;
56158
55801
  },
56159
55802
  get style() {
56160
- var _a3;
56161
- return (_a3 = loadingOptions()) == null ? void 0 : _a3.style;
55803
+ var _a2;
55804
+ return (_a2 = loadingOptions()) == null ? void 0 : _a2.style;
56162
55805
  }
56163
55806
  });
56164
55807
  }
@@ -56170,13 +55813,15 @@ function OasisEditorApp(props = {}) {
56170
55813
  onClose: () => setWelcomeOpen(false)
56171
55814
  }), null);
56172
55815
  createRenderEffect((_p$) => {
56173
- var _v$ = !!useComposedShell(), _v$2 = !!isReadOnly();
56174
- _v$ !== _p$.e && _el$.classList.toggle("oasis-editor-docs", _p$.e = _v$);
56175
- _v$2 !== _p$.t && _el$.classList.toggle("oasis-editor-read-only", _p$.t = _v$2);
55816
+ var _v$ = ui().theme ?? "light", _v$2 = !!useComposedShell(), _v$3 = !!isReadOnly();
55817
+ _v$ !== _p$.e && setAttribute(_el$, "data-theme", _p$.e = _v$);
55818
+ _v$2 !== _p$.t && _el$.classList.toggle("oasis-editor-docs", _p$.t = _v$2);
55819
+ _v$3 !== _p$.a && _el$.classList.toggle("oasis-editor-read-only", _p$.a = _v$3);
56176
55820
  return _p$;
56177
55821
  }, {
56178
55822
  e: void 0,
56179
- t: void 0
55823
+ t: void 0,
55824
+ a: void 0
56180
55825
  });
56181
55826
  return _el$;
56182
55827
  }