@grapesjs/studio-sdk-plugins 1.0.21 → 1.0.22-rc.0

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 (66) hide show
  1. package/dist/animationComponent/components/Animation.d.ts +6 -0
  2. package/dist/animationComponent/components/AnimationGroup.d.ts +4 -0
  3. package/dist/animationComponent/index.cjs.d.ts +3 -0
  4. package/dist/animationComponent/index.cjs.js +507 -0
  5. package/dist/animationComponent/index.d.ts +3 -0
  6. package/dist/animationComponent/index.es.d.ts +3 -0
  7. package/dist/animationComponent/index.es.js +1111 -0
  8. package/dist/animationComponent/index.umd.js +507 -0
  9. package/dist/animationComponent/shared.d.ts +3 -0
  10. package/dist/animationComponent/types.d.ts +28 -0
  11. package/dist/animationComponent/typesSchema.d.ts +48 -0
  12. package/dist/animationComponent/utils.d.ts +19 -0
  13. package/dist/dataSourceEjs/EjsExporter.d.ts +13 -0
  14. package/dist/dataSourceEjs/EjsImporter.d.ts +29 -0
  15. package/dist/dataSourceEjs/index.cjs.d.ts +2 -2
  16. package/dist/dataSourceEjs/index.cjs.js +24 -3
  17. package/dist/dataSourceEjs/index.d.ts +2 -2
  18. package/dist/dataSourceEjs/index.es.d.ts +2 -2
  19. package/dist/dataSourceEjs/index.es.js +697 -114
  20. package/dist/dataSourceEjs/index.umd.js +24 -3
  21. package/dist/dataSourceEjs/shared.d.ts +3 -0
  22. package/dist/dataSourceEjs/types.d.ts +2 -2
  23. package/dist/dataSourceEjs/typesSchema.d.ts +3 -0
  24. package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +16 -0
  25. package/dist/dataSourceHandlebars/HandlebarsImporter.d.ts +20 -0
  26. package/dist/dataSourceHandlebars/helperImplementations.d.ts +1 -0
  27. package/dist/dataSourceHandlebars/index.cjs.js +20 -1
  28. package/dist/dataSourceHandlebars/index.es.js +401 -99
  29. package/dist/dataSourceHandlebars/index.umd.js +20 -1
  30. package/dist/dataSourceHandlebars/shared.d.ts +3 -0
  31. package/dist/dataSourceHandlebars/types.d.ts +2 -2
  32. package/dist/dataSourceHandlebars/typesSchema.d.ts +3 -0
  33. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  34. package/dist/googleFontsAssetProvider/index.es.js +29 -29
  35. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  36. package/dist/iconifyComponent/index.cjs.js +2 -2
  37. package/dist/iconifyComponent/index.es.js +64 -64
  38. package/dist/iconifyComponent/index.umd.js +2 -2
  39. package/dist/index.cjs.d.ts +1 -0
  40. package/dist/index.cjs.js +587 -51
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.es.d.ts +1 -0
  43. package/dist/index.es.js +4809 -3046
  44. package/dist/index.umd.js +584 -48
  45. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  46. package/dist/layoutSidebarButtons/index.es.js +59 -59
  47. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  48. package/dist/presetPrintable/index.cjs.js +3 -3
  49. package/dist/presetPrintable/index.es.js +136 -131
  50. package/dist/presetPrintable/index.umd.js +4 -4
  51. package/dist/prosemirror/index.cjs.js +1 -1
  52. package/dist/prosemirror/index.es.js +1 -1
  53. package/dist/prosemirror/index.umd.js +1 -1
  54. package/dist/rteTinyMce/index.cjs.js +2 -2
  55. package/dist/rteTinyMce/index.es.js +67 -67
  56. package/dist/rteTinyMce/index.umd.js +2 -2
  57. package/dist/tableComponent/index.cjs.js +1 -1
  58. package/dist/tableComponent/index.es.js +14 -14
  59. package/dist/tableComponent/index.umd.js +1 -1
  60. package/dist/utilsDataSources.d.ts +28 -0
  61. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  62. package/dist/youtubeAssetProvider/index.es.js +26 -26
  63. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  64. package/package.json +2 -1
  65. package/dist/dataSourceEjs/EjsStrategy.d.ts +0 -15
  66. package/dist/dataSourceHandlebars/HandlebarsStrategy.d.ts +0 -17
@@ -7,4 +7,4 @@
7
7
  `),h&&p==u.nodeValue.length)for(let m=u,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:V(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=u.childNodes[p-1];h=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(ie&&f.focusNode&&f.focusNode!=a.node&&f.focusNode.nodeType==1){let u=f.focusNode.childNodes[f.focusOffset];u&&u.contentEditable=="false"&&(i=!0)}if(!(i||h&&J)&&Ge(l.node,l.offset,f.anchorNode,f.anchorOffset)&&Ge(a.node,a.offset,f.focusNode,f.focusOffset))return;let d=!1;if((c.extend||e==t)&&!h){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let p=l;l=a,a=p}let u=document.createRange();u.setEnd(a.node,a.offset),u.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(u)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?Fe:si,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ae:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Fe:ae}r=o}this.dirty=Fe}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Fe:si;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Zs extends Pt{constructor(e,t,r,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==ee&&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 side(){return this.widget.type.side}}class Ka extends Pt{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class _e extends Pt{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=Xe.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new _e(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ae||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ae&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ee){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ee}}slice(e,t,r){let i=_e.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=er(s,t,o,r)),e>0&&(s=er(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Re extends Pt{constructor(e,t,r,i,s,o,l,a,c){super(e,[],s,o),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),f=c&&c.dom,h=c&&c.contentDOM;if(t.isText){if(!f)f=document.createTextNode(t.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:h}=Xe.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),t.type.spec.draggable&&(f.draggable=!0));let d=f;return f=no(f,r,t),c?a=new Ua(e,t,r,i,f,h||null,d,c,s,o+1):t.isText?new bn(e,t,r,i,f,d,s):new Re(e,t,r,i,f,h||null,d,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>y.empty)}return e}matchesNode(e,t,r){return this.dirty==ee&&e.eq(this.node)&&on(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Ga(this,o&&o.node,e);Ya(this.node,this.innerDeco,(c,f,h)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?N.none:this.node.child(f).marks,r,e),a.placeWidget(c,e,i)},(c,f,h,d)=>{a.syncToMarks(c.marks,r,e);let u;a.findNodeMatch(c,f,h,d)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(u=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,f,h,u,e)||a.updateNextNode(c,f,h,e,d,i)||a.addNode(c,f,h,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Fe)&&(o&&this.protectLocalComposition(e,o),eo(this.contentDOM,this.children,e),ht&&Za(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof C)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=Qa(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;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 o=new Ka(this,s,t,i);e.input.compositionNodes.push(o),this.children=er(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==ae||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ee}updateOuterDeco(e){if(on(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=to(this.dom,this.nodeDOM,Qn(this.outerDeco,this.node,t),Qn(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function oi(n,e,t,r,i){no(r,e,n);let s=new Re(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class bn extends Re{constructor(e,t,r,i,s,o,l){super(e,t,r,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==ae||this.dirty!=ee&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ee||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=ee,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new bn(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ae)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Qs extends Pt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ee&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ua extends Re{constructor(e,t,r,i,s,o,l,a,c,f){super(e,t,r,i,s,o,l,c,f),this.spec=a}update(e,t,r,i){if(this.dirty==ae)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}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 eo(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=li(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof _e){let a=r?r.previousSibling:n.lastChild;eo(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=li(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const wt=function(n){n&&(this.nodeName=n)};wt.prototype=Object.create(null);const Le=[new wt];function Qn(n,e,t){if(n.length==0)return Le;let r=t?Le[0]:new wt,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new wt(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(r=new wt(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function to(n,e,t,r){if(t==Le&&r==Le)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Le[0]),i=a}ja(i,l||Le[0],o)}return i}function ja(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function no(n,e,t){return to(n,n,Le,Qn(e,t,n.nodeType!=1))}function on(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function li(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Ga{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=_a(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(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.dirty=ee,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;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=_e.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let o=this.top.children[i];return o.dirty==ae&&o.dom==o.contentDOM&&(o.dirty=Fe),o.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Re){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let f=a.dom,h,d=this.isLocked(f)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ae&&on(t,a.outerDeco));if(!d&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=f&&(this.changed=!0),this.index++,!0;if(!d&&(h=this.recreateWrapper(a,e,t,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=Fe,h.updateChildren(i,o+1),h.dirty=ee),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!on(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Re.create(this.top,t,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,i,s){let o=Re.create(this.top,e,t,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Zs(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof _e;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof bn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((J||$)&&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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Qs(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function _a(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof _e)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function Xa(n,e){return n.type.side-e.type.side}function Ya(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let f=n.child(c);r(f,i,e.forChild(s,f),c),s+=f.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let f,h;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(f?(h||(h=[f])).push(g):f=g)}if(f)if(h){h.sort(Xa);for(let g=0;g<h.length;g++)t(h[g],c,!!a)}else t(f,c,!!a);let d,u;if(a)u=-1,d=a,a=null;else if(c<n.childCount)u=c,d=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+d.nodeSize;if(d.isText){let g=p;o<i.length&&i[o].from<g&&(g=i[o].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<p&&(a=d.cut(g-s),d=d.cut(0,g-s),p=g,u=-1)}else for(;o<i.length&&i[o].to<p;)o++;let m=d.isInline&&!d.isLeaf?l.filter(g=>!g.inline):l.slice();r(d,m,e.forChild(s,d),u),s=p}}function Za(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Qa(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let o=n.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<n.childCount;){let c=n.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function er(n,e,t,r,i){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,f=l+=a.size;c>=t||f<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),i&&(s.push(i),i=void 0),f>t&&s.push(a.slice(t-c,a.size,r)))}return s}function yr(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(yn(t)){for(a=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&k.isSelectable(h)&&i.parent&&!(h.isInline&&Oa(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new k(o==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=o,d=o;for(let u=0;u<t.rangeCount;u++){let p=t.getRangeAt(u);h=Math.min(h,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(h<0)return null;[a,o]=d==n.state.selection.anchor?[d,h]:[h,d],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let f=r.resolve(a);if(!c){let h=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=br(n,f,l,h)}return c}function ro(n){return n.editable?n.hasFocus():so(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ye(n,e=!1){let t=n.state.selection;if(io(n,t),!!ro(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&$){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Ge(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)tc(n);else{let{anchor:r,head:i}=t,s,o;ai&&!(t instanceof C)&&(t.$from.parent.inlineContent||(s=ci(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=ci(n,t.to))),n.docView.setSelection(r,i,n,e),ai&&(s&&fi(s),o&&fi(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ec(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const ai=J||$&&Ks<63;function ci(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(J&&i&&i.contentEditable=="false")return Vn(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Vn(i);if(s)return Vn(s)}}function Vn(n){return n.contentEditable="true",J&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function fi(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function ec(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!ro(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function tc(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,V(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&j&&Ee<=11&&(r.disabled=!0,r.disabled=!1)}function io(n,e){if(e instanceof k){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(hi(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else hi(n)}function hi(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function br(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||C.between(e,t,r)}function di(n){return n.editable&&!n.hasFocus()?!1:so(n)}function so(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function nc(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Ge(e.node,e.offset,t.anchorNode,t.anchorOffset)}function tr(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&S.findFrom(s,e)}function we(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ui(n,e,t){let r=n.state.selection;if(r instanceof C)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return we(n,new C(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=tr(n.state,e);return i&&i instanceof k?we(n,i):!1}else if(!(Z&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?k.isSelectable(s)?we(n,new k(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Bt?we(n,new C(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof k&&r.node.isInline)return we(n,new C(e>0?r.$to:r.$from));{let i=tr(n.state,e);return i?we(n,i):!1}}}function ln(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Mt(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Ze(n,e){return e<0?rc(n):ic(n)}function rc(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(ie&&t.nodeType==1&&r<ln(t)&&Mt(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Mt(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(oo(t))break;{let l=t.previousSibling;for(;l&&Mt(l,-1);)i=t.parentNode,s=V(l),l=l.previousSibling;if(l)t=l,r=ln(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?nr(n,t,r):i&&nr(n,i,s)}function ic(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=ln(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Mt(l,1))s=t,o=++r;else break}else{if(oo(t))break;{let l=t.nextSibling;for(;l&&Mt(l,1);)s=l.parentNode,o=V(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=ln(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&nr(n,s,o)}function oo(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function sc(n,e){for(;n&&e==n.childNodes.length&&!zt(n);)e=V(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function oc(n,e){for(;n&&!e&&!zt(n);)e=V(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function nr(n,e,t){if(e.nodeType!=3){let s,o;(o=sc(e,t))?(e=o,t=0):(s=oc(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(yn(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&ye(n)},50)}function pi(n,e){let t=n.state.doc.resolve(e);if(!($||Aa)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function mi(n,e,t){let r=n.state.selection;if(r instanceof C&&!r.empty||t.indexOf("s")>-1||Z&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=tr(n.state,e);if(o&&o instanceof k)return we(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof X?S.near(o,e):S.findFrom(o,e);return l?we(n,l):!1}return!1}function gi(n,e){if(!(n.state.selection instanceof C))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function yi(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function lc(n){if(!J||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;yi(n,r,"true"),setTimeout(()=>yi(n,r,"false"),20)}return!1}function ac(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function cc(n,e){let t=e.keyCode,r=ac(e);if(t==8||Z&&t==72&&r=="c")return gi(n,-1)||Ze(n,-1);if(t==46&&!e.shiftKey||Z&&t==68&&r=="c")return gi(n,1)||Ze(n,1);if(t==13||t==27)return!0;if(t==37||Z&&t==66&&r=="c"){let i=t==37?pi(n,n.state.selection.from)=="ltr"?-1:1:-1;return ui(n,i,r)||Ze(n,i)}else if(t==39||Z&&t==70&&r=="c"){let i=t==39?pi(n,n.state.selection.from)=="ltr"?1:-1:1;return ui(n,i,r)||Ze(n,i)}else{if(t==38||Z&&t==80&&r=="c")return mi(n,-1,r)||Ze(n,-1);if(t==40||Z&&t==78&&r=="c")return lc(n)||mi(n,1,r)||Ze(n,1);if(r==(Z?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function lo(n,e){n.someProp("transformCopied",u=>{e=u(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let u=r.firstChild;t.push(u.type.name,u.attrs!=u.type.defaultAttrs?u.attrs:null),r=u.content}let o=n.someProp("clipboardSerializer")||Xe.fromSchema(n.state.schema),l=po(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,f,h=0;for(;c&&c.nodeType==1&&(f=uo[c.nodeName.toLowerCase()]);){for(let u=f.length-1;u>=0;u--){let p=l.createElement(f[u]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),h++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",u=>u(e,n))||e.content.textBetween(0,e.content.size,`
8
8
 
9
9
  `);return{dom:a,text:d,slice:e}}function ao(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,s||r,n)}),s)return e?new x(y.from(n.state.schema.text(e.replace(/\r\n?/g,`
10
- `))),0,0):x.empty;let h=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(h)l=h;else{let d=i.marks(),{schema:u}=n.state,p=Xe.fromSchema(u);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(u.text(m,d)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),o=uc(t),Bt&&pc(o);let c=o&&o.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let h=+f[3];h>0;h--){let d=o.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;o=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||lt.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!fc.test(d.parentNode.nodeName)?{ignore:!0}:null}})),f)l=mc(bi(l,+f[1],+f[2]),f[4]);else if(l=x.maxOpen(hc(l.content,i),!0),l.openStart||l.openEnd){let h=0,d=0;for(let u=l.content.firstChild;h<l.openStart&&!u.type.spec.isolating;h++,u=u.firstChild);for(let u=l.content.lastChild;d<l.openEnd&&!u.type.spec.isolating;d++,u=u.lastChild);l=bi(l,h,d)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const fc=/^(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 hc(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&fo(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=ho(o[o.length-1],s.length));let f=co(l,a);o.push(f),i=i.matchType(f.type),s=a}}),o)return y.from(o)}return n}function co(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,y.from(n));return n}function fo(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=fo(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(y.from(co(t,n,i+1))))}}function ho(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ho(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(y.empty,!0);return n.copy(t.append(r))}function rr(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=rr(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(y.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function bi(n,e,t){return e<n.openStart&&(n=new x(rr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new x(rr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const uo={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let xi=null;function po(){return xi||(xi=document.implementation.createHTMLDocument("title"))}let Fn=null;function dc(n){let e=window.trustedTypes;return e?(Fn||(Fn=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Fn.createHTML(n)):n}function uc(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=po().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&uo[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=dc(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function pc(n){let e=n.querySelectorAll($?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function mc(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=y.from(a.create(r[l+1],i)),s++,o++}return new x(i,s,o)}const q={},K={},gc={touchstart:!0,touchmove:!0};class yc{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function bc(n){for(let e in q){let t=q[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{kc(n,r)&&!xr(n,r)&&(n.editable||!(r.type in K))&&t(n,r)},gc[e]?{passive:!0}:void 0)}J&&n.dom.addEventListener("input",()=>null),ir(n)}function De(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function xc(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ir(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>xr(n,r))})}function xr(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function kc(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Sc(n,e){!xr(n,e)&&q[e.type]&&(n.editable||!(e.type in K))&&q[e.type](n,e)}K.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!go(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ne&&$&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ht&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Ve(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||cc(n,t)?t.preventDefault():De(n,"key")};K.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};K.keypress=(n,e)=>{let t=e;if(go(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Z&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof C)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function xn(n){return{left:n.clientX,top:n.clientY}}function Cc(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function kr(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function ot(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function wc(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&k.isSelectable(r)?(ot(n,new k(t)),!0):!1}function Mc(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof k&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(k.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(ot(n,k.create(n.state.doc,i)),!0):!1}function Oc(n,e,t,r,i){return kr(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Mc(n,t):wc(n,t))}function Nc(n,e,t,r){return kr(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Tc(n,e,t,r){return kr(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Ac(n,t,r)}function Ac(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(ot(n,C.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)ot(n,C.create(r,l+1,l+1+o.content.size));else if(k.isSelectable(o))ot(n,k.create(r,l));else continue;return!0}}function Sr(n){return an(n)}const mo=Z?"metaKey":"ctrlKey";q.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Sr(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Cc(t,n.input.lastClick)&&!t[mo]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=n.posAtCoords(xn(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Dc(n,o,t,!!r)):(s=="doubleClick"?Nc:Tc)(n,o.pos,o.inside,t)?t.preventDefault():De(n,"pointer"))};class Dc{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[mo],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let f=e.state.doc.resolve(t.pos);s=f.parent,o=f.depth?f.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof k&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ie&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),De(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ye(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(xn(e))),this.updateAllowDefault(e),this.allowDefault||!t?De(this.view,"pointer"):Oc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||J&&this.mightDrag&&!this.mightDrag.node.isAtom||$&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(ot(this.view,S.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):De(this.view,"pointer")}move(e){this.updateAllowDefault(e),De(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}q.touchstart=n=>{n.input.lastTouch=Date.now(),Sr(n),De(n,"pointer")};q.touchmove=n=>{n.input.lastTouch=Date.now(),De(n,"pointer")};q.contextmenu=n=>Sr(n);function go(n,e){return n.composing?!0:J&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Ec=ne?5e3:-1;K.compositionstart=K.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof C&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),an(n,!0),n.markCursor=null;else if(an(n,!e.selection.empty),ie&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}yo(n,Ec)};K.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,yo(n,20))};function yo(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>an(n),e))}function bo(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Ic());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Rc(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=wa(e.focusNode,e.focusOffset),r=Ma(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Ic(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function an(n,e=!1){if(!(ne&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),bo(n),e||n.docView&&n.docView.dirty){let t=yr(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function vc(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Et=j&&Ee<15||ht&&Da<604;q.copy=K.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=Et?null:t.clipboardData,o=r.content(),{dom:l,text:a}=lo(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):vc(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function zc(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Bc(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Rt(n,r.value,null,i,e):Rt(n,r.textContent,r.innerHTML,i,e)},50)}function Rt(n,e,t,r,i){let s=ao(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||x.empty)))return!0;if(!s)return!1;let o=zc(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function xo(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}K.paste=(n,e)=>{let t=e;if(n.composing&&!ne)return;let r=Et?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Rt(n,xo(r),r.getData("text/html"),i,t)?t.preventDefault():Bc(n,t)};class ko{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const So=Z?"altKey":"ctrlKey";q.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(xn(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof k?i.to-1:i.to))){if(r&&r.mightDrag)o=k.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(o=k.create(n.state.doc,h.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:f}=lo(n,l);(!t.dataTransfer.files.length||!$||Ks>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Et?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Et||t.dataTransfer.setData("text/plain",c),n.dragging=new ko(f,!t[So],o)};q.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};K.dragover=K.dragenter=(n,e)=>e.preventDefault();K.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(xn(t));if(!i)return;let s=n.state.doc.resolve(i.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=ao(n,xo(t.dataTransfer),Et?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[So]);if(n.someProp("handleDrop",p=>p(n,t,o||x.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?Dl(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let f=c.mapping.map(a),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=c.doc;if(h?c.replaceRangeWith(f,f,o.content.firstChild):c.replaceRange(f,f,o),c.doc.eq(d))return;let u=c.doc.resolve(f);if(h&&k.isSelectable(o.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new k(u));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,w)=>p=w),c.setSelection(br(n,u,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};q.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ye(n)},20))};q.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};q.beforeinput=(n,e)=>{if($&&ne&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Ve(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in K)q[n]=K[n];function It(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class cn{constructor(e,t){this.toDOM=e,this.spec=t||Ke,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new U(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof cn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&It(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ie{constructor(e,t){this.attrs=e,this.spec=t||Ke}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new U(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ie&&It(this.attrs,e.attrs)&&It(this.spec,e.spec)}static is(e){return e.type instanceof Ie}destroy(){}}class Cr{constructor(e,t){this.attrs=e,this.spec=t||Ke}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new U(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof Cr&&It(this.attrs,e.attrs)&&It(this.spec,e.spec)}destroy(){}}class U{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new U(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new U(e,e,new cn(t,r))}static inline(e,t,r,i){return new U(e,t,new Ie(r,i))}static node(e,t,r,i){return new U(e,t,new Cr(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ie}get widget(){return this.type instanceof cn}}const et=[],Ke={};class A{constructor(e,t){this.local=e.length?e:et,this.children=t.length?t:et}static create(e,t){return t.length?fn(t,e,0,Ke):L}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==L||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ke)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Pc(this.children,o||[],e,t,r,i,s):o?new A(o.sort(Ue),et):L}add(e,t){return t.length?this==L?A.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,f;if(f=wo(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,f,c+1):i.splice(s,0,a,a+l.nodeSize,fn(f,l,c+1,Ke)),s+=3}});let o=Co(s?Mo(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new A(o.length?this.local.concat(o).sort(Ue):this.local,i||this.children)}remove(e){return e.length==0||this==L?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;for(let f=0,h;f<e.length;f++)(h=e[f])&&h.from>l&&h.to<a&&(e[f]=null,(o||(o=[])).push(h));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=L?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new A(i,r):L}forChild(e,t){if(this==L)return this;if(t.isLeaf)return A.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Ie){let c=Math.max(s,a.from)-s,f=Math.min(o,a.to)-s;c<f&&(i||(i=[])).push(a.copy(c,f))}}if(i){let l=new A(i.sort(Ue),et);return r?new Oe([l,r]):l}return r||L}eq(e){if(this==e)return!0;if(!(e instanceof A)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return wr(this.localsInner(e))}localsInner(e){if(this==L)return et;if(e.inlineContent||!this.local.some(Ie.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ie||t.push(this.local[r]);return t}forEachSet(e){e(this)}}A.empty=new A([],[]);A.removeOverlap=wr;const L=A.empty;class Oe{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Ke));return Oe.from(r)}forChild(e,t){if(t.isLeaf)return A.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=L&&(s instanceof Oe?r=r.concat(s.members):r.push(s))}return Oe.from(r)}eq(e){if(!(e instanceof Oe)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?wr(r?t:t.sort(Ue)):et}static from(e){switch(e.length){case 0:return L;case 1:return e[0];default:return new Oe(e.every(t=>t instanceof A)?e:e.reduce((t,r)=>t.concat(r instanceof A?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Pc(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,f=s;c<t.maps.length;c++){let h=0;t.maps[c].forEach((d,u,p,m)=>{let g=m-p-(u-d);for(let b=0;b<l.length;b+=3){let w=l[b+1];if(w<0||d>w+f-h)continue;let O=l[b]+f-h;u>=O?l[b+1]=d<=O?-2:-1:d>=f&&g&&(l[b]+=g,l[b+1]+=g)}h+=g}),f=t.maps[c].map(f,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let f=t.map(n[c]+s),h=f-i;if(h<0||h>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),u=d-i,{index:p,offset:m}=r.content.findIndex(h),g=r.maybeChild(p);if(g&&m==h&&m+g.nodeSize==u){let b=l[c+2].mapInner(t,g,f+1,n[c]+s+1,o);b!=L?(l[c]=h,l[c+1]=u,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Vc(l,n,e,t,i,s,o),f=fn(c,r,0,o);e=f.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,d=0;h<f.children.length;h+=3){let u=f.children[h];for(;d<l.length&&l[d]<u;)d+=3;l.splice(d,0,f.children[h],f.children[h+1],f.children[h+2])}}return new A(e.sort(Ue),l)}function Co(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new U(i.from+e,i.to+e,i.type))}return t}function Vc(n,e,t,r,i,s,o){function l(a,c){for(let f=0;f<a.local.length;f++){let h=a.local[f].map(r,i,c);h?t.push(h):o.onRemove&&o.onRemove(a.local[f].spec)}for(let f=0;f<a.children.length;f+=3)l(a.children[f+2],a.children[f]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function wo(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function Mo(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function fn(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=wo(n,l,a+t);if(c){s=!0;let f=fn(c,l,t+a+1,r);f!=L&&i.push(a,a+l.nodeSize,f)}});let o=Co(s?Mo(n):n,-t).sort(Ue);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new A(o,i):L}function Ue(n,e){return n.from-e.from||n.to-e.to}function wr(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),ki(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),ki(e,i,r.copy(s.from,r.to)));break}}}return e}function ki(n,e,t){for(;e<n.length&&Ue(t,n[e])>0;)e++;n.splice(e,0,t)}function Ln(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=L&&e.push(r)}),n.cursorWrapper&&e.push(A.create(n.state.doc,[n.cursorWrapper.deco])),Oe.from(e)}const Fc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Lc=j&&Ee<=11;class Hc{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class $c{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Hc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);j&&Ee<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Lc&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Fc)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){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.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(di(this.view)){if(this.suppressingSelectionUpdates)return ye(this.view);if(j&&Ee<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ge(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Dt(s))t.add(s);for(let s=e.anchorNode;s;s=Dt(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&di(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let f=0;f<t.length;f++){let h=this.registerMutation(t[f],a);h&&(s=s<0?h.from:Math.min(h.from,s),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(l=!0))}if(ie&&a.length){let f=a.filter(h=>h.nodeName=="BR");if(f.length==2){let[h,d]=f;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of f){let u=d.parentNode;u&&u.nodeName=="LI"&&(!h||qc(e,h)!=u)&&d.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&yn(r)&&(c=yr(e))&&c.eq(S.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ye(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Wc(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ye(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;f<e.addedNodes.length;f++){let h=e.addedNodes[f];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(j&&Ee<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:h,nextSibling:d}=e.addedNodes[f];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let o=i&&i.parentNode==e.target?V(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?V(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Si=new WeakMap,Ci=!1;function Wc(n){if(!Si.has(n)&&(Si.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ie,Ci)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."),Ci=!0}}function wi(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Ge(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Jc(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return wi(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?wi(n,t):null}function qc(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Kc(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,f=a.anchorNode;if(f&&n.dom.contains(f.nodeType==1?f:f.parentNode)&&(c=[{node:f,offset:a.anchorOffset}],yn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),$&&n.input.lastKeyCode===8)for(let g=s;g>i;g--){let b=r.childNodes[g-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){s=g;break}if(!w||w.size)break}let h=n.state.doc,d=n.someProp("domParser")||lt.fromSchema(n.state.schema),u=h.resolve(o),p=null,m=d.parse(r,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:u.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Uc,context:u});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:m,sel:p,from:o,to:l}}function Uc(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(J&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||J&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const jc=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Gc(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,ke=yr(n,M);if(ke&&!n.state.selection.eq(ke)){if($&&ne&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",$o=>$o(n,Ve(13,"Enter"))))return;let Ft=n.state.tr.setSelection(ke);M=="pointer"?Ft.setMeta("pointer",!0):M=="key"&&Ft.scrollIntoView(),s&&Ft.setMeta("composition",s),n.dispatch(Ft)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Kc(n,e,t),f=n.state.doc,h=f.slice(c.from,c.to),d,u;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,u="end"):(d=n.state.selection.from,u="start"),n.input.lastKeyCode=null;let p=Yc(h.content,c.doc.content,c.from,d,u);if(p&&n.input.domChangeCount++,(ht&&n.input.lastIOSEnter>Date.now()-225||ne)&&i.some(M=>M.nodeType==1&&!jc.test(M.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",M=>M(n,Ve(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof C&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let M=Mi(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let ke=n.state.tr.setSelection(M);s&&ke.setMeta("composition",s),n.dispatch(ke)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof C&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),j&&Ee<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=f.resolve(p.start),w=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA,O;if((ht&&n.input.lastIOSEnter>Date.now()-225&&(!w||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!w&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(O=S.findFrom(c.doc.resolve(m.pos+1),1,!0))&&O.head==g.pos)&&n.someProp("handleKeyDown",M=>M(n,Ve(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Xc(f,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,Ve(8,"Backspace")))){ne&&$&&n.domObserver.suppressSelectionUpdates();return}$&&ne&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),ne&&!w&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(M){return M(n,Ve(13,"Enter"))})},20));let T=p.start,R=p.endA,I,fe,xe;if(w){if(m.pos==g.pos)j&&Ee<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ye(n),20)),I=n.state.tr.delete(T,R),fe=f.resolve(p.start).marksAcross(f.resolve(p.endA));else if(p.endA==p.endB&&(xe=_c(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))I=n.state.tr,xe.type=="add"?I.addMark(T,R,xe.mark):I.removeMark(T,R,xe.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",ke=>ke(n,T,R,M)))return;I=n.state.tr.insertText(M,T,R)}}if(I||(I=n.state.tr.replace(T,R,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let M=Mi(n,I.doc,c.sel);M&&!($&&ne&&n.composing&&M.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(M.head==T||M.head==I.mapping.map(R)-1)||j&&M.empty&&M.head==T)&&I.setSelection(M)}fe&&I.ensureMarks(fe),s&&I.setMeta("composition",s),n.dispatch(I.scrollIntoView())}function Mi(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:br(n,e.resolve(t.anchor),e.resolve(t.head))}function _c(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let f=0;f<r.length;f++)i=r[f].removeFromSet(i);for(let f=0;f<t.length;f++)s=t[f].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=f=>f.mark(l.addToSet(f.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=f=>f.mark(l.removeFromSet(f.marks));else return null;let c=[];for(let f=0;f<e.childCount;f++)c.push(a(e.child(f)));if(y.from(c).eq(n))return{mark:l,type:o}}function Xc(n,e,t,r,i){if(t-e<=i.pos-r.pos||Hn(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(Hn(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Hn(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Hn(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Yc(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&n.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&Oi(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&Oi(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function Oi(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Zc{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 yc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ei),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=Ai(this),Ti(this),this.nodeViews=Di(this),this.docView=oi(this.state.doc,Ni(this),Ln(this),this.dom,this),this.domObserver=new $c(this,(r,i,s,o)=>Gc(this,r,i,s,o)),this.domObserver.start(),bc(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&&ir(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ei),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(bo(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let u=Di(this);ef(u,this.nodeViews)&&(this.nodeViews=u,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ir(this),this.editable=Ai(this),Ti(this);let a=Ln(this),c=Ni(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(i.selection))&&(o=!0);let d=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Ia(this);if(o){this.domObserver.stop();let u=h&&(j||$)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Qc(i.selection,e.selection);if(h){let p=$?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Rc(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=oi(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(u=!0)}u||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&nc(this))?ye(this,u):(io(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():d&&va(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof k){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ei(this,t.getBoundingClientRect(),e)}else ei(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 r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new ko(e.slice,e.move,i<0?void 0:k.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(j){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&za(this.dom),ye(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return La(this,e)}coordsAtPos(e,t=1){return Xs(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,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return qa(this,t||this.state,e)}pasteHTML(e,t){return Rt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Rt(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(xc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ln(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Sa())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Sc(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?J&&this.root.nodeType===11&&Na(this.dom.ownerDocument)==this.dom&&Jc(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ni(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[U.node(0,n.state.doc.content.size,e)]}function Ti(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:U.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ai(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Qc(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Di(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function ef(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Ei(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var sr,or;if(typeof WeakMap<"u"){let n=new WeakMap;sr=e=>n.get(e),or=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;sr=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},or=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var D=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,i=e/this.width|0;let s=r+1,o=i+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:r,top:i,right:s,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:i,top:s,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?r==0:i==this.width)?null:this.map[s*this.width+(t<0?r-1:i)]:(t<0?s==0:o==this.height)?null:this.map[r+this.width*(t<0?s-1:o)]}rectBetween(n,e){const{left:t,right:r,top:i,bottom:s}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(i,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let i=n.left;i<n.right;i++){const s=r*this.width+i,o=this.map[s];t[o]||(t[o]=!0,!(i==n.left&&i&&this.map[s-1]==o||r==n.top&&r&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let r=0,i=0;;r++){const s=i+t.child(r).nodeSize;if(r==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<i;)o++;return o==l?s-1:this.map[o]}i=s}}static get(n){return sr(n)||or(n,tf(n))}};function tf(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=nf(n),t=n.childCount,r=[];let i=0,s=null;const o=[];for(let c=0,f=e*t;c<f;c++)r[c]=0;for(let c=0,f=0;c<t;c++){const h=n.child(c);f++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==h.childCount)break;const m=h.child(p),{colspan:g,rowspan:b,colwidth:w}=m.attrs;for(let O=0;O<b;O++){if(O+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:f,n:b-O});break}const T=i+O*e;for(let R=0;R<g;R++){r[T+R]==0?r[T+R]=f:(s||(s=[])).push({type:"collision",row:c,pos:f,n:g-R});const I=w&&w[R];if(I){const fe=(T+R)%e*2,xe=o[fe];xe==null||xe!=I&&o[fe+1]==1?(o[fe]=I,o[fe+1]=1):xe==I&&o[fe+1]++}}}i+=g,f+=m.nodeSize}const d=(c+1)*e;let u=0;for(;i<d;)r[i++]==0&&u++;u&&(s||(s=[])).push({type:"missing",row:c,n:u}),f++}const l=new D(e,t,r,s);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&rf(l,o,n),l}function nf(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const i=n.child(r);let s=0;if(t)for(let o=0;o<r;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){const l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function rf(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;i<n.map.length;i++){const s=n.map[i];if(r[s])continue;r[s]=!0;const o=t.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const f=(i+c)%n.width,h=e[f*2];h!=null&&(!a.colwidth||a.colwidth[c]!=h)&&((l||(l=sf(a)))[c]=h)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function sf(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Ri(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(o=>Number(o)):null,i=Number(n.getAttribute("colspan")||1),s={colspan:i,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==i?r:null};for(const o in e){const l=e[o].getFromDOM,a=l&&l(n);a!=null&&(s[o]=a)}return s}function Ii(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const r in e){const i=e[r].setDOMAttr;i&&i(n.attrs[r],t)}return t}function of(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const r in e)t[r]={default:e[r].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>Ri(r,e)}],toDOM(r){return["td",Ii(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Ri(r,e)}],toDOM(r){return["th",Ii(r,e),0]}}}}function ce(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}var Ne=new vt("selectingCells");function Vt(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function kn(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Mr(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Vt(e.$head)||lf(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function lf(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function lr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function af(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Or(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Oo(n,e,t){const r=n.node(-1),i=D.get(r),s=n.start(-1),o=i.nextCell(n.pos-s,e,t);return o==null?null:n.node(0).resolve(s+o)}function dt(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}var z=class pe extends S{constructor(e,t=e){const r=e.node(-1),i=D.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(f=>f!=t.pos-s);a.unshift(t.pos-s);const c=a.map(f=>{const h=r.nodeAt(f);if(!h)throw RangeError(`No cell with offset ${f} found`);const d=s+f+1;return new Ts(l.resolve(d),l.resolve(d+h.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(lr(r)&&lr(i)&&Or(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?pe.rowSelection(r,i):s&&this.isColSelection()?pe.colSelection(r,i):new pe(r,i)}return C.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=D.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let f=a*t.width+i.left,h=i.left;h<i.right;h++,f++){const d=t.map[f];if(s[d])continue;s[d]=!0;const u=t.findCell(d);let p=e.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const m=i.left-u.left,g=u.right-i.right;if(m>0||g>0){let b=p.attrs;if(m>0&&(b=dt(b,0,m)),g>0&&(b=dt(b,b.colspan-g,g)),u.left<i.left){if(p=p.type.createAndFill(b),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(u.top<i.top||u.bottom>i.bottom){const b={...p.attrs,rowspan:Math.min(u.bottom,i.bottom)-Math.max(u.top,i.top)};u.top<i.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(y.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new x(y.from(l),1,1)}replace(e,t=x.empty){const r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){const{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?x.empty:t)}const s=S.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new x(y.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=D.get(t),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),i+s[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=D.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(s+i.map[o.left])),l.bottom<i.height&&(t=a.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+i.map[l.left])),o.bottom<i.height&&(e=a.resolve(s+i.map[i.width*(i.height-1)+o.right-1]))),new pe(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=D.get(e),r=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(i,s)>0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof pe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=D.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(s+i.map[o.top*i.width])),l.right<i.width&&(t=a.resolve(s+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+i.map[l.top*i.width])),o.right<i.width&&(e=a.resolve(s+i.map[i.width*(o.top+1)-1]))),new pe(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new pe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new pe(e.resolve(t),e.resolve(r))}getBookmark(){return new cf(this.$anchorCell.pos,this.$headCell.pos)}};z.prototype.visible=!1;S.jsonID("cell",z);var cf=class No{constructor(e,t){this.anchor=e,this.head=t}map(e){return new No(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Or(t,r)?new z(t,r):S.near(r,1)}};function ff(n){if(!(n.selection instanceof z))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(U.node(r,r+t.nodeSize,{class:"selectedCell"}))}),A.create(n.doc,e)}function hf({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function df({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){const s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function uf(n,e,t){const r=(e||n).selection,i=(e||n).doc;let s,o;if(r instanceof k&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=z.create(i,r.from);else if(o=="row"){const l=i.resolve(r.from+1);s=z.rowSelection(l,l)}else if(!t){const l=D.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=z.create(i,a+1,c)}}else r instanceof C&&hf(r)?s=C.create(i,r.from):r instanceof C&&df(r)&&(s=C.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var pf=new vt("fix-tables");function To(n,e,t,r){const i=n.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){const a=e.child(o);for(let c=l,f=Math.min(i,o+3);c<f;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<i&&n.child(l).sameMarkup(a)?To(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function mf(n,e){let t;const r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=gf(n,i,s,t))};return e?e.doc!=n.doc&&To(e.doc,n.doc,0,r):n.doc.descendants(r),t}function gf(n,e,t,r){const i=D.get(e);if(!i.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){const c=i.problems[a];if(c.type=="collision"){const f=e.nodeAt(c.pos);if(!f)continue;const h=f.attrs;for(let d=0;d<h.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,dt(h,h.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const f=e.nodeAt(c.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const f=e.nodeAt(c.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...f.attrs,colwidth:c.colwidth})}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<i.height;a++){const f=e.child(a),h=c+f.nodeSize,d=s[a];if(d>0){let u="cell";f.firstChild&&(u=f.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<d;g++){const b=ce(n.schema)[u].createAndFill();b&&p.push(b)}const m=(a==0||o==a-1)&&l==a?c+1:h-1;r.insert(r.mapping.map(m),p)}c=h}return r.setMeta(pf,{fixTables:!0})}function Ao(n){const e=n.selection,t=Mr(n),r=t.node(-1),i=t.start(-1),s=D.get(r);return{...e instanceof z?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(t.pos-i),tableStart:i,map:s,table:r}}function yf(n){return function(e,t){if(!kn(e))return!1;if(t){const r=ce(e.schema),i=Ao(e),s=e.tr,o=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);t(s)}return!0}}function vi(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function Nr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?yf(n):function(t,r){if(!kn(t))return!1;if(r){const i=ce(t.schema),s=Ao(t),o=t.tr,l=vi("row",s,i),a=vi("column",s,i),f=(n==="column"?l:n==="row"?a:!1)?1:0,h=n=="column"?{left:0,top:f,right:1,bottom:s.map.height}:n=="row"?{left:f,top:0,right:s.map.width,bottom:1}:s,d=n=="column"?a?i.cell:i.header_cell:n=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(h).forEach(u=>{const p=u+s.tableStart,m=o.doc.nodeAt(p);m&&o.setNodeMarkup(p,d,m.attrs)}),r(o)}return!0}}Nr("row",{useDeprecatedLogic:!0});Nr("column",{useDeprecatedLogic:!0});Nr("cell",{useDeprecatedLogic:!0});function bf(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){const s=n.node(-1).child(r),o=s.lastChild;if(o)return i-1-o.nodeSize;i-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}return null}function zi(n){return function(e,t){if(!kn(e))return!1;const r=bf(Mr(e),n);if(r==null)return!1;if(t){const i=e.doc.resolve(r);t(e.tr.setSelection(C.between(i,af(i))).scrollIntoView())}return!0}}function Wt(n,e){const t=n.selection;if(!(t instanceof z))return!1;if(e){const r=n.tr,i=ce(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new x(i,0,0))}),r.docChanged&&e(r)}return!0}function xf(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const f=a?0:Math.max(0,t-1),h=a<e.childCount-1?0:Math.max(0,r-1);(f||h)&&(c=ar(ce(o).row,new x(c,f,h)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?ar(ce(o).row,new x(e,t,r)).content:e);else return null;return kf(o,l)}function kf(n,e){const t=[];for(let i=0;i<e.length;i++){const s=e[i];for(let o=s.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c<i+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(y.empty),t[i]<r){const s=ce(n).cell.createAndFill(),o=[];for(let l=t[i];l<r;l++)o.push(s);e[i]=e[i].append(y.from(o))}return{height:e.length,width:r,rows:e}}function ar(n,e){const t=n.createAndFill();return new Ns(t).replace(0,t.content.size,e).doc}function Sf({width:n,height:e,rows:t},r,i){if(n!=r){const s=[],o=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let f=s[l]||0,h=0;f<r;h++){let d=a.child(h%a.childCount);f+d.attrs.colspan>r&&(d=d.type.createChecked(dt(d.attrs,d.attrs.colspan,f+d.attrs.colspan-r),d.content)),c.push(d),f+=d.attrs.colspan;for(let u=1;u<d.attrs.rowspan;u++)s[l+u]=(s[l+u]||0)+d.attrs.colspan}o.push(y.from(c))}t=o,n=r}if(e!=i){const s=[];for(let o=0,l=0;o<i;o++,l++){const a=[],c=t[l%e];for(let f=0;f<c.childCount;f++){let h=c.child(f);o+h.attrs.rowspan>i&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,i-h.attrs.rowspan)},h.content)),a.push(h)}s.push(y.from(a))}t=s,e=i}return{width:n,height:e,rows:t}}function Cf(n,e,t,r,i,s,o){const l=n.doc.type.schema,a=ce(l);let c,f;if(i>e.width)for(let h=0,d=0;h<e.height;h++){const u=t.child(h);d+=u.nodeSize;const p=[];let m;u.lastChild==null||u.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=f||(f=a.header_cell.createAndFill());for(let g=e.width;g<i;g++)p.push(m);n.insert(n.mapping.slice(o).map(d-1+r),p)}if(s>e.height){const h=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,i);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;h.push(g?f||(f=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,y.from(h)),u=[];for(let p=e.height;p<s;p++)u.push(d);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),u)}return!!(c||f)}function Bi(n,e,t,r,i,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=i;c<s;c++){const f=o*e.width+c,h=e.map[f];if(e.map[f-e.width]==h){a=!0;const d=t.nodeAt(h),{top:u,left:p}=e.findCell(h);n.setNodeMarkup(n.mapping.slice(l).map(h+r),null,{...d.attrs,rowspan:o-u}),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),d.type.createAndFill({...d.attrs,rowspan:u+d.attrs.rowspan-o})),c+=d.attrs.colspan-1}}return a}function Pi(n,e,t,r,i,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=i;c<s;c++){const f=c*e.width+o,h=e.map[f];if(e.map[f-1]==h){a=!0;const d=t.nodeAt(h),u=e.colCount(h),p=n.mapping.slice(l).map(h+r);n.setNodeMarkup(p,null,dt(d.attrs,o-u,d.attrs.colspan-(o-u))),n.insert(p+d.nodeSize,d.type.createAndFill(dt(d.attrs,0,o-u))),c+=d.attrs.rowspan-1}}return a}function Vi(n,e,t,r,i){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let o=D.get(s);const{top:l,left:a}=r,c=a+i.width,f=l+i.height,h=n.tr;let d=0;function u(){if(s=t?h.doc.nodeAt(t-1):h.doc,!s)throw new Error("No table found");o=D.get(s),d=h.mapping.maps.length}Cf(h,o,s,t,c,f,d)&&u(),Bi(h,o,s,t,a,c,l,d)&&u(),Bi(h,o,s,t,a,c,f,d)&&u(),Pi(h,o,s,t,l,f,a,d)&&u(),Pi(h,o,s,t,l,f,c,d)&&u();for(let p=l;p<f;p++){const m=o.positionAt(p,a,s),g=o.positionAt(p,c,s);h.replace(h.mapping.slice(d).map(m+t),h.mapping.slice(d).map(g+t),new x(i.rows[p-l],0,0))}u(),h.setSelection(new z(h.doc.resolve(t+o.positionAt(l,a,s)),h.doc.resolve(t+o.positionAt(f-1,c-1,s)))),e(h)}var wf=Js({ArrowLeft:Jt("horiz",-1),ArrowRight:Jt("horiz",1),ArrowUp:Jt("vert",-1),ArrowDown:Jt("vert",1),"Shift-ArrowLeft":qt("horiz",-1),"Shift-ArrowRight":qt("horiz",1),"Shift-ArrowUp":qt("vert",-1),"Shift-ArrowDown":qt("vert",1),Backspace:Wt,"Mod-Backspace":Wt,Delete:Wt,"Mod-Delete":Wt});function Gt(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Jt(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;if(s instanceof z)return Gt(t,r,S.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=Do(i,n,e);if(o==null)return!1;if(n=="horiz")return Gt(t,r,S.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=Oo(l,n,e);let c;return a?c=S.near(a,1):e<0?c=S.near(t.doc.resolve(l.before(-1)),-1):c=S.near(t.doc.resolve(l.after(-1)),1),Gt(t,r,c)}}}function qt(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;let o;if(s instanceof z)o=s;else{const a=Do(i,n,e);if(a==null)return!1;o=new z(t.doc.resolve(a))}const l=Oo(o.$headCell,n,e);return l?Gt(t,r,new z(o.$anchorCell,l)):!1}}function Mf(n,e){const t=n.state.doc,r=Vt(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new z(r))),!0):!1}function Of(n,e,t){if(!kn(n.state))return!1;let r=xf(t);const i=n.state.selection;if(i instanceof z){r||(r={width:1,height:1,rows:[y.from(ar(ce(n.state.schema).cell,t))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=D.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=Sf(r,l.right-l.left,l.bottom-l.top),Vi(n.state,n.dispatch,o,l,r),!0}else if(r){const s=Mr(n.state),o=s.start(-1);return Vi(n.state,n.dispatch,o,D.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function Nf(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Fi(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof z)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Vt(n.state.selection.$anchor))!=null&&((t=$n(n,e))==null?void 0:t.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(a,c){let f=$n(n,c);const h=Ne.getState(n.state)==null;if(!f||!Or(a,f))if(h)f=a;else return;const d=new z(a,f);if(h||!n.state.selection.eq(d)){const u=n.state.tr.setSelection(d);h&&u.setMeta(Ne,a.pos),n.dispatch(u)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),Ne.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ne,-1))}function l(a){const c=a,f=Ne.getState(n.state);let h;if(f!=null)h=n.state.doc.resolve(f);else if(Fi(n,c.target)!=r&&(h=$n(n,e),!h))return o();h&&s(h,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function Do(n,e,t){if(!(n.state.selection instanceof C))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Fi(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function $n(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Vt(n.state.doc.resolve(t.pos)):null}var Tf=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),cr(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,cr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function cr(n,e,t,r,i,s){var o;let l=0,a=!0,c=e.firstChild;const f=n.firstChild;if(f){for(let h=0,d=0;h<f.childCount;h++){const{colspan:u,colwidth:p}=f.child(h).attrs;for(let m=0;m<u;m++,d++){const g=i==d?s:p&&p[m],b=g?g+"px":"";if(l+=g||r,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;c;){const h=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=h}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var _=new vt("tableColumnResizing");function Af({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=Tf,lastColumnResizable:i=!0}={}){const s=new ut({key:_,state:{init(o,l){var a,c;const f=(c=(a=s.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,h=ce(l.schema).table.name;return r&&f&&(f[h]=(d,u)=>new r(d,t,u)),new Df(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=_.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{Ef(o,l,n,i)},mouseleave:o=>{Rf(o)},mousedown:(o,l)=>{If(o,l,e,t)}},decorations:o=>{const l=_.getState(o);if(l&&l.activeHandle>-1)return Vf(o,l.activeHandle)},nodeViews:{}}});return s}var Df=class _t{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(_);if(r&&r.setHandle!=null)return new _t(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new _t(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return lr(e.doc.resolve(i))||(i=-1),new _t(i,t.dragging)}return t}};function Ef(n,e,t,r){const i=_.getState(n.state);if(i&&!i.dragging){const s=zf(e.target);let o=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=t?o=Li(n,e,"left",t):a-e.clientX<=t&&(o=Li(n,e,"right",t))}if(o!=i.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=D.get(a),f=l.start(-1);if(c.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Eo(n,o)}}}function Rf(n){const e=_.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Eo(n,-1)}function If(n,e,t,r){var i;const s=(i=n.dom.ownerDocument.defaultView)!=null?i:window,o=_.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=vf(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(_,{setDragging:{startX:e.clientX,startWidth:a}}));function c(h){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",f);const d=_.getState(n.state);d!=null&&d.dragging&&(Bf(n,d.activeHandle,Hi(d.dragging,h,t)),n.dispatch(n.state.tr.setMeta(_,{setDragging:null})))}function f(h){if(!h.which)return c(h);const d=_.getState(n.state);if(d&&d.dragging){const u=Hi(d.dragging,h,t);$i(n,d.activeHandle,u,r)}}return $i(n,o.activeHandle,a,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",f),e.preventDefault(),!0}function vf(n,e,{colspan:t,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=n.domAtPos(e);let l=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function zf(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Li(n,e,t,r){const i=t=="right"?-r:r,s=n.posAtCoords({left:e.clientX+i,top:e.clientY});if(!s)return-1;const{pos:o}=s,l=Vt(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=D.get(l.node(-1)),c=l.start(-1),f=a.map.indexOf(l.pos-c);return f%a.width==0?-1:c+a.map[f-1]}function Hi(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Eo(n,e){n.dispatch(n.state.tr.setMeta(_,{setHandle:e}))}function Bf(n,e,t){const r=n.state.doc.resolve(e),i=r.node(-1),s=D.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){const f=c*s.width+l;if(c&&s.map[f]==s.map[f-s.width])continue;const h=s.map[f],d=i.nodeAt(h).attrs,u=d.colspan==1?0:l-s.colCount(h);if(d.colwidth&&d.colwidth[u]==t)continue;const p=d.colwidth?d.colwidth.slice():Pf(d.colspan);p[u]=t,a.setNodeMarkup(o+h,null,{...d,colwidth:p})}a.docChanged&&n.dispatch(a)}function $i(n,e,t,r){const i=n.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=D.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1;let a=n.domAtPos(i.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&cr(s,a.firstChild,a,r,l,t)}function Pf(n){return Array(n).fill(0)}function Vf(n,e){var t;const r=[],i=n.doc.resolve(e),s=i.node(-1);if(!s)return A.empty;const o=D.get(s),l=i.start(-1),a=o.colCount(i.pos-l)+i.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const f=a+c*o.width;if((a==o.width-1||o.map[f]!=o.map[f+1])&&(c==0||o.map[f]!=o.map[f-o.width])){const h=o.map[f],d=l+h+s.nodeAt(h).nodeSize-1,u=document.createElement("div");u.className="column-resize-handle",(t=_.getState(n))!=null&&t.dragging&&r.push(U.node(l+h,l+h+s.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),r.push(U.widget(d,u))}}return A.create(n.doc,r)}function Ff({allowTableNodeSelection:n=!1}={}){return new ut({key:Ne,state:{init(){return null},apply(e,t){const r=e.getMeta(Ne);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:i,pos:s}=e.mapping.mapResult(t);return i?null:s}},props:{decorations:ff,handleDOMEvents:{mousedown:Nf},createSelectionBetween(e){return Ne.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Mf,handleKeyDown:wf,handlePaste:Of},appendTransaction(e,t,r){return uf(r,mf(r,t),n)}})}const Ro="app.grapesjs.com",Io="app-stage.grapesjs.com",Wi=[Ro,Io,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Lf="license:check:start",Hf="license:check:end",$f=()=>typeof window<"u",Wf=({isDev:n,isStage:e})=>`${n?"":`https://${e?Io:Ro}`}/api`,Jf=()=>{const n=$f()&&window.location.hostname;return!!n&&(Wi.includes(n)||Wi.some(e=>n.endsWith(e)))};async function qf({path:n,baseApiUrl:e,method:t="GET",headers:r={},params:i,body:s}){const l=`${e||Wf({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...r}};s&&(a.body=JSON.stringify(s));const c=i?new URLSearchParams(i).toString():"",f=c?`?${c}`:"",h=await fetch(`${l}${f}`,a);if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return h.json()}var nt=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(nt||{}),hn=(n=>(n.toastAdd="studio:toastAdd",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.sidebarLeftSet="studio:sidebarLeft:set",n.sidebarLeftGet="studio:sidebarLeft:get",n.sidebarLeftToggle="studio:sidebarLeft:toggle",n.sidebarRightSet="studio:sidebarRight:set",n.sidebarRightGet="studio:sidebarRight:get",n.sidebarRightToggle="studio:sidebarRight:toggle",n.sidebarTopSet="studio:sidebarTop:set",n.sidebarTopGet="studio:sidebarTop:get",n.sidebarTopToggle="studio:sidebarTop:toggle",n.sidebarBottomSet="studio:sidebarBottom:set",n.sidebarBottomGet="studio:sidebarBottom:get",n.sidebarBottomToggle="studio:sidebarBottom:toggle",n.symbolAdd="studio:symbolAdd",n.symbolDetach="studio:symbolDetach",n.symbolOverride="studio:symbolOverride",n.symbolPropagateStyles="studio:propagateStyles",n.getPagesConfig="studio:getPagesConfig",n.setPagesConfig="studio:setPagesConfig",n.getPageSettings="studio:getPageSettings",n.setPageSettings="studio:setPageSettings",n.projectFiles="studio:projectFiles",n.canvasReload="studio:canvasReload",n.getBlocksPanel="studio:getBlocksPanel",n.setBlocksPanel="studio:setBlocksPanel",n.getStateContextMenu="studio:getStateContextMenu",n.setStateContextMenu="studio:setStateContextMenu",n.contextMenuComponent="studio:contextMenuComponent",n.layoutAdd="studio:layoutAdd",n.layoutRemove="studio:layoutRemove",n.layoutToggle="studio:layoutToggle",n.layoutUpdate="studio:layoutUpdate",n.layoutGet="studio:layoutGet",n.layoutConfigGet="studio:layoutConfigGet",n.layoutConfigSet="studio:layoutConfigSet",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.assetProviderGet="studio:assetProviderGet",n.assetProviderAdd="studio:assetProviderAdd",n.assetProviderRemove="studio:assetProviderRemove",n.fontGet="studio:fontGet",n.fontAdd="studio:fontAdd",n.fontRemove="studio:fontRemove",n.fontManagerOpen="studio:fontManagerOpen",n.menuFontLoad="studio:menuFontLoad",n.toggleStateDataSource="studio:toggleStateDataSource",n.getStateDataSource="studio:getStateDataSource",n.setDragAbsolute="studio:setDragAbsolute",n))(hn||{});const Ji={[nt.free]:0,[nt.startup]:10,[nt.business]:20,[nt.enterprise]:30};function Kf(n){const e=n;return e.init=t=>r=>n(r,t),e}const Uf=n=>Kf(n);async function jf({editor:n,plan:e,pluginName:t,licenseKey:r,cleanup:i}){let s="",o=!1;const l=Jf(),a=f=>{console.warn("Cleanup plugin:",t,"Reason:",f),i()},c=(f={})=>{var m;const{error:h,sdkLicense:d}=f,u=(m=f.plan)==null?void 0:m.category;if(!(d||f.license)||h)a(h||"Invalid license");else if(u){const g=Ji[e],b=Ji[u];g>b&&a({pluginRequiredPlan:e,licensePlan:u})}};n.on(Lf,f=>{s=f==null?void 0:f.baseApiUrl,o=!0}),n.on(Hf,f=>{c(f)}),setTimeout(async()=>{if(!o){if(l)return;if(r){const f=await Gf({licenseKey:r,pluginName:t,baseApiUrl:s});f&&c(f)}else a("The `licenseKey` option not provided")}},2e3)}async function Gf(n){const{licenseKey:e,pluginName:t,baseApiUrl:r}=n;try{return(await qf({baseApiUrl:r,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const Ot=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},qi="data-gs-mrk-fs",Ki="data-gs-ib",dn="data-gs-ifrg",be="attrs",vo={[be]:{default:"{}"}},de={[be]:{default:{}}},zo=n=>({[be]:JSON.stringify(Ot(n))}),ue=n=>({attrs:Ot(n)}),mt=n=>e=>[n,e.attrs.attrs,0],Me=n=>n.attrs[be]?JSON.parse(n.attrs[be]):{},_f={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${dn}]`,getAttrs:ue}],toDOM:()=>["span",{[dn]:""},0]},div:{group:"block",content:"inline*",attrs:de,parseDOM:[{tag:"div",getAttrs:ue}],toDOM:mt("div")},paragraph:{group:"block",content:"inline*",attrs:de,parseDOM:[{tag:"p",getAttrs:ue}],toDOM:mt("p")},orderedList:{group:"block",content:"listItem+",attrs:de,parseDOM:[{tag:"ol",getAttrs:ue}],toDOM:mt("ol")},bulletList:{group:"block",content:"listItem+",attrs:de,parseDOM:[{tag:"ul",getAttrs:ue}],toDOM:mt("ul")},listItem:{content:"block*",group:"block",attrs:de,parseDOM:[{tag:"li",getAttrs:ue}],toDOM:mt("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:de,parseDOM:[{tag:"pre",getAttrs:ue}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:de,parseDOM:[{tag:"img[src]",getAttrs:ue}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Ki}]`}],toDOM(){return["br",{[Ki]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:de,parseDOM:[{tag:"br",getAttrs:ue}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:Ot(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...of({tableGroup:"block",cellContent:"block+",cellAttributes:{[be]:{default:de[be].default,getFromDOM:Ot,setDOMAttr:(n,e)=>{n&&Object.assign(e,n)}},background:{default:null,getFromDOM(n){return n.style.backgroundColor||null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`background-color: ${n};`)}}}}),nonTextNode:{group:"block",content:"block*",attrs:{tagName:{default:"span"},attrs:{default:{}}},parseDOM:[{tag:"*:not(tbody)",getAttrs:n=>({tagName:n.tagName.toLowerCase(),attrs:Ot(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},gt=(n,e)=>({attrs:vo,parseDOM:n.map(t=>({tag:t,getAttrs:zo})),toDOM:e}),Xf={strong:gt(["strong","b"],n=>["b",Me(n)]),link:gt(["a"],n=>["a",Me(n),0]),em:gt(["em","i"],n=>["em",Me(n)]),underline:gt(["u"],n=>["u",Me(n),0]),strikethrough:gt(["s"],n=>["s",Me(n),0]),font_size:{attrs:{...vo,size:{default:null}},parseDOM:[{tag:`span[${qi}]`,getAttrs:n=>({...zo(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...Me(n),[qi]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Ui=new il({nodes:_f,marks:Xf}),Sn=new WeakMap,Tr=new WeakMap,Yf=(n,e)=>{Sn.set(n,e),Tr.set(e,n)},Zf=(n,e)=>{Sn.delete(n),Tr.delete(e)},Wn=n=>Sn.get(n),Qf=n=>Tr.get(n),ji=n=>{var t;const e=Qf(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},eh=n=>n.dispatchEvent(new CustomEvent("input"));function th(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(dn)){if(t.getAttribute("style")){t.removeAttribute(dn);return}const r=t.parentElement;if(r){for(;t.firstChild;)r.insertBefore(t.firstChild,t);r.removeChild(t)}}else Array.from(t.children).forEach(r=>e(r))};e(n)}function nh(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,r=f=>n.getSelectedAll().includes(f),i=f=>f.isInstanceOf("text")&&!f.isChildOf("text"),s=f=>f.isChildOf("text"),o=f=>n.getEditing()===f,l=(f,h={})=>{f.trigger("focus",h.event)},a=(f,h)=>{r(f)&&i(f)&&!o(f)&&l(f,h)},c=(f,h)=>{if(r(f)&&!i(f)&&s(f)){const d=f.parents().find(u=>u.isInstanceOf("text"));d&&(l(d,h),setTimeout(()=>n.select(d),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const rh=(n,e)=>{const t=ih(n);return t&&uh(t)?sh(n,e):t?Bs(()=>({type:n.schema.nodes.div}))(n,e):!1};function ih(n){const e=n.selection.$from;if(e.node(e.depth).type===n.schema.nodes.inlineFragment){const t=e.depth-1;return e.node(t)}return e.node(e.depth)}function sh(n,e){const{selection:t,schema:r,tr:i}=n;i.split(t.from,1);const s=t.from+1,o=i.doc.nodeAt(s),l={...o.attrs.attrs,id:void 0},a=o.textContent.length>0,c=o.textContent.length||0,f=o.textContent||" ",h=r.text(f),d=r.nodes.div.create(l,a?h:[],[]);return i.replaceRangeWith(s,s+c+2,d),i.setSelection(C.create(i.doc,s+1)),e==null||e(i.scrollIntoView()),!0}function oh(n,e,t){const{state:r,dispatch:i}=n,{selection:s,tr:o}=r,l=(a,c,f)=>{const h={};return a.split(";").forEach(d=>{const[u,p]=d.split(":").map(m=>m.trim());u&&(h[u]=p)}),h[c]=f,Object.entries(h).map(([d,u])=>`${d}: ${u}`).join("; ")};if(!s.empty||t)o.doc.nodesBetween(s.from,s.to,(a,c)=>{var f,h;if(a.type===r.schema.nodes.image){const d=l(((f=a.attrs.attrs)==null?void 0:f.style)||"","float",e);o.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:d}})}else if(a.type.isBlock){const d=l(((h=a.attrs.attrs)==null?void 0:h.style)||"","text-align",e);Bo(a)?o.setBlockType(s.from,void 0,r.schema.nodes.div,{attrs:{style:d}}):o.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:d}})}});else{const a=r.doc.resolve(s.from),c=a.start(a.depth),f=r.doc.nodeAt(c);if(f!=null&&f.type.isBlock){const h=l(f.attrs.style||"","text-align",e);o.setNodeMarkup(c,void 0,{...f.attrs,style:h})}}o.docChanged&&i(o.scrollIntoView())}const yt=(n,e)=>{const{from:t,to:r}=n.selection;let i=!1;return n.doc.nodesBetween(t,r,s=>{if(i)return!1;s.marks.some(o=>o.type===e)&&(i=!0)}),i};function lh(n,e,t="_blank"){const{state:r,dispatch:i}=n,{schema:s,selection:o,tr:l}=r,a=s.marks.link;try{const c=a.create({[be]:JSON.stringify({href:e,target:t})});l.addMark(o.from,o.to,c),i(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function ah(n,e){const{state:t,dispatch:r}=n,{selection:i,tr:s}=t;if(i.empty)return;const o=t.schema.marks.font_size;if(!o){console.error("Font size mark is not defined in the schema.");return}s.addMark(i.from,i.to,o.create({size:e})),r(s.scrollIntoView())}const He=(n,e)=>{const{doc:t,selection:r}=n.state,i=t.resolve(r.from);for(let s=i.depth;s>0;s--){const o=i.node(s);if(e(o))return{pos:s>0?i.before(s):0,start:i.start(s),depth:s,node:o}}},ch=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,r])=>(t=t.replace(/-./g,i=>i.toUpperCase()[1]).trim(),e[t]=`${r}`.trim(),e),{});function fh(...n){return(e,t)=>{const r=o=>{e=e.apply(o),t==null||t(o)},i=n.pop();return n.reduce((o,l)=>o||l(e,r),!1)&&i!==void 0&&i(e,t)}}const hh=(n,e)=>{const{state:t,dispatch:r}=n;if(e!=null&&e.event){const{event:i}=e,s=n.posAtCoords({left:i.clientX,top:i.clientY});s!=null&&s.pos&&r(t.tr.setSelection(C.create(t.doc,s.pos)))}else Ps(t,r);setTimeout(()=>setTimeout(()=>n.focus()))},fr=n=>n.isBlock,Bo=n=>n.type.name==="inlineFragment",dh=n=>fr(n)&&!Bo(n),Po=n=>n.type.name==="bulletList",Vo=n=>n.type.name==="orderedList",uh=n=>n.type.name==="heading",ph=n=>Po(n)||Vo(n),Gi=(n,e)=>{var s,o;const t=(s=He(n,l=>l.type===e))==null?void 0:s.node,r=n.state.schema.nodes.listItem;let i;return t?i=Gn(r):(o=He(n,ph))!=null&&o.node?i=fh(Gn(r),Yr(e)):i=Yr(e),i(n.state,n.dispatch)},Fo=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(r=>r.type.name===e)},mh=n=>{var o;const{view:e,prop:t,editor:r,propCSS:i}=n,s=(o=He(e,dh))==null?void 0:o.node;if(s){const l=s.attrs.attrs||{},a=ch(l.style);if(t in a)return a[t]||"";if(l.id){const c=r.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[i]||""}}return""},gh=n=>{const{view:e,prop:t,markName:r,editor:i,propCSS:s}=n,o=Fo(e,r);if(o){const l=o.attrs;if(l[t])return l[t];if(l[be]){const a=Me(o).id;if(a){const c=i.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[s]||""}}}return""},Lo=(n,e)=>{const{dispatch:t}=n,{nodes:r,marks:i}=n.state.schema;return{text:{selected:()=>{const{selection:s,doc:o}=n.state;return o.textBetween(s.from,s.to," ")},replace:(s,o={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(s));o.select&&(c=c.setSelection(C.create(c.doc,a,a+s.length))),t==null||t(c)}},bold:{toggle:()=>Pe(i.strong)(n.state,t),isActive:()=>yt(n.state,i.strong)},italic:{toggle:()=>Pe(i.em)(n.state,t),isActive:()=>yt(n.state,i.em)},underline:{toggle:()=>Pe(i.underline)(n.state,t),isActive:()=>yt(n.state,i.underline)},strikethrough:{toggle:()=>Pe(i.strikethrough)(n.state,t),isActive:()=>yt(n.state,i.strikethrough)},link:{get:()=>{const s=ji(n);if(s!=null&&s.is("link"))return s.getAttributes();{const o=Fo(n,"link");return o?Me(o):{}}},toggle:()=>Pe(i.link)(n.state,t),isActive:()=>yt(n.state,i.link),create:s=>{const o=ji(n);o!=null&&o.is("link")?(o.addAttributes({href:s.url,target:s.target}),n.focus()):lh(n,s.url,s.target)}},alignText:{get:()=>mh({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:s=>oh(n,s.value,!0)},fontSize:{get:()=>gh({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:s=>ah(n,s.value)},image:{open(){const s="assetLayout",{state:o,dispatch:l}=n,{selection:a,doc:c}=o,f=c.textBetween(a.from,a.to," "),h={id:s,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:d=>{const u={alt:f,src:d.asset.getSrc()};l(o.tr.replaceSelectionWith(r.image.createAndFill({attrs:u})))}}};e.runCommand(hn.layoutToggle,h)}},heading:{get:()=>{var o;const s=(o=He(n,fr))==null?void 0:o.node;return`${(s==null?void 0:s.attrs.level)||""}`},set:({value:s})=>{var a;const{state:o}=n,l=(a=He(n,fr))==null?void 0:a.node;Yl(o.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:s?parseInt(s,10):0})(o,t)}},listBullet:{isActive:()=>{var s;return!!((s=He(n,Po))!=null&&s.node)},toggle:()=>Gi(n,r.bulletList)},listOrdered:{isActive:()=>{var s;return!!((s=He(n,Vo))!=null&&s.node)},toggle:()=>Gi(n,r.orderedList)}}};class Be{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?yh(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}}function yh(n){return function(e,t,r,i){let s=n;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),r+=o;let l=r-i;l>0&&(s=t[0].slice(o-l,o)+s,r=i)}return e.tr.insertText(s,r,i)}}const bh=500;function xh({rules:n}){let e=new ut({state:{init(){return null},apply(t,r){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,s){return _i(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&_i(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function _i(n,e,t,r,i,s){if(n.composing)return!1;let o=n.state,l=o.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-bh),l.parentOffset,null,"")+r;for(let c=0;c<i.length;c++){let f=i[c];if(l.parent.type.spec.code){if(!f.inCode)continue}else if(f.inCode==="only")continue;let h=f.match.exec(a),d=h&&f.handler(o,h,e-(h[0].length-r.length),t);if(d)return f.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const kh=new Be(/--$/,"—"),Sh=new Be(/\.\.\.$/,"…"),Ch=new Be(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),wh=new Be(/"$/,"”"),Mh=new Be(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Oh=new Be(/'$/,"’"),Nh=[Ch,wh,Mh,Oh];function Ar(n,e,t=null,r){return new Be(n,(i,s,o,l)=>{let a=t instanceof Function?t(s):t,c=i.tr.delete(o,l),f=c.doc.resolve(o),h=f.blockRange(),d=h&&xs(h,e,a);if(!d)return null;c.wrap(h,d);let u=c.doc.resolve(o-1).nodeBefore;return u&&u.type==e&&mn(c.doc,o-1)&&(!r||r(s,u))&&c.join(o-1),c})}function Ho(n,e,t=null){return new Be(n,(r,i,s,o)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,o).setBlockType(s,s,e,a):null})}function Th(n){return Ar(/^\s*>\s$/,n)}function Ah(n){return Ar(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Dh(n){return Ar(/^\s*([-+*])\s$/,n)}function Eh(n){return Ho(/^```$/,n)}function Rh(n,e){return Ho(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function Ih(n){const e=Nh.concat(Sh,kh);let t;return(t=n.nodes.blockquote)&&e.push(Th(t)),(t=n.nodes.orderedList)&&e.push(Ah(t)),(t=n.nodes.bulletList)&&e.push(Dh(t)),(t=n.nodes.codeBlock)&&e.push(Eh(t)),(t=n.nodes.heading)&&e.push(Rh(t,6)),xh({rules:e})}const vh="rteProseMirror",zh=nt.free,te="rte:selectionchange",Y={bold:'<svg viewBox="0 0 24 24"><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',italic:'<svg viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',underline:'<svg viewBox="0 0 24 24"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" /></svg>',strikethrough:'<svg viewBox="0 0 24 24"><path d="M7.2 9.8c-1.2-2.3.5-5 2.9-5.5 3.1-1 7.6.4 7.5 4.2h-3l-.1-.8c-.2-.6-.6-.9-1.2-1.1-.8-.3-2.1-.2-2.8.3C9 8.2 10.4 9.5 12 10H7.4l-.2-.2M21 13v-2H3v2h9.6l.6.2c.6.3 1.1.5 1.3 1.1.1.4.2.9 0 1.3-.2.5-.6.7-1.1.9-1.8.5-4-.2-3.9-2.4h-3c-.1 2.6 2.1 4.4 4.5 4.7 3.8.8 8.3-1.6 6.3-5.9l3.7.1Z"/></svg>',link:'<svg viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',image:'<svg viewBox="0 0 24 24"><path d="M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z"></path></svg>',listBullet:'<svg viewBox="0 0 24 24"><path d="M7 5h14v2H7V5m0 8v-2h14v2H7M4 4.5A1.5 1.5 0 0 1 5.5 6 1.5 1.5 0 0 1 4 7.5 1.5 1.5 0 0 1 2.5 6 1.5 1.5 0 0 1 4 4.5m0 6A1.5 1.5 0 0 1 5.5 12 1.5 1.5 0 0 1 4 13.5 1.5 1.5 0 0 1 2.5 12 1.5 1.5 0 0 1 4 10.5M7 19v-2h14v2H7m-3-2.5A1.5 1.5 0 0 1 5.5 18 1.5 1.5 0 0 1 4 19.5 1.5 1.5 0 0 1 2.5 18 1.5 1.5 0 0 1 4 16.5Z"/></svg>',listOrdered:'<svg viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.3-7a.8.8 0 0 1 .7.8c0 .1 0 .3-.2.5L3 13h2v1H2v-1l2-2H2v-1h2.3Z"/></svg>',alignTextLeft:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>',alignTextCenter:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>',alignTextRight:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>',alignTextJustify:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /></svg>'},Bh=(n,e)=>{var a;const{editor:t,el:r}=n,i=Sn.get(r),s=Lo(i,t),o={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:Y.bold,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.bold.isActive()})}},onClick:({setState:c})=>{s.bold.toggle(),c({active:s.bold.isActive()})}},italic:{id:"italic",icon:Y.italic,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.italic.isActive()})}},onClick:({setState:c})=>{s.italic.toggle(),c({active:s.italic.isActive()})}},underline:{id:"underline",icon:Y.underline,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.underline.isActive()})}},onClick:({setState:c})=>{s.underline.toggle(),c({active:s.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:Y.strikethrough,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.strikethrough.isActive()})}},onClick:({setState:c})=>{s.strikethrough.toggle(),c({active:s.strikethrough.isActive()})}},image:{id:"image",icon:Y.image,size:"s",type:"button",onClick:()=>s.image.open()},link:{id:"link",icon:Y.link,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.link.isActive(),disabled:i.state.selection.empty})}},onClick:({event:c})=>{const f=c.currentTarget||c.target,{x:h,y:d,width:u,height:p}=f.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(hn.layoutRemove,{id:m}),b=s.link.get(),w={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:h,y:d,w:u,h:p},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:O=>{O.preventDefault();const T=new FormData(O.currentTarget);s.link.create({url:T.get("url"),target:T.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(b==null?void 0:b.href)||"",onChange:({value:O,setState:T})=>T({value:O})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(b==null?void 0:b.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:O,setState:T})=>T({value:O})},{type:"row",style:{gap:10,justifyContent:"end"},children:[s.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{s.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(hn.layoutToggle,w)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:Y.alignTextLeft},{id:"center",icon:Y.alignTextCenter},{id:"right",icon:Y.alignTextRight},{id:"justify",icon:Y.alignTextJustify}],editorEvents:{[te]:({setState:c})=>{c({value:s.alignText.get()})}},onChange:({value:c,setState:f})=>{f({value:c}),s.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:Y.listBullet,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.listBullet.isActive()})}},onClick:({setState:c})=>{s.listBullet.toggle(),c({active:s.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:Y.listOrdered,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.listOrdered.isActive()})}},onClick:({setState:c})=>{s.listOrdered.toggle(),c({active:s.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[te]:({setState:c})=>{c({value:s.heading.get()})}},onChange:({value:c,setState:f})=>{f({value:c}),s.heading.set({value:c}),i.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[te]:({setState:c})=>{c({value:s.fontSize.get()})}},onChange:({value:c,setState:f})=>{f({value:c}),s.fontSize.set({value:c}),i.focus()}}},l=[o.bold,o.italic,o.underline,o.strikethrough,o.image,o.link,o.listBullet,o.listOrdered,o.alignText,o.heading,o.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:s,layouts:o,proseMirror:{view:i},items:l}))||l};class Ph{constructor(e,t,r){this.editor=r,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(i=>{this.dom.setAttribute(i,e.attrs.attrs[i])}),this.dom.addEventListener("dblclick",i=>this.handleDoubleClick(i))}handleDoubleClick(e){const{editor:t,view:r}=this;Lo(r,t).image.open(),e.preventDefault()}update(e){return e.type!==this.node.type?!1:(this.node=e,Object.keys(e.attrs.attrs).forEach(t=>{this.dom.setAttribute(t,e.attrs.attrs[t])}),!0)}selectNode(){this.dom.style.outline="2px solid #ffca6f"}deselectNode(){this.dom.style.outline=""}}const Vh=function(n,e={}){const t={plugins:o=>o.plugins,...e},r=(o,l)=>{var p,m;const a=((p=t.schema)==null?void 0:p.call(t,{editor:n,schema:Ui}))||Ui,{nodes:c,marks:f}=a,h=lt.fromSchema(a).parse(o),d=tt.create({doc:h,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,Plugin:ut,plugins:[Af(),Ff(),Ih(a),ca(),Bn({Tab:zi(1),"Shift-Tab":zi(-1)}),Bn({Enter:At(zs,ya(c.listItem),rh),"Shift-Enter":At(vs,(g,b)=>(b&&b(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":Ws,"Mod-y":jn,"Mod-Shift-z":jn,"Mod-b":Pe(f.strong),"Mod-i":Pe(f.em),"Shift-Tab":Gn(c.listItem),Tab:ka(c.listItem)}),Bn(ea)]})}),u=new Zc({mount:o},{state:d,dispatchTransaction(g){var R;const{state:b}=u,w=b.apply(g),O=!b.doc.eq(w.doc);u.updateState(w);const T=!b.selection.eq(w.selection);O&&(eh(((R=l==null?void 0:l.view)==null?void 0:R.el)||o),u.focus()),(T||O)&&n.trigger(te)}});return o.__rteView=u,u.setProps({nodeViews:{image(g){return new Ph(g,u,n)}}}),u},i=o=>Bh(o,t);n.setCustomRte({toolbar:i,parseContent:!0,async enable(o,l,a){const c=Wn(o);if(c)return c;const f=r(o,a);return Yf(o,f),hh(f,a),f},disable(o){const l=Wn(o);if(l)return Zf(o,l),l.destroy(),{forceSync:!0}},getContent(o){const l=Wn(o);if(l){const{schema:a,doc:c}=l.state,f=document.createElement("div"),h=Xe.fromSchema(a).serializeFragment(c.content);return h.childNodes.forEach(d=>{d.nodeType===Node.ELEMENT_NODE&&d.innerHTML===""&&(d.innerHTML="<br/>")}),f.appendChild(h),th(f),o.classList.remove("ProseMirror-focused"),f.innerHTML}return o.innerHTML}});const s=nh(n,t);jf({editor:n,licenseKey:t.licenseKey,plan:zh,pluginName:vh,cleanup:()=>{n.RichTextEditor.customRte=void 0,s()}})},Fh=Uf(Vh);module.exports=Fh;
10
+ `))),0,0):x.empty;let h=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(h)l=h;else{let d=i.marks(),{schema:u}=n.state,p=Xe.fromSchema(u);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(u.text(m,d)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),o=uc(t),Bt&&pc(o);let c=o&&o.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let h=+f[3];h>0;h--){let d=o.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;o=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||lt.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!fc.test(d.parentNode.nodeName)?{ignore:!0}:null}})),f)l=mc(bi(l,+f[1],+f[2]),f[4]);else if(l=x.maxOpen(hc(l.content,i),!0),l.openStart||l.openEnd){let h=0,d=0;for(let u=l.content.firstChild;h<l.openStart&&!u.type.spec.isolating;h++,u=u.firstChild);for(let u=l.content.lastChild;d<l.openEnd&&!u.type.spec.isolating;d++,u=u.lastChild);l=bi(l,h,d)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const fc=/^(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 hc(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&fo(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=ho(o[o.length-1],s.length));let f=co(l,a);o.push(f),i=i.matchType(f.type),s=a}}),o)return y.from(o)}return n}function co(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,y.from(n));return n}function fo(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=fo(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(y.from(co(t,n,i+1))))}}function ho(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ho(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(y.empty,!0);return n.copy(t.append(r))}function rr(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=rr(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(y.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function bi(n,e,t){return e<n.openStart&&(n=new x(rr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new x(rr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const uo={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let xi=null;function po(){return xi||(xi=document.implementation.createHTMLDocument("title"))}let Fn=null;function dc(n){let e=window.trustedTypes;return e?(Fn||(Fn=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Fn.createHTML(n)):n}function uc(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=po().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&uo[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=dc(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function pc(n){let e=n.querySelectorAll($?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function mc(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=y.from(a.create(r[l+1],i)),s++,o++}return new x(i,s,o)}const q={},K={},gc={touchstart:!0,touchmove:!0};class yc{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function bc(n){for(let e in q){let t=q[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{kc(n,r)&&!xr(n,r)&&(n.editable||!(r.type in K))&&t(n,r)},gc[e]?{passive:!0}:void 0)}J&&n.dom.addEventListener("input",()=>null),ir(n)}function De(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function xc(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ir(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>xr(n,r))})}function xr(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function kc(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Sc(n,e){!xr(n,e)&&q[e.type]&&(n.editable||!(e.type in K))&&q[e.type](n,e)}K.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!go(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ne&&$&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ht&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Ve(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||cc(n,t)?t.preventDefault():De(n,"key")};K.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};K.keypress=(n,e)=>{let t=e;if(go(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Z&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof C)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function xn(n){return{left:n.clientX,top:n.clientY}}function Cc(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function kr(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function ot(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function wc(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&k.isSelectable(r)?(ot(n,new k(t)),!0):!1}function Mc(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof k&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(k.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(ot(n,k.create(n.state.doc,i)),!0):!1}function Oc(n,e,t,r,i){return kr(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Mc(n,t):wc(n,t))}function Nc(n,e,t,r){return kr(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Tc(n,e,t,r){return kr(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Ac(n,t,r)}function Ac(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(ot(n,C.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)ot(n,C.create(r,l+1,l+1+o.content.size));else if(k.isSelectable(o))ot(n,k.create(r,l));else continue;return!0}}function Sr(n){return an(n)}const mo=Z?"metaKey":"ctrlKey";q.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Sr(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Cc(t,n.input.lastClick)&&!t[mo]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=n.posAtCoords(xn(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Dc(n,o,t,!!r)):(s=="doubleClick"?Nc:Tc)(n,o.pos,o.inside,t)?t.preventDefault():De(n,"pointer"))};class Dc{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[mo],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let f=e.state.doc.resolve(t.pos);s=f.parent,o=f.depth?f.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof k&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ie&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),De(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ye(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(xn(e))),this.updateAllowDefault(e),this.allowDefault||!t?De(this.view,"pointer"):Oc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||J&&this.mightDrag&&!this.mightDrag.node.isAtom||$&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(ot(this.view,S.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):De(this.view,"pointer")}move(e){this.updateAllowDefault(e),De(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}q.touchstart=n=>{n.input.lastTouch=Date.now(),Sr(n),De(n,"pointer")};q.touchmove=n=>{n.input.lastTouch=Date.now(),De(n,"pointer")};q.contextmenu=n=>Sr(n);function go(n,e){return n.composing?!0:J&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Ec=ne?5e3:-1;K.compositionstart=K.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof C&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),an(n,!0),n.markCursor=null;else if(an(n,!e.selection.empty),ie&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}yo(n,Ec)};K.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,yo(n,20))};function yo(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>an(n),e))}function bo(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Ic());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Rc(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=wa(e.focusNode,e.focusOffset),r=Ma(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Ic(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function an(n,e=!1){if(!(ne&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),bo(n),e||n.docView&&n.docView.dirty){let t=yr(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function vc(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Et=j&&Ee<15||ht&&Da<604;q.copy=K.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=Et?null:t.clipboardData,o=r.content(),{dom:l,text:a}=lo(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):vc(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function zc(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Bc(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Rt(n,r.value,null,i,e):Rt(n,r.textContent,r.innerHTML,i,e)},50)}function Rt(n,e,t,r,i){let s=ao(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||x.empty)))return!0;if(!s)return!1;let o=zc(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function xo(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}K.paste=(n,e)=>{let t=e;if(n.composing&&!ne)return;let r=Et?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Rt(n,xo(r),r.getData("text/html"),i,t)?t.preventDefault():Bc(n,t)};class ko{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const So=Z?"altKey":"ctrlKey";q.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(xn(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof k?i.to-1:i.to))){if(r&&r.mightDrag)o=k.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(o=k.create(n.state.doc,h.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:f}=lo(n,l);(!t.dataTransfer.files.length||!$||Ks>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Et?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Et||t.dataTransfer.setData("text/plain",c),n.dragging=new ko(f,!t[So],o)};q.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};K.dragover=K.dragenter=(n,e)=>e.preventDefault();K.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(xn(t));if(!i)return;let s=n.state.doc.resolve(i.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=ao(n,xo(t.dataTransfer),Et?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[So]);if(n.someProp("handleDrop",p=>p(n,t,o||x.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?Dl(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let f=c.mapping.map(a),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=c.doc;if(h?c.replaceRangeWith(f,f,o.content.firstChild):c.replaceRange(f,f,o),c.doc.eq(d))return;let u=c.doc.resolve(f);if(h&&k.isSelectable(o.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new k(u));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,w)=>p=w),c.setSelection(br(n,u,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};q.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ye(n)},20))};q.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};q.beforeinput=(n,e)=>{if($&&ne&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Ve(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in K)q[n]=K[n];function It(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class cn{constructor(e,t){this.toDOM=e,this.spec=t||Ke,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new U(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof cn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&It(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ie{constructor(e,t){this.attrs=e,this.spec=t||Ke}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new U(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ie&&It(this.attrs,e.attrs)&&It(this.spec,e.spec)}static is(e){return e.type instanceof Ie}destroy(){}}class Cr{constructor(e,t){this.attrs=e,this.spec=t||Ke}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new U(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof Cr&&It(this.attrs,e.attrs)&&It(this.spec,e.spec)}destroy(){}}class U{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new U(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new U(e,e,new cn(t,r))}static inline(e,t,r,i){return new U(e,t,new Ie(r,i))}static node(e,t,r,i){return new U(e,t,new Cr(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ie}get widget(){return this.type instanceof cn}}const et=[],Ke={};class A{constructor(e,t){this.local=e.length?e:et,this.children=t.length?t:et}static create(e,t){return t.length?fn(t,e,0,Ke):L}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==L||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ke)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Pc(this.children,o||[],e,t,r,i,s):o?new A(o.sort(Ue),et):L}add(e,t){return t.length?this==L?A.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,f;if(f=wo(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,f,c+1):i.splice(s,0,a,a+l.nodeSize,fn(f,l,c+1,Ke)),s+=3}});let o=Co(s?Mo(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new A(o.length?this.local.concat(o).sort(Ue):this.local,i||this.children)}remove(e){return e.length==0||this==L?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;for(let f=0,h;f<e.length;f++)(h=e[f])&&h.from>l&&h.to<a&&(e[f]=null,(o||(o=[])).push(h));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=L?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new A(i,r):L}forChild(e,t){if(this==L)return this;if(t.isLeaf)return A.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Ie){let c=Math.max(s,a.from)-s,f=Math.min(o,a.to)-s;c<f&&(i||(i=[])).push(a.copy(c,f))}}if(i){let l=new A(i.sort(Ue),et);return r?new Oe([l,r]):l}return r||L}eq(e){if(this==e)return!0;if(!(e instanceof A)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return wr(this.localsInner(e))}localsInner(e){if(this==L)return et;if(e.inlineContent||!this.local.some(Ie.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ie||t.push(this.local[r]);return t}forEachSet(e){e(this)}}A.empty=new A([],[]);A.removeOverlap=wr;const L=A.empty;class Oe{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Ke));return Oe.from(r)}forChild(e,t){if(t.isLeaf)return A.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=L&&(s instanceof Oe?r=r.concat(s.members):r.push(s))}return Oe.from(r)}eq(e){if(!(e instanceof Oe)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?wr(r?t:t.sort(Ue)):et}static from(e){switch(e.length){case 0:return L;case 1:return e[0];default:return new Oe(e.every(t=>t instanceof A)?e:e.reduce((t,r)=>t.concat(r instanceof A?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Pc(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,f=s;c<t.maps.length;c++){let h=0;t.maps[c].forEach((d,u,p,m)=>{let g=m-p-(u-d);for(let b=0;b<l.length;b+=3){let w=l[b+1];if(w<0||d>w+f-h)continue;let O=l[b]+f-h;u>=O?l[b+1]=d<=O?-2:-1:d>=f&&g&&(l[b]+=g,l[b+1]+=g)}h+=g}),f=t.maps[c].map(f,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let f=t.map(n[c]+s),h=f-i;if(h<0||h>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),u=d-i,{index:p,offset:m}=r.content.findIndex(h),g=r.maybeChild(p);if(g&&m==h&&m+g.nodeSize==u){let b=l[c+2].mapInner(t,g,f+1,n[c]+s+1,o);b!=L?(l[c]=h,l[c+1]=u,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Vc(l,n,e,t,i,s,o),f=fn(c,r,0,o);e=f.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,d=0;h<f.children.length;h+=3){let u=f.children[h];for(;d<l.length&&l[d]<u;)d+=3;l.splice(d,0,f.children[h],f.children[h+1],f.children[h+2])}}return new A(e.sort(Ue),l)}function Co(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new U(i.from+e,i.to+e,i.type))}return t}function Vc(n,e,t,r,i,s,o){function l(a,c){for(let f=0;f<a.local.length;f++){let h=a.local[f].map(r,i,c);h?t.push(h):o.onRemove&&o.onRemove(a.local[f].spec)}for(let f=0;f<a.children.length;f+=3)l(a.children[f+2],a.children[f]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function wo(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function Mo(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function fn(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=wo(n,l,a+t);if(c){s=!0;let f=fn(c,l,t+a+1,r);f!=L&&i.push(a,a+l.nodeSize,f)}});let o=Co(s?Mo(n):n,-t).sort(Ue);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new A(o,i):L}function Ue(n,e){return n.from-e.from||n.to-e.to}function wr(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),ki(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),ki(e,i,r.copy(s.from,r.to)));break}}}return e}function ki(n,e,t){for(;e<n.length&&Ue(t,n[e])>0;)e++;n.splice(e,0,t)}function Ln(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=L&&e.push(r)}),n.cursorWrapper&&e.push(A.create(n.state.doc,[n.cursorWrapper.deco])),Oe.from(e)}const Fc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Lc=j&&Ee<=11;class Hc{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class $c{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Hc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);j&&Ee<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Lc&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Fc)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){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.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(di(this.view)){if(this.suppressingSelectionUpdates)return ye(this.view);if(j&&Ee<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ge(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Dt(s))t.add(s);for(let s=e.anchorNode;s;s=Dt(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&di(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let f=0;f<t.length;f++){let h=this.registerMutation(t[f],a);h&&(s=s<0?h.from:Math.min(h.from,s),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(l=!0))}if(ie&&a.length){let f=a.filter(h=>h.nodeName=="BR");if(f.length==2){let[h,d]=f;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of f){let u=d.parentNode;u&&u.nodeName=="LI"&&(!h||qc(e,h)!=u)&&d.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&yn(r)&&(c=yr(e))&&c.eq(S.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ye(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Wc(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ye(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;f<e.addedNodes.length;f++){let h=e.addedNodes[f];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(j&&Ee<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:h,nextSibling:d}=e.addedNodes[f];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let o=i&&i.parentNode==e.target?V(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?V(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Si=new WeakMap,Ci=!1;function Wc(n){if(!Si.has(n)&&(Si.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ie,Ci)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."),Ci=!0}}function wi(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Ge(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Jc(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return wi(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?wi(n,t):null}function qc(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Kc(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,f=a.anchorNode;if(f&&n.dom.contains(f.nodeType==1?f:f.parentNode)&&(c=[{node:f,offset:a.anchorOffset}],yn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),$&&n.input.lastKeyCode===8)for(let g=s;g>i;g--){let b=r.childNodes[g-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){s=g;break}if(!w||w.size)break}let h=n.state.doc,d=n.someProp("domParser")||lt.fromSchema(n.state.schema),u=h.resolve(o),p=null,m=d.parse(r,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:u.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Uc,context:u});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:m,sel:p,from:o,to:l}}function Uc(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(J&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||J&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const jc=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Gc(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,ke=yr(n,M);if(ke&&!n.state.selection.eq(ke)){if($&&ne&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",$o=>$o(n,Ve(13,"Enter"))))return;let Ft=n.state.tr.setSelection(ke);M=="pointer"?Ft.setMeta("pointer",!0):M=="key"&&Ft.scrollIntoView(),s&&Ft.setMeta("composition",s),n.dispatch(Ft)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Kc(n,e,t),f=n.state.doc,h=f.slice(c.from,c.to),d,u;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,u="end"):(d=n.state.selection.from,u="start"),n.input.lastKeyCode=null;let p=Yc(h.content,c.doc.content,c.from,d,u);if(p&&n.input.domChangeCount++,(ht&&n.input.lastIOSEnter>Date.now()-225||ne)&&i.some(M=>M.nodeType==1&&!jc.test(M.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",M=>M(n,Ve(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof C&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let M=Mi(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let ke=n.state.tr.setSelection(M);s&&ke.setMeta("composition",s),n.dispatch(ke)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof C&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),j&&Ee<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=f.resolve(p.start),w=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA,O;if((ht&&n.input.lastIOSEnter>Date.now()-225&&(!w||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!w&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(O=S.findFrom(c.doc.resolve(m.pos+1),1,!0))&&O.head==g.pos)&&n.someProp("handleKeyDown",M=>M(n,Ve(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Xc(f,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,Ve(8,"Backspace")))){ne&&$&&n.domObserver.suppressSelectionUpdates();return}$&&ne&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),ne&&!w&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(M){return M(n,Ve(13,"Enter"))})},20));let T=p.start,R=p.endA,I,fe,xe;if(w){if(m.pos==g.pos)j&&Ee<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ye(n),20)),I=n.state.tr.delete(T,R),fe=f.resolve(p.start).marksAcross(f.resolve(p.endA));else if(p.endA==p.endB&&(xe=_c(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))I=n.state.tr,xe.type=="add"?I.addMark(T,R,xe.mark):I.removeMark(T,R,xe.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",ke=>ke(n,T,R,M)))return;I=n.state.tr.insertText(M,T,R)}}if(I||(I=n.state.tr.replace(T,R,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let M=Mi(n,I.doc,c.sel);M&&!($&&ne&&n.composing&&M.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(M.head==T||M.head==I.mapping.map(R)-1)||j&&M.empty&&M.head==T)&&I.setSelection(M)}fe&&I.ensureMarks(fe),s&&I.setMeta("composition",s),n.dispatch(I.scrollIntoView())}function Mi(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:br(n,e.resolve(t.anchor),e.resolve(t.head))}function _c(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let f=0;f<r.length;f++)i=r[f].removeFromSet(i);for(let f=0;f<t.length;f++)s=t[f].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=f=>f.mark(l.addToSet(f.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=f=>f.mark(l.removeFromSet(f.marks));else return null;let c=[];for(let f=0;f<e.childCount;f++)c.push(a(e.child(f)));if(y.from(c).eq(n))return{mark:l,type:o}}function Xc(n,e,t,r,i){if(t-e<=i.pos-r.pos||Hn(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(Hn(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Hn(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Hn(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Yc(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&n.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&Oi(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&Oi(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function Oi(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Zc{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 yc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ei),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=Ai(this),Ti(this),this.nodeViews=Di(this),this.docView=oi(this.state.doc,Ni(this),Ln(this),this.dom,this),this.domObserver=new $c(this,(r,i,s,o)=>Gc(this,r,i,s,o)),this.domObserver.start(),bc(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&&ir(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ei),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(bo(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let u=Di(this);ef(u,this.nodeViews)&&(this.nodeViews=u,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ir(this),this.editable=Ai(this),Ti(this);let a=Ln(this),c=Ni(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(i.selection))&&(o=!0);let d=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Ia(this);if(o){this.domObserver.stop();let u=h&&(j||$)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Qc(i.selection,e.selection);if(h){let p=$?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Rc(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=oi(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(u=!0)}u||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&nc(this))?ye(this,u):(io(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():d&&va(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof k){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ei(this,t.getBoundingClientRect(),e)}else ei(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 r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new ko(e.slice,e.move,i<0?void 0:k.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(j){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&za(this.dom),ye(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return La(this,e)}coordsAtPos(e,t=1){return Xs(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,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return qa(this,t||this.state,e)}pasteHTML(e,t){return Rt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Rt(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(xc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ln(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Sa())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Sc(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?J&&this.root.nodeType===11&&Na(this.dom.ownerDocument)==this.dom&&Jc(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ni(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[U.node(0,n.state.doc.content.size,e)]}function Ti(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:U.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ai(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Qc(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Di(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function ef(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Ei(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var sr,or;if(typeof WeakMap<"u"){let n=new WeakMap;sr=e=>n.get(e),or=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;sr=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},or=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var D=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,i=e/this.width|0;let s=r+1,o=i+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:r,top:i,right:s,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:i,top:s,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?r==0:i==this.width)?null:this.map[s*this.width+(t<0?r-1:i)]:(t<0?s==0:o==this.height)?null:this.map[r+this.width*(t<0?s-1:o)]}rectBetween(n,e){const{left:t,right:r,top:i,bottom:s}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(i,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let i=n.left;i<n.right;i++){const s=r*this.width+i,o=this.map[s];t[o]||(t[o]=!0,!(i==n.left&&i&&this.map[s-1]==o||r==n.top&&r&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let r=0,i=0;;r++){const s=i+t.child(r).nodeSize;if(r==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<i;)o++;return o==l?s-1:this.map[o]}i=s}}static get(n){return sr(n)||or(n,tf(n))}};function tf(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=nf(n),t=n.childCount,r=[];let i=0,s=null;const o=[];for(let c=0,f=e*t;c<f;c++)r[c]=0;for(let c=0,f=0;c<t;c++){const h=n.child(c);f++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==h.childCount)break;const m=h.child(p),{colspan:g,rowspan:b,colwidth:w}=m.attrs;for(let O=0;O<b;O++){if(O+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:f,n:b-O});break}const T=i+O*e;for(let R=0;R<g;R++){r[T+R]==0?r[T+R]=f:(s||(s=[])).push({type:"collision",row:c,pos:f,n:g-R});const I=w&&w[R];if(I){const fe=(T+R)%e*2,xe=o[fe];xe==null||xe!=I&&o[fe+1]==1?(o[fe]=I,o[fe+1]=1):xe==I&&o[fe+1]++}}}i+=g,f+=m.nodeSize}const d=(c+1)*e;let u=0;for(;i<d;)r[i++]==0&&u++;u&&(s||(s=[])).push({type:"missing",row:c,n:u}),f++}const l=new D(e,t,r,s);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&rf(l,o,n),l}function nf(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const i=n.child(r);let s=0;if(t)for(let o=0;o<r;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){const l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function rf(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;i<n.map.length;i++){const s=n.map[i];if(r[s])continue;r[s]=!0;const o=t.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const f=(i+c)%n.width,h=e[f*2];h!=null&&(!a.colwidth||a.colwidth[c]!=h)&&((l||(l=sf(a)))[c]=h)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function sf(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Ri(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(o=>Number(o)):null,i=Number(n.getAttribute("colspan")||1),s={colspan:i,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==i?r:null};for(const o in e){const l=e[o].getFromDOM,a=l&&l(n);a!=null&&(s[o]=a)}return s}function Ii(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const r in e){const i=e[r].setDOMAttr;i&&i(n.attrs[r],t)}return t}function of(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const r in e)t[r]={default:e[r].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>Ri(r,e)}],toDOM(r){return["td",Ii(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Ri(r,e)}],toDOM(r){return["th",Ii(r,e),0]}}}}function ce(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}var Ne=new vt("selectingCells");function Vt(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function kn(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Mr(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Vt(e.$head)||lf(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function lf(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function lr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function af(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Or(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Oo(n,e,t){const r=n.node(-1),i=D.get(r),s=n.start(-1),o=i.nextCell(n.pos-s,e,t);return o==null?null:n.node(0).resolve(s+o)}function dt(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}var z=class pe extends S{constructor(e,t=e){const r=e.node(-1),i=D.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(f=>f!=t.pos-s);a.unshift(t.pos-s);const c=a.map(f=>{const h=r.nodeAt(f);if(!h)throw RangeError(`No cell with offset ${f} found`);const d=s+f+1;return new Ts(l.resolve(d),l.resolve(d+h.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(lr(r)&&lr(i)&&Or(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?pe.rowSelection(r,i):s&&this.isColSelection()?pe.colSelection(r,i):new pe(r,i)}return C.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=D.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let f=a*t.width+i.left,h=i.left;h<i.right;h++,f++){const d=t.map[f];if(s[d])continue;s[d]=!0;const u=t.findCell(d);let p=e.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const m=i.left-u.left,g=u.right-i.right;if(m>0||g>0){let b=p.attrs;if(m>0&&(b=dt(b,0,m)),g>0&&(b=dt(b,b.colspan-g,g)),u.left<i.left){if(p=p.type.createAndFill(b),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(u.top<i.top||u.bottom>i.bottom){const b={...p.attrs,rowspan:Math.min(u.bottom,i.bottom)-Math.max(u.top,i.top)};u.top<i.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(y.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new x(y.from(l),1,1)}replace(e,t=x.empty){const r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){const{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?x.empty:t)}const s=S.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new x(y.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=D.get(t),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),i+s[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=D.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(s+i.map[o.left])),l.bottom<i.height&&(t=a.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+i.map[l.left])),o.bottom<i.height&&(e=a.resolve(s+i.map[i.width*(i.height-1)+o.right-1]))),new pe(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=D.get(e),r=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(i,s)>0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof pe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=D.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(s+i.map[o.top*i.width])),l.right<i.width&&(t=a.resolve(s+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+i.map[l.top*i.width])),o.right<i.width&&(e=a.resolve(s+i.map[i.width*(o.top+1)-1]))),new pe(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new pe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new pe(e.resolve(t),e.resolve(r))}getBookmark(){return new cf(this.$anchorCell.pos,this.$headCell.pos)}};z.prototype.visible=!1;S.jsonID("cell",z);var cf=class No{constructor(e,t){this.anchor=e,this.head=t}map(e){return new No(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Or(t,r)?new z(t,r):S.near(r,1)}};function ff(n){if(!(n.selection instanceof z))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(U.node(r,r+t.nodeSize,{class:"selectedCell"}))}),A.create(n.doc,e)}function hf({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function df({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){const s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function uf(n,e,t){const r=(e||n).selection,i=(e||n).doc;let s,o;if(r instanceof k&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=z.create(i,r.from);else if(o=="row"){const l=i.resolve(r.from+1);s=z.rowSelection(l,l)}else if(!t){const l=D.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=z.create(i,a+1,c)}}else r instanceof C&&hf(r)?s=C.create(i,r.from):r instanceof C&&df(r)&&(s=C.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var pf=new vt("fix-tables");function To(n,e,t,r){const i=n.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){const a=e.child(o);for(let c=l,f=Math.min(i,o+3);c<f;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<i&&n.child(l).sameMarkup(a)?To(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function mf(n,e){let t;const r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=gf(n,i,s,t))};return e?e.doc!=n.doc&&To(e.doc,n.doc,0,r):n.doc.descendants(r),t}function gf(n,e,t,r){const i=D.get(e);if(!i.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){const c=i.problems[a];if(c.type=="collision"){const f=e.nodeAt(c.pos);if(!f)continue;const h=f.attrs;for(let d=0;d<h.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,dt(h,h.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const f=e.nodeAt(c.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const f=e.nodeAt(c.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...f.attrs,colwidth:c.colwidth})}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<i.height;a++){const f=e.child(a),h=c+f.nodeSize,d=s[a];if(d>0){let u="cell";f.firstChild&&(u=f.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<d;g++){const b=ce(n.schema)[u].createAndFill();b&&p.push(b)}const m=(a==0||o==a-1)&&l==a?c+1:h-1;r.insert(r.mapping.map(m),p)}c=h}return r.setMeta(pf,{fixTables:!0})}function Ao(n){const e=n.selection,t=Mr(n),r=t.node(-1),i=t.start(-1),s=D.get(r);return{...e instanceof z?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(t.pos-i),tableStart:i,map:s,table:r}}function yf(n){return function(e,t){if(!kn(e))return!1;if(t){const r=ce(e.schema),i=Ao(e),s=e.tr,o=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);t(s)}return!0}}function vi(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function Nr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?yf(n):function(t,r){if(!kn(t))return!1;if(r){const i=ce(t.schema),s=Ao(t),o=t.tr,l=vi("row",s,i),a=vi("column",s,i),f=(n==="column"?l:n==="row"?a:!1)?1:0,h=n=="column"?{left:0,top:f,right:1,bottom:s.map.height}:n=="row"?{left:f,top:0,right:s.map.width,bottom:1}:s,d=n=="column"?a?i.cell:i.header_cell:n=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(h).forEach(u=>{const p=u+s.tableStart,m=o.doc.nodeAt(p);m&&o.setNodeMarkup(p,d,m.attrs)}),r(o)}return!0}}Nr("row",{useDeprecatedLogic:!0});Nr("column",{useDeprecatedLogic:!0});Nr("cell",{useDeprecatedLogic:!0});function bf(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){const s=n.node(-1).child(r),o=s.lastChild;if(o)return i-1-o.nodeSize;i-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}return null}function zi(n){return function(e,t){if(!kn(e))return!1;const r=bf(Mr(e),n);if(r==null)return!1;if(t){const i=e.doc.resolve(r);t(e.tr.setSelection(C.between(i,af(i))).scrollIntoView())}return!0}}function Wt(n,e){const t=n.selection;if(!(t instanceof z))return!1;if(e){const r=n.tr,i=ce(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new x(i,0,0))}),r.docChanged&&e(r)}return!0}function xf(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const f=a?0:Math.max(0,t-1),h=a<e.childCount-1?0:Math.max(0,r-1);(f||h)&&(c=ar(ce(o).row,new x(c,f,h)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?ar(ce(o).row,new x(e,t,r)).content:e);else return null;return kf(o,l)}function kf(n,e){const t=[];for(let i=0;i<e.length;i++){const s=e[i];for(let o=s.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c<i+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(y.empty),t[i]<r){const s=ce(n).cell.createAndFill(),o=[];for(let l=t[i];l<r;l++)o.push(s);e[i]=e[i].append(y.from(o))}return{height:e.length,width:r,rows:e}}function ar(n,e){const t=n.createAndFill();return new Ns(t).replace(0,t.content.size,e).doc}function Sf({width:n,height:e,rows:t},r,i){if(n!=r){const s=[],o=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let f=s[l]||0,h=0;f<r;h++){let d=a.child(h%a.childCount);f+d.attrs.colspan>r&&(d=d.type.createChecked(dt(d.attrs,d.attrs.colspan,f+d.attrs.colspan-r),d.content)),c.push(d),f+=d.attrs.colspan;for(let u=1;u<d.attrs.rowspan;u++)s[l+u]=(s[l+u]||0)+d.attrs.colspan}o.push(y.from(c))}t=o,n=r}if(e!=i){const s=[];for(let o=0,l=0;o<i;o++,l++){const a=[],c=t[l%e];for(let f=0;f<c.childCount;f++){let h=c.child(f);o+h.attrs.rowspan>i&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,i-h.attrs.rowspan)},h.content)),a.push(h)}s.push(y.from(a))}t=s,e=i}return{width:n,height:e,rows:t}}function Cf(n,e,t,r,i,s,o){const l=n.doc.type.schema,a=ce(l);let c,f;if(i>e.width)for(let h=0,d=0;h<e.height;h++){const u=t.child(h);d+=u.nodeSize;const p=[];let m;u.lastChild==null||u.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=f||(f=a.header_cell.createAndFill());for(let g=e.width;g<i;g++)p.push(m);n.insert(n.mapping.slice(o).map(d-1+r),p)}if(s>e.height){const h=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,i);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;h.push(g?f||(f=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,y.from(h)),u=[];for(let p=e.height;p<s;p++)u.push(d);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),u)}return!!(c||f)}function Bi(n,e,t,r,i,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=i;c<s;c++){const f=o*e.width+c,h=e.map[f];if(e.map[f-e.width]==h){a=!0;const d=t.nodeAt(h),{top:u,left:p}=e.findCell(h);n.setNodeMarkup(n.mapping.slice(l).map(h+r),null,{...d.attrs,rowspan:o-u}),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),d.type.createAndFill({...d.attrs,rowspan:u+d.attrs.rowspan-o})),c+=d.attrs.colspan-1}}return a}function Pi(n,e,t,r,i,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=i;c<s;c++){const f=c*e.width+o,h=e.map[f];if(e.map[f-1]==h){a=!0;const d=t.nodeAt(h),u=e.colCount(h),p=n.mapping.slice(l).map(h+r);n.setNodeMarkup(p,null,dt(d.attrs,o-u,d.attrs.colspan-(o-u))),n.insert(p+d.nodeSize,d.type.createAndFill(dt(d.attrs,0,o-u))),c+=d.attrs.rowspan-1}}return a}function Vi(n,e,t,r,i){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let o=D.get(s);const{top:l,left:a}=r,c=a+i.width,f=l+i.height,h=n.tr;let d=0;function u(){if(s=t?h.doc.nodeAt(t-1):h.doc,!s)throw new Error("No table found");o=D.get(s),d=h.mapping.maps.length}Cf(h,o,s,t,c,f,d)&&u(),Bi(h,o,s,t,a,c,l,d)&&u(),Bi(h,o,s,t,a,c,f,d)&&u(),Pi(h,o,s,t,l,f,a,d)&&u(),Pi(h,o,s,t,l,f,c,d)&&u();for(let p=l;p<f;p++){const m=o.positionAt(p,a,s),g=o.positionAt(p,c,s);h.replace(h.mapping.slice(d).map(m+t),h.mapping.slice(d).map(g+t),new x(i.rows[p-l],0,0))}u(),h.setSelection(new z(h.doc.resolve(t+o.positionAt(l,a,s)),h.doc.resolve(t+o.positionAt(f-1,c-1,s)))),e(h)}var wf=Js({ArrowLeft:Jt("horiz",-1),ArrowRight:Jt("horiz",1),ArrowUp:Jt("vert",-1),ArrowDown:Jt("vert",1),"Shift-ArrowLeft":qt("horiz",-1),"Shift-ArrowRight":qt("horiz",1),"Shift-ArrowUp":qt("vert",-1),"Shift-ArrowDown":qt("vert",1),Backspace:Wt,"Mod-Backspace":Wt,Delete:Wt,"Mod-Delete":Wt});function Gt(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Jt(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;if(s instanceof z)return Gt(t,r,S.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=Do(i,n,e);if(o==null)return!1;if(n=="horiz")return Gt(t,r,S.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=Oo(l,n,e);let c;return a?c=S.near(a,1):e<0?c=S.near(t.doc.resolve(l.before(-1)),-1):c=S.near(t.doc.resolve(l.after(-1)),1),Gt(t,r,c)}}}function qt(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;let o;if(s instanceof z)o=s;else{const a=Do(i,n,e);if(a==null)return!1;o=new z(t.doc.resolve(a))}const l=Oo(o.$headCell,n,e);return l?Gt(t,r,new z(o.$anchorCell,l)):!1}}function Mf(n,e){const t=n.state.doc,r=Vt(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new z(r))),!0):!1}function Of(n,e,t){if(!kn(n.state))return!1;let r=xf(t);const i=n.state.selection;if(i instanceof z){r||(r={width:1,height:1,rows:[y.from(ar(ce(n.state.schema).cell,t))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=D.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=Sf(r,l.right-l.left,l.bottom-l.top),Vi(n.state,n.dispatch,o,l,r),!0}else if(r){const s=Mr(n.state),o=s.start(-1);return Vi(n.state,n.dispatch,o,D.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function Nf(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Fi(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof z)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Vt(n.state.selection.$anchor))!=null&&((t=$n(n,e))==null?void 0:t.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(a,c){let f=$n(n,c);const h=Ne.getState(n.state)==null;if(!f||!Or(a,f))if(h)f=a;else return;const d=new z(a,f);if(h||!n.state.selection.eq(d)){const u=n.state.tr.setSelection(d);h&&u.setMeta(Ne,a.pos),n.dispatch(u)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),Ne.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ne,-1))}function l(a){const c=a,f=Ne.getState(n.state);let h;if(f!=null)h=n.state.doc.resolve(f);else if(Fi(n,c.target)!=r&&(h=$n(n,e),!h))return o();h&&s(h,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function Do(n,e,t){if(!(n.state.selection instanceof C))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Fi(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function $n(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Vt(n.state.doc.resolve(t.pos)):null}var Tf=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),cr(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,cr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function cr(n,e,t,r,i,s){var o;let l=0,a=!0,c=e.firstChild;const f=n.firstChild;if(f){for(let h=0,d=0;h<f.childCount;h++){const{colspan:u,colwidth:p}=f.child(h).attrs;for(let m=0;m<u;m++,d++){const g=i==d?s:p&&p[m],b=g?g+"px":"";if(l+=g||r,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;c;){const h=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=h}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var _=new vt("tableColumnResizing");function Af({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=Tf,lastColumnResizable:i=!0}={}){const s=new ut({key:_,state:{init(o,l){var a,c;const f=(c=(a=s.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,h=ce(l.schema).table.name;return r&&f&&(f[h]=(d,u)=>new r(d,t,u)),new Df(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=_.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{Ef(o,l,n,i)},mouseleave:o=>{Rf(o)},mousedown:(o,l)=>{If(o,l,e,t)}},decorations:o=>{const l=_.getState(o);if(l&&l.activeHandle>-1)return Vf(o,l.activeHandle)},nodeViews:{}}});return s}var Df=class _t{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(_);if(r&&r.setHandle!=null)return new _t(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new _t(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return lr(e.doc.resolve(i))||(i=-1),new _t(i,t.dragging)}return t}};function Ef(n,e,t,r){const i=_.getState(n.state);if(i&&!i.dragging){const s=zf(e.target);let o=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=t?o=Li(n,e,"left",t):a-e.clientX<=t&&(o=Li(n,e,"right",t))}if(o!=i.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=D.get(a),f=l.start(-1);if(c.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Eo(n,o)}}}function Rf(n){const e=_.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Eo(n,-1)}function If(n,e,t,r){var i;const s=(i=n.dom.ownerDocument.defaultView)!=null?i:window,o=_.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=vf(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(_,{setDragging:{startX:e.clientX,startWidth:a}}));function c(h){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",f);const d=_.getState(n.state);d!=null&&d.dragging&&(Bf(n,d.activeHandle,Hi(d.dragging,h,t)),n.dispatch(n.state.tr.setMeta(_,{setDragging:null})))}function f(h){if(!h.which)return c(h);const d=_.getState(n.state);if(d&&d.dragging){const u=Hi(d.dragging,h,t);$i(n,d.activeHandle,u,r)}}return $i(n,o.activeHandle,a,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",f),e.preventDefault(),!0}function vf(n,e,{colspan:t,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=n.domAtPos(e);let l=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function zf(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Li(n,e,t,r){const i=t=="right"?-r:r,s=n.posAtCoords({left:e.clientX+i,top:e.clientY});if(!s)return-1;const{pos:o}=s,l=Vt(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=D.get(l.node(-1)),c=l.start(-1),f=a.map.indexOf(l.pos-c);return f%a.width==0?-1:c+a.map[f-1]}function Hi(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Eo(n,e){n.dispatch(n.state.tr.setMeta(_,{setHandle:e}))}function Bf(n,e,t){const r=n.state.doc.resolve(e),i=r.node(-1),s=D.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){const f=c*s.width+l;if(c&&s.map[f]==s.map[f-s.width])continue;const h=s.map[f],d=i.nodeAt(h).attrs,u=d.colspan==1?0:l-s.colCount(h);if(d.colwidth&&d.colwidth[u]==t)continue;const p=d.colwidth?d.colwidth.slice():Pf(d.colspan);p[u]=t,a.setNodeMarkup(o+h,null,{...d,colwidth:p})}a.docChanged&&n.dispatch(a)}function $i(n,e,t,r){const i=n.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=D.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1;let a=n.domAtPos(i.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&cr(s,a.firstChild,a,r,l,t)}function Pf(n){return Array(n).fill(0)}function Vf(n,e){var t;const r=[],i=n.doc.resolve(e),s=i.node(-1);if(!s)return A.empty;const o=D.get(s),l=i.start(-1),a=o.colCount(i.pos-l)+i.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const f=a+c*o.width;if((a==o.width-1||o.map[f]!=o.map[f+1])&&(c==0||o.map[f]!=o.map[f-o.width])){const h=o.map[f],d=l+h+s.nodeAt(h).nodeSize-1,u=document.createElement("div");u.className="column-resize-handle",(t=_.getState(n))!=null&&t.dragging&&r.push(U.node(l+h,l+h+s.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),r.push(U.widget(d,u))}}return A.create(n.doc,r)}function Ff({allowTableNodeSelection:n=!1}={}){return new ut({key:Ne,state:{init(){return null},apply(e,t){const r=e.getMeta(Ne);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:i,pos:s}=e.mapping.mapResult(t);return i?null:s}},props:{decorations:ff,handleDOMEvents:{mousedown:Nf},createSelectionBetween(e){return Ne.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Mf,handleKeyDown:wf,handlePaste:Of},appendTransaction(e,t,r){return uf(r,mf(r,t),n)}})}const Ro="app.grapesjs.com",Io="app-stage.grapesjs.com",Wi=[Ro,Io,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Lf="license:check:start",Hf="license:check:end",$f=()=>typeof window<"u",Wf=({isDev:n,isStage:e})=>`${n?"":`https://${e?Io:Ro}`}/api`,Jf=()=>{const n=$f()&&window.location.hostname;return!!n&&(Wi.includes(n)||Wi.some(e=>n.endsWith(e)))};async function qf({path:n,baseApiUrl:e,method:t="GET",headers:r={},params:i,body:s}){const l=`${e||Wf({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...r}};s&&(a.body=JSON.stringify(s));const c=i?new URLSearchParams(i).toString():"",f=c?`?${c}`:"",h=await fetch(`${l}${f}`,a);if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return h.json()}var nt=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(nt||{}),hn=(n=>(n.toastAdd="studio:toastAdd",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.sidebarLeftSet="studio:sidebarLeft:set",n.sidebarLeftGet="studio:sidebarLeft:get",n.sidebarLeftToggle="studio:sidebarLeft:toggle",n.sidebarRightSet="studio:sidebarRight:set",n.sidebarRightGet="studio:sidebarRight:get",n.sidebarRightToggle="studio:sidebarRight:toggle",n.sidebarTopSet="studio:sidebarTop:set",n.sidebarTopGet="studio:sidebarTop:get",n.sidebarTopToggle="studio:sidebarTop:toggle",n.sidebarBottomSet="studio:sidebarBottom:set",n.sidebarBottomGet="studio:sidebarBottom:get",n.sidebarBottomToggle="studio:sidebarBottom:toggle",n.symbolAdd="studio:symbolAdd",n.symbolDetach="studio:symbolDetach",n.symbolOverride="studio:symbolOverride",n.symbolPropagateStyles="studio:propagateStyles",n.getPagesConfig="studio:getPagesConfig",n.setPagesConfig="studio:setPagesConfig",n.getPageSettings="studio:getPageSettings",n.setPageSettings="studio:setPageSettings",n.projectFiles="studio:projectFiles",n.canvasReload="studio:canvasReload",n.getBlocksPanel="studio:getBlocksPanel",n.setBlocksPanel="studio:setBlocksPanel",n.getStateContextMenu="studio:getStateContextMenu",n.setStateContextMenu="studio:setStateContextMenu",n.contextMenuComponent="studio:contextMenuComponent",n.layoutAdd="studio:layoutAdd",n.layoutRemove="studio:layoutRemove",n.layoutToggle="studio:layoutToggle",n.layoutUpdate="studio:layoutUpdate",n.layoutGet="studio:layoutGet",n.layoutConfigGet="studio:layoutConfigGet",n.layoutConfigSet="studio:layoutConfigSet",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.assetProviderGet="studio:assetProviderGet",n.assetProviderAdd="studio:assetProviderAdd",n.assetProviderRemove="studio:assetProviderRemove",n.fontGet="studio:fontGet",n.fontAdd="studio:fontAdd",n.fontRemove="studio:fontRemove",n.fontManagerOpen="studio:fontManagerOpen",n.menuFontLoad="studio:menuFontLoad",n.toggleStateDataSource="studio:toggleStateDataSource",n.getStateDataSource="studio:getStateDataSource",n.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",n.dataSourceSetImporter="studio:dataSourceSetImporter",n.dataSourceSetExporter="studio:dataSourceSetExporter",n.setDragAbsolute="studio:setDragAbsolute",n))(hn||{});const Ji={[nt.free]:0,[nt.startup]:10,[nt.business]:20,[nt.enterprise]:30};function Kf(n){const e=n;return e.init=t=>r=>n(r,t),e}const Uf=n=>Kf(n);async function jf({editor:n,plan:e,pluginName:t,licenseKey:r,cleanup:i}){let s="",o=!1;const l=Jf(),a=f=>{console.warn("Cleanup plugin:",t,"Reason:",f),i()},c=(f={})=>{var m;const{error:h,sdkLicense:d}=f,u=(m=f.plan)==null?void 0:m.category;if(!(d||f.license)||h)a(h||"Invalid license");else if(u){const g=Ji[e],b=Ji[u];g>b&&a({pluginRequiredPlan:e,licensePlan:u})}};n.on(Lf,f=>{s=f==null?void 0:f.baseApiUrl,o=!0}),n.on(Hf,f=>{c(f)}),setTimeout(async()=>{if(!o){if(l)return;if(r){const f=await Gf({licenseKey:r,pluginName:t,baseApiUrl:s});f&&c(f)}else a("The `licenseKey` option not provided")}},2e3)}async function Gf(n){const{licenseKey:e,pluginName:t,baseApiUrl:r}=n;try{return(await qf({baseApiUrl:r,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const Ot=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},qi="data-gs-mrk-fs",Ki="data-gs-ib",dn="data-gs-ifrg",be="attrs",vo={[be]:{default:"{}"}},de={[be]:{default:{}}},zo=n=>({[be]:JSON.stringify(Ot(n))}),ue=n=>({attrs:Ot(n)}),mt=n=>e=>[n,e.attrs.attrs,0],Me=n=>n.attrs[be]?JSON.parse(n.attrs[be]):{},_f={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${dn}]`,getAttrs:ue}],toDOM:()=>["span",{[dn]:""},0]},div:{group:"block",content:"inline*",attrs:de,parseDOM:[{tag:"div",getAttrs:ue}],toDOM:mt("div")},paragraph:{group:"block",content:"inline*",attrs:de,parseDOM:[{tag:"p",getAttrs:ue}],toDOM:mt("p")},orderedList:{group:"block",content:"listItem+",attrs:de,parseDOM:[{tag:"ol",getAttrs:ue}],toDOM:mt("ol")},bulletList:{group:"block",content:"listItem+",attrs:de,parseDOM:[{tag:"ul",getAttrs:ue}],toDOM:mt("ul")},listItem:{content:"block*",group:"block",attrs:de,parseDOM:[{tag:"li",getAttrs:ue}],toDOM:mt("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:de,parseDOM:[{tag:"pre",getAttrs:ue}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:de,parseDOM:[{tag:"img[src]",getAttrs:ue}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Ki}]`}],toDOM(){return["br",{[Ki]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:de,parseDOM:[{tag:"br",getAttrs:ue}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:Ot(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...of({tableGroup:"block",cellContent:"block+",cellAttributes:{[be]:{default:de[be].default,getFromDOM:Ot,setDOMAttr:(n,e)=>{n&&Object.assign(e,n)}},background:{default:null,getFromDOM(n){return n.style.backgroundColor||null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`background-color: ${n};`)}}}}),nonTextNode:{group:"block",content:"block*",attrs:{tagName:{default:"span"},attrs:{default:{}}},parseDOM:[{tag:"*:not(tbody)",getAttrs:n=>({tagName:n.tagName.toLowerCase(),attrs:Ot(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},gt=(n,e)=>({attrs:vo,parseDOM:n.map(t=>({tag:t,getAttrs:zo})),toDOM:e}),Xf={strong:gt(["strong","b"],n=>["b",Me(n)]),link:gt(["a"],n=>["a",Me(n),0]),em:gt(["em","i"],n=>["em",Me(n)]),underline:gt(["u"],n=>["u",Me(n),0]),strikethrough:gt(["s"],n=>["s",Me(n),0]),font_size:{attrs:{...vo,size:{default:null}},parseDOM:[{tag:`span[${qi}]`,getAttrs:n=>({...zo(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...Me(n),[qi]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Ui=new il({nodes:_f,marks:Xf}),Sn=new WeakMap,Tr=new WeakMap,Yf=(n,e)=>{Sn.set(n,e),Tr.set(e,n)},Zf=(n,e)=>{Sn.delete(n),Tr.delete(e)},Wn=n=>Sn.get(n),Qf=n=>Tr.get(n),ji=n=>{var t;const e=Qf(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},eh=n=>n.dispatchEvent(new CustomEvent("input"));function th(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(dn)){if(t.getAttribute("style")){t.removeAttribute(dn);return}const r=t.parentElement;if(r){for(;t.firstChild;)r.insertBefore(t.firstChild,t);r.removeChild(t)}}else Array.from(t.children).forEach(r=>e(r))};e(n)}function nh(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,r=f=>n.getSelectedAll().includes(f),i=f=>f.isInstanceOf("text")&&!f.isChildOf("text"),s=f=>f.isChildOf("text"),o=f=>n.getEditing()===f,l=(f,h={})=>{f.trigger("focus",h.event)},a=(f,h)=>{r(f)&&i(f)&&!o(f)&&l(f,h)},c=(f,h)=>{if(r(f)&&!i(f)&&s(f)){const d=f.parents().find(u=>u.isInstanceOf("text"));d&&(l(d,h),setTimeout(()=>n.select(d),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const rh=(n,e)=>{const t=ih(n);return t&&uh(t)?sh(n,e):t?Bs(()=>({type:n.schema.nodes.div}))(n,e):!1};function ih(n){const e=n.selection.$from;if(e.node(e.depth).type===n.schema.nodes.inlineFragment){const t=e.depth-1;return e.node(t)}return e.node(e.depth)}function sh(n,e){const{selection:t,schema:r,tr:i}=n;i.split(t.from,1);const s=t.from+1,o=i.doc.nodeAt(s),l={...o.attrs.attrs,id:void 0},a=o.textContent.length>0,c=o.textContent.length||0,f=o.textContent||" ",h=r.text(f),d=r.nodes.div.create(l,a?h:[],[]);return i.replaceRangeWith(s,s+c+2,d),i.setSelection(C.create(i.doc,s+1)),e==null||e(i.scrollIntoView()),!0}function oh(n,e,t){const{state:r,dispatch:i}=n,{selection:s,tr:o}=r,l=(a,c,f)=>{const h={};return a.split(";").forEach(d=>{const[u,p]=d.split(":").map(m=>m.trim());u&&(h[u]=p)}),h[c]=f,Object.entries(h).map(([d,u])=>`${d}: ${u}`).join("; ")};if(!s.empty||t)o.doc.nodesBetween(s.from,s.to,(a,c)=>{var f,h;if(a.type===r.schema.nodes.image){const d=l(((f=a.attrs.attrs)==null?void 0:f.style)||"","float",e);o.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:d}})}else if(a.type.isBlock){const d=l(((h=a.attrs.attrs)==null?void 0:h.style)||"","text-align",e);Bo(a)?o.setBlockType(s.from,void 0,r.schema.nodes.div,{attrs:{style:d}}):o.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:d}})}});else{const a=r.doc.resolve(s.from),c=a.start(a.depth),f=r.doc.nodeAt(c);if(f!=null&&f.type.isBlock){const h=l(f.attrs.style||"","text-align",e);o.setNodeMarkup(c,void 0,{...f.attrs,style:h})}}o.docChanged&&i(o.scrollIntoView())}const yt=(n,e)=>{const{from:t,to:r}=n.selection;let i=!1;return n.doc.nodesBetween(t,r,s=>{if(i)return!1;s.marks.some(o=>o.type===e)&&(i=!0)}),i};function lh(n,e,t="_blank"){const{state:r,dispatch:i}=n,{schema:s,selection:o,tr:l}=r,a=s.marks.link;try{const c=a.create({[be]:JSON.stringify({href:e,target:t})});l.addMark(o.from,o.to,c),i(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function ah(n,e){const{state:t,dispatch:r}=n,{selection:i,tr:s}=t;if(i.empty)return;const o=t.schema.marks.font_size;if(!o){console.error("Font size mark is not defined in the schema.");return}s.addMark(i.from,i.to,o.create({size:e})),r(s.scrollIntoView())}const He=(n,e)=>{const{doc:t,selection:r}=n.state,i=t.resolve(r.from);for(let s=i.depth;s>0;s--){const o=i.node(s);if(e(o))return{pos:s>0?i.before(s):0,start:i.start(s),depth:s,node:o}}},ch=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,r])=>(t=t.replace(/-./g,i=>i.toUpperCase()[1]).trim(),e[t]=`${r}`.trim(),e),{});function fh(...n){return(e,t)=>{const r=o=>{e=e.apply(o),t==null||t(o)},i=n.pop();return n.reduce((o,l)=>o||l(e,r),!1)&&i!==void 0&&i(e,t)}}const hh=(n,e)=>{const{state:t,dispatch:r}=n;if(e!=null&&e.event){const{event:i}=e,s=n.posAtCoords({left:i.clientX,top:i.clientY});s!=null&&s.pos&&r(t.tr.setSelection(C.create(t.doc,s.pos)))}else Ps(t,r);setTimeout(()=>setTimeout(()=>n.focus()))},fr=n=>n.isBlock,Bo=n=>n.type.name==="inlineFragment",dh=n=>fr(n)&&!Bo(n),Po=n=>n.type.name==="bulletList",Vo=n=>n.type.name==="orderedList",uh=n=>n.type.name==="heading",ph=n=>Po(n)||Vo(n),Gi=(n,e)=>{var s,o;const t=(s=He(n,l=>l.type===e))==null?void 0:s.node,r=n.state.schema.nodes.listItem;let i;return t?i=Gn(r):(o=He(n,ph))!=null&&o.node?i=fh(Gn(r),Yr(e)):i=Yr(e),i(n.state,n.dispatch)},Fo=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(r=>r.type.name===e)},mh=n=>{var o;const{view:e,prop:t,editor:r,propCSS:i}=n,s=(o=He(e,dh))==null?void 0:o.node;if(s){const l=s.attrs.attrs||{},a=ch(l.style);if(t in a)return a[t]||"";if(l.id){const c=r.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[i]||""}}return""},gh=n=>{const{view:e,prop:t,markName:r,editor:i,propCSS:s}=n,o=Fo(e,r);if(o){const l=o.attrs;if(l[t])return l[t];if(l[be]){const a=Me(o).id;if(a){const c=i.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[s]||""}}}return""},Lo=(n,e)=>{const{dispatch:t}=n,{nodes:r,marks:i}=n.state.schema;return{text:{selected:()=>{const{selection:s,doc:o}=n.state;return o.textBetween(s.from,s.to," ")},replace:(s,o={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(s));o.select&&(c=c.setSelection(C.create(c.doc,a,a+s.length))),t==null||t(c)}},bold:{toggle:()=>Pe(i.strong)(n.state,t),isActive:()=>yt(n.state,i.strong)},italic:{toggle:()=>Pe(i.em)(n.state,t),isActive:()=>yt(n.state,i.em)},underline:{toggle:()=>Pe(i.underline)(n.state,t),isActive:()=>yt(n.state,i.underline)},strikethrough:{toggle:()=>Pe(i.strikethrough)(n.state,t),isActive:()=>yt(n.state,i.strikethrough)},link:{get:()=>{const s=ji(n);if(s!=null&&s.is("link"))return s.getAttributes();{const o=Fo(n,"link");return o?Me(o):{}}},toggle:()=>Pe(i.link)(n.state,t),isActive:()=>yt(n.state,i.link),create:s=>{const o=ji(n);o!=null&&o.is("link")?(o.addAttributes({href:s.url,target:s.target}),n.focus()):lh(n,s.url,s.target)}},alignText:{get:()=>mh({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:s=>oh(n,s.value,!0)},fontSize:{get:()=>gh({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:s=>ah(n,s.value)},image:{open(){const s="assetLayout",{state:o,dispatch:l}=n,{selection:a,doc:c}=o,f=c.textBetween(a.from,a.to," "),h={id:s,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:d=>{const u={alt:f,src:d.asset.getSrc()};l(o.tr.replaceSelectionWith(r.image.createAndFill({attrs:u})))}}};e.runCommand(hn.layoutToggle,h)}},heading:{get:()=>{var o;const s=(o=He(n,fr))==null?void 0:o.node;return`${(s==null?void 0:s.attrs.level)||""}`},set:({value:s})=>{var a;const{state:o}=n,l=(a=He(n,fr))==null?void 0:a.node;Yl(o.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:s?parseInt(s,10):0})(o,t)}},listBullet:{isActive:()=>{var s;return!!((s=He(n,Po))!=null&&s.node)},toggle:()=>Gi(n,r.bulletList)},listOrdered:{isActive:()=>{var s;return!!((s=He(n,Vo))!=null&&s.node)},toggle:()=>Gi(n,r.orderedList)}}};class Be{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?yh(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}}function yh(n){return function(e,t,r,i){let s=n;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),r+=o;let l=r-i;l>0&&(s=t[0].slice(o-l,o)+s,r=i)}return e.tr.insertText(s,r,i)}}const bh=500;function xh({rules:n}){let e=new ut({state:{init(){return null},apply(t,r){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,s){return _i(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&_i(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function _i(n,e,t,r,i,s){if(n.composing)return!1;let o=n.state,l=o.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-bh),l.parentOffset,null,"")+r;for(let c=0;c<i.length;c++){let f=i[c];if(l.parent.type.spec.code){if(!f.inCode)continue}else if(f.inCode==="only")continue;let h=f.match.exec(a),d=h&&f.handler(o,h,e-(h[0].length-r.length),t);if(d)return f.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const kh=new Be(/--$/,"—"),Sh=new Be(/\.\.\.$/,"…"),Ch=new Be(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),wh=new Be(/"$/,"”"),Mh=new Be(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Oh=new Be(/'$/,"’"),Nh=[Ch,wh,Mh,Oh];function Ar(n,e,t=null,r){return new Be(n,(i,s,o,l)=>{let a=t instanceof Function?t(s):t,c=i.tr.delete(o,l),f=c.doc.resolve(o),h=f.blockRange(),d=h&&xs(h,e,a);if(!d)return null;c.wrap(h,d);let u=c.doc.resolve(o-1).nodeBefore;return u&&u.type==e&&mn(c.doc,o-1)&&(!r||r(s,u))&&c.join(o-1),c})}function Ho(n,e,t=null){return new Be(n,(r,i,s,o)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,o).setBlockType(s,s,e,a):null})}function Th(n){return Ar(/^\s*>\s$/,n)}function Ah(n){return Ar(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Dh(n){return Ar(/^\s*([-+*])\s$/,n)}function Eh(n){return Ho(/^```$/,n)}function Rh(n,e){return Ho(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function Ih(n){const e=Nh.concat(Sh,kh);let t;return(t=n.nodes.blockquote)&&e.push(Th(t)),(t=n.nodes.orderedList)&&e.push(Ah(t)),(t=n.nodes.bulletList)&&e.push(Dh(t)),(t=n.nodes.codeBlock)&&e.push(Eh(t)),(t=n.nodes.heading)&&e.push(Rh(t,6)),xh({rules:e})}const vh="rteProseMirror",zh=nt.free,te="rte:selectionchange",Y={bold:'<svg viewBox="0 0 24 24"><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',italic:'<svg viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',underline:'<svg viewBox="0 0 24 24"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" /></svg>',strikethrough:'<svg viewBox="0 0 24 24"><path d="M7.2 9.8c-1.2-2.3.5-5 2.9-5.5 3.1-1 7.6.4 7.5 4.2h-3l-.1-.8c-.2-.6-.6-.9-1.2-1.1-.8-.3-2.1-.2-2.8.3C9 8.2 10.4 9.5 12 10H7.4l-.2-.2M21 13v-2H3v2h9.6l.6.2c.6.3 1.1.5 1.3 1.1.1.4.2.9 0 1.3-.2.5-.6.7-1.1.9-1.8.5-4-.2-3.9-2.4h-3c-.1 2.6 2.1 4.4 4.5 4.7 3.8.8 8.3-1.6 6.3-5.9l3.7.1Z"/></svg>',link:'<svg viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',image:'<svg viewBox="0 0 24 24"><path d="M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z"></path></svg>',listBullet:'<svg viewBox="0 0 24 24"><path d="M7 5h14v2H7V5m0 8v-2h14v2H7M4 4.5A1.5 1.5 0 0 1 5.5 6 1.5 1.5 0 0 1 4 7.5 1.5 1.5 0 0 1 2.5 6 1.5 1.5 0 0 1 4 4.5m0 6A1.5 1.5 0 0 1 5.5 12 1.5 1.5 0 0 1 4 13.5 1.5 1.5 0 0 1 2.5 12 1.5 1.5 0 0 1 4 10.5M7 19v-2h14v2H7m-3-2.5A1.5 1.5 0 0 1 5.5 18 1.5 1.5 0 0 1 4 19.5 1.5 1.5 0 0 1 2.5 18 1.5 1.5 0 0 1 4 16.5Z"/></svg>',listOrdered:'<svg viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.3-7a.8.8 0 0 1 .7.8c0 .1 0 .3-.2.5L3 13h2v1H2v-1l2-2H2v-1h2.3Z"/></svg>',alignTextLeft:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>',alignTextCenter:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>',alignTextRight:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>',alignTextJustify:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /></svg>'},Bh=(n,e)=>{var a;const{editor:t,el:r}=n,i=Sn.get(r),s=Lo(i,t),o={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:Y.bold,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.bold.isActive()})}},onClick:({setState:c})=>{s.bold.toggle(),c({active:s.bold.isActive()})}},italic:{id:"italic",icon:Y.italic,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.italic.isActive()})}},onClick:({setState:c})=>{s.italic.toggle(),c({active:s.italic.isActive()})}},underline:{id:"underline",icon:Y.underline,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.underline.isActive()})}},onClick:({setState:c})=>{s.underline.toggle(),c({active:s.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:Y.strikethrough,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.strikethrough.isActive()})}},onClick:({setState:c})=>{s.strikethrough.toggle(),c({active:s.strikethrough.isActive()})}},image:{id:"image",icon:Y.image,size:"s",type:"button",onClick:()=>s.image.open()},link:{id:"link",icon:Y.link,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.link.isActive(),disabled:i.state.selection.empty})}},onClick:({event:c})=>{const f=c.currentTarget||c.target,{x:h,y:d,width:u,height:p}=f.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(hn.layoutRemove,{id:m}),b=s.link.get(),w={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:h,y:d,w:u,h:p},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:O=>{O.preventDefault();const T=new FormData(O.currentTarget);s.link.create({url:T.get("url"),target:T.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(b==null?void 0:b.href)||"",onChange:({value:O,setState:T})=>T({value:O})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(b==null?void 0:b.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:O,setState:T})=>T({value:O})},{type:"row",style:{gap:10,justifyContent:"end"},children:[s.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{s.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(hn.layoutToggle,w)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:Y.alignTextLeft},{id:"center",icon:Y.alignTextCenter},{id:"right",icon:Y.alignTextRight},{id:"justify",icon:Y.alignTextJustify}],editorEvents:{[te]:({setState:c})=>{c({value:s.alignText.get()})}},onChange:({value:c,setState:f})=>{f({value:c}),s.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:Y.listBullet,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.listBullet.isActive()})}},onClick:({setState:c})=>{s.listBullet.toggle(),c({active:s.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:Y.listOrdered,size:"s",type:"button",editorEvents:{[te]:({setState:c})=>{c({active:s.listOrdered.isActive()})}},onClick:({setState:c})=>{s.listOrdered.toggle(),c({active:s.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[te]:({setState:c})=>{c({value:s.heading.get()})}},onChange:({value:c,setState:f})=>{f({value:c}),s.heading.set({value:c}),i.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[te]:({setState:c})=>{c({value:s.fontSize.get()})}},onChange:({value:c,setState:f})=>{f({value:c}),s.fontSize.set({value:c}),i.focus()}}},l=[o.bold,o.italic,o.underline,o.strikethrough,o.image,o.link,o.listBullet,o.listOrdered,o.alignText,o.heading,o.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:s,layouts:o,proseMirror:{view:i},items:l}))||l};class Ph{constructor(e,t,r){this.editor=r,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(i=>{this.dom.setAttribute(i,e.attrs.attrs[i])}),this.dom.addEventListener("dblclick",i=>this.handleDoubleClick(i))}handleDoubleClick(e){const{editor:t,view:r}=this;Lo(r,t).image.open(),e.preventDefault()}update(e){return e.type!==this.node.type?!1:(this.node=e,Object.keys(e.attrs.attrs).forEach(t=>{this.dom.setAttribute(t,e.attrs.attrs[t])}),!0)}selectNode(){this.dom.style.outline="2px solid #ffca6f"}deselectNode(){this.dom.style.outline=""}}const Vh=function(n,e={}){const t={plugins:o=>o.plugins,...e},r=(o,l)=>{var p,m;const a=((p=t.schema)==null?void 0:p.call(t,{editor:n,schema:Ui}))||Ui,{nodes:c,marks:f}=a,h=lt.fromSchema(a).parse(o),d=tt.create({doc:h,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,Plugin:ut,plugins:[Af(),Ff(),Ih(a),ca(),Bn({Tab:zi(1),"Shift-Tab":zi(-1)}),Bn({Enter:At(zs,ya(c.listItem),rh),"Shift-Enter":At(vs,(g,b)=>(b&&b(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":Ws,"Mod-y":jn,"Mod-Shift-z":jn,"Mod-b":Pe(f.strong),"Mod-i":Pe(f.em),"Shift-Tab":Gn(c.listItem),Tab:ka(c.listItem)}),Bn(ea)]})}),u=new Zc({mount:o},{state:d,dispatchTransaction(g){var R;const{state:b}=u,w=b.apply(g),O=!b.doc.eq(w.doc);u.updateState(w);const T=!b.selection.eq(w.selection);O&&(eh(((R=l==null?void 0:l.view)==null?void 0:R.el)||o),u.focus()),(T||O)&&n.trigger(te)}});return o.__rteView=u,u.setProps({nodeViews:{image(g){return new Ph(g,u,n)}}}),u},i=o=>Bh(o,t);n.setCustomRte({toolbar:i,parseContent:!0,async enable(o,l,a){const c=Wn(o);if(c)return c;const f=r(o,a);return Yf(o,f),hh(f,a),f},disable(o){const l=Wn(o);if(l)return Zf(o,l),l.destroy(),{forceSync:!0}},getContent(o){const l=Wn(o);if(l){const{schema:a,doc:c}=l.state,f=document.createElement("div"),h=Xe.fromSchema(a).serializeFragment(c.content);return h.childNodes.forEach(d=>{d.nodeType===Node.ELEMENT_NODE&&d.innerHTML===""&&(d.innerHTML="<br/>")}),f.appendChild(h),th(f),o.classList.remove("ProseMirror-focused"),f.innerHTML}return o.innerHTML}});const s=nh(n,t);jf({editor:n,licenseKey:t.licenseKey,plan:zh,pluginName:vh,cleanup:()=>{n.RichTextEditor.customRte=void 0,s()}})},Fh=Uf(Vh);module.exports=Fh;