1||0==l||g.content.size)&&(d=m,u.push(qk(g.mark(h.allowedMarks(g.marks)),1==c?l:0,c==a.childCount?p:-1)))}let f=c==a.childCount;f||(p=-1),this.placed=oh(this.placed,e,L.from(u)),this.frontier[e].match=d,f&&p<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=a;g1&&r==this.$to.end(--i);)++r;return r}findCloseLevel(t){e:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:i,type:r}=this.frontier[e],o=e=0;a--){let{match:l,type:c}=this.frontier[a],u=jC(t,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:e,fit:s,move:o?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=oh(this.placed,e.depth,e.fit)),t=e.move;for(let i=e.depth+1;i<=t.depth;i++){let r=t.node(i),o=r.type.contentMatch.fillBefore(r.content,!0,t.index(i));this.openFrontierNode(r.type,r.attrs,o)}return t}openFrontierNode(t,e=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=oh(this.placed,this.depth,L.from(t.create(e,i))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(L.empty,!0);e.childCount&&(this.placed=oh(this.placed,this.frontier.length,e))}}function rh(n,t,e){return 0==t?n.cutByIndex(e,n.childCount):n.replaceChild(0,n.firstChild.copy(rh(n.firstChild.content,t-1,e)))}function oh(n,t,e){return 0==t?n.append(e):n.replaceChild(n.childCount-1,n.lastChild.copy(oh(n.lastChild.content,t-1,e)))}function UC(n,t){for(let e=0;e1&&(i=i.replaceChild(0,qk(i.firstChild,t-1,1==i.childCount?e-1:0))),t>0&&(i=n.type.contentMatch.fillBefore(i).append(i),e<=0&&(i=i.append(n.type.contentMatch.matchFragment(i).fillBefore(L.empty,!0)))),n.copy(i)}function jC(n,t,e,i,r){let o=n.node(t),s=r?n.indexAfter(t):n.index(t);if(s==o.childCount&&!e.compatibleContent(o.type))return null;let a=i.fillBefore(o.content,!0,s);return a&&!function q6(n,t,e){for(let i=e;ii){let o=r.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(L.empty,!0))}return n}function Zk(n,t){let e=[];for(let r=Math.min(n.depth,t.depth);r>=0;r--){let o=n.start(r);if(ot.pos+(t.depth-r)||n.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==n.depth&&r==t.depth&&n.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&e.push(r)}return e}class Nc extends Jn{constructor(t,e,i){super(),this.pos=t,this.attr=e,this.value=i}apply(t){let e=t.nodeAt(this.pos);if(!e)return ln.fail("No node at attribute step's position");let i=Object.create(null);for(let o in e.attrs)i[o]=e.attrs[o];i[this.attr]=this.value;let r=e.type.create(i,null,e.marks);return ln.fromReplace(t,this.pos,this.pos+1,new G(L.from(r),0,e.isLeaf?0:1))}getMap(){return cr.empty}invert(t){return new Nc(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Nc(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Nc(e.pos,e.attr,e.value)}}Jn.jsonID("attr",Nc);let Lc=class extends Error{};Lc=function n(t){let e=Error.call(this,t);return e.__proto__=n.prototype,e},(Lc.prototype=Object.create(Error.prototype)).constructor=Lc,Lc.prototype.name="TransformError";class zC{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Pc}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Lc(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,i=G.empty){let r=QC(this.doc,t,e,i);return r&&this.step(r),this}replaceWith(t,e,i){return this.replace(t,e,new G(L.from(i),0,0))}delete(t,e){return this.replace(t,e,G.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,i){return function Z6(n,t,e,i){if(!i.size)return n.deleteRange(t,e);let r=n.doc.resolve(t),o=n.doc.resolve(e);if($k(r,o,i))return n.step(new Kn(t,e,i));let s=Zk(r,n.doc.resolve(e));0==s[s.length-1]&&s.pop();let a=-(r.depth+1);s.unshift(a);for(let h=r.depth,p=r.pos-1;h>0;h--,p--){let f=r.node(h).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;s.indexOf(h)>-1?a=h:r.before(h)==p&&s.splice(1,0,-h)}let l=s.indexOf(a),c=[],u=i.openStart;for(let h=i.content,p=0;;p++){let f=h.firstChild;if(c.push(f),p==i.openStart)break;h=f.content}for(let h=u-1;h>=0;h--){let p=c[h].type,f=X6(p);if(f&&r.node(l).type!=p)u=h;else if(f||!p.isTextblock)break}for(let h=i.openStart;h>=0;h--){let p=(h+u+1)%(i.openStart+1),f=c[p];if(f)for(let g=0;g=0&&(n.replace(t,e,i),!(n.steps.length>d));h--){let p=s[h];p<0||(t=r.before(p),e=o.after(p))}}(this,t,e,i),this}replaceRangeWith(t,e,i){return function eq(n,t,e,i){if(!i.isInline&&t==e&&n.doc.resolve(t).parent.content.size){let r=function K6(n,t,e){let i=n.resolve(t);if(i.parent.canReplaceWith(i.index(),i.index(),e))return t;if(0==i.parentOffset)for(let r=i.depth-1;r>=0;r--){let o=i.index(r);if(i.node(r).canReplaceWith(o,o,e))return i.before(r+1);if(o>0)return null}if(i.parentOffset==i.parent.content.size)for(let r=i.depth-1;r>=0;r--){let o=i.indexAfter(r);if(i.node(r).canReplaceWith(o,o,e))return i.after(r+1);if(o0&&(l||i.node(a-1).canReplace(i.index(a-1),r.indexAfter(a-1))))return n.delete(i.before(a),r.after(a))}for(let s=1;s<=i.depth&&s<=r.depth;s++)if(t-i.start(s)==i.depth-s&&e>i.end(s)&&r.end(s)-e!=r.depth-s)return n.delete(i.before(s),e);n.delete(t,e)}(this,t,e),this}lift(t,e){return function U6(n,t,e){let{$from:i,$to:r,depth:o}=t,s=i.before(o+1),a=r.after(o+1),l=s,c=a,u=L.empty,d=0;for(let f=o,g=!1;f>e;f--)g||i.index(f)>0?(g=!0,u=L.from(i.node(f).copy(u)),d++):l--;let h=L.empty,p=0;for(let f=o,g=!1;f>e;f--)g||r.after(f+1)=0;s--){if(i.size){let a=e[s].type.contentMatch.matchFragment(i);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=L.from(e[s].type.create(e[s].attrs,i))}let r=t.start,o=t.end;n.step(new Mn(r,o,r,o,new G(i,0,0),e.length,!0))}(this,t,e),this}setBlockType(t,e=t,i,r=null){return function V6(n,t,e,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(t,e,(s,a)=>{if(s.isTextblock&&!s.hasMarkup(i,r)&&function G6(n,t,e){let i=n.resolve(t),r=i.index();return i.parent.canReplaceWith(r,r+1,e)}(n.doc,n.mapping.slice(o).map(a),i)){n.clearIncompatible(n.mapping.slice(o).map(a,1),i);let l=n.mapping.slice(o),c=l.map(a,1),u=l.map(a+s.nodeSize,1);return n.step(new Mn(c,u,c+1,u-1,new G(L.from(i.create(r,null,s.marks)),0,0),1,!0)),!1}})}(this,t,e,i,r),this}setNodeMarkup(t,e,i=null,r=[]){return function Y6(n,t,e,i,r){let o=n.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");e||(e=o.type);let s=e.create(i,null,r||o.marks);if(o.isLeaf)return n.replaceWith(t,t+o.nodeSize,s);if(!e.validContent(o.content))throw new RangeError("Invalid content for node type "+e.name);n.step(new Mn(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new G(L.from(s),0,0),1,!0))}(this,t,e,i,r),this}setNodeAttribute(t,e,i){return this.step(new Nc(t,e,i)),this}addNodeMark(t,e){return this.step(new Qs(t,e)),this}removeNodeMark(t,e){if(!(e instanceof Tt)){let i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(i.marks)))return this}return this.step(new Fc(t,e)),this}split(t,e=1,i){return function W6(n,t,e=1,i){let r=n.doc.resolve(t),o=L.empty,s=L.empty;for(let a=r.depth,l=r.depth-e,c=e-1;a>l;a--,c--){o=L.from(r.node(a).copy(o));let u=i&&i[c];s=L.from(u?u.type.create(u.attrs,s):r.node(a).copy(s))}n.step(new Kn(t,t,new G(o.append(s),e,e),!0))}(this,t,e,i),this}addMark(t,e,i){return function R6(n,t,e,i){let s,a,r=[],o=[];n.doc.nodesBetween(t,e,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!i.isInSet(d)&&u.type.allowsMarkType(i.type)){let h=Math.max(c,t),p=Math.min(c+l.nodeSize,e),f=i.addToSet(d);for(let g=0;gn.step(l)),o.forEach(l=>n.step(l))}(this,t,e,i),this}removeMark(t,e,i){return function N6(n,t,e,i){let r=[],o=0;n.doc.nodesBetween(t,e,(s,a)=>{if(!s.isInline)return;o++;let l=null;if(i instanceof nm){let u,c=s.marks;for(;u=i.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else i?i.isInSet(s.marks)&&(l=[i]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,e);for(let u=0;un.step(new uo(s.from,s.to,s.style)))}(this,t,e,i),this}clearIncompatible(t,e,i){return function L6(n,t,e,i=e.contentMatch){let r=n.doc.nodeAt(t),o=[],s=t+1;for(let a=0;a=0;a--)n.step(o[a])}(this,t,e,i),this}}const HC=Object.create(null);class _e{constructor(t,e,i){this.$anchor=t,this.$head=e,this.ranges=i||[new eP(t.min(e),t.max(e))]}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 e=0;e=0;o--){let s=e<0?Qc(t.node(0),t.node(o),t.before(o+1),t.index(o),e,i):Qc(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,i);if(s)return s}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new zi(t.node(0))}static atStart(t){return Qc(t,t,0,0,1)||new zi(t)}static atEnd(t){return Qc(t,t,t.content.size,t.childCount,-1)||new zi(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=HC[e.type];if(!i)throw new RangeError(`No selection type ${e.type} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in HC)throw new RangeError("Duplicate use of selection JSON ID "+t);return HC[t]=e,e.prototype.jsonID=t,e}getBookmark(){return Ee.between(this.$anchor,this.$head).getBookmark()}}_e.prototype.visible=!0;class eP{constructor(t,e){this.$from=t,this.$to=e}}let tP=!1;function nP(n){!tP&&!n.parent.inlineContent&&(tP=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class Ee extends _e{constructor(t,e=t){nP(t),nP(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let i=t.resolve(e.map(this.head));if(!i.parent.inlineContent)return _e.near(i);let r=t.resolve(e.map(this.anchor));return new Ee(r.parent.inlineContent?r:i,i)}replace(t,e=G.empty){if(super.replace(t,e),e==G.empty){let i=this.$from.marksAcross(this.$to);i&&t.ensureMarks(i)}}eq(t){return t instanceof Ee&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new am(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ee(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,i=e){let r=t.resolve(e);return new this(r,i==e?r:t.resolve(i))}static between(t,e,i){let r=t.pos-e.pos;if((!i||r)&&(i=r>=0?1:-1),!e.parent.inlineContent){let o=_e.findFrom(e,i,!0)||_e.findFrom(e,-i,!0);if(!o)return _e.near(e,i);e=o.$head}return t.parent.inlineContent||(0==r||(t=(_e.findFrom(t,-i,!0)||_e.findFrom(t,i,!0)).$anchor).posnew zi(n)};function Qc(n,t,e,i,r,o=!1){if(t.inlineContent)return Ee.create(n,e);for(let s=i-(r>0?0:1);r>0?s=0;s+=r){let a=t.child(s);if(a.isAtom){if(!o&&ce.isSelectable(a))return ce.create(n,e-(r<0?a.nodeSize:0))}else{let l=Qc(n,a,e+r,r<0?a.childCount:0,r,o);if(l)return l}e+=a.nodeSize*r}return null}function iP(n,t,e){let i=n.steps.length-1;if(i{null==s&&(s=u)}),n.setSelection(_e.near(n.doc.resolve(s),e)))}class iq extends zC{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|=2,this}ensureMarks(t){return Tt.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(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let i=this.selection;return e&&(t=t.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||Tt.none))),i.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,i){let r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();{if(null==i&&(i=e),i=i??e,!t)return this.deleteRange(e,i);let o=this.storedMarks;if(!o){let s=this.doc.resolve(e);o=i==e?s.marks():s.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(e,i,r.text(t,o)),this.selection.empty||this.setSelection(_e.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function sP(n,t){return t&&n?n.bind(t):n}class sh{constructor(t,e,i){this.name=t,this.init=sP(e.init,i),this.apply=sP(e.apply,i)}}const rq=[new sh("doc",{init:n=>n.doc||n.schema.topNodeType.createAndFill(),apply:n=>n.doc}),new sh("selection",{init:(n,t)=>n.selection||_e.atStart(t.doc),apply:n=>n.selection}),new sh("storedMarks",{init:n=>n.storedMarks||null,apply:(n,t,e,i)=>i.selection.$cursor?n.storedMarks:null}),new sh("scrollToSelection",{init:()=>0,apply:(n,t)=>n.scrolledIntoView?t+1:t})];class GC{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=rq.slice(),e&&e.forEach(i=>{if(this.pluginsByKey[i.key])throw new RangeError("Adding different instances of a keyed plugin ("+i.key+")");this.plugins.push(i),this.pluginsByKey[i.key]=i,i.spec.state&&this.fields.push(new sh(i.key,i.spec.state,i))})}}class Uc{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,e=-1){for(let i=0;ii.toJSON())),t&&"object"==typeof t)for(let i in t){if("doc"==i||"selection"==i)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[i],o=r.spec.state;o&&o.toJSON&&(e[i]=o.toJSON.call(r,this[r.key]))}return e}static fromJSON(t,e,i){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new GC(t.schema,t.plugins),o=new Uc(r);return r.fields.forEach(s=>{if("doc"==s.name)o.doc=lo.fromJSON(t.schema,e.doc);else if("selection"==s.name)o.selection=_e.fromJSON(o.doc,e.selection);else if("storedMarks"==s.name)e.storedMarks&&(o.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(i)for(let a in i){let l=i[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(e,a))return void(o[s.name]=c.fromJSON.call(l,t,e[a],o))}o[s.name]=s.init(t,o)}}),o}}function aP(n,t,e){for(let i in n){let r=n[i];r instanceof Function?r=r.bind(t):"handleDOMEvents"==i&&(r=aP(r,t,{})),e[i]=r}return e}class it{constructor(t){this.spec=t,this.props={},t.props&&aP(t.props,this,this.props),this.key=t.key?t.key.key:lP("plugin")}getState(t){return t[this.key]}}const YC=Object.create(null);function lP(n){return n in YC?n+"$"+ ++YC[n]:(YC[n]=0,n+"$")}class _t{constructor(t="key"){this.key=lP(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}function ur(n){if(null==n)return window;if("[object Window]"!==n.toString()){var t=n.ownerDocument;return t&&t.defaultView||window}return n}function Za(n){return n instanceof ur(n).Element||n instanceof Element}function dr(n){return n instanceof ur(n).HTMLElement||n instanceof HTMLElement}function WC(n){return!(typeof ShadowRoot>"u")&&(n instanceof ur(n).ShadowRoot||n instanceof ShadowRoot)}var el=Math.max,cm=Math.min,jc=Math.round;function JC(){var n=navigator.userAgentData;return null!=n&&n.brands?n.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function cP(){return!/^((?!chrome|android).)*safari/i.test(JC())}function zc(n,t,e){void 0===t&&(t=!1),void 0===e&&(e=!1);var i=n.getBoundingClientRect(),r=1,o=1;t&&dr(n)&&(r=n.offsetWidth>0&&jc(i.width)/n.offsetWidth||1,o=n.offsetHeight>0&&jc(i.height)/n.offsetHeight||1);var a=(Za(n)?ur(n):window).visualViewport,l=!cP()&&e,c=(i.left+(l&&a?a.offsetLeft:0))/r,u=(i.top+(l&&a?a.offsetTop:0))/o,d=i.width/r,h=i.height/o;return{width:d,height:h,top:u,right:c+d,bottom:u+h,left:c,x:c,y:u}}function KC(n){var t=ur(n);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function ho(n){return n?(n.nodeName||"").toLowerCase():null}function js(n){return((Za(n)?n.ownerDocument:n.document)||window.document).documentElement}function $C(n){return zc(js(n)).left+KC(n).scrollLeft}function qo(n){return ur(n).getComputedStyle(n)}function qC(n){var t=qo(n);return/auto|scroll|overlay|hidden/.test(t.overflow+t.overflowY+t.overflowX)}function lq(n,t,e){void 0===e&&(e=!1);var i=dr(t),r=dr(t)&&function aq(n){var t=n.getBoundingClientRect(),e=jc(t.width)/n.offsetWidth||1,i=jc(t.height)/n.offsetHeight||1;return 1!==e||1!==i}(t),o=js(t),s=zc(n,r,e),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(i||!i&&!e)&&(("body"!==ho(t)||qC(o))&&(a=function sq(n){return n!==ur(n)&&dr(n)?function oq(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}(n):KC(n)}(t)),dr(t)?((l=zc(t,!0)).x+=t.clientLeft,l.y+=t.clientTop):o&&(l.x=$C(o))),{x:s.left+a.scrollLeft-l.x,y:s.top+a.scrollTop-l.y,width:s.width,height:s.height}}function XC(n){var t=zc(n),e=n.offsetWidth,i=n.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:n.offsetLeft,y:n.offsetTop,width:e,height:i}}function um(n){return"html"===ho(n)?n:n.assignedSlot||n.parentNode||(WC(n)?n.host:null)||js(n)}function uP(n){return["html","body","#document"].indexOf(ho(n))>=0?n.ownerDocument.body:dr(n)&&qC(n)?n:uP(um(n))}function ah(n,t){var e;void 0===t&&(t=[]);var i=uP(n),r=i===(null==(e=n.ownerDocument)?void 0:e.body),o=ur(i),s=r?[o].concat(o.visualViewport||[],qC(i)?i:[]):i,a=t.concat(s);return r?a:a.concat(ah(um(s)))}function cq(n){return["table","td","th"].indexOf(ho(n))>=0}function dP(n){return dr(n)&&"fixed"!==qo(n).position?n.offsetParent:null}function lh(n){for(var t=ur(n),e=dP(n);e&&cq(e)&&"static"===qo(e).position;)e=dP(e);return e&&("html"===ho(e)||"body"===ho(e)&&"static"===qo(e).position)?t:e||function uq(n){var t=/firefox/i.test(JC());if(/Trident/i.test(JC())&&dr(n)&&"fixed"===qo(n).position)return null;var r=um(n);for(WC(r)&&(r=r.host);dr(r)&&["html","body"].indexOf(ho(r))<0;){var o=qo(r);if("none"!==o.transform||"none"!==o.perspective||"paint"===o.contain||-1!==["transform","perspective"].indexOf(o.willChange)||t&&"filter"===o.willChange||t&&o.filter&&"none"!==o.filter)return r;r=r.parentNode}return null}(n)||t}var Ci="top",hr="bottom",pr="right",vi="left",ZC="auto",ch=[Ci,hr,pr,vi],Hc="start",uh="end",hP="viewport",dh="popper",pP=ch.reduce(function(n,t){return n.concat([t+"-"+Hc,t+"-"+uh])},[]),fP=[].concat(ch,[ZC]).reduce(function(n,t){return n.concat([t,t+"-"+Hc,t+"-"+uh])},[]),Cq=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function vq(n){var t=new Map,e=new Set,i=[];function r(o){e.add(o.name),[].concat(o.requires||[],o.requiresIfExists||[]).forEach(function(a){if(!e.has(a)){var l=t.get(a);l&&r(l)}}),i.push(o)}return n.forEach(function(o){t.set(o.name,o)}),n.forEach(function(o){e.has(o.name)||r(o)}),i}function wq(n){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(n())})})),t}}var gP={placement:"bottom",modifiers:[],strategy:"absolute"};function mP(){for(var n=arguments.length,t=new Array(n),e=0;e=0?"x":"y"}function AP(n){var l,t=n.reference,e=n.element,i=n.placement,r=i?po(i):null,o=i?Vc(i):null,s=t.x+t.width/2-e.width/2,a=t.y+t.height/2-e.height/2;switch(r){case Ci:l={x:s,y:t.y-e.height};break;case hr:l={x:s,y:t.y+t.height};break;case pr:l={x:t.x+t.width,y:a};break;case vi:l={x:t.x-e.width,y:a};break;default:l={x:t.x,y:t.y}}var c=r?ev(r):null;if(null!=c){var u="y"===c?"height":"width";switch(o){case Hc:l[c]=l[c]-(t[u]/2-e[u]/2);break;case uh:l[c]=l[c]+(t[u]/2-e[u]/2)}}return l}const Bq={name:"popperOffsets",enabled:!0,phase:"read",fn:function Tq(n){var t=n.state;t.modifiersData[n.name]=AP({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}};var Oq={top:"auto",right:"auto",bottom:"auto",left:"auto"};function bP(n){var t,e=n.popper,i=n.popperRect,r=n.placement,o=n.variation,s=n.offsets,a=n.position,l=n.gpuAcceleration,c=n.adaptive,u=n.roundOffsets,d=n.isFixed,h=s.x,p=void 0===h?0:h,f=s.y,g=void 0===f?0:f,m="function"==typeof u?u({x:p,y:g}):{x:p,y:g};p=m.x,g=m.y;var A=s.hasOwnProperty("x"),y=s.hasOwnProperty("y"),E=vi,b=Ci,D=window;if(c){var I=lh(e),Q="clientHeight",O="clientWidth";I===ur(e)&&"static"!==qo(I=js(e)).position&&"absolute"===a&&(Q="scrollHeight",O="scrollWidth"),(r===Ci||(r===vi||r===pr)&&o===uh)&&(b=hr,g-=(d&&I===D&&D.visualViewport?D.visualViewport.height:I[Q])-i.height,g*=l?1:-1),r!==vi&&(r!==Ci&&r!==hr||o!==uh)||(E=pr,p-=(d&&I===D&&D.visualViewport?D.visualViewport.width:I[O])-i.width,p*=l?1:-1)}var Ae,xe=Object.assign({position:a},c&&Oq),ke=!0===u?function kq(n){var e=n.y,r=window.devicePixelRatio||1;return{x:jc(n.x*r)/r||0,y:jc(e*r)/r||0}}({x:p,y:g}):{x:p,y:g};return p=ke.x,g=ke.y,Object.assign({},xe,l?((Ae={})[b]=y?"0":"",Ae[E]=A?"0":"",Ae.transform=(D.devicePixelRatio||1)<=1?"translate("+p+"px, "+g+"px)":"translate3d("+p+"px, "+g+"px, 0)",Ae):((t={})[b]=y?g+"px":"",t[E]=A?p+"px":"",t.transform="",t))}const Fq={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function Pq(n){var t=n.state,e=n.options,i=e.gpuAcceleration,r=void 0===i||i,o=e.adaptive,s=void 0===o||o,a=e.roundOffsets,l=void 0===a||a,u={placement:po(t.placement),variation:Vc(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:r,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,bP(Object.assign({},u,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,bP(Object.assign({},u,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},yP={name:"applyStyles",enabled:!0,phase:"write",fn:function Rq(n){var t=n.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},r=t.attributes[e]||{},o=t.elements[e];!dr(o)||!ho(o)||(Object.assign(o.style,i),Object.keys(r).forEach(function(s){var a=r[s];!1===a?o.removeAttribute(s):o.setAttribute(s,!0===a?"":a)}))})},effect:function Nq(n){var t=n.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(i){var r=t.elements[i],o=t.attributes[i]||{},a=Object.keys(t.styles.hasOwnProperty(i)?t.styles[i]:e[i]).reduce(function(l,c){return l[c]="",l},{});!dr(r)||!ho(r)||(Object.assign(r.style,a),Object.keys(o).forEach(function(l){r.removeAttribute(l)}))})}},requires:["computeStyles"]},Uq={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function Qq(n){var t=n.state,i=n.name,r=n.options.offset,o=void 0===r?[0,0]:r,s=fP.reduce(function(u,d){return u[d]=function Lq(n,t,e){var i=po(n),r=[vi,Ci].indexOf(i)>=0?-1:1,o="function"==typeof e?e(Object.assign({},t,{placement:n})):e,s=o[0],a=o[1];return s=s||0,a=(a||0)*r,[vi,pr].indexOf(i)>=0?{x:a,y:s}:{x:s,y:a}}(d,t.rects,o),u},{}),a=s[t.placement],c=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=a.x,t.modifiersData.popperOffsets.y+=c),t.modifiersData[i]=s}};var jq={left:"right",right:"left",bottom:"top",top:"bottom"};function hm(n){return n.replace(/left|right|bottom|top/g,function(t){return jq[t]})}var zq={start:"end",end:"start"};function _P(n){return n.replace(/start|end/g,function(t){return zq[t]})}function EP(n,t){var e=t.getRootNode&&t.getRootNode();if(n.contains(t))return!0;if(e&&WC(e)){var i=t;do{if(i&&n.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function tv(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function CP(n,t,e){return t===hP?tv(function Hq(n,t){var e=ur(n),i=js(n),r=e.visualViewport,o=i.clientWidth,s=i.clientHeight,a=0,l=0;if(r){o=r.width,s=r.height;var c=cP();(c||!c&&"fixed"===t)&&(a=r.offsetLeft,l=r.offsetTop)}return{width:o,height:s,x:a+$C(n),y:l}}(n,e)):Za(t)?function Gq(n,t){var e=zc(n,!1,"fixed"===t);return e.top=e.top+n.clientTop,e.left=e.left+n.clientLeft,e.bottom=e.top+n.clientHeight,e.right=e.left+n.clientWidth,e.width=n.clientWidth,e.height=n.clientHeight,e.x=e.left,e.y=e.top,e}(t,e):tv(function Vq(n){var t,e=js(n),i=KC(n),r=null==(t=n.ownerDocument)?void 0:t.body,o=el(e.scrollWidth,e.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),s=el(e.scrollHeight,e.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),a=-i.scrollLeft+$C(n),l=-i.scrollTop;return"rtl"===qo(r||e).direction&&(a+=el(e.clientWidth,r?r.clientWidth:0)-o),{width:o,height:s,x:a,y:l}}(js(n)))}function MP(n){return Object.assign({},{top:0,right:0,bottom:0,left:0},n)}function wP(n,t){return t.reduce(function(e,i){return e[i]=n,e},{})}function hh(n,t){void 0===t&&(t={});var i=t.placement,r=void 0===i?n.placement:i,o=t.strategy,s=void 0===o?n.strategy:o,a=t.boundary,l=void 0===a?"clippingParents":a,c=t.rootBoundary,u=void 0===c?hP:c,d=t.elementContext,h=void 0===d?dh:d,p=t.altBoundary,f=void 0!==p&&p,g=t.padding,m=void 0===g?0:g,A=MP("number"!=typeof m?m:wP(m,ch)),E=n.rects.popper,b=n.elements[f?h===dh?"reference":dh:h],D=function Wq(n,t,e,i){var r="clippingParents"===t?function Yq(n){var t=ah(um(n)),i=["absolute","fixed"].indexOf(qo(n).position)>=0&&dr(n)?lh(n):n;return Za(i)?t.filter(function(r){return Za(r)&&EP(r,i)&&"body"!==ho(r)}):[]}(n):[].concat(t),o=[].concat(r,[e]),a=o.reduce(function(l,c){var u=CP(n,c,i);return l.top=el(u.top,l.top),l.right=cm(u.right,l.right),l.bottom=cm(u.bottom,l.bottom),l.left=el(u.left,l.left),l},CP(n,o[0],i));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}(Za(b)?b:b.contextElement||js(n.elements.popper),l,u,s),I=zc(n.elements.reference),Q=AP({reference:I,element:E,strategy:"absolute",placement:r}),O=tv(Object.assign({},E,Q)),q=h===dh?O:I,le={top:D.top-q.top+A.top,bottom:q.bottom-D.bottom+A.bottom,left:D.left-q.left+A.left,right:q.right-D.right+A.right},xe=n.modifiersData.offset;if(h===dh&&xe){var ke=xe[r];Object.keys(le).forEach(function(Ae){var dt=[pr,hr].indexOf(Ae)>=0?1:-1,ht=[Ci,hr].indexOf(Ae)>=0?"y":"x";le[Ae]+=ke[ht]*dt})}return le}const qq={name:"flip",enabled:!0,phase:"main",fn:function $q(n){var t=n.state,e=n.options,i=n.name;if(!t.modifiersData[i]._skip){for(var r=e.mainAxis,o=void 0===r||r,s=e.altAxis,a=void 0===s||s,l=e.fallbackPlacements,c=e.padding,u=e.boundary,d=e.rootBoundary,h=e.altBoundary,p=e.flipVariations,f=void 0===p||p,g=e.allowedAutoPlacements,m=t.options.placement,A=po(m),E=l||(A!==m&&f?function Kq(n){if(po(n)===ZC)return[];var t=hm(n);return[_P(n),t,_P(t)]}(m):[hm(m)]),b=[m].concat(E).reduce(function(Xe,Si){return Xe.concat(po(Si)===ZC?function Jq(n,t){void 0===t&&(t={});var r=t.boundary,o=t.rootBoundary,s=t.padding,a=t.flipVariations,l=t.allowedAutoPlacements,c=void 0===l?fP:l,u=Vc(t.placement),d=u?a?pP:pP.filter(function(f){return Vc(f)===u}):ch,h=d.filter(function(f){return c.indexOf(f)>=0});0===h.length&&(h=d);var p=h.reduce(function(f,g){return f[g]=hh(n,{placement:g,boundary:r,rootBoundary:o,padding:s})[po(g)],f},{});return Object.keys(p).sort(function(f,g){return p[f]-p[g]})}(t,{placement:Si,boundary:u,rootBoundary:d,padding:c,flipVariations:f,allowedAutoPlacements:g}):Si)},[]),D=t.rects.reference,I=t.rects.popper,Q=new Map,O=!0,q=b[0],le=0;le=0,ht=dt?"width":"height",U=hh(t,{placement:xe,boundary:u,rootBoundary:d,altBoundary:h,padding:c}),V=dt?Ae?pr:vi:Ae?hr:Ci;D[ht]>I[ht]&&(V=hm(V));var W=hm(V),X=[];if(o&&X.push(U[ke]<=0),a&&X.push(U[V]<=0,U[W]<=0),X.every(function(Xe){return Xe})){q=xe,O=!1;break}Q.set(xe,X)}if(O)for(var ft=function(Si){var Hr=b.find(function(Ht){var Rn=Q.get(Ht);if(Rn)return Rn.slice(0,Si).every(function(En){return En})});if(Hr)return q=Hr,"break"},Bt=f?3:1;Bt>0&&"break"!==ft(Bt);Bt--);t.placement!==q&&(t.modifiersData[i]._skip=!0,t.placement=q,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function ph(n,t,e){return el(n,cm(t,e))}const t7={name:"preventOverflow",enabled:!0,phase:"main",fn:function e7(n){var t=n.state,e=n.options,i=n.name,r=e.mainAxis,o=void 0===r||r,s=e.altAxis,a=void 0!==s&&s,h=e.tether,p=void 0===h||h,f=e.tetherOffset,g=void 0===f?0:f,m=hh(t,{boundary:e.boundary,rootBoundary:e.rootBoundary,padding:e.padding,altBoundary:e.altBoundary}),A=po(t.placement),y=Vc(t.placement),E=!y,b=ev(A),D=function Xq(n){return"x"===n?"y":"x"}(b),I=t.modifiersData.popperOffsets,Q=t.rects.reference,O=t.rects.popper,q="function"==typeof g?g(Object.assign({},t.rects,{placement:t.placement})):g,le="number"==typeof q?{mainAxis:q,altAxis:q}:Object.assign({mainAxis:0,altAxis:0},q),xe=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,ke={x:0,y:0};if(I){if(o){var Ae,dt="y"===b?Ci:vi,ht="y"===b?hr:pr,U="y"===b?"height":"width",V=I[b],W=V+m[dt],X=V-m[ht],Ce=p?-O[U]/2:0,ft=y===Hc?Q[U]:O[U],Bt=y===Hc?-O[U]:-Q[U],un=t.elements.arrow,Xe=p&&un?XC(un):{width:0,height:0},Si=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},Hr=Si[dt],Ht=Si[ht],Rn=ph(0,Q[U],Xe[U]),En=E?Q[U]/2-Ce-Rn-Hr-le.mainAxis:ft-Rn-Hr-le.mainAxis,Yi=E?-Q[U]/2+Ce+Rn+Ht+le.mainAxis:Bt+Rn+Ht+le.mainAxis,Mo=t.elements.arrow&&lh(t.elements.arrow),ip=null!=(Ae=xe?.[b])?Ae:0,YA=V+Yi-ip,rp=ph(p?cm(W,V+En-ip-(Mo?"y"===b?Mo.clientTop||0:Mo.clientLeft||0:0)):W,V,p?el(X,YA):X);I[b]=rp,ke[b]=rp-V}if(a){var op,ls=I[D],ha="y"===D?"height":"width",sp=ls+m["x"===b?Ci:vi],wl=ls-m["x"===b?hr:pr],ap=-1!==[Ci,vi].indexOf(A),KA=null!=(op=xe?.[D])?op:0,$A=ap?sp:ls-Q[ha]-O[ha]-KA+le.altAxis,qA=ap?ls+Q[ha]+O[ha]-KA-le.altAxis:wl,XA=p&&ap?function Zq(n,t,e){var i=ph(n,t,e);return i>e?e:i}($A,ls,qA):ph(p?$A:sp,ls,p?qA:wl);I[D]=XA,ke[D]=XA-ls}t.modifiersData[i]=ke}},requiresIfExists:["offset"]},o7={name:"arrow",enabled:!0,phase:"main",fn:function i7(n){var t,e=n.state,i=n.name,r=n.options,o=e.elements.arrow,s=e.modifiersData.popperOffsets,a=po(e.placement),l=ev(a),u=[vi,pr].indexOf(a)>=0?"height":"width";if(o&&s){var d=function(t,e){return MP("number"!=typeof(t="function"==typeof t?t(Object.assign({},e.rects,{placement:e.placement})):t)?t:wP(t,ch))}(r.padding,e),h=XC(o),p="y"===l?Ci:vi,f="y"===l?hr:pr,g=e.rects.reference[u]+e.rects.reference[l]-s[l]-e.rects.popper[u],m=s[l]-e.rects.reference[l],A=lh(o),y=A?"y"===l?A.clientHeight||0:A.clientWidth||0:0,I=y/2-h[u]/2+(g/2-m/2),Q=ph(d[p],I,y-h[u]-d[f]);e.modifiersData[i]=((t={})[l]=Q,t.centerOffset=Q-I,t)}},effect:function r7(n){var t=n.state,i=n.options.element,r=void 0===i?"[data-popper-arrow]":i;null!=r&&("string"==typeof r&&!(r=t.elements.popper.querySelector(r))||!EP(t.elements.popper,r)||(t.elements.arrow=r))},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function DP(n,t,e){return void 0===e&&(e={x:0,y:0}),{top:n.top-t.height-e.y,right:n.right-t.width+e.x,bottom:n.bottom-t.height+e.y,left:n.left-t.width-e.x}}function IP(n){return[Ci,pr,hr,vi].some(function(t){return n[t]>=0})}var a7=[xq,Bq,Fq,yP,Uq,qq,t7,o7,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function s7(n){var t=n.state,e=n.name,i=t.rects.reference,r=t.rects.popper,o=t.modifiersData.preventOverflow,s=hh(t,{elementContext:"reference"}),a=hh(t,{altBoundary:!0}),l=DP(s,i),c=DP(a,r,o),u=IP(l),d=IP(c);t.modifiersData[e]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}}],l7=Iq({defaultModifiers:a7}),SP="tippy-content",TP="tippy-arrow",BP="tippy-svg-arrow",zs={passive:!0,capture:!0},OP=function(){return document.body};function nv(n,t,e){return Array.isArray(n)?n[t]??(Array.isArray(e)?e[t]:e):n}function iv(n,t){var e={}.toString.call(n);return 0===e.indexOf("[object")&&e.indexOf(t+"]")>-1}function kP(n,t){return"function"==typeof n?n.apply(void 0,t):n}function PP(n,t){return 0===t?n:function(i){clearTimeout(e),e=setTimeout(function(){n(i)},t)};var e}function Hs(n){return[].concat(n)}function FP(n,t){-1===n.indexOf(t)&&n.push(t)}function Gc(n){return[].slice.call(n)}function NP(n){return Object.keys(n).reduce(function(t,e){return void 0!==n[e]&&(t[e]=n[e]),t},{})}function tl(){return document.createElement("div")}function pm(n){return["Element","Fragment"].some(function(t){return iv(n,t)})}function sv(n,t){n.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function fh(n,t){n.forEach(function(e){e&&e.setAttribute("data-state",t)})}function av(n,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(r){n[i](r,e)})}function UP(n,t){for(var e=t;e;){var i;if(n.contains(e))return!0;e=null==e.getRootNode||null==(i=e.getRootNode())?void 0:i.host}return!1}var fo={isTouch:!1},jP=0;function m7(){fo.isTouch||(fo.isTouch=!0,window.performance&&document.addEventListener("mousemove",zP))}function zP(){var n=performance.now();n-jP<20&&(fo.isTouch=!1,document.removeEventListener("mousemove",zP)),jP=n}function A7(){var n=document.activeElement;(function LP(n){return!(!n||!n._tippy||n._tippy.reference!==n)})(n)&&n.blur&&!n._tippy.state.isVisible&&n.blur()}var _7=!!(typeof window<"u"&&typeof document<"u")&&!!window.msCrypto,Mi=Object.assign({appendTo:OP,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},{animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},{allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999}),M7=Object.keys(Mi);function WP(n){var e=(n.plugins||[]).reduce(function(i,r){var a,o=r.name;return o&&(i[o]=void 0!==n[o]?n[o]:null!=(a=Mi[o])?a:r.defaultValue),i},{});return Object.assign({},n,e)}function JP(n,t){var e=Object.assign({},t,{content:kP(t.content,[n])},t.ignoreAttributes?{}:function D7(n,t){return(t?Object.keys(WP(Object.assign({},Mi,{plugins:t}))):M7).reduce(function(r,o){var s=(n.getAttribute("data-tippy-"+o)||"").trim();if(!s)return r;if("content"===o)r[o]=s;else try{r[o]=JSON.parse(s)}catch{r[o]=s}return r},{})}(n,t.plugins));return e.aria=Object.assign({},Mi.aria,e.aria),e.aria={expanded:"auto"===e.aria.expanded?t.interactive:e.aria.expanded,content:"auto"===e.aria.content?t.interactive?null:"describedby":e.aria.content},e}function lv(n,t){n.innerHTML=t}function KP(n){var t=tl();return!0===n?t.className=TP:(t.className=BP,pm(n)?t.appendChild(n):lv(t,n)),t}function $P(n,t){pm(t.content)?(lv(n,""),n.appendChild(t.content)):"function"!=typeof t.content&&(t.allowHTML?lv(n,t.content):n.textContent=t.content)}function fm(n){var t=n.firstElementChild,e=Gc(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(SP)}),arrow:e.find(function(i){return i.classList.contains(TP)||i.classList.contains(BP)}),backdrop:e.find(function(i){return i.classList.contains("tippy-backdrop")})}}function qP(n){var t=tl(),e=tl();e.className="tippy-box",e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=tl();function r(o,s){var a=fm(t),l=a.box,c=a.content,u=a.arrow;s.theme?l.setAttribute("data-theme",s.theme):l.removeAttribute("data-theme"),"string"==typeof s.animation?l.setAttribute("data-animation",s.animation):l.removeAttribute("data-animation"),s.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth="number"==typeof s.maxWidth?s.maxWidth+"px":s.maxWidth,s.role?l.setAttribute("role",s.role):l.removeAttribute("role"),(o.content!==s.content||o.allowHTML!==s.allowHTML)&&$P(c,n.props),s.arrow?u?o.arrow!==s.arrow&&(l.removeChild(u),l.appendChild(KP(s.arrow))):l.appendChild(KP(s.arrow)):u&&l.removeChild(u)}return i.className=SP,i.setAttribute("data-state","hidden"),$P(i,n.props),t.appendChild(e),e.appendChild(i),r(n.props,n.props),{popper:t,onUpdate:r}}qP.$$tippy=!0;var S7=1,gm=[],mm=[];function x7(n,t){var i,r,o,u,d,h,g,e=JP(n,Object.assign({},Mi,WP(NP(t)))),s=!1,a=!1,l=!1,c=!1,p=[],f=PP(GA,e.interactiveDebounce),m=S7++,y=function h7(n){return n.filter(function(t,e){return n.indexOf(t)===e})}(e.plugins),b={id:m,reference:n,popper:tl(),popperInstance:null,props:e,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:y,clearDelayTimeouts:function $A(){clearTimeout(i),clearTimeout(r),cancelAnimationFrame(o)},setProps:function qA(k){if(!b.state.isDestroyed){W("onBeforeUpdate",[b,k]),VA();var se=b.props,De=JP(n,Object.assign({},se,NP(k),{ignoreAttributes:!0}));b.props=De,Mo(),se.interactiveDebounce!==De.interactiveDebounce&&(ft(),f=PP(GA,De.interactiveDebounce)),se.triggerTarget&&!De.triggerTarget?Hs(se.triggerTarget).forEach(function(bt){bt.removeAttribute("aria-expanded")}):De.triggerTarget&&n.removeAttribute("aria-expanded"),Ce(),V(),Q&&Q(se,De),b.popperInstance&&(WA(),ha().forEach(function(bt){requestAnimationFrame(bt._tippy.popperInstance.forceUpdate)})),W("onAfterUpdate",[b,k])}},setContent:function XA(k){b.setProps({content:k})},show:function pfe(){var k=b.state.isVisible,se=b.state.isDestroyed,De=!b.state.isEnabled,bt=fo.isTouch&&!b.props.touch,Ze=nv(b.props.duration,0,Mi.duration);if(!(k||se||De||bt||Ae().hasAttribute("disabled")||(W("onShow",[b],!1),!1===b.props.onShow(b)))){if(b.state.isVisible=!0,ke()&&(I.style.visibility="visible"),V(),Si(),b.state.isMounted||(I.style.transition="none"),ke()){var pi=ht();sv([pi.box,pi.content],0)}h=function(){var Dl;if(b.state.isVisible&&!c){if(c=!0,I.style.transition=b.props.moveTransition,ke()&&b.props.animation){var Iw=ht(),ZA=Iw.box,bu=Iw.content;sv([ZA,bu],Ze),fh([ZA,bu],"visible")}X(),Ce(),FP(mm,b),null==(Dl=b.popperInstance)||Dl.forceUpdate(),W("onMount",[b]),b.props.animation&&ke()&&function Rn(k,se){En(k,se)}(Ze,function(){b.state.isShown=!0,W("onShown",[b])})}},function ls(){var se,k=b.props.appendTo,De=Ae();(se=b.props.interactive&&k===OP||"parent"===k?De.parentNode:kP(k,[De])).contains(I)||se.appendChild(I),b.state.isMounted=!0,WA()}()}},hide:function ffe(){var k=!b.state.isVisible,se=b.state.isDestroyed,De=!b.state.isEnabled,bt=nv(b.props.duration,1,Mi.duration);if(!(k||se||De)&&(W("onHide",[b],!1),!1!==b.props.onHide(b))){if(b.state.isVisible=!1,b.state.isShown=!1,c=!1,s=!1,ke()&&(I.style.visibility="hidden"),ft(),Hr(),V(!0),ke()){var Ze=ht(),pi=Ze.box,_r=Ze.content;b.props.animation&&(sv([pi,_r],bt),fh([pi,_r],"hidden"))}X(),Ce(),b.props.animation?ke()&&function Ht(k,se){En(k,function(){!b.state.isVisible&&I.parentNode&&I.parentNode.contains(I)&&se()})}(bt,b.unmount):b.unmount()}},hideWithInteractivity:function gfe(k){dt().addEventListener("mousemove",f),FP(gm,f),f(k)},enable:function ap(){b.state.isEnabled=!0},disable:function KA(){b.hide(),b.state.isEnabled=!1},unmount:function mfe(){b.state.isVisible&&b.hide(),b.state.isMounted&&(JA(),ha().forEach(function(k){k._tippy.unmount()}),I.parentNode&&I.parentNode.removeChild(I),mm=mm.filter(function(k){return k!==b}),b.state.isMounted=!1,W("onHidden",[b]))},destroy:function Afe(){b.state.isDestroyed||(b.clearDelayTimeouts(),b.unmount(),VA(),delete n._tippy,b.state.isDestroyed=!0,W("onDestroy",[b]))}};if(!e.render)return b;var D=e.render(b),I=D.popper,Q=D.onUpdate;I.setAttribute("data-tippy-root",""),I.id="tippy-"+b.id,b.popper=I,n._tippy=b,I._tippy=b;var O=y.map(function(k){return k.fn(b)}),q=n.hasAttribute("aria-expanded");return Mo(),Ce(),V(),W("onCreate",[b]),e.showOnCreate&&sp(),I.addEventListener("mouseenter",function(){b.props.interactive&&b.state.isVisible&&b.clearDelayTimeouts()}),I.addEventListener("mouseleave",function(){b.props.interactive&&b.props.trigger.indexOf("mouseenter")>=0&&dt().addEventListener("mousemove",f)}),b;function le(){var k=b.props.touch;return Array.isArray(k)?k:[k,0]}function xe(){return"hold"===le()[0]}function ke(){var k;return!(null==(k=b.props.render)||!k.$$tippy)}function Ae(){return g||n}function dt(){var k=Ae().parentNode;return k?function QP(n){var t,i=Hs(n)[0];return null!=i&&null!=(t=i.ownerDocument)&&t.body?i.ownerDocument:document}(k):document}function ht(){return fm(I)}function U(k){return b.state.isMounted&&!b.state.isVisible||fo.isTouch||u&&"focus"===u.type?0:nv(b.props.delay,k?0:1,Mi.delay)}function V(k){void 0===k&&(k=!1),I.style.pointerEvents=b.props.interactive&&!k?"":"none",I.style.zIndex=""+b.props.zIndex}function W(k,se,De){var bt;void 0===De&&(De=!0),O.forEach(function(Ze){Ze[k]&&Ze[k].apply(Ze,se)}),De&&(bt=b.props)[k].apply(bt,se)}function X(){var k=b.props.aria;if(k.content){var se="aria-"+k.content,De=I.id;Hs(b.props.triggerTarget||n).forEach(function(Ze){var pi=Ze.getAttribute(se);if(b.state.isVisible)Ze.setAttribute(se,pi?pi+" "+De:De);else{var _r=pi&&pi.replace(De,"").trim();_r?Ze.setAttribute(se,_r):Ze.removeAttribute(se)}})}}function Ce(){!q&&b.props.aria.expanded&&Hs(b.props.triggerTarget||n).forEach(function(se){b.props.interactive?se.setAttribute("aria-expanded",b.state.isVisible&&se===Ae()?"true":"false"):se.removeAttribute("aria-expanded")})}function ft(){dt().removeEventListener("mousemove",f),gm=gm.filter(function(k){return k!==f})}function Bt(k){if(!fo.isTouch||!l&&"mousedown"!==k.type){var se=k.composedPath&&k.composedPath()[0]||k.target;if(!b.props.interactive||!UP(I,se)){if(Hs(b.props.triggerTarget||n).some(function(De){return UP(De,se)})){if(fo.isTouch||b.state.isVisible&&b.props.trigger.indexOf("click")>=0)return}else W("onClickOutside",[b,k]);!0===b.props.hideOnClick&&(b.clearDelayTimeouts(),b.hide(),a=!0,setTimeout(function(){a=!1}),b.state.isMounted||Hr())}}}function un(){l=!0}function Xe(){l=!1}function Si(){var k=dt();k.addEventListener("mousedown",Bt,!0),k.addEventListener("touchend",Bt,zs),k.addEventListener("touchstart",Xe,zs),k.addEventListener("touchmove",un,zs)}function Hr(){var k=dt();k.removeEventListener("mousedown",Bt,!0),k.removeEventListener("touchend",Bt,zs),k.removeEventListener("touchstart",Xe,zs),k.removeEventListener("touchmove",un,zs)}function En(k,se){var De=ht().box;function bt(Ze){Ze.target===De&&(av(De,"remove",bt),se())}if(0===k)return se();av(De,"remove",d),av(De,"add",bt),d=bt}function Yi(k,se,De){void 0===De&&(De=!1),Hs(b.props.triggerTarget||n).forEach(function(Ze){Ze.addEventListener(k,se,De),p.push({node:Ze,eventType:k,handler:se,options:De})})}function Mo(){xe()&&(Yi("touchstart",ip,{passive:!0}),Yi("touchend",YA,{passive:!0})),function d7(n){return n.split(/\s+/).filter(Boolean)}(b.props.trigger).forEach(function(k){if("manual"!==k)switch(Yi(k,ip),k){case"mouseenter":Yi("mouseleave",YA);break;case"focus":Yi(_7?"focusout":"blur",rp);break;case"focusin":Yi("focusout",rp)}})}function VA(){p.forEach(function(k){k.node.removeEventListener(k.eventType,k.handler,k.options)}),p=[]}function ip(k){var se,De=!1;if(b.state.isEnabled&&!op(k)&&!a){var bt="focus"===(null==(se=u)?void 0:se.type);u=k,g=k.currentTarget,Ce(),!b.state.isVisible&&function ov(n){return iv(n,"MouseEvent")}(k)&&gm.forEach(function(Ze){return Ze(k)}),"click"===k.type&&(b.props.trigger.indexOf("mouseenter")<0||s)&&!1!==b.props.hideOnClick&&b.state.isVisible?De=!0:sp(k),"click"===k.type&&(s=!De),De&&!bt&&wl(k)}}function GA(k){var se=k.target,De=Ae().contains(se)||I.contains(se);"mousemove"===k.type&&De||function g7(n,t){var e=t.clientX,i=t.clientY;return n.every(function(r){var o=r.popperRect,s=r.popperState,l=r.props.interactiveBorder,c=function RP(n){return n.split("-")[0]}(s.placement),u=s.modifiersData.offset;return!u||o.top-i+("bottom"===c?u.top.y:0)>l||i-o.bottom-("top"===c?u.bottom.y:0)>l||o.left-e+("right"===c?u.left.x:0)>l||e-o.right-("left"===c?u.right.x:0)>l})}(ha().concat(I).map(function(Ze){var pi,Au=null==(pi=Ze._tippy.popperInstance)?void 0:pi.state;return Au?{popperRect:Ze.getBoundingClientRect(),popperState:Au,props:e}:null}).filter(Boolean),k)&&(ft(),wl(k))}function YA(k){if(!(op(k)||b.props.trigger.indexOf("click")>=0&&s)){if(b.props.interactive)return void b.hideWithInteractivity(k);wl(k)}}function rp(k){b.props.trigger.indexOf("focusin")<0&&k.target!==Ae()||b.props.interactive&&k.relatedTarget&&I.contains(k.relatedTarget)||wl(k)}function op(k){return!!fo.isTouch&&xe()!==k.type.indexOf("touch")>=0}function WA(){JA();var k=b.props,se=k.popperOptions,De=k.placement,bt=k.offset,Ze=k.getReferenceClientRect,pi=k.moveTransition,_r=ke()?fm(I).arrow:null,Au=Ze?{getBoundingClientRect:Ze,contextElement:Ze.contextElement||Ae()}:n,Dl=[{name:"offset",options:{offset:bt}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!pi}},{name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(ZA){var bu=ZA.state;if(ke()){var Sw=ht().box;["placement","reference-hidden","escaped"].forEach(function(eb){"placement"===eb?Sw.setAttribute("data-placement",bu.placement):bu.attributes.popper["data-popper-"+eb]?Sw.setAttribute("data-"+eb,""):Sw.removeAttribute("data-"+eb)}),bu.attributes.popper={}}}}];ke()&&_r&&Dl.push({name:"arrow",options:{element:_r,padding:3}}),Dl.push.apply(Dl,se?.modifiers||[]),b.popperInstance=l7(Au,I,Object.assign({},se,{placement:De,onFirstUpdate:h,modifiers:Dl}))}function JA(){b.popperInstance&&(b.popperInstance.destroy(),b.popperInstance=null)}function ha(){return Gc(I.querySelectorAll("[data-tippy-root]"))}function sp(k){b.clearDelayTimeouts(),k&&W("onTrigger",[b,k]),Si();var se=U(!0),De=le(),Ze=De[1];fo.isTouch&&"hold"===De[0]&&Ze&&(se=Ze),se?i=setTimeout(function(){b.show()},se):b.show()}function wl(k){if(b.clearDelayTimeouts(),W("onUntrigger",[b,k]),b.state.isVisible){if(!(b.props.trigger.indexOf("mouseenter")>=0&&b.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(k.type)>=0&&s)){var se=U(!1);se?r=setTimeout(function(){b.state.isVisible&&b.hide()},se):o=requestAnimationFrame(function(){b.hide()})}}else Hr()}}function Vs(n,t){void 0===t&&(t={});var e=Mi.plugins.concat(t.plugins||[]);!function b7(){document.addEventListener("touchstart",m7,zs),window.addEventListener("blur",A7)}();var i=Object.assign({},t,{plugins:e}),a=function f7(n){return pm(n)?[n]:function p7(n){return iv(n,"NodeList")}(n)?Gc(n):Array.isArray(n)?n:Gc(document.querySelectorAll(n))}(n).reduce(function(l,c){var u=c&&x7(c,i);return u&&l.push(u),l},[]);return pm(n)?a[0]:a}Vs.defaultProps=Mi,Vs.setDefaultProps=function(t){Object.keys(t).forEach(function(i){Mi[i]=t[i]})},Vs.currentInput=fo,Object.assign({},yP,{effect:function(t){var e=t.state,i={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(e.elements.popper.style,i.popper),e.styles=i,e.elements.arrow&&Object.assign(e.elements.arrow.style,i.arrow)}}),Vs.setDefaultProps({render:qP});const Xo=Vs,eF=(()=>{function n(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return n.prototype=Object.create(Error.prototype),n})();function $n(n){return t=>0===n?tg():t.lift(new N7(n))}class N7{constructor(t){if(this.total=t,this.total<0)throw new eF}call(t,e){return e.subscribe(new L7(t,this.total))}}class L7 extends Ge{constructor(t,e){super(t),this.total=e,this.count=0}_next(t){const e=this.total,i=++this.count;i<=e&&(this.destination.next(t),i===e&&(this.destination.complete(),this.unsubscribe()))}}const Hi=function(n){for(var t=0;;t++)if(!(n=n.previousSibling))return t},mh=function(n){let t=n.assignedSlot||n.parentNode;return t&&11==t.nodeType?t.host:t};let tF=null;const Zo=function(n,t,e){let i=tF||(tF=document.createRange());return i.setEnd(n,e??n.nodeValue.length),i.setStart(n,t||0),i},nl=function(n,t,e,i){return e&&(nF(n,t,e,i,-1)||nF(n,t,e,i,1))},Q7=/^(img|br|input|textarea|hr)$/i;function nF(n,t,e,i,r){for(;;){if(n==e&&t==i)return!0;if(t==(r<0?0:go(n))){let o=n.parentNode;if(!o||1!=o.nodeType||j7(n)||Q7.test(n.nodeName)||"false"==n.contentEditable)return!1;t=Hi(n)+(r<0?0:1),n=o}else{if(1!=n.nodeType)return!1;if("false"==(n=n.childNodes[t+(r<0?-1:0)]).contentEditable)return!1;t=r<0?go(n):0}}}function go(n){return 3==n.nodeType?n.nodeValue.length:n.childNodes.length}function j7(n){let t;for(let e=n;e&&!(t=e.pmViewDesc);e=e.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==n||t.contentDOM==n)}const bm=function(n){return n.focusNode&&nl(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Yc(n,t){let e=document.createEvent("Event");return e.initEvent("keydown",!0,!0),e.keyCode=n,e.key=e.code=t,e}const Gs=typeof navigator<"u"?navigator:null,iF=typeof document<"u"?document:null,Ys=Gs&&Gs.userAgent||"",uv=/Edge\/(\d+)/.exec(Ys),rF=/MSIE \d/.exec(Ys),dv=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ys),wi=!!(rF||dv||uv),Ws=rF?document.documentMode:dv?+dv[1]:uv?+uv[1]:0,Nr=!wi&&/gecko\/(\d+)/i.test(Ys);Nr&&/Firefox\/(\d+)/.exec(Ys);const hv=!wi&&/Chrome\/(\d+)/.exec(Ys),Di=!!hv,H7=hv?+hv[1]:0,ci=!wi&&!!Gs&&/Apple Computer/.test(Gs.vendor),Wc=ci&&(/Mobile\/\w+/.test(Ys)||!!Gs&&Gs.maxTouchPoints>2),fr=Wc||!!Gs&&/Mac/.test(Gs.platform),mo=/Android \d/.test(Ys),ym=!!iF&&"webkitFontSmoothing"in iF.documentElement.style,V7=ym?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function G7(n){return{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Js(n,t){return"number"==typeof n?n:n[t]}function Y7(n){let t=n.getBoundingClientRect();return{left:t.left,right:t.left+n.clientWidth*(t.width/n.offsetWidth||1),top:t.top,bottom:t.top+n.clientHeight*(t.height/n.offsetHeight||1)}}function oF(n,t,e){let i=n.someProp("scrollThreshold")||0,r=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=e||n.dom;s;s=mh(s)){if(1!=s.nodeType)continue;let a=s,l=a==o.body,c=l?G7(o):Y7(a),u=0,d=0;if(t.topc.bottom-Js(i,"bottom")&&(d=t.bottom-c.bottom+Js(r,"bottom")),t.leftc.right-Js(i,"right")&&(u=t.right-c.right+Js(r,"right")),u||d)if(l)o.defaultView.scrollBy(u,d);else{let h=a.scrollLeft,p=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let f=a.scrollLeft-h,g=a.scrollTop-p;t={left:t.left-f,top:t.top-g,right:t.right-f,bottom:t.bottom-g}}if(l)break}}function sF(n){let t=[],e=n.ownerDocument;for(let i=n;i&&(t.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),n!=e);i=mh(i));return t}function aF(n,t){for(let e=0;e=a){s=Math.max(h.bottom,s),a=Math.min(h.top,a);let p=h.left>t.left?h.left-t.left:h.right=(h.left+h.right)/2?1:0));continue}}!e&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(o=c+1)}}return e&&3==e.nodeType?function $7(n,t){let e=n.nodeValue.length,i=document.createRange();for(let r=0;r=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}(e,r):!e||i&&1==e.nodeType?{node:n,offset:o}:lF(e,r)}function pv(n,t){return n.left>=t.left-1&&n.left<=t.right+1&&n.top>=t.top-1&&n.top<=t.bottom+1}function cF(n,t,e){let i=n.childNodes.length;if(i&&e.topt.top&&r++}i==n.dom&&r==i.childNodes.length-1&&1==i.lastChild.nodeType&&t.top>i.lastChild.getBoundingClientRect().bottom?s=n.state.doc.content.size:(0==r||1!=i.nodeType||"BR"!=i.childNodes[r-1].nodeName)&&(s=function Z7(n,t,e,i){let r=-1;for(let o=t;o!=n.dom;){let s=n.docView.nearestDesc(o,!0);if(!s)return null;if(s.node.isBlock&&s.parent){let a=s.dom.getBoundingClientRect();if(a.left>i.left||a.top>i.top)r=s.posBefore;else{if(!(a.right-1?r:n.docView.posFromDOM(t,e,1)}(n,i,r,t))}null==s&&(s=function X7(n,t,e){let{node:i,offset:r}=lF(t,e),o=-1;if(1==i.nodeType&&!i.firstChild){let s=i.getBoundingClientRect();o=s.left!=s.right&&e.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(i,r,o)}(n,o,t));let a=n.docView.nearestDesc(o,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Ks(n,t){let e=n.getClientRects();return e.length?e[t<0?0:e.length-1]:n.getBoundingClientRect()}const tX=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function uF(n,t,e){let{node:i,offset:r,atom:o}=n.docView.domFromPos(t,e<0?-1:1),s=ym||Nr;if(3==i.nodeType){if(!s||!tX.test(i.nodeValue)&&(e<0?r:r!=i.nodeValue.length)){let l=r,c=r,u=e<0?1:-1;return e<0&&!r?(c++,u=-1):e>=0&&r==i.nodeValue.length?(l--,u=1):e<0?l--:c++,Ah(Ks(Zo(i,l,c),1),u<0)}{let l=Ks(Zo(i,r,r),e);if(Nr&&r&&/\s/.test(i.nodeValue[r-1])&&r=0)}if(null==o&&r&&(e<0||r==go(i))){let l=i.childNodes[r-1],c=3==l.nodeType?Zo(l,go(l)-(s?0:1)):1!=l.nodeType||"BR"==l.nodeName&&l.nextSibling?null:l;if(c)return Ah(Ks(c,1),!1)}if(null==o&&r=0)}function Ah(n,t){if(0==n.width)return n;let e=t?n.left:n.right;return{top:n.top,bottom:n.bottom,left:e,right:e}}function fv(n,t){if(0==n.height)return n;let e=t?n.top:n.bottom;return{top:e,bottom:e,left:n.left,right:n.right}}function dF(n,t,e){let i=n.state,r=n.root.activeElement;i!=t&&n.updateState(t),r!=n.dom&&n.focus();try{return e()}finally{i!=t&&n.updateState(i),r!=n.dom&&r&&r.focus()}}const iX=/[\u0590-\u08ac]/;let hF=null,pF=null,fF=!1;class bh{constructor(t,e,i,r){this.parent=t,this.children=e,this.dom=i,this.contentDOM=r,this.dirty=0,i.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,i){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;eHi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let o=t;;o=o.parentNode){if(o==this.dom){r=!1;break}if(o.previousSibling)break}if(null==r&&e==t.childNodes.length)for(let o=t;;o=o.parentNode){if(o==this.dom){r=!0;break}if(o.nextSibling)break}}return r??i>0?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let i=!0,r=t;r;r=r.parentNode){let s,o=this.getDesc(r);if(o&&(!e||o.node)){if(!i||!(s=o.nodeDOM)||(1==s.nodeType?s.contains(1==t.nodeType?t:t.parentNode):s==t))return o;i=!1}}}getDesc(t){let e=t.pmViewDesc;for(let i=e;i;i=i.parent)if(i==this)return e}posFromDOM(t,e,i){for(let r=t;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,i)}return-1}descAt(t){for(let e=0,i=0;et||s instanceof bF){r=t-o;break}o=a}if(r)return this.children[i].domFromPos(r-this.children[i].border,e);for(;i&&!(o=this.children[i-1]).size&&o instanceof mF&&o.side>=0;i--);if(e<=0){let o,s=!0;for(;o=i?this.children[i-1]:null,o&&o.dom.parentNode!=this.contentDOM;i--,s=!1);return o&&e&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,e):{node:this.contentDOM,offset:o?Hi(o.dom)+1:0}}{let o,s=!0;for(;o=i=u&&e<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(t,e,u);t=s;for(let d=a;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){r=Hi(h.dom)+1;break}t-=h.size}-1==r&&(r=0)}if(r>-1&&(c>e||a==this.children.length-1)){e=c;for(let u=a+1;up&&se){let p=a;a=l,l=p}let h=document.createRange();h.setEnd(l.node,l.offset),h.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let i=0,r=0;r=i:ti){let a=i+o.border,l=s-o.border;if(t>=a&&e<=l)return this.dirty=t==i||e==s?2:1,void(t!=a||e!=l||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-a,e-a):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}i=s}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let i=1==t?2:1;e.dirtyo?o.parent?o.parent.posBeforeChild(o):void 0:r)),!e.type.spec.raw){if(1!=s.nodeType){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=e,this.widget=e,o=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||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 sX extends bh{constructor(t,e,i,r){super(t,[],e,null),this.textDOM=i,this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class il extends bh{constructor(t,e,i,r){super(t,[],i,r),this.mark=e}static create(t,e,i,r){let o=r.nodeViews[e.type.name],s=o&&o(e,r,i);return(!s||!s.dom)&&(s=co.renderSpec(document,e.type.spec.toDOM(e,i))),new il(t,e,s.dom,s.contentDOM||s.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty0&&(o=Av(o,0,t,i));for(let a=0;al?l.parent?l.parent.posBeforeChild(l):void 0:s,i,r),u=c&&c.dom,d=c&&c.contentDOM;if(e.isText)if(u){if(3!=u.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else u=document.createTextNode(e.text);else u||({dom:u,contentDOM:d}=co.renderSpec(document,e.type.spec.toDOM(e)));!d&&!e.isText&&"BR"!=u.nodeName&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),e.type.spec.draggable&&(u.draggable=!0));let h=u;return u=EF(u,i,e),c?l=new aX(t,e,i,r,u,d||null,h,c,o,s+1):e.isText?new _m(t,e,i,r,u,h,o):new rl(t,e,i,r,u,d||null,h,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let i=this.children[e];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}t.contentElement||(t.getContent=()=>L.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,i){return 0==this.dirty&&t.eq(this.node)&&mv(e,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let i=this.node.inlineContent,r=e,o=t.composing?this.localCompositionInfo(t,e):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new cX(this,s&&s.node,t);(function hX(n,t,e,i){let r=t.locals(n),o=0;if(0==r.length){for(let c=0;co;)a.push(r[s++]);let h=o+u.nodeSize;if(u.isText){let f=h;s!f.inline):a.slice(),t.forChild(o,u),d),o=h}})(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,i,t):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?Tt.none:this.node.child(u).marks,i,t),l.placeWidget(c,t,r)},(c,u,d,h)=>{let p;l.syncToMarks(c.marks,i,t),l.findNodeMatch(c,u,d,h)||a&&t.state.selection.from>r&&t.state.selection.to-1&&l.updateNodeAt(c,u,d,p,t)||l.updateNextNode(c,u,d,t,h)||l.addNode(c,u,d,t,r),r+=c.nodeSize}),l.syncToMarks([],i,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),yF(this.contentDOM,this.children,t),Wc&&function pX(n){if("UL"==n.nodeName||"OL"==n.nodeName){let t=n.style.cssText;n.style.cssText=t+"; list-style: square !important",window.getComputedStyle(n),n.style.cssText=t}}(this.dom))}localCompositionInfo(t,e){let{from:i,to:r}=t.state.selection;if(!(t.state.selection instanceof Ee)||ie+this.node.content.size)return null;let o=t.domSelectionRange(),s=function fX(n,t){for(;;){if(3==n.nodeType)return n;if(1==n.nodeType&&t>0){if(n.childNodes.length>t&&3==n.childNodes[t].nodeType)return n.childNodes[t];t=go(n=n.childNodes[t-1])}else{if(!(1==n.nodeType&&t=e){let c=a=0&&c+t.length+a>=e)return a+c;if(e==i&&l.length>=i+t.length-a&&l.slice(i-a,i-a+t.length)==t)return i}}return-1}(this.node.content,a,i-e,r-e);return l<0?null:{node:s,pos:l,text:a}}return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:i,text:r}){if(this.getDesc(e))return;let o=e;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new sX(this,o,e,r);t.input.compositionNodes.push(s),this.children=Av(this.children,i,i+r.length,t,s)}update(t,e,i,r){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,i,r),0))}updateInner(t,e,i,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=i,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(mv(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,i=this.dom;this.dom=_F(this.dom,this.nodeDOM,gv(this.outerDeco,this.node,e),gv(t,this.node,e)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function AF(n,t,e,i,r){return EF(i,t,n),new rl(void 0,n,t,e,i,i,i,r,0)}class _m extends rl{constructor(t,e,i,r,o,s,a){super(t,e,i,r,o,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,e,i,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),(0!=this.dirty||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,0))}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,i){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,i)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,i){let r=this.node.cut(t,e),o=document.createTextNode(r.text);return new _m(this.parent,r,this.outerDeco,this.innerDeco,o,o,i)}markDirty(t,e){super.markDirty(t,e),this.dom!=this.nodeDOM&&(0==t||e==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}}class bF extends bh{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class aX extends rl{constructor(t,e,i,r,o,s,a,l,c,u){super(t,e,i,r,o,s,a,c,u),this.spec=l}update(t,e,i,r){if(3==this.dirty)return!1;if(this.spec.update){let o=this.spec.update(t,e,i);return o&&this.updateInner(t,e,i,r),o}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,i,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,i,r){this.spec.setSelection?this.spec.setSelection(t,e,i):super.setSelection(t,e,i,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function yF(n,t,e){let i=n.firstChild,r=!1;for(let o=0;o0;){let a;for(;;)if(i){let c=e.children[i-1];if(!(c instanceof il)){a=c,i--;break}e=c,i=c.children.length}else{if(e==t)break e;i=e.parent.children.indexOf(e),e=e.parent}let l=a.node;if(l){if(l!=n.child(r-1))break;--r,o.set(a,r),s.push(a)}}return{index:r,matched:o,matches:s.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let i=t;i>1,s=Math.min(o,t.length);for(;r-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=il.create(this.top,t[o],e,i);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,o++}}findNodeMatch(t,e,i,r){let s,o=-1;if(r>=this.preMatch.index&&(s=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,i))o=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a=e||u<=t?o.push(l):(ce&&o.push(l.slice(e-c,l.size,i)))}return o}function bv(n,t=null){let e=n.domSelectionRange(),i=n.state.doc;if(!e.focusNode)return null;let r=n.docView.nearestDesc(e.focusNode),o=r&&0==r.size,s=n.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(s<0)return null;let l,c,a=i.resolve(s);if(bm(e)){for(l=a;r&&!r.node;)r=r.parent;let u=r.node;if(r&&u.isAtom&&ce.isSelectable(u)&&r.parent&&(!u.isInline||!function U7(n,t,e){for(let i=0==t,r=t==go(n);i||r;){if(n==e)return!0;let o=Hi(n);if(!(n=n.parentNode))return!1;i=i&&0==o,r=r&&o==go(n)}}(e.focusNode,e.focusOffset,r.dom))){let d=r.posBefore;c=new ce(s==d?a:i.resolve(d))}}else{let u=n.docView.posFromDOM(e.anchorNode,e.anchorOffset,1);if(u<0)return null;l=i.resolve(u)}return c||(c=_v(n,l,a,"pointer"==t||n.state.selection.head{(e.anchorNode!=i||e.anchorOffset!=r)&&(t.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!vF(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const MF=ci||Di&&H7<63;function wF(n,t){let{node:e,offset:i}=n.docView.domFromPos(t,0),r=ir(n,t,e))||Ee.between(t,e,i)}function xF(n){return!(n.editable&&!n.hasFocus())&&TF(n)}function TF(n){let t=n.domSelectionRange();if(!t.anchorNode)return!1;try{return n.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(n.editable||n.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Ev(n,t){let{$anchor:e,$head:i}=n.selection,r=t>0?e.max(i):e.min(i),o=r.parent.inlineContent?r.depth?n.doc.resolve(t>0?r.after():r.before()):null:r;return o&&_e.findFrom(o,t)}function sl(n,t){return n.dispatch(n.state.tr.setSelection(t).scrollIntoView()),!0}function BF(n,t,e){let i=n.state.selection;if(!(i instanceof Ee)){if(i instanceof ce&&i.node.isInline)return sl(n,new Ee(t>0?i.$to:i.$from));{let r=Ev(n.state,t);return!!r&&sl(n,r)}}if(!i.empty||e.indexOf("s")>-1)return!1;if(n.endOfTextblock(t>0?"right":"left")){let r=Ev(n.state,t);return!!(r&&r instanceof ce)&&sl(n,r)}if(!(fr&&e.indexOf("m")>-1)){let s,r=i.$head,o=r.textOffset?null:t<0?r.nodeBefore:r.nodeAfter;if(!o||o.isText)return!1;let a=t<0?r.pos-o.nodeSize:r.pos;return!!(o.isAtom||(s=n.docView.descAt(a))&&!s.contentDOM)&&(ce.isSelectable(o)?sl(n,new ce(t<0?n.state.doc.resolve(r.pos-o.nodeSize):r)):!!ym&&sl(n,new Ee(n.state.doc.resolve(t<0?a:a+o.nodeSize))))}}function Em(n){return 3==n.nodeType?n.nodeValue.length:n.childNodes.length}function _h(n){let t=n.pmViewDesc;return t&&0==t.size&&(n.nextSibling||"BR"!=n.nodeName)}function Cv(n){let t=n.domSelectionRange(),e=t.focusNode,i=t.focusOffset;if(!e)return;let r,o,s=!1;for(Nr&&1==e.nodeType&&i0){if(1!=e.nodeType)break;{let a=e.childNodes[i-1];if(_h(a))r=e,o=--i;else{if(3!=a.nodeType)break;e=a,i=e.nodeValue.length}}}else{if(OF(e))break;{let a=e.previousSibling;for(;a&&_h(a);)r=e.parentNode,o=Hi(a),a=a.previousSibling;if(a)e=a,i=Em(e);else{if(e=e.parentNode,e==n.dom)break;i=0}}}s?Mv(n,e,i):r&&Mv(n,r,o)}function vv(n){let t=n.domSelectionRange(),e=t.focusNode,i=t.focusOffset;if(!e)return;let o,s,r=Em(e);for(;;)if(i{n.state==r&&es(n)},50)}function kF(n,t,e){let i=n.state.selection;if(i instanceof Ee&&!i.empty||e.indexOf("s")>-1||fr&&e.indexOf("m")>-1)return!1;let{$from:r,$to:o}=i;if(!r.parent.inlineContent||n.endOfTextblock(t<0?"up":"down")){let s=Ev(n.state,t);if(s&&s instanceof ce)return sl(n,s)}if(!r.parent.inlineContent){let s=t<0?r:o,a=i instanceof zi?_e.near(s,t):_e.findFrom(s,t);return!!a&&sl(n,a)}return!1}function PF(n,t){if(!(n.state.selection instanceof Ee))return!0;let{$head:e,$anchor:i,empty:r}=n.state.selection;if(!e.sameParent(i))return!0;if(!r)return!1;if(n.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!e.textOffset&&(t<0?e.nodeBefore:e.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return t<0?s.delete(e.pos-o.nodeSize,e.pos):s.delete(e.pos,e.pos+o.nodeSize),n.dispatch(s),!0}return!1}function FF(n,t,e){n.domObserver.stop(),t.contentEditable=e,n.domObserver.start()}function RF(n,t){n.someProp("transformCopied",p=>{t=p(t,n)});let e=[],{content:i,openStart:r,openEnd:o}=t;for(;r>1&&o>1&&1==i.childCount&&1==i.firstChild.childCount;){r--,o--;let p=i.firstChild;e.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),i=p.content}let s=n.someProp("clipboardSerializer")||co.fromSchema(n.state.schema),a=VF(),l=a.createElement("div");l.appendChild(s.serializeFragment(i,{document:a}));let u,c=l.firstChild,d=0;for(;c&&1==c.nodeType&&(u=zF[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let f=a.createElement(u[p]);for(;l.firstChild;)f.appendChild(l.firstChild);l.appendChild(f),d++}c=l.firstChild}return c&&1==c.nodeType&&c.setAttribute("data-pm-slice",`${r} ${o}${d?` -${d}`:""} ${JSON.stringify(e)}`),{dom:l,text:n.someProp("clipboardTextSerializer",p=>p(t,n))||t.content.textBetween(0,t.content.size,"\n\n")}}function NF(n,t,e,i,r){let s,a,o=r.parent.type.spec.code;if(!e&&!t)return null;let l=t&&(i||o||!e);if(l){if(n.someProp("transformPastedText",h=>{t=h(t,o||i,n)}),o)return t?new G(L.from(n.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):G.empty;let d=n.someProp("clipboardTextParser",h=>h(t,r,i,n));if(d)a=d;else{let h=r.marks(),{schema:p}=n.state,f=co.fromSchema(p);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(g=>{let m=s.appendChild(document.createElement("p"));g&&m.appendChild(f.serializeNode(p.text(g,h)))})}}else n.someProp("transformPastedHTML",d=>{e=d(e,n)}),s=function MX(n){let t=/^(\s*]*>)*/.exec(n);t&&(n=n.slice(t[0].length));let r,e=VF().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(n);if((r=i&&zF[i[1].toLowerCase()])&&(n=r.map(o=>"<"+o+">").join("")+n+r.map(o=>""+o+">").reverse().join("")),e.innerHTML=n,r)for(let o=0;o0;d--){let h=s.firstChild;for(;h&&1!=h.nodeType;)h=h.nextSibling;if(!h)break;s=h}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||kc.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!(!l&&!u),context:r,ruleFromNode:h=>"BR"!=h.nodeName||h.nextSibling||!h.parentNode||CX.test(h.parentNode.nodeName)?null:{ignore:!0}})),u)a=function DX(n,t){if(!n.size)return n;let i,e=n.content.firstChild.type.schema;try{i=JSON.parse(t)}catch{return n}let{content:r,openStart:o,openEnd:s}=n;for(let a=i.length-2;a>=0;a-=2){let l=e.nodes[i[a]];if(!l||l.hasRequiredAttrs())break;r=L.from(l.create(i[a+1],r)),o++,s++}return new G(r,o,s)}(jF(a,+u[1],+u[2]),u[4]);else if(a=G.maxOpen(function vX(n,t){if(n.childCount<2)return n;for(let e=t.depth;e>=0;e--){let o,r=t.node(e).contentMatchAt(t.index(e)),s=[];if(n.forEach(a=>{if(!s)return;let c,l=r.findWrapping(a.type);if(!l)return s=null;if(c=s.length&&o.length&&QF(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=UF(s[s.length-1],o.length));let u=LF(a,l);s.push(u),r=r.matchType(u.type),o=l}}),s)return L.from(s)}return n}(a.content,r),!0),a.openStart||a.openEnd){let d=0,h=0;for(let p=a.content.firstChild;d{a=d(a,n)}),a}const CX=/^(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 LF(n,t,e=0){for(let i=t.length-1;i>=e;i--)n=t[i].create(null,L.from(n));return n}function QF(n,t,e,i,r){if(r=e&&(a=t<0?s.contentMatchAt(0).fillBefore(a,n.childCount>1||o<=r).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(L.empty,!0))),n.replaceChild(t<0?0:n.childCount-1,s.copy(a))}function jF(n,t,e){return t{for(let e in t)n.input.eventHandlers[e]||n.dom.addEventListener(e,n.input.eventHandlers[e]=i=>Iv(n,i))})}function Iv(n,t){return n.someProp("handleDOMEvents",e=>{let i=e[t.type];return!!i&&(i(n,t)||t.defaultPrevented)})}function BX(n,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target;e!=n.dom;e=e.parentNode)if(!e||11==e.nodeType||e.pmViewDesc&&e.pmViewDesc.stopEvent(t))return!1;return!0}function Cm(n){return{left:n.clientX,top:n.clientY}}function Sv(n,t,e,i,r){if(-1==i)return!1;let o=n.state.doc.resolve(i);for(let s=o.depth+1;s>0;s--)if(n.someProp(t,a=>s>o.depth?a(n,e,o.nodeAfter,o.before(s),r,!0):a(n,e,o.node(s),o.before(s),r,!1)))return!0;return!1}function $c(n,t,e){n.focused||n.focus();let i=n.state.tr.setSelection(t);"pointer"==e&&i.setMeta("pointer",!0),n.dispatch(i)}function NX(n,t,e,i){return Sv(n,"handleDoubleClickOn",t,e,i)||n.someProp("handleDoubleClick",r=>r(n,t,i))}function LX(n,t,e,i){return Sv(n,"handleTripleClickOn",t,e,i)||n.someProp("handleTripleClick",r=>r(n,t,i))||function QX(n,t,e){if(0!=e.button)return!1;let i=n.state.doc;if(-1==t)return!!i.inlineContent&&($c(n,Ee.create(i,0,i.content.size),"pointer"),!0);let r=i.resolve(t);for(let o=r.depth+1;o>0;o--){let s=o>r.depth?r.nodeAfter:r.node(o),a=r.before(o);if(s.inlineContent)$c(n,Ee.create(i,a+1,a+1+s.content.size),"pointer");else{if(!ce.isSelectable(s))continue;$c(n,ce.create(i,a),"pointer")}return!0}}(n,e,i)}function xv(n){return vm(n)}di.keydown=(n,t)=>{let e=t;if(n.input.shiftKey=16==e.keyCode||e.shiftKey,!YF(n,e)&&(n.input.lastKeyCode=e.keyCode,n.input.lastKeyCodeTime=Date.now(),!mo||!Di||13!=e.keyCode))if(229!=e.keyCode&&n.domObserver.forceFlush(),!Wc||13!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey)n.someProp("handleKeyDown",i=>i(n,e))||function EX(n,t){let e=t.keyCode,i=function _X(n){let t="";return n.ctrlKey&&(t+="c"),n.metaKey&&(t+="m"),n.altKey&&(t+="a"),n.shiftKey&&(t+="s"),t}(t);return 8==e||fr&&72==e&&"c"==i?PF(n,-1)||Cv(n):46==e||fr&&68==e&&"c"==i?PF(n,1)||vv(n):13==e||27==e||(37==e||fr&&66==e&&"c"==i?BF(n,-1,i)||Cv(n):39==e||fr&&70==e&&"c"==i?BF(n,1,i)||vv(n):38==e||fr&&80==e&&"c"==i?kF(n,-1,i)||Cv(n):40==e||fr&&78==e&&"c"==i?function yX(n){if(!ci||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:e}=n.domSelectionRange();if(t&&1==t.nodeType&&0==e&&t.firstChild&&"false"==t.firstChild.contentEditable){let i=t.firstChild;FF(n,i,"true"),setTimeout(()=>FF(n,i,"false"),20)}return!1}(n)||kF(n,1,i)||vv(n):i==(fr?"m":"c")&&(66==e||73==e||89==e||90==e))}(n,e)?e.preventDefault():$s(n,"key");else{let i=Date.now();n.input.lastIOSEnter=i,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==i&&(n.someProp("handleKeyDown",r=>r(n,Yc(13,"Enter"))),n.input.lastIOSEnter=0)},200)}},di.keyup=(n,t)=>{16==t.keyCode&&(n.input.shiftKey=!1)},di.keypress=(n,t)=>{let e=t;if(YF(n,e)||!e.charCode||e.ctrlKey&&!e.altKey||fr&&e.metaKey)return;if(n.someProp("handleKeyPress",r=>r(n,e)))return void e.preventDefault();let i=n.state.selection;if(!(i instanceof Ee&&i.$from.sameParent(i.$to))){let r=String.fromCharCode(e.charCode);n.someProp("handleTextInput",o=>o(n,i.$from.pos,i.$to.pos,r))||n.dispatch(n.state.tr.insertText(r).scrollIntoView()),e.preventDefault()}};const GF=fr?"metaKey":"ctrlKey";ui.mousedown=(n,t)=>{let e=t;n.input.shiftKey=e.shiftKey;let i=xv(n),r=Date.now(),o="singleClick";r-n.input.lastClick.time<500&&function kX(n,t){let e=t.x-n.clientX,i=t.y-n.clientY;return e*e+i*i<100}(e,n.input.lastClick)&&!e[GF]&&("singleClick"==n.input.lastClick.type?o="doubleClick":"doubleClick"==n.input.lastClick.type&&(o="tripleClick")),n.input.lastClick={time:r,x:e.clientX,y:e.clientY,type:o};let s=n.posAtCoords(Cm(e));!s||("singleClick"==o?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new UX(n,s,e,!!i)):("doubleClick"==o?NX:LX)(n,s.pos,s.inside,e)?e.preventDefault():$s(n,"pointer"))};class UX{constructor(t,e,i,r){let o,s;if(this.view=t,this.pos=e,this.event=i,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!i[GF],this.allowDefault=i.shiftKey,e.inside>-1)o=t.state.doc.nodeAt(e.inside),s=e.inside;else{let u=t.state.doc.resolve(e.pos);o=u.parent,s=u.depth?u.before():0}const a=r?null:i.target,l=a?t.docView.nearestDesc(a,!0):null;this.target=l?l.dom:null;let{selection:c}=t.state;(0==i.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||c instanceof ce&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Nr||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)),$s(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(()=>es(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Cm(t))),this.updateAllowDefault(t),this.allowDefault||!e?$s(this.view,"pointer"):function RX(n,t,e,i,r){return Sv(n,"handleClickOn",t,e,i)||n.someProp("handleClick",o=>o(n,t,i))||(r?function FX(n,t){if(-1==t)return!1;let i,r,e=n.state.selection;e instanceof ce&&(i=e.node);let o=n.state.doc.resolve(t);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(ce.isSelectable(a)){r=i&&e.$from.depth>0&&s>=e.$from.depth&&o.before(e.$from.depth+1)==e.$from.pos?o.before(e.$from.depth):o.before(s);break}}return null!=r&&($c(n,ce.create(n.state.doc,r),"pointer"),!0)}(n,e):function PX(n,t){if(-1==t)return!1;let e=n.state.doc.resolve(t),i=e.nodeAfter;return!!(i&&i.isAtom&&ce.isSelectable(i))&&($c(n,new ce(e),"pointer"),!0)}(n,e))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||ci&&this.mightDrag&&!this.mightDrag.node.isAtom||Di&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?($c(this.view,_e.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):$s(this.view,"pointer")}move(t){this.updateAllowDefault(t),$s(this.view,"pointer"),0==t.buttons&&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)}}function YF(n,t){return!!n.composing||!!(ci&&Math.abs(t.timeStamp-n.input.compositionEndedAt)<500)&&(n.input.compositionEndedAt=-2e8,!0)}ui.touchstart=n=>{n.input.lastTouch=Date.now(),xv(n),$s(n,"pointer")},ui.touchmove=n=>{n.input.lastTouch=Date.now(),$s(n,"pointer")},ui.contextmenu=n=>xv(n);const jX=mo?5e3:-1;function WF(n,t){clearTimeout(n.input.composingTimeout),t>-1&&(n.input.composingTimeout=setTimeout(()=>vm(n),t))}function JF(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=function zX(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function vm(n,t=!1){if(!(mo&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),JF(n),t||n.docView&&n.docView.dirty){let e=bv(n);return e&&!e.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(e)):n.updateState(n.state),!0}return!1}}di.compositionstart=di.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:t}=n,e=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!e.textOffset&&e.parentOffset&&e.nodeBefore.marks.some(i=>!1===i.type.spec.inclusive)))n.markCursor=n.state.storedMarks||e.marks(),vm(n,!0),n.markCursor=null;else if(vm(n),Nr&&t.selection.empty&&e.parentOffset&&!e.textOffset&&e.nodeBefore.marks.length){let i=n.domSelectionRange();for(let r=i.focusNode,o=i.focusOffset;r&&1==r.nodeType&&0!=o;){let s=o<0?r.lastChild:r.childNodes[o-1];if(!s)break;if(3==s.nodeType){n.domSelection().collapse(s,s.nodeValue.length);break}r=s,o=-1}}n.input.composing=!0}WF(n,jX)},di.compositionend=(n,t)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=t.timeStamp,WF(n,20))};const qc=wi&&Ws<15||Wc&&V7<604;function Tv(n,t,e,i){let r=NF(n,t,e,n.input.shiftKey,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,r||G.empty)))return!0;if(!r)return!1;let o=function VX(n){return 0==n.openStart&&0==n.openEnd&&1==n.content.childCount?n.content.firstChild:null}(r),s=o?n.state.tr.replaceSelectionWith(o,n.input.shiftKey):n.state.tr.replaceSelection(r);return n.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}ui.copy=di.cut=(n,t)=>{let e=t,i=n.state.selection,r="cut"==e.type;if(i.empty)return;let o=qc?null:e.clipboardData,s=i.content(),{dom:a,text:l}=RF(n,s);o?(e.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):function HX(n,t){if(!n.dom.parentNode)return;let e=n.dom.parentNode.appendChild(document.createElement("div"));e.appendChild(t),e.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),r=document.createRange();r.selectNodeContents(t),n.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e),n.focus()},50)}(n,a),r&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},di.paste=(n,t)=>{let e=t;if(n.composing&&!mo)return;let i=qc?null:e.clipboardData;i&&Tv(n,i.getData("text/plain"),i.getData("text/html"),e)?e.preventDefault():function GX(n,t){if(!n.dom.parentNode)return;let e=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,i=n.dom.parentNode.appendChild(document.createElement(e?"textarea":"div"));e||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{n.focus(),i.parentNode&&i.parentNode.removeChild(i),e?Tv(n,i.value,null,t):Tv(n,i.textContent,i.innerHTML,t)},50)}(n,e)};class YX{constructor(t,e){this.slice=t,this.move=e}}const KF=fr?"altKey":"ctrlKey";ui.dragstart=(n,t)=>{let e=t,i=n.input.mouseDown;if(i&&i.done(),!e.dataTransfer)return;let r=n.state.selection,o=r.empty?null:n.posAtCoords(Cm(e));if(!(o&&o.pos>=r.from&&o.pos<=(r instanceof ce?r.to-1:r.to)))if(i&&i.mightDrag)n.dispatch(n.state.tr.setSelection(ce.create(n.state.doc,i.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){let c=n.docView.nearestDesc(e.target,!0);c&&c.node.type.spec.draggable&&c!=n.docView&&n.dispatch(n.state.tr.setSelection(ce.create(n.state.doc,c.posBefore)))}let s=n.state.selection.content(),{dom:a,text:l}=RF(n,s);e.dataTransfer.clearData(),e.dataTransfer.setData(qc?"Text":"text/html",a.innerHTML),e.dataTransfer.effectAllowed="copyMove",qc||e.dataTransfer.setData("text/plain",l),n.dragging=new YX(s,!e[KF])},ui.dragend=n=>{let t=n.dragging;window.setTimeout(()=>{n.dragging==t&&(n.dragging=null)},50)},di.dragover=di.dragenter=(n,t)=>t.preventDefault(),di.drop=(n,t)=>{let e=t,i=n.dragging;if(n.dragging=null,!e.dataTransfer)return;let r=n.posAtCoords(Cm(e));if(!r)return;let o=n.state.doc.resolve(r.pos),s=i&&i.slice;s?n.someProp("transformPasted",f=>{s=f(s,n)}):s=NF(n,e.dataTransfer.getData(qc?"Text":"text/plain"),qc?null:e.dataTransfer.getData("text/html"),!1,o);let a=!(!i||e[KF]);if(n.someProp("handleDrop",f=>f(n,e,s||G.empty,a)))return void e.preventDefault();if(!s)return;e.preventDefault();let l=s?Kk(n.state.doc,o.pos,s):o.pos;null==l&&(l=o.pos);let c=n.state.tr;a&&c.deleteSelection();let u=c.mapping.map(l),d=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,h=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(h))return;let p=c.doc.resolve(u);if(d&&ce.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new ce(p));else{let f=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((g,m,A,y)=>f=y),c.setSelection(_v(n,p,c.doc.resolve(f)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},ui.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&es(n)},20))},ui.blur=(n,t)=>{let e=t;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),e.relatedTarget&&n.dom.contains(e.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},ui.beforeinput=(n,t)=>{if(Di&&mo&&"deleteContentBackward"==t.inputType){n.domObserver.flushSoon();let{domChangeCount:i}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=i||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,Yc(8,"Backspace")))))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in di)ui[n]=di[n];function Eh(n,t){if(n==t)return!0;for(let e in n)if(n[e]!==t[e])return!1;for(let e in t)if(!(e in n))return!1;return!0}class Bv{constructor(t,e){this.toDOM=t,this.spec=e||al,this.side=this.spec.side||0}map(t,e,i,r){let{pos:o,deleted:s}=t.mapResult(e.from+r,this.side<0?-1:1);return s?null:new wn(o-i,o-i,this)}valid(){return!0}eq(t){return this==t||t instanceof Bv&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Eh(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class qs{constructor(t,e){this.attrs=t,this.spec=e||al}map(t,e,i,r){let o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-i,s=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-i;return o>=s?null:new wn(o,s,this)}valid(t,e){return e.from=t&&(!o||o(a.spec))&&i.push(a.copy(a.from+r,a.to+r))}for(let s=0;st){let a=this.children[s]+1;this.children[s+2].findInner(t-a,e-a,i,r+a,o)}}map(t,e,i){return this==qn||0==t.maps.length?this:this.mapInner(t,e,0,0,i||al)}mapInner(t,e,i,r,o){let s;for(let a=0;a{let m=g-f-(p-h);for(let A=0;Ay+u-d)continue;let E=a[A]+u-d;p>=E?a[A+1]=h<=E?-2:-1:f>=r&&m&&(a[A]+=m,a[A+1]+=m)}d+=m}),u=e.maps[c].map(u,-1)}let l=!1;for(let c=0;c=i.content.size){l=!0;continue}let p=e.map(n[c+1]+o,-1)-r,{index:f,offset:g}=i.content.findIndex(d),m=i.maybeChild(f);if(m&&g==d&&g+m.nodeSize==p){let A=a[c+2].mapInner(e,m,u+1,n[c]+o+1,s);A!=qn?(a[c]=d,a[c+1]=p,a[c+2]=A):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=function JX(n,t,e,i,r,o,s){function a(l,c){for(let u=0;u{let u,c=l+i;if(u=qF(e,a,c)){for(r||(r=this.children.slice());oa&&d.to=t){this.children[a]==t&&(i=this.children[a+2]);break}let o=t+1,s=o+e.content.size;for(let a=0;ao&&l.type instanceof qs){let c=Math.max(o,l.from)-o,u=Math.min(s,l.to)-o;cr.map(t,e,al));return Xs.from(i)}forChild(t,e){if(e.isLeaf)return kt.empty;let i=[];for(let r=0;re instanceof kt)?t:t.reduce((e,i)=>e.concat(i instanceof kt?i:i.members),[]))}}}function $F(n,t){if(!t||!n.length)return n;let e=[];for(let i=0;ie&&s.to{let c=qF(n,a,l+e);if(c){o=!0;let u=Mm(c,a,e+l+1,i);u!=qn&&r.push(l,l+a.nodeSize,u)}});let s=$F(o?XF(n):n,-e).sort(ll);for(let a=0;a0;)t++;n.splice(t,0,e)}function Pv(n){let t=[];return n.someProp("decorations",e=>{let i=e(n.state);i&&i!=qn&&t.push(i)}),n.cursorWrapper&&t.push(kt.create(n.state.doc,[n.cursorWrapper.deco])),Xs.from(t)}const KX={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},$X=wi&&Ws<=11;class qX{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 XX{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new qX,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let r=0;r"childList"==r.type&&r.removedNodes.length||"characterData"==r.type&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),$X&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,KX)),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 e=0;ethis.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(xF(this.view)){if(this.suppressingSelectionUpdates)return es(this.view);if(wi&&Ws<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&nl(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 i,e=new Set;for(let o=t.focusNode;o;o=mh(o))e.add(o);for(let o=t.anchorNode;o;o=mh(o))if(e.has(o)){i=o;break}let r=i&&this.view.docView.nearestDesc(i);return r&&r.ignoreMutation({type:"selection",target:3==i.nodeType?i.parentNode:i})?(this.setCurSelection(),!0):void 0}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.observer?this.observer.takeRecords():[];this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);let i=t.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&xF(t)&&!this.ignoreSelectionChange(i),o=-1,s=-1,a=!1,l=[];if(t.editable)for(let u=0;u1){let u=l.filter(d=>"BR"==d.nodeName);if(2==u.length){let d=u[0],h=u[1];d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}}let c=null;o<0&&r&&t.input.lastFocus>Date.now()-200&&t.input.lastTouch-1||r)&&(o>-1&&(t.docView.markDirty(o,s),function ZX(n){if(!eR.has(n)&&(eR.set(n,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace))){if(n.requiresGeckoHackNode=Nr,tR)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),tR=!0}}(t)),this.handleDOMChange(o,s,a,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(i)||es(t),this.currentSelection.set(i))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let i=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(i==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style"))||!i||i.ignoreMutation(t))return null;if("childList"==t.type){for(let u=0;ut.content.size?null:_v(n,t.resolve(e.anchor),t.resolve(e.head))}function Fv(n,t,e){let i=n.depth,r=t?n.end():n.pos;for(;i>0&&(t||n.indexAfter(i)==n.node(i).childCount);)i--,r++,t=!1;if(e){let o=n.node(i).maybeChild(n.indexAfter(i));for(;o&&!o.isLeaf;)o=o.firstChild,r++}return r}class aZ{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new SX,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(aR),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=oR(this),rR(this),this.nodeViews=sR(this),this.docView=AF(this.state.doc,iR(this),Pv(this),this.dom,this),this.domObserver=new XX(this,(i,r,o,s)=>function iZ(n,t,e,i,r){if(t<0){let O=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,q=bv(n,O);if(q&&!n.state.selection.eq(q)){let le=n.state.tr.setSelection(q);"pointer"==O?le.setMeta("pointer",!0):"key"==O&&le.scrollIntoView(),n.dispatch(le)}return}let o=n.state.doc.resolve(t),s=o.sharedDepth(e);t=o.before(s+1),e=n.state.doc.resolve(e).after(s+1);let d,h,a=n.state.selection,l=function tZ(n,t,e){let c,{node:i,fromOffset:r,toOffset:o,from:s,to:a}=n.docView.parseRange(t,e),l=n.domSelectionRange(),u=l.anchorNode;if(u&&n.dom.contains(1==u.nodeType?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],bm(l)||c.push({node:l.focusNode,offset:l.focusOffset})),Di&&8===n.input.lastKeyCode)for(let m=o;m>r;m--){let A=i.childNodes[m-1],y=A.pmViewDesc;if("BR"==A.nodeName&&!y){o=m;break}if(!y||y.size)break}let d=n.state.doc,h=n.someProp("domParser")||kc.fromSchema(n.state.schema),p=d.resolve(s),f=null,g=h.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:r,to:o,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:c,ruleFromNode:nZ,context:p});if(c&&null!=c[0].pos){let m=c[0].pos,A=c[1]&&c[1].pos;null==A&&(A=m),f={anchor:m+s,head:A+s}}return{doc:g,sel:f,from:s,to:a}}(n,t,e),c=n.state.doc,u=c.slice(l.from,l.to);8===n.input.lastKeyCode&&Date.now()-100=s?o-i:0,a=o+(a-s),s=o):a=a?o-i:0,s=o+(s-a),a=o),{start:o,endA:s,endB:a}}(u.content,l.doc.content,l.from,d,h);if((Wc&&n.input.lastIOSEnter>Date.now()-225||mo)&&r.some(O=>"DIV"==O.nodeName||"P"==O.nodeName||"LI"==O.nodeName)&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",O=>O(n,Yc(13,"Enter"))))return void(n.input.lastIOSEnter=0);if(!p){if(!(i&&a instanceof Ee&&!a.empty&&a.$head.sameParent(a.$anchor))||n.composing||l.sel&&l.sel.anchor!=l.sel.head){if(l.sel){let O=nR(n,n.state.doc,l.sel);O&&!O.eq(n.state.selection)&&n.dispatch(n.state.tr.setSelection(O))}return}p={start:a.from,endA:a.to,endB:a.to}}if(Di&&n.cursorWrapper&&l.sel&&l.sel.anchor==n.cursorWrapper.deco.from&&l.sel.head==l.sel.anchor){let O=p.endB-p.start;l.sel={anchor:l.sel.anchor+O,head:l.sel.anchor+O}}n.input.domChangeCount++,n.state.selection.fromn.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=l.from?p.start=n.state.selection.from:p.endA=n.state.selection.to-2&&n.state.selection.to<=l.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),wi&&Ws<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>l.from&&" \xa0"==l.doc.textBetween(p.start-l.from-1,p.start-l.from+1)&&(p.start--,p.endA--,p.endB--);let y,f=l.doc.resolveNoCache(p.start-l.from),g=l.doc.resolveNoCache(p.endB-l.from),m=c.resolve(p.start),A=f.sameParent(g)&&f.parent.inlineContent&&m.end()>=p.endA;if((Wc&&n.input.lastIOSEnter>Date.now()-225&&(!A||r.some(O=>"DIV"==O.nodeName||"P"==O.nodeName))||!A&&f.posO(n,Yc(13,"Enter"))))return void(n.input.lastIOSEnter=0);if(n.state.selection.anchor>p.start&&function oZ(n,t,e,i,r){if(!i.parent.isTextblock||e-t<=r.pos-i.pos||Fv(i,!0,!1)e||Fv(s,!0,!1)O(n,Yc(8,"Backspace"))))return void(mo&&Di&&n.domObserver.suppressSelectionUpdates());Di&&mo&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),mo&&!A&&f.start()!=g.start()&&0==g.parentOffset&&f.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==p.endA&&(p.endB-=2,g=l.doc.resolveNoCache(p.endB-l.from),setTimeout(()=>{n.someProp("handleKeyDown",function(O){return O(n,Yc(13,"Enter"))})},20));let D,I,Q,E=p.start,b=p.endA;if(A)if(f.pos==g.pos)wi&&Ws<=11&&0==f.parentOffset&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>es(n),20)),D=n.state.tr.delete(E,b),I=c.resolve(p.start).marksAcross(c.resolve(p.endA));else if(p.endA==p.endB&&(Q=function rZ(n,t){let s,a,l,e=n.firstChild.marks,i=t.firstChild.marks,r=e,o=i;for(let u=0;uu.mark(a.addToSet(u.marks));else{if(0!=r.length||1!=o.length)return null;a=o[0],s="remove",l=u=>u.mark(a.removeFromSet(u.marks))}let c=[];for(let u=0;uq(n,E,b,O)))return;D=n.state.tr.insertText(O,E,b)}if(D||(D=n.state.tr.replace(E,b,l.doc.slice(p.start-l.from,p.endB-l.from))),l.sel){let O=nR(n,D.doc,l.sel);O&&!(Di&&mo&&n.composing&&O.empty&&(p.start!=p.endB||n.input.lastAndroidDelete{BX(n,i)&&!Iv(n,i)&&(n.editable||!(i.type in di))&&e(n,i)},IX[t]?{passive:!0}:void 0)}ci&&n.dom.addEventListener("input",()=>null),Dv(n)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Dv(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(aR),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let i in this._props)e[i]=this._props[i];e.state=this.state;for(let i in t)e[i]=t[i];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){let i=this.state,r=!1,o=!1;t.storedMarks&&this.composing&&(JF(this),o=!0),this.state=t;let s=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let h=sR(this);(function cZ(n,t){let e=0,i=0;for(let r in n){if(n[r]!=t[r])return!0;e++}for(let r in t)i++;return e!=i})(h,this.nodeViews)&&(this.nodeViews=h,r=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&Dv(this),this.editable=oR(this),rR(this);let a=Pv(this),l=iR(this),c=i.plugins==t.plugins||i.doc.eq(t.doc)?t.scrollToSelection>i.scrollToSelection?"to selection":"preserve":"reset",u=r||!this.docView.matchesNode(t.doc,l,a);(u||!t.selection.eq(i.selection))&&(o=!0);let d="preserve"==c&&o&&null==this.dom.style.overflowAnchor&&function W7(n){let i,r,t=n.dom.getBoundingClientRect(),e=Math.max(0,t.top);for(let o=(t.left+t.right)/2,s=e+1;s=e-20){i=a,r=l.top;break}}return{refDOM:i,refTop:r,stack:sF(n.dom)}}(this);if(o){this.domObserver.stop();let h=u&&(wi||Di)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&function lZ(n,t){let e=Math.min(n.$anchor.sharedDepth(n.head),t.$anchor.sharedDepth(t.head));return n.$anchor.start(e)!=t.$anchor.start(e)}(i.selection,t.selection);if(u){let p=Di?this.trackWrites=this.domSelectionRange().focusNode:null;(r||!this.docView.update(t.doc,l,a,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=AF(t.doc,l,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function bX(n){let t=n.docView.domFromPos(n.state.selection.anchor,0),e=n.domSelectionRange();return nl(t.node,t.offset,e.anchorNode,e.anchorOffset)}(this))?es(this,h):(IF(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():d&&function J7({refDOM:n,refTop:t,stack:e}){let i=n?n.getBoundingClientRect().top:0;aF(e,0==i?0:i-t)}(d)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",e=>e(this)))if(this.state.selection instanceof ce){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&oF(this,e.getBoundingClientRect(),t)}else oF(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;ee.ownerDocument.getSelection()),this._root=e;return t||document}posAtCoords(t){return eX(this,t)}coordsAtPos(t,e=1){return uF(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,i=-1){let r=this.docView.posFromDOM(t,e,i);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return function oX(n,t,e){return hF==t&&pF==e?fF:(hF=t,pF=e,fF="up"==e||"down"==e?function nX(n,t,e){let i=t.selection,r="up"==e?i.$from:i.$to;return dF(n,t,()=>{let{node:o}=n.docView.domFromPos(r.pos,"up"==e?-1:1);for(;;){let a=n.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.dom;break}o=a.dom.parentNode}let s=uF(n,r.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(1==a.nodeType)l=a.getClientRects();else{if(3!=a.nodeType)continue;l=Zo(a,0,a.nodeValue.length).getClientRects()}for(let c=0;cu.top+1&&("up"==e?s.top-u.top>2*(u.bottom-s.top):u.bottom-s.bottom>2*(s.bottom-u.top)))return!1}}return!0})}(n,t,e):function rX(n,t,e){let{$head:i}=t.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,o=!r,s=r==i.parent.content.size,a=n.domSelection();return iX.test(i.parent.textContent)&&a.modify?dF(n,t,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",e,"character");let p=i.depth?n.docView.domAfterPos(i.before()):n.dom,{focusNode:f,focusOffset:g}=n.domSelectionRange(),m=f&&!p.contains(1==f.nodeType?f:f.parentNode)||l==f&&c==g;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return null!=h&&(a.caretBidiLevel=h),m}):"left"==e||"backward"==e?o:s}(n,t,e))}(this,e||this.state,t)}destroy(){!this.docView||(function TX(n){n.domObserver.stop();for(let t in n.input.eventHandlers)n.dom.removeEventListener(t,n.input.eventHandlers[t]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Pv(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function OX(n,t){!Iv(n,t)&&ui[t.type]&&(n.editable||!(t.type in di))&&ui[t.type](n,t)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){return ci&&11===this.root.nodeType&&function z7(n){let t=n.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom?function eZ(n){let t;function e(l){l.preventDefault(),l.stopImmediatePropagation(),t=l.getTargetRanges()[0]}n.dom.addEventListener("beforeinput",e,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",e,!0);let i=t.startContainer,r=t.startOffset,o=t.endContainer,s=t.endOffset,a=n.domAtPos(n.state.selection.anchor);return nl(a.node,a.offset,o,s)&&([i,r,o,s]=[o,s,i,r]),{anchorNode:i,anchorOffset:r,focusNode:o,focusOffset:s}}(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function iR(n){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(n.editable),t.translate="no",n.someProp("attributes",e=>{if("function"==typeof e&&(e=e(n.state)),e)for(let i in e)"class"==i&&(t.class+=" "+e[i]),"style"==i?t.style=(t.style?t.style+";":"")+e[i]:!t[i]&&"contenteditable"!=i&&"nodeName"!=i&&(t[i]=String(e[i]))}),[wn.node(0,n.state.doc.content.size,t)]}function rR(n){if(n.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),n.cursorWrapper={dom:t,deco:wn.widget(n.state.selection.head,t,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function oR(n){return!n.someProp("editable",t=>!1===t(n.state))}function sR(n){let t=Object.create(null);function e(i){for(let r in i)Object.prototype.hasOwnProperty.call(t,r)||(t[r]=i[r])}return n.someProp("nodeViews",e),n.someProp("markViews",e),t}function aR(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var Zs={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},wm={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},lR=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),uZ=(typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),typeof navigator<"u"&&/Mac/.test(navigator.platform)),dZ=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),hZ=uZ||lR&&+lR[1]<57,Bn=0;Bn<10;Bn++)Zs[48+Bn]=Zs[96+Bn]=String(Bn);for(Bn=1;Bn<=24;Bn++)Zs[Bn+111]="F"+Bn;for(Bn=65;Bn<=90;Bn++)Zs[Bn]=String.fromCharCode(Bn+32),wm[Bn]=String.fromCharCode(Bn);for(var Rv in Zs)wm.hasOwnProperty(Rv)||(wm[Rv]=Zs[Rv]);const fZ=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function gZ(n){let i,r,o,s,t=n.split(/-(?!$)/),e=t[t.length-1];"Space"==e&&(e=" ");for(let a=0;a127)&&(s=Zs[i.keyCode])&&s!=r){let l=t[Nv(s,i,!0)];if(l&&l(e.state,e.dispatch,e))return!0}else if(o&&i.shiftKey){let l=t[Nv(r,i,!0)];if(l&&l(e.state,e.dispatch,e))return!0}return!1}}const Qv=(n,t)=>!n.selection.empty&&(t&&t(n.tr.deleteSelection().scrollIntoView()),!0);const uR=(n,t,e)=>{let i=function cR(n,t){let{$cursor:e}=n.selection;return!e||(t?!t.endOfTextblock("backward",n):e.parentOffset>0)?null:e}(n,e);if(!i)return!1;let r=Uv(i);if(!r){let s=i.blockRange(),a=s&&Rc(s);return null!=a&&(t&&t(n.tr.lift(s,a).scrollIntoView()),!0)}let o=r.nodeBefore;if(!o.type.spec.isolating&&ER(n,r,t))return!0;if(0==i.parent.content.size&&(Zc(o,"end")||ce.isSelectable(o))){let s=QC(n.doc,i.before(),i.after(),G.empty);if(s&&s.slice.size{let{$head:i,empty:r}=n.selection,o=i;if(!r)return!1;if(i.parent.isTextblock){if(e?!e.endOfTextblock("backward",n):i.parentOffset>0)return!1;o=Uv(i)}let s=o&&o.nodeBefore;return!(!s||!ce.isSelectable(s)||(t&&t(n.tr.setSelection(ce.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),0))};function Uv(n){if(!n.parent.type.spec.isolating)for(let t=n.depth-1;t>=0;t--){if(n.index(t)>0)return n.doc.resolve(n.before(t+1));if(n.node(t).type.spec.isolating)break}return null}const fR=(n,t,e)=>{let i=function pR(n,t){let{$cursor:e}=n.selection;return!e||(t?!t.endOfTextblock("forward",n):e.parentOffset{let{$head:i,empty:r}=n.selection,o=i;if(!r)return!1;if(i.parent.isTextblock){if(e?!e.endOfTextblock("forward",n):i.parentOffset=0;t--){let e=n.node(t);if(n.index(t)+1{let{$head:e,$anchor:i}=n.selection;return!(!e.parent.type.spec.code||!e.sameParent(i)||(t&&t(n.tr.insertText("\n").scrollIntoView()),0))};function zv(n){for(let t=0;t