@harbour-enterprises/superdoc 1.0.0-next.9 → 1.0.2

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/chunks/{PdfViewer-C7Wo4VVN.es.js → PdfViewer-C51KNTCu.es.js} +2 -2
  2. package/dist/chunks/{PdfViewer-QwjK1Tx6.cjs → PdfViewer-Dk7wI3bm.cjs} +2 -2
  3. package/dist/chunks/{eventemitter3-DQmQUge-.cjs → eventemitter3-DIclNhoR.cjs} +1 -1
  4. package/dist/chunks/{eventemitter3-44XulWQe.es.js → eventemitter3-D_2kqkfV.es.js} +1 -1
  5. package/dist/chunks/{index-DI2R4qz8.cjs → index-Cf7hdzkm.cjs} +20 -15
  6. package/dist/chunks/{index-DNIymDRK-CzsYNHvC.cjs → index-DDZ1ZT8N-DzepXBTN.cjs} +1 -1
  7. package/dist/chunks/{index-DNIymDRK-BMrUTNeb.es.js → index-DDZ1ZT8N-MJzqg0qg.es.js} +1 -1
  8. package/dist/chunks/{index-CfSkb15j.es.js → index-rtbawgUA.es.js} +20 -15
  9. package/dist/chunks/{jszip-VP334ufO.es.js → jszip-B690S4j-.es.js} +1 -1
  10. package/dist/chunks/{jszip-BdEez1WM.cjs → jszip-qHp7FC78.cjs} +1 -1
  11. package/dist/chunks/{super-editor.es-BI8ByUNm.cjs → super-editor.es-BijxiFs9.cjs} +1671 -353
  12. package/dist/chunks/{super-editor.es-B42HV1fg.es.js → super-editor.es-DFXddrgb.es.js} +1671 -353
  13. package/dist/chunks/{vue-BuPTonTJ.es.js → vue-CLFbn_1r.es.js} +209 -185
  14. package/dist/chunks/{vue-jWLMl8Ts.cjs → vue-gvuFr0vx.cjs} +209 -185
  15. package/dist/chunks/xml-js-BXUvL-Mz.es.js +2 -0
  16. package/dist/chunks/xml-js-CCH4ckfW.cjs +3 -0
  17. package/dist/super-editor/ai-writer.es.js +2 -2
  18. package/dist/super-editor/chunks/{converter-a3CAItrf.js → converter-VYPiNbpo.js} +1 -1
  19. package/dist/super-editor/chunks/{docx-zipper-BsmzO0LG.js → docx-zipper-D8Tzq3RX.js} +1 -1
  20. package/dist/super-editor/chunks/{editor-qn0f9LDg.js → editor-mgoEnsBi.js} +1635 -288
  21. package/dist/super-editor/chunks/{index-DNIymDRK.js → index-DDZ1ZT8N.js} +1 -1
  22. package/dist/super-editor/chunks/{toolbar-DW8hTxsF.js → toolbar-DULgxvjl.js} +2 -2
  23. package/dist/super-editor/converter.es.js +1 -1
  24. package/dist/super-editor/docx-zipper.es.js +2 -2
  25. package/dist/super-editor/editor.es.js +3 -3
  26. package/dist/super-editor/file-zipper.es.js +1 -1
  27. package/dist/super-editor/super-editor.es.js +6 -6
  28. package/dist/super-editor/toolbar.es.js +2 -2
  29. package/dist/super-editor.cjs +2 -2
  30. package/dist/super-editor.es.js +2 -2
  31. package/dist/superdoc.cjs +2 -2
  32. package/dist/superdoc.es.js +2 -2
  33. package/dist/superdoc.umd.js +1913 -572
  34. package/dist/superdoc.umd.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunks/xml-js-Dz51sEbr.cjs +0 -3
  37. package/dist/chunks/xml-js-LkEmUa9-.es.js +0 -2
@@ -9,11 +9,11 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _currentEpoch, _mapsByFromEpoch, _maxEpochsToKeep, _EpochPositionMapper_instances, pruneByCurrentEpoch_fn, _entries, _windowRoot, _getPainterHost, _onRebuild, _observer, _rebuildScheduled, _rebuildRafId, _docEpoch, _layoutEpoch, _layoutUpdating, _pending, _scheduled, _rafHandle, _scheduler, _SelectionSyncCoordinator_instances, isSafeToRender_fn, maybeSchedule_fn, cancelScheduledRender_fn, _windowRoot2, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _pageGeometryHelper, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionSync, _remoteCursorUpdateScheduled, _epochMapper, _layoutEpoch2, _domPositionIndex, _domIndexObserverManager, _debugLastPointer, _debugLastHit, _pendingMarginClick, _rafHandle2, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _a11ySelectionAnnounceTimeout, _a11yLastAnnouncedSelectionKey, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _dragAnchorPageIndex, _isDragging, _dragExtensionMode, _dragLastPointer, _dragLastRawHit, _dragUsedPageNotMountedFallback, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, updateSelectionDebugHud_fn, computePendingMarginClick_fn, aggregateLayoutBounds_fn, rebuildDomPositionIndex_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, _handlePointerMove, _handlePointerLeave, _handleVisibleHostFocusIn, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, syncHiddenEditorA11yAttributes_fn, scheduleA11ySelectionAnnouncement_fn, announceSelectionNow_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, isSelectionAwareVirtualizationEnabled_fn, updateSelectionVirtualizationPins_fn, finalizeDragSelectionWithDom_fn, scrollPageIntoView_fn, waitForPageMount_fn, getEffectivePageGap_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderCellSelectionOverlay_fn, renderHoverRegion_fn, clearHoverRegion_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, applyZoom_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeSelectionRectsFromDom_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
12
+ var _a, _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _currentEpoch, _mapsByFromEpoch, _maxEpochsToKeep, _EpochPositionMapper_instances, pruneByCurrentEpoch_fn, _entries, _windowRoot, _getPainterHost, _onRebuild, _observer, _rebuildScheduled, _rebuildRafId, _docEpoch, _layoutEpoch, _layoutUpdating, _pending, _scheduled, _rafHandle, _scheduler, _SelectionSyncCoordinator_instances, isSafeToRender_fn, maybeSchedule_fn, cancelScheduledRender_fn, _windowRoot2, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _pageGeometryHelper, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionSync, _remoteCursorUpdateScheduled, _epochMapper, _layoutEpoch2, _domPositionIndex, _domIndexObserverManager, _debugLastPointer, _debugLastHit, _pendingMarginClick, _rafHandle2, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _a11ySelectionAnnounceTimeout, _a11yLastAnnouncedSelectionKey, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _dragAnchorPageIndex, _isDragging, _dragExtensionMode, _dragLastPointer, _dragLastRawHit, _dragUsedPageNotMountedFallback, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, wrapHiddenEditorFocus_fn, collectCommentPositions_fn, updateSelectionDebugHud_fn, computePendingMarginClick_fn, aggregateLayoutBounds_fn, rebuildDomPositionIndex_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, _handlePointerMove, _handlePointerLeave, _handleVisibleHostFocusIn, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, syncHiddenEditorA11yAttributes_fn, scheduleA11ySelectionAnnouncement_fn, announceSelectionNow_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, isSelectionAwareVirtualizationEnabled_fn, updateSelectionVirtualizationPins_fn, finalizeDragSelectionWithDom_fn, scrollPageIntoView_fn, waitForPageMount_fn, getEffectivePageGap_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderCellSelectionOverlay_fn, renderHoverRegion_fn, clearHoverRegion_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, applyZoom_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeSelectionRectsFromDom_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-a3CAItrf.js";
16
- import { D as DocxZipper } from "./docx-zipper-BsmzO0LG.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$2, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-VYPiNbpo.js";
16
+ import { D as DocxZipper } from "./docx-zipper-D8Tzq3RX.js";
17
17
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
@@ -577,7 +577,7 @@ const isEquivalentPosition = function(node, off, targetNode, targetOff) {
577
577
  };
578
578
  const atomElements = /^(img|br|input|textarea|hr)$/i;
579
579
  function scanFor(node, off, targetNode, targetOff, dir) {
580
- var _a;
580
+ var _a2;
581
581
  for (; ; ) {
582
582
  if (node == targetNode && off == targetOff)
583
583
  return true;
@@ -590,7 +590,7 @@ function scanFor(node, off, targetNode, targetOff, dir) {
590
590
  } else if (node.nodeType == 1) {
591
591
  let child = node.childNodes[off + (dir < 0 ? -1 : 0)];
592
592
  if (child.nodeType == 1 && child.contentEditable == "false") {
593
- if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection)
593
+ if ((_a2 = child.pmViewDesc) === null || _a2 === void 0 ? void 0 : _a2.ignoreForSelection)
594
594
  off += dir;
595
595
  else
596
596
  return false;
@@ -1217,10 +1217,10 @@ class ViewDesc {
1217
1217
  }
1218
1218
  // The size of the content represented by this desc.
1219
1219
  get size() {
1220
- let size = 0;
1220
+ let size2 = 0;
1221
1221
  for (let i = 0; i < this.children.length; i++)
1222
- size += this.children[i].size;
1223
- return size;
1222
+ size2 += this.children[i].size;
1223
+ return size2;
1224
1224
  }
1225
1225
  // For block nodes, this represents the space taken up by their
1226
1226
  // start/end tokens.
@@ -1672,9 +1672,9 @@ class MarkViewDesc extends ViewDesc {
1672
1672
  }
1673
1673
  slice(from2, to, view) {
1674
1674
  let copy = MarkViewDesc.create(this.parent, this.mark, true, view);
1675
- let nodes = this.children, size = this.size;
1676
- if (to < size)
1677
- nodes = replaceNodes(nodes, to, size, view);
1675
+ let nodes = this.children, size2 = this.size;
1676
+ if (to < size2)
1677
+ nodes = replaceNodes(nodes, to, size2, view);
1678
1678
  if (from2 > 0)
1679
1679
  nodes = replaceNodes(nodes, 0, from2, view);
1680
1680
  for (let i = 0; i < nodes.length; i++)
@@ -3147,12 +3147,12 @@ function normalizeSiblings(fragment, $context) {
3147
3147
  return fragment;
3148
3148
  for (let d2 = $context.depth; d2 >= 0; d2--) {
3149
3149
  let parent = $context.node(d2);
3150
- let match = parent.contentMatchAt($context.index(d2));
3150
+ let match2 = parent.contentMatchAt($context.index(d2));
3151
3151
  let lastWrap, result = [];
3152
3152
  fragment.forEach((node) => {
3153
3153
  if (!result)
3154
3154
  return;
3155
- let wrap = match.findWrapping(node.type), inLast;
3155
+ let wrap = match2.findWrapping(node.type), inLast;
3156
3156
  if (!wrap)
3157
3157
  return result = null;
3158
3158
  if (inLast = result.length && lastWrap.length && addToSibling(wrap, lastWrap, node, result[result.length - 1], 0)) {
@@ -3162,7 +3162,7 @@ function normalizeSiblings(fragment, $context) {
3162
3162
  result[result.length - 1] = closeRight(result[result.length - 1], lastWrap.length);
3163
3163
  let wrapped = withWrappers(node, wrap);
3164
3164
  result.push(wrapped);
3165
- match = match.matchType(wrapped.type);
3165
+ match2 = match2.matchType(wrapped.type);
3166
3166
  lastWrap = wrap;
3167
3167
  }
3168
3168
  });
@@ -3181,8 +3181,8 @@ function addToSibling(wrap, lastWrap, node, sibling, depth) {
3181
3181
  let inner = addToSibling(wrap, lastWrap, node, sibling.lastChild, depth + 1);
3182
3182
  if (inner)
3183
3183
  return sibling.copy(sibling.content.replaceChild(sibling.childCount - 1, inner));
3184
- let match = sibling.contentMatchAt(sibling.childCount);
3185
- if (match.matchType(depth == wrap.length - 1 ? node.type : wrap[depth + 1]))
3184
+ let match2 = sibling.contentMatchAt(sibling.childCount);
3185
+ if (match2.matchType(depth == wrap.length - 1 ? node.type : wrap[depth + 1]))
3186
3186
  return sibling.copy(sibling.content.append(Fragment.from(withWrappers(node, wrap, depth + 1))));
3187
3187
  }
3188
3188
  }
@@ -5319,7 +5319,7 @@ class EditorView {
5319
5319
  this.updateStateInner(state, this._props);
5320
5320
  }
5321
5321
  updateStateInner(state, prevProps) {
5322
- var _a;
5322
+ var _a2;
5323
5323
  let prev = this.state, redraw = false, updateSel = false;
5324
5324
  if (state.storedMarks && this.composing) {
5325
5325
  clearComposition(this);
@@ -5369,7 +5369,7 @@ class EditorView {
5369
5369
  this.domObserver.start();
5370
5370
  }
5371
5371
  this.updatePluginViews(prev);
5372
- if (((_a = this.dragging) === null || _a === void 0 ? void 0 : _a.node) && !prev.doc.eq(state.doc))
5372
+ if (((_a2 = this.dragging) === null || _a2 === void 0 ? void 0 : _a2.node) && !prev.doc.eq(state.doc))
5373
5373
  this.updateDraggedNode(this.dragging, prev);
5374
5374
  if (scroll == "reset") {
5375
5375
  this.dom.scrollTop = 0;
@@ -5739,15 +5739,40 @@ const BIT30 = 1 << 29;
5739
5739
  const BITS6 = 63;
5740
5740
  const BITS7 = 127;
5741
5741
  const BITS31 = 2147483647;
5742
+ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
5743
+ const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER;
5742
5744
  const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
5743
5745
  const create$2 = () => /* @__PURE__ */ new Set();
5746
+ const every$1 = (arr, f2) => {
5747
+ for (let i = 0; i < arr.length; i++) {
5748
+ if (!f2(arr[i], i, arr)) {
5749
+ return false;
5750
+ }
5751
+ }
5752
+ return true;
5753
+ };
5754
+ const some = (arr, f2) => {
5755
+ for (let i = 0; i < arr.length; i++) {
5756
+ if (f2(arr[i], i, arr)) {
5757
+ return true;
5758
+ }
5759
+ }
5760
+ return false;
5761
+ };
5762
+ const unfold = (len, f2) => {
5763
+ const array = new Array(len);
5764
+ for (let i = 0; i < len; i++) {
5765
+ array[i] = f2(i, array);
5766
+ }
5767
+ return array;
5768
+ };
5744
5769
  const isArray = Array.isArray;
5745
5770
  const fromCharCode = String.fromCharCode;
5746
5771
  const toLowerCase = (s2) => s2.toLowerCase();
5747
5772
  const trimLeftRegex = /^\s*/g;
5748
5773
  const trimLeft = (s2) => s2.replace(trimLeftRegex, "");
5749
5774
  const fromCamelCaseRegex = /([A-Z])/g;
5750
- const fromCamelCase = (s2, separator) => trimLeft(s2.replace(fromCamelCaseRegex, (match) => `${separator}${toLowerCase(match)}`));
5775
+ const fromCamelCase = (s2, separator) => trimLeft(s2.replace(fromCamelCaseRegex, (match2) => `${separator}${toLowerCase(match2)}`));
5751
5776
  const _encodeUtf8Polyfill = (str) => {
5752
5777
  const encodedString = unescape(encodeURIComponent(str));
5753
5778
  const len = encodedString.length;
@@ -5768,6 +5793,7 @@ let utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecode
5768
5793
  if (utf8TextDecoder && utf8TextDecoder.decode(new Uint8Array()).length === 1) {
5769
5794
  utf8TextDecoder = null;
5770
5795
  }
5796
+ const repeat = (source, n) => unfold(n, () => source).join("");
5771
5797
  class Encoder {
5772
5798
  constructor() {
5773
5799
  this.cpos = 0;
@@ -5964,7 +5990,11 @@ const setIfUndefined = (map2, key2, createT) => {
5964
5990
  }
5965
5991
  return set;
5966
5992
  };
5993
+ const EqualityTraitSymbol = Symbol("Equality");
5994
+ const equals = (a, b) => a === b || a[EqualityTraitSymbol]?.(b) || false;
5995
+ const isObject$2 = (o) => typeof o === "object";
5967
5996
  const keys = Object.keys;
5997
+ const size = (obj) => keys(obj).length;
5968
5998
  const every = (obj, f2) => {
5969
5999
  for (const key2 in obj) {
5970
6000
  if (!f2(obj[key2], key2)) {
@@ -5973,6 +6003,81 @@ const every = (obj, f2) => {
5973
6003
  }
5974
6004
  return true;
5975
6005
  };
6006
+ const hasProperty = (obj, key2) => Object.prototype.hasOwnProperty.call(obj, key2);
6007
+ const equalityDeep = (a, b) => {
6008
+ if (a === b) {
6009
+ return true;
6010
+ }
6011
+ if (a == null || b == null || a.constructor !== b.constructor && (a.constructor || Object) !== (b.constructor || Object)) {
6012
+ return false;
6013
+ }
6014
+ if (a[EqualityTraitSymbol] != null) {
6015
+ return a[EqualityTraitSymbol](b);
6016
+ }
6017
+ switch (a.constructor) {
6018
+ case ArrayBuffer:
6019
+ a = new Uint8Array(a);
6020
+ b = new Uint8Array(b);
6021
+ // eslint-disable-next-line no-fallthrough
6022
+ case Uint8Array: {
6023
+ if (a.byteLength !== b.byteLength) {
6024
+ return false;
6025
+ }
6026
+ for (let i = 0; i < a.length; i++) {
6027
+ if (a[i] !== b[i]) {
6028
+ return false;
6029
+ }
6030
+ }
6031
+ break;
6032
+ }
6033
+ case Set: {
6034
+ if (a.size !== b.size) {
6035
+ return false;
6036
+ }
6037
+ for (const value of a) {
6038
+ if (!b.has(value)) {
6039
+ return false;
6040
+ }
6041
+ }
6042
+ break;
6043
+ }
6044
+ case Map: {
6045
+ if (a.size !== b.size) {
6046
+ return false;
6047
+ }
6048
+ for (const key2 of a.keys()) {
6049
+ if (!b.has(key2) || !equalityDeep(a.get(key2), b.get(key2))) {
6050
+ return false;
6051
+ }
6052
+ }
6053
+ break;
6054
+ }
6055
+ case void 0:
6056
+ case Object:
6057
+ if (size(a) !== size(b)) {
6058
+ return false;
6059
+ }
6060
+ for (const key2 in a) {
6061
+ if (!hasProperty(a, key2) || !equalityDeep(a[key2], b[key2])) {
6062
+ return false;
6063
+ }
6064
+ }
6065
+ break;
6066
+ case Array:
6067
+ if (a.length !== b.length) {
6068
+ return false;
6069
+ }
6070
+ for (let i = 0; i < a.length; i++) {
6071
+ if (!equalityDeep(a[i], b[i])) {
6072
+ return false;
6073
+ }
6074
+ }
6075
+ break;
6076
+ default:
6077
+ return false;
6078
+ }
6079
+ return true;
6080
+ };
5976
6081
  const isOneOf = (value, options) => options.includes(value);
5977
6082
  const createMutex = () => {
5978
6083
  let token = true;
@@ -6013,7 +6118,7 @@ const ySyncPluginKey = new PluginKey("y-sync");
6013
6118
  const yUndoPluginKey = new PluginKey("y-undo");
6014
6119
  const yCursorPluginKey = new PluginKey("yjs-cursor");
6015
6120
  const rand = Math.random;
6016
- const oneOf = (arr) => arr[floor(rand() * arr.length)];
6121
+ const oneOf$1 = (arr) => arr[floor(rand() * arr.length)];
6017
6122
  const undefinedToNull = (v) => v === void 0 ? null : v;
6018
6123
  class VarStoragePolyfill {
6019
6124
  constructor() {
@@ -6087,15 +6192,771 @@ const computeParams = () => {
6087
6192
  const hasParam = (name) => computeParams().has(name);
6088
6193
  const getVariable = (name) => isNode ? undefinedToNull(process$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
6089
6194
  const hasConf = (name) => hasParam("--" + name) || getVariable(name) !== null;
6090
- hasConf("production");
6195
+ const production = hasConf("production");
6091
6196
  const forceColor = isNode && isOneOf(process$1.env.FORCE_COLOR, ["true", "1", "2"]);
6092
6197
  forceColor || !hasParam("--no-colors") && // @todo deprecate --no-colors
6093
6198
  !hasConf("no-color") && (!isNode || process$1.stdout.isTTY) && (!isNode || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
6199
+ const toBase64Browser = (bytes) => {
6200
+ let s2 = "";
6201
+ for (let i = 0; i < bytes.byteLength; i++) {
6202
+ s2 += fromCharCode(bytes[i]);
6203
+ }
6204
+ return btoa(s2);
6205
+ };
6206
+ const toBase64Node = (bytes) => Buffer2.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
6207
+ const toBase64 = isBrowser$1 ? toBase64Browser : toBase64Node;
6208
+ const encodeAny = (data) => encode((encoder) => writeAny(encoder, data));
6209
+ const bool = (gen) => gen.next() >= 0.5;
6210
+ const int53 = (gen, min2, max2) => floor(gen.next() * (max2 + 1 - min2) + min2);
6211
+ const int32 = (gen, min2, max2) => floor(gen.next() * (max2 + 1 - min2) + min2);
6212
+ const int31 = (gen, min2, max2) => int32(gen, min2, max2);
6213
+ const letter = (gen) => fromCharCode(int31(gen, 97, 122));
6214
+ const word = (gen, minLen = 0, maxLen = 20) => {
6215
+ const len = int31(gen, minLen, maxLen);
6216
+ let str = "";
6217
+ for (let i = 0; i < len; i++) {
6218
+ str += letter(gen);
6219
+ }
6220
+ return str;
6221
+ };
6222
+ const oneOf = (gen, array) => array[int31(gen, 0, array.length - 1)];
6223
+ const schemaSymbol = Symbol("0schema");
6224
+ class ValidationError {
6225
+ constructor() {
6226
+ this._rerrs = [];
6227
+ }
6228
+ /**
6229
+ * @param {string?} path
6230
+ * @param {string} expected
6231
+ * @param {string} has
6232
+ * @param {string?} message
6233
+ */
6234
+ extend(path, expected, has, message = null) {
6235
+ this._rerrs.push({ path, expected, has, message });
6236
+ }
6237
+ toString() {
6238
+ const s2 = [];
6239
+ for (let i = this._rerrs.length - 1; i > 0; i--) {
6240
+ const r2 = this._rerrs[i];
6241
+ s2.push(repeat(" ", (this._rerrs.length - i) * 2) + `${r2.path != null ? `[${r2.path}] ` : ""}${r2.has} doesn't match ${r2.expected}. ${r2.message}`);
6242
+ }
6243
+ return s2.join("\n");
6244
+ }
6245
+ }
6246
+ const shapeExtends = (a, b) => {
6247
+ if (a === b) return true;
6248
+ if (a == null || b == null || a.constructor !== b.constructor) return false;
6249
+ if (a[EqualityTraitSymbol]) return equals(a, b);
6250
+ if (isArray(a)) {
6251
+ return every$1(
6252
+ a,
6253
+ (aitem) => some(b, (bitem) => shapeExtends(aitem, bitem))
6254
+ );
6255
+ } else if (isObject$2(a)) {
6256
+ return every(
6257
+ a,
6258
+ (aitem, akey) => shapeExtends(aitem, b[akey])
6259
+ );
6260
+ }
6261
+ return false;
6262
+ };
6263
+ let Schema$1 = (_a = class {
6264
+ /**
6265
+ * @param {Schema<any>} other
6266
+ */
6267
+ extends(other) {
6268
+ let [a, b] = [
6269
+ /** @type {any} */
6270
+ this.shape,
6271
+ /** @type {any} */
6272
+ other.shape
6273
+ ];
6274
+ if (
6275
+ /** @type {typeof Schema<any>} */
6276
+ this.constructor._dilutes
6277
+ ) [b, a] = [a, b];
6278
+ return shapeExtends(a, b);
6279
+ }
6280
+ /**
6281
+ * Overwrite this when necessary. By default, we only check the `shape` property which every shape
6282
+ * should have.
6283
+ * @param {Schema<any>} other
6284
+ */
6285
+ equals(other) {
6286
+ return this.constructor === other.constructor && equalityDeep(this.shape, other.shape);
6287
+ }
6288
+ [schemaSymbol]() {
6289
+ return true;
6290
+ }
6291
+ /**
6292
+ * @param {object} other
6293
+ */
6294
+ [EqualityTraitSymbol](other) {
6295
+ return this.equals(
6296
+ /** @type {any} */
6297
+ other
6298
+ );
6299
+ }
6300
+ /**
6301
+ * Use `schema.validate(obj)` with a typed parameter that is already of typed to be an instance of
6302
+ * Schema. Validate will check the structure of the parameter and return true iff the instance
6303
+ * really is an instance of Schema.
6304
+ *
6305
+ * @param {T} o
6306
+ * @return {boolean}
6307
+ */
6308
+ validate(o) {
6309
+ return this.check(o);
6310
+ }
6311
+ /* c8 ignore start */
6312
+ /**
6313
+ * Similar to validate, but this method accepts untyped parameters.
6314
+ *
6315
+ * @param {any} _o
6316
+ * @param {ValidationError} [_err]
6317
+ * @return {_o is T}
6318
+ */
6319
+ check(_o, _err) {
6320
+ methodUnimplemented();
6321
+ }
6322
+ /* c8 ignore stop */
6323
+ /**
6324
+ * @type {Schema<T?>}
6325
+ */
6326
+ get nullable() {
6327
+ return $union(this, $null);
6328
+ }
6329
+ /**
6330
+ * @type {$Optional<Schema<T>>}
6331
+ */
6332
+ get optional() {
6333
+ return new $Optional(
6334
+ /** @type {Schema<T>} */
6335
+ this
6336
+ );
6337
+ }
6338
+ /**
6339
+ * Cast a variable to a specific type. Returns the casted value, or throws an exception otherwise.
6340
+ * Use this if you know that the type is of a specific type and you just want to convince the type
6341
+ * system.
6342
+ *
6343
+ * **Do not rely on these error messages!**
6344
+ * Performs an assertion check only if not in a production environment.
6345
+ *
6346
+ * @template OO
6347
+ * @param {OO} o
6348
+ * @return {Extract<OO, T> extends never ? T : (OO extends Array<never> ? T : Extract<OO,T>)}
6349
+ */
6350
+ cast(o) {
6351
+ assert(o, this);
6352
+ return (
6353
+ /** @type {any} */
6354
+ o
6355
+ );
6356
+ }
6357
+ /**
6358
+ * EXPECTO PATRONUM!! 🪄
6359
+ * This function protects against type errors. Though it may not work in the real world.
6360
+ *
6361
+ * "After all this time?"
6362
+ * "Always." - Snape, talking about type safety
6363
+ *
6364
+ * Ensures that a variable is a a specific type. Returns the value, or throws an exception if the assertion check failed.
6365
+ * Use this if you know that the type is of a specific type and you just want to convince the type
6366
+ * system.
6367
+ *
6368
+ * Can be useful when defining lambdas: `s.lambda(s.$number, s.$void).expect((n) => n + 1)`
6369
+ *
6370
+ * **Do not rely on these error messages!**
6371
+ * Performs an assertion check if not in a production environment.
6372
+ *
6373
+ * @param {T} o
6374
+ * @return {o extends T ? T : never}
6375
+ */
6376
+ expect(o) {
6377
+ assert(o, this);
6378
+ return o;
6379
+ }
6380
+ }, // this.shape must not be defined on Schema. Otherwise typecheck on metatypes (e.g. $$object) won't work as expected anymore
6381
+ /**
6382
+ * If true, the more things are added to the shape the more objects this schema will accept (e.g.
6383
+ * union). By default, the more objects are added, the the fewer objects this schema will accept.
6384
+ * @protected
6385
+ */
6386
+ __publicField(_a, "_dilutes", false), _a);
6387
+ class $ConstructedBy extends Schema$1 {
6388
+ /**
6389
+ * @param {C} c
6390
+ * @param {((o:Instance<C>)=>boolean)|null} check
6391
+ */
6392
+ constructor(c, check) {
6393
+ super();
6394
+ this.shape = c;
6395
+ this._c = check;
6396
+ }
6397
+ /**
6398
+ * @param {any} o
6399
+ * @param {ValidationError} [err]
6400
+ * @return {o is C extends ((...args:any[]) => infer T) ? T : (C extends (new (...args:any[]) => any) ? InstanceType<C> : never)} o
6401
+ */
6402
+ check(o, err = void 0) {
6403
+ const c = o?.constructor === this.shape && (this._c == null || this._c(o));
6404
+ !c && err?.extend(null, this.shape.name, o?.constructor.name, o?.constructor !== this.shape ? "Constructor match failed" : "Check failed");
6405
+ return c;
6406
+ }
6407
+ }
6408
+ const $constructedBy = (c, check = null) => new $ConstructedBy(c, check);
6409
+ $constructedBy($ConstructedBy);
6410
+ class $Custom extends Schema$1 {
6411
+ /**
6412
+ * @param {(o:any) => boolean} check
6413
+ */
6414
+ constructor(check) {
6415
+ super();
6416
+ this.shape = check;
6417
+ }
6418
+ /**
6419
+ * @param {any} o
6420
+ * @param {ValidationError} err
6421
+ * @return {o is any}
6422
+ */
6423
+ check(o, err) {
6424
+ const c = this.shape(o);
6425
+ !c && err?.extend(null, "custom prop", o?.constructor.name, "failed to check custom prop");
6426
+ return c;
6427
+ }
6428
+ }
6429
+ const $custom = (check) => new $Custom(check);
6430
+ $constructedBy($Custom);
6431
+ class $Literal extends Schema$1 {
6432
+ /**
6433
+ * @param {Array<T>} literals
6434
+ */
6435
+ constructor(literals) {
6436
+ super();
6437
+ this.shape = literals;
6438
+ }
6439
+ /**
6440
+ *
6441
+ * @param {any} o
6442
+ * @param {ValidationError} [err]
6443
+ * @return {o is T}
6444
+ */
6445
+ check(o, err) {
6446
+ const c = this.shape.some((a) => a === o);
6447
+ !c && err?.extend(null, this.shape.join(" | "), o.toString());
6448
+ return c;
6449
+ }
6450
+ }
6451
+ const $literal = (...literals) => new $Literal(literals);
6452
+ const $$literal = $constructedBy($Literal);
6453
+ const _regexEscape = (
6454
+ /** @type {any} */
6455
+ RegExp.escape || /** @type {(str:string) => string} */
6456
+ ((str) => str.replace(/[().|&,$^[\]]/g, (s2) => "\\" + s2))
6457
+ );
6458
+ const _schemaStringTemplateToRegex = (s2) => {
6459
+ if ($string.check(s2)) {
6460
+ return [_regexEscape(s2)];
6461
+ }
6462
+ if ($$literal.check(s2)) {
6463
+ return (
6464
+ /** @type {Array<string|number>} */
6465
+ s2.shape.map((v) => v + "")
6466
+ );
6467
+ }
6468
+ if ($$number.check(s2)) {
6469
+ return ["[+-]?\\d+.?\\d*"];
6470
+ }
6471
+ if ($$string.check(s2)) {
6472
+ return [".*"];
6473
+ }
6474
+ if ($$union.check(s2)) {
6475
+ return s2.shape.map(_schemaStringTemplateToRegex).flat(1);
6476
+ }
6477
+ unexpectedCase();
6478
+ };
6479
+ class $StringTemplate extends Schema$1 {
6480
+ /**
6481
+ * @param {T} shape
6482
+ */
6483
+ constructor(shape) {
6484
+ super();
6485
+ this.shape = shape;
6486
+ this._r = new RegExp("^" + shape.map(_schemaStringTemplateToRegex).map((opts) => `(${opts.join("|")})`).join("") + "$");
6487
+ }
6488
+ /**
6489
+ * @param {any} o
6490
+ * @param {ValidationError} [err]
6491
+ * @return {o is CastStringTemplateArgsToTemplate<T>}
6492
+ */
6493
+ check(o, err) {
6494
+ const c = this._r.exec(o) != null;
6495
+ !c && err?.extend(null, this._r.toString(), o.toString(), "String doesn't match string template.");
6496
+ return c;
6497
+ }
6498
+ }
6499
+ $constructedBy($StringTemplate);
6500
+ const isOptionalSymbol = Symbol("optional");
6501
+ class $Optional extends Schema$1 {
6502
+ /**
6503
+ * @param {S} shape
6504
+ */
6505
+ constructor(shape) {
6506
+ super();
6507
+ this.shape = shape;
6508
+ }
6509
+ /**
6510
+ * @param {any} o
6511
+ * @param {ValidationError} [err]
6512
+ * @return {o is (Unwrap<S>|undefined)}
6513
+ */
6514
+ check(o, err) {
6515
+ const c = o === void 0 || this.shape.check(o);
6516
+ !c && err?.extend(null, "undefined (optional)", "()");
6517
+ return c;
6518
+ }
6519
+ get [isOptionalSymbol]() {
6520
+ return true;
6521
+ }
6522
+ }
6523
+ const $$optional = $constructedBy($Optional);
6524
+ class $Never extends Schema$1 {
6525
+ /**
6526
+ * @param {any} _o
6527
+ * @param {ValidationError} [err]
6528
+ * @return {_o is never}
6529
+ */
6530
+ check(_o, err) {
6531
+ err?.extend(null, "never", typeof _o);
6532
+ return false;
6533
+ }
6534
+ }
6535
+ $constructedBy($Never);
6536
+ const _$Object = class _$Object extends Schema$1 {
6537
+ /**
6538
+ * @param {S} shape
6539
+ * @param {boolean} partial
6540
+ */
6541
+ constructor(shape, partial = false) {
6542
+ super();
6543
+ this.shape = shape;
6544
+ this._isPartial = partial;
6545
+ }
6546
+ /**
6547
+ * @type {Schema<Partial<$ObjectToType<S>>>}
6548
+ */
6549
+ get partial() {
6550
+ return new _$Object(this.shape, true);
6551
+ }
6552
+ /**
6553
+ * @param {any} o
6554
+ * @param {ValidationError} err
6555
+ * @return {o is $ObjectToType<S>}
6556
+ */
6557
+ check(o, err) {
6558
+ if (o == null) {
6559
+ err?.extend(null, "object", "null");
6560
+ return false;
6561
+ }
6562
+ return every(this.shape, (vv, vk) => {
6563
+ const c = this._isPartial && !hasProperty(o, vk) || vv.check(o[vk], err);
6564
+ !c && err?.extend(vk.toString(), vv.toString(), typeof o[vk], "Object property does not match");
6565
+ return c;
6566
+ });
6567
+ }
6568
+ };
6569
+ __publicField(_$Object, "_dilutes", true);
6570
+ let $Object = _$Object;
6571
+ const $object = (def) => (
6572
+ /** @type {any} */
6573
+ new $Object(def)
6574
+ );
6575
+ const $$object = $constructedBy($Object);
6576
+ const $objectAny = $custom((o) => o != null && (o.constructor === Object || o.constructor == null));
6577
+ class $Record extends Schema$1 {
6578
+ /**
6579
+ * @param {Keys} keys
6580
+ * @param {Values} values
6581
+ */
6582
+ constructor(keys2, values) {
6583
+ super();
6584
+ this.shape = {
6585
+ keys: keys2,
6586
+ values
6587
+ };
6588
+ }
6589
+ /**
6590
+ * @param {any} o
6591
+ * @param {ValidationError} err
6592
+ * @return {o is { [key in Unwrap<Keys>]: Unwrap<Values> }}
6593
+ */
6594
+ check(o, err) {
6595
+ return o != null && every(o, (vv, vk) => {
6596
+ const ck = this.shape.keys.check(vk, err);
6597
+ !ck && err?.extend(vk + "", "Record", typeof o, ck ? "Key doesn't match schema" : "Value doesn't match value");
6598
+ return ck && this.shape.values.check(vv, err);
6599
+ });
6600
+ }
6601
+ }
6602
+ const $record = (keys2, values) => new $Record(keys2, values);
6603
+ const $$record = $constructedBy($Record);
6604
+ class $Tuple extends Schema$1 {
6605
+ /**
6606
+ * @param {S} shape
6607
+ */
6608
+ constructor(shape) {
6609
+ super();
6610
+ this.shape = shape;
6611
+ }
6612
+ /**
6613
+ * @param {any} o
6614
+ * @param {ValidationError} err
6615
+ * @return {o is { [K in keyof S]: S[K] extends Schema<infer Type> ? Type : never }}
6616
+ */
6617
+ check(o, err) {
6618
+ return o != null && every(this.shape, (vv, vk) => {
6619
+ const c = (
6620
+ /** @type {Schema<any>} */
6621
+ vv.check(o[vk], err)
6622
+ );
6623
+ !c && err?.extend(vk.toString(), "Tuple", typeof vv);
6624
+ return c;
6625
+ });
6626
+ }
6627
+ }
6628
+ const $tuple = (...def) => new $Tuple(def);
6629
+ $constructedBy($Tuple);
6630
+ class $Array extends Schema$1 {
6631
+ /**
6632
+ * @param {Array<S>} v
6633
+ */
6634
+ constructor(v) {
6635
+ super();
6636
+ this.shape = v.length === 1 ? v[0] : new $Union(v);
6637
+ }
6638
+ /**
6639
+ * @param {any} o
6640
+ * @param {ValidationError} [err]
6641
+ * @return {o is Array<S extends Schema<infer T> ? T : never>} o
6642
+ */
6643
+ check(o, err) {
6644
+ const c = isArray(o) && every$1(o, (oi) => this.shape.check(oi));
6645
+ !c && err?.extend(null, "Array", "");
6646
+ return c;
6647
+ }
6648
+ }
6649
+ const $array = (...def) => new $Array(def);
6650
+ const $$array = $constructedBy($Array);
6651
+ const $arrayAny = $custom((o) => isArray(o));
6652
+ class $InstanceOf extends Schema$1 {
6653
+ /**
6654
+ * @param {new (...args:any) => T} constructor
6655
+ * @param {((o:T) => boolean)|null} check
6656
+ */
6657
+ constructor(constructor, check) {
6658
+ super();
6659
+ this.shape = constructor;
6660
+ this._c = check;
6661
+ }
6662
+ /**
6663
+ * @param {any} o
6664
+ * @param {ValidationError} err
6665
+ * @return {o is T}
6666
+ */
6667
+ check(o, err) {
6668
+ const c = o instanceof this.shape && (this._c == null || this._c(o));
6669
+ !c && err?.extend(null, this.shape.name, o?.constructor.name);
6670
+ return c;
6671
+ }
6672
+ }
6673
+ const $instanceOf = (c, check = null) => new $InstanceOf(c, check);
6674
+ $constructedBy($InstanceOf);
6675
+ const $$schema = $instanceOf(Schema$1);
6676
+ class $Lambda extends Schema$1 {
6677
+ /**
6678
+ * @param {Args} args
6679
+ */
6680
+ constructor(args) {
6681
+ super();
6682
+ this.len = args.length - 1;
6683
+ this.args = $tuple(...args.slice(-1));
6684
+ this.res = args[this.len];
6685
+ }
6686
+ /**
6687
+ * @param {any} f
6688
+ * @param {ValidationError} err
6689
+ * @return {f is _LArgsToLambdaDef<Args>}
6690
+ */
6691
+ check(f2, err) {
6692
+ const c = f2.constructor === Function && f2.length <= this.len;
6693
+ !c && err?.extend(null, "function", typeof f2);
6694
+ return c;
6695
+ }
6696
+ }
6697
+ const $$lambda = $constructedBy($Lambda);
6698
+ const $function = $custom((o) => typeof o === "function");
6699
+ class $Intersection extends Schema$1 {
6700
+ /**
6701
+ * @param {T} v
6702
+ */
6703
+ constructor(v) {
6704
+ super();
6705
+ this.shape = v;
6706
+ }
6707
+ /**
6708
+ * @param {any} o
6709
+ * @param {ValidationError} [err]
6710
+ * @return {o is Intersect<UnwrapArray<T>>}
6711
+ */
6712
+ check(o, err) {
6713
+ const c = every$1(this.shape, (check) => check.check(o, err));
6714
+ !c && err?.extend(null, "Intersectinon", typeof o);
6715
+ return c;
6716
+ }
6717
+ }
6718
+ $constructedBy($Intersection, (o) => o.shape.length > 0);
6719
+ class $Union extends Schema$1 {
6720
+ /**
6721
+ * @param {Array<Schema<S>>} v
6722
+ */
6723
+ constructor(v) {
6724
+ super();
6725
+ this.shape = v;
6726
+ }
6727
+ /**
6728
+ * @param {any} o
6729
+ * @param {ValidationError} [err]
6730
+ * @return {o is S}
6731
+ */
6732
+ check(o, err) {
6733
+ const c = some(this.shape, (vv) => vv.check(o, err));
6734
+ err?.extend(null, "Union", typeof o);
6735
+ return c;
6736
+ }
6737
+ }
6738
+ __publicField($Union, "_dilutes", true);
6739
+ const $union = (...schemas) => schemas.findIndex(($s) => $$union.check($s)) >= 0 ? $union(...schemas.map(($s) => $($s)).map(($s) => $$union.check($s) ? $s.shape : [$s]).flat(1)) : schemas.length === 1 ? schemas[0] : new $Union(schemas);
6740
+ const $$union = (
6741
+ /** @type {Schema<$Union<any>>} */
6742
+ $constructedBy($Union)
6743
+ );
6744
+ const _t = () => true;
6745
+ const $any = $custom(_t);
6746
+ const $$any = (
6747
+ /** @type {Schema<Schema<any>>} */
6748
+ $constructedBy($Custom, (o) => o.shape === _t)
6749
+ );
6750
+ const $bigint = $custom((o) => typeof o === "bigint");
6751
+ const $$bigint = (
6752
+ /** @type {Schema<Schema<BigInt>>} */
6753
+ $custom((o) => o === $bigint)
6754
+ );
6755
+ const $symbol = $custom((o) => typeof o === "symbol");
6756
+ $custom((o) => o === $symbol);
6757
+ const $number = $custom((o) => typeof o === "number");
6758
+ const $$number = (
6759
+ /** @type {Schema<Schema<number>>} */
6760
+ $custom((o) => o === $number)
6761
+ );
6762
+ const $string = $custom((o) => typeof o === "string");
6763
+ const $$string = (
6764
+ /** @type {Schema<Schema<string>>} */
6765
+ $custom((o) => o === $string)
6766
+ );
6767
+ const $boolean = $custom((o) => typeof o === "boolean");
6768
+ const $$boolean = (
6769
+ /** @type {Schema<Schema<Boolean>>} */
6770
+ $custom((o) => o === $boolean)
6771
+ );
6772
+ const $undefined = $literal(void 0);
6773
+ $constructedBy($Literal, (o) => o.shape.length === 1 && o.shape[0] === void 0);
6774
+ $literal(void 0);
6775
+ const $null = $literal(null);
6776
+ const $$null = (
6777
+ /** @type {Schema<Schema<null>>} */
6778
+ $constructedBy($Literal, (o) => o.shape.length === 1 && o.shape[0] === null)
6779
+ );
6780
+ $constructedBy(Uint8Array);
6781
+ $constructedBy($ConstructedBy, (o) => o.shape === Uint8Array);
6782
+ const $primitive = $union($number, $string, $null, $undefined, $bigint, $boolean, $symbol);
6783
+ (() => {
6784
+ const $jsonArr = (
6785
+ /** @type {$Array<$any>} */
6786
+ $array($any)
6787
+ );
6788
+ const $jsonRecord = (
6789
+ /** @type {$Record<$string,$any>} */
6790
+ $record($string, $any)
6791
+ );
6792
+ const $json = $union($number, $string, $null, $boolean, $jsonArr, $jsonRecord);
6793
+ $jsonArr.shape = $json;
6794
+ $jsonRecord.shape.values = $json;
6795
+ return $json;
6796
+ })();
6797
+ const $ = (o) => {
6798
+ if ($$schema.check(o)) {
6799
+ return (
6800
+ /** @type {any} */
6801
+ o
6802
+ );
6803
+ } else if ($objectAny.check(o)) {
6804
+ const o2 = {};
6805
+ for (const k2 in o) {
6806
+ o2[k2] = $(o[k2]);
6807
+ }
6808
+ return (
6809
+ /** @type {any} */
6810
+ $object(o2)
6811
+ );
6812
+ } else if ($arrayAny.check(o)) {
6813
+ return (
6814
+ /** @type {any} */
6815
+ $union(...o.map($))
6816
+ );
6817
+ } else if ($primitive.check(o)) {
6818
+ return (
6819
+ /** @type {any} */
6820
+ $literal(o)
6821
+ );
6822
+ } else if ($function.check(o)) {
6823
+ return (
6824
+ /** @type {any} */
6825
+ $constructedBy(
6826
+ /** @type {any} */
6827
+ o
6828
+ )
6829
+ );
6830
+ }
6831
+ unexpectedCase();
6832
+ };
6833
+ const assert = production ? () => {
6834
+ } : (o, schema) => {
6835
+ const err = new ValidationError();
6836
+ if (!schema.check(o, err)) {
6837
+ throw create$1(`Expected value to be of type ${schema.constructor.name}.
6838
+ ${err.toString()}`);
6839
+ }
6840
+ };
6841
+ class PatternMatcher {
6842
+ /**
6843
+ * @param {Schema<State>} [$state]
6844
+ */
6845
+ constructor($state) {
6846
+ this.patterns = [];
6847
+ this.$state = $state;
6848
+ }
6849
+ /**
6850
+ * @template P
6851
+ * @template R
6852
+ * @param {P} pattern
6853
+ * @param {(o:NoInfer<Unwrap<ReadSchema<P>>>,s:State)=>R} handler
6854
+ * @return {PatternMatcher<State,Patterns|Pattern<Unwrap<ReadSchema<P>>,R>>}
6855
+ */
6856
+ if(pattern, handler) {
6857
+ this.patterns.push({ if: $(pattern), h: handler });
6858
+ return this;
6859
+ }
6860
+ /**
6861
+ * @template R
6862
+ * @param {(o:any,s:State)=>R} h
6863
+ */
6864
+ else(h) {
6865
+ return this.if($any, h);
6866
+ }
6867
+ /**
6868
+ * @return {State extends undefined
6869
+ * ? <In extends Unwrap<Patterns['if']>>(o:In,state?:undefined)=>PatternMatchResult<Patterns,In>
6870
+ * : <In extends Unwrap<Patterns['if']>>(o:In,state:State)=>PatternMatchResult<Patterns,In>}
6871
+ */
6872
+ done() {
6873
+ return (
6874
+ /** @type {any} */
6875
+ (o, s2) => {
6876
+ for (let i = 0; i < this.patterns.length; i++) {
6877
+ const p = this.patterns[i];
6878
+ if (p.if.check(o)) {
6879
+ return p.h(o, s2);
6880
+ }
6881
+ }
6882
+ throw create$1("Unhandled pattern");
6883
+ }
6884
+ );
6885
+ }
6886
+ }
6887
+ const match = (state) => new PatternMatcher(
6888
+ /** @type {any} */
6889
+ state
6890
+ );
6891
+ const _random = (
6892
+ /** @type {any} */
6893
+ match(
6894
+ /** @type {Schema<prng.PRNG>} */
6895
+ $any
6896
+ ).if($$number, (_o, gen) => int53(gen, MIN_SAFE_INTEGER, MAX_SAFE_INTEGER)).if($$string, (_o, gen) => word(gen)).if($$boolean, (_o, gen) => bool(gen)).if($$bigint, (_o, gen) => BigInt(int53(gen, MIN_SAFE_INTEGER, MAX_SAFE_INTEGER))).if($$union, (o, gen) => random(gen, oneOf(gen, o.shape))).if($$object, (o, gen) => {
6897
+ const res = {};
6898
+ for (const k2 in o.shape) {
6899
+ let prop = o.shape[k2];
6900
+ if ($$optional.check(prop)) {
6901
+ if (bool(gen)) {
6902
+ continue;
6903
+ }
6904
+ prop = prop.shape;
6905
+ }
6906
+ res[k2] = _random(prop, gen);
6907
+ }
6908
+ return res;
6909
+ }).if($$array, (o, gen) => {
6910
+ const arr = [];
6911
+ const n = int32(gen, 0, 42);
6912
+ for (let i = 0; i < n; i++) {
6913
+ arr.push(random(gen, o.shape));
6914
+ }
6915
+ return arr;
6916
+ }).if($$literal, (o, gen) => {
6917
+ return oneOf(gen, o.shape);
6918
+ }).if($$null, (o, gen) => {
6919
+ return null;
6920
+ }).if($$lambda, (o, gen) => {
6921
+ const res = random(gen, o.res);
6922
+ return () => res;
6923
+ }).if($$any, (o, gen) => random(gen, oneOf(gen, [
6924
+ $number,
6925
+ $string,
6926
+ $null,
6927
+ $undefined,
6928
+ $bigint,
6929
+ $boolean,
6930
+ $array($number),
6931
+ $record($union("a", "b", "c"), $number)
6932
+ ]))).if($$record, (o, gen) => {
6933
+ const res = {};
6934
+ const keysN = int53(gen, 0, 3);
6935
+ for (let i = 0; i < keysN; i++) {
6936
+ const key2 = random(gen, o.shape.keys);
6937
+ const val = random(gen, o.shape.values);
6938
+ res[key2] = val;
6939
+ }
6940
+ return res;
6941
+ }).done()
6942
+ );
6943
+ const random = (gen, schema) => (
6944
+ /** @type {any} */
6945
+ _random($(schema), gen)
6946
+ );
6094
6947
  const doc = (
6095
6948
  /** @type {Document} */
6096
6949
  typeof document !== "undefined" ? document : {}
6097
6950
  );
6951
+ $custom((el) => el.nodeType === DOCUMENT_FRAGMENT_NODE);
6098
6952
  typeof DOMParser !== "undefined" ? new DOMParser() : null;
6953
+ $custom((el) => el.nodeType === ELEMENT_NODE);
6954
+ $custom((el) => el.nodeType === TEXT_NODE);
6955
+ const ELEMENT_NODE = doc.ELEMENT_NODE;
6956
+ const TEXT_NODE = doc.TEXT_NODE;
6957
+ const DOCUMENT_NODE = doc.DOCUMENT_NODE;
6958
+ const DOCUMENT_FRAGMENT_NODE = doc.DOCUMENT_FRAGMENT_NODE;
6959
+ $custom((el) => el.nodeType === DOCUMENT_NODE);
6099
6960
  const createTimeoutClass = (clearFunction) => class TT {
6100
6961
  /**
6101
6962
  * @param {number} timeoutId
@@ -6278,16 +7139,6 @@ class Hasher {
6278
7139
  }
6279
7140
  }
6280
7141
  const digest = (data) => new Hasher().digest(data);
6281
- const toBase64Browser = (bytes) => {
6282
- let s2 = "";
6283
- for (let i = 0; i < bytes.byteLength; i++) {
6284
- s2 += fromCharCode(bytes[i]);
6285
- }
6286
- return btoa(s2);
6287
- };
6288
- const toBase64Node = (bytes) => Buffer2.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
6289
- const toBase64 = isBrowser$1 ? toBase64Browser : toBase64Node;
6290
- const encodeAny = (data) => encode((encoder) => writeAny(encoder, data));
6291
7142
  const _convolute = (digest2) => {
6292
7143
  const N = 6;
6293
7144
  for (let i = N; i < digest2.length; i++) {
@@ -6310,7 +7161,7 @@ const getUserColor = (colorMapping, colors, user) => {
6310
7161
  colorMapping.forEach((color) => usedColors.add(color));
6311
7162
  colors = colors.filter((color) => !usedColors.has(color));
6312
7163
  }
6313
- colorMapping.set(user, oneOf(colors));
7164
+ colorMapping.set(user, oneOf$1(colors));
6314
7165
  }
6315
7166
  return (
6316
7167
  /** @type {ColorDef} */
@@ -8083,14 +8934,14 @@ const _Schema = class _Schema {
8083
8934
  * @returns PM schema
8084
8935
  */
8085
8936
  static createSchemaByExtensions(extensions, editor) {
8086
- var _a, _b;
8937
+ var _a2, _b;
8087
8938
  const nodeExtensions = extensions.filter((e) => e.type === "node");
8088
8939
  const markExtensions = extensions.filter((e) => e.type === "mark");
8089
8940
  const topNode = nodeExtensions.find((e) => getExtensionConfigField(e, "topNode"))?.name;
8090
8941
  const attributes = Attribute.getAttributesFromExtensions(extensions);
8091
- const nodes = __privateMethod(_a = _Schema, _Schema_static, createNodesSchema_fn).call(_a, nodeExtensions, attributes, editor);
8942
+ const nodes = __privateMethod(_a2 = _Schema, _Schema_static, createNodesSchema_fn).call(_a2, nodeExtensions, attributes, editor);
8092
8943
  const marks = __privateMethod(_b = _Schema, _Schema_static, createMarksSchema_fn).call(_b, markExtensions, attributes, editor);
8093
- return new Schema$1({ topNode, nodes, marks });
8944
+ return new Schema$2({ topNode, nodes, marks });
8094
8945
  }
8095
8946
  };
8096
8947
  _Schema_static = new WeakSet();
@@ -8591,9 +9442,9 @@ const newlineInCode$1 = (state, dispatch) => {
8591
9442
  dispatch(state.tr.insertText("\n").scrollIntoView());
8592
9443
  return true;
8593
9444
  };
8594
- function defaultBlockAt(match) {
8595
- for (let i = 0; i < match.edgeCount; i++) {
8596
- let { type } = match.edge(i);
9445
+ function defaultBlockAt(match2) {
9446
+ for (let i = 0; i < match2.edgeCount; i++) {
9447
+ let { type } = match2.edge(i);
8597
9448
  if (type.isTextblock && !type.hasRequiredAttrs())
8598
9449
  return type;
8599
9450
  }
@@ -8720,12 +9571,12 @@ function joinMaybeClear(state, $pos, dispatch) {
8720
9571
  return true;
8721
9572
  }
8722
9573
  function deleteBarrier(state, $cut, dispatch, dir) {
8723
- let before = $cut.nodeBefore, after = $cut.nodeAfter, conn, match;
9574
+ let before = $cut.nodeBefore, after = $cut.nodeAfter, conn, match2;
8724
9575
  let isolated = before.type.spec.isolating || after.type.spec.isolating;
8725
9576
  if (!isolated && joinMaybeClear(state, $cut, dispatch))
8726
9577
  return true;
8727
9578
  let canDelAfter = !isolated && $cut.parent.canReplace($cut.index(), $cut.index() + 1);
8728
- if (canDelAfter && (conn = (match = before.contentMatchAt(before.childCount)).findWrapping(after.type)) && match.matchType(conn[0] || after.type).validEnd) {
9579
+ if (canDelAfter && (conn = (match2 = before.contentMatchAt(before.childCount)).findWrapping(after.type)) && match2.matchType(conn[0] || after.type).validEnd) {
8729
9580
  if (dispatch) {
8730
9581
  let end2 = $cut.pos + after.nodeSize, wrap = Fragment.empty;
8731
9582
  for (let i = conn.length - 1; i >= 0; i--)
@@ -9337,7 +10188,7 @@ function createNodeFromContent(content, editor, options) {
9337
10188
  if (options.errorOnInvalidContent) {
9338
10189
  let hasInvalidContent = false;
9339
10190
  let invalidContent = "";
9340
- const contentCheckSchema = new Schema$1({
10191
+ const contentCheckSchema = new Schema$2({
9341
10192
  topNode: schema.spec.topNode,
9342
10193
  marks: schema.spec.marks,
9343
10194
  // Prosemirror's schemas are executed such that: the last to execute, matches last
@@ -12268,7 +13119,11 @@ const trackedTransaction = ({ tr, state, user }) => {
12268
13119
  const onlyInputTypeMeta = ["inputType", "uiEvent", "paste", "pointer"];
12269
13120
  const notAllowedMeta = ["historyUndo", "historyRedo", "acceptReject"];
12270
13121
  const isProgrammaticInput = tr.getMeta("inputType") === "programmatic";
12271
- if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => onlyInputTypeMeta.includes(meta)) && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
13122
+ const ySyncMeta = tr.getMeta(ySyncPluginKey);
13123
+ const allowedMeta = /* @__PURE__ */ new Set([...onlyInputTypeMeta, ySyncPluginKey.key]);
13124
+ const hasDisallowedMeta = tr.meta && Object.keys(tr.meta).some((meta) => !allowedMeta.has(meta));
13125
+ if (ySyncMeta?.isChangeOrigin || // Skip Yjs-origin transactions (remote/rehydration).
13126
+ !tr.steps.length || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
12272
13127
  return tr;
12273
13128
  }
12274
13129
  const newTr = state.tr;
@@ -13960,7 +14815,7 @@ const isHeadless = (editor) => {
13960
14815
  const shouldSkipNodeView = (editor) => {
13961
14816
  return isHeadless(editor);
13962
14817
  };
13963
- const summaryVersion = "1.0.0-next.9";
14818
+ const summaryVersion = "1.0.2";
13964
14819
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
13965
14820
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
13966
14821
  function mapAttributes(attrs) {
@@ -14752,7 +15607,7 @@ const _Editor = class _Editor extends EventEmitter {
14752
15607
  { default: remarkStringify },
14753
15608
  { default: remarkGfm }
14754
15609
  ] = await Promise.all([
14755
- import("./index-DNIymDRK.js"),
15610
+ import("./index-DDZ1ZT8N.js"),
14756
15611
  import("./index-DRCvimau.js"),
14757
15612
  import("./index-C_x_N6Uh.js"),
14758
15613
  import("./index-D_sWOSiG.js"),
@@ -14957,7 +15812,7 @@ const _Editor = class _Editor extends EventEmitter {
14957
15812
  * Process collaboration migrations
14958
15813
  */
14959
15814
  processCollaborationMigrations() {
14960
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-next.9");
15815
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.2");
14961
15816
  if (!this.options.ydoc) return;
14962
15817
  const metaMap = this.options.ydoc.getMap("meta");
14963
15818
  let docVersion = metaMap.get("version");
@@ -26044,6 +26899,86 @@ const createDomPainter = (options) => {
26044
26899
  }
26045
26900
  };
26046
26901
  };
26902
+ const DEFAULT_CONFIG = {
26903
+ logLevel: "off",
26904
+ hud: false,
26905
+ dumpRects: false,
26906
+ disableRectDedupe: false
26907
+ };
26908
+ const levelOrder = {
26909
+ error: 0,
26910
+ warn: 1,
26911
+ info: 2,
26912
+ verbose: 3
26913
+ };
26914
+ function getSelectionDebugConfig() {
26915
+ var _a2;
26916
+ if (typeof window === "undefined") {
26917
+ return DEFAULT_CONFIG;
26918
+ }
26919
+ window.superdocDebug ?? (window.superdocDebug = {});
26920
+ (_a2 = window.superdocDebug).selection ?? (_a2.selection = {});
26921
+ const cfg = window.superdocDebug.selection;
26922
+ return {
26923
+ logLevel: cfg.logLevel ?? DEFAULT_CONFIG.logLevel,
26924
+ hud: cfg.hud ?? DEFAULT_CONFIG.hud,
26925
+ dumpRects: cfg.dumpRects ?? DEFAULT_CONFIG.dumpRects,
26926
+ disableRectDedupe: cfg.disableRectDedupe ?? DEFAULT_CONFIG.disableRectDedupe
26927
+ };
26928
+ }
26929
+ function debugLog(level, message, data) {
26930
+ const cfg = getSelectionDebugConfig();
26931
+ if (cfg.logLevel === "off") return;
26932
+ if (levelOrder[level] > levelOrder[cfg.logLevel]) return;
26933
+ const prefix = "[Selection]";
26934
+ if (data) {
26935
+ console.log(prefix, message, data);
26936
+ } else {
26937
+ console.log(prefix, message);
26938
+ }
26939
+ }
26940
+ const HUD_DATA_ATTR = "data-superdoc-selection-debug-hud";
26941
+ function updateSelectionDebugHud(host, state) {
26942
+ const cfg = getSelectionDebugConfig();
26943
+ const doc2 = host.ownerDocument ?? (typeof document !== "undefined" ? document : null);
26944
+ if (!doc2) return;
26945
+ const existing = host.querySelector(`[${HUD_DATA_ATTR}="true"]`);
26946
+ if (!cfg.hud) {
26947
+ existing?.remove();
26948
+ return;
26949
+ }
26950
+ const hud = existing ?? doc2.createElement("div");
26951
+ hud.setAttribute(HUD_DATA_ATTR, "true");
26952
+ hud.style.position = "absolute";
26953
+ hud.style.top = "8px";
26954
+ hud.style.left = "8px";
26955
+ hud.style.zIndex = "9999";
26956
+ hud.style.maxWidth = "420px";
26957
+ hud.style.padding = "6px 8px";
26958
+ hud.style.borderRadius = "6px";
26959
+ hud.style.background = "rgba(0, 0, 0, 0.72)";
26960
+ hud.style.color = "white";
26961
+ hud.style.fontFamily = 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
26962
+ hud.style.fontSize = "12px";
26963
+ hud.style.lineHeight = "1.3";
26964
+ hud.style.pointerEvents = "none";
26965
+ hud.style.whiteSpace = "pre";
26966
+ const behind = Math.max(0, state.docEpoch - state.layoutEpoch);
26967
+ const selectionText = state.selection ? `${state.selection.from}..${state.selection.to}` : "null";
26968
+ const pointerText = state.lastPointer ? `${state.lastPointer.clientX},${state.lastPointer.clientY} -> ${Math.round(state.lastPointer.x)},${Math.round(
26969
+ state.lastPointer.y
26970
+ )}` : "null";
26971
+ const hitText = state.lastHit ? `${state.lastHit.source} pos=${state.lastHit.pos ?? "null"} epoch=${state.lastHit.layoutEpoch ?? "null"} mapped=${state.lastHit.mappedPos ?? "null"}` : "null";
26972
+ hud.textContent = [
26973
+ `docEpoch=${state.docEpoch} layoutEpoch=${state.layoutEpoch} behind=${behind}`,
26974
+ `selection=${selectionText}`,
26975
+ `pointer=${pointerText}`,
26976
+ `hit=${hitText}`
26977
+ ].join("\n");
26978
+ if (!existing) {
26979
+ host.appendChild(hud);
26980
+ }
26981
+ }
26047
26982
  class DomPositionIndex {
26048
26983
  constructor() {
26049
26984
  __privateAdd(this, _entries, []);
@@ -26100,6 +27035,7 @@ class DomPositionIndex {
26100
27035
  }
26101
27036
  for (const node of pmNodes) {
26102
27037
  if (node.classList.contains(DOM_CLASS_NAMES.INLINE_SDT_WRAPPER)) continue;
27038
+ if (node.closest(".superdoc-page-header, .superdoc-page-footer")) continue;
26103
27039
  if (leafOnly && nonLeaf.has(node)) continue;
26104
27040
  const pmStart = Number(node.dataset.pmStart ?? "NaN");
26105
27041
  const pmEnd = Number(node.dataset.pmEnd ?? "NaN");
@@ -26109,6 +27045,60 @@ class DomPositionIndex {
26109
27045
  }
26110
27046
  entries.sort((a, b) => a.pmStart - b.pmStart !== 0 ? a.pmStart - b.pmStart : a.pmEnd - b.pmEnd);
26111
27047
  __privateSet(this, _entries, entries);
27048
+ const isVerbose = getSelectionDebugConfig().logLevel === "verbose";
27049
+ if (isVerbose) {
27050
+ const counts = { total: entries.length, body: 0, header: 0, footer: 0 };
27051
+ const bodySamples = [];
27052
+ const headerSamples = [];
27053
+ const footerSamples = [];
27054
+ for (const entry of entries) {
27055
+ const pageEl = entry.el.closest(`.${DOM_CLASS_NAMES.PAGE}`);
27056
+ const pageIndex = pageEl?.dataset.pageIndex ?? null;
27057
+ const section = entry.el.closest(".superdoc-page-header") ? "header" : entry.el.closest(".superdoc-page-footer") ? "footer" : "body";
27058
+ if (section === "header") {
27059
+ counts.header += 1;
27060
+ if (headerSamples.length < 10) {
27061
+ headerSamples.push({
27062
+ pmStart: entry.pmStart,
27063
+ pmEnd: entry.pmEnd,
27064
+ pageIndex,
27065
+ text: (entry.el.textContent ?? "").slice(0, 40)
27066
+ });
27067
+ }
27068
+ continue;
27069
+ }
27070
+ if (section === "footer") {
27071
+ counts.footer += 1;
27072
+ if (footerSamples.length < 10) {
27073
+ footerSamples.push({
27074
+ pmStart: entry.pmStart,
27075
+ pmEnd: entry.pmEnd,
27076
+ pageIndex,
27077
+ text: (entry.el.textContent ?? "").slice(0, 40)
27078
+ });
27079
+ }
27080
+ continue;
27081
+ }
27082
+ counts.body += 1;
27083
+ if (bodySamples.length < 10) {
27084
+ bodySamples.push({
27085
+ pmStart: entry.pmStart,
27086
+ pmEnd: entry.pmEnd,
27087
+ pageIndex,
27088
+ text: (entry.el.textContent ?? "").slice(0, 40)
27089
+ });
27090
+ }
27091
+ }
27092
+ debugLog(
27093
+ "verbose",
27094
+ `DomPositionIndex: rebuild summary ${JSON.stringify({
27095
+ counts,
27096
+ bodySamples,
27097
+ headerSamples,
27098
+ footerSamples
27099
+ })}`
27100
+ );
27101
+ }
26112
27102
  }
26113
27103
  /**
26114
27104
  * Finds the index entry whose position range contains the given position.
@@ -26358,82 +27348,6 @@ _onRebuild = new WeakMap();
26358
27348
  _observer = new WeakMap();
26359
27349
  _rebuildScheduled = new WeakMap();
26360
27350
  _rebuildRafId = new WeakMap();
26361
- const DEFAULT_CONFIG = {
26362
- logLevel: "off",
26363
- hud: false
26364
- };
26365
- const levelOrder = {
26366
- error: 0,
26367
- warn: 1,
26368
- info: 2,
26369
- verbose: 3
26370
- };
26371
- function getSelectionDebugConfig() {
26372
- var _a;
26373
- if (typeof window === "undefined") {
26374
- return DEFAULT_CONFIG;
26375
- }
26376
- window.superdocDebug ?? (window.superdocDebug = {});
26377
- (_a = window.superdocDebug).selection ?? (_a.selection = {});
26378
- const cfg = window.superdocDebug.selection;
26379
- return {
26380
- logLevel: cfg.logLevel ?? DEFAULT_CONFIG.logLevel,
26381
- hud: cfg.hud ?? DEFAULT_CONFIG.hud
26382
- };
26383
- }
26384
- function debugLog(level, message, data) {
26385
- const cfg = getSelectionDebugConfig();
26386
- if (cfg.logLevel === "off") return;
26387
- if (levelOrder[level] > levelOrder[cfg.logLevel]) return;
26388
- const prefix = "[Selection]";
26389
- if (data) {
26390
- console.log(prefix, message, data);
26391
- } else {
26392
- console.log(prefix, message);
26393
- }
26394
- }
26395
- const HUD_DATA_ATTR = "data-superdoc-selection-debug-hud";
26396
- function updateSelectionDebugHud(host, state) {
26397
- const cfg = getSelectionDebugConfig();
26398
- const doc2 = host.ownerDocument ?? (typeof document !== "undefined" ? document : null);
26399
- if (!doc2) return;
26400
- const existing = host.querySelector(`[${HUD_DATA_ATTR}="true"]`);
26401
- if (!cfg.hud) {
26402
- existing?.remove();
26403
- return;
26404
- }
26405
- const hud = existing ?? doc2.createElement("div");
26406
- hud.setAttribute(HUD_DATA_ATTR, "true");
26407
- hud.style.position = "absolute";
26408
- hud.style.top = "8px";
26409
- hud.style.left = "8px";
26410
- hud.style.zIndex = "9999";
26411
- hud.style.maxWidth = "420px";
26412
- hud.style.padding = "6px 8px";
26413
- hud.style.borderRadius = "6px";
26414
- hud.style.background = "rgba(0, 0, 0, 0.72)";
26415
- hud.style.color = "white";
26416
- hud.style.fontFamily = 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
26417
- hud.style.fontSize = "12px";
26418
- hud.style.lineHeight = "1.3";
26419
- hud.style.pointerEvents = "none";
26420
- hud.style.whiteSpace = "pre";
26421
- const behind = Math.max(0, state.docEpoch - state.layoutEpoch);
26422
- const selectionText = state.selection ? `${state.selection.from}..${state.selection.to}` : "null";
26423
- const pointerText = state.lastPointer ? `${state.lastPointer.clientX},${state.lastPointer.clientY} -> ${Math.round(state.lastPointer.x)},${Math.round(
26424
- state.lastPointer.y
26425
- )}` : "null";
26426
- const hitText = state.lastHit ? `${state.lastHit.source} pos=${state.lastHit.pos ?? "null"} epoch=${state.lastHit.layoutEpoch ?? "null"} mapped=${state.lastHit.mappedPos ?? "null"}` : "null";
26427
- hud.textContent = [
26428
- `docEpoch=${state.docEpoch} layoutEpoch=${state.layoutEpoch} behind=${behind}`,
26429
- `selection=${selectionText}`,
26430
- `pointer=${pointerText}`,
26431
- `hit=${hitText}`
26432
- ].join("\n");
26433
- if (!existing) {
26434
- host.appendChild(hud);
26435
- }
26436
- }
26437
27351
  function computeSelectionRectsFromDom(options, from2, to) {
26438
27352
  const painterHost = options.painterHost;
26439
27353
  if (!painterHost) return null;
@@ -26454,6 +27368,34 @@ function computeSelectionRectsFromDom(options, from2, to) {
26454
27368
  );
26455
27369
  const out = [];
26456
27370
  let rebuiltOnce = false;
27371
+ const debugConfig = getSelectionDebugConfig();
27372
+ const isVerbose = debugConfig.logLevel === "verbose";
27373
+ const dumpRects = isVerbose && debugConfig.dumpRects;
27374
+ const disableRectDedupe = debugConfig.disableRectDedupe;
27375
+ const entryDebugInfo = (entry) => {
27376
+ const pageEl = entry.el.closest(`.${DOM_CLASS_NAMES.PAGE}`);
27377
+ const section = entry.el.closest(".superdoc-page-header") ? "header" : entry.el.closest(".superdoc-page-footer") ? "footer" : "body";
27378
+ return {
27379
+ pmStart: entry.pmStart,
27380
+ pmEnd: entry.pmEnd,
27381
+ pageIndex: pageEl?.dataset.pageIndex ?? null,
27382
+ section,
27383
+ connected: entry.el.isConnected,
27384
+ layoutEpoch: entry.el.dataset.layoutEpoch ?? null,
27385
+ pageEpoch: pageEl?.dataset.layoutEpoch ?? null,
27386
+ text: (entry.el.textContent ?? "").slice(0, 80)
27387
+ };
27388
+ };
27389
+ const rectDebugInfo = (rect) => ({
27390
+ x: rect.x,
27391
+ y: rect.y,
27392
+ width: rect.width,
27393
+ height: rect.height,
27394
+ top: rect.top,
27395
+ left: rect.left,
27396
+ right: rect.right,
27397
+ bottom: rect.bottom
27398
+ });
26457
27399
  for (const pageEl of pageEls) {
26458
27400
  const pageIndex = Number(pageEl.dataset.pageIndex ?? "NaN");
26459
27401
  if (!Number.isFinite(pageIndex)) continue;
@@ -26477,9 +27419,47 @@ function computeSelectionRectsFromDom(options, from2, to) {
26477
27419
  if (sliceEntries.length === 0) {
26478
27420
  continue;
26479
27421
  }
27422
+ if (isVerbose) {
27423
+ debugLog(
27424
+ "verbose",
27425
+ `DOM selection rects: slice entries ${JSON.stringify({
27426
+ pageIndex,
27427
+ sliceFrom,
27428
+ sliceTo,
27429
+ entriesCount: sliceEntries.length,
27430
+ entriesPreview: sliceEntries.slice(0, 20).map(entryDebugInfo)
27431
+ })}`
27432
+ );
27433
+ }
26480
27434
  let startEntry = options.domPositionIndex.findEntryAtPosition(sliceFrom) ?? sliceEntries[0];
26481
27435
  let endEntry = options.domPositionIndex.findEntryAtPosition(sliceTo) ?? sliceEntries[sliceEntries.length - 1];
26482
- if (!pageEl.contains(startEntry.el) || !pageEl.contains(endEntry.el)) {
27436
+ if (isVerbose) {
27437
+ debugLog(
27438
+ "verbose",
27439
+ `DOM selection rects: boundaries ${JSON.stringify({
27440
+ pageIndex,
27441
+ sliceFrom,
27442
+ sliceTo,
27443
+ start: entryDebugInfo(startEntry),
27444
+ end: entryDebugInfo(endEntry)
27445
+ })}`
27446
+ );
27447
+ }
27448
+ let startContained = pageEl.contains(startEntry.el);
27449
+ let endContained = pageEl.contains(endEntry.el);
27450
+ if (!startContained || !endContained) {
27451
+ if (isVerbose) {
27452
+ debugLog(
27453
+ "verbose",
27454
+ `DOM selection rects: boundary containment ${JSON.stringify({
27455
+ pageIndex,
27456
+ sliceFrom,
27457
+ sliceTo,
27458
+ startContained,
27459
+ endContained
27460
+ })}`
27461
+ );
27462
+ }
26483
27463
  if (!rebuiltOnce) {
26484
27464
  options.rebuildDomPositionIndex();
26485
27465
  rebuiltOnce = true;
@@ -26487,9 +27467,34 @@ function computeSelectionRectsFromDom(options, from2, to) {
26487
27467
  if (sliceEntries.length === 0) continue;
26488
27468
  startEntry = options.domPositionIndex.findEntryAtPosition(sliceFrom) ?? sliceEntries[0];
26489
27469
  endEntry = options.domPositionIndex.findEntryAtPosition(sliceTo) ?? sliceEntries[sliceEntries.length - 1];
27470
+ startContained = pageEl.contains(startEntry.el);
27471
+ endContained = pageEl.contains(endEntry.el);
27472
+ if (isVerbose) {
27473
+ debugLog(
27474
+ "verbose",
27475
+ `DOM selection rects: boundary containment after rebuild ${JSON.stringify({
27476
+ pageIndex,
27477
+ sliceFrom,
27478
+ sliceTo,
27479
+ startContained,
27480
+ endContained,
27481
+ start: entryDebugInfo(startEntry),
27482
+ end: entryDebugInfo(endEntry)
27483
+ })}`
27484
+ );
27485
+ }
26490
27486
  }
26491
- if (!pageEl.contains(startEntry.el) || !pageEl.contains(endEntry.el)) {
26492
- debugLog("warn", "DOM selection rects: stale index after rebuild", { pageIndex, sliceFrom, sliceTo });
27487
+ if (!startContained || !endContained) {
27488
+ debugLog(
27489
+ "warn",
27490
+ `DOM selection rects: stale index after rebuild ${JSON.stringify({
27491
+ pageIndex,
27492
+ sliceFrom,
27493
+ sliceTo,
27494
+ start: entryDebugInfo(startEntry),
27495
+ end: entryDebugInfo(endEntry)
27496
+ })}`
27497
+ );
26493
27498
  return null;
26494
27499
  }
26495
27500
  }
@@ -26504,8 +27509,83 @@ function computeSelectionRectsFromDom(options, from2, to) {
26504
27509
  }
26505
27510
  let clientRects = [];
26506
27511
  try {
26507
- const rawRects = Array.from(range.getClientRects());
26508
- clientRects = deduplicateOverlappingRects(rawRects);
27512
+ let rawRects = Array.from(range.getClientRects());
27513
+ if (dumpRects) {
27514
+ debugLog(
27515
+ "verbose",
27516
+ `DOM selection rects: raw rects ${JSON.stringify({
27517
+ pageIndex,
27518
+ sliceFrom,
27519
+ sliceTo,
27520
+ rects: rawRects.map(rectDebugInfo)
27521
+ })}`
27522
+ );
27523
+ }
27524
+ let missingEntries = null;
27525
+ if (typeof range.intersectsNode === "function") {
27526
+ for (const entry of sliceEntries) {
27527
+ try {
27528
+ if (!range.intersectsNode(entry.el)) {
27529
+ missingEntries ?? (missingEntries = []);
27530
+ missingEntries.push(entry);
27531
+ }
27532
+ } catch {
27533
+ }
27534
+ }
27535
+ }
27536
+ if (missingEntries && missingEntries.length > 0) {
27537
+ if (isVerbose) {
27538
+ debugLog(
27539
+ "verbose",
27540
+ `DOM selection rects: range missing entries ${JSON.stringify({
27541
+ pageIndex,
27542
+ sliceFrom,
27543
+ sliceTo,
27544
+ missingCount: missingEntries.length,
27545
+ missingPreview: missingEntries.slice(0, 20).map(entryDebugInfo)
27546
+ })}`
27547
+ );
27548
+ }
27549
+ rawRects = collectClientRectsByLine(doc2, sliceEntries, sliceFrom, sliceTo);
27550
+ if (dumpRects) {
27551
+ debugLog(
27552
+ "verbose",
27553
+ `DOM selection rects: fallback raw rects ${JSON.stringify({
27554
+ pageIndex,
27555
+ sliceFrom,
27556
+ sliceTo,
27557
+ rects: rawRects.map(rectDebugInfo)
27558
+ })}`
27559
+ );
27560
+ }
27561
+ }
27562
+ clientRects = disableRectDedupe ? rawRects : deduplicateOverlappingRects(rawRects);
27563
+ if (dumpRects) {
27564
+ debugLog(
27565
+ "verbose",
27566
+ `DOM selection rects: final rects ${JSON.stringify({
27567
+ pageIndex,
27568
+ sliceFrom,
27569
+ sliceTo,
27570
+ dedupeDisabled: disableRectDedupe,
27571
+ rects: clientRects.map(rectDebugInfo)
27572
+ })}`
27573
+ );
27574
+ const nonPositive = clientRects.filter(
27575
+ (rect) => !Number.isFinite(rect.width) || !Number.isFinite(rect.height) || rect.width <= 0 || rect.height <= 0
27576
+ );
27577
+ if (nonPositive.length > 0) {
27578
+ debugLog(
27579
+ "verbose",
27580
+ `DOM selection rects: non-positive rects ${JSON.stringify({
27581
+ pageIndex,
27582
+ sliceFrom,
27583
+ sliceTo,
27584
+ rects: nonPositive.map(rectDebugInfo)
27585
+ })}`
27586
+ );
27587
+ }
27588
+ }
26509
27589
  } catch (error) {
26510
27590
  debugLog("warn", "DOM selection rects: getClientRects failed", { error: String(error) });
26511
27591
  return null;
@@ -26529,6 +27609,57 @@ function computeSelectionRectsFromDom(options, from2, to) {
26529
27609
  }
26530
27610
  return out;
26531
27611
  }
27612
+ function collectClientRectsByLine(doc2, entries, sliceFrom, sliceTo) {
27613
+ const rects = [];
27614
+ const lineMap = /* @__PURE__ */ new Map();
27615
+ const looseEntries = [];
27616
+ for (const entry of entries) {
27617
+ const lineEl = entry.el.closest(".superdoc-line");
27618
+ if (!lineEl) {
27619
+ looseEntries.push(entry);
27620
+ continue;
27621
+ }
27622
+ const list = lineMap.get(lineEl);
27623
+ if (list) {
27624
+ list.push(entry);
27625
+ } else {
27626
+ lineMap.set(lineEl, [entry]);
27627
+ }
27628
+ }
27629
+ for (const [, lineEntries] of lineMap) {
27630
+ lineEntries.sort((a, b) => a.pmStart - b.pmStart !== 0 ? a.pmStart - b.pmStart : a.pmEnd - b.pmEnd);
27631
+ const linePmStart = lineEntries[0]?.pmStart ?? Infinity;
27632
+ const linePmEnd = lineEntries[lineEntries.length - 1]?.pmEnd ?? -Infinity;
27633
+ if (!Number.isFinite(linePmStart) || !Number.isFinite(linePmEnd) || linePmEnd <= linePmStart) continue;
27634
+ const lineFrom = Math.max(sliceFrom, linePmStart);
27635
+ const lineTo = Math.min(sliceTo, linePmEnd);
27636
+ if (lineFrom >= lineTo) continue;
27637
+ const startEntry = lineEntries.find((entry) => lineFrom >= entry.pmStart && lineFrom <= entry.pmEnd) ?? lineEntries[0];
27638
+ const endEntry = lineEntries.find((entry) => lineTo >= entry.pmStart && lineTo <= entry.pmEnd) ?? lineEntries[lineEntries.length - 1];
27639
+ const range = doc2.createRange();
27640
+ try {
27641
+ if (!setDomRangeStart(range, startEntry, lineFrom)) continue;
27642
+ if (!setDomRangeEnd(range, endEntry, lineTo)) continue;
27643
+ } catch {
27644
+ continue;
27645
+ }
27646
+ rects.push(...Array.from(range.getClientRects()));
27647
+ }
27648
+ for (const entry of looseEntries) {
27649
+ const entryFrom = Math.max(sliceFrom, entry.pmStart);
27650
+ const entryTo = Math.min(sliceTo, entry.pmEnd);
27651
+ if (entryFrom >= entryTo) continue;
27652
+ const range = doc2.createRange();
27653
+ try {
27654
+ if (!setDomRangeStart(range, entry, entryFrom)) continue;
27655
+ if (!setDomRangeEnd(range, entry, entryTo)) continue;
27656
+ } catch {
27657
+ continue;
27658
+ }
27659
+ rects.push(...Array.from(range.getClientRects()));
27660
+ }
27661
+ return rects;
27662
+ }
26532
27663
  function setDomRangeStart(range, entry, pos) {
26533
27664
  const el = entry.el;
26534
27665
  const pmStart = entry.pmStart;
@@ -26638,31 +27769,69 @@ function deduplicateOverlappingRects(rects) {
26638
27769
  return a.x - b.x;
26639
27770
  });
26640
27771
  const result = [];
26641
- let i = 0;
26642
- while (i < sorted.length) {
26643
- const current = sorted[i];
26644
- let best = current;
26645
- let j = i + 1;
26646
- while (j < sorted.length) {
26647
- const next = sorted[j];
26648
- const yOverlap = Math.abs(next.y - current.y) < Y_SAME_LINE_THRESHOLD_PX;
26649
- const xOverlapStart = Math.max(current.x, next.x);
26650
- const xOverlapEnd = Math.min(current.x + current.width, next.x + next.width);
26651
- const hasHorizontalOverlap = xOverlapEnd > xOverlapStart;
26652
- const overlapWidth = Math.max(0, xOverlapEnd - xOverlapStart);
26653
- const minWidth = Math.min(current.width, next.width);
26654
- const significantOverlap = minWidth > 0 && overlapWidth / minWidth > HORIZONTAL_OVERLAP_THRESHOLD;
26655
- if (yOverlap && hasHorizontalOverlap && significantOverlap) {
26656
- if (next.height < best.height) {
26657
- best = next;
26658
- }
26659
- j++;
26660
- } else {
26661
- break;
27772
+ const groups = [];
27773
+ let currentGroup = [];
27774
+ for (const rect of sorted) {
27775
+ if (currentGroup.length === 0) {
27776
+ currentGroup.push(rect);
27777
+ continue;
27778
+ }
27779
+ const groupY = currentGroup[0].y;
27780
+ if (Math.abs(rect.y - groupY) <= Y_SAME_LINE_THRESHOLD_PX) {
27781
+ currentGroup.push(rect);
27782
+ } else {
27783
+ groups.push(currentGroup);
27784
+ currentGroup = [rect];
27785
+ }
27786
+ }
27787
+ if (currentGroup.length > 0) {
27788
+ groups.push(currentGroup);
27789
+ }
27790
+ const SIZE_EPS_PX = 0.5;
27791
+ const X_DUPLICATE_EPS_PX = 1;
27792
+ const hasSignificantOverlap = (a, b) => {
27793
+ const xOverlapStart = Math.max(a.x, b.x);
27794
+ const xOverlapEnd = Math.min(a.x + a.width, b.x + b.width);
27795
+ const hasHorizontalOverlap = xOverlapEnd > xOverlapStart;
27796
+ if (!hasHorizontalOverlap) return false;
27797
+ const overlapWidth = Math.max(0, xOverlapEnd - xOverlapStart);
27798
+ const minWidth = Math.min(a.width, b.width);
27799
+ return minWidth > 0 && overlapWidth / minWidth > HORIZONTAL_OVERLAP_THRESHOLD;
27800
+ };
27801
+ const isLargerRect = (a, b) => {
27802
+ return a.width > b.width + SIZE_EPS_PX || a.height > b.height + SIZE_EPS_PX;
27803
+ };
27804
+ for (const group of groups) {
27805
+ const unique2 = [];
27806
+ for (const rect of group) {
27807
+ const isDuplicate = unique2.some((existing) => {
27808
+ const xClose = Math.abs(existing.x - rect.x) <= X_DUPLICATE_EPS_PX;
27809
+ const yClose = Math.abs(existing.y - rect.y) <= Y_SAME_LINE_THRESHOLD_PX;
27810
+ const widthClose = Math.abs(existing.width - rect.width) <= SIZE_EPS_PX;
27811
+ const heightClose = Math.abs(existing.height - rect.height) <= SIZE_EPS_PX;
27812
+ return xClose && yClose && widthClose && heightClose;
27813
+ });
27814
+ if (!isDuplicate) {
27815
+ unique2.push(rect);
26662
27816
  }
26663
27817
  }
26664
- result.push(best);
26665
- i = j;
27818
+ if (unique2.length <= 1) {
27819
+ result.push(...unique2);
27820
+ continue;
27821
+ }
27822
+ const containers = /* @__PURE__ */ new Set();
27823
+ for (const rect of unique2) {
27824
+ for (const other of unique2) {
27825
+ if (rect === other) continue;
27826
+ if (!hasSignificantOverlap(rect, other)) continue;
27827
+ if (isLargerRect(rect, other)) {
27828
+ containers.add(rect);
27829
+ break;
27830
+ }
27831
+ }
27832
+ }
27833
+ const filtered = unique2.filter((rect) => !containers.has(rect));
27834
+ result.push(...filtered.length > 0 ? filtered : unique2);
26666
27835
  }
26667
27836
  return result;
26668
27837
  }
@@ -26786,10 +27955,11 @@ function safeCleanup(fn2, context) {
26786
27955
  function createHiddenHost(doc2, widthPx) {
26787
27956
  const host = doc2.createElement("div");
26788
27957
  host.className = "presentation-editor__hidden-host";
26789
- host.style.position = "absolute";
27958
+ host.style.position = "fixed";
26790
27959
  host.style.left = "-9999px";
26791
27960
  host.style.top = "0";
26792
27961
  host.style.width = `${widthPx}px`;
27962
+ host.style.setProperty("overflow-anchor", "none");
26793
27963
  host.style.pointerEvents = "none";
26794
27964
  host.style.opacity = "0";
26795
27965
  host.style.zIndex = "-1";
@@ -27263,7 +28433,8 @@ function clickToPositionDom(domContainer, clientX, clientY) {
27263
28433
  });
27264
28434
  let hitChain = [];
27265
28435
  const doc2 = document;
27266
- if (typeof doc2.elementsFromPoint === "function") {
28436
+ const hasElementsFromPoint = typeof doc2.elementsFromPoint === "function";
28437
+ if (hasElementsFromPoint) {
27267
28438
  try {
27268
28439
  hitChain = doc2.elementsFromPoint(viewX, viewY) ?? [];
27269
28440
  } catch {
@@ -27309,11 +28480,14 @@ function clickToPositionDom(domContainer, clientX, clientY) {
27309
28480
  log("All fragments on page:", JSON.stringify(fragmentData, null, 2));
27310
28481
  const fragmentEl = hitChain.find((el) => el.classList?.contains?.(CLASS_NAMES.fragment));
27311
28482
  if (!fragmentEl) {
28483
+ if (hasElementsFromPoint) {
28484
+ return null;
28485
+ }
27312
28486
  const fallbackFragment = pageEl.querySelector(`.${CLASS_NAMES.fragment}`);
27313
28487
  if (!fallbackFragment) {
27314
28488
  return null;
27315
28489
  }
27316
- log("Using fallback fragment:", {
28490
+ log("Using fallback fragment (no elementsFromPoint):", {
27317
28491
  blockId: fallbackFragment.dataset.blockId,
27318
28492
  pmStart: fallbackFragment.dataset.pmStart,
27319
28493
  pmEnd: fallbackFragment.dataset.pmEnd
@@ -31599,11 +32773,11 @@ function isTextRun$2(run) {
31599
32773
  }
31600
32774
  function fontString(run) {
31601
32775
  const textRun = isTextRun$2(run) ? run : null;
31602
- const size = textRun?.fontSize ?? 16;
32776
+ const size2 = textRun?.fontSize ?? 16;
31603
32777
  const family = textRun?.fontFamily ?? "Arial";
31604
32778
  const italic = textRun?.italic ? "italic " : "";
31605
32779
  const bold = textRun?.bold ? "bold " : "";
31606
- return `${italic}${bold}${size}px ${family}`.trim();
32780
+ return `${italic}${bold}${size2}px ${family}`.trim();
31607
32781
  }
31608
32782
  function runText(run) {
31609
32783
  return "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
@@ -31649,8 +32823,8 @@ function measureRunSliceWidth(run, fromChar, toChar) {
31649
32823
  const text = runText(run).slice(fromChar, toChar);
31650
32824
  if (!context) {
31651
32825
  const textRun = isTextRun$2(run) ? run : null;
31652
- const size = textRun?.fontSize ?? 16;
31653
- return Math.max(1, text.length * (size * 0.6));
32826
+ const size2 = textRun?.fontSize ?? 16;
32827
+ return Math.max(1, text.length * (size2 * 0.6));
31654
32828
  }
31655
32829
  context.font = fontString(run);
31656
32830
  const metrics = context.measureText(text);
@@ -31661,8 +32835,8 @@ function lineHeightForRuns(runs, fromRun, toRun) {
31661
32835
  for (let i = fromRun; i <= toRun; i += 1) {
31662
32836
  const run = runs[i];
31663
32837
  const textRun = run && isTextRun$2(run) ? run : null;
31664
- const size = textRun?.fontSize ?? 16;
31665
- if (size > maxSize2) maxSize2 = size;
32838
+ const size2 = textRun?.fontSize ?? 16;
32839
+ if (size2 > maxSize2) maxSize2 = size2;
31666
32840
  }
31667
32841
  return maxSize2 * 1.2;
31668
32842
  }
@@ -34661,7 +35835,7 @@ class PresentationInputBridge {
34661
35835
  __privateSet(this, _destroyed, true);
34662
35836
  }
34663
35837
  notifyTargetChanged() {
34664
- var _a;
35838
+ var _a2;
34665
35839
  if (__privateGet(this, _destroyed)) {
34666
35840
  return;
34667
35841
  }
@@ -34685,7 +35859,7 @@ class PresentationInputBridge {
34685
35859
  }
34686
35860
  }
34687
35861
  __privateSet(this, _currentTarget, nextTarget);
34688
- (_a = __privateGet(this, _onTargetChanged)) == null ? void 0 : _a.call(this, nextTarget ?? null);
35862
+ (_a2 = __privateGet(this, _onTargetChanged)) == null ? void 0 : _a2.call(this, nextTarget ?? null);
34689
35863
  }
34690
35864
  }
34691
35865
  _windowRoot2 = new WeakMap();
@@ -36786,8 +37960,8 @@ const buildPositionMap = (root, options) => {
36786
37960
  }
36787
37961
  const visit = (node, pos) => {
36788
37962
  if (node.type === "text") {
36789
- const size = node.text?.length ?? 0;
36790
- const end22 = pos + size;
37963
+ const size2 = node.text?.length ?? 0;
37964
+ const end22 = pos + size2;
36791
37965
  map2.set(node, { start: pos, end: end22 });
36792
37966
  return end22;
36793
37967
  }
@@ -37750,10 +38924,10 @@ function tokenNodeToRun(node, positions, defaultFont, defaultSize, inheritedMark
37750
38924
  const EIGHTHS_PER_POINT = 8;
37751
38925
  const MIN_BORDER_SIZE_PX = 0.5;
37752
38926
  const MAX_BORDER_SIZE_PX = 100;
37753
- const borderSizeToPx = (size) => {
37754
- if (!isFiniteNumber(size)) return void 0;
37755
- if (size <= 0) return 0;
37756
- const points = size / EIGHTHS_PER_POINT;
38927
+ const borderSizeToPx = (size2) => {
38928
+ if (!isFiniteNumber(size2)) return void 0;
38929
+ if (size2 <= 0) return 0;
38930
+ const points = size2 / EIGHTHS_PER_POINT;
37757
38931
  const pixelValue = points * PX_PER_PT;
37758
38932
  return Math.min(MAX_BORDER_SIZE_PX, Math.max(MIN_BORDER_SIZE_PX, pixelValue));
37759
38933
  };
@@ -37768,11 +38942,11 @@ function convertBorderSpec(ooxmlBorder) {
37768
38942
  const border = ooxmlBorder;
37769
38943
  const hasValidStructure = Object.keys(border).length > 0;
37770
38944
  if (!hasValidStructure) return void 0;
37771
- const { val, size, color } = border;
37772
- if (size !== void 0 && typeof size !== "number") return void 0;
38945
+ const { val, size: size2, color } = border;
38946
+ if (size2 !== void 0 && typeof size2 !== "number") return void 0;
37773
38947
  if (color !== void 0 && typeof color !== "string") return void 0;
37774
38948
  if (val !== void 0 && typeof val !== "string") return void 0;
37775
- const sizeNumber = typeof size === "number" ? size : void 0;
38949
+ const sizeNumber = typeof size2 === "number" ? size2 : void 0;
37776
38950
  const colorString = typeof color === "string" ? color : void 0;
37777
38951
  if (val === "nil" || val === "none" || sizeNumber === 0) {
37778
38952
  return { style: "none", width: 0 };
@@ -37792,11 +38966,11 @@ function convertTableBorderValue(ooxmlBorder) {
37792
38966
  if (Object.keys(border).length === 0) {
37793
38967
  return void 0;
37794
38968
  }
37795
- const { val, size, color } = border;
37796
- if (val === "nil" || val === "none" || size === 0) {
38969
+ const { val, size: size2, color } = border;
38970
+ if (val === "nil" || val === "none" || size2 === 0) {
37797
38971
  return { none: true };
37798
38972
  }
37799
- const width = borderSizeToPx(size);
38973
+ const width = borderSizeToPx(size2);
37800
38974
  if (width == null) return void 0;
37801
38975
  const normalizedColor = normalizeColorWithDefault(color);
37802
38976
  return {
@@ -38392,7 +39566,7 @@ function mergeCharacter(base2, overrides) {
38392
39566
  function normalizeFieldAnnotationMetadata(attrs) {
38393
39567
  const fieldId = toOptionalString(attrs.fieldId) ?? "";
38394
39568
  const formatting = extractFormatting(attrs);
38395
- const size = normalizeSize(attrs.size);
39569
+ const size2 = normalizeSize(attrs.size);
38396
39570
  const extras = isPlainObject$1(attrs.extras) ? attrs.extras : null;
38397
39571
  const marks = isPlainObject$1(attrs.marks) ? attrs.marks : void 0;
38398
39572
  return {
@@ -38413,7 +39587,7 @@ function normalizeFieldAnnotationMetadata(attrs) {
38413
39587
  linkUrl: toNullableString(attrs.linkUrl),
38414
39588
  imageSrc: toNullableString(attrs.imageSrc),
38415
39589
  rawHtml: attrs.rawHtml ?? void 0,
38416
- size: size ?? null,
39590
+ size: size2 ?? null,
38417
39591
  extras,
38418
39592
  multipleImage: toBoolean$2(attrs.multipleImage, false),
38419
39593
  hash: toOptionalString(attrs.hash) ?? null,
@@ -38654,9 +39828,9 @@ const buildFontCss = (run) => {
38654
39828
  }
38655
39829
  fontSize = Math.floor(fontSize);
38656
39830
  fontSize = Math.max(1, Math.min(999, fontSize));
38657
- const size = `${fontSize}px`;
39831
+ const size2 = `${fontSize}px`;
38658
39832
  const family = run.fontFamily ?? "Times New Roman";
38659
- return `${style}${weight}${size} ${family}`;
39833
+ return `${style}${weight}${size2} ${family}`;
38660
39834
  };
38661
39835
  const TWIPS_PER_INCH$1 = 1440;
38662
39836
  const PIXELS_PER_INCH = 96;
@@ -39414,13 +40588,13 @@ const inferBooleanFromParagraphElements = (paragraphProps, elementNames) => {
39414
40588
  (name) => name.startsWith("w:") ? [name, name.slice(2)] : [name, `w:${name}`]
39415
40589
  )
39416
40590
  );
39417
- const match = elements.find((el) => {
40591
+ const match2 = elements.find((el) => {
39418
40592
  if (!el || typeof el !== "object") return false;
39419
40593
  const name = el.name;
39420
40594
  return typeof name === "string" && normalizedTargets.has(name);
39421
40595
  });
39422
- if (!match) return void 0;
39423
- const rawVal = match.attributes?.["w:val"] ?? match.attributes?.val;
40596
+ if (!match2) return void 0;
40597
+ const rawVal = match2.attributes?.["w:val"] ?? match2.attributes?.val;
39424
40598
  if (rawVal == null) return true;
39425
40599
  if (isExplicitFalse(rawVal)) return false;
39426
40600
  if (isTruthy(rawVal)) return true;
@@ -40786,9 +41960,9 @@ function vectorShapeNodeToDrawingBlock(node, nextBlockId, positions) {
40786
41960
  function shapeGroupNodeToDrawingBlock(node, nextBlockId, positions) {
40787
41961
  const rawAttrs = getAttrs$1(node);
40788
41962
  const groupTransform = isShapeGroupTransform(rawAttrs.groupTransform) ? { ...rawAttrs.groupTransform } : void 0;
40789
- const size = normalizeShapeSize(rawAttrs.size);
40790
- const width = size?.width ?? groupTransform?.width ?? 1;
40791
- const height = size?.height ?? groupTransform?.height ?? 1;
41963
+ const size2 = normalizeShapeSize(rawAttrs.size);
41964
+ const width = size2?.width ?? groupTransform?.width ?? 1;
41965
+ const height = size2?.height ?? groupTransform?.height ?? 1;
40792
41966
  const geometry = {
40793
41967
  width: coercePositiveNumber(width, 1),
40794
41968
  height: coercePositiveNumber(height, 1),
@@ -40799,7 +41973,7 @@ function shapeGroupNodeToDrawingBlock(node, nextBlockId, positions) {
40799
41973
  return buildDrawingBlock(rawAttrs, nextBlockId, positions, node, geometry, "shapeGroup", {
40800
41974
  groupTransform,
40801
41975
  shapes: normalizeShapeGroupChildren(rawAttrs.shapes),
40802
- size
41976
+ size: size2
40803
41977
  });
40804
41978
  }
40805
41979
  function shapeContainerNodeToDrawingBlock(node, nextBlockId, positions) {
@@ -40876,9 +42050,9 @@ function contentBlockNodeToDrawingBlock(node, nextBlockId, positions) {
40876
42050
  if (rawAttrs.horizontalRule !== true) {
40877
42051
  return null;
40878
42052
  }
40879
- const size = isPlainObject$2(rawAttrs.size) ? rawAttrs.size : void 0;
40880
- const { width, isFullWidth } = parseFullWidth(size?.width);
40881
- const height = pickNumber(size?.height);
42053
+ const size2 = isPlainObject$2(rawAttrs.size) ? rawAttrs.size : void 0;
42054
+ const { width, isFullWidth } = parseFullWidth(size2?.width);
42055
+ const height = pickNumber(size2?.height);
40882
42056
  if (!height || height <= 0) {
40883
42057
  return null;
40884
42058
  }
@@ -40955,11 +42129,11 @@ const toPxNumber = (value) => {
40955
42129
  if (typeof raw === "number" && Number.isFinite(raw)) return raw;
40956
42130
  if (typeof raw !== "string") return void 0;
40957
42131
  const trimmed = raw.trim();
40958
- const match = trimmed.match(/^(-?\d+(\.\d+)?)([a-z%]*)$/i);
40959
- if (!match) return void 0;
40960
- const numeric = parseFloat(match[1]);
42132
+ const match2 = trimmed.match(/^(-?\d+(\.\d+)?)([a-z%]*)$/i);
42133
+ if (!match2) return void 0;
42134
+ const numeric = parseFloat(match2[1]);
40961
42135
  if (!Number.isFinite(numeric)) return void 0;
40962
- const unit = match[3]?.toLowerCase();
42136
+ const unit = match2[3]?.toLowerCase();
40963
42137
  if (!unit || unit === "px") return numeric;
40964
42138
  if (unit === "pt") return numeric * PT_TO_PX;
40965
42139
  return numeric;
@@ -41103,9 +42277,9 @@ function imageNodeToRun(node, positions, activeSdt) {
41103
42277
  if (!src) {
41104
42278
  return null;
41105
42279
  }
41106
- const size = attrs.size ?? {};
41107
- const width = typeof size.width === "number" && Number.isFinite(size.width) && size.width > 0 ? size.width : DEFAULT_IMAGE_DIMENSION_PX;
41108
- const height = typeof size.height === "number" && Number.isFinite(size.height) && size.height > 0 ? size.height : DEFAULT_IMAGE_DIMENSION_PX;
42280
+ const size2 = attrs.size ?? {};
42281
+ const width = typeof size2.width === "number" && Number.isFinite(size2.width) && size2.width > 0 ? size2.width : DEFAULT_IMAGE_DIMENSION_PX;
42282
+ const height = typeof size2.height === "number" && Number.isFinite(size2.height) && size2.height > 0 ? size2.height : DEFAULT_IMAGE_DIMENSION_PX;
41109
42283
  const wrap = isPlainObject$2(attrs.wrap) ? attrs.wrap : {};
41110
42284
  const wrapAttrs = isPlainObject$2(wrap.attrs) ? wrap.attrs : {};
41111
42285
  const run = {
@@ -41165,11 +42339,11 @@ function fieldAnnotationNodeToRun(node, positions, fieldMetadata) {
41165
42339
  if (linkUrl) run.linkUrl = linkUrl;
41166
42340
  const rawHtml = attrs.rawHtml ?? fieldMetadata?.rawHtml;
41167
42341
  if (typeof rawHtml === "string") run.rawHtml = rawHtml;
41168
- const size = attrs.size ?? fieldMetadata?.size;
41169
- if (size && (typeof size.width === "number" || typeof size.height === "number")) {
42342
+ const size2 = attrs.size ?? fieldMetadata?.size;
42343
+ if (size2 && (typeof size2.width === "number" || typeof size2.height === "number")) {
41170
42344
  run.size = {
41171
- width: typeof size.width === "number" ? size.width : void 0,
41172
- height: typeof size.height === "number" ? size.height : void 0
42345
+ width: typeof size2.width === "number" ? size2.width : void 0,
42346
+ height: typeof size2.height === "number" ? size2.height : void 0
41173
42347
  };
41174
42348
  }
41175
42349
  const fontFamily = attrs.fontFamily ?? fieldMetadata?.fontFamily;
@@ -41260,12 +42434,12 @@ const extractFirstTextRunFont = (para) => {
41260
42434
  const attrs = mark.attrs;
41261
42435
  if (attrs.fontSize != null) {
41262
42436
  const fontSizeStr = String(attrs.fontSize);
41263
- const size = parseFloat(fontSizeStr);
41264
- if (Number.isFinite(size)) {
42437
+ const size2 = parseFloat(fontSizeStr);
42438
+ if (Number.isFinite(size2)) {
41265
42439
  if (fontSizeStr.endsWith("pt")) {
41266
- result.fontSizePx = ptToPx(size);
42440
+ result.fontSizePx = ptToPx(size2);
41267
42441
  } else {
41268
- result.fontSizePx = size;
42442
+ result.fontSizePx = size2;
41269
42443
  }
41270
42444
  }
41271
42445
  }
@@ -41993,9 +43167,9 @@ function imageNodeToBlock(node, nextBlockId, positions, _trackedMeta, _trackedCh
41993
43167
  attrsWithPm.pmStart = pos.start;
41994
43168
  attrsWithPm.pmEnd = pos.end;
41995
43169
  }
41996
- const size = attrs.size ?? {};
41997
- const width = typeof size.width === "number" && Number.isFinite(size.width) ? size.width : void 0;
41998
- const height = typeof size.height === "number" && Number.isFinite(size.height) ? size.height : void 0;
43170
+ const size2 = attrs.size ?? {};
43171
+ const width = typeof size2.width === "number" && Number.isFinite(size2.width) ? size2.width : void 0;
43172
+ const height = typeof size2.height === "number" && Number.isFinite(size2.height) ? size2.height : void 0;
41999
43173
  const explicitDisplay = typeof attrs.display === "string" ? attrs.display : void 0;
42000
43174
  const normalizedWrap = normalizeWrap$1(attrs.wrap);
42001
43175
  let anchor = normalizeAnchorData(attrs.anchorData, attrs, normalizedWrap?.behindDoc);
@@ -45184,8 +46358,8 @@ async function measureParagraphBlock(block, maxWidth) {
45184
46358
  }
45185
46359
  }
45186
46360
  for (let wordIndex = 0; wordIndex < words.length; wordIndex++) {
45187
- const word = words[wordIndex];
45188
- if (word === "") {
46361
+ const word2 = words[wordIndex];
46362
+ if (word2 === "") {
45189
46363
  const spaceStartChar = charPosInRun;
45190
46364
  const spaceEndChar = charPosInRun + 1;
45191
46365
  const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run);
@@ -45239,15 +46413,15 @@ async function measureParagraphBlock(block, maxWidth) {
45239
46413
  charPosInRun = spaceEndChar;
45240
46414
  continue;
45241
46415
  }
45242
- const wordOnlyWidth = measureRunWidth(word, font, ctx2, run);
46416
+ const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run);
45243
46417
  const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
45244
46418
  const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run) : 0;
45245
46419
  const wordCommitWidth = wordOnlyWidth + spaceWidth;
45246
46420
  const wordStartChar = charPosInRun;
45247
- const wordEndNoSpace = charPosInRun + word.length;
46421
+ const wordEndNoSpace = charPosInRun + word2.length;
45248
46422
  const wordEndWithSpace = wordEndNoSpace + (shouldIncludeDelimiterSpace ? 1 : 0);
45249
46423
  const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
45250
- if (wordOnlyWidth > effectiveMaxWidth && word.length > 1) {
46424
+ if (wordOnlyWidth > effectiveMaxWidth && word2.length > 1) {
45251
46425
  if (currentLine && currentLine.width > 0 && currentLine.segments && currentLine.segments.length > 0) {
45252
46426
  trimTrailingWrapSpaces(currentLine);
45253
46427
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
@@ -45263,7 +46437,7 @@ async function measureParagraphBlock(block, maxWidth) {
45263
46437
  const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
45264
46438
  const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
45265
46439
  const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
45266
- const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run);
46440
+ const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run);
45267
46441
  let chunkCharOffset = wordStartChar;
45268
46442
  for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
45269
46443
  const chunk = chunks[chunkIndex];
@@ -45938,10 +47112,10 @@ const measureRunWidth = (text, font, ctx2, run) => {
45938
47112
  const width = getMeasuredTextWidth(text, font, letterSpacing, ctx2);
45939
47113
  return roundValue(width);
45940
47114
  };
45941
- const breakWordIntoChunks = (word, maxWidth, font, ctx2, run) => {
47115
+ const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run) => {
45942
47116
  const chunks = [];
45943
47117
  if (maxWidth <= 0) {
45944
- for (const char of word) {
47118
+ for (const char of word2) {
45945
47119
  const charWidth = measureRunWidth(char, font, ctx2, run);
45946
47120
  chunks.push({ text: char, width: charWidth });
45947
47121
  }
@@ -45949,8 +47123,8 @@ const breakWordIntoChunks = (word, maxWidth, font, ctx2, run) => {
45949
47123
  }
45950
47124
  let currentChunk = "";
45951
47125
  let currentWidth = 0;
45952
- for (let i = 0; i < word.length; i++) {
45953
- const char = word[i];
47126
+ for (let i = 0; i < word2.length; i++) {
47127
+ const char = word2[i];
45954
47128
  const testChunk = currentChunk + char;
45955
47129
  const testWidth = measureRunWidth(testChunk, font, ctx2, run);
45956
47130
  if (testWidth > maxWidth && currentChunk.length > 0) {
@@ -46539,6 +47713,25 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
46539
47713
  } else {
46540
47714
  __privateSet(this, _dragExtensionMode, "char");
46541
47715
  }
47716
+ debugLog(
47717
+ "verbose",
47718
+ `Drag selection start ${JSON.stringify({
47719
+ pointer: { clientX: event.clientX, clientY: event.clientY, x, y },
47720
+ clickDepth,
47721
+ extensionMode: __privateGet(this, _dragExtensionMode),
47722
+ anchor: __privateGet(this, _dragAnchor),
47723
+ anchorPageIndex: __privateGet(this, _dragAnchorPageIndex),
47724
+ rawHit: rawHit ? {
47725
+ pos: rawHit.pos,
47726
+ pageIndex: rawHit.pageIndex,
47727
+ blockId: rawHit.blockId,
47728
+ lineIndex: rawHit.lineIndex,
47729
+ layoutEpoch: rawHit.layoutEpoch
47730
+ } : null,
47731
+ mapped: mapped ? mapped.ok ? { ok: true, pos: mapped.pos, fromEpoch: mapped.fromEpoch, toEpoch: mapped.toEpoch } : { ok: false, reason: mapped.reason, fromEpoch: mapped.fromEpoch, toEpoch: mapped.toEpoch } : null,
47732
+ hit: hit ? { pos: hit.pos, pageIndex: hit.pageIndex, layoutEpoch: hit.layoutEpoch } : null
47733
+ })}`
47734
+ );
46542
47735
  if (typeof __privateGet(this, _viewportHost).setPointerCapture === "function") {
46543
47736
  __privateGet(this, _viewportHost).setPointerCapture(event.pointerId);
46544
47737
  }
@@ -46575,6 +47768,8 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
46575
47768
  if (!normalized) return;
46576
47769
  if (__privateGet(this, _isDragging) && __privateGet(this, _dragAnchor) !== null && event.buttons & 1) {
46577
47770
  __privateSet(this, _pendingMarginClick, null);
47771
+ const prevPointer = __privateGet(this, _dragLastPointer);
47772
+ const prevRawHit = __privateGet(this, _dragLastRawHit);
46578
47773
  __privateSet(this, _dragLastPointer, { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y });
46579
47774
  const rawHit = clickToPosition(
46580
47775
  __privateGet(this, _layoutState).layout,
@@ -46586,7 +47781,17 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
46586
47781
  event.clientY,
46587
47782
  __privateGet(this, _pageGeometryHelper) ?? void 0
46588
47783
  );
46589
- if (!rawHit) return;
47784
+ if (!rawHit) {
47785
+ debugLog(
47786
+ "verbose",
47787
+ `Drag selection update (no hit) ${JSON.stringify({
47788
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y },
47789
+ prevPointer,
47790
+ anchor: __privateGet(this, _dragAnchor)
47791
+ })}`
47792
+ );
47793
+ return;
47794
+ }
46590
47795
  const doc2 = __privateGet(this, _editor3).state?.doc;
46591
47796
  if (!doc2) return;
46592
47797
  __privateSet(this, _dragLastRawHit, rawHit);
@@ -46599,6 +47804,27 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
46599
47804
  const mappedHead = __privateGet(this, _epochMapper).mapPosFromLayoutToCurrentDetailed(rawHit.pos, rawHit.layoutEpoch, 1);
46600
47805
  if (!mappedHead.ok) {
46601
47806
  debugLog("warn", "drag mapping failed", mappedHead);
47807
+ debugLog(
47808
+ "verbose",
47809
+ `Drag selection update (map failed) ${JSON.stringify({
47810
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y },
47811
+ prevPointer,
47812
+ anchor: __privateGet(this, _dragAnchor),
47813
+ rawHit: {
47814
+ pos: rawHit.pos,
47815
+ pageIndex: rawHit.pageIndex,
47816
+ blockId: rawHit.blockId,
47817
+ lineIndex: rawHit.lineIndex,
47818
+ layoutEpoch: rawHit.layoutEpoch
47819
+ },
47820
+ mapped: {
47821
+ ok: false,
47822
+ reason: mappedHead.reason,
47823
+ fromEpoch: mappedHead.fromEpoch,
47824
+ toEpoch: mappedHead.toEpoch
47825
+ }
47826
+ })}`
47827
+ );
46602
47828
  return;
46603
47829
  }
46604
47830
  const hit = {
@@ -46613,6 +47839,41 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
46613
47839
  mappedPos: hit.pos
46614
47840
  });
46615
47841
  __privateMethod(this, _PresentationEditor_instances, updateSelectionDebugHud_fn).call(this);
47842
+ const anchor = __privateGet(this, _dragAnchor);
47843
+ const head = hit.pos;
47844
+ const { selAnchor, selHead } = __privateMethod(this, _PresentationEditor_instances, calculateExtendedSelection_fn).call(this, anchor, head, __privateGet(this, _dragExtensionMode));
47845
+ debugLog(
47846
+ "verbose",
47847
+ `Drag selection update ${JSON.stringify({
47848
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y },
47849
+ prevPointer,
47850
+ rawHit: {
47851
+ pos: rawHit.pos,
47852
+ pageIndex: rawHit.pageIndex,
47853
+ blockId: rawHit.blockId,
47854
+ lineIndex: rawHit.lineIndex,
47855
+ layoutEpoch: rawHit.layoutEpoch
47856
+ },
47857
+ prevRawHit: prevRawHit ? {
47858
+ pos: prevRawHit.pos,
47859
+ pageIndex: prevRawHit.pageIndex,
47860
+ blockId: prevRawHit.blockId,
47861
+ lineIndex: prevRawHit.lineIndex,
47862
+ layoutEpoch: prevRawHit.layoutEpoch
47863
+ } : null,
47864
+ mappedHead: { pos: mappedHead.pos, fromEpoch: mappedHead.fromEpoch, toEpoch: mappedHead.toEpoch },
47865
+ hit: { pos: hit.pos, pageIndex: hit.pageIndex, layoutEpoch: hit.layoutEpoch },
47866
+ anchor,
47867
+ head,
47868
+ selAnchor,
47869
+ selHead,
47870
+ direction: head >= anchor ? "down" : "up",
47871
+ selectionDirection: selHead >= selAnchor ? "down" : "up",
47872
+ extensionMode: __privateGet(this, _dragExtensionMode),
47873
+ hitSource: pageMounted ? "dom" : "geometry",
47874
+ pageMounted
47875
+ })}`
47876
+ );
46616
47877
  const currentTableHit = __privateMethod(this, _PresentationEditor_instances, hitTestTable_fn).call(this, normalized.x, normalized.y);
46617
47878
  const shouldUseCellSel = __privateMethod(this, _PresentationEditor_instances, shouldUseCellSelection_fn).call(this, currentTableHit);
46618
47879
  if (shouldUseCellSel && __privateGet(this, _cellAnchor)) {
@@ -46647,9 +47908,6 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
46647
47908
  return;
46648
47909
  }
46649
47910
  }
46650
- const anchor = __privateGet(this, _dragAnchor);
46651
- const head = hit.pos;
46652
- const { selAnchor, selHead } = __privateMethod(this, _PresentationEditor_instances, calculateExtendedSelection_fn).call(this, anchor, head, __privateGet(this, _dragExtensionMode));
46653
47911
  try {
46654
47912
  const tr = __privateGet(this, _editor3).state.tr.setSelection(TextSelection.create(__privateGet(this, _editor3).state.doc, selAnchor, selHead));
46655
47913
  __privateGet(this, _editor3).view?.dispatch(tr);
@@ -47044,6 +48302,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
47044
48302
  editorProps: normalizedEditorProps,
47045
48303
  documentMode: __privateGet(this, _documentMode)
47046
48304
  }));
48305
+ __privateMethod(this, _PresentationEditor_instances, wrapHiddenEditorFocus_fn).call(this);
47047
48306
  __privateGet(this, _editor3).presentationEditor = this;
47048
48307
  __privateGet(this, _editor3)._presentationEditor = this;
47049
48308
  __privateMethod(this, _PresentationEditor_instances, syncHiddenEditorA11yAttributes_fn).call(this);
@@ -48017,7 +49276,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
48017
49276
  * Safe to call during partial initialization.
48018
49277
  */
48019
49278
  destroy() {
48020
- var _a;
49279
+ var _a2;
48021
49280
  if (__privateGet(this, _rafHandle2) != null) {
48022
49281
  safeCleanup(() => {
48023
49282
  const win = __privateGet(this, _visibleHost)?.ownerDocument?.defaultView ?? window;
@@ -48089,7 +49348,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
48089
49348
  __privateSet(this, _activeHeaderFooterEditor, null);
48090
49349
  __privateSet(this, _domPainter, null);
48091
49350
  __privateSet(this, _pageGeometryHelper, null);
48092
- (_a = __privateGet(this, _dragHandlerCleanup)) == null ? void 0 : _a.call(this);
49351
+ (_a2 = __privateGet(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
48093
49352
  __privateSet(this, _dragHandlerCleanup, null);
48094
49353
  __privateGet(this, _selectionOverlay2)?.remove();
48095
49354
  __privateGet(this, _painterHost)?.remove();
@@ -48243,6 +49502,94 @@ _scrollTimeout = new WeakMap();
48243
49502
  _lastRemoteCursorRenderTime = new WeakMap();
48244
49503
  _remoteCursorThrottleTimeout = new WeakMap();
48245
49504
  _PresentationEditor_instances = new WeakSet();
49505
+ /**
49506
+ * Wraps the hidden editor's focus method to prevent unwanted scrolling when it receives focus.
49507
+ *
49508
+ * The hidden ProseMirror editor is positioned off-screen but must remain focusable for
49509
+ * accessibility. When it receives focus, browsers may attempt to scroll it into view,
49510
+ * disrupting the user's viewport position. This method wraps the view's focus function
49511
+ * to prevent that scroll behavior using multiple fallback strategies.
49512
+ *
49513
+ * @remarks
49514
+ * **Why this exists:**
49515
+ * - The hidden editor provides semantic document structure for screen readers
49516
+ * - It must be focusable, but is positioned off-screen with `left: -9999px`
49517
+ * - Some browsers scroll to bring focused elements into view, breaking the user experience
49518
+ * - This wrapper prevents that scroll while maintaining focus behavior
49519
+ *
49520
+ * **Fallback strategies (in order):**
49521
+ * 1. Try `view.dom.focus({ preventScroll: true })` - the standard approach
49522
+ * 2. If that fails, try `view.dom.focus()` without options and restore scroll position
49523
+ * 3. If both fail, call the original ProseMirror focus method as last resort
49524
+ * 4. Always restore scroll position if it changed during any focus attempt
49525
+ *
49526
+ * **Idempotency:**
49527
+ * - Safe to call multiple times - checks `__sdPreventScrollFocus` flag to avoid re-wrapping
49528
+ * - The flag is set on the view object after first successful wrap
49529
+ *
49530
+ * **Test awareness:**
49531
+ * - Skips wrapping if the focus function has a `mock` property (Vitest/Jest mocks)
49532
+ * - Prevents interference with test assertions and mock function tracking
49533
+ */
49534
+ wrapHiddenEditorFocus_fn = function() {
49535
+ const view = __privateGet(this, _editor3)?.view;
49536
+ if (!view || !view.dom || typeof view.focus !== "function") {
49537
+ return;
49538
+ }
49539
+ const viewWithFlag = view;
49540
+ if (viewWithFlag.__sdPreventScrollFocus) {
49541
+ return;
49542
+ }
49543
+ const focusFn = view.focus;
49544
+ if (focusFn.mock) {
49545
+ return;
49546
+ }
49547
+ viewWithFlag.__sdPreventScrollFocus = true;
49548
+ const originalFocus = view.focus.bind(view);
49549
+ view.focus = () => {
49550
+ const win = __privateGet(this, _visibleHost).ownerDocument?.defaultView;
49551
+ if (!win) {
49552
+ originalFocus();
49553
+ return;
49554
+ }
49555
+ const beforeX = win.scrollX;
49556
+ const beforeY = win.scrollY;
49557
+ let focused = false;
49558
+ try {
49559
+ view.dom.focus({ preventScroll: true });
49560
+ focused = true;
49561
+ } catch (error) {
49562
+ debugLog("warn", "Hidden editor focus: preventScroll failed", {
49563
+ error: String(error),
49564
+ strategy: "preventScroll"
49565
+ });
49566
+ }
49567
+ if (!focused) {
49568
+ try {
49569
+ view.dom.focus();
49570
+ focused = true;
49571
+ } catch (error) {
49572
+ debugLog("warn", "Hidden editor focus: standard focus failed", {
49573
+ error: String(error),
49574
+ strategy: "standard"
49575
+ });
49576
+ }
49577
+ }
49578
+ if (!focused) {
49579
+ try {
49580
+ originalFocus();
49581
+ } catch (error) {
49582
+ debugLog("error", "Hidden editor focus: all strategies failed", {
49583
+ error: String(error),
49584
+ strategy: "original"
49585
+ });
49586
+ }
49587
+ }
49588
+ if (win.scrollX !== beforeX || win.scrollY !== beforeY) {
49589
+ win.scrollTo(beforeX, beforeY);
49590
+ }
49591
+ };
49592
+ };
48246
49593
  /**
48247
49594
  * Collect all comment and tracked change positions from the PM document.
48248
49595
  *
@@ -48724,8 +50071,8 @@ setupPointerHandlers_fn = function() {
48724
50071
  * coordinates to ProseMirror positions.
48725
50072
  */
48726
50073
  setupDragHandlers_fn = function() {
48727
- var _a;
48728
- (_a = __privateGet(this, _dragHandlerCleanup)) == null ? void 0 : _a.call(this);
50074
+ var _a2;
50075
+ (_a2 = __privateGet(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
48729
50076
  __privateSet(this, _dragHandlerCleanup, null);
48730
50077
  __privateSet(this, _dragHandlerCleanup, setupInternalFieldAnnotationDragHandlers({
48731
50078
  painterHost: __privateGet(this, _painterHost),
@@ -49729,10 +51076,10 @@ rebuildHeaderFooterRegions_fn = function(layout) {
49729
51076
  }
49730
51077
  }
49731
51078
  layout.pages.forEach((page, pageIndex) => {
49732
- var _a, _b;
51079
+ var _a2, _b;
49733
51080
  const margins = page.margins ?? __privateGet(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
49734
51081
  const actualPageHeight = page.size?.h ?? pageHeight;
49735
- const headerPayload = (_a = __privateGet(this, _headerDecorationProvider)) == null ? void 0 : _a.call(this, page.number, margins, page);
51082
+ const headerPayload = (_a2 = __privateGet(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, margins, page);
49736
51083
  const headerBox = __privateMethod(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "header", margins, actualPageHeight);
49737
51084
  __privateGet(this, _headerRegions).set(pageIndex, {
49738
51085
  kind: "header",
@@ -50091,8 +51438,8 @@ resolveDescriptorForRegion_fn = function(region) {
50091
51438
  }
50092
51439
  if (region.sectionType) {
50093
51440
  const descriptors2 = __privateGet(this, _headerFooterManager).getDescriptors(region.kind);
50094
- const match = descriptors2.find((entry) => entry.variant === region.sectionType);
50095
- if (match) return match;
51441
+ const match2 = descriptors2.find((entry) => entry.variant === region.sectionType);
51442
+ if (match2) return match2;
50096
51443
  }
50097
51444
  const descriptors = __privateGet(this, _headerFooterManager).getDescriptors(region.kind);
50098
51445
  if (!descriptors.length) {
@@ -50493,11 +51840,11 @@ getTrackChangesPluginState_fn = function() {
50493
51840
  computeDefaultLayoutDefaults_fn = function() {
50494
51841
  const converter = __privateGet(this, _editor3)?.converter;
50495
51842
  const pageStyles2 = converter?.pageStyles ?? {};
50496
- const size = pageStyles2.pageSize ?? {};
51843
+ const size2 = pageStyles2.pageSize ?? {};
50497
51844
  const pageMargins = pageStyles2.pageMargins ?? {};
50498
51845
  const pageSize = {
50499
- w: inchesToPx(size.width) ?? DEFAULT_PAGE_SIZE.w,
50500
- h: inchesToPx(size.height) ?? DEFAULT_PAGE_SIZE.h
51846
+ w: inchesToPx(size2.width) ?? DEFAULT_PAGE_SIZE.w,
51847
+ h: inchesToPx(size2.height) ?? DEFAULT_PAGE_SIZE.h
50501
51848
  };
50502
51849
  const margins = {
50503
51850
  top: inchesToPx(pageMargins.top) ?? DEFAULT_MARGINS.top,
@@ -51166,12 +52513,12 @@ function dropCursor(options = {}) {
51166
52513
  }
51167
52514
  class DropCursorView {
51168
52515
  constructor(editorView, options) {
51169
- var _a;
52516
+ var _a2;
51170
52517
  this.editorView = editorView;
51171
52518
  this.cursorPos = null;
51172
52519
  this.element = null;
51173
52520
  this.timeout = -1;
51174
- this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;
52521
+ this.width = (_a2 = options.width) !== null && _a2 !== void 0 ? _a2 : 1;
51175
52522
  this.color = options.color === false ? void 0 : options.color || "black";
51176
52523
  this.class = options.class;
51177
52524
  this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((name) => {
@@ -53487,7 +54834,7 @@ const Document = Node$1.create({
53487
54834
  */
53488
54835
  getDocumentStats: () => ({ editor }) => {
53489
54836
  const text = editor.getText();
53490
- const words = text.split(/\s+/).filter((word) => word.length > 0).length;
54837
+ const words = text.split(/\s+/).filter((word2) => word2.length > 0).length;
53491
54838
  const characters = text.length;
53492
54839
  const paragraphs = editor.state.doc.content.childCount;
53493
54840
  return {
@@ -53603,9 +54950,9 @@ const buildWrapTransaction = (state, ranges, runType) => {
53603
54950
  ranges.forEach(({ from: from2, to }) => {
53604
54951
  state.doc.nodesBetween(from2, to, (node, pos, parent, index2) => {
53605
54952
  if (!node.isText || !parent || parent.type === runType) return;
53606
- const match = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
53607
- if (match && !match.matchType(runType)) return;
53608
- if (!match && !parent.type.contentMatch.matchType(runType)) return;
54953
+ const match2 = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
54954
+ if (match2 && !match2.matchType(runType)) return;
54955
+ if (!match2 && !parent.type.contentMatch.matchType(runType)) return;
53609
54956
  const runProperties = decodeRPrFromMarks(node.marks);
53610
54957
  const runNode = runType.create({ runProperties }, node);
53611
54958
  replacements.push({ from: pos, to: pos + node.nodeSize, runNode });
@@ -56234,8 +57581,8 @@ const Table = Node$1.create({
56234
57581
  default: {},
56235
57582
  renderDOM({ borders }) {
56236
57583
  if (!borders) return {};
56237
- const style = Object.entries(borders).reduce((acc, [key2, { size, color }]) => {
56238
- return `${acc}border-${key2}: ${Math.ceil(size)}px solid ${color || "black"};`;
57584
+ const style = Object.entries(borders).reduce((acc, [key2, { size: size2, color }]) => {
57585
+ return `${acc}border-${key2}: ${Math.ceil(size2)}px solid ${color || "black"};`;
56239
57586
  }, "");
56240
57587
  return {
56241
57588
  style
@@ -56371,8 +57718,8 @@ const Table = Node$1.create({
56371
57718
  let resolvedTablePos = tablePos;
56372
57719
  if (typeof resolvedTablePos !== "number" && workingTable) {
56373
57720
  const tables = editor.getNodesOfType("table");
56374
- const match = workingTable ? tables.find((t) => t.node.eq(workingTable)) : tables[0];
56375
- resolvedTablePos = match?.pos ?? null;
57721
+ const match2 = workingTable ? tables.find((t) => t.node.eq(workingTable)) : tables[0];
57722
+ resolvedTablePos = match2?.pos ?? null;
56376
57723
  }
56377
57724
  if (typeof resolvedTablePos !== "number") {
56378
57725
  return false;
@@ -58070,9 +59417,9 @@ const FieldAnnotation = Node$1.create({
58070
59417
  },
58071
59418
  size: {
58072
59419
  default: null,
58073
- renderDOM: ({ size }) => {
58074
- if (!size || !size.width) return {};
58075
- const style = `width: ${size.width}px; height: ${size.height}px; overflow: hidden;`;
59420
+ renderDOM: ({ size: size2 }) => {
59421
+ if (!size2 || !size2.width) return {};
59422
+ const style = `width: ${size2.width}px; height: ${size2.height}px; overflow: hidden;`;
58076
59423
  return { style };
58077
59424
  }
58078
59425
  },
@@ -59192,7 +60539,7 @@ const generateUniqueDocPrId = (editor) => {
59192
60539
  } while (!candidate || existingIds.has(candidate));
59193
60540
  return candidate;
59194
60541
  };
59195
- async function uploadAndInsertImage({ editor, view, file, size, id }) {
60542
+ async function uploadAndInsertImage({ editor, view, file, size: size2, id }) {
59196
60543
  const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
59197
60544
  const placeholderId = id;
59198
60545
  try {
@@ -59217,7 +60564,7 @@ async function uploadAndInsertImage({ editor, view, file, size, id }) {
59217
60564
  }
59218
60565
  let imageNode = view.state.schema.nodes.image.create({
59219
60566
  src: mediaPath,
59220
- size,
60567
+ size: size2,
59221
60568
  id: docPrId,
59222
60569
  rId
59223
60570
  });
@@ -59514,7 +60861,7 @@ const getImagePositionDecorations = (state, view) => {
59514
60861
  let style = "";
59515
60862
  let className = "";
59516
60863
  const { vRelativeFrom, alignH } = node.attrs.anchorData;
59517
- const { size, padding } = node.attrs;
60864
+ const { size: size2, padding } = node.attrs;
59518
60865
  const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
59519
60866
  if (pageBreak && vRelativeFrom === "margin" && alignH) {
59520
60867
  let pageBreakPos = pageBreakPositionCache.get(pageBreak);
@@ -59534,7 +60881,7 @@ const getImagePositionDecorations = (state, view) => {
59534
60881
  const $pos = view.state.doc.resolve(pos);
59535
60882
  decorations.push(
59536
60883
  Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
59537
- style: `height: ${size.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
60884
+ style: `height: ${size2.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
59538
60885
  })
59539
60886
  );
59540
60887
  }
@@ -59547,8 +60894,8 @@ const getImagePositionDecorations = (state, view) => {
59547
60894
  } else {
59548
60895
  paddingHorizontal = parseInt(padding[alignH]) || 0;
59549
60896
  }
59550
- imageBlock.style.width = size.width + paddingHorizontal + "px";
59551
- imageBlock.style.height = size.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
60897
+ imageBlock.style.width = size2.width + paddingHorizontal + "px";
60898
+ imageBlock.style.height = size2.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
59552
60899
  decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
59553
60900
  decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style, class: className }));
59554
60901
  }
@@ -59762,9 +61109,9 @@ const Image = Node$1.create({
59762
61109
  },
59763
61110
  size: {
59764
61111
  default: {},
59765
- renderDOM: ({ size, shouldStretch }) => {
61112
+ renderDOM: ({ size: size2, shouldStretch }) => {
59766
61113
  let style = "";
59767
- let { width, height } = size ?? {};
61114
+ let { width, height } = size2 ?? {};
59768
61115
  if (width) style += `width: ${width}px;`;
59769
61116
  if (height && shouldStretch) {
59770
61117
  style += `height: ${height}px; object-fit: fill;`;
@@ -59809,7 +61156,7 @@ const Image = Node$1.create({
59809
61156
  },
59810
61157
  renderDOM({ node, htmlAttributes }) {
59811
61158
  const { wrap, marginOffset } = getNormalizedImageAttrs(node.attrs);
59812
- const { anchorData, padding, transformData = {}, size = { width: 0, height: 0 } } = node.attrs;
61159
+ const { anchorData, padding, transformData = {}, size: size2 = { width: 0, height: 0 } } = node.attrs;
59813
61160
  const margin = {
59814
61161
  left: 0,
59815
61162
  right: 0,
@@ -59827,7 +61174,7 @@ const Image = Node$1.create({
59827
61174
  if (padding.bottom) margin.bottom += padding.bottom;
59828
61175
  }
59829
61176
  const { rotation } = transformData;
59830
- const { height, width } = size;
61177
+ const { height, width } = size2;
59831
61178
  if (rotation && height && width) {
59832
61179
  const { horizontal, vertical } = getRotationMargins(width, height, rotation);
59833
61180
  margin.left += horizontal;
@@ -59861,7 +61208,7 @@ const Image = Node$1.create({
59861
61208
  const pageStylesData = getDataFromPageStyles({
59862
61209
  editor: this.editor,
59863
61210
  marginOffset,
59864
- size,
61211
+ size: size2,
59865
61212
  attrs
59866
61213
  });
59867
61214
  style += pageStylesData.style;
@@ -59879,7 +61226,7 @@ const Image = Node$1.create({
59879
61226
  const pageStylesData = getDataFromPageStyles({
59880
61227
  editor: this.editor,
59881
61228
  marginOffset,
59882
- size,
61229
+ size: size2,
59883
61230
  attrs
59884
61231
  });
59885
61232
  style += pageStylesData.style;
@@ -59904,8 +61251,8 @@ const Image = Node$1.create({
59904
61251
  });
59905
61252
  const originalWidth = maxX - minX;
59906
61253
  const originalHeight = maxY - minY;
59907
- const scaleWidth = Math.min(1, size.width / originalWidth);
59908
- const scaleHeight = Math.min(1, size.height / originalHeight);
61254
+ const scaleWidth = Math.min(1, size2.width / originalWidth);
61255
+ const scaleHeight = Math.min(1, size2.height / originalHeight);
59909
61256
  const verticalOffset = Math.max(0, marginOffset.top);
59910
61257
  const points = attrs.polygon.map(([x, y]) => `${horizontalOffset + x * scaleWidth}px ${verticalOffset + y * scaleHeight}px`).join(", ");
59911
61258
  style += `shape-outside: polygon(${points});`;
@@ -59969,7 +61316,7 @@ const Image = Node$1.create({
59969
61316
  let rotationHorizontal = 0;
59970
61317
  let rotationTop = 0;
59971
61318
  const { rotation: rotation2 } = transformData ?? {};
59972
- const { height: height2, width: width2 } = size ?? {};
61319
+ const { height: height2, width: width2 } = size2 ?? {};
59973
61320
  if (rotation2 && height2 && width2) {
59974
61321
  const { horizontal: horizontal2, vertical } = getRotationMargins(width2, height2, rotation2);
59975
61322
  rotationHorizontal = horizontal2;
@@ -60110,17 +61457,17 @@ const Image = Node$1.create({
60110
61457
  return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
60111
61458
  }
60112
61459
  });
60113
- const getDataFromPageStyles = ({ editor, marginOffset, size, attrs }) => {
61460
+ const getDataFromPageStyles = ({ editor, marginOffset, size: size2, attrs }) => {
60114
61461
  let style = "";
60115
61462
  let floatRight = false;
60116
61463
  let baseHorizontal = marginOffset?.horizontal || 0;
60117
61464
  const pageStyles2 = editor?.converter?.pageStyles || editor?.options.parentEditor?.converter?.pageStyles;
60118
- if (pageStyles2?.pageSize && pageStyles2?.pageMargins && size.width) {
61465
+ if (pageStyles2?.pageSize && pageStyles2?.pageMargins && size2.width) {
60119
61466
  const pageWidth = inchesToPixels(pageStyles2.pageSize.width);
60120
61467
  const leftMargin = inchesToPixels(pageStyles2.pageMargins.left);
60121
61468
  const rightMargin = inchesToPixels(pageStyles2.pageMargins.right);
60122
61469
  const contentWidth = pageWidth - leftMargin - rightMargin;
60123
- const imageWidth = size.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
61470
+ const imageWidth = size2.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
60124
61471
  const leftSpace = marginOffset.horizontal;
60125
61472
  const rightSpace = contentWidth - leftSpace - imageWidth;
60126
61473
  if (rightSpace < 0) {
@@ -61905,12 +63252,12 @@ class ShapeGroupView {
61905
63252
  }
61906
63253
  createElement() {
61907
63254
  const attrs = this.node.attrs;
61908
- const { groupTransform, shapes, size, marginOffset, originalAttributes, wrap, anchorData } = attrs;
63255
+ const { groupTransform, shapes, size: size2, marginOffset, originalAttributes, wrap, anchorData } = attrs;
61909
63256
  const container = document.createElement("div");
61910
63257
  container.classList.add("sd-shape-group");
61911
63258
  container.setAttribute("data-shape-group", "");
61912
- const width = size?.width || groupTransform?.width || 300;
61913
- const height = size?.height || groupTransform?.height || 200;
63259
+ const width = size2?.width || groupTransform?.width || 300;
63260
+ const height = size2?.height || groupTransform?.height || 200;
61914
63261
  container.style.width = `${width}px`;
61915
63262
  container.style.height = `${height}px`;
61916
63263
  container.style.position = "relative";
@@ -67387,8 +68734,8 @@ class Popover {
67387
68734
  if (from2 < 1) return false;
67388
68735
  const textBefore = this.getMentionText(from2);
67389
68736
  const mentionPattern = /(?:^|\s)@[\w]*$/;
67390
- const match = textBefore.match(mentionPattern);
67391
- return match && this.state.selection.empty;
68737
+ const match2 = textBefore.match(mentionPattern);
68738
+ return match2 && this.state.selection.empty;
67392
68739
  }
67393
68740
  destroy() {
67394
68741
  this.tippyInstance.destroy();
@@ -67466,8 +68813,8 @@ class SearchQuery {
67466
68813
  let $from = state.doc.resolve(result.from);
67467
68814
  let marks = $from.marksAcross(state.doc.resolve(result.to));
67468
68815
  let ranges = [];
67469
- let frag = Fragment.empty, pos = result.from, { match } = result;
67470
- let groups = match ? getGroupIndices(match) : [[0, result.to - result.from]];
68816
+ let frag = Fragment.empty, pos = result.from, { match: match2 } = result;
68817
+ let groups = match2 ? getGroupIndices(match2) : [[0, result.to - result.from]];
67471
68818
  let replParts = parseReplacement(this.unquote(this.replace));
67472
68819
  for (let part of replParts) {
67473
68820
  if (typeof part == "string") {
@@ -67545,39 +68892,39 @@ class RegExpQuery {
67545
68892
  return scanTextblocks(state.doc, from2, to, (node, start2) => {
67546
68893
  let content = textContent(node).slice(0, Math.min(node.content.size, to - start2));
67547
68894
  this.regexp.lastIndex = from2 - start2;
67548
- let match = this.regexp.exec(content);
67549
- if (!match) return null;
67550
- const absoluteIndex = match.index;
68895
+ let match2 = this.regexp.exec(content);
68896
+ if (!match2) return null;
68897
+ const absoluteIndex = match2.index;
67551
68898
  const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
67552
- const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match[0].length);
67553
- return { from: fromPos, to: toPos, match, matchStart: start2 };
68899
+ const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match2[0].length);
68900
+ return { from: fromPos, to: toPos, match: match2, matchStart: start2 };
67554
68901
  });
67555
68902
  }
67556
68903
  findPrev(state, from2, to) {
67557
68904
  return scanTextblocks(state.doc, from2, to, (node, start2) => {
67558
68905
  let content = textContent(node).slice(0, Math.min(node.content.size, from2 - start2));
67559
- let match;
68906
+ let match2;
67560
68907
  for (let off = 0; ; ) {
67561
68908
  this.regexp.lastIndex = off;
67562
68909
  let next = this.regexp.exec(content);
67563
68910
  if (!next) break;
67564
- match = next;
68911
+ match2 = next;
67565
68912
  off = next.index + 1;
67566
68913
  }
67567
- if (!match) return null;
67568
- const absoluteIndex = match.index;
68914
+ if (!match2) return null;
68915
+ const absoluteIndex = match2.index;
67569
68916
  const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
67570
- const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match[0].length);
67571
- return { from: fromPos, to: toPos, match, matchStart: start2 };
68917
+ const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match2[0].length);
68918
+ return { from: fromPos, to: toPos, match: match2, matchStart: start2 };
67572
68919
  });
67573
68920
  }
67574
68921
  }
67575
- function getGroupIndices(match) {
67576
- if (match.indices) return match.indices;
67577
- let result = [[0, match[0].length]];
67578
- for (let i = 1, pos = 0; i < match.length; i++) {
67579
- let found = match[i] ? match[0].indexOf(match[i], pos) : -1;
67580
- result.push(found < 0 ? void 0 : [found, pos = found + match[i].length]);
68922
+ function getGroupIndices(match2) {
68923
+ if (match2.indices) return match2.indices;
68924
+ let result = [[0, match2[0].length]];
68925
+ for (let i = 1, pos = 0; i < match2.length; i++) {
68926
+ let found = match2[i] ? match2[0].indexOf(match2[i], pos) : -1;
68927
+ result.push(found < 0 ? void 0 : [found, pos = found + match2[i].length]);
67581
68928
  }
67582
68929
  return result;
67583
68930
  }
@@ -67819,8 +69166,8 @@ const Search = Extension.create({
67819
69166
  const matches = storage?.searchResults;
67820
69167
  if (!matches?.length) return null;
67821
69168
  const decorations = matches.map(
67822
- (match) => Decoration.inline(match.from, match.to, {
67823
- id: `search-match-${match.id}`
69169
+ (match2) => Decoration.inline(match2.from, match2.to, {
69170
+ id: `search-match-${match2.id}`
67824
69171
  })
67825
69172
  );
67826
69173
  return DecorationSet.create(state.doc, decorations);
@@ -67924,10 +69271,10 @@ const Search = Extension.create({
67924
69271
  * editor.commands.goToSearchResult(searchResults[3])
67925
69272
  * @note Scrolls to match and selects it
67926
69273
  */
67927
- goToSearchResult: (match) => (
69274
+ goToSearchResult: (match2) => (
67928
69275
  /** @returns {boolean} */
67929
69276
  ({ state, dispatch, editor }) => {
67930
- const { from: from2, to } = match;
69277
+ const { from: from2, to } = match2;
67931
69278
  editor.view.focus();
67932
69279
  const tr = state.tr.setSelection(TextSelection.create(state.doc, from2, to)).scrollIntoView();
67933
69280
  dispatch(tr);