@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
@@ -2556,29 +2556,29 @@ function requireAbs() {
2556
2556
  abs$1 = Math.abs;
2557
2557
  return abs$1;
2558
2558
  }
2559
- var floor$1;
2559
+ var floor$2;
2560
2560
  var hasRequiredFloor;
2561
2561
  function requireFloor() {
2562
- if (hasRequiredFloor) return floor$1;
2562
+ if (hasRequiredFloor) return floor$2;
2563
2563
  hasRequiredFloor = 1;
2564
- floor$1 = Math.floor;
2565
- return floor$1;
2564
+ floor$2 = Math.floor;
2565
+ return floor$2;
2566
2566
  }
2567
- var max$2;
2567
+ var max$3;
2568
2568
  var hasRequiredMax;
2569
2569
  function requireMax() {
2570
- if (hasRequiredMax) return max$2;
2570
+ if (hasRequiredMax) return max$3;
2571
2571
  hasRequiredMax = 1;
2572
- max$2 = Math.max;
2573
- return max$2;
2572
+ max$3 = Math.max;
2573
+ return max$3;
2574
2574
  }
2575
- var min$2;
2575
+ var min$3;
2576
2576
  var hasRequiredMin;
2577
2577
  function requireMin() {
2578
- if (hasRequiredMin) return min$2;
2578
+ if (hasRequiredMin) return min$3;
2579
2579
  hasRequiredMin = 1;
2580
- min$2 = Math.min;
2581
- return min$2;
2580
+ min$3 = Math.min;
2581
+ return min$3;
2582
2582
  }
2583
2583
  var pow;
2584
2584
  var hasRequiredPow;
@@ -2588,13 +2588,13 @@ function requirePow() {
2588
2588
  pow = Math.pow;
2589
2589
  return pow;
2590
2590
  }
2591
- var round$1;
2591
+ var round$2;
2592
2592
  var hasRequiredRound;
2593
2593
  function requireRound() {
2594
- if (hasRequiredRound) return round$1;
2594
+ if (hasRequiredRound) return round$2;
2595
2595
  hasRequiredRound = 1;
2596
- round$1 = Math.round;
2597
- return round$1;
2596
+ round$2 = Math.round;
2597
+ return round$2;
2598
2598
  }
2599
2599
  var _isNaN;
2600
2600
  var hasRequired_isNaN;
@@ -16057,7 +16057,6 @@ const getLineHeightValueString = (lineHeight2, defaultUnit, lineRule = "", isObj
16057
16057
  if (Number.isNaN(value) || value === 0) return {};
16058
16058
  if (lineRule === "atLeast" && value < 1) return {};
16059
16059
  unit = unit ? unit : defaultUnit;
16060
- value += unit ? 4 : 0.2;
16061
16060
  return isObject2 ? { ["line-height"]: `${value}${unit}` } : `line-height: ${value}${unit}`;
16062
16061
  };
16063
16062
  const deobfuscateFont = (arrayBuffer, guidHex) => {
@@ -18846,7 +18845,9 @@ function exportSchemaToJson(params2) {
18846
18845
  shapeContainer: translateShapeContainer,
18847
18846
  shapeTextbox: translateShapeTextbox,
18848
18847
  contentBlock: translateContentBlock,
18849
- structuredContent: translateStructuredContent
18848
+ structuredContent: translateStructuredContent,
18849
+ "page-number": translatePageNumberNode,
18850
+ "total-page-number": translateTotalPageNumberNode
18850
18851
  };
18851
18852
  if (!router[type2]) {
18852
18853
  console.error("No translation function found for node type:", type2);
@@ -19284,7 +19285,10 @@ function translateList(params2) {
19284
19285
  if (Array.isArray(outputNode)) {
19285
19286
  const mapped = [];
19286
19287
  outputNode.forEach((el, index22) => {
19287
- mapped.push(...el.elements);
19288
+ el.elements.forEach((element) => {
19289
+ if (element.name === "w:pPr") return;
19290
+ mapped.push(element);
19291
+ });
19288
19292
  if (index22 < outputNode.length - 1) mapped.push({ name: "w:br", type: "element" });
19289
19293
  });
19290
19294
  mapped.unshift(carbonCopy(pPr));
@@ -20540,6 +20544,81 @@ function translateStructuredContent(params2) {
20540
20544
  elements: nodeElements
20541
20545
  };
20542
20546
  }
20547
+ const translatePageNumberNode = (params2) => {
20548
+ const outputMarks = processOutputMarks(params2.node.attrs?.marksAsAttrs || []);
20549
+ return getAutoPageJson("PAGE", outputMarks);
20550
+ };
20551
+ const translateTotalPageNumberNode = (params2) => {
20552
+ const outputMarks = processOutputMarks(params2.node.attrs?.marksAsAttrs || []);
20553
+ return getAutoPageJson("NUMPAGES", outputMarks);
20554
+ };
20555
+ const getAutoPageJson = (type2, outputMarks = []) => {
20556
+ return [
20557
+ {
20558
+ "name": "w:r",
20559
+ "elements": [
20560
+ {
20561
+ "name": "w:rPr",
20562
+ "elements": outputMarks
20563
+ },
20564
+ {
20565
+ "name": "w:fldChar",
20566
+ "attributes": {
20567
+ "w:fldCharType": "begin"
20568
+ }
20569
+ }
20570
+ ]
20571
+ },
20572
+ {
20573
+ "name": "w:r",
20574
+ "elements": [
20575
+ {
20576
+ "name": "w:rPr",
20577
+ "elements": outputMarks
20578
+ },
20579
+ {
20580
+ "name": "w:instrText",
20581
+ "elements": [
20582
+ {
20583
+ "type": "text",
20584
+ "text": ` ${type2}`
20585
+ }
20586
+ ]
20587
+ }
20588
+ ]
20589
+ },
20590
+ {
20591
+ "name": "w:r",
20592
+ "elements": [
20593
+ {
20594
+ "name": "w:rPr",
20595
+ "elements": outputMarks
20596
+ },
20597
+ {
20598
+ "name": "w:fldChar",
20599
+ "attributes": {
20600
+ "w:fldCharType": "separate"
20601
+ }
20602
+ }
20603
+ ]
20604
+ },
20605
+ {
20606
+ "name": "w:r",
20607
+ "elements": [
20608
+ {
20609
+ "name": "w:rPr",
20610
+ "elements": outputMarks
20611
+ },
20612
+ {
20613
+ "name": "w:fldChar",
20614
+ "attributes": {
20615
+ "w:fldCharType": "end"
20616
+ }
20617
+ }
20618
+ ]
20619
+ }
20620
+ ];
20621
+ };
20543
20622
  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>`;
20544
20623
  const parseXmlToJson = (xml) => {
20545
20624
  return JSON.parse(xmljs.xml2json(xml, null, 2));
@@ -22248,15 +22327,25 @@ const processCombinedNodesForFldChar = (nodesToCombine = []) => {
22248
22327
  if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
22249
22328
  const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
22250
22329
  if (hasPageMarker) {
22251
- processedNodes.push({
22330
+ const pageNumNode = {
22252
22331
  name: "sd:autoPageNumber",
22253
22332
  type: "element"
22333
+ };
22334
+ nodesToCombine.forEach((n) => {
22335
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22336
+ if (rPrNode) pageNumNode.elements = [rPrNode];
22254
22337
  });
22338
+ processedNodes.push(pageNumNode);
22255
22339
  } else if (isNumPages) {
22256
- processedNodes.push({
22340
+ const totalPageNumNode = {
22257
22341
  name: "sd:totalPageNumber",
22258
22342
  type: "element"
22343
+ };
22344
+ nodesToCombine.forEach((n) => {
22345
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22346
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
22259
22347
  });
22348
+ processedNodes.push(totalPageNumNode);
22260
22349
  } else if (urlMatch && urlMatch?.length >= 2) {
22261
22350
  const url = urlMatch[1];
22262
22351
  const textMarks = [];
@@ -22592,8 +22681,13 @@ const handleAutoPageNumber = (params2) => {
22592
22681
  if (nodes.length === 0 || nodes[0].name !== "sd:autoPageNumber") {
22593
22682
  return { nodes: [], consumed: 0 };
22594
22683
  }
22684
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22685
+ const marks = parseMarks(rPr || { elements: [] });
22595
22686
  const processedNode = {
22596
- type: "page-number"
22687
+ type: "page-number",
22688
+ attrs: {
22689
+ marksAsAttrs: marks
22690
+ }
22597
22691
  };
22598
22692
  return { nodes: [processedNode], consumed: 1 };
22599
22693
  };
@@ -22606,8 +22700,13 @@ const handleAutoTotalPageNumber = (params2) => {
22606
22700
  if (nodes.length === 0 || nodes[0].name !== "sd:totalPageNumber") {
22607
22701
  return { nodes: [], consumed: 0 };
22608
22702
  }
22703
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22704
+ const marks = parseMarks(rPr || { elements: [] });
22609
22705
  const processedNode = {
22610
- type: "total-page-number"
22706
+ type: "total-page-number",
22707
+ attrs: {
22708
+ marksAsAttrs: marks
22709
+ }
22611
22710
  };
22612
22711
  return { nodes: [processedNode], consumed: 1 };
22613
22712
  };
@@ -23292,7 +23391,7 @@ const _SuperConverter = class _SuperConverter2 {
23292
23391
  return;
23293
23392
  }
23294
23393
  }
23295
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.35") {
23394
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.36-next.10") {
23296
23395
  const customLocation = "docProps/custom.xml";
23297
23396
  if (!docx[customLocation]) {
23298
23397
  docx[customLocation] = generateCustomXml();
@@ -23759,7 +23858,7 @@ function storeSuperdocVersion(docx) {
23759
23858
  function generateCustomXml() {
23760
23859
  return DEFAULT_CUSTOM_XML;
23761
23860
  }
23762
- function generateSuperdocVersion(pid = 2, version2 = "0.12.35") {
23861
+ function generateSuperdocVersion(pid = 2, version2 = "0.12.36-next.10") {
23763
23862
  return {
23764
23863
  type: "element",
23765
23864
  name: "property",
@@ -26292,7 +26391,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
26292
26391
  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);
26293
26392
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
26294
26393
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
26295
- 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;
26394
+ 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;
26296
26395
  function getMarksFromSelection(state2) {
26297
26396
  const { from: from2, to, empty: empty2 } = state2.selection;
26298
26397
  const marks = [];
@@ -30701,7 +30800,7 @@ function windowRect(doc2) {
30701
30800
  bottom: doc2.documentElement.clientHeight
30702
30801
  };
30703
30802
  }
30704
- function getSide(value, side) {
30803
+ function getSide$1(value, side) {
30705
30804
  return typeof value == "number" ? value : value[side];
30706
30805
  }
30707
30806
  function clientRect(node2) {
@@ -30729,14 +30828,14 @@ function scrollRectIntoView(view, rect, startDOM) {
30729
30828
  let atTop = elt == doc2.body;
30730
30829
  let bounding = atTop ? windowRect(doc2) : clientRect(elt);
30731
30830
  let moveX = 0, moveY = 0;
30732
- if (rect.top < bounding.top + getSide(scrollThreshold, "top"))
30733
- moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top"));
30734
- else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom"))
30735
- moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom");
30736
- if (rect.left < bounding.left + getSide(scrollThreshold, "left"))
30737
- moveX = -(bounding.left - rect.left + getSide(scrollMargin, "left"));
30738
- else if (rect.right > bounding.right - getSide(scrollThreshold, "right"))
30739
- moveX = rect.right - bounding.right + getSide(scrollMargin, "right");
30831
+ if (rect.top < bounding.top + getSide$1(scrollThreshold, "top"))
30832
+ moveY = -(bounding.top - rect.top + getSide$1(scrollMargin, "top"));
30833
+ else if (rect.bottom > bounding.bottom - getSide$1(scrollThreshold, "bottom"))
30834
+ 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");
30835
+ if (rect.left < bounding.left + getSide$1(scrollThreshold, "left"))
30836
+ moveX = -(bounding.left - rect.left + getSide$1(scrollMargin, "left"));
30837
+ else if (rect.right > bounding.right - getSide$1(scrollThreshold, "right"))
30838
+ moveX = rect.right - bounding.right + getSide$1(scrollMargin, "right");
30740
30839
  if (moveX || moveY) {
30741
30840
  if (atTop) {
30742
30841
  doc2.defaultView.scrollBy(moveX, moveY);
@@ -35675,10 +35774,10 @@ function checkStateComponent(plugin2) {
35675
35774
  if (plugin2.spec.state || plugin2.spec.filterTransaction || plugin2.spec.appendTransaction)
35676
35775
  throw new RangeError("Plugins passed directly to the view must not have a state component");
35677
35776
  }
35678
- const floor = Math.floor;
35777
+ const floor$1 = Math.floor;
35679
35778
  const abs = Math.abs;
35680
- const min$1 = (a, b) => a < b ? a : b;
35681
- const max$1 = (a, b) => a > b ? a : b;
35779
+ const min$2 = (a, b) => a < b ? a : b;
35780
+ const max$2 = (a, b) => a > b ? a : b;
35682
35781
  const isNegativeZero = (n) => n !== 0 ? n < 0 : 1 / n < 0;
35683
35782
  const BIT7 = 64;
35684
35783
  const BIT8 = 128;
@@ -35686,7 +35785,7 @@ const BIT30 = 1 << 29;
35686
35785
  const BITS6 = 63;
35687
35786
  const BITS7 = 127;
35688
35787
  const BITS31 = 2147483647;
35689
- const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
35788
+ const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor$1(num) === num);
35690
35789
  const create$2 = () => /* @__PURE__ */ new Set();
35691
35790
  const isArray$1 = Array.isArray;
35692
35791
  const fromCharCode = String.fromCharCode;
@@ -35750,7 +35849,7 @@ const verifyLen = (encoder, len) => {
35750
35849
  const bufferLen = encoder.cbuf.length;
35751
35850
  if (bufferLen - encoder.cpos < len) {
35752
35851
  encoder.bufs.push(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos));
35753
- encoder.cbuf = new Uint8Array(max$1(bufferLen, len) * 2);
35852
+ encoder.cbuf = new Uint8Array(max$2(bufferLen, len) * 2);
35754
35853
  encoder.cpos = 0;
35755
35854
  }
35756
35855
  };
@@ -35766,7 +35865,7 @@ const write$1 = (encoder, num) => {
35766
35865
  const writeVarUint = (encoder, num) => {
35767
35866
  while (num > BITS7) {
35768
35867
  write$1(encoder, BIT8 | BITS7 & num);
35769
- num = floor(num / 128);
35868
+ num = floor$1(num / 128);
35770
35869
  }
35771
35870
  write$1(encoder, BITS7 & num);
35772
35871
  };
@@ -35776,10 +35875,10 @@ const writeVarInt = (encoder, num) => {
35776
35875
  num = -num;
35777
35876
  }
35778
35877
  write$1(encoder, (num > BITS6 ? BIT8 : 0) | (isNegative ? BIT7 : 0) | BITS6 & num);
35779
- num = floor(num / 64);
35878
+ num = floor$1(num / 64);
35780
35879
  while (num > 0) {
35781
35880
  write$1(encoder, (num > BITS7 ? BIT8 : 0) | BITS7 & num);
35782
- num = floor(num / 128);
35881
+ num = floor$1(num / 128);
35783
35882
  }
35784
35883
  };
35785
35884
  const _strBuffer = new Uint8Array(3e4);
@@ -35812,13 +35911,13 @@ utf8TextEncoder.encodeInto ? _writeVarStringNative : _writeVarStringPolyfill;
35812
35911
  const writeUint8Array = (encoder, uint8Array) => {
35813
35912
  const bufferLen = encoder.cbuf.length;
35814
35913
  const cpos = encoder.cpos;
35815
- const leftCopyLen = min$1(bufferLen - cpos, uint8Array.length);
35914
+ const leftCopyLen = min$2(bufferLen - cpos, uint8Array.length);
35816
35915
  const rightCopyLen = uint8Array.length - leftCopyLen;
35817
35916
  encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
35818
35917
  encoder.cpos += leftCopyLen;
35819
35918
  if (rightCopyLen > 0) {
35820
35919
  encoder.bufs.push(encoder.cbuf);
35821
- encoder.cbuf = new Uint8Array(max$1(bufferLen * 2, rightCopyLen));
35920
+ encoder.cbuf = new Uint8Array(max$2(bufferLen * 2, rightCopyLen));
35822
35921
  encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
35823
35922
  encoder.cpos = rightCopyLen;
35824
35923
  }
@@ -35960,7 +36059,7 @@ const ySyncPluginKey = new PluginKey("y-sync");
35960
36059
  const yUndoPluginKey = new PluginKey("y-undo");
35961
36060
  const yCursorPluginKey = new PluginKey("yjs-cursor");
35962
36061
  const rand = Math.random;
35963
- const oneOf = (arr) => arr[floor(rand() * arr.length)];
36062
+ const oneOf = (arr) => arr[floor$1(rand() * arr.length)];
35964
36063
  const undefinedToNull = (v) => v === void 0 ? null : v;
35965
36064
  class VarStoragePolyfill {
35966
36065
  constructor() {
@@ -35990,12 +36089,12 @@ try {
35990
36089
  } catch (e) {
35991
36090
  }
35992
36091
  const varStorage = _localStorage;
35993
- 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]";
35994
- const isBrowser$1$1 = typeof window !== "undefined" && typeof document !== "undefined" && !isNode;
36092
+ 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]";
36093
+ const isBrowser$1$1 = typeof window !== "undefined" && typeof document !== "undefined" && !isNode$1;
35995
36094
  let params;
35996
36095
  const computeParams = () => {
35997
36096
  if (params === void 0) {
35998
- if (isNode) {
36097
+ if (isNode$1) {
35999
36098
  params = create();
36000
36099
  const pargs = process$1$1.argv;
36001
36100
  let currParamName = null;
@@ -36032,12 +36131,12 @@ const computeParams = () => {
36032
36131
  return params;
36033
36132
  };
36034
36133
  const hasParam = (name) => computeParams().has(name);
36035
- const getVariable = (name) => isNode ? undefinedToNull(process$1$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
36134
+ const getVariable = (name) => isNode$1 ? undefinedToNull(process$1$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
36036
36135
  const hasConf = (name) => hasParam("--" + name) || getVariable(name) !== null;
36037
36136
  hasConf("production");
36038
- const forceColor = isNode && isOneOf(process$1$1.env.FORCE_COLOR, ["true", "1", "2"]);
36137
+ const forceColor = isNode$1 && isOneOf(process$1$1.env.FORCE_COLOR, ["true", "1", "2"]);
36039
36138
  forceColor || !hasParam("--no-colors") && // @todo deprecate --no-colors
36040
- !hasConf("no-color") && (!isNode || process$1$1.stdout.isTTY) && (!isNode || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
36139
+ !hasConf("no-color") && (!isNode$1 || process$1$1.stdout.isTTY) && (!isNode$1 || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
36041
36140
  const doc = (
36042
36141
  /** @type {Document} */
36043
36142
  typeof document !== "undefined" ? document : {}
@@ -36546,8 +36645,8 @@ class ProsemirrorBinding {
36546
36645
  new Slice(Fragment.from(fragmentContent), 0, 0)
36547
36646
  );
36548
36647
  if (sel) {
36549
- const clampedAnchor = min$1(max$1(sel.anchor, 0), tr.doc.content.size);
36550
- const clampedHead = min$1(max$1(sel.head, 0), tr.doc.content.size);
36648
+ const clampedAnchor = min$2(max$2(sel.anchor, 0), tr.doc.content.size);
36649
+ const clampedHead = min$2(max$2(sel.head, 0), tr.doc.content.size);
36551
36650
  tr.setSelection(TextSelection.create(tr.doc, clampedAnchor, clampedHead));
36552
36651
  }
36553
36652
  this.prosemirrorView.dispatch(
@@ -36944,7 +37043,7 @@ const computeChildEqualityFactor = (ytype, pnode, meta) => {
36944
37043
  const pChildren = normalizePNodeContent(pnode);
36945
37044
  const pChildCnt = pChildren.length;
36946
37045
  const yChildCnt = yChildren.length;
36947
- const minCnt = min$1(yChildCnt, pChildCnt);
37046
+ const minCnt = min$2(yChildCnt, pChildCnt);
36948
37047
  let left2 = 0;
36949
37048
  let right2 = 0;
36950
37049
  let foundMappedChild = false;
@@ -37056,7 +37155,7 @@ const updateYFragment = (y, yDomFragment, pNode, meta) => {
37056
37155
  const pChildCnt = pChildren.length;
37057
37156
  const yChildren = yDomFragment.toArray();
37058
37157
  const yChildCnt = yChildren.length;
37059
- const minCnt = min$1(pChildCnt, yChildCnt);
37158
+ const minCnt = min$2(pChildCnt, yChildCnt);
37060
37159
  let left2 = 0;
37061
37160
  let right2 = 0;
37062
37161
  for (; left2 < minCnt; left2++) {
@@ -37429,17 +37528,17 @@ const createDecorations = (state2, awareness, awarenessFilter, createCursor, cre
37429
37528
  ystate.binding.mapping
37430
37529
  );
37431
37530
  if (anchor !== null && head !== null) {
37432
- const maxsize = max$1(state2.doc.content.size - 1, 0);
37433
- anchor = min$1(anchor, maxsize);
37434
- head = min$1(head, maxsize);
37531
+ const maxsize = max$2(state2.doc.content.size - 1, 0);
37532
+ anchor = min$2(anchor, maxsize);
37533
+ head = min$2(head, maxsize);
37435
37534
  decorations.push(
37436
37535
  Decoration.widget(head, () => createCursor(user, clientId), {
37437
37536
  key: clientId + "",
37438
37537
  side: 10
37439
37538
  })
37440
37539
  );
37441
- const from2 = min$1(anchor, head);
37442
- const to = max$1(anchor, head);
37540
+ const from2 = min$2(anchor, head);
37541
+ const to = max$2(anchor, head);
37443
37542
  decorations.push(
37444
37543
  Decoration.inline(from2, to, createSelection(user, clientId), {
37445
37544
  inclusiveEnd: true,
@@ -39061,7 +39160,8 @@ const createHeaderFooterEditor = ({
39061
39160
  appendToBody = true,
39062
39161
  sectionId,
39063
39162
  type: type2,
39064
- availableHeight
39163
+ availableHeight,
39164
+ currentPageNumber
39065
39165
  }) => {
39066
39166
  const parentStyles = editor.converter.getDocumentDefaultStyles();
39067
39167
  const { fontSizePt, typeface } = parentStyles;
@@ -39097,11 +39197,13 @@ const createHeaderFooterEditor = ({
39097
39197
  content: data,
39098
39198
  extensions: getStarterExtensions(),
39099
39199
  documentId: sectionId || "sectionId",
39100
- media: editor.options.media,
39101
- mediaFiles: editor.options.mediaFiles,
39200
+ media: editor.storage.image.media,
39201
+ mediaFiles: editor.storage.image.media,
39102
39202
  fonts: editor.options.fonts,
39103
39203
  isHeaderOrFooter: true,
39104
39204
  annotations: true,
39205
+ currentPageNumber,
39206
+ parentEditor: editor,
39105
39207
  onCreate: (evt) => setEditorToolbar(evt, editor),
39106
39208
  onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type2)
39107
39209
  });
@@ -40219,6 +40321,68 @@ const deleteHeaderFooterFieldAnnotations = ({ editor, fieldIdOrArray }) => {
40219
40321
  );
40220
40322
  });
40221
40323
  };
40324
+ const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
40325
+ if (!Array.isArray(fieldsToDelete)) fieldsToDelete = [fieldsToDelete];
40326
+ const { doc: doc2 } = editor.state;
40327
+ const docxAnnotations = getAllFieldAnnotations(editor.state) || [];
40328
+ const nodesToDelete = [];
40329
+ fieldsToDelete.forEach((fieldId) => {
40330
+ const matched = docxAnnotations.find((a) => a.node.attrs.fieldId === fieldId);
40331
+ if (!matched) return;
40332
+ const listItem = findParentNodeClosestToPos(
40333
+ doc2.resolve(matched.pos),
40334
+ (node22) => node22.type.name === "listItem"
40335
+ );
40336
+ if (!listItem) return;
40337
+ let remainingNodes = 0;
40338
+ listItem.node.descendants((node22) => {
40339
+ if (node22.type.name === "fieldAnnotation") {
40340
+ remainingNodes += 1;
40341
+ }
40342
+ });
40343
+ let matchingNodesFound = 0;
40344
+ let hasOtherNodes = false;
40345
+ listItem.node.children.forEach((child, index2) => {
40346
+ const { type: type2 } = child;
40347
+ if (type2.name !== "paragraph" && type2.name !== "fieldAnnotation") return;
40348
+ child.children.forEach((inline) => {
40349
+ const isFieldToDelete = fieldsToDelete.includes(inline.attrs.fieldId);
40350
+ const isFieldType = inline.type.name === "fieldAnnotation";
40351
+ const isMatchingField = isFieldType && isFieldToDelete;
40352
+ if (!isFieldType && !isMatchingField) hasOtherNodes = true;
40353
+ if (isMatchingField) matchingNodesFound += 1;
40354
+ });
40355
+ });
40356
+ if (!hasOtherNodes && matchingNodesFound > 0) {
40357
+ remainingNodes -= matchingNodesFound;
40358
+ }
40359
+ if (remainingNodes > 0) {
40360
+ return;
40361
+ }
40362
+ let { pos, node: node2, depth } = listItem;
40363
+ let $pos = doc2.resolve(pos);
40364
+ while (depth > 0) {
40365
+ const parent = $pos.node(depth - 1);
40366
+ if (parent.childCount === 1) {
40367
+ depth -= 1;
40368
+ pos = $pos.before(depth);
40369
+ node2 = parent;
40370
+ $pos = doc2.resolve(pos);
40371
+ } else {
40372
+ break;
40373
+ }
40374
+ }
40375
+ if (!nodesToDelete.some((n) => n.pos === pos)) {
40376
+ nodesToDelete.push({ pos, node: node2 });
40377
+ }
40378
+ });
40379
+ if (!nodesToDelete.length) return;
40380
+ const tr = editor.state.tr;
40381
+ nodesToDelete.sort((a, b) => b.pos - a.pos).forEach(({ pos, node: node2 }) => {
40382
+ tr.delete(pos, pos + node2.nodeSize);
40383
+ });
40384
+ editor.view.dispatch(tr);
40385
+ };
40222
40386
  const AnnotatorHelpers = {
40223
40387
  getFieldAttrs,
40224
40388
  processTables,
@@ -40226,7 +40390,8 @@ const AnnotatorHelpers = {
40226
40390
  annotateHeadersAndFooters,
40227
40391
  getAllHeaderFooterEditors,
40228
40392
  updateHeaderFooterFieldAnnotations,
40229
- deleteHeaderFooterFieldAnnotations
40393
+ deleteHeaderFooterFieldAnnotations,
40394
+ cleanUpListsWithAnnotations
40230
40395
  };
40231
40396
  const CollaborationPluginKey = new PluginKey("collaboration");
40232
40397
  const Collaboration = Extension.create({
@@ -40386,6 +40551,19 @@ function useHighContrastMode() {
40386
40551
  setHighContrastMode
40387
40552
  };
40388
40553
  }
40554
+ const findWordBounds = (doc2, pos) => {
40555
+ const $pos = doc2.resolve(pos);
40556
+ const parent = $pos.parent;
40557
+ const offset2 = $pos.parentOffset;
40558
+ const text = parent.textContent;
40559
+ if (!text) return { from: pos, to: pos };
40560
+ let start2 = offset2, end2 = offset2;
40561
+ while (start2 > 0 && /\w/.test(text[start2 - 1])) start2--;
40562
+ while (end2 < text.length && /\w/.test(text[end2])) end2++;
40563
+ const from2 = $pos.start() + start2;
40564
+ const to = $pos.start() + end2;
40565
+ return { from: from2, to };
40566
+ };
40389
40567
  const _Editor = class _Editor2 extends EventEmitter$1 {
40390
40568
  /**
40391
40569
  * Create a new Editor instance
@@ -40629,6 +40807,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
40629
40807
  __privateMethod$1(this, _Editor_instances, initMedia_fn).call(this);
40630
40808
  const doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
40631
40809
  const tr = this.state.tr.replaceWith(0, this.state.doc.content.size, doc2);
40810
+ tr.setMeta("replaceContent", true);
40632
40811
  this.view.dispatch(tr);
40633
40812
  }
40634
40813
  /**
@@ -41036,7 +41215,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41036
41215
  * @returns {Object | void} Migration results
41037
41216
  */
41038
41217
  processCollaborationMigrations() {
41039
- console.debug("[checkVersionMigrations] Current editor version", "0.12.35");
41218
+ console.debug("[checkVersionMigrations] Current editor version", "0.12.36-next.10");
41040
41219
  if (!this.options.ydoc) return;
41041
41220
  const metaMap = this.options.ydoc.getMap("meta");
41042
41221
  let docVersion = metaMap.get("version");
@@ -41401,6 +41580,10 @@ createView_fn = function() {
41401
41580
  pm.classList.remove("header-footer-edit");
41402
41581
  pm.setAttribute("aria-readonly", false);
41403
41582
  }
41583
+ const { state: state22, dispatch } = view;
41584
+ const word = findWordBounds(state22.doc, pos);
41585
+ const tr = state22.tr.setSelection(TextSelection.create(state22.doc, word.from, word.to));
41586
+ dispatch(tr);
41404
41587
  }
41405
41588
  });
41406
41589
  const newState = this.state.reconfigure({
@@ -41801,7 +41984,14 @@ const LineHeight = Extension.create({
41801
41984
  parseDOM: (el) => el.style.lineHeight,
41802
41985
  renderDOM: (attrs) => {
41803
41986
  if (!attrs.lineHeight) return {};
41804
- return { style: getLineHeightValueString(attrs.lineHeight, this.options.defaults.unit, attrs.spacing?.lineRule) };
41987
+ const lineHeightStyle = getLineHeightValueString(
41988
+ attrs.lineHeight,
41989
+ this.options.defaults.unit,
41990
+ attrs.spacing?.lineRule
41991
+ );
41992
+ return {
41993
+ style: `${lineHeightStyle}`
41994
+ };
41805
41995
  }
41806
41996
  }
41807
41997
  }
@@ -43726,7 +43916,9 @@ const Paragraph = Node$1.create({
43726
43916
  renderDOM: (attrs) => {
43727
43917
  const { spacing } = attrs;
43728
43918
  if (!spacing) return {};
43729
- const style2 = getSpacingStyleString(spacing);
43919
+ const spacingCopy = { ...spacing };
43920
+ if (attrs.lineHeight) delete spacingCopy.line;
43921
+ const style2 = getSpacingStyleString(spacingCopy);
43730
43922
  if (style2) return { style: style2 };
43731
43923
  return {};
43732
43924
  }
@@ -46903,8 +47095,8 @@ const TableCell = Node$1.create({
46903
47095
  cellMargins: {
46904
47096
  renderDOM({ cellMargins }) {
46905
47097
  if (!cellMargins) return {};
46906
- const sides = ["top", "right", "bottom", "left"];
46907
- const style2 = sides.map((side) => {
47098
+ const sides2 = ["top", "right", "bottom", "left"];
47099
+ const style2 = sides2.map((side) => {
46908
47100
  const margin = cellMargins?.[side];
46909
47101
  if (margin) return `padding-${side}: ${margin}px;`;
46910
47102
  return "";
@@ -46916,8 +47108,8 @@ const TableCell = Node$1.create({
46916
47108
  default: () => createCellBorders(),
46917
47109
  renderDOM({ borders }) {
46918
47110
  if (!borders) return {};
46919
- const sides = ["top", "right", "bottom", "left"];
46920
- const style2 = sides.map((side) => {
47111
+ const sides2 = ["top", "right", "bottom", "left"];
47112
+ const style2 = sides2.map((side) => {
46921
47113
  const border = borders?.[side];
46922
47114
  if (border && border.val === "none") return `border-${side}: ${border.val};`;
46923
47115
  if (border) return `border-${side}: ${border.size}px solid ${border.color || "black"};`;
@@ -48675,32 +48867,89 @@ const PageNumber = Node$1.create({
48675
48867
  name: "page-number",
48676
48868
  group: "inline",
48677
48869
  inline: true,
48678
- content: "text*",
48870
+ atom: true,
48871
+ selectable: false,
48872
+ draggable: false,
48873
+ selectable: false,
48874
+ defining: true,
48875
+ content: "",
48679
48876
  addOptions() {
48680
48877
  return {
48681
48878
  htmlAttributes: {
48879
+ contenteditable: false,
48682
48880
  "data-id": "auto-page-number",
48683
48881
  "aria-label": "Page number node"
48684
48882
  }
48685
48883
  };
48686
48884
  },
48885
+ addAttributes() {
48886
+ return {
48887
+ marksAsAttrs: {
48888
+ default: null,
48889
+ rendered: false
48890
+ }
48891
+ };
48892
+ },
48893
+ addNodeView() {
48894
+ return ({ node: node2, editor, getPos, decorations }) => {
48895
+ const htmlAttributes = this.options.htmlAttributes;
48896
+ return new AutoPageNumberNodeView(node2, getPos, decorations, editor, htmlAttributes);
48897
+ };
48898
+ },
48687
48899
  parseDOM() {
48688
48900
  return [{ tag: 'span[data-id="auto-page-number"' }];
48689
48901
  },
48690
48902
  renderDOM({ htmlAttributes }) {
48691
- return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
48903
+ return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
48904
+ },
48905
+ addCommands() {
48906
+ return {
48907
+ addAutoPageNumber: () => ({ tr, dispatch, state: state2, editor }) => {
48908
+ const { options: options2 } = editor;
48909
+ if (!options2.isHeaderOrFooter) return false;
48910
+ const { schema } = state2;
48911
+ const pageNumberType = schema?.nodes?.["page-number"];
48912
+ if (!pageNumberType) return false;
48913
+ const pageNumberNodeJSON = { type: "page-number" };
48914
+ const pageNumberNode = schema.nodeFromJSON(pageNumberNodeJSON);
48915
+ if (dispatch) {
48916
+ tr.replaceSelectionWith(pageNumberNode, false);
48917
+ tr.setMeta("forceUpdatePagination", true);
48918
+ }
48919
+ return true;
48920
+ }
48921
+ };
48922
+ },
48923
+ addShortcuts() {
48924
+ return {
48925
+ "Mod-Shift-alt-p": () => this.editor.commands.addAutoPageNumber()
48926
+ };
48692
48927
  }
48693
48928
  });
48694
48929
  const TotalPageCount = Node$1.create({
48695
48930
  name: "total-page-number",
48696
48931
  group: "inline",
48697
48932
  inline: true,
48933
+ atom: true,
48934
+ selectable: false,
48935
+ draggable: false,
48936
+ selectable: false,
48698
48937
  content: "text*",
48699
48938
  addOptions() {
48700
48939
  return {
48701
48940
  htmlAttributes: {
48941
+ contenteditable: false,
48702
48942
  "data-id": "auto-total-pages",
48703
- "aria-label": "Total page count node"
48943
+ "aria-label": "Total page count node",
48944
+ "class": "sd-editor-auto-total-pages"
48945
+ }
48946
+ };
48947
+ },
48948
+ addAttributes() {
48949
+ return {
48950
+ marksAsAttrs: {
48951
+ default: null,
48952
+ rendered: false
48704
48953
  }
48705
48954
  };
48706
48955
  },
@@ -48709,8 +48958,139 @@ const TotalPageCount = Node$1.create({
48709
48958
  },
48710
48959
  renderDOM({ htmlAttributes }) {
48711
48960
  return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
48961
+ },
48962
+ addCommands() {
48963
+ return {
48964
+ addTotalPageCount: () => ({ tr, dispatch, state: state2, editor }) => {
48965
+ const { options: options2 } = editor;
48966
+ if (!options2.isHeaderOrFooter) return false;
48967
+ const { schema } = state2;
48968
+ const pageNumberType = schema.nodes?.["total-page-number"];
48969
+ if (!pageNumberType) return false;
48970
+ const currentPages = editor?.options?.parentEditor?.currentTotalPages || 1;
48971
+ const pageNumberNode = {
48972
+ type: "total-page-number",
48973
+ content: [{ type: "text", text: String(currentPages) }]
48974
+ };
48975
+ const pageNode = schema.nodeFromJSON(pageNumberNode);
48976
+ if (dispatch) {
48977
+ tr.replaceSelectionWith(pageNode, false);
48978
+ }
48979
+ return true;
48980
+ }
48981
+ };
48982
+ },
48983
+ addShortcuts() {
48984
+ return {
48985
+ "Mod-Shift-alt-c": () => this.editor.commands.addTotalPageCount()
48986
+ };
48712
48987
  }
48713
48988
  });
48989
+ class AutoPageNumberNodeView {
48990
+ constructor(node2, getPos, decorations, editor, htmlAttributes = {}) {
48991
+ __privateAdd$1(this, _AutoPageNumberNodeView_instances);
48992
+ this.node = node2;
48993
+ this.editor = editor;
48994
+ this.view = editor.view;
48995
+ this.getPos = getPos;
48996
+ this.editor = editor;
48997
+ this.dom = __privateMethod$1(this, _AutoPageNumberNodeView_instances, renderDom_fn).call(this, node2, htmlAttributes);
48998
+ }
48999
+ update(node2) {
49000
+ if (node2.type !== this.node.type) return false;
49001
+ this.node = node2;
49002
+ return true;
49003
+ }
49004
+ }
49005
+ _AutoPageNumberNodeView_instances = /* @__PURE__ */ new WeakSet();
49006
+ renderDom_fn = function(node2, htmlAttributes) {
49007
+ const pageText = this.editor.options.currentPageNumber || "1";
49008
+ const content = document.createTextNode(String(pageText));
49009
+ const nodeContent = document.createElement("span");
49010
+ nodeContent.className = "sd-editor-auto-page-number";
49011
+ nodeContent.setAttribute("data-id", "auto-page-number");
49012
+ nodeContent.setAttribute("aria-label", "Page number node");
49013
+ const currentPos = this.getPos();
49014
+ const { styles, marks } = getMarksFromNeighbors(currentPos, this.view);
49015
+ __privateMethod$1(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
49016
+ Object.assign(nodeContent.style, styles);
49017
+ nodeContent.appendChild(content);
49018
+ Object.entries(htmlAttributes).forEach(([key, value]) => {
49019
+ if (value) nodeContent.setAttribute(key, value);
49020
+ });
49021
+ return nodeContent;
49022
+ };
49023
+ scheduleUpdateNodeStyle_fn = function(pos, marks) {
49024
+ setTimeout(() => {
49025
+ const { state: state2 } = this.editor;
49026
+ const { dispatch } = this.view;
49027
+ const node2 = state2.doc.nodeAt(pos);
49028
+ if (!node2) return;
49029
+ const currentMarks = node2.attrs.marksAsAttrs || [];
49030
+ const newMarks = marks.map((m) => ({ type: m.type.name, attrs: m.attrs }));
49031
+ const isEqual = JSON.stringify(currentMarks) === JSON.stringify(newMarks);
49032
+ if (isEqual) return;
49033
+ const newAttrs = {
49034
+ ...node2.attrs,
49035
+ marksAsAttrs: newMarks
49036
+ };
49037
+ const tr = state2.tr.setNodeMarkup(pos, void 0, newAttrs);
49038
+ dispatch(tr);
49039
+ }, 0);
49040
+ };
49041
+ const getMarksFromNeighbors = (currentPos, view) => {
49042
+ const $pos = view.state.doc.resolve(currentPos);
49043
+ const styles = {};
49044
+ const marks = [];
49045
+ const before = $pos.nodeBefore;
49046
+ if (before) {
49047
+ Object.assign(styles, processMarks(before.marks));
49048
+ marks.push(...before.marks);
49049
+ }
49050
+ const after = $pos.nodeAfter;
49051
+ if (after) {
49052
+ Object.assign(styles, { ...styles, ...processMarks(after.marks) });
49053
+ marks.push(...after.marks);
49054
+ }
49055
+ return {
49056
+ styles,
49057
+ marks
49058
+ };
49059
+ };
49060
+ const processMarks = (marks) => {
49061
+ const styles = {};
49062
+ marks.forEach((mark) => {
49063
+ const { type: type2, attrs } = mark;
49064
+ switch (type2.name) {
49065
+ case "textStyle":
49066
+ if (attrs.fontFamily) styles["font-family"] = attrs.fontFamily;
49067
+ if (attrs.fontSize) styles["font-size"] = attrs.fontSize;
49068
+ if (attrs.color) styles["color"] = attrs.color;
49069
+ if (attrs.backgroundColor) styles["background-color"] = attrs.backgroundColor;
49070
+ break;
49071
+ case "bold":
49072
+ styles["font-weight"] = "bold";
49073
+ break;
49074
+ case "italic":
49075
+ styles["font-style"] = "italic";
49076
+ break;
49077
+ case "underline":
49078
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " underline";
49079
+ break;
49080
+ case "strike":
49081
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " line-through";
49082
+ break;
49083
+ default:
49084
+ if (attrs?.style) {
49085
+ Object.entries(attrs.style).forEach(([key, value]) => {
49086
+ styles[key] = value;
49087
+ });
49088
+ }
49089
+ break;
49090
+ }
49091
+ });
49092
+ return styles;
49093
+ };
48714
49094
  const ShapeContainer = Node$1.create({
48715
49095
  name: "shapeContainer",
48716
49096
  group: "block",
@@ -49723,10 +50103,10 @@ var beforeWrite = "beforeWrite";
49723
50103
  var write = "write";
49724
50104
  var afterWrite = "afterWrite";
49725
50105
  var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
49726
- function getNodeName(element) {
50106
+ function getNodeName$1(element) {
49727
50107
  return element ? (element.nodeName || "").toLowerCase() : null;
49728
50108
  }
49729
- function getWindow(node2) {
50109
+ function getWindow$1(node2) {
49730
50110
  if (node2 == null) {
49731
50111
  return window;
49732
50112
  }
@@ -49736,19 +50116,19 @@ function getWindow(node2) {
49736
50116
  }
49737
50117
  return node2;
49738
50118
  }
49739
- function isElement$1(node2) {
49740
- var OwnElement = getWindow(node2).Element;
50119
+ function isElement$2(node2) {
50120
+ var OwnElement = getWindow$1(node2).Element;
49741
50121
  return node2 instanceof OwnElement || node2 instanceof Element;
49742
50122
  }
49743
50123
  function isHTMLElement$1(node2) {
49744
- var OwnElement = getWindow(node2).HTMLElement;
50124
+ var OwnElement = getWindow$1(node2).HTMLElement;
49745
50125
  return node2 instanceof OwnElement || node2 instanceof HTMLElement;
49746
50126
  }
49747
- function isShadowRoot(node2) {
50127
+ function isShadowRoot$1(node2) {
49748
50128
  if (typeof ShadowRoot === "undefined") {
49749
50129
  return false;
49750
50130
  }
49751
- var OwnElement = getWindow(node2).ShadowRoot;
50131
+ var OwnElement = getWindow$1(node2).ShadowRoot;
49752
50132
  return node2 instanceof OwnElement || node2 instanceof ShadowRoot;
49753
50133
  }
49754
50134
  function applyStyles(_ref) {
@@ -49757,7 +50137,7 @@ function applyStyles(_ref) {
49757
50137
  var style2 = state2.styles[name] || {};
49758
50138
  var attributes = state2.attributes[name] || {};
49759
50139
  var element = state2.elements[name];
49760
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
50140
+ if (!isHTMLElement$1(element) || !getNodeName$1(element)) {
49761
50141
  return;
49762
50142
  }
49763
50143
  Object.assign(element.style, style2);
@@ -49799,7 +50179,7 @@ function effect$2(_ref2) {
49799
50179
  style22[property2] = "";
49800
50180
  return style22;
49801
50181
  }, {});
49802
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
50182
+ if (!isHTMLElement$1(element) || !getNodeName$1(element)) {
49803
50183
  return;
49804
50184
  }
49805
50185
  Object.assign(element.style, style2);
@@ -49820,9 +50200,9 @@ const applyStyles$1 = {
49820
50200
  function getBasePlacement$1(placement) {
49821
50201
  return placement.split("-")[0];
49822
50202
  }
49823
- var max = Math.max;
49824
- var min = Math.min;
49825
- var round = Math.round;
50203
+ var max$1 = Math.max;
50204
+ var min$1 = Math.min;
50205
+ var round$1 = Math.round;
49826
50206
  function getUAString() {
49827
50207
  var uaData = navigator.userAgentData;
49828
50208
  if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
@@ -49835,7 +50215,7 @@ function getUAString() {
49835
50215
  function isLayoutViewport() {
49836
50216
  return !/^((?!chrome|android).)*safari/i.test(getUAString());
49837
50217
  }
49838
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
50218
+ function getBoundingClientRect$1(element, includeScale, isFixedStrategy) {
49839
50219
  if (includeScale === void 0) {
49840
50220
  includeScale = false;
49841
50221
  }
@@ -49846,10 +50226,10 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
49846
50226
  var scaleX = 1;
49847
50227
  var scaleY = 1;
49848
50228
  if (includeScale && isHTMLElement$1(element)) {
49849
- scaleX = element.offsetWidth > 0 ? round(clientRect2.width) / element.offsetWidth || 1 : 1;
49850
- scaleY = element.offsetHeight > 0 ? round(clientRect2.height) / element.offsetHeight || 1 : 1;
50229
+ scaleX = element.offsetWidth > 0 ? round$1(clientRect2.width) / element.offsetWidth || 1 : 1;
50230
+ scaleY = element.offsetHeight > 0 ? round$1(clientRect2.height) / element.offsetHeight || 1 : 1;
49851
50231
  }
49852
- var _ref = isElement$1(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
50232
+ var _ref = isElement$2(element) ? getWindow$1(element) : window, visualViewport = _ref.visualViewport;
49853
50233
  var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
49854
50234
  var x = (clientRect2.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
49855
50235
  var y = (clientRect2.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
@@ -49867,7 +50247,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
49867
50247
  };
49868
50248
  }
49869
50249
  function getLayoutRect(element) {
49870
- var clientRect2 = getBoundingClientRect(element);
50250
+ var clientRect2 = getBoundingClientRect$1(element);
49871
50251
  var width = element.offsetWidth;
49872
50252
  var height = element.offsetHeight;
49873
50253
  if (Math.abs(clientRect2.width - width) <= 1) {
@@ -49887,7 +50267,7 @@ function contains$1(parent, child) {
49887
50267
  var rootNode = child.getRootNode && child.getRootNode();
49888
50268
  if (parent.contains(child)) {
49889
50269
  return true;
49890
- } else if (rootNode && isShadowRoot(rootNode)) {
50270
+ } else if (rootNode && isShadowRoot$1(rootNode)) {
49891
50271
  var next = child;
49892
50272
  do {
49893
50273
  if (next && parent.isSameNode(next)) {
@@ -49898,20 +50278,20 @@ function contains$1(parent, child) {
49898
50278
  }
49899
50279
  return false;
49900
50280
  }
49901
- function getComputedStyle$1(element) {
49902
- return getWindow(element).getComputedStyle(element);
50281
+ function getComputedStyle$2(element) {
50282
+ return getWindow$1(element).getComputedStyle(element);
49903
50283
  }
49904
- function isTableElement(element) {
49905
- return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
50284
+ function isTableElement$1(element) {
50285
+ return ["table", "td", "th"].indexOf(getNodeName$1(element)) >= 0;
49906
50286
  }
49907
- function getDocumentElement(element) {
49908
- return ((isElement$1(element) ? element.ownerDocument : (
50287
+ function getDocumentElement$1(element) {
50288
+ return ((isElement$2(element) ? element.ownerDocument : (
49909
50289
  // $FlowFixMe[prop-missing]
49910
50290
  element.document
49911
50291
  )) || window.document).documentElement;
49912
50292
  }
49913
50293
  function getParentNode$1(element) {
49914
- if (getNodeName(element) === "html") {
50294
+ if (getNodeName$1(element) === "html") {
49915
50295
  return element;
49916
50296
  }
49917
50297
  return (
@@ -49920,33 +50300,33 @@ function getParentNode$1(element) {
49920
50300
  // $FlowFixMe[prop-missing]
49921
50301
  element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
49922
50302
  element.parentNode || // DOM Element detected
49923
- (isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
50303
+ (isShadowRoot$1(element) ? element.host : null) || // ShadowRoot detected
49924
50304
  // $FlowFixMe[incompatible-call]: HTMLElement is a Node
49925
- getDocumentElement(element)
50305
+ getDocumentElement$1(element)
49926
50306
  );
49927
50307
  }
49928
- function getTrueOffsetParent(element) {
50308
+ function getTrueOffsetParent$1(element) {
49929
50309
  if (!isHTMLElement$1(element) || // https://github.com/popperjs/popper-core/issues/837
49930
- getComputedStyle$1(element).position === "fixed") {
50310
+ getComputedStyle$2(element).position === "fixed") {
49931
50311
  return null;
49932
50312
  }
49933
50313
  return element.offsetParent;
49934
50314
  }
49935
- function getContainingBlock(element) {
50315
+ function getContainingBlock$1(element) {
49936
50316
  var isFirefox = /firefox/i.test(getUAString());
49937
50317
  var isIE = /Trident/i.test(getUAString());
49938
50318
  if (isIE && isHTMLElement$1(element)) {
49939
- var elementCss = getComputedStyle$1(element);
50319
+ var elementCss = getComputedStyle$2(element);
49940
50320
  if (elementCss.position === "fixed") {
49941
50321
  return null;
49942
50322
  }
49943
50323
  }
49944
50324
  var currentNode = getParentNode$1(element);
49945
- if (isShadowRoot(currentNode)) {
50325
+ if (isShadowRoot$1(currentNode)) {
49946
50326
  currentNode = currentNode.host;
49947
50327
  }
49948
- while (isHTMLElement$1(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
49949
- var css = getComputedStyle$1(currentNode);
50328
+ while (isHTMLElement$1(currentNode) && ["html", "body"].indexOf(getNodeName$1(currentNode)) < 0) {
50329
+ var css = getComputedStyle$2(currentNode);
49950
50330
  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") {
49951
50331
  return currentNode;
49952
50332
  } else {
@@ -49955,22 +50335,22 @@ function getContainingBlock(element) {
49955
50335
  }
49956
50336
  return null;
49957
50337
  }
49958
- function getOffsetParent(element) {
49959
- var window2 = getWindow(element);
49960
- var offsetParent = getTrueOffsetParent(element);
49961
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
49962
- offsetParent = getTrueOffsetParent(offsetParent);
50338
+ function getOffsetParent$1(element) {
50339
+ var window2 = getWindow$1(element);
50340
+ var offsetParent = getTrueOffsetParent$1(element);
50341
+ while (offsetParent && isTableElement$1(offsetParent) && getComputedStyle$2(offsetParent).position === "static") {
50342
+ offsetParent = getTrueOffsetParent$1(offsetParent);
49963
50343
  }
49964
- if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
50344
+ if (offsetParent && (getNodeName$1(offsetParent) === "html" || getNodeName$1(offsetParent) === "body" && getComputedStyle$2(offsetParent).position === "static")) {
49965
50345
  return window2;
49966
50346
  }
49967
- return offsetParent || getContainingBlock(element) || window2;
50347
+ return offsetParent || getContainingBlock$1(element) || window2;
49968
50348
  }
49969
50349
  function getMainAxisFromPlacement(placement) {
49970
50350
  return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
49971
50351
  }
49972
- function within(min$12, value, max$12) {
49973
- return max(min$12, min(value, max$12));
50352
+ function within(min2, value, max2) {
50353
+ return max$1(min2, min$1(value, max2));
49974
50354
  }
49975
50355
  function withinMaxClamp(min2, value, max2) {
49976
50356
  var v = within(min2, value, max2);
@@ -50017,7 +50397,7 @@ function arrow(_ref) {
50017
50397
  var maxProp = axis === "y" ? bottom : right;
50018
50398
  var endDiff = state2.rects.reference[len] + state2.rects.reference[axis] - popperOffsets2[axis] - state2.rects.popper[len];
50019
50399
  var startDiff = popperOffsets2[axis] - state2.rects.reference[axis];
50020
- var arrowOffsetParent = getOffsetParent(arrowElement);
50400
+ var arrowOffsetParent = getOffsetParent$1(arrowElement);
50021
50401
  var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
50022
50402
  var centerToReference = endDiff / 2 - startDiff / 2;
50023
50403
  var min2 = paddingObject[minProp];
@@ -50066,8 +50446,8 @@ function roundOffsetsByDPR(_ref, win) {
50066
50446
  var x = _ref.x, y = _ref.y;
50067
50447
  var dpr = win.devicePixelRatio || 1;
50068
50448
  return {
50069
- x: round(x * dpr) / dpr || 0,
50070
- y: round(y * dpr) / dpr || 0
50449
+ x: round$1(x * dpr) / dpr || 0,
50450
+ y: round$1(y * dpr) / dpr || 0
50071
50451
  };
50072
50452
  }
50073
50453
  function mapToStyles(_ref2) {
@@ -50089,12 +50469,12 @@ function mapToStyles(_ref2) {
50089
50469
  var sideY = top;
50090
50470
  var win = window;
50091
50471
  if (adaptive) {
50092
- var offsetParent = getOffsetParent(popper2);
50472
+ var offsetParent = getOffsetParent$1(popper2);
50093
50473
  var heightProp = "clientHeight";
50094
50474
  var widthProp = "clientWidth";
50095
- if (offsetParent === getWindow(popper2)) {
50096
- offsetParent = getDocumentElement(popper2);
50097
- if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
50475
+ if (offsetParent === getWindow$1(popper2)) {
50476
+ offsetParent = getDocumentElement$1(popper2);
50477
+ if (getComputedStyle$2(offsetParent).position !== "static" && position === "absolute") {
50098
50478
  heightProp = "scrollHeight";
50099
50479
  widthProp = "scrollWidth";
50100
50480
  }
@@ -50125,7 +50505,7 @@ function mapToStyles(_ref2) {
50125
50505
  var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
50126
50506
  x,
50127
50507
  y
50128
- }, getWindow(popper2)) : {
50508
+ }, getWindow$1(popper2)) : {
50129
50509
  x,
50130
50510
  y
50131
50511
  };
@@ -50181,7 +50561,7 @@ var passive = {
50181
50561
  function effect(_ref) {
50182
50562
  var state2 = _ref.state, instance = _ref.instance, options2 = _ref.options;
50183
50563
  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;
50184
- var window2 = getWindow(state2.elements.popper);
50564
+ var window2 = getWindow$1(state2.elements.popper);
50185
50565
  var scrollParents = [].concat(state2.scrollParents.reference, state2.scrollParents.popper);
50186
50566
  if (scroll) {
50187
50567
  scrollParents.forEach(function(scrollParent) {
@@ -50232,7 +50612,7 @@ function getOppositeVariationPlacement(placement) {
50232
50612
  });
50233
50613
  }
50234
50614
  function getWindowScroll(node2) {
50235
- var win = getWindow(node2);
50615
+ var win = getWindow$1(node2);
50236
50616
  var scrollLeft = win.pageXOffset;
50237
50617
  var scrollTop = win.pageYOffset;
50238
50618
  return {
@@ -50240,12 +50620,12 @@ function getWindowScroll(node2) {
50240
50620
  scrollTop
50241
50621
  };
50242
50622
  }
50243
- function getWindowScrollBarX(element) {
50244
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
50623
+ function getWindowScrollBarX$1(element) {
50624
+ return getBoundingClientRect$1(getDocumentElement$1(element)).left + getWindowScroll(element).scrollLeft;
50245
50625
  }
50246
- function getViewportRect(element, strategy) {
50247
- var win = getWindow(element);
50248
- var html = getDocumentElement(element);
50626
+ function getViewportRect$1(element, strategy) {
50627
+ var win = getWindow$1(element);
50628
+ var html = getDocumentElement$1(element);
50249
50629
  var visualViewport = win.visualViewport;
50250
50630
  var width = html.clientWidth;
50251
50631
  var height = html.clientHeight;
@@ -50263,21 +50643,21 @@ function getViewportRect(element, strategy) {
50263
50643
  return {
50264
50644
  width,
50265
50645
  height,
50266
- x: x + getWindowScrollBarX(element),
50646
+ x: x + getWindowScrollBarX$1(element),
50267
50647
  y
50268
50648
  };
50269
50649
  }
50270
- function getDocumentRect(element) {
50650
+ function getDocumentRect$1(element) {
50271
50651
  var _element$ownerDocumen;
50272
- var html = getDocumentElement(element);
50652
+ var html = getDocumentElement$1(element);
50273
50653
  var winScroll = getWindowScroll(element);
50274
50654
  var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
50275
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
50276
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
50277
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
50655
+ var width = max$1(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
50656
+ var height = max$1(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
50657
+ var x = -winScroll.scrollLeft + getWindowScrollBarX$1(element);
50278
50658
  var y = -winScroll.scrollTop;
50279
- if (getComputedStyle$1(body || html).direction === "rtl") {
50280
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
50659
+ if (getComputedStyle$2(body || html).direction === "rtl") {
50660
+ x += max$1(html.clientWidth, body ? body.clientWidth : 0) - width;
50281
50661
  }
50282
50662
  return {
50283
50663
  width,
@@ -50287,11 +50667,11 @@ function getDocumentRect(element) {
50287
50667
  };
50288
50668
  }
50289
50669
  function isScrollParent(element) {
50290
- var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
50670
+ var _getComputedStyle = getComputedStyle$2(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
50291
50671
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
50292
50672
  }
50293
50673
  function getScrollParent$1(node2) {
50294
- if (["html", "body", "#document"].indexOf(getNodeName(node2)) >= 0) {
50674
+ if (["html", "body", "#document"].indexOf(getNodeName$1(node2)) >= 0) {
50295
50675
  return node2.ownerDocument.body;
50296
50676
  }
50297
50677
  if (isHTMLElement$1(node2) && isScrollParent(node2)) {
@@ -50306,7 +50686,7 @@ function listScrollParents(element, list) {
50306
50686
  }
50307
50687
  var scrollParent = getScrollParent$1(element);
50308
50688
  var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
50309
- var win = getWindow(scrollParent);
50689
+ var win = getWindow$1(scrollParent);
50310
50690
  var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
50311
50691
  var updatedList = list.concat(target);
50312
50692
  return isBody ? updatedList : (
@@ -50314,7 +50694,7 @@ function listScrollParents(element, list) {
50314
50694
  updatedList.concat(listScrollParents(getParentNode$1(target)))
50315
50695
  );
50316
50696
  }
50317
- function rectToClientRect(rect) {
50697
+ function rectToClientRect$1(rect) {
50318
50698
  return Object.assign({}, rect, {
50319
50699
  left: rect.x,
50320
50700
  top: rect.y,
@@ -50322,8 +50702,8 @@ function rectToClientRect(rect) {
50322
50702
  bottom: rect.y + rect.height
50323
50703
  });
50324
50704
  }
50325
- function getInnerBoundingClientRect(element, strategy) {
50326
- var rect = getBoundingClientRect(element, false, strategy === "fixed");
50705
+ function getInnerBoundingClientRect$1(element, strategy) {
50706
+ var rect = getBoundingClientRect$1(element, false, strategy === "fixed");
50327
50707
  rect.top = rect.top + element.clientTop;
50328
50708
  rect.left = rect.left + element.clientLeft;
50329
50709
  rect.bottom = rect.top + element.clientHeight;
@@ -50335,29 +50715,29 @@ function getInnerBoundingClientRect(element, strategy) {
50335
50715
  return rect;
50336
50716
  }
50337
50717
  function getClientRectFromMixedType(element, clippingParent, strategy) {
50338
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
50718
+ return clippingParent === viewport ? rectToClientRect$1(getViewportRect$1(element, strategy)) : isElement$2(clippingParent) ? getInnerBoundingClientRect$1(clippingParent, strategy) : rectToClientRect$1(getDocumentRect$1(getDocumentElement$1(element)));
50339
50719
  }
50340
50720
  function getClippingParents(element) {
50341
50721
  var clippingParents2 = listScrollParents(getParentNode$1(element));
50342
- var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$1(element).position) >= 0;
50343
- var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent(element) : element;
50344
- if (!isElement$1(clipperElement)) {
50722
+ var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$2(element).position) >= 0;
50723
+ var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent$1(element) : element;
50724
+ if (!isElement$2(clipperElement)) {
50345
50725
  return [];
50346
50726
  }
50347
50727
  return clippingParents2.filter(function(clippingParent) {
50348
- return isElement$1(clippingParent) && contains$1(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
50728
+ return isElement$2(clippingParent) && contains$1(clippingParent, clipperElement) && getNodeName$1(clippingParent) !== "body";
50349
50729
  });
50350
50730
  }
50351
- function getClippingRect(element, boundary, rootBoundary, strategy) {
50731
+ function getClippingRect$1(element, boundary, rootBoundary, strategy) {
50352
50732
  var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
50353
50733
  var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
50354
50734
  var firstClippingParent = clippingParents2[0];
50355
50735
  var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
50356
50736
  var rect = getClientRectFromMixedType(element, clippingParent, strategy);
50357
- accRect.top = max(rect.top, accRect.top);
50358
- accRect.right = min(rect.right, accRect.right);
50359
- accRect.bottom = min(rect.bottom, accRect.bottom);
50360
- accRect.left = max(rect.left, accRect.left);
50737
+ accRect.top = max$1(rect.top, accRect.top);
50738
+ accRect.right = min$1(rect.right, accRect.right);
50739
+ accRect.bottom = min$1(rect.bottom, accRect.bottom);
50740
+ accRect.left = max$1(rect.left, accRect.left);
50361
50741
  return accRect;
50362
50742
  }, getClientRectFromMixedType(element, firstClippingParent, strategy));
50363
50743
  clippingRect.width = clippingRect.right - clippingRect.left;
@@ -50418,7 +50798,7 @@ function computeOffsets(_ref) {
50418
50798
  }
50419
50799
  return offsets;
50420
50800
  }
50421
- function detectOverflow(state2, options2) {
50801
+ function detectOverflow$1(state2, options2) {
50422
50802
  if (options2 === void 0) {
50423
50803
  options2 = {};
50424
50804
  }
@@ -50427,14 +50807,14 @@ function detectOverflow(state2, options2) {
50427
50807
  var altContext = elementContext === popper ? reference : popper;
50428
50808
  var popperRect = state2.rects.popper;
50429
50809
  var element = state2.elements[altBoundary ? altContext : elementContext];
50430
- var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state2.elements.popper), boundary, rootBoundary, strategy);
50431
- var referenceClientRect = getBoundingClientRect(state2.elements.reference);
50810
+ var clippingClientRect = getClippingRect$1(isElement$2(element) ? element : element.contextElement || getDocumentElement$1(state2.elements.popper), boundary, rootBoundary, strategy);
50811
+ var referenceClientRect = getBoundingClientRect$1(state2.elements.reference);
50432
50812
  var popperOffsets2 = computeOffsets({
50433
50813
  reference: referenceClientRect,
50434
50814
  element: popperRect,
50435
50815
  placement
50436
50816
  });
50437
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
50817
+ var popperClientRect = rectToClientRect$1(Object.assign({}, popperRect, popperOffsets2));
50438
50818
  var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
50439
50819
  var overflowOffsets = {
50440
50820
  top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
@@ -50469,7 +50849,7 @@ function computeAutoPlacement(state2, options2) {
50469
50849
  allowedPlacements = placements$1;
50470
50850
  }
50471
50851
  var overflows = allowedPlacements.reduce(function(acc, placement2) {
50472
- acc[placement2] = detectOverflow(state2, {
50852
+ acc[placement2] = detectOverflow$1(state2, {
50473
50853
  placement: placement2,
50474
50854
  boundary,
50475
50855
  rootBoundary,
@@ -50519,7 +50899,7 @@ function flip(_ref) {
50519
50899
  var isStartVariation = getVariation(placement) === start;
50520
50900
  var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
50521
50901
  var len = isVertical ? "width" : "height";
50522
- var overflow = detectOverflow(state2, {
50902
+ var overflow = detectOverflow$1(state2, {
50523
50903
  placement,
50524
50904
  boundary,
50525
50905
  rootBoundary,
@@ -50584,7 +50964,7 @@ const flip$1 = {
50584
50964
  _skip: false
50585
50965
  }
50586
50966
  };
50587
- function getSideOffsets(overflow, rect, preventedOffsets) {
50967
+ function getSideOffsets$1(overflow, rect, preventedOffsets) {
50588
50968
  if (preventedOffsets === void 0) {
50589
50969
  preventedOffsets = {
50590
50970
  x: 0,
@@ -50598,26 +50978,26 @@ function getSideOffsets(overflow, rect, preventedOffsets) {
50598
50978
  left: overflow.left - rect.width - preventedOffsets.x
50599
50979
  };
50600
50980
  }
50601
- function isAnySideFullyClipped(overflow) {
50981
+ function isAnySideFullyClipped$1(overflow) {
50602
50982
  return [top, right, bottom, left].some(function(side) {
50603
50983
  return overflow[side] >= 0;
50604
50984
  });
50605
50985
  }
50606
- function hide(_ref) {
50986
+ function hide$2(_ref) {
50607
50987
  var state2 = _ref.state, name = _ref.name;
50608
50988
  var referenceRect = state2.rects.reference;
50609
50989
  var popperRect = state2.rects.popper;
50610
50990
  var preventedOffsets = state2.modifiersData.preventOverflow;
50611
- var referenceOverflow = detectOverflow(state2, {
50991
+ var referenceOverflow = detectOverflow$1(state2, {
50612
50992
  elementContext: "reference"
50613
50993
  });
50614
- var popperAltOverflow = detectOverflow(state2, {
50994
+ var popperAltOverflow = detectOverflow$1(state2, {
50615
50995
  altBoundary: true
50616
50996
  });
50617
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
50618
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
50619
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
50620
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
50997
+ var referenceClippingOffsets = getSideOffsets$1(referenceOverflow, referenceRect);
50998
+ var popperEscapeOffsets = getSideOffsets$1(popperAltOverflow, popperRect, preventedOffsets);
50999
+ var isReferenceHidden = isAnySideFullyClipped$1(referenceClippingOffsets);
51000
+ var hasPopperEscaped = isAnySideFullyClipped$1(popperEscapeOffsets);
50621
51001
  state2.modifiersData[name] = {
50622
51002
  referenceClippingOffsets,
50623
51003
  popperEscapeOffsets,
@@ -50629,12 +51009,12 @@ function hide(_ref) {
50629
51009
  "data-popper-escaped": hasPopperEscaped
50630
51010
  });
50631
51011
  }
50632
- const hide$1 = {
51012
+ const hide$3 = {
50633
51013
  name: "hide",
50634
51014
  enabled: true,
50635
51015
  phase: "main",
50636
51016
  requiresIfExists: ["preventOverflow"],
50637
- fn: hide
51017
+ fn: hide$2
50638
51018
  };
50639
51019
  function distanceAndSkiddingToXY(placement, rects, offset2) {
50640
51020
  var basePlacement = getBasePlacement$1(placement);
@@ -50694,7 +51074,7 @@ function getAltAxis(axis) {
50694
51074
  function preventOverflow(_ref) {
50695
51075
  var state2 = _ref.state, options2 = _ref.options, name = _ref.name;
50696
51076
  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;
50697
- var overflow = detectOverflow(state2, {
51077
+ var overflow = detectOverflow$1(state2, {
50698
51078
  boundary,
50699
51079
  rootBoundary,
50700
51080
  padding,
@@ -50732,8 +51112,8 @@ function preventOverflow(_ref) {
50732
51112
  var altSide = mainAxis === "y" ? bottom : right;
50733
51113
  var len = mainAxis === "y" ? "height" : "width";
50734
51114
  var offset2 = popperOffsets2[mainAxis];
50735
- var min$12 = offset2 + overflow[mainSide];
50736
- var max$12 = offset2 - overflow[altSide];
51115
+ var min2 = offset2 + overflow[mainSide];
51116
+ var max2 = offset2 - overflow[altSide];
50737
51117
  var additive = tether ? -popperRect[len] / 2 : 0;
50738
51118
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
50739
51119
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
@@ -50748,12 +51128,12 @@ function preventOverflow(_ref) {
50748
51128
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
50749
51129
  var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
50750
51130
  var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
50751
- var arrowOffsetParent = state2.elements.arrow && getOffsetParent(state2.elements.arrow);
51131
+ var arrowOffsetParent = state2.elements.arrow && getOffsetParent$1(state2.elements.arrow);
50752
51132
  var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
50753
51133
  var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
50754
51134
  var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
50755
51135
  var tetherMax = offset2 + maxOffset - offsetModifierValue;
50756
- var preventedOffset = within(tether ? min(min$12, tetherMin) : min$12, offset2, tether ? max(max$12, tetherMax) : max$12);
51136
+ var preventedOffset = within(tether ? min$1(min2, tetherMin) : min2, offset2, tether ? max$1(max2, tetherMax) : max2);
50757
51137
  popperOffsets2[mainAxis] = preventedOffset;
50758
51138
  data[mainAxis] = preventedOffset - offset2;
50759
51139
  }
@@ -50788,8 +51168,8 @@ function getHTMLElementScroll(element) {
50788
51168
  scrollTop: element.scrollTop
50789
51169
  };
50790
51170
  }
50791
- function getNodeScroll(node2) {
50792
- if (node2 === getWindow(node2) || !isHTMLElement$1(node2)) {
51171
+ function getNodeScroll$1(node2) {
51172
+ if (node2 === getWindow$1(node2) || !isHTMLElement$1(node2)) {
50793
51173
  return getWindowScroll(node2);
50794
51174
  } else {
50795
51175
  return getHTMLElementScroll(node2);
@@ -50797,8 +51177,8 @@ function getNodeScroll(node2) {
50797
51177
  }
50798
51178
  function isElementScaled(element) {
50799
51179
  var rect = element.getBoundingClientRect();
50800
- var scaleX = round(rect.width) / element.offsetWidth || 1;
50801
- var scaleY = round(rect.height) / element.offsetHeight || 1;
51180
+ var scaleX = round$1(rect.width) / element.offsetWidth || 1;
51181
+ var scaleY = round$1(rect.height) / element.offsetHeight || 1;
50802
51182
  return scaleX !== 1 || scaleY !== 1;
50803
51183
  }
50804
51184
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
@@ -50807,8 +51187,8 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
50807
51187
  }
50808
51188
  var isOffsetParentAnElement = isHTMLElement$1(offsetParent);
50809
51189
  var offsetParentIsScaled = isHTMLElement$1(offsetParent) && isElementScaled(offsetParent);
50810
- var documentElement = getDocumentElement(offsetParent);
50811
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
51190
+ var documentElement = getDocumentElement$1(offsetParent);
51191
+ var rect = getBoundingClientRect$1(elementOrVirtualElement, offsetParentIsScaled, isFixed);
50812
51192
  var scroll = {
50813
51193
  scrollLeft: 0,
50814
51194
  scrollTop: 0
@@ -50818,16 +51198,16 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
50818
51198
  y: 0
50819
51199
  };
50820
51200
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
50821
- if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
51201
+ if (getNodeName$1(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
50822
51202
  isScrollParent(documentElement)) {
50823
- scroll = getNodeScroll(offsetParent);
51203
+ scroll = getNodeScroll$1(offsetParent);
50824
51204
  }
50825
51205
  if (isHTMLElement$1(offsetParent)) {
50826
- offsets = getBoundingClientRect(offsetParent, true);
51206
+ offsets = getBoundingClientRect$1(offsetParent, true);
50827
51207
  offsets.x += offsetParent.clientLeft;
50828
51208
  offsets.y += offsetParent.clientTop;
50829
51209
  } else if (documentElement) {
50830
- offsets.x = getWindowScrollBarX(documentElement);
51210
+ offsets.x = getWindowScrollBarX$1(documentElement);
50831
51211
  }
50832
51212
  }
50833
51213
  return {
@@ -50942,7 +51322,7 @@ function popperGenerator(generatorOptions) {
50942
51322
  cleanupModifierEffects();
50943
51323
  state2.options = Object.assign({}, defaultOptions, state2.options, options22);
50944
51324
  state2.scrollParents = {
50945
- reference: isElement$1(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
51325
+ reference: isElement$2(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
50946
51326
  popper: listScrollParents(popper2)
50947
51327
  };
50948
51328
  var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state2.options.modifiers)));
@@ -50966,7 +51346,7 @@ function popperGenerator(generatorOptions) {
50966
51346
  return;
50967
51347
  }
50968
51348
  state2.rects = {
50969
- reference: getCompositeRect(reference3, getOffsetParent(popper3), state2.options.strategy === "fixed"),
51349
+ reference: getCompositeRect(reference3, getOffsetParent$1(popper3), state2.options.strategy === "fixed"),
50970
51350
  popper: getLayoutRect(popper3)
50971
51351
  };
50972
51352
  state2.reset = false;
@@ -51037,7 +51417,7 @@ function popperGenerator(generatorOptions) {
51037
51417
  return instance;
51038
51418
  };
51039
51419
  }
51040
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
51420
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$3];
51041
51421
  var createPopper = /* @__PURE__ */ popperGenerator({
51042
51422
  defaultModifiers
51043
51423
  });
@@ -51122,7 +51502,7 @@ function removeUndefinedProps(obj) {
51122
51502
  function div() {
51123
51503
  return document.createElement("div");
51124
51504
  }
51125
- function isElement$2(value) {
51505
+ function isElement$1(value) {
51126
51506
  return ["Element", "Fragment"].some(function(type2) {
51127
51507
  return isType(value, type2);
51128
51508
  });
@@ -51137,7 +51517,7 @@ function isReferenceElement(value) {
51137
51517
  return !!(value && value._tippy && value._tippy.reference === value);
51138
51518
  }
51139
51519
  function getArrayOfElements(value) {
51140
- if (isElement$2(value)) {
51520
+ if (isElement$1(value)) {
51141
51521
  return [value];
51142
51522
  }
51143
51523
  if (isNodeList(value)) {
@@ -51446,7 +51826,7 @@ function createArrowElement(value) {
51446
51826
  arrow2.className = ARROW_CLASS;
51447
51827
  } else {
51448
51828
  arrow2.className = SVG_ARROW_CLASS;
51449
- if (isElement$2(value)) {
51829
+ if (isElement$1(value)) {
51450
51830
  arrow2.appendChild(value);
51451
51831
  } else {
51452
51832
  dangerouslySetInnerHTML(arrow2, value);
@@ -51455,7 +51835,7 @@ function createArrowElement(value) {
51455
51835
  return arrow2;
51456
51836
  }
51457
51837
  function setContent(content, props) {
51458
- if (isElement$2(props.content)) {
51838
+ if (isElement$1(props.content)) {
51459
51839
  dangerouslySetInnerHTML(content, "");
51460
51840
  content.appendChild(props.content);
51461
51841
  } else if (typeof props.content !== "function") {
@@ -52278,7 +52658,7 @@ function tippy(targets, optionalProps) {
52278
52658
  });
52279
52659
  var elements = getArrayOfElements(targets);
52280
52660
  if (process$1$1.env.NODE_ENV !== "production") {
52281
- var isSingleContentElement = isElement$2(passedProps.content);
52661
+ var isSingleContentElement = isElement$1(passedProps.content);
52282
52662
  var isMoreThanOneReferenceElement = elements.length > 1;
52283
52663
  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(" "));
52284
52664
  }
@@ -52289,7 +52669,7 @@ function tippy(targets, optionalProps) {
52289
52669
  }
52290
52670
  return acc;
52291
52671
  }, []);
52292
- return isElement$2(targets) ? instances[0] : instances;
52672
+ return isElement$1(targets) ? instances[0] : instances;
52293
52673
  }
52294
52674
  tippy.defaultProps = defaultProps;
52295
52675
  tippy.setDefaultProps = setDefaultProps;
@@ -52558,7 +52938,1067 @@ class Popover {
52558
52938
  this.popover.remove();
52559
52939
  }
52560
52940
  }
52941
+ const sides = ["top", "right", "bottom", "left"];
52942
+ const min = Math.min;
52943
+ const max = Math.max;
52944
+ const round = Math.round;
52945
+ const floor = Math.floor;
52946
+ const createCoords = (v) => ({
52947
+ x: v,
52948
+ y: v
52949
+ });
52950
+ function evaluate(value, param) {
52951
+ return typeof value === "function" ? value(param) : value;
52952
+ }
52953
+ function getSide(placement) {
52954
+ return placement.split("-")[0];
52955
+ }
52956
+ function getAlignment(placement) {
52957
+ return placement.split("-")[1];
52958
+ }
52959
+ function getOppositeAxis(axis) {
52960
+ return axis === "x" ? "y" : "x";
52961
+ }
52962
+ function getAxisLength(axis) {
52963
+ return axis === "y" ? "height" : "width";
52964
+ }
52965
+ function getSideAxis(placement) {
52966
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
52967
+ }
52968
+ function getAlignmentAxis(placement) {
52969
+ return getOppositeAxis(getSideAxis(placement));
52970
+ }
52971
+ function expandPaddingObject(padding) {
52972
+ return {
52973
+ top: 0,
52974
+ right: 0,
52975
+ bottom: 0,
52976
+ left: 0,
52977
+ ...padding
52978
+ };
52979
+ }
52980
+ function getPaddingObject(padding) {
52981
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
52982
+ top: padding,
52983
+ right: padding,
52984
+ bottom: padding,
52985
+ left: padding
52986
+ };
52987
+ }
52988
+ function rectToClientRect(rect) {
52989
+ const {
52990
+ x,
52991
+ y,
52992
+ width,
52993
+ height
52994
+ } = rect;
52995
+ return {
52996
+ width,
52997
+ height,
52998
+ top: y,
52999
+ left: x,
53000
+ right: x + width,
53001
+ bottom: y + height,
53002
+ x,
53003
+ y
53004
+ };
53005
+ }
53006
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
53007
+ let {
53008
+ reference: reference2,
53009
+ floating
53010
+ } = _ref;
53011
+ const sideAxis = getSideAxis(placement);
53012
+ const alignmentAxis = getAlignmentAxis(placement);
53013
+ const alignLength = getAxisLength(alignmentAxis);
53014
+ const side = getSide(placement);
53015
+ const isVertical = sideAxis === "y";
53016
+ const commonX = reference2.x + reference2.width / 2 - floating.width / 2;
53017
+ const commonY = reference2.y + reference2.height / 2 - floating.height / 2;
53018
+ const commonAlign = reference2[alignLength] / 2 - floating[alignLength] / 2;
53019
+ let coords;
53020
+ switch (side) {
53021
+ case "top":
53022
+ coords = {
53023
+ x: commonX,
53024
+ y: reference2.y - floating.height
53025
+ };
53026
+ break;
53027
+ case "bottom":
53028
+ coords = {
53029
+ x: commonX,
53030
+ y: reference2.y + reference2.height
53031
+ };
53032
+ break;
53033
+ case "right":
53034
+ coords = {
53035
+ x: reference2.x + reference2.width,
53036
+ y: commonY
53037
+ };
53038
+ break;
53039
+ case "left":
53040
+ coords = {
53041
+ x: reference2.x - floating.width,
53042
+ y: commonY
53043
+ };
53044
+ break;
53045
+ default:
53046
+ coords = {
53047
+ x: reference2.x,
53048
+ y: reference2.y
53049
+ };
53050
+ }
53051
+ switch (getAlignment(placement)) {
53052
+ case "start":
53053
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
53054
+ break;
53055
+ case "end":
53056
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
53057
+ break;
53058
+ }
53059
+ return coords;
53060
+ }
53061
+ const computePosition$1 = async (reference2, floating, config) => {
53062
+ const {
53063
+ placement = "bottom",
53064
+ strategy = "absolute",
53065
+ middleware = [],
53066
+ platform: platform2
53067
+ } = config;
53068
+ const validMiddleware = middleware.filter(Boolean);
53069
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
53070
+ let rects = await platform2.getElementRects({
53071
+ reference: reference2,
53072
+ floating,
53073
+ strategy
53074
+ });
53075
+ let {
53076
+ x,
53077
+ y
53078
+ } = computeCoordsFromPlacement(rects, placement, rtl);
53079
+ let statefulPlacement = placement;
53080
+ let middlewareData = {};
53081
+ let resetCount = 0;
53082
+ for (let i = 0; i < validMiddleware.length; i++) {
53083
+ const {
53084
+ name,
53085
+ fn: fn2
53086
+ } = validMiddleware[i];
53087
+ const {
53088
+ x: nextX,
53089
+ y: nextY,
53090
+ data,
53091
+ reset
53092
+ } = await fn2({
53093
+ x,
53094
+ y,
53095
+ initialPlacement: placement,
53096
+ placement: statefulPlacement,
53097
+ strategy,
53098
+ middlewareData,
53099
+ rects,
53100
+ platform: platform2,
53101
+ elements: {
53102
+ reference: reference2,
53103
+ floating
53104
+ }
53105
+ });
53106
+ x = nextX != null ? nextX : x;
53107
+ y = nextY != null ? nextY : y;
53108
+ middlewareData = {
53109
+ ...middlewareData,
53110
+ [name]: {
53111
+ ...middlewareData[name],
53112
+ ...data
53113
+ }
53114
+ };
53115
+ if (reset && resetCount <= 50) {
53116
+ resetCount++;
53117
+ if (typeof reset === "object") {
53118
+ if (reset.placement) {
53119
+ statefulPlacement = reset.placement;
53120
+ }
53121
+ if (reset.rects) {
53122
+ rects = reset.rects === true ? await platform2.getElementRects({
53123
+ reference: reference2,
53124
+ floating,
53125
+ strategy
53126
+ }) : reset.rects;
53127
+ }
53128
+ ({
53129
+ x,
53130
+ y
53131
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
53132
+ }
53133
+ i = -1;
53134
+ }
53135
+ }
53136
+ return {
53137
+ x,
53138
+ y,
53139
+ placement: statefulPlacement,
53140
+ strategy,
53141
+ middlewareData
53142
+ };
53143
+ };
53144
+ async function detectOverflow(state2, options2) {
53145
+ var _await$platform$isEle;
53146
+ if (options2 === void 0) {
53147
+ options2 = {};
53148
+ }
53149
+ const {
53150
+ x,
53151
+ y,
53152
+ platform: platform2,
53153
+ rects,
53154
+ elements,
53155
+ strategy
53156
+ } = state2;
53157
+ const {
53158
+ boundary = "clippingAncestors",
53159
+ rootBoundary = "viewport",
53160
+ elementContext = "floating",
53161
+ altBoundary = false,
53162
+ padding = 0
53163
+ } = evaluate(options2, state2);
53164
+ const paddingObject = getPaddingObject(padding);
53165
+ const altContext = elementContext === "floating" ? "reference" : "floating";
53166
+ const element = elements[altBoundary ? altContext : elementContext];
53167
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
53168
+ 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)),
53169
+ boundary,
53170
+ rootBoundary,
53171
+ strategy
53172
+ }));
53173
+ const rect = elementContext === "floating" ? {
53174
+ x,
53175
+ y,
53176
+ width: rects.floating.width,
53177
+ height: rects.floating.height
53178
+ } : rects.reference;
53179
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
53180
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
53181
+ x: 1,
53182
+ y: 1
53183
+ } : {
53184
+ x: 1,
53185
+ y: 1
53186
+ };
53187
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
53188
+ elements,
53189
+ rect,
53190
+ offsetParent,
53191
+ strategy
53192
+ }) : rect);
53193
+ return {
53194
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
53195
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
53196
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
53197
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
53198
+ };
53199
+ }
53200
+ function getSideOffsets(overflow, rect) {
53201
+ return {
53202
+ top: overflow.top - rect.height,
53203
+ right: overflow.right - rect.width,
53204
+ bottom: overflow.bottom - rect.height,
53205
+ left: overflow.left - rect.width
53206
+ };
53207
+ }
53208
+ function isAnySideFullyClipped(overflow) {
53209
+ return sides.some((side) => overflow[side] >= 0);
53210
+ }
53211
+ const hide$1 = function(options2) {
53212
+ if (options2 === void 0) {
53213
+ options2 = {};
53214
+ }
53215
+ return {
53216
+ name: "hide",
53217
+ options: options2,
53218
+ async fn(state2) {
53219
+ const {
53220
+ rects
53221
+ } = state2;
53222
+ const {
53223
+ strategy = "referenceHidden",
53224
+ ...detectOverflowOptions
53225
+ } = evaluate(options2, state2);
53226
+ switch (strategy) {
53227
+ case "referenceHidden": {
53228
+ const overflow = await detectOverflow(state2, {
53229
+ ...detectOverflowOptions,
53230
+ elementContext: "reference"
53231
+ });
53232
+ const offsets = getSideOffsets(overflow, rects.reference);
53233
+ return {
53234
+ data: {
53235
+ referenceHiddenOffsets: offsets,
53236
+ referenceHidden: isAnySideFullyClipped(offsets)
53237
+ }
53238
+ };
53239
+ }
53240
+ case "escaped": {
53241
+ const overflow = await detectOverflow(state2, {
53242
+ ...detectOverflowOptions,
53243
+ altBoundary: true
53244
+ });
53245
+ const offsets = getSideOffsets(overflow, rects.floating);
53246
+ return {
53247
+ data: {
53248
+ escapedOffsets: offsets,
53249
+ escaped: isAnySideFullyClipped(offsets)
53250
+ }
53251
+ };
53252
+ }
53253
+ default: {
53254
+ return {};
53255
+ }
53256
+ }
53257
+ }
53258
+ };
53259
+ };
53260
+ function hasWindow() {
53261
+ return typeof window !== "undefined";
53262
+ }
53263
+ function getNodeName(node2) {
53264
+ if (isNode(node2)) {
53265
+ return (node2.nodeName || "").toLowerCase();
53266
+ }
53267
+ return "#document";
53268
+ }
53269
+ function getWindow(node2) {
53270
+ var _node$ownerDocument;
53271
+ return (node2 == null || (_node$ownerDocument = node2.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
53272
+ }
53273
+ function getDocumentElement(node2) {
53274
+ var _ref;
53275
+ return (_ref = (isNode(node2) ? node2.ownerDocument : node2.document) || window.document) == null ? void 0 : _ref.documentElement;
53276
+ }
53277
+ function isNode(value) {
53278
+ if (!hasWindow()) {
53279
+ return false;
53280
+ }
53281
+ return value instanceof Node || value instanceof getWindow(value).Node;
53282
+ }
53283
+ function isElement$3(value) {
53284
+ if (!hasWindow()) {
53285
+ return false;
53286
+ }
53287
+ return value instanceof Element || value instanceof getWindow(value).Element;
53288
+ }
53289
+ function isHTMLElement$2(value) {
53290
+ if (!hasWindow()) {
53291
+ return false;
53292
+ }
53293
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
53294
+ }
53295
+ function isShadowRoot(value) {
53296
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
53297
+ return false;
53298
+ }
53299
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
53300
+ }
53301
+ function isOverflowElement(element) {
53302
+ const {
53303
+ overflow,
53304
+ overflowX,
53305
+ overflowY,
53306
+ display
53307
+ } = getComputedStyle$1(element);
53308
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
53309
+ }
53310
+ function isTableElement(element) {
53311
+ return ["table", "td", "th"].includes(getNodeName(element));
53312
+ }
53313
+ function isTopLayer(element) {
53314
+ return [":popover-open", ":modal"].some((selector) => {
53315
+ try {
53316
+ return element.matches(selector);
53317
+ } catch (e) {
53318
+ return false;
53319
+ }
53320
+ });
53321
+ }
53322
+ function isContainingBlock(elementOrCss) {
53323
+ const webkit2 = isWebKit();
53324
+ const css = isElement$3(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
53325
+ 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));
53326
+ }
53327
+ function getContainingBlock(element) {
53328
+ let currentNode = getParentNode$2(element);
53329
+ while (isHTMLElement$2(currentNode) && !isLastTraversableNode(currentNode)) {
53330
+ if (isContainingBlock(currentNode)) {
53331
+ return currentNode;
53332
+ } else if (isTopLayer(currentNode)) {
53333
+ return null;
53334
+ }
53335
+ currentNode = getParentNode$2(currentNode);
53336
+ }
53337
+ return null;
53338
+ }
53339
+ function isWebKit() {
53340
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
53341
+ return CSS.supports("-webkit-backdrop-filter", "none");
53342
+ }
53343
+ function isLastTraversableNode(node2) {
53344
+ return ["html", "body", "#document"].includes(getNodeName(node2));
53345
+ }
53346
+ function getComputedStyle$1(element) {
53347
+ return getWindow(element).getComputedStyle(element);
53348
+ }
53349
+ function getNodeScroll(element) {
53350
+ if (isElement$3(element)) {
53351
+ return {
53352
+ scrollLeft: element.scrollLeft,
53353
+ scrollTop: element.scrollTop
53354
+ };
53355
+ }
53356
+ return {
53357
+ scrollLeft: element.scrollX,
53358
+ scrollTop: element.scrollY
53359
+ };
53360
+ }
53361
+ function getParentNode$2(node2) {
53362
+ if (getNodeName(node2) === "html") {
53363
+ return node2;
53364
+ }
53365
+ const result = (
53366
+ // Step into the shadow DOM of the parent of a slotted node.
53367
+ node2.assignedSlot || // DOM Element detected.
53368
+ node2.parentNode || // ShadowRoot detected.
53369
+ isShadowRoot(node2) && node2.host || // Fallback.
53370
+ getDocumentElement(node2)
53371
+ );
53372
+ return isShadowRoot(result) ? result.host : result;
53373
+ }
53374
+ function getNearestOverflowAncestor(node2) {
53375
+ const parentNode2 = getParentNode$2(node2);
53376
+ if (isLastTraversableNode(parentNode2)) {
53377
+ return node2.ownerDocument ? node2.ownerDocument.body : node2.body;
53378
+ }
53379
+ if (isHTMLElement$2(parentNode2) && isOverflowElement(parentNode2)) {
53380
+ return parentNode2;
53381
+ }
53382
+ return getNearestOverflowAncestor(parentNode2);
53383
+ }
53384
+ function getOverflowAncestors(node2, list, traverseIframes) {
53385
+ var _node$ownerDocument2;
53386
+ if (list === void 0) {
53387
+ list = [];
53388
+ }
53389
+ if (traverseIframes === void 0) {
53390
+ traverseIframes = true;
53391
+ }
53392
+ const scrollableAncestor = getNearestOverflowAncestor(node2);
53393
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node2.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
53394
+ const win = getWindow(scrollableAncestor);
53395
+ if (isBody) {
53396
+ const frameElement = getFrameElement(win);
53397
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
53398
+ }
53399
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
53400
+ }
53401
+ function getFrameElement(win) {
53402
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
53403
+ }
53404
+ function getCssDimensions(element) {
53405
+ const css = getComputedStyle$1(element);
53406
+ let width = parseFloat(css.width) || 0;
53407
+ let height = parseFloat(css.height) || 0;
53408
+ const hasOffset = isHTMLElement$2(element);
53409
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
53410
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
53411
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
53412
+ if (shouldFallback) {
53413
+ width = offsetWidth;
53414
+ height = offsetHeight;
53415
+ }
53416
+ return {
53417
+ width,
53418
+ height,
53419
+ $: shouldFallback
53420
+ };
53421
+ }
53422
+ function unwrapElement(element) {
53423
+ return !isElement$3(element) ? element.contextElement : element;
53424
+ }
53425
+ function getScale(element) {
53426
+ const domElement = unwrapElement(element);
53427
+ if (!isHTMLElement$2(domElement)) {
53428
+ return createCoords(1);
53429
+ }
53430
+ const rect = domElement.getBoundingClientRect();
53431
+ const {
53432
+ width,
53433
+ height,
53434
+ $
53435
+ } = getCssDimensions(domElement);
53436
+ let x = ($ ? round(rect.width) : rect.width) / width;
53437
+ let y = ($ ? round(rect.height) : rect.height) / height;
53438
+ if (!x || !Number.isFinite(x)) {
53439
+ x = 1;
53440
+ }
53441
+ if (!y || !Number.isFinite(y)) {
53442
+ y = 1;
53443
+ }
53444
+ return {
53445
+ x,
53446
+ y
53447
+ };
53448
+ }
53449
+ const noOffsets = /* @__PURE__ */ createCoords(0);
53450
+ function getVisualOffsets(element) {
53451
+ const win = getWindow(element);
53452
+ if (!isWebKit() || !win.visualViewport) {
53453
+ return noOffsets;
53454
+ }
53455
+ return {
53456
+ x: win.visualViewport.offsetLeft,
53457
+ y: win.visualViewport.offsetTop
53458
+ };
53459
+ }
53460
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
53461
+ if (isFixed === void 0) {
53462
+ isFixed = false;
53463
+ }
53464
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
53465
+ return false;
53466
+ }
53467
+ return isFixed;
53468
+ }
53469
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
53470
+ if (includeScale === void 0) {
53471
+ includeScale = false;
53472
+ }
53473
+ if (isFixedStrategy === void 0) {
53474
+ isFixedStrategy = false;
53475
+ }
53476
+ const clientRect2 = element.getBoundingClientRect();
53477
+ const domElement = unwrapElement(element);
53478
+ let scale = createCoords(1);
53479
+ if (includeScale) {
53480
+ if (offsetParent) {
53481
+ if (isElement$3(offsetParent)) {
53482
+ scale = getScale(offsetParent);
53483
+ }
53484
+ } else {
53485
+ scale = getScale(element);
53486
+ }
53487
+ }
53488
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
53489
+ let x = (clientRect2.left + visualOffsets.x) / scale.x;
53490
+ let y = (clientRect2.top + visualOffsets.y) / scale.y;
53491
+ let width = clientRect2.width / scale.x;
53492
+ let height = clientRect2.height / scale.y;
53493
+ if (domElement) {
53494
+ const win = getWindow(domElement);
53495
+ const offsetWin = offsetParent && isElement$3(offsetParent) ? getWindow(offsetParent) : offsetParent;
53496
+ let currentWin = win;
53497
+ let currentIFrame = getFrameElement(currentWin);
53498
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
53499
+ const iframeScale = getScale(currentIFrame);
53500
+ const iframeRect = currentIFrame.getBoundingClientRect();
53501
+ const css = getComputedStyle$1(currentIFrame);
53502
+ const left2 = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
53503
+ const top2 = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
53504
+ x *= iframeScale.x;
53505
+ y *= iframeScale.y;
53506
+ width *= iframeScale.x;
53507
+ height *= iframeScale.y;
53508
+ x += left2;
53509
+ y += top2;
53510
+ currentWin = getWindow(currentIFrame);
53511
+ currentIFrame = getFrameElement(currentWin);
53512
+ }
53513
+ }
53514
+ return rectToClientRect({
53515
+ width,
53516
+ height,
53517
+ x,
53518
+ y
53519
+ });
53520
+ }
53521
+ function getWindowScrollBarX(element, rect) {
53522
+ const leftScroll = getNodeScroll(element).scrollLeft;
53523
+ if (!rect) {
53524
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
53525
+ }
53526
+ return rect.left + leftScroll;
53527
+ }
53528
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
53529
+ if (ignoreScrollbarX === void 0) {
53530
+ ignoreScrollbarX = false;
53531
+ }
53532
+ const htmlRect = documentElement.getBoundingClientRect();
53533
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
53534
+ // RTL <body> scrollbar.
53535
+ getWindowScrollBarX(documentElement, htmlRect)
53536
+ ));
53537
+ const y = htmlRect.top + scroll.scrollTop;
53538
+ return {
53539
+ x,
53540
+ y
53541
+ };
53542
+ }
53543
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
53544
+ let {
53545
+ elements,
53546
+ rect,
53547
+ offsetParent,
53548
+ strategy
53549
+ } = _ref;
53550
+ const isFixed = strategy === "fixed";
53551
+ const documentElement = getDocumentElement(offsetParent);
53552
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
53553
+ if (offsetParent === documentElement || topLayer && isFixed) {
53554
+ return rect;
53555
+ }
53556
+ let scroll = {
53557
+ scrollLeft: 0,
53558
+ scrollTop: 0
53559
+ };
53560
+ let scale = createCoords(1);
53561
+ const offsets = createCoords(0);
53562
+ const isOffsetParentAnElement = isHTMLElement$2(offsetParent);
53563
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
53564
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
53565
+ scroll = getNodeScroll(offsetParent);
53566
+ }
53567
+ if (isHTMLElement$2(offsetParent)) {
53568
+ const offsetRect = getBoundingClientRect(offsetParent);
53569
+ scale = getScale(offsetParent);
53570
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
53571
+ offsets.y = offsetRect.y + offsetParent.clientTop;
53572
+ }
53573
+ }
53574
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
53575
+ return {
53576
+ width: rect.width * scale.x,
53577
+ height: rect.height * scale.y,
53578
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
53579
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
53580
+ };
53581
+ }
53582
+ function getClientRects(element) {
53583
+ return Array.from(element.getClientRects());
53584
+ }
53585
+ function getDocumentRect(element) {
53586
+ const html = getDocumentElement(element);
53587
+ const scroll = getNodeScroll(element);
53588
+ const body = element.ownerDocument.body;
53589
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
53590
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
53591
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
53592
+ const y = -scroll.scrollTop;
53593
+ if (getComputedStyle$1(body).direction === "rtl") {
53594
+ x += max(html.clientWidth, body.clientWidth) - width;
53595
+ }
53596
+ return {
53597
+ width,
53598
+ height,
53599
+ x,
53600
+ y
53601
+ };
53602
+ }
53603
+ function getViewportRect(element, strategy) {
53604
+ const win = getWindow(element);
53605
+ const html = getDocumentElement(element);
53606
+ const visualViewport = win.visualViewport;
53607
+ let width = html.clientWidth;
53608
+ let height = html.clientHeight;
53609
+ let x = 0;
53610
+ let y = 0;
53611
+ if (visualViewport) {
53612
+ width = visualViewport.width;
53613
+ height = visualViewport.height;
53614
+ const visualViewportBased = isWebKit();
53615
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
53616
+ x = visualViewport.offsetLeft;
53617
+ y = visualViewport.offsetTop;
53618
+ }
53619
+ }
53620
+ return {
53621
+ width,
53622
+ height,
53623
+ x,
53624
+ y
53625
+ };
53626
+ }
53627
+ function getInnerBoundingClientRect(element, strategy) {
53628
+ const clientRect2 = getBoundingClientRect(element, true, strategy === "fixed");
53629
+ const top2 = clientRect2.top + element.clientTop;
53630
+ const left2 = clientRect2.left + element.clientLeft;
53631
+ const scale = isHTMLElement$2(element) ? getScale(element) : createCoords(1);
53632
+ const width = element.clientWidth * scale.x;
53633
+ const height = element.clientHeight * scale.y;
53634
+ const x = left2 * scale.x;
53635
+ const y = top2 * scale.y;
53636
+ return {
53637
+ width,
53638
+ height,
53639
+ x,
53640
+ y
53641
+ };
53642
+ }
53643
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
53644
+ let rect;
53645
+ if (clippingAncestor === "viewport") {
53646
+ rect = getViewportRect(element, strategy);
53647
+ } else if (clippingAncestor === "document") {
53648
+ rect = getDocumentRect(getDocumentElement(element));
53649
+ } else if (isElement$3(clippingAncestor)) {
53650
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
53651
+ } else {
53652
+ const visualOffsets = getVisualOffsets(element);
53653
+ rect = {
53654
+ x: clippingAncestor.x - visualOffsets.x,
53655
+ y: clippingAncestor.y - visualOffsets.y,
53656
+ width: clippingAncestor.width,
53657
+ height: clippingAncestor.height
53658
+ };
53659
+ }
53660
+ return rectToClientRect(rect);
53661
+ }
53662
+ function hasFixedPositionAncestor(element, stopNode) {
53663
+ const parentNode2 = getParentNode$2(element);
53664
+ if (parentNode2 === stopNode || !isElement$3(parentNode2) || isLastTraversableNode(parentNode2)) {
53665
+ return false;
53666
+ }
53667
+ return getComputedStyle$1(parentNode2).position === "fixed" || hasFixedPositionAncestor(parentNode2, stopNode);
53668
+ }
53669
+ function getClippingElementAncestors(element, cache2) {
53670
+ const cachedResult2 = cache2.get(element);
53671
+ if (cachedResult2) {
53672
+ return cachedResult2;
53673
+ }
53674
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement$3(el) && getNodeName(el) !== "body");
53675
+ let currentContainingBlockComputedStyle = null;
53676
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
53677
+ let currentNode = elementIsFixed ? getParentNode$2(element) : element;
53678
+ while (isElement$3(currentNode) && !isLastTraversableNode(currentNode)) {
53679
+ const computedStyle = getComputedStyle$1(currentNode);
53680
+ const currentNodeIsContaining = isContainingBlock(currentNode);
53681
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
53682
+ currentContainingBlockComputedStyle = null;
53683
+ }
53684
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
53685
+ if (shouldDropCurrentNode) {
53686
+ result = result.filter((ancestor) => ancestor !== currentNode);
53687
+ } else {
53688
+ currentContainingBlockComputedStyle = computedStyle;
53689
+ }
53690
+ currentNode = getParentNode$2(currentNode);
53691
+ }
53692
+ cache2.set(element, result);
53693
+ return result;
53694
+ }
53695
+ function getClippingRect(_ref) {
53696
+ let {
53697
+ element,
53698
+ boundary,
53699
+ rootBoundary,
53700
+ strategy
53701
+ } = _ref;
53702
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
53703
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
53704
+ const firstClippingAncestor = clippingAncestors[0];
53705
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
53706
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
53707
+ accRect.top = max(rect.top, accRect.top);
53708
+ accRect.right = min(rect.right, accRect.right);
53709
+ accRect.bottom = min(rect.bottom, accRect.bottom);
53710
+ accRect.left = max(rect.left, accRect.left);
53711
+ return accRect;
53712
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
53713
+ return {
53714
+ width: clippingRect.right - clippingRect.left,
53715
+ height: clippingRect.bottom - clippingRect.top,
53716
+ x: clippingRect.left,
53717
+ y: clippingRect.top
53718
+ };
53719
+ }
53720
+ function getDimensions(element) {
53721
+ const {
53722
+ width,
53723
+ height
53724
+ } = getCssDimensions(element);
53725
+ return {
53726
+ width,
53727
+ height
53728
+ };
53729
+ }
53730
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
53731
+ const isOffsetParentAnElement = isHTMLElement$2(offsetParent);
53732
+ const documentElement = getDocumentElement(offsetParent);
53733
+ const isFixed = strategy === "fixed";
53734
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
53735
+ let scroll = {
53736
+ scrollLeft: 0,
53737
+ scrollTop: 0
53738
+ };
53739
+ const offsets = createCoords(0);
53740
+ function setLeftRTLScrollbarOffset() {
53741
+ offsets.x = getWindowScrollBarX(documentElement);
53742
+ }
53743
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
53744
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
53745
+ scroll = getNodeScroll(offsetParent);
53746
+ }
53747
+ if (isOffsetParentAnElement) {
53748
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
53749
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
53750
+ offsets.y = offsetRect.y + offsetParent.clientTop;
53751
+ } else if (documentElement) {
53752
+ setLeftRTLScrollbarOffset();
53753
+ }
53754
+ }
53755
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
53756
+ setLeftRTLScrollbarOffset();
53757
+ }
53758
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
53759
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
53760
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
53761
+ return {
53762
+ x,
53763
+ y,
53764
+ width: rect.width,
53765
+ height: rect.height
53766
+ };
53767
+ }
53768
+ function isStaticPositioned(element) {
53769
+ return getComputedStyle$1(element).position === "static";
53770
+ }
53771
+ function getTrueOffsetParent(element, polyfill) {
53772
+ if (!isHTMLElement$2(element) || getComputedStyle$1(element).position === "fixed") {
53773
+ return null;
53774
+ }
53775
+ if (polyfill) {
53776
+ return polyfill(element);
53777
+ }
53778
+ let rawOffsetParent = element.offsetParent;
53779
+ if (getDocumentElement(element) === rawOffsetParent) {
53780
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
53781
+ }
53782
+ return rawOffsetParent;
53783
+ }
53784
+ function getOffsetParent(element, polyfill) {
53785
+ const win = getWindow(element);
53786
+ if (isTopLayer(element)) {
53787
+ return win;
53788
+ }
53789
+ if (!isHTMLElement$2(element)) {
53790
+ let svgOffsetParent = getParentNode$2(element);
53791
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
53792
+ if (isElement$3(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
53793
+ return svgOffsetParent;
53794
+ }
53795
+ svgOffsetParent = getParentNode$2(svgOffsetParent);
53796
+ }
53797
+ return win;
53798
+ }
53799
+ let offsetParent = getTrueOffsetParent(element, polyfill);
53800
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
53801
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
53802
+ }
53803
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
53804
+ return win;
53805
+ }
53806
+ return offsetParent || getContainingBlock(element) || win;
53807
+ }
53808
+ const getElementRects = async function(data) {
53809
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
53810
+ const getDimensionsFn = this.getDimensions;
53811
+ const floatingDimensions = await getDimensionsFn(data.floating);
53812
+ return {
53813
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
53814
+ floating: {
53815
+ x: 0,
53816
+ y: 0,
53817
+ width: floatingDimensions.width,
53818
+ height: floatingDimensions.height
53819
+ }
53820
+ };
53821
+ };
53822
+ function isRTL(element) {
53823
+ return getComputedStyle$1(element).direction === "rtl";
53824
+ }
53825
+ const platform = {
53826
+ convertOffsetParentRelativeRectToViewportRelativeRect,
53827
+ getDocumentElement,
53828
+ getClippingRect,
53829
+ getOffsetParent,
53830
+ getElementRects,
53831
+ getClientRects,
53832
+ getDimensions,
53833
+ getScale,
53834
+ isElement: isElement$3,
53835
+ isRTL
53836
+ };
53837
+ function rectsAreEqual(a, b) {
53838
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
53839
+ }
53840
+ function observeMove(element, onMove) {
53841
+ let io = null;
53842
+ let timeoutId;
53843
+ const root2 = getDocumentElement(element);
53844
+ function cleanup() {
53845
+ var _io;
53846
+ clearTimeout(timeoutId);
53847
+ (_io = io) == null || _io.disconnect();
53848
+ io = null;
53849
+ }
53850
+ function refresh(skip, threshold) {
53851
+ if (skip === void 0) {
53852
+ skip = false;
53853
+ }
53854
+ if (threshold === void 0) {
53855
+ threshold = 1;
53856
+ }
53857
+ cleanup();
53858
+ const elementRectForRootMargin = element.getBoundingClientRect();
53859
+ const {
53860
+ left: left2,
53861
+ top: top2,
53862
+ width,
53863
+ height
53864
+ } = elementRectForRootMargin;
53865
+ if (!skip) {
53866
+ onMove();
53867
+ }
53868
+ if (!width || !height) {
53869
+ return;
53870
+ }
53871
+ const insetTop = floor(top2);
53872
+ const insetRight = floor(root2.clientWidth - (left2 + width));
53873
+ const insetBottom = floor(root2.clientHeight - (top2 + height));
53874
+ const insetLeft = floor(left2);
53875
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
53876
+ const options2 = {
53877
+ rootMargin,
53878
+ threshold: max(0, min(1, threshold)) || 1
53879
+ };
53880
+ let isFirstUpdate = true;
53881
+ function handleObserve(entries) {
53882
+ const ratio = entries[0].intersectionRatio;
53883
+ if (ratio !== threshold) {
53884
+ if (!isFirstUpdate) {
53885
+ return refresh();
53886
+ }
53887
+ if (!ratio) {
53888
+ timeoutId = setTimeout(() => {
53889
+ refresh(false, 1e-7);
53890
+ }, 1e3);
53891
+ } else {
53892
+ refresh(false, ratio);
53893
+ }
53894
+ }
53895
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
53896
+ refresh();
53897
+ }
53898
+ isFirstUpdate = false;
53899
+ }
53900
+ try {
53901
+ io = new IntersectionObserver(handleObserve, {
53902
+ ...options2,
53903
+ // Handle <iframe>s
53904
+ root: root2.ownerDocument
53905
+ });
53906
+ } catch (_e) {
53907
+ io = new IntersectionObserver(handleObserve, options2);
53908
+ }
53909
+ io.observe(element);
53910
+ }
53911
+ refresh(true);
53912
+ return cleanup;
53913
+ }
53914
+ function autoUpdate(reference2, floating, update, options2) {
53915
+ if (options2 === void 0) {
53916
+ options2 = {};
53917
+ }
53918
+ const {
53919
+ ancestorScroll = true,
53920
+ ancestorResize = true,
53921
+ elementResize = typeof ResizeObserver === "function",
53922
+ layoutShift = typeof IntersectionObserver === "function",
53923
+ animationFrame = false
53924
+ } = options2;
53925
+ const referenceEl = unwrapElement(reference2);
53926
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
53927
+ ancestors.forEach((ancestor) => {
53928
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
53929
+ passive: true
53930
+ });
53931
+ ancestorResize && ancestor.addEventListener("resize", update);
53932
+ });
53933
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
53934
+ let reobserveFrame = -1;
53935
+ let resizeObserver = null;
53936
+ if (elementResize) {
53937
+ resizeObserver = new ResizeObserver((_ref) => {
53938
+ let [firstEntry] = _ref;
53939
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
53940
+ resizeObserver.unobserve(floating);
53941
+ cancelAnimationFrame(reobserveFrame);
53942
+ reobserveFrame = requestAnimationFrame(() => {
53943
+ var _resizeObserver;
53944
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
53945
+ });
53946
+ }
53947
+ update();
53948
+ });
53949
+ if (referenceEl && !animationFrame) {
53950
+ resizeObserver.observe(referenceEl);
53951
+ }
53952
+ resizeObserver.observe(floating);
53953
+ }
53954
+ let frameId;
53955
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference2) : null;
53956
+ if (animationFrame) {
53957
+ frameLoop();
53958
+ }
53959
+ function frameLoop() {
53960
+ const nextRefRect = getBoundingClientRect(reference2);
53961
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
53962
+ update();
53963
+ }
53964
+ prevRefRect = nextRefRect;
53965
+ frameId = requestAnimationFrame(frameLoop);
53966
+ }
53967
+ update();
53968
+ return () => {
53969
+ var _resizeObserver2;
53970
+ ancestors.forEach((ancestor) => {
53971
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
53972
+ ancestorResize && ancestor.removeEventListener("resize", update);
53973
+ });
53974
+ cleanupIo == null || cleanupIo();
53975
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
53976
+ resizeObserver = null;
53977
+ if (animationFrame) {
53978
+ cancelAnimationFrame(frameId);
53979
+ }
53980
+ };
53981
+ }
53982
+ const hide = hide$1;
53983
+ const computePosition = (reference2, floating, options2) => {
53984
+ const cache2 = /* @__PURE__ */ new Map();
53985
+ const mergedOptions = {
53986
+ platform,
53987
+ ...options2
53988
+ };
53989
+ const platformWithCache = {
53990
+ ...mergedOptions.platform,
53991
+ _c: cache2
53992
+ };
53993
+ return computePosition$1(reference2, floating, {
53994
+ ...mergedOptions,
53995
+ platform: platformWithCache
53996
+ });
53997
+ };
53998
+ const SEPARATOR_CLASS = "pagination-separator";
53999
+ const SEPARATOR_FLOATING_CLASS = "pagination-separator-floating";
52561
54000
  const isDebugging = false;
54001
+ const cleanupFunctions = /* @__PURE__ */ new Set();
52562
54002
  const Pagination = Extension.create({
52563
54003
  name: "pagination",
52564
54004
  addStorage() {
@@ -52648,7 +54088,7 @@ const Pagination = Extension.create({
52648
54088
  view: (view) => {
52649
54089
  let previousDecorations = DecorationSet.empty;
52650
54090
  return {
52651
- update: (view2) => {
54091
+ update: (view2, prevState) => {
52652
54092
  if (!shouldUpdate || isUpdating) return;
52653
54093
  isUpdating = true;
52654
54094
  hasInitialized = true;
@@ -52665,6 +54105,9 @@ const Pagination = Extension.create({
52665
54105
  }
52666
54106
  });
52667
54107
  return [paginationPlugin];
54108
+ },
54109
+ onDestroy() {
54110
+ cleanupFloatingSeparators();
52668
54111
  }
52669
54112
  });
52670
54113
  const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null) => {
@@ -52702,12 +54145,23 @@ const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null)
52702
54145
  const performUpdate = (editor, view, previousDecorations) => {
52703
54146
  const sectionData = editor.storage.pagination.sectionData;
52704
54147
  const newDecorations = calculatePageBreaks(view, editor, sectionData);
54148
+ const editorElement = editor.options.element;
52705
54149
  if (!previousDecorations.eq(newDecorations)) {
52706
54150
  const updateTransaction = view.state.tr.setMeta(
52707
54151
  PaginationPluginKey,
52708
54152
  { decorations: newDecorations }
52709
54153
  );
52710
54154
  view.dispatch(updateTransaction);
54155
+ requestAnimationFrame(() => {
54156
+ requestAnimationFrame(() => {
54157
+ cleanupFloatingSeparators();
54158
+ const separators = [...editorElement.querySelectorAll(`.${SEPARATOR_CLASS}--table`)];
54159
+ separators.forEach((separator) => {
54160
+ const { cleanup } = createFloatingSeparator(separator, editor);
54161
+ cleanupFunctions.add(cleanup);
54162
+ });
54163
+ });
54164
+ });
52711
54165
  }
52712
54166
  editor.emit("paginationUpdate");
52713
54167
  };
@@ -52748,16 +54202,15 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52748
54202
  const decorations = [];
52749
54203
  const { pageSize, pageMargins } = editor.converter.pageStyles;
52750
54204
  const pageHeight = pageSize.height * 96;
52751
- editor.options.scale;
52752
54205
  let currentPageNumber = 1;
52753
54206
  let pageHeightThreshold = pageHeight;
52754
54207
  let footer = null, header = null;
52755
54208
  const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52756
- const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor);
54209
+ const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
52757
54210
  const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
52758
54211
  decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
52759
54212
  const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
52760
- const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor);
54213
+ const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
52761
54214
  pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
52762
54215
  let coords = view?.coordsAtPos(doc2.content.size);
52763
54216
  if (!coords) return [];
@@ -52776,7 +54229,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52776
54229
  if (currentPageNumber === 1) {
52777
54230
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
52778
54231
  decorations.pop();
52779
- const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
54232
+ const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
52780
54233
  const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
52781
54234
  decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
52782
54235
  }
@@ -52792,7 +54245,9 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52792
54245
  }
52793
54246
  if (isHardBreakNode || shouldAddPageBreak) {
52794
54247
  const $currentPos = view.state.doc.resolve(currentPos);
54248
+ const table = findParentNodeClosestToPos($currentPos, (node22) => node22.type.name === "table");
52795
54249
  const tableRow = findParentNodeClosestToPos($currentPos, (node22) => node22.type.name === "tableRow");
54250
+ let isInTable2 = table || tableRow ? true : false;
52796
54251
  if (tableRow) {
52797
54252
  currentNode = tableRow.node;
52798
54253
  currentPos = tableRow.pos;
@@ -52805,13 +54260,13 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52805
54260
  const footerId2 = getHeaderFooterId(currentPageNumber, "footerIds", editor, currentNode);
52806
54261
  currentPageNumber++;
52807
54262
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52808
- header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
54263
+ header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
52809
54264
  footer = createFooter(pageMargins, pageSize, sectionData, footerId2, editor, currentPageNumber - 1);
52810
54265
  const bufferHeight2 = pageHeightThreshold - actualBreakBottom;
52811
54266
  const { node: spacingNode2 } = createFinalPagePadding(bufferHeight2);
52812
54267
  const pageSpacer2 = Decoration.widget(breakPos, spacingNode2, { key: "stable-key" });
52813
54268
  decorations.push(pageSpacer2);
52814
- const pageBreak2 = createPageBreak({ editor, header, footer });
54269
+ const pageBreak2 = createPageBreak({ editor, header, footer, isInTable: isInTable2 });
52815
54270
  decorations.push(Decoration.widget(breakPos, pageBreak2, { key: "stable-key" }));
52816
54271
  pageHeightThreshold = actualBreakBottom + (pageHeight - header.headerHeight - footer.footerHeight);
52817
54272
  }
@@ -52820,7 +54275,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52820
54275
  const lastNodeCoords = view.coordsAtPos(finalPos);
52821
54276
  const headerId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52822
54277
  const footerId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
52823
- header = createHeader(pageMargins, pageSize, sectionData, headerId, editor);
54278
+ header = createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber);
52824
54279
  footer = createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber);
52825
54280
  const bufferHeight = pageHeightThreshold - lastNodeCoords.bottom;
52826
54281
  const { node: spacingNode } = createFinalPagePadding(bufferHeight);
@@ -52837,6 +54292,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52837
54292
  totalPageNumber.innerText = currentPageNumber;
52838
54293
  }
52839
54294
  });
54295
+ editor.currentTotalPages = currentPageNumber;
52840
54296
  return decorations;
52841
54297
  }
52842
54298
  function createFinalPagePadding(bufferHeight) {
@@ -52847,7 +54303,7 @@ function createFinalPagePadding(bufferHeight) {
52847
54303
  div2.style.height = bufferHeight + "px";
52848
54304
  return { nodeHeight: bufferHeight, node: div2 };
52849
54305
  }
52850
- function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
54306
+ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
52851
54307
  const headerDef = sectionData.headers?.[headerId];
52852
54308
  const minHeaderHeight = pageMargins.top * 96;
52853
54309
  const headerMargin = pageMargins.header * 96;
@@ -52874,7 +54330,8 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
52874
54330
  appendToBody: false,
52875
54331
  sectionId: headerId,
52876
54332
  type: "header",
52877
- availableHeight
54333
+ availableHeight,
54334
+ currentPageNumber
52878
54335
  });
52879
54336
  editor.converter.headerEditors.push({
52880
54337
  id: headerId,
@@ -52900,13 +54357,6 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
52900
54357
  const minFooterHeight = pageMargins.bottom * 96;
52901
54358
  const footerPaddingFromEdge = pageMargins.footer * 96;
52902
54359
  const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
52903
- const sectionContainer = footerDef?.sectionContainer?.cloneNode(true);
52904
- const autoPageNumber = sectionContainer?.querySelector('span[data-id="auto-page-number"]');
52905
- if (autoPageNumber) {
52906
- const fontSize2 = autoPageNumber.previousElementSibling?.style?.fontSize || autoPageNumber.nextElementSibling?.style?.fontSize;
52907
- if (fontSize2) autoPageNumber.style.fontSize = fontSize2;
52908
- autoPageNumber.innerText = currentPageNumber;
52909
- }
52910
54360
  const editorContainer = document.createElement("div");
52911
54361
  if (!footerId && !editor.converter.footerIds["default"]) {
52912
54362
  footerId = "rId" + generateDocxRandomId();
@@ -52926,7 +54376,8 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
52926
54376
  appendToBody: false,
52927
54377
  sectionId: footerId,
52928
54378
  type: "footer",
52929
- availableHeight: footerHeight
54379
+ availableHeight: footerHeight,
54380
+ currentPageNumber
52930
54381
  });
52931
54382
  editor.converter.footerEditors.push({
52932
54383
  id: footerId,
@@ -52952,7 +54403,7 @@ const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
52952
54403
  editor.setEditable(false, false);
52953
54404
  toggleHeaderFooterEditMode(editor, currentFocusedSectionEditor, true);
52954
54405
  };
52955
- function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter }) {
54406
+ function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
52956
54407
  const { pageSize, pageMargins } = editor.converter.pageStyles;
52957
54408
  let sectionHeight = 0;
52958
54409
  const paginationDiv = document.createElement("div");
@@ -52971,7 +54422,10 @@ function createPageBreak({ editor, header, footer, footerBottom = null, isFirstH
52971
54422
  const separatorHeight = 20;
52972
54423
  sectionHeight += separatorHeight;
52973
54424
  const separator = document.createElement("div");
52974
- separator.className = "pagination-separator";
54425
+ separator.classList.add(SEPARATOR_CLASS);
54426
+ if (isInTable2) {
54427
+ separator.classList.add(`${SEPARATOR_CLASS}--table`);
54428
+ }
52975
54429
  innerDiv.appendChild(separator);
52976
54430
  }
52977
54431
  if (header) {
@@ -53010,6 +54464,85 @@ const onImageLoad = (editor) => {
53010
54464
  editor.view.dispatch(newTr);
53011
54465
  });
53012
54466
  };
54467
+ function createFloatingSeparator(separator, editor) {
54468
+ const floatingSeparator = document.createElement("div");
54469
+ floatingSeparator.classList.add(SEPARATOR_FLOATING_CLASS);
54470
+ floatingSeparator.dataset.floatingSeparator = "";
54471
+ const editorElement = editor.options.element;
54472
+ editorElement.append(floatingSeparator);
54473
+ const updatePosition2 = () => {
54474
+ computePosition(separator, floatingSeparator, {
54475
+ strategy: "absolute",
54476
+ placement: "top-start",
54477
+ middleware: [
54478
+ hide(),
54479
+ {
54480
+ name: "copy",
54481
+ fn: ({ elements }) => {
54482
+ const rect = elements.reference.getBoundingClientRect();
54483
+ const containerRect = editorElement.getBoundingClientRect();
54484
+ const scaleFactor = getScaleFactor(editorElement);
54485
+ const x = Math.round((rect.left - containerRect.left) / scaleFactor);
54486
+ const y = Math.round((rect.top - containerRect.top) / scaleFactor);
54487
+ const width = Math.round(rect.width / scaleFactor);
54488
+ const height = Math.round(rect.height / scaleFactor);
54489
+ return {
54490
+ x,
54491
+ y,
54492
+ data: { width, height }
54493
+ };
54494
+ }
54495
+ }
54496
+ ]
54497
+ }).then(({ x, y, middlewareData }) => {
54498
+ Object.assign(floatingSeparator.style, {
54499
+ top: `${y}px`,
54500
+ left: `${x}px`,
54501
+ width: `${middlewareData.copy.width}px`,
54502
+ height: `${middlewareData.copy.height}px`,
54503
+ visibility: middlewareData.hide?.referenceHidden ? "hidden" : "visible"
54504
+ });
54505
+ });
54506
+ };
54507
+ const cleanup = autoUpdate(
54508
+ separator,
54509
+ floatingSeparator,
54510
+ updatePosition2
54511
+ );
54512
+ const extendedCleanup = () => {
54513
+ floatingSeparator?.remove();
54514
+ cleanup();
54515
+ };
54516
+ return {
54517
+ cleanup: extendedCleanup,
54518
+ updatePosition: updatePosition2
54519
+ };
54520
+ }
54521
+ function cleanupFloatingSeparators() {
54522
+ cleanupFunctions.forEach((cleanup) => cleanup());
54523
+ cleanupFunctions.clear();
54524
+ }
54525
+ function getScaleFactor(element) {
54526
+ let scale = 1;
54527
+ let currentElement2 = element;
54528
+ while (currentElement2 && currentElement2 !== document.documentElement) {
54529
+ let zoomStyle = currentElement2.style.zoom;
54530
+ if (zoomStyle) {
54531
+ let zoom = parseFloat(zoomStyle) || 1;
54532
+ scale *= zoom;
54533
+ }
54534
+ let transformStyle = currentElement2.style.transform;
54535
+ if (transformStyle) {
54536
+ let scaleMatch = transformStyle.match(/scale\(([^)]+)\)/);
54537
+ if (scaleMatch) {
54538
+ let scaleValue = parseFloat(scaleMatch[1]) || 1;
54539
+ scale *= scaleValue;
54540
+ }
54541
+ }
54542
+ currentElement2 = currentElement2.parentElement;
54543
+ }
54544
+ return scale;
54545
+ }
53013
54546
  class SearchQuery {
53014
54547
  /**
53015
54548
  Create a query object.
@@ -57049,7 +58582,7 @@ var ResizeObserverController = function() {
57049
58582
  };
57050
58583
  return ResizeObserverController2;
57051
58584
  }();
57052
- var ResizeObserver = function() {
58585
+ var ResizeObserver$1 = function() {
57053
58586
  function ResizeObserver2(callback) {
57054
58587
  if (arguments.length === 0) {
57055
58588
  throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
@@ -57088,7 +58621,7 @@ var ResizeObserver = function() {
57088
58621
  class ResizeObserverDelegate {
57089
58622
  constructor() {
57090
58623
  this.handleResize = this.handleResize.bind(this);
57091
- this.observer = new (typeof window !== "undefined" && window.ResizeObserver || ResizeObserver)(this.handleResize);
58624
+ this.observer = new (typeof window !== "undefined" && window.ResizeObserver || ResizeObserver$1)(this.handleResize);
57092
58625
  this.elHandlersMap = /* @__PURE__ */ new Map();
57093
58626
  }
57094
58627
  handleResize(entries) {
@@ -67494,7 +69027,7 @@ const _sfc_main$2 = {
67494
69027
  };
67495
69028
  }
67496
69029
  };
67497
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-199a4ecf"]]);
69030
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-4b700df1"]]);
67498
69031
  const _sfc_main$1 = {
67499
69032
  __name: "BasicUpload",
67500
69033
  emits: ["file-change"],