@svgrid/enterprise 3.1.70 → 3.1.72

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 (86) hide show
  1. package/dist/SvGridBoard.svelte +22 -3
  2. package/dist/SvGridGallery.svelte +1 -1
  3. package/dist/card-look.d.ts +18 -0
  4. package/dist/card-look.js +2 -0
  5. package/dist/cdn/svgrid-enterprise.svelte-external.js +487 -484
  6. package/dist/designer/assets/GridMenus-BWRHlEUz.js +1 -0
  7. package/dist/designer/assets/PinSplitter-DFIcNVPE.js +1 -0
  8. package/dist/designer/assets/{index-0ETkK4qg.js → index-BQsNM94_.js} +3 -3
  9. package/dist/designer/index.html +1 -1
  10. package/dist/fields/BaseTableView.svelte +1 -1
  11. package/dist/fields/BaseTableView.svelte.d.ts +1 -1
  12. package/dist/fields/FieldsHeaderEnd.svelte +2 -2
  13. package/dist/fields/RecordView.svelte +134 -3
  14. package/dist/fields/RecordView.svelte.d.ts +3 -0
  15. package/dist/fields/SvBase.svelte +5 -3
  16. package/dist/fields/SvBase.svelte.d.ts +11 -0
  17. package/dist/fields/SvBaseViewBar.svelte +2 -2
  18. package/dist/fields/base-tables.d.ts +19 -0
  19. package/dist/fields/editor-request.svelte.d.ts +4 -1
  20. package/dist/fields/index.d.ts +1 -1
  21. package/dist/fields/index.js +1 -1
  22. package/dist/fields/messages/record.d.ts +118 -0
  23. package/dist/fields/messages/record.js +1 -1
  24. package/dist/fields/messages/shell.d.ts +2 -0
  25. package/dist/fields/messages/shell.js +1 -1
  26. package/dist/fields/messages/viewbar.d.ts +2 -0
  27. package/dist/fields/messages/viewbar.js +1 -1
  28. package/dist/fields/messages.svelte.d.ts +122 -0
  29. package/dist/fields/page/EmojiPicker.svelte +22 -0
  30. package/dist/fields/page/EmojiPicker.svelte.d.ts +8 -0
  31. package/dist/fields/page/PageEditor.svelte +155 -0
  32. package/dist/fields/page/PageEditor.svelte.d.ts +20 -0
  33. package/dist/fields/page/PageSettings.svelte +34 -0
  34. package/dist/fields/page/PageSettings.svelte.d.ts +17 -0
  35. package/dist/fields/page/embed-url.d.ts +20 -0
  36. package/dist/fields/page/embed-url.js +1 -0
  37. package/dist/fields/page/page-editor.d.ts +159 -0
  38. package/dist/fields/page/page-editor.js +10 -0
  39. package/dist/fields/page/page-schema.d.ts +35 -0
  40. package/dist/fields/page/page-schema.js +1 -0
  41. package/dist/fields/rich-html-write.js +1 -1
  42. package/dist/fields/sources.svelte.d.ts +3 -1
  43. package/dist/fields/view-model.d.ts +14 -4
  44. package/dist/fields/view-model.js +1 -1
  45. package/dist/fields/viewbar/BoardPanel.svelte +30 -2
  46. package/dist/node/studio.js +1 -1
  47. package/dist/version.d.ts +2 -2
  48. package/dist/version.js +1 -1
  49. package/dist/wc/CardMenu-D9GMS8U3.js +1 -0
  50. package/dist/wc/GridMenus-BcOloz5b.js +16 -0
  51. package/dist/wc/GridMenus-CaWxHkj0.js +16 -0
  52. package/dist/wc/PageEditor-9QJDKhtZ.js +10 -0
  53. package/dist/wc/PinSplitter-BmwDy-Ow.js +11 -0
  54. package/dist/wc/PinSplitter-D7UYjmiP.js +11 -0
  55. package/dist/wc/SvForm-CgshrajJ.js +46 -0
  56. package/dist/wc/board-DZKHA_nQ.js +31 -0
  57. package/dist/wc/card-look-CtMsGc56.js +6 -0
  58. package/dist/wc/date-locale-HgJNFY2n.js +1 -0
  59. package/dist/wc/dist-38sT7vmy.js +1 -0
  60. package/dist/wc/dist-BeUwTaC6.js +1 -0
  61. package/dist/wc/dist-Bl8aVOmr.js +2 -0
  62. package/dist/wc/dist-C7Z0Guly.js +1 -0
  63. package/dist/wc/dist-CEyUgQt3.js +2 -0
  64. package/dist/wc/dist-D2lK5znU.js +4 -0
  65. package/dist/wc/dist-DdZ3e9iY.js +5 -0
  66. package/dist/wc/dist-DgLsWEqp.js +1 -0
  67. package/dist/wc/dist-Jl2k94vj.js +1 -0
  68. package/dist/wc/dist-ZVYC9b49.js +1 -0
  69. package/dist/wc/dist-z_tOCaGG.js +1 -0
  70. package/dist/wc/embed-url-BTRiV8zf.js +1 -0
  71. package/dist/wc/gallery-B-VEjOws.js +14 -0
  72. package/dist/wc/{gantt-D0gdx_Tq.js → gantt-BZfS6Kbz.js} +2 -2
  73. package/dist/wc/{scheduler-BCY96peY.js → scheduler-BzuGk1RZ.js} +2 -2
  74. package/dist/wc/sv-base-element.js +109 -95
  75. package/dist/wc/sv-sheet-element.js +1 -1
  76. package/package.json +58 -3
  77. package/dist/designer/assets/GridMenus-Cx3LyUQM.js +0 -1
  78. package/dist/designer/assets/PinSplitter-oi6ffxQy.js +0 -1
  79. package/dist/wc/CardMenu-DC9pBy2r.js +0 -5
  80. package/dist/wc/GridMenus-BJsnJOkz.js +0 -16
  81. package/dist/wc/GridMenus-sqW-Y7S5.js +0 -16
  82. package/dist/wc/PinSplitter-3i65naKl.js +0 -11
  83. package/dist/wc/PinSplitter-CLTE0bRc.js +0 -11
  84. package/dist/wc/board-B-lyDG1V.js +0 -28
  85. package/dist/wc/date-locale-CKE0m3Dc.js +0 -46
  86. package/dist/wc/gallery-BpWvIrwO.js +0 -15
@@ -0,0 +1,5 @@
1
+ import{i as In,n as Te,r as q,t as at,u as U}from"./dist-D2lK5znU.js";import{u as Ln}from"./dist-Bl8aVOmr.js";import{AllSelection as Fn,NodeSelection as v,Selection as fe,TextSelection as S}from"./dist-z_tOCaGG.js";var M=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t};function te(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t}var dt=null;function F(e,t,n){let o=dt||=document.createRange();return o.setEnd(e,n??e.nodeValue.length),o.setStart(e,t||0),o}function zn(){dt=null}function ue(e,t,n,o){return n&&(ht(e,t,n,o,-1)||ht(e,t,n,o,1))}var ct=/^(img|br|input|textarea|hr)$/i;function ht(e,t,n,o,i){for(;;){if(e==n&&t==o)return!0;if(t==(i<0?0:O(e))){let s=e.parentNode;if(!s||!y(s)||pe(e)||ct.test(e.nodeName)||e.contentEditable=="false")return!1;t=M(e)+(i<0?0:1),e=s}else if(y(e)){let s=e.childNodes[t+(i<0?-1:0)];if(y(s)&&s.contentEditable=="false")if(s.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else{if(pe(s)||ct.test(s.nodeName))return!1;e=s,t=i<0?O(e):0}}else return!1}}function O(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function y(e){return e.nodeType==1}function C(e){return e.nodeType==3}function ne(e,t){return t?e.contains(y(t)?t:t.parentNode):!1}function Be(e,t){for(;;){if(C(e)&&t)return e;if(y(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=O(e)}else if(e.parentNode&&!pe(e,!0))t=M(e),e=e.parentNode;else return null}}function Ie(e,t){for(;;){if(C(e)&&t<e.nodeValue.length)return e;if(y(e)&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!pe(e,!0))t=M(e)+1,e=e.parentNode;else return null}}function $n(e,t,n){for(let o=t==0,i=t==O(e);o||i;){if(e==n)return!0;let s=M(e);if(e=e.parentNode,!e)return!1;o&&=s==0,i&&=s==O(e)}}function pe(e,t=!1){let n;for(let o=e;o&&!(n=o.pmViewDesc);o=o.parentNode);return n&&n.node&&(!t||n.node.isBlock)&&(n.dom==e||n.contentDOM==e)}function Ae(e){return e.focusNode&&ue(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)}function ft(e,t){e.collapse(t.anchorNode,t.anchorOffset),(t.focusNode!=t.anchorNode||t.focusOffset!=t.anchorOffset)&&e.extend(t.focusNode,t.focusOffset)}function qn(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function Kn(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Wn(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(O(o.offsetNode),o.offset)}}catch{}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(O(o.startContainer),o.startOffset)}}}var z=typeof navigator<"u"?navigator:null,ut=typeof document<"u"?document:null,oe=z&&z.userAgent||"",B=/gecko\/(\d+)/i.test(oe)&&!/edge?\//i.test(oe);B&&+(/Firefox\/(\d+)/.exec(oe)||[0,0])[1];var Le=/Chrome\/(\d+)/.exec(oe),A=!!Le,pt=Le?+Le[1]:0,k=!!z&&/Apple Computer/.test(z.vendor),ie=k&&(/Mobile\/\w+/.test(oe)||!!z&&z.maxTouchPoints>2),R=ie||(z?/Mac/.test(z.platform):!1),mt=z?/Win/.test(z.platform):!1,K=/Android \d/.test(oe),Pe=!!ut&&"webkitFontSmoothing"in ut.documentElement.style,Hn=Pe?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Gn(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function W(e,t){return typeof e=="number"?e:e[t]}function jn(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function gt(e,t,n){for(;;)if(n<0?t:t<O(e)){if(C(e))return $(F(e,t+(n<0?-1:0),t+ +(n>0)),-n);let o=e.childNodes[n<0?t-1:t];if(C(o))e=o,t=n<0?o.nodeValue.length:0;else return y(o)?$(o,-n):null}else{if(pe(e,!0)||!e.parentNode)return null;t=M(e)+(n<0?0:1),e=e.parentNode}}function bt(e,t,n){if(!ze(t)&&t.left==0)return;let o=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,s=e.dom.ownerDocument;for(let r=n||e.dom;r;){if(!y(r)){r=te(r);continue}let l=r==s.body,d=l?Gn(s):jn(r),c=0,a=0;if(t.top<d.top+W(o,"top")?a=-(d.top-t.top+W(i,"top")):t.bottom>d.bottom-W(o,"bottom")&&(a=t.bottom-t.top>d.bottom-d.top?t.top+W(i,"top")-d.top:t.bottom-d.bottom+W(i,"bottom")),t.left<d.left+W(o,"left")?c=-(d.left-t.left+W(i,"left")):t.right>d.right-W(o,"right")&&(c=t.right-d.right+W(i,"right")),c||a)if(l)s.defaultView.scrollBy(c,a);else{let f=r.scrollLeft,p=r.scrollTop;a&&(r.scrollTop+=a),c&&(r.scrollLeft+=c);let g=r.scrollLeft-f,u=r.scrollTop-p;t={left:t.left-g,top:t.top-u,right:t.right-g,bottom:t.bottom-u}}let h=l?"fixed":getComputedStyle(r).position;if(/^(fixed|sticky)$/.test(h))break;r=h=="absolute"?r.offsetParent:te(r)}}function Yn(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),o,i;for(let s=(t.left+t.right)/2,r=n+1;r<Math.min(innerHeight,t.bottom);r+=5){let l=e.root.elementFromPoint(s,r);if(!l||l==e.dom||!e.dom.contains(l))continue;let d=l.getBoundingClientRect();if(d.top>=n-20){o=l,i=d.top;break}}return{refDOM:o,refTop:i,stack:yt(e.dom)}}function yt(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=te(o));return t}function _n({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;vt(n,o==0?0:o-t)}function vt(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:i,left:s}=e[n];o.scrollTop!=i+t&&(o.scrollTop=i+t),o.scrollLeft!=s&&(o.scrollLeft=s)}}var se=null;function wt(e){if(e.setActive)return e.setActive();if(se)return e.focus(se);let t=yt(e);e.focus(se==null?{get preventScroll(){return se={preventScroll:!0},!0}}:void 0),se||(se=!1,vt(t,0))}function Dt(e,t){let n,o=2e8,i,s=0,r=t.top,l=t.top,d,c;for(let a=e.firstChild,h=0;a;a=a.nextSibling,h++){let f;if(y(a))f=a.getClientRects();else if(C(a))f=F(a).getClientRects();else continue;for(let p=0;p<f.length;p++){let g=f[p];if(g.top<=r&&g.bottom>=l){r=Math.max(g.bottom,r),l=Math.min(g.top,l);let u=g.left>t.left?g.left-t.left:g.right<t.left?t.left-g.right:0;if(u<o){n=a,o=u,i=u&&C(n)?{left:g.right<t.left?g.right:g.left,top:t.top}:t,y(a)&&u&&(s=h+ +(t.left>=(g.left+g.right)/2));continue}}else g.top>t.top&&!d&&g.left<=t.left&&g.right>=t.left&&(d=a,c={left:Math.max(g.left,Math.min(g.right,t.left)),top:g.top});!n&&(t.left>=g.right&&t.top>=g.top||t.left>=g.left&&t.top>=g.bottom)&&(s=h+1)}}return!n&&d&&(n=d,i=c,o=0),n&&C(n)?Xn(n,i):!n||o?{node:e,offset:s}:Dt(n,i)}function Xn(e,t){let n=e.nodeValue.length,o=document.createRange(),i;for(let s=0;s<n;s++){o.setEnd(e,s+1),o.setStart(e,s);let r=$(o,1);if(r.top!=r.bottom&&Fe(t,r)){i={node:e,offset:s+ +(t.left>=(r.left+r.right)/2)};break}}return o.detach(),i||{node:e,offset:0}}function Fe(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Jn(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Un(e,t,n){let{node:o,offset:i}=Dt(t,n),s=-1;if(y(o)&&!o.firstChild){let r=o.getBoundingClientRect();s=r.left!=r.right&&n.left>(r.left+r.right)/2?1:-1}return{pos:e.docView.posFromDOM(o,i,s),affinity:Ct(o,i,n)}}function Nt(e,t){return e<t.left?t.left-e:e>t.right?e-t.right:0}function Ct(e,t,n){let o=gt(e,t,-1),i=gt(e,t,1);return o?i?o.bottom<=i.top?n.top>(o.bottom+i.top)/2?1:-1:Nt(n.left,o)<Nt(n.left,i)?-1:1:-1:1}function Qn(e,t,n,o){let i=-1;for(let s=t;s!=e.dom;){let r=e.docView.nearestDesc(s,!0),l;if(!r)return null;if(y(r.dom)&&((l=r.dom.getBoundingClientRect()).width||l.height)){if(!r.contentDOM&&!r.node.isText&&o.left>=l.left&&o.left<=l.right&&o.top>=l.top&&o.top<=l.bottom){let d=r.node.isBlock?o.top<(l.top+l.bottom)/2:o.left<(l.left+l.right)/2;return{pos:d?r.posBefore:r.posAfter,affinity:d?1:-1}}r.node.isBlock&&r.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(r.dom.nodeName)&&(o.top<l.top||o.top>l.bottom)&&(i=o.top<l.top?r.posBefore:r.posAfter)}s=r.dom.parentNode}return i>-1?{pos:i,affinity:0}:{pos:e.docView.posFromDOM(t,n,-1),affinity:Ct(t,n,o)}}function St(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let i=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let r=e.childNodes[s];if(y(r)){let l=r.getClientRects();for(let d=0;d<l.length;d++){let c=l[d];if(Fe(t,c))return St(r,t,c)}}if((s=(s+1)%o)==i)break}return e}function Zn(e,t){let n=e.dom.ownerDocument,o,i=0,s=Wn(n,t.left,t.top);s&&({node:o,offset:i}=s);let r=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),l,d=0;if(!r||!e.dom.contains(r)){let a=e.dom.getBoundingClientRect();if(!Fe(t,a)||(r=St(e.dom,t,a),!r))return null}if(k)for(let a=r;o&&a;a=te(a))a.draggable&&(o=void 0);if(r=Jn(r,t),o){if(B&&y(o)&&(i=Math.min(i,o.childNodes.length),i<o.childNodes.length)){let h=o.childNodes[i],f;h.nodeName=="IMG"&&(f=h.getBoundingClientRect()).right<=t.left&&f.bottom>t.top&&i++}let a;if(Pe&&i&&y(o)&&y(a=o.childNodes[i-1])&&a.contentEditable=="false"&&a.getBoundingClientRect().top>=t.top&&i--,o==e.dom&&i==o.childNodes.length-1&&y(o.lastChild)&&t.top>o.lastChild.getBoundingClientRect().bottom)l=e.state.doc.content.size;else if(i==0||!y(o)||o.childNodes[i-1].nodeName!="BR"){let h=Qn(e,o,i,t);h&&({pos:l,affinity:d}=h)}}l??({pos:l,affinity:d}=Un(e,r,t));let c=e.docView.nearestDesc(r,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1,affinity:d}}function ze(e){return e.top<e.bottom||e.left<e.right}function $(e,t){let n=e.getClientRects();if(n.length){let o=n[t<0?0:n.length-1];if(ze(o))return o}return Array.prototype.find.call(n,ze)||e.getBoundingClientRect()}var eo=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function xt(e,t,n){let{node:o,offset:i,atom:s}=e.docView.domFromPos(t,n<0?-1:1),r=Pe||B;if(C(o)){if(r&&(eo.test(o.nodeValue)||(n<0?!i:i==o.nodeValue.length))){let l=$(F(o,i,i),n);if(B&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){let d=$(F(o,i-1,i-1),-1);if(d.top==l.top){let c=$(F(o,i,i+1),-1);if(c.top!=l.top)return me(c,c.left<d.left)}}return l}{let l=i,d=i,c=n<0?1:-1;return n<0&&!i?(d++,c=-1):n>=0&&i==o.nodeValue.length?(l--,c=1):n<0?l--:d++,me($(F(o,l,d),c),c<0)}}if(!e.state.doc.resolve(t-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==O(o))){let l=o.childNodes[i-1];if(y(l))return $e(l.getBoundingClientRect(),!1)}if(s==null&&i<O(o)){let l=o.childNodes[i];if(y(l))return $e(l.getBoundingClientRect(),!0)}return $e(o.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==O(o))){let l=o.childNodes[i-1],d=C(l)?F(l,O(l)-+!r):y(l)&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(d)return me($(d,1),!1)}if(s==null&&i<O(o)){let l=o.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let d=l?C(l)?F(l,0,+!r):y(l)?l:null:null;if(d)return me($(d,-1),!0)}return me($(C(o)?F(o):o,-n),n>=0)}function me(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function $e(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Ot(e,t,n){let o=e.state,i=e.root.activeElement;o!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),i!=e.dom&&i&&i.focus()}}function to(e,t,n){let o=t.selection,i=n=="up"?o.$from:o.$to;return Ot(e,t,()=>{let{node:s}=e.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=e.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let r=xt(e,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let d;if(y(l))d=l.getClientRects();else if(C(l))d=F(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<d.length;c++){let a=d[c];if(a.bottom>a.top+1&&(n=="up"?r.top-a.top>(a.bottom-r.top)*2:a.bottom-r.bottom>(r.bottom-a.top)*2))return!1}}return!0})}var no=/[\u0590-\u08ac]/;function oo(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let i=o.parentOffset,s=!i,r=i==o.parent.content.size,l=e.domSelection();return l?!no.test(o.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:r:Ot(e,t,()=>{let d=e.domSel.readRange(),c=l.caretBidiLevel;l.modify("move",n,"character");let a=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:h,focusOffset:f}=e.domSel.readRange(),p=h&&!ne(a,h)||d.focusNode==h&&d.focusOffset==f;return ft(l,d),c!=null&&(l.caretBidiLevel=c),p}):o.pos==o.start()||o.pos==o.end()}var Mt=null,kt=null,Tt=!1;function io(e,t,n){return Mt==t&&kt==n?Tt:(Mt=t,kt=n,Tt=n=="up"||n=="down"?to(e,t,n):oo(e,t,n))}var ge=class{constructor(e,t,n,o){this.parent=e,this.children=t,this.dom=n,this.contentDOM=o,this.damage=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let o=this.children[t];if(o==e)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&ne(this.contentDOM,e)){if(n<0){let i,s;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}{let i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}}let o;if(e==this.dom&&this.contentDOM)o=t>M(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);o=i&16?t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):!(i&4)}else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(n&&(s=i.nodeDOM)&&!(y(s)?ne(s,e):s==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let o=this.children[t],i=n+o.size;if(n==e&&i!=n){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let r=o.children[s];if(r.size){o=r;break}}return o}if(e<i)return o.descAt(e-n-o.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,o=0;for(let i=0;n<this.children.length;n++){let s=this.children[n],r=i+s.size;if(r>e){o=e-i;break}i=r}if(o)return this.children[n].domFromPos(o-this.children[n].border,t);for(;n>0;n--){let i=this.children[n-1];if(i.size||!(i instanceof Et||i instanceof At&&i.side>=0))break}if(t<=0){let i,s=!0;for(;i=n?this.children[n-1]:null,!(!i||i.dom.parentNode==this.contentDOM);n--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?M(i.dom)+1:0}}{let i,s=!0;for(;i=n<this.children.length?this.children[n]:null,!(!i||i.dom.parentNode==this.contentDOM);n++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?M(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=n,r=0;;r++){let l=this.children[r],d=s+l.size;if(o==-1&&e<=d){let c=s+l.border;if(e>=c&&t<=d-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,c);e=s;for(let a=r;a>0;a--){let h=this.children[a-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=M(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(d>t||r==this.children.length-1)){t=d;for(let c=r+1;c<this.children.length;c++){let a=this.children[c];if(a.size&&a.dom.parentNode==this.contentDOM&&!a.emptyChildAt(-1)){i=M(a.dom);break}t+=a.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=d}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(!y(t)||n==t.childNodes.length)throw RangeError("No node after pos "+e);return t.childNodes[n]}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDamage(e){e&&(this.damage|=e,this.markParentDamage())}markParentDamage(){for(let e=this;;){let{parent:t}=e;if(!t||t.damage&1)break;t.damage|=1,e=t}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},At=class extends ge{constructor(e,t,n,o){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let r=y(s)?s:document.createElement("span");r!=s&&(r.appendChild(s),s=r),r.hasAttribute("contenteditable")||(r.contentEditable="false"),r.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return!this.damage&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},so=class extends ge{constructor(e,t,n,o){super(e,[],t,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},be=class st extends ge{constructor(t,n,o,i,s){super(t,[],o,i),this.mark=n,this.spec=s}static create(t,n,o,i){let s=i.nodeViews[n.type.name],r=s&&s(n,i,o);return(!r||!r.dom)&&(r=Te.renderSpec(document,n.type.spec.toDOM(n,o),null,n.attrs)),new st(t,n,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.damage&4||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return!(this.damage&4)&&this.mark.eq(t)}markDamage(t){var n;this.damage|=t,(n=this.parent)==null||n.markDamage(2)}slice(t,n,o){let i=st.create(this.parent,this.mark,!0,o),s=this.children,r=this.size;n<r&&(s=We(s,n,r,o)),t>0&&(s=We(s,0,t,o));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},re=class En extends ge{constructor(t,n,o,i,s,r,l){super(t,[],s,r),this.node=n,this.outerDeco=o,this.innerDeco=i,this.nodeDOM=l}static create(t,n,o,i,s,r){let l=s.nodeViews[n.type.name],d,c=l&&l(n,s,()=>{if(!d)return r;if(d.parent)return d.parent.posBeforeChild(d)},o,i),a=c&&c.dom,h=c&&c.contentDOM;if(n.isText){if(!a)a=document.createTextNode(n.text);else if(!C(a))throw RangeError("Text must be rendered as a DOM text node")}else a||({dom:a,contentDOM:h}=Te.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&a.nodeName!="BR"&&(a.hasAttribute("contenteditable")||(a.contentEditable="false"),n.type.spec.draggable&&(a.draggable=!0));let f=a;return a=Bt(a,o,n),c?d=new Vt(t,n,o,i,a,h||null,f,c):n.isText?new qe(t,n,o,i,a,f):new En(t,n,o,i,a,h||null,f)}parseRule(t){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let o=this.children.length-1;o>=0;o--){let i=this.children[o];if(this.dom.contains(i.dom.parentNode)){n.contentElement=i.dom.parentNode;break}}if(!n.contentElement){let o=t&&t.find(i=>y(i)&&t.indexOf(i.parentNode)<0&&this.dom.contains(i));o?n.contentElement=o:n.getContent=()=>q.empty}}return n}matchesNode(t,n,o){return!this.damage&&t.eq(this.node)&&Ee(n,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(t,n){let o=this.node.inlineContent,i=n,s=t.composing?this.localCompositionInfo(t,n):null,r=s&&s.pos>-1?s:null,l=s&&s.pos<0,d=new lo(this,r&&r.node,t),c=this.node.inlineContent,a=c&&this.node.isBlock;ho(this.node,this.innerDeco,(h,f,p)=>{h.spec.marks?d.syncToMarks(h.spec.marks,o,t,f):h.type.side>=0&&!p&&d.syncToMarks(f==this.node.childCount?In.none:this.node.child(f).marks,o,t,f),d.placeWidget(h,t,i)},(h,f,p,g)=>{d.syncToMarks(h.marks,o,t,g),a&&h.isAtom&&!h.isText&&d.addHackNode("IMG",d.top);let u;d.findNodeMatch(h,f,p,g)||l&&t.state.selection.from>i&&t.state.selection.to<i+h.nodeSize&&(u=d.findIndexWithChild(s.node))>-1&&d.updateNodeAt(h,f,p,u,t,i)||d.updateNextNode(h,f,p,t,g,i)||d.addNode(h,f,p,t,i),i+=h.nodeSize,c&&(a=h.isAtom&&!h.isText)}),d.syncToMarks([],o,t,0),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.damage&2)&&(r&&this.protectLocalComposition(t,r),Rt(this.contentDOM,this.children,t),ie&&fo(this.dom))}localCompositionInfo(t,n){let{from:o,to:i}=t.state.selection;if(!(t.state.selection instanceof S)||o<n||i>n+this.node.content.size)return null;let s=t.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let r=s.nodeValue,l=uo(this.node.content,r,o-n,i-n);return l<0?null:{node:s,pos:l,text:r}}return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:n,pos:o,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let r=new so(this,s,n,i);t.input.compositionNodes.push(r),this.children=We(this.children,o,o+i.length,t,r)}update(t,n,o,i,s){return this.damage&4||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,o,i,s),!0)}updateInner(t,n,o,i,s){this.updateOuterDeco(n),this.node=t,this.innerDeco=o,this.contentDOM&&this.updateChildren(i,s+1),this.damage=0}updateOuterDeco(t){if(Ee(t,this.outerDeco))return;let n=!y(this.nodeDOM),o=this.dom;this.dom=Ke(this.dom,this.nodeDOM,ve(this.outerDeco,this.node,n),ve(t,this.node,n)),this.dom!=o&&(o.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){y(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){y(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Pt(e,t,n,o,i,s){s?Ke(o,o,ve(s,e,!1),ve(t,e,!1)):Bt(o,t,e);let r=new re(void 0,e,t,n,o,o,o);return r.contentDOM&&r.updateChildren(i,0),r}var qe=class Vn extends re{constructor(t,n,o,i,s,r){super(t,n,o,i,s,null,r)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,n,o,i){return this.damage&4||this.damage&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.damage&8||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=t,this.damage=0,!0)}inParent(){let t=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,n,o){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(t,n,o)}ignoreMutation(t){return!1}slice(t,n,o){let i=this.node.cut(t,n),s=document.createTextNode(i.text);return new Vn(this.parent,i,this.outerDeco,this.innerDeco,s,s)}get domAtom(){return!1}isText(t){return this.node.text==t}},Et=class extends ge{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Vt=class extends re{constructor(e,t,n,o,i,s,r,l){super(e,t,n,o,i,s,r),this.spec=l}update(e,t,n,o,i){if(this.damage&4)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,o,i),s}return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,o,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Rt(e,t,n){let o=e.firstChild,i=!1;for(let s=0;s<t.length;s++){let r=t[s],l=r.dom;if(l.parentNode==e){for(;l!=o;)o=It(o),i=!0;o=o.nextSibling}else i=!0,e.insertBefore(l,o);if(r instanceof be){let d=o?o.previousSibling:e.lastChild;Rt(r.contentDOM,r.children,n),o=d?d.nextSibling:e.firstChild}}for(;o;)o=It(o),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var ye=function(e){e&&(this.nodeName=e)};ye.prototype=Object.create(null);var Q=[new ye];function ve(e,t,n){if(e.length==0)return Q;let o=n?Q[0]:new ye,i=[o];for(let s=0;s<e.length;s++){let r=e[s].type.attrs;if(r){r.nodeName&&i.push(o=new ye(r.nodeName));for(let l in r){let d=r[l];d!=null&&(n&&i.length==1&&i.push(o=new ye(t.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+d:l=="style"?o.style=(o.style?o.style+";":"")+d:l!="nodeName"&&(o[l]=d))}}}return i}function Ke(e,t,n,o){if(n==Q&&o==Q)return t;let i=t;for(let s=0;s<o.length;s++){let r=o[s],l=n[s];if(s){let d;l&&l.nodeName==r.nodeName&&i!=e&&(d=i.parentNode)&&d.nodeName.toLowerCase()==r.nodeName||(d=document.createElement(r.nodeName),d.pmIsDeco=!0,d.appendChild(i),l=Q[0]),i=d}ro(i,l||Q[0],r)}return i}function ro(e,t,n){for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&!(o in n)&&e.removeAttribute(o);for(let o in n)o!="class"&&o!="style"&&o!="nodeName"&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){let o=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<o.length;s++)i.indexOf(o[s])==-1&&e.classList.remove(o[s]);for(let s=0;s<i.length;s++)o.indexOf(i[s])==-1&&e.classList.add(i[s]);e.classList.length==0&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=o.exec(t.style);)e.style.removeProperty(i[1])}n.style&&(e.style.cssText+=n.style)}}function Bt(e,t,n){return Ke(e,e,Q,ve(t,n,!y(e)))}function Ee(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function It(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var lo=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ao(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,o){let i=0,s=this.stack.length>>1,r=Math.min(s,e.length);for(;i<r&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.damage=0,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,d=this.top.children.length;o<this.preMatch.index&&(d=Math.min(this.index+3,d));for(let c=this.index;c<d;c++){let a=this.top.children[c];if(a.matchesMark(e[s])&&!this.isLocked(a.dom)){l=c;break}}if(l<0&&this.index<this.top.children.length){let c=this.top.children[this.index];c instanceof be&&!(c.damage&4)&&c.mark.type==e[s].type&&c.spec.update&&!this.isLocked(c.dom)&&c.spec.update(e[s])&&(c.mark=e[s],l=this.index,this.changed=!0)}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=be.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))i=this.top.children.indexOf(s,this.index);else for(let r=this.index,l=Math.min(this.top.children.length,r+5);r<l;r++){let d=this.top.children[r];if(d.matchesNode(e,t,n)&&!this.preMatch.matched.has(d)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,o,i,s){let r=this.top.children[o];return r.damage&4&&r.dom==r.contentDOM&&(r.damage=2),r.update(e,t,n,i,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==n)return o}return-1}e=t}}updateNextNode(e,t,n,o,i,s){for(let r=this.index;r<this.top.children.length;r++){let l=this.top.children[r];if(l instanceof re){let d=this.preMatch.matched.get(l);if(d!=null&&d!=i)return!1;let c=l.dom,a,h=this.isLocked(c)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&!(l.damage&4)&&Ee(t,l.outerDeco));if(!h&&l.update(e,t,n,o,s))return this.destroyBetween(this.index,r),l.dom!=c&&(this.changed=!0),this.index++,!0;if(!h&&(a=this.recreateWrapper(l,e,t,n,o,s)))return this.destroyBetween(this.index,r),this.top.children[this.index]=a,a.contentDOM&&(a.damage|=2,a.updateChildren(o,s+1),a.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,o,i,s){if(e.damage&3||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ee(n,e.outerDeco)||!o.eq(e.innerDeco))return null;let r=re.create(this.top,t,n,o,i,s);if(r.contentDOM){r.children=e.children,e.children=[];for(let l of r.children)l.parent=r}return e.destroy(),r}addNode(e,t,n,o,i){let s=re.create(this.top,e,t,n,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new At(this.top,e,t,n);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof be;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof qe)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((k||A)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let o=new Et(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,o):t.children.push(o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||y(e)&&e.contains(this.lock.parentNode))}};function ao(e,t){let n=t,o=n.children.length,i=[],s=e.childCount,r=new Map,l=[];e:for(;s>0;){let d;for(;;)if(o){let a=n.children[o-1];if(a instanceof be)i.push(o-1),n=a,o=a.children.length;else{d=a,o--;break}}else{if(n==t)break e;o=i.pop(),n=n.parent}let c=d.node;if(c){if(c!=e.child(s-1))break;--s,r.set(d,s),l.push(d)}}return{index:s,matched:r,matches:l.reverse()}}function co(e,t){return e.type.side-t.type.side}function ho(e,t,n,o){let i=t.locals(e),s=0;if(i.length==0){for(let c=0;c<e.childCount;c++){let a=e.child(c);o(a,i,t.forChild(s,a),c),s+=a.nodeSize}return}let r=0,l=[],d=null;for(let c=0;;){let a,h;for(;r<i.length&&i[r].to==s;){let m=i[r++];m.widget&&(a?(h||=[a]).push(m):a=m)}if(a)if(h){h.sort(co);for(let m=0;m<h.length;m++)n(h[m],c,!!d)}else n(a,c,!!d);let f,p;if(d)p=-1,f=d,d=null;else if(c<e.childCount)p=c,f=e.child(c++);else break;for(let m=0;m<l.length;m++)l[m].to<=s&&l.splice(m--,1);for(;r<i.length&&i[r].from<=s&&i[r].to>s;)l.push(i[r++]);let g=s+f.nodeSize;if(f.isText){let m=g;r<i.length&&i[r].from<m&&(m=i[r].from);for(let b=0;b<l.length;b++)l[b].to<m&&(m=l[b].to);m<g&&(d=f.cut(m-s),f=f.cut(0,m-s),g=m,p=-1)}else for(;r<i.length&&i[r].to<g;)r++;let u=f.isInline&&!f.isLeaf?l.filter(m=>!m.inline):l.slice();o(f,u,t.forChild(s,f),p),s=g}}function fo(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function uo(e,t,n,o){for(let i=0,s=0;i<e.childCount&&s<=o;){let r=e.child(i++),l=s;if(s+=r.nodeSize,!r.isText)continue;let d=r.text;for(;i<e.childCount;){let c=e.child(i++);if(s+=c.nodeSize,!c.isText)break;d+=c.text}if(s>=n){if(s>=o&&d.slice(o-t.length-l,o-l)==t)return o-t.length;let c=l<o?d.lastIndexOf(t,o-l-1):-1;if(c>=0&&c+t.length+l>=n)return l+c;if(n==o&&d.length>=o+t.length-l&&d.slice(o-l,o-l+t.length)==t)return o}}return-1}function We(e,t,n,o,i){let s=[];for(let r=0,l=0;r<e.length;r++){let d=e[r],c=l,a=l+=d.size;c>=n||a<=t?s.push(d):(c<t&&s.push(d.slice(0,t-c,o)),i&&=(s.push(i),void 0),a>n&&s.push(d.slice(n-c,d.size,o)))}return s}function He(e,t){let{$anchor:n,$head:o}=e.selection,i=t>0?n.max(o):n.min(o),s=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return s&&fe.findFrom(s,t)}function H(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Lt(e,t,n){let o=e.state.selection;if(o instanceof S){if(n.indexOf("s")>-1){let{$head:i}=o,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let r=e.state.doc.resolve(i.pos+s.nodeSize*(t<0?-1:1));return H(e,new S(o.$anchor,r))}if(!o.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let i=He(e.state,t);return i&&i instanceof v?H(e,i):!1}if(!R||n.indexOf("m")<0){let i=o.$head,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter,r;if(!s||s.isText)return!1;let l=t<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(r=e.docView.descAt(l))&&!r.contentDOM?v.isSelectable(s)?H(e,new v(t<0?e.state.doc.resolve(i.pos-s.nodeSize):i)):H(e,new S(e.state.doc.resolve(t<0?l:l+s.nodeSize))):!1}}else{if(o instanceof v&&o.node.isInline)return H(e,new S(t>0?o.$to:o.$from));{let i=He(e.state,t);return i?H(e,i):!1}}}function we(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR"):y(e)&&e.contentEditable=="false"}function le(e,t){return t<0?po(e):mo(e)}function po(e){let t=e.domSel.readRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let i,s,r=!1;for(B&&y(n)&&o<O(n)&&we(n.childNodes[o],-1)&&(r=!0);;)if(o>0){if(!y(n))break;let l=n.childNodes[o-1];if(we(l,-1))i=n,s=--o;else if(C(l))n=l,o=n.nodeValue.length;else break}else{if(Ft(n))break;{let l=n.previousSibling;for(;l&&we(l,-1);)i=n.parentNode,s=M(l),l=l.previousSibling;if(l)n=l,o=O(n);else{if(n=n.parentNode,n==e.dom)break;o=0}}}r?Ge(e,n,o):i&&Ge(e,i,s)}function mo(e){let t=e.domSel.readRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let i=O(n),s,r;for(;;)if(o<i){if(!y(n))break;let l=n.childNodes[o];if(we(l,1))s=n,r=++o;else break}else{if(Ft(n))break;{let l=n.nextSibling;for(;l&&we(l,1);)s=l.parentNode,r=M(l)+1,l=l.nextSibling;if(l)n=l,o=0,i=O(n);else{if(n=n.parentNode,n==e.dom)break;o=i=0}}}s&&Ge(e,s,r)}function Ft(e){for(let t=e;t;t=t.parentNode){let n=t.pmViewDesc;if(n)return n.node?n.node.isBlock:!1}return!1}function Ge(e,t,n){if(!C(t)){let r,l;(l=Ie(t,n))?(t=l,n=0):(r=Be(t,n))&&(t=r,n=r.nodeValue.length)}let o=e.domSelection(),i=e.domSel.readRange();if(!o)return;Ae(i)?o.collapse(t,n):o.extend&&(o.collapse(i.anchorNode,i.anchorOffset),o.extend(t,n)),e.domSel.ignore();let{state:s}=e;setTimeout(()=>{e.state==s&&e.domSel.sync()},50)}function zt(e,t){let n=e.state.doc.resolve(t);if(!(A||mt)&&n.parent.inlineContent){let i=e.coordsAtPos(t);if(t>n.start()){let s=e.coordsAtPos(t-1),r=(s.top+s.bottom)/2;if(r>i.top&&r<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(t<n.end()){let s=e.coordsAtPos(t+1),r=(s.top+s.bottom)/2;if(r>i.top&&r<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}let o=e.dom;for(let i=n.depth;i>0;i--)if(n.node(i).isBlock){o=e.nodeDOM(n.before(i))||o;break}return getComputedStyle(o).direction=="rtl"?"rtl":"ltr"}function $t(e,t,n){let o=e.state.selection;if(o instanceof S&&!o.empty||n.indexOf("s")>-1||R&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=o;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let r=He(e.state,t);if(r&&r instanceof v)return H(e,r)}if(!i.parent.inlineContent){let r=t<0?i:s,l=o instanceof Fn?fe.near(r,t):fe.findFrom(r,t);return l?H(e,l):!1}return!1}function qt(e,t){if(!(e.state.selection instanceof S))return!0;let{$head:n,$anchor:o,empty:i}=e.state.selection;if(!n.sameParent(o))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=e.state.tr;return t<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),e.dispatch(r),!0}return!1}function Kt(e,t,n){e.domObserver.stopped(()=>t.contentEditable=n)}function go(e){if(!k||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSel.readRange();if(t&&y(t)&&n==0&&t.firstChild&&y(t.firstChild)&&t.firstChild.contentEditable=="false"){let o=t.firstChild;Kt(e,o,"true"),setTimeout(()=>Kt(e,o,"false"),20)}return!1}function bo(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function yo(e,t){let n=t.keyCode,o=bo(t);if(n==8||R&&n==72&&o=="c")return qt(e,-1)||le(e,-1);if(n==46&&!t.shiftKey||R&&n==68&&o=="c")return qt(e,1)||le(e,1);if(n==13||n==27)return!0;if(n==37||R&&n==66&&o=="c"){let i=n==37?zt(e,e.state.selection.from)=="ltr"?-1:1:-1;return Lt(e,i,o)||le(e,i)}if(n==39||R&&n==70&&o=="c"){let i=n==39?zt(e,e.state.selection.from)=="ltr"?1:-1:1;return Lt(e,i,o)||le(e,i)}return n==38||R&&n==80&&o=="c"?$t(e,-1,o)||le(e,-1):n==40||R&&n==78&&o=="c"?go(e)||$t(e,1,o)||le(e,1):!(o!=(R?"m":"c")||n!=66&&n!=73&&n!=89&&n!=90)}function je(e,t){e.someProp("transformCopied",f=>{t=f(t,e)});let n=[],{content:o,openStart:i,openEnd:s}=t;for(;i>1&&s>1&&o.childCount==1&&o.firstChild.childCount==1;){i--,s--;let f=o.firstChild;n.push(f.type.name,f.attrs==f.type.defaultAttrs?null:f.attrs),o=f.content}let r=e.someProp("clipboardSerializer")||Te.fromSchema(e.state.schema),l=_t(),d=l.createElement("div");d.appendChild(r.serializeFragment(o,{document:l}));let c=d.firstChild,a,h=0;for(;c&&y(c)&&(a=Yt[c.nodeName.toLowerCase()]);){for(let f=a.length-1;f>=0;f--){let p=l.createElement(a[f]);for(;d.firstChild;)p.appendChild(d.firstChild);d.appendChild(p),h++}c=d.firstChild}return c&&y(c)&&c.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:d,text:e.someProp("clipboardTextSerializer",f=>f(t,e))||t.content.textBetween(0,t.content.size,`
2
+
3
+ `),slice:t}}function Ye(e,t,n,o,i){let s=i.parent.type.spec.code,r,l;if(!n&&!t)return null;let d=!!t&&(o||s||!n);if(d){if(e.someProp("transformPastedText",f=>{t=f(t,s||o,e)}),s)return l=new U(q.from(e.state.schema.text(t.replace(/\r\n?/g,`
4
+ `))),0,0),e.someProp("transformPasted",f=>{l=f(l,e,!0)}),l;let h=e.someProp("clipboardTextParser",f=>f(t,i,o,e));if(h)l=h;else{let f=i.marks(),{schema:p}=e.state,g=Te.fromSchema(p);r=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(u=>{let m=r.appendChild(document.createElement("p"));u&&m.appendChild(g.serializeNode(p.text(u,f)))})}}else e.someProp("transformPastedHTML",h=>{n=h(n,e)}),r=No(n),Pe&&Co(r);let c=r&&r.querySelector("[data-pm-slice]"),a=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(a&&a[3])for(let h=+a[3];h>0;h--){let f=r.firstChild;for(;f&&!y(f);)f=f.nextSibling;if(!f)break;r=f}if(l||=(e.someProp("clipboardParser")||e.someProp("domParser")||at.fromSchema(e.state.schema)).parseSlice(r,{preserveWhitespace:!!(d||a),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!vo.test(h.parentNode.nodeName)?{ignore:!0}:null}}),a)l=So(jt(l,+a[1],+a[2]),a[4]);else if(l=U.maxOpen(wo(l.content,i),!0),l.openStart||l.openEnd){let h=0,f=0;for(let p=l.content.firstChild;h<l.openStart&&!p.type.spec.isolating;h++,p=p.firstChild);for(let p=l.content.lastChild;f<l.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);l=jt(l,h,f)}return e.someProp("transformPasted",h=>{l=h(l,e,o)}),l}var vo=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function wo(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o=t.node(n).contentMatchAt(t.index(n)),i,s=[];if(e.forEach(r=>{if(!s)return;let l=o.findWrapping(r.type),d;if(!l)return s=null;if(d=s.length&&i.length&&Ht(l,i,r,s[s.length-1],0))s[s.length-1]=d;else{s.length&&(s[s.length-1]=Gt(s[s.length-1],i.length));let c=Wt(r,l);s.push(c),o=o.matchType(c.type),i=l}}),s)return q.from(s)}return e}function Wt(e,t,n=0){for(let o=t.length-1;o>=n;o--)e=t[o].create(null,q.from(e));return e}function Ht(e,t,n,o,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let s=Ht(e,t,n,o.lastChild,i+1);if(s)return o.copy(o.content.replaceChild(o.childCount-1,s));if(o.contentMatchAt(o.childCount).matchType(i==e.length-1?n.type:e[i+1]))return o.copy(o.content.append(q.from(Wt(n,e,i+1))))}}function Gt(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Gt(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(q.empty,!0);return e.copy(n.append(o))}function _e(e,t,n,o,i,s){let r=t<0?e.firstChild:e.lastChild,l=r.content;return e.childCount>1&&(s=0),i<o-1&&(l=_e(l,t,n,o,i+1,s)),i>=n&&(l=t<0?r.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(q.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,r.copy(l))}function jt(e,t,n){return t<e.openStart&&(e=new U(_e(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new U(_e(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Yt={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function _t(){return document.implementation.createHTMLDocument("title")}var De=null;function Do(e){let t=window.trustedTypes;if(!t)return e;if(!De){if(De=t.defaultPolicy)try{return De.createHTML(e)}catch{}De=t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return De.createHTML(e)}function No(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=_t(),o=n.body,i=/<([a-z][^>\s]+)/i.exec(e),s;if((s=i&&Yt[i[1].toLowerCase()])&&(e=s.map(r=>"<"+r+">").join("")+e+s.map(r=>"</"+r+">").reverse().join("")),o.innerHTML=Do(e),s)for(let r=0;r<s.length;r++)o=o.querySelector(s[r])||o;for(let r=0;r<n.styleSheets.length;r++){let l=n.styleSheets[r];for(let d=0;d<l.rules.length;d++){let c=l.rules[d];if(c instanceof CSSStyleRule){let a=o.querySelectorAll(c.selectorText);for(let h=0;h<a.length;h++)a[h].style.cssText+=c.style.cssText}}}return o}function Co(e){let t=e.querySelectorAll(A?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}function So(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,o;try{o=JSON.parse(t)}catch{return e}let{content:i,openStart:s,openEnd:r}=e;for(let l=o.length-2;l>=0;l-=2){let d=n.nodes[o[l]];if(!d||d.hasRequiredAttrs()||!d.createAndFill(null,i))break;try{i=q.from(d.create(o[l+1],i))}catch{break}s++,r++}return new U(i,s,r)}var I=class rt{constructor(t,n,o,i){this.anchorNode=t,this.anchorOffset=n,this.focusNode=o,this.focusOffset=i}static from(t){return t instanceof rt?t:new rt(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}};I.null=new I(null,0,null,0);var xo=class{constructor(e){this.view=e,this.range=I.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=e,e.addEventListener("selectionchange",this.onSelectionChange))}destroy(){this.currentDocument&&=(this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),null),this.active=!1,this.range=I.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,t=e.dom.isConnected!==!1&&e.domSelection();return t?k&&e.root.nodeType===11&&Kn(e.dom.ownerDocument)==e.dom?I.from(Oo(e,t)||t):I.from(t):I.null}read(){this.ensureListener();let e=nn(this.view);if(!e){this.active=!1,this.range=I.null;return}return this.active=!0,!this.range.eq(e)&&(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:t}=this;t.docView&&(this.ensureListener(),t.domObserver.stopped(()=>{Po(t,t.state.selection);let n=t.state.selection;if(t.input.mouseSelecting||Jt(t)){let{desc:o,start:i}=Ut(t.docView,n.from,n.to,0);t.cursorWrapper?Ao(t):o instanceof Vt&&o.spec.setSelection?o.spec.setSelection(n.anchor-i,n.head-i,t.root):Mo(t,e,o,i),this.synced=this.active=!0}n.visible==t.dom.classList.contains("ProseMirror-hideselection")&&(n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),To(t))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=I.from(e),this.synced=!0}deactivate(){this.range=I.null,this.active=this.synced=!1}};function Oo(e,t){if(t.getComposedRanges){let i=t.getComposedRanges({shadowRoots:[e.root]})[0];if(i)return Xt(e,i)}let n;function o(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?Xt(e,n):null}function Xt(e,t){let n=t.startContainer,o=t.startOffset,i=t.endContainer,s=t.endOffset,r=e.domAtPos(e.state.selection.anchor);return ue(r.node,r.offset,i,s)&&([n,o,i,s]=[i,s,n,o]),new I(n,o,i,s)}function Xe(e,t,n=null){let o=e.state.doc;if(!t.focusNode)return null;let i=e.docView.nearestDesc(t.focusNode),s=i&&i.size==0,r=e.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(r<0)return null;let l=o.resolve(r),d,c;if(Ae(t)){for(d=r;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&v.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&$n(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;c=new v(r==h?l:o.resolve(h))}else if(B&&n=="key"&&r>e.state.selection.to&&y(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let h=t.focusNode;;h=h.parentNode){if(getComputedStyle(h).overflow!="visible"){c=fe.findFrom(o.resolve(i.posAtStart),1);break}if(h==i.dom||h.nextSibling||!h.parentNode||!y(h.parentNode))break}}else{if(t instanceof e.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=r,f=r;for(let p=0;p<t.rangeCount;p++){let g=t.getRangeAt(p);h=Math.min(h,e.docView.posFromDOM(g.startContainer,g.startOffset,1)),f=Math.max(f,e.docView.posFromDOM(g.endContainer,g.endOffset,-1))}if(h<0)return null;[d,r]=f==e.state.selection.anchor?[f,h]:[h,f],l=o.resolve(r)}else d=e.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(d<0)return null}let a=o.resolve(d);if(!c){let h=n=="pointer"||e.state.selection.head<l.pos&&!s?1:-1;c=ae(e,a,l,h)}return c}function Jt(e){return e.editable?e.hasFocus():on(e,e.domSel.readRange())&&(!document.activeElement||document.activeElement.contains(e.dom))}function Mo(e,t,n,o){let i=e.state.selection,{anchor:s,head:r}=i,l,d;Qt&&!(i instanceof S)&&(i.$from.parent.inlineContent||(l=Zt(e,i.from)),!i.empty&&!i.$from.parent.inlineContent&&(d=Zt(e,i.to)));let c=n.domFromPos(s-o,s>o?-1:1);ko(s,r,c,r==s?c:n.domFromPos(r-o,r>o?-1:1),e,t),Qt&&(l&&en(l),d&&en(d))}function Ut(e,t,n,o=0){for(let i=0,s=o;i<e.children.length;i++){let r=e.children[i],l=s+r.size;if(t>s&&n<l)return Ut(r,t,n,s+r.border);s=l}return{desc:e,start:o}}function ko(e,t,n,o,i,s){let r=!1;if((B||k)&&e==t){let{node:a,offset:h}=n;if(C(a)){if(r=!!(h&&a.nodeValue[h-1]==`
5
+ `),r&&h==a.nodeValue.length)for(let f=a,p;f;f=f.parentNode){if(p=f.nextSibling){p.nodeName=="BR"&&(n=o={node:p.parentNode,offset:M(p)+1});break}let g=f.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let f=a.childNodes[h-1];r=f&&(f.nodeName=="BR"||f.contentEditable=="false")}}let l=i.domSel.readRange();if(B&&l.focusNode&&l.focusNode!=o.node&&y(l.focusNode)){let a=l.focusNode.childNodes[l.focusOffset];a&&a.contentEditable=="false"&&(s=!0)}if(!(s||r&&k)&&ue(n.node,n.offset,l.anchorNode,l.anchorOffset)&&ue(o.node,o.offset,l.focusNode,l.focusOffset))return;let d=i.domSelection(),c=i.input.mouseSelecting;if(c&&c.affinity&&e==t&&c.pos==e){let{affinity:a}=c,{node:h,offset:f}=o,p,g=0;if(C(h)&&(a>0?f<O(h):f>0)?(p=h,g=f+a):(p=(a>0?Ie:Be)(h,f),p&&(g=a>0?1:p.nodeValue.length-1)),p){d.collapse(p,g),d.modify("move",a>0?"backward":"forward","lineboundary");let{focusNode:u,focusOffset:m}=d;if(k&&i.root.nodeType==11){let b=d.getComposedRanges({shadowRoots:[i.root]});b.length&&(u=b[0].startContainer,m=b[0].startOffset)}if(ue(h,f,u,m))return}}ft(d,{focusNode:o.node,focusOffset:o.offset,anchorNode:n.node,anchorOffset:n.offset})}var Qt=k||A&&pt<63;function Zt(e,t){let{node:n,offset:o}=e.docView.domFromPos(t,0),i=o<n.childNodes.length?n.childNodes[o]:null,s=o?n.childNodes[o-1]:null;if(k&&i&&i.contentEditable=="false")return Je(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Je(i);if(s)return Je(s)}}function Je(e){return e.contentEditable="true",k&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function en(e){e.contentEditable="false",e.wasDraggable&&=(e.draggable=!0,null)}function To(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSel.readRange(),o=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=o||n.anchorOffset!=i)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!Jt(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ao(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom;n.nodeName=="IMG"?t.collapse(n.parentNode,M(n)+1):t.collapse(n,0)}function Po(e,t){if(t instanceof v){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(tn(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else tn(e)}function tn(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function ae(e,t,n,o){let i=e.someProp("createSelectionBetween",s=>s(e,t,n))||S.between(t,n,o);return e.someProp("adjustSelectionFromDOM",s=>{i=s(e,i)}),i}function nn(e){if(e.editable&&!e.hasFocus())return null;let t=e.domSel.readRange();return t&&on(e,t)?t:null}function on(e,t){if(!t.anchorNode)return!1;try{return ne(e.dom,t.anchorNode)&&(e.editable||ne(e.dom,t.focusNode))}catch{return!1}}var P={},E={},Eo={touchstart:!0,touchmove:!0},Vo=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.mouseSelecting=null,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Ro(e){for(let t in P){let n=P[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=o=>{Io(e,o)&&(e.input.composing&&(o.type=="keydown"||o.type=="beforeinput")&&o.isComposing===!1&&hn(e,!0),!Qe(e,o)&&(e.editable||!(o.type in E))&&n(e,o))},Eo[t]?{passive:!0}:void 0)}k&&e.dom.addEventListener("input",()=>null),Ue(e)}function Ve(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Bo(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function Ue(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=o=>Qe(e,o))})}function Qe(e,t){return e.someProp("handleDOMEvents",n=>{let o=n[t.type];return o?o(e,t)||t.defaultPrevented:!1})}function Io(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Lo(e,t){!Qe(e,t)&&P[t.type]&&(e.editable||!(t.type in E))&&P[t.type](e,t)}function G(e,t){let{input:n}=e;return n.lastKeyDispatched||e.composing?!1:(n.lastKeyDispatched=!0,typeof t=="string"&&(t=qn(t=="Backspace"?8:13,t)),e.someProp("handleKeyDown",o=>o(e,t)))}E.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!(K&&A&&n.keyCode==13)){if(ie&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let o=Date.now();e.input.lastIOSEnter=o,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==o&&(G(e,"Enter"),e.input.lastIOSEnter=0)},200);return}n.keyCode!=229&&e.domObserver.forceFlush(!0),G(e,n)||yo(e,n)?n.preventDefault():Ve(e,"key")}},E.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},E.keypress=(e,t)=>{let n=t;if(jo(e)||!n.charCode||n.ctrlKey&&!n.altKey||R&&n.metaKey)return;if(e.someProp("handleKeyPress",i=>i(e,n))){n.preventDefault();return}let o=e.state.selection;if(!(o instanceof S)||!o.$from.sameParent(o.$to)){let i=String.fromCharCode(n.charCode),s=()=>e.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!e.someProp("handleTextInput",r=>r(e,o.$from.pos,o.$to.pos,i,s))&&e.dispatch(s()),n.preventDefault()}};function Ne(e){return{left:e.clientX,top:e.clientY}}function Fo(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}function Ze(e,t,n,o,i){if(o==-1)return!1;let s=e.state.doc.resolve(o);for(let r=s.depth+1;r>0;r--)if(e.someProp(t,l=>r>s.depth?l(e,n,s.nodeAfter,s.before(r),i,!0):l(e,n,s.node(r),s.before(r),i,!1)))return!0;return!1}function sn(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);o.setMeta("pointer",!0),e.dispatch(o)}function zo(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return o&&o.isAtom&&v.isSelectable(o)?(sn(e,new v(n)),!0):!1}function $o(e,t){if(t==-1)return!1;let n=e.state.selection,o,i;n instanceof v&&(o=n.node);let s=e.state.doc.resolve(t);for(let r=s.depth+1;r>0;r--){let l=r>s.depth?s.nodeAfter:s.node(r);if(v.isSelectable(l)){i=o&&n.$from.depth>0&&r>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?s.before(n.$from.depth):s.before(r);break}}return i!=null&&(sn(e,v.create(e.state.doc,i)),!0)}function qo(e,t,n,o,i){return Ze(e,"handleClickOn",t,n,o)||e.someProp("handleClick",s=>s(e,t,o))||(i?$o(e,n):zo(e,n))}function Ko(e,t,n,o){return Ze(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",i=>i(e,t,o))}function Wo(e,t,n,o){return Ze(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",i=>i(e,t,o))}function rn(e,t,n){if(t==-1)return e.inlineContent?S.create(e,0,e.content.size):null;let o=e.resolve(t);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),r=o.before(i);if(s.inlineContent)return S.create(e,r+1,r+1+s.content.size);if(n&&v.isSelectable(s))return v.create(e,r)}return null}var et=/[\w_\u00a1-\uffff]+/g;try{et=RegExp("[\\p{L}\\p{N}_]+","gu")}catch{}function ln(e,t){let n=e.resolve(t),o=n.node(),i="",s=t,r=t;for(let u=n.indexAfter(),m=!1;u>0;u--){let b=o.child(u-1);if(!b.text)break;let N=s==t?t-n.posAtIndex(u-1):b.text.length,w=N;for(;w>0;w--)if(/\S/.test(b.text[w-1]))m=!0;else if(m)break;if(i=b.text.slice(w,N)+i,s-=N-w,w||s<t-50)break}for(let u=n.index(),m=!1;u<o.childCount;u++){let b=o.child(u);if(!b.text)break;let N=r==t?t-n.posAtIndex(u):0,w=N;for(;w<b.text.length;w++)if(/\S/.test(b.text[w]))m=!0;else if(m)break;if(i+=b.text.slice(N,w),r+=w-N,w<b.text.length||r>t+50)break}let l=s,d=r;if(Intl.Segmenter){for(let u of new Intl.Segmenter(void 0,{granularity:"word"}).segment(i))if(u.isWordLike){let m=u.index+s,b=m+u.segment.length;if(b<t)l=b;else if(m>t){d=m;break}else return S.create(e,m,b)}}else{et.lastIndex=0;for(let u;u=et.exec(i);){let m=u.index+s,b=m+u[0].length;if(b<t)l=b;else if(m>t){d=m;break}else return S.create(e,m,b)}}let c=i.slice(l-s,t-s),a=i.slice(t-s,d-s),h=/\S*$/.exec(c)[0].length,f=/^\S*/.exec(a)[0].length;if(h||f)return S.create(e,t-h,t+f);let p=/\s*$/.exec(c)[0].length,g=/^\s*/.exec(a)[0].length;return S.create(e,t-p,t+g)}var an=R?"metaKey":"ctrlKey";P.mousedown=(e,t)=>{let n=t,o=Date.now();if(e.input.shiftKey=n.shiftKey,e.input.lastTouch>o-500)return!1;j(e);let i="singleClick";o-e.input.lastClick.time<500&&Fo(n,e.input.lastClick)&&!n[an]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(Ne(n));if(s)if(n.button==0){if(!e.hasFocus()){wt(e.dom);let r=e.root.activeElement;r&&!r.contains(e.dom)&&r.blur()}(e.input.mouseDown=new Ho(e,s,n,i)).mightDrag||n.preventDefault()}else Ve(e,"pointer")};var Ho=class{constructor(e,t,n,o){this.view=e,this.startPos=t,this.event=n,this.type=o,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!n[an],this.extend=n.shiftKey,this.anchorDoc=this.startDoc;let i=dn(e);if(this.extend){let s=e.state.selection;this.anchorRange=s instanceof v?{from:s.from,to:s.to}:{from:s.anchor,to:s.anchor};let r=s instanceof v?e.nodeDOM(s.from).getBoundingClientRect():e.coordsAtPos(s.anchor);this.anchorOffset={x:(r.left+r.right)/2-i.x,y:(r.top+r.bottom)/2-i.y}}else this.anchorOffset={x:n.clientX-i.x,y:n.clientY-i.y};if(o=="singleClick"){let{selection:s}=e.state,r,l,d=!1;if(s instanceof v&&s.from<=t.pos&&s.to>=t.pos)l=s.from,r=s.node,d=!0;else if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),l=t.inside;else{let c=e.state.doc.resolve(t.pos);r=c.parent,l=c.depth?c.before():-1}if(d||l>-1&&r.type.spec.draggable&&r.type.spec.selectable!==!1){let c=e.docView.descAt(l)?.nodeDOM;this.mightDrag={node:r,elt:c,pos:l,addAttr:!1},c&&!c.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>c.draggable=!0))}else this.mightDrag=Go(e,n)}else this.mightDrag=!1;e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag=="object"&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute("draggable"))}maybeRunHandler(e,t){return(this.type=="singleClick"?qo:this.type=="doubleClick"?Ko:Wo)(this.view,e.pos,e.inside,t,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.startPos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Ne(e))),t&&(this.didMove||this.maybeRunHandler(t,e)||this.select(t,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let t=this.view.posAtCoords(Ne(e));t&&this.select(t,!1)}e.preventDefault()}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:n}=this,{doc:o}=n.state,i=this.type=="singleClick"?cn(n,o,e):this.type=="doubleClick"?ln(o,e.pos):rn(o,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(o.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=ae(n,o.resolve(this.anchorRange.from),o.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=ae(n,o.resolve(this.anchorRange.to),o.resolve(i.from)))),i.eq(n.state.selection)||(n.input.mouseSelecting=e,n.dispatch(n.state.tr.setSelection(i).setMeta("pointer",!0).scrollIntoView()),n.input.mouseSelecting=null))}restoreAnchor(){let e=dn(this.view),t=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!t)this.anchorRange=null;else{let{doc:n}=this.view.state;this.anchorRange=this.type=="singleClick"?cn(this.view,n,t):this.type=="doubleClick"?ln(n,t.pos):rn(n,t.inside,!1),this.anchorDoc=this.view.state.doc}}};function dn(e){let t=e.dom.getBoundingClientRect();return{x:t.left-e.dom.scrollLeft,y:t.top-e.dom.scrollTop}}function cn(e,t,n){if(n.inside>-1){let i=t.nodeAt(n.inside);if(i.isAtom&&v.isSelectable(i))return v.create(t,n.inside)}let o=t.resolve(n.pos);return ae(e,o,o)}function Go(e,t){let{selection:n}=e.state;if(n.empty)return!1;let o=e.domSelection();if(!o||o.rangeCount==0)return!0;let i=o.getRangeAt(0).getClientRects();for(let s=0;s<i.length;s++){let r=i[s];if(r.left<=t.clientX&&r.right>=t.clientX&&r.top<=t.clientY&&r.bottom>=t.clientY)return!0}return!1}P.touchstart=e=>{e.input.lastTouch=Date.now(),j(e),Ve(e,"pointer")},P.touchmove=e=>{e.input.lastTouch=Date.now(),Ve(e,"pointer")},P.contextmenu=e=>j(e);function jo(e,t){return e.composing?!0:k&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Yo=K?5e3:-1;E.compositionstart=E.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof S&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)||A&&mt&&_o(e)))e.markCursor=e.state.storedMarks||n.marks(),j(e,!0),e.markCursor=null;else if(j(e,!t.selection.empty),B&&e.domSel.active&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(let{focusNode:o,focusOffset:i}=e.domSel.range;o&&y(o)&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(C(s)){let r=e.domSelection();r&&r.collapse(s,s.nodeValue.length);break}o=s,i=-1}e.input.composing=!0}fn(e,Yo)};function _o(e){let{focusNode:t,focusOffset:n}=e.domSel.range;if(!t||!y(t)||n>=t.childNodes.length)return!1;let o=t.childNodes[n];return y(o)&&o.contentEditable=="false"}E.compositionend=(e,t)=>{e.composing&&hn(e)};function hn(e,t=!1){e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,t?j(e):fn(e,20)}function fn(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>j(e),t))}function un(e){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());for(let t;t=e.input.compositionNodes.pop();)t.markParentDamage()}function Xo(e){let t=e.domSel.range;if(!e.domSel.active||!t.focusNode)return null;let n=Be(t.focusNode,t.focusOffset),o=Ie(t.focusNode,t.focusOffset);if(n&&o&&n!=o){let i=o.pmViewDesc,s=e.domObserver.lastChangedTextNode;if(n==s||o==s)return s;if(!i||!i.isText(o.nodeValue))return o;if(e.input.compositionNode==o){let r=n.pmViewDesc;if(!(!r||!r.isText(n.nodeValue)))return o}}return n||o}function j(e,t=!1){if(!(K&&e.domObserver.flushingSoon>=0)&&(e.domObserver.forceFlush(),un(e),t||e.docView&&e.docView.damage)){let n=Xe(e,e.domSel.readRange()),o=e.state.selection;n&&!n.eq(o)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state)}}function Jo(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Ce=ie&&Hn<604;P.copy=E.cut=(e,t)=>{let n=t,o=e.state.selection,i=n.type=="cut";if(o.empty)return;let s=Ce?null:n.clipboardData,{dom:r,text:l}=je(e,o.content());s?(n.preventDefault(),s.clearData(),s.setData("text/html",r.innerHTML),s.setData("text/plain",l)):Jo(e,r),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Uo(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Qo(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?Se(e,o.value,null,i,t):Se(e,o.textContent,o.innerHTML,i,t)},50)}function Se(e,t,n,o,i){let s=Ye(e,t,n,o,e.state.selection.$from);if(e.someProp("handlePaste",d=>d(e,i,s||U.empty)))return!0;if(!s)return!1;let r=Uo(s),l=r?e.state.tr.replaceSelectionWith(r,o):e.state.tr.replaceSelection(s);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function pn(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}E.paste=(e,t)=>{let n=t;if(e.composing&&!K)return;let o=Ce?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;o&&Se(e,pn(o),o.getData("text/html"),i,n)?n.preventDefault():Qo(e,n)};var mn=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Zo=R?"altKey":"ctrlKey";function gn(e,t){let n;return e.someProp("dragCopies",o=>{n||=o(t)}),n==null?!t[Zo]:!n}P.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let i=e.state.selection,s=i.empty?null:e.posAtCoords(Ne(n)),r;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof v?i.to-1:i.to))){if(o&&typeof o.mightDrag=="object")r=v.create(e.state.doc,o.mightDrag.pos);else if(n.target&&y(n.target)){let a=e.docView.nearestDesc(n.target,!0);a&&a.node.type.spec.draggable&&a!=e.docView&&(r=v.create(e.state.doc,a.posBefore))}}let{dom:l,text:d,slice:c}=je(e,(r||e.state.selection).content());(!n.dataTransfer.files.length||!A||pt>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ce?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ce||n.dataTransfer.setData("text/plain",d),e.dragging=new mn(c,gn(e,n),r)},P.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},E.dragover=E.dragenter=(e,t)=>t.preventDefault(),E.drop=(e,t)=>{try{ei(e,t,e.dragging)}finally{e.dragging=null}};function ei(e,t,n){if(!t.dataTransfer)return;let o=e.posAtCoords(Ne(t));if(!o)return;let i=e.state.doc.resolve(o.pos),s=n&&n.slice;s?e.someProp("transformPasted",p=>{s=p(s,e,!1)}):s=Ye(e,pn(t.dataTransfer),Ce?null:t.dataTransfer.getData("text/html"),!1,i);let r=!!(n&&gn(e,t));if(e.someProp("handleDrop",p=>p(e,t,s||U.empty,r))){t.preventDefault();return}if(!s)return;t.preventDefault();let l=s?Ln(e.state.doc,i.pos,s):i.pos;l??=i.pos;let d=e.state.tr;if(r){let{node:p}=n;p?p.replace(d):d.deleteSelection()}let c=d.mapping.map(l),a=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=d.doc;if(a?d.replaceRangeWith(c,c,s.content.firstChild):d.replaceRange(c,c,s),d.doc.eq(h))return;let f=d.doc.resolve(c);if(a&&v.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))d.setSelection(new v(f));else{let p=d.mapping.map(l);d.mapping.maps[d.mapping.maps.length-1].forEach((g,u,m,b)=>p=b),d.setSelection(ae(e,f,d.doc.resolve(p)))}e.focus(),e.dispatch(d.setMeta("uiEvent","drop"))}P.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused&&(e.domObserver.stopped(()=>e.dom.classList.add("ProseMirror-focused")),e.focused=!0,e.domSel.read(),!e.domSel.synced)){let t=e.domSel.range;setTimeout(()=>{let n=e.domSel.readRange();n&&t.eq(n)&&e.domSel.sync()},20)}},P.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stopped(()=>e.dom.classList.remove("ProseMirror-focused")),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domSel.deactivate(),!1)},P.beforeinput=(e,t)=>{if(K&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:n}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=n||e.domObserver.pendingRecords().length||(e.dom.blur(),e.focus(),G(e,"Backspace")))return;let{$cursor:o}=e.state.selection;o&&o.pos>0&&e.dispatch(e.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let e in E)P[e]=E[e];function xe(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var tt=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},bn=class Rn{constructor(t,n){this.toDOM=t,this.spec=n||ee,this.side=this.spec.side||0}map(t,n,o,i){let{pos:s,deleted:r}=t.mapResult(n.from+i,this.side<0?-1:1);return r?null:new Z(s-o,s-o,this)}valid(){return!0}eq(t){return this==t||t instanceof Rn&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&xe(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},Oe=class lt{constructor(t,n){this.attrs=t,this.spec=n||ee}map(t,n,o,i){let s=t.map(n.from+i,this.spec.inclusiveStart?-1:1)-o,r=t.map(n.to+i,this.spec.inclusiveEnd?1:-1)-o;return s>=r?null:new Z(s,r,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof lt&&xe(this.attrs,t.attrs)&&xe(this.spec,t.spec)}static is(t){return t.type instanceof lt}destroy(){}},ti=class Bn{constructor(t,n){this.attrs=t,this.spec=n||ee}map(t,n,o,i){let s=t.mapResult(n.from+i,1);if(s.deleted)return null;let r=t.mapResult(n.to+i,-1);return r.deleted||r.pos<=s.pos?null:new Z(s.pos-o,r.pos-o,this)}valid(t,n,o){let i=o.nodeAt(n.from);return!!i&&!i.isText&&n.from+i.nodeSize==n.to}eq(t){return this==t||t instanceof Bn&&xe(this.attrs,t.attrs)&&xe(this.spec,t.spec)}destroy(){}},Z=class Me{constructor(t,n,o){this.from=t,this.to=n,this.type=o}copy(t,n){return new Me(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,o){return this.type.map(t,this,n,o)}static widget(t,n,o){return new Me(t,t,new bn(n,o))}static inline(t,n,o,i){return new Me(t,n,new Oe(o,i))}static node(t,n,o,i){return new Me(t,n,new ti(o,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Oe}get widget(){return this.type instanceof bn}},de=[],ee={},L=class _{constructor(t,n){this.local=t.length?t:de,this.children=n.length?n:de}static create(t,n){return n.length?Re(n,t,0,ee):T}find(t,n,o){let i=[];return this.findInner(t??0,n??1e9,i,0,o),i}findInner(t,n,o,i,s){for(let r=0;r<this.local.length;r++){let l=this.local[r];if(l.from>n)break;l.to>=t&&(!s||s(l.spec))&&o.push(l.copy(l.from+i,l.to+i))}for(let r=0;r<this.children.length&&!(this.children[r]>=n);r+=3)if(this.children[r+1]>t){let l=this.children[r]+1;this.children[r+2].findInner(t-l,n-l,o,i+l,s)}}map(t,n,o){return this==T||t.maps.length==0?this:this.mapInner(t,n,0,0,o||ee)}mapInner(t,n,o,i,s){let r;if(this.local.length){let l=new tt(n.content);for(let d=0;d<this.local.length;d++){let c=this.local[d].map(t,o,i);c&&c.type.valid(n,c,l)?(r||=[]).push(c):s.onRemove&&s.onRemove(this.local[d].spec)}}return this.children.length?ni(this.children,r||[],t,n,o,i,s):r?new _(r.sort(Y),de):T}add(t,n){return n.length?this==T?_.create(t,n):this.addInner(t,n,0):this}addInner(t,n,o){let i,s=0;t.forEach((l,d)=>{let c=d+o,a;if(a=wn(n,l,c)){for(i||=this.children.slice();s<i.length&&i[s]<d;)s+=3;i[s]==d?i[s+2]=i[s+2].addInner(l,a,c+1):i.splice(s,0,d,d+l.nodeSize,Re(a,l,c+1,ee)),s+=3}});let r=vn(s?Dn(n):n,-o).sort(Y);if(r.length){let l=new tt(t.content);for(let d=0;d<r.length;d++)r[d].type.valid(t,r[d],l)||r.splice(d--,1)}return new _(r.length?this.local.concat(r).sort(Y):this.local,i||this.children)}remove(t){return t.length==0||this==T?this:this.removeInner(t,0)}removeInner(t,n){let o=this.children,i=this.local;for(let s=0;s<o.length;s+=3){let r,l=o[s]+n,d=o[s+1]+n;for(let a=0,h;a<t.length;a++)(h=t[a])&&h.from>l&&h.to<d&&(t[a]=null,(r||=[]).push(h));if(!r)continue;o==this.children&&(o=this.children.slice());let c=o[s+2].removeInner(r,l+1);c==T?(o.splice(s,3),s-=3):o[s+2]=c}if(i.length){for(let s=0,r;s<t.length;s++)if(r=t[s])for(let l=0;l<i.length;l++)i[l].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return o==this.children&&i==this.local?this:i.length||o.length?new _(i,o):T}forChild(t,n){if(this==T)return this;if(n.isLeaf)return _.empty;let o,i,s=0,r=this.children.length/3;for(;s<r;){let c=s+r>>>1,a=c*3,h=this.children[a];if(h<t)s=c+1;else if(h>t)r=c;else{o=this.children[a+2];break}}let l=t+1,d=l+n.content.size;for(let c=0;c<this.local.length;c++){let a=this.local[c];if(a.from<d&&a.to>l&&a.type instanceof Oe){let h=Math.max(l,a.from)-l,f=Math.min(d,a.to)-l;h<f&&(i||=[]).push(a.copy(h,f))}}if(i){let c=new _(i.sort(Y),de);return o?new yn([c,o]):c}return o||T}eq(t){if(this==t)return!0;if(!(t instanceof _)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return nt(this.localsInner(t))}localsInner(t){if(this==T)return de;if(t.inlineContent||!this.local.some(Oe.is))return this.local;let n=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof Oe||n.push(this.local[o]);return n}forEachSet(t){t(this)}};L.empty=new L([],[]),L.removeOverlap=nt;var T=L.empty,yn=class ce{constructor(t){this.members=t}map(t,n){let o=this.members.map(i=>i.map(t,n,ee));return ce.from(o)}forChild(t,n){if(n.isLeaf)return L.empty;let o=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(t,n);s!=T&&(s instanceof ce?o=o.concat(s.members):o.push(s))}return ce.from(o)}eq(t){if(!(t instanceof ce)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,o=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(t);if(s.length)if(!n)n=s;else{o&&=(n=n.slice(),!1);for(let r=0;r<s.length;r++)n.push(s[r])}}return n?nt(o?n:n.sort(Y)):de}static from(t){switch(t.length){case 0:return T;case 1:return t[0];default:return new ce(t.every(n=>n instanceof L)?t:t.reduce((n,o)=>n.concat(o instanceof L?o:o.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}};function ni(e,t,n,o,i,s,r){let l=e.slice();for(let c=0,a=s;c<n.maps.length;c++){let h=0;n.maps[c].forEach((f,p,g,u)=>{let m=u-g-(p-f);for(let b=0;b<l.length;b+=3){let N=l[b+1];if(N<0||f>N+a-h)continue;let w=l[b]+a-h;p>=w?l[b+1]=f<=w?-2:-1:f>=a&&m&&(l[b]+=m,l[b+1]+=m)}h+=m}),a=n.maps[c].map(a,-1)}let d=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){d=!0,l[c+1]=-1;continue}let a=n.map(e[c]+s),h=a-i;if(h<0||h>=o.content.size){d=!0;continue}let f=n.map(e[c+1]+s,-1)-i,{index:p,offset:g}=o.content.findIndex(h),u=o.maybeChild(p);if(u&&g==h&&g+u.nodeSize==f){let m=l[c+2].mapInner(n,u,a+1,e[c]+s+1,r);m==T?(l[c+1]=-2,d=!0):(l[c]=h,l[c+1]=f,l[c+2]=m)}else d=!0}if(d){let c=Re(oi(l,e,t,n,i,s,r),o,0,r);t=c.local;for(let a=0;a<l.length;a+=3)l[a+1]<0&&(l.splice(a,3),a-=3);for(let a=0,h=0;a<c.children.length;a+=3){let f=c.children[a];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,c.children[a],c.children[a+1],c.children[a+2])}}return new L(t.sort(Y),l)}function vn(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let i=e[o];n.push(new Z(i.from+t,i.to+t,i.type))}return n}function oi(e,t,n,o,i,s,r){function l(d,c){for(let a=0;a<d.local.length;a++){let h=d.local[a].map(o,i,c);h?n.push(h):r.onRemove&&r.onRemove(d.local[a].spec)}for(let a=0;a<d.children.length;a+=3)l(d.children[a+2],d.children[a]+c+1)}for(let d=0;d<e.length;d+=3)e[d+1]==-1&&l(e[d+2],t[d]+s+1);return n}function wn(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,i=null;for(let s=0,r;s<e.length;s++)(r=e[s])&&r.from>n&&r.to<o&&((i||=[]).push(r),e[s]=null);return i}function Dn(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Re(e,t,n,o){let i=[],s=!1;t.forEach((l,d)=>{let c=wn(e,l,d+n);if(c){s=!0;let a=Re(c,l,n+d+1,o);a!=T&&i.push(d,d+l.nodeSize,a)}});let r=vn(s?Dn(e):e,-n).sort(Y);if(r.length){let l=new tt(t.content);for(let d=0;d<r.length;d++)r[d].type.valid(t,r[d],l)||(o.onRemove&&o.onRemove(r[d].spec),r.splice(d--,1))}return r.length||i.length?new L(r,i):T}function Y(e,t){return e.from-t.from||e.to-t.to}function nt(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let i=n+1;i<t.length;i++){let s=t[i];if(s.from==o.from){s.to!=o.to&&(t==e&&(t=e.slice()),t[i]=s.copy(s.from,o.to),Nn(t,i+1,s.copy(o.to,s.to)));continue}s.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,s.from),Nn(t,i,o.copy(s.from,o.to)));break}}return t}function Nn(e,t,n){for(;t<e.length&&Y(n,e[t])>0;)t++;e.splice(t,0,n)}function ot(e){let t=[];return e.someProp("decorations",n=>{let o=n(e.state);o&&o!=T&&t.push(o)}),e.cursorWrapper&&t.push(L.create(e.state.doc,[e.cursorWrapper.deco])),yn.from(t)}function ii(e,t,n,o){let{node:i,fromOffset:s,toOffset:r,from:l,to:d}=e.docView.parseRange(t,n),c=e.domSel.range,a,h=c.anchorNode;if(h&&ne(e.dom,h)&&(a=[{node:h,offset:c.anchorOffset}],Ae(c)||a.push({node:c.focusNode,offset:c.focusOffset})),A&&e.input.lastKeyCode===8)for(let b=r;b>s;b--){let N=i.childNodes[b-1],w=N.pmViewDesc;if(N.nodeName=="BR"&&!w){r=b;break}if(!w||w.size)break}let f=e.state.doc,p=e.someProp("domParser")||at.fromSchema(e.state.schema),g=f.resolve(l),u=null,m=p.parse(i,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:s,to:r,preserveWhitespace:g.parent.type.whitespace!="pre"||"full",findPositions:a,ruleFromNode:si(o),context:g});if(a&&a[0].pos!=null){let b=a[0].pos,N=a[1]&&a[1].pos;N??=b,u={anchor:b+l,head:N+l}}return{doc:m,sel:u,from:l,to:d}}var si=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName=="BR"&&t.parentNode){if(k&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let o=document.createElement("div");return o.appendChild(document.createElement("li")),{skip:o}}if(t.parentNode.lastChild==t||k&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},ri=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function li(e,t,n,o,i,s){let r=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let D=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,x=Xe(e,e.domSel.range,D);if(x&&!e.state.selection.eq(x)&&e.domSel.active){if(A&&K&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&G(e,"Enter"))return;let V=e.state.tr.setSelection(x);D=="pointer"?V.setMeta("pointer",!0):D=="key"&&V.scrollIntoView(),r&&V.setMeta("composition",r),e.dispatch(V)}return}let l=e.state.doc.resolve(t),d=l.sharedDepth(n);t=l.before(d+1),n=e.state.doc.resolve(n).after(d+1);let c=e.state.selection,a=ii(e,t,n,s),h=e.state.doc,f=h.slice(a.from,a.to),p,g;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(p=e.state.selection.to,g="end"):(p=e.state.selection.from,g="start"),e.input.lastKeyCode=null;let u=hi(f.content,a.doc.content,a.from,p,g);if(u&&e.input.domChangeCount++,(ie&&e.input.lastIOSEnter>Date.now()-225||K)&&s.some(D=>y(D)&&!ri.test(D.nodeName))&&(!u||u.endA>=u.endB)&&G(e,"Enter")){e.input.lastIOSEnter=0;return}if(!u)if(i&&c instanceof S&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(a.sel&&a.sel.anchor!=a.sel.head))u={start:c.from,endA:c.to,endB:c.to};else{if(a.sel){let D=Cn(e,e.state.doc,a.sel);if(D&&!D.eq(e.state.selection)){let x=e.state.tr.setSelection(D);r&&x.setMeta("composition",r),e.dispatch(x)}}return}e.state.selection.from<e.state.selection.to&&u.start==u.endB&&e.state.selection instanceof S&&(u.start>e.state.selection.from&&u.start<=e.state.selection.from+2&&e.state.selection.from>=a.from?u.start=e.state.selection.from:u.endA<e.state.selection.to&&u.endA>=e.state.selection.to-2&&e.state.selection.to<=a.to&&(u.endB+=e.state.selection.to-u.endA,u.endA=e.state.selection.to));let m=a.doc.resolveNoCache(u.start-a.from),b=a.doc.resolveNoCache(u.endB-a.from),N=h.resolve(u.start),w=m.sameParent(b)&&m.parent.inlineContent&&N.end()>=u.endA;if((ie&&e.input.lastIOSEnter>Date.now()-225&&(!w||s.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!w&&ci(a.doc,m.pos,b.pos))&&G(e,"Enter")){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>u.start&&(w?u.endA>u.start&&u.endB==u.start:di(h,u.start,u.endA,m,b))&&G(e,"Backspace")){K&&A&&e.domSel.suppressChanges();return}A&&u.endB==u.start&&(e.input.lastChromeDelete=Date.now()),K&&!w&&m.start()!=b.start()&&b.parentOffset==0&&m.depth==b.depth&&a.sel&&a.sel.anchor==a.sel.head&&a.sel.head==u.endA&&(u.endB-=2,b=a.doc.resolveNoCache(u.endB-a.from),setTimeout(()=>G(e,"Enter"),20));let X=u.start,J=u.endA,he=D=>{let x=D||e.state.tr.replace(X,J,a.doc.slice(u.start-a.from,u.endB-a.from));if(a.sel){let V=Cn(e,x.doc,a.sel);V&&!(A&&e.composing&&V.empty&&(u.start!=u.endB||e.input.lastChromeDelete<Date.now()-100)&&(V.head==X||V.head==x.mapping.map(J)-1))&&x.setSelection(V)}return r&&x.setMeta("composition",r),x.scrollIntoView()},ke;if(w)if(m.pos==b.pos){let D=he(e.state.tr.delete(X,J)),x=h.resolve(u.start).marksAcross(h.resolve(u.endA));x&&D.ensureMarks(x),e.dispatch(D)}else if(u.endA==u.endB&&(ke=ai(m.parent.content.cut(m.parentOffset,b.parentOffset),N.parent.content.cut(N.parentOffset,u.endA-N.start())))){let D=he(e.state.tr);ke.type=="add"?D.addMark(X,J,ke.mark):D.removeMark(X,J,ke.mark),e.dispatch(D)}else if(m.parent.child(m.index()).isText&&m.index()==b.index()-+!b.textOffset){let D=m.parent.textBetween(m.parentOffset,b.parentOffset),x=()=>he(e.state.tr.insertText(D,X,J));e.someProp("handleTextInput",V=>V(e,X,J,D,x))||e.dispatch(x())}else e.dispatch(he());else e.dispatch(he())}function Cn(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:ae(e,t.resolve(n.anchor),t.resolve(n.head))}function ai(e,t){let n=e.firstChild.marks,o=t.firstChild.marks,i=n,s=o,r,l,d;for(let a=0;a<o.length;a++)i=o[a].removeFromSet(i);for(let a=0;a<n.length;a++)s=n[a].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],r="add",d=a=>a.mark(l.addToSet(a.marks));else if(i.length==0&&s.length==1)l=s[0],r="remove",d=a=>a.mark(l.removeFromSet(a.marks));else return null;let c=[];for(let a=0;a<t.childCount;a++)c.push(d(t.child(a)));if(q.from(c).eq(e))return{mark:l,type:r}}function di(e,t,n,o,i){if(n-t<=i.pos-o.pos||it(o,!0,!1)<i.pos)return!1;let s=e.resolve(t);if(!o.parent.inlineContent){let l=s.nodeAfter;return l!=null&&n==t+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let r=e.resolve(it(s,!0,!0));return!r.parent.isTextblock||r.pos>n||it(r,!0,!1)<n?!1:o.parent.content.cut(o.parentOffset).eq(r.parent.content)}function ci(e,t,n){let o=0,i=0;return e.nodesBetween(t,n,(s,r)=>{s.isTextblock&&r>=t&&r<n?o++:(s.isText?/\S/.test(s.text.slice(Math.max(0,t-r),Math.min(s.nodeSize,n-r))):s.isLeaf)&&i++}),i==0&&o==1}function it(e,t,n){let o=e.depth,i=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,i++,t=!1;if(n){let s=e.node(o).maybeChild(e.indexAfter(o));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function hi(e,t,n,o,i){let s=e.findDiffStart(t,n),r=n+e.size,l=n+t.size;if(s==null)return null;let{a:d,b:c}=e.findDiffEnd(t,r,l);if(i=="end"){let a=Math.max(0,s-Math.min(d,c));o-=d+a-s}if(d<s&&r<l){let a=o<=s&&o>=d?s-o:0;s-=a,c=s+(c-d),d=s}else if(c<s){let a=o<=s&&o>=c?s-o:0;s-=a,d=s+(d-c),c=s}return{start:s,endA:d,endB:c}}var fi={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ui=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(t=>{for(let n=0;n<t.length;n++)this.queue.push(t[n]);k&&e.composing&&t.some(n=>n.type=="childList"&&n.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,fi),this.started=!0}stop(){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect(),this.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let i=e.focusNode;i;i=te(i))t.add(i);for(let i=e.anchorNode;i;i=te(i))if(t.has(i)){n=i;break}let o=n&&this.view.docView.nearestDesc(n);if(o&&o.ignoreMutation({type:"selection",target:C(n)?n.parentNode:n}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]),e&&t.domSel.read();let o=!t.domSel.suppress&&!t.domSel.synced&&!!nn(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,s=-1,r=!1,l=[];if(t.editable)for(let c=0;c<n.length;c++){let a=this.registerMutation(n[c],l);a&&(i=i<0?a.from:Math.min(a.from,i),s=s<0?a.to:Math.max(a.to,s),a.typeOver&&(r=!0))}if(l.some(c=>c.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||A&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&n.some(c=>c.type=="childList"&&c.removedNodes.length))){for(let c of l)if(c.nodeName=="BR"&&c.parentNode){let a=c.nextSibling;for(;a&&y(a);){if(a.contentEditable=="false"){c.parentNode.removeChild(c);break}a=a.firstChild}}}else if(B&&l.length){let c=l.filter(a=>a.nodeName=="BR");if(c.length==2){let[a,h]=c;a.parentNode&&a.parentNode.parentNode==h.parentNode?h.remove():a.remove()}else{let{focusNode:a}=t.domSel.range;for(let h of c){let f=h.parentNode;f&&f.nodeName=="LI"&&(!a||mi(t,a)!=f)&&h.remove()}}}let d=null;i<0&&o&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&t.input.lastTouch<Date.now()-300&&Ae(t.domSel.range)&&(d=Xe(t,t.domSel.range))&&d.eq(fe.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||o)&&(i>-1&&pi(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,gi(t,l)),li(this.view,i,s,o,r,l),t.docView&&t.docView.damage?t.updateState(t.state):o&&t.domSel.sync())}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n;for(let o=e.target;o&&!(n=this.view.docView.getDesc(o));o=o.parentNode);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;c<e.addedNodes.length;c++){let a=e.addedNodes[c];t.push(a),C(a)&&(this.lastChangedTextNode=a)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return n.markDamage(4),{from:n.posBefore,to:n.posAfter};let o=e.previousSibling,i=e.nextSibling,s=o&&o.parentNode==e.target?M(o)+1:0,r=n.localPosFromDOM(e.target,s,-1),l=i&&i.parentNode==e.target?M(i):e.target.childNodes.length,d=n.localPosFromDOM(e.target,l,1);return n.markDamage(n.contentDOM?.contains(e.target)?2:4),{from:r,to:d}}return e.type=="attributes"?(n.markDamage(4),{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}):(this.lastChangedTextNode=e.target,n.markDamage(n instanceof qe&&e.target==n.nodeDOM?8:4),{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Sn=new WeakMap,xn=!1;function pi(e){if(!Sn.has(e)&&(Sn.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=B,xn)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),xn=!0}}function mi(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let o=e.docView.nearestDesc(n,!0);if(o&&o.node.isBlock)return n}return null}function gi(e,t){let{focusNode:n,focusOffset:o}=e.domSel.range;for(let i of t)if(i.parentNode?.nodeName=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let r=s;for(;;){let l=r.firstChild;if(!l||!y(l)||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;r=l}r.insertBefore(i,r.firstChild),n==i&&e.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}var bi=Ye,yi=j,On=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Vo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Pn),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Tn(this),kn(this),this.nodeViews=An(this),this.docView=Pt(this.state.doc,Mn(this),ot(this),this.dom,this),this.domObserver=new ui(this),this.domSel=new xo(this),this.domObserver.start(),this.domSel.read(),Ro(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ue(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Pn),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(un(this),i=!0),this.state=e;let s=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=An(this);wi(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ue(this),this.editable=Tn(this),kn(this);let r=ot(this),l=Mn(this),d=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?"reset":e.scrollToSelection>n.scrollToSelection?"to selection":"preserve",c=o||!this.docView.matchesNode(e.doc,l,r);(c||!e.selection.eq(n.selection))&&(i=!0);let a=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Yn(this);i&&this.domObserver.stopped(()=>{let h=c&&A&&!this.composing&&!n.selection.empty&&!e.selection.empty&&vi(n.selection,e.selection);if(c){let f=A?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=Xo(this)),o||!this.docView.update(e.doc,l,r,this,-1)){let p=this.docView.outerDeco;this.docView.destroy(),this.docView=Pt(e.doc,l,r,this.dom,this,p)}f&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}this.domSel.sync(h)}),this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():a&&_n(a)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)&&!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof v){let t=this.docView.domAfterPos(this.state.selection.from);y(t)&&bt(this,t.getBoundingClientRect(),e)}else bt(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,o=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let i=n.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==n.node&&(o=i)}this.dragging=new mn(e.slice,e.move,o<0?void 0:v.create(this.state.doc,o))}someProp(e,t){let n=this._props&&this._props[e],o;if(n!=null&&(o=t?t(n):n))return o;for(let s=0;s<this.directPlugins.length;s++){let r=this.directPlugins[s].props[e];if(r!=null&&(o=t?t(r):r))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let r=i[s].props[e];if(r!=null&&(o=t?t(r):r))return o}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&wt(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let t=this._root;if(t==null&&e){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return t||document}updateRoot(){this._root=null}posAtCoords(e){return Zn(this,e)}coordsAtPos(e,t=1){return xt(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let o=this.docView.posFromDOM(e,t,n);if(o==null)throw RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return io(this,t||this.state,e)}pasteHTML(e,t){return Se(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Se(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return je(this,e)}destroy(){this.docView&&(Bo(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ot(this),this,-1),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,zn())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Lo(this,e)}domSelection(){return this.root.getSelection()}};On.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Mn(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(e.state)),n)for(let o in n)o=="class"?t.class+=" "+n[o]:o=="style"?t.style=(t.style?t.style+";":"")+n[o]:!t[o]&&o!="contenteditable"&&o!="nodeName"&&(t[o]=String(n[o]))}),t.translate||="no",[Z.node(0,e.state.doc.content.size,t)]}function kn(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Z.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Tn(e){return!e.someProp("editable",t=>t(e.state)===!1)}function vi(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function An(e){let t=Object.create(null);function n(o){for(let i in o)Object.prototype.hasOwnProperty.call(t,i)||(t[i]=o[i])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function wi(e,t){let n=0,o=0;for(let i in e){if(e[i]!=t[i])return!0;n++}for(let i in t)o++;return n!=o}function Pn(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}export{Z as Decoration,L as DecorationSet,On as EditorView,yi as __endComposition,bi as __parseFromClipboard};
@@ -0,0 +1 @@
1
+ import{r as h,u as m}from"./dist-D2lK5znU.js";import{NodeSelection as v,Plugin as y,Selection as d,TextSelection as C}from"./dist-z_tOCaGG.js";import{keydownHandler as x}from"./dist-38sT7vmy.js";import{Decoration as A,DecorationSet as S}from"./dist-DdZ3e9iY.js";var l=class c extends d{constructor(e){super(e,e)}map(e,t){let o=e.resolve(t.map(this.head));return c.valid(o)?new c(o):d.near(o)}content(){return m.empty}eq(e){return e instanceof c&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw RangeError("Invalid input for GapCursor.fromJSON");return new c(e.resolve(t.pos))}getBookmark(){return new b(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!k(e)||!G(e))return!1;let o=t.type.spec.allowGapCursor;if(o!=null)return o;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,o=!1){e:for(;;){if(!o&&c.valid(e))return e;let r=e.pos,s=null;for(let i=e.depth;;i--){let a=e.node(i);if(t>0?e.indexAfter(i)<a.childCount:e.index(i)>0){s=a.child(t>0?e.indexAfter(i):e.index(i)-1);break}if(i==0)return null;r+=t;let u=e.doc.resolve(r);if(c.valid(u))return u}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!v.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),o=!1;continue e}break}s=i,r+=t;let a=e.doc.resolve(r);if(c.valid(a))return a}return null}}};l.prototype.visible=!1,l.findFrom=l.findGapCursorFrom,d.jsonID("gapcursor",l);var b=class g{constructor(e){this.pos=e}map(e){return new g(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return l.valid(t)?new l(t):d.near(t)}};function w(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function k(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),o=n.node(e);if(t==0){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||w(r.type))return!0;if(r.inlineContent)return!1}}return!0}function G(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),o=n.node(e);if(t==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||w(r.type))return!0;if(r.inlineContent)return!1}}return!0}function T(){return new y({props:{decorations:O,createSelectionBetween(n,e,t){return e.pos==t.pos&&l.valid(t)?new l(t):null},handleClick:F,handleKeyDown:D,handleDOMEvents:{beforeinput:N}}})}var D=x({ArrowLeft:f("horiz",-1),ArrowRight:f("horiz",1),ArrowUp:f("vert",-1),ArrowDown:f("vert",1)});function f(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(o,r,s){let i=o.selection,a=e>0?i.$to:i.$from,u=i.empty;if(i instanceof C){if(!s.endOfTextblock(t)||a.depth==0)return!1;u=!1,a=o.doc.resolve(e>0?a.after():a.before())}let p=l.findGapCursorFrom(a,e,u);return p?(r&&r(o.tr.setSelection(new l(p))),!0):!1}}function F(n,e,t){if(!n||!n.editable)return!1;let o=n.state.doc.resolve(e);if(!l.valid(o))return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});return r&&r.inside>-1&&v.isSelectable(n.state.doc.nodeAt(r.inside))?!1:(n.dispatch(n.state.tr.setSelection(new l(o))),!0)}function N(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof l))return!1;let{$from:t}=n.state.selection,o=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!o)return!1;let r=h.empty;for(let i=o.length-1;i>=0;i--)r=h.from(o[i].createAndFill(null,r));let s=n.state.tr.replace(t.pos,t.pos,new m(r,0,0));return s.setSelection(C.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function O(n){if(!(n.selection instanceof l))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",S.create(n.doc,[A.widget(n.selection.head,e,{key:"gapcursor"})])}export{l as GapCursor,T as gapCursor};
@@ -0,0 +1 @@
1
+ import{c as M}from"./dist-D2lK5znU.js";import{d as b,s as T}from"./dist-Bl8aVOmr.js";import{Plugin as $}from"./dist-z_tOCaGG.js";var d=class{constructor(s,t,e={}){this.match=s,this.match=s,this.handler=typeof t=="string"?Q(t):t,this.undoable=e.undoable!==!1,this.inCode=e.inCode||!1,this.inCodeMark=e.inCodeMark!==!1}};function Q(s){return function(t,e,n,l){let o=s;if(e[1]){let i=e[0].lastIndexOf(e[1]);o+=e[0].slice(i+e[1].length),n+=i;let r=n-l;r>0&&(o=e[0].slice(i-r,i)+o,n=l)}return t.tr.insertText(o,n,l)}}var A=500;function B({rules:s}){let t=new $({state:{init(){return null},apply(e,n){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:n)}},props:{handleTextInput(e,n,l,o){return x(e,n,l,o,s,t)},handleDOMEvents:{compositionend:e=>{setTimeout(()=>{let{$cursor:n}=e.state.selection;n&&x(e,n.pos,n.pos,"",s,t)})}}},isInputRules:!0});return t}function x(s,t,e,n,l,o){if(s.composing)return!1;let i=s.state,r=i.doc.resolve(t),a=s.state.selection,p=r.parent.textBetween(Math.max(0,r.parentOffset-A),r.parentOffset,null,"")+n,h=t==a.from&&e==a.to&&s.state.storedMarks||(t==e?r.marks():r.marksAcross(i.doc.resolve(e))||[]);for(let c=0;c<l.length;c++){let u=l[c];if(!u.inCodeMark&&h.some(k=>k.type.spec.code))continue;if(r.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let f=u.match.exec(p);if(!f||f[0].length<n.length)continue;let m=t-(f[0].length-n.length);if(!u.inCodeMark){let k=!1;if(i.doc.nodesBetween(m,r.pos,C=>{C.isInline&&C.marks.some(R=>R.type.spec.code)&&(k=!0)}),k)continue}let g=u.handler(i,f,m,e,n);if(g)return u.undoable&&g.setMeta(o,{transform:g,from:t,to:e,text:n}),s.dispatch(g),!0}return!1}var D=(s,t)=>{let e=s.plugins;for(let n=0;n<e.length;n++){let l=e[n],o;if(l.spec.isInputRules&&(o=l.getState(s))){if(t){let i=s.tr,r=o.transform;for(let a=r.steps.length-1;a>=0;a--)i.step(r.steps[a].invert(r.docs[a]));if(o.text){let a=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,s.schema.text(o.text,a))}else i.delete(o.from,o.to);t(i)}return!0}}return!1},O=new d(/--$/,"—",{inCodeMark:!1}),S=new d(/\.\.\.$/,"…",{inCodeMark:!1}),w=new d(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),v=new d(/"$/,"”",{inCodeMark:!1}),y=new d(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),I=new d(/'$/,"’",{inCodeMark:!1}),j=[w,v,y,I];function F(s,t,e,n){let l,o;return t instanceof M?o=t:(l=t,o=t.nodeType,e=t.getAttrs,n=t.joinPredicate),new d(s,(i,r,a,p)=>{let h=e instanceof Function?e(r):e,c=i.tr.delete(a,p),u=c.doc.resolve(a).blockRange(),f=u&&b(u,o,h);if(!f)return null;c.wrap(u,f);let m=c.doc.resolve(a-1).nodeBefore;return m&&m.type==o&&T(c.doc,a-1)&&(!n||n(r,m))&&c.join(a-1),c},l)}function P(s,t,e){let n,l;return t instanceof M?l=t:(n=t,l=t.nodeType,e=t.getAttrs),new d(s,(o,i,r,a)=>{let p=o.doc.resolve(r),h=e instanceof Function?e(i):e;return p.node(-1).canReplaceWith(p.index(-1),p.indexAfter(-1),l)?o.tr.delete(r,a).setBlockType(r,r,l,h):null},n)}export{d as InputRule,v as closeDoubleQuote,I as closeSingleQuote,S as ellipsis,O as emDash,B as inputRules,w as openDoubleQuote,y as openSingleQuote,j as smartQuotes,P as textblockTypeInputRule,D as undoInputRule,F as wrappingInputRule};
@@ -0,0 +1 @@
1
+ import{u as f}from"./dist-Bl8aVOmr.js";import{Plugin as w}from"./dist-z_tOCaGG.js";function v(t={}){return new w({view(e){return new C(e,t)}})}var C=class{constructor(t,e){this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=e.width??1,this.color=e.color===!1?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=h=>{this[i](h)};return t.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc)if(this.lastDragEvent){let i=this.computeTarget(this.lastDragEvent);i==this.cursorPos?this.updateOverlay():this.setCursor(i)}else this.updateOverlay()}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),e=!t.parent.inlineContent,i,o=this.editorView.dom,h=o.getBoundingClientRect(),l=h.width/o.offsetWidth,d=h.height/o.offsetHeight;if(e){let s=t.nodeBefore,n=t.nodeAfter;if(s||n){let a=this.editorView.nodeDOM(this.cursorPos-(s?s.nodeSize:0));if(a){let u=a.getBoundingClientRect(),c=s?u.bottom:u.top;s&&n&&(c=(c+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*d;i={left:u.left,right:u.right,top:c-g,bottom:c+g}}}}if(!i){let s=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*l;i={left:s.left-n,right:s.left+n,top:s.top,bottom:s.bottom}}let r=this.editorView.dom.offsetParent;this.element||(this.element=r.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",e),this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let m,p;if(!r||r==document.body&&getComputedStyle(r).position=="static")m=-pageXOffset,p=-pageYOffset;else{let s=r.getBoundingClientRect(),n=s.width/r.offsetWidth,a=s.height/r.offsetHeight;m=s.left-r.scrollLeft*n,p=s.top-r.scrollTop*a}this.element.style.left=(i.left-m)/l+"px",this.element.style.top=(i.top-p)/d+"px",this.element.style.width=(i.right-i.left)/l+"px",this.element.style.height=(i.bottom-i.top)/d+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}computeTarget(t){let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),i=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),o=i&&i.type.spec.disableDropCursor,h=typeof o=="function"?o(this.editorView,e,t):o;if(!e||h)return null;let l=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let d=f(this.editorView.state.doc,l,this.editorView.dragging.slice);d!=null&&(l=d)}return l}dragover(t){if(!this.editorView.editable)return;this.lastDragEvent=t;let e=this.computeTarget(t);e!=null&&(this.setCursor(e),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}};export{v as dropCursor};
@@ -0,0 +1 @@
1
+ import{i as J,o as W,r as K,u}from"./dist-D2lK5znU.js";import{a as P,i as V,o as G}from"./dist-Bl8aVOmr.js";var O=Object.create(null),a=class{constructor(t,e,r){this.$anchor=t,this.$head=e,this.ranges=r||[new b(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=u.empty){let r=e.content.lastChild,s=null;for(let o=0;o<e.openEnd;o++)s=r,r=r.lastChild;let n=t.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:c}=i[o],h=t.mapping.slice(n);t.replaceRange(h.map(l.pos),h.map(c.pos),o?u.empty:e),o==0&&R(t,n,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,s=this.ranges;for(let n=0;n<s.length;n++){let{$from:i,$to:o}=s[n],l=t.mapping.slice(r),c=l.map(i.pos),h=l.map(o.pos);n?t.deleteRange(c,h):(t.replaceRangeWith(c,h,e),R(t,r,e.isInline?-1:1))}}static findFrom(t,e,r=!1){let s=t.parent.inlineContent?new f(t):g(t.node(0),t.parent,t.pos,t.index(),e,r);if(s)return s;for(let n=t.depth-1;n>=0;n--){let i=e<0?g(t.node(0),t.node(n),t.before(n+1),t.index(n),e,r):g(t.node(0),t.node(n),t.after(n+1),t.index(n)+1,e,r);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new m(t.node(0))}static atStart(t){return g(t,t,0,0,1)||new m(t)}static atEnd(t){return g(t,t,t.content.size,t.childCount,-1)||new m(t)}static fromJSON(t,e){if(!e||!e.type)throw RangeError("Invalid input for Selection.fromJSON");let r=O[e.type];if(!r)throw RangeError(`No selection type ${e.type} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in O)throw RangeError("Duplicate use of selection JSON ID "+t);return O[t]=e,e.prototype.jsonID=t,e}getBookmark(){return f.between(this.$anchor,this.$head).getBookmark()}};a.prototype.visible=!0;var b=class{constructor(t,e){this.$from=t,this.$to=e}},T=!1;function x(t){!T&&!t.parent.inlineContent&&(T=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var f=class y extends a{constructor(e,r=e){x(e),x(r),super(e,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,r){let s=e.resolve(r.map(this.head));if(!s.parent.inlineContent)return a.near(s);let n=e.resolve(r.map(this.anchor));return new y(n.parent.inlineContent?n:s,s)}replace(e,r=u.empty){if(super.replace(e,r),r==u.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof y&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new E(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,r){if(typeof r.anchor!="number"||typeof r.head!="number")throw RangeError("Invalid input for TextSelection.fromJSON");return new y(e.resolve(r.anchor),e.resolve(r.head))}static create(e,r,s=r){let n=e.resolve(r);return new this(n,s==r?n:e.resolve(s))}static between(e,r,s){let n=e.pos-r.pos;if((!s||n)&&(s=n>=0?1:-1),!r.parent.inlineContent){let i=a.findFrom(r,s,!0)||a.findFrom(r,-s,!0);if(i)r=i.$head;else return a.near(r,s)}return e.parent.inlineContent||(n==0?e=r:(e=(a.findFrom(e,-s,!0)||a.findFrom(e,s,!0)).$anchor,e.pos<r.pos!=n<0&&(e=r))),new y(e,r)}};a.jsonID("text",f);var E=class q{constructor(e,r){this.anchor=e,this.head=r}map(e){return new q(e.map(this.anchor),e.map(this.head))}resolve(e){return f.between(e.resolve(this.anchor),e.resolve(this.head))}},d=class k extends a{constructor(e){let r=e.nodeAfter,s=e.node(0).resolve(e.pos+r.nodeSize);super(e,s),this.node=r}map(e,r){let{deleted:s,pos:n}=r.mapResult(this.anchor),i=e.resolve(n);return s?a.near(i):new k(i)}content(){return new u(K.from(this.node),0,0)}eq(e){return e instanceof k&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new H(this.anchor)}static fromJSON(e,r){if(typeof r.anchor!="number")throw RangeError("Invalid input for NodeSelection.fromJSON");return new k(e.resolve(r.anchor))}static create(e,r){return new k(e.resolve(r))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};d.prototype.visible=!1,a.jsonID("node",d);var H=class z{constructor(e){this.anchor=e}map(e){let{deleted:r,pos:s}=e.mapResult(this.anchor);return r?new E(s,s):new z(s)}resolve(e){let r=e.resolve(this.anchor),s=r.nodeAfter;return s&&d.isSelectable(s)?new d(r):a.near(r)}},m=class v extends a{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,r=u.empty){if(r==u.empty){e.delete(0,e.doc.content.size);let s=a.atStart(e.doc);s.eq(e.selection)||e.setSelection(s)}else super.replace(e,r)}toJSON(){return{type:"all"}}static fromJSON(e){return new v(e)}map(e){return new v(e)}eq(e){return e instanceof v}getBookmark(){return L}};a.jsonID("all",m);var L={map(){return this},resolve(t){return new m(t)}};function g(t,e,r,s,n,i=!1){if(e.inlineContent)return f.create(t,r);for(let o=s-(n>0?0:1);n>0?o<e.childCount:o>=0;o+=n){let l=e.child(o);if(l.isAtom){if(!i&&d.isSelectable(l))return d.create(t,r-(n<0?l.nodeSize:0))}else{let c=g(t,l,r+n,n<0?l.childCount:0,n,i);if(c)return c}r+=l.nodeSize*n}return null}function R(t,e,r){let s=t.steps.length-1;if(s<e)return;let n=t.steps[s];if(!(n instanceof P||n instanceof V))return;let i=t.mapping.maps[s],o;i.forEach((l,c,h,p)=>{o??=p}),t.setSelection(a.near(t.doc.resolve(o),r))}var I=1,F=2,C=4,j=class extends G{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=(this.updated|I)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&I)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=F,this}ensureMarks(t){return J.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&F)>0}addStep(t,e){super.addStep(t,e),this.updated&=-3,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let r=this.selection;return e&&(t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||J.none))),r.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,r){let s=this.doc.type.schema;if(e==null)return t?this.replaceSelectionWith(s.text(t),!0):this.deleteSelection();{if(r??=e,!t)return this.deleteRange(e,r);let n=this.storedMarks;if(!n){let i=this.doc.resolve(e);n=r==e?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(e,r,s.text(t,n)),!this.selection.empty&&this.selection.to==e+t.length&&this.setSelection(a.near(this.selection.$to)),this}}setMeta(t,e){return this.meta[typeof t=="string"?t:t.key]=e,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=C,this}get scrolledIntoView(){return(this.updated&C)>0}};function A(t,e){return!e||!t?t:t.bind(e)}var S=class{constructor(t,e,r){this.name=t,this.init=A(e.init,r),this.apply=A(e.apply,r)}},Q=[new S("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new S("selection",{init(t,e){return t.selection||a.atStart(e.doc)},apply(t){return t.selection}}),new S("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,s){return s.selection.$cursor?t.storedMarks:null}}),new S("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],M=class{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Q.slice(),e&&e.forEach(r=>{if(this.pluginsByKey[r.key])throw RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new S(r.key,r.spec.state,r))})}},U=class w{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,r=-1){for(let s=0;s<this.config.plugins.length;s++)if(s!=r){let n=this.config.plugins[s];if(n.spec.filterTransaction&&!n.spec.filterTransaction.call(n,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let r=[e],s=this.applyInner(e),n=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=n?n[o].n:0,h=n?n[o].state:this,p=c<r.length&&l.spec.appendTransaction.call(l,c?r.slice(c):r,h,s);if(p&&s.filterTransaction(p,o)){if(p.setMeta("appendedTransaction",e),!n){n=[];for(let $=0;$<this.config.plugins.length;$++)n.push($<o?{state:s,n:r.length}:{state:this,n:0})}r.push(p),s=s.applyInner(p),i=!0}n&&(n[o]={state:s,n:r.length})}}if(!i)return{state:s,transactions:r}}}applyInner(e){if(!e.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let r=new w(this.config),s=this.config.fields;for(let n=0;n<s.length;n++){let i=s[n];r[i.name]=i.apply(e,this[i.name],this,r)}return r}get tr(){return new j(this)}static create(e){let r=new M(e.doc?e.doc.type.schema:e.schema,e.plugins),s=new w(r);for(let n=0;n<r.fields.length;n++)s[r.fields[n].name]=r.fields[n].init(e,s);return s}reconfigure(e){let r=new M(this.schema,e.plugins),s=r.fields,n=new w(r);for(let i=0;i<s.length;i++){let o=s[i].name;n[o]=this.hasOwnProperty(o)?this[o]:s[i].init(e,n)}return n}toJSON(e){let r={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(r.storedMarks=this.storedMarks.map(s=>s.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw RangeError("The JSON fields `doc` and `selection` are reserved");let n=e[s],i=n.spec.state;i&&i.toJSON&&(r[s]=i.toJSON.call(n,this[n.key]))}return r}static fromJSON(e,r,s){if(!r)throw RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw RangeError("Required config field 'schema' missing");let n=new M(e.schema,e.plugins),i=new w(n);return n.fields.forEach(o=>{if(o.name=="doc")i.doc=W.fromJSON(e.schema,r.doc);else if(o.name=="selection")i.selection=a.fromJSON(i.doc,r.selection);else if(o.name=="storedMarks")r.storedMarks&&(i.storedMarks=r.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let l in s){let c=s[l],h=c.spec.state;if(c.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(r,l)){i[o.name]=h.fromJSON.call(c,e,r[l],i);return}}i[o.name]=o.init(e,i)}}),i}};function D(t,e,r){for(let s in t){let n=t[s];n instanceof Function?n=n.bind(e):s=="handleDOMEvents"&&(n=D(n,e,{})),r[s]=n}return r}var X=class{constructor(t){this.spec=t,this.props={},t.props&&D(t.props,this,this.props),this.key=t.key?t.key.key:B("plugin")}getState(t){return t[this.key]}},N=Object.create(null);function B(t){return t in N?t+"$"+ ++N[t]:(N[t]=0,t+"$")}var Y=class{constructor(t="key"){this.key=B(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}};export{m as AllSelection,U as EditorState,d as NodeSelection,X as Plugin,Y as PluginKey,a as Selection,b as SelectionRange,f as TextSelection,j as Transaction};