@oneclick.dev/cms-core-modules 0.0.95 → 0.0.97
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/{ContentEditor-BR5mbmjy.js → ContentEditor-BHru9lxl.js} +1 -1
- package/dist/{ContentEditor-BEZaS8d0.mjs → ContentEditor-kY8CVobZ.mjs} +5 -3
- package/dist/{TableView-YJ3BvQk7.mjs → TableView-Bf67F7Hd.mjs} +86 -89
- package/dist/TableView-pK16x94F.js +4 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
- package/dist/TableView-DtcF-oQc.js +0 -4
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
`),c&&h==_.nodeValue.length)for(let m=_,F;m;m=m.parentNode){if(F=m.nextSibling){F.nodeName=="BR"&&(l=u={node:F.parentNode,offset:ke(F)+1});break}let p=m.pmViewDesc;if(p&&p.node&&p.node.isBlock)break}}else{let m=_.childNodes[h-1];c=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(et&&f.focusNode&&f.focusNode!=u.node&&f.focusNode.nodeType==1){let _=f.focusNode.childNodes[f.focusOffset];_&&_.contentEditable=="false"&&(n=!0)}if(!(n||c&&Be)&&Da(l.node,l.offset,f.anchorNode,f.anchorOffset)&&Da(u.node,u.offset,f.focusNode,f.focusOffset))return;let g=!1;if((d.extend||e==t)&&!(c&&et)){d.collapse(l.node,l.offset);try{e!=t&&d.extend(u.node,u.offset),g=!0}catch{}}if(!g){if(e>t){let h=l;l=u,u=h}let _=document.createRange();_.setEnd(u.node,u.offset),_.setStart(l.node,l.offset),d.removeAllRanges(),d.addRange(_)}}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 i=0,n=0;n<this.children.length;n++){let r=this.children[n],s=i+r.size;if(i==s?e<=s&&t>=i:e<s&&t>i){let l=i+r.border,u=s-r.border;if(e>=l&&t<=u){this.dirty=e==i||t==s?da:Ul,e==l&&t==u&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=pt:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?da:pt}i=s}this.dirty=da}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=e==1?da:Ul;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class pf extends $i{constructor(e,t,i,n){let r,s=t.type.toDOM;if(typeof s=="function"&&(s=s(i,()=>{if(!r)return n;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==tt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Ah extends $i{constructor(e,t,i,n){super(e,[],t,null),this.textDOM=i,this.text=n}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 va extends $i{constructor(e,t,i,n,r){super(e,[],i,n),this.mark=t,this.spec=r}static create(e,t,i,n){let r=n.nodeViews[t.type.name],s=r&&r(t,n,i);return(!s||!s.dom)&&(s=xa.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new va(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&pt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=pt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=tt){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=tt}}slice(e,t,i){let n=va.create(this.parent,this.mark,!0,i),r=this.children,s=this.size;t<s&&(r=Nr(r,t,s,i)),e>0&&(r=Nr(r,0,e,i));for(let l=0;l<r.length;l++)r[l].parent=n;return n.children=r,n}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Yt extends $i{constructor(e,t,i,n,r,s,l,u,d){super(e,[],r,s),this.node=t,this.outerDeco=i,this.innerDeco=n,this.nodeDOM=l}static create(e,t,i,n,r,s){let l=r.nodeViews[t.type.name],u,d=l&&l(t,r,()=>{if(!u)return s;if(u.parent)return u.parent.posBeforeChild(u)},i,n),f=d&&d.dom,c=d&&d.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:c}=xa.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!c&&!t.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),t.type.spec.draggable&&(f.draggable=!0));let g=f;return f=wf(f,i,t),d?u=new Th(e,t,i,n,f,c||null,g,d,r,s+1):t.isText?new Do(e,t,i,n,f,g,r):new Yt(e,t,i,n,f,c||null,g,r,s+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 i=this.children[t];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>V.empty)}return e}matchesNode(e,t,i){return this.dirty==tt&&e.eq(this.node)&&Bn(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,n=t,r=e.composing?this.localCompositionInfo(e,t):null,s=r&&r.pos>-1?r:null,l=r&&r.pos<0,u=new Vh(this,s&&s.node,e);zh(this.node,this.innerDeco,(d,f,c)=>{d.spec.marks?u.syncToMarks(d.spec.marks,i,e,f):d.type.side>=0&&!c&&u.syncToMarks(f==this.node.childCount?ie.none:this.node.child(f).marks,i,e,f),u.placeWidget(d,e,n)},(d,f,c,g)=>{u.syncToMarks(d.marks,i,e,g);let _;u.findNodeMatch(d,f,c,g)||l&&e.state.selection.from>n&&e.state.selection.to<n+d.nodeSize&&(_=u.findIndexWithChild(r.node))>-1&&u.updateNodeAt(d,f,c,_,e)||u.updateNextNode(d,f,c,e,g,n)||u.addNode(d,f,c,e,n),n+=d.nodeSize}),u.syncToMarks([],i,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==da)&&(s&&this.protectLocalComposition(e,s),yf(this.contentDOM,this.children,e),$a&&Ih(this.dom))}localCompositionInfo(e,t){let{from:i,to:n}=e.state.selection;if(!(e.state.selection instanceof H)||i<t||n>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let s=r.nodeValue,l=Ph(this.node.content,s,i-t,n-t);return l<0?null:{node:r,pos:l,text:s}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:n}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let s=new Ah(this,r,t,n);e.input.compositionNodes.push(s),this.children=Nr(this.children,i,i+n.length,e,s)}update(e,t,i,n){return this.dirty==pt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,i,n),!0)}updateInner(e,t,i,n){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(n,this.posAtStart),this.dirty=tt}updateOuterDeco(e){if(Bn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=kf(this.dom,this.nodeDOM,jr(this.outerDeco,this.node,t),jr(e,this.node,t)),this.dom!=i&&(i.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.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Kl(a,e,t,i,n){wf(i,e,a);let r=new Yt(void 0,a,e,t,i,i,i,n,0);return r.contentDOM&&r.updateChildren(n,0),r}class Do extends Yt{constructor(e,t,i,n,r,s,l){super(e,t,i,n,r,null,s,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,i,n){return this.dirty==pt||this.dirty!=tt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=tt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,n.trackWrites==this.nodeDOM&&(n.trackWrites=null)),this.node=e,this.dirty=tt,!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,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,i){let n=this.node.cut(e,t),r=document.createTextNode(n.text);return new Do(this.parent,n,this.outerDeco,this.innerDeco,r,r,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=pt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class bf extends $i{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==tt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Th extends Yt{constructor(e,t,i,n,r,s,l,u,d,f){super(e,t,i,n,r,s,l,d,f),this.spec=u}update(e,t,i,n){if(this.dirty==pt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,i);return r&&this.updateInner(e,t,i,n),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,i,n)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,n){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,n)}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 yf(a,e,t){let i=a.firstChild,n=!1;for(let r=0;r<e.length;r++){let s=e[r],l=s.dom;if(l.parentNode==a){for(;l!=i;)i=Jl(i),n=!0;i=i.nextSibling}else n=!0,a.insertBefore(l,i);if(s instanceof va){let u=i?i.previousSibling:a.lastChild;yf(s.contentDOM,s.children,t),i=u?u.nextSibling:a.firstChild}}for(;i;)i=Jl(i),n=!0;n&&t.trackWrites==a&&(t.trackWrites=null)}const _i=function(a){a&&(this.nodeName=a)};_i.prototype=Object.create(null);const fa=[new _i];function jr(a,e,t){if(a.length==0)return fa;let i=t?fa[0]:new _i,n=[i];for(let r=0;r<a.length;r++){let s=a[r].type.attrs;if(s){s.nodeName&&n.push(i=new _i(s.nodeName));for(let l in s){let u=s[l];u!=null&&(t&&n.length==1&&n.push(i=new _i(e.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+u:l=="style"?i.style=(i.style?i.style+";":"")+u:l!="nodeName"&&(i[l]=u))}}}return n}function kf(a,e,t,i){if(t==fa&&i==fa)return e;let n=e;for(let r=0;r<i.length;r++){let s=i[r],l=t[r];if(r){let u;l&&l.nodeName==s.nodeName&&n!=a&&(u=n.parentNode)&&u.nodeName.toLowerCase()==s.nodeName||(u=document.createElement(s.nodeName),u.pmIsDeco=!0,u.appendChild(n),l=fa[0]),n=u}Mh(n,l||fa[0],s)}return n}function Mh(a,e,t){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in t)&&a.removeAttribute(i);for(let i in t)i!="class"&&i!="style"&&i!="nodeName"&&t[i]!=e[i]&&a.setAttribute(i,t[i]);if(e.class!=t.class){let i=e.class?e.class.split(" ").filter(Boolean):[],n=t.class?t.class.split(" ").filter(Boolean):[];for(let r=0;r<i.length;r++)n.indexOf(i[r])==-1&&a.classList.remove(i[r]);for(let r=0;r<n.length;r++)i.indexOf(n[r])==-1&&a.classList.add(n[r]);a.classList.length==0&&a.removeAttribute("class")}if(e.style!=t.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,n;for(;n=i.exec(e.style);)a.style.removeProperty(n[1])}t.style&&(a.style.cssText+=t.style)}}function wf(a,e,t){return kf(a,a,fa,jr(e,t,a.nodeType!=1))}function Bn(a,e){if(a.length!=e.length)return!1;for(let t=0;t<a.length;t++)if(!a[t].type.eq(e[t].type))return!1;return!0}function Jl(a){let e=a.nextSibling;return a.parentNode.removeChild(a),e}class Vh{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Oh(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i,n){let r=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;r<l&&(r==s-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&e[r].type.spec.spanning!==!1;)r++;for(;r<s;)this.destroyRest(),this.top.dirty=tt,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let u=-1,d=this.top.children.length;n<this.preMatch.index&&(d=Math.min(this.index+3,d));for(let f=this.index;f<d;f++){let c=this.top.children[f];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){u=f;break}}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=va.create(this.top,e[s],t,i);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,i,n){let r=-1,s;if(n>=this.preMatch.index&&(s=this.preMatch.matches[n-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,i))r=this.top.children.indexOf(s,this.index);else for(let l=this.index,u=Math.min(this.top.children.length,l+5);l<u;l++){let d=this.top.children[l];if(d.matchesNode(e,t,i)&&!this.preMatch.matched.has(d)){r=l;break}}return r<0?!1:(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,i,n,r){let s=this.top.children[n];return s.dirty==pt&&s.dom==s.contentDOM&&(s.dirty=da),s.update(e,t,i,r)?(this.destroyBetween(this.index,n),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let i=e.pmViewDesc;if(i){for(let n=this.index;n<this.top.children.length;n++)if(this.top.children[n]==i)return n}return-1}e=t}}updateNextNode(e,t,i,n,r,s){for(let l=this.index;l<this.top.children.length;l++){let u=this.top.children[l];if(u instanceof Yt){let d=this.preMatch.matched.get(u);if(d!=null&&d!=r)return!1;let f=u.dom,c,g=this.isLocked(f)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=pt&&Bn(t,u.outerDeco));if(!g&&u.update(e,t,i,n))return this.destroyBetween(this.index,l),u.dom!=f&&(this.changed=!0),this.index++,!0;if(!g&&(c=this.recreateWrapper(u,e,t,i,n,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=da,c.updateChildren(n,s+1),c.dirty=tt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,n,r,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Bn(i,e.outerDeco)||!n.eq(e.innerDeco))return null;let l=Yt.create(this.top,t,i,n,r,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let u of l.children)u.parent=l}return e.destroy(),l}addNode(e,t,i,n,r){let s=Yt.create(this.top,e,t,i,n,r);s.contentDOM&&s.updateChildren(n,r+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,i){let n=this.index<this.top.children.length?this.top.children[this.index]:null;if(n&&n.matchesWidget(e)&&(e==n.widget||!n.widget.type.toDOM.parentNode))this.index++;else{let r=new pf(this.top,e,t,i);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof va;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Do)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Be||De)&&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 i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let n=new bf(this.top,[],i,null);t!=this.top?t.children.push(n):t.children.splice(this.index++,0,n),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Oh(a,e){let t=e,i=t.children.length,n=a.childCount,r=new Map,s=[];e:for(;n>0;){let l;for(;;)if(i){let d=t.children[i-1];if(d instanceof va)t=d,i=d.children.length;else{l=d,i--;break}}else{if(t==e)break e;i=t.parent.children.indexOf(t),t=t.parent}let u=l.node;if(u){if(u!=a.child(n-1))break;--n,r.set(l,n),s.push(l)}}return{index:n,matched:r,matches:s.reverse()}}function Lh(a,e){return a.type.side-e.type.side}function zh(a,e,t,i){let n=e.locals(a),r=0;if(n.length==0){for(let d=0;d<a.childCount;d++){let f=a.child(d);i(f,n,e.forChild(r,f),d),r+=f.nodeSize}return}let s=0,l=[],u=null;for(let d=0;;){let f,c;for(;s<n.length&&n[s].to==r;){let F=n[s++];F.widget&&(f?(c||(c=[f])).push(F):f=F)}if(f)if(c){c.sort(Lh);for(let F=0;F<c.length;F++)t(c[F],d,!!u)}else t(f,d,!!u);let g,_;if(u)_=-1,g=u,u=null;else if(d<a.childCount)_=d,g=a.child(d++);else break;for(let F=0;F<l.length;F++)l[F].to<=r&&l.splice(F--,1);for(;s<n.length&&n[s].from<=r&&n[s].to>r;)l.push(n[s++]);let h=r+g.nodeSize;if(g.isText){let F=h;s<n.length&&n[s].from<F&&(F=n[s].from);for(let p=0;p<l.length;p++)l[p].to<F&&(F=l[p].to);F<h&&(u=g.cut(F-r),g=g.cut(0,F-r),h=F,_=-1)}else for(;s<n.length&&n[s].to<h;)s++;let m=g.isInline&&!g.isLeaf?l.filter(F=>!F.inline):l.slice();i(g,m,e.forChild(r,g),_),r=h}}function Ih(a){if(a.nodeName=="UL"||a.nodeName=="OL"){let e=a.style.cssText;a.style.cssText=e+"; list-style: square !important",window.getComputedStyle(a).listStyle,a.style.cssText=e}}function Ph(a,e,t,i){for(let n=0,r=0;n<a.childCount&&r<=i;){let s=a.child(n++),l=r;if(r+=s.nodeSize,!s.isText)continue;let u=s.text;for(;n<a.childCount;){let d=a.child(n++);if(r+=d.nodeSize,!d.isText)break;u+=d.text}if(r>=t){if(r>=i&&u.slice(i-e.length-l,i-l)==e)return i-e.length;let d=l<i?u.lastIndexOf(e,i-l-1):-1;if(d>=0&&d+e.length+l>=t)return l+d;if(t==i&&u.length>=i+e.length-l&&u.slice(i-l,i-l+e.length)==e)return i}}return-1}function Nr(a,e,t,i,n){let r=[];for(let s=0,l=0;s<a.length;s++){let u=a[s],d=l,f=l+=u.size;d>=t||f<=e?r.push(u):(d<e&&r.push(u.slice(0,e-d,i)),n&&(r.push(n),n=void 0),f>t&&r.push(u.slice(t-d,u.size,i)))}return r}function ws(a,e=null){let t=a.domSelectionRange(),i=a.state.doc;if(!t.focusNode)return null;let n=a.docView.nearestDesc(t.focusNode),r=n&&n.size==0,s=a.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=i.resolve(s),u,d;if(wo(t)){for(u=s;n&&!n.node;)n=n.parent;let c=n.node;if(n&&c.isAtom&&$.isSelectable(c)&&n.parent&&!(c.isInline&&_h(t.focusNode,t.focusOffset,n.dom))){let g=n.posBefore;d=new $(s==g?l:i.resolve(g))}}else{if(t instanceof a.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let c=s,g=s;for(let _=0;_<t.rangeCount;_++){let h=t.getRangeAt(_);c=Math.min(c,a.docView.posFromDOM(h.startContainer,h.startOffset,1)),g=Math.max(g,a.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(c<0)return null;[u,s]=g==a.state.selection.anchor?[g,c]:[c,g],l=i.resolve(s)}else u=a.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(u<0)return null}let f=i.resolve(u);if(!d){let c=e=="pointer"||a.state.selection.head<l.pos&&!r?1:-1;d=Ds(a,f,l,c)}return d}function Df(a){return a.editable?a.hasFocus():Ef(a)&&document.activeElement&&document.activeElement.contains(a.dom)}function jt(a,e=!1){let t=a.state.selection;if(vf(a,t),!!Df(a)){if(!e&&a.input.mouseDown&&a.input.mouseDown.allowDefault&&De){let i=a.domSelectionRange(),n=a.domObserver.currentSelection;if(i.anchorNode&&n.anchorNode&&Da(i.anchorNode,i.anchorOffset,n.anchorNode,n.anchorOffset)){a.input.mouseDown.delayedSelectionSync=!0,a.domObserver.setCurSelection();return}}if(a.domObserver.disconnectSelection(),a.cursorWrapper)$h(a);else{let{anchor:i,head:n}=t,r,s;Gl&&!(t instanceof H)&&(t.$from.parent.inlineContent||(r=Yl(a,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Yl(a,t.to))),a.docView.setSelection(i,n,a,e),Gl&&(r&&Xl(r),s&&Xl(s)),t.visible?a.dom.classList.remove("ProseMirror-hideselection"):(a.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Rh(a))}a.domObserver.setCurSelection(),a.domObserver.connectSelection()}}const Gl=Be||De&&df<63;function Yl(a,e){let{node:t,offset:i}=a.docView.domFromPos(e,0),n=i<t.childNodes.length?t.childNodes[i]:null,r=i?t.childNodes[i-1]:null;if(Be&&n&&n.contentEditable=="false")return Ko(n);if((!n||n.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(n)return Ko(n);if(r)return Ko(r)}}function Ko(a){return a.contentEditable="true",Be&&a.draggable&&(a.draggable=!1,a.wasDraggable=!0),a}function Xl(a){a.contentEditable="false",a.wasDraggable&&(a.draggable=!0,a.wasDraggable=null)}function Rh(a){let e=a.dom.ownerDocument;e.removeEventListener("selectionchange",a.input.hideSelectionGuard);let t=a.domSelectionRange(),i=t.anchorNode,n=t.anchorOffset;e.addEventListener("selectionchange",a.input.hideSelectionGuard=()=>{(t.anchorNode!=i||t.anchorOffset!=n)&&(e.removeEventListener("selectionchange",a.input.hideSelectionGuard),setTimeout(()=>{(!Df(a)||a.state.selection.visible)&&a.dom.classList.remove("ProseMirror-hideselection")},20))})}function $h(a){let e=a.domSelection();if(!e)return;let t=a.cursorWrapper.dom,i=t.nodeName=="IMG";i?e.collapse(t.parentNode,ke(t)+1):e.collapse(t,0),!i&&!a.state.selection.visible&&$e&&Gt<=11&&(t.disabled=!0,t.disabled=!1)}function vf(a,e){if(e instanceof $){let t=a.docView.descAt(e.from);t!=a.lastSelectedViewDesc&&(Ql(a),t&&t.selectNode(),a.lastSelectedViewDesc=t)}else Ql(a)}function Ql(a){a.lastSelectedViewDesc&&(a.lastSelectedViewDesc.parent&&a.lastSelectedViewDesc.deselectNode(),a.lastSelectedViewDesc=void 0)}function Ds(a,e,t,i){return a.someProp("createSelectionBetween",n=>n(a,e,t))||H.between(e,t,i)}function Zl(a){return a.editable&&!a.hasFocus()?!1:Ef(a)}function Ef(a){let e=a.domSelectionRange();if(!e.anchorNode)return!1;try{return a.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(a.editable||a.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Hh(a){let e=a.docView.domFromPos(a.state.selection.anchor,0),t=a.domSelectionRange();return Da(e.node,e.offset,t.anchorNode,t.anchorOffset)}function qr(a,e){let{$anchor:t,$head:i}=a.selection,n=e>0?t.max(i):t.min(i),r=n.parent.inlineContent?n.depth?a.doc.resolve(e>0?n.after():n.before()):null:n;return r&&J.findFrom(r,e)}function It(a,e){return a.dispatch(a.state.tr.setSelection(e).scrollIntoView()),!0}function eu(a,e,t){let i=a.state.selection;if(i instanceof H)if(t.indexOf("s")>-1){let{$head:n}=i,r=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let s=a.state.doc.resolve(n.pos+r.nodeSize*(e<0?-1:1));return It(a,new H(i.$anchor,s))}else if(i.empty){if(a.endOfTextblock(e>0?"forward":"backward")){let n=qr(a.state,e);return n&&n instanceof $?It(a,n):!1}else if(!(Xe&&t.indexOf("m")>-1)){let n=i.$head,r=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter,s;if(!r||r.isText)return!1;let l=e<0?n.pos-r.nodeSize:n.pos;return r.isAtom||(s=a.docView.descAt(l))&&!s.contentDOM?$.isSelectable(r)?It(a,new $(e<0?a.state.doc.resolve(n.pos-r.nodeSize):n)):Ri?It(a,new H(a.state.doc.resolve(e<0?l:l+r.nodeSize))):!1:!1}}else return!1;else{if(i instanceof $&&i.node.isInline)return It(a,new H(e>0?i.$to:i.$from));{let n=qr(a.state,e);return n?It(a,n):!1}}}function Sn(a){return a.nodeType==3?a.nodeValue.length:a.childNodes.length}function hi(a,e){let t=a.pmViewDesc;return t&&t.size==0&&(e<0||a.nextSibling||a.nodeName!="BR")}function ja(a,e){return e<0?Wh(a):Uh(a)}function Wh(a){let e=a.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let n,r,s=!1;for(et&&t.nodeType==1&&i<Sn(t)&&hi(t.childNodes[i],-1)&&(s=!0);;)if(i>0){if(t.nodeType!=1)break;{let l=t.childNodes[i-1];if(hi(l,-1))n=t,r=--i;else if(l.nodeType==3)t=l,i=t.nodeValue.length;else break}}else{if(xf(t))break;{let l=t.previousSibling;for(;l&&hi(l,-1);)n=t.parentNode,r=ke(l),l=l.previousSibling;if(l)t=l,i=Sn(t);else{if(t=t.parentNode,t==a.dom)break;i=0}}}s?Ar(a,t,i):n&&Ar(a,n,r)}function Uh(a){let e=a.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let n=Sn(t),r,s;for(;;)if(i<n){if(t.nodeType!=1)break;let l=t.childNodes[i];if(hi(l,1))r=t,s=++i;else break}else{if(xf(t))break;{let l=t.nextSibling;for(;l&&hi(l,1);)r=l.parentNode,s=ke(l)+1,l=l.nextSibling;if(l)t=l,i=0,n=Sn(t);else{if(t=t.parentNode,t==a.dom)break;i=n=0}}}r&&Ar(a,r,s)}function xf(a){let e=a.pmViewDesc;return e&&e.node&&e.node.isBlock}function Kh(a,e){for(;a&&e==a.childNodes.length&&!Pi(a);)e=ke(a)+1,a=a.parentNode;for(;a&&e<a.childNodes.length;){let t=a.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;a=t,e=0}}function Jh(a,e){for(;a&&!e&&!Pi(a);)e=ke(a),a=a.parentNode;for(;a&&e;){let t=a.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;a=t,e=a.childNodes.length}}function Ar(a,e,t){if(e.nodeType!=3){let r,s;(s=Kh(e,t))?(e=s,t=0):(r=Jh(e,t))&&(e=r,t=r.nodeValue.length)}let i=a.domSelection();if(!i)return;if(wo(i)){let r=document.createRange();r.setEnd(e,t),r.setStart(e,t),i.removeAllRanges(),i.addRange(r)}else i.extend&&i.extend(e,t);a.domObserver.setCurSelection();let{state:n}=a;setTimeout(()=>{a.state==n&&jt(a)},50)}function tu(a,e){let t=a.state.doc.resolve(e);if(!(De||ff)&&t.parent.inlineContent){let n=a.coordsAtPos(e);if(e>t.start()){let r=a.coordsAtPos(e-1),s=(r.top+r.bottom)/2;if(s>n.top&&s<n.bottom&&Math.abs(r.left-n.left)>1)return r.left<n.left?"ltr":"rtl"}if(e<t.end()){let r=a.coordsAtPos(e+1),s=(r.top+r.bottom)/2;if(s>n.top&&s<n.bottom&&Math.abs(r.left-n.left)>1)return r.left>n.left?"ltr":"rtl"}}return getComputedStyle(a.dom).direction=="rtl"?"rtl":"ltr"}function au(a,e,t){let i=a.state.selection;if(i instanceof H&&!i.empty||t.indexOf("s")>-1||Xe&&t.indexOf("m")>-1)return!1;let{$from:n,$to:r}=i;if(!n.parent.inlineContent||a.endOfTextblock(e<0?"up":"down")){let s=qr(a.state,e);if(s&&s instanceof $)return It(a,s)}if(!n.parent.inlineContent){let s=e<0?n:r,l=i instanceof Ue?J.near(s,e):J.findFrom(s,e);return l?It(a,l):!1}return!1}function iu(a,e){if(!(a.state.selection instanceof H))return!0;let{$head:t,$anchor:i,empty:n}=a.state.selection;if(!t.sameParent(i))return!0;if(!n)return!1;if(a.endOfTextblock(e>0?"forward":"backward"))return!0;let r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let s=a.state.tr;return e<0?s.delete(t.pos-r.nodeSize,t.pos):s.delete(t.pos,t.pos+r.nodeSize),a.dispatch(s),!0}return!1}function nu(a,e,t){a.domObserver.stop(),e.contentEditable=t,a.domObserver.start()}function Gh(a){if(!Be||a.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=a.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;nu(a,i,"true"),setTimeout(()=>nu(a,i,"false"),20)}return!1}function Yh(a){let e="";return a.ctrlKey&&(e+="c"),a.metaKey&&(e+="m"),a.altKey&&(e+="a"),a.shiftKey&&(e+="s"),e}function Xh(a,e){let t=e.keyCode,i=Yh(e);if(t==8||Xe&&t==72&&i=="c")return iu(a,-1)||ja(a,-1);if(t==46&&!e.shiftKey||Xe&&t==68&&i=="c")return iu(a,1)||ja(a,1);if(t==13||t==27)return!0;if(t==37||Xe&&t==66&&i=="c"){let n=t==37?tu(a,a.state.selection.from)=="ltr"?-1:1:-1;return eu(a,n,i)||ja(a,n)}else if(t==39||Xe&&t==70&&i=="c"){let n=t==39?tu(a,a.state.selection.from)=="ltr"?1:-1:1;return eu(a,n,i)||ja(a,n)}else{if(t==38||Xe&&t==80&&i=="c")return au(a,-1,i)||ja(a,-1);if(t==40||Xe&&t==78&&i=="c")return Gh(a)||au(a,1,i)||ja(a,1);if(i==(Xe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function vs(a,e){a.someProp("transformCopied",_=>{e=_(e,a)});let t=[],{content:i,openStart:n,openEnd:r}=e;for(;n>1&&r>1&&i.childCount==1&&i.firstChild.childCount==1;){n--,r--;let _=i.firstChild;t.push(_.type.name,_.attrs!=_.type.defaultAttrs?_.attrs:null),i=_.content}let s=a.someProp("clipboardSerializer")||xa.fromSchema(a.state.schema),l=qf(),u=l.createElement("div");u.appendChild(s.serializeFragment(i,{document:l}));let d=u.firstChild,f,c=0;for(;d&&d.nodeType==1&&(f=Nf[d.nodeName.toLowerCase()]);){for(let _=f.length-1;_>=0;_--){let h=l.createElement(f[_]);for(;u.firstChild;)h.appendChild(u.firstChild);u.appendChild(h),c++}d=u.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${n} ${r}${c?` -${c}`:""} ${JSON.stringify(t)}`);let g=a.someProp("clipboardTextSerializer",_=>_(e,a))||e.content.textBetween(0,e.content.size,`
|
|
8
8
|
|
|
9
9
|
`);return{dom:u,text:g,slice:e}}function Cf(a,e,t,i,n){let r=n.parent.type.spec.code,s,l;if(!t&&!e)return null;let u=!!e&&(i||r||!t);if(u){if(a.someProp("transformPastedText",g=>{e=g(e,r||i,a)}),r)return l=new P(V.from(a.state.schema.text(e.replace(/\r\n?/g,`
|
|
10
|
-
`))),0,0),a.someProp("transformPasted",g=>{l=g(l,a,!0)}),l;let c=a.someProp("clipboardTextParser",g=>g(e,n,i,a));if(c)l=c;else{let g=n.marks(),{schema:_}=a.state,h=xa.fromSchema(_);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let F=s.appendChild(document.createElement("p"));m&&F.appendChild(h.serializeNode(_.text(m,g)))})}}else a.someProp("transformPastedHTML",c=>{t=c(t,a)}),s=tm(t),Ri&&am(s);let d=s&&s.querySelector("[data-pm-slice]"),f=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let c=+f[3];c>0;c--){let g=s.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;s=g}if(l||(l=(a.someProp("clipboardParser")||a.someProp("domParser")||Jt.fromSchema(a.state.schema)).parseSlice(s,{preserveWhitespace:!!(u||f),context:n,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!Qh.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)l=im(ou(l,+f[1],+f[2]),f[4]);else if(l=P.maxOpen(Zh(l.content,n),!0),l.openStart||l.openEnd){let c=0,g=0;for(let _=l.content.firstChild;c<l.openStart&&!_.type.spec.isolating;c++,_=_.firstChild);for(let _=l.content.lastChild;g<l.openEnd&&!_.type.spec.isolating;g++,_=_.lastChild);l=ou(l,c,g)}return a.someProp("transformPasted",c=>{l=c(l,a,u)}),l}const Qh=/^(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 Zh(a,e){if(a.childCount<2)return a;for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.index(t)),r,s=[];if(a.forEach(l=>{if(!s)return;let u=n.findWrapping(l.type),d;if(!u)return s=null;if(d=s.length&&r.length&&Sf(u,r,l,s[s.length-1],0))s[s.length-1]=d;else{s.length&&(s[s.length-1]=jf(s[s.length-1],r.length));let f=Bf(l,u);s.push(f),n=n.matchType(f.type),r=u}}),s)return V.from(s)}return a}function Bf(a,e,t=0){for(let i=e.length-1;i>=t;i--)a=e[i].create(null,V.from(a));return a}function Sf(a,e,t,i,n){if(n<a.length&&n<e.length&&a[n]==e[n]){let r=Sf(a,e,t,i.lastChild,n+1);if(r)return i.copy(i.content.replaceChild(i.childCount-1,r));if(i.contentMatchAt(i.childCount).matchType(n==a.length-1?t.type:a[n+1]))return i.copy(i.content.append(V.from(Bf(t,a,n+1))))}}function jf(a,e){if(e==0)return a;let t=a.content.replaceChild(a.childCount-1,jf(a.lastChild,e-1)),i=a.contentMatchAt(a.childCount).fillBefore(V.empty,!0);return a.copy(t.append(i))}function Tr(a,e,t,i,n,r){let s=e<0?a.firstChild:a.lastChild,l=s.content;return a.childCount>1&&(r=0),n<i-1&&(l=Tr(l,e,t,i,n+1,r)),n>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,r<=n).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(V.empty,!0))),a.replaceChild(e<0?0:a.childCount-1,s.copy(l))}function ou(a,e,t){return e<a.openStart&&(a=new P(Tr(a.content,-1,e,a.openStart,0,a.openEnd),e,a.openEnd)),t<a.openEnd&&(a=new P(Tr(a.content,1,t,a.openEnd,0,0),a.openStart,t)),a}const Nf={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 ru=null;function qf(){return ru||(ru=document.implementation.createHTMLDocument("title"))}let Jo=null;function em(a){let e=window.trustedTypes;return e?(Jo||(Jo=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Jo.createHTML(a)):a}function tm(a){let e=/^(\s*<meta [^>]*>)*/.exec(a);e&&(a=a.slice(e[0].length));let t=qf().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(a),n;if((n=i&&Nf[i[1].toLowerCase()])&&(a=n.map(r=>"<"+r+">").join("")+a+n.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=em(a),n)for(let r=0;r<n.length;r++)t=t.querySelector(n[r])||t;return t}function am(a){let e=a.querySelectorAll(De?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent==" "&&i.parentNode&&i.parentNode.replaceChild(a.ownerDocument.createTextNode(" "),i)}}function im(a,e){if(!a.size)return a;let t=a.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return a}let{content:n,openStart:r,openEnd:s}=a;for(let l=i.length-2;l>=0;l-=2){let u=t.nodes[i[l]];if(!u||u.hasRequiredAttrs())break;n=V.from(u.create(i[l+1],n)),r++,s++}return new P(n,r,s)}const Ve={},Oe={},nm={touchstart:!0,touchmove:!0};class om{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function rm(a){for(let e in Ve){let t=Ve[e];a.dom.addEventListener(e,a.input.eventHandlers[e]=i=>{lm(a,i)&&!Es(a,i)&&(a.editable||!(i.type in Oe))&&t(a,i)},nm[e]?{passive:!0}:void 0)}Be&&a.dom.addEventListener("input",()=>null),Mr(a)}function Ut(a,e){a.input.lastSelectionOrigin=e,a.input.lastSelectionTime=Date.now()}function sm(a){a.domObserver.stop();for(let e in a.input.eventHandlers)a.dom.removeEventListener(e,a.input.eventHandlers[e]);clearTimeout(a.input.composingTimeout),clearTimeout(a.input.lastIOSEnterFallbackTimeout)}function Mr(a){a.someProp("handleDOMEvents",e=>{for(let t in e)a.input.eventHandlers[t]||a.dom.addEventListener(t,a.input.eventHandlers[t]=i=>Es(a,i))})}function Es(a,e){return a.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(a,e)||e.defaultPrevented:!1})}function lm(a,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=a.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function um(a,e){!Es(a,e)&&Ve[e.type]&&(a.editable||!(e.type in Oe))&&Ve[e.type](a,e)}Oe.keydown=(a,e)=>{let t=e;if(a.input.shiftKey=t.keyCode==16||t.shiftKey,!Tf(a,t)&&(a.input.lastKeyCode=t.keyCode,a.input.lastKeyCodeTime=Date.now(),!(Ct&&De&&t.keyCode==13)))if(t.keyCode!=229&&a.domObserver.forceFlush(),$a&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();a.input.lastIOSEnter=i,a.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{a.input.lastIOSEnter==i&&(a.someProp("handleKeyDown",n=>n(a,ua(13,"Enter"))),a.input.lastIOSEnter=0)},200)}else a.someProp("handleKeyDown",i=>i(a,t))||Xh(a,t)?t.preventDefault():Ut(a,"key")};Oe.keyup=(a,e)=>{e.keyCode==16&&(a.input.shiftKey=!1)};Oe.keypress=(a,e)=>{let t=e;if(Tf(a,t)||!t.charCode||t.ctrlKey&&!t.altKey||Xe&&t.metaKey)return;if(a.someProp("handleKeyPress",n=>n(a,t))){t.preventDefault();return}let i=a.state.selection;if(!(i instanceof H)||!i.$from.sameParent(i.$to)){let n=String.fromCharCode(t.charCode),r=()=>a.state.tr.insertText(n).scrollIntoView();!/[\r\n]/.test(n)&&!a.someProp("handleTextInput",s=>s(a,i.$from.pos,i.$to.pos,n,r))&&a.dispatch(r()),t.preventDefault()}};function vo(a){return{left:a.clientX,top:a.clientY}}function dm(a,e){let t=e.x-a.clientX,i=e.y-a.clientY;return t*t+i*i<100}function xs(a,e,t,i,n){if(i==-1)return!1;let r=a.state.doc.resolve(i);for(let s=r.depth+1;s>0;s--)if(a.someProp(e,l=>s>r.depth?l(a,t,r.nodeAfter,r.before(s),n,!0):l(a,t,r.node(s),r.before(s),n,!1)))return!0;return!1}function Oa(a,e,t){if(a.focused||a.focus(),a.state.selection.eq(e))return;let i=a.state.tr.setSelection(e);i.setMeta("pointer",!0),a.dispatch(i)}function fm(a,e){if(e==-1)return!1;let t=a.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&$.isSelectable(i)?(Oa(a,new $(t)),!0):!1}function cm(a,e){if(e==-1)return!1;let t=a.state.selection,i,n;t instanceof $&&(i=t.node);let r=a.state.doc.resolve(e);for(let s=r.depth+1;s>0;s--){let l=s>r.depth?r.nodeAfter:r.node(s);if($.isSelectable(l)){i&&t.$from.depth>0&&s>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?n=r.before(t.$from.depth):n=r.before(s);break}}return n!=null?(Oa(a,$.create(a.state.doc,n)),!0):!1}function gm(a,e,t,i,n){return xs(a,"handleClickOn",e,t,i)||a.someProp("handleClick",r=>r(a,e,i))||(n?cm(a,t):fm(a,t))}function _m(a,e,t,i){return xs(a,"handleDoubleClickOn",e,t,i)||a.someProp("handleDoubleClick",n=>n(a,e,i))}function hm(a,e,t,i){return xs(a,"handleTripleClickOn",e,t,i)||a.someProp("handleTripleClick",n=>n(a,e,i))||mm(a,t,i)}function mm(a,e,t){if(t.button!=0)return!1;let i=a.state.doc;if(e==-1)return i.inlineContent?(Oa(a,H.create(i,0,i.content.size)),!0):!1;let n=i.resolve(e);for(let r=n.depth+1;r>0;r--){let s=r>n.depth?n.nodeAfter:n.node(r),l=n.before(r);if(s.inlineContent)Oa(a,H.create(i,l+1,l+1+s.content.size));else if($.isSelectable(s))Oa(a,$.create(i,l));else continue;return!0}}function Cs(a){return jn(a)}const Af=Xe?"metaKey":"ctrlKey";Ve.mousedown=(a,e)=>{let t=e;a.input.shiftKey=t.shiftKey;let i=Cs(a),n=Date.now(),r="singleClick";n-a.input.lastClick.time<500&&dm(t,a.input.lastClick)&&!t[Af]&&a.input.lastClick.button==t.button&&(a.input.lastClick.type=="singleClick"?r="doubleClick":a.input.lastClick.type=="doubleClick"&&(r="tripleClick")),a.input.lastClick={time:n,x:t.clientX,y:t.clientY,type:r,button:t.button};let s=a.posAtCoords(vo(t));s&&(r=="singleClick"?(a.input.mouseDown&&a.input.mouseDown.done(),a.input.mouseDown=new Fm(a,s,t,!!i)):(r=="doubleClick"?_m:hm)(a,s.pos,s.inside,t)?t.preventDefault():Ut(a,"pointer"))};class Fm{constructor(e,t,i,n){this.view=e,this.pos=t,this.event=i,this.flushed=n,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[Af],this.allowDefault=i.shiftKey;let r,s;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),s=t.inside;else{let f=e.state.doc.resolve(t.pos);r=f.parent,s=f.depth?f.before():0}const l=n?null:i.target,u=l?e.docView.nearestDesc(l,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:d}=e.state;(i.button==0&&r.type.spec.draggable&&r.type.spec.selectable!==!1||d instanceof $&&d.from<=s&&d.to>s)&&(this.mightDrag={node:r,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&et&&!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)),Ut(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(()=>jt(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(vo(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ut(this.view,"pointer"):gm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Be&&this.mightDrag&&!this.mightDrag.node.isAtom||De&&!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)?(Oa(this.view,J.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ut(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ut(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)}}Ve.touchstart=a=>{a.input.lastTouch=Date.now(),Cs(a),Ut(a,"pointer")};Ve.touchmove=a=>{a.input.lastTouch=Date.now(),Ut(a,"pointer")};Ve.contextmenu=a=>Cs(a);function Tf(a,e){return a.composing?!0:Be&&Math.abs(e.timeStamp-a.input.compositionEndedAt)<500?(a.input.compositionEndedAt=-2e8,!0):!1}const pm=Ct?5e3:-1;Oe.compositionstart=Oe.compositionupdate=a=>{if(!a.composing){a.domObserver.flush();let{state:e}=a,t=e.selection.$to;if(e.selection instanceof H&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)||De&&ff&&bm(a)))a.markCursor=a.state.storedMarks||t.marks(),jn(a,!0),a.markCursor=null;else if(jn(a,!e.selection.empty),et&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=a.domSelectionRange();for(let n=i.focusNode,r=i.focusOffset;n&&n.nodeType==1&&r!=0;){let s=r<0?n.lastChild:n.childNodes[r-1];if(!s)break;if(s.nodeType==3){let l=a.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else n=s,r=-1}}a.input.composing=!0}Mf(a,pm)};function bm(a){let{focusNode:e,focusOffset:t}=a.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let i=e.childNodes[t];return i.nodeType==1&&i.contentEditable=="false"}Oe.compositionend=(a,e)=>{a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=e.timeStamp,a.input.compositionPendingChanges=a.domObserver.pendingRecords().length?a.input.compositionID:0,a.input.compositionNode=null,a.input.badSafariComposition?a.domObserver.forceFlush():a.input.compositionPendingChanges&&Promise.resolve().then(()=>a.domObserver.flush()),a.input.compositionID++,Mf(a,20))};function Mf(a,e){clearTimeout(a.input.composingTimeout),e>-1&&(a.input.composingTimeout=setTimeout(()=>jn(a),e))}function Vf(a){for(a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=km());a.input.compositionNodes.length>0;)a.input.compositionNodes.pop().markParentsDirty()}function ym(a){let e=a.domSelectionRange();if(!e.focusNode)return null;let t=ch(e.focusNode,e.focusOffset),i=gh(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let n=i.pmViewDesc,r=a.domObserver.lastChangedTextNode;if(t==r||i==r)return r;if(!n||!n.isText(i.nodeValue))return i;if(a.input.compositionNode==i){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return i}}return t||i}function km(){let a=document.createEvent("Event");return a.initEvent("event",!0,!0),a.timeStamp}function jn(a,e=!1){if(!(Ct&&a.domObserver.flushingSoon>=0)){if(a.domObserver.forceFlush(),Vf(a),e||a.docView&&a.docView.dirty){let t=ws(a),i=a.state.selection;return t&&!t.eq(i)?a.dispatch(a.state.tr.setSelection(t)):(a.markCursor||e)&&!i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?a.dispatch(a.state.tr.deleteSelection()):a.updateState(a.state),!0}return!1}}function wm(a,e){if(!a.dom.parentNode)return;let t=a.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),n=document.createRange();n.selectNodeContents(e),a.dom.blur(),i.removeAllRanges(),i.addRange(n),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),a.focus()},50)}const ji=$e&&Gt<15||$a&&Fh<604;Ve.copy=Oe.cut=(a,e)=>{let t=e,i=a.state.selection,n=t.type=="cut";if(i.empty)return;let r=ji?null:t.clipboardData,s=i.content(),{dom:l,text:u}=vs(a,s);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",u)):wm(a,l),n&&a.dispatch(a.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Dm(a){return a.openStart==0&&a.openEnd==0&&a.content.childCount==1?a.content.firstChild:null}function vm(a,e){if(!a.dom.parentNode)return;let t=a.input.shiftKey||a.state.selection.$from.parent.type.spec.code,i=a.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let n=a.input.shiftKey&&a.input.lastKeyCode!=45;setTimeout(()=>{a.focus(),i.parentNode&&i.parentNode.removeChild(i),t?Ni(a,i.value,null,n,e):Ni(a,i.textContent,i.innerHTML,n,e)},50)}function Ni(a,e,t,i,n){let r=Cf(a,e,t,i,a.state.selection.$from);if(a.someProp("handlePaste",u=>u(a,n,r||P.empty)))return!0;if(!r)return!1;let s=Dm(r),l=s?a.state.tr.replaceSelectionWith(s,i):a.state.tr.replaceSelection(r);return a.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Of(a){let e=a.getData("text/plain")||a.getData("Text");if(e)return e;let t=a.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Oe.paste=(a,e)=>{let t=e;if(a.composing&&!Ct)return;let i=ji?null:t.clipboardData,n=a.input.shiftKey&&a.input.lastKeyCode!=45;i&&Ni(a,Of(i),i.getData("text/html"),n,t)?t.preventDefault():vm(a,t)};class Lf{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const Em=Xe?"altKey":"ctrlKey";function zf(a,e){let t=a.someProp("dragCopies",i=>!i(e));return t??!e[Em]}Ve.dragstart=(a,e)=>{let t=e,i=a.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let n=a.state.selection,r=n.empty?null:a.posAtCoords(vo(t)),s;if(!(r&&r.pos>=n.from&&r.pos<=(n instanceof $?n.to-1:n.to))){if(i&&i.mightDrag)s=$.create(a.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let c=a.docView.nearestDesc(t.target,!0);c&&c.node.type.spec.draggable&&c!=a.docView&&(s=$.create(a.state.doc,c.posBefore))}}let l=(s||a.state.selection).content(),{dom:u,text:d,slice:f}=vs(a,l);(!t.dataTransfer.files.length||!De||df>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ji?"Text":"text/html",u.innerHTML),t.dataTransfer.effectAllowed="copyMove",ji||t.dataTransfer.setData("text/plain",d),a.dragging=new Lf(f,zf(a,t),s)};Ve.dragend=a=>{let e=a.dragging;window.setTimeout(()=>{a.dragging==e&&(a.dragging=null)},50)};Oe.dragover=Oe.dragenter=(a,e)=>e.preventDefault();Oe.drop=(a,e)=>{try{xm(a,e,a.dragging)}finally{a.dragging=null}};function xm(a,e,t){if(!e.dataTransfer)return;let i=a.posAtCoords(vo(e));if(!i)return;let n=a.state.doc.resolve(i.pos),r=t&&t.slice;r?a.someProp("transformPasted",_=>{r=_(r,a,!1)}):r=Cf(a,Of(e.dataTransfer),ji?null:e.dataTransfer.getData("text/html"),!1,n);let s=!!(t&&zf(a,e));if(a.someProp("handleDrop",_=>_(a,e,r||P.empty,s))){e.preventDefault();return}if(!r)return;e.preventDefault();let l=r?zd(a.state.doc,n.pos,r):n.pos;l==null&&(l=n.pos);let u=a.state.tr;if(s){let{node:_}=t;_?_.replace(u):u.deleteSelection()}let d=u.mapping.map(l),f=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,c=u.doc;if(f?u.replaceRangeWith(d,d,r.content.firstChild):u.replaceRange(d,d,r),u.doc.eq(c))return;let g=u.doc.resolve(d);if(f&&$.isSelectable(r.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(r.content.firstChild))u.setSelection(new $(g));else{let _=u.mapping.map(l);u.mapping.maps[u.mapping.maps.length-1].forEach((h,m,F,p)=>_=p),u.setSelection(Ds(a,g,u.doc.resolve(_)))}a.focus(),a.dispatch(u.setMeta("uiEvent","drop"))}Ve.focus=a=>{a.input.lastFocus=Date.now(),a.focused||(a.domObserver.stop(),a.dom.classList.add("ProseMirror-focused"),a.domObserver.start(),a.focused=!0,setTimeout(()=>{a.docView&&a.hasFocus()&&!a.domObserver.currentSelection.eq(a.domSelectionRange())&&jt(a)},20))};Ve.blur=(a,e)=>{let t=e;a.focused&&(a.domObserver.stop(),a.dom.classList.remove("ProseMirror-focused"),a.domObserver.start(),t.relatedTarget&&a.dom.contains(t.relatedTarget)&&a.domObserver.currentSelection.clear(),a.focused=!1)};Ve.beforeinput=(a,e)=>{if(De&&Ct&&e.inputType=="deleteContentBackward"){a.domObserver.flushSoon();let{domChangeCount:i}=a.input;setTimeout(()=>{if(a.input.domChangeCount!=i||(a.dom.blur(),a.focus(),a.someProp("handleKeyDown",r=>r(a,ua(8,"Backspace")))))return;let{$cursor:n}=a.state.selection;n&&n.pos>0&&a.dispatch(a.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let a in Oe)Ve[a]=Oe[a];function qi(a,e){if(a==e)return!0;for(let t in a)if(a[t]!==e[t])return!1;for(let t in e)if(!(t in a))return!1;return!0}class Nn{constructor(e,t){this.toDOM=e,this.spec=t||pa,this.side=this.spec.side||0}map(e,t,i,n){let{pos:r,deleted:s}=e.mapResult(t.from+n,this.side<0?-1:1);return s?null:new Me(r-i,r-i,this)}valid(){return!0}eq(e){return this==e||e instanceof Nn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&qi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Xt{constructor(e,t){this.attrs=e,this.spec=t||pa}map(e,t,i,n){let r=e.map(t.from+n,this.spec.inclusiveStart?-1:1)-i,s=e.map(t.to+n,this.spec.inclusiveEnd?1:-1)-i;return r>=s?null:new Me(r,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Xt&&qi(this.attrs,e.attrs)&&qi(this.spec,e.spec)}static is(e){return e.type instanceof Xt}destroy(){}}class Bs{constructor(e,t){this.attrs=e,this.spec=t||pa}map(e,t,i,n){let r=e.mapResult(t.from+n,1);if(r.deleted)return null;let s=e.mapResult(t.to+n,-1);return s.deleted||s.pos<=r.pos?null:new Me(r.pos-i,s.pos-i,this)}valid(e,t){let{index:i,offset:n}=e.content.findIndex(t.from),r;return n==t.from&&!(r=e.child(i)).isText&&n+r.nodeSize==t.to}eq(e){return this==e||e instanceof Bs&&qi(this.attrs,e.attrs)&&qi(this.spec,e.spec)}destroy(){}}class Me{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new Me(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,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new Me(e,e,new Nn(t,i))}static inline(e,t,i,n){return new Me(e,t,new Xt(i,n))}static node(e,t,i,n){return new Me(e,t,new Bs(i,n))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xt}get widget(){return this.type instanceof Nn}}const Ta=[],pa={};class ue{constructor(e,t){this.local=e.length?e:Ta,this.children=t.length?t:Ta}static create(e,t){return t.length?qn(t,e,0,pa):xe}find(e,t,i){let n=[];return this.findInner(e??0,t??1e9,n,0,i),n}findInner(e,t,i,n,r){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&i.push(l.copy(l.from+n,l.to+n))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,i,n+l,r)}}map(e,t,i){return this==xe||e.maps.length==0?this:this.mapInner(e,t,0,0,i||pa)}mapInner(e,t,i,n,r){let s;for(let l=0;l<this.local.length;l++){let u=this.local[l].map(e,i,n);u&&u.type.valid(t,u)?(s||(s=[])).push(u):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?Cm(this.children,s||[],e,t,i,n,r):s?new ue(s.sort(ba),Ta):xe}add(e,t){return t.length?this==xe?ue.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let n,r=0;e.forEach((l,u)=>{let d=u+i,f;if(f=Pf(t,l,d)){for(n||(n=this.children.slice());r<n.length&&n[r]<u;)r+=3;n[r]==u?n[r+2]=n[r+2].addInner(l,f,d+1):n.splice(r,0,u,u+l.nodeSize,qn(f,l,d+1,pa)),r+=3}});let s=If(r?Rf(t):t,-i);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new ue(s.length?this.local.concat(s).sort(ba):this.local,n||this.children)}remove(e){return e.length==0||this==xe?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,n=this.local;for(let r=0;r<i.length;r+=3){let s,l=i[r]+t,u=i[r+1]+t;for(let f=0,c;f<e.length;f++)(c=e[f])&&c.from>l&&c.to<u&&(e[f]=null,(s||(s=[])).push(c));if(!s)continue;i==this.children&&(i=this.children.slice());let d=i[r+2].removeInner(s,l+1);d!=xe?i[r+2]=d:(i.splice(r,3),r-=3)}if(n.length){for(let r=0,s;r<e.length;r++)if(s=e[r])for(let l=0;l<n.length;l++)n[l].eq(s,t)&&(n==this.local&&(n=this.local.slice()),n.splice(l--,1))}return i==this.children&&n==this.local?this:n.length||i.length?new ue(n,i):xe}forChild(e,t){if(this==xe)return this;if(t.isLeaf)return ue.empty;let i,n;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=this.children[l+2]);break}let r=e+1,s=r+t.content.size;for(let l=0;l<this.local.length;l++){let u=this.local[l];if(u.from<s&&u.to>r&&u.type instanceof Xt){let d=Math.max(r,u.from)-r,f=Math.min(s,u.to)-r;d<f&&(n||(n=[])).push(u.copy(d,f))}}if(n){let l=new ue(n.sort(ba),Ta);return i?new Ht([l,i]):l}return i||xe}eq(e){if(this==e)return!0;if(!(e instanceof ue)||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 Ss(this.localsInner(e))}localsInner(e){if(this==xe)return Ta;if(e.inlineContent||!this.local.some(Xt.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof Xt||t.push(this.local[i]);return t}forEachSet(e){e(this)}}ue.empty=new ue([],[]);ue.removeOverlap=Ss;const xe=ue.empty;class Ht{constructor(e){this.members=e}map(e,t){const i=this.members.map(n=>n.map(e,t,pa));return Ht.from(i)}forChild(e,t){if(t.isLeaf)return ue.empty;let i=[];for(let n=0;n<this.members.length;n++){let r=this.members[n].forChild(e,t);r!=xe&&(r instanceof Ht?i=i.concat(r.members):i.push(r))}return Ht.from(i)}eq(e){if(!(e instanceof Ht)||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,i=!0;for(let n=0;n<this.members.length;n++){let r=this.members[n].localsInner(e);if(r.length)if(!t)t=r;else{i&&(t=t.slice(),i=!1);for(let s=0;s<r.length;s++)t.push(r[s])}}return t?Ss(i?t:t.sort(ba)):Ta}static from(e){switch(e.length){case 0:return xe;case 1:return e[0];default:return new Ht(e.every(t=>t instanceof ue)?e:e.reduce((t,i)=>t.concat(i instanceof ue?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Cm(a,e,t,i,n,r,s){let l=a.slice();for(let d=0,f=r;d<t.maps.length;d++){let c=0;t.maps[d].forEach((g,_,h,m)=>{let F=m-h-(_-g);for(let p=0;p<l.length;p+=3){let b=l[p+1];if(b<0||g>b+f-c)continue;let y=l[p]+f-c;_>=y?l[p+1]=g<=y?-2:-1:g>=f&&F&&(l[p]+=F,l[p+1]+=F)}c+=F}),f=t.maps[d].map(f,-1)}let u=!1;for(let d=0;d<l.length;d+=3)if(l[d+1]<0){if(l[d+1]==-2){u=!0,l[d+1]=-1;continue}let f=t.map(a[d]+r),c=f-n;if(c<0||c>=i.content.size){u=!0;continue}let g=t.map(a[d+1]+r,-1),_=g-n,{index:h,offset:m}=i.content.findIndex(c),F=i.maybeChild(h);if(F&&m==c&&m+F.nodeSize==_){let p=l[d+2].mapInner(t,F,f+1,a[d]+r+1,s);p!=xe?(l[d]=c,l[d+1]=_,l[d+2]=p):(l[d+1]=-2,u=!0)}else u=!0}if(u){let d=Bm(l,a,e,t,n,r,s),f=qn(d,i,0,s);e=f.local;for(let c=0;c<l.length;c+=3)l[c+1]<0&&(l.splice(c,3),c-=3);for(let c=0,g=0;c<f.children.length;c+=3){let _=f.children[c];for(;g<l.length&&l[g]<_;)g+=3;l.splice(g,0,f.children[c],f.children[c+1],f.children[c+2])}}return new ue(e.sort(ba),l)}function If(a,e){if(!e||!a.length)return a;let t=[];for(let i=0;i<a.length;i++){let n=a[i];t.push(new Me(n.from+e,n.to+e,n.type))}return t}function Bm(a,e,t,i,n,r,s){function l(u,d){for(let f=0;f<u.local.length;f++){let c=u.local[f].map(i,n,d);c?t.push(c):s.onRemove&&s.onRemove(u.local[f].spec)}for(let f=0;f<u.children.length;f+=3)l(u.children[f+2],u.children[f]+d+1)}for(let u=0;u<a.length;u+=3)a[u+1]==-1&&l(a[u+2],e[u]+r+1);return t}function Pf(a,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,n=null;for(let r=0,s;r<a.length;r++)(s=a[r])&&s.from>t&&s.to<i&&((n||(n=[])).push(s),a[r]=null);return n}function Rf(a){let e=[];for(let t=0;t<a.length;t++)a[t]!=null&&e.push(a[t]);return e}function qn(a,e,t,i){let n=[],r=!1;e.forEach((l,u)=>{let d=Pf(a,l,u+t);if(d){r=!0;let f=qn(d,l,t+u+1,i);f!=xe&&n.push(u,u+l.nodeSize,f)}});let s=If(r?Rf(a):a,-t).sort(ba);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(i.onRemove&&i.onRemove(s[l].spec),s.splice(l--,1));return s.length||n.length?new ue(s,n):xe}function ba(a,e){return a.from-e.from||a.to-e.to}function Ss(a){let e=a;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let n=t+1;n<e.length;n++){let r=e[n];if(r.from==i.from){r.to!=i.to&&(e==a&&(e=a.slice()),e[n]=r.copy(r.from,i.to),su(e,n+1,r.copy(i.to,r.to)));continue}else{r.from<i.to&&(e==a&&(e=a.slice()),e[t]=i.copy(i.from,r.from),su(e,n,i.copy(r.from,i.to)));break}}}return e}function su(a,e,t){for(;e<a.length&&ba(t,a[e])>0;)e++;a.splice(e,0,t)}function Go(a){let e=[];return a.someProp("decorations",t=>{let i=t(a.state);i&&i!=xe&&e.push(i)}),a.cursorWrapper&&e.push(ue.create(a.state.doc,[a.cursorWrapper.deco])),Ht.from(e)}const Sm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jm=$e&&Gt<=11;class Nm{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 qm{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Nm,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let n=0;n<i.length;n++)this.queue.push(i[n]);$e&&Gt<=11&&i.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():Be&&e.composing&&i.some(n=>n.type=="childList"&&n.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),jm&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.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,Sm)),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(Zl(this.view)){if(this.suppressingSelectionUpdates)return jt(this.view);if($e&&Gt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Da(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,i;for(let r=e.focusNode;r;r=Ra(r))t.add(r);for(let r=e.anchorNode;r;r=Ra(r))if(t.has(r)){i=r;break}let n=i&&this.view.docView.nearestDesc(i);if(n&&n.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))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 i=e.domSelectionRange(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&Zl(e)&&!this.ignoreSelectionChange(i),r=-1,s=-1,l=!1,u=[];if(e.editable)for(let f=0;f<t.length;f++){let c=this.registerMutation(t[f],u);c&&(r=r<0?c.from:Math.min(c.from,r),s=s<0?c.to:Math.max(c.to,s),c.typeOver&&(l=!0))}if(u.some(f=>f.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let f of u)if(f.nodeName=="BR"&&f.parentNode){let c=f.nextSibling;for(;c&&c.nodeType==1;){if(c.contentEditable=="false"){f.parentNode.removeChild(f);break}c=c.firstChild}}}else if(et&&u.length){let f=u.filter(c=>c.nodeName=="BR");if(f.length==2){let[c,g]=f;c.parentNode&&c.parentNode.parentNode==g.parentNode?g.remove():c.remove()}else{let{focusNode:c}=this.currentSelection;for(let g of f){let _=g.parentNode;_&&_.nodeName=="LI"&&(!c||Mm(e,c)!=_)&&g.remove()}}}let d=null;r<0&&n&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&wo(i)&&(d=ws(e))&&d.eq(J.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,jt(e),this.currentSelection.set(i),e.scrollToSelection()):(r>-1||n)&&(r>-1&&(e.docView.markDirty(r,s),Am(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Vm(e,u)),this.handleDOMChange(r,s,l,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||jt(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;f<e.addedNodes.length;f++){let c=e.addedNodes[f];t.push(c),c.nodeType==3&&(this.lastChangedTextNode=c)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let n=e.previousSibling,r=e.nextSibling;if($e&&Gt<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:c,nextSibling:g}=e.addedNodes[f];(!c||Array.prototype.indexOf.call(e.addedNodes,c)<0)&&(n=c),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(r=g)}let s=n&&n.parentNode==e.target?ke(n)+1:0,l=i.localPosFromDOM(e.target,s,-1),u=r&&r.parentNode==e.target?ke(r):e.target.childNodes.length,d=i.localPosFromDOM(e.target,u,1);return{from:l,to:d}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let lu=new WeakMap,uu=!1;function Am(a){if(!lu.has(a)&&(lu.set(a,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(a.dom).whiteSpace)!==-1)){if(a.requiresGeckoHackNode=et,uu)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."),uu=!0}}function du(a,e){let t=e.startContainer,i=e.startOffset,n=e.endContainer,r=e.endOffset,s=a.domAtPos(a.state.selection.anchor);return Da(s.node,s.offset,n,r)&&([t,i,n,r]=[n,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}}function Tm(a,e){if(e.getComposedRanges){let n=e.getComposedRanges(a.root)[0];if(n)return du(a,n)}let t;function i(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return a.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),a.dom.removeEventListener("beforeinput",i,!0),t?du(a,t):null}function Mm(a,e){for(let t=e.parentNode;t&&t!=a.dom;t=t.parentNode){let i=a.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function Vm(a,e){var t;let{focusNode:i,focusOffset:n}=a.domSelectionRange();for(let r of e)if(((t=r.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=r.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let u=l.firstChild;if(!u||u.nodeType!=1||u.contentEditable=="false"||/^(BR|IMG)$/.test(u.nodeName))break;l=u}l.insertBefore(r,l.firstChild),i==r&&a.domSelection().collapse(r,n)}else r.parentNode.removeChild(r)}}function Om(a,e,t){let{node:i,fromOffset:n,toOffset:r,from:s,to:l}=a.docView.parseRange(e,t),u=a.domSelectionRange(),d,f=u.anchorNode;if(f&&a.dom.contains(f.nodeType==1?f:f.parentNode)&&(d=[{node:f,offset:u.anchorOffset}],wo(u)||d.push({node:u.focusNode,offset:u.focusOffset})),De&&a.input.lastKeyCode===8)for(let F=r;F>n;F--){let p=i.childNodes[F-1],b=p.pmViewDesc;if(p.nodeName=="BR"&&!b){r=F;break}if(!b||b.size)break}let c=a.state.doc,g=a.someProp("domParser")||Jt.fromSchema(a.state.schema),_=c.resolve(s),h=null,m=g.parse(i,{topNode:_.parent,topMatch:_.parent.contentMatchAt(_.index()),topOpen:!0,from:n,to:r,preserveWhitespace:_.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:Lm,context:_});if(d&&d[0].pos!=null){let F=d[0].pos,p=d[1]&&d[1].pos;p==null&&(p=F),h={anchor:F+s,head:p+s}}return{doc:m,sel:h,from:s,to:l}}function Lm(a){let e=a.pmViewDesc;if(e)return e.parseRule();if(a.nodeName=="BR"&&a.parentNode){if(Be&&/^(ul|ol)$/i.test(a.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(a.parentNode.lastChild==a||Be&&/^(tr|table)$/i.test(a.parentNode.nodeName))return{ignore:!0}}else if(a.nodeName=="IMG"&&a.getAttribute("mark-placeholder"))return{ignore:!0};return null}const zm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Im(a,e,t,i,n){let r=a.input.compositionPendingChanges||(a.composing?a.input.compositionID:0);if(a.input.compositionPendingChanges=0,e<0){let v=a.input.lastSelectionTime>Date.now()-50?a.input.lastSelectionOrigin:null,E=ws(a,v);if(E&&!a.state.selection.eq(E)){if(De&&Ct&&a.input.lastKeyCode===13&&Date.now()-100<a.input.lastKeyCodeTime&&a.someProp("handleKeyDown",N=>N(a,ua(13,"Enter"))))return;let C=a.state.tr.setSelection(E);v=="pointer"?C.setMeta("pointer",!0):v=="key"&&C.scrollIntoView(),r&&C.setMeta("composition",r),a.dispatch(C)}return}let s=a.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=a.state.doc.resolve(t).after(l+1);let u=a.state.selection,d=Om(a,e,t),f=a.state.doc,c=f.slice(d.from,d.to),g,_;a.input.lastKeyCode===8&&Date.now()-100<a.input.lastKeyCodeTime?(g=a.state.selection.to,_="end"):(g=a.state.selection.from,_="start"),a.input.lastKeyCode=null;let h=$m(c.content,d.doc.content,d.from,g,_);if(h&&a.input.domChangeCount++,($a&&a.input.lastIOSEnter>Date.now()-225||Ct)&&n.some(v=>v.nodeType==1&&!zm.test(v.nodeName))&&(!h||h.endA>=h.endB)&&a.someProp("handleKeyDown",v=>v(a,ua(13,"Enter")))){a.input.lastIOSEnter=0;return}if(!h)if(i&&u instanceof H&&!u.empty&&u.$head.sameParent(u.$anchor)&&!a.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))h={start:u.from,endA:u.to,endB:u.to};else{if(d.sel){let v=fu(a,a.state.doc,d.sel);if(v&&!v.eq(a.state.selection)){let E=a.state.tr.setSelection(v);r&&E.setMeta("composition",r),a.dispatch(E)}}return}a.state.selection.from<a.state.selection.to&&h.start==h.endB&&a.state.selection instanceof H&&(h.start>a.state.selection.from&&h.start<=a.state.selection.from+2&&a.state.selection.from>=d.from?h.start=a.state.selection.from:h.endA<a.state.selection.to&&h.endA>=a.state.selection.to-2&&a.state.selection.to<=d.to&&(h.endB+=a.state.selection.to-h.endA,h.endA=a.state.selection.to)),$e&&Gt<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>d.from&&d.doc.textBetween(h.start-d.from-1,h.start-d.from+1)==" "&&(h.start--,h.endA--,h.endB--);let m=d.doc.resolveNoCache(h.start-d.from),F=d.doc.resolveNoCache(h.endB-d.from),p=f.resolve(h.start),b=m.sameParent(F)&&m.parent.inlineContent&&p.end()>=h.endA;if(($a&&a.input.lastIOSEnter>Date.now()-225&&(!b||n.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!b&&m.pos<d.doc.content.size&&(!m.sameParent(F)||!m.parent.inlineContent)&&m.pos<F.pos&&!/\S/.test(d.doc.textBetween(m.pos,F.pos,"","")))&&a.someProp("handleKeyDown",v=>v(a,ua(13,"Enter")))){a.input.lastIOSEnter=0;return}if(a.state.selection.anchor>h.start&&Rm(f,h.start,h.endA,m,F)&&a.someProp("handleKeyDown",v=>v(a,ua(8,"Backspace")))){Ct&&De&&a.domObserver.suppressSelectionUpdates();return}De&&h.endB==h.start&&(a.input.lastChromeDelete=Date.now()),Ct&&!b&&m.start()!=F.start()&&F.parentOffset==0&&m.depth==F.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==h.endA&&(h.endB-=2,F=d.doc.resolveNoCache(h.endB-d.from),setTimeout(()=>{a.someProp("handleKeyDown",function(v){return v(a,ua(13,"Enter"))})},20));let y=h.start,k=h.endA,w=v=>{let E=v||a.state.tr.replace(y,k,d.doc.slice(h.start-d.from,h.endB-d.from));if(d.sel){let C=fu(a,E.doc,d.sel);C&&!(De&&a.composing&&C.empty&&(h.start!=h.endB||a.input.lastChromeDelete<Date.now()-100)&&(C.head==y||C.head==E.mapping.map(k)-1)||$e&&C.empty&&C.head==y)&&E.setSelection(C)}return r&&E.setMeta("composition",r),E.scrollIntoView()},D;if(b)if(m.pos==F.pos){$e&&Gt<=11&&m.parentOffset==0&&(a.domObserver.suppressSelectionUpdates(),setTimeout(()=>jt(a),20));let v=w(a.state.tr.delete(y,k)),E=f.resolve(h.start).marksAcross(f.resolve(h.endA));E&&v.ensureMarks(E),a.dispatch(v)}else if(h.endA==h.endB&&(D=Pm(m.parent.content.cut(m.parentOffset,F.parentOffset),p.parent.content.cut(p.parentOffset,h.endA-p.start())))){let v=w(a.state.tr);D.type=="add"?v.addMark(y,k,D.mark):v.removeMark(y,k,D.mark),a.dispatch(v)}else if(m.parent.child(m.index()).isText&&m.index()==F.index()-(F.textOffset?0:1)){let v=m.parent.textBetween(m.parentOffset,F.parentOffset),E=()=>w(a.state.tr.insertText(v,y,k));a.someProp("handleTextInput",C=>C(a,y,k,v,E))||a.dispatch(E())}else a.dispatch(w());else a.dispatch(w())}function fu(a,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Ds(a,e.resolve(t.anchor),e.resolve(t.head))}function Pm(a,e){let t=a.firstChild.marks,i=e.firstChild.marks,n=t,r=i,s,l,u;for(let f=0;f<i.length;f++)n=i[f].removeFromSet(n);for(let f=0;f<t.length;f++)r=t[f].removeFromSet(r);if(n.length==1&&r.length==0)l=n[0],s="add",u=f=>f.mark(l.addToSet(f.marks));else if(n.length==0&&r.length==1)l=r[0],s="remove",u=f=>f.mark(l.removeFromSet(f.marks));else return null;let d=[];for(let f=0;f<e.childCount;f++)d.push(u(e.child(f)));if(V.from(d).eq(a))return{mark:l,type:s}}function Rm(a,e,t,i,n){if(t-e<=n.pos-i.pos||Yo(i,!0,!1)<n.pos)return!1;let r=a.resolve(e);if(!i.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let s=a.resolve(Yo(r,!0,!0));return!s.parent.isTextblock||s.pos>t||Yo(s,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(s.parent.content)}function Yo(a,e,t){let i=a.depth,n=e?a.end():a.pos;for(;i>0&&(e||a.indexAfter(i)==a.node(i).childCount);)i--,n++,e=!1;if(t){let r=a.node(i).maybeChild(a.indexAfter(i));for(;r&&!r.isLeaf;)r=r.firstChild,n++}return n}function $m(a,e,t,i,n){let r=a.findDiffStart(e,t);if(r==null)return null;let{a:s,b:l}=a.findDiffEnd(e,t+a.size,t+e.size);if(n=="end"){let u=Math.max(0,r-Math.min(s,l));i-=s+u-r}if(s<r&&a.size<e.size){let u=i<=r&&i>=s?r-i:0;r-=u,r&&r<e.size&&cu(e.textBetween(r-1,r+1))&&(r+=u?1:-1),l=r+(l-s),s=r}else if(l<r){let u=i<=r&&i>=l?r-i:0;r-=u,r&&r<a.size&&cu(a.textBetween(r-1,r+1))&&(r+=u?1:-1),s=r+(s-l),l=r}return{start:r,endA:s,endB:l}}function cu(a){if(a.length!=2)return!1;let e=a.charCodeAt(0),t=a.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class $f{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 om,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Fu),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=hu(this),_u(this),this.nodeViews=mu(this),this.docView=Kl(this.state.doc,gu(this),Go(this),this.dom,this),this.domObserver=new qm(this,(i,n,r,s)=>Im(this,i,n,r,s)),this.domObserver.start(),rm(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&&Mr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Fu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let n=this.state,r=!1,s=!1;e.storedMarks&&this.composing&&(Vf(this),s=!0),this.state=e;let l=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let _=mu(this);Wm(_,this.nodeViews)&&(this.nodeViews=_,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Mr(this),this.editable=hu(this),_u(this);let u=Go(this),d=gu(this),f=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?"reset":e.scrollToSelection>n.scrollToSelection?"to selection":"preserve",c=r||!this.docView.matchesNode(e.doc,d,u);(c||!e.selection.eq(n.selection))&&(s=!0);let g=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&yh(this);if(s){this.domObserver.stop();let _=c&&($e||De)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Hm(n.selection,e.selection);if(c){let h=De?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ym(this)),(r||!this.docView.update(e.doc,d,u,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=Kl(e.doc,d,u,this.dom,this)),h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Hh(this))?jt(this,_):(vf(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),!((i=this.dragging)===null||i===void 0)&&i.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&kh(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof $){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Pl(this,t.getBoundingClientRect(),e)}else Pl(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 i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,n=-1;if(i.from<this.state.doc.content.size&&this.state.doc.nodeAt(i.from)==i.node)n=i.from;else{let r=i.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&r<this.state.doc.content.size&&this.state.doc.nodeAt(r))==i.node&&(n=r)}this.dragging=new Lf(e.slice,e.move,n<0?void 0:$.create(this.state.doc,n))}someProp(e,t){let i=this._props&&this._props[e],n;if(i!=null&&(n=t?t(i):i))return n;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(n=t?t(l):l))return n}let r=this.state.plugins;if(r)for(let s=0;s<r.length;s++){let l=r[s].props[e];if(l!=null&&(n=t?t(l):l))return n}}hasFocus(){if($e){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&&wh(this.dom),jt(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 Ch(this,e)}coordsAtPos(e,t=1){return mf(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,i=-1){let n=this.docView.posFromDOM(e,t,i);if(n==null)throw new RangeError("DOM position not inside the editor");return n}endOfTextblock(e,t){return qh(this,t||this.state,e)}pasteHTML(e,t){return Ni(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ni(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return vs(this,e)}destroy(){this.docView&&(sm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Go(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,dh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return um(this,e)}domSelectionRange(){let e=this.domSelection();return e?Be&&this.root.nodeType===11&&hh(this.dom.ownerDocument)==this.dom&&Tm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}$f.prototype.dispatch=function(a){let e=this._props.dispatchTransaction;e?e.call(this,a):this.updateState(this.state.apply(a))};function gu(a){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(a.editable),a.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(a.state)),t)for(let i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[Me.node(0,a.state.doc.content.size,e)]}function _u(a){if(a.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),a.cursorWrapper={dom:e,deco:Me.widget(a.state.selection.from,e,{raw:!0,marks:a.markCursor})}}else a.cursorWrapper=null}function hu(a){return!a.someProp("editable",e=>e(a.state)===!1)}function Hm(a,e){let t=Math.min(a.$anchor.sharedDepth(a.head),e.$anchor.sharedDepth(e.head));return a.$anchor.start(t)!=e.$anchor.start(t)}function mu(a){let e=Object.create(null);function t(i){for(let n in i)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=i[n])}return a.someProp("nodeViews",t),a.someProp("markViews",t),e}function Wm(a,e){let t=0,i=0;for(let n in a){if(a[n]!=e[n])return!0;t++}for(let n in e)i++;return t!=i}function Fu(a){if(a.spec.state||a.spec.filterTransaction||a.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Qt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},An={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Um=typeof navigator<"u"&&/Mac/.test(navigator.platform),Km=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var we=0;we<10;we++)Qt[48+we]=Qt[96+we]=String(we);for(var we=1;we<=24;we++)Qt[we+111]="F"+we;for(var we=65;we<=90;we++)Qt[we]=String.fromCharCode(we+32),An[we]=String.fromCharCode(we);for(var Xo in Qt)An.hasOwnProperty(Xo)||(An[Xo]=Qt[Xo]);function Jm(a){var e=Um&&a.metaKey&&a.shiftKey&&!a.ctrlKey&&!a.altKey||Km&&a.shiftKey&&a.key&&a.key.length==1||a.key=="Unidentified",t=!e&&a.key||(a.shiftKey?An:Qt)[a.keyCode]||a.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Gm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ym=typeof navigator<"u"&&/Win/.test(navigator.platform);function Xm(a){let e=a.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let i,n,r,s;for(let l=0;l<e.length-1;l++){let u=e[l];if(/^(cmd|meta|m)$/i.test(u))s=!0;else if(/^a(lt)?$/i.test(u))i=!0;else if(/^(c|ctrl|control)$/i.test(u))n=!0;else if(/^s(hift)?$/i.test(u))r=!0;else if(/^mod$/i.test(u))Gm?s=!0:n=!0;else throw new Error("Unrecognized modifier name: "+u)}return i&&(t="Alt-"+t),n&&(t="Ctrl-"+t),s&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function Qm(a){let e=Object.create(null);for(let t in a)e[Xm(t)]=a[t];return e}function Qo(a,e,t=!0){return e.altKey&&(a="Alt-"+a),e.ctrlKey&&(a="Ctrl-"+a),e.metaKey&&(a="Meta-"+a),t&&e.shiftKey&&(a="Shift-"+a),a}function Zm(a){return new X({props:{handleKeyDown:js(a)}})}function js(a){let e=Qm(a);return function(t,i){let n=Jm(i),r,s=e[Qo(n,i)];if(s&&s(t.state,t.dispatch,t))return!0;if(n.length==1&&n!=" "){if(i.shiftKey){let l=e[Qo(n,i,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((i.altKey||i.metaKey||i.ctrlKey)&&!(Ym&&i.ctrlKey&&i.altKey)&&(r=Qt[i.keyCode])&&r!=n){let l=e[Qo(r,i)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var eF=Object.defineProperty,Ns=(a,e)=>{for(var t in e)eF(a,t,{get:e[t],enumerable:!0})};function Eo(a){const{state:e,transaction:t}=a;let{selection:i}=t,{doc:n}=t,{storedMarks:r}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return r},get selection(){return i},get doc(){return n},get tr(){return i=t.selection,n=t.doc,r=t.storedMarks,t}}}var xo=class{constructor(a){this.editor=a.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=a.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:a,editor:e,state:t}=this,{view:i}=e,{tr:n}=t,r=this.buildProps(n);return Object.fromEntries(Object.entries(a).map(([s,l])=>[s,(...d)=>{const f=l(...d)(r);return!n.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(n),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(a,e=!0){const{rawCommands:t,editor:i,state:n}=this,{view:r}=i,s=[],l=!!a,u=a||n.tr,d=()=>(!l&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(u),s.every(c=>c===!0)),f={...Object.fromEntries(Object.entries(t).map(([c,g])=>[c,(...h)=>{const m=this.buildProps(u,e),F=g(...h)(m);return s.push(F),f}])),run:d};return f}createCan(a){const{rawCommands:e,state:t}=this,i=!1,n=a||t.tr,r=this.buildProps(n,i);return{...Object.fromEntries(Object.entries(e).map(([l,u])=>[l,(...d)=>u(...d)({...r,dispatch:void 0})])),chain:()=>this.createChain(n,i)}}buildProps(a,e=!0){const{rawCommands:t,editor:i,state:n}=this,{view:r}=i,s={tr:a,editor:i,view:r,state:Eo({state:n,transaction:a}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(a,e),can:()=>this.createCan(a),get commands(){return Object.fromEntries(Object.entries(t).map(([l,u])=>[l,(...d)=>u(...d)(s)]))}};return s}},Hf={};Ns(Hf,{blur:()=>tF,clearContent:()=>aF,clearNodes:()=>iF,command:()=>nF,createParagraphNear:()=>oF,cut:()=>rF,deleteCurrentNode:()=>sF,deleteNode:()=>lF,deleteRange:()=>uF,deleteSelection:()=>dF,enter:()=>fF,exitCode:()=>cF,extendMarkRange:()=>gF,first:()=>_F,focus:()=>mF,forEach:()=>FF,insertContent:()=>pF,insertContentAt:()=>kF,joinBackward:()=>vF,joinDown:()=>DF,joinForward:()=>EF,joinItemBackward:()=>xF,joinItemForward:()=>CF,joinTextblockBackward:()=>BF,joinTextblockForward:()=>SF,joinUp:()=>wF,keyboardShortcut:()=>NF,lift:()=>qF,liftEmptyBlock:()=>AF,liftListItem:()=>TF,newlineInCode:()=>MF,resetAttributes:()=>VF,scrollIntoView:()=>OF,selectAll:()=>LF,selectNodeBackward:()=>zF,selectNodeForward:()=>IF,selectParentNode:()=>PF,selectTextblockEnd:()=>RF,selectTextblockStart:()=>$F,setContent:()=>HF,setMark:()=>rp,setMeta:()=>sp,setNode:()=>lp,setNodeSelection:()=>up,setTextDirection:()=>dp,setTextSelection:()=>fp,sinkListItem:()=>cp,splitBlock:()=>gp,splitListItem:()=>_p,toggleList:()=>hp,toggleMark:()=>mp,toggleNode:()=>Fp,toggleWrap:()=>pp,undoInputRule:()=>bp,unsetAllMarks:()=>yp,unsetMark:()=>kp,unsetTextDirection:()=>wp,updateAttributes:()=>Dp,wrapIn:()=>vp,wrapInList:()=>Ep});var tF=()=>({editor:a,view:e})=>(requestAnimationFrame(()=>{var t;a.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),aF=(a=!0)=>({commands:e})=>e.setContent("",{emitUpdate:a}),iF=()=>({state:a,tr:e,dispatch:t})=>{const{selection:i}=e,{ranges:n}=i;return t&&n.forEach(({$from:r,$to:s})=>{a.doc.nodesBetween(r.pos,s.pos,(l,u)=>{if(l.type.isText)return;const{doc:d,mapping:f}=e,c=d.resolve(f.map(u)),g=d.resolve(f.map(u+l.nodeSize)),_=c.blockRange(g);if(!_)return;const h=Xa(_);if(l.type.isTextblock){const{defaultType:m}=c.parent.contentMatchAt(c.index());e.setNodeMarkup(_.start,m)}(h||h===0)&&e.lift(_,h)})}),!0},nF=a=>e=>a(e),oF=()=>({state:a,dispatch:e})=>of(a,e),rF=(a,e)=>({editor:t,tr:i})=>{const{state:n}=t,r=n.doc.slice(a.from,a.to);i.deleteRange(a.from,a.to);const s=i.mapping.map(e);return i.insert(s,r.content),i.setSelection(new H(i.doc.resolve(Math.max(s-1,0)))),!0},sF=()=>({tr:a,dispatch:e})=>{const{selection:t}=a,i=t.$anchor.node();if(i.content.size>0)return!1;const n=a.selection.$anchor;for(let r=n.depth;r>0;r-=1)if(n.node(r).type===i.type){if(e){const l=n.before(r),u=n.after(r);a.delete(l,u).scrollIntoView()}return!0}return!1};function ce(a,e){if(typeof a=="string"){if(!e.nodes[a])throw Error(`There is no node type named '${a}'. Maybe you forgot to add the extension?`);return e.nodes[a]}return a}var lF=a=>({tr:e,state:t,dispatch:i})=>{const n=ce(a,t.schema),r=e.selection.$anchor;for(let s=r.depth;s>0;s-=1)if(r.node(s).type===n){if(i){const u=r.before(s),d=r.after(s);e.delete(u,d).scrollIntoView()}return!0}return!1},uF=a=>({tr:e,dispatch:t})=>{const{from:i,to:n}=a;return t&&e.delete(i,n),!0},dF=()=>({state:a,dispatch:e})=>ms(a,e),fF=()=>({commands:a})=>a.keyboardShortcut("Enter"),cF=()=>({state:a,dispatch:e})=>G1(a,e);function qs(a){return Object.prototype.toString.call(a)==="[object RegExp]"}function Tn(a,e,t={strict:!0}){const i=Object.keys(e);return i.length?i.every(n=>t.strict?e[n]===a[n]:qs(e[n])?e[n].test(a[n]):e[n]===a[n]):!0}function Wf(a,e,t={}){return a.find(i=>i.type===e&&Tn(Object.fromEntries(Object.keys(t).map(n=>[n,i.attrs[n]])),t))}function pu(a,e,t={}){return!!Wf(a,e,t)}function As(a,e,t){var i;if(!a||!e)return;let n=a.parent.childAfter(a.parentOffset);if((!n.node||!n.node.marks.some(f=>f.type===e))&&(n=a.parent.childBefore(a.parentOffset)),!n.node||!n.node.marks.some(f=>f.type===e)||(t=t||((i=n.node.marks[0])==null?void 0:i.attrs),!Wf([...n.node.marks],e,t)))return;let s=n.index,l=a.start()+n.offset,u=s+1,d=l+n.node.nodeSize;for(;s>0&&pu([...a.parent.child(s-1).marks],e,t);)s-=1,l-=a.parent.child(s).nodeSize;for(;u<a.parent.childCount&&pu([...a.parent.child(u).marks],e,t);)d+=a.parent.child(u).nodeSize,u+=1;return{from:l,to:d}}function Nt(a,e){if(typeof a=="string"){if(!e.marks[a])throw Error(`There is no mark type named '${a}'. Maybe you forgot to add the extension?`);return e.marks[a]}return a}var gF=(a,e={})=>({tr:t,state:i,dispatch:n})=>{const r=Nt(a,i.schema),{doc:s,selection:l}=t,{$from:u,from:d,to:f}=l;if(n){const c=As(u,r,e);if(c&&c.from<=d&&c.to>=f){const g=H.create(s,c.from,c.to);t.setSelection(g)}}return!0},_F=a=>e=>{const t=typeof a=="function"?a(e):a;for(let i=0;i<t.length;i+=1)if(t[i](e))return!0;return!1};function Ts(a){return a instanceof H}function Bt(a=0,e=0,t=0){return Math.min(Math.max(a,e),t)}function Uf(a,e=null){if(!e)return null;const t=J.atStart(a),i=J.atEnd(a);if(e==="start"||e===!0)return t;if(e==="end")return i;const n=t.from,r=i.to;return e==="all"?H.create(a,Bt(0,n,r),Bt(a.content.size,n,r)):H.create(a,Bt(e,n,r),Bt(e,n,r))}function Vr(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ai(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function hF(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var mF=(a=null,e={})=>({editor:t,view:i,tr:n,dispatch:r})=>{e={scrollIntoView:!0,...e};const s=()=>{(Ai()||Vr())&&i.dom.focus(),hF()&&!Ai()&&!Vr()&&i.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(i.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};try{if(i.hasFocus()&&a===null||a===!1)return!0}catch{return!1}if(r&&a===null&&!Ts(t.state.selection))return s(),!0;const l=Uf(n.doc,a)||t.state.selection,u=t.state.selection.eq(l);return r&&(u||n.setSelection(l),u&&n.storedMarks&&n.setStoredMarks(n.storedMarks),s()),!0},FF=(a,e)=>t=>a.every((i,n)=>e(i,{...t,index:n})),pF=(a,e)=>({tr:t,commands:i})=>i.insertContentAt({from:t.selection.from,to:t.selection.to},a,e),Kf=a=>{const e=a.childNodes;for(let t=e.length-1;t>=0;t-=1){const i=e[t];i.nodeType===3&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)?a.removeChild(i):i.nodeType===1&&Kf(i)}return a};function Gi(a){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${a}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Kf(t)}function Ti(a,e,t){if(a instanceof Kt||a instanceof V)return a;t={slice:!0,parseOptions:{},...t};const i=typeof a=="object"&&a!==null,n=typeof a=="string";if(i)try{if(Array.isArray(a)&&a.length>0)return V.fromArray(a.map(l=>e.nodeFromJSON(l)));const s=e.nodeFromJSON(a);return t.errorOnInvalidContent&&s.check(),s}catch(r){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",a,"Error:",r),Ti("",e,t)}if(n){if(t.errorOnInvalidContent){let s=!1,l="";const u=new Bd({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(s=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?Jt.fromSchema(u).parseSlice(Gi(a),t.parseOptions):Jt.fromSchema(u).parse(Gi(a),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const r=Jt.fromSchema(e);return t.slice?r.parseSlice(Gi(a),t.parseOptions).content:r.parse(Gi(a),t.parseOptions)}return Ti("",e,t)}function bF(a,e,t){const i=a.steps.length-1;if(i<e)return;const n=a.steps[i];if(!(n instanceof at||n instanceof He))return;const r=a.mapping.maps[i];let s=0;r.forEach((l,u,d,f)=>{s===0&&(s=f)}),a.setSelection(J.near(a.doc.resolve(s),t))}var yF=a=>!("type"in a),kF=(a,e,t)=>({tr:i,dispatch:n,editor:r})=>{var s;if(n){t={parseOptions:r.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const u=F=>{r.emit("contentError",{editor:r,error:F,disableCollaboration:()=>{"collaboration"in r.storage&&typeof r.storage.collaboration=="object"&&r.storage.collaboration&&(r.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!r.options.enableContentCheck&&r.options.emitContentError)try{Ti(e,r.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(F){u(F)}try{l=Ti(e,r.schema,{parseOptions:d,errorOnInvalidContent:(s=t.errorOnInvalidContent)!=null?s:r.options.enableContentCheck})}catch(F){return u(F),!1}let{from:f,to:c}=typeof a=="number"?{from:a,to:a}:{from:a.from,to:a.to},g=!0,_=!0;if((yF(l)?l:[l]).forEach(F=>{F.check(),g=g?F.isText&&F.marks.length===0:!1,_=_?F.isBlock:!1}),f===c&&_){const{parent:F}=i.doc.resolve(f);F.isTextblock&&!F.type.spec.code&&!F.childCount&&(f-=1,c+=1)}let m;if(g){if(Array.isArray(e))m=e.map(F=>F.text||"").join("");else if(e instanceof V){let F="";e.forEach(p=>{p.text&&(F+=p.text)}),m=F}else typeof e=="object"&&e&&e.text?m=e.text:m=e;i.insertText(m,f,c)}else{m=l;const F=i.doc.resolve(f),p=F.node(),b=F.parentOffset===0,y=p.isText||p.isTextblock,k=p.content.size>0;b&&y&&k&&(f=Math.max(0,f-1)),i.replaceWith(f,c,m)}t.updateSelection&&bF(i,i.steps.length-1,-1),t.applyInputRules&&i.setMeta("applyInputRules",{from:f,text:m}),t.applyPasteRules&&i.setMeta("applyPasteRules",{from:f,text:m})}return!0},wF=()=>({state:a,dispatch:e})=>U1(a,e),DF=()=>({state:a,dispatch:e})=>K1(a,e),vF=()=>({state:a,dispatch:e})=>Xd(a,e),EF=()=>({state:a,dispatch:e})=>tf(a,e),xF=()=>({state:a,dispatch:e,tr:t})=>{try{const i=bo(a.doc,a.selection.$from.pos,-1);return i==null?!1:(t.join(i,2),e&&e(t),!0)}catch{return!1}},CF=()=>({state:a,dispatch:e,tr:t})=>{try{const i=bo(a.doc,a.selection.$from.pos,1);return i==null?!1:(t.join(i,2),e&&e(t),!0)}catch{return!1}},BF=()=>({state:a,dispatch:e})=>H1(a,e),SF=()=>({state:a,dispatch:e})=>W1(a,e);function Jf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function jF(a){const e=a.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let i,n,r,s;for(let l=0;l<e.length-1;l+=1){const u=e[l];if(/^(cmd|meta|m)$/i.test(u))s=!0;else if(/^a(lt)?$/i.test(u))i=!0;else if(/^(c|ctrl|control)$/i.test(u))n=!0;else if(/^s(hift)?$/i.test(u))r=!0;else if(/^mod$/i.test(u))Ai()||Jf()?s=!0:n=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return i&&(t=`Alt-${t}`),n&&(t=`Ctrl-${t}`),s&&(t=`Meta-${t}`),r&&(t=`Shift-${t}`),t}var NF=a=>({editor:e,view:t,tr:i,dispatch:n})=>{const r=jF(a).split(/-(?!$)/),s=r.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:r.includes("Alt"),ctrlKey:r.includes("Ctrl"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,l))});return u?.steps.forEach(d=>{const f=d.map(i.mapping);f&&n&&i.maybeStep(f)}),!0};function Zt(a,e,t={}){const{from:i,to:n,empty:r}=a.selection,s=e?ce(e,a.schema):null,l=[];a.doc.nodesBetween(i,n,(c,g)=>{if(c.isText)return;const _=Math.max(i,g),h=Math.min(n,g+c.nodeSize);l.push({node:c,from:_,to:h})});const u=n-i,d=l.filter(c=>s?s.name===c.node.type.name:!0).filter(c=>Tn(c.node.attrs,t,{strict:!1}));return r?!!d.length:d.reduce((c,g)=>c+g.to-g.from,0)>=u}var qF=(a,e={})=>({state:t,dispatch:i})=>{const n=ce(a,t.schema);return Zt(t,n,e)?J1(t,i):!1},AF=()=>({state:a,dispatch:e})=>rf(a,e),TF=a=>({state:e,dispatch:t})=>{const i=ce(a,e.schema);return rh(i)(e,t)},MF=()=>({state:a,dispatch:e})=>nf(a,e);function Co(a,e){return e.nodes[a]?"node":e.marks[a]?"mark":null}function bu(a,e){const t=typeof e=="string"?[e]:e;return Object.keys(a).reduce((i,n)=>(t.includes(n)||(i[n]=a[n]),i),{})}var VF=(a,e)=>({tr:t,state:i,dispatch:n})=>{let r=null,s=null;const l=Co(typeof a=="string"?a:a.name,i.schema);if(!l)return!1;l==="node"&&(r=ce(a,i.schema)),l==="mark"&&(s=Nt(a,i.schema));let u=!1;return t.selection.ranges.forEach(d=>{i.doc.nodesBetween(d.$from.pos,d.$to.pos,(f,c)=>{r&&r===f.type&&(u=!0,n&&t.setNodeMarkup(c,void 0,bu(f.attrs,e))),s&&f.marks.length&&f.marks.forEach(g=>{s===g.type&&(u=!0,n&&t.addMark(c,c+f.nodeSize,s.create(bu(g.attrs,e))))})})}),u},OF=()=>({tr:a,dispatch:e})=>(e&&a.scrollIntoView(),!0),LF=()=>({tr:a,dispatch:e})=>{if(e){const t=new Ue(a.doc);a.setSelection(t)}return!0},zF=()=>({state:a,dispatch:e})=>Zd(a,e),IF=()=>({state:a,dispatch:e})=>af(a,e),PF=()=>({state:a,dispatch:e})=>Q1(a,e),RF=()=>({state:a,dispatch:e})=>th(a,e),$F=()=>({state:a,dispatch:e})=>eh(a,e);function Or(a,e,t={},i={}){return Ti(a,e,{slice:!1,parseOptions:t,errorOnInvalidContent:i.errorOnInvalidContent})}var HF=(a,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:i={}}={})=>({editor:n,tr:r,dispatch:s,commands:l})=>{const{doc:u}=r;if(i.preserveWhitespace!=="full"){const d=Or(a,n.schema,i,{errorOnInvalidContent:e??n.options.enableContentCheck});return s&&r.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!t),!0}return s&&r.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:u.content.size},a,{parseOptions:i,errorOnInvalidContent:e??n.options.enableContentCheck})};function Gf(a,e){const t=Nt(e,a.schema),{from:i,to:n,empty:r}=a.selection,s=[];r?(a.storedMarks&&s.push(...a.storedMarks),s.push(...a.selection.$head.marks())):a.doc.nodesBetween(i,n,u=>{s.push(...u.marks)});const l=s.find(u=>u.type.name===t.name);return l?{...l.attrs}:{}}function Ms(a,e){const t=new Ud(a);return e.forEach(i=>{i.steps.forEach(n=>{t.step(n)})}),t}function Vs(a){for(let e=0;e<a.edgeCount;e+=1){const{type:t}=a.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function mi(a,e){const t=[];return a.descendants((i,n)=>{e(i)&&t.push({node:i,pos:n})}),t}function Yf(a,e,t){const i=[];return a.nodesBetween(e.from,e.to,(n,r)=>{t(n)&&i.push({node:n,pos:r})}),i}function WF(a,e){for(let t=a.depth;t>0;t-=1){const i=a.node(t);if(e(i))return{pos:t>0?a.before(t):0,start:a.start(t),depth:t,node:i}}}function Ca(a){return e=>WF(e.$from,a)}function K(a,e,t){return a.config[e]===void 0&&a.parent?K(a.parent,e,t):typeof a.config[e]=="function"?a.config[e].bind({...t,parent:a.parent?K(a.parent,e,t):null}):a.config[e]}function Os(a){return a.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},i=K(e,"addExtensions",t);return i?[e,...Os(i())]:e}).flat(10)}function Ls(a,e){const t=xa.fromSchema(e).serializeFragment(a),n=document.implementation.createHTMLDocument().createElement("div");return n.appendChild(t),n.innerHTML}function Xf(a){return typeof a=="function"}function ee(a,e=void 0,...t){return Xf(a)?e?a.bind(e)(...t):a(...t):a}function UF(a={}){return Object.keys(a).length===0&&a.constructor===Object}function Ha(a){const e=a.filter(n=>n.type==="extension"),t=a.filter(n=>n.type==="node"),i=a.filter(n=>n.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:i}}function Qf(a){const e=[],{nodeExtensions:t,markExtensions:i}=Ha(a),n=[...t,...i],r={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=t.filter(d=>d.name!=="text").map(d=>d.name),l=i.map(d=>d.name),u=[...s,...l];return a.forEach(d=>{const f={name:d.name,options:d.options,storage:d.storage,extensions:n},c=K(d,"addGlobalAttributes",f);if(!c)return;c().forEach(_=>{let h;Array.isArray(_.types)?h=_.types:_.types==="*"?h=u:_.types==="nodes"?h=s:_.types==="marks"?h=l:h=[],h.forEach(m=>{Object.entries(_.attributes).forEach(([F,p])=>{e.push({type:m,name:F,attribute:{...r,...p}})})})})}),n.forEach(d=>{const f={name:d.name,options:d.options,storage:d.storage},c=K(d,"addAttributes",f);if(!c)return;const g=c();Object.entries(g).forEach(([_,h])=>{const m={...r,...h};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:d.name,name:_,attribute:m})})}),e}function Y(...a){return a.filter(e=>!!e).reduce((e,t)=>{const i={...e};return Object.entries(t).forEach(([n,r])=>{if(!i[n]){i[n]=r;return}if(n==="class"){const l=r?String(r).split(" "):[],u=i[n]?i[n].split(" "):[],d=l.filter(f=>!u.includes(f));i[n]=[...u,...d].join(" ")}else if(n==="style"){const l=r?r.split(";").map(f=>f.trim()).filter(Boolean):[],u=i[n]?i[n].split(";").map(f=>f.trim()).filter(Boolean):[],d=new Map;u.forEach(f=>{const[c,g]=f.split(":").map(_=>_.trim());d.set(c,g)}),l.forEach(f=>{const[c,g]=f.split(":").map(_=>_.trim());d.set(c,g)}),i[n]=Array.from(d.entries()).map(([f,c])=>`${f}: ${c}`).join("; ")}else i[n]=r}),i},{})}function Mi(a,e){return e.filter(t=>t.type===a.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(a.attrs)||{}:{[t.name]:a.attrs[t.name]}).reduce((t,i)=>Y(t,i),{})}function KF(a){return typeof a!="string"?a:a.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(a):a==="true"?!0:a==="false"?!1:a}function yu(a,e){return"style"in a?a:{...a,getAttrs:t=>{const i=a.getAttrs?a.getAttrs(t):a.attrs;if(i===!1)return!1;const n=e.reduce((r,s)=>{const l=s.attribute.parseHTML?s.attribute.parseHTML(t):KF(t.getAttribute(s.name));return l==null?r:{...r,[s.name]:l}},{});return{...i,...n}}}}function ku(a){return Object.fromEntries(Object.entries(a).filter(([e,t])=>e==="attrs"&&UF(t)?!1:t!=null))}function wu(a){var e,t;const i={};return!((e=a?.attribute)!=null&&e.isRequired)&&"default"in(a?.attribute||{})&&(i.default=a.attribute.default),((t=a?.attribute)==null?void 0:t.validate)!==void 0&&(i.validate=a.attribute.validate),[a.name,i]}function JF(a,e){var t;const i=Qf(a),{nodeExtensions:n,markExtensions:r}=Ha(a),s=(t=n.find(d=>K(d,"topNode")))==null?void 0:t.name,l=Object.fromEntries(n.map(d=>{const f=i.filter(p=>p.type===d.name),c={name:d.name,options:d.options,storage:d.storage,editor:e},g=a.reduce((p,b)=>{const y=K(b,"extendNodeSchema",c);return{...p,...y?y(d):{}}},{}),_=ku({...g,content:ee(K(d,"content",c)),marks:ee(K(d,"marks",c)),group:ee(K(d,"group",c)),inline:ee(K(d,"inline",c)),atom:ee(K(d,"atom",c)),selectable:ee(K(d,"selectable",c)),draggable:ee(K(d,"draggable",c)),code:ee(K(d,"code",c)),whitespace:ee(K(d,"whitespace",c)),linebreakReplacement:ee(K(d,"linebreakReplacement",c)),defining:ee(K(d,"defining",c)),isolating:ee(K(d,"isolating",c)),attrs:Object.fromEntries(f.map(wu))}),h=ee(K(d,"parseHTML",c));h&&(_.parseDOM=h.map(p=>yu(p,f)));const m=K(d,"renderHTML",c);m&&(_.toDOM=p=>m({node:p,HTMLAttributes:Mi(p,f)}));const F=K(d,"renderText",c);return F&&(_.toText=F),[d.name,_]})),u=Object.fromEntries(r.map(d=>{const f=i.filter(F=>F.type===d.name),c={name:d.name,options:d.options,storage:d.storage,editor:e},g=a.reduce((F,p)=>{const b=K(p,"extendMarkSchema",c);return{...F,...b?b(d):{}}},{}),_=ku({...g,inclusive:ee(K(d,"inclusive",c)),excludes:ee(K(d,"excludes",c)),group:ee(K(d,"group",c)),spanning:ee(K(d,"spanning",c)),code:ee(K(d,"code",c)),attrs:Object.fromEntries(f.map(wu))}),h=ee(K(d,"parseHTML",c));h&&(_.parseDOM=h.map(F=>yu(F,f)));const m=K(d,"renderHTML",c);return m&&(_.toDOM=F=>m({mark:F,HTMLAttributes:Mi(F,f)})),[d.name,_]}));return new Bd({topNode:s,nodes:l,marks:u})}function GF(a){const e=a.filter((t,i)=>a.indexOf(t)!==i);return Array.from(new Set(e))}function Fi(a){return a.sort((t,i)=>{const n=K(t,"priority")||100,r=K(i,"priority")||100;return n>r?-1:n<r?1:0})}function Zf(a){const e=Fi(Os(a)),t=GF(e.map(i=>i.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),e}function ec(a,e,t){const{from:i,to:n}=e,{blockSeparator:r=`
|
|
10
|
+
`))),0,0),a.someProp("transformPasted",g=>{l=g(l,a,!0)}),l;let c=a.someProp("clipboardTextParser",g=>g(e,n,i,a));if(c)l=c;else{let g=n.marks(),{schema:_}=a.state,h=xa.fromSchema(_);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let F=s.appendChild(document.createElement("p"));m&&F.appendChild(h.serializeNode(_.text(m,g)))})}}else a.someProp("transformPastedHTML",c=>{t=c(t,a)}),s=tm(t),Ri&&am(s);let d=s&&s.querySelector("[data-pm-slice]"),f=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let c=+f[3];c>0;c--){let g=s.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;s=g}if(l||(l=(a.someProp("clipboardParser")||a.someProp("domParser")||Jt.fromSchema(a.state.schema)).parseSlice(s,{preserveWhitespace:!!(u||f),context:n,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!Qh.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)l=im(ou(l,+f[1],+f[2]),f[4]);else if(l=P.maxOpen(Zh(l.content,n),!0),l.openStart||l.openEnd){let c=0,g=0;for(let _=l.content.firstChild;c<l.openStart&&!_.type.spec.isolating;c++,_=_.firstChild);for(let _=l.content.lastChild;g<l.openEnd&&!_.type.spec.isolating;g++,_=_.lastChild);l=ou(l,c,g)}return a.someProp("transformPasted",c=>{l=c(l,a,u)}),l}const Qh=/^(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 Zh(a,e){if(a.childCount<2)return a;for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.index(t)),r,s=[];if(a.forEach(l=>{if(!s)return;let u=n.findWrapping(l.type),d;if(!u)return s=null;if(d=s.length&&r.length&&Sf(u,r,l,s[s.length-1],0))s[s.length-1]=d;else{s.length&&(s[s.length-1]=jf(s[s.length-1],r.length));let f=Bf(l,u);s.push(f),n=n.matchType(f.type),r=u}}),s)return V.from(s)}return a}function Bf(a,e,t=0){for(let i=e.length-1;i>=t;i--)a=e[i].create(null,V.from(a));return a}function Sf(a,e,t,i,n){if(n<a.length&&n<e.length&&a[n]==e[n]){let r=Sf(a,e,t,i.lastChild,n+1);if(r)return i.copy(i.content.replaceChild(i.childCount-1,r));if(i.contentMatchAt(i.childCount).matchType(n==a.length-1?t.type:a[n+1]))return i.copy(i.content.append(V.from(Bf(t,a,n+1))))}}function jf(a,e){if(e==0)return a;let t=a.content.replaceChild(a.childCount-1,jf(a.lastChild,e-1)),i=a.contentMatchAt(a.childCount).fillBefore(V.empty,!0);return a.copy(t.append(i))}function Tr(a,e,t,i,n,r){let s=e<0?a.firstChild:a.lastChild,l=s.content;return a.childCount>1&&(r=0),n<i-1&&(l=Tr(l,e,t,i,n+1,r)),n>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,r<=n).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(V.empty,!0))),a.replaceChild(e<0?0:a.childCount-1,s.copy(l))}function ou(a,e,t){return e<a.openStart&&(a=new P(Tr(a.content,-1,e,a.openStart,0,a.openEnd),e,a.openEnd)),t<a.openEnd&&(a=new P(Tr(a.content,1,t,a.openEnd,0,0),a.openStart,t)),a}const Nf={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 ru=null;function qf(){return ru||(ru=document.implementation.createHTMLDocument("title"))}let Jo=null;function em(a){let e=window.trustedTypes;return e?(Jo||(Jo=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Jo.createHTML(a)):a}function tm(a){let e=/^(\s*<meta [^>]*>)*/.exec(a);e&&(a=a.slice(e[0].length));let t=qf().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(a),n;if((n=i&&Nf[i[1].toLowerCase()])&&(a=n.map(r=>"<"+r+">").join("")+a+n.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=em(a),n)for(let r=0;r<n.length;r++)t=t.querySelector(n[r])||t;return t}function am(a){let e=a.querySelectorAll(De?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent==" "&&i.parentNode&&i.parentNode.replaceChild(a.ownerDocument.createTextNode(" "),i)}}function im(a,e){if(!a.size)return a;let t=a.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return a}let{content:n,openStart:r,openEnd:s}=a;for(let l=i.length-2;l>=0;l-=2){let u=t.nodes[i[l]];if(!u||u.hasRequiredAttrs())break;n=V.from(u.create(i[l+1],n)),r++,s++}return new P(n,r,s)}const Ve={},Oe={},nm={touchstart:!0,touchmove:!0};class om{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function rm(a){for(let e in Ve){let t=Ve[e];a.dom.addEventListener(e,a.input.eventHandlers[e]=i=>{lm(a,i)&&!Es(a,i)&&(a.editable||!(i.type in Oe))&&t(a,i)},nm[e]?{passive:!0}:void 0)}Be&&a.dom.addEventListener("input",()=>null),Mr(a)}function Ut(a,e){a.input.lastSelectionOrigin=e,a.input.lastSelectionTime=Date.now()}function sm(a){a.domObserver.stop();for(let e in a.input.eventHandlers)a.dom.removeEventListener(e,a.input.eventHandlers[e]);clearTimeout(a.input.composingTimeout),clearTimeout(a.input.lastIOSEnterFallbackTimeout)}function Mr(a){a.someProp("handleDOMEvents",e=>{for(let t in e)a.input.eventHandlers[t]||a.dom.addEventListener(t,a.input.eventHandlers[t]=i=>Es(a,i))})}function Es(a,e){return a.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(a,e)||e.defaultPrevented:!1})}function lm(a,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=a.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function um(a,e){!Es(a,e)&&Ve[e.type]&&(a.editable||!(e.type in Oe))&&Ve[e.type](a,e)}Oe.keydown=(a,e)=>{let t=e;if(a.input.shiftKey=t.keyCode==16||t.shiftKey,!Tf(a,t)&&(a.input.lastKeyCode=t.keyCode,a.input.lastKeyCodeTime=Date.now(),!(Ct&&De&&t.keyCode==13)))if(t.keyCode!=229&&a.domObserver.forceFlush(),$a&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();a.input.lastIOSEnter=i,a.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{a.input.lastIOSEnter==i&&(a.someProp("handleKeyDown",n=>n(a,ua(13,"Enter"))),a.input.lastIOSEnter=0)},200)}else a.someProp("handleKeyDown",i=>i(a,t))||Xh(a,t)?t.preventDefault():Ut(a,"key")};Oe.keyup=(a,e)=>{e.keyCode==16&&(a.input.shiftKey=!1)};Oe.keypress=(a,e)=>{let t=e;if(Tf(a,t)||!t.charCode||t.ctrlKey&&!t.altKey||Xe&&t.metaKey)return;if(a.someProp("handleKeyPress",n=>n(a,t))){t.preventDefault();return}let i=a.state.selection;if(!(i instanceof H)||!i.$from.sameParent(i.$to)){let n=String.fromCharCode(t.charCode),r=()=>a.state.tr.insertText(n).scrollIntoView();!/[\r\n]/.test(n)&&!a.someProp("handleTextInput",s=>s(a,i.$from.pos,i.$to.pos,n,r))&&a.dispatch(r()),t.preventDefault()}};function vo(a){return{left:a.clientX,top:a.clientY}}function dm(a,e){let t=e.x-a.clientX,i=e.y-a.clientY;return t*t+i*i<100}function xs(a,e,t,i,n){if(i==-1)return!1;let r=a.state.doc.resolve(i);for(let s=r.depth+1;s>0;s--)if(a.someProp(e,l=>s>r.depth?l(a,t,r.nodeAfter,r.before(s),n,!0):l(a,t,r.node(s),r.before(s),n,!1)))return!0;return!1}function Oa(a,e,t){if(a.focused||a.focus(),a.state.selection.eq(e))return;let i=a.state.tr.setSelection(e);i.setMeta("pointer",!0),a.dispatch(i)}function fm(a,e){if(e==-1)return!1;let t=a.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&$.isSelectable(i)?(Oa(a,new $(t)),!0):!1}function cm(a,e){if(e==-1)return!1;let t=a.state.selection,i,n;t instanceof $&&(i=t.node);let r=a.state.doc.resolve(e);for(let s=r.depth+1;s>0;s--){let l=s>r.depth?r.nodeAfter:r.node(s);if($.isSelectable(l)){i&&t.$from.depth>0&&s>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?n=r.before(t.$from.depth):n=r.before(s);break}}return n!=null?(Oa(a,$.create(a.state.doc,n)),!0):!1}function gm(a,e,t,i,n){return xs(a,"handleClickOn",e,t,i)||a.someProp("handleClick",r=>r(a,e,i))||(n?cm(a,t):fm(a,t))}function _m(a,e,t,i){return xs(a,"handleDoubleClickOn",e,t,i)||a.someProp("handleDoubleClick",n=>n(a,e,i))}function hm(a,e,t,i){return xs(a,"handleTripleClickOn",e,t,i)||a.someProp("handleTripleClick",n=>n(a,e,i))||mm(a,t,i)}function mm(a,e,t){if(t.button!=0)return!1;let i=a.state.doc;if(e==-1)return i.inlineContent?(Oa(a,H.create(i,0,i.content.size)),!0):!1;let n=i.resolve(e);for(let r=n.depth+1;r>0;r--){let s=r>n.depth?n.nodeAfter:n.node(r),l=n.before(r);if(s.inlineContent)Oa(a,H.create(i,l+1,l+1+s.content.size));else if($.isSelectable(s))Oa(a,$.create(i,l));else continue;return!0}}function Cs(a){return jn(a)}const Af=Xe?"metaKey":"ctrlKey";Ve.mousedown=(a,e)=>{let t=e;a.input.shiftKey=t.shiftKey;let i=Cs(a),n=Date.now(),r="singleClick";n-a.input.lastClick.time<500&&dm(t,a.input.lastClick)&&!t[Af]&&a.input.lastClick.button==t.button&&(a.input.lastClick.type=="singleClick"?r="doubleClick":a.input.lastClick.type=="doubleClick"&&(r="tripleClick")),a.input.lastClick={time:n,x:t.clientX,y:t.clientY,type:r,button:t.button};let s=a.posAtCoords(vo(t));s&&(r=="singleClick"?(a.input.mouseDown&&a.input.mouseDown.done(),a.input.mouseDown=new Fm(a,s,t,!!i)):(r=="doubleClick"?_m:hm)(a,s.pos,s.inside,t)?t.preventDefault():Ut(a,"pointer"))};class Fm{constructor(e,t,i,n){this.view=e,this.pos=t,this.event=i,this.flushed=n,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[Af],this.allowDefault=i.shiftKey;let r,s;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),s=t.inside;else{let f=e.state.doc.resolve(t.pos);r=f.parent,s=f.depth?f.before():0}const l=n?null:i.target,u=l?e.docView.nearestDesc(l,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:d}=e.state;i.button==0&&(r.type.spec.draggable&&r.type.spec.selectable!==!1||d instanceof $&&d.from<=s&&d.to>s)&&(this.mightDrag={node:r,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&et&&!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)),Ut(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(()=>jt(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(vo(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ut(this.view,"pointer"):gm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Be&&this.mightDrag&&!this.mightDrag.node.isAtom||De&&!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)?(Oa(this.view,J.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ut(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ut(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)}}Ve.touchstart=a=>{a.input.lastTouch=Date.now(),Cs(a),Ut(a,"pointer")};Ve.touchmove=a=>{a.input.lastTouch=Date.now(),Ut(a,"pointer")};Ve.contextmenu=a=>Cs(a);function Tf(a,e){return a.composing?!0:Be&&Math.abs(e.timeStamp-a.input.compositionEndedAt)<500?(a.input.compositionEndedAt=-2e8,!0):!1}const pm=Ct?5e3:-1;Oe.compositionstart=Oe.compositionupdate=a=>{if(!a.composing){a.domObserver.flush();let{state:e}=a,t=e.selection.$to;if(e.selection instanceof H&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)||De&&ff&&bm(a)))a.markCursor=a.state.storedMarks||t.marks(),jn(a,!0),a.markCursor=null;else if(jn(a,!e.selection.empty),et&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=a.domSelectionRange();for(let n=i.focusNode,r=i.focusOffset;n&&n.nodeType==1&&r!=0;){let s=r<0?n.lastChild:n.childNodes[r-1];if(!s)break;if(s.nodeType==3){let l=a.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else n=s,r=-1}}a.input.composing=!0}Mf(a,pm)};function bm(a){let{focusNode:e,focusOffset:t}=a.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let i=e.childNodes[t];return i.nodeType==1&&i.contentEditable=="false"}Oe.compositionend=(a,e)=>{a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=e.timeStamp,a.input.compositionPendingChanges=a.domObserver.pendingRecords().length?a.input.compositionID:0,a.input.compositionNode=null,a.input.badSafariComposition?a.domObserver.forceFlush():a.input.compositionPendingChanges&&Promise.resolve().then(()=>a.domObserver.flush()),a.input.compositionID++,Mf(a,20))};function Mf(a,e){clearTimeout(a.input.composingTimeout),e>-1&&(a.input.composingTimeout=setTimeout(()=>jn(a),e))}function Vf(a){for(a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=km());a.input.compositionNodes.length>0;)a.input.compositionNodes.pop().markParentsDirty()}function ym(a){let e=a.domSelectionRange();if(!e.focusNode)return null;let t=ch(e.focusNode,e.focusOffset),i=gh(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let n=i.pmViewDesc,r=a.domObserver.lastChangedTextNode;if(t==r||i==r)return r;if(!n||!n.isText(i.nodeValue))return i;if(a.input.compositionNode==i){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return i}}return t||i}function km(){let a=document.createEvent("Event");return a.initEvent("event",!0,!0),a.timeStamp}function jn(a,e=!1){if(!(Ct&&a.domObserver.flushingSoon>=0)){if(a.domObserver.forceFlush(),Vf(a),e||a.docView&&a.docView.dirty){let t=ws(a),i=a.state.selection;return t&&!t.eq(i)?a.dispatch(a.state.tr.setSelection(t)):(a.markCursor||e)&&!i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?a.dispatch(a.state.tr.deleteSelection()):a.updateState(a.state),!0}return!1}}function wm(a,e){if(!a.dom.parentNode)return;let t=a.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),n=document.createRange();n.selectNodeContents(e),a.dom.blur(),i.removeAllRanges(),i.addRange(n),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),a.focus()},50)}const ji=$e&&Gt<15||$a&&Fh<604;Ve.copy=Oe.cut=(a,e)=>{let t=e,i=a.state.selection,n=t.type=="cut";if(i.empty)return;let r=ji?null:t.clipboardData,s=i.content(),{dom:l,text:u}=vs(a,s);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",u)):wm(a,l),n&&a.dispatch(a.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Dm(a){return a.openStart==0&&a.openEnd==0&&a.content.childCount==1?a.content.firstChild:null}function vm(a,e){if(!a.dom.parentNode)return;let t=a.input.shiftKey||a.state.selection.$from.parent.type.spec.code,i=a.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let n=a.input.shiftKey&&a.input.lastKeyCode!=45;setTimeout(()=>{a.focus(),i.parentNode&&i.parentNode.removeChild(i),t?Ni(a,i.value,null,n,e):Ni(a,i.textContent,i.innerHTML,n,e)},50)}function Ni(a,e,t,i,n){let r=Cf(a,e,t,i,a.state.selection.$from);if(a.someProp("handlePaste",u=>u(a,n,r||P.empty)))return!0;if(!r)return!1;let s=Dm(r),l=s?a.state.tr.replaceSelectionWith(s,i):a.state.tr.replaceSelection(r);return a.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Of(a){let e=a.getData("text/plain")||a.getData("Text");if(e)return e;let t=a.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Oe.paste=(a,e)=>{let t=e;if(a.composing&&!Ct)return;let i=ji?null:t.clipboardData,n=a.input.shiftKey&&a.input.lastKeyCode!=45;i&&Ni(a,Of(i),i.getData("text/html"),n,t)?t.preventDefault():vm(a,t)};class Lf{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const Em=Xe?"altKey":"ctrlKey";function zf(a,e){let t;return a.someProp("dragCopies",i=>{t=t||i(e)}),t!=null?!t:!e[Em]}Ve.dragstart=(a,e)=>{let t=e,i=a.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let n=a.state.selection,r=n.empty?null:a.posAtCoords(vo(t)),s;if(!(r&&r.pos>=n.from&&r.pos<=(n instanceof $?n.to-1:n.to))){if(i&&i.mightDrag)s=$.create(a.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let c=a.docView.nearestDesc(t.target,!0);c&&c.node.type.spec.draggable&&c!=a.docView&&(s=$.create(a.state.doc,c.posBefore))}}let l=(s||a.state.selection).content(),{dom:u,text:d,slice:f}=vs(a,l);(!t.dataTransfer.files.length||!De||df>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ji?"Text":"text/html",u.innerHTML),t.dataTransfer.effectAllowed="copyMove",ji||t.dataTransfer.setData("text/plain",d),a.dragging=new Lf(f,zf(a,t),s)};Ve.dragend=a=>{let e=a.dragging;window.setTimeout(()=>{a.dragging==e&&(a.dragging=null)},50)};Oe.dragover=Oe.dragenter=(a,e)=>e.preventDefault();Oe.drop=(a,e)=>{try{xm(a,e,a.dragging)}finally{a.dragging=null}};function xm(a,e,t){if(!e.dataTransfer)return;let i=a.posAtCoords(vo(e));if(!i)return;let n=a.state.doc.resolve(i.pos),r=t&&t.slice;r?a.someProp("transformPasted",_=>{r=_(r,a,!1)}):r=Cf(a,Of(e.dataTransfer),ji?null:e.dataTransfer.getData("text/html"),!1,n);let s=!!(t&&zf(a,e));if(a.someProp("handleDrop",_=>_(a,e,r||P.empty,s))){e.preventDefault();return}if(!r)return;e.preventDefault();let l=r?zd(a.state.doc,n.pos,r):n.pos;l==null&&(l=n.pos);let u=a.state.tr;if(s){let{node:_}=t;_?_.replace(u):u.deleteSelection()}let d=u.mapping.map(l),f=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,c=u.doc;if(f?u.replaceRangeWith(d,d,r.content.firstChild):u.replaceRange(d,d,r),u.doc.eq(c))return;let g=u.doc.resolve(d);if(f&&$.isSelectable(r.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(r.content.firstChild))u.setSelection(new $(g));else{let _=u.mapping.map(l);u.mapping.maps[u.mapping.maps.length-1].forEach((h,m,F,p)=>_=p),u.setSelection(Ds(a,g,u.doc.resolve(_)))}a.focus(),a.dispatch(u.setMeta("uiEvent","drop"))}Ve.focus=a=>{a.input.lastFocus=Date.now(),a.focused||(a.domObserver.stop(),a.dom.classList.add("ProseMirror-focused"),a.domObserver.start(),a.focused=!0,setTimeout(()=>{a.docView&&a.hasFocus()&&!a.domObserver.currentSelection.eq(a.domSelectionRange())&&jt(a)},20))};Ve.blur=(a,e)=>{let t=e;a.focused&&(a.domObserver.stop(),a.dom.classList.remove("ProseMirror-focused"),a.domObserver.start(),t.relatedTarget&&a.dom.contains(t.relatedTarget)&&a.domObserver.currentSelection.clear(),a.focused=!1)};Ve.beforeinput=(a,e)=>{if(De&&Ct&&e.inputType=="deleteContentBackward"){a.domObserver.flushSoon();let{domChangeCount:i}=a.input;setTimeout(()=>{if(a.input.domChangeCount!=i||(a.dom.blur(),a.focus(),a.someProp("handleKeyDown",r=>r(a,ua(8,"Backspace")))))return;let{$cursor:n}=a.state.selection;n&&n.pos>0&&a.dispatch(a.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let a in Oe)Ve[a]=Oe[a];function qi(a,e){if(a==e)return!0;for(let t in a)if(a[t]!==e[t])return!1;for(let t in e)if(!(t in a))return!1;return!0}class Nn{constructor(e,t){this.toDOM=e,this.spec=t||pa,this.side=this.spec.side||0}map(e,t,i,n){let{pos:r,deleted:s}=e.mapResult(t.from+n,this.side<0?-1:1);return s?null:new Me(r-i,r-i,this)}valid(){return!0}eq(e){return this==e||e instanceof Nn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&qi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Xt{constructor(e,t){this.attrs=e,this.spec=t||pa}map(e,t,i,n){let r=e.map(t.from+n,this.spec.inclusiveStart?-1:1)-i,s=e.map(t.to+n,this.spec.inclusiveEnd?1:-1)-i;return r>=s?null:new Me(r,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Xt&&qi(this.attrs,e.attrs)&&qi(this.spec,e.spec)}static is(e){return e.type instanceof Xt}destroy(){}}class Bs{constructor(e,t){this.attrs=e,this.spec=t||pa}map(e,t,i,n){let r=e.mapResult(t.from+n,1);if(r.deleted)return null;let s=e.mapResult(t.to+n,-1);return s.deleted||s.pos<=r.pos?null:new Me(r.pos-i,s.pos-i,this)}valid(e,t){let{index:i,offset:n}=e.content.findIndex(t.from),r;return n==t.from&&!(r=e.child(i)).isText&&n+r.nodeSize==t.to}eq(e){return this==e||e instanceof Bs&&qi(this.attrs,e.attrs)&&qi(this.spec,e.spec)}destroy(){}}class Me{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new Me(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,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new Me(e,e,new Nn(t,i))}static inline(e,t,i,n){return new Me(e,t,new Xt(i,n))}static node(e,t,i,n){return new Me(e,t,new Bs(i,n))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xt}get widget(){return this.type instanceof Nn}}const Ta=[],pa={};class ue{constructor(e,t){this.local=e.length?e:Ta,this.children=t.length?t:Ta}static create(e,t){return t.length?qn(t,e,0,pa):xe}find(e,t,i){let n=[];return this.findInner(e??0,t??1e9,n,0,i),n}findInner(e,t,i,n,r){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&i.push(l.copy(l.from+n,l.to+n))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,i,n+l,r)}}map(e,t,i){return this==xe||e.maps.length==0?this:this.mapInner(e,t,0,0,i||pa)}mapInner(e,t,i,n,r){let s;for(let l=0;l<this.local.length;l++){let u=this.local[l].map(e,i,n);u&&u.type.valid(t,u)?(s||(s=[])).push(u):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?Cm(this.children,s||[],e,t,i,n,r):s?new ue(s.sort(ba),Ta):xe}add(e,t){return t.length?this==xe?ue.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let n,r=0;e.forEach((l,u)=>{let d=u+i,f;if(f=Pf(t,l,d)){for(n||(n=this.children.slice());r<n.length&&n[r]<u;)r+=3;n[r]==u?n[r+2]=n[r+2].addInner(l,f,d+1):n.splice(r,0,u,u+l.nodeSize,qn(f,l,d+1,pa)),r+=3}});let s=If(r?Rf(t):t,-i);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new ue(s.length?this.local.concat(s).sort(ba):this.local,n||this.children)}remove(e){return e.length==0||this==xe?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,n=this.local;for(let r=0;r<i.length;r+=3){let s,l=i[r]+t,u=i[r+1]+t;for(let f=0,c;f<e.length;f++)(c=e[f])&&c.from>l&&c.to<u&&(e[f]=null,(s||(s=[])).push(c));if(!s)continue;i==this.children&&(i=this.children.slice());let d=i[r+2].removeInner(s,l+1);d!=xe?i[r+2]=d:(i.splice(r,3),r-=3)}if(n.length){for(let r=0,s;r<e.length;r++)if(s=e[r])for(let l=0;l<n.length;l++)n[l].eq(s,t)&&(n==this.local&&(n=this.local.slice()),n.splice(l--,1))}return i==this.children&&n==this.local?this:n.length||i.length?new ue(n,i):xe}forChild(e,t){if(this==xe)return this;if(t.isLeaf)return ue.empty;let i,n;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=this.children[l+2]);break}let r=e+1,s=r+t.content.size;for(let l=0;l<this.local.length;l++){let u=this.local[l];if(u.from<s&&u.to>r&&u.type instanceof Xt){let d=Math.max(r,u.from)-r,f=Math.min(s,u.to)-r;d<f&&(n||(n=[])).push(u.copy(d,f))}}if(n){let l=new ue(n.sort(ba),Ta);return i?new Ht([l,i]):l}return i||xe}eq(e){if(this==e)return!0;if(!(e instanceof ue)||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 Ss(this.localsInner(e))}localsInner(e){if(this==xe)return Ta;if(e.inlineContent||!this.local.some(Xt.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof Xt||t.push(this.local[i]);return t}forEachSet(e){e(this)}}ue.empty=new ue([],[]);ue.removeOverlap=Ss;const xe=ue.empty;class Ht{constructor(e){this.members=e}map(e,t){const i=this.members.map(n=>n.map(e,t,pa));return Ht.from(i)}forChild(e,t){if(t.isLeaf)return ue.empty;let i=[];for(let n=0;n<this.members.length;n++){let r=this.members[n].forChild(e,t);r!=xe&&(r instanceof Ht?i=i.concat(r.members):i.push(r))}return Ht.from(i)}eq(e){if(!(e instanceof Ht)||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,i=!0;for(let n=0;n<this.members.length;n++){let r=this.members[n].localsInner(e);if(r.length)if(!t)t=r;else{i&&(t=t.slice(),i=!1);for(let s=0;s<r.length;s++)t.push(r[s])}}return t?Ss(i?t:t.sort(ba)):Ta}static from(e){switch(e.length){case 0:return xe;case 1:return e[0];default:return new Ht(e.every(t=>t instanceof ue)?e:e.reduce((t,i)=>t.concat(i instanceof ue?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Cm(a,e,t,i,n,r,s){let l=a.slice();for(let d=0,f=r;d<t.maps.length;d++){let c=0;t.maps[d].forEach((g,_,h,m)=>{let F=m-h-(_-g);for(let p=0;p<l.length;p+=3){let b=l[p+1];if(b<0||g>b+f-c)continue;let y=l[p]+f-c;_>=y?l[p+1]=g<=y?-2:-1:g>=f&&F&&(l[p]+=F,l[p+1]+=F)}c+=F}),f=t.maps[d].map(f,-1)}let u=!1;for(let d=0;d<l.length;d+=3)if(l[d+1]<0){if(l[d+1]==-2){u=!0,l[d+1]=-1;continue}let f=t.map(a[d]+r),c=f-n;if(c<0||c>=i.content.size){u=!0;continue}let g=t.map(a[d+1]+r,-1),_=g-n,{index:h,offset:m}=i.content.findIndex(c),F=i.maybeChild(h);if(F&&m==c&&m+F.nodeSize==_){let p=l[d+2].mapInner(t,F,f+1,a[d]+r+1,s);p!=xe?(l[d]=c,l[d+1]=_,l[d+2]=p):(l[d+1]=-2,u=!0)}else u=!0}if(u){let d=Bm(l,a,e,t,n,r,s),f=qn(d,i,0,s);e=f.local;for(let c=0;c<l.length;c+=3)l[c+1]<0&&(l.splice(c,3),c-=3);for(let c=0,g=0;c<f.children.length;c+=3){let _=f.children[c];for(;g<l.length&&l[g]<_;)g+=3;l.splice(g,0,f.children[c],f.children[c+1],f.children[c+2])}}return new ue(e.sort(ba),l)}function If(a,e){if(!e||!a.length)return a;let t=[];for(let i=0;i<a.length;i++){let n=a[i];t.push(new Me(n.from+e,n.to+e,n.type))}return t}function Bm(a,e,t,i,n,r,s){function l(u,d){for(let f=0;f<u.local.length;f++){let c=u.local[f].map(i,n,d);c?t.push(c):s.onRemove&&s.onRemove(u.local[f].spec)}for(let f=0;f<u.children.length;f+=3)l(u.children[f+2],u.children[f]+d+1)}for(let u=0;u<a.length;u+=3)a[u+1]==-1&&l(a[u+2],e[u]+r+1);return t}function Pf(a,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,n=null;for(let r=0,s;r<a.length;r++)(s=a[r])&&s.from>t&&s.to<i&&((n||(n=[])).push(s),a[r]=null);return n}function Rf(a){let e=[];for(let t=0;t<a.length;t++)a[t]!=null&&e.push(a[t]);return e}function qn(a,e,t,i){let n=[],r=!1;e.forEach((l,u)=>{let d=Pf(a,l,u+t);if(d){r=!0;let f=qn(d,l,t+u+1,i);f!=xe&&n.push(u,u+l.nodeSize,f)}});let s=If(r?Rf(a):a,-t).sort(ba);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(i.onRemove&&i.onRemove(s[l].spec),s.splice(l--,1));return s.length||n.length?new ue(s,n):xe}function ba(a,e){return a.from-e.from||a.to-e.to}function Ss(a){let e=a;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let n=t+1;n<e.length;n++){let r=e[n];if(r.from==i.from){r.to!=i.to&&(e==a&&(e=a.slice()),e[n]=r.copy(r.from,i.to),su(e,n+1,r.copy(i.to,r.to)));continue}else{r.from<i.to&&(e==a&&(e=a.slice()),e[t]=i.copy(i.from,r.from),su(e,n,i.copy(r.from,i.to)));break}}}return e}function su(a,e,t){for(;e<a.length&&ba(t,a[e])>0;)e++;a.splice(e,0,t)}function Go(a){let e=[];return a.someProp("decorations",t=>{let i=t(a.state);i&&i!=xe&&e.push(i)}),a.cursorWrapper&&e.push(ue.create(a.state.doc,[a.cursorWrapper.deco])),Ht.from(e)}const Sm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jm=$e&&Gt<=11;class Nm{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 qm{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Nm,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let n=0;n<i.length;n++)this.queue.push(i[n]);$e&&Gt<=11&&i.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():Be&&e.composing&&i.some(n=>n.type=="childList"&&n.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),jm&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.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,Sm)),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(Zl(this.view)){if(this.suppressingSelectionUpdates)return jt(this.view);if($e&&Gt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Da(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,i;for(let r=e.focusNode;r;r=Ra(r))t.add(r);for(let r=e.anchorNode;r;r=Ra(r))if(t.has(r)){i=r;break}let n=i&&this.view.docView.nearestDesc(i);if(n&&n.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))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 i=e.domSelectionRange(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&Zl(e)&&!this.ignoreSelectionChange(i),r=-1,s=-1,l=!1,u=[];if(e.editable)for(let f=0;f<t.length;f++){let c=this.registerMutation(t[f],u);c&&(r=r<0?c.from:Math.min(c.from,r),s=s<0?c.to:Math.max(c.to,s),c.typeOver&&(l=!0))}if(u.some(f=>f.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let f of u)if(f.nodeName=="BR"&&f.parentNode){let c=f.nextSibling;for(;c&&c.nodeType==1;){if(c.contentEditable=="false"){f.parentNode.removeChild(f);break}c=c.firstChild}}}else if(et&&u.length){let f=u.filter(c=>c.nodeName=="BR");if(f.length==2){let[c,g]=f;c.parentNode&&c.parentNode.parentNode==g.parentNode?g.remove():c.remove()}else{let{focusNode:c}=this.currentSelection;for(let g of f){let _=g.parentNode;_&&_.nodeName=="LI"&&(!c||Mm(e,c)!=_)&&g.remove()}}}let d=null;r<0&&n&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&wo(i)&&(d=ws(e))&&d.eq(J.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,jt(e),this.currentSelection.set(i),e.scrollToSelection()):(r>-1||n)&&(r>-1&&(e.docView.markDirty(r,s),Am(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Vm(e,u)),this.handleDOMChange(r,s,l,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||jt(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;f<e.addedNodes.length;f++){let c=e.addedNodes[f];t.push(c),c.nodeType==3&&(this.lastChangedTextNode=c)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let n=e.previousSibling,r=e.nextSibling;if($e&&Gt<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:c,nextSibling:g}=e.addedNodes[f];(!c||Array.prototype.indexOf.call(e.addedNodes,c)<0)&&(n=c),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(r=g)}let s=n&&n.parentNode==e.target?ke(n)+1:0,l=i.localPosFromDOM(e.target,s,-1),u=r&&r.parentNode==e.target?ke(r):e.target.childNodes.length,d=i.localPosFromDOM(e.target,u,1);return{from:l,to:d}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let lu=new WeakMap,uu=!1;function Am(a){if(!lu.has(a)&&(lu.set(a,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(a.dom).whiteSpace)!==-1)){if(a.requiresGeckoHackNode=et,uu)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."),uu=!0}}function du(a,e){let t=e.startContainer,i=e.startOffset,n=e.endContainer,r=e.endOffset,s=a.domAtPos(a.state.selection.anchor);return Da(s.node,s.offset,n,r)&&([t,i,n,r]=[n,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}}function Tm(a,e){if(e.getComposedRanges){let n=e.getComposedRanges(a.root)[0];if(n)return du(a,n)}let t;function i(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return a.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),a.dom.removeEventListener("beforeinput",i,!0),t?du(a,t):null}function Mm(a,e){for(let t=e.parentNode;t&&t!=a.dom;t=t.parentNode){let i=a.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function Vm(a,e){var t;let{focusNode:i,focusOffset:n}=a.domSelectionRange();for(let r of e)if(((t=r.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=r.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let u=l.firstChild;if(!u||u.nodeType!=1||u.contentEditable=="false"||/^(BR|IMG)$/.test(u.nodeName))break;l=u}l.insertBefore(r,l.firstChild),i==r&&a.domSelection().collapse(r,n)}else r.parentNode.removeChild(r)}}function Om(a,e,t){let{node:i,fromOffset:n,toOffset:r,from:s,to:l}=a.docView.parseRange(e,t),u=a.domSelectionRange(),d,f=u.anchorNode;if(f&&a.dom.contains(f.nodeType==1?f:f.parentNode)&&(d=[{node:f,offset:u.anchorOffset}],wo(u)||d.push({node:u.focusNode,offset:u.focusOffset})),De&&a.input.lastKeyCode===8)for(let F=r;F>n;F--){let p=i.childNodes[F-1],b=p.pmViewDesc;if(p.nodeName=="BR"&&!b){r=F;break}if(!b||b.size)break}let c=a.state.doc,g=a.someProp("domParser")||Jt.fromSchema(a.state.schema),_=c.resolve(s),h=null,m=g.parse(i,{topNode:_.parent,topMatch:_.parent.contentMatchAt(_.index()),topOpen:!0,from:n,to:r,preserveWhitespace:_.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:Lm,context:_});if(d&&d[0].pos!=null){let F=d[0].pos,p=d[1]&&d[1].pos;p==null&&(p=F),h={anchor:F+s,head:p+s}}return{doc:m,sel:h,from:s,to:l}}function Lm(a){let e=a.pmViewDesc;if(e)return e.parseRule();if(a.nodeName=="BR"&&a.parentNode){if(Be&&/^(ul|ol)$/i.test(a.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(a.parentNode.lastChild==a||Be&&/^(tr|table)$/i.test(a.parentNode.nodeName))return{ignore:!0}}else if(a.nodeName=="IMG"&&a.getAttribute("mark-placeholder"))return{ignore:!0};return null}const zm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Im(a,e,t,i,n){let r=a.input.compositionPendingChanges||(a.composing?a.input.compositionID:0);if(a.input.compositionPendingChanges=0,e<0){let v=a.input.lastSelectionTime>Date.now()-50?a.input.lastSelectionOrigin:null,E=ws(a,v);if(E&&!a.state.selection.eq(E)){if(De&&Ct&&a.input.lastKeyCode===13&&Date.now()-100<a.input.lastKeyCodeTime&&a.someProp("handleKeyDown",N=>N(a,ua(13,"Enter"))))return;let C=a.state.tr.setSelection(E);v=="pointer"?C.setMeta("pointer",!0):v=="key"&&C.scrollIntoView(),r&&C.setMeta("composition",r),a.dispatch(C)}return}let s=a.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=a.state.doc.resolve(t).after(l+1);let u=a.state.selection,d=Om(a,e,t),f=a.state.doc,c=f.slice(d.from,d.to),g,_;a.input.lastKeyCode===8&&Date.now()-100<a.input.lastKeyCodeTime?(g=a.state.selection.to,_="end"):(g=a.state.selection.from,_="start"),a.input.lastKeyCode=null;let h=$m(c.content,d.doc.content,d.from,g,_);if(h&&a.input.domChangeCount++,($a&&a.input.lastIOSEnter>Date.now()-225||Ct)&&n.some(v=>v.nodeType==1&&!zm.test(v.nodeName))&&(!h||h.endA>=h.endB)&&a.someProp("handleKeyDown",v=>v(a,ua(13,"Enter")))){a.input.lastIOSEnter=0;return}if(!h)if(i&&u instanceof H&&!u.empty&&u.$head.sameParent(u.$anchor)&&!a.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))h={start:u.from,endA:u.to,endB:u.to};else{if(d.sel){let v=fu(a,a.state.doc,d.sel);if(v&&!v.eq(a.state.selection)){let E=a.state.tr.setSelection(v);r&&E.setMeta("composition",r),a.dispatch(E)}}return}a.state.selection.from<a.state.selection.to&&h.start==h.endB&&a.state.selection instanceof H&&(h.start>a.state.selection.from&&h.start<=a.state.selection.from+2&&a.state.selection.from>=d.from?h.start=a.state.selection.from:h.endA<a.state.selection.to&&h.endA>=a.state.selection.to-2&&a.state.selection.to<=d.to&&(h.endB+=a.state.selection.to-h.endA,h.endA=a.state.selection.to)),$e&&Gt<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>d.from&&d.doc.textBetween(h.start-d.from-1,h.start-d.from+1)==" "&&(h.start--,h.endA--,h.endB--);let m=d.doc.resolveNoCache(h.start-d.from),F=d.doc.resolveNoCache(h.endB-d.from),p=f.resolve(h.start),b=m.sameParent(F)&&m.parent.inlineContent&&p.end()>=h.endA;if(($a&&a.input.lastIOSEnter>Date.now()-225&&(!b||n.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!b&&m.pos<d.doc.content.size&&(!m.sameParent(F)||!m.parent.inlineContent)&&m.pos<F.pos&&!/\S/.test(d.doc.textBetween(m.pos,F.pos,"","")))&&a.someProp("handleKeyDown",v=>v(a,ua(13,"Enter")))){a.input.lastIOSEnter=0;return}if(a.state.selection.anchor>h.start&&Rm(f,h.start,h.endA,m,F)&&a.someProp("handleKeyDown",v=>v(a,ua(8,"Backspace")))){Ct&&De&&a.domObserver.suppressSelectionUpdates();return}De&&h.endB==h.start&&(a.input.lastChromeDelete=Date.now()),Ct&&!b&&m.start()!=F.start()&&F.parentOffset==0&&m.depth==F.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==h.endA&&(h.endB-=2,F=d.doc.resolveNoCache(h.endB-d.from),setTimeout(()=>{a.someProp("handleKeyDown",function(v){return v(a,ua(13,"Enter"))})},20));let y=h.start,k=h.endA,w=v=>{let E=v||a.state.tr.replace(y,k,d.doc.slice(h.start-d.from,h.endB-d.from));if(d.sel){let C=fu(a,E.doc,d.sel);C&&!(De&&a.composing&&C.empty&&(h.start!=h.endB||a.input.lastChromeDelete<Date.now()-100)&&(C.head==y||C.head==E.mapping.map(k)-1)||$e&&C.empty&&C.head==y)&&E.setSelection(C)}return r&&E.setMeta("composition",r),E.scrollIntoView()},D;if(b)if(m.pos==F.pos){$e&&Gt<=11&&m.parentOffset==0&&(a.domObserver.suppressSelectionUpdates(),setTimeout(()=>jt(a),20));let v=w(a.state.tr.delete(y,k)),E=f.resolve(h.start).marksAcross(f.resolve(h.endA));E&&v.ensureMarks(E),a.dispatch(v)}else if(h.endA==h.endB&&(D=Pm(m.parent.content.cut(m.parentOffset,F.parentOffset),p.parent.content.cut(p.parentOffset,h.endA-p.start())))){let v=w(a.state.tr);D.type=="add"?v.addMark(y,k,D.mark):v.removeMark(y,k,D.mark),a.dispatch(v)}else if(m.parent.child(m.index()).isText&&m.index()==F.index()-(F.textOffset?0:1)){let v=m.parent.textBetween(m.parentOffset,F.parentOffset),E=()=>w(a.state.tr.insertText(v,y,k));a.someProp("handleTextInput",C=>C(a,y,k,v,E))||a.dispatch(E())}else a.dispatch(w());else a.dispatch(w())}function fu(a,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Ds(a,e.resolve(t.anchor),e.resolve(t.head))}function Pm(a,e){let t=a.firstChild.marks,i=e.firstChild.marks,n=t,r=i,s,l,u;for(let f=0;f<i.length;f++)n=i[f].removeFromSet(n);for(let f=0;f<t.length;f++)r=t[f].removeFromSet(r);if(n.length==1&&r.length==0)l=n[0],s="add",u=f=>f.mark(l.addToSet(f.marks));else if(n.length==0&&r.length==1)l=r[0],s="remove",u=f=>f.mark(l.removeFromSet(f.marks));else return null;let d=[];for(let f=0;f<e.childCount;f++)d.push(u(e.child(f)));if(V.from(d).eq(a))return{mark:l,type:s}}function Rm(a,e,t,i,n){if(t-e<=n.pos-i.pos||Yo(i,!0,!1)<n.pos)return!1;let r=a.resolve(e);if(!i.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let s=a.resolve(Yo(r,!0,!0));return!s.parent.isTextblock||s.pos>t||Yo(s,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(s.parent.content)}function Yo(a,e,t){let i=a.depth,n=e?a.end():a.pos;for(;i>0&&(e||a.indexAfter(i)==a.node(i).childCount);)i--,n++,e=!1;if(t){let r=a.node(i).maybeChild(a.indexAfter(i));for(;r&&!r.isLeaf;)r=r.firstChild,n++}return n}function $m(a,e,t,i,n){let r=a.findDiffStart(e,t);if(r==null)return null;let{a:s,b:l}=a.findDiffEnd(e,t+a.size,t+e.size);if(n=="end"){let u=Math.max(0,r-Math.min(s,l));i-=s+u-r}if(s<r&&a.size<e.size){let u=i<=r&&i>=s?r-i:0;r-=u,r&&r<e.size&&cu(e.textBetween(r-1,r+1))&&(r+=u?1:-1),l=r+(l-s),s=r}else if(l<r){let u=i<=r&&i>=l?r-i:0;r-=u,r&&r<a.size&&cu(a.textBetween(r-1,r+1))&&(r+=u?1:-1),s=r+(s-l),l=r}return{start:r,endA:s,endB:l}}function cu(a){if(a.length!=2)return!1;let e=a.charCodeAt(0),t=a.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class $f{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 om,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Fu),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=hu(this),_u(this),this.nodeViews=mu(this),this.docView=Kl(this.state.doc,gu(this),Go(this),this.dom,this),this.domObserver=new qm(this,(i,n,r,s)=>Im(this,i,n,r,s)),this.domObserver.start(),rm(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&&Mr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Fu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let n=this.state,r=!1,s=!1;e.storedMarks&&this.composing&&(Vf(this),s=!0),this.state=e;let l=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let _=mu(this);Wm(_,this.nodeViews)&&(this.nodeViews=_,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Mr(this),this.editable=hu(this),_u(this);let u=Go(this),d=gu(this),f=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?"reset":e.scrollToSelection>n.scrollToSelection?"to selection":"preserve",c=r||!this.docView.matchesNode(e.doc,d,u);(c||!e.selection.eq(n.selection))&&(s=!0);let g=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&yh(this);if(s){this.domObserver.stop();let _=c&&($e||De)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Hm(n.selection,e.selection);if(c){let h=De?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ym(this)),(r||!this.docView.update(e.doc,d,u,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=Kl(e.doc,d,u,this.dom,this)),h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Hh(this))?jt(this,_):(vf(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),!((i=this.dragging)===null||i===void 0)&&i.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&kh(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof $){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Pl(this,t.getBoundingClientRect(),e)}else Pl(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 i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,n=-1;if(i.from<this.state.doc.content.size&&this.state.doc.nodeAt(i.from)==i.node)n=i.from;else{let r=i.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&r<this.state.doc.content.size&&this.state.doc.nodeAt(r))==i.node&&(n=r)}this.dragging=new Lf(e.slice,e.move,n<0?void 0:$.create(this.state.doc,n))}someProp(e,t){let i=this._props&&this._props[e],n;if(i!=null&&(n=t?t(i):i))return n;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(n=t?t(l):l))return n}let r=this.state.plugins;if(r)for(let s=0;s<r.length;s++){let l=r[s].props[e];if(l!=null&&(n=t?t(l):l))return n}}hasFocus(){if($e){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&&wh(this.dom),jt(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 Ch(this,e)}coordsAtPos(e,t=1){return mf(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,i=-1){let n=this.docView.posFromDOM(e,t,i);if(n==null)throw new RangeError("DOM position not inside the editor");return n}endOfTextblock(e,t){return qh(this,t||this.state,e)}pasteHTML(e,t){return Ni(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ni(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return vs(this,e)}destroy(){this.docView&&(sm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Go(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,dh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return um(this,e)}domSelectionRange(){let e=this.domSelection();return e?Be&&this.root.nodeType===11&&hh(this.dom.ownerDocument)==this.dom&&Tm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}$f.prototype.dispatch=function(a){let e=this._props.dispatchTransaction;e?e.call(this,a):this.updateState(this.state.apply(a))};function gu(a){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(a.editable),a.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(a.state)),t)for(let i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[Me.node(0,a.state.doc.content.size,e)]}function _u(a){if(a.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),a.cursorWrapper={dom:e,deco:Me.widget(a.state.selection.from,e,{raw:!0,marks:a.markCursor})}}else a.cursorWrapper=null}function hu(a){return!a.someProp("editable",e=>e(a.state)===!1)}function Hm(a,e){let t=Math.min(a.$anchor.sharedDepth(a.head),e.$anchor.sharedDepth(e.head));return a.$anchor.start(t)!=e.$anchor.start(t)}function mu(a){let e=Object.create(null);function t(i){for(let n in i)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=i[n])}return a.someProp("nodeViews",t),a.someProp("markViews",t),e}function Wm(a,e){let t=0,i=0;for(let n in a){if(a[n]!=e[n])return!0;t++}for(let n in e)i++;return t!=i}function Fu(a){if(a.spec.state||a.spec.filterTransaction||a.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Qt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},An={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Um=typeof navigator<"u"&&/Mac/.test(navigator.platform),Km=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var we=0;we<10;we++)Qt[48+we]=Qt[96+we]=String(we);for(var we=1;we<=24;we++)Qt[we+111]="F"+we;for(var we=65;we<=90;we++)Qt[we]=String.fromCharCode(we+32),An[we]=String.fromCharCode(we);for(var Xo in Qt)An.hasOwnProperty(Xo)||(An[Xo]=Qt[Xo]);function Jm(a){var e=Um&&a.metaKey&&a.shiftKey&&!a.ctrlKey&&!a.altKey||Km&&a.shiftKey&&a.key&&a.key.length==1||a.key=="Unidentified",t=!e&&a.key||(a.shiftKey?An:Qt)[a.keyCode]||a.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Gm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ym=typeof navigator<"u"&&/Win/.test(navigator.platform);function Xm(a){let e=a.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let i,n,r,s;for(let l=0;l<e.length-1;l++){let u=e[l];if(/^(cmd|meta|m)$/i.test(u))s=!0;else if(/^a(lt)?$/i.test(u))i=!0;else if(/^(c|ctrl|control)$/i.test(u))n=!0;else if(/^s(hift)?$/i.test(u))r=!0;else if(/^mod$/i.test(u))Gm?s=!0:n=!0;else throw new Error("Unrecognized modifier name: "+u)}return i&&(t="Alt-"+t),n&&(t="Ctrl-"+t),s&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function Qm(a){let e=Object.create(null);for(let t in a)e[Xm(t)]=a[t];return e}function Qo(a,e,t=!0){return e.altKey&&(a="Alt-"+a),e.ctrlKey&&(a="Ctrl-"+a),e.metaKey&&(a="Meta-"+a),t&&e.shiftKey&&(a="Shift-"+a),a}function Zm(a){return new X({props:{handleKeyDown:js(a)}})}function js(a){let e=Qm(a);return function(t,i){let n=Jm(i),r,s=e[Qo(n,i)];if(s&&s(t.state,t.dispatch,t))return!0;if(n.length==1&&n!=" "){if(i.shiftKey){let l=e[Qo(n,i,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((i.altKey||i.metaKey||i.ctrlKey)&&!(Ym&&i.ctrlKey&&i.altKey)&&(r=Qt[i.keyCode])&&r!=n){let l=e[Qo(r,i)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var eF=Object.defineProperty,Ns=(a,e)=>{for(var t in e)eF(a,t,{get:e[t],enumerable:!0})};function Eo(a){const{state:e,transaction:t}=a;let{selection:i}=t,{doc:n}=t,{storedMarks:r}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return r},get selection(){return i},get doc(){return n},get tr(){return i=t.selection,n=t.doc,r=t.storedMarks,t}}}var xo=class{constructor(a){this.editor=a.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=a.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:a,editor:e,state:t}=this,{view:i}=e,{tr:n}=t,r=this.buildProps(n);return Object.fromEntries(Object.entries(a).map(([s,l])=>[s,(...d)=>{const f=l(...d)(r);return!n.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(n),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(a,e=!0){const{rawCommands:t,editor:i,state:n}=this,{view:r}=i,s=[],l=!!a,u=a||n.tr,d=()=>(!l&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(u),s.every(c=>c===!0)),f={...Object.fromEntries(Object.entries(t).map(([c,g])=>[c,(...h)=>{const m=this.buildProps(u,e),F=g(...h)(m);return s.push(F),f}])),run:d};return f}createCan(a){const{rawCommands:e,state:t}=this,i=!1,n=a||t.tr,r=this.buildProps(n,i);return{...Object.fromEntries(Object.entries(e).map(([l,u])=>[l,(...d)=>u(...d)({...r,dispatch:void 0})])),chain:()=>this.createChain(n,i)}}buildProps(a,e=!0){const{rawCommands:t,editor:i,state:n}=this,{view:r}=i,s={tr:a,editor:i,view:r,state:Eo({state:n,transaction:a}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(a,e),can:()=>this.createCan(a),get commands(){return Object.fromEntries(Object.entries(t).map(([l,u])=>[l,(...d)=>u(...d)(s)]))}};return s}},Hf={};Ns(Hf,{blur:()=>tF,clearContent:()=>aF,clearNodes:()=>iF,command:()=>nF,createParagraphNear:()=>oF,cut:()=>rF,deleteCurrentNode:()=>sF,deleteNode:()=>lF,deleteRange:()=>uF,deleteSelection:()=>dF,enter:()=>fF,exitCode:()=>cF,extendMarkRange:()=>gF,first:()=>_F,focus:()=>mF,forEach:()=>FF,insertContent:()=>pF,insertContentAt:()=>kF,joinBackward:()=>vF,joinDown:()=>DF,joinForward:()=>EF,joinItemBackward:()=>xF,joinItemForward:()=>CF,joinTextblockBackward:()=>BF,joinTextblockForward:()=>SF,joinUp:()=>wF,keyboardShortcut:()=>NF,lift:()=>qF,liftEmptyBlock:()=>AF,liftListItem:()=>TF,newlineInCode:()=>MF,resetAttributes:()=>VF,scrollIntoView:()=>OF,selectAll:()=>LF,selectNodeBackward:()=>zF,selectNodeForward:()=>IF,selectParentNode:()=>PF,selectTextblockEnd:()=>RF,selectTextblockStart:()=>$F,setContent:()=>HF,setMark:()=>rp,setMeta:()=>sp,setNode:()=>lp,setNodeSelection:()=>up,setTextDirection:()=>dp,setTextSelection:()=>fp,sinkListItem:()=>cp,splitBlock:()=>gp,splitListItem:()=>_p,toggleList:()=>hp,toggleMark:()=>mp,toggleNode:()=>Fp,toggleWrap:()=>pp,undoInputRule:()=>bp,unsetAllMarks:()=>yp,unsetMark:()=>kp,unsetTextDirection:()=>wp,updateAttributes:()=>Dp,wrapIn:()=>vp,wrapInList:()=>Ep});var tF=()=>({editor:a,view:e})=>(requestAnimationFrame(()=>{var t;a.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),aF=(a=!0)=>({commands:e})=>e.setContent("",{emitUpdate:a}),iF=()=>({state:a,tr:e,dispatch:t})=>{const{selection:i}=e,{ranges:n}=i;return t&&n.forEach(({$from:r,$to:s})=>{a.doc.nodesBetween(r.pos,s.pos,(l,u)=>{if(l.type.isText)return;const{doc:d,mapping:f}=e,c=d.resolve(f.map(u)),g=d.resolve(f.map(u+l.nodeSize)),_=c.blockRange(g);if(!_)return;const h=Xa(_);if(l.type.isTextblock){const{defaultType:m}=c.parent.contentMatchAt(c.index());e.setNodeMarkup(_.start,m)}(h||h===0)&&e.lift(_,h)})}),!0},nF=a=>e=>a(e),oF=()=>({state:a,dispatch:e})=>of(a,e),rF=(a,e)=>({editor:t,tr:i})=>{const{state:n}=t,r=n.doc.slice(a.from,a.to);i.deleteRange(a.from,a.to);const s=i.mapping.map(e);return i.insert(s,r.content),i.setSelection(new H(i.doc.resolve(Math.max(s-1,0)))),!0},sF=()=>({tr:a,dispatch:e})=>{const{selection:t}=a,i=t.$anchor.node();if(i.content.size>0)return!1;const n=a.selection.$anchor;for(let r=n.depth;r>0;r-=1)if(n.node(r).type===i.type){if(e){const l=n.before(r),u=n.after(r);a.delete(l,u).scrollIntoView()}return!0}return!1};function ce(a,e){if(typeof a=="string"){if(!e.nodes[a])throw Error(`There is no node type named '${a}'. Maybe you forgot to add the extension?`);return e.nodes[a]}return a}var lF=a=>({tr:e,state:t,dispatch:i})=>{const n=ce(a,t.schema),r=e.selection.$anchor;for(let s=r.depth;s>0;s-=1)if(r.node(s).type===n){if(i){const u=r.before(s),d=r.after(s);e.delete(u,d).scrollIntoView()}return!0}return!1},uF=a=>({tr:e,dispatch:t})=>{const{from:i,to:n}=a;return t&&e.delete(i,n),!0},dF=()=>({state:a,dispatch:e})=>ms(a,e),fF=()=>({commands:a})=>a.keyboardShortcut("Enter"),cF=()=>({state:a,dispatch:e})=>G1(a,e);function qs(a){return Object.prototype.toString.call(a)==="[object RegExp]"}function Tn(a,e,t={strict:!0}){const i=Object.keys(e);return i.length?i.every(n=>t.strict?e[n]===a[n]:qs(e[n])?e[n].test(a[n]):e[n]===a[n]):!0}function Wf(a,e,t={}){return a.find(i=>i.type===e&&Tn(Object.fromEntries(Object.keys(t).map(n=>[n,i.attrs[n]])),t))}function pu(a,e,t={}){return!!Wf(a,e,t)}function As(a,e,t){var i;if(!a||!e)return;let n=a.parent.childAfter(a.parentOffset);if((!n.node||!n.node.marks.some(f=>f.type===e))&&(n=a.parent.childBefore(a.parentOffset)),!n.node||!n.node.marks.some(f=>f.type===e)||(t=t||((i=n.node.marks[0])==null?void 0:i.attrs),!Wf([...n.node.marks],e,t)))return;let s=n.index,l=a.start()+n.offset,u=s+1,d=l+n.node.nodeSize;for(;s>0&&pu([...a.parent.child(s-1).marks],e,t);)s-=1,l-=a.parent.child(s).nodeSize;for(;u<a.parent.childCount&&pu([...a.parent.child(u).marks],e,t);)d+=a.parent.child(u).nodeSize,u+=1;return{from:l,to:d}}function Nt(a,e){if(typeof a=="string"){if(!e.marks[a])throw Error(`There is no mark type named '${a}'. Maybe you forgot to add the extension?`);return e.marks[a]}return a}var gF=(a,e={})=>({tr:t,state:i,dispatch:n})=>{const r=Nt(a,i.schema),{doc:s,selection:l}=t,{$from:u,from:d,to:f}=l;if(n){const c=As(u,r,e);if(c&&c.from<=d&&c.to>=f){const g=H.create(s,c.from,c.to);t.setSelection(g)}}return!0},_F=a=>e=>{const t=typeof a=="function"?a(e):a;for(let i=0;i<t.length;i+=1)if(t[i](e))return!0;return!1};function Ts(a){return a instanceof H}function Bt(a=0,e=0,t=0){return Math.min(Math.max(a,e),t)}function Uf(a,e=null){if(!e)return null;const t=J.atStart(a),i=J.atEnd(a);if(e==="start"||e===!0)return t;if(e==="end")return i;const n=t.from,r=i.to;return e==="all"?H.create(a,Bt(0,n,r),Bt(a.content.size,n,r)):H.create(a,Bt(e,n,r),Bt(e,n,r))}function Vr(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ai(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function hF(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var mF=(a=null,e={})=>({editor:t,view:i,tr:n,dispatch:r})=>{e={scrollIntoView:!0,...e};const s=()=>{(Ai()||Vr())&&i.dom.focus(),hF()&&!Ai()&&!Vr()&&i.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(i.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};try{if(i.hasFocus()&&a===null||a===!1)return!0}catch{return!1}if(r&&a===null&&!Ts(t.state.selection))return s(),!0;const l=Uf(n.doc,a)||t.state.selection,u=t.state.selection.eq(l);return r&&(u||n.setSelection(l),u&&n.storedMarks&&n.setStoredMarks(n.storedMarks),s()),!0},FF=(a,e)=>t=>a.every((i,n)=>e(i,{...t,index:n})),pF=(a,e)=>({tr:t,commands:i})=>i.insertContentAt({from:t.selection.from,to:t.selection.to},a,e),Kf=a=>{const e=a.childNodes;for(let t=e.length-1;t>=0;t-=1){const i=e[t];i.nodeType===3&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)?a.removeChild(i):i.nodeType===1&&Kf(i)}return a};function Gi(a){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${a}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Kf(t)}function Ti(a,e,t){if(a instanceof Kt||a instanceof V)return a;t={slice:!0,parseOptions:{},...t};const i=typeof a=="object"&&a!==null,n=typeof a=="string";if(i)try{if(Array.isArray(a)&&a.length>0)return V.fromArray(a.map(l=>e.nodeFromJSON(l)));const s=e.nodeFromJSON(a);return t.errorOnInvalidContent&&s.check(),s}catch(r){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",a,"Error:",r),Ti("",e,t)}if(n){if(t.errorOnInvalidContent){let s=!1,l="";const u=new Bd({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(s=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?Jt.fromSchema(u).parseSlice(Gi(a),t.parseOptions):Jt.fromSchema(u).parse(Gi(a),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const r=Jt.fromSchema(e);return t.slice?r.parseSlice(Gi(a),t.parseOptions).content:r.parse(Gi(a),t.parseOptions)}return Ti("",e,t)}function bF(a,e,t){const i=a.steps.length-1;if(i<e)return;const n=a.steps[i];if(!(n instanceof at||n instanceof He))return;const r=a.mapping.maps[i];let s=0;r.forEach((l,u,d,f)=>{s===0&&(s=f)}),a.setSelection(J.near(a.doc.resolve(s),t))}var yF=a=>!("type"in a),kF=(a,e,t)=>({tr:i,dispatch:n,editor:r})=>{var s;if(n){t={parseOptions:r.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const u=F=>{r.emit("contentError",{editor:r,error:F,disableCollaboration:()=>{"collaboration"in r.storage&&typeof r.storage.collaboration=="object"&&r.storage.collaboration&&(r.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!r.options.enableContentCheck&&r.options.emitContentError)try{Ti(e,r.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(F){u(F)}try{l=Ti(e,r.schema,{parseOptions:d,errorOnInvalidContent:(s=t.errorOnInvalidContent)!=null?s:r.options.enableContentCheck})}catch(F){return u(F),!1}let{from:f,to:c}=typeof a=="number"?{from:a,to:a}:{from:a.from,to:a.to},g=!0,_=!0;if((yF(l)?l:[l]).forEach(F=>{F.check(),g=g?F.isText&&F.marks.length===0:!1,_=_?F.isBlock:!1}),f===c&&_){const{parent:F}=i.doc.resolve(f);F.isTextblock&&!F.type.spec.code&&!F.childCount&&(f-=1,c+=1)}let m;if(g){if(Array.isArray(e))m=e.map(F=>F.text||"").join("");else if(e instanceof V){let F="";e.forEach(p=>{p.text&&(F+=p.text)}),m=F}else typeof e=="object"&&e&&e.text?m=e.text:m=e;i.insertText(m,f,c)}else{m=l;const F=i.doc.resolve(f),p=F.node(),b=F.parentOffset===0,y=p.isText||p.isTextblock,k=p.content.size>0;b&&y&&k&&(f=Math.max(0,f-1)),i.replaceWith(f,c,m)}t.updateSelection&&bF(i,i.steps.length-1,-1),t.applyInputRules&&i.setMeta("applyInputRules",{from:f,text:m}),t.applyPasteRules&&i.setMeta("applyPasteRules",{from:f,text:m})}return!0},wF=()=>({state:a,dispatch:e})=>U1(a,e),DF=()=>({state:a,dispatch:e})=>K1(a,e),vF=()=>({state:a,dispatch:e})=>Xd(a,e),EF=()=>({state:a,dispatch:e})=>tf(a,e),xF=()=>({state:a,dispatch:e,tr:t})=>{try{const i=bo(a.doc,a.selection.$from.pos,-1);return i==null?!1:(t.join(i,2),e&&e(t),!0)}catch{return!1}},CF=()=>({state:a,dispatch:e,tr:t})=>{try{const i=bo(a.doc,a.selection.$from.pos,1);return i==null?!1:(t.join(i,2),e&&e(t),!0)}catch{return!1}},BF=()=>({state:a,dispatch:e})=>H1(a,e),SF=()=>({state:a,dispatch:e})=>W1(a,e);function Jf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function jF(a){const e=a.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let i,n,r,s;for(let l=0;l<e.length-1;l+=1){const u=e[l];if(/^(cmd|meta|m)$/i.test(u))s=!0;else if(/^a(lt)?$/i.test(u))i=!0;else if(/^(c|ctrl|control)$/i.test(u))n=!0;else if(/^s(hift)?$/i.test(u))r=!0;else if(/^mod$/i.test(u))Ai()||Jf()?s=!0:n=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return i&&(t=`Alt-${t}`),n&&(t=`Ctrl-${t}`),s&&(t=`Meta-${t}`),r&&(t=`Shift-${t}`),t}var NF=a=>({editor:e,view:t,tr:i,dispatch:n})=>{const r=jF(a).split(/-(?!$)/),s=r.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:r.includes("Alt"),ctrlKey:r.includes("Ctrl"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,l))});return u?.steps.forEach(d=>{const f=d.map(i.mapping);f&&n&&i.maybeStep(f)}),!0};function Zt(a,e,t={}){const{from:i,to:n,empty:r}=a.selection,s=e?ce(e,a.schema):null,l=[];a.doc.nodesBetween(i,n,(c,g)=>{if(c.isText)return;const _=Math.max(i,g),h=Math.min(n,g+c.nodeSize);l.push({node:c,from:_,to:h})});const u=n-i,d=l.filter(c=>s?s.name===c.node.type.name:!0).filter(c=>Tn(c.node.attrs,t,{strict:!1}));return r?!!d.length:d.reduce((c,g)=>c+g.to-g.from,0)>=u}var qF=(a,e={})=>({state:t,dispatch:i})=>{const n=ce(a,t.schema);return Zt(t,n,e)?J1(t,i):!1},AF=()=>({state:a,dispatch:e})=>rf(a,e),TF=a=>({state:e,dispatch:t})=>{const i=ce(a,e.schema);return rh(i)(e,t)},MF=()=>({state:a,dispatch:e})=>nf(a,e);function Co(a,e){return e.nodes[a]?"node":e.marks[a]?"mark":null}function bu(a,e){const t=typeof e=="string"?[e]:e;return Object.keys(a).reduce((i,n)=>(t.includes(n)||(i[n]=a[n]),i),{})}var VF=(a,e)=>({tr:t,state:i,dispatch:n})=>{let r=null,s=null;const l=Co(typeof a=="string"?a:a.name,i.schema);if(!l)return!1;l==="node"&&(r=ce(a,i.schema)),l==="mark"&&(s=Nt(a,i.schema));let u=!1;return t.selection.ranges.forEach(d=>{i.doc.nodesBetween(d.$from.pos,d.$to.pos,(f,c)=>{r&&r===f.type&&(u=!0,n&&t.setNodeMarkup(c,void 0,bu(f.attrs,e))),s&&f.marks.length&&f.marks.forEach(g=>{s===g.type&&(u=!0,n&&t.addMark(c,c+f.nodeSize,s.create(bu(g.attrs,e))))})})}),u},OF=()=>({tr:a,dispatch:e})=>(e&&a.scrollIntoView(),!0),LF=()=>({tr:a,dispatch:e})=>{if(e){const t=new Ue(a.doc);a.setSelection(t)}return!0},zF=()=>({state:a,dispatch:e})=>Zd(a,e),IF=()=>({state:a,dispatch:e})=>af(a,e),PF=()=>({state:a,dispatch:e})=>Q1(a,e),RF=()=>({state:a,dispatch:e})=>th(a,e),$F=()=>({state:a,dispatch:e})=>eh(a,e);function Or(a,e,t={},i={}){return Ti(a,e,{slice:!1,parseOptions:t,errorOnInvalidContent:i.errorOnInvalidContent})}var HF=(a,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:i={}}={})=>({editor:n,tr:r,dispatch:s,commands:l})=>{const{doc:u}=r;if(i.preserveWhitespace!=="full"){const d=Or(a,n.schema,i,{errorOnInvalidContent:e??n.options.enableContentCheck});return s&&r.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!t),!0}return s&&r.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:u.content.size},a,{parseOptions:i,errorOnInvalidContent:e??n.options.enableContentCheck})};function Gf(a,e){const t=Nt(e,a.schema),{from:i,to:n,empty:r}=a.selection,s=[];r?(a.storedMarks&&s.push(...a.storedMarks),s.push(...a.selection.$head.marks())):a.doc.nodesBetween(i,n,u=>{s.push(...u.marks)});const l=s.find(u=>u.type.name===t.name);return l?{...l.attrs}:{}}function Ms(a,e){const t=new Ud(a);return e.forEach(i=>{i.steps.forEach(n=>{t.step(n)})}),t}function Vs(a){for(let e=0;e<a.edgeCount;e+=1){const{type:t}=a.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function mi(a,e){const t=[];return a.descendants((i,n)=>{e(i)&&t.push({node:i,pos:n})}),t}function Yf(a,e,t){const i=[];return a.nodesBetween(e.from,e.to,(n,r)=>{t(n)&&i.push({node:n,pos:r})}),i}function WF(a,e){for(let t=a.depth;t>0;t-=1){const i=a.node(t);if(e(i))return{pos:t>0?a.before(t):0,start:a.start(t),depth:t,node:i}}}function Ca(a){return e=>WF(e.$from,a)}function K(a,e,t){return a.config[e]===void 0&&a.parent?K(a.parent,e,t):typeof a.config[e]=="function"?a.config[e].bind({...t,parent:a.parent?K(a.parent,e,t):null}):a.config[e]}function Os(a){return a.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},i=K(e,"addExtensions",t);return i?[e,...Os(i())]:e}).flat(10)}function Ls(a,e){const t=xa.fromSchema(e).serializeFragment(a),n=document.implementation.createHTMLDocument().createElement("div");return n.appendChild(t),n.innerHTML}function Xf(a){return typeof a=="function"}function ee(a,e=void 0,...t){return Xf(a)?e?a.bind(e)(...t):a(...t):a}function UF(a={}){return Object.keys(a).length===0&&a.constructor===Object}function Ha(a){const e=a.filter(n=>n.type==="extension"),t=a.filter(n=>n.type==="node"),i=a.filter(n=>n.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:i}}function Qf(a){const e=[],{nodeExtensions:t,markExtensions:i}=Ha(a),n=[...t,...i],r={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=t.filter(d=>d.name!=="text").map(d=>d.name),l=i.map(d=>d.name),u=[...s,...l];return a.forEach(d=>{const f={name:d.name,options:d.options,storage:d.storage,extensions:n},c=K(d,"addGlobalAttributes",f);if(!c)return;c().forEach(_=>{let h;Array.isArray(_.types)?h=_.types:_.types==="*"?h=u:_.types==="nodes"?h=s:_.types==="marks"?h=l:h=[],h.forEach(m=>{Object.entries(_.attributes).forEach(([F,p])=>{e.push({type:m,name:F,attribute:{...r,...p}})})})})}),n.forEach(d=>{const f={name:d.name,options:d.options,storage:d.storage},c=K(d,"addAttributes",f);if(!c)return;const g=c();Object.entries(g).forEach(([_,h])=>{const m={...r,...h};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:d.name,name:_,attribute:m})})}),e}function Y(...a){return a.filter(e=>!!e).reduce((e,t)=>{const i={...e};return Object.entries(t).forEach(([n,r])=>{if(!i[n]){i[n]=r;return}if(n==="class"){const l=r?String(r).split(" "):[],u=i[n]?i[n].split(" "):[],d=l.filter(f=>!u.includes(f));i[n]=[...u,...d].join(" ")}else if(n==="style"){const l=r?r.split(";").map(f=>f.trim()).filter(Boolean):[],u=i[n]?i[n].split(";").map(f=>f.trim()).filter(Boolean):[],d=new Map;u.forEach(f=>{const[c,g]=f.split(":").map(_=>_.trim());d.set(c,g)}),l.forEach(f=>{const[c,g]=f.split(":").map(_=>_.trim());d.set(c,g)}),i[n]=Array.from(d.entries()).map(([f,c])=>`${f}: ${c}`).join("; ")}else i[n]=r}),i},{})}function Mi(a,e){return e.filter(t=>t.type===a.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(a.attrs)||{}:{[t.name]:a.attrs[t.name]}).reduce((t,i)=>Y(t,i),{})}function KF(a){return typeof a!="string"?a:a.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(a):a==="true"?!0:a==="false"?!1:a}function yu(a,e){return"style"in a?a:{...a,getAttrs:t=>{const i=a.getAttrs?a.getAttrs(t):a.attrs;if(i===!1)return!1;const n=e.reduce((r,s)=>{const l=s.attribute.parseHTML?s.attribute.parseHTML(t):KF(t.getAttribute(s.name));return l==null?r:{...r,[s.name]:l}},{});return{...i,...n}}}}function ku(a){return Object.fromEntries(Object.entries(a).filter(([e,t])=>e==="attrs"&&UF(t)?!1:t!=null))}function wu(a){var e,t;const i={};return!((e=a?.attribute)!=null&&e.isRequired)&&"default"in(a?.attribute||{})&&(i.default=a.attribute.default),((t=a?.attribute)==null?void 0:t.validate)!==void 0&&(i.validate=a.attribute.validate),[a.name,i]}function JF(a,e){var t;const i=Qf(a),{nodeExtensions:n,markExtensions:r}=Ha(a),s=(t=n.find(d=>K(d,"topNode")))==null?void 0:t.name,l=Object.fromEntries(n.map(d=>{const f=i.filter(p=>p.type===d.name),c={name:d.name,options:d.options,storage:d.storage,editor:e},g=a.reduce((p,b)=>{const y=K(b,"extendNodeSchema",c);return{...p,...y?y(d):{}}},{}),_=ku({...g,content:ee(K(d,"content",c)),marks:ee(K(d,"marks",c)),group:ee(K(d,"group",c)),inline:ee(K(d,"inline",c)),atom:ee(K(d,"atom",c)),selectable:ee(K(d,"selectable",c)),draggable:ee(K(d,"draggable",c)),code:ee(K(d,"code",c)),whitespace:ee(K(d,"whitespace",c)),linebreakReplacement:ee(K(d,"linebreakReplacement",c)),defining:ee(K(d,"defining",c)),isolating:ee(K(d,"isolating",c)),attrs:Object.fromEntries(f.map(wu))}),h=ee(K(d,"parseHTML",c));h&&(_.parseDOM=h.map(p=>yu(p,f)));const m=K(d,"renderHTML",c);m&&(_.toDOM=p=>m({node:p,HTMLAttributes:Mi(p,f)}));const F=K(d,"renderText",c);return F&&(_.toText=F),[d.name,_]})),u=Object.fromEntries(r.map(d=>{const f=i.filter(F=>F.type===d.name),c={name:d.name,options:d.options,storage:d.storage,editor:e},g=a.reduce((F,p)=>{const b=K(p,"extendMarkSchema",c);return{...F,...b?b(d):{}}},{}),_=ku({...g,inclusive:ee(K(d,"inclusive",c)),excludes:ee(K(d,"excludes",c)),group:ee(K(d,"group",c)),spanning:ee(K(d,"spanning",c)),code:ee(K(d,"code",c)),attrs:Object.fromEntries(f.map(wu))}),h=ee(K(d,"parseHTML",c));h&&(_.parseDOM=h.map(F=>yu(F,f)));const m=K(d,"renderHTML",c);return m&&(_.toDOM=F=>m({mark:F,HTMLAttributes:Mi(F,f)})),[d.name,_]}));return new Bd({topNode:s,nodes:l,marks:u})}function GF(a){const e=a.filter((t,i)=>a.indexOf(t)!==i);return Array.from(new Set(e))}function Fi(a){return a.sort((t,i)=>{const n=K(t,"priority")||100,r=K(i,"priority")||100;return n>r?-1:n<r?1:0})}function Zf(a){const e=Fi(Os(a)),t=GF(e.map(i=>i.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),e}function ec(a,e,t){const{from:i,to:n}=e,{blockSeparator:r=`
|
|
11
11
|
|
|
12
12
|
`,textSerializers:s={}}=t||{};let l="";return a.nodesBetween(i,n,(u,d,f,c)=>{var g;u.isBlock&&d>i&&(l+=r);const _=s?.[u.type.name];if(_)return f&&(l+=_({node:u,pos:d,parent:f,index:c,range:e})),!1;u.isText&&(l+=(g=u?.text)==null?void 0:g.slice(Math.max(i,d)-d,n-d))}),l}function tc(a,e){const t={from:0,to:a.content.size};return ec(a,t,e)}function zs(a){return Object.fromEntries(Object.entries(a.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function YF(a,e){const t=ce(e,a.schema),{from:i,to:n}=a.selection,r=[];a.doc.nodesBetween(i,n,l=>{r.push(l)});const s=r.reverse().find(l=>l.type.name===t.name);return s?{...s.attrs}:{}}function ac(a,e){const t=Co(typeof e=="string"?e:e.name,a.schema);return t==="node"?YF(a,e):t==="mark"?Gf(a,e):{}}function XF(a,e=JSON.stringify){const t={};return a.filter(i=>{const n=e(i);return Object.prototype.hasOwnProperty.call(t,n)?!1:t[n]=!0})}function QF(a){const e=XF(a);return e.length===1?e:e.filter((t,i)=>!e.filter((r,s)=>s!==i).some(r=>t.oldRange.from>=r.oldRange.from&&t.oldRange.to<=r.oldRange.to&&t.newRange.from>=r.newRange.from&&t.newRange.to<=r.newRange.to))}function Is(a){const{mapping:e,steps:t}=a,i=[];return e.maps.forEach((n,r)=>{const s=[];if(n.ranges.length)n.forEach((l,u)=>{s.push({from:l,to:u})});else{const{from:l,to:u}=t[r];if(l===void 0||u===void 0)return;s.push({from:l,to:u})}s.forEach(({from:l,to:u})=>{const d=e.slice(r).map(l,-1),f=e.slice(r).map(u),c=e.invert().map(d,-1),g=e.invert().map(f);i.push({oldRange:{from:c,to:g},newRange:{from:d,to:f}})})}),QF(i)}function Ps(a,e,t){const i=[];return a===e?t.resolve(a).marks().forEach(n=>{const r=t.resolve(a),s=As(r,n.type);s&&i.push({mark:n,...s})}):t.nodesBetween(a,e,(n,r)=>{!n||n?.nodeSize===void 0||i.push(...n.marks.map(s=>({from:r,to:r+n.nodeSize,mark:s})))}),i}var ZF=(a,e,t,i=20)=>{const n=a.doc.resolve(t);let r=i,s=null;for(;r>0&&s===null;){const l=n.node(r);l?.type.name===e?s=l:r-=1}return[s,r]};function ei(a,e){return e.nodes[a]||e.marks[a]||null}function hn(a,e,t){return Object.fromEntries(Object.entries(t).filter(([i])=>{const n=a.find(r=>r.type===e&&r.name===i);return n?n.attribute.keepOnSplit:!1}))}var ep=(a,e=500)=>{let t="";const i=a.parentOffset;return a.parent.nodesBetween(Math.max(0,i-e),i,(n,r,s,l)=>{var u,d;const f=((d=(u=n.type.spec).toText)==null?void 0:d.call(u,{node:n,pos:r,parent:s,index:l}))||n.textContent||"%leaf%";t+=n.isAtom&&!n.isText?f:f.slice(0,Math.max(0,i-r))}),t};function Lr(a,e,t={}){const{empty:i,ranges:n}=a.selection,r=e?Nt(e,a.schema):null;if(i)return!!(a.storedMarks||a.selection.$from.marks()).filter(c=>r?r.name===c.type.name:!0).find(c=>Tn(c.attrs,t,{strict:!1}));let s=0;const l=[];if(n.forEach(({$from:c,$to:g})=>{const _=c.pos,h=g.pos;a.doc.nodesBetween(_,h,(m,F)=>{if(r&&m.inlineContent&&!m.type.allowsMarkType(r))return!1;if(!m.isText&&!m.marks.length)return;const p=Math.max(_,F),b=Math.min(h,F+m.nodeSize),y=b-p;s+=y,l.push(...m.marks.map(k=>({mark:k,from:p,to:b})))})}),s===0)return!1;const u=l.filter(c=>r?r.name===c.mark.type.name:!0).filter(c=>Tn(c.mark.attrs,t,{strict:!1})).reduce((c,g)=>c+g.to-g.from,0),d=l.filter(c=>r?c.mark.type!==r&&c.mark.type.excludes(r):!0).reduce((c,g)=>c+g.to-g.from,0);return(u>0?u+d:u)>=s}function ui(a,e,t={}){if(!e)return Zt(a,null,t)||Lr(a,null,t);const i=Co(e,a.schema);return i==="node"?Zt(a,e,t):i==="mark"?Lr(a,e,t):!1}var tp=(a,e)=>{const{$from:t,$to:i,$anchor:n}=a.selection;if(e){const r=Ca(l=>l.type.name===e)(a.selection);if(!r)return!1;const s=a.doc.resolve(r.pos+1);return n.pos+1===s.end()}return!(i.parentOffset<i.parent.nodeSize-2||t.pos!==i.pos)},ap=a=>{const{$from:e,$to:t}=a.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Du(a,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===a.name):e}function vu(a,e){const{nodeExtensions:t}=Ha(e),i=t.find(s=>s.name===a);if(!i)return!1;const n={name:i.name,options:i.options,storage:i.storage},r=ee(K(i,"group",n));return typeof r!="string"?!1:r.split(" ").includes("list")}function Bo(a,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var i;if(t){if(a.type.name==="hardBreak")return!0;if(a.isText)return/^\s*$/m.test((i=a.text)!=null?i:"")}if(a.isText)return!a.text;if(a.isAtom||a.isLeaf)return!1;if(a.content.childCount===0)return!0;if(e){let n=!0;return a.content.forEach(r=>{n!==!1&&(Bo(r,{ignoreWhitespace:t,checkChildren:e})||(n=!1))}),n}return!1}function ic(a){return a instanceof $}var nc=class oc{constructor(e){this.position=e}static fromJSON(e){return new oc(e.position)}toJSON(){return{position:this.position}}};function ip(a,e){const t=e.mapping.mapResult(a.position);return{position:new nc(t.pos),mapResult:t}}function np(a){return new nc(a)}function Mn(a,e,t){const n=a.state.doc.content.size,r=Bt(e,0,n),s=Bt(t,0,n),l=a.coordsAtPos(r),u=a.coordsAtPos(s,-1),d=Math.min(l.top,u.top),f=Math.max(l.bottom,u.bottom),c=Math.min(l.left,u.left),g=Math.max(l.right,u.right),_=g-c,h=f-d,p={top:d,bottom:f,left:c,right:g,width:_,height:h,x:c,y:d};return{...p,toJSON:()=>p}}function op(a,e,t){var i;const{selection:n}=e;let r=null;if(Ts(n)&&(r=n.$cursor),r){const l=(i=a.storedMarks)!=null?i:r.marks();return r.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(d=>d.type.excludes(t)))}const{ranges:s}=n;return s.some(({$from:l,$to:u})=>{let d=l.depth===0?a.doc.inlineContent&&a.doc.type.allowsMarkType(t):!1;return a.doc.nodesBetween(l.pos,u.pos,(f,c,g)=>{if(d)return!1;if(f.isInline){const _=!g||g.type.allowsMarkType(t),h=!!t.isInSet(f.marks)||!f.marks.some(m=>m.type.excludes(t));d=_&&h}return!d}),d})}var rp=(a,e={})=>({tr:t,state:i,dispatch:n})=>{const{selection:r}=t,{empty:s,ranges:l}=r,u=Nt(a,i.schema);if(n)if(s){const d=Gf(i,u);t.addStoredMark(u.create({...d,...e}))}else l.forEach(d=>{const f=d.$from.pos,c=d.$to.pos;i.doc.nodesBetween(f,c,(g,_)=>{const h=Math.max(_,f),m=Math.min(_+g.nodeSize,c);g.marks.find(p=>p.type===u)?g.marks.forEach(p=>{u===p.type&&t.addMark(h,m,u.create({...p.attrs,...e}))}):t.addMark(h,m,u.create(e))})});return op(i,t,u)},sp=(a,e)=>({tr:t})=>(t.setMeta(a,e),!0),lp=(a,e={})=>({state:t,dispatch:i,chain:n})=>{const r=ce(a,t.schema);let s;return t.selection.$anchor.sameParent(t.selection.$head)&&(s=t.selection.$anchor.parent.attrs),r.isTextblock?n().command(({commands:l})=>Ll(r,{...s,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Ll(r,{...s,...e})(l,i)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},up=a=>({tr:e,dispatch:t})=>{if(t){const{doc:i}=e,n=Bt(a,0,i.content.size),r=$.create(i,n);e.setSelection(r)}return!0},dp=(a,e)=>({tr:t,state:i,dispatch:n})=>{const{selection:r}=i;let s,l;return typeof e=="number"?(s=e,l=e):e&&"from"in e&&"to"in e?(s=e.from,l=e.to):(s=r.from,l=r.to),n&&t.doc.nodesBetween(s,l,(u,d)=>{u.isText||t.setNodeMarkup(d,void 0,{...u.attrs,dir:a})}),!0},fp=a=>({tr:e,dispatch:t})=>{if(t){const{doc:i}=e,{from:n,to:r}=typeof a=="number"?{from:a,to:a}:a,s=H.atStart(i).from,l=H.atEnd(i).to,u=Bt(n,s,l),d=Bt(r,s,l),f=H.create(i,u,d);e.setSelection(f)}return!0},cp=a=>({state:e,dispatch:t})=>{const i=ce(a,e.schema);return uh(i)(e,t)};function Eu(a,e){const t=a.storedMarks||a.selection.$to.parentOffset&&a.selection.$from.marks();if(t){const i=t.filter(n=>e?.includes(n.type.name));a.tr.ensureMarks(i)}}var gp=({keepMarks:a=!0}={})=>({tr:e,state:t,dispatch:i,editor:n})=>{const{selection:r,doc:s}=e,{$from:l,$to:u}=r,d=n.extensionManager.attributes,f=hn(d,l.node().type.name,l.node().attrs);if(r instanceof $&&r.node.isBlock)return!l.parentOffset||!St(s,l.pos)?!1:(i&&(a&&Eu(t,n.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const c=u.parentOffset===u.parent.content.size,g=l.depth===0?void 0:Vs(l.node(-1).contentMatchAt(l.indexAfter(-1)));let _=c&&g?[{type:g,attrs:f}]:void 0,h=St(e.doc,e.mapping.map(l.pos),1,_);if(!_&&!h&&St(e.doc,e.mapping.map(l.pos),1,g?[{type:g}]:void 0)&&(h=!0,_=g?[{type:g,attrs:f}]:void 0),i){if(h&&(r instanceof H&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,_),g&&!c&&!l.parentOffset&&l.parent.type!==g)){const m=e.mapping.map(l.before()),F=e.doc.resolve(m);l.node(-1).canReplaceWith(F.index(),F.index()+1,g)&&e.setNodeMarkup(e.mapping.map(l.before()),g)}a&&Eu(t,n.extensionManager.splittableMarks),e.scrollIntoView()}return h},_p=(a,e={})=>({tr:t,state:i,dispatch:n,editor:r})=>{var s;const l=ce(a,i.schema),{$from:u,$to:d}=i.selection,f=i.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(d))return!1;const c=u.node(-1);if(c.type!==l)return!1;const g=r.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==l||u.index(-2)!==u.node(-2).childCount-1)return!1;if(n){let p=V.empty;const b=u.index(-1)?1:u.index(-2)?2:3;for(let E=u.depth-b;E>=u.depth-3;E-=1)p=V.from(u.node(E).copy(p));const y=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,k={...hn(g,u.node().type.name,u.node().attrs),...e},w=((s=l.contentMatch.defaultType)==null?void 0:s.createAndFill(k))||void 0;p=p.append(V.from(l.createAndFill(null,w)||void 0));const D=u.before(u.depth-(b-1));t.replace(D,u.after(-y),new P(p,4-b,0));let v=-1;t.doc.nodesBetween(D,t.doc.content.size,(E,C)=>{if(v>-1)return!1;E.isTextblock&&E.content.size===0&&(v=C+1)}),v>-1&&t.setSelection(H.near(t.doc.resolve(v))),t.scrollIntoView()}return!0}const _=d.pos===u.end()?c.contentMatchAt(0).defaultType:null,h={...hn(g,c.type.name,c.attrs),...e},m={...hn(g,u.node().type.name,u.node().attrs),...e};t.delete(u.pos,d.pos);const F=_?[{type:l,attrs:h},{type:_,attrs:m}]:[{type:l,attrs:h}];if(!St(t.doc,u.pos,2))return!1;if(n){const{selection:p,storedMarks:b}=i,{splittableMarks:y}=r.extensionManager,k=b||p.$to.parentOffset&&p.$from.marks();if(t.split(u.pos,2,F).scrollIntoView(),!k||!n)return!0;const w=k.filter(D=>y.includes(D.type.name));t.ensureMarks(w)}return!0},Zo=(a,e)=>{const t=Ca(s=>s.type===e)(a.selection);if(!t)return!0;const i=a.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(i===void 0)return!0;const n=a.doc.nodeAt(i);return t.node.type===n?.type&&ta(a.doc,t.pos)&&a.join(t.pos),!0},er=(a,e)=>{const t=Ca(s=>s.type===e)(a.selection);if(!t)return!0;const i=a.doc.resolve(t.start).after(t.depth);if(i===void 0)return!0;const n=a.doc.nodeAt(i);return t.node.type===n?.type&&ta(a.doc,i)&&a.join(i),!0},hp=(a,e,t,i={})=>({editor:n,tr:r,state:s,dispatch:l,chain:u,commands:d,can:f})=>{const{extensions:c,splittableMarks:g}=n.extensionManager,_=ce(a,s.schema),h=ce(e,s.schema),{selection:m,storedMarks:F}=s,{$from:p,$to:b}=m,y=p.blockRange(b),k=F||m.$to.parentOffset&&m.$from.marks();if(!y)return!1;const w=Ca(D=>vu(D.type.name,c))(m);if(y.depth>=1&&w&&y.depth-w.depth<=1){if(w.node.type===_)return d.liftListItem(h);if(vu(w.node.type.name,c)&&_.validContent(w.node.content)&&l)return u().command(()=>(r.setNodeMarkup(w.pos,_),!0)).command(()=>Zo(r,_)).command(()=>er(r,_)).run()}return!t||!k||!l?u().command(()=>f().wrapInList(_,i)?!0:d.clearNodes()).wrapInList(_,i).command(()=>Zo(r,_)).command(()=>er(r,_)).run():u().command(()=>{const D=f().wrapInList(_,i),v=k.filter(E=>g.includes(E.type.name));return r.ensureMarks(v),D?!0:d.clearNodes()}).wrapInList(_,i).command(()=>Zo(r,_)).command(()=>er(r,_)).run()},mp=(a,e={},t={})=>({state:i,commands:n})=>{const{extendEmptyMarkRange:r=!1}=t,s=Nt(a,i.schema);return Lr(i,s,e)?n.unsetMark(s,{extendEmptyMarkRange:r}):n.setMark(s,e)},Fp=(a,e,t={})=>({state:i,commands:n})=>{const r=ce(a,i.schema),s=ce(e,i.schema),l=Zt(i,r,t);let u;return i.selection.$anchor.sameParent(i.selection.$head)&&(u=i.selection.$anchor.parent.attrs),l?n.setNode(s,u):n.setNode(r,{...u,...t})},pp=(a,e={})=>({state:t,commands:i})=>{const n=ce(a,t.schema);return Zt(t,n,e)?i.lift(n):i.wrapIn(n,e)},bp=()=>({state:a,dispatch:e})=>{const t=a.plugins;for(let i=0;i<t.length;i+=1){const n=t[i];let r;if(n.spec.isInputRules&&(r=n.getState(a))){if(e){const s=a.tr,l=r.transform;for(let u=l.steps.length-1;u>=0;u-=1)s.step(l.steps[u].invert(l.docs[u]));if(r.text){const u=s.doc.resolve(r.from).marks();s.replaceWith(r.from,r.to,a.schema.text(r.text,u))}else s.delete(r.from,r.to)}return!0}}return!1},yp=()=>({tr:a,dispatch:e})=>{const{selection:t}=a,{empty:i,ranges:n}=t;return i||e&&n.forEach(r=>{a.removeMark(r.$from.pos,r.$to.pos)}),!0},kp=(a,e={})=>({tr:t,state:i,dispatch:n})=>{var r;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=t,u=Nt(a,i.schema),{$from:d,empty:f,ranges:c}=l;if(!n)return!0;if(f&&s){let{from:g,to:_}=l;const h=(r=d.marks().find(F=>F.type===u))==null?void 0:r.attrs,m=As(d,u,h);m&&(g=m.from,_=m.to),t.removeMark(g,_,u)}else c.forEach(g=>{t.removeMark(g.$from.pos,g.$to.pos,u)});return t.removeStoredMark(u),!0},wp=a=>({tr:e,state:t,dispatch:i})=>{const{selection:n}=t;let r,s;return typeof a=="number"?(r=a,s=a):a&&"from"in a&&"to"in a?(r=a.from,s=a.to):(r=n.from,s=n.to),i&&e.doc.nodesBetween(r,s,(l,u)=>{if(l.isText)return;const d={...l.attrs};delete d.dir,e.setNodeMarkup(u,void 0,d)}),!0},Dp=(a,e={})=>({tr:t,state:i,dispatch:n})=>{let r=null,s=null;const l=Co(typeof a=="string"?a:a.name,i.schema);if(!l)return!1;l==="node"&&(r=ce(a,i.schema)),l==="mark"&&(s=Nt(a,i.schema));let u=!1;return t.selection.ranges.forEach(d=>{const f=d.$from.pos,c=d.$to.pos;let g,_,h,m;t.selection.empty?i.doc.nodesBetween(f,c,(F,p)=>{r&&r===F.type&&(u=!0,h=Math.max(p,f),m=Math.min(p+F.nodeSize,c),g=p,_=F)}):i.doc.nodesBetween(f,c,(F,p)=>{p<f&&r&&r===F.type&&(u=!0,h=Math.max(p,f),m=Math.min(p+F.nodeSize,c),g=p,_=F),p>=f&&p<=c&&(r&&r===F.type&&(u=!0,n&&t.setNodeMarkup(p,void 0,{...F.attrs,...e})),s&&F.marks.length&&F.marks.forEach(b=>{if(s===b.type&&(u=!0,n)){const y=Math.max(p,f),k=Math.min(p+F.nodeSize,c);t.addMark(y,k,s.create({...b.attrs,...e}))}}))}),_&&(g!==void 0&&n&&t.setNodeMarkup(g,void 0,{..._.attrs,...e}),s&&_.marks.length&&_.marks.forEach(F=>{s===F.type&&n&&t.addMark(h,m,s.create({...F.attrs,...e}))}))}),u},vp=(a,e={})=>({state:t,dispatch:i})=>{const n=ce(a,t.schema);return ah(n,e)(t,i)},Ep=(a,e={})=>({state:t,dispatch:i})=>{const n=ce(a,t.schema);return ih(n,e)(t,i)},xp=class{constructor(){this.callbacks={}}on(a,e){return this.callbacks[a]||(this.callbacks[a]=[]),this.callbacks[a].push(e),this}emit(a,...e){const t=this.callbacks[a];return t&&t.forEach(i=>i.apply(this,e)),this}off(a,e){const t=this.callbacks[a];return t&&(e?this.callbacks[a]=t.filter(i=>i!==e):delete this.callbacks[a]),this}once(a,e){const t=(...i)=>{this.off(a,t),e.apply(this,i)};return this.on(a,t)}removeAllListeners(){this.callbacks={}}},So=class{constructor(a){var e;this.find=a.find,this.handler=a.handler,this.undoable=(e=a.undoable)!=null?e:!0}},Cp=(a,e)=>{if(qs(e))return e.exec(a);const t=e(a);if(!t)return null;const i=[t.text];return i.index=t.index,i.input=a,i.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(t.replaceWith)),i};function Yi(a){var e;const{editor:t,from:i,to:n,text:r,rules:s,plugin:l}=a,{view:u}=t;if(u.composing)return!1;const d=u.state.doc.resolve(i);if(d.parent.type.spec.code||(e=d.nodeBefore||d.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let f=!1;const c=ep(d)+r;return s.forEach(g=>{if(f)return;const _=Cp(c,g.find);if(!_)return;const h=u.state.tr,m=Eo({state:u.state,transaction:h}),F={from:i-(_[0].length-r.length),to:n},{commands:p,chain:b,can:y}=new xo({editor:t,state:m});g.handler({state:m,range:F,match:_,commands:p,chain:b,can:y})===null||!h.steps.length||(g.undoable&&h.setMeta(l,{transform:h,from:i,to:n,text:r}),u.dispatch(h),f=!0)}),f}function Bp(a){const{editor:e,rules:t}=a,i=new X({state:{init(){return null},apply(n,r,s){const l=n.getMeta(i);if(l)return l;const u=n.getMeta("applyInputRules");return u&&setTimeout(()=>{let{text:f}=u;typeof f=="string"?f=f:f=Ls(V.from(f),s.schema);const{from:c}=u,g=c+f.length;Yi({editor:e,from:c,to:g,text:f,rules:t,plugin:i})}),n.selectionSet||n.docChanged?null:r}},props:{handleTextInput(n,r,s,l){return Yi({editor:e,from:r,to:s,text:l,rules:t,plugin:i})},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:r}=n.state.selection;r&&Yi({editor:e,from:r.pos,to:r.pos,text:"",rules:t,plugin:i})}),!1)},handleKeyDown(n,r){if(r.key!=="Enter")return!1;const{$cursor:s}=n.state.selection;return s?Yi({editor:e,from:s.pos,to:s.pos,text:`
|
|
13
13
|
`,rules:t,plugin:i}):!1}},isInputRules:!0});return i}function Sp(a){return Object.prototype.toString.call(a).slice(8,-1)}function Xi(a){return Sp(a)!=="Object"?!1:a.constructor===Object&&Object.getPrototypeOf(a)===Object.prototype}function rc(a,e){const t={...a};return Xi(a)&&Xi(e)&&Object.keys(e).forEach(i=>{Xi(e[i])&&Xi(a[i])?t[i]=rc(a[i],e[i]):t[i]=e[i]}),t}var Rs=class{constructor(a={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...a},this.name=this.config.name}get options(){return{...ee(K(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ee(K(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(a={}){const e=this.extend({...this.config,addOptions:()=>rc(this.options,a)});return e.name=this.name,e.parent=this.parent,e}extend(a={}){const e=new this.constructor({...this.config,...a});return e.parent=this,this.child=e,e.name="name"in a?a.name:e.parent.name,e}},ia=class sc extends Rs{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new sc(t)}static handleExit({editor:e,mark:t}){const{tr:i}=e.state,n=e.state.selection.$from;if(n.pos===n.end()){const s=n.marks();if(!!!s.find(d=>d?.type.name===t.name))return!1;const u=s.find(d=>d?.type.name===t.name);return u&&i.removeStoredMark(u),i.insertText(" ",n.pos),e.view.dispatch(i),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function jp(a){return typeof a=="number"}var Np=class{constructor(a){this.find=a.find,this.handler=a.handler}},qp=(a,e,t)=>{if(qs(e))return[...a.matchAll(e)];const i=e(a,t);return i?i.map(n=>{const r=[n.text];return r.index=n.index,r.input=a,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),r.push(n.replaceWith)),r}):[]};function Ap(a){const{editor:e,state:t,from:i,to:n,rule:r,pasteEvent:s,dropEvent:l}=a,{commands:u,chain:d,can:f}=new xo({editor:e,state:t}),c=[];return t.doc.nodesBetween(i,n,(_,h)=>{var m,F,p,b,y;if((F=(m=_.type)==null?void 0:m.spec)!=null&&F.code||!(_.isText||_.isTextblock||_.isInline))return;const k=(y=(b=(p=_.content)==null?void 0:p.size)!=null?b:_.nodeSize)!=null?y:0,w=Math.max(i,h),D=Math.min(n,h+k);if(w>=D)return;const v=_.isText?_.text||"":_.textBetween(w-h,D-h,void 0,"");qp(v,r.find,s).forEach(C=>{if(C.index===void 0)return;const N=w+C.index+1,A=N+C[0].length,L={from:t.tr.mapping.map(N),to:t.tr.mapping.map(A)},B=r.handler({state:t,range:L,match:C,commands:u,chain:d,can:f,pasteEvent:s,dropEvent:l});c.push(B)})}),c.every(_=>_!==null)}var Qi=null,Tp=a=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",a),t};function Mp(a){const{editor:e,rules:t}=a;let i=null,n=!1,r=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const u=({state:f,from:c,to:g,rule:_,pasteEvt:h})=>{const m=f.tr,F=Eo({state:f,transaction:m});if(!(!Ap({editor:e,state:F,from:Math.max(c-1,0),to:g.b-1,rule:_,pasteEvent:h,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(f=>new X({view(c){const g=h=>{var m;i=(m=c.dom.parentElement)!=null&&m.contains(h.target)?c.dom.parentElement:null,i&&(Qi=e)},_=()=>{Qi&&(Qi=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",_),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",_)}}},props:{handleDOMEvents:{drop:(c,g)=>{if(r=i===c.dom.parentElement,l=g,!r){const _=Qi;_?.isEditable&&setTimeout(()=>{const h=_.state.selection;h&&_.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(c,g)=>{var _;const h=(_=g.clipboardData)==null?void 0:_.getData("text/html");return s=g,n=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(c,g,_)=>{const h=c[0],m=h.getMeta("uiEvent")==="paste"&&!n,F=h.getMeta("uiEvent")==="drop"&&!r,p=h.getMeta("applyPasteRules"),b=!!p;if(!m&&!F&&!b)return;if(b){let{text:w}=p;typeof w=="string"?w=w:w=Ls(V.from(w),_.schema);const{from:D}=p,v=D+w.length,E=Tp(w);return u({rule:f,state:_,from:D,to:{b:v},pasteEvt:E})}const y=g.doc.content.findDiffStart(_.doc.content),k=g.doc.content.findDiffEnd(_.doc.content);if(!(!jp(y)||!k||y===k.b))return u({rule:f,state:_,from:y,to:k,pasteEvt:s})}}))}var jo=class{constructor(a,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=a,this.extensions=Zf(a),this.schema=JF(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((a,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ei(e.name,this.schema)},i=K(e,"addCommands",t);return i?{...a,...i()}:a},{})}get plugins(){const{editor:a}=this;return Fi([...this.extensions].reverse()).flatMap(i=>{const n={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:a,type:ei(i.name,this.schema)},r=[],s=K(i,"addKeyboardShortcuts",n);let l={};if(i.type==="mark"&&K(i,"exitable",n)&&(l.ArrowRight=()=>ia.handleExit({editor:a,mark:i})),s){const g=Object.fromEntries(Object.entries(s()).map(([_,h])=>[_,()=>h({editor:a})]));l={...l,...g}}const u=Zm(l);r.push(u);const d=K(i,"addInputRules",n);if(Du(i,a.options.enableInputRules)&&d){const g=d();if(g&&g.length){const _=Bp({editor:a,rules:g}),h=Array.isArray(_)?_:[_];r.push(...h)}}const f=K(i,"addPasteRules",n);if(Du(i,a.options.enablePasteRules)&&f){const g=f();if(g&&g.length){const _=Mp({editor:a,rules:g});r.push(..._)}}const c=K(i,"addProseMirrorPlugins",n);if(c){const g=c();r.push(...g)}return r})}get attributes(){return Qf(this.extensions)}get nodeViews(){const{editor:a}=this,{nodeExtensions:e}=Ha(this.extensions);return Object.fromEntries(e.filter(t=>!!K(t,"addNodeView")).map(t=>{const i=this.attributes.filter(u=>u.type===t.name),n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:a,type:ce(t.name,this.schema)},r=K(t,"addNodeView",n);if(!r)return[];const s=r();if(!s)return[];const l=(u,d,f,c,g)=>{const _=Mi(u,i);return s({node:u,view:d,getPos:f,decorations:c,innerDecorations:g,editor:a,extension:t,HTMLAttributes:_})};return[t.name,l]}))}dispatchTransaction(a){const{editor:e}=this;return Fi([...this.extensions].reverse()).reduceRight((i,n)=>{const r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:ei(n.name,this.schema)},s=K(n,"dispatchTransaction",r);return s?l=>{s.call(r,{transaction:l,next:i})}:i},a)}transformPastedHTML(a){const{editor:e}=this;return Fi([...this.extensions]).reduce((i,n)=>{const r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:ei(n.name,this.schema)},s=K(n,"transformPastedHTML",r);return s?(l,u)=>{const d=i(l,u);return s.call(r,d)}:i},a||(i=>i))}get markViews(){const{editor:a}=this,{markExtensions:e}=Ha(this.extensions);return Object.fromEntries(e.filter(t=>!!K(t,"addMarkView")).map(t=>{const i=this.attributes.filter(l=>l.type===t.name),n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:a,type:Nt(t.name,this.schema)},r=K(t,"addMarkView",n);if(!r)return[];const s=(l,u,d)=>{const f=Mi(l,i);return r()({mark:l,view:u,inline:d,editor:a,extension:t,HTMLAttributes:f,updateAttributes:c=>{Gp(l,a,c)}})};return[t.name,s]}))}setupExtensions(){const a=this.extensions;this.editor.extensionStorage=Object.fromEntries(a.map(e=>[e.name,e.storage])),a.forEach(e=>{var t;const i={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ei(e.name,this.schema)};e.type==="mark"&&((t=ee(K(e,"keepOnSplit",i)))==null||t)&&this.splittableMarks.push(e.name);const n=K(e,"onBeforeCreate",i),r=K(e,"onCreate",i),s=K(e,"onUpdate",i),l=K(e,"onSelectionUpdate",i),u=K(e,"onTransaction",i),d=K(e,"onFocus",i),f=K(e,"onBlur",i),c=K(e,"onDestroy",i);n&&this.editor.on("beforeCreate",n),r&&this.editor.on("create",r),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),u&&this.editor.on("transaction",u),d&&this.editor.on("focus",d),f&&this.editor.on("blur",f),c&&this.editor.on("destroy",c)})}};jo.resolve=Zf;jo.sort=Fi;jo.flatten=Os;var Vp={};Ns(Vp,{ClipboardTextSerializer:()=>uc,Commands:()=>dc,Delete:()=>fc,Drop:()=>cc,Editable:()=>gc,FocusEvents:()=>hc,Keymap:()=>mc,Paste:()=>Fc,Tabindex:()=>pc,TextDirection:()=>bc,focusEventsPluginKey:()=>_c});var oe=class lc extends Rs{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new lc(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},uc=oe.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new X({key:new te("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:a}=this,{state:e,schema:t}=a,{doc:i,selection:n}=e,{ranges:r}=n,s=Math.min(...r.map(f=>f.$from.pos)),l=Math.max(...r.map(f=>f.$to.pos)),u=zs(t);return ec(i,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),dc=oe.create({name:"commands",addCommands(){return{...Hf}}}),fc=oe.create({name:"delete",onUpdate({transaction:a,appendedTransactions:e}){var t,i,n;const r=()=>{var s,l,u,d;if((d=(u=(l=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:l.filterTransaction)==null?void 0:u.call(l,a))!=null?d:a.getMeta("y-sync$"))return;const f=Ms(a.before,[a,...e]);Is(f).forEach(_=>{f.mapping.mapResult(_.oldRange.from).deletedAfter&&f.mapping.mapResult(_.oldRange.to).deletedBefore&&f.before.nodesBetween(_.oldRange.from,_.oldRange.to,(h,m)=>{const F=m+h.nodeSize-2,p=_.oldRange.from<=m&&F<=_.oldRange.to;this.editor.emit("delete",{type:"node",node:h,from:m,to:F,newFrom:f.mapping.map(m),newTo:f.mapping.map(F),deletedRange:_.oldRange,newRange:_.newRange,partial:!p,editor:this.editor,transaction:a,combinedTransform:f})})});const g=f.mapping;f.steps.forEach((_,h)=>{var m,F;if(_ instanceof Ya){const p=g.slice(h).map(_.from,-1),b=g.slice(h).map(_.to),y=g.invert().map(p,-1),k=g.invert().map(b),w=(m=f.doc.nodeAt(p-1))==null?void 0:m.marks.some(v=>v.eq(_.mark)),D=(F=f.doc.nodeAt(b))==null?void 0:F.marks.some(v=>v.eq(_.mark));this.editor.emit("delete",{type:"mark",mark:_.mark,from:_.from,to:_.to,deletedRange:{from:y,to:k},newRange:{from:p,to:b},partial:!!(D||w),editor:this.editor,transaction:a,combinedTransform:f})}})};(n=(i=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:i.async)==null||n?setTimeout(r,0):r()}}),cc=oe.create({name:"drop",addProseMirrorPlugins(){return[new X({key:new te("tiptapDrop"),props:{handleDrop:(a,e,t,i)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:i})}}})]}}),gc=oe.create({name:"editable",addProseMirrorPlugins(){return[new X({key:new te("editable"),props:{editable:()=>this.editor.options.editable}})]}}),_c=new te("focusEvents"),hc=oe.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:a}=this;return[new X({key:_c,props:{handleDOMEvents:{focus:(e,t)=>{a.isFocused=!0;const i=a.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(i),!1},blur:(e,t)=>{a.isFocused=!1;const i=a.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(i),!1}}}})]}}),mc=oe.create({name:"keymap",addKeyboardShortcuts(){const a=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{const{selection:u,doc:d}=l,{empty:f,$anchor:c}=u,{pos:g,parent:_}=c,h=c.parent.isTextblock&&g>0?l.doc.resolve(g-1):c,m=h.parent.type.spec.isolating,F=c.pos-c.parentOffset,p=m&&h.parent.childCount===1?F===c.pos:J.atStart(d).from===g;return!f||!_.type.isTextblock||_.textContent.length||!p||p&&c.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),i={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:a,"Mod-Backspace":a,"Shift-Backspace":a,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},n={...i},r={...i,"Ctrl-h":a,"Alt-Backspace":a,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ai()||Jf()?r:n},addProseMirrorPlugins(){return[new X({key:new te("clearDocument"),appendTransaction:(a,e,t)=>{if(a.some(m=>m.getMeta("composition")))return;const i=a.some(m=>m.docChanged)&&!e.doc.eq(t.doc),n=a.some(m=>m.getMeta("preventClearDocument"));if(!i||n)return;const{empty:r,from:s,to:l}=e.selection,u=J.atStart(e.doc).from,d=J.atEnd(e.doc).to;if(r||!(s===u&&l===d)||!Bo(t.doc))return;const g=t.tr,_=Eo({state:t,transaction:g}),{commands:h}=new xo({editor:this.editor,state:_});if(h.clearNodes(),!!g.steps.length)return g}})]}}),Fc=oe.create({name:"paste",addProseMirrorPlugins(){return[new X({key:new te("tiptapPaste"),props:{handlePaste:(a,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),pc=oe.create({name:"tabindex",addProseMirrorPlugins(){return[new X({key:new te("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),bc=oe.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:a}=Ha(this.extensions);return[{types:a.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new X({key:new te("textDirection"),props:{attributes:()=>{const a=this.options.direction;return a?{dir:a}:{}}}})]}}),Op=class di{constructor(e,t,i=!1,n=null){this.currentNode=null,this.actualDepth=null,this.isBlock=i,this.resolvedPos=e,this.editor=t,this.currentNode=n}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,i=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,i=this.to-1}this.editor.commands.insertContentAt({from:t,to:i},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new di(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new di(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new di(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,i)=>{const n=t.isBlock&&!t.isTextblock,r=t.isAtom&&!t.isText,s=t.isInline,l=this.pos+i+(r?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(l);if(!n&&!s&&u.depth<=this.depth)return;const d=new di(u,this.editor,n,n||s?t:null);n&&(d.actualDepth=this.depth+1),e.push(d)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let i=null,n=this.parent;for(;n&&!i;){if(n.node.type.name===e)if(Object.keys(t).length>0){const r=n.node.attrs,s=Object.keys(t);for(let l=0;l<s.length;l+=1){const u=s[l];if(r[u]!==t[u])break}}else i=n;n=n.parent}return i}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},i=!1){let n=[];if(!this.children||this.children.length===0)return n;const r=Object.keys(t);return this.children.forEach(s=>{i&&n.length>0||(s.node.type.name===e&&r.every(u=>t[u]===s.node.attrs[u])&&n.push(s),!(i&&n.length>0)&&(n=n.concat(s.querySelectorAll(e,t,i))))}),n}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},Lp=`.ProseMirror {
|
|
@@ -8470,7 +8470,7 @@ class D0 {
|
|
|
8470
8470
|
const s = n ? null : i.target, l = s ? e.docView.nearestDesc(s, !0) : null;
|
|
8471
8471
|
this.target = l && l.nodeDOM.nodeType == 1 ? l.nodeDOM : null;
|
|
8472
8472
|
let { selection: u } = e.state;
|
|
8473
|
-
|
|
8473
|
+
i.button == 0 && (o.type.spec.draggable && o.type.spec.selectable !== !1 || u instanceof Z && u.from <= r && u.to > r) && (this.mightDrag = {
|
|
8474
8474
|
node: o,
|
|
8475
8475
|
pos: r,
|
|
8476
8476
|
addAttr: !!(this.target && !this.target.draggable),
|
|
@@ -8648,8 +8648,10 @@ class Vg {
|
|
|
8648
8648
|
}
|
|
8649
8649
|
const q0 = kt ? "altKey" : "ctrlKey";
|
|
8650
8650
|
function Wg(a, e) {
|
|
8651
|
-
let t
|
|
8652
|
-
return
|
|
8651
|
+
let t;
|
|
8652
|
+
return a.someProp("dragCopies", (i) => {
|
|
8653
|
+
t = t || i(e);
|
|
8654
|
+
}), t != null ? !t : !e[q0];
|
|
8653
8655
|
}
|
|
8654
8656
|
it.dragstart = (a, e) => {
|
|
8655
8657
|
let t = e, i = a.input.mouseDown;
|