1||l==0||m.content.size)&&(d=b,u.push(OE(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=zc(this.placed,r,N.from(u)),this.frontier[r].match=d,h&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,b=a;m1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(t){e:for(let r=Math.min(this.depth,t.depth);r>=0;r--){let{match:n,type:o}=this.frontier[r],i=r=0;a--){let{match:l,type:c}=this.frontier[a],u=gg(t,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:r,fit:s,move:i?t.doc.resolve(t.after(r+1)):t}}}}close(t){let r=this.findCloseLevel(t);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=zc(this.placed,r.depth,r.fit)),t=r.move;for(let n=r.depth+1;n<=t.depth;n++){let o=t.node(n),i=o.type.contentMatch.fillBefore(o.content,!0,t.index(n));this.openFrontierNode(o.type,o.attrs,i)}return t}openFrontierNode(t,r=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=zc(this.placed,this.depth,N.from(t.create(r,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(N.empty,!0);r.childCount&&(this.placed=zc(this.placed,this.frontier.length,r))}}function Pc(e,t,r){return t==0?e.cutByIndex(r,e.childCount):e.replaceChild(0,e.firstChild.copy(Pc(e.firstChild.content,t-1,r)))}function zc(e,t,r){return t==0?e.append(r):e.replaceChild(e.childCount-1,e.lastChild.copy(zc(e.lastChild.content,t-1,r)))}function mg(e,t){for(let r=0;r1&&(n=n.replaceChild(0,OE(n.firstChild,t-1,n.childCount==1?r-1:0))),t>0&&(n=e.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(e.type.contentMatch.matchFragment(n).fillBefore(N.empty,!0)))),e.copy(n)}function gg(e,t,r,n,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!r.compatibleContent(i.type))return null;let a=n.fillBefore(i.content,!0,s);return a&&!iR(r,i.content,s)?a:null}function iR(e,t,r){for(let n=r;n0;f--,p--){let h=o.node(f).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(f)>-1?a=f:o.before(f)==p&&s.splice(1,0,-f)}let l=s.indexOf(a),c=[],u=n.openStart;for(let f=n.content,p=0;;p++){let h=f.firstChild;if(c.push(h),p==n.openStart)break;f=h.content}for(let f=u-1;f>=0;f--){let p=c[f],h=sR(p.type);if(h&&!p.sameMarkup(o.node(Math.abs(a)-1)))u=f;else if(h||!p.type.isTextblock)break}for(let f=n.openStart;f>=0;f--){let p=(f+u+1)%(n.openStart+1),h=c[p];if(h)for(let m=0;m=0&&(e.replace(t,r,n),!(e.steps.length>d));f--){let p=s[f];p<0||(t=o.before(p),r=i.after(p))}}function _E(e,t,r,n,o){if(tn){let i=o.contentMatchAt(0),s=i.fillBefore(e).append(e);e=s.append(i.matchFragment(s).fillBefore(N.empty,!0))}return e}function lR(e,t,r,n){if(!n.isInline&&t==r&&e.doc.resolve(t).parent.content.size){let o=ME(e.doc,t,n.type);o!=null&&(t=r=o)}e.replaceRange(t,r,new W(N.from(n),0,0))}function cR(e,t,r){let n=e.doc.resolve(t),o=e.doc.resolve(r),i=AE(n,o);for(let s=0;s0&&(l||n.node(a-1).canReplace(n.index(a-1),o.indexAfter(a-1))))return e.delete(n.before(a),o.after(a))}for(let s=1;s<=n.depth&&s<=o.depth;s++)if(t-n.start(s)==n.depth-s&&r>n.end(s)&&o.end(s)-r!=o.depth-s)return e.delete(n.before(s),r);e.delete(t,r)}function AE(e,t){let r=[],n=Math.min(e.depth,t.depth);for(let o=n;o>=0;o--){let i=e.start(o);if(it.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(i==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==i-1)&&r.push(o)}return r}class hl extends Dt{constructor(t,r,n){super(),this.pos=t,this.attr=r,this.value=n}apply(t){let r=t.nodeAt(this.pos);if(!r)return wt.fail("No node at attribute step's position");let n=Object.create(null);for(let i in r.attrs)n[i]=r.attrs[i];n[this.attr]=this.value;let o=r.type.create(n,null,r.marks);return wt.fromReplace(t,this.pos,this.pos+1,new W(N.from(o),0,r.isLeaf?0:1))}getMap(){return sn.empty}invert(t){return new hl(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let r=t.mapResult(this.pos,1);return r.deletedAfter?null:new hl(r.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,r){if(typeof r.pos!="number"||typeof r.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new hl(r.pos,r.attr,r.value)}}Dt.jsonID("attr",hl);class Iu extends Dt{constructor(t,r){super(),this.attr=t,this.value=r}apply(t){let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let n=t.type.create(r,t.content,t.marks);return wt.ok(n)}getMap(){return sn.empty}invert(t){return new Iu(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,r){if(typeof r.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Iu(r.attr,r.value)}}Dt.jsonID("docAttr",Iu);let Rl=class extends Error{};Rl=function e(t){let r=Error.call(this,t);return r.__proto__=e.prototype,r};Rl.prototype=Object.create(Error.prototype);Rl.prototype.constructor=Rl;Rl.prototype.name="TransformError";class uR{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new fl}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let r=this.maybeStep(t);if(r.failed)throw new Rl(r.failed);return this}maybeStep(t){let r=t.apply(this.doc);return r.failed||this.addStep(t,r.doc),r}get docChanged(){return this.steps.length>0}addStep(t,r){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=r}replace(t,r=t,n=W.empty){let o=zv(this.doc,t,r,n);return o&&this.step(o),this}replaceWith(t,r,n){return this.replace(t,r,new W(N.from(n),0,0))}delete(t,r){return this.replace(t,r,W.empty)}insert(t,r){return this.replaceWith(t,t,r)}replaceRange(t,r,n){return aR(this,t,r,n),this}replaceRangeWith(t,r,n){return lR(this,t,r,n),this}deleteRange(t,r){return cR(this,t,r),this}lift(t,r){return qA(this,t,r),this}join(t,r=1){return rR(this,t,r),this}wrap(t,r){return XA(this,t,r),this}setBlockType(t,r=t,n,o=null){return JA(this,t,r,n,o),this}setNodeMarkup(t,r,n=null,o){return ZA(this,t,r,n,o),this}setNodeAttribute(t,r,n){return this.step(new hl(t,r,n)),this}setDocAttribute(t,r){return this.step(new Iu(t,r)),this}addNodeMark(t,r){return this.step(new Ii(t,r)),this}removeNodeMark(t,r){if(!(r instanceof _e)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(r=r.isInSet(n.marks),!r)return this}return this.step(new Al(t,r)),this}split(t,r=1,n){return eR(this,t,r,n),this}addMark(t,r,n){return jA(this,t,r,n),this}removeMark(t,r,n){return UA(this,t,r,n),this}clearIncompatible(t,r,n){return WA(this,t,r,n),this}}const vg=Object.create(null);class xe{constructor(t,r,n){this.$anchor=t,this.$head=r,this.ranges=n||[new dR(t.min(r),t.max(r))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let r=0;r=0;i--){let s=r<0?ja(t.node(0),t.node(i),t.before(i+1),t.index(i),r,n):ja(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,r,n);if(s)return s}return null}static near(t,r=1){return this.findFrom(t,r)||this.findFrom(t,-r)||new wr(t.node(0))}static atStart(t){return ja(t,t,0,0,1)||new wr(t)}static atEnd(t){return ja(t,t,t.content.size,t.childCount,-1)||new wr(t)}static fromJSON(t,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=vg[r.type];if(!n)throw new RangeError(`No selection type ${r.type} defined`);return n.fromJSON(t,r)}static jsonID(t,r){if(t in vg)throw new RangeError("Duplicate use of selection JSON ID "+t);return vg[t]=r,r.prototype.jsonID=t,r}getBookmark(){return ue.between(this.$anchor,this.$head).getBookmark()}}xe.prototype.visible=!0;class dR{constructor(t,r){this.$from=t,this.$to=r}}let px=!1;function hx(e){!px&&!e.parent.inlineContent&&(px=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class ue extends xe{constructor(t,r=t){hx(t),hx(r),super(t,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,r){let n=t.resolve(r.map(this.head));if(!n.parent.inlineContent)return xe.near(n);let o=t.resolve(r.map(this.anchor));return new ue(o.parent.inlineContent?o:n,n)}replace(t,r=W.empty){if(super.replace(t,r),r==W.empty){let n=this.$from.marksAcross(this.$to);n&&t.ensureMarks(n)}}eq(t){return t instanceof ue&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Dh(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,r){if(typeof r.anchor!="number"||typeof r.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ue(t.resolve(r.anchor),t.resolve(r.head))}static create(t,r,n=r){let o=t.resolve(r);return new this(o,n==r?o:t.resolve(n))}static between(t,r,n){let o=t.pos-r.pos;if((!n||o)&&(n=o>=0?1:-1),!r.parent.inlineContent){let i=xe.findFrom(r,n,!0)||xe.findFrom(r,-n,!0);if(i)r=i.$head;else return xe.near(r,n)}return t.parent.inlineContent||(o==0?t=r:(t=(xe.findFrom(t,-n,!0)||xe.findFrom(t,n,!0)).$anchor,t.pos0?0:1);o>0?s=0;s+=o){let a=t.child(s);if(a.isAtom){if(!i&&de.isSelectable(a))return de.create(e,r-(o<0?a.nodeSize:0))}else{let l=ja(e,a,r+o,o<0?a.childCount:0,o,i);if(l)return l}r+=a.nodeSize*o}return null}function mx(e,t,r){let n=e.steps.length-1;if(n{s==null&&(s=u)}),e.setSelection(xe.near(e.doc.resolve(s),r))}const gx=1,of=2,vx=4;class pR extends uR{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(t){return this.storedMarks=t,this.updated|=of,this}ensureMarks(t){return _e.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&of)>0}addStep(t,r){super.addStep(t,r),this.updated=this.updated&~of,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,r=!0){let n=this.selection;return r&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||_e.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,r,n){let o=this.doc.type.schema;if(r==null)return t?this.replaceSelectionWith(o.text(t),!0):this.deleteSelection();{if(n==null&&(n=r),n=n??r,!t)return this.deleteRange(r,n);let i=this.storedMarks;if(!i){let s=this.doc.resolve(r);i=n==r?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(r,n,o.text(t,i)),this.selection.empty||this.setSelection(xe.near(this.selection.$to)),this}}setMeta(t,r){return this.meta[typeof t=="string"?t:t.key]=r,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=vx,this}get scrolledIntoView(){return(this.updated&vx)>0}}function yx(e,t){return!t||!e?e:e.bind(t)}class Lc{constructor(t,r,n){this.name=t,this.init=yx(r.init,n),this.apply=yx(r.apply,n)}}const hR=[new Lc("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Lc("selection",{init(e,t){return e.selection||xe.atStart(t.doc)},apply(e){return e.selection}}),new Lc("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,r,n){return n.selection.$cursor?e.storedMarks:null}}),new Lc("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})];class yg{constructor(t,r){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=hR.slice(),r&&r.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new Lc(n.key,n.spec.state,n))})}}class Fs{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,r=-1){for(let n=0;nn.toJSON())),t&&typeof t=="object")for(let n in t){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=t[n],i=o.spec.state;i&&i.toJSON&&(r[n]=i.toJSON.call(o,this[o.key]))}return r}static fromJSON(t,r,n){if(!r)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let o=new yg(t.schema,t.plugins),i=new Fs(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Fi.fromJSON(t.schema,r.doc);else if(s.name=="selection")i.selection=xe.fromJSON(i.doc,r.selection);else if(s.name=="storedMarks")r.storedMarks&&(i.storedMarks=r.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let a in n){let l=n[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(r,a)){i[s.name]=c.fromJSON.call(l,t,r[a],i);return}}i[s.name]=s.init(t,i)}}),i}}function RE(e,t,r){for(let n in e){let o=e[n];o instanceof Function?o=o.bind(t):n=="handleDOMEvents"&&(o=RE(o,t,{})),r[n]=o}return r}class zo{constructor(t){this.spec=t,this.props={},t.props&&RE(t.props,this,this.props),this.key=t.key?t.key.key:NE("plugin")}getState(t){return t[this.key]}}const bg=Object.create(null);function NE(e){return e in bg?e+"$"+ ++bg[e]:(bg[e]=0,e+"$")}class wa{constructor(t="key"){this.key=NE(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}var mR=/[A-Z]/g,gR=/^ms-/,kg={};function vR(e){return"-"+e.toLowerCase()}function yR(e){if(kg.hasOwnProperty(e))return kg[e];var t=e.replace(mR,vR);return kg[e]=gR.test(t)?"-"+t:t}function bR(e){return yR(e)}function kR(e,t){return bR(e)+":"+t}function xR(e){var t="";for(var r in e){var n=e[r];typeof n!="string"&&typeof n!="number"||(t&&(t+=";"),t+=kR(r,n))}return t}function wR(){return typeof document<"u"?document:null}var PE=wR;function zE(e,t){if(typeof e!="string")return[e];var r=[e];typeof t=="string"||Array.isArray(t)?t={brackets:t}:t||(t={});var n=t.brackets?Array.isArray(t.brackets)?t.brackets:[t.brackets]:["{}","[]","()"],o=t.escape||"___",i=!!t.flat;n.forEach(function(l){var c=new RegExp(["\\",l[0],"[^\\",l[0],"\\",l[1],"]*\\",l[1]].join("")),u=[];function d(f,p,h){var m=r.push(f.slice(l[0].length,-l[1].length))-1;return u.push(m),o+m+o}r.forEach(function(f,p){for(var h,m=0;f!=h;)if(h=f,f=f.replace(c,d),m++>1e4)throw Error("References have circular dependency. Please, check them.");r[p]=f}),u=u.reverse(),r=r.map(function(f){return u.forEach(function(p){f=f.replace(new RegExp("(\\"+o+p+"\\"+o+")","g"),l[0]+"$1"+l[1])}),f})});var s=new RegExp("\\"+o+"([0-9]+)\\"+o);function a(l,c,u){for(var d=[],f,p=0;f=s.exec(l);){if(p++>1e4)throw Error("Circular references in parenthesis");d.push(l.slice(0,f.index)),d.push(a(c[f[1]],c)),l=l.slice(f.index+f[0].length)}return d.push(l),d}return i?r:a(r[0],r)}function LE(e,t){if(t&&t.flat){var r=t&&t.escape||"___",n=e[0],o;if(!n)return"";for(var i=new RegExp("\\"+r+"([0-9]+)\\"+r),s=0;n!=o;){if(s++>1e4)throw Error("Circular references in "+e);o=n,n=n.replace(i,a)}return n}return e.reduce(function l(c,u){return Array.isArray(u)&&(u=u.reduce(l,"")),c+u},"");function a(l,c){if(e[c]==null)throw Error("Reference "+c+"is undefined");return e[c]}}function IE(e,t){return Array.isArray(e)?LE(e,t):zE(e,t)}IE.parse=zE;IE.stringify=LE;const SR={id:"extension.command.copy.label",message:"Copy",comment:"Label for copy command."},ER={id:"extension.command.copy.description",message:"Copy the selected text",comment:"Description for copy command."},CR={id:"extension.command.cut.label",message:"Cut",comment:"Label for cut command."},MR={id:"extension.command.cut.description",message:"Cut the selected text",comment:"Description for cut command."},TR={id:"extension.command.paste.label",message:"Paste",comment:"Label for paste command."},OR={id:"extension.command.paste.description",message:"Paste content into the editor",comment:"Description for paste command."},_R={id:"extension.command.select-all.label",message:"Select all",comment:"Label for select all command."},AR={id:"extension.command.select-all.description",message:"Select all content within the editor",comment:"Description for select all command."};var rs=Object.freeze({__proto__:null,COPY_DESCRIPTION:ER,COPY_LABEL:SR,CUT_DESCRIPTION:MR,CUT_LABEL:CR,PASTE_DESCRIPTION:OR,PASTE_LABEL:TR,SELECT_ALL_DESCRIPTION:AR,SELECT_ALL_LABEL:_R});const RR={id:"keyboard.shortcut.escape",message:"Enter",comment:"Label for escape key in shortcuts."},NR={id:"keyboard.shortcut.command",message:"Command",comment:"Label for command key in shortcuts."},PR={id:"keyboard.shortcut.control",message:"Control",comment:"Label for control key in shortcuts."},zR={id:"keyboard.shortcut.enter",message:"Enter",comment:"Label for enter key in shortcuts."},LR={id:"keyboard.shortcut.shift",message:"Shift",comment:"Label for shift key in shortcuts."},IR={id:"keyboard.shortcut.alt",message:"Alt",comment:"Label for alt key in shortcuts."},DR={id:"keyboard.shortcut.capsLock",message:"Caps Lock",comment:"Label for caps lock key in shortcuts."},$R={id:"keyboard.shortcut.backspace",message:"Backspace",comment:"Label for backspace key in shortcuts."},HR={id:"keyboard.shortcut.tab",message:"Tab",comment:"Label for tab key in shortcuts."},BR={id:"keyboard.shortcut.space",message:"Space",comment:"Label for space key in shortcuts."},FR={id:"keyboard.shortcut.delete",message:"Delete",comment:"Label for delete key in shortcuts."},VR={id:"keyboard.shortcut.pageUp",message:"Page Up",comment:"Label for page up key in shortcuts."},jR={id:"keyboard.shortcut.pageDown",message:"Page Down",comment:"Label for page down key in shortcuts."},UR={id:"keyboard.shortcut.home",message:"Home",comment:"Label for home key in shortcuts."},WR={id:"keyboard.shortcut.end",message:"End",comment:"Label for end key in shortcuts."},KR={id:"keyboard.shortcut.arrowLeft",message:"Arrow Left",comment:"Label for arrow left key in shortcuts."},qR={id:"keyboard.shortcut.arrowRight",message:"Arrow Right",comment:"Label for arrow right key in shortcuts."},GR={id:"keyboard.shortcut.arrowUp",message:"Arrow Up",comment:"Label for arrow up key in shortcuts."},YR={id:"keyboard.shortcut.arrowDown",message:"Arrow Down",comment:"Label for arrowDown key in shortcuts."};var Rt=Object.freeze({__proto__:null,ALT_KEY:IR,ARROW_DOWN_KEY:YR,ARROW_LEFT_KEY:KR,ARROW_RIGHT_KEY:qR,ARROW_UP_KEY:GR,BACKSPACE_KEY:$R,CAPS_LOCK_KEY:DR,COMMAND_KEY:NR,CONTROL_KEY:PR,DELETE_KEY:FR,END_KEY:WR,ENTER_KEY:zR,ESCAPE_KEY:RR,HOME_KEY:UR,PAGE_DOWN_KEY:jR,PAGE_UP_KEY:VR,SHIFT_KEY:LR,SPACE_KEY:BR,TAB_KEY:HR});const XR={id:"extension.command.toggle-blockquote.label",message:"Blockquote",comment:"Label for blockquote formatting command."},JR={id:"extension.command.toggle-blockquote.description",message:"Add blockquote formatting to the selected text",comment:"Description for blockquote formatting command."};var bx=Object.freeze({__proto__:null,DESCRIPTION:JR,LABEL:XR});const QR={id:"extension.command.toggle-bold.label",message:"Bold",comment:"Label for bold formatting command."},ZR={id:"extension.command.toggle-bold.description",message:"Add bold formatting to the selected text",comment:"Description for bold formatting command."};var kx=Object.freeze({__proto__:null,DESCRIPTION:ZR,LABEL:QR});const eN={id:"extension.command.toggle-code-block.label",message:"Codeblock",comment:"Label for the code block command."},tN={id:"extension.command.toggle-code-block.description",message:"Add a code block",comment:"Description for the code block command."};var rN=Object.freeze({__proto__:null,DESCRIPTION:tN,LABEL:eN});const nN={id:"extension.command.toggle-code.label",message:"Code",comment:"Label for the inline code formatting."},oN={id:"extension.command.toggle-code.description",message:"Add inline code formatting to the selected text",comment:"Description for the inline code formatting command."};var iN=Object.freeze({__proto__:null,DESCRIPTION:oN,LABEL:nN});const sN={id:"extension.command.toggle-heading.label",message:`{level, select, 1 {Heading 1}
+`:"";return`${n}${o}For more information visit ${NC}#${e.toLowerCase()}`}var RC=class extends fC.BaseError{constructor({code:e,message:t,disableLogging:r=!1}={}){const n=J4(e)?e:U.CUSTOM;super(Q4(n,t)),this.errorCode=n,this.url=`${NC}#${n.toLowerCase()}`,r||console.error(this.message)}static create(e={}){return new RC(e)}};function re(e,t){if(!e)throw RC.create(t)}function Yh(e){if(typeof e!="object"||e===null)return e;const t=Symbol.toStringTag in e&&e[Symbol.toStringTag]==="Module"?e.default??e:e;return t&&typeof e=="object"&&"__esModule"in t&&t.__esModule&&t.default!==void 0?t.default:t}function Vs(e,t={}){return e}function Zt(e){this.content=e}Zt.prototype={constructor:Zt,find:function(e){for(var t=0;t>1}};Zt.from=function(e){if(e instanceof Zt)return e;var t=[];if(e)for(var r in e)t.push(r,e[r]);return new Zt(t)};function _C(e,t,r){for(let n=0;;n++){if(n==e.childCount||n==t.childCount)return e.childCount==t.childCount?null:r;let o=e.child(n),i=t.child(n);if(o==i){r+=o.nodeSize;continue}if(!o.sameMarkup(i))return r;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)r++;return r}if(o.content.size||i.content.size){let s=_C(o.content,i.content,r+1);if(s!=null)return s}r+=o.nodeSize}}function IC(e,t,r,n){for(let o=e.childCount,i=t.childCount;;){if(o==0||i==0)return o==i?null:{a:r,b:n};let s=e.child(--o),a=t.child(--i),l=s.nodeSize;if(s==a){r-=l,n-=l;continue}if(!s.sameMarkup(a))return{a:r,b:n};if(s.isText&&s.text!=a.text){let c=0,u=Math.min(s.text.length,a.text.length);for(;ct&&n(l,o+a,i||null,s)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,t-u),Math.min(l.content.size,r-u),n,o+u)}a=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,r,n,o){let i="",s=!0;return this.nodesBetween(t,r,(a,l)=>{a.isText?(i+=a.text.slice(Math.max(t,l)-l,r-l),s=!n):a.isLeaf?(o?i+=typeof o=="function"?o(a):o:a.type.spec.leafText&&(i+=a.type.spec.leafText(a)),s=!n):!s&&a.isBlock&&(i+=n,s=!0)},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let r=this.lastChild,n=t.firstChild,o=this.content.slice(),i=0;for(r.isText&&r.sameMarkup(n)&&(o[o.length-1]=r.withText(r.text+n.text),i=1);it)for(let i=0,s=0;st&&((sr)&&(a.isText?a=a.cut(Math.max(0,t-s),Math.min(a.text.length,r-s)):a=a.cut(Math.max(0,t-s-1),Math.min(a.content.size,r-s-1))),n.push(a),o+=a.nodeSize),s=l}return new I(n,o)}cutByIndex(t,r){return t==r?I.empty:t==0&&r==this.content.length?this:new I(this.content.slice(t,r))}replaceChild(t,r){let n=this.content[t];if(n==r)return this;let o=this.content.slice(),i=this.size+r.nodeSize-n.nodeSize;return o[t]=r,new I(o,i)}addToStart(t){return new I([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new I(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let r=0;rthis.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,o=0;;n++){let i=this.child(n),s=o+i.nodeSize;if(s>=t)return s==t||r>0?hp(n+1,s):hp(n,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,r){if(!r)return I.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new I(r.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return I.empty;let r,n=0;for(let o=0;othis.type.rank&&(r||(r=t.slice(0,o)),r.push(this),n=!0),r&&r.push(i)}}return r||(r=t.slice()),n||r.push(this),r}removeFromSet(t){for(let r=0;rn.type.rank-o.type.rank),r}}Ne.none=[];class _f extends Error{}class W{constructor(t,r,n){this.content=t,this.openStart=r,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,r){let n=LC(this.content,t+this.openStart,r);return n&&new W(n,this.openStart,this.openEnd)}removeBetween(t,r){return new W(MC(this.content,t+this.openStart,r+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,r){if(!r)return W.empty;let n=r.openStart||0,o=r.openEnd||0;if(typeof n!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new W(I.fromJSON(t,r.content),n,o)}static maxOpen(t,r=!0){let n=0,o=0;for(let i=t.firstChild;i&&!i.isLeaf&&(r||!i.type.spec.isolating);i=i.firstChild)n++;for(let i=t.lastChild;i&&!i.isLeaf&&(r||!i.type.spec.isolating);i=i.lastChild)o++;return new W(t,n,o)}}W.empty=new W(I.empty,0,0);function MC(e,t,r){let{index:n,offset:o}=e.findIndex(t),i=e.maybeChild(n),{index:s,offset:a}=e.findIndex(r);if(o==t||i.isText){if(a!=r&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(r))}if(n!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(n,i.copy(MC(i.content,t-o-1,r-o-1)))}function LC(e,t,r,n){let{index:o,offset:i}=e.findIndex(t),s=e.maybeChild(o);if(i==t||s.isText)return n&&!n.canReplace(o,o,r)?null:e.cut(0,t).append(r).append(e.cut(t));let a=LC(s.content,t-i-1,r);return a&&e.replaceChild(o,s.copy(a))}function eL(e,t,r){if(r.openStart>e.depth)throw new _f("Inserted content deeper than insertion position");if(e.depth-r.openStart!=t.depth-r.openEnd)throw new _f("Inconsistent open depths");return DC(e,t,r,0)}function DC(e,t,r,n){let o=e.index(n),i=e.node(n);if(o==t.index(n)&&n=0&&e.isText&&e.sameMarkup(t[r])?t[r]=e.withText(t[r].text+e.text):t.push(e)}function Su(e,t,r,n){let o=(t||e).node(r),i=0,s=t?t.index(r):o.childCount;e&&(i=e.index(r),e.depth>r?i++:e.textOffset&&(Js(e.nodeAfter,n),i++));for(let a=i;ao&&j1(e,t,o+1),s=n.depth>o&&j1(r,n,o+1),a=[];return Su(null,e,o,a),i&&s&&t.index(o)==r.index(o)?(PC(i,s),Js(Qs(i,zC(e,t,r,n,o+1)),a)):(i&&Js(Qs(i,If(e,t,o+1)),a),Su(t,r,o,a),s&&Js(Qs(s,If(r,n,o+1)),a)),Su(n,null,o,a),new I(a)}function If(e,t,r){let n=[];if(Su(null,e,r,n),e.depth>r){let o=j1(e,t,r+1);Js(Qs(o,If(e,t,r+1)),n)}return Su(t,null,r,n),new I(n)}function tL(e,t){let r=t.depth-e.openStart,o=t.node(r).copy(e.content);for(let i=r-1;i>=0;i--)o=t.node(i).copy(I.from(o));return{start:o.resolveNoCache(e.openStart+r),end:o.resolveNoCache(o.content.size-e.openEnd-r)}}class Dl{constructor(t,r,n){this.pos=t,this.path=r,this.parentOffset=n,this.depth=r.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,r=this.index(this.depth);if(r==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=t.child(r);return n?t.child(r).cut(n):o}get nodeBefore(){let t=this.index(this.depth),r=this.pos-this.path[this.path.length-1];return r?this.parent.child(t).cut(0,r):t==0?null:this.parent.child(t-1)}posAtIndex(t,r){r=this.resolveDepth(r);let n=this.path[r*3],o=r==0?0:this.path[r*3-1]+1;for(let i=0;i0;r--)if(this.start(r)<=t&&this.end(r)>=t)return r;return 0}blockRange(t=this,r){if(t.pos=0;n--)if(t.pos<=this.end(n)&&(!r||r(this.node(n))))return new sa(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos=0&&r<=t.content.size))throw new RangeError("Position "+r+" out of range");let n=[],o=0,i=r;for(let s=t;;){let{index:a,offset:l}=s.content.findIndex(i),c=i-l;if(n.push(s,a,o+l),!c||(s=s.child(a),s.isText))break;i=c-1,o+=l+1}return new Dl(r,n,i)}static resolveCached(t,r){for(let o=0;ot&&this.nodesBetween(t,r,i=>(n.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),$C(this.marks,t)}contentMatchAt(t){let r=this.type.contentMatch.matchFragment(this.content,0,t);if(!r)throw new Error("Called contentMatchAt on a node with invalid content");return r}canReplace(t,r,n=I.empty,o=0,i=n.childCount){let s=this.contentMatchAt(t).matchFragment(n,o,i),a=s&&s.matchFragment(this.content,r);if(!a||!a.validEnd)return!1;for(let l=o;lr.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let t={type:this.type.name};for(let r in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(r=>r.toJSON())),t}static fromJSON(t,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(t.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(r.text,n)}let o=I.fromJSON(t,r.content);return t.nodeType(r.type).create(r.attrs,o,n)}};ji.prototype.text=void 0;class Mf extends ji{constructor(t,r,n,o){if(super(t,r,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$C(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,r){return this.text.slice(t,r)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new Mf(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new Mf(this.type,this.attrs,t,this.marks)}cut(t=0,r=this.text.length){return t==0&&r==this.text.length?this:this.withText(this.text.slice(t,r))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function $C(e,t){for(let r=e.length-1;r>=0;r--)t=e[r].type.name+"("+t+")";return t}class aa{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,r){let n=new oL(t,r);if(n.next==null)return aa.empty;let o=BC(n);n.next&&n.err("Unexpected trailing text");let i=dL(uL(o));return pL(i,n),i}matchType(t){for(let r=0;rc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function r(n){t.push(n);for(let o=0;o{let i=o+(n.validEnd?"*":" ")+" ";for(let s=0;s"+t.indexOf(n.next[s].next);return i}).join(`
+`)}}aa.empty=new aa(!0);class oL{constructor(t,r){this.string=t,this.nodeTypes=r,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function BC(e){let t=[];do t.push(iL(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function iL(e){let t=[];do t.push(sL(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function sL(e){let t=cL(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=aL(e,t);else break;return t}function Nx(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function aL(e,t){let r=Nx(e),n=r;return e.eat(",")&&(e.next!="}"?n=Nx(e):n=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:t}}function lL(e,t){let r=e.nodeTypes,n=r[t];if(n)return[n];let o=[];for(let i in r){let s=r[i];s.groups.indexOf(t)>-1&&o.push(s)}return o.length==0&&e.err("No node type or group '"+t+"' found"),o}function cL(e){if(e.eat("(")){let t=BC(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=lL(e,e.next).map(r=>(e.inline==null?e.inline=r.isInline:e.inline!=r.isInline&&e.err("Mixing inline and block content"),{type:"name",value:r}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function uL(e){let t=[[]];return o(i(e,0),r()),t;function r(){return t.push([])-1}function n(s,a,l){let c={term:l,to:a};return t[s].push(c),c}function o(s,a){s.forEach(l=>l.to=a)}function i(s,a){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(i(c,a)),[]);if(s.type=="seq")for(let l=0;;l++){let c=i(s.exprs[l],a);if(l==s.exprs.length-1)return c;o(c,a=r())}else if(s.type=="star"){let l=r();return n(a,l),o(i(s.expr,l),l),[n(l)]}else if(s.type=="plus"){let l=r();return o(i(s.expr,a),l),o(i(s.expr,l),l),[n(l)]}else{if(s.type=="opt")return[n(a)].concat(i(s.expr,a));if(s.type=="range"){let l=a;for(let c=0;c{e[s].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u{c||o.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=t[n.join(",")]=new aa(n.indexOf(e.length-1)>-1);for(let s=0;s-1}allowsMarks(t){if(this.markSet==null)return!0;for(let r=0;rn[i]=new jC(i,r,s));let o=r.spec.topNode||"doc";if(!n[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let i in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};class fL{constructor(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default}get isRequired(){return!this.hasDefault}}class Bd{constructor(t,r,n,o){this.name=t,this.rank=r,this.schema=n,this.spec=o,this.attrs=VC(o.attrs),this.excluded=null;let i=FC(this.attrs);this.instance=i?new Ne(this,i):null}create(t=null){return!t&&this.instance?this.instance:new Ne(this,UC(this.attrs,t))}static compile(t,r){let n=Object.create(null),o=0;return t.forEach((i,s)=>n[i]=new Bd(i,o++,r,s)),n}removeFromSet(t){for(var r=0;r-1}}let hL=class{constructor(t){this.cached=Object.create(null);let r=this.spec={};for(let o in t)r[o]=t[o];r.nodes=Zt.from(t.nodes),r.marks=Zt.from(t.marks||{}),this.nodes=W1.compile(this.spec.nodes,this),this.marks=Bd.compile(this.spec.marks,this);let n=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",a=i.spec.marks;i.contentMatch=n[s]||(n[s]=aa.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet=a=="_"?null:a?_x(this,a.split(" ")):a==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:_x(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,r=null,n,o){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof W1){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(r,n,o)}text(t,r){let n=this.nodes.text;return new Mf(n,n.defaultAttrs,t,Ne.setFrom(r))}mark(t,r){return typeof t=="string"&&(t=this.marks[t]),t.create(r)}nodeFromJSON(t){return ji.fromJSON(this,t)}markFromJSON(t){return Ne.fromJSON(this,t)}nodeType(t){let r=this.nodes[t];if(!r)throw new RangeError("Unknown node type: "+t);return r}};function _x(e,t){let r=[];for(let n=0;n-1)&&r.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[n]+"'")}return r}let Vy=class K1{constructor(t,r){this.schema=t,this.rules=r,this.tags=[],this.styles=[],r.forEach(n=>{n.tag?this.tags.push(n):n.style&&this.styles.push(n)}),this.normalizeLists=!this.tags.some(n=>{if(!/^(ul|ol)\b/.test(n.tag)||!n.node)return!1;let o=t.nodes[n.node];return o.contentMatch.matchType(o)})}parse(t,r={}){let n=new Mx(this,r,!1);return n.addAll(t,r.from,r.to),n.finish()}parseSlice(t,r={}){let n=new Mx(this,r,!0);return n.addAll(t,r.from,r.to),W.maxOpen(n.finish())}matchTag(t,r,n){for(let o=n?this.tags.indexOf(n)+1:0;ot.length&&(a.charCodeAt(t.length)!=61||a.slice(t.length+1)!=r))){if(s.getAttrs){let l=s.getAttrs(r);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(t){let r=[];function n(o){let i=o.priority==null?50:o.priority,s=0;for(;s{n(s=Lx(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in t.nodes){let i=t.nodes[o].spec.parseDOM;i&&i.forEach(s=>{n(s=Lx(s)),s.node||s.ignore||s.mark||(s.node=o)})}return r}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new K1(t,K1.schemaRules(t)))}};const GC={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},mL={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},WC={ol:!0,ul:!0},Lf=1,Df=2,wu=4;function Ix(e,t,r){return t!=null?(t?Lf:0)|(t==="full"?Df:0):e&&e.whitespace=="pre"?Lf|Df:r&~wu}class mp{constructor(t,r,n,o,i,s,a){this.type=t,this.attrs=r,this.marks=n,this.pendingMarks=o,this.solid=i,this.options=a,this.content=[],this.activeMarks=Ne.none,this.stashMarks=[],this.match=s||(a&wu?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(I.from(t));if(r)this.match=this.type.contentMatch.matchFragment(r);else{let n=this.type.contentMatch,o;return(o=n.findWrapping(t.type))?(this.match=n,o):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Lf)){let n=this.content[this.content.length-1],o;if(n&&n.isText&&(o=/[ \t\r\n\u000c]+$/.exec(n.text))){let i=n;n.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let r=I.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(I.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}popFromStashMark(t){for(let r=this.stashMarks.length-1;r>=0;r--)if(t.eq(this.stashMarks[r]))return this.stashMarks.splice(r,1)[0]}applyPending(t){for(let r=0,n=this.pendingMarks;rthis.addAll(t)),s&&this.sync(a),this.needsBlock=l}else this.withStyleRules(t,()=>{this.addElementByRule(t,i,i.consuming===!1?o:void 0)})}leafFallback(t){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
+`))}ignoreFallback(t){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(t){let r=Ne.none,n=Ne.none;for(let o=0;o{s.clearMark(a)&&(n=a.addToSet(n))}):r=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(r),s.consuming===!1)i=s;else break}return[r,n]}addElementByRule(t,r,n){let o,i,s;r.node?(i=this.parser.schema.nodes[r.node],i.isLeaf?this.insertNode(i.create(r.attrs))||this.leafFallback(t):o=this.enter(i,r.attrs||null,r.preserveWhitespace)):(s=this.parser.schema.marks[r.mark].create(r.attrs),this.addPendingMark(s));let a=this.top;if(i&&i.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(r.getContent)this.findInside(t),r.getContent(t,this.parser.schema).forEach(l=>this.insertNode(l));else{let l=t;typeof r.contentElement=="string"?l=t.querySelector(r.contentElement):typeof r.contentElement=="function"?l=r.contentElement(t):r.contentElement&&(l=r.contentElement),this.findAround(t,l,!0),this.addAll(l)}o&&this.sync(a)&&this.open--,s&&this.removePendingMark(s,a)}addAll(t,r,n){let o=r||0;for(let i=r?t.childNodes[r]:t.firstChild,s=n==null?null:t.childNodes[n];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i);this.findAtPoint(t,o)}findPlace(t){let r,n;for(let o=this.open;o>=0;o--){let i=this.nodes[o],s=i.findWrapping(t);if(s&&(!r||r.length>s.length)&&(r=s,n=i,!s.length)||i.solid)break}if(!r)return!1;this.sync(n);for(let o=0;othis.open){for(;r>this.open;r--)this.nodes[r-1].content.push(this.nodes[r].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let r=this.open;r>=0;r--)if(this.nodes[r]==t)return this.open=r,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let r=this.open;r>=0;r--){let n=this.nodes[r].content;for(let o=n.length-1;o>=0;o--)t+=n[o].nodeSize;r&&t++}return t}findAtPoint(t,r){if(this.find)for(let n=0;n-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let r=t.split("/"),n=this.options.context,o=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+(o?0:1),s=(a,l)=>{for(;a>=0;a--){let c=r[a];if(c==""){if(a==r.length-1||a==0)continue;for(;l>=i;l--)if(s(a-1,l))return!0;return!1}else{let u=l>0||l==0&&o?this.nodes[l].type:n&&l>=i?n.node(l-i).type:null;if(!u||u.name!=c&&u.groups.indexOf(c)==-1)return!1;l--}}return!0};return s(r.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let r=t.depth;r>=0;r--){let n=t.node(r).contentMatchAt(t.indexAfter(r)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let r in this.parser.schema.nodes){let n=this.parser.schema.nodes[r];if(n.isTextblock&&n.defaultAttrs)return n}}addPendingMark(t){let r=EL(t,this.top.pendingMarks);r&&this.top.stashMarks.push(r),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,r){for(let n=this.open;n>=0;n--){let o=this.nodes[n];if(o.pendingMarks.lastIndexOf(t)>-1)o.pendingMarks=t.removeFromSet(o.pendingMarks);else{o.activeMarks=t.removeFromSet(o.activeMarks);let s=o.popFromStashMark(t);s&&o.type&&o.type.allowsMarkType(s.type)&&(o.activeMarks=s.addToSet(o.activeMarks))}if(o==r)break}}}function gL(e){for(let t=e.firstChild,r=null;t;t=t.nextSibling){let n=t.nodeType==1?t.nodeName.toLowerCase():null;n&&WC.hasOwnProperty(n)&&r?(r.appendChild(t),t=r):n=="li"?r=t:n&&(r=null)}}function yL(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function vL(e){let t=/\s*([\w-]+)\s*:\s*([^;]+)/g,r,n=[];for(;r=t.exec(e);)n.push(r[1],r[2].trim());return n}function Lx(e){let t={};for(let r in e)t[r]=e[r];return t}function bL(e,t){let r=t.schema.nodes;for(let n in r){let o=r[n];if(!o.allowsMarkType(e))continue;let i=[],s=a=>{i.push(a);for(let l=0;l{if(i.length||s.marks.length){let a=0,l=0;for(;a=0;o--){let i=this.serializeMark(t.marks[o],t.isInline,r);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(t,r,n={}){let o=this.marks[t.type.name];return o&&un.renderSpec(Og(n),o(t,r))}static renderSpec(t,r,n=null){if(typeof r=="string")return{dom:t.createTextNode(r)};if(r.nodeType!=null)return{dom:r};if(r.dom&&r.dom.nodeType!=null)return r;let o=r[0],i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let s,a=n?t.createElementNS(n,o):t.createElement(o),l=r[1],c=1;if(l&&typeof l=="object"&&l.nodeType==null&&!Array.isArray(l)){c=2;for(let u in l)if(l[u]!=null){let d=u.indexOf(" ");d>0?a.setAttributeNS(u.slice(0,d),u.slice(d+1),l[u]):a.setAttribute(u,l[u])}}for(let u=c;uc)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:f}=un.renderSpec(t,d,n);if(a.appendChild(p),f){if(s)throw new RangeError("Multiple content holes");s=f}}}return{dom:a,contentDOM:s}}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new un(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let r=Dx(t.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(t){return Dx(t.marks)}}function Dx(e){let t={};for(let r in e){let n=e[r].spec.toDOM;n&&(t[r]=n)}return t}function Og(e){return e.document||window.document}const KC=65535,YC=Math.pow(2,16);function kL(e,t){return e+t*YC}function Px(e){return e&KC}function xL(e){return(e-(e&KC))/YC}const qC=1,XC=2,Yp=4,ZC=8;class Y1{constructor(t,r,n){this.pos=t,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&ZC)>0}get deletedBefore(){return(this.delInfo&(qC|Yp))>0}get deletedAfter(){return(this.delInfo&(XC|Yp))>0}get deletedAcross(){return(this.delInfo&Yp)>0}}class an{constructor(t,r=!1){if(this.ranges=t,this.inverted=r,!t.length&&an.empty)return an.empty}recover(t){let r=0,n=Px(t);if(!this.inverted)for(let o=0;ot)break;let c=this.ranges[a+i],u=this.ranges[a+s],d=l+c;if(t<=d){let p=c?t==l?-1:t==d?1:r:r,f=l+o+(p<0?0:u);if(n)return f;let h=t==(r<0?l:d)?null:kL(a/3,t-l),m=t==l?XC:t==d?qC:Yp;return(r<0?t!=l:t!=d)&&(m|=ZC),new Y1(f,m,h)}o+=u-c}return n?t+o:new Y1(t+o,0,null)}touches(t,r){let n=0,o=Px(r),i=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;at)break;let c=this.ranges[a+i],u=l+c;if(t<=u&&a==o*3)return!0;n+=this.ranges[a+s]-c}return!1}forEach(t){let r=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,i=0;o=0;r--){let o=t.getMirror(r);this.appendMap(t.maps[r].invert(),o!=null&&o>r?n-o-1:void 0)}}invert(){let t=new vl;return t.appendMappingInverted(this),t}map(t,r=1){if(this.mirror)return this._map(t,r,!0);for(let n=this.from;ni&&l!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),r.openStart,r.openEnd);return xt.fromReplace(t,this.from,this.to,i)}invert(){return new oo(this.from,this.to,this.mark)}map(t){let r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new Jo(r.pos,n.pos,this.mark)}merge(t){return t instanceof Jo&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Jo(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Jo(r.from,r.to,t.markFromJSON(r.mark))}}zt.jsonID("addMark",Jo);class oo extends zt{constructor(t,r,n){super(),this.from=t,this.to=r,this.mark=n}apply(t){let r=t.slice(this.from,this.to),n=new W(jy(r.content,o=>o.mark(this.mark.removeFromSet(o.marks)),t),r.openStart,r.openEnd);return xt.fromReplace(t,this.from,this.to,n)}invert(){return new Jo(this.from,this.to,this.mark)}map(t){let r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new oo(r.pos,n.pos,this.mark)}merge(t){return t instanceof oo&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new oo(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new oo(r.from,r.to,t.markFromJSON(r.mark))}}zt.jsonID("removeMark",oo);class Bi extends zt{constructor(t,r){super(),this.pos=t,this.mark=r}apply(t){let r=t.nodeAt(this.pos);if(!r)return xt.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return xt.fromReplace(t,this.pos,this.pos+1,new W(I.from(n),0,r.isLeaf?0:1))}invert(t){let r=t.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let o=0;on.pos?null:new St(r.pos,n.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,r){if(typeof r.from!="number"||typeof r.to!="number"||typeof r.gapFrom!="number"||typeof r.gapTo!="number"||typeof r.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new St(r.from,r.to,r.gapFrom,r.gapTo,W.fromJSON(t,r.slice),r.insert,!!r.structure)}}zt.jsonID("replaceAround",St);function q1(e,t,r){let n=e.resolve(t),o=r-t,i=n.depth;for(;o>0&&i>0&&n.indexAfter(i)==n.node(i).childCount;)i--,o--;if(o>0){let s=n.node(i).maybeChild(n.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function SL(e,t,r,n){let o=[],i=[],s,a;e.doc.nodesBetween(t,r,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!n.isInSet(d)&&u.type.allowsMarkType(n.type)){let p=Math.max(c,t),f=Math.min(c+l.nodeSize,r),h=n.addToSet(d);for(let m=0;me.step(l)),i.forEach(l=>e.step(l))}function wL(e,t,r,n){let o=[],i=0;e.doc.nodesBetween(t,r,(s,a)=>{if(!s.isInline)return;i++;let l=null;if(n instanceof Bd){let c=s.marks,u;for(;u=n.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else n?n.isInSet(s.marks)&&(l=[n]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,r);for(let u=0;ue.step(new oo(s.from,s.to,s.style)))}function TL(e,t,r,n=r.contentMatch){let o=e.doc.nodeAt(t),i=[],s=t+1;for(let a=0;a=0;a--)e.step(i[a])}function CL(e,t,r){return(t==0||e.canReplace(t,e.childCount))&&(r==e.childCount||e.canReplace(0,r))}function uc(e){let r=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let o=e.$from.node(n),i=e.$from.index(n),s=e.$to.indexAfter(n);if(nr;h--)m||n.index(h)>0?(m=!0,u=I.from(n.node(h).copy(u)),d++):l--;let p=I.empty,f=0;for(let h=i,m=!1;h>r;h--)m||o.after(h+1)=0;s--){if(n.size){let a=r[s].type.contentMatch.matchFragment(n);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=I.from(r[s].type.create(r[s].attrs,n))}let o=t.start,i=t.end;e.step(new St(o,i,o,i,new W(n,0,0),r.length,!0))}function _L(e,t,r,n,o){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,r,(s,a)=>{if(s.isTextblock&&!s.hasMarkup(n,o)&&IL(e.doc,e.mapping.slice(i).map(a),n)){e.clearIncompatible(e.mapping.slice(i).map(a,1),n);let l=e.mapping.slice(i),c=l.map(a,1),u=l.map(a+s.nodeSize,1);return e.step(new St(c,u,c+1,u-1,new W(I.from(n.create(o,null,s.marks)),0,0),1,!0)),!1}})}function IL(e,t,r){let n=e.resolve(t),o=n.index();return n.parent.canReplaceWith(o,o+1,r)}function ML(e,t,r,n,o){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");r||(r=i.type);let s=r.create(n,null,o||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,s);if(!r.validContent(i.content))throw new RangeError("Invalid content for node type "+r.name);e.step(new St(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new W(I.from(s),0,0),1,!0))}function bl(e,t,r=1,n){let o=e.resolve(t),i=o.depth-r,s=n&&n[n.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=r-2;c>i;c--,u--){let d=o.node(c),p=o.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(p,d.childCount),h=n&&n[u+1];h&&(f=f.replaceChild(0,h.type.create(h.attrs)));let m=n&&n[u]||d;if(!d.canReplace(p+1,d.childCount)||!m.type.validContent(f))return!1}let a=o.indexAfter(i),l=n&&n[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function LL(e,t,r=1,n){let o=e.doc.resolve(t),i=I.empty,s=I.empty;for(let a=o.depth,l=o.depth-r,c=r-1;a>l;a--,c--){i=I.from(o.node(a).copy(i));let u=n&&n[c];s=I.from(u?u.type.create(u.attrs,s):o.node(a).copy(s))}e.step(new Ut(t,t,new W(i.append(s),r,r),!0))}function Hd(e,t){let r=e.resolve(t),n=r.index();return DL(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function DL(e,t){return!!(e&&t&&!e.isLeaf&&e.canAppend(t))}function PL(e,t,r){let n=new Ut(t-r,t+r,W.empty,!0);e.step(n)}function JC(e,t,r){let n=e.resolve(t);if(n.parent.canReplaceWith(n.index(),n.index(),r))return t;if(n.parentOffset==0)for(let o=n.depth-1;o>=0;o--){let i=n.index(o);if(n.node(o).canReplaceWith(i,i,r))return n.before(o+1);if(i>0)return null}if(n.parentOffset==n.parent.content.size)for(let o=n.depth-1;o>=0;o--){let i=n.indexAfter(o);if(n.node(o).canReplaceWith(i,i,r))return n.after(o+1);if(i=0;s--){let a=s==n.depth?0:n.pos<=(n.start(s+1)+n.end(s+1))/2?-1:1,l=n.index(s)+(a>0?1:0),c=n.node(s),u=!1;if(i==1)u=c.canReplace(l,l,o);else{let d=c.contentMatchAt(l).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?n.pos:a<0?n.before(s+1):n.after(s+1)}return null}function Wy(e,t,r=t,n=W.empty){if(t==r&&!n.size)return null;let o=e.resolve(t),i=e.resolve(r);return QC(o,i,n)?new Ut(t,r,n):new $L(o,i,n).fit()}function QC(e,t,r){return!r.openStart&&!r.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),r.content)}class $L{constructor(t,r,n){this.$from=t,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=I.empty;for(let o=0;o<=t.depth;o++){let i=t.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(o))})}for(let o=t.depth;o>0;o--)this.placed=I.from(t.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(t<0?this.$to:n.doc.resolve(t));if(!o)return null;let i=this.placed,s=n.depth,a=o.depth;for(;s&&a&&i.childCount==1;)i=i.firstChild.content,s--,a--;let l=new W(i,s,a);return t>-1?new St(n.pos,t,this.$to.pos,this.$to.end(),l,r):l.size||n.pos!=this.$to.pos?new Ut(n.pos,o.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,o=this.unplaced.openEnd;n1&&(o=0),i.type.spec.isolating&&o<=n){t=n;break}r=i.content}for(let r=1;r<=2;r++)for(let n=r==1?t:this.unplaced.openStart;n>=0;n--){let o,i=null;n?(i=Ng(this.unplaced.content,n-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(r==1&&(s?c.matchType(s.type)||(d=c.fillBefore(I.from(s),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:n,frontierDepth:a,parent:i,inject:d};if(r==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:a,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:t,openStart:r,openEnd:n}=this.unplaced,o=Ng(t,r);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new W(t,r+1,Math.max(n,o.size+r>=t.size-n?r+1:0)),!0)}dropNode(){let{content:t,openStart:r,openEnd:n}=this.unplaced,o=Ng(t,r);if(o.childCount<=1&&r>0){let i=t.size-r<=r+o.size;this.unplaced=new W(Uc(t,r-1,1),r-1,i?r-1:n)}else this.unplaced=new W(Uc(t,r,1),r,n)}placeNodes({sliceDepth:t,frontierDepth:r,parent:n,inject:o,wrap:i}){for(;this.depth>r;)this.closeFrontierNode();if(i)for(let m=0;m1||l==0||m.content.size)&&(d=b,u.push(eO(m.mark(p.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?f:-1)))}let h=c==a.childCount;h||(f=-1),this.placed=Vc(this.placed,r,I.from(u)),this.frontier[r].match=d,h&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,b=a;m1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(t){e:for(let r=Math.min(this.depth,t.depth);r>=0;r--){let{match:n,type:o}=this.frontier[r],i=r=0;a--){let{match:l,type:c}=this.frontier[a],u=Rg(t,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:r,fit:s,move:i?t.doc.resolve(t.after(r+1)):t}}}}close(t){let r=this.findCloseLevel(t);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=Vc(this.placed,r.depth,r.fit)),t=r.move;for(let n=r.depth+1;n<=t.depth;n++){let o=t.node(n),i=o.type.contentMatch.fillBefore(o.content,!0,t.index(n));this.openFrontierNode(o.type,o.attrs,i)}return t}openFrontierNode(t,r=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=Vc(this.placed,this.depth,I.from(t.create(r,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(I.empty,!0);r.childCount&&(this.placed=Vc(this.placed,this.frontier.length,r))}}function Uc(e,t,r){return t==0?e.cutByIndex(r,e.childCount):e.replaceChild(0,e.firstChild.copy(Uc(e.firstChild.content,t-1,r)))}function Vc(e,t,r){return t==0?e.append(r):e.replaceChild(e.childCount-1,e.lastChild.copy(Vc(e.lastChild.content,t-1,r)))}function Ng(e,t){for(let r=0;r1&&(n=n.replaceChild(0,eO(n.firstChild,t-1,n.childCount==1?r-1:0))),t>0&&(n=e.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(e.type.contentMatch.matchFragment(n).fillBefore(I.empty,!0)))),e.copy(n)}function Rg(e,t,r,n,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!r.compatibleContent(i.type))return null;let a=n.fillBefore(i.content,!0,s);return a&&!BL(r,i.content,s)?a:null}function BL(e,t,r){for(let n=r;n0;p--,f--){let h=o.node(p).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(p)>-1?a=p:o.before(p)==f&&s.splice(1,0,-p)}let l=s.indexOf(a),c=[],u=n.openStart;for(let p=n.content,f=0;;f++){let h=p.firstChild;if(c.push(h),f==n.openStart)break;p=h.content}for(let p=u-1;p>=0;p--){let f=c[p],h=HL(f.type);if(h&&!f.sameMarkup(o.node(Math.abs(a)-1)))u=p;else if(h||!f.type.isTextblock)break}for(let p=n.openStart;p>=0;p--){let f=(p+u+1)%(n.openStart+1),h=c[f];if(h)for(let m=0;m=0&&(e.replace(t,r,n),!(e.steps.length>d));p--){let f=s[p];f<0||(t=o.before(f),r=i.after(f))}}function tO(e,t,r,n,o){if(tn){let i=o.contentMatchAt(0),s=i.fillBefore(e).append(e);e=s.append(i.matchFragment(s).fillBefore(I.empty,!0))}return e}function UL(e,t,r,n){if(!n.isInline&&t==r&&e.doc.resolve(t).parent.content.size){let o=JC(e.doc,t,n.type);o!=null&&(t=r=o)}e.replaceRange(t,r,new W(I.from(n),0,0))}function VL(e,t,r){let n=e.doc.resolve(t),o=e.doc.resolve(r),i=rO(n,o);for(let s=0;s0&&(l||n.node(a-1).canReplace(n.index(a-1),o.indexAfter(a-1))))return e.delete(n.before(a),o.after(a))}for(let s=1;s<=n.depth&&s<=o.depth;s++)if(t-n.start(s)==n.depth-s&&r>n.end(s)&&o.end(s)-r!=o.depth-s)return e.delete(n.before(s),r);e.delete(t,r)}function rO(e,t){let r=[],n=Math.min(e.depth,t.depth);for(let o=n;o>=0;o--){let i=e.start(o);if(it.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(i==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==i-1)&&r.push(o)}return r}class El extends zt{constructor(t,r,n){super(),this.pos=t,this.attr=r,this.value=n}apply(t){let r=t.nodeAt(this.pos);if(!r)return xt.fail("No node at attribute step's position");let n=Object.create(null);for(let i in r.attrs)n[i]=r.attrs[i];n[this.attr]=this.value;let o=r.type.create(n,null,r.marks);return xt.fromReplace(t,this.pos,this.pos+1,new W(I.from(o),0,r.isLeaf?0:1))}getMap(){return an.empty}invert(t){return new El(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let r=t.mapResult(this.pos,1);return r.deletedAfter?null:new El(r.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,r){if(typeof r.pos!="number"||typeof r.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new El(r.pos,r.attr,r.value)}}zt.jsonID("attr",El);class ju extends zt{constructor(t,r){super(),this.attr=t,this.value=r}apply(t){let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let n=t.type.create(r,t.content,t.marks);return xt.ok(n)}getMap(){return an.empty}invert(t){return new ju(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,r){if(typeof r.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ju(r.attr,r.value)}}zt.jsonID("docAttr",ju);let zl=class extends Error{};zl=function e(t){let r=Error.call(this,t);return r.__proto__=e.prototype,r};zl.prototype=Object.create(Error.prototype);zl.prototype.constructor=zl;zl.prototype.name="TransformError";class jL{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new vl}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let r=this.maybeStep(t);if(r.failed)throw new zl(r.failed);return this}maybeStep(t){let r=t.apply(this.doc);return r.failed||this.addStep(t,r.doc),r}get docChanged(){return this.steps.length>0}addStep(t,r){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=r}replace(t,r=t,n=W.empty){let o=Wy(this.doc,t,r,n);return o&&this.step(o),this}replaceWith(t,r,n){return this.replace(t,r,new W(I.from(n),0,0))}delete(t,r){return this.replace(t,r,W.empty)}insert(t,r){return this.replaceWith(t,t,r)}replaceRange(t,r,n){return FL(this,t,r,n),this}replaceRangeWith(t,r,n){return UL(this,t,r,n),this}deleteRange(t,r){return VL(this,t,r),this}lift(t,r){return OL(this,t,r),this}join(t,r=1){return PL(this,t,r),this}wrap(t,r){return RL(this,t,r),this}setBlockType(t,r=t,n,o=null){return _L(this,t,r,n,o),this}setNodeMarkup(t,r,n=null,o){return ML(this,t,r,n,o),this}setNodeAttribute(t,r,n){return this.step(new El(t,r,n)),this}setDocAttribute(t,r){return this.step(new ju(t,r)),this}addNodeMark(t,r){return this.step(new Bi(t,r)),this}removeNodeMark(t,r){if(!(r instanceof Ne)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(r=r.isInSet(n.marks),!r)return this}return this.step(new Pl(t,r)),this}split(t,r=1,n){return LL(this,t,r,n),this}addMark(t,r,n){return SL(this,t,r,n),this}removeMark(t,r,n){return wL(this,t,r,n),this}clearIncompatible(t,r,n){return TL(this,t,r,n),this}}const _g=Object.create(null);class ke{constructor(t,r,n){this.$anchor=t,this.$head=r,this.ranges=n||[new GL(t.min(r),t.max(r))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let r=0;r=0;i--){let s=r<0?qa(t.node(0),t.node(i),t.before(i+1),t.index(i),r,n):qa(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,r,n);if(s)return s}return null}static near(t,r=1){return this.findFrom(t,r)||this.findFrom(t,-r)||new xr(t.node(0))}static atStart(t){return qa(t,t,0,0,1)||new xr(t)}static atEnd(t){return qa(t,t,t.content.size,t.childCount,-1)||new xr(t)}static fromJSON(t,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=_g[r.type];if(!n)throw new RangeError(`No selection type ${r.type} defined`);return n.fromJSON(t,r)}static jsonID(t,r){if(t in _g)throw new RangeError("Duplicate use of selection JSON ID "+t);return _g[t]=r,r.prototype.jsonID=t,r}getBookmark(){return ue.between(this.$anchor,this.$head).getBookmark()}}ke.prototype.visible=!0;class GL{constructor(t,r){this.$from=t,this.$to=r}}let $x=!1;function Bx(e){!$x&&!e.parent.inlineContent&&($x=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class ue extends ke{constructor(t,r=t){Bx(t),Bx(r),super(t,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,r){let n=t.resolve(r.map(this.head));if(!n.parent.inlineContent)return ke.near(n);let o=t.resolve(r.map(this.anchor));return new ue(o.parent.inlineContent?o:n,n)}replace(t,r=W.empty){if(super.replace(t,r),r==W.empty){let n=this.$from.marksAcross(this.$to);n&&t.ensureMarks(n)}}eq(t){return t instanceof ue&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new qh(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,r){if(typeof r.anchor!="number"||typeof r.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ue(t.resolve(r.anchor),t.resolve(r.head))}static create(t,r,n=r){let o=t.resolve(r);return new this(o,n==r?o:t.resolve(n))}static between(t,r,n){let o=t.pos-r.pos;if((!n||o)&&(n=o>=0?1:-1),!r.parent.inlineContent){let i=ke.findFrom(r,n,!0)||ke.findFrom(r,-n,!0);if(i)r=i.$head;else return ke.near(r,n)}return t.parent.inlineContent||(o==0?t=r:(t=(ke.findFrom(t,-n,!0)||ke.findFrom(t,n,!0)).$anchor,t.pos0?0:1);o>0?s=0;s+=o){let a=t.child(s);if(a.isAtom){if(!i&&de.isSelectable(a))return de.create(e,r-(o<0?a.nodeSize:0))}else{let l=qa(e,a,r+o,o<0?a.childCount:0,o,i);if(l)return l}r+=a.nodeSize*o}return null}function Hx(e,t,r){let n=e.steps.length-1;if(n{s==null&&(s=u)}),e.setSelection(ke.near(e.doc.resolve(s),r))}const Fx=1,gp=2,Ux=4;class KL extends jL{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(t){return this.storedMarks=t,this.updated|=gp,this}ensureMarks(t){return Ne.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&gp)>0}addStep(t,r){super.addStep(t,r),this.updated=this.updated&~gp,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,r=!0){let n=this.selection;return r&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Ne.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,r,n){let o=this.doc.type.schema;if(r==null)return t?this.replaceSelectionWith(o.text(t),!0):this.deleteSelection();{if(n==null&&(n=r),n=n??r,!t)return this.deleteRange(r,n);let i=this.storedMarks;if(!i){let s=this.doc.resolve(r);i=n==r?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(r,n,o.text(t,i)),this.selection.empty||this.setSelection(ke.near(this.selection.$to)),this}}setMeta(t,r){return this.meta[typeof t=="string"?t:t.key]=r,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ux,this}get scrolledIntoView(){return(this.updated&Ux)>0}}function Vx(e,t){return!t||!e?e:e.bind(t)}class jc{constructor(t,r,n){this.name=t,this.init=Vx(r.init,n),this.apply=Vx(r.apply,n)}}const YL=[new jc("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new jc("selection",{init(e,t){return e.selection||ke.atStart(t.doc)},apply(e){return e.selection}}),new jc("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,r,n){return n.selection.$cursor?e.storedMarks:null}}),new jc("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})];class Ig{constructor(t,r){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=YL.slice(),r&&r.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new jc(n.key,n.spec.state,n))})}}class js{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,r=-1){for(let n=0;nn.toJSON())),t&&typeof t=="object")for(let n in t){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=t[n],i=o.spec.state;i&&i.toJSON&&(r[n]=i.toJSON.call(o,this[o.key]))}return r}static fromJSON(t,r,n){if(!r)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let o=new Ig(t.schema,t.plugins),i=new js(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=ji.fromJSON(t.schema,r.doc);else if(s.name=="selection")i.selection=ke.fromJSON(i.doc,r.selection);else if(s.name=="storedMarks")r.storedMarks&&(i.storedMarks=r.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let a in n){let l=n[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(r,a)){i[s.name]=c.fromJSON.call(l,t,r[a],i);return}}i[s.name]=s.init(t,i)}}),i}}function nO(e,t,r){for(let n in e){let o=e[n];o instanceof Function?o=o.bind(t):n=="handleDOMEvents"&&(o=nO(o,t,{})),r[n]=o}return r}class Po{constructor(t){this.spec=t,this.props={},t.props&&nO(t.props,this,this.props),this.key=t.key?t.key.key:oO("plugin")}getState(t){return t[this.key]}}const Mg=Object.create(null);function oO(e){return e in Mg?e+"$"+ ++Mg[e]:(Mg[e]=0,e+"$")}class Ca{constructor(t="key"){this.key=oO(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}var qL=/[A-Z]/g,XL=/^ms-/,Lg={};function ZL(e){return"-"+e.toLowerCase()}function JL(e){if(Lg.hasOwnProperty(e))return Lg[e];var t=e.replace(qL,ZL);return Lg[e]=XL.test(t)?"-"+t:t}function QL(e){return JL(e)}function e5(e,t){return QL(e)+":"+t}function t5(e){var t="";for(var r in e){var n=e[r];typeof n!="string"&&typeof n!="number"||(t&&(t+=";"),t+=e5(r,n))}return t}function r5(){return typeof document<"u"?document:null}var iO=r5;function sO(e,t){if(typeof e!="string")return[e];var r=[e];typeof t=="string"||Array.isArray(t)?t={brackets:t}:t||(t={});var n=t.brackets?Array.isArray(t.brackets)?t.brackets:[t.brackets]:["{}","[]","()"],o=t.escape||"___",i=!!t.flat;n.forEach(function(l){var c=new RegExp(["\\",l[0],"[^\\",l[0],"\\",l[1],"]*\\",l[1]].join("")),u=[];function d(p,f,h){var m=r.push(p.slice(l[0].length,-l[1].length))-1;return u.push(m),o+m+o}r.forEach(function(p,f){for(var h,m=0;p!=h;)if(h=p,p=p.replace(c,d),m++>1e4)throw Error("References have circular dependency. Please, check them.");r[f]=p}),u=u.reverse(),r=r.map(function(p){return u.forEach(function(f){p=p.replace(new RegExp("(\\"+o+f+"\\"+o+")","g"),l[0]+"$1"+l[1])}),p})});var s=new RegExp("\\"+o+"([0-9]+)\\"+o);function a(l,c,u){for(var d=[],p,f=0;p=s.exec(l);){if(f++>1e4)throw Error("Circular references in parenthesis");d.push(l.slice(0,p.index)),d.push(a(c[p[1]],c)),l=l.slice(p.index+p[0].length)}return d.push(l),d}return i?r:a(r[0],r)}function aO(e,t){if(t&&t.flat){var r=t&&t.escape||"___",n=e[0],o;if(!n)return"";for(var i=new RegExp("\\"+r+"([0-9]+)\\"+r),s=0;n!=o;){if(s++>1e4)throw Error("Circular references in "+e);o=n,n=n.replace(i,a)}return n}return e.reduce(function l(c,u){return Array.isArray(u)&&(u=u.reduce(l,"")),c+u},"");function a(l,c){if(e[c]==null)throw Error("Reference "+c+"is undefined");return e[c]}}function lO(e,t){return Array.isArray(e)?aO(e,t):sO(e,t)}lO.parse=sO;lO.stringify=aO;const n5={id:"extension.command.copy.label",message:"Copy",comment:"Label for copy command."},o5={id:"extension.command.copy.description",message:"Copy the selected text",comment:"Description for copy command."},i5={id:"extension.command.cut.label",message:"Cut",comment:"Label for cut command."},s5={id:"extension.command.cut.description",message:"Cut the selected text",comment:"Description for cut command."},a5={id:"extension.command.paste.label",message:"Paste",comment:"Label for paste command."},l5={id:"extension.command.paste.description",message:"Paste content into the editor",comment:"Description for paste command."},c5={id:"extension.command.select-all.label",message:"Select all",comment:"Label for select all command."},u5={id:"extension.command.select-all.description",message:"Select all content within the editor",comment:"Description for select all command."};var ss=Object.freeze({__proto__:null,COPY_DESCRIPTION:o5,COPY_LABEL:n5,CUT_DESCRIPTION:s5,CUT_LABEL:i5,PASTE_DESCRIPTION:l5,PASTE_LABEL:a5,SELECT_ALL_DESCRIPTION:u5,SELECT_ALL_LABEL:c5});const d5={id:"keyboard.shortcut.escape",message:"Enter",comment:"Label for escape key in shortcuts."},p5={id:"keyboard.shortcut.command",message:"Command",comment:"Label for command key in shortcuts."},f5={id:"keyboard.shortcut.control",message:"Control",comment:"Label for control key in shortcuts."},h5={id:"keyboard.shortcut.enter",message:"Enter",comment:"Label for enter key in shortcuts."},m5={id:"keyboard.shortcut.shift",message:"Shift",comment:"Label for shift key in shortcuts."},g5={id:"keyboard.shortcut.alt",message:"Alt",comment:"Label for alt key in shortcuts."},y5={id:"keyboard.shortcut.capsLock",message:"Caps Lock",comment:"Label for caps lock key in shortcuts."},v5={id:"keyboard.shortcut.backspace",message:"Backspace",comment:"Label for backspace key in shortcuts."},b5={id:"keyboard.shortcut.tab",message:"Tab",comment:"Label for tab key in shortcuts."},E5={id:"keyboard.shortcut.space",message:"Space",comment:"Label for space key in shortcuts."},k5={id:"keyboard.shortcut.delete",message:"Delete",comment:"Label for delete key in shortcuts."},x5={id:"keyboard.shortcut.pageUp",message:"Page Up",comment:"Label for page up key in shortcuts."},S5={id:"keyboard.shortcut.pageDown",message:"Page Down",comment:"Label for page down key in shortcuts."},w5={id:"keyboard.shortcut.home",message:"Home",comment:"Label for home key in shortcuts."},T5={id:"keyboard.shortcut.end",message:"End",comment:"Label for end key in shortcuts."},C5={id:"keyboard.shortcut.arrowLeft",message:"Arrow Left",comment:"Label for arrow left key in shortcuts."},O5={id:"keyboard.shortcut.arrowRight",message:"Arrow Right",comment:"Label for arrow right key in shortcuts."},A5={id:"keyboard.shortcut.arrowUp",message:"Arrow Up",comment:"Label for arrow up key in shortcuts."},N5={id:"keyboard.shortcut.arrowDown",message:"Arrow Down",comment:"Label for arrowDown key in shortcuts."};var _t=Object.freeze({__proto__:null,ALT_KEY:g5,ARROW_DOWN_KEY:N5,ARROW_LEFT_KEY:C5,ARROW_RIGHT_KEY:O5,ARROW_UP_KEY:A5,BACKSPACE_KEY:v5,CAPS_LOCK_KEY:y5,COMMAND_KEY:p5,CONTROL_KEY:f5,DELETE_KEY:k5,END_KEY:T5,ENTER_KEY:h5,ESCAPE_KEY:d5,HOME_KEY:w5,PAGE_DOWN_KEY:S5,PAGE_UP_KEY:x5,SHIFT_KEY:m5,SPACE_KEY:E5,TAB_KEY:b5});const R5={id:"extension.command.toggle-blockquote.label",message:"Blockquote",comment:"Label for blockquote formatting command."},_5={id:"extension.command.toggle-blockquote.description",message:"Add blockquote formatting to the selected text",comment:"Description for blockquote formatting command."};var jx=Object.freeze({__proto__:null,DESCRIPTION:_5,LABEL:R5});const I5={id:"extension.command.toggle-bold.label",message:"Bold",comment:"Label for bold formatting command."},M5={id:"extension.command.toggle-bold.description",message:"Add bold formatting to the selected text",comment:"Description for bold formatting command."};var Gx=Object.freeze({__proto__:null,DESCRIPTION:M5,LABEL:I5});const L5={id:"extension.command.toggle-code-block.label",message:"Codeblock",comment:"Label for the code block command."},D5={id:"extension.command.toggle-code-block.description",message:"Add a code block",comment:"Description for the code block command."};var P5=Object.freeze({__proto__:null,DESCRIPTION:D5,LABEL:L5});const z5={id:"extension.command.toggle-code.label",message:"Code",comment:"Label for the inline code formatting."},$5={id:"extension.command.toggle-code.description",message:"Add inline code formatting to the selected text",comment:"Description for the inline code formatting command."};var B5=Object.freeze({__proto__:null,DESCRIPTION:$5,LABEL:z5});const H5={id:"extension.command.toggle-heading.label",message:`{level, select, 1 {Heading 1}
2 {Heading 2}
3 {Heading 3}
4 {Heading 4}
5 {Heading 5}
6 {Heading 6}
-other {Heading}}`,comment:"Label for heading command with support for levels."};var aN=Object.freeze({__proto__:null,LABEL:sN});const lN={id:"extension.command.undo.label",message:"Undo",comment:"Label for undo."},cN={id:"extension.command.undo.description",message:"Undo the most recent action",comment:"Description for undo."},uN={id:"extension.command.redo.label",message:"Redo",comment:"Label for redo."},dN={id:"extension.command.redo.description",message:"Redo the most recent action",comment:"Description for redo."};var Ep=Object.freeze({__proto__:null,REDO_DESCRIPTION:dN,REDO_LABEL:uN,UNDO_DESCRIPTION:cN,UNDO_LABEL:lN});const fN={id:"extension.command.insert-horizontal-rule.label",message:"Divider",comment:"Label for inserting a horizontal rule (divider) command."},pN={id:"extension.command.insert-horizontal-rule.description",message:"Separate content with a diving horizontal line",comment:"Description for inserting a horizontal rule (divider) command."};var xx=Object.freeze({__proto__:null,DESCRIPTION:pN,LABEL:fN});const hN={id:"extension.command.toggle-italic.label",message:"Italic",comment:"Label for italic formatting command."},mN={id:"extension.command.toggle-italic.description",message:"Italicize the selected text",comment:"Description for italic formatting command."};var wx=Object.freeze({__proto__:null,DESCRIPTION:mN,LABEL:hN});const gN={id:"extension.command.toggle-ordered-list.label",message:"Ordered list",comment:"Label for inserting an ordered list into the editor."},vN={id:"extension.command.toggle-bullet-list.description",message:"Bulleted list",comment:"Description for inserting a bullet list into the editor."},yN={id:"extension.command.toggle-task-list.description",message:"Tasked list",comment:"Description for inserting a task list into the editor."};var Iv=Object.freeze({__proto__:null,BULLET_LIST_LABEL:vN,ORDERED_LIST_LABEL:gN,TASK_LIST_LABEL:yN});const bN={id:"extension.command.insert-paragraph.label",message:"Insert Paragraph",comment:"Label for inserting a paragraph."},kN={id:"extension.command.insert-paragraph.description",message:"Insert a new paragraph",comment:"Description for inserting a paragraph."},xN={id:"extension.command.convert-paragraph.label",message:"Convert Paragraph",comment:"Label for converting the current node into a paragraph."},wN={id:"extension.command.convert-paragraph.description",message:"Convert current block into a paragraph block.",comment:"Description for converting a paragraph."};var Cp=Object.freeze({__proto__:null,CONVERT_DESCRIPTION:wN,CONVERT_LABEL:xN,INSERT_DESCRIPTION:kN,INSERT_LABEL:bN});const SN={id:"extension.command.toggle-strike.label",message:"Strikethrough",comment:"Label for strike formatting command."},EN={id:"extension.command.toggle-strike.description",message:"Strikethrough the selected text",comment:"Description for strike formatting command."};var Sx=Object.freeze({__proto__:null,DESCRIPTION:EN,LABEL:SN});const CN={id:"extension.command.toggle-underline.label",message:"Underline",comment:"Label for underline formatting command."},MN={id:"extension.command.toggle-underline.description",message:"Underline the selected text",comment:"Description for underline formatting command."};var Ex=Object.freeze({__proto__:null,DESCRIPTION:MN,LABEL:CN});class Sa{constructor(t,r){this.match=t,this.match=t,this.handler=typeof r=="string"?TN(r):r}}function TN(e){return function(t,r,n,o){let i=e;if(r[1]){let s=r[0].lastIndexOf(r[1]);i+=r[0].slice(s+r[1].length),n+=s;let a=n-o;a>0&&(i=r[0].slice(s-a,s)+i,n=o)}return t.tr.insertText(i,n,o)}}const ON=500;function _N({rules:e}){let t=new zo({state:{init(){return null},apply(r,n){let o=r.getMeta(this);return o||(r.selectionSet||r.docChanged?null:n)}},props:{handleTextInput(r,n,o,i){return Cx(r,n,o,i,e,t)},handleDOMEvents:{compositionend:r=>{setTimeout(()=>{let{$cursor:n}=r.state.selection;n&&Cx(r,n.pos,n.pos,"",e,t)})}}},isInputRules:!0});return t}function Cx(e,t,r,n,o,i){if(e.composing)return!1;let s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;let l=a.parent.textBetween(Math.max(0,a.parentOffset-ON),a.parentOffset,null,"")+n;for(let c=0;c{let r=e.plugins;for(let n=0;n=0;l--)s.step(a.steps[l].invert(a.docs[l]));if(i.text){let l=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,e.schema.text(i.text,l))}else s.delete(i.from,i.to);t(s)}return!0}}return!1};function $h(e,t,r=null,n){return new Sa(e,(o,i,s,a)=>{let l=r instanceof Function?r(i):r,c=o.tr.delete(s,a),u=c.doc.resolve(s),d=u.blockRange(),f=d&&Pv(d,t,l);if(!f)return null;c.wrap(d,f);let p=c.doc.resolve(s-1).nodeBefore;return p&&p.type==t&&Nd(c.doc,s-1)&&(!n||n(i,p))&&c.join(s-1),c})}function RN(e,t,r=null){return new Sa(e,(n,o,i,s)=>{let a=n.doc.resolve(i),l=r instanceof Function?r(o):r;return a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t)?n.tr.delete(i,s).setBlockType(i,i,t,l):null})}const kr=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Du=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t};let Mx=null;const jo=function(e,t,r){let n=Mx||(Mx=document.createRange());return n.setEnd(e,r??e.nodeValue.length),n.setStart(e,t||0),n},ia=function(e,t,r,n){return r&&(Tx(e,t,r,n,-1)||Tx(e,t,r,n,1))},NN=/^(img|br|input|textarea|hr)$/i;function Tx(e,t,r,n,o){for(;;){if(e==r&&t==n)return!0;if(t==(o<0?0:bo(e))){let i=e.parentNode;if(!i||i.nodeType!=1||Dv(e)||NN.test(e.nodeName)||e.contentEditable=="false")return!1;t=kr(e)+(o<0?0:1),e=i}else if(e.nodeType==1){if(e=e.childNodes[t+(o<0?-1:0)],e.contentEditable=="false")return!1;t=o<0?bo(e):0}else return!1}}function bo(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function PN(e,t,r){for(let n=t==0,o=t==bo(e);n||o;){if(e==r)return!0;let i=kr(e);if(e=e.parentNode,!e)return!1;n=n&&i==0,o=o&&i==bo(e)}}function Dv(e){let t;for(let r=e;r&&!(t=r.pmViewDesc);r=r.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Hh=function(e){return e.focusNode&&ia(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Hs(e,t){let r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=e,r.key=r.code=t,r}function zN(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function LN(e,t,r){if(e.caretPositionFromPoint)try{let n=e.caretPositionFromPoint(t,r);if(n)return{node:n.offsetNode,offset:n.offset}}catch{}if(e.caretRangeFromPoint){let n=e.caretRangeFromPoint(t,r);if(n)return{node:n.startContainer,offset:n.startOffset}}}const _o=typeof navigator<"u"?navigator:null,Ox=typeof document<"u"?document:null,ms=_o&&_o.userAgent||"",L1=/Edge\/(\d+)/.exec(ms),DE=/MSIE \d/.exec(ms),I1=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ms),$r=!!(DE||I1||L1),Vi=DE?document.documentMode:I1?+I1[1]:L1?+L1[1]:0,io=!$r&&/gecko\/(\d+)/i.test(ms);io&&+(/Firefox\/(\d+)/.exec(ms)||[0,0])[1];const D1=!$r&&/Chrome\/(\d+)/.exec(ms),hr=!!D1,IN=D1?+D1[1]:0,Cr=!$r&&!!_o&&/Apple Computer/.test(_o.vendor),Nl=Cr&&(/Mobile\/\w+/.test(ms)||!!_o&&_o.maxTouchPoints>2),En=Nl||(_o?/Mac/.test(_o.platform):!1),DN=_o?/Win/.test(_o.platform):!1,Jn=/Android \d/.test(ms),Pd=!!Ox&&"webkitFontSmoothing"in Ox.documentElement.style,$N=Pd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function HN(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Do(e,t){return typeof e=="number"?e:e[t]}function BN(e){let t=e.getBoundingClientRect(),r=t.width/e.offsetWidth||1,n=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*r,top:t.top,bottom:t.top+e.clientHeight*n}}function _x(e,t,r){let n=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=r||e.dom;s;s=Du(s)){if(s.nodeType!=1)continue;let a=s,l=a==i.body,c=l?HN(i):BN(a),u=0,d=0;if(t.topc.bottom-Do(n,"bottom")&&(d=t.bottom-t.top>c.bottom-c.top?t.top+Do(o,"top")-c.top:t.bottom-c.bottom+Do(o,"bottom")),t.leftc.right-Do(n,"right")&&(u=t.right-c.right+Do(o,"right")),u||d)if(l)i.defaultView.scrollBy(u,d);else{let f=a.scrollLeft,p=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let h=a.scrollLeft-f,m=a.scrollTop-p;t={left:t.left-h,top:t.top-m,right:t.right-h,bottom:t.bottom-m}}if(l||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function FN(e){let t=e.dom.getBoundingClientRect(),r=Math.max(0,t.top),n,o;for(let i=(t.left+t.right)/2,s=r+1;s=r-20){n=a,o=l.top;break}}return{refDOM:n,refTop:o,stack:$E(e.dom)}}function $E(e){let t=[],r=e.ownerDocument;for(let n=e;n&&(t.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),e!=r);n=Du(n));return t}function VN({refDOM:e,refTop:t,stack:r}){let n=e?e.getBoundingClientRect().top:0;HE(r,n==0?0:n-t)}function HE(e,t){for(let r=0;r=a){s=Math.max(h.bottom,s),a=Math.min(h.top,a);let m=h.left>t.left?h.left-t.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!l&&h.left<=t.left&&h.right>=t.left&&(l=u,c={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!r&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(i=d+1)}}return!r&&l&&(r=l,o=c,n=0),r&&r.nodeType==3?UN(r,o):!r||n&&r.nodeType==1?{node:e,offset:i}:BE(r,o)}function UN(e,t){let r=e.nodeValue.length,n=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:e,offset:0}}function $v(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function WN(e,t){let r=e.parentNode;return r&&/^li$/i.test(r.nodeName)&&t.left(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(n,o,i)}function qN(e,t,r,n){let o=-1;for(let i=t,s=!1;i!=e.dom;){let a=e.docView.nearestDesc(i,!0);if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent&&!s||!a.contentDOM)){let l=a.dom.getBoundingClientRect();if(a.node.isBlock&&a.parent&&!s&&(s=!0,l.left>n.left||l.top>n.top?o=a.posBefore:(l.right-1?o:e.docView.posFromDOM(t,r,-1)}function FE(e,t,r){let n=e.childNodes.length;if(n&&r.topt.top&&o++}let c;Pd&&o&&n.nodeType==1&&(c=n.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&n.lastChild.nodeType==1&&t.top>n.lastChild.getBoundingClientRect().bottom?a=e.state.doc.content.size:(o==0||n.nodeType!=1||n.childNodes[o-1].nodeName!="BR")&&(a=qN(e,n,o,t))}a==null&&(a=KN(e,s,t));let l=e.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Ax(e){return e.top=0&&o==n.nodeValue.length?(l--,u=1):r<0?l--:c++,vc(wi(jo(n,l,c),u),u<0)}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(i==null&&o&&(r<0||o==bo(n))){let l=n.childNodes[o-1];if(l.nodeType==1)return xg(l.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(r<0||o==bo(n))){let l=n.childNodes[o-1],c=l.nodeType==3?jo(l,bo(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return vc(wi(c,1),!1)}if(i==null&&o=0)}function vc(e,t){if(e.width==0)return e;let r=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:r,right:r}}function xg(e,t){if(e.height==0)return e;let r=t?e.top:e.bottom;return{top:r,bottom:r,left:e.left,right:e.right}}function jE(e,t,r){let n=e.state,o=e.root.activeElement;n!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return r()}finally{n!=t&&e.updateState(n),o!=e.dom&&o&&o.focus()}}function XN(e,t,r){let n=t.selection,o=r=="up"?n.$from:n.$to;return jE(e,t,()=>{let{node:i}=e.docView.domFromPos(o.pos,r=="up"?-1:1);for(;;){let a=e.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.contentDOM||a.dom;break}i=a.dom.parentNode}let s=VE(e,o.pos,1);for(let a=i.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=jo(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(r=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const JN=/[\u0590-\u08ac]/;function QN(e,t,r){let{$head:n}=t.selection;if(!n.parent.isTextblock)return!1;let o=n.parentOffset,i=!o,s=o==n.parent.content.size,a=e.domSelection();return!JN.test(n.parent.textContent)||!a.modify?r=="left"||r=="backward"?i:s:jE(e,t,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=e.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",r,"character");let p=n.depth?e.docView.domAfterPos(n.before()):e.dom,{focusNode:h,focusOffset:m}=e.domSelectionRange(),b=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),b})}let Rx=null,Nx=null,Px=!1;function ZN(e,t,r){return Rx==t&&Nx==r?Px:(Rx=t,Nx=r,Px=r=="up"||r=="down"?XN(e,t,r):QN(e,t,r))}const An=0,zx=1,Vs=2,Ao=3;class zd{constructor(t,r,n,o){this.parent=t,this.children=r,this.dom=n,this.contentDOM=o,this.dirty=An,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,r,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let r=0;rkr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(r==0)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&r==t.childNodes.length)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??n>0?this.posAtEnd:this.posAtStart}nearestDesc(t,r=!1){for(let n=!0,o=t;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!r||i.node))if(n&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))n=!1;else return i}}getDesc(t){let r=t.pmViewDesc;for(let n=r;n;n=n.parent)if(n==this)return r}posFromDOM(t,r,n){for(let o=t;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(t,r,n)}return-1}descAt(t){for(let r=0,n=0;rt||s instanceof WE){o=t-i;break}i=a}if(o)return this.children[n].domFromPos(o-this.children[n].border,r);for(let i;n&&!(i=this.children[n-1]).size&&i instanceof UE&&i.side>=0;n--);if(r<=0){let i,s=!0;for(;i=n?this.children[n-1]:null,!(!i||i.dom.parentNode==this.contentDOM);n--,s=!1);return i&&r&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,r):{node:this.contentDOM,offset:i?kr(i.dom)+1:0}}else{let i,s=!0;for(;i=n=u&&r<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(t,r,u);t=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)){o=kr(f.dom)+1;break}t-=f.size}o==-1&&(o=0)}if(o>-1&&(c>r||a==this.children.length-1)){r=c;for(let u=a+1;up&&sr){let p=a;a=l,l=p}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,r){for(let n=0,o=0;o=n:tn){let a=n+i.border,l=s-i.border;if(t>=a&&r<=l){this.dirty=t==n||r==s?Vs:zx,t==a&&r==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ao:i.markDirty(t-a,r-a);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Vs:Ao}n=s}this.dirty=Vs}markParentsDirty(){let t=1;for(let r=this.parent;r;r=r.parent,t++){let n=t==1?Vs:zx;r.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!r.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(t,[],s,null),this.widget=r,this.widget=r,i=this}matchesWidget(t){return this.dirty==An&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let r=this.widget.spec.stopEvent;return r?r(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class eP extends zd{constructor(t,r,n,o){super(t,[],r,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(t,r){return t!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class sa extends zd{constructor(t,r,n,o){super(t,[],n,o),this.mark=r}static create(t,r,n,o){let i=o.nodeViews[r.type.name],s=i&&i(r,o,n);return(!s||!s.dom)&&(s=cn.renderSpec(document,r.type.spec.toDOM(r,n))),new sa(t,r,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&Ao||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Ao&&this.mark.eq(t)}markDirty(t,r){if(super.markDirty(t,r),this.dirty!=An){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(i=B1(i,0,t,n));for(let a=0;a{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},n,o),u=c&&c.dom,d=c&&c.contentDOM;if(r.isText){if(!u)u=document.createTextNode(r.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=cn.renderSpec(document,r.type.spec.toDOM(r)));!d&&!r.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),r.type.spec.draggable&&(u.draggable=!0));let f=u;return u=GE(u,n,r),c?l=new tP(t,r,n,o,u,d||null,f,c,i,s+1):r.isText?new Bh(t,r,n,o,u,f,i):new ji(t,r,n,o,u,d||null,f,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let n=this.children[r];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>N.empty)}return t}matchesNode(t,r,n){return this.dirty==An&&t.eq(this.node)&&H1(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,r){let n=this.node.inlineContent,o=r,i=t.composing?this.localCompositionInfo(t,r):null,s=i&&i.pos>-1?i:null,a=i&&i.pos<0,l=new nP(this,s&&s.node,t);sP(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,n,t):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?_e.none:this.node.child(u).marks,n,t),l.placeWidget(c,t,o)},(c,u,d,f)=>{l.syncToMarks(c.marks,n,t);let p;l.findNodeMatch(c,u,d,f)||a&&t.state.selection.from>o&&t.state.selection.to-1&&l.updateNodeAt(c,u,d,p,t)||l.updateNextNode(c,u,d,t,f,o)||l.addNode(c,u,d,t,o),o+=c.nodeSize}),l.syncToMarks([],n,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Vs)&&(s&&this.protectLocalComposition(t,s),KE(this.contentDOM,this.children,t),Nl&&aP(this.dom))}localCompositionInfo(t,r){let{from:n,to:o}=t.state.selection;if(!(t.state.selection instanceof ue)||nr+this.node.content.size)return null;let i=t.domSelectionRange(),s=lP(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,l=cP(this.node.content,a,n-r,o-r);return l<0?null:{node:s,pos:l,text:a}}else return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:r,pos:n,text:o}){if(this.getDesc(r))return;let i=r;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new eP(this,i,r,o);t.input.compositionNodes.push(s),this.children=B1(this.children,n,n+o.length,t,s)}update(t,r,n,o){return this.dirty==Ao||!t.sameMarkup(this.node)?!1:(this.updateInner(t,r,n,o),!0)}updateInner(t,r,n,o){this.updateOuterDeco(r),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=An}updateOuterDeco(t){if(H1(t,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=qE(this.dom,this.nodeDOM,$1(this.outerDeco,this.node,r),$1(t,this.node,r)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function Lx(e,t,r,n,o){GE(n,t,e);let i=new ji(void 0,e,t,r,n,n,n,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Bh extends ji{constructor(t,r,n,o,i,s,a){super(t,r,n,o,i,null,s,a,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,r,n,o){return this.dirty==Ao||this.dirty!=An&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=An||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=An,!0)}inParent(){let t=this.parent.contentDOM;for(let r=this.nodeDOM;r;r=r.parentNode)if(r==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,r,n){return t==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):super.localPosFromDOM(t,r,n)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,r,n){let o=this.node.cut(t,r),i=document.createTextNode(o.text);return new Bh(this.parent,o,this.outerDeco,this.innerDeco,i,i,n)}markDirty(t,r){super.markDirty(t,r),this.dom!=this.nodeDOM&&(t==0||r==this.nodeDOM.nodeValue.length)&&(this.dirty=Ao)}get domAtom(){return!1}}class WE extends zd{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==An&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class tP extends ji{constructor(t,r,n,o,i,s,a,l,c,u){super(t,r,n,o,i,s,a,c,u),this.spec=l}update(t,r,n,o){if(this.dirty==Ao)return!1;if(this.spec.update){let i=this.spec.update(t,r,n);return i&&this.updateInner(t,r,n,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,r,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,r,n,o){this.spec.setSelection?this.spec.setSelection(t,r,n):super.setSelection(t,r,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function KE(e,t,r){let n=e.firstChild,o=!1;for(let i=0;i>1,s=Math.min(i,t.length);for(;o-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=sa.create(this.top,t[i],r,n);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,i++}}findNodeMatch(t,r,n,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(t,r,n))i=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(n){let c=r.children[n-1];if(c instanceof sa)r=c,n=c.children.length;else{a=c,n--;break}}else{if(r==t)break e;n=r.parent.children.indexOf(r),r=r.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}function iP(e,t){return e.type.side-t.type.side}function sP(e,t,r,n){let o=t.locals(e),i=0;if(o.length==0){for(let c=0;ci;)a.push(o[s++]);let h=i+f.nodeSize;if(f.isText){let b=h;s!b.inline):a.slice();n(f,m,t.forChild(i,f),p),i=h}}function aP(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function lP(e,t){for(;;){if(e.nodeType==3)return e;if(e.nodeType==1&&t>0){if(e.childNodes.length>t&&e.childNodes[t].nodeType==3)return e.childNodes[t];e=e.childNodes[t-1],t=bo(e)}else if(e.nodeType==1&&t=r){if(i>=n&&l.slice(n-t.length-a,n-a)==t)return n-t.length;let c=a=0&&c+t.length+a>=r)return a+c;if(r==n&&l.length>=n+t.length-a&&l.slice(n-a,n-a+t.length)==t)return n}}return-1}function B1(e,t,r,n,o){let i=[];for(let s=0,a=0;s=r||u<=t?i.push(l):(cr&&i.push(l.slice(r-c,l.size,n)))}return i}function Hv(e,t=null){let r=e.domSelectionRange(),n=e.state.doc;if(!r.focusNode)return null;let o=e.docView.nearestDesc(r.focusNode),i=o&&o.size==0,s=e.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(s<0)return null;let a=n.resolve(s),l,c;if(Hh(r)){for(l=a;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&de.isSelectable(u)&&o.parent&&!(u.isInline&&PN(r.focusNode,r.focusOffset,o.dom))){let d=o.posBefore;c=new de(s==d?a:n.resolve(d))}}else{let u=e.docView.posFromDOM(r.anchorNode,r.anchorOffset,1);if(u<0)return null;l=n.resolve(u)}if(!c){let u=t=="pointer"||e.state.selection.head{(r.anchorNode!=n||r.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!YE(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function dP(e){let t=e.domSelection(),r=document.createRange(),n=e.cursorWrapper.dom,o=n.nodeName=="IMG";o?r.setEnd(n.parentNode,kr(n)+1):r.setEnd(n,0),r.collapse(!1),t.removeAllRanges(),t.addRange(r),!o&&!e.state.selection.visible&&$r&&Vi<=11&&(n.disabled=!0,n.disabled=!1)}function XE(e,t){if(t instanceof de){let r=e.docView.descAt(t.from);r!=e.lastSelectedViewDesc&&(Bx(e),r&&r.selectNode(),e.lastSelectedViewDesc=r)}else Bx(e)}function Bx(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Bv(e,t,r,n){return e.someProp("createSelectionBetween",o=>o(e,t,r))||ue.between(t,r,n)}function Fx(e){return e.editable&&!e.hasFocus()?!1:JE(e)}function JE(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function fP(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),r=e.domSelectionRange();return ia(t.node,t.offset,r.anchorNode,r.anchorOffset)}function F1(e,t){let{$anchor:r,$head:n}=e.selection,o=t>0?r.max(n):r.min(n),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&xe.findFrom(i,t)}function Oi(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Vx(e,t,r){let n=e.state.selection;if(n instanceof ue)if(r.indexOf("s")>-1){let{$head:o}=n,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=e.state.doc.resolve(o.pos+i.nodeSize*(t<0?-1:1));return Oi(e,new ue(n.$anchor,s))}else if(n.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=F1(e.state,t);return o&&o instanceof de?Oi(e,o):!1}else if(!(En&&r.indexOf("m")>-1)){let o=n.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let a=t<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=e.docView.descAt(a))&&!s.contentDOM?de.isSelectable(i)?Oi(e,new de(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):Pd?Oi(e,new ue(e.state.doc.resolve(t<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(n instanceof de&&n.node.isInline)return Oi(e,new ue(t>0?n.$to:n.$from));{let o=F1(e.state,t);return o?Oi(e,o):!1}}}function Mp(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function vu(e,t){let r=e.pmViewDesc;return r&&r.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function Na(e,t){return t<0?pP(e):hP(e)}function pP(e){let t=e.domSelectionRange(),r=t.focusNode,n=t.focusOffset;if(!r)return;let o,i,s=!1;for(io&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let a=r.childNodes[n-1];if(vu(a,-1))o=r,i=--n;else if(a.nodeType==3)r=a,n=r.nodeValue.length;else break}}else{if(QE(r))break;{let a=r.previousSibling;for(;a&&vu(a,-1);)o=r.parentNode,i=kr(a),a=a.previousSibling;if(a)r=a,n=Mp(r);else{if(r=r.parentNode,r==e.dom)break;n=0}}}s?V1(e,r,n):o&&V1(e,o,i)}function hP(e){let t=e.domSelectionRange(),r=t.focusNode,n=t.focusOffset;if(!r)return;let o=Mp(r),i,s;for(;;)if(n{e.state==o&&ei(e)},50)}function jx(e,t){let r=e.state.doc.resolve(t);if(!(hr||DN)&&r.parent.inlineContent){let o=e.coordsAtPos(t);if(t>r.start()){let i=e.coordsAtPos(t-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function Ux(e,t,r){let n=e.state.selection;if(n instanceof ue&&!n.empty||r.indexOf("s")>-1||En&&r.indexOf("m")>-1)return!1;let{$from:o,$to:i}=n;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let s=F1(e.state,t);if(s&&s instanceof de)return Oi(e,s)}if(!o.parent.inlineContent){let s=t<0?o:i,a=n instanceof wr?xe.near(s,t):xe.findFrom(s,t);return a?Oi(e,a):!1}return!1}function Wx(e,t){if(!(e.state.selection instanceof ue))return!0;let{$head:r,$anchor:n,empty:o}=e.state.selection;if(!r.sameParent(n))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!r.textOffset&&(t<0?r.nodeBefore:r.nodeAfter);if(i&&!i.isText){let s=e.state.tr;return t<0?s.delete(r.pos-i.nodeSize,r.pos):s.delete(r.pos,r.pos+i.nodeSize),e.dispatch(s),!0}return!1}function Kx(e,t,r){e.domObserver.stop(),t.contentEditable=r,e.domObserver.start()}function vP(e){if(!Cr||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:r}=e.domSelectionRange();if(t&&t.nodeType==1&&r==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let n=t.firstChild;Kx(e,n,"true"),setTimeout(()=>Kx(e,n,"false"),20)}return!1}function yP(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function bP(e,t){let r=t.keyCode,n=yP(t);if(r==8||En&&r==72&&n=="c")return Wx(e,-1)||Na(e,-1);if(r==46&&!t.shiftKey||En&&r==68&&n=="c")return Wx(e,1)||Na(e,1);if(r==13||r==27)return!0;if(r==37||En&&r==66&&n=="c"){let o=r==37?jx(e,e.state.selection.from)=="ltr"?-1:1:-1;return Vx(e,o,n)||Na(e,o)}else if(r==39||En&&r==70&&n=="c"){let o=r==39?jx(e,e.state.selection.from)=="ltr"?1:-1:1;return Vx(e,o,n)||Na(e,o)}else{if(r==38||En&&r==80&&n=="c")return Ux(e,-1,n)||Na(e,-1);if(r==40||En&&r==78&&n=="c")return vP(e)||Ux(e,1,n)||Na(e,1);if(n==(En?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function ZE(e,t){e.someProp("transformCopied",p=>{t=p(t,e)});let r=[],{content:n,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&n.childCount==1&&n.firstChild.childCount==1;){o--,i--;let p=n.firstChild;r.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),n=p.content}let s=e.someProp("clipboardSerializer")||cn.fromSchema(e.state.schema),a=i5(),l=a.createElement("div");l.appendChild(s.serializeFragment(n,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=o5[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",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(r)}`);let f=e.someProp("clipboardTextSerializer",p=>p(t,e))||t.content.textBetween(0,t.content.size,`
+other {Heading}}`,comment:"Label for heading command with support for levels."};var F5=Object.freeze({__proto__:null,LABEL:H5});const U5={id:"extension.command.undo.label",message:"Undo",comment:"Label for undo."},V5={id:"extension.command.undo.description",message:"Undo the most recent action",comment:"Description for undo."},j5={id:"extension.command.redo.label",message:"Redo",comment:"Label for redo."},G5={id:"extension.command.redo.description",message:"Redo the most recent action",comment:"Description for redo."};var Pf=Object.freeze({__proto__:null,REDO_DESCRIPTION:G5,REDO_LABEL:j5,UNDO_DESCRIPTION:V5,UNDO_LABEL:U5});const W5={id:"extension.command.insert-horizontal-rule.label",message:"Divider",comment:"Label for inserting a horizontal rule (divider) command."},K5={id:"extension.command.insert-horizontal-rule.description",message:"Separate content with a diving horizontal line",comment:"Description for inserting a horizontal rule (divider) command."};var Wx=Object.freeze({__proto__:null,DESCRIPTION:K5,LABEL:W5});const Y5={id:"extension.command.toggle-italic.label",message:"Italic",comment:"Label for italic formatting command."},q5={id:"extension.command.toggle-italic.description",message:"Italicize the selected text",comment:"Description for italic formatting command."};var Kx=Object.freeze({__proto__:null,DESCRIPTION:q5,LABEL:Y5});const X5={id:"extension.command.toggle-ordered-list.label",message:"Ordered list",comment:"Label for inserting an ordered list into the editor."},Z5={id:"extension.command.toggle-bullet-list.description",message:"Bulleted list",comment:"Description for inserting a bullet list into the editor."},J5={id:"extension.command.toggle-task-list.description",message:"Tasked list",comment:"Description for inserting a task list into the editor."};var Yy=Object.freeze({__proto__:null,BULLET_LIST_LABEL:Z5,ORDERED_LIST_LABEL:X5,TASK_LIST_LABEL:J5});const Q5={id:"extension.command.insert-paragraph.label",message:"Insert Paragraph",comment:"Label for inserting a paragraph."},eD={id:"extension.command.insert-paragraph.description",message:"Insert a new paragraph",comment:"Description for inserting a paragraph."},tD={id:"extension.command.convert-paragraph.label",message:"Convert Paragraph",comment:"Label for converting the current node into a paragraph."},rD={id:"extension.command.convert-paragraph.description",message:"Convert current block into a paragraph block.",comment:"Description for converting a paragraph."};var zf=Object.freeze({__proto__:null,CONVERT_DESCRIPTION:rD,CONVERT_LABEL:tD,INSERT_DESCRIPTION:eD,INSERT_LABEL:Q5});const nD={id:"extension.command.toggle-strike.label",message:"Strikethrough",comment:"Label for strike formatting command."},oD={id:"extension.command.toggle-strike.description",message:"Strikethrough the selected text",comment:"Description for strike formatting command."};var Yx=Object.freeze({__proto__:null,DESCRIPTION:oD,LABEL:nD});const iD={id:"extension.command.toggle-underline.label",message:"Underline",comment:"Label for underline formatting command."},sD={id:"extension.command.toggle-underline.description",message:"Underline the selected text",comment:"Description for underline formatting command."};var qx=Object.freeze({__proto__:null,DESCRIPTION:sD,LABEL:iD});class Oa{constructor(t,r){this.match=t,this.match=t,this.handler=typeof r=="string"?aD(r):r}}function aD(e){return function(t,r,n,o){let i=e;if(r[1]){let s=r[0].lastIndexOf(r[1]);i+=r[0].slice(s+r[1].length),n+=s;let a=n-o;a>0&&(i=r[0].slice(s-a,s)+i,n=o)}return t.tr.insertText(i,n,o)}}const lD=500;function cD({rules:e}){let t=new Po({state:{init(){return null},apply(r,n){let o=r.getMeta(this);return o||(r.selectionSet||r.docChanged?null:n)}},props:{handleTextInput(r,n,o,i){return Xx(r,n,o,i,e,t)},handleDOMEvents:{compositionend:r=>{setTimeout(()=>{let{$cursor:n}=r.state.selection;n&&Xx(r,n.pos,n.pos,"",e,t)})}}},isInputRules:!0});return t}function Xx(e,t,r,n,o,i){if(e.composing)return!1;let s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;let l=a.parent.textBetween(Math.max(0,a.parentOffset-lD),a.parentOffset,null,"")+n;for(let c=0;c{let r=e.plugins;for(let n=0;n=0;l--)s.step(a.steps[l].invert(a.docs[l]));if(i.text){let l=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,e.schema.text(i.text,l))}else s.delete(i.from,i.to);t(s)}return!0}}return!1};function Xh(e,t,r=null,n){return new Oa(e,(o,i,s,a)=>{let l=r instanceof Function?r(i):r,c=o.tr.delete(s,a),u=c.doc.resolve(s),d=u.blockRange(),p=d&&Gy(d,t,l);if(!p)return null;c.wrap(d,p);let f=c.doc.resolve(s-1).nodeBefore;return f&&f.type==t&&Hd(c.doc,s-1)&&(!n||n(i,f))&&c.join(s-1),c})}function dD(e,t,r=null){return new Oa(e,(n,o,i,s)=>{let a=n.doc.resolve(i),l=r instanceof Function?r(o):r;return a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t)?n.tr.delete(i,s).setBlockType(i,i,t,l):null})}const Er=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Gu=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t};let Zx=null;const Wo=function(e,t,r){let n=Zx||(Zx=document.createRange());return n.setEnd(e,r??e.nodeValue.length),n.setStart(e,t||0),n},la=function(e,t,r,n){return r&&(Jx(e,t,r,n,-1)||Jx(e,t,r,n,1))},pD=/^(img|br|input|textarea|hr)$/i;function Jx(e,t,r,n,o){for(;;){if(e==r&&t==n)return!0;if(t==(o<0?0:ko(e))){let i=e.parentNode;if(!i||i.nodeType!=1||qy(e)||pD.test(e.nodeName)||e.contentEditable=="false")return!1;t=Er(e)+(o<0?0:1),e=i}else if(e.nodeType==1){if(e=e.childNodes[t+(o<0?-1:0)],e.contentEditable=="false")return!1;t=o<0?ko(e):0}else return!1}}function ko(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function fD(e,t,r){for(let n=t==0,o=t==ko(e);n||o;){if(e==r)return!0;let i=Er(e);if(e=e.parentNode,!e)return!1;n=n&&i==0,o=o&&i==ko(e)}}function qy(e){let t;for(let r=e;r&&!(t=r.pmViewDesc);r=r.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Zh=function(e){return e.focusNode&&la(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Us(e,t){let r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=e,r.key=r.code=t,r}function hD(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function mD(e,t,r){if(e.caretPositionFromPoint)try{let n=e.caretPositionFromPoint(t,r);if(n)return{node:n.offsetNode,offset:n.offset}}catch{}if(e.caretRangeFromPoint){let n=e.caretRangeFromPoint(t,r);if(n)return{node:n.startContainer,offset:n.startOffset}}}const _o=typeof navigator<"u"?navigator:null,Qx=typeof document<"u"?document:null,ys=_o&&_o.userAgent||"",X1=/Edge\/(\d+)/.exec(ys),cO=/MSIE \d/.exec(ys),Z1=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ys),Hr=!!(cO||Z1||X1),Gi=cO?document.documentMode:Z1?+Z1[1]:X1?+X1[1]:0,ao=!Hr&&/gecko\/(\d+)/i.test(ys);ao&&+(/Firefox\/(\d+)/.exec(ys)||[0,0])[1];const J1=!Hr&&/Chrome\/(\d+)/.exec(ys),hr=!!J1,gD=J1?+J1[1]:0,Tr=!Hr&&!!_o&&/Apple Computer/.test(_o.vendor),$l=Tr&&(/Mobile\/\w+/.test(ys)||!!_o&&_o.maxTouchPoints>2),Cn=$l||(_o?/Mac/.test(_o.platform):!1),yD=_o?/Win/.test(_o.platform):!1,eo=/Android \d/.test(ys),Fd=!!Qx&&"webkitFontSmoothing"in Qx.documentElement.style,vD=Fd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function bD(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Ho(e,t){return typeof e=="number"?e:e[t]}function ED(e){let t=e.getBoundingClientRect(),r=t.width/e.offsetWidth||1,n=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*r,top:t.top,bottom:t.top+e.clientHeight*n}}function eS(e,t,r){let n=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=r||e.dom;s;s=Gu(s)){if(s.nodeType!=1)continue;let a=s,l=a==i.body,c=l?bD(i):ED(a),u=0,d=0;if(t.topc.bottom-Ho(n,"bottom")&&(d=t.bottom-t.top>c.bottom-c.top?t.top+Ho(o,"top")-c.top:t.bottom-c.bottom+Ho(o,"bottom")),t.leftc.right-Ho(n,"right")&&(u=t.right-c.right+Ho(o,"right")),u||d)if(l)i.defaultView.scrollBy(u,d);else{let p=a.scrollLeft,f=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let h=a.scrollLeft-p,m=a.scrollTop-f;t={left:t.left-h,top:t.top-m,right:t.right-h,bottom:t.bottom-m}}if(l||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function kD(e){let t=e.dom.getBoundingClientRect(),r=Math.max(0,t.top),n,o;for(let i=(t.left+t.right)/2,s=r+1;s=r-20){n=a,o=l.top;break}}return{refDOM:n,refTop:o,stack:uO(e.dom)}}function uO(e){let t=[],r=e.ownerDocument;for(let n=e;n&&(t.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),e!=r);n=Gu(n));return t}function xD({refDOM:e,refTop:t,stack:r}){let n=e?e.getBoundingClientRect().top:0;dO(r,n==0?0:n-t)}function dO(e,t){for(let r=0;r=a){s=Math.max(h.bottom,s),a=Math.min(h.top,a);let m=h.left>t.left?h.left-t.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!l&&h.left<=t.left&&h.right>=t.left&&(l=u,c={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!r&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(i=d+1)}}return!r&&l&&(r=l,o=c,n=0),r&&r.nodeType==3?wD(r,o):!r||n&&r.nodeType==1?{node:e,offset:i}:pO(r,o)}function wD(e,t){let r=e.nodeValue.length,n=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:e,offset:0}}function Xy(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function TD(e,t){let r=e.parentNode;return r&&/^li$/i.test(r.nodeName)&&t.left(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(n,o,i)}function OD(e,t,r,n){let o=-1;for(let i=t,s=!1;i!=e.dom;){let a=e.docView.nearestDesc(i,!0);if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent&&!s||!a.contentDOM)){let l=a.dom.getBoundingClientRect();if(a.node.isBlock&&a.parent&&!s&&(s=!0,l.left>n.left||l.top>n.top?o=a.posBefore:(l.right-1?o:e.docView.posFromDOM(t,r,-1)}function fO(e,t,r){let n=e.childNodes.length;if(n&&r.topt.top&&o++}let c;Fd&&o&&n.nodeType==1&&(c=n.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&n.lastChild.nodeType==1&&t.top>n.lastChild.getBoundingClientRect().bottom?a=e.state.doc.content.size:(o==0||n.nodeType!=1||n.childNodes[o-1].nodeName!="BR")&&(a=OD(e,n,o,t))}a==null&&(a=CD(e,s,t));let l=e.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function tS(e){return e.top=0&&o==n.nodeValue.length?(l--,u=1):r<0?l--:c++,Cc(Ti(Wo(n,l,c),u),u<0)}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(i==null&&o&&(r<0||o==ko(n))){let l=n.childNodes[o-1];if(l.nodeType==1)return Dg(l.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(r<0||o==ko(n))){let l=n.childNodes[o-1],c=l.nodeType==3?Wo(l,ko(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Cc(Ti(c,1),!1)}if(i==null&&o=0)}function Cc(e,t){if(e.width==0)return e;let r=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:r,right:r}}function Dg(e,t){if(e.height==0)return e;let r=t?e.top:e.bottom;return{top:r,bottom:r,left:e.left,right:e.right}}function mO(e,t,r){let n=e.state,o=e.root.activeElement;n!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return r()}finally{n!=t&&e.updateState(n),o!=e.dom&&o&&o.focus()}}function RD(e,t,r){let n=t.selection,o=r=="up"?n.$from:n.$to;return mO(e,t,()=>{let{node:i}=e.docView.domFromPos(o.pos,r=="up"?-1:1);for(;;){let a=e.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.contentDOM||a.dom;break}i=a.dom.parentNode}let s=hO(e,o.pos,1);for(let a=i.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Wo(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(r=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const _D=/[\u0590-\u08ac]/;function ID(e,t,r){let{$head:n}=t.selection;if(!n.parent.isTextblock)return!1;let o=n.parentOffset,i=!o,s=o==n.parent.content.size,a=e.domSelection();return!_D.test(n.parent.textContent)||!a.modify?r=="left"||r=="backward"?i:s:mO(e,t,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=e.domSelectionRange(),p=a.caretBidiLevel;a.modify("move",r,"character");let f=n.depth?e.docView.domAfterPos(n.before()):e.dom,{focusNode:h,focusOffset:m}=e.domSelectionRange(),b=h&&!f.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 p!=null&&(a.caretBidiLevel=p),b})}let rS=null,nS=null,oS=!1;function MD(e,t,r){return rS==t&&nS==r?oS:(rS=t,nS=r,oS=r=="up"||r=="down"?RD(e,t,r):ID(e,t,r))}const In=0,iS=1,Gs=2,Io=3;class Ud{constructor(t,r,n,o){this.parent=t,this.children=r,this.dom=n,this.contentDOM=o,this.dirty=In,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,r,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let r=0;rEr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(r==0)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&r==t.childNodes.length)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??n>0?this.posAtEnd:this.posAtStart}nearestDesc(t,r=!1){for(let n=!0,o=t;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!r||i.node))if(n&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))n=!1;else return i}}getDesc(t){let r=t.pmViewDesc;for(let n=r;n;n=n.parent)if(n==this)return r}posFromDOM(t,r,n){for(let o=t;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(t,r,n)}return-1}descAt(t){for(let r=0,n=0;rt||s instanceof yO){o=t-i;break}i=a}if(o)return this.children[n].domFromPos(o-this.children[n].border,r);for(let i;n&&!(i=this.children[n-1]).size&&i instanceof gO&&i.side>=0;n--);if(r<=0){let i,s=!0;for(;i=n?this.children[n-1]:null,!(!i||i.dom.parentNode==this.contentDOM);n--,s=!1);return i&&r&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,r):{node:this.contentDOM,offset:i?Er(i.dom)+1:0}}else{let i,s=!0;for(;i=n=u&&r<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(t,r,u);t=s;for(let d=a;d>0;d--){let p=this.children[d-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){o=Er(p.dom)+1;break}t-=p.size}o==-1&&(o=0)}if(o>-1&&(c>r||a==this.children.length-1)){r=c;for(let u=a+1;uf&&sr){let f=a;a=l,l=f}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,r){for(let n=0,o=0;o=n:tn){let a=n+i.border,l=s-i.border;if(t>=a&&r<=l){this.dirty=t==n||r==s?Gs:iS,t==a&&r==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Io:i.markDirty(t-a,r-a);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Gs:Io}n=s}this.dirty=Gs}markParentsDirty(){let t=1;for(let r=this.parent;r;r=r.parent,t++){let n=t==1?Gs:iS;r.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!r.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(t,[],s,null),this.widget=r,this.widget=r,i=this}matchesWidget(t){return this.dirty==In&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let r=this.widget.spec.stopEvent;return r?r(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class LD extends Ud{constructor(t,r,n,o){super(t,[],r,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(t,r){return t!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class ca extends Ud{constructor(t,r,n,o){super(t,[],n,o),this.mark=r}static create(t,r,n,o){let i=o.nodeViews[r.type.name],s=i&&i(r,o,n);return(!s||!s.dom)&&(s=un.renderSpec(document,r.type.spec.toDOM(r,n))),new ca(t,r,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&Io||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Io&&this.mark.eq(t)}markDirty(t,r){if(super.markDirty(t,r),this.dirty!=In){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(i=t0(i,0,t,n));for(let a=0;a{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},n,o),u=c&&c.dom,d=c&&c.contentDOM;if(r.isText){if(!u)u=document.createTextNode(r.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=un.renderSpec(document,r.type.spec.toDOM(r)));!d&&!r.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),r.type.spec.draggable&&(u.draggable=!0));let p=u;return u=EO(u,n,r),c?l=new DD(t,r,n,o,u,d||null,p,c,i,s+1):r.isText?new Jh(t,r,n,o,u,p,i):new Wi(t,r,n,o,u,d||null,p,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let n=this.children[r];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>I.empty)}return t}matchesNode(t,r,n){return this.dirty==In&&t.eq(this.node)&&e0(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,r){let n=this.node.inlineContent,o=r,i=t.composing?this.localCompositionInfo(t,r):null,s=i&&i.pos>-1?i:null,a=i&&i.pos<0,l=new zD(this,s&&s.node,t);HD(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,n,t):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?Ne.none:this.node.child(u).marks,n,t),l.placeWidget(c,t,o)},(c,u,d,p)=>{l.syncToMarks(c.marks,n,t);let f;l.findNodeMatch(c,u,d,p)||a&&t.state.selection.from>o&&t.state.selection.to-1&&l.updateNodeAt(c,u,d,f,t)||l.updateNextNode(c,u,d,t,p,o)||l.addNode(c,u,d,t,o),o+=c.nodeSize}),l.syncToMarks([],n,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Gs)&&(s&&this.protectLocalComposition(t,s),vO(this.contentDOM,this.children,t),$l&&FD(this.dom))}localCompositionInfo(t,r){let{from:n,to:o}=t.state.selection;if(!(t.state.selection instanceof ue)||nr+this.node.content.size)return null;let i=t.domSelectionRange(),s=UD(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,l=VD(this.node.content,a,n-r,o-r);return l<0?null:{node:s,pos:l,text:a}}else return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:r,pos:n,text:o}){if(this.getDesc(r))return;let i=r;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new LD(this,i,r,o);t.input.compositionNodes.push(s),this.children=t0(this.children,n,n+o.length,t,s)}update(t,r,n,o){return this.dirty==Io||!t.sameMarkup(this.node)?!1:(this.updateInner(t,r,n,o),!0)}updateInner(t,r,n,o){this.updateOuterDeco(r),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=In}updateOuterDeco(t){if(e0(t,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=bO(this.dom,this.nodeDOM,Q1(this.outerDeco,this.node,r),Q1(t,this.node,r)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function sS(e,t,r,n,o){EO(n,t,e);let i=new Wi(void 0,e,t,r,n,n,n,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Jh extends Wi{constructor(t,r,n,o,i,s,a){super(t,r,n,o,i,null,s,a,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,r,n,o){return this.dirty==Io||this.dirty!=In&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=In||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=In,!0)}inParent(){let t=this.parent.contentDOM;for(let r=this.nodeDOM;r;r=r.parentNode)if(r==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,r,n){return t==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):super.localPosFromDOM(t,r,n)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,r,n){let o=this.node.cut(t,r),i=document.createTextNode(o.text);return new Jh(this.parent,o,this.outerDeco,this.innerDeco,i,i,n)}markDirty(t,r){super.markDirty(t,r),this.dom!=this.nodeDOM&&(t==0||r==this.nodeDOM.nodeValue.length)&&(this.dirty=Io)}get domAtom(){return!1}}class yO extends Ud{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==In&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class DD extends Wi{constructor(t,r,n,o,i,s,a,l,c,u){super(t,r,n,o,i,s,a,c,u),this.spec=l}update(t,r,n,o){if(this.dirty==Io)return!1;if(this.spec.update){let i=this.spec.update(t,r,n);return i&&this.updateInner(t,r,n,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,r,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,r,n,o){this.spec.setSelection?this.spec.setSelection(t,r,n):super.setSelection(t,r,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function vO(e,t,r){let n=e.firstChild,o=!1;for(let i=0;i>1,s=Math.min(i,t.length);for(;o-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=ca.create(this.top,t[i],r,n);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,i++}}findNodeMatch(t,r,n,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(t,r,n))i=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(n){let c=r.children[n-1];if(c instanceof ca)r=c,n=c.children.length;else{a=c,n--;break}}else{if(r==t)break e;n=r.parent.children.indexOf(r),r=r.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}function BD(e,t){return e.type.side-t.type.side}function HD(e,t,r,n){let o=t.locals(e),i=0;if(o.length==0){for(let c=0;ci;)a.push(o[s++]);let h=i+p.nodeSize;if(p.isText){let b=h;s!b.inline):a.slice();n(p,m,t.forChild(i,p),f),i=h}}function FD(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function UD(e,t){for(;;){if(e.nodeType==3)return e;if(e.nodeType==1&&t>0){if(e.childNodes.length>t&&e.childNodes[t].nodeType==3)return e.childNodes[t];e=e.childNodes[t-1],t=ko(e)}else if(e.nodeType==1&&t=r){if(i>=n&&l.slice(n-t.length-a,n-a)==t)return n-t.length;let c=a=0&&c+t.length+a>=r)return a+c;if(r==n&&l.length>=n+t.length-a&&l.slice(n-a,n-a+t.length)==t)return n}}return-1}function t0(e,t,r,n,o){let i=[];for(let s=0,a=0;s=r||u<=t?i.push(l):(cr&&i.push(l.slice(r-c,l.size,n)))}return i}function Zy(e,t=null){let r=e.domSelectionRange(),n=e.state.doc;if(!r.focusNode)return null;let o=e.docView.nearestDesc(r.focusNode),i=o&&o.size==0,s=e.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(s<0)return null;let a=n.resolve(s),l,c;if(Zh(r)){for(l=a;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&de.isSelectable(u)&&o.parent&&!(u.isInline&&fD(r.focusNode,r.focusOffset,o.dom))){let d=o.posBefore;c=new de(s==d?a:n.resolve(d))}}else{let u=e.docView.posFromDOM(r.anchorNode,r.anchorOffset,1);if(u<0)return null;l=n.resolve(u)}if(!c){let u=t=="pointer"||e.state.selection.head{(r.anchorNode!=n||r.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!kO(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function GD(e){let t=e.domSelection(),r=document.createRange(),n=e.cursorWrapper.dom,o=n.nodeName=="IMG";o?r.setEnd(n.parentNode,Er(n)+1):r.setEnd(n,0),r.collapse(!1),t.removeAllRanges(),t.addRange(r),!o&&!e.state.selection.visible&&Hr&&Gi<=11&&(n.disabled=!0,n.disabled=!1)}function xO(e,t){if(t instanceof de){let r=e.docView.descAt(t.from);r!=e.lastSelectedViewDesc&&(dS(e),r&&r.selectNode(),e.lastSelectedViewDesc=r)}else dS(e)}function dS(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Jy(e,t,r,n){return e.someProp("createSelectionBetween",o=>o(e,t,r))||ue.between(t,r,n)}function pS(e){return e.editable&&!e.hasFocus()?!1:SO(e)}function SO(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function WD(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),r=e.domSelectionRange();return la(t.node,t.offset,r.anchorNode,r.anchorOffset)}function r0(e,t){let{$anchor:r,$head:n}=e.selection,o=t>0?r.max(n):r.min(n),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&ke.findFrom(i,t)}function _i(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function fS(e,t,r){let n=e.state.selection;if(n instanceof ue)if(r.indexOf("s")>-1){let{$head:o}=n,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=e.state.doc.resolve(o.pos+i.nodeSize*(t<0?-1:1));return _i(e,new ue(n.$anchor,s))}else if(n.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=r0(e.state,t);return o&&o instanceof de?_i(e,o):!1}else if(!(Cn&&r.indexOf("m")>-1)){let o=n.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let a=t<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=e.docView.descAt(a))&&!s.contentDOM?de.isSelectable(i)?_i(e,new de(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):Fd?_i(e,new ue(e.state.doc.resolve(t<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(n instanceof de&&n.node.isInline)return _i(e,new ue(t>0?n.$to:n.$from));{let o=r0(e.state,t);return o?_i(e,o):!1}}}function $f(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Cu(e,t){let r=e.pmViewDesc;return r&&r.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function $a(e,t){return t<0?KD(e):YD(e)}function KD(e){let t=e.domSelectionRange(),r=t.focusNode,n=t.focusOffset;if(!r)return;let o,i,s=!1;for(ao&&r.nodeType==1&&n<$f(r)&&Cu(r.childNodes[n],-1)&&(s=!0);;)if(n>0){if(r.nodeType!=1)break;{let a=r.childNodes[n-1];if(Cu(a,-1))o=r,i=--n;else if(a.nodeType==3)r=a,n=r.nodeValue.length;else break}}else{if(wO(r))break;{let a=r.previousSibling;for(;a&&Cu(a,-1);)o=r.parentNode,i=Er(a),a=a.previousSibling;if(a)r=a,n=$f(r);else{if(r=r.parentNode,r==e.dom)break;n=0}}}s?n0(e,r,n):o&&n0(e,o,i)}function YD(e){let t=e.domSelectionRange(),r=t.focusNode,n=t.focusOffset;if(!r)return;let o=$f(r),i,s;for(;;)if(n{e.state==o&&oi(e)},50)}function hS(e,t){let r=e.state.doc.resolve(t);if(!(hr||yD)&&r.parent.inlineContent){let o=e.coordsAtPos(t);if(t>r.start()){let i=e.coordsAtPos(t-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function mS(e,t,r){let n=e.state.selection;if(n instanceof ue&&!n.empty||r.indexOf("s")>-1||Cn&&r.indexOf("m")>-1)return!1;let{$from:o,$to:i}=n;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let s=r0(e.state,t);if(s&&s instanceof de)return _i(e,s)}if(!o.parent.inlineContent){let s=t<0?o:i,a=n instanceof xr?ke.near(s,t):ke.findFrom(s,t);return a?_i(e,a):!1}return!1}function gS(e,t){if(!(e.state.selection instanceof ue))return!0;let{$head:r,$anchor:n,empty:o}=e.state.selection;if(!r.sameParent(n))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!r.textOffset&&(t<0?r.nodeBefore:r.nodeAfter);if(i&&!i.isText){let s=e.state.tr;return t<0?s.delete(r.pos-i.nodeSize,r.pos):s.delete(r.pos,r.pos+i.nodeSize),e.dispatch(s),!0}return!1}function yS(e,t,r){e.domObserver.stop(),t.contentEditable=r,e.domObserver.start()}function ZD(e){if(!Tr||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:r}=e.domSelectionRange();if(t&&t.nodeType==1&&r==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let n=t.firstChild;yS(e,n,"true"),setTimeout(()=>yS(e,n,"false"),20)}return!1}function JD(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function QD(e,t){let r=t.keyCode,n=JD(t);if(r==8||Cn&&r==72&&n=="c")return gS(e,-1)||$a(e,-1);if(r==46&&!t.shiftKey||Cn&&r==68&&n=="c")return gS(e,1)||$a(e,1);if(r==13||r==27)return!0;if(r==37||Cn&&r==66&&n=="c"){let o=r==37?hS(e,e.state.selection.from)=="ltr"?-1:1:-1;return fS(e,o,n)||$a(e,o)}else if(r==39||Cn&&r==70&&n=="c"){let o=r==39?hS(e,e.state.selection.from)=="ltr"?1:-1:1;return fS(e,o,n)||$a(e,o)}else{if(r==38||Cn&&r==80&&n=="c")return mS(e,-1,n)||$a(e,-1);if(r==40||Cn&&r==78&&n=="c")return ZD(e)||mS(e,1,n)||$a(e,1);if(n==(Cn?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function TO(e,t){e.someProp("transformCopied",f=>{t=f(t,e)});let r=[],{content:n,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&n.childCount==1&&n.firstChild.childCount==1;){o--,i--;let f=n.firstChild;r.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),n=f.content}let s=e.someProp("clipboardSerializer")||un.fromSchema(e.state.schema),a=_O(),l=a.createElement("div");l.appendChild(s.serializeFragment(n,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=RO[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let h=a.createElement(u[f]);for(;l.firstChild;)h.appendChild(l.firstChild);l.appendChild(h),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(r)}`);let p=e.someProp("clipboardTextSerializer",f=>f(t,e))||t.content.textBetween(0,t.content.size,`
-`);return{dom:l,text:f}}function e5(e,t,r,n,o){let i=o.parent.type.spec.code,s,a;if(!r&&!t)return null;let l=t&&(n||i||!r);if(l){if(e.someProp("transformPastedText",f=>{t=f(t,i||n,e)}),i)return t?new W(N.from(e.state.schema.text(t.replace(/\r\n?/g,`
-`))),0,0):W.empty;let d=e.someProp("clipboardTextParser",f=>f(t,o,n,e));if(d)a=d;else{let f=o.marks(),{schema:p}=e.state,h=cn.fromSchema(p);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(m=>{let b=s.appendChild(document.createElement("p"));m&&b.appendChild(h.serializeNode(p.text(m,f)))})}}else e.someProp("transformPastedHTML",d=>{r=d(r,e)}),s=wP(r),Pd&&SP(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=(e.someProp("clipboardParser")||e.someProp("domParser")||Rv.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!kP.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=EP(qx(a,+u[1],+u[2]),u[4]);else if(a=W.maxOpen(xP(a.content,o),!0),a.openStart||a.openEnd){let d=0,f=0;for(let p=a.content.firstChild;d{a=d(a,e)}),a}const kP=/^(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 xP(e,t){if(e.childCount<2)return e;for(let r=t.depth;r>=0;r--){let o=t.node(r).contentMatchAt(t.index(r)),i,s=[];if(e.forEach(a=>{if(!s)return;let l=o.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&i.length&&r5(l,i,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=n5(s[s.length-1],i.length));let u=t5(a,l);s.push(u),o=o.matchType(u.type),i=l}}),s)return N.from(s)}return e}function t5(e,t,r=0){for(let n=t.length-1;n>=r;n--)e=t[n].create(null,N.from(e));return e}function r5(e,t,r,n,o){if(o1&&(i=0),o=r&&(a=t<0?s.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(N.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function qx(e,t,r){return t]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let r=i5().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(e),o;if((o=n&&o5[n[1].toLowerCase()])&&(e=o.map(i=>"<"+i+">").join("")+e+o.map(i=>""+i+">").reverse().join("")),r.innerHTML=e,o)for(let i=0;i=0;a-=2){let l=r.nodes[n[a]];if(!l||l.hasRequiredAttrs())break;o=N.from(l.create(n[a+1],o)),i++,s++}return new W(o,i,s)}const Mr={},Tr={},CP={touchstart:!0,touchmove:!0};class MP{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function TP(e){for(let t in Mr){let r=Mr[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=n=>{_P(e,n)&&!Fv(e,n)&&(e.editable||!(n.type in Tr))&&r(e,n)},CP[t]?{passive:!0}:void 0)}Cr&&e.dom.addEventListener("input",()=>null),U1(e)}function Di(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function OP(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function U1(e){e.someProp("handleDOMEvents",t=>{for(let r in t)e.input.eventHandlers[r]||e.dom.addEventListener(r,e.input.eventHandlers[r]=n=>Fv(e,n))})}function Fv(e,t){return e.someProp("handleDOMEvents",r=>{let n=r[t.type];return n?n(e,t)||t.defaultPrevented:!1})}function _P(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let r=t.target;r!=e.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(t))return!1;return!0}function AP(e,t){!Fv(e,t)&&Mr[t.type]&&(e.editable||!(t.type in Tr))&&Mr[t.type](e,t)}Tr.keydown=(e,t)=>{let r=t;if(e.input.shiftKey=r.keyCode==16||r.shiftKey,!a5(e,r)&&(e.input.lastKeyCode=r.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Jn&&hr&&r.keyCode==13)))if(r.keyCode!=229&&e.domObserver.forceFlush(),Nl&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let n=Date.now();e.input.lastIOSEnter=n,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==n&&(e.someProp("handleKeyDown",o=>o(e,Hs(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",n=>n(e,r))||bP(e,r)?r.preventDefault():Di(e,"key")};Tr.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};Tr.keypress=(e,t)=>{let r=t;if(a5(e,r)||!r.charCode||r.ctrlKey&&!r.altKey||En&&r.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,r))){r.preventDefault();return}let n=e.state.selection;if(!(n instanceof ue)||!n.$from.sameParent(n.$to)){let o=String.fromCharCode(r.charCode);!/[\r\n]/.test(o)&&!e.someProp("handleTextInput",i=>i(e,n.$from.pos,n.$to.pos,o))&&e.dispatch(e.state.tr.insertText(o).scrollIntoView()),r.preventDefault()}};function Fh(e){return{left:e.clientX,top:e.clientY}}function RP(e,t){let r=t.x-e.clientX,n=t.y-e.clientY;return r*r+n*n<100}function Vv(e,t,r,n,o){if(n==-1)return!1;let i=e.state.doc.resolve(n);for(let s=i.depth+1;s>0;s--)if(e.someProp(t,a=>s>i.depth?a(e,r,i.nodeAfter,i.before(s),o,!0):a(e,r,i.node(s),i.before(s),o,!1)))return!0;return!1}function ml(e,t,r){e.focused||e.focus();let n=e.state.tr.setSelection(t);r=="pointer"&&n.setMeta("pointer",!0),e.dispatch(n)}function NP(e,t){if(t==-1)return!1;let r=e.state.doc.resolve(t),n=r.nodeAfter;return n&&n.isAtom&&de.isSelectable(n)?(ml(e,new de(r),"pointer"),!0):!1}function PP(e,t){if(t==-1)return!1;let r=e.state.selection,n,o;r instanceof de&&(n=r.node);let i=e.state.doc.resolve(t);for(let s=i.depth+1;s>0;s--){let a=s>i.depth?i.nodeAfter:i.node(s);if(de.isSelectable(a)){n&&r.$from.depth>0&&s>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?o=i.before(r.$from.depth):o=i.before(s);break}}return o!=null?(ml(e,de.create(e.state.doc,o),"pointer"),!0):!1}function zP(e,t,r,n,o){return Vv(e,"handleClickOn",t,r,n)||e.someProp("handleClick",i=>i(e,t,n))||(o?PP(e,r):NP(e,r))}function LP(e,t,r,n){return Vv(e,"handleDoubleClickOn",t,r,n)||e.someProp("handleDoubleClick",o=>o(e,t,n))}function IP(e,t,r,n){return Vv(e,"handleTripleClickOn",t,r,n)||e.someProp("handleTripleClick",o=>o(e,t,n))||DP(e,r,n)}function DP(e,t,r){if(r.button!=0)return!1;let n=e.state.doc;if(t==-1)return n.inlineContent?(ml(e,ue.create(n,0,n.content.size),"pointer"),!0):!1;let o=n.resolve(t);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),a=o.before(i);if(s.inlineContent)ml(e,ue.create(n,a+1,a+1+s.content.size),"pointer");else if(de.isSelectable(s))ml(e,de.create(n,a),"pointer");else continue;return!0}}function jv(e){return Tp(e)}const s5=En?"metaKey":"ctrlKey";Mr.mousedown=(e,t)=>{let r=t;e.input.shiftKey=r.shiftKey;let n=jv(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&RP(r,e.input.lastClick)&&!r[s5]&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:o,x:r.clientX,y:r.clientY,type:i};let s=e.posAtCoords(Fh(r));s&&(i=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new $P(e,s,r,!!n)):(i=="doubleClick"?LP:IP)(e,s.pos,s.inside,r)?r.preventDefault():Di(e,"pointer"))};class $P{constructor(t,r,n,o){this.view=t,this.pos=r,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[s5],this.allowDefault=n.shiftKey;let i,s;if(r.inside>-1)i=t.state.doc.nodeAt(r.inside),s=r.inside;else{let u=t.state.doc.resolve(r.pos);i=u.parent,s=u.depth?u.before():0}const a=o?null:n.target,l=a?t.docView.nearestDesc(a,!0):null;this.target=l?l.dom:null;let{selection:c}=t.state;(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof de&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&io&&!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()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Di(t,"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(()=>ei(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let r=this.pos;this.view.state.doc!=this.startDoc&&(r=this.view.posAtCoords(Fh(t))),this.updateAllowDefault(t),this.allowDefault||!r?Di(this.view,"pointer"):zP(this.view,r.pos,r.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Cr&&this.mightDrag&&!this.mightDrag.node.isAtom||hr&&!this.view.state.selection.visible&&Math.min(Math.abs(r.pos-this.view.state.selection.from),Math.abs(r.pos-this.view.state.selection.to))<=2)?(ml(this.view,xe.near(this.view.state.doc.resolve(r.pos)),"pointer"),t.preventDefault()):Di(this.view,"pointer")}move(t){this.updateAllowDefault(t),Di(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}Mr.touchstart=e=>{e.input.lastTouch=Date.now(),jv(e),Di(e,"pointer")};Mr.touchmove=e=>{e.input.lastTouch=Date.now(),Di(e,"pointer")};Mr.contextmenu=e=>jv(e);function a5(e,t){return e.composing?!0:Cr&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const HP=Jn?5e3:-1;Tr.compositionstart=Tr.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,r=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))e.markCursor=e.state.storedMarks||r.marks(),Tp(e,!0),e.markCursor=null;else if(Tp(e),io&&t.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let n=e.domSelectionRange();for(let o=n.focusNode,i=n.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){e.domSelection().collapse(s,s.nodeValue.length);break}else o=s,i=-1}}e.input.composing=!0}l5(e,HP)};Tr.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,l5(e,20))};function l5(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Tp(e),t))}function c5(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=BP());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function BP(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function Tp(e,t=!1){if(!(Jn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),c5(e),t||e.docView&&e.docView.dirty){let r=Hv(e);return r&&!r.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(r)):e.updateState(e.state),!0}return!1}}function FP(e,t){if(!e.dom.parentNode)return;let r=e.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(t),r.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),n.removeAllRanges(),n.addRange(o),setTimeout(()=>{r.parentNode&&r.parentNode.removeChild(r),e.focus()},50)}const Pl=$r&&Vi<15||Nl&&$N<604;Mr.copy=Tr.cut=(e,t)=>{let r=t,n=e.state.selection,o=r.type=="cut";if(n.empty)return;let i=Pl?null:r.clipboardData,s=n.content(),{dom:a,text:l}=ZE(e,s);i?(r.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):FP(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function VP(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function jP(e,t){if(!e.dom.parentNode)return;let r=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,n=e.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let o=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),n.parentNode&&n.parentNode.removeChild(n),r?$u(e,n.value,null,o,t):$u(e,n.textContent,n.innerHTML,o,t)},50)}function $u(e,t,r,n,o){let i=e5(e,t,r,n,e.state.selection.$from);if(e.someProp("handlePaste",l=>l(e,o,i||W.empty)))return!0;if(!i)return!1;let s=VP(i),a=s?e.state.tr.replaceSelectionWith(s,n):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Tr.paste=(e,t)=>{let r=t;if(e.composing&&!Jn)return;let n=Pl?null:r.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;n&&$u(e,n.getData("text/plain"),n.getData("text/html"),o,r)?r.preventDefault():jP(e,r)};class UP{constructor(t,r){this.slice=t,this.move=r}}const u5=En?"altKey":"ctrlKey";Mr.dragstart=(e,t)=>{let r=t,n=e.input.mouseDown;if(n&&n.done(),!r.dataTransfer)return;let o=e.state.selection,i=o.empty?null:e.posAtCoords(Fh(r));if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof de?o.to-1:o.to))){if(n&&n.mightDrag)e.dispatch(e.state.tr.setSelection(de.create(e.state.doc,n.mightDrag.pos)));else if(r.target&&r.target.nodeType==1){let c=e.docView.nearestDesc(r.target,!0);c&&c.node.type.spec.draggable&&c!=e.docView&&e.dispatch(e.state.tr.setSelection(de.create(e.state.doc,c.posBefore)))}}let s=e.state.selection.content(),{dom:a,text:l}=ZE(e,s);r.dataTransfer.clearData(),r.dataTransfer.setData(Pl?"Text":"text/html",a.innerHTML),r.dataTransfer.effectAllowed="copyMove",Pl||r.dataTransfer.setData("text/plain",l),e.dragging=new UP(s,!r[u5])};Mr.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};Tr.dragover=Tr.dragenter=(e,t)=>t.preventDefault();Tr.drop=(e,t)=>{let r=t,n=e.dragging;if(e.dragging=null,!r.dataTransfer)return;let o=e.posAtCoords(Fh(r));if(!o)return;let i=e.state.doc.resolve(o.pos),s=n&&n.slice;s?e.someProp("transformPasted",h=>{s=h(s,e)}):s=e5(e,r.dataTransfer.getData(Pl?"Text":"text/plain"),Pl?null:r.dataTransfer.getData("text/html"),!1,i);let a=!!(n&&!r[u5]);if(e.someProp("handleDrop",h=>h(e,r,s||W.empty,a))){r.preventDefault();return}if(!s)return;r.preventDefault();let l=s?nR(e.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let c=e.state.tr;a&&c.deleteSelection();let u=c.mapping.map(l),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(f))return;let p=c.doc.resolve(u);if(d&&de.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new de(p));else{let h=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,b,v,g)=>h=g),c.setSelection(Bv(e,p,c.doc.resolve(h)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))};Mr.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ei(e)},20))};Mr.blur=(e,t)=>{let r=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),r.relatedTarget&&e.dom.contains(r.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};Mr.beforeinput=(e,t)=>{if(hr&&Jn&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:n}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=n||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,Hs(8,"Backspace")))))return;let{$cursor:o}=e.state.selection;o&&o.pos>0&&e.dispatch(e.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let e in Tr)Mr[e]=Tr[e];function Hu(e,t){if(e==t)return!0;for(let r in e)if(e[r]!==t[r])return!1;for(let r in t)if(!(r in e))return!1;return!0}class Op{constructor(t,r){this.toDOM=t,this.spec=r||Js,this.side=this.spec.side||0}map(t,r,n,o){let{pos:i,deleted:s}=t.mapResult(r.from+o,this.side<0?-1:1);return s?null:new Qe(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof Op&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Hu(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Ui{constructor(t,r){this.attrs=t,this.spec=r||Js}map(t,r,n,o){let i=t.map(r.from+o,this.spec.inclusiveStart?-1:1)-n,s=t.map(r.to+o,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new Qe(i,s,this)}valid(t,r){return r.from=t&&(!i||i(a.spec))&&n.push(a.copy(a.from+o,a.to+o))}for(let s=0;st){let a=this.children[s]+1;this.children[s+2].findInner(t-a,r-a,n,o+a,i)}}map(t,r,n){return this==dr||t.maps.length==0?this:this.mapInner(t,r,0,0,n||Js)}mapInner(t,r,n,o,i){let s;for(let a=0;a{let c=l+n,u;if(u=f5(r,a,c)){for(o||(o=this.children.slice());ia&&d.to=t){this.children[a]==t&&(n=this.children[a+2]);break}let i=t+1,s=i+r.content.size;for(let a=0;ai&&l.type instanceof Ui){let c=Math.max(i,l.from)-i,u=Math.min(s,l.to)-i;co.map(t,r,Js));return Ni.from(n)}forChild(t,r){if(r.isLeaf)return Me.empty;let n=[];for(let o=0;or instanceof Me)?t:t.reduce((r,n)=>r.concat(n instanceof Me?n:n.members),[]))}}}function WP(e,t,r,n,o,i,s){let a=e.slice();for(let c=0,u=i;c{let b=m-h-(p-f);for(let v=0;vg+u-d)continue;let y=a[v]+u-d;p>=y?a[v+1]=f<=y?-2:-1:h>=o&&b&&(a[v]+=b,a[v+1]+=b)}d+=b}),u=r.maps[c].map(u,-1)}let l=!1;for(let c=0;c=n.content.size){l=!0;continue}let f=r.map(e[c+1]+i,-1),p=f-o,{index:h,offset:m}=n.content.findIndex(d),b=n.maybeChild(h);if(b&&m==d&&m+b.nodeSize==p){let v=a[c+2].mapInner(r,b,u+1,e[c]+i+1,s);v!=dr?(a[c]=d,a[c+1]=p,a[c+2]=v):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=KP(a,e,t,r,o,i,s),u=_p(c,n,0,s);t=u.local;for(let d=0;dr&&s.to{let c=f5(e,a,l+r);if(c){i=!0;let u=_p(c,a,r+l+1,n);u!=dr&&o.push(l,l+a.nodeSize,u)}});let s=d5(i?p5(e):e,-r).sort(Qs);for(let a=0;a0;)t++;e.splice(t,0,r)}function Sg(e){let t=[];return e.someProp("decorations",r=>{let n=r(e.state);n&&n!=dr&&t.push(n)}),e.cursorWrapper&&t.push(Me.create(e.state.doc,[e.cursorWrapper.deco])),Ni.from(t)}const qP={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},GP=$r&&Vi<=11;class YP{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class XP{constructor(t,r){this.view=t,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new YP,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let o=0;oo.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),GP&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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,qP)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let r=0;rthis.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(Fx(this.view)){if(this.suppressingSelectionUpdates)return ei(this.view);if($r&&Vi<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&ia(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let r=new Set,n;for(let i=t.focusNode;i;i=Du(i))r.add(i);for(let i=t.anchorNode;i;i=Du(i))if(r.has(i)){n=i;break}let o=n&&this.view.docView.nearestDesc(n);if(o&&o.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]);let n=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Fx(t)&&!this.ignoreSelectionChange(n),i=-1,s=-1,a=!1,l=[];if(t.editable)for(let u=0;u1){let u=l.filter(d=>d.nodeName=="BR");if(u.length==2){let d=u[0],f=u[1];d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}}let c=null;i<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)-1||o)&&(i>-1&&(t.docView.markDirty(i,s),JP(t)),this.handleDOMChange(i,s,a,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||ei(t),this.currentSelection.set(n))}registerMutation(t,r){if(r.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(n==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!n||n.ignoreMutation(t))return null;if(t.type=="childList"){for(let u=0;uo;b--){let v=n.childNodes[b-1],g=v.pmViewDesc;if(v.nodeName=="BR"&&!g){i=b;break}if(!g||g.size)break}let d=e.state.doc,f=e.someProp("domParser")||Rv.fromSchema(e.state.schema),p=d.resolve(s),h=null,m=f.parse(n,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:i,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:e6,context:p});if(c&&c[0].pos!=null){let b=c[0].pos,v=c[1]&&c[1].pos;v==null&&(v=b),h={anchor:b+s,head:v+s}}return{doc:m,sel:h,from:s,to:a}}function e6(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName=="BR"&&e.parentNode){if(Cr&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||Cr&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const t6=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function r6(e,t,r,n,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let C=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,T=Hv(e,C);if(T&&!e.state.selection.eq(T)){if(hr&&Jn&&e.input.lastKeyCode===13&&Date.now()-100z(e,Hs(13,"Enter"))))return;let R=e.state.tr.setSelection(T);C=="pointer"?R.setMeta("pointer",!0):C=="key"&&R.scrollIntoView(),i&&R.setMeta("composition",i),e.dispatch(R)}return}let s=e.state.doc.resolve(t),a=s.sharedDepth(r);t=s.before(a+1),r=e.state.doc.resolve(r).after(a+1);let l=e.state.selection,c=ZP(e,t,r),u=e.state.doc,d=u.slice(c.from,c.to),f,p;e.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Jn)&&o.some(C=>C.nodeType==1&&!t6.test(C.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",C=>C(e,Hs(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!h)if(n&&l instanceof ue&&!l.empty&&l.$head.sameParent(l.$anchor)&&!e.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let C=Qx(e,e.state.doc,c.sel);if(C&&!C.eq(e.state.selection)){let T=e.state.tr.setSelection(C);i&&T.setMeta("composition",i),e.dispatch(T)}}return}if(hr&&e.cursorWrapper&&c.sel&&c.sel.anchor==e.cursorWrapper.deco.from&&c.sel.head==c.sel.anchor){let C=h.endB-h.start;c.sel={anchor:c.sel.anchor+C,head:c.sel.anchor+C}}e.input.domChangeCount++,e.state.selection.frome.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=c.from?h.start=e.state.selection.from:h.endA=e.state.selection.to-2&&e.state.selection.to<=c.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),$r&&Vi<=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)==" "&&(h.start--,h.endA--,h.endB--);let m=c.doc.resolveNoCache(h.start-c.from),b=c.doc.resolveNoCache(h.endB-c.from),v=u.resolve(h.start),g=m.sameParent(b)&&m.parent.inlineContent&&v.end()>=h.endA,y;if((Nl&&e.input.lastIOSEnter>Date.now()-225&&(!g||o.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!g&&m.posC(e,Hs(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&o6(u,h.start,h.endA,m,b)&&e.someProp("handleKeyDown",C=>C(e,Hs(8,"Backspace")))){Jn&&hr&&e.domObserver.suppressSelectionUpdates();return}hr&&Jn&&h.endB==h.start&&(e.input.lastAndroidDelete=Date.now()),Jn&&!g&&m.start()!=b.start()&&b.parentOffset==0&&m.depth==b.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,b=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{e.someProp("handleKeyDown",function(C){return C(e,Hs(13,"Enter"))})},20));let k=h.start,x=h.endA,w,E,M;if(g){if(m.pos==b.pos)$r&&Vi<=11&&m.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>ei(e),20)),w=e.state.tr.delete(k,x),E=u.resolve(h.start).marksAcross(u.resolve(h.endA));else if(h.endA==h.endB&&(M=n6(m.parent.content.cut(m.parentOffset,b.parentOffset),v.parent.content.cut(v.parentOffset,h.endA-v.start()))))w=e.state.tr,M.type=="add"?w.addMark(k,x,M.mark):w.removeMark(k,x,M.mark);else if(m.parent.child(m.index()).isText&&m.index()==b.index()-(b.textOffset?0:1)){let C=m.parent.textBetween(m.parentOffset,b.parentOffset);if(e.someProp("handleTextInput",T=>T(e,k,x,C)))return;w=e.state.tr.insertText(C,k,x)}}if(w||(w=e.state.tr.replace(k,x,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let C=Qx(e,w.doc,c.sel);C&&!(hr&&Jn&&e.composing&&C.empty&&(h.start!=h.endB||e.input.lastAndroidDeletet.content.size?null:Bv(e,t.resolve(r.anchor),t.resolve(r.head))}function n6(e,t){let r=e.firstChild.marks,n=t.firstChild.marks,o=r,i=n,s,a,l;for(let u=0;uu.mark(a.addToSet(u.marks));else if(o.length==0&&i.length==1)a=i[0],s="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;ur||Eg(s,!0,!1)0&&(t||e.indexAfter(n)==e.node(n).childCount);)n--,o++,t=!1;if(r){let i=e.node(n).maybeChild(e.indexAfter(n));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function i6(e,t,r,n,o){let i=e.findDiffStart(t,r);if(i==null)return null;let{a:s,b:a}=e.findDiffEnd(t,r+e.size,r+t.size);if(o=="end"){let l=Math.max(0,i-Math.min(s,a));n-=s+l-i}if(s