@harbour-enterprises/superdoc 0.12.36 → 0.12.37-next.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 (72) hide show
  1. package/dist/chunks/{eventemitter3-Dq2TEegt.es.js → eventemitter3-BrspJk8q.es.js} +1 -1
  2. package/dist/chunks/{eventemitter3-DuScojUH.cjs → eventemitter3-DfVviFzP.cjs} +1 -1
  3. package/dist/chunks/{index-CMBtuT02.cjs → index-B4J7wgs6.cjs} +2 -2
  4. package/dist/chunks/{index-B1MhwjTC.cjs → index-Cdsq63Xq.cjs} +4 -4
  5. package/dist/chunks/{index-SKpROzLW.es.js → index-Diu6UKHt.es.js} +4 -4
  6. package/dist/chunks/{index-BrSjd1Id.es.js → index-Hr3Um-Bg.es.js} +2 -2
  7. package/dist/chunks/{jszip-Bwu_om3F.cjs → jszip-BTAcmbVg.cjs} +1 -1
  8. package/dist/chunks/{jszip-BmWWPxfF.es.js → jszip-DckFs3A7.es.js} +1 -1
  9. package/dist/chunks/{super-editor.es-akFFn4Ld.cjs → super-editor.es-3IGIxgjF.cjs} +2139 -422
  10. package/dist/chunks/{super-editor.es-BtKVLpiq.es.js → super-editor.es-WrgX5vxB.es.js} +2139 -422
  11. package/dist/chunks/{url-DuggQ5JR.cjs → url-BIzg4y2i.cjs} +2 -2
  12. package/dist/chunks/{url-CAZQTNP3.es.js → url-CHayXMZH.es.js} +2 -2
  13. package/dist/chunks/{vue-IIIZMHTg.es.js → vue-Bi1uWinj.es.js} +17 -11
  14. package/dist/chunks/{vue-DPZkajuO.cjs → vue-HIY1g7dm.cjs} +17 -11
  15. package/dist/chunks/{xml-js-B7Vccv2s.cjs → xml-js-BjqmFOSP.cjs} +2 -2
  16. package/dist/chunks/{xml-js-BV-kCPOA.es.js → xml-js-CfClL-1b.es.js} +2 -2
  17. package/dist/core/SuperDoc.d.ts +0 -6
  18. package/dist/core/SuperDoc.d.ts.map +1 -1
  19. package/dist/core/collaboration/collaboration.d.ts +0 -9
  20. package/dist/core/collaboration/collaboration.d.ts.map +1 -1
  21. package/dist/core/collaboration/helpers.d.ts.map +1 -1
  22. package/dist/style.css +112 -7
  23. package/dist/super-editor/ai-writer.es.js +2 -2
  24. package/dist/super-editor/chunks/{converter-BSl_E2ED.js → converter-RpLHCUPf.js} +109 -10
  25. package/dist/super-editor/chunks/{docx-zipper-USmuqzmo.js → docx-zipper-V5sLSr7T.js} +1 -1
  26. package/dist/super-editor/chunks/{editor-C0hNf44Q.js → editor-CAT1dxaK.js} +2103 -350
  27. package/dist/super-editor/chunks/{toolbar-IN0IJC2L.js → toolbar-Cts0XR5V.js} +2 -2
  28. package/dist/super-editor/components/pagination-helpers.d.ts.map +1 -1
  29. package/dist/super-editor/converter.es.js +1 -1
  30. package/dist/super-editor/core/Attribute.d.ts +2 -2
  31. package/dist/super-editor/core/Editor.d.ts.map +1 -1
  32. package/dist/super-editor/core/InputRule.d.ts +7 -0
  33. package/dist/super-editor/core/InputRule.d.ts.map +1 -1
  34. package/dist/super-editor/core/Schema.d.ts +2 -2
  35. package/dist/super-editor/core/helpers/findWordBounds.d.ts +5 -0
  36. package/dist/super-editor/core/helpers/findWordBounds.d.ts.map +1 -0
  37. package/dist/super-editor/core/helpers/setWordSelection.d.ts +2 -0
  38. package/dist/super-editor/core/helpers/setWordSelection.d.ts.map +1 -0
  39. package/dist/super-editor/core/inputRules/docx-paste/docx-paste.d.ts.map +1 -1
  40. package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
  41. package/dist/super-editor/core/super-converter/v2/importer/autoPageNumberImporter.d.ts.map +1 -1
  42. package/dist/super-editor/core/super-converter/v2/importer/listImporter.d.ts.map +1 -1
  43. package/dist/super-editor/docx-zipper.es.js +2 -2
  44. package/dist/super-editor/editor.es.js +3 -3
  45. package/dist/super-editor/extensions/field-annotation/FieldAnnotationView.d.ts.map +1 -1
  46. package/dist/super-editor/extensions/field-annotation/field-annotation.d.ts.map +1 -1
  47. package/dist/super-editor/extensions/image/imageHelpers/imagePositionPlugin.d.ts.map +1 -1
  48. package/dist/super-editor/extensions/image/imageHelpers/index.d.ts +1 -0
  49. package/dist/super-editor/extensions/image/imageHelpers/processUploadedImage.d.ts.map +1 -1
  50. package/dist/super-editor/extensions/image/index.d.ts +1 -0
  51. package/dist/super-editor/extensions/index.d.ts +2 -1
  52. package/dist/super-editor/extensions/index.d.ts.map +1 -1
  53. package/dist/super-editor/extensions/noderesizer/index.d.ts +2 -0
  54. package/dist/super-editor/extensions/noderesizer/index.d.ts.map +1 -0
  55. package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts +7 -0
  56. package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts.map +1 -0
  57. package/dist/super-editor/extensions/page-number/page-number.d.ts +10 -0
  58. package/dist/super-editor/extensions/page-number/page-number.d.ts.map +1 -1
  59. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +2 -1
  60. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
  61. package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
  62. package/dist/super-editor/file-zipper.es.js +1 -1
  63. package/dist/super-editor/style.css +112 -7
  64. package/dist/super-editor/super-editor.es.js +8 -142
  65. package/dist/super-editor/toolbar.es.js +2 -2
  66. package/dist/super-editor.cjs +2 -2
  67. package/dist/super-editor.es.js +2 -2
  68. package/dist/superdoc.cjs +1587 -366
  69. package/dist/superdoc.es.js +1572 -367
  70. package/dist/superdoc.umd.js +3697 -774
  71. package/dist/superdoc.umd.js.map +1 -1
  72. package/package.json +3 -2
@@ -9,12 +9,12 @@ 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, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn;
12
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
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, c as callOrGet, i as isEmptyObject, S as Schema$1, T as TextSelection, b as canSplit, l as liftTarget, A as AllSelection, d as canJoin, j as joinPoint, N as NodeSelection, r as replaceStep$1, e as Selection, F as Fragment, R as ReplaceAroundStep, f as Slice, o as objectIncludes, g as deleteProps, D as DOMParser$1, h as ReplaceStep, k as NodeRange, m as findWrapping, n as isMacOS, p as isIOS, q as generateDocxRandomId, s as minMax, t as generateRandom32BitHex, u as DOMSerializer, v as Mark$1, w as dropPoint, x as process$1, B as Buffer2, y as isRegExp, z as TrackDeleteMarkName, C as TrackInsertMarkName, E as v4, G as TrackFormatMarkName, H as comments_module_events, I as AddMarkStep, J as RemoveMarkStep, K as twipsToLines, L as pixelsToTwips, O as SuperConverter, Q as EditorState, U as hasSomeParentWithClass, V as parseSizeUnit, W as getLineHeightValueString, X as toKebabCase, Y as kebabCase, Z as getColStyleDeclaration, _ as SelectionRange, $ as Transform, a0 as createColGroup } from "./converter-BSl_E2ED.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, i as isEmptyObject, S as Schema$1, T as TextSelection, b as canSplit, l as liftTarget, A as AllSelection, d as canJoin, j as joinPoint, N as NodeSelection, r as replaceStep$1, e as Selection, F as Fragment, R as ReplaceAroundStep, f as Slice, o as objectIncludes, g as deleteProps, D as DOMParser$1, h as ReplaceStep, k as NodeRange, m as findWrapping, n as isMacOS, p as isIOS, q as generateDocxRandomId, s as minMax, t as generateRandom32BitHex, u as DOMSerializer, v as Mark$1, w as dropPoint, x as process$1, B as Buffer2, y as isRegExp, z as TrackDeleteMarkName, C as TrackInsertMarkName, E as v4, G as TrackFormatMarkName, H as comments_module_events, I as AddMarkStep, J as RemoveMarkStep, K as twipsToLines, L as pixelsToTwips, O as SuperConverter, Q as EditorState, U as hasSomeParentWithClass, V as parseSizeUnit, W as getLineHeightValueString, X as toKebabCase, Y as kebabCase, Z as getColStyleDeclaration, _ as SelectionRange, $ as Transform, a0 as createColGroup } from "./converter-RpLHCUPf.js";
16
16
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
17
- import { D as DocxZipper } from "./docx-zipper-USmuqzmo.js";
17
+ import { D as DocxZipper } from "./docx-zipper-V5sLSr7T.js";
18
18
  function getMarksFromSelection(state) {
19
19
  const { from: from2, to, empty: empty2 } = state.selection;
20
20
  const marks = [];
@@ -4281,6 +4281,7 @@ const isEquivalentPosition = function(node, off, targetNode, targetOff) {
4281
4281
  };
4282
4282
  const atomElements = /^(img|br|input|textarea|hr)$/i;
4283
4283
  function scanFor(node, off, targetNode, targetOff, dir) {
4284
+ var _a;
4284
4285
  for (; ; ) {
4285
4286
  if (node == targetNode && off == targetOff)
4286
4287
  return true;
@@ -4291,10 +4292,16 @@ function scanFor(node, off, targetNode, targetOff, dir) {
4291
4292
  off = domIndex(node) + (dir < 0 ? 0 : 1);
4292
4293
  node = parent;
4293
4294
  } else if (node.nodeType == 1) {
4294
- node = node.childNodes[off + (dir < 0 ? -1 : 0)];
4295
- if (node.contentEditable == "false")
4296
- return false;
4297
- off = dir < 0 ? nodeSize(node) : 0;
4295
+ let child = node.childNodes[off + (dir < 0 ? -1 : 0)];
4296
+ if (child.nodeType == 1 && child.contentEditable == "false") {
4297
+ if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection)
4298
+ off += dir;
4299
+ else
4300
+ return false;
4301
+ } else {
4302
+ node = child;
4303
+ off = dir < 0 ? nodeSize(node) : 0;
4304
+ }
4298
4305
  } else {
4299
4306
  return false;
4300
4307
  }
@@ -4423,7 +4430,7 @@ function windowRect(doc2) {
4423
4430
  bottom: doc2.documentElement.clientHeight
4424
4431
  };
4425
4432
  }
4426
- function getSide(value, side) {
4433
+ function getSide$1(value, side) {
4427
4434
  return typeof value == "number" ? value : value[side];
4428
4435
  }
4429
4436
  function clientRect(node) {
@@ -4451,14 +4458,14 @@ function scrollRectIntoView(view, rect, startDOM) {
4451
4458
  let atTop = elt == doc2.body;
4452
4459
  let bounding = atTop ? windowRect(doc2) : clientRect(elt);
4453
4460
  let moveX = 0, moveY = 0;
4454
- if (rect.top < bounding.top + getSide(scrollThreshold, "top"))
4455
- moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top"));
4456
- else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom"))
4457
- moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom");
4458
- if (rect.left < bounding.left + getSide(scrollThreshold, "left"))
4459
- moveX = -(bounding.left - rect.left + getSide(scrollMargin, "left"));
4460
- else if (rect.right > bounding.right - getSide(scrollThreshold, "right"))
4461
- moveX = rect.right - bounding.right + getSide(scrollMargin, "right");
4461
+ if (rect.top < bounding.top + getSide$1(scrollThreshold, "top"))
4462
+ moveY = -(bounding.top - rect.top + getSide$1(scrollMargin, "top"));
4463
+ else if (rect.bottom > bounding.bottom - getSide$1(scrollThreshold, "bottom"))
4464
+ moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide$1(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide$1(scrollMargin, "bottom");
4465
+ if (rect.left < bounding.left + getSide$1(scrollThreshold, "left"))
4466
+ moveX = -(bounding.left - rect.left + getSide$1(scrollMargin, "left"));
4467
+ else if (rect.right > bounding.right - getSide$1(scrollThreshold, "right"))
4468
+ moveX = rect.right - bounding.right + getSide$1(scrollMargin, "right");
4462
4469
  if (moveX || moveY) {
4463
4470
  if (atTop) {
4464
4471
  doc2.defaultView.scrollBy(moveX, moveY);
@@ -5253,6 +5260,9 @@ class ViewDesc {
5253
5260
  get ignoreForCoords() {
5254
5261
  return false;
5255
5262
  }
5263
+ get ignoreForSelection() {
5264
+ return false;
5265
+ }
5256
5266
  isText(text) {
5257
5267
  return false;
5258
5268
  }
@@ -5301,6 +5311,9 @@ class WidgetViewDesc extends ViewDesc {
5301
5311
  get domAtom() {
5302
5312
  return true;
5303
5313
  }
5314
+ get ignoreForSelection() {
5315
+ return !!this.widget.type.spec.relaxedSide;
5316
+ }
5304
5317
  get side() {
5305
5318
  return this.widget.type.side;
5306
5319
  }
@@ -7081,8 +7094,9 @@ editHandlers.keypress = (view, _event) => {
7081
7094
  let sel = view.state.selection;
7082
7095
  if (!(sel instanceof TextSelection) || !sel.$from.sameParent(sel.$to)) {
7083
7096
  let text = String.fromCharCode(event.charCode);
7084
- if (!/[\r\n]/.test(text) && !view.someProp("handleTextInput", (f) => f(view, sel.$from.pos, sel.$to.pos, text)))
7085
- view.dispatch(view.state.tr.insertText(text).scrollIntoView());
7097
+ let deflt = () => view.state.tr.insertText(text).scrollIntoView();
7098
+ if (!/[\r\n]/.test(text) && !view.someProp("handleTextInput", (f) => f(view, sel.$from.pos, sel.$to.pos, text, deflt)))
7099
+ view.dispatch(deflt());
7086
7100
  event.preventDefault();
7087
7101
  }
7088
7102
  };
@@ -8654,14 +8668,14 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
8654
8668
  if (newSel && !view.state.selection.eq(newSel)) {
8655
8669
  if (chrome && android && view.input.lastKeyCode === 13 && Date.now() - 100 < view.input.lastKeyCodeTime && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter"))))
8656
8670
  return;
8657
- let tr2 = view.state.tr.setSelection(newSel);
8671
+ let tr = view.state.tr.setSelection(newSel);
8658
8672
  if (origin == "pointer")
8659
- tr2.setMeta("pointer", true);
8673
+ tr.setMeta("pointer", true);
8660
8674
  else if (origin == "key")
8661
- tr2.scrollIntoView();
8675
+ tr.scrollIntoView();
8662
8676
  if (compositionID)
8663
- tr2.setMeta("composition", compositionID);
8664
- view.dispatch(tr2);
8677
+ tr.setMeta("composition", compositionID);
8678
+ view.dispatch(tr);
8665
8679
  }
8666
8680
  return;
8667
8681
  }
@@ -8695,10 +8709,10 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
8695
8709
  if (parse.sel) {
8696
8710
  let sel2 = resolveSelection(view, view.state.doc, parse.sel);
8697
8711
  if (sel2 && !sel2.eq(view.state.selection)) {
8698
- let tr2 = view.state.tr.setSelection(sel2);
8712
+ let tr = view.state.tr.setSelection(sel2);
8699
8713
  if (compositionID)
8700
- tr2.setMeta("composition", compositionID);
8701
- view.dispatch(tr2);
8714
+ tr.setMeta("composition", compositionID);
8715
+ view.dispatch(tr);
8702
8716
  }
8703
8717
  }
8704
8718
  return;
@@ -8743,43 +8757,48 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
8743
8757
  }, 20);
8744
8758
  }
8745
8759
  let chFrom = change.start, chTo = change.endA;
8746
- let tr, storedMarks, markChange;
8760
+ let mkTr = (base2) => {
8761
+ let tr = base2 || view.state.tr.replace(chFrom, chTo, parse.doc.slice(change.start - parse.from, change.endB - parse.from));
8762
+ if (parse.sel) {
8763
+ let sel2 = resolveSelection(view, tr.doc, parse.sel);
8764
+ if (sel2 && !(chrome && view.composing && sel2.empty && (change.start != change.endB || view.input.lastChromeDelete < Date.now() - 100) && (sel2.head == chFrom || sel2.head == tr.mapping.map(chTo) - 1) || ie$1 && sel2.empty && sel2.head == chFrom))
8765
+ tr.setSelection(sel2);
8766
+ }
8767
+ if (compositionID)
8768
+ tr.setMeta("composition", compositionID);
8769
+ return tr.scrollIntoView();
8770
+ };
8771
+ let markChange;
8747
8772
  if (inlineChange) {
8748
8773
  if ($from.pos == $to.pos) {
8749
8774
  if (ie$1 && ie_version <= 11 && $from.parentOffset == 0) {
8750
8775
  view.domObserver.suppressSelectionUpdates();
8751
8776
  setTimeout(() => selectionToDOM(view), 20);
8752
8777
  }
8753
- tr = view.state.tr.delete(chFrom, chTo);
8754
- storedMarks = doc2.resolve(change.start).marksAcross(doc2.resolve(change.endA));
8778
+ let tr = mkTr(view.state.tr.delete(chFrom, chTo));
8779
+ let marks = doc2.resolve(change.start).marksAcross(doc2.resolve(change.endA));
8780
+ if (marks)
8781
+ tr.ensureMarks(marks);
8782
+ view.dispatch(tr);
8755
8783
  } else if (
8756
8784
  // Adding or removing a mark
8757
8785
  change.endA == change.endB && (markChange = isMarkChange($from.parent.content.cut($from.parentOffset, $to.parentOffset), $fromA.parent.content.cut($fromA.parentOffset, change.endA - $fromA.start())))
8758
8786
  ) {
8759
- tr = view.state.tr;
8787
+ let tr = mkTr(view.state.tr);
8760
8788
  if (markChange.type == "add")
8761
8789
  tr.addMark(chFrom, chTo, markChange.mark);
8762
8790
  else
8763
8791
  tr.removeMark(chFrom, chTo, markChange.mark);
8792
+ view.dispatch(tr);
8764
8793
  } else if ($from.parent.child($from.index()).isText && $from.index() == $to.index() - ($to.textOffset ? 0 : 1)) {
8765
8794
  let text = $from.parent.textBetween($from.parentOffset, $to.parentOffset);
8766
- if (view.someProp("handleTextInput", (f) => f(view, chFrom, chTo, text)))
8767
- return;
8768
- tr = view.state.tr.insertText(text, chFrom, chTo);
8795
+ let deflt = () => mkTr(view.state.tr.insertText(text, chFrom, chTo));
8796
+ if (!view.someProp("handleTextInput", (f) => f(view, chFrom, chTo, text, deflt)))
8797
+ view.dispatch(deflt());
8769
8798
  }
8799
+ } else {
8800
+ view.dispatch(mkTr());
8770
8801
  }
8771
- if (!tr)
8772
- tr = view.state.tr.replace(chFrom, chTo, parse.doc.slice(change.start - parse.from, change.endB - parse.from));
8773
- if (parse.sel) {
8774
- let sel2 = resolveSelection(view, tr.doc, parse.sel);
8775
- if (sel2 && !(chrome && view.composing && sel2.empty && (change.start != change.endB || view.input.lastChromeDelete < Date.now() - 100) && (sel2.head == chFrom || sel2.head == tr.mapping.map(chTo) - 1) || ie$1 && sel2.empty && sel2.head == chFrom))
8776
- tr.setSelection(sel2);
8777
- }
8778
- if (storedMarks)
8779
- tr.ensureMarks(storedMarks);
8780
- if (compositionID)
8781
- tr.setMeta("composition", compositionID);
8782
- view.dispatch(tr.scrollIntoView());
8783
8802
  }
8784
8803
  function resolveSelection(view, doc2, parsedSel) {
8785
8804
  if (Math.max(parsedSel.anchor, parsedSel.head) > doc2.content.size)
@@ -9301,22 +9320,6 @@ class EditorView {
9301
9320
  return dispatchEvent(this, event);
9302
9321
  }
9303
9322
  /**
9304
- Dispatch a transaction. Will call
9305
- [`dispatchTransaction`](https://prosemirror.net/docs/ref/#view.DirectEditorProps.dispatchTransaction)
9306
- when given, and otherwise defaults to applying the transaction to
9307
- the current state and calling
9308
- [`updateState`](https://prosemirror.net/docs/ref/#view.EditorView.updateState) with the result.
9309
- This method is bound to the view instance, so that it can be
9310
- easily passed around.
9311
- */
9312
- dispatch(tr) {
9313
- let dispatchTransaction = this._props.dispatchTransaction;
9314
- if (dispatchTransaction)
9315
- dispatchTransaction.call(this, tr);
9316
- else
9317
- this.updateState(this.state.apply(tr));
9318
- }
9319
- /**
9320
9323
  @internal
9321
9324
  */
9322
9325
  domSelectionRange() {
@@ -9332,6 +9335,13 @@ class EditorView {
9332
9335
  return this.root.getSelection();
9333
9336
  }
9334
9337
  }
9338
+ EditorView.prototype.dispatch = function(tr) {
9339
+ let dispatchTransaction = this._props.dispatchTransaction;
9340
+ if (dispatchTransaction)
9341
+ dispatchTransaction.call(this, tr);
9342
+ else
9343
+ this.updateState(this.state.apply(tr));
9344
+ };
9335
9345
  function computeDocDeco(view) {
9336
9346
  let attrs = /* @__PURE__ */ Object.create(null);
9337
9347
  attrs.class = "ProseMirror";
@@ -9397,10 +9407,10 @@ function checkStateComponent(plugin) {
9397
9407
  if (plugin.spec.state || plugin.spec.filterTransaction || plugin.spec.appendTransaction)
9398
9408
  throw new RangeError("Plugins passed directly to the view must not have a state component");
9399
9409
  }
9400
- const floor = Math.floor;
9410
+ const floor$1 = Math.floor;
9401
9411
  const abs = Math.abs;
9402
- const min$1 = (a, b) => a < b ? a : b;
9403
- const max$1 = (a, b) => a > b ? a : b;
9412
+ const min$2 = (a, b) => a < b ? a : b;
9413
+ const max$2 = (a, b) => a > b ? a : b;
9404
9414
  const isNegativeZero = (n) => n !== 0 ? n < 0 : 1 / n < 0;
9405
9415
  const BIT7 = 64;
9406
9416
  const BIT8 = 128;
@@ -9408,7 +9418,7 @@ const BIT30 = 1 << 29;
9408
9418
  const BITS6 = 63;
9409
9419
  const BITS7 = 127;
9410
9420
  const BITS31 = 2147483647;
9411
- const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
9421
+ const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor$1(num) === num);
9412
9422
  const create$2 = () => /* @__PURE__ */ new Set();
9413
9423
  const isArray = Array.isArray;
9414
9424
  const fromCharCode = String.fromCharCode;
@@ -9472,7 +9482,7 @@ const verifyLen = (encoder, len) => {
9472
9482
  const bufferLen = encoder.cbuf.length;
9473
9483
  if (bufferLen - encoder.cpos < len) {
9474
9484
  encoder.bufs.push(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos));
9475
- encoder.cbuf = new Uint8Array(max$1(bufferLen, len) * 2);
9485
+ encoder.cbuf = new Uint8Array(max$2(bufferLen, len) * 2);
9476
9486
  encoder.cpos = 0;
9477
9487
  }
9478
9488
  };
@@ -9488,7 +9498,7 @@ const write$1 = (encoder, num) => {
9488
9498
  const writeVarUint = (encoder, num) => {
9489
9499
  while (num > BITS7) {
9490
9500
  write$1(encoder, BIT8 | BITS7 & num);
9491
- num = floor(num / 128);
9501
+ num = floor$1(num / 128);
9492
9502
  }
9493
9503
  write$1(encoder, BITS7 & num);
9494
9504
  };
@@ -9498,10 +9508,10 @@ const writeVarInt = (encoder, num) => {
9498
9508
  num = -num;
9499
9509
  }
9500
9510
  write$1(encoder, (num > BITS6 ? BIT8 : 0) | (isNegative ? BIT7 : 0) | BITS6 & num);
9501
- num = floor(num / 64);
9511
+ num = floor$1(num / 64);
9502
9512
  while (num > 0) {
9503
9513
  write$1(encoder, (num > BITS7 ? BIT8 : 0) | BITS7 & num);
9504
- num = floor(num / 128);
9514
+ num = floor$1(num / 128);
9505
9515
  }
9506
9516
  };
9507
9517
  const _strBuffer = new Uint8Array(3e4);
@@ -9534,13 +9544,13 @@ utf8TextEncoder.encodeInto ? _writeVarStringNative : _writeVarStringPolyfill;
9534
9544
  const writeUint8Array = (encoder, uint8Array) => {
9535
9545
  const bufferLen = encoder.cbuf.length;
9536
9546
  const cpos = encoder.cpos;
9537
- const leftCopyLen = min$1(bufferLen - cpos, uint8Array.length);
9547
+ const leftCopyLen = min$2(bufferLen - cpos, uint8Array.length);
9538
9548
  const rightCopyLen = uint8Array.length - leftCopyLen;
9539
9549
  encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
9540
9550
  encoder.cpos += leftCopyLen;
9541
9551
  if (rightCopyLen > 0) {
9542
9552
  encoder.bufs.push(encoder.cbuf);
9543
- encoder.cbuf = new Uint8Array(max$1(bufferLen * 2, rightCopyLen));
9553
+ encoder.cbuf = new Uint8Array(max$2(bufferLen * 2, rightCopyLen));
9544
9554
  encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
9545
9555
  encoder.cpos = rightCopyLen;
9546
9556
  }
@@ -9682,7 +9692,7 @@ const ySyncPluginKey = new PluginKey("y-sync");
9682
9692
  const yUndoPluginKey = new PluginKey("y-undo");
9683
9693
  const yCursorPluginKey = new PluginKey("yjs-cursor");
9684
9694
  const rand = Math.random;
9685
- const oneOf = (arr) => arr[floor(rand() * arr.length)];
9695
+ const oneOf = (arr) => arr[floor$1(rand() * arr.length)];
9686
9696
  const undefinedToNull = (v) => v === void 0 ? null : v;
9687
9697
  class VarStoragePolyfill {
9688
9698
  constructor() {
@@ -9712,12 +9722,12 @@ try {
9712
9722
  } catch (e) {
9713
9723
  }
9714
9724
  const varStorage = _localStorage;
9715
- const isNode = typeof process$1 !== "undefined" && process$1.release && /node|io\.js/.test(process$1.release.name) && Object.prototype.toString.call(typeof process$1 !== "undefined" ? process$1 : 0) === "[object process]";
9716
- const isBrowser$1 = typeof window !== "undefined" && typeof document !== "undefined" && !isNode;
9725
+ const isNode$1 = typeof process$1 !== "undefined" && process$1.release && /node|io\.js/.test(process$1.release.name) && Object.prototype.toString.call(typeof process$1 !== "undefined" ? process$1 : 0) === "[object process]";
9726
+ const isBrowser$1 = typeof window !== "undefined" && typeof document !== "undefined" && !isNode$1;
9717
9727
  let params;
9718
9728
  const computeParams = () => {
9719
9729
  if (params === void 0) {
9720
- if (isNode) {
9730
+ if (isNode$1) {
9721
9731
  params = create();
9722
9732
  const pargs = process$1.argv;
9723
9733
  let currParamName = null;
@@ -9754,12 +9764,12 @@ const computeParams = () => {
9754
9764
  return params;
9755
9765
  };
9756
9766
  const hasParam = (name) => computeParams().has(name);
9757
- const getVariable = (name) => isNode ? undefinedToNull(process$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
9767
+ const getVariable = (name) => isNode$1 ? undefinedToNull(process$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
9758
9768
  const hasConf = (name) => hasParam("--" + name) || getVariable(name) !== null;
9759
9769
  hasConf("production");
9760
- const forceColor = isNode && isOneOf(process$1.env.FORCE_COLOR, ["true", "1", "2"]);
9770
+ const forceColor = isNode$1 && isOneOf(process$1.env.FORCE_COLOR, ["true", "1", "2"]);
9761
9771
  forceColor || !hasParam("--no-colors") && // @todo deprecate --no-colors
9762
- !hasConf("no-color") && (!isNode || process$1.stdout.isTTY) && (!isNode || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
9772
+ !hasConf("no-color") && (!isNode$1 || process$1.stdout.isTTY) && (!isNode$1 || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
9763
9773
  const doc = (
9764
9774
  /** @type {Document} */
9765
9775
  typeof document !== "undefined" ? document : {}
@@ -10268,8 +10278,8 @@ class ProsemirrorBinding {
10268
10278
  new Slice(Fragment.from(fragmentContent), 0, 0)
10269
10279
  );
10270
10280
  if (sel) {
10271
- const clampedAnchor = min$1(max$1(sel.anchor, 0), tr.doc.content.size);
10272
- const clampedHead = min$1(max$1(sel.head, 0), tr.doc.content.size);
10281
+ const clampedAnchor = min$2(max$2(sel.anchor, 0), tr.doc.content.size);
10282
+ const clampedHead = min$2(max$2(sel.head, 0), tr.doc.content.size);
10273
10283
  tr.setSelection(TextSelection.create(tr.doc, clampedAnchor, clampedHead));
10274
10284
  }
10275
10285
  this.prosemirrorView.dispatch(
@@ -10666,7 +10676,7 @@ const computeChildEqualityFactor = (ytype, pnode, meta) => {
10666
10676
  const pChildren = normalizePNodeContent(pnode);
10667
10677
  const pChildCnt = pChildren.length;
10668
10678
  const yChildCnt = yChildren.length;
10669
- const minCnt = min$1(yChildCnt, pChildCnt);
10679
+ const minCnt = min$2(yChildCnt, pChildCnt);
10670
10680
  let left2 = 0;
10671
10681
  let right2 = 0;
10672
10682
  let foundMappedChild = false;
@@ -10778,7 +10788,7 @@ const updateYFragment = (y, yDomFragment, pNode, meta) => {
10778
10788
  const pChildCnt = pChildren.length;
10779
10789
  const yChildren = yDomFragment.toArray();
10780
10790
  const yChildCnt = yChildren.length;
10781
- const minCnt = min$1(pChildCnt, yChildCnt);
10791
+ const minCnt = min$2(pChildCnt, yChildCnt);
10782
10792
  let left2 = 0;
10783
10793
  let right2 = 0;
10784
10794
  for (; left2 < minCnt; left2++) {
@@ -11151,17 +11161,17 @@ const createDecorations = (state, awareness, awarenessFilter, createCursor, crea
11151
11161
  ystate.binding.mapping
11152
11162
  );
11153
11163
  if (anchor !== null && head !== null) {
11154
- const maxsize = max$1(state.doc.content.size - 1, 0);
11155
- anchor = min$1(anchor, maxsize);
11156
- head = min$1(head, maxsize);
11164
+ const maxsize = max$2(state.doc.content.size - 1, 0);
11165
+ anchor = min$2(anchor, maxsize);
11166
+ head = min$2(head, maxsize);
11157
11167
  decorations.push(
11158
11168
  Decoration.widget(head, () => createCursor(user, clientId), {
11159
11169
  key: clientId + "",
11160
11170
  side: 10
11161
11171
  })
11162
11172
  );
11163
- const from2 = min$1(anchor, head);
11164
- const to = max$1(anchor, head);
11173
+ const from2 = min$2(anchor, head);
11174
+ const to = max$2(anchor, head);
11165
11175
  decorations.push(
11166
11176
  Decoration.inline(from2, to, createSelection(user, clientId), {
11167
11177
  inclusiveEnd: true,
@@ -11615,7 +11625,8 @@ const getTextContentFromNodes = ($from, maxMatch = 500) => {
11615
11625
  const handleDocxPaste = (html, editor, view, plugin) => {
11616
11626
  const { converter } = editor;
11617
11627
  if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin);
11618
- const cleanedHtml = convertEmToPt(html);
11628
+ let cleanedHtml = convertEmToPt(html);
11629
+ cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
11619
11630
  const tempDiv = document.createElement("div");
11620
11631
  tempDiv.innerHTML = cleanedHtml;
11621
11632
  const paragraphs = tempDiv.querySelectorAll("p");
@@ -11986,6 +11997,9 @@ const convertEmToPt = (html) => {
11986
11997
  }
11987
11998
  );
11988
11999
  };
12000
+ function cleanHtmlUnnecessaryTags(html) {
12001
+ return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/&nbsp;/gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
12002
+ }
11989
12003
  const _ExtensionService = class _ExtensionService {
11990
12004
  constructor(extensions, userExtensions, editor) {
11991
12005
  __privateAdd(this, _ExtensionService_instances);
@@ -12792,7 +12806,8 @@ const createHeaderFooterEditor = ({
12792
12806
  appendToBody = true,
12793
12807
  sectionId,
12794
12808
  type,
12795
- availableHeight
12809
+ availableHeight,
12810
+ currentPageNumber
12796
12811
  }) => {
12797
12812
  const parentStyles = editor.converter.getDocumentDefaultStyles();
12798
12813
  const { fontSizePt, typeface } = parentStyles;
@@ -12833,6 +12848,8 @@ const createHeaderFooterEditor = ({
12833
12848
  fonts: editor.options.fonts,
12834
12849
  isHeaderOrFooter: true,
12835
12850
  annotations: true,
12851
+ currentPageNumber,
12852
+ parentEditor: editor,
12836
12853
  onCreate: (evt) => setEditorToolbar(evt, editor),
12837
12854
  onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type)
12838
12855
  });
@@ -13976,9 +13993,9 @@ const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
13976
13993
  if (type.name !== "paragraph" && type.name !== "fieldAnnotation") return;
13977
13994
  child.children.forEach((inline) => {
13978
13995
  const isFieldToDelete = fieldsToDelete.includes(inline.attrs.fieldId);
13979
- const isMatchingField = inline.type.name === "fieldAnnotation" && isFieldToDelete;
13980
- const isEmpty2 = inline.childCount === 0;
13981
- if (!isEmpty2 && !isMatchingField) hasOtherNodes = true;
13996
+ const isFieldType = inline.type.name === "fieldAnnotation";
13997
+ const isMatchingField = isFieldType && isFieldToDelete;
13998
+ if (!isFieldType && !isMatchingField) hasOtherNodes = true;
13982
13999
  if (isMatchingField) matchingNodesFound += 1;
13983
14000
  });
13984
14001
  });
@@ -14180,6 +14197,25 @@ function useHighContrastMode() {
14180
14197
  setHighContrastMode
14181
14198
  };
14182
14199
  }
14200
+ const findWordBounds = (doc2, pos) => {
14201
+ const $pos = doc2.resolve(pos);
14202
+ const parent = $pos.parent;
14203
+ const offset2 = $pos.parentOffset;
14204
+ const text = parent.textContent;
14205
+ if (!text) return { from: pos, to: pos };
14206
+ let start2 = offset2, end2 = offset2;
14207
+ while (start2 > 0 && /\w/.test(text[start2 - 1])) start2--;
14208
+ while (end2 < text.length && /\w/.test(text[end2])) end2++;
14209
+ const from2 = $pos.start() + start2;
14210
+ const to = $pos.start() + end2;
14211
+ return { from: from2, to };
14212
+ };
14213
+ const setWordSelection = (view, pos) => {
14214
+ const { state, dispatch } = view;
14215
+ const word = findWordBounds(state.doc, pos);
14216
+ const tr = state.tr.setSelection(TextSelection.create(state.doc, word.from, word.to));
14217
+ dispatch(tr);
14218
+ };
14183
14219
  const _Editor = class _Editor extends EventEmitter {
14184
14220
  /**
14185
14221
  * Create a new Editor instance
@@ -14451,6 +14487,7 @@ const _Editor = class _Editor extends EventEmitter {
14451
14487
  __privateMethod(this, _Editor_instances, initMedia_fn).call(this);
14452
14488
  const doc2 = __privateMethod(this, _Editor_instances, generatePmData_fn).call(this);
14453
14489
  const tr = this.state.tr.replaceWith(0, this.state.doc.content.size, doc2);
14490
+ tr.setMeta("replaceContent", true);
14454
14491
  this.view.dispatch(tr);
14455
14492
  }
14456
14493
  /**
@@ -14858,7 +14895,7 @@ const _Editor = class _Editor extends EventEmitter {
14858
14895
  * @returns {Object | void} Migration results
14859
14896
  */
14860
14897
  processCollaborationMigrations() {
14861
- console.debug("[checkVersionMigrations] Current editor version", "0.12.36");
14898
+ console.debug("[checkVersionMigrations] Current editor version", "0.12.37-next.2");
14862
14899
  if (!this.options.ydoc) return;
14863
14900
  const metaMap = this.options.ydoc.getMap("meta");
14864
14901
  let docVersion = metaMap.get("version");
@@ -15309,6 +15346,7 @@ createView_fn = function() {
15309
15346
  if (isHeader || isFooter) {
15310
15347
  const eventClone = new event.constructor(event.type);
15311
15348
  event.target.dispatchEvent(eventClone);
15349
+ if (this.options.isHeaderOrFooter && this.options.editable) setWordSelection(view, pos);
15312
15350
  return;
15313
15351
  }
15314
15352
  event.stopPropagation();
@@ -15319,6 +15357,7 @@ createView_fn = function() {
15319
15357
  pm.classList.remove("header-footer-edit");
15320
15358
  pm.setAttribute("aria-readonly", false);
15321
15359
  }
15360
+ setWordSelection(view, pos);
15322
15361
  }
15323
15362
  });
15324
15363
  const newState = this.state.reconfigure({
@@ -20528,7 +20567,7 @@ const Table = Node$1.create({
20528
20567
  if (!borders) return {};
20529
20568
  const style = Object.entries(borders).reduce(
20530
20569
  (acc, [key, { size, color }]) => {
20531
- return `${acc}border-${key}: ${size}px solid ${color || "black"};`;
20570
+ return `${acc}border-${key}: ${Math.ceil(size)}px solid ${color || "black"};`;
20532
20571
  },
20533
20572
  ""
20534
20573
  );
@@ -20868,8 +20907,8 @@ const TableCell = Node$1.create({
20868
20907
  cellMargins: {
20869
20908
  renderDOM({ cellMargins }) {
20870
20909
  if (!cellMargins) return {};
20871
- const sides = ["top", "right", "bottom", "left"];
20872
- const style = sides.map((side) => {
20910
+ const sides2 = ["top", "right", "bottom", "left"];
20911
+ const style = sides2.map((side) => {
20873
20912
  const margin = cellMargins?.[side];
20874
20913
  if (margin) return `padding-${side}: ${margin}px;`;
20875
20914
  return "";
@@ -20881,11 +20920,11 @@ const TableCell = Node$1.create({
20881
20920
  default: () => createCellBorders(),
20882
20921
  renderDOM({ borders }) {
20883
20922
  if (!borders) return {};
20884
- const sides = ["top", "right", "bottom", "left"];
20885
- const style = sides.map((side) => {
20923
+ const sides2 = ["top", "right", "bottom", "left"];
20924
+ const style = sides2.map((side) => {
20886
20925
  const border = borders?.[side];
20887
20926
  if (border && border.val === "none") return `border-${side}: ${border.val};`;
20888
- if (border) return `border-${side}: ${border.size}px solid ${border.color || "black"};`;
20927
+ if (border) return `border-${side}: ${Math.ceil(border.size)}px solid ${border.color || "black"};`;
20889
20928
  return "";
20890
20929
  }).join(" ");
20891
20930
  return { style };
@@ -21111,7 +21150,7 @@ class FieldAnnotationView {
21111
21150
  }
21112
21151
  _FieldAnnotationView_instances = new WeakSet();
21113
21152
  createAnnotation_fn = function({ displayLabel } = {}) {
21114
- let { highlighted } = this.node.attrs;
21153
+ let { highlighted, rawHtml } = this.node.attrs;
21115
21154
  let annotation = document.createElement("span");
21116
21155
  annotation.classList.add(this.annotationClass);
21117
21156
  let content = document.createElement("span");
@@ -21123,7 +21162,11 @@ createAnnotation_fn = function({ displayLabel } = {}) {
21123
21162
  }
21124
21163
  annotation.append(content);
21125
21164
  let omitHighlight = highlighted === false;
21126
- let annotationStyle = [`border: 2px solid ${this.borderColor}`, `border-radius: 2px`, `padding: 1px 2px`, `box-sizing: border-box`].join(
21165
+ let styles = [`border: 2px solid ${this.borderColor}`, `border-radius: 2px`, `padding: 1px 2px`, `box-sizing: border-box`];
21166
+ if (rawHtml) {
21167
+ styles.push("font-weight: normal");
21168
+ }
21169
+ let annotationStyle = styles.join(
21127
21170
  "; "
21128
21171
  );
21129
21172
  let mergedAttrs = Attribute.mergeAttributes(this.htmlAttributes, {
@@ -21678,6 +21721,12 @@ const FieldAnnotation = Node$1.create({
21678
21721
  parseDOM: (elem) => elem.getAttribute("data-bold") === "true",
21679
21722
  renderDOM: (attrs) => {
21680
21723
  if (!attrs.bold) return {};
21724
+ if (attrs.rawHtml) {
21725
+ return {
21726
+ "data-bold": "false",
21727
+ style: "font-weight: normal"
21728
+ };
21729
+ }
21681
21730
  return {
21682
21731
  "data-bold": "true",
21683
21732
  style: "font-weight: bold"
@@ -21688,7 +21737,7 @@ const FieldAnnotation = Node$1.create({
21688
21737
  default: false,
21689
21738
  parseDOM: (elem) => elem.getAttribute("data-italic") === "true",
21690
21739
  renderDOM: (attrs) => {
21691
- if (!attrs.italic) return {};
21740
+ if (!attrs.italic || attrs.rawHtml) return {};
21692
21741
  return {
21693
21742
  "data-italic": "true",
21694
21743
  style: "font-style: italic"
@@ -21699,7 +21748,7 @@ const FieldAnnotation = Node$1.create({
21699
21748
  default: false,
21700
21749
  parseDOM: (elem) => elem.getAttribute("data-underline") === "true",
21701
21750
  renderDOM: (attrs) => {
21702
- if (!attrs.underline) return {};
21751
+ if (!attrs.underline || attrs.rawHtml) return {};
21703
21752
  return {
21704
21753
  "data-underline": "true",
21705
21754
  style: "text-decoration: underline"
@@ -21721,7 +21770,7 @@ const FieldAnnotation = Node$1.create({
21721
21770
  default: null,
21722
21771
  parseDOM: (elem) => elem.getAttribute("data-font-size") || elem.style.fontSize || null,
21723
21772
  renderDOM: (attrs) => {
21724
- if (!attrs.fontSize) return {};
21773
+ if (!attrs.fontSize || attrs.rawHtml) return {};
21725
21774
  let [value, unit] = parseSizeUnit(attrs.fontSize);
21726
21775
  if (Number.isNaN(value)) return {};
21727
21776
  unit = unit ? unit : "pt";
@@ -22363,10 +22412,7 @@ const ImagePositionPlugin = ({ editor }) => {
22363
22412
  if (shouldUpdate) {
22364
22413
  shouldUpdate = false;
22365
22414
  const decorations = getImagePositionDecorations(lastState, view3);
22366
- const updateTransaction = view3.state.tr.setMeta(
22367
- ImagePositionPluginKey,
22368
- { decorations }
22369
- );
22415
+ const updateTransaction = view3.state.tr.setMeta(ImagePositionPluginKey, { decorations });
22370
22416
  view3.dispatch(updateTransaction);
22371
22417
  }
22372
22418
  if (pagination?.isReadyToInit) {
@@ -22498,16 +22544,16 @@ const Image = Node$1.create({
22498
22544
  default: {},
22499
22545
  renderDOM: ({ size }) => {
22500
22546
  let style = "";
22501
- let { width, height } = size ?? {};
22547
+ const { width, height } = size ?? {};
22502
22548
  if (width) style += `width: ${width}px;`;
22503
- if (height) style += `height: auto;`;
22549
+ if (height) style += "height: auto;";
22504
22550
  return { style };
22505
22551
  }
22506
22552
  },
22507
22553
  padding: {
22508
22554
  default: {},
22509
22555
  renderDOM: ({ padding, marginOffset }) => {
22510
- let { left: left2 = 0, top: top2 = 0, bottom: bottom2 = 0, right: right2 = 0 } = padding ?? {};
22556
+ const { left: left2 = 0, top: top2 = 0, bottom: bottom2 = 0, right: right2 = 0 } = padding ?? {};
22511
22557
  let style = "";
22512
22558
  if (left2 && !marginOffset?.left) style += `margin-left: ${left2}px;`;
22513
22559
  if (top2 && !marginOffset?.top) style += `margin-top: ${top2}px;`;
@@ -22519,7 +22565,7 @@ const Image = Node$1.create({
22519
22565
  marginOffset: {
22520
22566
  default: {},
22521
22567
  renderDOM: ({ marginOffset }) => {
22522
- let { left: left2 = 0, top: top2 = 0 } = marginOffset ?? {};
22568
+ const { left: left2 = 0, top: top2 = 0 } = marginOffset ?? {};
22523
22569
  let style = "";
22524
22570
  if (left2) style += `margin-left: ${left2}px;`;
22525
22571
  if (top2) style += `margin-top: ${top2}px;`;
@@ -22560,6 +22606,136 @@ const Image = Node$1.create({
22560
22606
  return [ImagePlaceholderPlugin(), ImagePositionPlugin({ editor: this.editor })];
22561
22607
  }
22562
22608
  });
22609
+ const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
22610
+ const getFileOpener = () => {
22611
+ let fileInput = document.createElement("input");
22612
+ fileInput.type = "file";
22613
+ let acceptTypes = ACCEPT_IMAGE_TYPES;
22614
+ fileInput.accept = acceptTypes.join(",");
22615
+ const openFile = () => {
22616
+ return new Promise((resolve, reject) => {
22617
+ fileInput.onchange = async () => {
22618
+ const files = fileInput.files;
22619
+ if (!files) return resolve(null);
22620
+ const file = files.item(0);
22621
+ if (!file) return resolve(null);
22622
+ return resolve({ file });
22623
+ };
22624
+ fileInput.oncancel = () => resolve(null);
22625
+ fileInput.onerror = reject;
22626
+ fileInput.click();
22627
+ });
22628
+ };
22629
+ return openFile;
22630
+ };
22631
+ const handleImageUpload = (file) => {
22632
+ return new Promise((resolve, reject) => {
22633
+ let reader = new FileReader();
22634
+ reader.onload = (event) => resolve(event.target.result);
22635
+ reader.onerror = reject;
22636
+ setTimeout(() => reader.readAsDataURL(file), 250);
22637
+ });
22638
+ };
22639
+ const processUploadedImage = (fileData, editor) => {
22640
+ return new Promise((resolve, reject) => {
22641
+ const img = new window.Image();
22642
+ img.onload = () => {
22643
+ const canvas = document.createElement("canvas");
22644
+ const { width, height } = getAllowedImageDimensions(img.width, img.height, editor);
22645
+ canvas.width = width;
22646
+ canvas.height = height;
22647
+ const ctx = canvas.getContext("2d");
22648
+ ctx.drawImage(img, 0, 0, width, height);
22649
+ if (typeof fileData === "string") {
22650
+ const resizedBase64 = canvas.toDataURL();
22651
+ resolve(resizedBase64);
22652
+ } else {
22653
+ canvas.toBlob((blob) => {
22654
+ const updatedFile = new File([blob], fileData.name, {
22655
+ type: fileData.type,
22656
+ lastModified: Date.now()
22657
+ });
22658
+ resolve({ file: updatedFile, width, height });
22659
+ });
22660
+ }
22661
+ };
22662
+ img.onerror = (error) => reject(error);
22663
+ img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
22664
+ });
22665
+ };
22666
+ const getAllowedImageDimensions = (width, height, editor) => {
22667
+ const { width: maxWidth, height: maxHeight } = editor.getMaxContentSize();
22668
+ if (!maxWidth || !maxHeight) return { width, height };
22669
+ let adjustedWidth = width;
22670
+ let adjustedHeight = height;
22671
+ const aspectRatio = width / height;
22672
+ if (height > maxHeight) {
22673
+ adjustedHeight = maxHeight;
22674
+ adjustedWidth = Math.round(maxHeight * aspectRatio);
22675
+ }
22676
+ if (adjustedWidth > maxWidth) {
22677
+ adjustedWidth = maxWidth;
22678
+ adjustedHeight = Math.round(maxWidth / aspectRatio);
22679
+ }
22680
+ return { width: adjustedWidth, height: adjustedHeight };
22681
+ };
22682
+ const startImageUpload = async ({ editor, view, file }) => {
22683
+ let imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
22684
+ let fileSizeMb = (file.size / (1024 * 1024)).toFixed(4);
22685
+ if (fileSizeMb > 5) {
22686
+ window.alert("Image size must be less than 5MB");
22687
+ return;
22688
+ }
22689
+ let width;
22690
+ let height;
22691
+ try {
22692
+ const processedImageResult = await processUploadedImage(file, editor);
22693
+ width = processedImageResult.width;
22694
+ height = processedImageResult.height;
22695
+ file = processedImageResult.file;
22696
+ } catch (err) {
22697
+ console.warn("Error processing image:", err);
22698
+ return;
22699
+ }
22700
+ let id = {};
22701
+ let { tr, schema } = view.state;
22702
+ if (!tr.selection.empty) {
22703
+ tr.deleteSelection();
22704
+ }
22705
+ let imageMeta = {
22706
+ type: "add",
22707
+ pos: tr.selection.from,
22708
+ id
22709
+ };
22710
+ tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
22711
+ view.dispatch(tr);
22712
+ imageUploadHandler(file).then(
22713
+ (url) => {
22714
+ let fileName = file.name.replace(" ", "_");
22715
+ let placeholderPos = findPlaceholder(view.state, id);
22716
+ if (placeholderPos == null) {
22717
+ return;
22718
+ }
22719
+ let removeMeta = { type: "remove", id };
22720
+ let mediaPath = `word/media/${fileName}`;
22721
+ let imageNode = schema.nodes.image.create({
22722
+ src: mediaPath,
22723
+ size: { width, height }
22724
+ });
22725
+ editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
22726
+ if (editor.options.ydoc) {
22727
+ editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
22728
+ }
22729
+ view.dispatch(
22730
+ view.state.tr.replaceWith(placeholderPos, placeholderPos, imageNode).setMeta(ImagePlaceholderPluginKey, removeMeta)
22731
+ );
22732
+ },
22733
+ () => {
22734
+ let removeMeta = { type: "remove", id };
22735
+ view.dispatch(tr.setMeta(ImagePlaceholderPluginKey, removeMeta));
22736
+ }
22737
+ );
22738
+ };
22563
22739
  const BookmarkStart = Node$1.create({
22564
22740
  name: "bookmarkStart",
22565
22741
  group: "inline",
@@ -22640,32 +22816,89 @@ const PageNumber = Node$1.create({
22640
22816
  name: "page-number",
22641
22817
  group: "inline",
22642
22818
  inline: true,
22643
- content: "text*",
22819
+ atom: true,
22820
+ selectable: false,
22821
+ draggable: false,
22822
+ selectable: false,
22823
+ defining: true,
22824
+ content: "",
22644
22825
  addOptions() {
22645
22826
  return {
22646
22827
  htmlAttributes: {
22828
+ contenteditable: false,
22647
22829
  "data-id": "auto-page-number",
22648
22830
  "aria-label": "Page number node"
22649
22831
  }
22650
22832
  };
22651
22833
  },
22834
+ addAttributes() {
22835
+ return {
22836
+ marksAsAttrs: {
22837
+ default: null,
22838
+ rendered: false
22839
+ }
22840
+ };
22841
+ },
22842
+ addNodeView() {
22843
+ return ({ node, editor, getPos, decorations }) => {
22844
+ const htmlAttributes = this.options.htmlAttributes;
22845
+ return new AutoPageNumberNodeView(node, getPos, decorations, editor, htmlAttributes);
22846
+ };
22847
+ },
22652
22848
  parseDOM() {
22653
22849
  return [{ tag: 'span[data-id="auto-page-number"' }];
22654
22850
  },
22655
22851
  renderDOM({ htmlAttributes }) {
22656
- return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
22852
+ return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
22853
+ },
22854
+ addCommands() {
22855
+ return {
22856
+ addAutoPageNumber: () => ({ tr, dispatch, state, editor }) => {
22857
+ const { options } = editor;
22858
+ if (!options.isHeaderOrFooter) return false;
22859
+ const { schema } = state;
22860
+ const pageNumberType = schema?.nodes?.["page-number"];
22861
+ if (!pageNumberType) return false;
22862
+ const pageNumberNodeJSON = { type: "page-number" };
22863
+ const pageNumberNode = schema.nodeFromJSON(pageNumberNodeJSON);
22864
+ if (dispatch) {
22865
+ tr.replaceSelectionWith(pageNumberNode, false);
22866
+ tr.setMeta("forceUpdatePagination", true);
22867
+ }
22868
+ return true;
22869
+ }
22870
+ };
22871
+ },
22872
+ addShortcuts() {
22873
+ return {
22874
+ "Mod-Shift-alt-p": () => this.editor.commands.addAutoPageNumber()
22875
+ };
22657
22876
  }
22658
22877
  });
22659
22878
  const TotalPageCount = Node$1.create({
22660
22879
  name: "total-page-number",
22661
22880
  group: "inline",
22662
22881
  inline: true,
22882
+ atom: true,
22883
+ selectable: false,
22884
+ draggable: false,
22885
+ selectable: false,
22663
22886
  content: "text*",
22664
22887
  addOptions() {
22665
22888
  return {
22666
22889
  htmlAttributes: {
22890
+ contenteditable: false,
22667
22891
  "data-id": "auto-total-pages",
22668
- "aria-label": "Total page count node"
22892
+ "aria-label": "Total page count node",
22893
+ "class": "sd-editor-auto-total-pages"
22894
+ }
22895
+ };
22896
+ },
22897
+ addAttributes() {
22898
+ return {
22899
+ marksAsAttrs: {
22900
+ default: null,
22901
+ rendered: false
22669
22902
  }
22670
22903
  };
22671
22904
  },
@@ -22674,8 +22907,139 @@ const TotalPageCount = Node$1.create({
22674
22907
  },
22675
22908
  renderDOM({ htmlAttributes }) {
22676
22909
  return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
22910
+ },
22911
+ addCommands() {
22912
+ return {
22913
+ addTotalPageCount: () => ({ tr, dispatch, state, editor }) => {
22914
+ const { options } = editor;
22915
+ if (!options.isHeaderOrFooter) return false;
22916
+ const { schema } = state;
22917
+ const pageNumberType = schema.nodes?.["total-page-number"];
22918
+ if (!pageNumberType) return false;
22919
+ const currentPages = editor?.options?.parentEditor?.currentTotalPages || 1;
22920
+ const pageNumberNode = {
22921
+ type: "total-page-number",
22922
+ content: [{ type: "text", text: String(currentPages) }]
22923
+ };
22924
+ const pageNode = schema.nodeFromJSON(pageNumberNode);
22925
+ if (dispatch) {
22926
+ tr.replaceSelectionWith(pageNode, false);
22927
+ }
22928
+ return true;
22929
+ }
22930
+ };
22931
+ },
22932
+ addShortcuts() {
22933
+ return {
22934
+ "Mod-Shift-alt-c": () => this.editor.commands.addTotalPageCount()
22935
+ };
22677
22936
  }
22678
22937
  });
22938
+ class AutoPageNumberNodeView {
22939
+ constructor(node, getPos, decorations, editor, htmlAttributes = {}) {
22940
+ __privateAdd(this, _AutoPageNumberNodeView_instances);
22941
+ this.node = node;
22942
+ this.editor = editor;
22943
+ this.view = editor.view;
22944
+ this.getPos = getPos;
22945
+ this.editor = editor;
22946
+ this.dom = __privateMethod(this, _AutoPageNumberNodeView_instances, renderDom_fn).call(this, node, htmlAttributes);
22947
+ }
22948
+ update(node) {
22949
+ if (node.type !== this.node.type) return false;
22950
+ this.node = node;
22951
+ return true;
22952
+ }
22953
+ }
22954
+ _AutoPageNumberNodeView_instances = new WeakSet();
22955
+ renderDom_fn = function(node, htmlAttributes) {
22956
+ const pageText = this.editor.options.currentPageNumber || "1";
22957
+ const content = document.createTextNode(String(pageText));
22958
+ const nodeContent = document.createElement("span");
22959
+ nodeContent.className = "sd-editor-auto-page-number";
22960
+ nodeContent.setAttribute("data-id", "auto-page-number");
22961
+ nodeContent.setAttribute("aria-label", "Page number node");
22962
+ const currentPos = this.getPos();
22963
+ const { styles, marks } = getMarksFromNeighbors(currentPos, this.view);
22964
+ __privateMethod(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
22965
+ Object.assign(nodeContent.style, styles);
22966
+ nodeContent.appendChild(content);
22967
+ Object.entries(htmlAttributes).forEach(([key, value]) => {
22968
+ if (value) nodeContent.setAttribute(key, value);
22969
+ });
22970
+ return nodeContent;
22971
+ };
22972
+ scheduleUpdateNodeStyle_fn = function(pos, marks) {
22973
+ setTimeout(() => {
22974
+ const { state } = this.editor;
22975
+ const { dispatch } = this.view;
22976
+ const node = state.doc.nodeAt(pos);
22977
+ if (!node) return;
22978
+ const currentMarks = node.attrs.marksAsAttrs || [];
22979
+ const newMarks = marks.map((m) => ({ type: m.type.name, attrs: m.attrs }));
22980
+ const isEqual = JSON.stringify(currentMarks) === JSON.stringify(newMarks);
22981
+ if (isEqual) return;
22982
+ const newAttrs = {
22983
+ ...node.attrs,
22984
+ marksAsAttrs: newMarks
22985
+ };
22986
+ const tr = state.tr.setNodeMarkup(pos, void 0, newAttrs);
22987
+ dispatch(tr);
22988
+ }, 0);
22989
+ };
22990
+ const getMarksFromNeighbors = (currentPos, view) => {
22991
+ const $pos = view.state.doc.resolve(currentPos);
22992
+ const styles = {};
22993
+ const marks = [];
22994
+ const before = $pos.nodeBefore;
22995
+ if (before) {
22996
+ Object.assign(styles, processMarks(before.marks));
22997
+ marks.push(...before.marks);
22998
+ }
22999
+ const after = $pos.nodeAfter;
23000
+ if (after) {
23001
+ Object.assign(styles, { ...styles, ...processMarks(after.marks) });
23002
+ marks.push(...after.marks);
23003
+ }
23004
+ return {
23005
+ styles,
23006
+ marks
23007
+ };
23008
+ };
23009
+ const processMarks = (marks) => {
23010
+ const styles = {};
23011
+ marks.forEach((mark) => {
23012
+ const { type, attrs } = mark;
23013
+ switch (type.name) {
23014
+ case "textStyle":
23015
+ if (attrs.fontFamily) styles["font-family"] = attrs.fontFamily;
23016
+ if (attrs.fontSize) styles["font-size"] = attrs.fontSize;
23017
+ if (attrs.color) styles["color"] = attrs.color;
23018
+ if (attrs.backgroundColor) styles["background-color"] = attrs.backgroundColor;
23019
+ break;
23020
+ case "bold":
23021
+ styles["font-weight"] = "bold";
23022
+ break;
23023
+ case "italic":
23024
+ styles["font-style"] = "italic";
23025
+ break;
23026
+ case "underline":
23027
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " underline";
23028
+ break;
23029
+ case "strike":
23030
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " line-through";
23031
+ break;
23032
+ default:
23033
+ if (attrs?.style) {
23034
+ Object.entries(attrs.style).forEach(([key, value]) => {
23035
+ styles[key] = value;
23036
+ });
23037
+ }
23038
+ break;
23039
+ }
23040
+ });
23041
+ return styles;
23042
+ };
22679
23043
  const ShapeContainer = Node$1.create({
22680
23044
  name: "shapeContainer",
22681
23045
  group: "block",
@@ -23688,10 +24052,10 @@ var beforeWrite = "beforeWrite";
23688
24052
  var write = "write";
23689
24053
  var afterWrite = "afterWrite";
23690
24054
  var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
23691
- function getNodeName(element) {
24055
+ function getNodeName$1(element) {
23692
24056
  return element ? (element.nodeName || "").toLowerCase() : null;
23693
24057
  }
23694
- function getWindow(node) {
24058
+ function getWindow$1(node) {
23695
24059
  if (node == null) {
23696
24060
  return window;
23697
24061
  }
@@ -23701,19 +24065,19 @@ function getWindow(node) {
23701
24065
  }
23702
24066
  return node;
23703
24067
  }
23704
- function isElement$1(node) {
23705
- var OwnElement = getWindow(node).Element;
24068
+ function isElement$2(node) {
24069
+ var OwnElement = getWindow$1(node).Element;
23706
24070
  return node instanceof OwnElement || node instanceof Element;
23707
24071
  }
23708
- function isHTMLElement(node) {
23709
- var OwnElement = getWindow(node).HTMLElement;
24072
+ function isHTMLElement$1(node) {
24073
+ var OwnElement = getWindow$1(node).HTMLElement;
23710
24074
  return node instanceof OwnElement || node instanceof HTMLElement;
23711
24075
  }
23712
- function isShadowRoot(node) {
24076
+ function isShadowRoot$1(node) {
23713
24077
  if (typeof ShadowRoot === "undefined") {
23714
24078
  return false;
23715
24079
  }
23716
- var OwnElement = getWindow(node).ShadowRoot;
24080
+ var OwnElement = getWindow$1(node).ShadowRoot;
23717
24081
  return node instanceof OwnElement || node instanceof ShadowRoot;
23718
24082
  }
23719
24083
  function applyStyles(_ref) {
@@ -23722,7 +24086,7 @@ function applyStyles(_ref) {
23722
24086
  var style = state.styles[name] || {};
23723
24087
  var attributes = state.attributes[name] || {};
23724
24088
  var element = state.elements[name];
23725
- if (!isHTMLElement(element) || !getNodeName(element)) {
24089
+ if (!isHTMLElement$1(element) || !getNodeName$1(element)) {
23726
24090
  return;
23727
24091
  }
23728
24092
  Object.assign(element.style, style);
@@ -23764,7 +24128,7 @@ function effect$2(_ref2) {
23764
24128
  style2[property] = "";
23765
24129
  return style2;
23766
24130
  }, {});
23767
- if (!isHTMLElement(element) || !getNodeName(element)) {
24131
+ if (!isHTMLElement$1(element) || !getNodeName$1(element)) {
23768
24132
  return;
23769
24133
  }
23770
24134
  Object.assign(element.style, style);
@@ -23785,9 +24149,9 @@ const applyStyles$1 = {
23785
24149
  function getBasePlacement$1(placement) {
23786
24150
  return placement.split("-")[0];
23787
24151
  }
23788
- var max = Math.max;
23789
- var min = Math.min;
23790
- var round = Math.round;
24152
+ var max$1 = Math.max;
24153
+ var min$1 = Math.min;
24154
+ var round$1 = Math.round;
23791
24155
  function getUAString() {
23792
24156
  var uaData = navigator.userAgentData;
23793
24157
  if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
@@ -23800,7 +24164,7 @@ function getUAString() {
23800
24164
  function isLayoutViewport() {
23801
24165
  return !/^((?!chrome|android).)*safari/i.test(getUAString());
23802
24166
  }
23803
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
24167
+ function getBoundingClientRect$1(element, includeScale, isFixedStrategy) {
23804
24168
  if (includeScale === void 0) {
23805
24169
  includeScale = false;
23806
24170
  }
@@ -23810,11 +24174,11 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
23810
24174
  var clientRect2 = element.getBoundingClientRect();
23811
24175
  var scaleX = 1;
23812
24176
  var scaleY = 1;
23813
- if (includeScale && isHTMLElement(element)) {
23814
- scaleX = element.offsetWidth > 0 ? round(clientRect2.width) / element.offsetWidth || 1 : 1;
23815
- scaleY = element.offsetHeight > 0 ? round(clientRect2.height) / element.offsetHeight || 1 : 1;
24177
+ if (includeScale && isHTMLElement$1(element)) {
24178
+ scaleX = element.offsetWidth > 0 ? round$1(clientRect2.width) / element.offsetWidth || 1 : 1;
24179
+ scaleY = element.offsetHeight > 0 ? round$1(clientRect2.height) / element.offsetHeight || 1 : 1;
23816
24180
  }
23817
- var _ref = isElement$1(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
24181
+ var _ref = isElement$2(element) ? getWindow$1(element) : window, visualViewport = _ref.visualViewport;
23818
24182
  var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
23819
24183
  var x = (clientRect2.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
23820
24184
  var y = (clientRect2.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
@@ -23832,7 +24196,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
23832
24196
  };
23833
24197
  }
23834
24198
  function getLayoutRect(element) {
23835
- var clientRect2 = getBoundingClientRect(element);
24199
+ var clientRect2 = getBoundingClientRect$1(element);
23836
24200
  var width = element.offsetWidth;
23837
24201
  var height = element.offsetHeight;
23838
24202
  if (Math.abs(clientRect2.width - width) <= 1) {
@@ -23852,7 +24216,7 @@ function contains(parent, child) {
23852
24216
  var rootNode = child.getRootNode && child.getRootNode();
23853
24217
  if (parent.contains(child)) {
23854
24218
  return true;
23855
- } else if (rootNode && isShadowRoot(rootNode)) {
24219
+ } else if (rootNode && isShadowRoot$1(rootNode)) {
23856
24220
  var next = child;
23857
24221
  do {
23858
24222
  if (next && parent.isSameNode(next)) {
@@ -23863,20 +24227,20 @@ function contains(parent, child) {
23863
24227
  }
23864
24228
  return false;
23865
24229
  }
23866
- function getComputedStyle$1(element) {
23867
- return getWindow(element).getComputedStyle(element);
24230
+ function getComputedStyle$2(element) {
24231
+ return getWindow$1(element).getComputedStyle(element);
23868
24232
  }
23869
- function isTableElement(element) {
23870
- return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
24233
+ function isTableElement$1(element) {
24234
+ return ["table", "td", "th"].indexOf(getNodeName$1(element)) >= 0;
23871
24235
  }
23872
- function getDocumentElement(element) {
23873
- return ((isElement$1(element) ? element.ownerDocument : (
24236
+ function getDocumentElement$1(element) {
24237
+ return ((isElement$2(element) ? element.ownerDocument : (
23874
24238
  // $FlowFixMe[prop-missing]
23875
24239
  element.document
23876
24240
  )) || window.document).documentElement;
23877
24241
  }
23878
- function getParentNode(element) {
23879
- if (getNodeName(element) === "html") {
24242
+ function getParentNode$1(element) {
24243
+ if (getNodeName$1(element) === "html") {
23880
24244
  return element;
23881
24245
  }
23882
24246
  return (
@@ -23885,33 +24249,33 @@ function getParentNode(element) {
23885
24249
  // $FlowFixMe[prop-missing]
23886
24250
  element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
23887
24251
  element.parentNode || // DOM Element detected
23888
- (isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
24252
+ (isShadowRoot$1(element) ? element.host : null) || // ShadowRoot detected
23889
24253
  // $FlowFixMe[incompatible-call]: HTMLElement is a Node
23890
- getDocumentElement(element)
24254
+ getDocumentElement$1(element)
23891
24255
  );
23892
24256
  }
23893
- function getTrueOffsetParent(element) {
23894
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
23895
- getComputedStyle$1(element).position === "fixed") {
24257
+ function getTrueOffsetParent$1(element) {
24258
+ if (!isHTMLElement$1(element) || // https://github.com/popperjs/popper-core/issues/837
24259
+ getComputedStyle$2(element).position === "fixed") {
23896
24260
  return null;
23897
24261
  }
23898
24262
  return element.offsetParent;
23899
24263
  }
23900
- function getContainingBlock(element) {
24264
+ function getContainingBlock$1(element) {
23901
24265
  var isFirefox = /firefox/i.test(getUAString());
23902
24266
  var isIE = /Trident/i.test(getUAString());
23903
- if (isIE && isHTMLElement(element)) {
23904
- var elementCss = getComputedStyle$1(element);
24267
+ if (isIE && isHTMLElement$1(element)) {
24268
+ var elementCss = getComputedStyle$2(element);
23905
24269
  if (elementCss.position === "fixed") {
23906
24270
  return null;
23907
24271
  }
23908
24272
  }
23909
- var currentNode = getParentNode(element);
23910
- if (isShadowRoot(currentNode)) {
24273
+ var currentNode = getParentNode$1(element);
24274
+ if (isShadowRoot$1(currentNode)) {
23911
24275
  currentNode = currentNode.host;
23912
24276
  }
23913
- while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
23914
- var css = getComputedStyle$1(currentNode);
24277
+ while (isHTMLElement$1(currentNode) && ["html", "body"].indexOf(getNodeName$1(currentNode)) < 0) {
24278
+ var css = getComputedStyle$2(currentNode);
23915
24279
  if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
23916
24280
  return currentNode;
23917
24281
  } else {
@@ -23920,22 +24284,22 @@ function getContainingBlock(element) {
23920
24284
  }
23921
24285
  return null;
23922
24286
  }
23923
- function getOffsetParent(element) {
23924
- var window2 = getWindow(element);
23925
- var offsetParent = getTrueOffsetParent(element);
23926
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
23927
- offsetParent = getTrueOffsetParent(offsetParent);
24287
+ function getOffsetParent$1(element) {
24288
+ var window2 = getWindow$1(element);
24289
+ var offsetParent = getTrueOffsetParent$1(element);
24290
+ while (offsetParent && isTableElement$1(offsetParent) && getComputedStyle$2(offsetParent).position === "static") {
24291
+ offsetParent = getTrueOffsetParent$1(offsetParent);
23928
24292
  }
23929
- if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
24293
+ if (offsetParent && (getNodeName$1(offsetParent) === "html" || getNodeName$1(offsetParent) === "body" && getComputedStyle$2(offsetParent).position === "static")) {
23930
24294
  return window2;
23931
24295
  }
23932
- return offsetParent || getContainingBlock(element) || window2;
24296
+ return offsetParent || getContainingBlock$1(element) || window2;
23933
24297
  }
23934
24298
  function getMainAxisFromPlacement(placement) {
23935
24299
  return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
23936
24300
  }
23937
- function within(min$12, value, max$12) {
23938
- return max(min$12, min(value, max$12));
24301
+ function within(min2, value, max2) {
24302
+ return max$1(min2, min$1(value, max2));
23939
24303
  }
23940
24304
  function withinMaxClamp(min2, value, max2) {
23941
24305
  var v = within(min2, value, max2);
@@ -23982,7 +24346,7 @@ function arrow(_ref) {
23982
24346
  var maxProp = axis === "y" ? bottom : right;
23983
24347
  var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
23984
24348
  var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
23985
- var arrowOffsetParent = getOffsetParent(arrowElement);
24349
+ var arrowOffsetParent = getOffsetParent$1(arrowElement);
23986
24350
  var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
23987
24351
  var centerToReference = endDiff / 2 - startDiff / 2;
23988
24352
  var min2 = paddingObject[minProp];
@@ -24031,8 +24395,8 @@ function roundOffsetsByDPR(_ref, win) {
24031
24395
  var x = _ref.x, y = _ref.y;
24032
24396
  var dpr = win.devicePixelRatio || 1;
24033
24397
  return {
24034
- x: round(x * dpr) / dpr || 0,
24035
- y: round(y * dpr) / dpr || 0
24398
+ x: round$1(x * dpr) / dpr || 0,
24399
+ y: round$1(y * dpr) / dpr || 0
24036
24400
  };
24037
24401
  }
24038
24402
  function mapToStyles(_ref2) {
@@ -24054,12 +24418,12 @@ function mapToStyles(_ref2) {
24054
24418
  var sideY = top;
24055
24419
  var win = window;
24056
24420
  if (adaptive) {
24057
- var offsetParent = getOffsetParent(popper2);
24421
+ var offsetParent = getOffsetParent$1(popper2);
24058
24422
  var heightProp = "clientHeight";
24059
24423
  var widthProp = "clientWidth";
24060
- if (offsetParent === getWindow(popper2)) {
24061
- offsetParent = getDocumentElement(popper2);
24062
- if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
24424
+ if (offsetParent === getWindow$1(popper2)) {
24425
+ offsetParent = getDocumentElement$1(popper2);
24426
+ if (getComputedStyle$2(offsetParent).position !== "static" && position === "absolute") {
24063
24427
  heightProp = "scrollHeight";
24064
24428
  widthProp = "scrollWidth";
24065
24429
  }
@@ -24090,7 +24454,7 @@ function mapToStyles(_ref2) {
24090
24454
  var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
24091
24455
  x,
24092
24456
  y
24093
- }, getWindow(popper2)) : {
24457
+ }, getWindow$1(popper2)) : {
24094
24458
  x,
24095
24459
  y
24096
24460
  };
@@ -24146,7 +24510,7 @@ var passive = {
24146
24510
  function effect(_ref) {
24147
24511
  var state = _ref.state, instance = _ref.instance, options = _ref.options;
24148
24512
  var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
24149
- var window2 = getWindow(state.elements.popper);
24513
+ var window2 = getWindow$1(state.elements.popper);
24150
24514
  var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
24151
24515
  if (scroll) {
24152
24516
  scrollParents.forEach(function(scrollParent) {
@@ -24197,7 +24561,7 @@ function getOppositeVariationPlacement(placement) {
24197
24561
  });
24198
24562
  }
24199
24563
  function getWindowScroll(node) {
24200
- var win = getWindow(node);
24564
+ var win = getWindow$1(node);
24201
24565
  var scrollLeft = win.pageXOffset;
24202
24566
  var scrollTop = win.pageYOffset;
24203
24567
  return {
@@ -24205,12 +24569,12 @@ function getWindowScroll(node) {
24205
24569
  scrollTop
24206
24570
  };
24207
24571
  }
24208
- function getWindowScrollBarX(element) {
24209
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
24572
+ function getWindowScrollBarX$1(element) {
24573
+ return getBoundingClientRect$1(getDocumentElement$1(element)).left + getWindowScroll(element).scrollLeft;
24210
24574
  }
24211
- function getViewportRect(element, strategy) {
24212
- var win = getWindow(element);
24213
- var html = getDocumentElement(element);
24575
+ function getViewportRect$1(element, strategy) {
24576
+ var win = getWindow$1(element);
24577
+ var html = getDocumentElement$1(element);
24214
24578
  var visualViewport = win.visualViewport;
24215
24579
  var width = html.clientWidth;
24216
24580
  var height = html.clientHeight;
@@ -24228,21 +24592,21 @@ function getViewportRect(element, strategy) {
24228
24592
  return {
24229
24593
  width,
24230
24594
  height,
24231
- x: x + getWindowScrollBarX(element),
24595
+ x: x + getWindowScrollBarX$1(element),
24232
24596
  y
24233
24597
  };
24234
24598
  }
24235
- function getDocumentRect(element) {
24599
+ function getDocumentRect$1(element) {
24236
24600
  var _element$ownerDocumen;
24237
- var html = getDocumentElement(element);
24601
+ var html = getDocumentElement$1(element);
24238
24602
  var winScroll = getWindowScroll(element);
24239
24603
  var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
24240
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
24241
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
24242
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
24604
+ var width = max$1(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
24605
+ var height = max$1(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
24606
+ var x = -winScroll.scrollLeft + getWindowScrollBarX$1(element);
24243
24607
  var y = -winScroll.scrollTop;
24244
- if (getComputedStyle$1(body || html).direction === "rtl") {
24245
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
24608
+ if (getComputedStyle$2(body || html).direction === "rtl") {
24609
+ x += max$1(html.clientWidth, body ? body.clientWidth : 0) - width;
24246
24610
  }
24247
24611
  return {
24248
24612
  width,
@@ -24252,17 +24616,17 @@ function getDocumentRect(element) {
24252
24616
  };
24253
24617
  }
24254
24618
  function isScrollParent(element) {
24255
- var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
24619
+ var _getComputedStyle = getComputedStyle$2(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
24256
24620
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
24257
24621
  }
24258
24622
  function getScrollParent(node) {
24259
- if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
24623
+ if (["html", "body", "#document"].indexOf(getNodeName$1(node)) >= 0) {
24260
24624
  return node.ownerDocument.body;
24261
24625
  }
24262
- if (isHTMLElement(node) && isScrollParent(node)) {
24626
+ if (isHTMLElement$1(node) && isScrollParent(node)) {
24263
24627
  return node;
24264
24628
  }
24265
- return getScrollParent(getParentNode(node));
24629
+ return getScrollParent(getParentNode$1(node));
24266
24630
  }
24267
24631
  function listScrollParents(element, list) {
24268
24632
  var _element$ownerDocumen;
@@ -24271,15 +24635,15 @@ function listScrollParents(element, list) {
24271
24635
  }
24272
24636
  var scrollParent = getScrollParent(element);
24273
24637
  var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
24274
- var win = getWindow(scrollParent);
24638
+ var win = getWindow$1(scrollParent);
24275
24639
  var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
24276
24640
  var updatedList = list.concat(target);
24277
24641
  return isBody ? updatedList : (
24278
24642
  // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
24279
- updatedList.concat(listScrollParents(getParentNode(target)))
24643
+ updatedList.concat(listScrollParents(getParentNode$1(target)))
24280
24644
  );
24281
24645
  }
24282
- function rectToClientRect(rect) {
24646
+ function rectToClientRect$1(rect) {
24283
24647
  return Object.assign({}, rect, {
24284
24648
  left: rect.x,
24285
24649
  top: rect.y,
@@ -24287,8 +24651,8 @@ function rectToClientRect(rect) {
24287
24651
  bottom: rect.y + rect.height
24288
24652
  });
24289
24653
  }
24290
- function getInnerBoundingClientRect(element, strategy) {
24291
- var rect = getBoundingClientRect(element, false, strategy === "fixed");
24654
+ function getInnerBoundingClientRect$1(element, strategy) {
24655
+ var rect = getBoundingClientRect$1(element, false, strategy === "fixed");
24292
24656
  rect.top = rect.top + element.clientTop;
24293
24657
  rect.left = rect.left + element.clientLeft;
24294
24658
  rect.bottom = rect.top + element.clientHeight;
@@ -24300,29 +24664,29 @@ function getInnerBoundingClientRect(element, strategy) {
24300
24664
  return rect;
24301
24665
  }
24302
24666
  function getClientRectFromMixedType(element, clippingParent, strategy) {
24303
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
24667
+ return clippingParent === viewport ? rectToClientRect$1(getViewportRect$1(element, strategy)) : isElement$2(clippingParent) ? getInnerBoundingClientRect$1(clippingParent, strategy) : rectToClientRect$1(getDocumentRect$1(getDocumentElement$1(element)));
24304
24668
  }
24305
24669
  function getClippingParents(element) {
24306
- var clippingParents2 = listScrollParents(getParentNode(element));
24307
- var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$1(element).position) >= 0;
24308
- var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
24309
- if (!isElement$1(clipperElement)) {
24670
+ var clippingParents2 = listScrollParents(getParentNode$1(element));
24671
+ var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$2(element).position) >= 0;
24672
+ var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent$1(element) : element;
24673
+ if (!isElement$2(clipperElement)) {
24310
24674
  return [];
24311
24675
  }
24312
24676
  return clippingParents2.filter(function(clippingParent) {
24313
- return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
24677
+ return isElement$2(clippingParent) && contains(clippingParent, clipperElement) && getNodeName$1(clippingParent) !== "body";
24314
24678
  });
24315
24679
  }
24316
- function getClippingRect(element, boundary, rootBoundary, strategy) {
24680
+ function getClippingRect$1(element, boundary, rootBoundary, strategy) {
24317
24681
  var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
24318
24682
  var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
24319
24683
  var firstClippingParent = clippingParents2[0];
24320
24684
  var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
24321
24685
  var rect = getClientRectFromMixedType(element, clippingParent, strategy);
24322
- accRect.top = max(rect.top, accRect.top);
24323
- accRect.right = min(rect.right, accRect.right);
24324
- accRect.bottom = min(rect.bottom, accRect.bottom);
24325
- accRect.left = max(rect.left, accRect.left);
24686
+ accRect.top = max$1(rect.top, accRect.top);
24687
+ accRect.right = min$1(rect.right, accRect.right);
24688
+ accRect.bottom = min$1(rect.bottom, accRect.bottom);
24689
+ accRect.left = max$1(rect.left, accRect.left);
24326
24690
  return accRect;
24327
24691
  }, getClientRectFromMixedType(element, firstClippingParent, strategy));
24328
24692
  clippingRect.width = clippingRect.right - clippingRect.left;
@@ -24383,7 +24747,7 @@ function computeOffsets(_ref) {
24383
24747
  }
24384
24748
  return offsets;
24385
24749
  }
24386
- function detectOverflow(state, options) {
24750
+ function detectOverflow$1(state, options) {
24387
24751
  if (options === void 0) {
24388
24752
  options = {};
24389
24753
  }
@@ -24392,14 +24756,14 @@ function detectOverflow(state, options) {
24392
24756
  var altContext = elementContext === popper ? reference : popper;
24393
24757
  var popperRect = state.rects.popper;
24394
24758
  var element = state.elements[altBoundary ? altContext : elementContext];
24395
- var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
24396
- var referenceClientRect = getBoundingClientRect(state.elements.reference);
24759
+ var clippingClientRect = getClippingRect$1(isElement$2(element) ? element : element.contextElement || getDocumentElement$1(state.elements.popper), boundary, rootBoundary, strategy);
24760
+ var referenceClientRect = getBoundingClientRect$1(state.elements.reference);
24397
24761
  var popperOffsets2 = computeOffsets({
24398
24762
  reference: referenceClientRect,
24399
24763
  element: popperRect,
24400
24764
  placement
24401
24765
  });
24402
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
24766
+ var popperClientRect = rectToClientRect$1(Object.assign({}, popperRect, popperOffsets2));
24403
24767
  var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
24404
24768
  var overflowOffsets = {
24405
24769
  top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
@@ -24434,7 +24798,7 @@ function computeAutoPlacement(state, options) {
24434
24798
  allowedPlacements = placements$1;
24435
24799
  }
24436
24800
  var overflows = allowedPlacements.reduce(function(acc, placement2) {
24437
- acc[placement2] = detectOverflow(state, {
24801
+ acc[placement2] = detectOverflow$1(state, {
24438
24802
  placement: placement2,
24439
24803
  boundary,
24440
24804
  rootBoundary,
@@ -24484,7 +24848,7 @@ function flip(_ref) {
24484
24848
  var isStartVariation = getVariation(placement) === start;
24485
24849
  var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
24486
24850
  var len = isVertical ? "width" : "height";
24487
- var overflow = detectOverflow(state, {
24851
+ var overflow = detectOverflow$1(state, {
24488
24852
  placement,
24489
24853
  boundary,
24490
24854
  rootBoundary,
@@ -24549,7 +24913,7 @@ const flip$1 = {
24549
24913
  _skip: false
24550
24914
  }
24551
24915
  };
24552
- function getSideOffsets(overflow, rect, preventedOffsets) {
24916
+ function getSideOffsets$1(overflow, rect, preventedOffsets) {
24553
24917
  if (preventedOffsets === void 0) {
24554
24918
  preventedOffsets = {
24555
24919
  x: 0,
@@ -24563,26 +24927,26 @@ function getSideOffsets(overflow, rect, preventedOffsets) {
24563
24927
  left: overflow.left - rect.width - preventedOffsets.x
24564
24928
  };
24565
24929
  }
24566
- function isAnySideFullyClipped(overflow) {
24930
+ function isAnySideFullyClipped$1(overflow) {
24567
24931
  return [top, right, bottom, left].some(function(side) {
24568
24932
  return overflow[side] >= 0;
24569
24933
  });
24570
24934
  }
24571
- function hide(_ref) {
24935
+ function hide$2(_ref) {
24572
24936
  var state = _ref.state, name = _ref.name;
24573
24937
  var referenceRect = state.rects.reference;
24574
24938
  var popperRect = state.rects.popper;
24575
24939
  var preventedOffsets = state.modifiersData.preventOverflow;
24576
- var referenceOverflow = detectOverflow(state, {
24940
+ var referenceOverflow = detectOverflow$1(state, {
24577
24941
  elementContext: "reference"
24578
24942
  });
24579
- var popperAltOverflow = detectOverflow(state, {
24943
+ var popperAltOverflow = detectOverflow$1(state, {
24580
24944
  altBoundary: true
24581
24945
  });
24582
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
24583
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
24584
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
24585
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
24946
+ var referenceClippingOffsets = getSideOffsets$1(referenceOverflow, referenceRect);
24947
+ var popperEscapeOffsets = getSideOffsets$1(popperAltOverflow, popperRect, preventedOffsets);
24948
+ var isReferenceHidden = isAnySideFullyClipped$1(referenceClippingOffsets);
24949
+ var hasPopperEscaped = isAnySideFullyClipped$1(popperEscapeOffsets);
24586
24950
  state.modifiersData[name] = {
24587
24951
  referenceClippingOffsets,
24588
24952
  popperEscapeOffsets,
@@ -24594,12 +24958,12 @@ function hide(_ref) {
24594
24958
  "data-popper-escaped": hasPopperEscaped
24595
24959
  });
24596
24960
  }
24597
- const hide$1 = {
24961
+ const hide$3 = {
24598
24962
  name: "hide",
24599
24963
  enabled: true,
24600
24964
  phase: "main",
24601
24965
  requiresIfExists: ["preventOverflow"],
24602
- fn: hide
24966
+ fn: hide$2
24603
24967
  };
24604
24968
  function distanceAndSkiddingToXY(placement, rects, offset2) {
24605
24969
  var basePlacement = getBasePlacement$1(placement);
@@ -24659,7 +25023,7 @@ function getAltAxis(axis) {
24659
25023
  function preventOverflow(_ref) {
24660
25024
  var state = _ref.state, options = _ref.options, name = _ref.name;
24661
25025
  var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
24662
- var overflow = detectOverflow(state, {
25026
+ var overflow = detectOverflow$1(state, {
24663
25027
  boundary,
24664
25028
  rootBoundary,
24665
25029
  padding,
@@ -24697,8 +25061,8 @@ function preventOverflow(_ref) {
24697
25061
  var altSide = mainAxis === "y" ? bottom : right;
24698
25062
  var len = mainAxis === "y" ? "height" : "width";
24699
25063
  var offset2 = popperOffsets2[mainAxis];
24700
- var min$12 = offset2 + overflow[mainSide];
24701
- var max$12 = offset2 - overflow[altSide];
25064
+ var min2 = offset2 + overflow[mainSide];
25065
+ var max2 = offset2 - overflow[altSide];
24702
25066
  var additive = tether ? -popperRect[len] / 2 : 0;
24703
25067
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
24704
25068
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
@@ -24713,12 +25077,12 @@ function preventOverflow(_ref) {
24713
25077
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
24714
25078
  var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
24715
25079
  var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
24716
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
25080
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent$1(state.elements.arrow);
24717
25081
  var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
24718
25082
  var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
24719
25083
  var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
24720
25084
  var tetherMax = offset2 + maxOffset - offsetModifierValue;
24721
- var preventedOffset = within(tether ? min(min$12, tetherMin) : min$12, offset2, tether ? max(max$12, tetherMax) : max$12);
25085
+ var preventedOffset = within(tether ? min$1(min2, tetherMin) : min2, offset2, tether ? max$1(max2, tetherMax) : max2);
24722
25086
  popperOffsets2[mainAxis] = preventedOffset;
24723
25087
  data[mainAxis] = preventedOffset - offset2;
24724
25088
  }
@@ -24753,8 +25117,8 @@ function getHTMLElementScroll(element) {
24753
25117
  scrollTop: element.scrollTop
24754
25118
  };
24755
25119
  }
24756
- function getNodeScroll(node) {
24757
- if (node === getWindow(node) || !isHTMLElement(node)) {
25120
+ function getNodeScroll$1(node) {
25121
+ if (node === getWindow$1(node) || !isHTMLElement$1(node)) {
24758
25122
  return getWindowScroll(node);
24759
25123
  } else {
24760
25124
  return getHTMLElementScroll(node);
@@ -24762,18 +25126,18 @@ function getNodeScroll(node) {
24762
25126
  }
24763
25127
  function isElementScaled(element) {
24764
25128
  var rect = element.getBoundingClientRect();
24765
- var scaleX = round(rect.width) / element.offsetWidth || 1;
24766
- var scaleY = round(rect.height) / element.offsetHeight || 1;
25129
+ var scaleX = round$1(rect.width) / element.offsetWidth || 1;
25130
+ var scaleY = round$1(rect.height) / element.offsetHeight || 1;
24767
25131
  return scaleX !== 1 || scaleY !== 1;
24768
25132
  }
24769
25133
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
24770
25134
  if (isFixed === void 0) {
24771
25135
  isFixed = false;
24772
25136
  }
24773
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
24774
- var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
24775
- var documentElement = getDocumentElement(offsetParent);
24776
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
25137
+ var isOffsetParentAnElement = isHTMLElement$1(offsetParent);
25138
+ var offsetParentIsScaled = isHTMLElement$1(offsetParent) && isElementScaled(offsetParent);
25139
+ var documentElement = getDocumentElement$1(offsetParent);
25140
+ var rect = getBoundingClientRect$1(elementOrVirtualElement, offsetParentIsScaled, isFixed);
24777
25141
  var scroll = {
24778
25142
  scrollLeft: 0,
24779
25143
  scrollTop: 0
@@ -24783,16 +25147,16 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
24783
25147
  y: 0
24784
25148
  };
24785
25149
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
24786
- if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
25150
+ if (getNodeName$1(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
24787
25151
  isScrollParent(documentElement)) {
24788
- scroll = getNodeScroll(offsetParent);
25152
+ scroll = getNodeScroll$1(offsetParent);
24789
25153
  }
24790
- if (isHTMLElement(offsetParent)) {
24791
- offsets = getBoundingClientRect(offsetParent, true);
25154
+ if (isHTMLElement$1(offsetParent)) {
25155
+ offsets = getBoundingClientRect$1(offsetParent, true);
24792
25156
  offsets.x += offsetParent.clientLeft;
24793
25157
  offsets.y += offsetParent.clientTop;
24794
25158
  } else if (documentElement) {
24795
- offsets.x = getWindowScrollBarX(documentElement);
25159
+ offsets.x = getWindowScrollBarX$1(documentElement);
24796
25160
  }
24797
25161
  }
24798
25162
  return {
@@ -24907,7 +25271,7 @@ function popperGenerator(generatorOptions) {
24907
25271
  cleanupModifierEffects();
24908
25272
  state.options = Object.assign({}, defaultOptions, state.options, options2);
24909
25273
  state.scrollParents = {
24910
- reference: isElement$1(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
25274
+ reference: isElement$2(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
24911
25275
  popper: listScrollParents(popper2)
24912
25276
  };
24913
25277
  var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
@@ -24931,7 +25295,7 @@ function popperGenerator(generatorOptions) {
24931
25295
  return;
24932
25296
  }
24933
25297
  state.rects = {
24934
- reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
25298
+ reference: getCompositeRect(reference3, getOffsetParent$1(popper3), state.options.strategy === "fixed"),
24935
25299
  popper: getLayoutRect(popper3)
24936
25300
  };
24937
25301
  state.reset = false;
@@ -25002,7 +25366,7 @@ function popperGenerator(generatorOptions) {
25002
25366
  return instance;
25003
25367
  };
25004
25368
  }
25005
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
25369
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$3];
25006
25370
  var createPopper = /* @__PURE__ */ popperGenerator({
25007
25371
  defaultModifiers
25008
25372
  });
@@ -25087,7 +25451,7 @@ function removeUndefinedProps(obj) {
25087
25451
  function div() {
25088
25452
  return document.createElement("div");
25089
25453
  }
25090
- function isElement(value) {
25454
+ function isElement$1(value) {
25091
25455
  return ["Element", "Fragment"].some(function(type) {
25092
25456
  return isType(value, type);
25093
25457
  });
@@ -25102,7 +25466,7 @@ function isReferenceElement(value) {
25102
25466
  return !!(value && value._tippy && value._tippy.reference === value);
25103
25467
  }
25104
25468
  function getArrayOfElements(value) {
25105
- if (isElement(value)) {
25469
+ if (isElement$1(value)) {
25106
25470
  return [value];
25107
25471
  }
25108
25472
  if (isNodeList(value)) {
@@ -25411,7 +25775,7 @@ function createArrowElement(value) {
25411
25775
  arrow2.className = ARROW_CLASS;
25412
25776
  } else {
25413
25777
  arrow2.className = SVG_ARROW_CLASS;
25414
- if (isElement(value)) {
25778
+ if (isElement$1(value)) {
25415
25779
  arrow2.appendChild(value);
25416
25780
  } else {
25417
25781
  dangerouslySetInnerHTML(arrow2, value);
@@ -25420,7 +25784,7 @@ function createArrowElement(value) {
25420
25784
  return arrow2;
25421
25785
  }
25422
25786
  function setContent(content, props) {
25423
- if (isElement(props.content)) {
25787
+ if (isElement$1(props.content)) {
25424
25788
  dangerouslySetInnerHTML(content, "");
25425
25789
  content.appendChild(props.content);
25426
25790
  } else if (typeof props.content !== "function") {
@@ -26243,7 +26607,7 @@ function tippy(targets, optionalProps) {
26243
26607
  });
26244
26608
  var elements = getArrayOfElements(targets);
26245
26609
  if (process$1.env.NODE_ENV !== "production") {
26246
- var isSingleContentElement = isElement(passedProps.content);
26610
+ var isSingleContentElement = isElement$1(passedProps.content);
26247
26611
  var isMoreThanOneReferenceElement = elements.length > 1;
26248
26612
  warnWhen(isSingleContentElement && isMoreThanOneReferenceElement, ["tippy() was passed an Element as the `content` prop, but more than", "one tippy instance was created by this invocation. This means the", "content element will only be appended to the last tippy instance.", "\n\n", "Instead, pass the .innerHTML of the element, or use a function that", "returns a cloned version of the element instead.", "\n\n", "1) content: element.innerHTML\n", "2) content: () => element.cloneNode(true)"].join(" "));
26249
26613
  }
@@ -26254,7 +26618,7 @@ function tippy(targets, optionalProps) {
26254
26618
  }
26255
26619
  return acc;
26256
26620
  }, []);
26257
- return isElement(targets) ? instances[0] : instances;
26621
+ return isElement$1(targets) ? instances[0] : instances;
26258
26622
  }
26259
26623
  tippy.defaultProps = defaultProps;
26260
26624
  tippy.setDefaultProps = setDefaultProps;
@@ -26523,80 +26887,1140 @@ class Popover {
26523
26887
  this.popover.remove();
26524
26888
  }
26525
26889
  }
26526
- const isDebugging = false;
26527
- const Pagination = Extension.create({
26528
- name: "pagination",
26529
- addStorage() {
26530
- return {
26531
- height: 0,
26532
- sectionData: null
26533
- };
26534
- },
26535
- addCommands() {
26536
- return {
26537
- insertPageBreak: () => ({ commands: commands2 }) => {
26538
- return commands2.insertContent({
26539
- type: "hardBreak"
26540
- });
26541
- }
26542
- };
26543
- },
26544
- addShortcuts() {
26545
- return {
26546
- "Mod-Enter": () => this.editor.commands.insertPageBreak()
26547
- };
26548
- },
26549
- /**
26550
- * The pagination plugin is responsible for calculating page breaks, and redering them using decorations.
26551
- */
26552
- addPmPlugins() {
26553
- const editor = this.editor;
26554
- let isUpdating = false;
26555
- let shouldUpdate = false;
26556
- let hasInitialized = false;
26557
- let shouldInitialize = false;
26558
- const paginationPlugin = new Plugin({
26559
- key: PaginationPluginKey,
26560
- state: {
26561
- isReadyToInit: false,
26562
- init(_, state) {
26563
- return {
26564
- isReadyToInit: false,
26565
- decorations: DecorationSet.empty,
26566
- isDebugging
26567
- };
26568
- },
26569
- apply(tr, oldState, prevEditorState, newEditorState) {
26570
- const meta = tr.getMeta(PaginationPluginKey);
26571
- if (meta && meta.isReadyToInit) {
26572
- shouldUpdate = true;
26573
- shouldInitialize = meta.isReadyToInit;
26574
- }
26575
- const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
26576
- if (imagePluginTransaction) {
26577
- if (imagePluginTransaction.type === "remove") {
26578
- const imagePos = imagePluginTransaction.pos;
26579
- const domImage = editor.view.domAtPos(imagePos).node.querySelector("img");
26580
- if (domImage.complete) onImageLoad(editor);
26581
- else domImage.onload = () => onImageLoad(editor);
26582
- }
26583
- return { ...oldState };
26584
- }
26585
- const isAnnotationUpdate = tr.getMeta("fieldAnnotationUpdate");
26586
- if (isAnnotationUpdate) {
26587
- return { ...oldState };
26588
- }
26589
- if (!shouldInitialize && !oldState.isReadyToInit) {
26590
- return { ...oldState };
26591
- }
26592
- if (meta && meta.decorations) {
26593
- shouldUpdate = true;
26594
- return {
26595
- ...oldState,
26596
- decorations: meta.decorations.map(tr.mapping, tr.doc)
26597
- };
26598
- }
26599
- const isForceUpdate = tr.getMeta("forceUpdatePagination");
26890
+ const sides = ["top", "right", "bottom", "left"];
26891
+ const min = Math.min;
26892
+ const max = Math.max;
26893
+ const round = Math.round;
26894
+ const floor = Math.floor;
26895
+ const createCoords = (v) => ({
26896
+ x: v,
26897
+ y: v
26898
+ });
26899
+ function evaluate(value, param) {
26900
+ return typeof value === "function" ? value(param) : value;
26901
+ }
26902
+ function getSide(placement) {
26903
+ return placement.split("-")[0];
26904
+ }
26905
+ function getAlignment(placement) {
26906
+ return placement.split("-")[1];
26907
+ }
26908
+ function getOppositeAxis(axis) {
26909
+ return axis === "x" ? "y" : "x";
26910
+ }
26911
+ function getAxisLength(axis) {
26912
+ return axis === "y" ? "height" : "width";
26913
+ }
26914
+ function getSideAxis(placement) {
26915
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
26916
+ }
26917
+ function getAlignmentAxis(placement) {
26918
+ return getOppositeAxis(getSideAxis(placement));
26919
+ }
26920
+ function expandPaddingObject(padding) {
26921
+ return {
26922
+ top: 0,
26923
+ right: 0,
26924
+ bottom: 0,
26925
+ left: 0,
26926
+ ...padding
26927
+ };
26928
+ }
26929
+ function getPaddingObject(padding) {
26930
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
26931
+ top: padding,
26932
+ right: padding,
26933
+ bottom: padding,
26934
+ left: padding
26935
+ };
26936
+ }
26937
+ function rectToClientRect(rect) {
26938
+ const {
26939
+ x,
26940
+ y,
26941
+ width,
26942
+ height
26943
+ } = rect;
26944
+ return {
26945
+ width,
26946
+ height,
26947
+ top: y,
26948
+ left: x,
26949
+ right: x + width,
26950
+ bottom: y + height,
26951
+ x,
26952
+ y
26953
+ };
26954
+ }
26955
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
26956
+ let {
26957
+ reference: reference2,
26958
+ floating
26959
+ } = _ref;
26960
+ const sideAxis = getSideAxis(placement);
26961
+ const alignmentAxis = getAlignmentAxis(placement);
26962
+ const alignLength = getAxisLength(alignmentAxis);
26963
+ const side = getSide(placement);
26964
+ const isVertical = sideAxis === "y";
26965
+ const commonX = reference2.x + reference2.width / 2 - floating.width / 2;
26966
+ const commonY = reference2.y + reference2.height / 2 - floating.height / 2;
26967
+ const commonAlign = reference2[alignLength] / 2 - floating[alignLength] / 2;
26968
+ let coords;
26969
+ switch (side) {
26970
+ case "top":
26971
+ coords = {
26972
+ x: commonX,
26973
+ y: reference2.y - floating.height
26974
+ };
26975
+ break;
26976
+ case "bottom":
26977
+ coords = {
26978
+ x: commonX,
26979
+ y: reference2.y + reference2.height
26980
+ };
26981
+ break;
26982
+ case "right":
26983
+ coords = {
26984
+ x: reference2.x + reference2.width,
26985
+ y: commonY
26986
+ };
26987
+ break;
26988
+ case "left":
26989
+ coords = {
26990
+ x: reference2.x - floating.width,
26991
+ y: commonY
26992
+ };
26993
+ break;
26994
+ default:
26995
+ coords = {
26996
+ x: reference2.x,
26997
+ y: reference2.y
26998
+ };
26999
+ }
27000
+ switch (getAlignment(placement)) {
27001
+ case "start":
27002
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
27003
+ break;
27004
+ case "end":
27005
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
27006
+ break;
27007
+ }
27008
+ return coords;
27009
+ }
27010
+ const computePosition$1 = async (reference2, floating, config) => {
27011
+ const {
27012
+ placement = "bottom",
27013
+ strategy = "absolute",
27014
+ middleware = [],
27015
+ platform: platform2
27016
+ } = config;
27017
+ const validMiddleware = middleware.filter(Boolean);
27018
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
27019
+ let rects = await platform2.getElementRects({
27020
+ reference: reference2,
27021
+ floating,
27022
+ strategy
27023
+ });
27024
+ let {
27025
+ x,
27026
+ y
27027
+ } = computeCoordsFromPlacement(rects, placement, rtl);
27028
+ let statefulPlacement = placement;
27029
+ let middlewareData = {};
27030
+ let resetCount = 0;
27031
+ for (let i = 0; i < validMiddleware.length; i++) {
27032
+ const {
27033
+ name,
27034
+ fn: fn2
27035
+ } = validMiddleware[i];
27036
+ const {
27037
+ x: nextX,
27038
+ y: nextY,
27039
+ data,
27040
+ reset
27041
+ } = await fn2({
27042
+ x,
27043
+ y,
27044
+ initialPlacement: placement,
27045
+ placement: statefulPlacement,
27046
+ strategy,
27047
+ middlewareData,
27048
+ rects,
27049
+ platform: platform2,
27050
+ elements: {
27051
+ reference: reference2,
27052
+ floating
27053
+ }
27054
+ });
27055
+ x = nextX != null ? nextX : x;
27056
+ y = nextY != null ? nextY : y;
27057
+ middlewareData = {
27058
+ ...middlewareData,
27059
+ [name]: {
27060
+ ...middlewareData[name],
27061
+ ...data
27062
+ }
27063
+ };
27064
+ if (reset && resetCount <= 50) {
27065
+ resetCount++;
27066
+ if (typeof reset === "object") {
27067
+ if (reset.placement) {
27068
+ statefulPlacement = reset.placement;
27069
+ }
27070
+ if (reset.rects) {
27071
+ rects = reset.rects === true ? await platform2.getElementRects({
27072
+ reference: reference2,
27073
+ floating,
27074
+ strategy
27075
+ }) : reset.rects;
27076
+ }
27077
+ ({
27078
+ x,
27079
+ y
27080
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
27081
+ }
27082
+ i = -1;
27083
+ }
27084
+ }
27085
+ return {
27086
+ x,
27087
+ y,
27088
+ placement: statefulPlacement,
27089
+ strategy,
27090
+ middlewareData
27091
+ };
27092
+ };
27093
+ async function detectOverflow(state, options) {
27094
+ var _await$platform$isEle;
27095
+ if (options === void 0) {
27096
+ options = {};
27097
+ }
27098
+ const {
27099
+ x,
27100
+ y,
27101
+ platform: platform2,
27102
+ rects,
27103
+ elements,
27104
+ strategy
27105
+ } = state;
27106
+ const {
27107
+ boundary = "clippingAncestors",
27108
+ rootBoundary = "viewport",
27109
+ elementContext = "floating",
27110
+ altBoundary = false,
27111
+ padding = 0
27112
+ } = evaluate(options, state);
27113
+ const paddingObject = getPaddingObject(padding);
27114
+ const altContext = elementContext === "floating" ? "reference" : "floating";
27115
+ const element = elements[altBoundary ? altContext : elementContext];
27116
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
27117
+ element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
27118
+ boundary,
27119
+ rootBoundary,
27120
+ strategy
27121
+ }));
27122
+ const rect = elementContext === "floating" ? {
27123
+ x,
27124
+ y,
27125
+ width: rects.floating.width,
27126
+ height: rects.floating.height
27127
+ } : rects.reference;
27128
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
27129
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
27130
+ x: 1,
27131
+ y: 1
27132
+ } : {
27133
+ x: 1,
27134
+ y: 1
27135
+ };
27136
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
27137
+ elements,
27138
+ rect,
27139
+ offsetParent,
27140
+ strategy
27141
+ }) : rect);
27142
+ return {
27143
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
27144
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
27145
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
27146
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
27147
+ };
27148
+ }
27149
+ function getSideOffsets(overflow, rect) {
27150
+ return {
27151
+ top: overflow.top - rect.height,
27152
+ right: overflow.right - rect.width,
27153
+ bottom: overflow.bottom - rect.height,
27154
+ left: overflow.left - rect.width
27155
+ };
27156
+ }
27157
+ function isAnySideFullyClipped(overflow) {
27158
+ return sides.some((side) => overflow[side] >= 0);
27159
+ }
27160
+ const hide$1 = function(options) {
27161
+ if (options === void 0) {
27162
+ options = {};
27163
+ }
27164
+ return {
27165
+ name: "hide",
27166
+ options,
27167
+ async fn(state) {
27168
+ const {
27169
+ rects
27170
+ } = state;
27171
+ const {
27172
+ strategy = "referenceHidden",
27173
+ ...detectOverflowOptions
27174
+ } = evaluate(options, state);
27175
+ switch (strategy) {
27176
+ case "referenceHidden": {
27177
+ const overflow = await detectOverflow(state, {
27178
+ ...detectOverflowOptions,
27179
+ elementContext: "reference"
27180
+ });
27181
+ const offsets = getSideOffsets(overflow, rects.reference);
27182
+ return {
27183
+ data: {
27184
+ referenceHiddenOffsets: offsets,
27185
+ referenceHidden: isAnySideFullyClipped(offsets)
27186
+ }
27187
+ };
27188
+ }
27189
+ case "escaped": {
27190
+ const overflow = await detectOverflow(state, {
27191
+ ...detectOverflowOptions,
27192
+ altBoundary: true
27193
+ });
27194
+ const offsets = getSideOffsets(overflow, rects.floating);
27195
+ return {
27196
+ data: {
27197
+ escapedOffsets: offsets,
27198
+ escaped: isAnySideFullyClipped(offsets)
27199
+ }
27200
+ };
27201
+ }
27202
+ default: {
27203
+ return {};
27204
+ }
27205
+ }
27206
+ }
27207
+ };
27208
+ };
27209
+ function hasWindow() {
27210
+ return typeof window !== "undefined";
27211
+ }
27212
+ function getNodeName(node) {
27213
+ if (isNode(node)) {
27214
+ return (node.nodeName || "").toLowerCase();
27215
+ }
27216
+ return "#document";
27217
+ }
27218
+ function getWindow(node) {
27219
+ var _node$ownerDocument;
27220
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
27221
+ }
27222
+ function getDocumentElement(node) {
27223
+ var _ref;
27224
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
27225
+ }
27226
+ function isNode(value) {
27227
+ if (!hasWindow()) {
27228
+ return false;
27229
+ }
27230
+ return value instanceof Node || value instanceof getWindow(value).Node;
27231
+ }
27232
+ function isElement(value) {
27233
+ if (!hasWindow()) {
27234
+ return false;
27235
+ }
27236
+ return value instanceof Element || value instanceof getWindow(value).Element;
27237
+ }
27238
+ function isHTMLElement(value) {
27239
+ if (!hasWindow()) {
27240
+ return false;
27241
+ }
27242
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
27243
+ }
27244
+ function isShadowRoot(value) {
27245
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
27246
+ return false;
27247
+ }
27248
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
27249
+ }
27250
+ function isOverflowElement(element) {
27251
+ const {
27252
+ overflow,
27253
+ overflowX,
27254
+ overflowY,
27255
+ display
27256
+ } = getComputedStyle$1(element);
27257
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
27258
+ }
27259
+ function isTableElement(element) {
27260
+ return ["table", "td", "th"].includes(getNodeName(element));
27261
+ }
27262
+ function isTopLayer(element) {
27263
+ return [":popover-open", ":modal"].some((selector) => {
27264
+ try {
27265
+ return element.matches(selector);
27266
+ } catch (e) {
27267
+ return false;
27268
+ }
27269
+ });
27270
+ }
27271
+ function isContainingBlock(elementOrCss) {
27272
+ const webkit2 = isWebKit();
27273
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
27274
+ return ["transform", "translate", "scale", "rotate", "perspective"].some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit2 && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit2 && (css.filter ? css.filter !== "none" : false) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
27275
+ }
27276
+ function getContainingBlock(element) {
27277
+ let currentNode = getParentNode(element);
27278
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
27279
+ if (isContainingBlock(currentNode)) {
27280
+ return currentNode;
27281
+ } else if (isTopLayer(currentNode)) {
27282
+ return null;
27283
+ }
27284
+ currentNode = getParentNode(currentNode);
27285
+ }
27286
+ return null;
27287
+ }
27288
+ function isWebKit() {
27289
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
27290
+ return CSS.supports("-webkit-backdrop-filter", "none");
27291
+ }
27292
+ function isLastTraversableNode(node) {
27293
+ return ["html", "body", "#document"].includes(getNodeName(node));
27294
+ }
27295
+ function getComputedStyle$1(element) {
27296
+ return getWindow(element).getComputedStyle(element);
27297
+ }
27298
+ function getNodeScroll(element) {
27299
+ if (isElement(element)) {
27300
+ return {
27301
+ scrollLeft: element.scrollLeft,
27302
+ scrollTop: element.scrollTop
27303
+ };
27304
+ }
27305
+ return {
27306
+ scrollLeft: element.scrollX,
27307
+ scrollTop: element.scrollY
27308
+ };
27309
+ }
27310
+ function getParentNode(node) {
27311
+ if (getNodeName(node) === "html") {
27312
+ return node;
27313
+ }
27314
+ const result = (
27315
+ // Step into the shadow DOM of the parent of a slotted node.
27316
+ node.assignedSlot || // DOM Element detected.
27317
+ node.parentNode || // ShadowRoot detected.
27318
+ isShadowRoot(node) && node.host || // Fallback.
27319
+ getDocumentElement(node)
27320
+ );
27321
+ return isShadowRoot(result) ? result.host : result;
27322
+ }
27323
+ function getNearestOverflowAncestor(node) {
27324
+ const parentNode2 = getParentNode(node);
27325
+ if (isLastTraversableNode(parentNode2)) {
27326
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
27327
+ }
27328
+ if (isHTMLElement(parentNode2) && isOverflowElement(parentNode2)) {
27329
+ return parentNode2;
27330
+ }
27331
+ return getNearestOverflowAncestor(parentNode2);
27332
+ }
27333
+ function getOverflowAncestors(node, list, traverseIframes) {
27334
+ var _node$ownerDocument2;
27335
+ if (list === void 0) {
27336
+ list = [];
27337
+ }
27338
+ if (traverseIframes === void 0) {
27339
+ traverseIframes = true;
27340
+ }
27341
+ const scrollableAncestor = getNearestOverflowAncestor(node);
27342
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
27343
+ const win = getWindow(scrollableAncestor);
27344
+ if (isBody) {
27345
+ const frameElement = getFrameElement(win);
27346
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
27347
+ }
27348
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
27349
+ }
27350
+ function getFrameElement(win) {
27351
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
27352
+ }
27353
+ function getCssDimensions(element) {
27354
+ const css = getComputedStyle$1(element);
27355
+ let width = parseFloat(css.width) || 0;
27356
+ let height = parseFloat(css.height) || 0;
27357
+ const hasOffset = isHTMLElement(element);
27358
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
27359
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
27360
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
27361
+ if (shouldFallback) {
27362
+ width = offsetWidth;
27363
+ height = offsetHeight;
27364
+ }
27365
+ return {
27366
+ width,
27367
+ height,
27368
+ $: shouldFallback
27369
+ };
27370
+ }
27371
+ function unwrapElement(element) {
27372
+ return !isElement(element) ? element.contextElement : element;
27373
+ }
27374
+ function getScale(element) {
27375
+ const domElement = unwrapElement(element);
27376
+ if (!isHTMLElement(domElement)) {
27377
+ return createCoords(1);
27378
+ }
27379
+ const rect = domElement.getBoundingClientRect();
27380
+ const {
27381
+ width,
27382
+ height,
27383
+ $
27384
+ } = getCssDimensions(domElement);
27385
+ let x = ($ ? round(rect.width) : rect.width) / width;
27386
+ let y = ($ ? round(rect.height) : rect.height) / height;
27387
+ if (!x || !Number.isFinite(x)) {
27388
+ x = 1;
27389
+ }
27390
+ if (!y || !Number.isFinite(y)) {
27391
+ y = 1;
27392
+ }
27393
+ return {
27394
+ x,
27395
+ y
27396
+ };
27397
+ }
27398
+ const noOffsets = /* @__PURE__ */ createCoords(0);
27399
+ function getVisualOffsets(element) {
27400
+ const win = getWindow(element);
27401
+ if (!isWebKit() || !win.visualViewport) {
27402
+ return noOffsets;
27403
+ }
27404
+ return {
27405
+ x: win.visualViewport.offsetLeft,
27406
+ y: win.visualViewport.offsetTop
27407
+ };
27408
+ }
27409
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
27410
+ if (isFixed === void 0) {
27411
+ isFixed = false;
27412
+ }
27413
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
27414
+ return false;
27415
+ }
27416
+ return isFixed;
27417
+ }
27418
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
27419
+ if (includeScale === void 0) {
27420
+ includeScale = false;
27421
+ }
27422
+ if (isFixedStrategy === void 0) {
27423
+ isFixedStrategy = false;
27424
+ }
27425
+ const clientRect2 = element.getBoundingClientRect();
27426
+ const domElement = unwrapElement(element);
27427
+ let scale = createCoords(1);
27428
+ if (includeScale) {
27429
+ if (offsetParent) {
27430
+ if (isElement(offsetParent)) {
27431
+ scale = getScale(offsetParent);
27432
+ }
27433
+ } else {
27434
+ scale = getScale(element);
27435
+ }
27436
+ }
27437
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
27438
+ let x = (clientRect2.left + visualOffsets.x) / scale.x;
27439
+ let y = (clientRect2.top + visualOffsets.y) / scale.y;
27440
+ let width = clientRect2.width / scale.x;
27441
+ let height = clientRect2.height / scale.y;
27442
+ if (domElement) {
27443
+ const win = getWindow(domElement);
27444
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
27445
+ let currentWin = win;
27446
+ let currentIFrame = getFrameElement(currentWin);
27447
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
27448
+ const iframeScale = getScale(currentIFrame);
27449
+ const iframeRect = currentIFrame.getBoundingClientRect();
27450
+ const css = getComputedStyle$1(currentIFrame);
27451
+ const left2 = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
27452
+ const top2 = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
27453
+ x *= iframeScale.x;
27454
+ y *= iframeScale.y;
27455
+ width *= iframeScale.x;
27456
+ height *= iframeScale.y;
27457
+ x += left2;
27458
+ y += top2;
27459
+ currentWin = getWindow(currentIFrame);
27460
+ currentIFrame = getFrameElement(currentWin);
27461
+ }
27462
+ }
27463
+ return rectToClientRect({
27464
+ width,
27465
+ height,
27466
+ x,
27467
+ y
27468
+ });
27469
+ }
27470
+ function getWindowScrollBarX(element, rect) {
27471
+ const leftScroll = getNodeScroll(element).scrollLeft;
27472
+ if (!rect) {
27473
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
27474
+ }
27475
+ return rect.left + leftScroll;
27476
+ }
27477
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
27478
+ if (ignoreScrollbarX === void 0) {
27479
+ ignoreScrollbarX = false;
27480
+ }
27481
+ const htmlRect = documentElement.getBoundingClientRect();
27482
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
27483
+ // RTL <body> scrollbar.
27484
+ getWindowScrollBarX(documentElement, htmlRect)
27485
+ ));
27486
+ const y = htmlRect.top + scroll.scrollTop;
27487
+ return {
27488
+ x,
27489
+ y
27490
+ };
27491
+ }
27492
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
27493
+ let {
27494
+ elements,
27495
+ rect,
27496
+ offsetParent,
27497
+ strategy
27498
+ } = _ref;
27499
+ const isFixed = strategy === "fixed";
27500
+ const documentElement = getDocumentElement(offsetParent);
27501
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
27502
+ if (offsetParent === documentElement || topLayer && isFixed) {
27503
+ return rect;
27504
+ }
27505
+ let scroll = {
27506
+ scrollLeft: 0,
27507
+ scrollTop: 0
27508
+ };
27509
+ let scale = createCoords(1);
27510
+ const offsets = createCoords(0);
27511
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
27512
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
27513
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
27514
+ scroll = getNodeScroll(offsetParent);
27515
+ }
27516
+ if (isHTMLElement(offsetParent)) {
27517
+ const offsetRect = getBoundingClientRect(offsetParent);
27518
+ scale = getScale(offsetParent);
27519
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
27520
+ offsets.y = offsetRect.y + offsetParent.clientTop;
27521
+ }
27522
+ }
27523
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
27524
+ return {
27525
+ width: rect.width * scale.x,
27526
+ height: rect.height * scale.y,
27527
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
27528
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
27529
+ };
27530
+ }
27531
+ function getClientRects(element) {
27532
+ return Array.from(element.getClientRects());
27533
+ }
27534
+ function getDocumentRect(element) {
27535
+ const html = getDocumentElement(element);
27536
+ const scroll = getNodeScroll(element);
27537
+ const body = element.ownerDocument.body;
27538
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
27539
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
27540
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
27541
+ const y = -scroll.scrollTop;
27542
+ if (getComputedStyle$1(body).direction === "rtl") {
27543
+ x += max(html.clientWidth, body.clientWidth) - width;
27544
+ }
27545
+ return {
27546
+ width,
27547
+ height,
27548
+ x,
27549
+ y
27550
+ };
27551
+ }
27552
+ function getViewportRect(element, strategy) {
27553
+ const win = getWindow(element);
27554
+ const html = getDocumentElement(element);
27555
+ const visualViewport = win.visualViewport;
27556
+ let width = html.clientWidth;
27557
+ let height = html.clientHeight;
27558
+ let x = 0;
27559
+ let y = 0;
27560
+ if (visualViewport) {
27561
+ width = visualViewport.width;
27562
+ height = visualViewport.height;
27563
+ const visualViewportBased = isWebKit();
27564
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
27565
+ x = visualViewport.offsetLeft;
27566
+ y = visualViewport.offsetTop;
27567
+ }
27568
+ }
27569
+ return {
27570
+ width,
27571
+ height,
27572
+ x,
27573
+ y
27574
+ };
27575
+ }
27576
+ function getInnerBoundingClientRect(element, strategy) {
27577
+ const clientRect2 = getBoundingClientRect(element, true, strategy === "fixed");
27578
+ const top2 = clientRect2.top + element.clientTop;
27579
+ const left2 = clientRect2.left + element.clientLeft;
27580
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
27581
+ const width = element.clientWidth * scale.x;
27582
+ const height = element.clientHeight * scale.y;
27583
+ const x = left2 * scale.x;
27584
+ const y = top2 * scale.y;
27585
+ return {
27586
+ width,
27587
+ height,
27588
+ x,
27589
+ y
27590
+ };
27591
+ }
27592
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
27593
+ let rect;
27594
+ if (clippingAncestor === "viewport") {
27595
+ rect = getViewportRect(element, strategy);
27596
+ } else if (clippingAncestor === "document") {
27597
+ rect = getDocumentRect(getDocumentElement(element));
27598
+ } else if (isElement(clippingAncestor)) {
27599
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
27600
+ } else {
27601
+ const visualOffsets = getVisualOffsets(element);
27602
+ rect = {
27603
+ x: clippingAncestor.x - visualOffsets.x,
27604
+ y: clippingAncestor.y - visualOffsets.y,
27605
+ width: clippingAncestor.width,
27606
+ height: clippingAncestor.height
27607
+ };
27608
+ }
27609
+ return rectToClientRect(rect);
27610
+ }
27611
+ function hasFixedPositionAncestor(element, stopNode) {
27612
+ const parentNode2 = getParentNode(element);
27613
+ if (parentNode2 === stopNode || !isElement(parentNode2) || isLastTraversableNode(parentNode2)) {
27614
+ return false;
27615
+ }
27616
+ return getComputedStyle$1(parentNode2).position === "fixed" || hasFixedPositionAncestor(parentNode2, stopNode);
27617
+ }
27618
+ function getClippingElementAncestors(element, cache) {
27619
+ const cachedResult2 = cache.get(element);
27620
+ if (cachedResult2) {
27621
+ return cachedResult2;
27622
+ }
27623
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
27624
+ let currentContainingBlockComputedStyle = null;
27625
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
27626
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
27627
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
27628
+ const computedStyle = getComputedStyle$1(currentNode);
27629
+ const currentNodeIsContaining = isContainingBlock(currentNode);
27630
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
27631
+ currentContainingBlockComputedStyle = null;
27632
+ }
27633
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
27634
+ if (shouldDropCurrentNode) {
27635
+ result = result.filter((ancestor) => ancestor !== currentNode);
27636
+ } else {
27637
+ currentContainingBlockComputedStyle = computedStyle;
27638
+ }
27639
+ currentNode = getParentNode(currentNode);
27640
+ }
27641
+ cache.set(element, result);
27642
+ return result;
27643
+ }
27644
+ function getClippingRect(_ref) {
27645
+ let {
27646
+ element,
27647
+ boundary,
27648
+ rootBoundary,
27649
+ strategy
27650
+ } = _ref;
27651
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
27652
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
27653
+ const firstClippingAncestor = clippingAncestors[0];
27654
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
27655
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
27656
+ accRect.top = max(rect.top, accRect.top);
27657
+ accRect.right = min(rect.right, accRect.right);
27658
+ accRect.bottom = min(rect.bottom, accRect.bottom);
27659
+ accRect.left = max(rect.left, accRect.left);
27660
+ return accRect;
27661
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
27662
+ return {
27663
+ width: clippingRect.right - clippingRect.left,
27664
+ height: clippingRect.bottom - clippingRect.top,
27665
+ x: clippingRect.left,
27666
+ y: clippingRect.top
27667
+ };
27668
+ }
27669
+ function getDimensions(element) {
27670
+ const {
27671
+ width,
27672
+ height
27673
+ } = getCssDimensions(element);
27674
+ return {
27675
+ width,
27676
+ height
27677
+ };
27678
+ }
27679
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
27680
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
27681
+ const documentElement = getDocumentElement(offsetParent);
27682
+ const isFixed = strategy === "fixed";
27683
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
27684
+ let scroll = {
27685
+ scrollLeft: 0,
27686
+ scrollTop: 0
27687
+ };
27688
+ const offsets = createCoords(0);
27689
+ function setLeftRTLScrollbarOffset() {
27690
+ offsets.x = getWindowScrollBarX(documentElement);
27691
+ }
27692
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
27693
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
27694
+ scroll = getNodeScroll(offsetParent);
27695
+ }
27696
+ if (isOffsetParentAnElement) {
27697
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
27698
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
27699
+ offsets.y = offsetRect.y + offsetParent.clientTop;
27700
+ } else if (documentElement) {
27701
+ setLeftRTLScrollbarOffset();
27702
+ }
27703
+ }
27704
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
27705
+ setLeftRTLScrollbarOffset();
27706
+ }
27707
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
27708
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
27709
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
27710
+ return {
27711
+ x,
27712
+ y,
27713
+ width: rect.width,
27714
+ height: rect.height
27715
+ };
27716
+ }
27717
+ function isStaticPositioned(element) {
27718
+ return getComputedStyle$1(element).position === "static";
27719
+ }
27720
+ function getTrueOffsetParent(element, polyfill) {
27721
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
27722
+ return null;
27723
+ }
27724
+ if (polyfill) {
27725
+ return polyfill(element);
27726
+ }
27727
+ let rawOffsetParent = element.offsetParent;
27728
+ if (getDocumentElement(element) === rawOffsetParent) {
27729
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
27730
+ }
27731
+ return rawOffsetParent;
27732
+ }
27733
+ function getOffsetParent(element, polyfill) {
27734
+ const win = getWindow(element);
27735
+ if (isTopLayer(element)) {
27736
+ return win;
27737
+ }
27738
+ if (!isHTMLElement(element)) {
27739
+ let svgOffsetParent = getParentNode(element);
27740
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
27741
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
27742
+ return svgOffsetParent;
27743
+ }
27744
+ svgOffsetParent = getParentNode(svgOffsetParent);
27745
+ }
27746
+ return win;
27747
+ }
27748
+ let offsetParent = getTrueOffsetParent(element, polyfill);
27749
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
27750
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
27751
+ }
27752
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
27753
+ return win;
27754
+ }
27755
+ return offsetParent || getContainingBlock(element) || win;
27756
+ }
27757
+ const getElementRects = async function(data) {
27758
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
27759
+ const getDimensionsFn = this.getDimensions;
27760
+ const floatingDimensions = await getDimensionsFn(data.floating);
27761
+ return {
27762
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
27763
+ floating: {
27764
+ x: 0,
27765
+ y: 0,
27766
+ width: floatingDimensions.width,
27767
+ height: floatingDimensions.height
27768
+ }
27769
+ };
27770
+ };
27771
+ function isRTL(element) {
27772
+ return getComputedStyle$1(element).direction === "rtl";
27773
+ }
27774
+ const platform = {
27775
+ convertOffsetParentRelativeRectToViewportRelativeRect,
27776
+ getDocumentElement,
27777
+ getClippingRect,
27778
+ getOffsetParent,
27779
+ getElementRects,
27780
+ getClientRects,
27781
+ getDimensions,
27782
+ getScale,
27783
+ isElement,
27784
+ isRTL
27785
+ };
27786
+ function rectsAreEqual(a, b) {
27787
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
27788
+ }
27789
+ function observeMove(element, onMove) {
27790
+ let io = null;
27791
+ let timeoutId;
27792
+ const root = getDocumentElement(element);
27793
+ function cleanup() {
27794
+ var _io;
27795
+ clearTimeout(timeoutId);
27796
+ (_io = io) == null || _io.disconnect();
27797
+ io = null;
27798
+ }
27799
+ function refresh(skip, threshold) {
27800
+ if (skip === void 0) {
27801
+ skip = false;
27802
+ }
27803
+ if (threshold === void 0) {
27804
+ threshold = 1;
27805
+ }
27806
+ cleanup();
27807
+ const elementRectForRootMargin = element.getBoundingClientRect();
27808
+ const {
27809
+ left: left2,
27810
+ top: top2,
27811
+ width,
27812
+ height
27813
+ } = elementRectForRootMargin;
27814
+ if (!skip) {
27815
+ onMove();
27816
+ }
27817
+ if (!width || !height) {
27818
+ return;
27819
+ }
27820
+ const insetTop = floor(top2);
27821
+ const insetRight = floor(root.clientWidth - (left2 + width));
27822
+ const insetBottom = floor(root.clientHeight - (top2 + height));
27823
+ const insetLeft = floor(left2);
27824
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
27825
+ const options = {
27826
+ rootMargin,
27827
+ threshold: max(0, min(1, threshold)) || 1
27828
+ };
27829
+ let isFirstUpdate = true;
27830
+ function handleObserve(entries) {
27831
+ const ratio = entries[0].intersectionRatio;
27832
+ if (ratio !== threshold) {
27833
+ if (!isFirstUpdate) {
27834
+ return refresh();
27835
+ }
27836
+ if (!ratio) {
27837
+ timeoutId = setTimeout(() => {
27838
+ refresh(false, 1e-7);
27839
+ }, 1e3);
27840
+ } else {
27841
+ refresh(false, ratio);
27842
+ }
27843
+ }
27844
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
27845
+ refresh();
27846
+ }
27847
+ isFirstUpdate = false;
27848
+ }
27849
+ try {
27850
+ io = new IntersectionObserver(handleObserve, {
27851
+ ...options,
27852
+ // Handle <iframe>s
27853
+ root: root.ownerDocument
27854
+ });
27855
+ } catch (_e) {
27856
+ io = new IntersectionObserver(handleObserve, options);
27857
+ }
27858
+ io.observe(element);
27859
+ }
27860
+ refresh(true);
27861
+ return cleanup;
27862
+ }
27863
+ function autoUpdate(reference2, floating, update, options) {
27864
+ if (options === void 0) {
27865
+ options = {};
27866
+ }
27867
+ const {
27868
+ ancestorScroll = true,
27869
+ ancestorResize = true,
27870
+ elementResize = typeof ResizeObserver === "function",
27871
+ layoutShift = typeof IntersectionObserver === "function",
27872
+ animationFrame = false
27873
+ } = options;
27874
+ const referenceEl = unwrapElement(reference2);
27875
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
27876
+ ancestors.forEach((ancestor) => {
27877
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
27878
+ passive: true
27879
+ });
27880
+ ancestorResize && ancestor.addEventListener("resize", update);
27881
+ });
27882
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
27883
+ let reobserveFrame = -1;
27884
+ let resizeObserver = null;
27885
+ if (elementResize) {
27886
+ resizeObserver = new ResizeObserver((_ref) => {
27887
+ let [firstEntry] = _ref;
27888
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
27889
+ resizeObserver.unobserve(floating);
27890
+ cancelAnimationFrame(reobserveFrame);
27891
+ reobserveFrame = requestAnimationFrame(() => {
27892
+ var _resizeObserver;
27893
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
27894
+ });
27895
+ }
27896
+ update();
27897
+ });
27898
+ if (referenceEl && !animationFrame) {
27899
+ resizeObserver.observe(referenceEl);
27900
+ }
27901
+ resizeObserver.observe(floating);
27902
+ }
27903
+ let frameId;
27904
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference2) : null;
27905
+ if (animationFrame) {
27906
+ frameLoop();
27907
+ }
27908
+ function frameLoop() {
27909
+ const nextRefRect = getBoundingClientRect(reference2);
27910
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
27911
+ update();
27912
+ }
27913
+ prevRefRect = nextRefRect;
27914
+ frameId = requestAnimationFrame(frameLoop);
27915
+ }
27916
+ update();
27917
+ return () => {
27918
+ var _resizeObserver2;
27919
+ ancestors.forEach((ancestor) => {
27920
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
27921
+ ancestorResize && ancestor.removeEventListener("resize", update);
27922
+ });
27923
+ cleanupIo == null || cleanupIo();
27924
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
27925
+ resizeObserver = null;
27926
+ if (animationFrame) {
27927
+ cancelAnimationFrame(frameId);
27928
+ }
27929
+ };
27930
+ }
27931
+ const hide = hide$1;
27932
+ const computePosition = (reference2, floating, options) => {
27933
+ const cache = /* @__PURE__ */ new Map();
27934
+ const mergedOptions = {
27935
+ platform,
27936
+ ...options
27937
+ };
27938
+ const platformWithCache = {
27939
+ ...mergedOptions.platform,
27940
+ _c: cache
27941
+ };
27942
+ return computePosition$1(reference2, floating, {
27943
+ ...mergedOptions,
27944
+ platform: platformWithCache
27945
+ });
27946
+ };
27947
+ const SEPARATOR_CLASS = "pagination-separator";
27948
+ const SEPARATOR_FLOATING_CLASS = "pagination-separator-floating";
27949
+ const isDebugging = false;
27950
+ const cleanupFunctions = /* @__PURE__ */ new Set();
27951
+ const Pagination = Extension.create({
27952
+ name: "pagination",
27953
+ addStorage() {
27954
+ return {
27955
+ height: 0,
27956
+ sectionData: null
27957
+ };
27958
+ },
27959
+ addCommands() {
27960
+ return {
27961
+ insertPageBreak: () => ({ commands: commands2 }) => {
27962
+ return commands2.insertContent({
27963
+ type: "hardBreak"
27964
+ });
27965
+ }
27966
+ };
27967
+ },
27968
+ addShortcuts() {
27969
+ return {
27970
+ "Mod-Enter": () => this.editor.commands.insertPageBreak()
27971
+ };
27972
+ },
27973
+ /**
27974
+ * The pagination plugin is responsible for calculating page breaks, and redering them using decorations.
27975
+ */
27976
+ addPmPlugins() {
27977
+ const editor = this.editor;
27978
+ let isUpdating = false;
27979
+ let shouldUpdate = false;
27980
+ let hasInitialized = false;
27981
+ let shouldInitialize = false;
27982
+ const paginationPlugin = new Plugin({
27983
+ key: PaginationPluginKey,
27984
+ state: {
27985
+ isReadyToInit: false,
27986
+ init(_, state) {
27987
+ return {
27988
+ isReadyToInit: false,
27989
+ decorations: DecorationSet.empty,
27990
+ isDebugging
27991
+ };
27992
+ },
27993
+ apply(tr, oldState, prevEditorState, newEditorState) {
27994
+ const meta = tr.getMeta(PaginationPluginKey);
27995
+ if (meta && meta.isReadyToInit) {
27996
+ shouldUpdate = true;
27997
+ shouldInitialize = meta.isReadyToInit;
27998
+ }
27999
+ const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
28000
+ if (imagePluginTransaction) {
28001
+ if (imagePluginTransaction.type === "remove") {
28002
+ const imagePos = imagePluginTransaction.pos;
28003
+ const domImage = editor.view.domAtPos(imagePos).node.querySelector("img");
28004
+ if (domImage.complete) onImageLoad(editor);
28005
+ else domImage.onload = () => onImageLoad(editor);
28006
+ }
28007
+ return { ...oldState };
28008
+ }
28009
+ const isAnnotationUpdate = tr.getMeta("fieldAnnotationUpdate");
28010
+ if (isAnnotationUpdate) {
28011
+ return { ...oldState };
28012
+ }
28013
+ if (!shouldInitialize && !oldState.isReadyToInit) {
28014
+ return { ...oldState };
28015
+ }
28016
+ if (meta && meta.decorations) {
28017
+ shouldUpdate = true;
28018
+ return {
28019
+ ...oldState,
28020
+ decorations: meta.decorations.map(tr.mapping, tr.doc)
28021
+ };
28022
+ }
28023
+ const isForceUpdate = tr.getMeta("forceUpdatePagination");
26600
28024
  if (!isForceUpdate && prevEditorState.doc.eq(newEditorState.doc) && hasInitialized) {
26601
28025
  shouldUpdate = false;
26602
28026
  return { ...oldState };
@@ -26613,7 +28037,7 @@ const Pagination = Extension.create({
26613
28037
  view: (view) => {
26614
28038
  let previousDecorations = DecorationSet.empty;
26615
28039
  return {
26616
- update: (view2) => {
28040
+ update: (view2, prevState) => {
26617
28041
  if (!shouldUpdate || isUpdating) return;
26618
28042
  isUpdating = true;
26619
28043
  hasInitialized = true;
@@ -26630,6 +28054,9 @@ const Pagination = Extension.create({
26630
28054
  }
26631
28055
  });
26632
28056
  return [paginationPlugin];
28057
+ },
28058
+ onDestroy() {
28059
+ cleanupFloatingSeparators();
26633
28060
  }
26634
28061
  });
26635
28062
  const getHeaderFooterId = (currentPageNumber, sectionType, editor, node = null) => {
@@ -26667,12 +28094,23 @@ const getHeaderFooterId = (currentPageNumber, sectionType, editor, node = null)
26667
28094
  const performUpdate = (editor, view, previousDecorations) => {
26668
28095
  const sectionData = editor.storage.pagination.sectionData;
26669
28096
  const newDecorations = calculatePageBreaks(view, editor, sectionData);
28097
+ const editorElement = editor.options.element;
26670
28098
  if (!previousDecorations.eq(newDecorations)) {
26671
28099
  const updateTransaction = view.state.tr.setMeta(
26672
28100
  PaginationPluginKey,
26673
28101
  { decorations: newDecorations }
26674
28102
  );
26675
28103
  view.dispatch(updateTransaction);
28104
+ requestAnimationFrame(() => {
28105
+ requestAnimationFrame(() => {
28106
+ cleanupFloatingSeparators();
28107
+ const separators = [...editorElement.querySelectorAll(`.${SEPARATOR_CLASS}--table`)];
28108
+ separators.forEach((separator) => {
28109
+ const { cleanup } = createFloatingSeparator(separator, editor);
28110
+ cleanupFunctions.add(cleanup);
28111
+ });
28112
+ });
28113
+ });
26676
28114
  }
26677
28115
  editor.emit("paginationUpdate");
26678
28116
  };
@@ -26713,16 +28151,15 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26713
28151
  const decorations = [];
26714
28152
  const { pageSize, pageMargins } = editor.converter.pageStyles;
26715
28153
  const pageHeight = pageSize.height * 96;
26716
- editor.options.scale;
26717
28154
  let currentPageNumber = 1;
26718
28155
  let pageHeightThreshold = pageHeight;
26719
28156
  let footer = null, header = null;
26720
28157
  const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
26721
- const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor);
28158
+ const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
26722
28159
  const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
26723
28160
  decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
26724
28161
  const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
26725
- const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor);
28162
+ const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
26726
28163
  pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
26727
28164
  let coords = view?.coordsAtPos(doc2.content.size);
26728
28165
  if (!coords) return [];
@@ -26741,7 +28178,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26741
28178
  if (currentPageNumber === 1) {
26742
28179
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
26743
28180
  decorations.pop();
26744
- const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
28181
+ const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
26745
28182
  const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
26746
28183
  decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
26747
28184
  }
@@ -26757,7 +28194,9 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26757
28194
  }
26758
28195
  if (isHardBreakNode || shouldAddPageBreak) {
26759
28196
  const $currentPos = view.state.doc.resolve(currentPos);
28197
+ const table = findParentNodeClosestToPos($currentPos, (node2) => node2.type.name === "table");
26760
28198
  const tableRow = findParentNodeClosestToPos($currentPos, (node2) => node2.type.name === "tableRow");
28199
+ let isInTable2 = table || tableRow ? true : false;
26761
28200
  if (tableRow) {
26762
28201
  currentNode = tableRow.node;
26763
28202
  currentPos = tableRow.pos;
@@ -26770,13 +28209,13 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26770
28209
  const footerId2 = getHeaderFooterId(currentPageNumber, "footerIds", editor, currentNode);
26771
28210
  currentPageNumber++;
26772
28211
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor);
26773
- header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
28212
+ header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
26774
28213
  footer = createFooter(pageMargins, pageSize, sectionData, footerId2, editor, currentPageNumber - 1);
26775
28214
  const bufferHeight2 = pageHeightThreshold - actualBreakBottom;
26776
28215
  const { node: spacingNode2 } = createFinalPagePadding(bufferHeight2);
26777
28216
  const pageSpacer2 = Decoration.widget(breakPos, spacingNode2, { key: "stable-key" });
26778
28217
  decorations.push(pageSpacer2);
26779
- const pageBreak2 = createPageBreak({ editor, header, footer });
28218
+ const pageBreak2 = createPageBreak({ editor, header, footer, isInTable: isInTable2 });
26780
28219
  decorations.push(Decoration.widget(breakPos, pageBreak2, { key: "stable-key" }));
26781
28220
  pageHeightThreshold = actualBreakBottom + (pageHeight - header.headerHeight - footer.footerHeight);
26782
28221
  }
@@ -26785,7 +28224,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26785
28224
  const lastNodeCoords = view.coordsAtPos(finalPos);
26786
28225
  const headerId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
26787
28226
  const footerId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
26788
- header = createHeader(pageMargins, pageSize, sectionData, headerId, editor);
28227
+ header = createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber);
26789
28228
  footer = createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber);
26790
28229
  const bufferHeight = pageHeightThreshold - lastNodeCoords.bottom;
26791
28230
  const { node: spacingNode } = createFinalPagePadding(bufferHeight);
@@ -26802,6 +28241,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26802
28241
  totalPageNumber.innerText = currentPageNumber;
26803
28242
  }
26804
28243
  });
28244
+ editor.currentTotalPages = currentPageNumber;
26805
28245
  return decorations;
26806
28246
  }
26807
28247
  function createFinalPagePadding(bufferHeight) {
@@ -26812,7 +28252,7 @@ function createFinalPagePadding(bufferHeight) {
26812
28252
  div2.style.height = bufferHeight + "px";
26813
28253
  return { nodeHeight: bufferHeight, node: div2 };
26814
28254
  }
26815
- function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
28255
+ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
26816
28256
  const headerDef = sectionData.headers?.[headerId];
26817
28257
  const minHeaderHeight = pageMargins.top * 96;
26818
28258
  const headerMargin = pageMargins.header * 96;
@@ -26839,7 +28279,8 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
26839
28279
  appendToBody: false,
26840
28280
  sectionId: headerId,
26841
28281
  type: "header",
26842
- availableHeight
28282
+ availableHeight,
28283
+ currentPageNumber
26843
28284
  });
26844
28285
  editor.converter.headerEditors.push({
26845
28286
  id: headerId,
@@ -26865,13 +28306,6 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
26865
28306
  const minFooterHeight = pageMargins.bottom * 96;
26866
28307
  const footerPaddingFromEdge = pageMargins.footer * 96;
26867
28308
  const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
26868
- const sectionContainer = footerDef?.sectionContainer?.cloneNode(true);
26869
- const autoPageNumber = sectionContainer?.querySelector('span[data-id="auto-page-number"]');
26870
- if (autoPageNumber) {
26871
- const fontSize = autoPageNumber.previousElementSibling?.style?.fontSize || autoPageNumber.nextElementSibling?.style?.fontSize;
26872
- if (fontSize) autoPageNumber.style.fontSize = fontSize;
26873
- autoPageNumber.innerText = currentPageNumber;
26874
- }
26875
28309
  const editorContainer = document.createElement("div");
26876
28310
  if (!footerId && !editor.converter.footerIds["default"]) {
26877
28311
  footerId = "rId" + generateDocxRandomId();
@@ -26891,7 +28325,8 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
26891
28325
  appendToBody: false,
26892
28326
  sectionId: footerId,
26893
28327
  type: "footer",
26894
- availableHeight: footerHeight
28328
+ availableHeight: footerHeight,
28329
+ currentPageNumber
26895
28330
  });
26896
28331
  editor.converter.footerEditors.push({
26897
28332
  id: footerId,
@@ -26917,7 +28352,7 @@ const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
26917
28352
  editor.setEditable(false, false);
26918
28353
  toggleHeaderFooterEditMode(editor, currentFocusedSectionEditor, true);
26919
28354
  };
26920
- function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter }) {
28355
+ function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
26921
28356
  const { pageSize, pageMargins } = editor.converter.pageStyles;
26922
28357
  let sectionHeight = 0;
26923
28358
  const paginationDiv = document.createElement("div");
@@ -26936,7 +28371,10 @@ function createPageBreak({ editor, header, footer, footerBottom = null, isFirstH
26936
28371
  const separatorHeight = 20;
26937
28372
  sectionHeight += separatorHeight;
26938
28373
  const separator = document.createElement("div");
26939
- separator.className = "pagination-separator";
28374
+ separator.classList.add(SEPARATOR_CLASS);
28375
+ if (isInTable2) {
28376
+ separator.classList.add(`${SEPARATOR_CLASS}--table`);
28377
+ }
26940
28378
  innerDiv.appendChild(separator);
26941
28379
  }
26942
28380
  if (header) {
@@ -26975,6 +28413,85 @@ const onImageLoad = (editor) => {
26975
28413
  editor.view.dispatch(newTr);
26976
28414
  });
26977
28415
  };
28416
+ function createFloatingSeparator(separator, editor) {
28417
+ const floatingSeparator = document.createElement("div");
28418
+ floatingSeparator.classList.add(SEPARATOR_FLOATING_CLASS);
28419
+ floatingSeparator.dataset.floatingSeparator = "";
28420
+ const editorElement = editor.options.element;
28421
+ editorElement.append(floatingSeparator);
28422
+ const updatePosition2 = () => {
28423
+ computePosition(separator, floatingSeparator, {
28424
+ strategy: "absolute",
28425
+ placement: "top-start",
28426
+ middleware: [
28427
+ hide(),
28428
+ {
28429
+ name: "copy",
28430
+ fn: ({ elements }) => {
28431
+ const rect = elements.reference.getBoundingClientRect();
28432
+ const containerRect = editorElement.getBoundingClientRect();
28433
+ const scaleFactor = getScaleFactor(editorElement);
28434
+ const x = Math.round((rect.left - containerRect.left) / scaleFactor);
28435
+ const y = Math.round((rect.top - containerRect.top) / scaleFactor);
28436
+ const width = Math.round(rect.width / scaleFactor);
28437
+ const height = Math.round(rect.height / scaleFactor);
28438
+ return {
28439
+ x,
28440
+ y,
28441
+ data: { width, height }
28442
+ };
28443
+ }
28444
+ }
28445
+ ]
28446
+ }).then(({ x, y, middlewareData }) => {
28447
+ Object.assign(floatingSeparator.style, {
28448
+ top: `${y}px`,
28449
+ left: `${x}px`,
28450
+ width: `${middlewareData.copy.width}px`,
28451
+ height: `${middlewareData.copy.height}px`,
28452
+ visibility: middlewareData.hide?.referenceHidden ? "hidden" : "visible"
28453
+ });
28454
+ });
28455
+ };
28456
+ const cleanup = autoUpdate(
28457
+ separator,
28458
+ floatingSeparator,
28459
+ updatePosition2
28460
+ );
28461
+ const extendedCleanup = () => {
28462
+ floatingSeparator?.remove();
28463
+ cleanup();
28464
+ };
28465
+ return {
28466
+ cleanup: extendedCleanup,
28467
+ updatePosition: updatePosition2
28468
+ };
28469
+ }
28470
+ function cleanupFloatingSeparators() {
28471
+ cleanupFunctions.forEach((cleanup) => cleanup());
28472
+ cleanupFunctions.clear();
28473
+ }
28474
+ function getScaleFactor(element) {
28475
+ let scale = 1;
28476
+ let currentElement = element;
28477
+ while (currentElement && currentElement !== document.documentElement) {
28478
+ let zoomStyle = currentElement.style.zoom;
28479
+ if (zoomStyle) {
28480
+ let zoom = parseFloat(zoomStyle) || 1;
28481
+ scale *= zoom;
28482
+ }
28483
+ let transformStyle = currentElement.style.transform;
28484
+ if (transformStyle) {
28485
+ let scaleMatch = transformStyle.match(/scale\(([^)]+)\)/);
28486
+ if (scaleMatch) {
28487
+ let scaleValue = parseFloat(scaleMatch[1]) || 1;
28488
+ scale *= scaleValue;
28489
+ }
28490
+ }
28491
+ currentElement = currentElement.parentElement;
28492
+ }
28493
+ return scale;
28494
+ }
26978
28495
  class SearchQuery {
26979
28496
  /**
26980
28497
  Create a query object.
@@ -27387,6 +28904,239 @@ const Search = Extension.create({
27387
28904
  };
27388
28905
  }
27389
28906
  });
28907
+ const NodeResizerKey = new PluginKey("node-resizer");
28908
+ const nodeResizer = (nodeNames = ["image"]) => {
28909
+ let resizeState = {
28910
+ dragging: false,
28911
+ startX: 0,
28912
+ startY: 0,
28913
+ startWidth: 0,
28914
+ handle: null,
28915
+ pos: null,
28916
+ resizableElement: null,
28917
+ aspectRatio: 1
28918
+ };
28919
+ let resizeContainer = null;
28920
+ let editorView = null;
28921
+ let globalClickHandler = null;
28922
+ let globalMousedownHandler = null;
28923
+ return new Plugin({
28924
+ key: NodeResizerKey,
28925
+ state: {
28926
+ init() {
28927
+ return DecorationSet.empty;
28928
+ },
28929
+ apply(tr, oldState, _, newState) {
28930
+ if (tr.getMeta(NodeResizerKey)) {
28931
+ return oldState;
28932
+ }
28933
+ const decorations = [];
28934
+ const { selection } = newState;
28935
+ if (nodeNames.includes(selection.node?.type.name)) {
28936
+ decorations.push(
28937
+ Decoration.node(selection.from, selection.to, {
28938
+ nodeName: "span",
28939
+ class: "sd-editor-resizable-wrapper",
28940
+ "data-pos": selection.from
28941
+ })
28942
+ );
28943
+ }
28944
+ return DecorationSet.create(newState.doc, decorations);
28945
+ }
28946
+ },
28947
+ props: {
28948
+ decorations(state) {
28949
+ return this.getState(state);
28950
+ }
28951
+ },
28952
+ view(view) {
28953
+ editorView = view;
28954
+ globalClickHandler = (event) => {
28955
+ if (!event.target.closest(".sd-editor-resizable-wrapper") && !event.target.closest(".sd-editor-resize-container")) {
28956
+ hideResizeHandles();
28957
+ }
28958
+ };
28959
+ document.addEventListener("click", globalClickHandler);
28960
+ globalMousedownHandler = (event) => {
28961
+ if (event.target.closest(".sd-editor-resize-handle")) {
28962
+ event.preventDefault();
28963
+ event.stopPropagation();
28964
+ startResize(editorView, event, event.target);
28965
+ return true;
28966
+ }
28967
+ };
28968
+ document.addEventListener("mousedown", globalMousedownHandler);
28969
+ return {
28970
+ update(view2, prevState) {
28971
+ const { selection } = view2.state;
28972
+ const prevSelection = prevState.selection;
28973
+ if (selection.from !== prevSelection.from || selection.to !== prevSelection.to) {
28974
+ setTimeout(() => {
28975
+ const selectedResizableWrapper = document.querySelector(".sd-editor-resizable-wrapper");
28976
+ if (selectedResizableWrapper) {
28977
+ showResizeHandles(view2, selectedResizableWrapper);
28978
+ } else {
28979
+ hideResizeHandles();
28980
+ }
28981
+ }, 10);
28982
+ }
28983
+ },
28984
+ destroy() {
28985
+ hideResizeHandles();
28986
+ cleanupEventListeners();
28987
+ if (globalClickHandler) {
28988
+ document.removeEventListener("click", globalClickHandler);
28989
+ globalClickHandler = null;
28990
+ }
28991
+ if (globalMousedownHandler) {
28992
+ document.removeEventListener("mousedown", globalMousedownHandler);
28993
+ globalMousedownHandler = null;
28994
+ }
28995
+ editorView = null;
28996
+ }
28997
+ };
28998
+ }
28999
+ });
29000
+ function showResizeHandles(view, wrapper) {
29001
+ hideResizeHandles();
29002
+ const pos = Number.parseInt(wrapper.getAttribute("data-pos"), 10);
29003
+ const node = view.state.doc.nodeAt(pos);
29004
+ if (!nodeNames.includes(node?.type.name)) return;
29005
+ resizeContainer = document.createElement("div");
29006
+ resizeContainer.className = "sd-editor-resize-container";
29007
+ resizeContainer.style.position = "absolute";
29008
+ resizeContainer.style.pointerEvents = "none";
29009
+ resizeContainer.style.zIndex = "1000";
29010
+ const handles = ["nw", "ne", "sw", "se"];
29011
+ for (const handle of handles) {
29012
+ const handleEl = document.createElement("div");
29013
+ handleEl.className = `sd-editor-resize-handle sd-editor-resize-handle-${handle}`;
29014
+ handleEl.setAttribute("data-handle", handle);
29015
+ handleEl.setAttribute("data-pos", pos);
29016
+ handleEl.style.pointerEvents = "auto";
29017
+ resizeContainer.appendChild(handleEl);
29018
+ }
29019
+ document.body.appendChild(resizeContainer);
29020
+ updateHandlePositions(wrapper.firstElementChild);
29021
+ }
29022
+ function hideResizeHandles() {
29023
+ if (resizeContainer?.parentNode) {
29024
+ resizeContainer.parentNode.removeChild(resizeContainer);
29025
+ resizeContainer = null;
29026
+ }
29027
+ }
29028
+ function updateHandlePositions(resizableElement) {
29029
+ if (!resizeContainer || !resizableElement) return;
29030
+ const rect = resizableElement.getBoundingClientRect();
29031
+ const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
29032
+ const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
29033
+ resizeContainer.style.left = `${rect.left + scrollLeft}px`;
29034
+ resizeContainer.style.top = `${rect.top + scrollTop}px`;
29035
+ resizeContainer.style.width = `${rect.width}px`;
29036
+ resizeContainer.style.height = `${rect.height}px`;
29037
+ }
29038
+ function startResize(view, event, handleElement) {
29039
+ if (!view.hasFocus()) return;
29040
+ const handle = handleElement.getAttribute("data-handle");
29041
+ const pos = Number.parseInt(handleElement.getAttribute("data-pos"), 10);
29042
+ if (view.state.selection.from !== pos || !nodeNames.includes(view.state.selection.node?.type.name)) return;
29043
+ const resizableElement = view.nodeDOM(pos);
29044
+ if (!resizableElement) return;
29045
+ const rect = resizableElement.getBoundingClientRect();
29046
+ resizeState = {
29047
+ dragging: true,
29048
+ startX: event.clientX,
29049
+ startY: event.clientY,
29050
+ startWidth: rect.width,
29051
+ startHeight: rect.height,
29052
+ handle,
29053
+ pos,
29054
+ resizableElement,
29055
+ aspectRatio: rect.width / rect.height
29056
+ };
29057
+ document.addEventListener("mousemove", handleMouseMove2);
29058
+ document.addEventListener("mouseup", handleMouseUp);
29059
+ document.body.style.cursor = getResizeCursor(handle);
29060
+ document.body.style.userSelect = "none";
29061
+ }
29062
+ function handleMouseMove2(event) {
29063
+ if (!resizeState.dragging) return;
29064
+ event.preventDefault();
29065
+ event.stopPropagation();
29066
+ let deltaX = event.clientX - resizeState.startX;
29067
+ event.clientY - resizeState.startY;
29068
+ if (resizeState.handle.includes("w")) deltaX = -deltaX;
29069
+ if (resizeState.handle.includes("n")) ;
29070
+ const newWidth = Math.max(20, resizeState.startWidth + deltaX);
29071
+ if (resizeState.resizableElement) {
29072
+ resizeState.resizableElement.style.width = `${newWidth}px`;
29073
+ resizeState.resizableElement.style.height = "auto";
29074
+ updateHandlePositions(resizeState.resizableElement);
29075
+ }
29076
+ }
29077
+ function handleMouseUp(event) {
29078
+ if (!resizeState.dragging) return;
29079
+ cleanupEventListeners();
29080
+ let deltaX = event.clientX - resizeState.startX;
29081
+ event.clientY - resizeState.startY;
29082
+ if (resizeState.handle.includes("w")) deltaX = -deltaX;
29083
+ if (resizeState.handle.includes("n")) ;
29084
+ const newWidth = Math.max(20, resizeState.startWidth + deltaX);
29085
+ const newHeight = newWidth / resizeState.aspectRatio;
29086
+ if (editorView && resizeState.pos < editorView.state.doc.content.size) {
29087
+ const tr = editorView.state.tr;
29088
+ const node = tr.doc.nodeAt(resizeState.pos);
29089
+ if (nodeNames.includes(node?.type.name)) {
29090
+ const attrs = {
29091
+ ...node.attrs,
29092
+ size: {
29093
+ ...node.attrs.size,
29094
+ width: Math.round(newWidth),
29095
+ height: Math.round(newHeight)
29096
+ }
29097
+ };
29098
+ tr.setNodeMarkup(resizeState.pos, null, attrs);
29099
+ tr.setMeta(NodeResizerKey, { action: "resize" });
29100
+ editorView.dispatch(tr);
29101
+ }
29102
+ }
29103
+ resizeState = {
29104
+ dragging: false,
29105
+ startX: 0,
29106
+ startY: 0,
29107
+ startWidth: 0,
29108
+ startHeight: 0,
29109
+ handle: null,
29110
+ pos: null,
29111
+ resizableElement: null,
29112
+ aspectRatio: 1
29113
+ };
29114
+ }
29115
+ function cleanupEventListeners() {
29116
+ document.removeEventListener("mousemove", handleMouseMove2);
29117
+ document.removeEventListener("mouseup", handleMouseUp);
29118
+ document.body.style.cursor = "";
29119
+ document.body.style.userSelect = "";
29120
+ }
29121
+ function getResizeCursor(handle) {
29122
+ switch (handle) {
29123
+ case "nw":
29124
+ case "se":
29125
+ return "nwse-resize";
29126
+ case "ne":
29127
+ case "sw":
29128
+ return "nesw-resize";
29129
+ default:
29130
+ return "default";
29131
+ }
29132
+ }
29133
+ };
29134
+ const NodeResizer = Extension.create({
29135
+ name: "nodeResizer",
29136
+ addPmPlugins() {
29137
+ return [nodeResizer(["image"])];
29138
+ }
29139
+ });
27390
29140
  const getRichTextExtensions = () => {
27391
29141
  return [
27392
29142
  Bold,
@@ -27424,7 +29174,8 @@ const getRichTextExtensions = () => {
27424
29174
  TrackDelete,
27425
29175
  TrackFormat,
27426
29176
  AiPlugin,
27427
- Image
29177
+ Image,
29178
+ NodeResizer
27428
29179
  ];
27429
29180
  };
27430
29181
  const getStarterExtensions = () => {
@@ -27488,14 +29239,14 @@ const getStarterExtensions = () => {
27488
29239
  ShapeTextbox,
27489
29240
  ContentBlock,
27490
29241
  Search,
27491
- StructuredContent
29242
+ StructuredContent,
29243
+ NodeResizer
27492
29244
  ];
27493
29245
  };
27494
29246
  export {
27495
29247
  Attribute as A,
27496
29248
  CommentsPluginKey as C,
27497
29249
  Editor as E,
27498
- ImagePlaceholderPluginKey as I,
27499
29250
  Mark as M,
27500
29251
  Node$1 as N,
27501
29252
  Placeholder as P,
@@ -27503,10 +29254,10 @@ export {
27503
29254
  _export_sfc as _,
27504
29255
  getQuickFormatList as a,
27505
29256
  generateLinkedStyleString as b,
27506
- findParentNode as c,
29257
+ getFileOpener as c,
27507
29258
  getActiveFormatting as d,
27508
29259
  undoDepth as e,
27509
- findPlaceholder as f,
29260
+ findParentNode as f,
27510
29261
  global as g,
27511
29262
  getStarterExtensions as h,
27512
29263
  isInTable$1 as i,
@@ -27517,6 +29268,8 @@ export {
27517
29268
  index as n,
27518
29269
  AnnotatorHelpers as o,
27519
29270
  getMarksFromSelection as p,
29271
+ getAllowedImageDimensions as q,
27520
29272
  redoDepth as r,
29273
+ startImageUpload as s,
27521
29274
  useHighContrastMode as u
27522
29275
  };