@harbour-enterprises/superdoc 0.12.35 → 0.12.36-next.10

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 (40) hide show
  1. package/dist/chunks/{super-editor.es-B4SPMXXo.cjs → super-editor.es-C5-RTRXN.cjs} +1754 -221
  2. package/dist/chunks/{super-editor.es-D8BL6ojY.es.js → super-editor.es-Zxne04bX.es.js} +1754 -221
  3. package/dist/style.css +36 -7
  4. package/dist/super-editor/ai-writer.es.js +2 -2
  5. package/dist/super-editor/chunks/{converter-DQPyKWs_.js → converter-Dhv5kzsP.js} +108 -9
  6. package/dist/super-editor/chunks/{docx-zipper-cJ42om_0.js → docx-zipper-Co1uS6tK.js} +1 -1
  7. package/dist/super-editor/chunks/{editor-B5TyAe8v.js → editor-D2aY4DLZ.js} +1688 -254
  8. package/dist/super-editor/chunks/{toolbar-CDeO5r_T.js → toolbar-CVZmXsRq.js} +2 -2
  9. package/dist/super-editor/components/pagination-helpers.d.ts.map +1 -1
  10. package/dist/super-editor/converter.es.js +1 -1
  11. package/dist/super-editor/core/Attribute.d.ts +2 -2
  12. package/dist/super-editor/core/Editor.d.ts.map +1 -1
  13. package/dist/super-editor/core/Schema.d.ts +2 -2
  14. package/dist/super-editor/core/helpers/annotator.d.ts +2 -0
  15. package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
  16. package/dist/super-editor/core/helpers/findWordBounds.d.ts +5 -0
  17. package/dist/super-editor/core/helpers/findWordBounds.d.ts.map +1 -0
  18. package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
  19. package/dist/super-editor/core/super-converter/helpers.d.ts.map +1 -1
  20. package/dist/super-editor/core/super-converter/v2/importer/autoPageNumberImporter.d.ts.map +1 -1
  21. package/dist/super-editor/docx-zipper.es.js +2 -2
  22. package/dist/super-editor/editor.es.js +3 -3
  23. package/dist/super-editor/extensions/line-height/line-height.d.ts.map +1 -1
  24. package/dist/super-editor/extensions/page-number/page-number.d.ts +10 -0
  25. package/dist/super-editor/extensions/page-number/page-number.d.ts.map +1 -1
  26. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +2 -1
  27. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
  28. package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
  29. package/dist/super-editor/extensions/paragraph/paragraph.d.ts.map +1 -1
  30. package/dist/super-editor/file-zipper.es.js +1 -1
  31. package/dist/super-editor/style.css +36 -7
  32. package/dist/super-editor/super-editor.es.js +7 -7
  33. package/dist/super-editor/toolbar.es.js +2 -2
  34. package/dist/super-editor.cjs +1 -1
  35. package/dist/super-editor.es.js +1 -1
  36. package/dist/superdoc.cjs +2 -2
  37. package/dist/superdoc.es.js +3 -3
  38. package/dist/superdoc.umd.js +1770 -237
  39. package/dist/superdoc.umd.js.map +1 -1
  40. package/package.json +1 -1
@@ -2573,29 +2573,29 @@ function requireAbs() {
2573
2573
  abs$1 = Math.abs;
2574
2574
  return abs$1;
2575
2575
  }
2576
- var floor$1;
2576
+ var floor$2;
2577
2577
  var hasRequiredFloor;
2578
2578
  function requireFloor() {
2579
- if (hasRequiredFloor) return floor$1;
2579
+ if (hasRequiredFloor) return floor$2;
2580
2580
  hasRequiredFloor = 1;
2581
- floor$1 = Math.floor;
2582
- return floor$1;
2581
+ floor$2 = Math.floor;
2582
+ return floor$2;
2583
2583
  }
2584
- var max$2;
2584
+ var max$3;
2585
2585
  var hasRequiredMax;
2586
2586
  function requireMax() {
2587
- if (hasRequiredMax) return max$2;
2587
+ if (hasRequiredMax) return max$3;
2588
2588
  hasRequiredMax = 1;
2589
- max$2 = Math.max;
2590
- return max$2;
2589
+ max$3 = Math.max;
2590
+ return max$3;
2591
2591
  }
2592
- var min$2;
2592
+ var min$3;
2593
2593
  var hasRequiredMin;
2594
2594
  function requireMin() {
2595
- if (hasRequiredMin) return min$2;
2595
+ if (hasRequiredMin) return min$3;
2596
2596
  hasRequiredMin = 1;
2597
- min$2 = Math.min;
2598
- return min$2;
2597
+ min$3 = Math.min;
2598
+ return min$3;
2599
2599
  }
2600
2600
  var pow;
2601
2601
  var hasRequiredPow;
@@ -2605,13 +2605,13 @@ function requirePow() {
2605
2605
  pow = Math.pow;
2606
2606
  return pow;
2607
2607
  }
2608
- var round$1;
2608
+ var round$2;
2609
2609
  var hasRequiredRound;
2610
2610
  function requireRound() {
2611
- if (hasRequiredRound) return round$1;
2611
+ if (hasRequiredRound) return round$2;
2612
2612
  hasRequiredRound = 1;
2613
- round$1 = Math.round;
2614
- return round$1;
2613
+ round$2 = Math.round;
2614
+ return round$2;
2615
2615
  }
2616
2616
  var _isNaN;
2617
2617
  var hasRequired_isNaN;
@@ -16074,7 +16074,6 @@ const getLineHeightValueString = (lineHeight2, defaultUnit, lineRule = "", isObj
16074
16074
  if (Number.isNaN(value) || value === 0) return {};
16075
16075
  if (lineRule === "atLeast" && value < 1) return {};
16076
16076
  unit = unit ? unit : defaultUnit;
16077
- value += unit ? 4 : 0.2;
16078
16077
  return isObject2 ? { ["line-height"]: `${value}${unit}` } : `line-height: ${value}${unit}`;
16079
16078
  };
16080
16079
  const deobfuscateFont = (arrayBuffer, guidHex) => {
@@ -18863,7 +18862,9 @@ function exportSchemaToJson(params2) {
18863
18862
  shapeContainer: translateShapeContainer,
18864
18863
  shapeTextbox: translateShapeTextbox,
18865
18864
  contentBlock: translateContentBlock,
18866
- structuredContent: translateStructuredContent
18865
+ structuredContent: translateStructuredContent,
18866
+ "page-number": translatePageNumberNode,
18867
+ "total-page-number": translateTotalPageNumberNode
18867
18868
  };
18868
18869
  if (!router[type2]) {
18869
18870
  console.error("No translation function found for node type:", type2);
@@ -19301,7 +19302,10 @@ function translateList(params2) {
19301
19302
  if (Array.isArray(outputNode)) {
19302
19303
  const mapped = [];
19303
19304
  outputNode.forEach((el, index22) => {
19304
- mapped.push(...el.elements);
19305
+ el.elements.forEach((element) => {
19306
+ if (element.name === "w:pPr") return;
19307
+ mapped.push(element);
19308
+ });
19305
19309
  if (index22 < outputNode.length - 1) mapped.push({ name: "w:br", type: "element" });
19306
19310
  });
19307
19311
  mapped.unshift(carbonCopy(pPr));
@@ -20557,6 +20561,81 @@ function translateStructuredContent(params2) {
20557
20561
  elements: nodeElements
20558
20562
  };
20559
20563
  }
20564
+ const translatePageNumberNode = (params2) => {
20565
+ const outputMarks = processOutputMarks(params2.node.attrs?.marksAsAttrs || []);
20566
+ return getAutoPageJson("PAGE", outputMarks);
20567
+ };
20568
+ const translateTotalPageNumberNode = (params2) => {
20569
+ const outputMarks = processOutputMarks(params2.node.attrs?.marksAsAttrs || []);
20570
+ return getAutoPageJson("NUMPAGES", outputMarks);
20571
+ };
20572
+ const getAutoPageJson = (type2, outputMarks = []) => {
20573
+ return [
20574
+ {
20575
+ "name": "w:r",
20576
+ "elements": [
20577
+ {
20578
+ "name": "w:rPr",
20579
+ "elements": outputMarks
20580
+ },
20581
+ {
20582
+ "name": "w:fldChar",
20583
+ "attributes": {
20584
+ "w:fldCharType": "begin"
20585
+ }
20586
+ }
20587
+ ]
20588
+ },
20589
+ {
20590
+ "name": "w:r",
20591
+ "elements": [
20592
+ {
20593
+ "name": "w:rPr",
20594
+ "elements": outputMarks
20595
+ },
20596
+ {
20597
+ "name": "w:instrText",
20598
+ "elements": [
20599
+ {
20600
+ "type": "text",
20601
+ "text": ` ${type2}`
20602
+ }
20603
+ ]
20604
+ }
20605
+ ]
20606
+ },
20607
+ {
20608
+ "name": "w:r",
20609
+ "elements": [
20610
+ {
20611
+ "name": "w:rPr",
20612
+ "elements": outputMarks
20613
+ },
20614
+ {
20615
+ "name": "w:fldChar",
20616
+ "attributes": {
20617
+ "w:fldCharType": "separate"
20618
+ }
20619
+ }
20620
+ ]
20621
+ },
20622
+ {
20623
+ "name": "w:r",
20624
+ "elements": [
20625
+ {
20626
+ "name": "w:rPr",
20627
+ "elements": outputMarks
20628
+ },
20629
+ {
20630
+ "name": "w:fldChar",
20631
+ "attributes": {
20632
+ "w:fldCharType": "end"
20633
+ }
20634
+ }
20635
+ ]
20636
+ }
20637
+ ];
20638
+ };
20560
20639
  const defaultInitialXml = `<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:oel="http://schemas.microsoft.com/office/2019/extlst" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml" xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14"><w:body></w:body></w:document>`;
20561
20640
  const parseXmlToJson = (xml) => {
20562
20641
  return JSON.parse(xmljs.xml2json(xml, null, 2));
@@ -22265,15 +22344,25 @@ const processCombinedNodesForFldChar = (nodesToCombine = []) => {
22265
22344
  if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
22266
22345
  const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
22267
22346
  if (hasPageMarker) {
22268
- processedNodes.push({
22347
+ const pageNumNode = {
22269
22348
  name: "sd:autoPageNumber",
22270
22349
  type: "element"
22350
+ };
22351
+ nodesToCombine.forEach((n) => {
22352
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22353
+ if (rPrNode) pageNumNode.elements = [rPrNode];
22271
22354
  });
22355
+ processedNodes.push(pageNumNode);
22272
22356
  } else if (isNumPages) {
22273
- processedNodes.push({
22357
+ const totalPageNumNode = {
22274
22358
  name: "sd:totalPageNumber",
22275
22359
  type: "element"
22360
+ };
22361
+ nodesToCombine.forEach((n) => {
22362
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22363
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
22276
22364
  });
22365
+ processedNodes.push(totalPageNumNode);
22277
22366
  } else if (urlMatch && urlMatch?.length >= 2) {
22278
22367
  const url = urlMatch[1];
22279
22368
  const textMarks = [];
@@ -22609,8 +22698,13 @@ const handleAutoPageNumber = (params2) => {
22609
22698
  if (nodes.length === 0 || nodes[0].name !== "sd:autoPageNumber") {
22610
22699
  return { nodes: [], consumed: 0 };
22611
22700
  }
22701
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22702
+ const marks = parseMarks(rPr || { elements: [] });
22612
22703
  const processedNode = {
22613
- type: "page-number"
22704
+ type: "page-number",
22705
+ attrs: {
22706
+ marksAsAttrs: marks
22707
+ }
22614
22708
  };
22615
22709
  return { nodes: [processedNode], consumed: 1 };
22616
22710
  };
@@ -22623,8 +22717,13 @@ const handleAutoTotalPageNumber = (params2) => {
22623
22717
  if (nodes.length === 0 || nodes[0].name !== "sd:totalPageNumber") {
22624
22718
  return { nodes: [], consumed: 0 };
22625
22719
  }
22720
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22721
+ const marks = parseMarks(rPr || { elements: [] });
22626
22722
  const processedNode = {
22627
- type: "total-page-number"
22723
+ type: "total-page-number",
22724
+ attrs: {
22725
+ marksAsAttrs: marks
22726
+ }
22628
22727
  };
22629
22728
  return { nodes: [processedNode], consumed: 1 };
22630
22729
  };
@@ -23309,7 +23408,7 @@ const _SuperConverter = class _SuperConverter2 {
23309
23408
  return;
23310
23409
  }
23311
23410
  }
23312
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.35") {
23411
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.36-next.10") {
23313
23412
  const customLocation = "docProps/custom.xml";
23314
23413
  if (!docx[customLocation]) {
23315
23414
  docx[customLocation] = generateCustomXml();
@@ -23776,7 +23875,7 @@ function storeSuperdocVersion(docx) {
23776
23875
  function generateCustomXml() {
23777
23876
  return DEFAULT_CUSTOM_XML;
23778
23877
  }
23779
- function generateSuperdocVersion(pid = 2, version2 = "0.12.35") {
23878
+ function generateSuperdocVersion(pid = 2, version2 = "0.12.36-next.10") {
23780
23879
  return {
23781
23880
  type: "element",
23782
23881
  name: "property",
@@ -26309,7 +26408,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
26309
26408
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
26310
26409
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
26311
26410
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
26312
- 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;
26411
+ 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;
26313
26412
  function getMarksFromSelection(state2) {
26314
26413
  const { from: from2, to, empty: empty2 } = state2.selection;
26315
26414
  const marks = [];
@@ -30718,7 +30817,7 @@ function windowRect(doc2) {
30718
30817
  bottom: doc2.documentElement.clientHeight
30719
30818
  };
30720
30819
  }
30721
- function getSide(value, side) {
30820
+ function getSide$1(value, side) {
30722
30821
  return typeof value == "number" ? value : value[side];
30723
30822
  }
30724
30823
  function clientRect(node2) {
@@ -30746,14 +30845,14 @@ function scrollRectIntoView(view, rect, startDOM) {
30746
30845
  let atTop = elt == doc2.body;
30747
30846
  let bounding = atTop ? windowRect(doc2) : clientRect(elt);
30748
30847
  let moveX = 0, moveY = 0;
30749
- if (rect.top < bounding.top + getSide(scrollThreshold, "top"))
30750
- moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top"));
30751
- else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom"))
30752
- moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom");
30753
- if (rect.left < bounding.left + getSide(scrollThreshold, "left"))
30754
- moveX = -(bounding.left - rect.left + getSide(scrollMargin, "left"));
30755
- else if (rect.right > bounding.right - getSide(scrollThreshold, "right"))
30756
- moveX = rect.right - bounding.right + getSide(scrollMargin, "right");
30848
+ if (rect.top < bounding.top + getSide$1(scrollThreshold, "top"))
30849
+ moveY = -(bounding.top - rect.top + getSide$1(scrollMargin, "top"));
30850
+ else if (rect.bottom > bounding.bottom - getSide$1(scrollThreshold, "bottom"))
30851
+ 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");
30852
+ if (rect.left < bounding.left + getSide$1(scrollThreshold, "left"))
30853
+ moveX = -(bounding.left - rect.left + getSide$1(scrollMargin, "left"));
30854
+ else if (rect.right > bounding.right - getSide$1(scrollThreshold, "right"))
30855
+ moveX = rect.right - bounding.right + getSide$1(scrollMargin, "right");
30757
30856
  if (moveX || moveY) {
30758
30857
  if (atTop) {
30759
30858
  doc2.defaultView.scrollBy(moveX, moveY);
@@ -35692,10 +35791,10 @@ function checkStateComponent(plugin2) {
35692
35791
  if (plugin2.spec.state || plugin2.spec.filterTransaction || plugin2.spec.appendTransaction)
35693
35792
  throw new RangeError("Plugins passed directly to the view must not have a state component");
35694
35793
  }
35695
- const floor = Math.floor;
35794
+ const floor$1 = Math.floor;
35696
35795
  const abs = Math.abs;
35697
- const min$1 = (a, b) => a < b ? a : b;
35698
- const max$1 = (a, b) => a > b ? a : b;
35796
+ const min$2 = (a, b) => a < b ? a : b;
35797
+ const max$2 = (a, b) => a > b ? a : b;
35699
35798
  const isNegativeZero = (n) => n !== 0 ? n < 0 : 1 / n < 0;
35700
35799
  const BIT7 = 64;
35701
35800
  const BIT8 = 128;
@@ -35703,7 +35802,7 @@ const BIT30 = 1 << 29;
35703
35802
  const BITS6 = 63;
35704
35803
  const BITS7 = 127;
35705
35804
  const BITS31 = 2147483647;
35706
- const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
35805
+ const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor$1(num) === num);
35707
35806
  const create$2 = () => /* @__PURE__ */ new Set();
35708
35807
  const isArray$1 = Array.isArray;
35709
35808
  const fromCharCode = String.fromCharCode;
@@ -35767,7 +35866,7 @@ const verifyLen = (encoder, len) => {
35767
35866
  const bufferLen = encoder.cbuf.length;
35768
35867
  if (bufferLen - encoder.cpos < len) {
35769
35868
  encoder.bufs.push(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos));
35770
- encoder.cbuf = new Uint8Array(max$1(bufferLen, len) * 2);
35869
+ encoder.cbuf = new Uint8Array(max$2(bufferLen, len) * 2);
35771
35870
  encoder.cpos = 0;
35772
35871
  }
35773
35872
  };
@@ -35783,7 +35882,7 @@ const write$1 = (encoder, num) => {
35783
35882
  const writeVarUint = (encoder, num) => {
35784
35883
  while (num > BITS7) {
35785
35884
  write$1(encoder, BIT8 | BITS7 & num);
35786
- num = floor(num / 128);
35885
+ num = floor$1(num / 128);
35787
35886
  }
35788
35887
  write$1(encoder, BITS7 & num);
35789
35888
  };
@@ -35793,10 +35892,10 @@ const writeVarInt = (encoder, num) => {
35793
35892
  num = -num;
35794
35893
  }
35795
35894
  write$1(encoder, (num > BITS6 ? BIT8 : 0) | (isNegative ? BIT7 : 0) | BITS6 & num);
35796
- num = floor(num / 64);
35895
+ num = floor$1(num / 64);
35797
35896
  while (num > 0) {
35798
35897
  write$1(encoder, (num > BITS7 ? BIT8 : 0) | BITS7 & num);
35799
- num = floor(num / 128);
35898
+ num = floor$1(num / 128);
35800
35899
  }
35801
35900
  };
35802
35901
  const _strBuffer = new Uint8Array(3e4);
@@ -35829,13 +35928,13 @@ utf8TextEncoder.encodeInto ? _writeVarStringNative : _writeVarStringPolyfill;
35829
35928
  const writeUint8Array = (encoder, uint8Array) => {
35830
35929
  const bufferLen = encoder.cbuf.length;
35831
35930
  const cpos = encoder.cpos;
35832
- const leftCopyLen = min$1(bufferLen - cpos, uint8Array.length);
35931
+ const leftCopyLen = min$2(bufferLen - cpos, uint8Array.length);
35833
35932
  const rightCopyLen = uint8Array.length - leftCopyLen;
35834
35933
  encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
35835
35934
  encoder.cpos += leftCopyLen;
35836
35935
  if (rightCopyLen > 0) {
35837
35936
  encoder.bufs.push(encoder.cbuf);
35838
- encoder.cbuf = new Uint8Array(max$1(bufferLen * 2, rightCopyLen));
35937
+ encoder.cbuf = new Uint8Array(max$2(bufferLen * 2, rightCopyLen));
35839
35938
  encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
35840
35939
  encoder.cpos = rightCopyLen;
35841
35940
  }
@@ -35977,7 +36076,7 @@ const ySyncPluginKey = new PluginKey("y-sync");
35977
36076
  const yUndoPluginKey = new PluginKey("y-undo");
35978
36077
  const yCursorPluginKey = new PluginKey("yjs-cursor");
35979
36078
  const rand = Math.random;
35980
- const oneOf = (arr) => arr[floor(rand() * arr.length)];
36079
+ const oneOf = (arr) => arr[floor$1(rand() * arr.length)];
35981
36080
  const undefinedToNull = (v) => v === void 0 ? null : v;
35982
36081
  class VarStoragePolyfill {
35983
36082
  constructor() {
@@ -36007,12 +36106,12 @@ try {
36007
36106
  } catch (e) {
36008
36107
  }
36009
36108
  const varStorage = _localStorage;
36010
- const isNode = typeof process$1$1 !== "undefined" && process$1$1.release && /node|io\.js/.test(process$1$1.release.name) && Object.prototype.toString.call(typeof process$1$1 !== "undefined" ? process$1$1 : 0) === "[object process]";
36011
- const isBrowser$1$1 = typeof window !== "undefined" && typeof document !== "undefined" && !isNode;
36109
+ const isNode$1 = typeof process$1$1 !== "undefined" && process$1$1.release && /node|io\.js/.test(process$1$1.release.name) && Object.prototype.toString.call(typeof process$1$1 !== "undefined" ? process$1$1 : 0) === "[object process]";
36110
+ const isBrowser$1$1 = typeof window !== "undefined" && typeof document !== "undefined" && !isNode$1;
36012
36111
  let params;
36013
36112
  const computeParams = () => {
36014
36113
  if (params === void 0) {
36015
- if (isNode) {
36114
+ if (isNode$1) {
36016
36115
  params = create();
36017
36116
  const pargs = process$1$1.argv;
36018
36117
  let currParamName = null;
@@ -36049,12 +36148,12 @@ const computeParams = () => {
36049
36148
  return params;
36050
36149
  };
36051
36150
  const hasParam = (name) => computeParams().has(name);
36052
- const getVariable = (name) => isNode ? undefinedToNull(process$1$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
36151
+ const getVariable = (name) => isNode$1 ? undefinedToNull(process$1$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
36053
36152
  const hasConf = (name) => hasParam("--" + name) || getVariable(name) !== null;
36054
36153
  hasConf("production");
36055
- const forceColor = isNode && isOneOf(process$1$1.env.FORCE_COLOR, ["true", "1", "2"]);
36154
+ const forceColor = isNode$1 && isOneOf(process$1$1.env.FORCE_COLOR, ["true", "1", "2"]);
36056
36155
  forceColor || !hasParam("--no-colors") && // @todo deprecate --no-colors
36057
- !hasConf("no-color") && (!isNode || process$1$1.stdout.isTTY) && (!isNode || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
36156
+ !hasConf("no-color") && (!isNode$1 || process$1$1.stdout.isTTY) && (!isNode$1 || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
36058
36157
  const doc = (
36059
36158
  /** @type {Document} */
36060
36159
  typeof document !== "undefined" ? document : {}
@@ -36563,8 +36662,8 @@ class ProsemirrorBinding {
36563
36662
  new Slice(Fragment.from(fragmentContent), 0, 0)
36564
36663
  );
36565
36664
  if (sel) {
36566
- const clampedAnchor = min$1(max$1(sel.anchor, 0), tr.doc.content.size);
36567
- const clampedHead = min$1(max$1(sel.head, 0), tr.doc.content.size);
36665
+ const clampedAnchor = min$2(max$2(sel.anchor, 0), tr.doc.content.size);
36666
+ const clampedHead = min$2(max$2(sel.head, 0), tr.doc.content.size);
36568
36667
  tr.setSelection(TextSelection.create(tr.doc, clampedAnchor, clampedHead));
36569
36668
  }
36570
36669
  this.prosemirrorView.dispatch(
@@ -36961,7 +37060,7 @@ const computeChildEqualityFactor = (ytype, pnode, meta) => {
36961
37060
  const pChildren = normalizePNodeContent(pnode);
36962
37061
  const pChildCnt = pChildren.length;
36963
37062
  const yChildCnt = yChildren.length;
36964
- const minCnt = min$1(yChildCnt, pChildCnt);
37063
+ const minCnt = min$2(yChildCnt, pChildCnt);
36965
37064
  let left2 = 0;
36966
37065
  let right2 = 0;
36967
37066
  let foundMappedChild = false;
@@ -37073,7 +37172,7 @@ const updateYFragment = (y, yDomFragment, pNode, meta) => {
37073
37172
  const pChildCnt = pChildren.length;
37074
37173
  const yChildren = yDomFragment.toArray();
37075
37174
  const yChildCnt = yChildren.length;
37076
- const minCnt = min$1(pChildCnt, yChildCnt);
37175
+ const minCnt = min$2(pChildCnt, yChildCnt);
37077
37176
  let left2 = 0;
37078
37177
  let right2 = 0;
37079
37178
  for (; left2 < minCnt; left2++) {
@@ -37446,17 +37545,17 @@ const createDecorations = (state2, awareness, awarenessFilter, createCursor, cre
37446
37545
  ystate.binding.mapping
37447
37546
  );
37448
37547
  if (anchor !== null && head !== null) {
37449
- const maxsize = max$1(state2.doc.content.size - 1, 0);
37450
- anchor = min$1(anchor, maxsize);
37451
- head = min$1(head, maxsize);
37548
+ const maxsize = max$2(state2.doc.content.size - 1, 0);
37549
+ anchor = min$2(anchor, maxsize);
37550
+ head = min$2(head, maxsize);
37452
37551
  decorations.push(
37453
37552
  Decoration.widget(head, () => createCursor(user, clientId), {
37454
37553
  key: clientId + "",
37455
37554
  side: 10
37456
37555
  })
37457
37556
  );
37458
- const from2 = min$1(anchor, head);
37459
- const to = max$1(anchor, head);
37557
+ const from2 = min$2(anchor, head);
37558
+ const to = max$2(anchor, head);
37460
37559
  decorations.push(
37461
37560
  Decoration.inline(from2, to, createSelection(user, clientId), {
37462
37561
  inclusiveEnd: true,
@@ -39078,7 +39177,8 @@ const createHeaderFooterEditor = ({
39078
39177
  appendToBody = true,
39079
39178
  sectionId,
39080
39179
  type: type2,
39081
- availableHeight
39180
+ availableHeight,
39181
+ currentPageNumber
39082
39182
  }) => {
39083
39183
  const parentStyles = editor.converter.getDocumentDefaultStyles();
39084
39184
  const { fontSizePt, typeface } = parentStyles;
@@ -39114,11 +39214,13 @@ const createHeaderFooterEditor = ({
39114
39214
  content: data,
39115
39215
  extensions: getStarterExtensions(),
39116
39216
  documentId: sectionId || "sectionId",
39117
- media: editor.options.media,
39118
- mediaFiles: editor.options.mediaFiles,
39217
+ media: editor.storage.image.media,
39218
+ mediaFiles: editor.storage.image.media,
39119
39219
  fonts: editor.options.fonts,
39120
39220
  isHeaderOrFooter: true,
39121
39221
  annotations: true,
39222
+ currentPageNumber,
39223
+ parentEditor: editor,
39122
39224
  onCreate: (evt) => setEditorToolbar(evt, editor),
39123
39225
  onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type2)
39124
39226
  });
@@ -40236,6 +40338,68 @@ const deleteHeaderFooterFieldAnnotations = ({ editor, fieldIdOrArray }) => {
40236
40338
  );
40237
40339
  });
40238
40340
  };
40341
+ const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
40342
+ if (!Array.isArray(fieldsToDelete)) fieldsToDelete = [fieldsToDelete];
40343
+ const { doc: doc2 } = editor.state;
40344
+ const docxAnnotations = getAllFieldAnnotations(editor.state) || [];
40345
+ const nodesToDelete = [];
40346
+ fieldsToDelete.forEach((fieldId) => {
40347
+ const matched = docxAnnotations.find((a) => a.node.attrs.fieldId === fieldId);
40348
+ if (!matched) return;
40349
+ const listItem = findParentNodeClosestToPos(
40350
+ doc2.resolve(matched.pos),
40351
+ (node22) => node22.type.name === "listItem"
40352
+ );
40353
+ if (!listItem) return;
40354
+ let remainingNodes = 0;
40355
+ listItem.node.descendants((node22) => {
40356
+ if (node22.type.name === "fieldAnnotation") {
40357
+ remainingNodes += 1;
40358
+ }
40359
+ });
40360
+ let matchingNodesFound = 0;
40361
+ let hasOtherNodes = false;
40362
+ listItem.node.children.forEach((child, index2) => {
40363
+ const { type: type2 } = child;
40364
+ if (type2.name !== "paragraph" && type2.name !== "fieldAnnotation") return;
40365
+ child.children.forEach((inline) => {
40366
+ const isFieldToDelete = fieldsToDelete.includes(inline.attrs.fieldId);
40367
+ const isFieldType = inline.type.name === "fieldAnnotation";
40368
+ const isMatchingField = isFieldType && isFieldToDelete;
40369
+ if (!isFieldType && !isMatchingField) hasOtherNodes = true;
40370
+ if (isMatchingField) matchingNodesFound += 1;
40371
+ });
40372
+ });
40373
+ if (!hasOtherNodes && matchingNodesFound > 0) {
40374
+ remainingNodes -= matchingNodesFound;
40375
+ }
40376
+ if (remainingNodes > 0) {
40377
+ return;
40378
+ }
40379
+ let { pos, node: node2, depth } = listItem;
40380
+ let $pos = doc2.resolve(pos);
40381
+ while (depth > 0) {
40382
+ const parent = $pos.node(depth - 1);
40383
+ if (parent.childCount === 1) {
40384
+ depth -= 1;
40385
+ pos = $pos.before(depth);
40386
+ node2 = parent;
40387
+ $pos = doc2.resolve(pos);
40388
+ } else {
40389
+ break;
40390
+ }
40391
+ }
40392
+ if (!nodesToDelete.some((n) => n.pos === pos)) {
40393
+ nodesToDelete.push({ pos, node: node2 });
40394
+ }
40395
+ });
40396
+ if (!nodesToDelete.length) return;
40397
+ const tr = editor.state.tr;
40398
+ nodesToDelete.sort((a, b) => b.pos - a.pos).forEach(({ pos, node: node2 }) => {
40399
+ tr.delete(pos, pos + node2.nodeSize);
40400
+ });
40401
+ editor.view.dispatch(tr);
40402
+ };
40239
40403
  const AnnotatorHelpers = {
40240
40404
  getFieldAttrs,
40241
40405
  processTables,
@@ -40243,7 +40407,8 @@ const AnnotatorHelpers = {
40243
40407
  annotateHeadersAndFooters,
40244
40408
  getAllHeaderFooterEditors,
40245
40409
  updateHeaderFooterFieldAnnotations,
40246
- deleteHeaderFooterFieldAnnotations
40410
+ deleteHeaderFooterFieldAnnotations,
40411
+ cleanUpListsWithAnnotations
40247
40412
  };
40248
40413
  const CollaborationPluginKey = new PluginKey("collaboration");
40249
40414
  const Collaboration = Extension.create({
@@ -40403,6 +40568,19 @@ function useHighContrastMode() {
40403
40568
  setHighContrastMode
40404
40569
  };
40405
40570
  }
40571
+ const findWordBounds = (doc2, pos) => {
40572
+ const $pos = doc2.resolve(pos);
40573
+ const parent = $pos.parent;
40574
+ const offset2 = $pos.parentOffset;
40575
+ const text = parent.textContent;
40576
+ if (!text) return { from: pos, to: pos };
40577
+ let start2 = offset2, end2 = offset2;
40578
+ while (start2 > 0 && /\w/.test(text[start2 - 1])) start2--;
40579
+ while (end2 < text.length && /\w/.test(text[end2])) end2++;
40580
+ const from2 = $pos.start() + start2;
40581
+ const to = $pos.start() + end2;
40582
+ return { from: from2, to };
40583
+ };
40406
40584
  const _Editor = class _Editor2 extends EventEmitter$1 {
40407
40585
  /**
40408
40586
  * Create a new Editor instance
@@ -40646,6 +40824,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
40646
40824
  __privateMethod$1(this, _Editor_instances, initMedia_fn).call(this);
40647
40825
  const doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
40648
40826
  const tr = this.state.tr.replaceWith(0, this.state.doc.content.size, doc2);
40827
+ tr.setMeta("replaceContent", true);
40649
40828
  this.view.dispatch(tr);
40650
40829
  }
40651
40830
  /**
@@ -41053,7 +41232,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41053
41232
  * @returns {Object | void} Migration results
41054
41233
  */
41055
41234
  processCollaborationMigrations() {
41056
- console.debug("[checkVersionMigrations] Current editor version", "0.12.35");
41235
+ console.debug("[checkVersionMigrations] Current editor version", "0.12.36-next.10");
41057
41236
  if (!this.options.ydoc) return;
41058
41237
  const metaMap = this.options.ydoc.getMap("meta");
41059
41238
  let docVersion = metaMap.get("version");
@@ -41418,6 +41597,10 @@ createView_fn = function() {
41418
41597
  pm.classList.remove("header-footer-edit");
41419
41598
  pm.setAttribute("aria-readonly", false);
41420
41599
  }
41600
+ const { state: state22, dispatch } = view;
41601
+ const word = findWordBounds(state22.doc, pos);
41602
+ const tr = state22.tr.setSelection(TextSelection.create(state22.doc, word.from, word.to));
41603
+ dispatch(tr);
41421
41604
  }
41422
41605
  });
41423
41606
  const newState = this.state.reconfigure({
@@ -41818,7 +42001,14 @@ const LineHeight = Extension.create({
41818
42001
  parseDOM: (el) => el.style.lineHeight,
41819
42002
  renderDOM: (attrs) => {
41820
42003
  if (!attrs.lineHeight) return {};
41821
- return { style: getLineHeightValueString(attrs.lineHeight, this.options.defaults.unit, attrs.spacing?.lineRule) };
42004
+ const lineHeightStyle = getLineHeightValueString(
42005
+ attrs.lineHeight,
42006
+ this.options.defaults.unit,
42007
+ attrs.spacing?.lineRule
42008
+ );
42009
+ return {
42010
+ style: `${lineHeightStyle}`
42011
+ };
41822
42012
  }
41823
42013
  }
41824
42014
  }
@@ -43743,7 +43933,9 @@ const Paragraph = Node$1.create({
43743
43933
  renderDOM: (attrs) => {
43744
43934
  const { spacing } = attrs;
43745
43935
  if (!spacing) return {};
43746
- const style2 = getSpacingStyleString(spacing);
43936
+ const spacingCopy = { ...spacing };
43937
+ if (attrs.lineHeight) delete spacingCopy.line;
43938
+ const style2 = getSpacingStyleString(spacingCopy);
43747
43939
  if (style2) return { style: style2 };
43748
43940
  return {};
43749
43941
  }
@@ -46920,8 +47112,8 @@ const TableCell = Node$1.create({
46920
47112
  cellMargins: {
46921
47113
  renderDOM({ cellMargins }) {
46922
47114
  if (!cellMargins) return {};
46923
- const sides = ["top", "right", "bottom", "left"];
46924
- const style2 = sides.map((side) => {
47115
+ const sides2 = ["top", "right", "bottom", "left"];
47116
+ const style2 = sides2.map((side) => {
46925
47117
  const margin = cellMargins?.[side];
46926
47118
  if (margin) return `padding-${side}: ${margin}px;`;
46927
47119
  return "";
@@ -46933,8 +47125,8 @@ const TableCell = Node$1.create({
46933
47125
  default: () => createCellBorders(),
46934
47126
  renderDOM({ borders }) {
46935
47127
  if (!borders) return {};
46936
- const sides = ["top", "right", "bottom", "left"];
46937
- const style2 = sides.map((side) => {
47128
+ const sides2 = ["top", "right", "bottom", "left"];
47129
+ const style2 = sides2.map((side) => {
46938
47130
  const border = borders?.[side];
46939
47131
  if (border && border.val === "none") return `border-${side}: ${border.val};`;
46940
47132
  if (border) return `border-${side}: ${border.size}px solid ${border.color || "black"};`;
@@ -48692,32 +48884,89 @@ const PageNumber = Node$1.create({
48692
48884
  name: "page-number",
48693
48885
  group: "inline",
48694
48886
  inline: true,
48695
- content: "text*",
48887
+ atom: true,
48888
+ selectable: false,
48889
+ draggable: false,
48890
+ selectable: false,
48891
+ defining: true,
48892
+ content: "",
48696
48893
  addOptions() {
48697
48894
  return {
48698
48895
  htmlAttributes: {
48896
+ contenteditable: false,
48699
48897
  "data-id": "auto-page-number",
48700
48898
  "aria-label": "Page number node"
48701
48899
  }
48702
48900
  };
48703
48901
  },
48902
+ addAttributes() {
48903
+ return {
48904
+ marksAsAttrs: {
48905
+ default: null,
48906
+ rendered: false
48907
+ }
48908
+ };
48909
+ },
48910
+ addNodeView() {
48911
+ return ({ node: node2, editor, getPos, decorations }) => {
48912
+ const htmlAttributes = this.options.htmlAttributes;
48913
+ return new AutoPageNumberNodeView(node2, getPos, decorations, editor, htmlAttributes);
48914
+ };
48915
+ },
48704
48916
  parseDOM() {
48705
48917
  return [{ tag: 'span[data-id="auto-page-number"' }];
48706
48918
  },
48707
48919
  renderDOM({ htmlAttributes }) {
48708
- return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
48920
+ return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
48921
+ },
48922
+ addCommands() {
48923
+ return {
48924
+ addAutoPageNumber: () => ({ tr, dispatch, state: state2, editor }) => {
48925
+ const { options: options2 } = editor;
48926
+ if (!options2.isHeaderOrFooter) return false;
48927
+ const { schema } = state2;
48928
+ const pageNumberType = schema?.nodes?.["page-number"];
48929
+ if (!pageNumberType) return false;
48930
+ const pageNumberNodeJSON = { type: "page-number" };
48931
+ const pageNumberNode = schema.nodeFromJSON(pageNumberNodeJSON);
48932
+ if (dispatch) {
48933
+ tr.replaceSelectionWith(pageNumberNode, false);
48934
+ tr.setMeta("forceUpdatePagination", true);
48935
+ }
48936
+ return true;
48937
+ }
48938
+ };
48939
+ },
48940
+ addShortcuts() {
48941
+ return {
48942
+ "Mod-Shift-alt-p": () => this.editor.commands.addAutoPageNumber()
48943
+ };
48709
48944
  }
48710
48945
  });
48711
48946
  const TotalPageCount = Node$1.create({
48712
48947
  name: "total-page-number",
48713
48948
  group: "inline",
48714
48949
  inline: true,
48950
+ atom: true,
48951
+ selectable: false,
48952
+ draggable: false,
48953
+ selectable: false,
48715
48954
  content: "text*",
48716
48955
  addOptions() {
48717
48956
  return {
48718
48957
  htmlAttributes: {
48958
+ contenteditable: false,
48719
48959
  "data-id": "auto-total-pages",
48720
- "aria-label": "Total page count node"
48960
+ "aria-label": "Total page count node",
48961
+ "class": "sd-editor-auto-total-pages"
48962
+ }
48963
+ };
48964
+ },
48965
+ addAttributes() {
48966
+ return {
48967
+ marksAsAttrs: {
48968
+ default: null,
48969
+ rendered: false
48721
48970
  }
48722
48971
  };
48723
48972
  },
@@ -48726,8 +48975,139 @@ const TotalPageCount = Node$1.create({
48726
48975
  },
48727
48976
  renderDOM({ htmlAttributes }) {
48728
48977
  return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
48978
+ },
48979
+ addCommands() {
48980
+ return {
48981
+ addTotalPageCount: () => ({ tr, dispatch, state: state2, editor }) => {
48982
+ const { options: options2 } = editor;
48983
+ if (!options2.isHeaderOrFooter) return false;
48984
+ const { schema } = state2;
48985
+ const pageNumberType = schema.nodes?.["total-page-number"];
48986
+ if (!pageNumberType) return false;
48987
+ const currentPages = editor?.options?.parentEditor?.currentTotalPages || 1;
48988
+ const pageNumberNode = {
48989
+ type: "total-page-number",
48990
+ content: [{ type: "text", text: String(currentPages) }]
48991
+ };
48992
+ const pageNode = schema.nodeFromJSON(pageNumberNode);
48993
+ if (dispatch) {
48994
+ tr.replaceSelectionWith(pageNode, false);
48995
+ }
48996
+ return true;
48997
+ }
48998
+ };
48999
+ },
49000
+ addShortcuts() {
49001
+ return {
49002
+ "Mod-Shift-alt-c": () => this.editor.commands.addTotalPageCount()
49003
+ };
48729
49004
  }
48730
49005
  });
49006
+ class AutoPageNumberNodeView {
49007
+ constructor(node2, getPos, decorations, editor, htmlAttributes = {}) {
49008
+ __privateAdd$1(this, _AutoPageNumberNodeView_instances);
49009
+ this.node = node2;
49010
+ this.editor = editor;
49011
+ this.view = editor.view;
49012
+ this.getPos = getPos;
49013
+ this.editor = editor;
49014
+ this.dom = __privateMethod$1(this, _AutoPageNumberNodeView_instances, renderDom_fn).call(this, node2, htmlAttributes);
49015
+ }
49016
+ update(node2) {
49017
+ if (node2.type !== this.node.type) return false;
49018
+ this.node = node2;
49019
+ return true;
49020
+ }
49021
+ }
49022
+ _AutoPageNumberNodeView_instances = /* @__PURE__ */ new WeakSet();
49023
+ renderDom_fn = function(node2, htmlAttributes) {
49024
+ const pageText = this.editor.options.currentPageNumber || "1";
49025
+ const content = document.createTextNode(String(pageText));
49026
+ const nodeContent = document.createElement("span");
49027
+ nodeContent.className = "sd-editor-auto-page-number";
49028
+ nodeContent.setAttribute("data-id", "auto-page-number");
49029
+ nodeContent.setAttribute("aria-label", "Page number node");
49030
+ const currentPos = this.getPos();
49031
+ const { styles, marks } = getMarksFromNeighbors(currentPos, this.view);
49032
+ __privateMethod$1(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
49033
+ Object.assign(nodeContent.style, styles);
49034
+ nodeContent.appendChild(content);
49035
+ Object.entries(htmlAttributes).forEach(([key, value]) => {
49036
+ if (value) nodeContent.setAttribute(key, value);
49037
+ });
49038
+ return nodeContent;
49039
+ };
49040
+ scheduleUpdateNodeStyle_fn = function(pos, marks) {
49041
+ setTimeout(() => {
49042
+ const { state: state2 } = this.editor;
49043
+ const { dispatch } = this.view;
49044
+ const node2 = state2.doc.nodeAt(pos);
49045
+ if (!node2) return;
49046
+ const currentMarks = node2.attrs.marksAsAttrs || [];
49047
+ const newMarks = marks.map((m) => ({ type: m.type.name, attrs: m.attrs }));
49048
+ const isEqual = JSON.stringify(currentMarks) === JSON.stringify(newMarks);
49049
+ if (isEqual) return;
49050
+ const newAttrs = {
49051
+ ...node2.attrs,
49052
+ marksAsAttrs: newMarks
49053
+ };
49054
+ const tr = state2.tr.setNodeMarkup(pos, void 0, newAttrs);
49055
+ dispatch(tr);
49056
+ }, 0);
49057
+ };
49058
+ const getMarksFromNeighbors = (currentPos, view) => {
49059
+ const $pos = view.state.doc.resolve(currentPos);
49060
+ const styles = {};
49061
+ const marks = [];
49062
+ const before = $pos.nodeBefore;
49063
+ if (before) {
49064
+ Object.assign(styles, processMarks(before.marks));
49065
+ marks.push(...before.marks);
49066
+ }
49067
+ const after = $pos.nodeAfter;
49068
+ if (after) {
49069
+ Object.assign(styles, { ...styles, ...processMarks(after.marks) });
49070
+ marks.push(...after.marks);
49071
+ }
49072
+ return {
49073
+ styles,
49074
+ marks
49075
+ };
49076
+ };
49077
+ const processMarks = (marks) => {
49078
+ const styles = {};
49079
+ marks.forEach((mark) => {
49080
+ const { type: type2, attrs } = mark;
49081
+ switch (type2.name) {
49082
+ case "textStyle":
49083
+ if (attrs.fontFamily) styles["font-family"] = attrs.fontFamily;
49084
+ if (attrs.fontSize) styles["font-size"] = attrs.fontSize;
49085
+ if (attrs.color) styles["color"] = attrs.color;
49086
+ if (attrs.backgroundColor) styles["background-color"] = attrs.backgroundColor;
49087
+ break;
49088
+ case "bold":
49089
+ styles["font-weight"] = "bold";
49090
+ break;
49091
+ case "italic":
49092
+ styles["font-style"] = "italic";
49093
+ break;
49094
+ case "underline":
49095
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " underline";
49096
+ break;
49097
+ case "strike":
49098
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " line-through";
49099
+ break;
49100
+ default:
49101
+ if (attrs?.style) {
49102
+ Object.entries(attrs.style).forEach(([key, value]) => {
49103
+ styles[key] = value;
49104
+ });
49105
+ }
49106
+ break;
49107
+ }
49108
+ });
49109
+ return styles;
49110
+ };
48731
49111
  const ShapeContainer = Node$1.create({
48732
49112
  name: "shapeContainer",
48733
49113
  group: "block",
@@ -49740,10 +50120,10 @@ var beforeWrite = "beforeWrite";
49740
50120
  var write = "write";
49741
50121
  var afterWrite = "afterWrite";
49742
50122
  var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
49743
- function getNodeName(element) {
50123
+ function getNodeName$1(element) {
49744
50124
  return element ? (element.nodeName || "").toLowerCase() : null;
49745
50125
  }
49746
- function getWindow(node2) {
50126
+ function getWindow$1(node2) {
49747
50127
  if (node2 == null) {
49748
50128
  return window;
49749
50129
  }
@@ -49753,19 +50133,19 @@ function getWindow(node2) {
49753
50133
  }
49754
50134
  return node2;
49755
50135
  }
49756
- function isElement$1(node2) {
49757
- var OwnElement = getWindow(node2).Element;
50136
+ function isElement$2(node2) {
50137
+ var OwnElement = getWindow$1(node2).Element;
49758
50138
  return node2 instanceof OwnElement || node2 instanceof Element;
49759
50139
  }
49760
50140
  function isHTMLElement$1(node2) {
49761
- var OwnElement = getWindow(node2).HTMLElement;
50141
+ var OwnElement = getWindow$1(node2).HTMLElement;
49762
50142
  return node2 instanceof OwnElement || node2 instanceof HTMLElement;
49763
50143
  }
49764
- function isShadowRoot(node2) {
50144
+ function isShadowRoot$1(node2) {
49765
50145
  if (typeof ShadowRoot === "undefined") {
49766
50146
  return false;
49767
50147
  }
49768
- var OwnElement = getWindow(node2).ShadowRoot;
50148
+ var OwnElement = getWindow$1(node2).ShadowRoot;
49769
50149
  return node2 instanceof OwnElement || node2 instanceof ShadowRoot;
49770
50150
  }
49771
50151
  function applyStyles(_ref) {
@@ -49774,7 +50154,7 @@ function applyStyles(_ref) {
49774
50154
  var style2 = state2.styles[name] || {};
49775
50155
  var attributes = state2.attributes[name] || {};
49776
50156
  var element = state2.elements[name];
49777
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
50157
+ if (!isHTMLElement$1(element) || !getNodeName$1(element)) {
49778
50158
  return;
49779
50159
  }
49780
50160
  Object.assign(element.style, style2);
@@ -49816,7 +50196,7 @@ function effect$2(_ref2) {
49816
50196
  style22[property2] = "";
49817
50197
  return style22;
49818
50198
  }, {});
49819
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
50199
+ if (!isHTMLElement$1(element) || !getNodeName$1(element)) {
49820
50200
  return;
49821
50201
  }
49822
50202
  Object.assign(element.style, style2);
@@ -49837,9 +50217,9 @@ const applyStyles$1 = {
49837
50217
  function getBasePlacement$1(placement) {
49838
50218
  return placement.split("-")[0];
49839
50219
  }
49840
- var max = Math.max;
49841
- var min = Math.min;
49842
- var round = Math.round;
50220
+ var max$1 = Math.max;
50221
+ var min$1 = Math.min;
50222
+ var round$1 = Math.round;
49843
50223
  function getUAString() {
49844
50224
  var uaData = navigator.userAgentData;
49845
50225
  if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
@@ -49852,7 +50232,7 @@ function getUAString() {
49852
50232
  function isLayoutViewport() {
49853
50233
  return !/^((?!chrome|android).)*safari/i.test(getUAString());
49854
50234
  }
49855
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
50235
+ function getBoundingClientRect$1(element, includeScale, isFixedStrategy) {
49856
50236
  if (includeScale === void 0) {
49857
50237
  includeScale = false;
49858
50238
  }
@@ -49863,10 +50243,10 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
49863
50243
  var scaleX = 1;
49864
50244
  var scaleY = 1;
49865
50245
  if (includeScale && isHTMLElement$1(element)) {
49866
- scaleX = element.offsetWidth > 0 ? round(clientRect2.width) / element.offsetWidth || 1 : 1;
49867
- scaleY = element.offsetHeight > 0 ? round(clientRect2.height) / element.offsetHeight || 1 : 1;
50246
+ scaleX = element.offsetWidth > 0 ? round$1(clientRect2.width) / element.offsetWidth || 1 : 1;
50247
+ scaleY = element.offsetHeight > 0 ? round$1(clientRect2.height) / element.offsetHeight || 1 : 1;
49868
50248
  }
49869
- var _ref = isElement$1(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
50249
+ var _ref = isElement$2(element) ? getWindow$1(element) : window, visualViewport = _ref.visualViewport;
49870
50250
  var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
49871
50251
  var x = (clientRect2.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
49872
50252
  var y = (clientRect2.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
@@ -49884,7 +50264,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
49884
50264
  };
49885
50265
  }
49886
50266
  function getLayoutRect(element) {
49887
- var clientRect2 = getBoundingClientRect(element);
50267
+ var clientRect2 = getBoundingClientRect$1(element);
49888
50268
  var width = element.offsetWidth;
49889
50269
  var height = element.offsetHeight;
49890
50270
  if (Math.abs(clientRect2.width - width) <= 1) {
@@ -49904,7 +50284,7 @@ function contains$1(parent, child) {
49904
50284
  var rootNode = child.getRootNode && child.getRootNode();
49905
50285
  if (parent.contains(child)) {
49906
50286
  return true;
49907
- } else if (rootNode && isShadowRoot(rootNode)) {
50287
+ } else if (rootNode && isShadowRoot$1(rootNode)) {
49908
50288
  var next = child;
49909
50289
  do {
49910
50290
  if (next && parent.isSameNode(next)) {
@@ -49915,20 +50295,20 @@ function contains$1(parent, child) {
49915
50295
  }
49916
50296
  return false;
49917
50297
  }
49918
- function getComputedStyle$1(element) {
49919
- return getWindow(element).getComputedStyle(element);
50298
+ function getComputedStyle$2(element) {
50299
+ return getWindow$1(element).getComputedStyle(element);
49920
50300
  }
49921
- function isTableElement(element) {
49922
- return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
50301
+ function isTableElement$1(element) {
50302
+ return ["table", "td", "th"].indexOf(getNodeName$1(element)) >= 0;
49923
50303
  }
49924
- function getDocumentElement(element) {
49925
- return ((isElement$1(element) ? element.ownerDocument : (
50304
+ function getDocumentElement$1(element) {
50305
+ return ((isElement$2(element) ? element.ownerDocument : (
49926
50306
  // $FlowFixMe[prop-missing]
49927
50307
  element.document
49928
50308
  )) || window.document).documentElement;
49929
50309
  }
49930
50310
  function getParentNode$1(element) {
49931
- if (getNodeName(element) === "html") {
50311
+ if (getNodeName$1(element) === "html") {
49932
50312
  return element;
49933
50313
  }
49934
50314
  return (
@@ -49937,33 +50317,33 @@ function getParentNode$1(element) {
49937
50317
  // $FlowFixMe[prop-missing]
49938
50318
  element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
49939
50319
  element.parentNode || // DOM Element detected
49940
- (isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
50320
+ (isShadowRoot$1(element) ? element.host : null) || // ShadowRoot detected
49941
50321
  // $FlowFixMe[incompatible-call]: HTMLElement is a Node
49942
- getDocumentElement(element)
50322
+ getDocumentElement$1(element)
49943
50323
  );
49944
50324
  }
49945
- function getTrueOffsetParent(element) {
50325
+ function getTrueOffsetParent$1(element) {
49946
50326
  if (!isHTMLElement$1(element) || // https://github.com/popperjs/popper-core/issues/837
49947
- getComputedStyle$1(element).position === "fixed") {
50327
+ getComputedStyle$2(element).position === "fixed") {
49948
50328
  return null;
49949
50329
  }
49950
50330
  return element.offsetParent;
49951
50331
  }
49952
- function getContainingBlock(element) {
50332
+ function getContainingBlock$1(element) {
49953
50333
  var isFirefox = /firefox/i.test(getUAString());
49954
50334
  var isIE = /Trident/i.test(getUAString());
49955
50335
  if (isIE && isHTMLElement$1(element)) {
49956
- var elementCss = getComputedStyle$1(element);
50336
+ var elementCss = getComputedStyle$2(element);
49957
50337
  if (elementCss.position === "fixed") {
49958
50338
  return null;
49959
50339
  }
49960
50340
  }
49961
50341
  var currentNode = getParentNode$1(element);
49962
- if (isShadowRoot(currentNode)) {
50342
+ if (isShadowRoot$1(currentNode)) {
49963
50343
  currentNode = currentNode.host;
49964
50344
  }
49965
- while (isHTMLElement$1(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
49966
- var css = getComputedStyle$1(currentNode);
50345
+ while (isHTMLElement$1(currentNode) && ["html", "body"].indexOf(getNodeName$1(currentNode)) < 0) {
50346
+ var css = getComputedStyle$2(currentNode);
49967
50347
  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") {
49968
50348
  return currentNode;
49969
50349
  } else {
@@ -49972,22 +50352,22 @@ function getContainingBlock(element) {
49972
50352
  }
49973
50353
  return null;
49974
50354
  }
49975
- function getOffsetParent(element) {
49976
- var window2 = getWindow(element);
49977
- var offsetParent = getTrueOffsetParent(element);
49978
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
49979
- offsetParent = getTrueOffsetParent(offsetParent);
50355
+ function getOffsetParent$1(element) {
50356
+ var window2 = getWindow$1(element);
50357
+ var offsetParent = getTrueOffsetParent$1(element);
50358
+ while (offsetParent && isTableElement$1(offsetParent) && getComputedStyle$2(offsetParent).position === "static") {
50359
+ offsetParent = getTrueOffsetParent$1(offsetParent);
49980
50360
  }
49981
- if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
50361
+ if (offsetParent && (getNodeName$1(offsetParent) === "html" || getNodeName$1(offsetParent) === "body" && getComputedStyle$2(offsetParent).position === "static")) {
49982
50362
  return window2;
49983
50363
  }
49984
- return offsetParent || getContainingBlock(element) || window2;
50364
+ return offsetParent || getContainingBlock$1(element) || window2;
49985
50365
  }
49986
50366
  function getMainAxisFromPlacement(placement) {
49987
50367
  return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
49988
50368
  }
49989
- function within(min$12, value, max$12) {
49990
- return max(min$12, min(value, max$12));
50369
+ function within(min2, value, max2) {
50370
+ return max$1(min2, min$1(value, max2));
49991
50371
  }
49992
50372
  function withinMaxClamp(min2, value, max2) {
49993
50373
  var v = within(min2, value, max2);
@@ -50034,7 +50414,7 @@ function arrow(_ref) {
50034
50414
  var maxProp = axis === "y" ? bottom : right;
50035
50415
  var endDiff = state2.rects.reference[len] + state2.rects.reference[axis] - popperOffsets2[axis] - state2.rects.popper[len];
50036
50416
  var startDiff = popperOffsets2[axis] - state2.rects.reference[axis];
50037
- var arrowOffsetParent = getOffsetParent(arrowElement);
50417
+ var arrowOffsetParent = getOffsetParent$1(arrowElement);
50038
50418
  var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
50039
50419
  var centerToReference = endDiff / 2 - startDiff / 2;
50040
50420
  var min2 = paddingObject[minProp];
@@ -50083,8 +50463,8 @@ function roundOffsetsByDPR(_ref, win) {
50083
50463
  var x = _ref.x, y = _ref.y;
50084
50464
  var dpr = win.devicePixelRatio || 1;
50085
50465
  return {
50086
- x: round(x * dpr) / dpr || 0,
50087
- y: round(y * dpr) / dpr || 0
50466
+ x: round$1(x * dpr) / dpr || 0,
50467
+ y: round$1(y * dpr) / dpr || 0
50088
50468
  };
50089
50469
  }
50090
50470
  function mapToStyles(_ref2) {
@@ -50106,12 +50486,12 @@ function mapToStyles(_ref2) {
50106
50486
  var sideY = top;
50107
50487
  var win = window;
50108
50488
  if (adaptive) {
50109
- var offsetParent = getOffsetParent(popper2);
50489
+ var offsetParent = getOffsetParent$1(popper2);
50110
50490
  var heightProp = "clientHeight";
50111
50491
  var widthProp = "clientWidth";
50112
- if (offsetParent === getWindow(popper2)) {
50113
- offsetParent = getDocumentElement(popper2);
50114
- if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
50492
+ if (offsetParent === getWindow$1(popper2)) {
50493
+ offsetParent = getDocumentElement$1(popper2);
50494
+ if (getComputedStyle$2(offsetParent).position !== "static" && position === "absolute") {
50115
50495
  heightProp = "scrollHeight";
50116
50496
  widthProp = "scrollWidth";
50117
50497
  }
@@ -50142,7 +50522,7 @@ function mapToStyles(_ref2) {
50142
50522
  var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
50143
50523
  x,
50144
50524
  y
50145
- }, getWindow(popper2)) : {
50525
+ }, getWindow$1(popper2)) : {
50146
50526
  x,
50147
50527
  y
50148
50528
  };
@@ -50198,7 +50578,7 @@ var passive = {
50198
50578
  function effect(_ref) {
50199
50579
  var state2 = _ref.state, instance = _ref.instance, options2 = _ref.options;
50200
50580
  var _options$scroll = options2.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options2.resize, resize = _options$resize === void 0 ? true : _options$resize;
50201
- var window2 = getWindow(state2.elements.popper);
50581
+ var window2 = getWindow$1(state2.elements.popper);
50202
50582
  var scrollParents = [].concat(state2.scrollParents.reference, state2.scrollParents.popper);
50203
50583
  if (scroll) {
50204
50584
  scrollParents.forEach(function(scrollParent) {
@@ -50249,7 +50629,7 @@ function getOppositeVariationPlacement(placement) {
50249
50629
  });
50250
50630
  }
50251
50631
  function getWindowScroll(node2) {
50252
- var win = getWindow(node2);
50632
+ var win = getWindow$1(node2);
50253
50633
  var scrollLeft = win.pageXOffset;
50254
50634
  var scrollTop = win.pageYOffset;
50255
50635
  return {
@@ -50257,12 +50637,12 @@ function getWindowScroll(node2) {
50257
50637
  scrollTop
50258
50638
  };
50259
50639
  }
50260
- function getWindowScrollBarX(element) {
50261
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
50640
+ function getWindowScrollBarX$1(element) {
50641
+ return getBoundingClientRect$1(getDocumentElement$1(element)).left + getWindowScroll(element).scrollLeft;
50262
50642
  }
50263
- function getViewportRect(element, strategy) {
50264
- var win = getWindow(element);
50265
- var html = getDocumentElement(element);
50643
+ function getViewportRect$1(element, strategy) {
50644
+ var win = getWindow$1(element);
50645
+ var html = getDocumentElement$1(element);
50266
50646
  var visualViewport = win.visualViewport;
50267
50647
  var width = html.clientWidth;
50268
50648
  var height = html.clientHeight;
@@ -50280,21 +50660,21 @@ function getViewportRect(element, strategy) {
50280
50660
  return {
50281
50661
  width,
50282
50662
  height,
50283
- x: x + getWindowScrollBarX(element),
50663
+ x: x + getWindowScrollBarX$1(element),
50284
50664
  y
50285
50665
  };
50286
50666
  }
50287
- function getDocumentRect(element) {
50667
+ function getDocumentRect$1(element) {
50288
50668
  var _element$ownerDocumen;
50289
- var html = getDocumentElement(element);
50669
+ var html = getDocumentElement$1(element);
50290
50670
  var winScroll = getWindowScroll(element);
50291
50671
  var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
50292
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
50293
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
50294
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
50672
+ var width = max$1(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
50673
+ var height = max$1(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
50674
+ var x = -winScroll.scrollLeft + getWindowScrollBarX$1(element);
50295
50675
  var y = -winScroll.scrollTop;
50296
- if (getComputedStyle$1(body || html).direction === "rtl") {
50297
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
50676
+ if (getComputedStyle$2(body || html).direction === "rtl") {
50677
+ x += max$1(html.clientWidth, body ? body.clientWidth : 0) - width;
50298
50678
  }
50299
50679
  return {
50300
50680
  width,
@@ -50304,11 +50684,11 @@ function getDocumentRect(element) {
50304
50684
  };
50305
50685
  }
50306
50686
  function isScrollParent(element) {
50307
- var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
50687
+ var _getComputedStyle = getComputedStyle$2(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
50308
50688
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
50309
50689
  }
50310
50690
  function getScrollParent$1(node2) {
50311
- if (["html", "body", "#document"].indexOf(getNodeName(node2)) >= 0) {
50691
+ if (["html", "body", "#document"].indexOf(getNodeName$1(node2)) >= 0) {
50312
50692
  return node2.ownerDocument.body;
50313
50693
  }
50314
50694
  if (isHTMLElement$1(node2) && isScrollParent(node2)) {
@@ -50323,7 +50703,7 @@ function listScrollParents(element, list) {
50323
50703
  }
50324
50704
  var scrollParent = getScrollParent$1(element);
50325
50705
  var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
50326
- var win = getWindow(scrollParent);
50706
+ var win = getWindow$1(scrollParent);
50327
50707
  var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
50328
50708
  var updatedList = list.concat(target);
50329
50709
  return isBody ? updatedList : (
@@ -50331,7 +50711,7 @@ function listScrollParents(element, list) {
50331
50711
  updatedList.concat(listScrollParents(getParentNode$1(target)))
50332
50712
  );
50333
50713
  }
50334
- function rectToClientRect(rect) {
50714
+ function rectToClientRect$1(rect) {
50335
50715
  return Object.assign({}, rect, {
50336
50716
  left: rect.x,
50337
50717
  top: rect.y,
@@ -50339,8 +50719,8 @@ function rectToClientRect(rect) {
50339
50719
  bottom: rect.y + rect.height
50340
50720
  });
50341
50721
  }
50342
- function getInnerBoundingClientRect(element, strategy) {
50343
- var rect = getBoundingClientRect(element, false, strategy === "fixed");
50722
+ function getInnerBoundingClientRect$1(element, strategy) {
50723
+ var rect = getBoundingClientRect$1(element, false, strategy === "fixed");
50344
50724
  rect.top = rect.top + element.clientTop;
50345
50725
  rect.left = rect.left + element.clientLeft;
50346
50726
  rect.bottom = rect.top + element.clientHeight;
@@ -50352,29 +50732,29 @@ function getInnerBoundingClientRect(element, strategy) {
50352
50732
  return rect;
50353
50733
  }
50354
50734
  function getClientRectFromMixedType(element, clippingParent, strategy) {
50355
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
50735
+ return clippingParent === viewport ? rectToClientRect$1(getViewportRect$1(element, strategy)) : isElement$2(clippingParent) ? getInnerBoundingClientRect$1(clippingParent, strategy) : rectToClientRect$1(getDocumentRect$1(getDocumentElement$1(element)));
50356
50736
  }
50357
50737
  function getClippingParents(element) {
50358
50738
  var clippingParents2 = listScrollParents(getParentNode$1(element));
50359
- var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$1(element).position) >= 0;
50360
- var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent(element) : element;
50361
- if (!isElement$1(clipperElement)) {
50739
+ var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$2(element).position) >= 0;
50740
+ var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent$1(element) : element;
50741
+ if (!isElement$2(clipperElement)) {
50362
50742
  return [];
50363
50743
  }
50364
50744
  return clippingParents2.filter(function(clippingParent) {
50365
- return isElement$1(clippingParent) && contains$1(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
50745
+ return isElement$2(clippingParent) && contains$1(clippingParent, clipperElement) && getNodeName$1(clippingParent) !== "body";
50366
50746
  });
50367
50747
  }
50368
- function getClippingRect(element, boundary, rootBoundary, strategy) {
50748
+ function getClippingRect$1(element, boundary, rootBoundary, strategy) {
50369
50749
  var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
50370
50750
  var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
50371
50751
  var firstClippingParent = clippingParents2[0];
50372
50752
  var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
50373
50753
  var rect = getClientRectFromMixedType(element, clippingParent, strategy);
50374
- accRect.top = max(rect.top, accRect.top);
50375
- accRect.right = min(rect.right, accRect.right);
50376
- accRect.bottom = min(rect.bottom, accRect.bottom);
50377
- accRect.left = max(rect.left, accRect.left);
50754
+ accRect.top = max$1(rect.top, accRect.top);
50755
+ accRect.right = min$1(rect.right, accRect.right);
50756
+ accRect.bottom = min$1(rect.bottom, accRect.bottom);
50757
+ accRect.left = max$1(rect.left, accRect.left);
50378
50758
  return accRect;
50379
50759
  }, getClientRectFromMixedType(element, firstClippingParent, strategy));
50380
50760
  clippingRect.width = clippingRect.right - clippingRect.left;
@@ -50435,7 +50815,7 @@ function computeOffsets(_ref) {
50435
50815
  }
50436
50816
  return offsets;
50437
50817
  }
50438
- function detectOverflow(state2, options2) {
50818
+ function detectOverflow$1(state2, options2) {
50439
50819
  if (options2 === void 0) {
50440
50820
  options2 = {};
50441
50821
  }
@@ -50444,14 +50824,14 @@ function detectOverflow(state2, options2) {
50444
50824
  var altContext = elementContext === popper ? reference : popper;
50445
50825
  var popperRect = state2.rects.popper;
50446
50826
  var element = state2.elements[altBoundary ? altContext : elementContext];
50447
- var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state2.elements.popper), boundary, rootBoundary, strategy);
50448
- var referenceClientRect = getBoundingClientRect(state2.elements.reference);
50827
+ var clippingClientRect = getClippingRect$1(isElement$2(element) ? element : element.contextElement || getDocumentElement$1(state2.elements.popper), boundary, rootBoundary, strategy);
50828
+ var referenceClientRect = getBoundingClientRect$1(state2.elements.reference);
50449
50829
  var popperOffsets2 = computeOffsets({
50450
50830
  reference: referenceClientRect,
50451
50831
  element: popperRect,
50452
50832
  placement
50453
50833
  });
50454
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
50834
+ var popperClientRect = rectToClientRect$1(Object.assign({}, popperRect, popperOffsets2));
50455
50835
  var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
50456
50836
  var overflowOffsets = {
50457
50837
  top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
@@ -50486,7 +50866,7 @@ function computeAutoPlacement(state2, options2) {
50486
50866
  allowedPlacements = placements$1;
50487
50867
  }
50488
50868
  var overflows = allowedPlacements.reduce(function(acc, placement2) {
50489
- acc[placement2] = detectOverflow(state2, {
50869
+ acc[placement2] = detectOverflow$1(state2, {
50490
50870
  placement: placement2,
50491
50871
  boundary,
50492
50872
  rootBoundary,
@@ -50536,7 +50916,7 @@ function flip(_ref) {
50536
50916
  var isStartVariation = getVariation(placement) === start;
50537
50917
  var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
50538
50918
  var len = isVertical ? "width" : "height";
50539
- var overflow = detectOverflow(state2, {
50919
+ var overflow = detectOverflow$1(state2, {
50540
50920
  placement,
50541
50921
  boundary,
50542
50922
  rootBoundary,
@@ -50601,7 +50981,7 @@ const flip$1 = {
50601
50981
  _skip: false
50602
50982
  }
50603
50983
  };
50604
- function getSideOffsets(overflow, rect, preventedOffsets) {
50984
+ function getSideOffsets$1(overflow, rect, preventedOffsets) {
50605
50985
  if (preventedOffsets === void 0) {
50606
50986
  preventedOffsets = {
50607
50987
  x: 0,
@@ -50615,26 +50995,26 @@ function getSideOffsets(overflow, rect, preventedOffsets) {
50615
50995
  left: overflow.left - rect.width - preventedOffsets.x
50616
50996
  };
50617
50997
  }
50618
- function isAnySideFullyClipped(overflow) {
50998
+ function isAnySideFullyClipped$1(overflow) {
50619
50999
  return [top, right, bottom, left].some(function(side) {
50620
51000
  return overflow[side] >= 0;
50621
51001
  });
50622
51002
  }
50623
- function hide(_ref) {
51003
+ function hide$2(_ref) {
50624
51004
  var state2 = _ref.state, name = _ref.name;
50625
51005
  var referenceRect = state2.rects.reference;
50626
51006
  var popperRect = state2.rects.popper;
50627
51007
  var preventedOffsets = state2.modifiersData.preventOverflow;
50628
- var referenceOverflow = detectOverflow(state2, {
51008
+ var referenceOverflow = detectOverflow$1(state2, {
50629
51009
  elementContext: "reference"
50630
51010
  });
50631
- var popperAltOverflow = detectOverflow(state2, {
51011
+ var popperAltOverflow = detectOverflow$1(state2, {
50632
51012
  altBoundary: true
50633
51013
  });
50634
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
50635
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
50636
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
50637
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
51014
+ var referenceClippingOffsets = getSideOffsets$1(referenceOverflow, referenceRect);
51015
+ var popperEscapeOffsets = getSideOffsets$1(popperAltOverflow, popperRect, preventedOffsets);
51016
+ var isReferenceHidden = isAnySideFullyClipped$1(referenceClippingOffsets);
51017
+ var hasPopperEscaped = isAnySideFullyClipped$1(popperEscapeOffsets);
50638
51018
  state2.modifiersData[name] = {
50639
51019
  referenceClippingOffsets,
50640
51020
  popperEscapeOffsets,
@@ -50646,12 +51026,12 @@ function hide(_ref) {
50646
51026
  "data-popper-escaped": hasPopperEscaped
50647
51027
  });
50648
51028
  }
50649
- const hide$1 = {
51029
+ const hide$3 = {
50650
51030
  name: "hide",
50651
51031
  enabled: true,
50652
51032
  phase: "main",
50653
51033
  requiresIfExists: ["preventOverflow"],
50654
- fn: hide
51034
+ fn: hide$2
50655
51035
  };
50656
51036
  function distanceAndSkiddingToXY(placement, rects, offset2) {
50657
51037
  var basePlacement = getBasePlacement$1(placement);
@@ -50711,7 +51091,7 @@ function getAltAxis(axis) {
50711
51091
  function preventOverflow(_ref) {
50712
51092
  var state2 = _ref.state, options2 = _ref.options, name = _ref.name;
50713
51093
  var _options$mainAxis = options2.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options2.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options2.boundary, rootBoundary = options2.rootBoundary, altBoundary = options2.altBoundary, padding = options2.padding, _options$tether = options2.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options2.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
50714
- var overflow = detectOverflow(state2, {
51094
+ var overflow = detectOverflow$1(state2, {
50715
51095
  boundary,
50716
51096
  rootBoundary,
50717
51097
  padding,
@@ -50749,8 +51129,8 @@ function preventOverflow(_ref) {
50749
51129
  var altSide = mainAxis === "y" ? bottom : right;
50750
51130
  var len = mainAxis === "y" ? "height" : "width";
50751
51131
  var offset2 = popperOffsets2[mainAxis];
50752
- var min$12 = offset2 + overflow[mainSide];
50753
- var max$12 = offset2 - overflow[altSide];
51132
+ var min2 = offset2 + overflow[mainSide];
51133
+ var max2 = offset2 - overflow[altSide];
50754
51134
  var additive = tether ? -popperRect[len] / 2 : 0;
50755
51135
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
50756
51136
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
@@ -50765,12 +51145,12 @@ function preventOverflow(_ref) {
50765
51145
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
50766
51146
  var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
50767
51147
  var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
50768
- var arrowOffsetParent = state2.elements.arrow && getOffsetParent(state2.elements.arrow);
51148
+ var arrowOffsetParent = state2.elements.arrow && getOffsetParent$1(state2.elements.arrow);
50769
51149
  var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
50770
51150
  var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
50771
51151
  var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
50772
51152
  var tetherMax = offset2 + maxOffset - offsetModifierValue;
50773
- var preventedOffset = within(tether ? min(min$12, tetherMin) : min$12, offset2, tether ? max(max$12, tetherMax) : max$12);
51153
+ var preventedOffset = within(tether ? min$1(min2, tetherMin) : min2, offset2, tether ? max$1(max2, tetherMax) : max2);
50774
51154
  popperOffsets2[mainAxis] = preventedOffset;
50775
51155
  data[mainAxis] = preventedOffset - offset2;
50776
51156
  }
@@ -50805,8 +51185,8 @@ function getHTMLElementScroll(element) {
50805
51185
  scrollTop: element.scrollTop
50806
51186
  };
50807
51187
  }
50808
- function getNodeScroll(node2) {
50809
- if (node2 === getWindow(node2) || !isHTMLElement$1(node2)) {
51188
+ function getNodeScroll$1(node2) {
51189
+ if (node2 === getWindow$1(node2) || !isHTMLElement$1(node2)) {
50810
51190
  return getWindowScroll(node2);
50811
51191
  } else {
50812
51192
  return getHTMLElementScroll(node2);
@@ -50814,8 +51194,8 @@ function getNodeScroll(node2) {
50814
51194
  }
50815
51195
  function isElementScaled(element) {
50816
51196
  var rect = element.getBoundingClientRect();
50817
- var scaleX = round(rect.width) / element.offsetWidth || 1;
50818
- var scaleY = round(rect.height) / element.offsetHeight || 1;
51197
+ var scaleX = round$1(rect.width) / element.offsetWidth || 1;
51198
+ var scaleY = round$1(rect.height) / element.offsetHeight || 1;
50819
51199
  return scaleX !== 1 || scaleY !== 1;
50820
51200
  }
50821
51201
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
@@ -50824,8 +51204,8 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
50824
51204
  }
50825
51205
  var isOffsetParentAnElement = isHTMLElement$1(offsetParent);
50826
51206
  var offsetParentIsScaled = isHTMLElement$1(offsetParent) && isElementScaled(offsetParent);
50827
- var documentElement = getDocumentElement(offsetParent);
50828
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
51207
+ var documentElement = getDocumentElement$1(offsetParent);
51208
+ var rect = getBoundingClientRect$1(elementOrVirtualElement, offsetParentIsScaled, isFixed);
50829
51209
  var scroll = {
50830
51210
  scrollLeft: 0,
50831
51211
  scrollTop: 0
@@ -50835,16 +51215,16 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
50835
51215
  y: 0
50836
51216
  };
50837
51217
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
50838
- if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
51218
+ if (getNodeName$1(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
50839
51219
  isScrollParent(documentElement)) {
50840
- scroll = getNodeScroll(offsetParent);
51220
+ scroll = getNodeScroll$1(offsetParent);
50841
51221
  }
50842
51222
  if (isHTMLElement$1(offsetParent)) {
50843
- offsets = getBoundingClientRect(offsetParent, true);
51223
+ offsets = getBoundingClientRect$1(offsetParent, true);
50844
51224
  offsets.x += offsetParent.clientLeft;
50845
51225
  offsets.y += offsetParent.clientTop;
50846
51226
  } else if (documentElement) {
50847
- offsets.x = getWindowScrollBarX(documentElement);
51227
+ offsets.x = getWindowScrollBarX$1(documentElement);
50848
51228
  }
50849
51229
  }
50850
51230
  return {
@@ -50959,7 +51339,7 @@ function popperGenerator(generatorOptions) {
50959
51339
  cleanupModifierEffects();
50960
51340
  state2.options = Object.assign({}, defaultOptions, state2.options, options22);
50961
51341
  state2.scrollParents = {
50962
- reference: isElement$1(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
51342
+ reference: isElement$2(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
50963
51343
  popper: listScrollParents(popper2)
50964
51344
  };
50965
51345
  var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state2.options.modifiers)));
@@ -50983,7 +51363,7 @@ function popperGenerator(generatorOptions) {
50983
51363
  return;
50984
51364
  }
50985
51365
  state2.rects = {
50986
- reference: getCompositeRect(reference3, getOffsetParent(popper3), state2.options.strategy === "fixed"),
51366
+ reference: getCompositeRect(reference3, getOffsetParent$1(popper3), state2.options.strategy === "fixed"),
50987
51367
  popper: getLayoutRect(popper3)
50988
51368
  };
50989
51369
  state2.reset = false;
@@ -51054,7 +51434,7 @@ function popperGenerator(generatorOptions) {
51054
51434
  return instance;
51055
51435
  };
51056
51436
  }
51057
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
51437
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$3];
51058
51438
  var createPopper = /* @__PURE__ */ popperGenerator({
51059
51439
  defaultModifiers
51060
51440
  });
@@ -51139,7 +51519,7 @@ function removeUndefinedProps(obj) {
51139
51519
  function div() {
51140
51520
  return document.createElement("div");
51141
51521
  }
51142
- function isElement$2(value) {
51522
+ function isElement$1(value) {
51143
51523
  return ["Element", "Fragment"].some(function(type2) {
51144
51524
  return isType(value, type2);
51145
51525
  });
@@ -51154,7 +51534,7 @@ function isReferenceElement(value) {
51154
51534
  return !!(value && value._tippy && value._tippy.reference === value);
51155
51535
  }
51156
51536
  function getArrayOfElements(value) {
51157
- if (isElement$2(value)) {
51537
+ if (isElement$1(value)) {
51158
51538
  return [value];
51159
51539
  }
51160
51540
  if (isNodeList(value)) {
@@ -51463,7 +51843,7 @@ function createArrowElement(value) {
51463
51843
  arrow2.className = ARROW_CLASS;
51464
51844
  } else {
51465
51845
  arrow2.className = SVG_ARROW_CLASS;
51466
- if (isElement$2(value)) {
51846
+ if (isElement$1(value)) {
51467
51847
  arrow2.appendChild(value);
51468
51848
  } else {
51469
51849
  dangerouslySetInnerHTML(arrow2, value);
@@ -51472,7 +51852,7 @@ function createArrowElement(value) {
51472
51852
  return arrow2;
51473
51853
  }
51474
51854
  function setContent(content, props) {
51475
- if (isElement$2(props.content)) {
51855
+ if (isElement$1(props.content)) {
51476
51856
  dangerouslySetInnerHTML(content, "");
51477
51857
  content.appendChild(props.content);
51478
51858
  } else if (typeof props.content !== "function") {
@@ -52295,7 +52675,7 @@ function tippy(targets, optionalProps) {
52295
52675
  });
52296
52676
  var elements = getArrayOfElements(targets);
52297
52677
  if (process$1$1.env.NODE_ENV !== "production") {
52298
- var isSingleContentElement = isElement$2(passedProps.content);
52678
+ var isSingleContentElement = isElement$1(passedProps.content);
52299
52679
  var isMoreThanOneReferenceElement = elements.length > 1;
52300
52680
  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(" "));
52301
52681
  }
@@ -52306,7 +52686,7 @@ function tippy(targets, optionalProps) {
52306
52686
  }
52307
52687
  return acc;
52308
52688
  }, []);
52309
- return isElement$2(targets) ? instances[0] : instances;
52689
+ return isElement$1(targets) ? instances[0] : instances;
52310
52690
  }
52311
52691
  tippy.defaultProps = defaultProps;
52312
52692
  tippy.setDefaultProps = setDefaultProps;
@@ -52575,7 +52955,1067 @@ class Popover {
52575
52955
  this.popover.remove();
52576
52956
  }
52577
52957
  }
52958
+ const sides = ["top", "right", "bottom", "left"];
52959
+ const min = Math.min;
52960
+ const max = Math.max;
52961
+ const round = Math.round;
52962
+ const floor = Math.floor;
52963
+ const createCoords = (v) => ({
52964
+ x: v,
52965
+ y: v
52966
+ });
52967
+ function evaluate(value, param) {
52968
+ return typeof value === "function" ? value(param) : value;
52969
+ }
52970
+ function getSide(placement) {
52971
+ return placement.split("-")[0];
52972
+ }
52973
+ function getAlignment(placement) {
52974
+ return placement.split("-")[1];
52975
+ }
52976
+ function getOppositeAxis(axis) {
52977
+ return axis === "x" ? "y" : "x";
52978
+ }
52979
+ function getAxisLength(axis) {
52980
+ return axis === "y" ? "height" : "width";
52981
+ }
52982
+ function getSideAxis(placement) {
52983
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
52984
+ }
52985
+ function getAlignmentAxis(placement) {
52986
+ return getOppositeAxis(getSideAxis(placement));
52987
+ }
52988
+ function expandPaddingObject(padding) {
52989
+ return {
52990
+ top: 0,
52991
+ right: 0,
52992
+ bottom: 0,
52993
+ left: 0,
52994
+ ...padding
52995
+ };
52996
+ }
52997
+ function getPaddingObject(padding) {
52998
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
52999
+ top: padding,
53000
+ right: padding,
53001
+ bottom: padding,
53002
+ left: padding
53003
+ };
53004
+ }
53005
+ function rectToClientRect(rect) {
53006
+ const {
53007
+ x,
53008
+ y,
53009
+ width,
53010
+ height
53011
+ } = rect;
53012
+ return {
53013
+ width,
53014
+ height,
53015
+ top: y,
53016
+ left: x,
53017
+ right: x + width,
53018
+ bottom: y + height,
53019
+ x,
53020
+ y
53021
+ };
53022
+ }
53023
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
53024
+ let {
53025
+ reference: reference2,
53026
+ floating
53027
+ } = _ref;
53028
+ const sideAxis = getSideAxis(placement);
53029
+ const alignmentAxis = getAlignmentAxis(placement);
53030
+ const alignLength = getAxisLength(alignmentAxis);
53031
+ const side = getSide(placement);
53032
+ const isVertical = sideAxis === "y";
53033
+ const commonX = reference2.x + reference2.width / 2 - floating.width / 2;
53034
+ const commonY = reference2.y + reference2.height / 2 - floating.height / 2;
53035
+ const commonAlign = reference2[alignLength] / 2 - floating[alignLength] / 2;
53036
+ let coords;
53037
+ switch (side) {
53038
+ case "top":
53039
+ coords = {
53040
+ x: commonX,
53041
+ y: reference2.y - floating.height
53042
+ };
53043
+ break;
53044
+ case "bottom":
53045
+ coords = {
53046
+ x: commonX,
53047
+ y: reference2.y + reference2.height
53048
+ };
53049
+ break;
53050
+ case "right":
53051
+ coords = {
53052
+ x: reference2.x + reference2.width,
53053
+ y: commonY
53054
+ };
53055
+ break;
53056
+ case "left":
53057
+ coords = {
53058
+ x: reference2.x - floating.width,
53059
+ y: commonY
53060
+ };
53061
+ break;
53062
+ default:
53063
+ coords = {
53064
+ x: reference2.x,
53065
+ y: reference2.y
53066
+ };
53067
+ }
53068
+ switch (getAlignment(placement)) {
53069
+ case "start":
53070
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
53071
+ break;
53072
+ case "end":
53073
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
53074
+ break;
53075
+ }
53076
+ return coords;
53077
+ }
53078
+ const computePosition$1 = async (reference2, floating, config) => {
53079
+ const {
53080
+ placement = "bottom",
53081
+ strategy = "absolute",
53082
+ middleware = [],
53083
+ platform: platform2
53084
+ } = config;
53085
+ const validMiddleware = middleware.filter(Boolean);
53086
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
53087
+ let rects = await platform2.getElementRects({
53088
+ reference: reference2,
53089
+ floating,
53090
+ strategy
53091
+ });
53092
+ let {
53093
+ x,
53094
+ y
53095
+ } = computeCoordsFromPlacement(rects, placement, rtl);
53096
+ let statefulPlacement = placement;
53097
+ let middlewareData = {};
53098
+ let resetCount = 0;
53099
+ for (let i = 0; i < validMiddleware.length; i++) {
53100
+ const {
53101
+ name,
53102
+ fn: fn2
53103
+ } = validMiddleware[i];
53104
+ const {
53105
+ x: nextX,
53106
+ y: nextY,
53107
+ data,
53108
+ reset
53109
+ } = await fn2({
53110
+ x,
53111
+ y,
53112
+ initialPlacement: placement,
53113
+ placement: statefulPlacement,
53114
+ strategy,
53115
+ middlewareData,
53116
+ rects,
53117
+ platform: platform2,
53118
+ elements: {
53119
+ reference: reference2,
53120
+ floating
53121
+ }
53122
+ });
53123
+ x = nextX != null ? nextX : x;
53124
+ y = nextY != null ? nextY : y;
53125
+ middlewareData = {
53126
+ ...middlewareData,
53127
+ [name]: {
53128
+ ...middlewareData[name],
53129
+ ...data
53130
+ }
53131
+ };
53132
+ if (reset && resetCount <= 50) {
53133
+ resetCount++;
53134
+ if (typeof reset === "object") {
53135
+ if (reset.placement) {
53136
+ statefulPlacement = reset.placement;
53137
+ }
53138
+ if (reset.rects) {
53139
+ rects = reset.rects === true ? await platform2.getElementRects({
53140
+ reference: reference2,
53141
+ floating,
53142
+ strategy
53143
+ }) : reset.rects;
53144
+ }
53145
+ ({
53146
+ x,
53147
+ y
53148
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
53149
+ }
53150
+ i = -1;
53151
+ }
53152
+ }
53153
+ return {
53154
+ x,
53155
+ y,
53156
+ placement: statefulPlacement,
53157
+ strategy,
53158
+ middlewareData
53159
+ };
53160
+ };
53161
+ async function detectOverflow(state2, options2) {
53162
+ var _await$platform$isEle;
53163
+ if (options2 === void 0) {
53164
+ options2 = {};
53165
+ }
53166
+ const {
53167
+ x,
53168
+ y,
53169
+ platform: platform2,
53170
+ rects,
53171
+ elements,
53172
+ strategy
53173
+ } = state2;
53174
+ const {
53175
+ boundary = "clippingAncestors",
53176
+ rootBoundary = "viewport",
53177
+ elementContext = "floating",
53178
+ altBoundary = false,
53179
+ padding = 0
53180
+ } = evaluate(options2, state2);
53181
+ const paddingObject = getPaddingObject(padding);
53182
+ const altContext = elementContext === "floating" ? "reference" : "floating";
53183
+ const element = elements[altBoundary ? altContext : elementContext];
53184
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
53185
+ 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)),
53186
+ boundary,
53187
+ rootBoundary,
53188
+ strategy
53189
+ }));
53190
+ const rect = elementContext === "floating" ? {
53191
+ x,
53192
+ y,
53193
+ width: rects.floating.width,
53194
+ height: rects.floating.height
53195
+ } : rects.reference;
53196
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
53197
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
53198
+ x: 1,
53199
+ y: 1
53200
+ } : {
53201
+ x: 1,
53202
+ y: 1
53203
+ };
53204
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
53205
+ elements,
53206
+ rect,
53207
+ offsetParent,
53208
+ strategy
53209
+ }) : rect);
53210
+ return {
53211
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
53212
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
53213
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
53214
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
53215
+ };
53216
+ }
53217
+ function getSideOffsets(overflow, rect) {
53218
+ return {
53219
+ top: overflow.top - rect.height,
53220
+ right: overflow.right - rect.width,
53221
+ bottom: overflow.bottom - rect.height,
53222
+ left: overflow.left - rect.width
53223
+ };
53224
+ }
53225
+ function isAnySideFullyClipped(overflow) {
53226
+ return sides.some((side) => overflow[side] >= 0);
53227
+ }
53228
+ const hide$1 = function(options2) {
53229
+ if (options2 === void 0) {
53230
+ options2 = {};
53231
+ }
53232
+ return {
53233
+ name: "hide",
53234
+ options: options2,
53235
+ async fn(state2) {
53236
+ const {
53237
+ rects
53238
+ } = state2;
53239
+ const {
53240
+ strategy = "referenceHidden",
53241
+ ...detectOverflowOptions
53242
+ } = evaluate(options2, state2);
53243
+ switch (strategy) {
53244
+ case "referenceHidden": {
53245
+ const overflow = await detectOverflow(state2, {
53246
+ ...detectOverflowOptions,
53247
+ elementContext: "reference"
53248
+ });
53249
+ const offsets = getSideOffsets(overflow, rects.reference);
53250
+ return {
53251
+ data: {
53252
+ referenceHiddenOffsets: offsets,
53253
+ referenceHidden: isAnySideFullyClipped(offsets)
53254
+ }
53255
+ };
53256
+ }
53257
+ case "escaped": {
53258
+ const overflow = await detectOverflow(state2, {
53259
+ ...detectOverflowOptions,
53260
+ altBoundary: true
53261
+ });
53262
+ const offsets = getSideOffsets(overflow, rects.floating);
53263
+ return {
53264
+ data: {
53265
+ escapedOffsets: offsets,
53266
+ escaped: isAnySideFullyClipped(offsets)
53267
+ }
53268
+ };
53269
+ }
53270
+ default: {
53271
+ return {};
53272
+ }
53273
+ }
53274
+ }
53275
+ };
53276
+ };
53277
+ function hasWindow() {
53278
+ return typeof window !== "undefined";
53279
+ }
53280
+ function getNodeName(node2) {
53281
+ if (isNode(node2)) {
53282
+ return (node2.nodeName || "").toLowerCase();
53283
+ }
53284
+ return "#document";
53285
+ }
53286
+ function getWindow(node2) {
53287
+ var _node$ownerDocument;
53288
+ return (node2 == null || (_node$ownerDocument = node2.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
53289
+ }
53290
+ function getDocumentElement(node2) {
53291
+ var _ref;
53292
+ return (_ref = (isNode(node2) ? node2.ownerDocument : node2.document) || window.document) == null ? void 0 : _ref.documentElement;
53293
+ }
53294
+ function isNode(value) {
53295
+ if (!hasWindow()) {
53296
+ return false;
53297
+ }
53298
+ return value instanceof Node || value instanceof getWindow(value).Node;
53299
+ }
53300
+ function isElement$3(value) {
53301
+ if (!hasWindow()) {
53302
+ return false;
53303
+ }
53304
+ return value instanceof Element || value instanceof getWindow(value).Element;
53305
+ }
53306
+ function isHTMLElement$2(value) {
53307
+ if (!hasWindow()) {
53308
+ return false;
53309
+ }
53310
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
53311
+ }
53312
+ function isShadowRoot(value) {
53313
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
53314
+ return false;
53315
+ }
53316
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
53317
+ }
53318
+ function isOverflowElement(element) {
53319
+ const {
53320
+ overflow,
53321
+ overflowX,
53322
+ overflowY,
53323
+ display
53324
+ } = getComputedStyle$1(element);
53325
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
53326
+ }
53327
+ function isTableElement(element) {
53328
+ return ["table", "td", "th"].includes(getNodeName(element));
53329
+ }
53330
+ function isTopLayer(element) {
53331
+ return [":popover-open", ":modal"].some((selector) => {
53332
+ try {
53333
+ return element.matches(selector);
53334
+ } catch (e) {
53335
+ return false;
53336
+ }
53337
+ });
53338
+ }
53339
+ function isContainingBlock(elementOrCss) {
53340
+ const webkit2 = isWebKit();
53341
+ const css = isElement$3(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
53342
+ 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));
53343
+ }
53344
+ function getContainingBlock(element) {
53345
+ let currentNode = getParentNode$2(element);
53346
+ while (isHTMLElement$2(currentNode) && !isLastTraversableNode(currentNode)) {
53347
+ if (isContainingBlock(currentNode)) {
53348
+ return currentNode;
53349
+ } else if (isTopLayer(currentNode)) {
53350
+ return null;
53351
+ }
53352
+ currentNode = getParentNode$2(currentNode);
53353
+ }
53354
+ return null;
53355
+ }
53356
+ function isWebKit() {
53357
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
53358
+ return CSS.supports("-webkit-backdrop-filter", "none");
53359
+ }
53360
+ function isLastTraversableNode(node2) {
53361
+ return ["html", "body", "#document"].includes(getNodeName(node2));
53362
+ }
53363
+ function getComputedStyle$1(element) {
53364
+ return getWindow(element).getComputedStyle(element);
53365
+ }
53366
+ function getNodeScroll(element) {
53367
+ if (isElement$3(element)) {
53368
+ return {
53369
+ scrollLeft: element.scrollLeft,
53370
+ scrollTop: element.scrollTop
53371
+ };
53372
+ }
53373
+ return {
53374
+ scrollLeft: element.scrollX,
53375
+ scrollTop: element.scrollY
53376
+ };
53377
+ }
53378
+ function getParentNode$2(node2) {
53379
+ if (getNodeName(node2) === "html") {
53380
+ return node2;
53381
+ }
53382
+ const result = (
53383
+ // Step into the shadow DOM of the parent of a slotted node.
53384
+ node2.assignedSlot || // DOM Element detected.
53385
+ node2.parentNode || // ShadowRoot detected.
53386
+ isShadowRoot(node2) && node2.host || // Fallback.
53387
+ getDocumentElement(node2)
53388
+ );
53389
+ return isShadowRoot(result) ? result.host : result;
53390
+ }
53391
+ function getNearestOverflowAncestor(node2) {
53392
+ const parentNode2 = getParentNode$2(node2);
53393
+ if (isLastTraversableNode(parentNode2)) {
53394
+ return node2.ownerDocument ? node2.ownerDocument.body : node2.body;
53395
+ }
53396
+ if (isHTMLElement$2(parentNode2) && isOverflowElement(parentNode2)) {
53397
+ return parentNode2;
53398
+ }
53399
+ return getNearestOverflowAncestor(parentNode2);
53400
+ }
53401
+ function getOverflowAncestors(node2, list, traverseIframes) {
53402
+ var _node$ownerDocument2;
53403
+ if (list === void 0) {
53404
+ list = [];
53405
+ }
53406
+ if (traverseIframes === void 0) {
53407
+ traverseIframes = true;
53408
+ }
53409
+ const scrollableAncestor = getNearestOverflowAncestor(node2);
53410
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node2.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
53411
+ const win = getWindow(scrollableAncestor);
53412
+ if (isBody) {
53413
+ const frameElement = getFrameElement(win);
53414
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
53415
+ }
53416
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
53417
+ }
53418
+ function getFrameElement(win) {
53419
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
53420
+ }
53421
+ function getCssDimensions(element) {
53422
+ const css = getComputedStyle$1(element);
53423
+ let width = parseFloat(css.width) || 0;
53424
+ let height = parseFloat(css.height) || 0;
53425
+ const hasOffset = isHTMLElement$2(element);
53426
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
53427
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
53428
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
53429
+ if (shouldFallback) {
53430
+ width = offsetWidth;
53431
+ height = offsetHeight;
53432
+ }
53433
+ return {
53434
+ width,
53435
+ height,
53436
+ $: shouldFallback
53437
+ };
53438
+ }
53439
+ function unwrapElement(element) {
53440
+ return !isElement$3(element) ? element.contextElement : element;
53441
+ }
53442
+ function getScale(element) {
53443
+ const domElement = unwrapElement(element);
53444
+ if (!isHTMLElement$2(domElement)) {
53445
+ return createCoords(1);
53446
+ }
53447
+ const rect = domElement.getBoundingClientRect();
53448
+ const {
53449
+ width,
53450
+ height,
53451
+ $
53452
+ } = getCssDimensions(domElement);
53453
+ let x = ($ ? round(rect.width) : rect.width) / width;
53454
+ let y = ($ ? round(rect.height) : rect.height) / height;
53455
+ if (!x || !Number.isFinite(x)) {
53456
+ x = 1;
53457
+ }
53458
+ if (!y || !Number.isFinite(y)) {
53459
+ y = 1;
53460
+ }
53461
+ return {
53462
+ x,
53463
+ y
53464
+ };
53465
+ }
53466
+ const noOffsets = /* @__PURE__ */ createCoords(0);
53467
+ function getVisualOffsets(element) {
53468
+ const win = getWindow(element);
53469
+ if (!isWebKit() || !win.visualViewport) {
53470
+ return noOffsets;
53471
+ }
53472
+ return {
53473
+ x: win.visualViewport.offsetLeft,
53474
+ y: win.visualViewport.offsetTop
53475
+ };
53476
+ }
53477
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
53478
+ if (isFixed === void 0) {
53479
+ isFixed = false;
53480
+ }
53481
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
53482
+ return false;
53483
+ }
53484
+ return isFixed;
53485
+ }
53486
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
53487
+ if (includeScale === void 0) {
53488
+ includeScale = false;
53489
+ }
53490
+ if (isFixedStrategy === void 0) {
53491
+ isFixedStrategy = false;
53492
+ }
53493
+ const clientRect2 = element.getBoundingClientRect();
53494
+ const domElement = unwrapElement(element);
53495
+ let scale = createCoords(1);
53496
+ if (includeScale) {
53497
+ if (offsetParent) {
53498
+ if (isElement$3(offsetParent)) {
53499
+ scale = getScale(offsetParent);
53500
+ }
53501
+ } else {
53502
+ scale = getScale(element);
53503
+ }
53504
+ }
53505
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
53506
+ let x = (clientRect2.left + visualOffsets.x) / scale.x;
53507
+ let y = (clientRect2.top + visualOffsets.y) / scale.y;
53508
+ let width = clientRect2.width / scale.x;
53509
+ let height = clientRect2.height / scale.y;
53510
+ if (domElement) {
53511
+ const win = getWindow(domElement);
53512
+ const offsetWin = offsetParent && isElement$3(offsetParent) ? getWindow(offsetParent) : offsetParent;
53513
+ let currentWin = win;
53514
+ let currentIFrame = getFrameElement(currentWin);
53515
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
53516
+ const iframeScale = getScale(currentIFrame);
53517
+ const iframeRect = currentIFrame.getBoundingClientRect();
53518
+ const css = getComputedStyle$1(currentIFrame);
53519
+ const left2 = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
53520
+ const top2 = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
53521
+ x *= iframeScale.x;
53522
+ y *= iframeScale.y;
53523
+ width *= iframeScale.x;
53524
+ height *= iframeScale.y;
53525
+ x += left2;
53526
+ y += top2;
53527
+ currentWin = getWindow(currentIFrame);
53528
+ currentIFrame = getFrameElement(currentWin);
53529
+ }
53530
+ }
53531
+ return rectToClientRect({
53532
+ width,
53533
+ height,
53534
+ x,
53535
+ y
53536
+ });
53537
+ }
53538
+ function getWindowScrollBarX(element, rect) {
53539
+ const leftScroll = getNodeScroll(element).scrollLeft;
53540
+ if (!rect) {
53541
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
53542
+ }
53543
+ return rect.left + leftScroll;
53544
+ }
53545
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
53546
+ if (ignoreScrollbarX === void 0) {
53547
+ ignoreScrollbarX = false;
53548
+ }
53549
+ const htmlRect = documentElement.getBoundingClientRect();
53550
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
53551
+ // RTL <body> scrollbar.
53552
+ getWindowScrollBarX(documentElement, htmlRect)
53553
+ ));
53554
+ const y = htmlRect.top + scroll.scrollTop;
53555
+ return {
53556
+ x,
53557
+ y
53558
+ };
53559
+ }
53560
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
53561
+ let {
53562
+ elements,
53563
+ rect,
53564
+ offsetParent,
53565
+ strategy
53566
+ } = _ref;
53567
+ const isFixed = strategy === "fixed";
53568
+ const documentElement = getDocumentElement(offsetParent);
53569
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
53570
+ if (offsetParent === documentElement || topLayer && isFixed) {
53571
+ return rect;
53572
+ }
53573
+ let scroll = {
53574
+ scrollLeft: 0,
53575
+ scrollTop: 0
53576
+ };
53577
+ let scale = createCoords(1);
53578
+ const offsets = createCoords(0);
53579
+ const isOffsetParentAnElement = isHTMLElement$2(offsetParent);
53580
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
53581
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
53582
+ scroll = getNodeScroll(offsetParent);
53583
+ }
53584
+ if (isHTMLElement$2(offsetParent)) {
53585
+ const offsetRect = getBoundingClientRect(offsetParent);
53586
+ scale = getScale(offsetParent);
53587
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
53588
+ offsets.y = offsetRect.y + offsetParent.clientTop;
53589
+ }
53590
+ }
53591
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
53592
+ return {
53593
+ width: rect.width * scale.x,
53594
+ height: rect.height * scale.y,
53595
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
53596
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
53597
+ };
53598
+ }
53599
+ function getClientRects(element) {
53600
+ return Array.from(element.getClientRects());
53601
+ }
53602
+ function getDocumentRect(element) {
53603
+ const html = getDocumentElement(element);
53604
+ const scroll = getNodeScroll(element);
53605
+ const body = element.ownerDocument.body;
53606
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
53607
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
53608
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
53609
+ const y = -scroll.scrollTop;
53610
+ if (getComputedStyle$1(body).direction === "rtl") {
53611
+ x += max(html.clientWidth, body.clientWidth) - width;
53612
+ }
53613
+ return {
53614
+ width,
53615
+ height,
53616
+ x,
53617
+ y
53618
+ };
53619
+ }
53620
+ function getViewportRect(element, strategy) {
53621
+ const win = getWindow(element);
53622
+ const html = getDocumentElement(element);
53623
+ const visualViewport = win.visualViewport;
53624
+ let width = html.clientWidth;
53625
+ let height = html.clientHeight;
53626
+ let x = 0;
53627
+ let y = 0;
53628
+ if (visualViewport) {
53629
+ width = visualViewport.width;
53630
+ height = visualViewport.height;
53631
+ const visualViewportBased = isWebKit();
53632
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
53633
+ x = visualViewport.offsetLeft;
53634
+ y = visualViewport.offsetTop;
53635
+ }
53636
+ }
53637
+ return {
53638
+ width,
53639
+ height,
53640
+ x,
53641
+ y
53642
+ };
53643
+ }
53644
+ function getInnerBoundingClientRect(element, strategy) {
53645
+ const clientRect2 = getBoundingClientRect(element, true, strategy === "fixed");
53646
+ const top2 = clientRect2.top + element.clientTop;
53647
+ const left2 = clientRect2.left + element.clientLeft;
53648
+ const scale = isHTMLElement$2(element) ? getScale(element) : createCoords(1);
53649
+ const width = element.clientWidth * scale.x;
53650
+ const height = element.clientHeight * scale.y;
53651
+ const x = left2 * scale.x;
53652
+ const y = top2 * scale.y;
53653
+ return {
53654
+ width,
53655
+ height,
53656
+ x,
53657
+ y
53658
+ };
53659
+ }
53660
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
53661
+ let rect;
53662
+ if (clippingAncestor === "viewport") {
53663
+ rect = getViewportRect(element, strategy);
53664
+ } else if (clippingAncestor === "document") {
53665
+ rect = getDocumentRect(getDocumentElement(element));
53666
+ } else if (isElement$3(clippingAncestor)) {
53667
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
53668
+ } else {
53669
+ const visualOffsets = getVisualOffsets(element);
53670
+ rect = {
53671
+ x: clippingAncestor.x - visualOffsets.x,
53672
+ y: clippingAncestor.y - visualOffsets.y,
53673
+ width: clippingAncestor.width,
53674
+ height: clippingAncestor.height
53675
+ };
53676
+ }
53677
+ return rectToClientRect(rect);
53678
+ }
53679
+ function hasFixedPositionAncestor(element, stopNode) {
53680
+ const parentNode2 = getParentNode$2(element);
53681
+ if (parentNode2 === stopNode || !isElement$3(parentNode2) || isLastTraversableNode(parentNode2)) {
53682
+ return false;
53683
+ }
53684
+ return getComputedStyle$1(parentNode2).position === "fixed" || hasFixedPositionAncestor(parentNode2, stopNode);
53685
+ }
53686
+ function getClippingElementAncestors(element, cache2) {
53687
+ const cachedResult2 = cache2.get(element);
53688
+ if (cachedResult2) {
53689
+ return cachedResult2;
53690
+ }
53691
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement$3(el) && getNodeName(el) !== "body");
53692
+ let currentContainingBlockComputedStyle = null;
53693
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
53694
+ let currentNode = elementIsFixed ? getParentNode$2(element) : element;
53695
+ while (isElement$3(currentNode) && !isLastTraversableNode(currentNode)) {
53696
+ const computedStyle = getComputedStyle$1(currentNode);
53697
+ const currentNodeIsContaining = isContainingBlock(currentNode);
53698
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
53699
+ currentContainingBlockComputedStyle = null;
53700
+ }
53701
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
53702
+ if (shouldDropCurrentNode) {
53703
+ result = result.filter((ancestor) => ancestor !== currentNode);
53704
+ } else {
53705
+ currentContainingBlockComputedStyle = computedStyle;
53706
+ }
53707
+ currentNode = getParentNode$2(currentNode);
53708
+ }
53709
+ cache2.set(element, result);
53710
+ return result;
53711
+ }
53712
+ function getClippingRect(_ref) {
53713
+ let {
53714
+ element,
53715
+ boundary,
53716
+ rootBoundary,
53717
+ strategy
53718
+ } = _ref;
53719
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
53720
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
53721
+ const firstClippingAncestor = clippingAncestors[0];
53722
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
53723
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
53724
+ accRect.top = max(rect.top, accRect.top);
53725
+ accRect.right = min(rect.right, accRect.right);
53726
+ accRect.bottom = min(rect.bottom, accRect.bottom);
53727
+ accRect.left = max(rect.left, accRect.left);
53728
+ return accRect;
53729
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
53730
+ return {
53731
+ width: clippingRect.right - clippingRect.left,
53732
+ height: clippingRect.bottom - clippingRect.top,
53733
+ x: clippingRect.left,
53734
+ y: clippingRect.top
53735
+ };
53736
+ }
53737
+ function getDimensions(element) {
53738
+ const {
53739
+ width,
53740
+ height
53741
+ } = getCssDimensions(element);
53742
+ return {
53743
+ width,
53744
+ height
53745
+ };
53746
+ }
53747
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
53748
+ const isOffsetParentAnElement = isHTMLElement$2(offsetParent);
53749
+ const documentElement = getDocumentElement(offsetParent);
53750
+ const isFixed = strategy === "fixed";
53751
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
53752
+ let scroll = {
53753
+ scrollLeft: 0,
53754
+ scrollTop: 0
53755
+ };
53756
+ const offsets = createCoords(0);
53757
+ function setLeftRTLScrollbarOffset() {
53758
+ offsets.x = getWindowScrollBarX(documentElement);
53759
+ }
53760
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
53761
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
53762
+ scroll = getNodeScroll(offsetParent);
53763
+ }
53764
+ if (isOffsetParentAnElement) {
53765
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
53766
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
53767
+ offsets.y = offsetRect.y + offsetParent.clientTop;
53768
+ } else if (documentElement) {
53769
+ setLeftRTLScrollbarOffset();
53770
+ }
53771
+ }
53772
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
53773
+ setLeftRTLScrollbarOffset();
53774
+ }
53775
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
53776
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
53777
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
53778
+ return {
53779
+ x,
53780
+ y,
53781
+ width: rect.width,
53782
+ height: rect.height
53783
+ };
53784
+ }
53785
+ function isStaticPositioned(element) {
53786
+ return getComputedStyle$1(element).position === "static";
53787
+ }
53788
+ function getTrueOffsetParent(element, polyfill) {
53789
+ if (!isHTMLElement$2(element) || getComputedStyle$1(element).position === "fixed") {
53790
+ return null;
53791
+ }
53792
+ if (polyfill) {
53793
+ return polyfill(element);
53794
+ }
53795
+ let rawOffsetParent = element.offsetParent;
53796
+ if (getDocumentElement(element) === rawOffsetParent) {
53797
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
53798
+ }
53799
+ return rawOffsetParent;
53800
+ }
53801
+ function getOffsetParent(element, polyfill) {
53802
+ const win = getWindow(element);
53803
+ if (isTopLayer(element)) {
53804
+ return win;
53805
+ }
53806
+ if (!isHTMLElement$2(element)) {
53807
+ let svgOffsetParent = getParentNode$2(element);
53808
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
53809
+ if (isElement$3(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
53810
+ return svgOffsetParent;
53811
+ }
53812
+ svgOffsetParent = getParentNode$2(svgOffsetParent);
53813
+ }
53814
+ return win;
53815
+ }
53816
+ let offsetParent = getTrueOffsetParent(element, polyfill);
53817
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
53818
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
53819
+ }
53820
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
53821
+ return win;
53822
+ }
53823
+ return offsetParent || getContainingBlock(element) || win;
53824
+ }
53825
+ const getElementRects = async function(data) {
53826
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
53827
+ const getDimensionsFn = this.getDimensions;
53828
+ const floatingDimensions = await getDimensionsFn(data.floating);
53829
+ return {
53830
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
53831
+ floating: {
53832
+ x: 0,
53833
+ y: 0,
53834
+ width: floatingDimensions.width,
53835
+ height: floatingDimensions.height
53836
+ }
53837
+ };
53838
+ };
53839
+ function isRTL(element) {
53840
+ return getComputedStyle$1(element).direction === "rtl";
53841
+ }
53842
+ const platform = {
53843
+ convertOffsetParentRelativeRectToViewportRelativeRect,
53844
+ getDocumentElement,
53845
+ getClippingRect,
53846
+ getOffsetParent,
53847
+ getElementRects,
53848
+ getClientRects,
53849
+ getDimensions,
53850
+ getScale,
53851
+ isElement: isElement$3,
53852
+ isRTL
53853
+ };
53854
+ function rectsAreEqual(a, b) {
53855
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
53856
+ }
53857
+ function observeMove(element, onMove) {
53858
+ let io = null;
53859
+ let timeoutId;
53860
+ const root2 = getDocumentElement(element);
53861
+ function cleanup() {
53862
+ var _io;
53863
+ clearTimeout(timeoutId);
53864
+ (_io = io) == null || _io.disconnect();
53865
+ io = null;
53866
+ }
53867
+ function refresh(skip, threshold) {
53868
+ if (skip === void 0) {
53869
+ skip = false;
53870
+ }
53871
+ if (threshold === void 0) {
53872
+ threshold = 1;
53873
+ }
53874
+ cleanup();
53875
+ const elementRectForRootMargin = element.getBoundingClientRect();
53876
+ const {
53877
+ left: left2,
53878
+ top: top2,
53879
+ width,
53880
+ height
53881
+ } = elementRectForRootMargin;
53882
+ if (!skip) {
53883
+ onMove();
53884
+ }
53885
+ if (!width || !height) {
53886
+ return;
53887
+ }
53888
+ const insetTop = floor(top2);
53889
+ const insetRight = floor(root2.clientWidth - (left2 + width));
53890
+ const insetBottom = floor(root2.clientHeight - (top2 + height));
53891
+ const insetLeft = floor(left2);
53892
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
53893
+ const options2 = {
53894
+ rootMargin,
53895
+ threshold: max(0, min(1, threshold)) || 1
53896
+ };
53897
+ let isFirstUpdate = true;
53898
+ function handleObserve(entries) {
53899
+ const ratio = entries[0].intersectionRatio;
53900
+ if (ratio !== threshold) {
53901
+ if (!isFirstUpdate) {
53902
+ return refresh();
53903
+ }
53904
+ if (!ratio) {
53905
+ timeoutId = setTimeout(() => {
53906
+ refresh(false, 1e-7);
53907
+ }, 1e3);
53908
+ } else {
53909
+ refresh(false, ratio);
53910
+ }
53911
+ }
53912
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
53913
+ refresh();
53914
+ }
53915
+ isFirstUpdate = false;
53916
+ }
53917
+ try {
53918
+ io = new IntersectionObserver(handleObserve, {
53919
+ ...options2,
53920
+ // Handle <iframe>s
53921
+ root: root2.ownerDocument
53922
+ });
53923
+ } catch (_e) {
53924
+ io = new IntersectionObserver(handleObserve, options2);
53925
+ }
53926
+ io.observe(element);
53927
+ }
53928
+ refresh(true);
53929
+ return cleanup;
53930
+ }
53931
+ function autoUpdate(reference2, floating, update, options2) {
53932
+ if (options2 === void 0) {
53933
+ options2 = {};
53934
+ }
53935
+ const {
53936
+ ancestorScroll = true,
53937
+ ancestorResize = true,
53938
+ elementResize = typeof ResizeObserver === "function",
53939
+ layoutShift = typeof IntersectionObserver === "function",
53940
+ animationFrame = false
53941
+ } = options2;
53942
+ const referenceEl = unwrapElement(reference2);
53943
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
53944
+ ancestors.forEach((ancestor) => {
53945
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
53946
+ passive: true
53947
+ });
53948
+ ancestorResize && ancestor.addEventListener("resize", update);
53949
+ });
53950
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
53951
+ let reobserveFrame = -1;
53952
+ let resizeObserver = null;
53953
+ if (elementResize) {
53954
+ resizeObserver = new ResizeObserver((_ref) => {
53955
+ let [firstEntry] = _ref;
53956
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
53957
+ resizeObserver.unobserve(floating);
53958
+ cancelAnimationFrame(reobserveFrame);
53959
+ reobserveFrame = requestAnimationFrame(() => {
53960
+ var _resizeObserver;
53961
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
53962
+ });
53963
+ }
53964
+ update();
53965
+ });
53966
+ if (referenceEl && !animationFrame) {
53967
+ resizeObserver.observe(referenceEl);
53968
+ }
53969
+ resizeObserver.observe(floating);
53970
+ }
53971
+ let frameId;
53972
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference2) : null;
53973
+ if (animationFrame) {
53974
+ frameLoop();
53975
+ }
53976
+ function frameLoop() {
53977
+ const nextRefRect = getBoundingClientRect(reference2);
53978
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
53979
+ update();
53980
+ }
53981
+ prevRefRect = nextRefRect;
53982
+ frameId = requestAnimationFrame(frameLoop);
53983
+ }
53984
+ update();
53985
+ return () => {
53986
+ var _resizeObserver2;
53987
+ ancestors.forEach((ancestor) => {
53988
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
53989
+ ancestorResize && ancestor.removeEventListener("resize", update);
53990
+ });
53991
+ cleanupIo == null || cleanupIo();
53992
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
53993
+ resizeObserver = null;
53994
+ if (animationFrame) {
53995
+ cancelAnimationFrame(frameId);
53996
+ }
53997
+ };
53998
+ }
53999
+ const hide = hide$1;
54000
+ const computePosition = (reference2, floating, options2) => {
54001
+ const cache2 = /* @__PURE__ */ new Map();
54002
+ const mergedOptions = {
54003
+ platform,
54004
+ ...options2
54005
+ };
54006
+ const platformWithCache = {
54007
+ ...mergedOptions.platform,
54008
+ _c: cache2
54009
+ };
54010
+ return computePosition$1(reference2, floating, {
54011
+ ...mergedOptions,
54012
+ platform: platformWithCache
54013
+ });
54014
+ };
54015
+ const SEPARATOR_CLASS = "pagination-separator";
54016
+ const SEPARATOR_FLOATING_CLASS = "pagination-separator-floating";
52578
54017
  const isDebugging = false;
54018
+ const cleanupFunctions = /* @__PURE__ */ new Set();
52579
54019
  const Pagination = Extension.create({
52580
54020
  name: "pagination",
52581
54021
  addStorage() {
@@ -52665,7 +54105,7 @@ const Pagination = Extension.create({
52665
54105
  view: (view) => {
52666
54106
  let previousDecorations = DecorationSet.empty;
52667
54107
  return {
52668
- update: (view2) => {
54108
+ update: (view2, prevState) => {
52669
54109
  if (!shouldUpdate || isUpdating) return;
52670
54110
  isUpdating = true;
52671
54111
  hasInitialized = true;
@@ -52682,6 +54122,9 @@ const Pagination = Extension.create({
52682
54122
  }
52683
54123
  });
52684
54124
  return [paginationPlugin];
54125
+ },
54126
+ onDestroy() {
54127
+ cleanupFloatingSeparators();
52685
54128
  }
52686
54129
  });
52687
54130
  const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null) => {
@@ -52719,12 +54162,23 @@ const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null)
52719
54162
  const performUpdate = (editor, view, previousDecorations) => {
52720
54163
  const sectionData = editor.storage.pagination.sectionData;
52721
54164
  const newDecorations = calculatePageBreaks(view, editor, sectionData);
54165
+ const editorElement = editor.options.element;
52722
54166
  if (!previousDecorations.eq(newDecorations)) {
52723
54167
  const updateTransaction = view.state.tr.setMeta(
52724
54168
  PaginationPluginKey,
52725
54169
  { decorations: newDecorations }
52726
54170
  );
52727
54171
  view.dispatch(updateTransaction);
54172
+ requestAnimationFrame(() => {
54173
+ requestAnimationFrame(() => {
54174
+ cleanupFloatingSeparators();
54175
+ const separators = [...editorElement.querySelectorAll(`.${SEPARATOR_CLASS}--table`)];
54176
+ separators.forEach((separator) => {
54177
+ const { cleanup } = createFloatingSeparator(separator, editor);
54178
+ cleanupFunctions.add(cleanup);
54179
+ });
54180
+ });
54181
+ });
52728
54182
  }
52729
54183
  editor.emit("paginationUpdate");
52730
54184
  };
@@ -52765,16 +54219,15 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52765
54219
  const decorations = [];
52766
54220
  const { pageSize, pageMargins } = editor.converter.pageStyles;
52767
54221
  const pageHeight = pageSize.height * 96;
52768
- editor.options.scale;
52769
54222
  let currentPageNumber = 1;
52770
54223
  let pageHeightThreshold = pageHeight;
52771
54224
  let footer = null, header = null;
52772
54225
  const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52773
- const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor);
54226
+ const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
52774
54227
  const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
52775
54228
  decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
52776
54229
  const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
52777
- const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor);
54230
+ const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
52778
54231
  pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
52779
54232
  let coords = view?.coordsAtPos(doc2.content.size);
52780
54233
  if (!coords) return [];
@@ -52793,7 +54246,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52793
54246
  if (currentPageNumber === 1) {
52794
54247
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
52795
54248
  decorations.pop();
52796
- const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
54249
+ const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
52797
54250
  const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
52798
54251
  decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
52799
54252
  }
@@ -52809,7 +54262,9 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52809
54262
  }
52810
54263
  if (isHardBreakNode || shouldAddPageBreak) {
52811
54264
  const $currentPos = view.state.doc.resolve(currentPos);
54265
+ const table = findParentNodeClosestToPos($currentPos, (node22) => node22.type.name === "table");
52812
54266
  const tableRow = findParentNodeClosestToPos($currentPos, (node22) => node22.type.name === "tableRow");
54267
+ let isInTable2 = table || tableRow ? true : false;
52813
54268
  if (tableRow) {
52814
54269
  currentNode = tableRow.node;
52815
54270
  currentPos = tableRow.pos;
@@ -52822,13 +54277,13 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52822
54277
  const footerId2 = getHeaderFooterId(currentPageNumber, "footerIds", editor, currentNode);
52823
54278
  currentPageNumber++;
52824
54279
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52825
- header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
54280
+ header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
52826
54281
  footer = createFooter(pageMargins, pageSize, sectionData, footerId2, editor, currentPageNumber - 1);
52827
54282
  const bufferHeight2 = pageHeightThreshold - actualBreakBottom;
52828
54283
  const { node: spacingNode2 } = createFinalPagePadding(bufferHeight2);
52829
54284
  const pageSpacer2 = Decoration.widget(breakPos, spacingNode2, { key: "stable-key" });
52830
54285
  decorations.push(pageSpacer2);
52831
- const pageBreak2 = createPageBreak({ editor, header, footer });
54286
+ const pageBreak2 = createPageBreak({ editor, header, footer, isInTable: isInTable2 });
52832
54287
  decorations.push(Decoration.widget(breakPos, pageBreak2, { key: "stable-key" }));
52833
54288
  pageHeightThreshold = actualBreakBottom + (pageHeight - header.headerHeight - footer.footerHeight);
52834
54289
  }
@@ -52837,7 +54292,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52837
54292
  const lastNodeCoords = view.coordsAtPos(finalPos);
52838
54293
  const headerId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52839
54294
  const footerId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
52840
- header = createHeader(pageMargins, pageSize, sectionData, headerId, editor);
54295
+ header = createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber);
52841
54296
  footer = createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber);
52842
54297
  const bufferHeight = pageHeightThreshold - lastNodeCoords.bottom;
52843
54298
  const { node: spacingNode } = createFinalPagePadding(bufferHeight);
@@ -52854,6 +54309,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52854
54309
  totalPageNumber.innerText = currentPageNumber;
52855
54310
  }
52856
54311
  });
54312
+ editor.currentTotalPages = currentPageNumber;
52857
54313
  return decorations;
52858
54314
  }
52859
54315
  function createFinalPagePadding(bufferHeight) {
@@ -52864,7 +54320,7 @@ function createFinalPagePadding(bufferHeight) {
52864
54320
  div2.style.height = bufferHeight + "px";
52865
54321
  return { nodeHeight: bufferHeight, node: div2 };
52866
54322
  }
52867
- function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
54323
+ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
52868
54324
  const headerDef = sectionData.headers?.[headerId];
52869
54325
  const minHeaderHeight = pageMargins.top * 96;
52870
54326
  const headerMargin = pageMargins.header * 96;
@@ -52891,7 +54347,8 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
52891
54347
  appendToBody: false,
52892
54348
  sectionId: headerId,
52893
54349
  type: "header",
52894
- availableHeight
54350
+ availableHeight,
54351
+ currentPageNumber
52895
54352
  });
52896
54353
  editor.converter.headerEditors.push({
52897
54354
  id: headerId,
@@ -52917,13 +54374,6 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
52917
54374
  const minFooterHeight = pageMargins.bottom * 96;
52918
54375
  const footerPaddingFromEdge = pageMargins.footer * 96;
52919
54376
  const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
52920
- const sectionContainer = footerDef?.sectionContainer?.cloneNode(true);
52921
- const autoPageNumber = sectionContainer?.querySelector('span[data-id="auto-page-number"]');
52922
- if (autoPageNumber) {
52923
- const fontSize2 = autoPageNumber.previousElementSibling?.style?.fontSize || autoPageNumber.nextElementSibling?.style?.fontSize;
52924
- if (fontSize2) autoPageNumber.style.fontSize = fontSize2;
52925
- autoPageNumber.innerText = currentPageNumber;
52926
- }
52927
54377
  const editorContainer = document.createElement("div");
52928
54378
  if (!footerId && !editor.converter.footerIds["default"]) {
52929
54379
  footerId = "rId" + generateDocxRandomId();
@@ -52943,7 +54393,8 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
52943
54393
  appendToBody: false,
52944
54394
  sectionId: footerId,
52945
54395
  type: "footer",
52946
- availableHeight: footerHeight
54396
+ availableHeight: footerHeight,
54397
+ currentPageNumber
52947
54398
  });
52948
54399
  editor.converter.footerEditors.push({
52949
54400
  id: footerId,
@@ -52969,7 +54420,7 @@ const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
52969
54420
  editor.setEditable(false, false);
52970
54421
  toggleHeaderFooterEditMode(editor, currentFocusedSectionEditor, true);
52971
54422
  };
52972
- function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter }) {
54423
+ function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
52973
54424
  const { pageSize, pageMargins } = editor.converter.pageStyles;
52974
54425
  let sectionHeight = 0;
52975
54426
  const paginationDiv = document.createElement("div");
@@ -52988,7 +54439,10 @@ function createPageBreak({ editor, header, footer, footerBottom = null, isFirstH
52988
54439
  const separatorHeight = 20;
52989
54440
  sectionHeight += separatorHeight;
52990
54441
  const separator = document.createElement("div");
52991
- separator.className = "pagination-separator";
54442
+ separator.classList.add(SEPARATOR_CLASS);
54443
+ if (isInTable2) {
54444
+ separator.classList.add(`${SEPARATOR_CLASS}--table`);
54445
+ }
52992
54446
  innerDiv.appendChild(separator);
52993
54447
  }
52994
54448
  if (header) {
@@ -53027,6 +54481,85 @@ const onImageLoad = (editor) => {
53027
54481
  editor.view.dispatch(newTr);
53028
54482
  });
53029
54483
  };
54484
+ function createFloatingSeparator(separator, editor) {
54485
+ const floatingSeparator = document.createElement("div");
54486
+ floatingSeparator.classList.add(SEPARATOR_FLOATING_CLASS);
54487
+ floatingSeparator.dataset.floatingSeparator = "";
54488
+ const editorElement = editor.options.element;
54489
+ editorElement.append(floatingSeparator);
54490
+ const updatePosition2 = () => {
54491
+ computePosition(separator, floatingSeparator, {
54492
+ strategy: "absolute",
54493
+ placement: "top-start",
54494
+ middleware: [
54495
+ hide(),
54496
+ {
54497
+ name: "copy",
54498
+ fn: ({ elements }) => {
54499
+ const rect = elements.reference.getBoundingClientRect();
54500
+ const containerRect = editorElement.getBoundingClientRect();
54501
+ const scaleFactor = getScaleFactor(editorElement);
54502
+ const x = Math.round((rect.left - containerRect.left) / scaleFactor);
54503
+ const y = Math.round((rect.top - containerRect.top) / scaleFactor);
54504
+ const width = Math.round(rect.width / scaleFactor);
54505
+ const height = Math.round(rect.height / scaleFactor);
54506
+ return {
54507
+ x,
54508
+ y,
54509
+ data: { width, height }
54510
+ };
54511
+ }
54512
+ }
54513
+ ]
54514
+ }).then(({ x, y, middlewareData }) => {
54515
+ Object.assign(floatingSeparator.style, {
54516
+ top: `${y}px`,
54517
+ left: `${x}px`,
54518
+ width: `${middlewareData.copy.width}px`,
54519
+ height: `${middlewareData.copy.height}px`,
54520
+ visibility: middlewareData.hide?.referenceHidden ? "hidden" : "visible"
54521
+ });
54522
+ });
54523
+ };
54524
+ const cleanup = autoUpdate(
54525
+ separator,
54526
+ floatingSeparator,
54527
+ updatePosition2
54528
+ );
54529
+ const extendedCleanup = () => {
54530
+ floatingSeparator?.remove();
54531
+ cleanup();
54532
+ };
54533
+ return {
54534
+ cleanup: extendedCleanup,
54535
+ updatePosition: updatePosition2
54536
+ };
54537
+ }
54538
+ function cleanupFloatingSeparators() {
54539
+ cleanupFunctions.forEach((cleanup) => cleanup());
54540
+ cleanupFunctions.clear();
54541
+ }
54542
+ function getScaleFactor(element) {
54543
+ let scale = 1;
54544
+ let currentElement2 = element;
54545
+ while (currentElement2 && currentElement2 !== document.documentElement) {
54546
+ let zoomStyle = currentElement2.style.zoom;
54547
+ if (zoomStyle) {
54548
+ let zoom = parseFloat(zoomStyle) || 1;
54549
+ scale *= zoom;
54550
+ }
54551
+ let transformStyle = currentElement2.style.transform;
54552
+ if (transformStyle) {
54553
+ let scaleMatch = transformStyle.match(/scale\(([^)]+)\)/);
54554
+ if (scaleMatch) {
54555
+ let scaleValue = parseFloat(scaleMatch[1]) || 1;
54556
+ scale *= scaleValue;
54557
+ }
54558
+ }
54559
+ currentElement2 = currentElement2.parentElement;
54560
+ }
54561
+ return scale;
54562
+ }
53030
54563
  class SearchQuery {
53031
54564
  /**
53032
54565
  Create a query object.
@@ -57066,7 +58599,7 @@ var ResizeObserverController = function() {
57066
58599
  };
57067
58600
  return ResizeObserverController2;
57068
58601
  }();
57069
- var ResizeObserver = function() {
58602
+ var ResizeObserver$1 = function() {
57070
58603
  function ResizeObserver2(callback) {
57071
58604
  if (arguments.length === 0) {
57072
58605
  throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
@@ -57105,7 +58638,7 @@ var ResizeObserver = function() {
57105
58638
  class ResizeObserverDelegate {
57106
58639
  constructor() {
57107
58640
  this.handleResize = this.handleResize.bind(this);
57108
- this.observer = new (typeof window !== "undefined" && window.ResizeObserver || ResizeObserver)(this.handleResize);
58641
+ this.observer = new (typeof window !== "undefined" && window.ResizeObserver || ResizeObserver$1)(this.handleResize);
57109
58642
  this.elHandlersMap = /* @__PURE__ */ new Map();
57110
58643
  }
57111
58644
  handleResize(entries) {
@@ -67511,7 +69044,7 @@ const _sfc_main$2 = {
67511
69044
  };
67512
69045
  }
67513
69046
  };
67514
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-199a4ecf"]]);
69047
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-4b700df1"]]);
67515
69048
  const _sfc_main$1 = {
67516
69049
  __name: "BasicUpload",
67517
69050
  emits: ["file-change"],