@grapesjs/studio-sdk-plugins 1.0.34 → 1.0.35
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.
- package/dist/aiChat/clientTools.d.ts +3 -3
- package/dist/aiChat/clientToolsProcessors.d.ts +5 -2
- package/dist/aiChat/components/AiChatHeader.d.ts +22 -2
- package/dist/aiChat/components/AiChatToolGenerateImage.d.ts +7 -0
- package/dist/aiChat/components/utils.d.ts +2 -0
- package/dist/aiChat/index.cjs.js +88 -99
- package/dist/aiChat/index.es.js +12677 -11001
- package/dist/aiChat/index.js +88 -99
- package/dist/aiChat/index.umd.js +97 -108
- package/dist/aiChat/locales/en.d.ts +38 -0
- package/dist/aiChat/server/index.cjs.js +91 -237
- package/dist/aiChat/server/index.es.js +721 -631
- package/dist/aiChat/server/index.js +91 -237
- package/dist/aiChat/server/index.umd.js +91 -237
- package/dist/aiChat/server/prompts.d.ts +15 -11
- package/dist/aiChat/server/tools.d.ts +74 -122
- package/dist/aiChat/server/types.d.ts +61 -3
- package/dist/aiChat/types.d.ts +69 -11
- package/dist/aiChat/typesSchema.d.ts +27 -0
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +11 -11
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +11 -11
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +20 -20
- package/dist/index.es.js +208 -208
- package/dist/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +7 -7
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/presetPrintable/index.cjs.js +2 -2
- package/dist/presetPrintable/index.es.js +5 -5
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +12 -12
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +83 -83
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +15 -15
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -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:F(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&&q)&&qe(l.node,l.offset,f.anchorNode,f.anchorOffset)&&qe(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?je:ds,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ce:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?je:ce}r=o}this.dirty=je}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?je:ds;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class us extends At{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==te&&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 Xa extends At{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 Ue extends At{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=$e.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Ue(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ce||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ce&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=te){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=te}}slice(e,t,r){let i=Ue.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=rr(s,t,o,r)),e>0&&(s=rr(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 Te extends At{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}=$e.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=bs(f,r,t),c?a=new Ya(e,t,r,i,f,h||null,d,c,s,o+1):t.isText?new ln(e,t,r,i,f,d,s):new Te(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==te&&e.eq(this.node)&&an(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 Qa(this,o&&o.node,e);nc(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?O.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==je)&&(o&&this.protectLocalComposition(e,o),gs(this.contentDOM,this.children,e),at&&rc(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=ic(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 Xa(this,s,t,i);e.input.compositionNodes.push(o),this.children=rr(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==ce||!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=te}updateOuterDeco(e){if(an(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ys(this.dom,this.nodeDOM,nr(this.outerDeco,this.node,t),nr(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 ps(n,e,t,r,i){bs(r,e,n);let s=new Te(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class ln extends Te{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==ce||this.dirty!=te&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=te||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=te,!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 ln(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=ce)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ms extends At{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==te&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ya extends Te{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==ce)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 gs(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=xs(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof Ue){let a=r?r.previousSibling:n.lastChild;gs(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=xs(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Dt=function(n){n&&(this.nodeName=n)};Dt.prototype=Object.create(null);const Ge=[new Dt];function nr(n,e,t){if(n.length==0)return Ge;let r=t?Ge[0]:new Dt,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new Dt(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(r=new Dt(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 ys(n,e,t,r){if(t==Ge&&r==Ge)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=Ge[0]),i=a}Za(i,l||Ge[0],o)}return i}function Za(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 bs(n,e,t){return ys(n,n,Ge,nr(e,t,n.nodeType!=1))}function an(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 xs(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Qa{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ec(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=te,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=Ue.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==ce&&o.dom==o.contentDOM&&(o.dirty=je),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 Te){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!=ce&&an(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=je,h.updateChildren(i,o+1),h.dirty=te),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)||!an(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Te.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=Te.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 us(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 Ue;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ln)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((q||$)&&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 ms(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 ec(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 Ue)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 tc(n,e){return n.type.side-e.type.side}function nc(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(tc);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 rc(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 ic(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 rr(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 ir(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(on(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&&Ea(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=or(n,f,l,h)}return c}function ks(n){return n.editable?n.hasFocus():Ts(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ye(n,e=!1){let t=n.state.selection;if(Ms(n,t),!!ks(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&$){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&qe(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)oc(n);else{let{anchor:r,head:i}=t,s,o;Ss&&!(t instanceof C)&&(t.$from.parent.inlineContent||(s=Cs(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Cs(n,t.to))),n.docView.setSelection(r,i,n,e),Ss&&(s&&ws(s),o&&ws(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&sc(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ss=q||$&&Qi<63;function Cs(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(q&&i&&i.contentEditable=="false")return sr(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return sr(i);if(s)return sr(s)}}function sr(n){return n.contentEditable="true",q&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ws(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function sc(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(()=>{(!ks(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function oc(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,F(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&G&&Oe<=11&&(r.disabled=!0,r.disabled=!1)}function Ms(n,e){if(e instanceof k){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Os(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Os(n)}function Os(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function or(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||C.between(e,t,r)}function Ns(n){return n.editable&&!n.hasFocus()?!1:Ts(n)}function Ts(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 lc(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return qe(e.node,e.offset,t.anchorNode,t.anchorOffset)}function lr(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 Ae(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function As(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 Ae(n,new C(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=lr(n.state,e);return i&&i instanceof k?Ae(n,i):!1}else if(!(ee&&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)?Ae(n,new k(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Nt?Ae(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 Ae(n,new C(e>0?r.$to:r.$from));{let i=lr(n.state,e);return i?Ae(n,i):!1}}}function cn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Et(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function ft(n,e){return e<0?ac(n):cc(n)}function ac(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<cn(t)&&Et(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Et(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Ds(t))break;{let l=t.previousSibling;for(;l&&Et(l,-1);)i=t.parentNode,s=F(l),l=l.previousSibling;if(l)t=l,r=cn(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?ar(n,t,r):i&&ar(n,i,s)}function cc(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=cn(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Et(l,1))s=t,o=++r;else break}else{if(Ds(t))break;{let l=t.nextSibling;for(;l&&Et(l,1);)s=l.parentNode,o=F(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=cn(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&ar(n,s,o)}function Ds(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function fc(n,e){for(;n&&e==n.childNodes.length&&!Ot(n);)e=F(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 hc(n,e){for(;n&&!e&&!Ot(n);)e=F(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 ar(n,e,t){if(e.nodeType!=3){let s,o;(o=fc(e,t))?(e=o,t=0):(s=hc(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(on(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 Es(n,e){let t=n.state.doc.resolve(e);if(!($||va)&&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 Rs(n,e,t){let r=n.state.selection;if(r instanceof C&&!r.empty||t.indexOf("s")>-1||ee&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=lr(n.state,e);if(o&&o instanceof k)return Ae(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Y?S.near(o,e):S.findFrom(o,e);return l?Ae(n,l):!1}return!1}function Is(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 vs(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function dc(n){if(!q||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;vs(n,r,"true"),setTimeout(()=>vs(n,r,"false"),20)}return!1}function uc(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function pc(n,e){let t=e.keyCode,r=uc(e);if(t==8||ee&&t==72&&r=="c")return Is(n,-1)||ft(n,-1);if(t==46&&!e.shiftKey||ee&&t==68&&r=="c")return Is(n,1)||ft(n,1);if(t==13||t==27)return!0;if(t==37||ee&&t==66&&r=="c"){let i=t==37?Es(n,n.state.selection.from)=="ltr"?-1:1:-1;return As(n,i,r)||ft(n,i)}else if(t==39||ee&&t==70&&r=="c"){let i=t==39?Es(n,n.state.selection.from)=="ltr"?1:-1:1;return As(n,i,r)||ft(n,i)}else{if(t==38||ee&&t==80&&r=="c")return Rs(n,-1,r)||ft(n,-1);if(t==40||ee&&t==78&&r=="c")return dc(n)||Rs(n,1,r)||ft(n,1);if(r==(ee?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function zs(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")||$e.fromSchema(n.state.schema),l=Ws(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,f,h=0;for(;c&&c.nodeType==1&&(f=Hs[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 Bs(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=$e.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=bc(t),Nt&&xc(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")||He.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!mc.test(d.parentNode.nodeName)?{ignore:!0}:null}})),f)l=kc(Ls(l,+f[1],+f[2]),f[4]);else if(l=x.maxOpen(gc(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=Ls(l,h,d)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const mc=/^(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 gc(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&&Vs(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Fs(o[o.length-1],s.length));let f=Ps(l,a);o.push(f),i=i.matchType(f.type),s=a}}),o)return y.from(o)}return n}function Ps(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,y.from(n));return n}function Vs(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Vs(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(Ps(t,n,i+1))))}}function Fs(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Fs(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(y.empty,!0);return n.copy(t.append(r))}function cr(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=cr(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 Ls(n,e,t){return e<n.openStart&&(n=new x(cr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new x(cr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Hs={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 $s=null;function Ws(){return $s||($s=document.implementation.createHTMLDocument("title"))}let fr=null;function yc(n){let e=window.trustedTypes;return e?(fr||(fr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),fr.createHTML(n)):n}function bc(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Ws().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Hs[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=yc(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function xc(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 kc(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 K={},j={},Sc={touchstart:!0,touchmove:!0};class Cc{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 wc(n){for(let e in K){let t=K[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Oc(n,r)&&!dr(n,r)&&(n.editable||!(r.type in j))&&t(n,r)},Sc[e]?{passive:!0}:void 0)}q&&n.dom.addEventListener("input",()=>null),hr(n)}function De(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Mc(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 hr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>dr(n,r))})}function dr(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Oc(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 Nc(n,e){!dr(n,e)&&K[e.type]&&(n.editable||!(e.type in j))&&K[e.type](n,e)}j.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!qs(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(se&&$&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),at&&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,Ke(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||pc(n,t)?t.preventDefault():De(n,"key")},j.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},j.keypress=(n,e)=>{let t=e;if(qs(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ee&&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 fn(n){return{left:n.clientX,top:n.clientY}}function Tc(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ur(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 ht(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 Ac(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&k.isSelectable(r)?(ht(n,new k(t)),!0):!1}function Dc(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?(ht(n,k.create(n.state.doc,i)),!0):!1}function Ec(n,e,t,r,i){return ur(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Dc(n,t):Ac(n,t))}function Rc(n,e,t,r){return ur(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Ic(n,e,t,r){return ur(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||vc(n,t,r)}function vc(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(ht(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)ht(n,C.create(r,l+1,l+1+o.content.size));else if(k.isSelectable(o))ht(n,k.create(r,l));else continue;return!0}}function pr(n){return hn(n)}const Js=ee?"metaKey":"ctrlKey";K.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=pr(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Tc(t,n.input.lastClick)&&!t[Js]&&(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(fn(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new zc(n,o,t,!!r)):(s=="doubleClick"?Rc:Ic)(n,o.pos,o.inside,t)?t.preventDefault():De(n,"pointer"))};class zc{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[Js],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(fn(e))),this.updateAllowDefault(e),this.allowDefault||!t?De(this.view,"pointer"):Ec(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||q&&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)?(ht(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)}}K.touchstart=n=>{n.input.lastTouch=Date.now(),pr(n),De(n,"pointer")},K.touchmove=n=>{n.input.lastTouch=Date.now(),De(n,"pointer")},K.contextmenu=n=>pr(n);function qs(n,e){return n.composing?!0:q&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Bc=se?5e3:-1;j.compositionstart=j.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(),hn(n,!0),n.markCursor=null;else if(hn(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}Ks(n,Bc)},j.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++,Ks(n,20))};function Ks(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>hn(n),e))}function js(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Vc());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Pc(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Aa(e.focusNode,e.focusOffset),r=Da(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 Vc(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function hn(n,e=!1){if(!(se&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),js(n),e||n.docView&&n.docView.dirty){let t=ir(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 Fc(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 Rt=G&&Oe<15||at&&za<604;K.copy=j.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=Rt?null:t.clipboardData,o=r.content(),{dom:l,text:a}=zs(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Fc(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Lc(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Hc(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?It(n,r.value,null,i,e):It(n,r.textContent,r.innerHTML,i,e)},50)}function It(n,e,t,r,i){let s=Bs(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=Lc(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 Us(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," "):""}j.paste=(n,e)=>{let t=e;if(n.composing&&!se)return;let r=Rt?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&It(n,Us(r),r.getData("text/html"),i,t)?t.preventDefault():Hc(n,t)};class Gs{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const _s=ee?"altKey":"ctrlKey";K.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(fn(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}=zs(n,l);(!t.dataTransfer.files.length||!$||Qi>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Rt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Rt||t.dataTransfer.setData("text/plain",c),n.dragging=new Gs(f,!t[_s],o)},K.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},j.dragover=j.dragenter=(n,e)=>e.preventDefault(),j.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(fn(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=Bs(n,Us(t.dataTransfer),Rt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[_s]);if(n.someProp("handleDrop",p=>p(n,t,o||x.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?Bl(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(or(n,u,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},K.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))},K.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)},K.beforeinput=(n,e)=>{if($&&se&&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,Ke(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 j)K[n]=j[n];function vt(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 dn{constructor(e,t){this.toDOM=e,this.spec=t||_e,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 _(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof dn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&vt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ee{constructor(e,t){this.attrs=e,this.spec=t||_e}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 _(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ee&&vt(this.attrs,e.attrs)&&vt(this.spec,e.spec)}static is(e){return e.type instanceof Ee}destroy(){}}class mr{constructor(e,t){this.attrs=e,this.spec=t||_e}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 _(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 mr&&vt(this.attrs,e.attrs)&&vt(this.spec,e.spec)}destroy(){}}class _{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new _(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 _(e,e,new dn(t,r))}static inline(e,t,r,i){return new _(e,t,new Ee(r,i))}static node(e,t,r,i){return new _(e,t,new mr(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ee}get widget(){return this.type instanceof dn}}const dt=[],_e={};class A{constructor(e,t){this.local=e.length?e:dt,this.children=t.length?t:dt}static create(e,t){return t.length?un(t,e,0,_e):W}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==W||e.maps.length==0?this:this.mapInner(e,t,0,0,r||_e)}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?$c(this.children,o||[],e,t,r,i,s):o?new A(o.sort(Xe),dt):W}add(e,t){return t.length?this==W?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=Ys(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,un(f,l,c+1,_e)),s+=3}});let o=Xs(s?Zs(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(Xe):this.local,i||this.children)}remove(e){return e.length==0||this==W?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!=W?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):W}forChild(e,t){if(this==W)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 Ee){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(Xe),dt);return r?new Re([l,r]):l}return r||W}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 gr(this.localsInner(e))}localsInner(e){if(this==W)return dt;if(e.inlineContent||!this.local.some(Ee.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ee||t.push(this.local[r]);return t}forEachSet(e){e(this)}}A.empty=new A([],[]),A.removeOverlap=gr;const W=A.empty;class Re{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,_e));return Re.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!=W&&(s instanceof Re?r=r.concat(s.members):r.push(s))}return Re.from(r)}eq(e){if(!(e instanceof Re)||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?gr(r?t:t.sort(Xe)):dt}static from(e){switch(e.length){case 0:return W;case 1:return e[0];default:return new Re(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 $c(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 N=l[b]+f-h;u>=N?l[b+1]=d<=N?-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!=W?(l[c]=h,l[c+1]=u,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Wc(l,n,e,t,i,s,o),f=un(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(Xe),l)}function Xs(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 _(i.from+e,i.to+e,i.type))}return t}function Wc(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 Ys(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 Zs(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function un(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=Ys(n,l,a+t);if(c){s=!0;let f=un(c,l,t+a+1,r);f!=W&&i.push(a,a+l.nodeSize,f)}});let o=Xs(s?Zs(n):n,-t).sort(Xe);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):W}function Xe(n,e){return n.from-e.from||n.to-e.to}function gr(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),Qs(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),Qs(e,i,r.copy(s.from,r.to)));break}}}return e}function Qs(n,e,t){for(;e<n.length&&Xe(t,n[e])>0;)e++;n.splice(e,0,t)}function yr(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=W&&e.push(r)}),n.cursorWrapper&&e.push(A.create(n.state.doc,[n.cursorWrapper.deco])),Re.from(e)}const Jc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},qc=G&&Oe<=11;class Kc{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 jc{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Kc,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]);G&&Oe<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),qc&&(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,Jc)),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(Ns(this.view)){if(this.suppressingSelectionUpdates)return ye(this.view);if(G&&Oe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&qe(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=Mt(s))t.add(s);for(let s=e.anchorNode;s;s=Mt(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)&&Ns(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||_c(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&&on(r)&&(c=ir(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),Uc(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(G&&Oe<=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?F(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?F(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 eo=new WeakMap,to=!1;function Uc(n){if(!eo.has(n)&&(eo.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ie,to)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."),to=!0}}function no(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return qe(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Gc(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return no(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?no(n,t):null}function _c(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 Xc(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}],on(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")||He.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:Yc,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 Yc(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(q&&/^(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||q&&/^(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 Zc=/^(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 Qc(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,Be=ir(n,M);if(Be&&!n.state.selection.eq(Be)){if($&&se&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",jh=>jh(n,Ke(13,"Enter"))))return;let Mn=n.state.tr.setSelection(Be);M=="pointer"?Mn.setMeta("pointer",!0):M=="key"&&Mn.scrollIntoView(),s&&Mn.setMeta("composition",s),n.dispatch(Mn)}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=Xc(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=nf(h.content,c.doc.content,c.from,d,u);if(p&&n.input.domChangeCount++,(at&&n.input.lastIOSEnter>Date.now()-225||se)&&i.some(M=>M.nodeType==1&&!Zc.test(M.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",M=>M(n,Ke(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=ro(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let Be=n.state.tr.setSelection(M);s&&Be.setMeta("composition",s),n.dispatch(Be)}}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)),G&&Oe<=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,N;if((at&&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)&&(N=S.findFrom(c.doc.resolve(m.pos+1),1,!0))&&N.head==g.pos)&&n.someProp("handleKeyDown",M=>M(n,Ke(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&tf(f,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,Ke(8,"Backspace")))){se&&$&&n.domObserver.suppressSelectionUpdates();return}$&&se&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),se&&!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,Ke(13,"Enter"))})},20));let J=p.start,B=p.endA,R,ne,ze;if(w){if(m.pos==g.pos)G&&Oe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ye(n),20)),R=n.state.tr.delete(J,B),ne=f.resolve(p.start).marksAcross(f.resolve(p.endA));else if(p.endA==p.endB&&(ze=ef(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))R=n.state.tr,ze.type=="add"?R.addMark(J,B,ze.mark):R.removeMark(J,B,ze.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",Be=>Be(n,J,B,M)))return;R=n.state.tr.insertText(M,J,B)}}if(R||(R=n.state.tr.replace(J,B,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let M=ro(n,R.doc,c.sel);M&&!($&&se&&n.composing&&M.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(M.head==J||M.head==R.mapping.map(B)-1)||G&&M.empty&&M.head==J)&&R.setSelection(M)}ne&&R.ensureMarks(ne),s&&R.setMeta("composition",s),n.dispatch(R.scrollIntoView())}function ro(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:or(n,e.resolve(t.anchor),e.resolve(t.head))}function ef(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 tf(n,e,t,r,i){if(t-e<=i.pos-r.pos||br(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(br(s,!0,!0));return!o.parent.isTextblock||o.pos>t||br(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function br(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 nf(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&&io(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&&io(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function io(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 rf{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 Cc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(co),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=lo(this),oo(this),this.nodeViews=ao(this),this.docView=ps(this.state.doc,so(this),yr(this),this.dom,this),this.domObserver=new jc(this,(r,i,s,o)=>Qc(this,r,i,s,o)),this.domObserver.start(),wc(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&&hr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(co),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&&(js(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=ao(this);of(u,this.nodeViews)&&(this.nodeViews=u,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&hr(this),this.editable=lo(this),oo(this);let a=yr(this),c=so(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&&Va(this);if(o){this.domObserver.stop();let u=h&&(G||$)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&sf(i.selection,e.selection);if(h){let p=$?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Pc(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ps(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(u=!0)}u||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&lc(this))?ye(this,u):(Ms(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&&Fa(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&&es(this,t.getBoundingClientRect(),e)}else es(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 Gs(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(G){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&&La(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 qa(this,e)}coordsAtPos(e,t=1){return ls(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 _a(this,t||this.state,e)}pasteHTML(e,t){return It(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return It(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Mc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],yr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Na())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Nc(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?q&&this.root.nodeType===11&&Ra(this.dom.ownerDocument)==this.dom&&Gc(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function so(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"),[_.node(0,n.state.doc.content.size,e)]}function oo(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:_.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function lo(n){return!n.someProp("editable",e=>e(n.state)===!1)}function sf(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 ao(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 of(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 co(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 xr,kr;if(typeof WeakMap<"u"){let n=new WeakMap;xr=e=>n.get(e),kr=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;xr=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},kr=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var E=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 xr(n)||kr(n,lf(n))}};function lf(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=af(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 N=0;N<b;N++){if(N+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:f,n:b-N});break}const J=i+N*e;for(let B=0;B<g;B++){r[J+B]==0?r[J+B]=f:(s||(s=[])).push({type:"collision",row:c,pos:f,n:g-B});const R=w&&w[B];if(R){const ne=(J+B)%e*2,ze=o[ne];ze==null||ze!=R&&o[ne+1]==1?(o[ne]=R,o[ne+1]=1):ze==R&&o[ne+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 E(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&&cf(l,o,n),l}function af(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 cf(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=ff(a)))[c]=h)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function ff(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function fo(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 ho(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 hf(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=>fo(r,e)}],toDOM(r){return["td",ho(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>fo(r,e)}],toDOM(r){return["th",ho(r,e),0]}}}}function fe(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 Ie=new Ct("selectingCells");function zt(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 pn(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 Sr(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=zt(e.$head)||df(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function df(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 Cr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function uf(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function wr(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function uo(n,e,t){const r=n.node(-1),i=E.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 ut(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 v=class xe extends S{constructor(e,t=e){const r=e.node(-1),i=E.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 wi(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(Cr(r)&&Cr(i)&&wr(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?xe.rowSelection(r,i):s&&this.isColSelection()?xe.colSelection(r,i):new xe(r,i)}return C.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=E.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=ut(b,0,m)),g>0&&(b=ut(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=E.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=E.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 xe(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=E.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 xe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=E.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 xe(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new xe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new xe(e.resolve(t),e.resolve(r))}getBookmark(){return new pf(this.$anchorCell.pos,this.$headCell.pos)}};v.prototype.visible=!1,S.jsonID("cell",v);var pf=class Uo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Uo(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&&wr(t,r)?new v(t,r):S.near(r,1)}};function mf(n){if(!(n.selection instanceof v))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(_.node(r,r+t.nodeSize,{class:"selectedCell"}))}),A.create(n.doc,e)}function gf({$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 yf({$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 bf(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=v.create(i,r.from);else if(o=="row"){const l=i.resolve(r.from+1);s=v.rowSelection(l,l)}else if(!t){const l=E.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=v.create(i,a+1,c)}}else r instanceof C&&gf(r)?s=C.create(i,r.from):r instanceof C&&yf(r)&&(s=C.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var xf=new Ct("fix-tables");function po(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)?po(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function kf(n,e){let t;const r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=Sf(n,i,s,t))};return e?e.doc!=n.doc&&po(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Sf(n,e,t,r){const i=E.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,ut(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=fe(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(xf,{fixTables:!0})}function mo(n){const e=n.selection,t=Sr(n),r=t.node(-1),i=t.start(-1),s=E.get(r);return{...e instanceof v?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(t.pos-i),tableStart:i,map:s,table:r}}function Cf(n){return function(e,t){if(!pn(e))return!1;if(t){const r=fe(e.schema),i=mo(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 go(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 Mr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Cf(n):function(t,r){if(!pn(t))return!1;if(r){const i=fe(t.schema),s=mo(t),o=t.tr,l=go("row",s,i),a=go("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}}Mr("row",{useDeprecatedLogic:!0}),Mr("column",{useDeprecatedLogic:!0}),Mr("cell",{useDeprecatedLogic:!0});function wf(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 yo(n){return function(e,t){if(!pn(e))return!1;const r=wf(Sr(e),n);if(r==null)return!1;if(t){const i=e.doc.resolve(r);t(e.tr.setSelection(C.between(i,uf(i))).scrollIntoView())}return!0}}function mn(n,e){const t=n.selection;if(!(t instanceof v))return!1;if(e){const r=n.tr,i=fe(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 Mf(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=Or(fe(o).row,new x(c,f,h)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Or(fe(o).row,new x(e,t,r)).content:e);else return null;return Of(o,l)}function Of(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=fe(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 Or(n,e){const t=n.createAndFill();return new Ci(t).replace(0,t.content.size,e).doc}function Nf({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(ut(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 Tf(n,e,t,r,i,s,o){const l=n.doc.type.schema,a=fe(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 bo(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 xo(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,ut(d.attrs,o-u,d.attrs.colspan-(o-u))),n.insert(p+d.nodeSize,d.type.createAndFill(ut(d.attrs,0,o-u))),c+=d.attrs.rowspan-1}}return a}function ko(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=E.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=E.get(s),d=h.mapping.maps.length}Tf(h,o,s,t,c,f,d)&&u(),bo(h,o,s,t,a,c,l,d)&&u(),bo(h,o,s,t,a,c,f,d)&&u(),xo(h,o,s,t,l,f,a,d)&&u(),xo(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 v(h.doc.resolve(t+o.positionAt(l,a,s)),h.doc.resolve(t+o.positionAt(f-1,c-1,s)))),e(h)}var Af=Gi({ArrowLeft:yn("horiz",-1),ArrowRight:yn("horiz",1),ArrowUp:yn("vert",-1),ArrowDown:yn("vert",1),"Shift-ArrowLeft":bn("horiz",-1),"Shift-ArrowRight":bn("horiz",1),"Shift-ArrowUp":bn("vert",-1),"Shift-ArrowDown":bn("vert",1),Backspace:mn,"Mod-Backspace":mn,Delete:mn,"Mod-Delete":mn});function gn(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function yn(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;if(s instanceof v)return gn(t,r,S.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=So(i,n,e);if(o==null)return!1;if(n=="horiz")return gn(t,r,S.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=uo(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),gn(t,r,c)}}}function bn(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;let o;if(s instanceof v)o=s;else{const a=So(i,n,e);if(a==null)return!1;o=new v(t.doc.resolve(a))}const l=uo(o.$headCell,n,e);return l?gn(t,r,new v(o.$anchorCell,l)):!1}}function Df(n,e){const t=n.state.doc,r=zt(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new v(r))),!0):!1}function Ef(n,e,t){if(!pn(n.state))return!1;let r=Mf(t);const i=n.state.selection;if(i instanceof v){r||(r={width:1,height:1,rows:[y.from(Or(fe(n.state.schema).cell,t))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=E.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=Nf(r,l.right-l.left,l.bottom-l.top),ko(n.state,n.dispatch,o,l,r),!0}else if(r){const s=Sr(n.state),o=s.start(-1);return ko(n.state,n.dispatch,o,E.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function Rf(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Co(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof v)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=zt(n.state.selection.$anchor))!=null&&((t=Nr(n,e))==null?void 0:t.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(a,c){let f=Nr(n,c);const h=Ie.getState(n.state)==null;if(!f||!wr(a,f))if(h)f=a;else return;const d=new v(a,f);if(h||!n.state.selection.eq(d)){const u=n.state.tr.setSelection(d);h&&u.setMeta(Ie,a.pos),n.dispatch(u)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),Ie.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ie,-1))}function l(a){const c=a,f=Ie.getState(n.state);let h;if(f!=null)h=n.state.doc.resolve(f);else if(Co(n,c.target)!=r&&(h=Nr(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 So(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 Co(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Nr(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?zt(n.state.doc.resolve(t.pos)):null}var If=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")),Tr(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,Tr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Tr(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 Z=new Ct("tableColumnResizing");function vf({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=If,lastColumnResizable:i=!0}={}){const s=new ot({key:Z,state:{init(o,l){var a,c;const f=(c=(a=s.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,h=fe(l.schema).table.name;return r&&f&&(f[h]=(d,u)=>new r(d,t,u)),new zf(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Z.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{Bf(o,l,n,i)},mouseleave:o=>{Pf(o)},mousedown:(o,l)=>{Vf(o,l,e,t)}},decorations:o=>{const l=Z.getState(o);if(l&&l.activeHandle>-1)return Wf(o,l.activeHandle)},nodeViews:{}}});return s}var zf=class On{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(Z);if(r&&r.setHandle!=null)return new On(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new On(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return Cr(e.doc.resolve(i))||(i=-1),new On(i,t.dragging)}return t}};function Bf(n,e,t,r){const i=Z.getState(n.state);if(i&&!i.dragging){const s=Lf(e.target);let o=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=t?o=wo(n,e,"left",t):a-e.clientX<=t&&(o=wo(n,e,"right",t))}if(o!=i.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=E.get(a),f=l.start(-1);if(c.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Oo(n,o)}}}function Pf(n){const e=Z.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Oo(n,-1)}function Vf(n,e,t,r){var i;const s=(i=n.dom.ownerDocument.defaultView)!=null?i:window,o=Z.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=Ff(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(Z,{setDragging:{startX:e.clientX,startWidth:a}}));function c(h){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",f);const d=Z.getState(n.state);d!=null&&d.dragging&&(Hf(n,d.activeHandle,Mo(d.dragging,h,t)),n.dispatch(n.state.tr.setMeta(Z,{setDragging:null})))}function f(h){if(!h.which)return c(h);const d=Z.getState(n.state);if(d&&d.dragging){const u=Mo(d.dragging,h,t);No(n,d.activeHandle,u,r)}}return No(n,o.activeHandle,a,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",f),e.preventDefault(),!0}function Ff(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 Lf(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function wo(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=zt(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=E.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 Mo(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Oo(n,e){n.dispatch(n.state.tr.setMeta(Z,{setHandle:e}))}function Hf(n,e,t){const r=n.state.doc.resolve(e),i=r.node(-1),s=E.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():$f(d.colspan);p[u]=t,a.setNodeMarkup(o+h,null,{...d,colwidth:p})}a.docChanged&&n.dispatch(a)}function No(n,e,t,r){const i=n.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=E.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&&Tr(s,a.firstChild,a,r,l,t)}function $f(n){return Array(n).fill(0)}function Wf(n,e){var t;const r=[],i=n.doc.resolve(e),s=i.node(-1);if(!s)return A.empty;const o=E.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=Z.getState(n))!=null&&t.dragging&&r.push(_.node(l+h,l+h+s.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),r.push(_.widget(d,u))}}return A.create(n.doc,r)}function Jf({allowTableNodeSelection:n=!1}={}){return new ot({key:Ie,state:{init(){return null},apply(e,t){const r=e.getMeta(Ie);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:mf,handleDOMEvents:{mousedown:Rf},createSelectionBetween(e){return Ie.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Df,handleKeyDown:Af,handlePaste:Ef},appendTransaction(e,t,r){return bf(r,kf(r,t),n)}})}const To="app.grapesjs.com",Ao="app-stage.grapesjs.com",Do=[To,"app2.grapesjs.com",Ao,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],qf="license:check:start",Kf="license:check:end",jf=()=>typeof window<"u",Uf=({isDev:n,isStage:e,isPlatform:t})=>`${n?"":`https://${e?Ao:To}`}/${t?"platform-api":"api"}`,Gf=()=>{const n=jf()&&window.location.hostname;return!!n&&(Do.includes(n)||Do.some(e=>n.endsWith(e)))};async function _f({path:n,baseApiUrl:e,method:t="GET",headers:r={},params:i,body:s}){const l=`${e||Uf({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 pt=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(pt||{}),xn=(n=>(n.toastAdd="studio:toastAdd",n.toastRemove="studio:toastRemove",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.dialogExportCode="studio:dialogExportCode",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.clearPage="studio:clearPage",n.projectFiles="studio:projectFiles",n.validateCode="studio:validateCode",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.layoutComponentAdd="studio:layoutComponentAdd",n.layoutComponentGet="studio:layoutComponentGet",n.layoutComponentRemove="studio:layoutComponentRemove",n.layoutComponentRender="studio:layoutComponentRender",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))(xn||{});const Eo={[pt.free]:0,[pt.startup]:10,[pt.business]:20,[pt.enterprise]:30};function Xf(n){const e=n;return e.init=t=>r=>n(r,t),e}const Yf=n=>Xf(n);async function Zf({editor:n,plan:e,pluginName:t,licenseKey:r,onLicenseCheckResponse:i,cleanup:s}){let o="",l=!1;const a=Gf(),c=h=>{console.warn("Cleanup plugin:",t,"Reason:",h),s()},f=(h={})=>{var g;const{error:d,sdkLicense:u}=h,p=(g=h.plan)==null?void 0:g.category;if(!(u||h.license)||d)c(d||"Invalid license");else if(p){const b=Eo[e],w=Eo[p];b>w&&c({pluginRequiredPlan:e,licensePlan:p})}};n.on(qf,h=>{o=h==null?void 0:h.baseApiUrl,l=!0}),n.on(Kf,h=>{i==null||i(h),f(h)}),setTimeout(async()=>{if(!l){if(a)return;if(r){const h=await Qf({licenseKey:r,pluginName:t,baseApiUrl:o});i==null||i(h),h&&f(h)}else c("The `licenseKey` option not provided")}},2e3)}async function Qf(n){const{licenseKey:e,pluginName:t,baseApiUrl:r}=n;try{return(await _f({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 eh=(n,e)=>{if(!e)return()=>{};const t="keydown",r=s=>{var o;s.key==="Escape"&&((o=n.getEditing())==null||o.trigger("disable"))},i=()=>document.removeEventListener(t,r);return n.onReady(()=>{document.addEventListener(t,r),n.on(n.events.destroy,i)}),i};function th(n,e){if(!e)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 Bt=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},Ar=n=>{const{key:e,cssProperty:t,tagName:r="span"}=n,i="value";return{attrs:{...Sn,[i]:{default:null}},parseDOM:[{tag:`${r}[${e}]`,getAttrs:s=>({...Cn(s),[i]:s.style.getPropertyValue(t)||null})}],toDOM(s){const{[i]:o}=s.attrs,l={...ue(s),[e]:""};return o&&(l.style=`${t}: ${o}`),[r,l,0]}}},Ro="data-gs-mrk-fs",nh="data-gs-mrk-color",rh="data-gs-mrk-bgcolor",Io="data-gs-mrk-wrap",kn="data-gs-ifrg",be="attrs",Sn={[be]:{default:"{}"}},he={[be]:{default:{}}},Cn=n=>({[be]:JSON.stringify(Bt(n))}),de=n=>({attrs:Bt(n)}),Pt=n=>e=>[n,e.attrs.attrs,0],ue=n=>n.attrs[be]?JSON.parse(n.attrs[be]):{},ih={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${kn}]`,getAttrs:de}],toDOM:()=>["span",{[kn]:""},0]},div:{group:"block",content:"inline*",attrs:he,parseDOM:[{tag:"div",getAttrs:de}],toDOM:Pt("div")},paragraph:{group:"block",content:"inline*",attrs:he,parseDOM:[{tag:"p",getAttrs:de}],toDOM:Pt("p")},orderedList:{group:"block",content:"listItem+",attrs:he,parseDOM:[{tag:"ol",getAttrs:de}],toDOM:Pt("ol")},bulletList:{group:"block",content:"listItem+",attrs:he,parseDOM:[{tag:"ul",getAttrs:de}],toDOM:Pt("ul")},listItem:{content:"block*",group:"block",attrs:he,parseDOM:[{tag:"li",getAttrs:de}],toDOM:Pt("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:he,parseDOM:[{tag:"pre",getAttrs:de}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:he,parseDOM:[{tag:"img[src]",getAttrs:de}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,attrs:he,parseDOM:[{tag:"br",getAttrs:de}],toDOM:n=>["br",{...n.attrs.attrs}]},hardBreak:{inline:!0,group:"inline",selectable:!1,attrs:he,parseDOM:[{tag:"br",getAttrs:de}],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:Bt(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...hf({tableGroup:"block",cellContent:"block+",cellAttributes:{[be]:{default:he[be].default,getFromDOM:Bt,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:Bt(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},Vt=(n,e)=>({attrs:Sn,parseDOM:n.map(t=>({tag:t,getAttrs:Cn})),toDOM:e}),sh=n=>({attrs:{...Sn},parseDOM:[{tag:`span[${n}]`,getAttrs:e=>({...Cn(e)})}],toDOM(e){return["span",{...ue(e),[n]:!0},0]}}),oh={strong:Vt(["strong","b"],n=>["b",ue(n)]),link:Vt(["a"],n=>["a",ue(n),0]),em:Vt(["em","i"],n=>["em",ue(n)]),underline:Vt(["u"],n=>["u",ue(n),0]),strikethrough:Vt(["s"],n=>["s",ue(n),0]),wrapStyle:sh(Io),font_size:{attrs:{...Sn,size:{default:null}},parseDOM:[{tag:`span[${Ro}]`,getAttrs:n=>({...Cn(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...ue(n),[Ro]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}},color:Ar({key:nh,cssProperty:"color"}),bgColor:Ar({key:rh,cssProperty:"background-color"})},vo=new fl({nodes:ih,marks:oh}),Ft=new WeakMap,Dr=new WeakMap,lh=(n,e,t)=>{Ft.set(n,{view:e,gjsView:t,initialDoc:e.state.doc}),Dr.set(e,{el:n,gjsView:t})},ah=(n,e)=>{Ft.delete(n),Dr.delete(e)},wn=n=>Ft.get(n),zo=n=>Dr.get(n),Bo=n=>{const e=wn(n),t=e==null?void 0:e.view,r=e==null?void 0:e.initialDoc;return!(t&&r&&r.eq(t.state.doc))},Er=n=>{var e,t;return(t=(e=zo(n))==null?void 0:e.gjsView)==null?void 0:t.model},ch=n=>n.dispatchEvent(new CustomEvent("input"));function fh(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(kn)){if(t.getAttribute("style")){t.removeAttribute(kn);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)}const Po=n=>{n.childNodes.forEach(e=>{if(e.nodeName==="BR"){const{nextSibling:t}=e,r=n.lastChild===e,i=(t==null?void 0:t.nodeType)===Node.ELEMENT_NODE&&(t==null?void 0:t.nodeName)!=="BR";(r||i)&&e.remove()}else Po(e)})},hh=(n,e)=>{const t=Vo(n);return t&&wh(t)?uh(n,e):t?Vi(()=>({type:n.schema.nodes.div}))(n,e):!1},dh=(n,e)=>(t,r)=>{var l;const i=Vo(t),s=Ft.get(n.el).view,o=(l=e.onEnter)==null?void 0:l.call(e,{...n,node:i,commands:vr(s,n.editor,e),proseMirror:{view:s,dispatch:r}});return o!==void 0?o:hh(t,r)};function Vo(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 uh(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 ph(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);Fo(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 Lt=(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 mh(n){var h,d;const{view:e,href:t,options:r,target:i="_blank"}=n,{state:s,dispatch:o}=e,{schema:l,selection:a,tr:c}=s,f=l.marks.link;try{const u={href:t,target:i},p=((d=(h=r.commandAttrs)==null?void 0:h.link)==null?void 0:d.call(h,u))||u,m=f.create({[be]:JSON.stringify(p)});c.addMark(a.from,a.to,m),o(c.scrollIntoView())}catch(u){console.error("Error applying link mark:",u)}}function gh(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())}function yh(n,e){const{state:t,dispatch:r}=n,{selection:i,tr:s}=t;if(i.empty)return;const o=t.schema.marks.color;if(!o){console.error("Color mark is not defined in the schema.");return}s.addMark(i.from,i.to,o.create({value:e})),r(s.scrollIntoView())}function bh(n,e){const{state:t,dispatch:r}=n,{selection:i,tr:s}=t;if(i.empty)return;const o=t.schema.marks.bgColor;if(!o){console.error("Background color mark is not defined in the schema.");return}s.addMark(i.from,i.to,o.create({value:e})),r(s.scrollIntoView())}const Ye=(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}}},xh=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 kh(...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 Sh=(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 Fi(t,r);setTimeout(()=>setTimeout(()=>n.focus()))},Rr=n=>n.isBlock,Fo=n=>n.type.name==="inlineFragment",Ch=n=>Rr(n)&&!Fo(n),Lo=n=>n.type.name==="bulletList",Ho=n=>n.type.name==="orderedList",wh=n=>n.type.name==="heading",Mh=n=>Lo(n)||Ho(n),$o=(n,e)=>{var s,o;const t=(s=Ye(n,l=>l.type===e))==null?void 0:s.node,r=n.state.schema.nodes.listItem;let i;return t?i=_n(r):(o=Ye(n,Mh))!=null&&o.node?i=kh(_n(r),_i(e)):i=_i(e),i(n.state,n.dispatch)},Wo=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(r=>r.type.name===e)},Oh=n=>{var o;const{view:e,prop:t,editor:r,propCSS:i}=n,s=(o=Ye(e,Ch))==null?void 0:o.node;if(s){const l=s.attrs.attrs||{},a=xh(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""},Ir=n=>{const{view:e,prop:t,markName:r,editor:i,propCSS:s}=n,o=Wo(e,r);if(o){const l=o.attrs;if(l[t])return l[t];if(l[be]){const a=ue(o).id;if(a){const c=i.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[s]||""}}}return""},vr=(n,e,t)=>{const{dispatch:r}=n,{nodes:i,marks:s}=n.state.schema,o={text:{selected:()=>{const{selection:l,doc:a}=n.state;return a.textBetween(l.from,l.to," ")},replace:(l,a={})=>{const{state:c}=n,{from:f}=c.selection;let h=c.tr.replaceSelectionWith(c.schema.text(l));a.select&&(h=h.setSelection(C.create(h.doc,f,f+l.length))),r==null||r(h)},replaceHtml:l=>{const{schema:a,selection:c,tr:f}=n.state,h=document.createElement("div");h.innerHTML=l;const d=He.fromSchema(a).parse(h),{from:u,to:p}=c;return r==null?void 0:r(f.replaceRangeWith(u,p,d).scrollIntoView())},wrapStyle:()=>{const l=Er(n),a=o.text.selected(),c=`i${e.Components._createId().slice(0,4)}`;o.text.replaceHtml(`<span id="${c}" ${Io}>${a}</span>`),l==null||l.trigger("disable"),setTimeout(()=>{const f=l==null?void 0:l.find(`#${c}`)[0];f&&e.select(f)})},createBreak:()=>{const{state:l}=n,a=l.tr.replaceSelectionWith(i.inlineBreak.create()).scrollIntoView();return r==null?void 0:r(a)}},bold:{toggle:()=>We(s.strong)(n.state,r),isActive:()=>Lt(n.state,s.strong)},italic:{toggle:()=>We(s.em)(n.state,r),isActive:()=>Lt(n.state,s.em)},underline:{toggle:()=>We(s.underline)(n.state,r),isActive:()=>Lt(n.state,s.underline)},strikethrough:{toggle:()=>We(s.strikethrough)(n.state,r),isActive:()=>Lt(n.state,s.strikethrough)},link:{get:()=>{const l=Er(n),a=l==null?void 0:l.getTrait("href");if(l!=null&&l.is("link"))return l.getAttributes();if(a)return{href:a.getValue()};{const c=Wo(n,"link");return c?ue(c):{}}},toggle:()=>We(s.link)(n.state,r),isActive:()=>Lt(n.state,s.link),create:l=>{const a=Er(n),c=a==null?void 0:a.getTrait("href"),{url:f,target:h}=l,d=()=>{var p,m;const u=(m=(p=zo(n))==null?void 0:p.gjsView)==null?void 0:m.el;u&&u.contentEditable!=="true"&&(u.contentEditable="true"),n.focus()};a!=null&&a.is("link")?(a.addAttributes({href:f,target:h}),d()):c?(a==null||a.addAttributes({[c.getName()]:f}),d()):mh({view:n,href:f,target:h,options:t})}},alignText:{get:()=>Oh({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:l=>ph(n,l.value,!0)},fontSize:{get:()=>Ir({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:l=>gh(n,l.value)},color:{get:()=>Ir({view:n,editor:e,markName:"color",prop:"value",propCSS:"color"}),set:l=>yh(n,l.value)},bgColor:{get:()=>Ir({view:n,editor:e,markName:"bgColor",prop:"value",propCSS:"background-color"}),set:l=>bh(n,l.value)},image:{open(){const l="assetLayout",{state:a,dispatch:c}=n,{selection:f,doc:h}=a,d=h.textBetween(f.from,f.to," "),u={id:l,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:p=>{const m={alt:d,src:p.asset.getSrc()};c(a.tr.replaceSelectionWith(i.image.createAndFill({attrs:m})))}}};e.runCommand(xn.layoutToggle,u)}},heading:{get:()=>{var a;const l=(a=Ye(n,Rr))==null?void 0:a.node;return`${(l==null?void 0:l.attrs.level)||""}`},set:({value:l})=>{var f;const{state:a}=n,c=(f=Ye(n,Rr))==null?void 0:f.node;ra(a.schema.nodes.heading,{attrs:c==null?void 0:c.attrs.attrs,level:l?parseInt(l,10):0})(a,r)}},listBullet:{isActive:()=>{var l;return!!((l=Ye(n,Lo))!=null&&l.node)},toggle:()=>$o(n,i.bulletList)},listOrdered:{isActive:()=>{var l;return!!((l=Ye(n,Ho))!=null&&l.node)},toggle:()=>$o(n,i.orderedList)}};return o};class ve{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Nh(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}}function Nh(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 Th=500;function Ah({rules:n}){let e=new ot({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 Jo(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Jo(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function Jo(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-Th),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 Dh=new ve(/--$/,"—"),Eh=new ve(/\.\.\.$/,"…"),Rh=new ve(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),Ih=new ve(/"$/,"”"),vh=new ve(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),zh=new ve(/'$/,"’"),Bh=[Rh,Ih,vh,zh];function zr(n,e,t=null,r){return new ve(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&&pi(h,e,a);if(!d)return null;c.wrap(h,d);let u=c.doc.resolve(o-1).nodeBefore;return u&&u.type==e&&Qt(c.doc,o-1)&&(!r||r(s,u))&&c.join(o-1),c})}function qo(n,e,t=null){return new ve(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 Ph(n){return zr(/^\s*>\s$/,n)}function Vh(n){return zr(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Fh(n){return zr(/^\s*([-+*])\s$/,n)}function Lh(n){return qo(/^```$/,n)}function Hh(n,e){return qo(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function $h(n){const e=Bh.concat(Eh,Dh);let t;return(t=n.nodes.blockquote)&&e.push(Ph(t)),(t=n.nodes.orderedList)&&e.push(Vh(t)),(t=n.nodes.bulletList)&&e.push(Fh(t)),(t=n.nodes.codeBlock)&&e.push(Lh(t)),(t=n.nodes.heading)&&e.push(Hh(t,6)),Ah({rules:e})}const Wh="rteProseMirror",Jh=pt.free,U="rte:selectionchange",z={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>',color:'<svg viewBox="0 0 24 24"><path d="M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z" /></svg>',bgColor:'<svg viewBox="0 0 24 24"><path d="M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z" /></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>'},Ko=n=>({state:e})=>({type:"column",style:{alignItems:"center",background:"none"},children:[{type:"icon",icon:n,size:16},{type:"row",style:{width:16,height:2,backgroundColor:e.value||"currentColor",borderRadius:1}}]}),qh=(n,e)=>{var a;const{editor:t,el:r}=n,i=Ft.get(r).view,s=vr(i,t,e),o={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},wrapStyle:{id:"wrapper",type:"button",icon:"tag",tooltip:"Wrap for styling",editorEvents:{[U]:({setState:c})=>{c({disabled:i.state.selection.empty})}},onClick:()=>s.text.wrapStyle()},bold:{id:"bold",icon:z.bold,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.bold.isActive()})}},onClick:({setState:c})=>{s.bold.toggle(),c({active:s.bold.isActive()})}},italic:{id:"italic",icon:z.italic,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.italic.isActive()})}},onClick:({setState:c})=>{s.italic.toggle(),c({active:s.italic.isActive()})}},underline:{id:"underline",icon:z.underline,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.underline.isActive()})}},onClick:({setState:c})=>{s.underline.toggle(),c({active:s.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:z.strikethrough,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.strikethrough.isActive()})}},onClick:({setState:c})=>{s.strikethrough.toggle(),c({active:s.strikethrough.isActive()})}},image:{id:"image",icon:z.image,size:"s",type:"button",onClick:()=>s.image.open()},link:{id:"link",icon:z.link,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.link.isActive(),disabled:i.state.selection.empty})}},onClick:({event:c})=>{const f=c.currentTarget||c.target,h="linkLayout",d=()=>t.runCommand(xn.layoutRemove,{id:h}),u=s.link.get(),p={id:h,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,target:f},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:m=>{m.preventDefault();const g=new FormData(m.currentTarget);s.link.create({url:g.get("url"),target:g.get("target")}),d()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(u==null?void 0:u.href)||"",onChange:({value:m,setState:g})=>g({value:m})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(u==null?void 0:u.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:m,setState:g})=>g({value:m})},{type:"row",style:{gap:10,justifyContent:"end"},children:[s.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{s.link.toggle(),d()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(xn.layoutToggle,p)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:z.alignTextLeft},{id:"center",icon:z.alignTextCenter},{id:"right",icon:z.alignTextRight},{id:"justify",icon:z.alignTextJustify}],editorEvents:{[U]:({setState:c})=>{c({value:s.alignText.get()})}},onChange:({value:c,setState:f})=>{f({value:c}),s.alignText.set({value:c})}},alignTextMenu:{id:"alignTextMenu",type:"buttonMenu",size:"s",value:"",options:[{id:"left",icon:z.alignTextLeft},{id:"center",icon:z.alignTextCenter},{id:"right",icon:z.alignTextRight},{id:"justify",icon:z.alignTextJustify}],editorEvents:{[U]:({setState:c})=>{c({value:s.alignText.get()})}},onOptionSelect:({option:c,state:f,setState:h})=>{const d=c.id===f.value?"":c.id;h({value:d}),s.alignText.set({value:d})},onClick:({state:c})=>{c.value&&s.alignText.set({value:c.value})}},listBullet:{id:"listBullet",icon:z.listBullet,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.listBullet.isActive()})}},onClick:({setState:c})=>{s.listBullet.toggle(),c({active:s.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:z.listOrdered,size:"s",type:"button",editorEvents:{[U]:({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:{[U]:({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:"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:{[U]:({setState:c})=>{c({value:s.fontSize.get()})}},onChange:({value:c,setState:f})=>{f({value:c}),s.fontSize.set({value:c}),i.focus()}},color:{id:"color",type:"buttonMenu",size:"s",value:"",label:Ko(z.color),editorEvents:{[U]:({setState:c})=>{c({disabled:i.state.selection.empty})}},children:({state:c,setState:f})=>({type:"colorPicker",value:c.value||"",onChange:h=>{const{value:d}=h;f({value:d}),h.setState({value:d}),s.color.set({value:d}),i.focus()}}),onClick:({state:c})=>{c.value&&(s.color.set({value:c.value}),i.focus())}},bgColor:{id:"bgColor",type:"buttonMenu",size:"s",value:"",label:Ko(z.bgColor),editorEvents:{[U]:({setState:c})=>{c({disabled:i.state.selection.empty})}},children:({state:c,setState:f})=>({type:"colorPicker",value:c.value||"",onChange:h=>{const{value:d}=h;f({value:d}),h.setState({value:d}),s.bgColor.set({value:d}),i.focus()}}),onClick:({state:c})=>{c.value&&(s.bgColor.set({value:c.value}),i.focus())}}},l=[o.bold,o.italic,o.underline,o.strikethrough,o.image,o.link,o.listBullet,o.listOrdered,o.color,o.bgColor,o.alignTextMenu,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 Kh{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;vr(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=""}}return Yf(function(n,e={}){const t={plugins:l=>l.plugins,...e},r=(l,a)=>{var g,b;const c=((g=t.schema)==null?void 0:g.call(t,{editor:n,schema:vo,createCustomMark:Ar}))||vo,{nodes:f,marks:h}=c,d={...a,component:a.view.model,editor:n,el:l};Po(l);const u=He.fromSchema(c).parse(l),p=st.create({doc:u,schema:c,plugins:(b=t.plugins)==null?void 0:b.call(t,{editor:n,Plugin:ot,plugins:[vf(),Jf(),$h(c),pa(),Gn({Tab:yo(1),"Shift-Tab":yo(-1)}),Gn({Enter:wt(Pi,Ca(f.listItem),dh(d,t)),"Shift-Enter":wt(Bi,(w,N)=>(N&&N(w.tr.replaceSelectionWith(f.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":Ui,"Mod-y":Kn,"Mod-Shift-z":Kn,"Mod-b":We(h.strong),"Mod-i":We(h.em),"Shift-Tab":_n(f.listItem),Tab:Oa(f.listItem)}),Gn(sa)]})}),m=new rf({mount:l},{state:p,dispatchTransaction(w){var ne;const{state:N}=m,J=N.apply(w),B=!N.doc.eq(J.doc);m.updateState(J);const R=!N.selection.eq(J.selection);B&&(ch(((ne=a==null?void 0:a.view)==null?void 0:ne.el)||l),m.focus()),(R||B)&&n.trigger(U)}});return l.__rteView=m,m.setProps({nodeViews:{image(w){return new Kh(w,m,n)}}}),m},i=l=>qh(l,t);n.setCustomRte({toolbar:i,parseContent:!0,async enable(l,a,c){const f=wn(l);if(f)return f;const h=r(l,c);return lh(l,h,c.view),Sh(h,c),h},disable(l){const a=wn(l),c=a==null?void 0:a.view;if(c){const f=Bo(l);return ah(l,c),f||n.once(n.RichTextEditor.events.disable,()=>{a.gjsView.model.trigger("rerender")}),c.destroy(),{forceSync:f}}},getContent(l,a,c){var h;const f=(h=wn(l))==null?void 0:h.view;if(f){const{schema:d,doc:u}=f.state;if(!Bo(l))return c.view.lastContent;const p=document.createElement("div"),m=$e.fromSchema(d).serializeFragment(u.content);return m.childNodes.forEach(g=>{var b;g.nodeType===Node.ELEMENT_NODE&&(g.innerHTML===""?g.innerHTML="<br/>":((b=g.lastChild)==null?void 0:b.nodeName)==="BR"&&g.appendChild(document.createElement("br")))}),p.appendChild(m),fh(p),l.classList.remove("ProseMirror-focused"),p.innerHTML}return l.innerHTML}});const s=th(n,t.enableOnClick),o=eh(n,t.disableOnEsc);Zf({editor:n,licenseKey:t.licenseKey,plan:Jh,pluginName:Wh,cleanup:()=>{n.RichTextEditor.customRte=void 0,s(),o()}})})});
|
|
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=$e.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=bc(t),Nt&&xc(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")||He.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!mc.test(d.parentNode.nodeName)?{ignore:!0}:null}})),f)l=kc(Ls(l,+f[1],+f[2]),f[4]);else if(l=x.maxOpen(gc(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=Ls(l,h,d)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const mc=/^(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 gc(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&&Vs(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Fs(o[o.length-1],s.length));let f=Ps(l,a);o.push(f),i=i.matchType(f.type),s=a}}),o)return y.from(o)}return n}function Ps(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,y.from(n));return n}function Vs(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Vs(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(Ps(t,n,i+1))))}}function Fs(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Fs(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(y.empty,!0);return n.copy(t.append(r))}function cr(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=cr(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 Ls(n,e,t){return e<n.openStart&&(n=new x(cr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new x(cr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Hs={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 $s=null;function Ws(){return $s||($s=document.implementation.createHTMLDocument("title"))}let fr=null;function yc(n){let e=window.trustedTypes;return e?(fr||(fr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),fr.createHTML(n)):n}function bc(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Ws().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Hs[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=yc(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function xc(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 kc(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 K={},j={},Sc={touchstart:!0,touchmove:!0};class Cc{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 wc(n){for(let e in K){let t=K[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Oc(n,r)&&!dr(n,r)&&(n.editable||!(r.type in j))&&t(n,r)},Sc[e]?{passive:!0}:void 0)}q&&n.dom.addEventListener("input",()=>null),hr(n)}function De(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Mc(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 hr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>dr(n,r))})}function dr(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Oc(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 Nc(n,e){!dr(n,e)&&K[e.type]&&(n.editable||!(e.type in j))&&K[e.type](n,e)}j.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!qs(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(se&&$&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),at&&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,Ke(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||pc(n,t)?t.preventDefault():De(n,"key")},j.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},j.keypress=(n,e)=>{let t=e;if(qs(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ee&&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 fn(n){return{left:n.clientX,top:n.clientY}}function Tc(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ur(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 ht(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 Ac(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&k.isSelectable(r)?(ht(n,new k(t)),!0):!1}function Dc(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?(ht(n,k.create(n.state.doc,i)),!0):!1}function Ec(n,e,t,r,i){return ur(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Dc(n,t):Ac(n,t))}function Rc(n,e,t,r){return ur(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Ic(n,e,t,r){return ur(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||vc(n,t,r)}function vc(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(ht(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)ht(n,C.create(r,l+1,l+1+o.content.size));else if(k.isSelectable(o))ht(n,k.create(r,l));else continue;return!0}}function pr(n){return hn(n)}const Js=ee?"metaKey":"ctrlKey";K.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=pr(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Tc(t,n.input.lastClick)&&!t[Js]&&(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(fn(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new zc(n,o,t,!!r)):(s=="doubleClick"?Rc:Ic)(n,o.pos,o.inside,t)?t.preventDefault():De(n,"pointer"))};class zc{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[Js],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(fn(e))),this.updateAllowDefault(e),this.allowDefault||!t?De(this.view,"pointer"):Ec(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||q&&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)?(ht(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)}}K.touchstart=n=>{n.input.lastTouch=Date.now(),pr(n),De(n,"pointer")},K.touchmove=n=>{n.input.lastTouch=Date.now(),De(n,"pointer")},K.contextmenu=n=>pr(n);function qs(n,e){return n.composing?!0:q&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Bc=se?5e3:-1;j.compositionstart=j.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(),hn(n,!0),n.markCursor=null;else if(hn(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}Ks(n,Bc)},j.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++,Ks(n,20))};function Ks(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>hn(n),e))}function js(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Vc());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Pc(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Aa(e.focusNode,e.focusOffset),r=Da(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 Vc(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function hn(n,e=!1){if(!(se&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),js(n),e||n.docView&&n.docView.dirty){let t=ir(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 Fc(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 Rt=G&&Oe<15||at&&za<604;K.copy=j.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=Rt?null:t.clipboardData,o=r.content(),{dom:l,text:a}=zs(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Fc(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Lc(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Hc(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?It(n,r.value,null,i,e):It(n,r.textContent,r.innerHTML,i,e)},50)}function It(n,e,t,r,i){let s=Bs(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=Lc(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 Us(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," "):""}j.paste=(n,e)=>{let t=e;if(n.composing&&!se)return;let r=Rt?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&It(n,Us(r),r.getData("text/html"),i,t)?t.preventDefault():Hc(n,t)};class Gs{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const _s=ee?"altKey":"ctrlKey";K.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(fn(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}=zs(n,l);(!t.dataTransfer.files.length||!$||Qi>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Rt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Rt||t.dataTransfer.setData("text/plain",c),n.dragging=new Gs(f,!t[_s],o)},K.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},j.dragover=j.dragenter=(n,e)=>e.preventDefault(),j.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(fn(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=Bs(n,Us(t.dataTransfer),Rt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[_s]);if(n.someProp("handleDrop",p=>p(n,t,o||x.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?Bl(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(or(n,u,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},K.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))},K.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)},K.beforeinput=(n,e)=>{if($&&se&&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,Ke(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 j)K[n]=j[n];function vt(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 dn{constructor(e,t){this.toDOM=e,this.spec=t||_e,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 _(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof dn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&vt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ee{constructor(e,t){this.attrs=e,this.spec=t||_e}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 _(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ee&&vt(this.attrs,e.attrs)&&vt(this.spec,e.spec)}static is(e){return e.type instanceof Ee}destroy(){}}class mr{constructor(e,t){this.attrs=e,this.spec=t||_e}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 _(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 mr&&vt(this.attrs,e.attrs)&&vt(this.spec,e.spec)}destroy(){}}class _{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new _(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 _(e,e,new dn(t,r))}static inline(e,t,r,i){return new _(e,t,new Ee(r,i))}static node(e,t,r,i){return new _(e,t,new mr(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ee}get widget(){return this.type instanceof dn}}const dt=[],_e={};class A{constructor(e,t){this.local=e.length?e:dt,this.children=t.length?t:dt}static create(e,t){return t.length?un(t,e,0,_e):W}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==W||e.maps.length==0?this:this.mapInner(e,t,0,0,r||_e)}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?$c(this.children,o||[],e,t,r,i,s):o?new A(o.sort(Xe),dt):W}add(e,t){return t.length?this==W?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=Ys(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,un(f,l,c+1,_e)),s+=3}});let o=Xs(s?Zs(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(Xe):this.local,i||this.children)}remove(e){return e.length==0||this==W?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!=W?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):W}forChild(e,t){if(this==W)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 Ee){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(Xe),dt);return r?new Re([l,r]):l}return r||W}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 gr(this.localsInner(e))}localsInner(e){if(this==W)return dt;if(e.inlineContent||!this.local.some(Ee.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ee||t.push(this.local[r]);return t}forEachSet(e){e(this)}}A.empty=new A([],[]),A.removeOverlap=gr;const W=A.empty;class Re{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,_e));return Re.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!=W&&(s instanceof Re?r=r.concat(s.members):r.push(s))}return Re.from(r)}eq(e){if(!(e instanceof Re)||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?gr(r?t:t.sort(Xe)):dt}static from(e){switch(e.length){case 0:return W;case 1:return e[0];default:return new Re(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 $c(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 N=l[b]+f-h;u>=N?l[b+1]=d<=N?-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!=W?(l[c]=h,l[c+1]=u,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Wc(l,n,e,t,i,s,o),f=un(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(Xe),l)}function Xs(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 _(i.from+e,i.to+e,i.type))}return t}function Wc(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 Ys(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 Zs(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function un(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=Ys(n,l,a+t);if(c){s=!0;let f=un(c,l,t+a+1,r);f!=W&&i.push(a,a+l.nodeSize,f)}});let o=Xs(s?Zs(n):n,-t).sort(Xe);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):W}function Xe(n,e){return n.from-e.from||n.to-e.to}function gr(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),Qs(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),Qs(e,i,r.copy(s.from,r.to)));break}}}return e}function Qs(n,e,t){for(;e<n.length&&Xe(t,n[e])>0;)e++;n.splice(e,0,t)}function yr(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=W&&e.push(r)}),n.cursorWrapper&&e.push(A.create(n.state.doc,[n.cursorWrapper.deco])),Re.from(e)}const Jc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},qc=G&&Oe<=11;class Kc{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 jc{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Kc,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]);G&&Oe<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),qc&&(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,Jc)),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(Ns(this.view)){if(this.suppressingSelectionUpdates)return ye(this.view);if(G&&Oe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&qe(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=Mt(s))t.add(s);for(let s=e.anchorNode;s;s=Mt(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)&&Ns(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||_c(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&&on(r)&&(c=ir(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),Uc(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(G&&Oe<=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?F(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?F(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 eo=new WeakMap,to=!1;function Uc(n){if(!eo.has(n)&&(eo.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ie,to)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."),to=!0}}function no(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return qe(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Gc(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return no(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?no(n,t):null}function _c(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 Xc(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}],on(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")||He.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:Yc,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 Yc(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(q&&/^(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||q&&/^(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 Zc=/^(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 Qc(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,Be=ir(n,M);if(Be&&!n.state.selection.eq(Be)){if($&&se&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",jh=>jh(n,Ke(13,"Enter"))))return;let Mn=n.state.tr.setSelection(Be);M=="pointer"?Mn.setMeta("pointer",!0):M=="key"&&Mn.scrollIntoView(),s&&Mn.setMeta("composition",s),n.dispatch(Mn)}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=Xc(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=nf(h.content,c.doc.content,c.from,d,u);if(p&&n.input.domChangeCount++,(at&&n.input.lastIOSEnter>Date.now()-225||se)&&i.some(M=>M.nodeType==1&&!Zc.test(M.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",M=>M(n,Ke(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=ro(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let Be=n.state.tr.setSelection(M);s&&Be.setMeta("composition",s),n.dispatch(Be)}}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)),G&&Oe<=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,N;if((at&&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)&&(N=S.findFrom(c.doc.resolve(m.pos+1),1,!0))&&N.head==g.pos)&&n.someProp("handleKeyDown",M=>M(n,Ke(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&tf(f,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,Ke(8,"Backspace")))){se&&$&&n.domObserver.suppressSelectionUpdates();return}$&&se&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),se&&!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,Ke(13,"Enter"))})},20));let J=p.start,B=p.endA,R,ne,ze;if(w){if(m.pos==g.pos)G&&Oe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ye(n),20)),R=n.state.tr.delete(J,B),ne=f.resolve(p.start).marksAcross(f.resolve(p.endA));else if(p.endA==p.endB&&(ze=ef(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))R=n.state.tr,ze.type=="add"?R.addMark(J,B,ze.mark):R.removeMark(J,B,ze.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",Be=>Be(n,J,B,M)))return;R=n.state.tr.insertText(M,J,B)}}if(R||(R=n.state.tr.replace(J,B,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let M=ro(n,R.doc,c.sel);M&&!($&&se&&n.composing&&M.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(M.head==J||M.head==R.mapping.map(B)-1)||G&&M.empty&&M.head==J)&&R.setSelection(M)}ne&&R.ensureMarks(ne),s&&R.setMeta("composition",s),n.dispatch(R.scrollIntoView())}function ro(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:or(n,e.resolve(t.anchor),e.resolve(t.head))}function ef(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 tf(n,e,t,r,i){if(t-e<=i.pos-r.pos||br(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(br(s,!0,!0));return!o.parent.isTextblock||o.pos>t||br(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function br(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 nf(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&&io(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&&io(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function io(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 rf{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 Cc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(co),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=lo(this),oo(this),this.nodeViews=ao(this),this.docView=ps(this.state.doc,so(this),yr(this),this.dom,this),this.domObserver=new jc(this,(r,i,s,o)=>Qc(this,r,i,s,o)),this.domObserver.start(),wc(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&&hr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(co),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&&(js(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=ao(this);of(u,this.nodeViews)&&(this.nodeViews=u,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&hr(this),this.editable=lo(this),oo(this);let a=yr(this),c=so(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&&Va(this);if(o){this.domObserver.stop();let u=h&&(G||$)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&sf(i.selection,e.selection);if(h){let p=$?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Pc(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ps(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(u=!0)}u||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&lc(this))?ye(this,u):(Ms(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&&Fa(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&&es(this,t.getBoundingClientRect(),e)}else es(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 Gs(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(G){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&&La(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 qa(this,e)}coordsAtPos(e,t=1){return ls(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 _a(this,t||this.state,e)}pasteHTML(e,t){return It(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return It(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Mc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],yr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Na())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Nc(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?q&&this.root.nodeType===11&&Ra(this.dom.ownerDocument)==this.dom&&Gc(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function so(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"),[_.node(0,n.state.doc.content.size,e)]}function oo(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:_.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function lo(n){return!n.someProp("editable",e=>e(n.state)===!1)}function sf(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 ao(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 of(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 co(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 xr,kr;if(typeof WeakMap<"u"){let n=new WeakMap;xr=e=>n.get(e),kr=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;xr=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},kr=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var E=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 xr(n)||kr(n,lf(n))}};function lf(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=af(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 N=0;N<b;N++){if(N+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:f,n:b-N});break}const J=i+N*e;for(let B=0;B<g;B++){r[J+B]==0?r[J+B]=f:(s||(s=[])).push({type:"collision",row:c,pos:f,n:g-B});const R=w&&w[B];if(R){const ne=(J+B)%e*2,ze=o[ne];ze==null||ze!=R&&o[ne+1]==1?(o[ne]=R,o[ne+1]=1):ze==R&&o[ne+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 E(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&&cf(l,o,n),l}function af(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 cf(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=ff(a)))[c]=h)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function ff(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function fo(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 ho(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 hf(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=>fo(r,e)}],toDOM(r){return["td",ho(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>fo(r,e)}],toDOM(r){return["th",ho(r,e),0]}}}}function fe(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 Ie=new Ct("selectingCells");function zt(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 pn(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 Sr(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=zt(e.$head)||df(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function df(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 Cr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function uf(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function wr(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function uo(n,e,t){const r=n.node(-1),i=E.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 ut(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 v=class xe extends S{constructor(e,t=e){const r=e.node(-1),i=E.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 wi(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(Cr(r)&&Cr(i)&&wr(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?xe.rowSelection(r,i):s&&this.isColSelection()?xe.colSelection(r,i):new xe(r,i)}return C.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=E.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=ut(b,0,m)),g>0&&(b=ut(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=E.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=E.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 xe(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=E.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 xe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=E.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 xe(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new xe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new xe(e.resolve(t),e.resolve(r))}getBookmark(){return new pf(this.$anchorCell.pos,this.$headCell.pos)}};v.prototype.visible=!1,S.jsonID("cell",v);var pf=class Uo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Uo(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&&wr(t,r)?new v(t,r):S.near(r,1)}};function mf(n){if(!(n.selection instanceof v))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(_.node(r,r+t.nodeSize,{class:"selectedCell"}))}),A.create(n.doc,e)}function gf({$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 yf({$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 bf(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=v.create(i,r.from);else if(o=="row"){const l=i.resolve(r.from+1);s=v.rowSelection(l,l)}else if(!t){const l=E.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=v.create(i,a+1,c)}}else r instanceof C&&gf(r)?s=C.create(i,r.from):r instanceof C&&yf(r)&&(s=C.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var xf=new Ct("fix-tables");function po(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)?po(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function kf(n,e){let t;const r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=Sf(n,i,s,t))};return e?e.doc!=n.doc&&po(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Sf(n,e,t,r){const i=E.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,ut(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=fe(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(xf,{fixTables:!0})}function mo(n){const e=n.selection,t=Sr(n),r=t.node(-1),i=t.start(-1),s=E.get(r);return{...e instanceof v?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(t.pos-i),tableStart:i,map:s,table:r}}function Cf(n){return function(e,t){if(!pn(e))return!1;if(t){const r=fe(e.schema),i=mo(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 go(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 Mr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Cf(n):function(t,r){if(!pn(t))return!1;if(r){const i=fe(t.schema),s=mo(t),o=t.tr,l=go("row",s,i),a=go("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}}Mr("row",{useDeprecatedLogic:!0}),Mr("column",{useDeprecatedLogic:!0}),Mr("cell",{useDeprecatedLogic:!0});function wf(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 yo(n){return function(e,t){if(!pn(e))return!1;const r=wf(Sr(e),n);if(r==null)return!1;if(t){const i=e.doc.resolve(r);t(e.tr.setSelection(C.between(i,uf(i))).scrollIntoView())}return!0}}function mn(n,e){const t=n.selection;if(!(t instanceof v))return!1;if(e){const r=n.tr,i=fe(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 Mf(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=Or(fe(o).row,new x(c,f,h)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Or(fe(o).row,new x(e,t,r)).content:e);else return null;return Of(o,l)}function Of(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=fe(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 Or(n,e){const t=n.createAndFill();return new Ci(t).replace(0,t.content.size,e).doc}function Nf({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(ut(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 Tf(n,e,t,r,i,s,o){const l=n.doc.type.schema,a=fe(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 bo(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 xo(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,ut(d.attrs,o-u,d.attrs.colspan-(o-u))),n.insert(p+d.nodeSize,d.type.createAndFill(ut(d.attrs,0,o-u))),c+=d.attrs.rowspan-1}}return a}function ko(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=E.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=E.get(s),d=h.mapping.maps.length}Tf(h,o,s,t,c,f,d)&&u(),bo(h,o,s,t,a,c,l,d)&&u(),bo(h,o,s,t,a,c,f,d)&&u(),xo(h,o,s,t,l,f,a,d)&&u(),xo(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 v(h.doc.resolve(t+o.positionAt(l,a,s)),h.doc.resolve(t+o.positionAt(f-1,c-1,s)))),e(h)}var Af=Gi({ArrowLeft:yn("horiz",-1),ArrowRight:yn("horiz",1),ArrowUp:yn("vert",-1),ArrowDown:yn("vert",1),"Shift-ArrowLeft":bn("horiz",-1),"Shift-ArrowRight":bn("horiz",1),"Shift-ArrowUp":bn("vert",-1),"Shift-ArrowDown":bn("vert",1),Backspace:mn,"Mod-Backspace":mn,Delete:mn,"Mod-Delete":mn});function gn(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function yn(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;if(s instanceof v)return gn(t,r,S.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=So(i,n,e);if(o==null)return!1;if(n=="horiz")return gn(t,r,S.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=uo(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),gn(t,r,c)}}}function bn(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;let o;if(s instanceof v)o=s;else{const a=So(i,n,e);if(a==null)return!1;o=new v(t.doc.resolve(a))}const l=uo(o.$headCell,n,e);return l?gn(t,r,new v(o.$anchorCell,l)):!1}}function Df(n,e){const t=n.state.doc,r=zt(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new v(r))),!0):!1}function Ef(n,e,t){if(!pn(n.state))return!1;let r=Mf(t);const i=n.state.selection;if(i instanceof v){r||(r={width:1,height:1,rows:[y.from(Or(fe(n.state.schema).cell,t))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=E.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=Nf(r,l.right-l.left,l.bottom-l.top),ko(n.state,n.dispatch,o,l,r),!0}else if(r){const s=Sr(n.state),o=s.start(-1);return ko(n.state,n.dispatch,o,E.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function Rf(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Co(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof v)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=zt(n.state.selection.$anchor))!=null&&((t=Nr(n,e))==null?void 0:t.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(a,c){let f=Nr(n,c);const h=Ie.getState(n.state)==null;if(!f||!wr(a,f))if(h)f=a;else return;const d=new v(a,f);if(h||!n.state.selection.eq(d)){const u=n.state.tr.setSelection(d);h&&u.setMeta(Ie,a.pos),n.dispatch(u)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),Ie.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ie,-1))}function l(a){const c=a,f=Ie.getState(n.state);let h;if(f!=null)h=n.state.doc.resolve(f);else if(Co(n,c.target)!=r&&(h=Nr(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 So(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 Co(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Nr(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?zt(n.state.doc.resolve(t.pos)):null}var If=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")),Tr(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,Tr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Tr(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 Z=new Ct("tableColumnResizing");function vf({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=If,lastColumnResizable:i=!0}={}){const s=new ot({key:Z,state:{init(o,l){var a,c;const f=(c=(a=s.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,h=fe(l.schema).table.name;return r&&f&&(f[h]=(d,u)=>new r(d,t,u)),new zf(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Z.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{Bf(o,l,n,i)},mouseleave:o=>{Pf(o)},mousedown:(o,l)=>{Vf(o,l,e,t)}},decorations:o=>{const l=Z.getState(o);if(l&&l.activeHandle>-1)return Wf(o,l.activeHandle)},nodeViews:{}}});return s}var zf=class On{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(Z);if(r&&r.setHandle!=null)return new On(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new On(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return Cr(e.doc.resolve(i))||(i=-1),new On(i,t.dragging)}return t}};function Bf(n,e,t,r){const i=Z.getState(n.state);if(i&&!i.dragging){const s=Lf(e.target);let o=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=t?o=wo(n,e,"left",t):a-e.clientX<=t&&(o=wo(n,e,"right",t))}if(o!=i.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=E.get(a),f=l.start(-1);if(c.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Oo(n,o)}}}function Pf(n){const e=Z.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Oo(n,-1)}function Vf(n,e,t,r){var i;const s=(i=n.dom.ownerDocument.defaultView)!=null?i:window,o=Z.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=Ff(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(Z,{setDragging:{startX:e.clientX,startWidth:a}}));function c(h){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",f);const d=Z.getState(n.state);d!=null&&d.dragging&&(Hf(n,d.activeHandle,Mo(d.dragging,h,t)),n.dispatch(n.state.tr.setMeta(Z,{setDragging:null})))}function f(h){if(!h.which)return c(h);const d=Z.getState(n.state);if(d&&d.dragging){const u=Mo(d.dragging,h,t);No(n,d.activeHandle,u,r)}}return No(n,o.activeHandle,a,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",f),e.preventDefault(),!0}function Ff(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 Lf(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function wo(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=zt(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=E.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 Mo(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Oo(n,e){n.dispatch(n.state.tr.setMeta(Z,{setHandle:e}))}function Hf(n,e,t){const r=n.state.doc.resolve(e),i=r.node(-1),s=E.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():$f(d.colspan);p[u]=t,a.setNodeMarkup(o+h,null,{...d,colwidth:p})}a.docChanged&&n.dispatch(a)}function No(n,e,t,r){const i=n.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=E.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&&Tr(s,a.firstChild,a,r,l,t)}function $f(n){return Array(n).fill(0)}function Wf(n,e){var t;const r=[],i=n.doc.resolve(e),s=i.node(-1);if(!s)return A.empty;const o=E.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=Z.getState(n))!=null&&t.dragging&&r.push(_.node(l+h,l+h+s.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),r.push(_.widget(d,u))}}return A.create(n.doc,r)}function Jf({allowTableNodeSelection:n=!1}={}){return new ot({key:Ie,state:{init(){return null},apply(e,t){const r=e.getMeta(Ie);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:mf,handleDOMEvents:{mousedown:Rf},createSelectionBetween(e){return Ie.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Df,handleKeyDown:Af,handlePaste:Ef},appendTransaction(e,t,r){return bf(r,kf(r,t),n)}})}const To="app.grapesjs.com",Ao="app-stage.grapesjs.com",Do=[To,"app2.grapesjs.com",Ao,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],qf="license:check:start",Kf="license:check:end",jf=()=>typeof window<"u",Uf=({isDev:n,isStage:e,isPlatform:t})=>`${n?"":`https://${e?Ao:To}`}/${t?"platform-api":"api"}`,Gf=()=>{const n=jf()&&window.location.hostname;return!!n&&(Do.includes(n)||Do.some(e=>n.endsWith(e)))};async function _f({path:n,baseApiUrl:e,method:t="GET",headers:r={},params:i,body:s}){const l=`${e||Uf({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 pt=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(pt||{}),xn=(n=>(n.toastAdd="studio:toastAdd",n.toastRemove="studio:toastRemove",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.dialogExportCode="studio:dialogExportCode",n.dialogImportCode="studio:dialogImportCode",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.clearPage="studio:clearPage",n.projectFiles="studio:projectFiles",n.validateCode="studio:validateCode",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.layoutComponentAdd="studio:layoutComponentAdd",n.layoutComponentGet="studio:layoutComponentGet",n.layoutComponentRemove="studio:layoutComponentRemove",n.layoutComponentRender="studio:layoutComponentRender",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))(xn||{});const Eo={[pt.free]:0,[pt.startup]:10,[pt.business]:20,[pt.enterprise]:30};function Xf(n){const e=n;return e.init=t=>r=>n(r,t),e}const Yf=n=>Xf(n);async function Zf({editor:n,plan:e,pluginName:t,licenseKey:r,onLicenseCheckResponse:i,cleanup:s}){let o="",l=!1;const a=Gf(),c=h=>{console.warn("Cleanup plugin:",t,"Reason:",h),s()},f=(h={})=>{var g;const{error:d,sdkLicense:u}=h,p=(g=h.plan)==null?void 0:g.category;if(!(u||h.license)||d)c(d||"Invalid license");else if(p){const b=Eo[e],w=Eo[p];b>w&&c({pluginRequiredPlan:e,licensePlan:p})}};n.on(qf,h=>{o=h==null?void 0:h.baseApiUrl,l=!0}),n.on(Kf,h=>{i==null||i(h),f(h)}),setTimeout(async()=>{if(!l){if(a)return;if(r){const h=await Qf({licenseKey:r,pluginName:t,baseApiUrl:o});i==null||i(h),h&&f(h)}else c("The `licenseKey` option not provided")}},2e3)}async function Qf(n){const{licenseKey:e,pluginName:t,baseApiUrl:r}=n;try{return(await _f({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 eh=(n,e)=>{if(!e)return()=>{};const t="keydown",r=s=>{var o;s.key==="Escape"&&((o=n.getEditing())==null||o.trigger("disable"))},i=()=>document.removeEventListener(t,r);return n.onReady(()=>{document.addEventListener(t,r),n.on(n.events.destroy,i)}),i};function th(n,e){if(!e)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 Bt=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},Ar=n=>{const{key:e,cssProperty:t,tagName:r="span"}=n,i="value";return{attrs:{...Sn,[i]:{default:null}},parseDOM:[{tag:`${r}[${e}]`,getAttrs:s=>({...Cn(s),[i]:s.style.getPropertyValue(t)||null})}],toDOM(s){const{[i]:o}=s.attrs,l={...ue(s),[e]:""};return o&&(l.style=`${t}: ${o}`),[r,l,0]}}},Ro="data-gs-mrk-fs",nh="data-gs-mrk-color",rh="data-gs-mrk-bgcolor",Io="data-gs-mrk-wrap",kn="data-gs-ifrg",be="attrs",Sn={[be]:{default:"{}"}},he={[be]:{default:{}}},Cn=n=>({[be]:JSON.stringify(Bt(n))}),de=n=>({attrs:Bt(n)}),Pt=n=>e=>[n,e.attrs.attrs,0],ue=n=>n.attrs[be]?JSON.parse(n.attrs[be]):{},ih={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${kn}]`,getAttrs:de}],toDOM:()=>["span",{[kn]:""},0]},div:{group:"block",content:"inline*",attrs:he,parseDOM:[{tag:"div",getAttrs:de}],toDOM:Pt("div")},paragraph:{group:"block",content:"inline*",attrs:he,parseDOM:[{tag:"p",getAttrs:de}],toDOM:Pt("p")},orderedList:{group:"block",content:"listItem+",attrs:he,parseDOM:[{tag:"ol",getAttrs:de}],toDOM:Pt("ol")},bulletList:{group:"block",content:"listItem+",attrs:he,parseDOM:[{tag:"ul",getAttrs:de}],toDOM:Pt("ul")},listItem:{content:"block*",group:"block",attrs:he,parseDOM:[{tag:"li",getAttrs:de}],toDOM:Pt("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:he,parseDOM:[{tag:"pre",getAttrs:de}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:he,parseDOM:[{tag:"img[src]",getAttrs:de}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,attrs:he,parseDOM:[{tag:"br",getAttrs:de}],toDOM:n=>["br",{...n.attrs.attrs}]},hardBreak:{inline:!0,group:"inline",selectable:!1,attrs:he,parseDOM:[{tag:"br",getAttrs:de}],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:Bt(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...hf({tableGroup:"block",cellContent:"block+",cellAttributes:{[be]:{default:he[be].default,getFromDOM:Bt,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:Bt(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},Vt=(n,e)=>({attrs:Sn,parseDOM:n.map(t=>({tag:t,getAttrs:Cn})),toDOM:e}),sh=n=>({attrs:{...Sn},parseDOM:[{tag:`span[${n}]`,getAttrs:e=>({...Cn(e)})}],toDOM(e){return["span",{...ue(e),[n]:!0},0]}}),oh={strong:Vt(["strong","b"],n=>["b",ue(n)]),link:Vt(["a"],n=>["a",ue(n),0]),em:Vt(["em","i"],n=>["em",ue(n)]),underline:Vt(["u"],n=>["u",ue(n),0]),strikethrough:Vt(["s"],n=>["s",ue(n),0]),wrapStyle:sh(Io),font_size:{attrs:{...Sn,size:{default:null}},parseDOM:[{tag:`span[${Ro}]`,getAttrs:n=>({...Cn(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...ue(n),[Ro]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}},color:Ar({key:nh,cssProperty:"color"}),bgColor:Ar({key:rh,cssProperty:"background-color"})},vo=new fl({nodes:ih,marks:oh}),Ft=new WeakMap,Dr=new WeakMap,lh=(n,e,t)=>{Ft.set(n,{view:e,gjsView:t,initialDoc:e.state.doc}),Dr.set(e,{el:n,gjsView:t})},ah=(n,e)=>{Ft.delete(n),Dr.delete(e)},wn=n=>Ft.get(n),zo=n=>Dr.get(n),Bo=n=>{const e=wn(n),t=e==null?void 0:e.view,r=e==null?void 0:e.initialDoc;return!(t&&r&&r.eq(t.state.doc))},Er=n=>{var e,t;return(t=(e=zo(n))==null?void 0:e.gjsView)==null?void 0:t.model},ch=n=>n.dispatchEvent(new CustomEvent("input"));function fh(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(kn)){if(t.getAttribute("style")){t.removeAttribute(kn);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)}const Po=n=>{n.childNodes.forEach(e=>{if(e.nodeName==="BR"){const{nextSibling:t}=e,r=n.lastChild===e,i=(t==null?void 0:t.nodeType)===Node.ELEMENT_NODE&&(t==null?void 0:t.nodeName)!=="BR";(r||i)&&e.remove()}else Po(e)})},hh=(n,e)=>{const t=Vo(n);return t&&wh(t)?uh(n,e):t?Vi(()=>({type:n.schema.nodes.div}))(n,e):!1},dh=(n,e)=>(t,r)=>{var l;const i=Vo(t),s=Ft.get(n.el).view,o=(l=e.onEnter)==null?void 0:l.call(e,{...n,node:i,commands:vr(s,n.editor,e),proseMirror:{view:s,dispatch:r}});return o!==void 0?o:hh(t,r)};function Vo(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 uh(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 ph(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);Fo(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 Lt=(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 mh(n){var h,d;const{view:e,href:t,options:r,target:i="_blank"}=n,{state:s,dispatch:o}=e,{schema:l,selection:a,tr:c}=s,f=l.marks.link;try{const u={href:t,target:i},p=((d=(h=r.commandAttrs)==null?void 0:h.link)==null?void 0:d.call(h,u))||u,m=f.create({[be]:JSON.stringify(p)});c.addMark(a.from,a.to,m),o(c.scrollIntoView())}catch(u){console.error("Error applying link mark:",u)}}function gh(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())}function yh(n,e){const{state:t,dispatch:r}=n,{selection:i,tr:s}=t;if(i.empty)return;const o=t.schema.marks.color;if(!o){console.error("Color mark is not defined in the schema.");return}s.addMark(i.from,i.to,o.create({value:e})),r(s.scrollIntoView())}function bh(n,e){const{state:t,dispatch:r}=n,{selection:i,tr:s}=t;if(i.empty)return;const o=t.schema.marks.bgColor;if(!o){console.error("Background color mark is not defined in the schema.");return}s.addMark(i.from,i.to,o.create({value:e})),r(s.scrollIntoView())}const Ye=(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}}},xh=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 kh(...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 Sh=(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 Fi(t,r);setTimeout(()=>setTimeout(()=>n.focus()))},Rr=n=>n.isBlock,Fo=n=>n.type.name==="inlineFragment",Ch=n=>Rr(n)&&!Fo(n),Lo=n=>n.type.name==="bulletList",Ho=n=>n.type.name==="orderedList",wh=n=>n.type.name==="heading",Mh=n=>Lo(n)||Ho(n),$o=(n,e)=>{var s,o;const t=(s=Ye(n,l=>l.type===e))==null?void 0:s.node,r=n.state.schema.nodes.listItem;let i;return t?i=_n(r):(o=Ye(n,Mh))!=null&&o.node?i=kh(_n(r),_i(e)):i=_i(e),i(n.state,n.dispatch)},Wo=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(r=>r.type.name===e)},Oh=n=>{var o;const{view:e,prop:t,editor:r,propCSS:i}=n,s=(o=Ye(e,Ch))==null?void 0:o.node;if(s){const l=s.attrs.attrs||{},a=xh(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""},Ir=n=>{const{view:e,prop:t,markName:r,editor:i,propCSS:s}=n,o=Wo(e,r);if(o){const l=o.attrs;if(l[t])return l[t];if(l[be]){const a=ue(o).id;if(a){const c=i.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[s]||""}}}return""},vr=(n,e,t)=>{const{dispatch:r}=n,{nodes:i,marks:s}=n.state.schema,o={text:{selected:()=>{const{selection:l,doc:a}=n.state;return a.textBetween(l.from,l.to," ")},replace:(l,a={})=>{const{state:c}=n,{from:f}=c.selection;let h=c.tr.replaceSelectionWith(c.schema.text(l));a.select&&(h=h.setSelection(C.create(h.doc,f,f+l.length))),r==null||r(h)},replaceHtml:l=>{const{schema:a,selection:c,tr:f}=n.state,h=document.createElement("div");h.innerHTML=l;const d=He.fromSchema(a).parse(h),{from:u,to:p}=c;return r==null?void 0:r(f.replaceRangeWith(u,p,d).scrollIntoView())},wrapStyle:()=>{const l=Er(n),a=o.text.selected(),c=`i${e.Components._createId().slice(0,4)}`;o.text.replaceHtml(`<span id="${c}" ${Io}>${a}</span>`),l==null||l.trigger("disable"),setTimeout(()=>{const f=l==null?void 0:l.find(`#${c}`)[0];f&&e.select(f)})},createBreak:()=>{const{state:l}=n,a=l.tr.replaceSelectionWith(i.inlineBreak.create()).scrollIntoView();return r==null?void 0:r(a)}},bold:{toggle:()=>We(s.strong)(n.state,r),isActive:()=>Lt(n.state,s.strong)},italic:{toggle:()=>We(s.em)(n.state,r),isActive:()=>Lt(n.state,s.em)},underline:{toggle:()=>We(s.underline)(n.state,r),isActive:()=>Lt(n.state,s.underline)},strikethrough:{toggle:()=>We(s.strikethrough)(n.state,r),isActive:()=>Lt(n.state,s.strikethrough)},link:{get:()=>{const l=Er(n),a=l==null?void 0:l.getTrait("href");if(l!=null&&l.is("link"))return l.getAttributes();if(a)return{href:a.getValue()};{const c=Wo(n,"link");return c?ue(c):{}}},toggle:()=>We(s.link)(n.state,r),isActive:()=>Lt(n.state,s.link),create:l=>{const a=Er(n),c=a==null?void 0:a.getTrait("href"),{url:f,target:h}=l,d=()=>{var p,m;const u=(m=(p=zo(n))==null?void 0:p.gjsView)==null?void 0:m.el;u&&u.contentEditable!=="true"&&(u.contentEditable="true"),n.focus()};a!=null&&a.is("link")?(a.addAttributes({href:f,target:h}),d()):c?(a==null||a.addAttributes({[c.getName()]:f}),d()):mh({view:n,href:f,target:h,options:t})}},alignText:{get:()=>Oh({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:l=>ph(n,l.value,!0)},fontSize:{get:()=>Ir({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:l=>gh(n,l.value)},color:{get:()=>Ir({view:n,editor:e,markName:"color",prop:"value",propCSS:"color"}),set:l=>yh(n,l.value)},bgColor:{get:()=>Ir({view:n,editor:e,markName:"bgColor",prop:"value",propCSS:"background-color"}),set:l=>bh(n,l.value)},image:{open(){const l="assetLayout",{state:a,dispatch:c}=n,{selection:f,doc:h}=a,d=h.textBetween(f.from,f.to," "),u={id:l,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:p=>{const m={alt:d,src:p.asset.getSrc()};c(a.tr.replaceSelectionWith(i.image.createAndFill({attrs:m})))}}};e.runCommand(xn.layoutToggle,u)}},heading:{get:()=>{var a;const l=(a=Ye(n,Rr))==null?void 0:a.node;return`${(l==null?void 0:l.attrs.level)||""}`},set:({value:l})=>{var f;const{state:a}=n,c=(f=Ye(n,Rr))==null?void 0:f.node;ra(a.schema.nodes.heading,{attrs:c==null?void 0:c.attrs.attrs,level:l?parseInt(l,10):0})(a,r)}},listBullet:{isActive:()=>{var l;return!!((l=Ye(n,Lo))!=null&&l.node)},toggle:()=>$o(n,i.bulletList)},listOrdered:{isActive:()=>{var l;return!!((l=Ye(n,Ho))!=null&&l.node)},toggle:()=>$o(n,i.orderedList)}};return o};class ve{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Nh(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}}function Nh(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 Th=500;function Ah({rules:n}){let e=new ot({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 Jo(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Jo(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function Jo(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-Th),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 Dh=new ve(/--$/,"—"),Eh=new ve(/\.\.\.$/,"…"),Rh=new ve(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),Ih=new ve(/"$/,"”"),vh=new ve(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),zh=new ve(/'$/,"’"),Bh=[Rh,Ih,vh,zh];function zr(n,e,t=null,r){return new ve(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&&pi(h,e,a);if(!d)return null;c.wrap(h,d);let u=c.doc.resolve(o-1).nodeBefore;return u&&u.type==e&&Qt(c.doc,o-1)&&(!r||r(s,u))&&c.join(o-1),c})}function qo(n,e,t=null){return new ve(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 Ph(n){return zr(/^\s*>\s$/,n)}function Vh(n){return zr(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Fh(n){return zr(/^\s*([-+*])\s$/,n)}function Lh(n){return qo(/^```$/,n)}function Hh(n,e){return qo(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function $h(n){const e=Bh.concat(Eh,Dh);let t;return(t=n.nodes.blockquote)&&e.push(Ph(t)),(t=n.nodes.orderedList)&&e.push(Vh(t)),(t=n.nodes.bulletList)&&e.push(Fh(t)),(t=n.nodes.codeBlock)&&e.push(Lh(t)),(t=n.nodes.heading)&&e.push(Hh(t,6)),Ah({rules:e})}const Wh="rteProseMirror",Jh=pt.free,U="rte:selectionchange",z={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>',color:'<svg viewBox="0 0 24 24"><path d="M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z" /></svg>',bgColor:'<svg viewBox="0 0 24 24"><path d="M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z" /></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>'},Ko=n=>({state:e})=>({type:"column",style:{alignItems:"center",background:"none"},children:[{type:"icon",icon:n,size:16},{type:"row",style:{width:16,height:2,backgroundColor:e.value||"currentColor",borderRadius:1}}]}),qh=(n,e)=>{var a;const{editor:t,el:r}=n,i=Ft.get(r).view,s=vr(i,t,e),o={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},wrapStyle:{id:"wrapper",type:"button",icon:"tag",tooltip:"Wrap for styling",editorEvents:{[U]:({setState:c})=>{c({disabled:i.state.selection.empty})}},onClick:()=>s.text.wrapStyle()},bold:{id:"bold",icon:z.bold,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.bold.isActive()})}},onClick:({setState:c})=>{s.bold.toggle(),c({active:s.bold.isActive()})}},italic:{id:"italic",icon:z.italic,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.italic.isActive()})}},onClick:({setState:c})=>{s.italic.toggle(),c({active:s.italic.isActive()})}},underline:{id:"underline",icon:z.underline,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.underline.isActive()})}},onClick:({setState:c})=>{s.underline.toggle(),c({active:s.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:z.strikethrough,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.strikethrough.isActive()})}},onClick:({setState:c})=>{s.strikethrough.toggle(),c({active:s.strikethrough.isActive()})}},image:{id:"image",icon:z.image,size:"s",type:"button",onClick:()=>s.image.open()},link:{id:"link",icon:z.link,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.link.isActive(),disabled:i.state.selection.empty})}},onClick:({event:c})=>{const f=c.currentTarget||c.target,h="linkLayout",d=()=>t.runCommand(xn.layoutRemove,{id:h}),u=s.link.get(),p={id:h,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,target:f},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:m=>{m.preventDefault();const g=new FormData(m.currentTarget);s.link.create({url:g.get("url"),target:g.get("target")}),d()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(u==null?void 0:u.href)||"",onChange:({value:m,setState:g})=>g({value:m})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(u==null?void 0:u.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:m,setState:g})=>g({value:m})},{type:"row",style:{gap:10,justifyContent:"end"},children:[s.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{s.link.toggle(),d()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(xn.layoutToggle,p)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:z.alignTextLeft},{id:"center",icon:z.alignTextCenter},{id:"right",icon:z.alignTextRight},{id:"justify",icon:z.alignTextJustify}],editorEvents:{[U]:({setState:c})=>{c({value:s.alignText.get()})}},onChange:({value:c,setState:f})=>{f({value:c}),s.alignText.set({value:c})}},alignTextMenu:{id:"alignTextMenu",type:"buttonMenu",size:"s",value:"",options:[{id:"left",icon:z.alignTextLeft},{id:"center",icon:z.alignTextCenter},{id:"right",icon:z.alignTextRight},{id:"justify",icon:z.alignTextJustify}],editorEvents:{[U]:({setState:c})=>{c({value:s.alignText.get()})}},onOptionSelect:({option:c,state:f,setState:h})=>{const d=c.id===f.value?"":c.id;h({value:d}),s.alignText.set({value:d})},onClick:({state:c})=>{c.value&&s.alignText.set({value:c.value})}},listBullet:{id:"listBullet",icon:z.listBullet,size:"s",type:"button",editorEvents:{[U]:({setState:c})=>{c({active:s.listBullet.isActive()})}},onClick:({setState:c})=>{s.listBullet.toggle(),c({active:s.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:z.listOrdered,size:"s",type:"button",editorEvents:{[U]:({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:{[U]:({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:"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:{[U]:({setState:c})=>{c({value:s.fontSize.get()})}},onChange:({value:c,setState:f})=>{f({value:c}),s.fontSize.set({value:c}),i.focus()}},color:{id:"color",type:"buttonMenu",size:"s",value:"",label:Ko(z.color),editorEvents:{[U]:({setState:c})=>{c({disabled:i.state.selection.empty})}},children:({state:c,setState:f})=>({type:"colorPicker",value:c.value||"",onChange:h=>{const{value:d}=h;f({value:d}),h.setState({value:d}),s.color.set({value:d}),i.focus()}}),onClick:({state:c})=>{c.value&&(s.color.set({value:c.value}),i.focus())}},bgColor:{id:"bgColor",type:"buttonMenu",size:"s",value:"",label:Ko(z.bgColor),editorEvents:{[U]:({setState:c})=>{c({disabled:i.state.selection.empty})}},children:({state:c,setState:f})=>({type:"colorPicker",value:c.value||"",onChange:h=>{const{value:d}=h;f({value:d}),h.setState({value:d}),s.bgColor.set({value:d}),i.focus()}}),onClick:({state:c})=>{c.value&&(s.bgColor.set({value:c.value}),i.focus())}}},l=[o.bold,o.italic,o.underline,o.strikethrough,o.image,o.link,o.listBullet,o.listOrdered,o.color,o.bgColor,o.alignTextMenu,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 Kh{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;vr(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=""}}return Yf(function(n,e={}){const t={plugins:l=>l.plugins,...e},r=(l,a)=>{var g,b;const c=((g=t.schema)==null?void 0:g.call(t,{editor:n,schema:vo,createCustomMark:Ar}))||vo,{nodes:f,marks:h}=c,d={...a,component:a.view.model,editor:n,el:l};Po(l);const u=He.fromSchema(c).parse(l),p=st.create({doc:u,schema:c,plugins:(b=t.plugins)==null?void 0:b.call(t,{editor:n,Plugin:ot,plugins:[vf(),Jf(),$h(c),pa(),Gn({Tab:yo(1),"Shift-Tab":yo(-1)}),Gn({Enter:wt(Pi,Ca(f.listItem),dh(d,t)),"Shift-Enter":wt(Bi,(w,N)=>(N&&N(w.tr.replaceSelectionWith(f.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":Ui,"Mod-y":Kn,"Mod-Shift-z":Kn,"Mod-b":We(h.strong),"Mod-i":We(h.em),"Shift-Tab":_n(f.listItem),Tab:Oa(f.listItem)}),Gn(sa)]})}),m=new rf({mount:l},{state:p,dispatchTransaction(w){var ne;const{state:N}=m,J=N.apply(w),B=!N.doc.eq(J.doc);m.updateState(J);const R=!N.selection.eq(J.selection);B&&(ch(((ne=a==null?void 0:a.view)==null?void 0:ne.el)||l),m.focus()),(R||B)&&n.trigger(U)}});return l.__rteView=m,m.setProps({nodeViews:{image(w){return new Kh(w,m,n)}}}),m},i=l=>qh(l,t);n.setCustomRte({toolbar:i,parseContent:!0,async enable(l,a,c){const f=wn(l);if(f)return f;const h=r(l,c);return lh(l,h,c.view),Sh(h,c),h},disable(l){const a=wn(l),c=a==null?void 0:a.view;if(c){const f=Bo(l);return ah(l,c),f||n.once(n.RichTextEditor.events.disable,()=>{a.gjsView.model.trigger("rerender")}),c.destroy(),{forceSync:f}}},getContent(l,a,c){var h;const f=(h=wn(l))==null?void 0:h.view;if(f){const{schema:d,doc:u}=f.state;if(!Bo(l))return c.view.lastContent;const p=document.createElement("div"),m=$e.fromSchema(d).serializeFragment(u.content);return m.childNodes.forEach(g=>{var b;g.nodeType===Node.ELEMENT_NODE&&(g.innerHTML===""?g.innerHTML="<br/>":((b=g.lastChild)==null?void 0:b.nodeName)==="BR"&&g.appendChild(document.createElement("br")))}),p.appendChild(m),fh(p),l.classList.remove("ProseMirror-focused"),p.innerHTML}return l.innerHTML}});const s=th(n,t.enableOnClick),o=eh(n,t.disableOnEsc);Zf({editor:n,licenseKey:t.licenseKey,plan:Jh,pluginName:Wh,cleanup:()=>{n.RichTextEditor.customRte=void 0,s(),o()}})})});
|