1||l==0||m.content.size)&&(d=g,u.push(ef(m.mark(f.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?p:-1)))}let h=c==a.childCount;h||(p=-1),this.placed=ai(this.placed,n,C.from(u)),this.frontier[n].match=d,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n=0;a--){let{match:l,type:c}=this.frontier[a],u=Ua(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=ai(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=ai(this.placed,this.depth,C.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(C.empty,!0);n.childCount&&(this.placed=ai(this.placed,this.frontier.length,n))}};function si(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(si(t.firstChild.content,e-1,n)))}function ai(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ai(t.lastChild.content,e-1,n)))}function Fa(t,e){for(let n=0;n1&&(r=r.replaceChild(0,ef(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(C.empty,!0)))),t.copy(r)}function Ua(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!fk(n,o.content,s)?a:null}function fk(t,e,n){for(let r=n;r0;f--,p--){let h=i.node(f).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(f)>-1?a=f:i.before(f)==p&&s.splice(1,0,-f)}let l=s.indexOf(a),c=[],u=r.openStart;for(let f=r.content,p=0;;p++){let h=f.firstChild;if(c.push(h),p==r.openStart)break;f=h.content}for(let f=u-1;f>=0;f--){let p=c[f],h=pk(p.type);if(h&&!p.sameMarkup(i.node(Math.abs(a)-1)))u=f;else if(h||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+u+1)%(r.openStart+1),h=c[p];if(h)for(let m=0;m=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let p=s[f];p<0||(e=i.before(p),n=o.after(p))}}function tf(t,e,n,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(C.empty,!0))}return t}function mk(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=dk(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new L(C.from(r),0,0))}function gk(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=nf(r,i);for(let s=0;s0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return t.delete(r.before(a),i.after(a))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function nf(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(oe.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}var fo=class t extends Fe{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ge.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Ge.fromReplace(e,this.pos,this.pos+1,new L(C.from(i),0,n.isLeaf?0:1))}getMap(){return cn.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};Fe.jsonID("attr",fo);var po=class t extends Fe{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Ge.ok(r)}getMap(){return cn.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};Fe.jsonID("docAttr",po);var Ar=class extends Error{};Ar=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Ar.prototype=Object.create(Error.prototype);Ar.prototype.constructor=Ar;Ar.prototype.name="TransformError";var Cn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ci}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Ar(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=L.empty){let i=fi(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new L(C.from(r),0,0))}delete(e,n){return this.replace(e,n,L.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return hk(this,e,n,r),this}replaceRangeWith(e,n,r){return mk(this,e,n,r),this}deleteRange(e,n){return gk(this,e,n),this}lift(e,n){return tk(this,e,n),this}join(e,n=1){return uk(this,e,n),this}wrap(e,n){return ik(this,e,n),this}setBlockType(e,n=e,r,i=null){return ok(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return ak(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new fo(e,n,r)),this}setDocAttribute(e,n){return this.step(new po(e,n)),this}addNodeMark(e,n){return this.step(new di(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof fe)n.isInSet(r.marks)&&this.step(new Nr(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new Nr(e,o)),i=o.removeFromSet(i);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(e,n=1,r){return lk(this,e,n,r),this}addMark(e,n,r){return XE(this,e,n,r),this}removeMark(e,n,r){return QE(this,e,n,r),this}clearIncompatible(e,n,r){return Ka(this,e,n,r),this}};var Ga=Object.create(null),q=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Rr(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;o--){let s=n<0?Or(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Or(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new at(e.node(0))}static atStart(e){return Or(e,e,0,0,1)||new at(e)}static atEnd(e){return Or(e,e,e.content.size,e.childCount,-1)||new at(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ga[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ga)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ga[e]=n,n.prototype.jsonID=e,n}getBookmark(){return G.between(this.$anchor,this.$head).getBookmark()}};q.prototype.visible=!0;var Rr=class{constructor(e,n){this.$from=e,this.$to=n}},rf=!1;function of(t){!rf&&!t.parent.inlineContent&&(rf=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var G=class t extends q{constructor(e,n=e){of(e),of(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return q.near(r);let i=e.resolve(n.map(this.anchor));return new t(i.parent.inlineContent?i:r,r)}replace(e,n=L.empty){if(super.replace(e,n),n==L.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new go(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=q.findFrom(n,r,!0)||q.findFrom(n,-r,!0);if(o)n=o.$head;else return q.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let a=e.child(s);if(a.isAtom){if(!o&&V.isSelectable(a))return V.create(t,n-(i<0?a.nodeSize:0))}else{let l=Or(t,a,n+i,i<0?a.childCount:0,i,o);if(l)return l}n+=a.nodeSize*i}return null}function sf(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=u)}),t.setSelection(q.near(t.doc.resolve(s),n))}var af=1,mo=2,lf=4,ja=class extends Cn{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=mo,this}ensureMarks(e){return fe.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&mo)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~mo,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||fe.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(q.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=lf,this}get scrolledIntoView(){return(this.updated&lf)>0}};function cf(t,e){return!e||!t?t:t.bind(e)}var Yn=class{constructor(e,n,r){this.name=e,this.init=cf(n.init,r),this.apply=cf(n.apply,r)}},yk=[new Yn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Yn("selection",{init(t,e){return t.selection||q.atStart(e.doc)},apply(t){return t.selection}}),new Yn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Yn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],pi=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=yk.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Yn(r.key,r.spec.state,r))})}},bo=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new pi(e.schema,e.plugins),o=new t(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=At.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=q.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){o[s.name]=c.fromJSON.call(l,e,n[a],o);return}}o[s.name]=s.init(e,o)}}),o}};function uf(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=uf(i,e,{})),n[r]=i}return n}var me=class{constructor(e){this.spec=e,this.props={},e.props&&uf(e.props,this,this.props),this.key=e.key?e.key.key:df("plugin")}getState(e){return e[this.key]}},Va=Object.create(null);function df(t){return t in Va?t+"$"+ ++Va[t]:(Va[t]=0,t+"$")}var _e=class{constructor(e="key"){this.key=df(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Ve=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Br=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},el=null,fn=function(t,e,n){let r=el||(el=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Ek=function(){el=null},nr=function(t,e,n,r){return n&&(ff(t,e,n,r,-1)||ff(t,e,n,r,1))},kk=/^(img|br|input|textarea|hr)$/i;function ff(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Ot(t))){let s=t.parentNode;if(!s||s.nodeType!=1||wi(t)||kk.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ve(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?Ot(t):0}else return!1}}function Ot(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function wk(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Ot(t)}else if(t.parentNode&&!wi(t))e=Ve(t),t=t.parentNode;else return null}}function Sk(t,e){for(;;){if(t.nodeType==3&&e2),Mt=zr||(Kt?/Mac/.test(Kt.platform):!1),qf=Kt?/Win/.test(Kt.platform):!1,pn=/Android \d/.test(Rn),Si=!!pf&&"webkitFontSmoothing"in pf.documentElement.style,Ck=Si?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Nk(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function dn(t,e){return typeof t=="number"?t:t[e]}function Ak(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function hf(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=Br(s);continue}let a=s,l=a==o.body,c=l?Nk(o):Ak(a),u=0,d=0;if(e.topc.bottom-dn(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+dn(i,"top")-c.top:e.bottom-c.bottom+dn(i,"bottom")),e.leftc.right-dn(r,"right")&&(u=e.right-c.right+dn(i,"right")),u||d)if(l)o.defaultView.scrollBy(u,d);else{let p=a.scrollLeft,h=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let m=a.scrollLeft-p,g=a.scrollTop-h;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:Br(s)}}function vk(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s=n-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:jf(t.dom)}}function jf(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Br(r));return e}function Mk({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Yf(n,r==0?0:r-e)}function Yf(t,e){for(let n=0;n=a){s=Math.max(h.bottom,s),a=Math.min(h.top,a);let m=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!l&&h.left<=e.left&&h.right>=e.left&&(l=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!n&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(o=d+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?Rk(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:Jf(n,i)}function Rk(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let o=0;o=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function yl(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ik(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function Lk(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let a=t.docView.nearestDesc(o,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?i=a.posBefore:(!s&&l.right-1?i:t.docView.posFromDOM(e,n,-1)}function Zf(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let c;Si&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=Lk(t,r,i,e))}a==null&&(a=Dk(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function mf(t){return t.top=0&&i==r.nodeValue.length?(l--,u=1):n<0?l--:c++,hi(Nn(fn(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==Ot(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return Ya(l.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(n<0||i==Ot(r))){let l=r.childNodes[i-1],c=l.nodeType==3?fn(l,Ot(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return hi(Nn(c,1),!1)}if(o==null&&i=0)}function hi(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Ya(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Qf(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function zk(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Qf(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=Xf(t,i.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=fn(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var Fk=/[\u0590-\u08ac]/;function Uk(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,a=t.domSelection();return a?!Fk.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?o:s:Qf(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:m}=t.domSelectionRange(),g=h&&!p.contains(h.nodeType==1?h:h.parentNode)||l==h&&c==m;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return f!=null&&(a.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var gf=null,bf=null,yf=!1;function $k(t,e,n){return gf==e&&bf==n?yf:(gf=e,bf=n,yf=n=="up"||n=="down"?zk(t,e,n):Uk(t,e,n))}var It=0,Ef=1,Zn=2,Gt=3,rr=class{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=It,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nVe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof ko){i=e-o;break}o=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof yo&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?Ve(o.dom)+1:0}}else{let o,s=!0;for(;o=r=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=s;for(let d=a;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Ve(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>n||a==this.children.length-1)){n=c;for(let u=a+1;uh&&sn){let h=a;a=l,l=h}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i=r:er){let a=r+o.border,l=s-o.border;if(e>=a&&n<=l){this.dirty=e==r||n==s?Zn:Ef,e==a&&n==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Gt:o.markDirty(e-a,n-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Zn:Gt}r=s}this.dirty=Zn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Zn:Ef;n.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==It&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(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}},il=class extends rr{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Fr=class t extends rr{constructor(e,n,r,i,o){super(e,[],r,i),this.mark=n,this.spec=o}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=ln.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Gt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Gt&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=It){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=ll(o,0,e,r));for(let a=0;a{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=ln.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=np(u,r,n),c?l=new ol(e,n,r,i,u,d||null,f,c,o,s+1):n.isText?new Eo(e,n,r,i,u,f,o):new t(e,n,r,i,u,d||null,f,o,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 n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>C.empty)}return e}matchesNode(e,n,r){return this.dirty==It&&e.eq(this.node)&&wo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new al(this,s&&s.node,e);Gk(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?fe.none:this.node.child(u).marks,r,e,u),l.placeWidget(c,e,i)},(c,u,d,f)=>{l.syncToMarks(c.marks,r,e,f);let p;l.findNodeMatch(c,u,d,f)||a&&e.state.selection.from>i&&e.state.selection.to-1&&l.updateNodeAt(c,u,d,p,e)||l.updateNextNode(c,u,d,e,f,i)||l.addNode(c,u,d,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Zn)&&(s&&this.protectLocalComposition(e,s),ep(this.contentDOM,this.children,e),zr&&Vk(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof G)||rn+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,a=qk(this.node.content,s,r-n,i-n);return a<0?null:{node:o,pos:a,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new il(this,o,n,i);e.input.compositionNodes.push(s),this.children=ll(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==Gt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=It}updateOuterDeco(e){if(wo(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=tp(this.dom,this.nodeDOM,sl(this.outerDeco,this.node,n),sl(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.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 kf(t,e,n,r,i){np(r,e,t);let o=new On(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var Eo=class t extends On{constructor(e,n,r,i,o,s,a){super(e,n,r,i,o,null,s,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Gt||this.dirty!=It&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=It||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=It,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new t(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Gt)}get domAtom(){return!1}isText(e){return this.node.text==e}},ko=class extends rr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==It&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},ol=class extends On{constructor(e,n,r,i,o,s,a,l,c,u){super(e,n,r,i,o,s,a,c,u),this.spec=l}update(e,n,r,i){if(this.dirty==Gt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function ep(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o>1,a=Math.min(s,e.length);for(;o-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=Fr.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof Fr)n=c,r=c.children.length;else{a=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function Kk(t,e){return t.type.side-e.type.side}function Gk(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let c=0;co;)a.push(i[s++]);let h=o+f.nodeSize;if(f.isText){let g=h;s!g.inline):a.slice();r(f,m,e.forChild(o,f),p),o=h}}function Vk(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function qk(t,e,n,r){for(let i=0,o=0;i=n){if(o>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a=0&&c+e.length+a>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function ll(t,e,n,r,i){let o=[];for(let s=0,a=0;s=n||u<=e?o.push(l):(cn&&o.push(l.slice(n-c,l.size,r)))}return o}function El(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(Ao(n)){for(l=s;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&V.isSelectable(d)&&i.parent&&!(d.isInline&&xk(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;c=new V(s==f?a:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=s,f=s;for(let p=0;p{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!rp(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Yk(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ve(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&wt&&Mn<=11&&(n.disabled=!0,n.disabled=!1)}function ip(t,e){if(e instanceof V){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Tf(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Tf(t)}function Tf(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function kl(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||G.between(e,n,r)}function Cf(t){return t.editable&&!t.hasFocus()?!1:op(t)}function op(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Jk(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return nr(e.node,e.offset,n.anchorNode,n.anchorOffset)}function cl(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&q.findFrom(o,e)}function An(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Nf(t,e,n){let r=t.state.selection;if(r instanceof G)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return An(t,new G(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=cl(t.state,e);return i&&i instanceof V?An(t,i):!1}else if(!(Mt&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let a=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(a))&&!s.contentDOM?V.isSelectable(o)?An(t,new V(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):Si?An(t,new G(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof V&&r.node.isInline)return An(t,new G(e>0?r.$to:r.$from));{let i=cl(t.state,e);return i?An(t,i):!1}}}function So(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function gi(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Dr(t,e){return e<0?Zk(t):Xk(t)}function Zk(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(Rt&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(gi(a,-1))i=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(sp(n))break;{let a=n.previousSibling;for(;a&&gi(a,-1);)i=n.parentNode,o=Ve(a),a=a.previousSibling;if(a)n=a,r=So(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?ul(t,n,r):i&&ul(t,i,o)}function Xk(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=So(n),o,s;for(;;)if(r{t.state==i&&hn(t)},50)}function Af(t,e){let n=t.state.doc.resolve(e);if(!(qe||qf)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function vf(t,e,n){let r=t.state.selection;if(r instanceof G&&!r.empty||n.indexOf("s")>-1||Mt&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=cl(t.state,e);if(s&&s instanceof V)return An(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof at?q.near(s,e):q.findFrom(s,e);return a?An(t,a):!1}return!1}function Mf(t,e){if(!(t.state.selection instanceof G))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function Of(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function tw(t){if(!Qe||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Of(t,r,"true"),setTimeout(()=>Of(t,r,"false"),20)}return!1}function nw(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function rw(t,e){let n=e.keyCode,r=nw(e);if(n==8||Mt&&n==72&&r=="c")return Mf(t,-1)||Dr(t,-1);if(n==46&&!e.shiftKey||Mt&&n==68&&r=="c")return Mf(t,1)||Dr(t,1);if(n==13||n==27)return!0;if(n==37||Mt&&n==66&&r=="c"){let i=n==37?Af(t,t.state.selection.from)=="ltr"?-1:1:-1;return Nf(t,i,r)||Dr(t,i)}else if(n==39||Mt&&n==70&&r=="c"){let i=n==39?Af(t,t.state.selection.from)=="ltr"?1:-1:1;return Nf(t,i,r)||Dr(t,i)}else{if(n==38||Mt&&n==80&&r=="c")return vf(t,-1,r)||Dr(t,-1);if(n==40||Mt&&n==78&&r=="c")return tw(t)||vf(t,1,r)||Dr(t,1);if(r==(Mt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function wl(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||ln.fromSchema(t.state.schema),a=fp(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=dp[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=a.createElement(u[p]);for(;l.firstChild;)h.appendChild(l.firstChild);l.appendChild(h),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
-
-`);return{dom:l,text:f,slice:e}}function ap(t,e,n,r,i){let o=i.parent.type.spec.code,s,a;if(!n&&!e)return null;let l=!!e&&(r||o||!n);if(l){if(t.someProp("transformPastedText",f=>{e=f(e,o||r,t)}),o)return a=new L(C.from(t.state.schema.text(e.replace(/\r\n?/g,`
-`))),0,0),t.someProp("transformPasted",f=>{a=f(a,t,!0)}),a;let d=t.someProp("clipboardTextParser",f=>f(e,i,r,t));if(d)a=d;else{let f=i.marks(),{schema:p}=t.state,h=ln.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(h.serializeNode(p.text(m,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),s=aw(n),Si&&lw(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||an.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!iw.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=cw(Rf(a,+u[1],+u[2]),u[4]);else if(a=L.maxOpen(ow(a.content,i),!0),a.openStart||a.openEnd){let d=0,f=0;for(let p=a.content.firstChild;d{a=d(a,t,l)}),a}var iw=/^(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 ow(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(a=>{if(!s)return;let l=i.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&o.length&&cp(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=up(s[s.length-1],o.length));let u=lp(a,l);s.push(u),i=i.matchType(u.type),o=l}}),s)return C.from(s)}return t}function lp(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,C.from(t));return t}function cp(t,e,n,r,i){if(i1&&(o=0),i=n&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(C.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}function Rf(t,e,n){return en})),Za.createHTML(t)):t}function aw(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=fp().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&dp[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>""+o+">").reverse().join("")),n.innerHTML=sw(t),i)for(let o=0;o=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=C.from(l.create(r[a+1],i)),o++,s++}return new L(i,o,s)}var lt={},ct={},uw={touchstart:!0,touchmove:!0},fl=class{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 dw(t){for(let e in lt){let n=lt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{pw(t,r)&&!Sl(t,r)&&(t.editable||!(r.type in ct))&&n(t,r)},uw[e]?{passive:!0}:void 0)}Qe&&t.dom.addEventListener("input",()=>null),pl(t)}function vn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function fw(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function pl(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Sl(t,r))})}function Sl(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function pw(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function hw(t,e){!Sl(t,e)&<[e.type]&&(t.editable||!(e.type in ct))&<[e.type](t,e)}ct.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!hp(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(pn&&qe&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),zr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Jn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||rw(t,n)?n.preventDefault():vn(t,"key")};ct.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ct.keypress=(t,e)=>{let n=e;if(hp(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Mt&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof G)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,o))&&t.dispatch(o()),n.preventDefault()}};function vo(t){return{left:t.clientX,top:t.clientY}}function mw(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function xl(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,a=>s>o.depth?a(t,n,o.nodeAfter,o.before(s),i,!0):a(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function Pr(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function gw(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&V.isSelectable(r)?(Pr(t,new V(n),"pointer"),!0):!1}function bw(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof V&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(V.isSelectable(a)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(Pr(t,V.create(t.state.doc,i),"pointer"),!0):!1}function yw(t,e,n,r,i){return xl(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?bw(t,n):gw(t,n))}function Ew(t,e,n,r){return xl(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function kw(t,e,n,r){return xl(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||ww(t,n,r)}function ww(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Pr(t,G.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),a=i.before(o);if(s.inlineContent)Pr(t,G.create(r,a+1,a+1+s.content.size),"pointer");else if(V.isSelectable(s))Pr(t,V.create(r,a),"pointer");else continue;return!0}}function _l(t){return xo(t)}var pp=Mt?"metaKey":"ctrlKey";lt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=_l(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&mw(n,t.input.lastClick)&&!n[pp]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button};let s=t.posAtCoords(vo(n));s&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new hl(t,s,n,!!r)):(o=="doubleClick"?Ew:kw)(t,s.pos,s.inside,n)?n.preventDefault():vn(t,"pointer"))};var hl=class{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[pp],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,s=u.depth?u.before():0}let a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof V&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Rt&&!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)),vn(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(()=>hn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(vo(e))),this.updateAllowDefault(e),this.allowDefault||!n?vn(this.view,"pointer"):yw(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Qe&&this.mightDrag&&!this.mightDrag.node.isAtom||qe&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Pr(this.view,q.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):vn(this.view,"pointer")}move(e){this.updateAllowDefault(e),vn(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)}};lt.touchstart=t=>{t.input.lastTouch=Date.now(),_l(t),vn(t,"pointer")};lt.touchmove=t=>{t.input.lastTouch=Date.now(),vn(t,"pointer")};lt.contextmenu=t=>_l(t);function hp(t,e){return t.composing?!0:Qe&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var Sw=pn?5e3:-1;ct.compositionstart=ct.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof G&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||qe&&qf&&xw(t)))t.markCursor=t.state.storedMarks||n.marks(),xo(t,!0),t.markCursor=null;else if(xo(t,!e.selection.empty),Rt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let a=t.domSelection();a&&a.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}mp(t,Sw)};function xw(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}ct.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,mp(t,20))};function mp(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>xo(t),e))}function gp(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Tw());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function _w(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=wk(e.focusNode,e.focusOffset),r=Sk(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Tw(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function xo(t,e=!1){if(!(pn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),gp(t),e||t.docView&&t.docView.dirty){let n=El(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Cw(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var bi=wt&&Mn<15||zr&&Ck<604;lt.copy=ct.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=bi?null:n.clipboardData,s=r.content(),{dom:a,text:l}=wl(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):Cw(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Nw(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Aw(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?yi(t,r.value,null,i,e):yi(t,r.textContent,r.innerHTML,i,e)},50)}function yi(t,e,n,r,i){let o=ap(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,o||L.empty)))return!0;if(!o)return!1;let s=Nw(o),a=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function bp(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}ct.paste=(t,e)=>{let n=e;if(t.composing&&!pn)return;let r=bi?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&yi(t,bp(r),r.getData("text/html"),i,n)?n.preventDefault():Aw(t,n)};var _o=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},vw=Mt?"altKey":"ctrlKey";function yp(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[vw]}lt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(vo(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof V?i.to-1:i.to))){if(r&&r.mightDrag)s=V.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(s=V.create(t.state.doc,d.posBefore))}}let a=(s||t.state.selection).content(),{dom:l,text:c,slice:u}=wl(t,a);(!n.dataTransfer.files.length||!qe||Vf>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(bi?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",bi||n.dataTransfer.setData("text/plain",c),t.dragging=new _o(u,yp(t,n),s)};lt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ct.dragover=ct.dragenter=(t,e)=>e.preventDefault();ct.drop=(t,e)=>{try{Mw(t,e,t.dragging)}finally{t.dragging=null}};function Mw(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(vo(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",p=>{o=p(o,t,!1)}):o=ap(t,bp(e.dataTransfer),bi?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&yp(t,e));if(t.someProp("handleDrop",p=>p(t,e,o||L.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?ho(t.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let l=t.state.tr;if(s){let{node:p}=n;p?p.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(d))return;let f=l.doc.resolve(c);if(u&&V.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new V(f));else{let p=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((h,m,g,b)=>p=b),l.setSelection(kl(t,f,l.doc.resolve(p)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}lt.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&hn(t)},20))};lt.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};lt.beforeinput=(t,e)=>{if(qe&&pn&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,Jn(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in ct)lt[t]=ct[t];function Ei(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var To=class t{constructor(e,n){this.toDOM=e,this.spec=n||er,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new et(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ei(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Qn=class t{constructor(e,n){this.attrs=e,this.spec=n||er}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new et(o,s,this)}valid(e,n){return n.from=e&&(!o||o(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let s=0;se){let a=this.children[s]+1;this.children[s+2].findInner(e-a,n-a,r,i+a,o)}}map(e,n,r){return this==Xe||e.maps.length==0?this:this.mapInner(e,n,0,0,r||er)}mapInner(e,n,r,i,o){let s;for(let a=0;a{let c=l+r,u;if(u=kp(n,a,c)){for(i||(i=this.children.slice());oa&&d.to=e){this.children[a]==e&&(r=this.children[a+2]);break}let o=e+1,s=o+n.content.size;for(let a=0;ao&&l.type instanceof Qn){let c=Math.max(o,l.from)-o,u=Math.min(s,l.to)-o;ci.map(e,n,er));return t.from(r)}forChild(e,n){if(n.isLeaf)return Pe.empty;let r=[];for(let i=0;in instanceof Pe)?e:e.reduce((n,r)=>n.concat(r instanceof Pe?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let g=m-h-(p-f);for(let b=0;bw+u-d)continue;let _=a[b]+u-d;p>=_?a[b+1]=f<=_?-2:-1:f>=u&&g&&(a[b]+=g,a[b+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c=r.content.size){l=!0;continue}let f=n.map(t[c+1]+o,-1),p=f-i,{index:h,offset:m}=r.content.findIndex(d),g=r.maybeChild(h);if(g&&m==d&&m+g.nodeSize==p){let b=a[c+2].mapInner(n,g,u+1,t[c]+o+1,s);b!=Xe?(a[c]=d,a[c+1]=p,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Rw(a,t,e,n,i,o,s),u=No(c,r,0,s);e=u.local;for(let d=0;dn&&s.to{let c=kp(t,a,l+n);if(c){o=!0;let u=No(c,a,n+l+1,r);u!=Xe&&i.push(l,l+a.nodeSize,u)}});let s=Ep(o?wp(t):t,-n).sort(tr);for(let a=0;a0;)e++;t.splice(e,0,n)}function Xa(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Xe&&e.push(r)}),t.cursorWrapper&&e.push(Pe.create(t.state.doc,[t.cursorWrapper.deco])),Co.from(e)}var Iw={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Dw=wt&&Mn<=11,gl=class{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}},bl=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new gl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Qe&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Dw&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Iw)),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 n=0;nthis.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(Cf(this.view)){if(this.suppressingSelectionUpdates)return hn(this.view);if(wt&&Mn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&nr(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 n=new Set,r;for(let o=e.focusNode;o;o=Br(o))n.add(o);for(let o=e.anchorNode;o;o=Br(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Cf(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let u=0;uu.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;d&&d.nodeType==1&&d.contentEditable=="false"&&u.parentNode.removeChild(u)}}else if(Rt&&l.length){let u=l.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let p=f.parentNode;p&&p.nodeName=="LI"&&(!d||Bw(e,d)!=p)&&f.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),Lw(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,zw(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||hn(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;ui;g--){let b=r.childNodes[g-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){o=g;break}if(!w||w.size)break}let d=t.state.doc,f=t.someProp("domParser")||an.fromSchema(t.state.schema),p=d.resolve(s),h=null,m=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Uw,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),h={anchor:g+s,head:b+s}}return{doc:m,sel:h,from:s,to:a}}function Uw(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Qe&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Qe&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}var $w=/^(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 Hw(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let D=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,B=El(t,D);if(B&&!t.state.selection.eq(B)){if(qe&&pn&&t.input.lastKeyCode===13&&Date.now()-100Ee(t,Jn(13,"Enter"))))return;let K=t.state.tr.setSelection(B);D=="pointer"?K.setMeta("pointer",!0):D=="key"&&K.scrollIntoView(),o&&K.setMeta("composition",o),t.dispatch(K)}return}let s=t.state.doc.resolve(e),a=s.sharedDepth(n);e=s.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,c=Fw(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),f,p;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||pn)&&i.some(D=>D.nodeType==1&&!$w.test(D.nodeName))&&(!h||h.endA>=h.endB)&&t.someProp("handleKeyDown",D=>D(t,Jn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!h)if(r&&l instanceof G&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let D=zf(t,t.state.doc,c.sel);if(D&&!D.eq(t.state.selection)){let B=t.state.tr.setSelection(D);o&&B.setMeta("composition",o),t.dispatch(B)}}return}t.state.selection.fromt.state.selection.from&&h.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?h.start=t.state.selection.from:h.endA=t.state.selection.to-2&&t.state.selection.to<=c.to&&(h.endB+=t.state.selection.to-h.endA,h.endA=t.state.selection.to)),wt&&Mn<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" \xA0"&&(h.start--,h.endA--,h.endB--);let m=c.doc.resolveNoCache(h.start-c.from),g=c.doc.resolveNoCache(h.endB-c.from),b=u.resolve(h.start),w=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=h.endA;if((zr&&t.input.lastIOSEnter>Date.now()-225&&(!w||i.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!w&&m.posD(t,Jn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>h.start&&Kw(u,h.start,h.endA,m,g)&&t.someProp("handleKeyDown",D=>D(t,Jn(8,"Backspace")))){pn&&qe&&t.domObserver.suppressSelectionUpdates();return}qe&&h.endB==h.start&&(t.input.lastChromeDelete=Date.now()),pn&&!w&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,g=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(D){return D(t,Jn(13,"Enter"))})},20));let _=h.start,T=h.endA,A=D=>{let B=D||t.state.tr.replace(_,T,c.doc.slice(h.start-c.from,h.endB-c.from));if(c.sel){let K=zf(t,B.doc,c.sel);K&&!(qe&&t.composing&&K.empty&&(h.start!=h.endB||t.input.lastChromeDeletehn(t),20));let D=A(t.state.tr.delete(_,T)),B=u.resolve(h.start).marksAcross(u.resolve(h.endA));B&&D.ensureMarks(B),t.dispatch(D)}else if(h.endA==h.endB&&(R=Ww(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,h.endA-b.start())))){let D=A(t.state.tr);R.type=="add"?D.addMark(_,T,R.mark):D.removeMark(_,T,R.mark),t.dispatch(D)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let D=m.parent.textBetween(m.parentOffset,g.parentOffset),B=()=>A(t.state.tr.insertText(D,_,T));t.someProp("handleTextInput",K=>K(t,_,T,D,B))||t.dispatch(B())}else t.dispatch(A());else t.dispatch(A())}function zf(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:kl(t,e.resolve(n.anchor),e.resolve(n.head))}function Ww(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,a,l;for(let u=0;uu.mark(a.addToSet(u.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;un||Qa(s,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Gw(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:s,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s=s?o-r:0;o-=l,o&&o=a?o-r:0;o-=l,o&&o=56320&&e<=57343&&n>=55296&&n<=56319}var ki=class{constructor(e,n){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 fl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Kf),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=Hf(this),$f(this),this.nodeViews=Wf(this),this.docView=kf(this.state.doc,Uf(this),Xa(this),this.dom,this),this.domObserver=new bl(this,(r,i,o,s)=>Hw(this,r,i,o,s)),this.domObserver.start(),dw(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 n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&pl(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Kf),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(gp(this),s=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=Wf(this);qw(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&pl(this),this.editable=Hf(this),$f(this);let l=Xa(this),c=Uf(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,l);(d||!e.selection.eq(i.selection))&&(s=!0);let f=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&vk(this);if(s){this.domObserver.stop();let p=d&&(wt||qe)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Vw(i.selection,e.selection);if(d){let h=qe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=_w(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=kf(e.doc,c,l,this.dom,this)),h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Jk(this))?hn(this,p):(ip(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Mk(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof V){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&hf(this,n.getBoundingClientRect(),e)}else hf(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 n=0;n0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new _o(e.slice,e.move,i<0?void 0:V.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;sn.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Pk(this,e)}coordsAtPos(e,n=1){return Xf(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return $k(this,n||this.state,e)}pasteHTML(e,n){return yi(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return yi(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return wl(this,e)}destroy(){this.docView&&(fw(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Xa(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ek())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return hw(this,e)}domSelectionRange(){let e=this.domSelection();return e?Qe&&this.root.nodeType===11&&_k(this.dom.ownerDocument)==this.dom&&Pw(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};ki.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Uf(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[et.node(0,t.state.doc.content.size,e)]}function $f(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:et.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Hf(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Vw(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Wf(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function qw(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Kf(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var mn={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:"'"},Oo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},jw=typeof navigator<"u"&&/Mac/.test(navigator.platform),Yw=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Be=0;Be<10;Be++)mn[48+Be]=mn[96+Be]=String(Be);var Be;for(Be=1;Be<=24;Be++)mn[Be+111]="F"+Be;var Be;for(Be=65;Be<=90;Be++)mn[Be]=String.fromCharCode(Be+32),Oo[Be]=String.fromCharCode(Be);var Be;for(Mo in mn)Oo.hasOwnProperty(Mo)||(Oo[Mo]=mn[Mo]);var Mo;function Sp(t){var e=jw&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Yw&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Oo:mn)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var Jw=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Zw=typeof navigator<"u"&&/Win/.test(navigator.platform);function Xw(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let a=0;at.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Tp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var Al=(t,e,n)=>{let r=Tp(t,n);if(!r)return!1;let i=Ml(r);if(!i){let s=r.blockRange(),a=s&&un(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(Dp(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Ur(o,"end")||V.isSelectable(o)))for(let s=r.depth;;s--){let a=fi(t.doc,r.before(s),r.after(s),L.empty);if(a&&a.slice.size1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},Cp=(t,e,n)=>{let r=Tp(t,n);if(!r)return!1;let i=Ml(r);return i?Ap(t,i,e):!1},Np=(t,e,n)=>{let r=vp(t,n);if(!r)return!1;let i=Il(r);return i?Ap(t,i,e):!1};function Ap(t,e,n){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,a=s,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=fi(t.doc,o,l,L.empty);if(!c||c.from!=o||c instanceof Ze&&c.slice.size>=l-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(G.create(u.doc,o)),n(u.scrollIntoView())}return!0}function Ur(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var vl=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=Ml(r)}let s=o&&o.nodeBefore;return!s||!V.isSelectable(s)?!1:(e&&e(t.tr.setSelection(V.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Ml(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function vp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=vp(t,n);if(!r)return!1;let i=Il(r);if(!i)return!1;let o=i.nodeAfter;if(Dp(t,i,e,1))return!0;if(r.parent.content.size==0&&(Ur(o,"start")||V.isSelectable(o))){let s=fi(t.doc,r.before(),r.after(),L.empty);if(s&&s.slice.size{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof V,i;if(r){if(n.node.isTextblock||!Ft(t.doc,n.from))return!1;i=n.from}else if(i=Mr(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(V.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Op=(t,e)=>{let n=t.selection,r;if(n instanceof V){if(n.node.isTextblock||!Ft(t.doc,n.to))return!1;r=n.to}else if(r=Mr(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Rp=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&un(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},Dl=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
-`).scrollIntoView()),!0)};function Ll(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=Ll(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,s.createAndFill());l.setSelection(q.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},Bl=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof at||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Ll(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(vt(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&un(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function e0(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof V&&e.selection.node.isBlock)return!r.parentOffset||!vt(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,a,l=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){l=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),a=Ll(r.node(p-1).contentMatchAt(r.indexAfter(p-1)));let m=t&&t(i.parent,l,r);o.unshift(m||(l&&a?{type:a}:null)),s=p;break}else{if(p==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof G||e.selection instanceof at)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=vt(u.doc,d,o.length,o);if(f||(o[0]=a?{type:a}:null,f=vt(u.doc,d,o.length,o)),!f)return!1;if(u.split(d,o.length,o),!l&&c&&r.node(s).type!=a){let p=u.mapping.map(r.before(s)),h=u.doc.resolve(p);a&&r.node(s-1).canReplaceWith(h.index(),h.index()+1,a)&&u.setNodeMarkup(u.mapping.map(r.before(s)),a)}return n&&n(u.scrollIntoView()),!0}}var t0=e0();var Ip=(t,e)=>{let{$from:n,to:r}=t.selection,i,o=n.sharedDepth(r);return o==0?!1:(i=n.before(o),e&&e(t.tr.setSelection(V.create(t.doc,i))),!0)},n0=(t,e)=>(e&&e(t.tr.setSelection(new at(t.doc))),!0);function r0(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Ft(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Dp(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&r0(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(a=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&a.matchType(s[0]||o.type).validEnd){if(n){let p=e.pos+o.nodeSize,h=C.empty;for(let b=s.length-1;b>=0;b--)h=C.from(s[b].create(null,h));h=C.from(i.copy(h));let m=t.tr.step(new Le(e.pos-1,p,e.pos,p,new L(h,1,0),s.length,!0)),g=m.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Ft(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&l?null:q.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&un(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&Ur(o,"start",!0)&&Ur(i,"end")){let p=i,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let m=o,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(n){let b=C.empty;for(let _=h.length-1;_>=0;_--)b=C.from(h[_].copy(b));let w=t.tr.step(new Le(e.pos-h.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new L(b,h.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function Lp(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(G.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}var Fl=Lp(-1),Ul=Lp(1);function Pp(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&vr(s,t,e);return a?(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0):!1}}function $l(t,e=null){return function(n,r){let i=!1;for(let o=0;o{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let u=n.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=s.resolve(e.start-2);o=new Vn(l,l,e.depth),e.endIndex=0;u--)o=C.from(n[u].type.create(n[u].attrs,o));t.step(new Le(e.start-(r?2:0),e.end,e.start,e.end,new L(o,0,0),n.length,!0));let s=0;for(let u=0;us.childCount>0&&s.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?a0(e,n,t,o):l0(e,n,o):!0:!1}}function a0(t,e,n,r){let i=t.tr,o=r.end,s=r.$to.end(r.depth);om;h--)p-=i.child(h).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,s.content.append(l?C.empty:C.from(i))))return!1;let d=o.pos,f=d+s.nodeSize;return r.step(new Le(d-(a?1:0),f+(l?1:0),d+1,f-1,new L((a?C.empty:C.from(i.copy(C.empty))).append(l?C.empty:C.from(i.copy(C.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function Fp(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,u=C.from(c?t.create():null),d=new L(C.from(t.create(null,C.from(a.type.create(null,u)))),c?3:1,0),f=o.start,p=o.end;n(e.tr.step(new Le(f-(c?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}function $o(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;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 o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}}}var $r=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:n,state:r}=this,{view:i}=n,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...u)=>{let d=l(...u)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){let{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a=[],l=!!e,c=e||o.tr,u=()=>(!l&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),a.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,p])=>[f,(...m)=>{let g=this.buildProps(c,n),b=p(...m)(g);return a.push(b),d}])),run:u};return d}createCan(e){let{rawCommands:n,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,n=!0){let{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a={tr:e,editor:i,view:s,state:$o({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}},Vl=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){let r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){let r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}once(e,n){let r=(...i)=>{this.off(e,r),n.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}};function F(t,e,n){return t.config[e]===void 0&&t.parent?F(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?F(t.parent,e,n):null}):t.config[e]}function Ho(t){let e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function jp(t){let e=[],{nodeExtensions:n,markExtensions:r}=Ho(t),i=[...n,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{let a={name:s.name,options:s.options,storage:s.storage,extensions:i},l=F(s,"addGlobalAttributes",a);if(!l)return;l().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,p])=>{e.push({type:d,name:f,attribute:{...o,...p}})})})})}),i.forEach(s=>{let a={name:s.name,options:s.options,storage:s.storage},l=F(s,"addAttributes",a);if(!l)return;let c=l();Object.entries(c).forEach(([u,d])=>{let f={...o,...d};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:s.name,name:u,attribute:f})})}),e}function Ue(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function ee(...t){return t.filter(e=>!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){let a=o?String(o).split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(u=>!l.includes(u));r[i]=[...l,...c].join(" ")}else if(i==="style"){let a=o?o.split(";").map(u=>u.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{let[d,f]=u.split(":").map(p=>p.trim());c.set(d,f)}),a.forEach(u=>{let[d,f]=u.split(":").map(p=>p.trim());c.set(d,f)}),r[i]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[i]=o}),r},{})}function ql(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>ee(n,r),{})}function Yp(t){return typeof t=="function"}function re(t,e=void 0,...n){return Yp(t)?e?t.bind(e)(...n):t(...n):t}function c0(t={}){return Object.keys(t).length===0&&t.constructor===Object}function u0(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Up(t,e){return"style"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let i=e.reduce((o,s)=>{let a=s.attribute.parseHTML?s.attribute.parseHTML(n):u0(n.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function $p(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&c0(n)?!1:n!=null))}function d0(t,e){var n;let r=jp(t),{nodeExtensions:i,markExtensions:o}=Ho(t),s=(n=i.find(c=>F(c,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(i.map(c=>{let u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((b,w)=>{let _=F(w,"extendNodeSchema",d);return{...b,..._?_(c):{}}},{}),p=$p({...f,content:re(F(c,"content",d)),marks:re(F(c,"marks",d)),group:re(F(c,"group",d)),inline:re(F(c,"inline",d)),atom:re(F(c,"atom",d)),selectable:re(F(c,"selectable",d)),draggable:re(F(c,"draggable",d)),code:re(F(c,"code",d)),whitespace:re(F(c,"whitespace",d)),linebreakReplacement:re(F(c,"linebreakReplacement",d)),defining:re(F(c,"defining",d)),isolating:re(F(c,"isolating",d)),attrs:Object.fromEntries(u.map(b=>{var w;return[b.name,{default:(w=b?.attribute)===null||w===void 0?void 0:w.default}]}))}),h=re(F(c,"parseHTML",d));h&&(p.parseDOM=h.map(b=>Up(b,u)));let m=F(c,"renderHTML",d);m&&(p.toDOM=b=>m({node:b,HTMLAttributes:ql(b,u)}));let g=F(c,"renderText",d);return g&&(p.toText=g),[c.name,p]})),l=Object.fromEntries(o.map(c=>{let u=r.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((g,b)=>{let w=F(b,"extendMarkSchema",d);return{...g,...w?w(c):{}}},{}),p=$p({...f,inclusive:re(F(c,"inclusive",d)),excludes:re(F(c,"excludes",d)),group:re(F(c,"group",d)),spanning:re(F(c,"spanning",d)),code:re(F(c,"code",d)),attrs:Object.fromEntries(u.map(g=>{var b;return[g.name,{default:(b=g?.attribute)===null||b===void 0?void 0:b.default}]}))}),h=re(F(c,"parseHTML",d));h&&(p.parseDOM=h.map(g=>Up(g,u)));let m=F(c,"renderHTML",d);return m&&(p.toDOM=g=>m({mark:g,HTMLAttributes:ql(g,u)})),[c.name,p]}));return new ii({topNode:s,nodes:a,marks:l})}function Wl(t,e){return e.nodes[t]||e.marks[t]||null}function Hp(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Ql(t,e){let n=ln.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}var f0=(t,e=500)=>{let n="",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,a)=>{var l,c;let u=((c=(l=i.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:i,pos:o,parent:s,index:a}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-o))}),n};function ec(t){return Object.prototype.toString.call(t)==="[object RegExp]"}var Hr=class{constructor(e){this.find=e.find,this.handler=e.handler}},p0=(t,e)=>{if(ec(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Io(t){var e;let{editor:n,from:r,to:i,text:o,rules:s,plugin:a}=t,{view:l}=n;if(l.composing)return!1;let c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1,d=f0(c)+o;return s.forEach(f=>{if(u)return;let p=p0(d,f.find);if(!p)return;let h=l.state.tr,m=$o({state:l.state,transaction:h}),g={from:r-(p[0].length-o.length),to:i},{commands:b,chain:w,can:_}=new $r({editor:n,state:m});f.handler({state:m,range:g,match:p,commands:b,chain:w,can:_})===null||!h.steps.length||(h.setMeta(a,{transform:h,from:r,to:i,text:o}),l.dispatch(h),u=!0)}),u}function h0(t){let{editor:e,rules:n}=t,r=new me({state:{init(){return null},apply(i,o,s){let a=i.getMeta(r);if(a)return a;let l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=Ql(C.from(u),s.schema);let{from:d}=l,f=d+u.length;Io({editor:e,from:d,to:f,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,a){return Io({editor:e,from:o,to:s,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{let{$cursor:o}=i.state.selection;o&&Io({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;let{$cursor:s}=i.state.selection;return s?Io({editor:e,from:s.pos,to:s.pos,text:`
-`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function m0(t){return Object.prototype.toString.call(t).slice(8,-1)}function Do(t){return m0(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Wo(t,e){let n={...t};return Do(t)&&Do(e)&&Object.keys(e).forEach(r=>{Do(e[r])&&Do(t[r])?n[r]=Wo(t[r],e[r]):n[r]=e[r]}),n}var ut=class t{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=re(F(this,"addOptions",{name:this.name}))),this.storage=re(F(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new t(e)}configure(e={}){let n=this.extend({...this.config,addOptions:()=>Wo(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){let n=new t(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=re(F(n,"addOptions",{name:n.name})),n.storage=re(F(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let s=i.marks();if(!!!s.find(c=>c?.type.name===n.name))return!1;let l=s.find(c=>c?.type.name===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}};function g0(t){return typeof t=="number"}var jl=class{constructor(e){this.find=e.find,this.handler=e.handler}},b0=(t,e,n)=>{if(ec(e))return[...t.matchAll(e)];let r=e(t,n);return r?r.map(i=>{let o=[i.text];return o.index=i.index,o.input=t,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function y0(t){let{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:c,can:u}=new $r({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(p,h)=>{if(!p.isTextblock||p.type.spec.code)return;let m=Math.max(r,h),g=Math.min(i,h+p.content.size),b=p.textBetween(m-h,g-h,void 0,"\uFFFC");b0(b,o.find,s).forEach(_=>{if(_.index===void 0)return;let T=m+_.index+1,A=T+_[0].length,R={from:n.tr.mapping.map(T),to:n.tr.mapping.map(A)},D=o.handler({state:n,range:R,match:_,commands:l,chain:c,can:u,pasteEvent:s,dropEvent:a});d.push(D)})}),d.every(p=>p!==null)}var Lo=null,E0=t=>{var e;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function k0(t){let{editor:e,rules:n}=t,r=null,i=!1,o=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}let l=({state:u,from:d,to:f,rule:p,pasteEvt:h})=>{let m=u.tr,g=$o({state:u,transaction:m});if(!(!y0({editor:e,state:g,from:Math.max(d-1,0),to:f.b-1,rule:p,pasteEvent:h,dropEvent:a})||!m.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(u=>new me({view(d){let f=h=>{var m;r=!((m=d.dom.parentElement)===null||m===void 0)&&m.contains(h.target)?d.dom.parentElement:null,r&&(Lo=e)},p=()=>{Lo&&(Lo=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(o=r===d.dom.parentElement,a=f,!o){let p=Lo;p?.isEditable&&setTimeout(()=>{let h=p.state.selection;h&&p.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(d,f)=>{var p;let h=(p=f.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=f,i=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,p)=>{let h=d[0],m=h.getMeta("uiEvent")==="paste"&&!i,g=h.getMeta("uiEvent")==="drop"&&!o,b=h.getMeta("applyPasteRules"),w=!!b;if(!m&&!g&&!w)return;if(w){let{text:A}=b;typeof A=="string"?A=A:A=Ql(C.from(A),p.schema);let{from:R}=b,D=R+A.length,B=E0(A);return l({rule:u,state:p,from:R,to:{b:D},pasteEvt:B})}let _=f.doc.content.findDiffStart(p.doc.content),T=f.doc.content.findDiffEnd(p.doc.content);if(!(!g0(_)||!T||_===T.b))return l({rule:u,state:p,from:_,to:T,pasteEvt:s})}}))}function w0(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}var Yl=class t{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=t.resolve(e),this.schema=d0(this.extensions,n),this.setupExtensions()}static resolve(e){let n=t.sort(t.flatten(e)),r=w0(n.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),n}static flatten(e){return e.map(n=>{let r={name:n.name,options:n.options,storage:n.storage},i=F(n,"addExtensions",r);return i?[n,...this.flatten(i())]:n}).flat(10)}static sort(e){return e.sort((r,i)=>{let o=F(r,"priority")||100,s=F(i,"priority")||100;return o>s?-1:o{let r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Wl(n.name,this.schema)},i=F(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){let{editor:e}=this,n=t.sort([...this.extensions].reverse()),r=[],i=[],o=n.map(s=>{let a={name:s.name,options:s.options,storage:s.storage,editor:e,type:Wl(s.name,this.schema)},l=[],c=F(s,"addKeyboardShortcuts",a),u={};if(s.type==="mark"&&F(s,"exitable",a)&&(u.ArrowRight=()=>ut.handleExit({editor:e,mark:s})),c){let m=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));u={...u,...m}}let d=xp(u);l.push(d);let f=F(s,"addInputRules",a);Hp(s,e.options.enableInputRules)&&f&&r.push(...f());let p=F(s,"addPasteRules",a);Hp(s,e.options.enablePasteRules)&&p&&i.push(...p());let h=F(s,"addProseMirrorPlugins",a);if(h){let m=h();l.push(...m)}return l}).flat();return[h0({editor:e,rules:r}),...k0({editor:e,rules:i}),...o]}get attributes(){return jp(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:n}=Ho(this.extensions);return Object.fromEntries(n.filter(r=>!!F(r,"addNodeView")).map(r=>{let i=this.attributes.filter(l=>l.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:e,type:Ue(r.name,this.schema)},s=F(r,"addNodeView",o);if(!s)return[];let a=(l,c,u,d,f)=>{let p=ql(l,i);return s()({node:l,view:c,getPos:u,decorations:d,innerDecorations:f,editor:e,extension:r,HTMLAttributes:p})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var n;this.editor.extensionStorage[e.name]=e.storage;let r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Wl(e.name,this.schema)};e.type==="mark"&&(!((n=re(F(e,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(e.name);let i=F(e,"onBeforeCreate",r),o=F(e,"onCreate",r),s=F(e,"onUpdate",r),a=F(e,"onSelectionUpdate",r),l=F(e,"onTransaction",r),c=F(e,"onFocus",r),u=F(e,"onBlur",r),d=F(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),s&&this.editor.on("update",s),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}},$e=class t{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=re(F(this,"addOptions",{name:this.name}))),this.storage=re(F(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new t(e)}configure(e={}){let n=this.extend({...this.config,addOptions:()=>Wo(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){let n=new t({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=re(F(n,"addOptions",{name:n.name})),n.storage=re(F(n,"addStorage",{name:n.name,options:n.options})),n}};function Jp(t,e,n){let{from:r,to:i}=e,{blockSeparator:o=`
-
-`,textSerializers:s={}}=n||{},a="";return t.nodesBetween(r,i,(l,c,u,d)=>{var f;l.isBlock&&c>r&&(a+=o);let p=s?.[l.type.name];if(p)return u&&(a+=p({node:l,pos:c,parent:u,index:d,range:e})),!1;l.isText&&(a+=(f=l?.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,i-c))}),a}function Zp(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}var S0=$e.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new me({key:new _e("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(u=>u.$from.pos)),a=Math.max(...o.map(u=>u.$to.pos)),l=Zp(n);return Jp(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),x0=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),_0=(t=!1)=>({commands:e})=>e.setContent("",t),T0=()=>({state:t,tr:e,dispatch:n})=>{let{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:o,$to:s})=>{t.doc.nodesBetween(o.pos,s.pos,(a,l)=>{if(a.type.isText)return;let{doc:c,mapping:u}=e,d=c.resolve(u.map(l)),f=c.resolve(u.map(l+a.nodeSize)),p=d.blockRange(f);if(!p)return;let h=un(p);if(a.type.isTextblock){let{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(p.start,m)}(h||h===0)&&e.lift(p,h)})}),!0},C0=t=>e=>t(e),N0=()=>({state:t,dispatch:e})=>Bl(t,e),A0=(t,e)=>({editor:n,tr:r})=>{let{state:i}=n,o=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new G(r.doc.resolve(Math.max(s-1,0)))),!0},v0=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let i=t.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){let a=i.before(o),l=i.after(o);t.delete(a,l).scrollIntoView()}return!0}return!1},M0=t=>({tr:e,state:n,dispatch:r})=>{let i=Ue(t,n.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){let l=o.before(s),c=o.after(s);e.delete(l,c).scrollIntoView()}return!0}return!1},O0=t=>({tr:e,dispatch:n})=>{let{from:r,to:i}=t;return n&&e.delete(r,i),!0},R0=()=>({state:t,dispatch:e})=>Ro(t,e),I0=()=>({commands:t})=>t.keyboardShortcut("Enter"),D0=()=>({state:t,dispatch:e})=>Pl(t,e);function zo(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:ec(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Xp(t,e,n={}){return t.find(r=>r.type===e&&zo(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function Wp(t,e,n={}){return!!Xp(t,e,n)}function tc(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(n=n||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!Xp([...i.node.marks],e,n)))return;let s=i.index,a=t.start()+i.offset,l=s+1,c=a+i.node.nodeSize;for(;s>0&&Wp([...t.parent.child(s-1).marks],e,n);)s-=1,a-=t.parent.child(s).nodeSize;for(;l({tr:n,state:r,dispatch:i})=>{let o=Dn(t,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){let d=tc(l,o,e);if(d&&d.from<=c&&d.to>=u){let f=G.create(s,d.from,d.to);n.setSelection(f)}}return!0},P0=t=>e=>{let n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};let s=()=>{(Fo()||Kp())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),B0()&&!Fo()&&!Kp()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!Qp(n.state.selection))return s(),!0;let a=eh(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},F0=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),U0=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),th=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&th(r)}return t};function Po(t){let e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return th(n)}function _i(t,e,n){if(t instanceof At||t instanceof C)return t;n={slice:!0,parseOptions:{},...n};let r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return C.fromArray(t.map(a=>e.nodeFromJSON(a)));let s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),_i("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,a="",l=new ii({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:c=>(s=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?an.fromSchema(l).parseSlice(Po(t),n.parseOptions):an.fromSchema(l).parse(Po(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}let o=an.fromSchema(e);return n.slice?o.parseSlice(Po(t),n.parseOptions).content:o.parse(Po(t),n.parseOptions)}return _i("",e,n)}function $0(t,e,n){let r=t.steps.length-1;if(r{s===0&&(s=u)}),t.setSelection(q.near(t.doc.resolve(s),n))}var H0=t=>!("type"in t),W0=(t,e,n)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a,l=g=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{_i(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=_i(e,o.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(g){return l(g),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,p=!0;if((H0(a)?a:[a]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),u===d&&p){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(f){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof C){let g="";e.forEach(b=>{b.text&&(g+=b.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else m=a,r.replaceWith(u,d,m);n.updateSelection&&$0(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},K0=()=>({state:t,dispatch:e})=>Mp(t,e),G0=()=>({state:t,dispatch:e})=>Op(t,e),V0=()=>({state:t,dispatch:e})=>Al(t,e),q0=()=>({state:t,dispatch:e})=>Ol(t,e),j0=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Mr(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Y0=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Mr(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},J0=()=>({state:t,dispatch:e})=>Cp(t,e),Z0=()=>({state:t,dispatch:e})=>Np(t,e);function nh(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function X0(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==="Space"&&(n=" ");let r,i,o,s;for(let a=0;a({editor:e,view:n,tr:r,dispatch:i})=>{let o=X0(t).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l?.steps.forEach(c=>{let u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Ti(t,e,n={}){let{from:r,to:i,empty:o}=t.selection,s=e?Ue(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;let p=Math.max(r,f),h=Math.min(i,f+d.nodeSize);a.push({node:d,from:p,to:h})});let l=i-r,c=a.filter(d=>s?s.name===d.node.type.name:!0).filter(d=>zo(d.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=l}var eS=(t,e={})=>({state:n,dispatch:r})=>{let i=Ue(t,n.schema);return Ti(n,i,e)?Rp(n,r):!1},tS=()=>({state:t,dispatch:e})=>zl(t,e),nS=t=>({state:e,dispatch:n})=>{let r=Ue(t,e.schema);return zp(r)(e,n)},rS=()=>({state:t,dispatch:e})=>Dl(t,e);function Ko(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Gp(t,e){let n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var iS=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null,a=Ko(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=Ue(t,r.schema)),a==="mark"&&(s=Dn(t,r.schema)),i&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,u)=>{o&&o===c.type&&n.setNodeMarkup(u,void 0,Gp(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(d=>{s===d.type&&n.addMark(u,u+c.nodeSize,s.create(Gp(d.attrs,e)))})})}),!0):!1},oS=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),sS=()=>({tr:t,dispatch:e})=>{if(e){let n=new at(t.doc);t.setSelection(n)}return!0},aS=()=>({state:t,dispatch:e})=>vl(t,e),lS=()=>({state:t,dispatch:e})=>Rl(t,e),cS=()=>({state:t,dispatch:e})=>Ip(t,e),uS=()=>({state:t,dispatch:e})=>Ul(t,e),dS=()=>({state:t,dispatch:e})=>Fl(t,e);function Jl(t,e,n={},r={}){return _i(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var fS=(t,e=!1,n={},r={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{var l,c;let{doc:u}=o;if(n.preserveWhitespace!=="full"){let d=Jl(t,i.schema,n,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:i.options.enableContentCheck});return s&&o.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:u.content.size},t,{parseOptions:n,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function rh(t,e){let n=Dn(e,t.schema),{from:r,to:i,empty:o}=t.selection,s=[];o?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{s.push(...l.marks)});let a=s.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function ih(t,e){let n=new Cn(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function pS(t){for(let e=0;e{e(r)&&n.push({node:r,pos:i})}),n}function oh(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function nc(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function rc(t){return e=>nc(e.$from,t)}function hS(t,e){let n={from:0,to:t.content.size};return Jp(t,n,e)}function mS(t,e){let n=Ue(e,t.schema),{from:r,to:i}=t.selection,o=[];t.doc.nodesBetween(r,i,a=>{o.push(a)});let s=o.reverse().find(a=>a.type.name===n.name);return s?{...s.attrs}:{}}function ic(t,e){let n=Ko(typeof e=="string"?e:e.name,t.schema);return n==="node"?mS(t,e):n==="mark"?rh(t,e):{}}function gS(t,e=JSON.stringify){let n={};return t.filter(r=>{let i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function bS(t){let e=gS(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,s)=>s!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function sh(t){let{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,o)=>{let s=[];if(i.ranges.length)i.forEach((a,l)=>{s.push({from:a,to:l})});else{let{from:a,to:l}=n[o];if(a===void 0||l===void 0)return;s.push({from:a,to:l})}s.forEach(({from:a,to:l})=>{let c=e.slice(o).map(a,-1),u=e.slice(o).map(l),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),bS(r)}function Vo(t,e,n){let r=[];return t===e?n.resolve(t).marks().forEach(i=>{let o=n.resolve(t),s=tc(o,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,o)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}function Bo(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let i=t.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function Zl(t,e,n={}){let{empty:r,ranges:i}=t.selection,o=e?Dn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>o?o.name===d.type.name:!0).find(d=>zo(d.attrs,n,{strict:!1}));let s=0,a=[];if(i.forEach(({$from:d,$to:f})=>{let p=d.pos,h=f.pos;t.doc.nodesBetween(p,h,(m,g)=>{if(!m.isText&&!m.marks.length)return;let b=Math.max(p,g),w=Math.min(h,g+m.nodeSize),_=w-b;s+=_,a.push(...m.marks.map(T=>({mark:T,from:b,to:w})))})}),s===0)return!1;let l=a.filter(d=>o?o.name===d.mark.type.name:!0).filter(d=>zo(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=a.filter(d=>o?d.mark.type!==o&&d.mark.type.excludes(o):!0).reduce((d,f)=>d+f.to-f.from,0);return(l>0?l+c:l)>=s}function yS(t,e,n={}){if(!e)return Ti(t,null,n)||Zl(t,null,n);let r=Ko(e,t.schema);return r==="node"?Ti(t,e,n):r==="mark"?Zl(t,e,n):!1}function Vp(t,e){let{nodeExtensions:n}=Ho(e),r=n.find(s=>s.name===t);if(!r)return!1;let i={name:r.name,options:r.options,storage:r.storage},o=re(F(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function oc(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!==null&&r!==void 0?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(o=>{i!==!1&&(oc(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function ah(t){return t instanceof V}function ES(t,e,n){var r;let{selection:i}=e,o=null;if(Qp(i)&&(o=i.$cursor),o){let a=(r=t.storedMarks)!==null&&r!==void 0?r:o.marks();return!!n.isInSet(a)||!a.some(l=>l.type.excludes(n))}let{ranges:s}=i;return s.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let p=!f||f.type.allowsMarkType(n),h=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=p&&h}return!c}),c})}var kS=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let{selection:o}=n,{empty:s,ranges:a}=o,l=Dn(t,r.schema);if(i)if(s){let c=rh(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,p)=>{let h=Math.max(p,u),m=Math.min(p+f.nodeSize,d);f.marks.find(b=>b.type===l)?f.marks.forEach(b=>{l===b.type&&n.addMark(h,m,l.create({...b.attrs,...e}))}):n.addMark(h,m,l.create(e))})});return ES(r,n,l)},wS=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),SS=(t,e={})=>({state:n,dispatch:r,chain:i})=>{let o=Ue(t,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:a})=>$l(o,{...s,...e})(n)?!0:a.clearNodes()).command(({state:a})=>$l(o,{...s,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},xS=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,i=ir(t,0,r.content.size),o=V.create(r,i);e.setSelection(o)}return!0},_S=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,s=G.atStart(r).from,a=G.atEnd(r).to,l=ir(i,s,a),c=ir(o,s,a),u=G.create(r,l,c);e.setSelection(u)}return!0},TS=t=>({state:e,dispatch:n})=>{let r=Ue(t,e.schema);return Fp(r)(e,n)};function qp(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var CS=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{let{selection:o,doc:s}=e,{$from:a,$to:l}=o,c=i.extensionManager.attributes,u=Bo(c,a.node().type.name,a.node().attrs);if(o instanceof V&&o.node.isBlock)return!a.parentOffset||!vt(s,a.pos)?!1:(r&&(t&&qp(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;let d=l.parentOffset===l.parent.content.size,f=a.depth===0?void 0:pS(a.node(-1).contentMatchAt(a.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,h=vt(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!h&&vt(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(h=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(h&&(o instanceof G&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),f&&!d&&!a.parentOffset&&a.parent.type!==f)){let m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}t&&qp(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return h},NS=(t,e={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;let a=Ue(t,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;let d=l.node(-1);if(d.type!==a)return!1;let f=o.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let b=C.empty,w=l.index(-1)?1:l.index(-2)?2:3;for(let B=l.depth-w;B>=l.depth-3;B-=1)b=C.from(l.node(B).copy(b));let _=l.indexAfter(-1){if(D>-1)return!1;B.isTextblock&&B.content.size===0&&(D=K+1)}),D>-1&&n.setSelection(G.near(n.doc.resolve(D))),n.scrollIntoView()}return!0}let p=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,h={...Bo(f,d.type.name,d.attrs),...e},m={...Bo(f,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);let g=p?[{type:a,attrs:h},{type:p,attrs:m}]:[{type:a,attrs:h}];if(!vt(n.doc,l.pos,2))return!1;if(i){let{selection:b,storedMarks:w}=r,{splittableMarks:_}=o.extensionManager,T=w||b.$to.parentOffset&&b.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!T||!i)return!0;let A=T.filter(R=>_.includes(R.type.name));n.ensureMarks(A)}return!0},Kl=(t,e)=>{let n=rc(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=t.doc.nodeAt(r);return n.node.type===i?.type&&Ft(t.doc,n.pos)&&t.join(n.pos),!0},Gl=(t,e)=>{let n=rc(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=t.doc.nodeAt(r);return n.node.type===i?.type&&Ft(t.doc,r)&&t.join(r),!0},AS=(t,e,n,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=Ue(t,s.schema),h=Ue(e,s.schema),{selection:m,storedMarks:g}=s,{$from:b,$to:w}=m,_=b.blockRange(w),T=g||m.$to.parentOffset&&m.$from.marks();if(!_)return!1;let A=rc(R=>Vp(R.type.name,d))(m);if(_.depth>=1&&A&&_.depth-A.depth<=1){if(A.node.type===p)return c.liftListItem(h);if(Vp(A.node.type.name,d)&&p.validContent(A.node.content)&&a)return l().command(()=>(o.setNodeMarkup(A.pos,p),!0)).command(()=>Kl(o,p)).command(()=>Gl(o,p)).run()}return!n||!T||!a?l().command(()=>u().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>Kl(o,p)).command(()=>Gl(o,p)).run():l().command(()=>{let R=u().wrapInList(p,r),D=T.filter(B=>f.includes(B.type.name));return o.ensureMarks(D),R?!0:c.clearNodes()}).wrapInList(p,r).command(()=>Kl(o,p)).command(()=>Gl(o,p)).run()},vS=(t,e={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:o=!1}=n,s=Dn(t,r.schema);return Zl(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},MS=(t,e,n={})=>({state:r,commands:i})=>{let o=Ue(t,r.schema),s=Ue(e,r.schema),a=Ti(r,o,n),l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(s,l):i.setNode(o,{...l,...n})},OS=(t,e={})=>({state:n,commands:r})=>{let i=Ue(t,n.schema);return Ti(n,i,e)?r.lift(i):r.wrapIn(i,e)},RS=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r=0;l-=1)s.step(a.steps[l].invert(a.docs[l]));if(o.text){let l=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,t.schema.text(o.text,l))}else s.delete(o.from,o.to)}return!0}}return!1},IS=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},DS=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;let{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=Dn(t,r.schema),{$from:c,empty:u,ranges:d}=a;if(!i)return!0;if(u&&s){let{from:f,to:p}=a,h=(o=c.marks().find(g=>g.type===l))===null||o===void 0?void 0:o.attrs,m=tc(c,l,h);m&&(f=m.from,p=m.to),n.removeMark(f,p,l)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},LS=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null,a=Ko(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=Ue(t,r.schema)),a==="mark"&&(s=Dn(t,r.schema)),i&&n.selection.ranges.forEach(l=>{let c=l.$from.pos,u=l.$to.pos,d,f,p,h;n.selection.empty?r.doc.nodesBetween(c,u,(m,g)=>{o&&o===m.type&&(p=Math.max(g,c),h=Math.min(g+m.nodeSize,u),d=g,f=m)}):r.doc.nodesBetween(c,u,(m,g)=>{g=c&&g<=u&&(o&&o===m.type&&n.setNodeMarkup(g,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(b=>{if(s===b.type){let w=Math.max(g,c),_=Math.min(g+m.nodeSize,u);n.addMark(w,_,s.create({...b.attrs,...e}))}}))}),f&&(d!==void 0&&n.setNodeMarkup(d,void 0,{...f.attrs,...e}),s&&f.marks.length&&f.marks.forEach(m=>{s===m.type&&n.addMark(p,h,s.create({...m.attrs,...e}))}))}),!0):!1},PS=(t,e={})=>({state:n,dispatch:r})=>{let i=Ue(t,n.schema);return Pp(i,e)(n,r)},BS=(t,e={})=>({state:n,dispatch:r})=>{let i=Ue(t,n.schema);return Bp(i,e)(n,r)},zS=Object.freeze({__proto__:null,blur:x0,clearContent:_0,clearNodes:T0,command:C0,createParagraphNear:N0,cut:A0,deleteCurrentNode:v0,deleteNode:M0,deleteRange:O0,deleteSelection:R0,enter:I0,exitCode:D0,extendMarkRange:L0,first:P0,focus:z0,forEach:F0,insertContent:U0,insertContentAt:W0,joinBackward:V0,joinDown:G0,joinForward:q0,joinItemBackward:j0,joinItemForward:Y0,joinTextblockBackward:J0,joinTextblockForward:Z0,joinUp:K0,keyboardShortcut:Q0,lift:eS,liftEmptyBlock:tS,liftListItem:nS,newlineInCode:rS,resetAttributes:iS,scrollIntoView:oS,selectAll:sS,selectNodeBackward:aS,selectNodeForward:lS,selectParentNode:cS,selectTextblockEnd:uS,selectTextblockStart:dS,setContent:fS,setMark:kS,setMeta:wS,setNode:SS,setNodeSelection:xS,setTextSelection:_S,sinkListItem:TS,splitBlock:CS,splitListItem:NS,toggleList:AS,toggleMark:vS,toggleNode:MS,toggleWrap:OS,undoInputRule:RS,unsetAllMarks:IS,unsetMark:DS,updateAttributes:LS,wrapIn:PS,wrapInList:BS}),FS=$e.create({name:"commands",addCommands(){return{...zS}}}),US=$e.create({name:"drop",addProseMirrorPlugins(){return[new me({key:new _e("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),$S=$e.create({name:"editable",addProseMirrorPlugins(){return[new me({key:new _e("editable"),props:{editable:()=>this.editor.options.editable}})]}}),HS=new _e("focusEvents"),WS=$e.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:t}=this;return[new me({key:HS,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),KS=$e.create({name:"keymap",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:a})=>{let{selection:l,doc:c}=a,{empty:u,$anchor:d}=l,{pos:f,parent:p}=d,h=d.parent.isTextblock&&f>0?a.doc.resolve(f-1):d,m=h.parent.type.spec.isolating,g=d.pos-d.parentOffset,b=m&&h.parent.childCount===1?g===d.pos:q.atStart(c).from===f;return!u||!p.type.isTextblock||p.textContent.length||!b||b&&d.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()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"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 Fo()||nh()?o:i},addProseMirrorPlugins(){return[new me({key:new _e("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;let r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),i=t.some(m=>m.getMeta("preventClearDocument"));if(!r||i)return;let{empty:o,from:s,to:a}=e.selection,l=q.atStart(e.doc).from,c=q.atEnd(e.doc).to;if(o||!(s===l&&a===c)||!oc(n.doc))return;let f=n.tr,p=$o({state:n,transaction:f}),{commands:h}=new $r({editor:this.editor,state:p});if(h.clearNodes(),!!f.steps.length)return f}})]}}),GS=$e.create({name:"paste",addProseMirrorPlugins(){return[new me({key:new _e("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),VS=$e.create({name:"tabindex",addProseMirrorPlugins(){return[new me({key:new _e("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});var Xl=class t{get name(){return this.node.type.name}constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}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!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},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;let e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new t(n,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 t(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 t(e,this.editor)}get children(){let e=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,s=this.pos+r+(o?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(s);if(!i&&a.depth<=this.depth)return;let l=new t(a,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new t(a,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){let o=i.node.attrs,s=Object.keys(n);for(let a=0;a{r&&i.length>0||(s.node.type.name===e&&o.every(l=>n[l]===s.node.attrs[l])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,n,r))))}),i}setAttribute(e){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},qS=`.ProseMirror {
+var wE=Object.create;var Aa=Object.defineProperty;var SE=Object.getOwnPropertyDescriptor;var xE=Object.getOwnPropertyNames;var _E=Object.getPrototypeOf,CE=Object.prototype.hasOwnProperty;var TE=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),NE=(t,e)=>{for(var n in e)Aa(t,n,{get:e[n],enumerable:!0})},AE=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of xE(e))!CE.call(t,i)&&i!==n&&Aa(t,i,{get:()=>e[i],enumerable:!(r=SE(e,i))||r.enumerable});return t};var vE=(t,e,n)=>(n=t!=null?wE(_E(t)):{},AE(e||!t||!t.__esModule?Aa(n,"default",{value:t,enumerable:!0}):n,t));var Mb=TE((yI,vb)=>{function bb(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw new Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw new Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(e=>{let n=t[e],r=typeof n;(r==="object"||r==="function")&&!Object.isFrozen(n)&&bb(n)}),t}var Xs=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function yb(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function Un(t,...e){let n=Object.create(null);for(let r in t)n[r]=t[r];return e.forEach(function(r){for(let i in r)n[i]=r[i]}),n}var EC="