"use strict";function ce(n){this.content=n}ce.prototype={constructor:ce,find:function(n){for(var e=0;e>1}};ce.from=function(n){if(n instanceof ce)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ce(e)};function Sl(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=Sl(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function wl(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){t-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:t,b:r};if(o.isText&&o.text!=a.text){let c=0,u=Math.min(o.text.length,a.text.length);for(;ce&&r(l,i+a,s||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,t-u),r,i+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(a,l)=>{a.isText?(s+=a.text.slice(Math.max(e,l)-l,t-l),o=!r):a.isLeaf?(i?s+=typeof i=="function"?i(a):i:a.type.spec.leafText&&(s+=a.type.spec.leafText(a)),o=!r):!o&&a.isBlock&&(s+=r,o=!0)},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);se)for(let s=0,o=0;oe&&((ot)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,t-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,t-o-1))),r.push(a),i+=a.nodeSize),o=l}return new S(r,i)}cutByIndex(e,t){return e==t?S.empty:e==0&&t==this.content.length?this:new S(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new S(i,s)}addToStart(e){return new S([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new S(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let s=this.child(r),o=i+s.nodeSize;if(o>=e)return o==e||t>0?Lr(r+1,o):Lr(r,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return S.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new S(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return S.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};U.none=[];class Xr extends Error{}class O{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Cl(this.content,e+this.openStart,t);return r&&new O(r,this.openStart,this.openEnd)}removeBetween(e,t){return new O(Ml(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return O.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new O(S.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new O(e,r,i)}}O.empty=new O(S.empty,0,0);function Ml(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:a}=n.findIndex(t);if(i==e||s.isText){if(a!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Ml(s.content,e-i-1,t-i-1)))}function Cl(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let a=Cl(o.content,e-s-1,t);return a&&n.replaceChild(i,o.copy(a))}function Cu(n,e,t){if(t.openStart>n.depth)throw new Xr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Xr("Inconsistent open depths");return Ol(n,e,t,0)}function Ol(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Yn(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Jt(n.nodeAfter,r),s++));for(let a=s;ai&&Ms(n,e,i+1),o=r.depth>i&&Ms(t,r,i+1),a=[];return Yn(null,n,i,a),s&&o&&e.index(i)==t.index(i)?(Tl(s,o),Jt(_t(s,El(n,e,t,r,i+1)),a)):(s&&Jt(_t(s,Qr(n,e,i+1)),a),Yn(e,t,i,a),o&&Jt(_t(o,Qr(t,r,i+1)),a)),Yn(r,null,i,a),new S(a)}function Qr(n,e,t){let r=[];if(Yn(null,n,t,r),n.depth>t){let i=Ms(n,e,t+1);Jt(_t(i,Qr(n,e,t+1)),r)}return Yn(e,null,t,r),new S(r)}function Ou(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(S.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class ar{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Zr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),c=s-l;if(r.push(o,a,i+l),!c||(o=o.child(a),o.isText))break;s=c-1,i+=l+1}return new ar(t,r,s)}static resolveCached(e,t){for(let i=0;ie&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Al(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=S.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=i;lt.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=S.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};Gt.prototype.text=void 0;class ei extends Gt{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Al(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new ei(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ei(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Al(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Zt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Au(e,t);if(r.next==null)return Zt.empty;let i=Nl(r);r.next&&r.err("Unexpected trailing text");let s=Bu(Lu(i));return zu(s,r),s}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return s}).join(` `)}}Zt.empty=new Zt(!0);class Au{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Nl(n){let e=[];do e.push(Nu(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Nu(n){let e=[];do e.push(Du(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Du(n){let e=Pu(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Iu(n,e);else break;return e}function Fo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Iu(n,e){let t=Fo(n),r=t;return n.eat(",")&&(n.next!="}"?r=Fo(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Ru(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Pu(n){if(n.eat("(")){let e=Nl(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Ru(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Lu(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,a,l){let c={term:l,to:a};return e[o].push(c),c}function i(o,a){o.forEach(l=>l.to=a)}function s(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(s(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=s(o.exprs[l],a);if(l==o.exprs.length-1)return c;i(c,a=t())}else if(o.type=="star"){let l=t();return r(a,l),i(s(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=t();return i(s(o.expr,a),l),i(s(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(s(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c{n[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u{c||i.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Zt(r.indexOf(n.length-1)>-1);for(let o=0;o-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[s]=new Ll(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class Hu{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Ei{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Pl(i.attrs),this.excluded=null;let s=Il(this.attrs);this.instance=s?new U(this,s):null}create(e=null){return!e&&this.instance?this.instance:new U(this,Rl(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new Ei(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t-1}}class Fu{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=ce.from(e.nodes),t.marks=ce.from(e.marks||{}),this.nodes=Vo.compile(this.spec.nodes,this),this.marks=Ei.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",a=s.spec.marks;s.contentMatch=r[o]||(r[o]=Zt.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.markSet=a=="_"?null:a?jo(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:jo(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Vo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new ei(r,r.defaultAttrs,e,U.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Gt.fromJSON(this,e)}markFromJSON(e){return U.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function jo(n,e){let t=[];for(let r=0;r-1)&&t.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}class Tn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new qo(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new qo(this,t,!0);return r.addAll(e,t.from,t.to),O.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o{r(o=Ko(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Ko(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Tn(e,Tn.schemaRules(e)))}}const Bl={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},$u={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},zl={ol:!0,ul:!0},ti=1,ni=2,Xn=4;function Wo(n,e,t){return e!=null?(e?ti:0)|(e==="full"?ni:0):n&&n.whitespace=="pre"?ti|ni:t&~Xn}class Br{constructor(e,t,r,i,s,o,a){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=i,this.solid=s,this.options=a,this.content=[],this.activeMarks=U.none,this.stashMarks=[],this.match=o||(a&Xn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ti)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;tthis.addAll(e)),o&&this.sync(a),this.needsBlock=l}else this.withStyleRules(e,()=>{this.addElementByRule(e,s,s.consuming===!1?i:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` `))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=U.none,r=U.none;for(let i=0;i{o.clearMark(a)&&(r=a.addToSet(r))}):t=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(t),o.consuming===!1)s=o;else break}return[t,r]}addElementByRule(e,t,r){let i,s,o;t.node?(s=this.parser.schema.nodes[t.node],s.isLeaf?this.insertNode(s.create(t.attrs))||this.leafFallback(e):i=this.enter(s,t.attrs||null,t.preserveWhitespace)):(o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o));let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l)}i&&this.sync(a)&&this.open--,o&&this.removePendingMark(o,a)}addAll(e,t,r){let i=t||0;for(let s=t?e.childNodes[t]:e.firstChild,o=r==null?null:e.childNodes[r];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s);this.findAtPoint(e,i)}findPlace(e){let t,r;for(let i=this.open;i>=0;i--){let s=this.nodes[i],o=s.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,r=s,!o.length)||s.solid)break}if(!t)return!1;this.sync(r);for(let i=0;ithis.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=s;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!u||u.name!=c&&u.groups.indexOf(c)==-1)return!1;l--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=Ku(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let o=i.popFromStashMark(e);o&&i.type&&i.type.allowsMarkType(o.type)&&(i.activeMarks=o.addToSet(i.activeMarks))}if(i==t)break}}}function Vu(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&zl.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function ju(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Wu(n){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,t,r=[];for(;t=e.exec(n);)r.push(t[1],t[2].trim());return r}function Ko(n){let e={};for(let t in n)e[t]=n[t];return e}function qu(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=a=>{s.push(a);for(let l=0;l{if(s.length||o.marks.length){let a=0,l=0;for(;a=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Qe.renderSpec(_i(r),i(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],s=i.indexOf(" ");s>0&&(r=i.slice(0,s),i=i.slice(s+1));let o,a=r?e.createElementNS(r,i):e.createElement(i),l=t[1],c=1;if(l&&typeof l=="object"&&l.nodeType==null&&!Array.isArray(l)){c=2;for(let u in l)if(l[u]!=null){let d=u.indexOf(" ");d>0?a.setAttributeNS(u.slice(0,d),u.slice(d+1),l[u]):a.setAttribute(u,l[u])}}for(let u=c;uc)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:h}=Qe.renderSpec(e,d,r);if(a.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:a,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Qe(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Uo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Uo(e.marks)}}function Uo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function _i(n){return n.document||window.document}const Hl=65535,Fl=Math.pow(2,16);function Uu(n,e){return n+e*Fl}function Jo(n){return n&Hl}function Ju(n){return(n-(n&Hl))/Fl}const $l=1,Vl=2,qr=4,jl=8;class Os{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&jl)>0}get deletedBefore(){return(this.delInfo&($l|qr))>0}get deletedAfter(){return(this.delInfo&(Vl|qr))>0}get deletedAcross(){return(this.delInfo&qr)>0}}class Ae{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ae.empty)return Ae.empty}recover(e){let t=0,r=Jo(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[a+s],u=this.ranges[a+o],d=l+c;if(e<=d){let f=c?e==l?-1:e==d?1:t:t,h=l+i+(f<0?0:u);if(r)return h;let p=e==(t<0?l:d)?null:Uu(a/3,e-l),m=e==l?Vl:e==d?$l:qr;return(t<0?e!=l:e!=d)&&(m|=jl),new Os(h,m,p)}i+=u-c}return r?e+i:new Os(e+i,0,null)}touches(e,t){let r=0,i=Jo(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;ae)break;let c=this.ranges[a+s],u=l+c;if(e<=u&&a==i*3)return!0;r+=this.ranges[a+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new wn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;rs&&l!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return te.fromReplace(e,this.from,this.to,s)}invert(){return new Ze(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Mt(t.pos,r.pos,this.mark)}merge(e){return e instanceof Mt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Mt(t.from,t.to,e.markFromJSON(t.mark))}}ye.jsonID("addMark",Mt);class Ze extends ye{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new O(eo(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return te.fromReplace(e,this.from,this.to,r)}invert(){return new Mt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ze(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ze&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ze(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ze(t.from,t.to,e.markFromJSON(t.mark))}}ye.jsonID("removeMark",Ze);class Ct extends ye{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return te.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return te.fromReplace(e,this.pos,this.pos+1,new O(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new oe(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new oe(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}}ye.jsonID("replaceAround",oe);function Ts(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function _u(n,e,t,r){let i=[],s=[],o,a;n.doc.nodesBetween(e,t,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+l.nodeSize,t),p=r.addToSet(d);for(let m=0;mn.step(l)),s.forEach(l=>n.step(l))}function Gu(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,a)=>{if(!o.isInline)return;s++;let l=null;if(r instanceof Ei){let c=o.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let c=Math.min(a+o.nodeSize,t);for(let u=0;un.step(new Ze(o.from,o.to,o.style)))}function Yu(n,e,t,r=t.contentMatch){let i=n.doc.nodeAt(e),s=[],o=e+1;for(let a=0;a=0;a--)n.step(s[a])}function Xu(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Hn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),o=n.$to.indexAfter(r);if(rt;p--)m||r.index(p)>0?(m=!0,u=S.from(r.node(p).copy(u)),d++):l--;let f=S.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)=0;o--){if(r.size){let a=t[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=S.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new oe(i,s,i,s,new O(r,0,0),t.length,!0))}function nd(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,a)=>{if(o.isTextblock&&!o.hasMarkup(r,i)&&rd(n.doc,n.mapping.slice(s).map(a),r)){n.clearIncompatible(n.mapping.slice(s).map(a,1),r);let l=n.mapping.slice(s),c=l.map(a,1),u=l.map(a+o.nodeSize,1);return n.step(new oe(c,u,c+1,u-1,new O(S.from(r.create(i,null,o.marks)),0,0),1,!0)),!1}})}function rd(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function id(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new oe(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new O(S.from(o),0,0),1,!0))}function Mn(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function sd(n,e,t=1,r){let i=n.doc.resolve(e),s=S.empty,o=S.empty;for(let a=i.depth,l=i.depth-t,c=t-1;a>l;a--,c--){s=S.from(i.node(a).copy(s));let u=r&&r[c];o=S.from(u?u.type.create(u.attrs,o):i.node(a).copy(o))}n.step(new ue(e,e,new O(s.append(o),t,t),!0))}function Rt(n,e){let t=n.resolve(e),r=t.index();return Wl(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Wl(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function Ai(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,o,a=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):t>0?(s=r.node(i+1),a++,o=r.node(i).maybeChild(a)):(s=r.node(i).maybeChild(a-1),o=r.node(i+1)),s&&!s.isTextblock&&Wl(s,o)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function od(n,e,t){let r=new ue(e-t,e+t,O.empty,!0);n.step(r)}function ad(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(l,l,i);else{let d=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}function no(n,e,t=e,r=O.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return Kl(i,s,r)?new ue(e,t,r):new ld(i,s,r).fit()}function Kl(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class ld{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=S.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=S.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,a=i.depth;for(;o&&a&&s.childCount==1;)s=s.firstChild.content,o--,a--;let l=new O(s,o,a);return e>-1?new oe(r.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||r.pos!=this.$to.pos?new ue(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Yi(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(t==1&&(o?c.matchType(o.type)||(d=c.fillBefore(S.from(o),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:d};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Yi(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new O(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Yi(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new O(Jn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new O(Jn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m1||l==0||m.content.size)&&(d=g,u.push(Ul(m.mark(f.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?h:-1)))}let p=c==a.childCount;p||(h=-1),this.placed=_n(this.placed,t,S.from(u)),this.frontier[t].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t=0;a--){let{match:l,type:c}=this.frontier[a],u=Xi(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=_n(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=_n(this.placed,this.depth,S.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=_n(this.placed,this.frontier.length,t))}}function Jn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Jn(n.firstChild.content,e-1,t)))}function _n(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(_n(n.lastChild.content,e-1,t)))}function Yi(n,e){for(let t=0;t1&&(r=r.replaceChild(0,Ul(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(S.empty,!0)))),n.copy(r)}function Xi(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!cd(t,s.content,o)?a:null}function cd(n,e,t){for(let r=t;r0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?a=f:i.before(f)==h&&o.splice(1,0,-f)}let l=o.indexOf(a),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=ud(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(a)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function Jl(n,e,t,r,i){if(er){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(S.empty,!0))}return n}function fd(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=ad(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new O(S.from(r),0,0))}function hd(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=_l(r,i);for(let o=0;o0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return n.delete(r.before(a),i.after(a))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o)return n.delete(r.before(o),t);n.delete(e,t)}function _l(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(se.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class Cn extends ye{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return te.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return te.fromReplace(e,this.pos,this.pos+1,new O(S.from(i),0,t.isLeaf?0:1))}getMap(){return Ae.empty}invert(e){return new Cn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Cn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Cn(t.pos,t.attr,t.value)}}ye.jsonID("attr",Cn);class lr extends ye{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return te.ok(r)}getMap(){return Ae.empty}invert(e){return new lr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new lr(t.attr,t.value)}}ye.jsonID("docAttr",lr);let An=class extends Error{};An=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};An.prototype=Object.create(Error.prototype);An.prototype.constructor=An;An.prototype.name="TransformError";class Gl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new wn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new An(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=O.empty){let i=no(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new O(S.from(r),0,0))}delete(e,t){return this.replace(e,t,O.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return dd(this,e,t,r),this}replaceRangeWith(e,t,r){return fd(this,e,t,r),this}deleteRange(e,t){return hd(this,e,t),this}lift(e,t){return Qu(this,e,t),this}join(e,t=1){return od(this,e,t),this}wrap(e,t){return td(this,e,t),this}setBlockType(e,t=e,r,i=null){return nd(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return id(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Cn(e,t,r)),this}setDocAttribute(e,t){return this.step(new lr(e,t)),this}addNodeMark(e,t){return this.step(new Ct(e,t)),this}removeNodeMark(e,t){if(!(t instanceof U)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new En(e,t)),this}split(e,t=1,r){return sd(this,e,t,r),this}addMark(e,t,r){return _u(this,e,t,r),this}removeMark(e,t,r){return Gu(this,e,t,r),this}clearIncompatible(e,t,r){return Yu(this,e,t,r),this}}const Qi=Object.create(null);class z{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new pd(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;s--){let o=t<0?pn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):pn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new qe(e.node(0))}static atStart(e){return pn(e,e,0,0,1)||new qe(e)}static atEnd(e){return pn(e,e,e.content.size,e.childCount,-1)||new qe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Qi[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Qi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Qi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return L.between(this.$anchor,this.$head).getBookmark()}}z.prototype.visible=!0;class pd{constructor(e,t){this.$from=e,this.$to=t}}let Go=!1;function Yo(n){!Go&&!n.parent.inlineContent&&(Go=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class L extends z{constructor(e,t=e){Yo(e),Yo(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return z.near(r);let i=e.resolve(t.map(this.anchor));return new L(i.parent.inlineContent?i:r,r)}replace(e,t=O.empty){if(super.replace(e,t),t==O.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof L&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ni(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new L(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=z.findFrom(t,r,!0)||z.findFrom(t,-r,!0);if(s)t=s.$head;else return z.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(z.findFrom(e,-r,!0)||z.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let a=e.child(o);if(a.isAtom){if(!s&&R.isSelectable(a))return R.create(n,t-(i<0?a.nodeSize:0))}else{let l=pn(n,a,t+i,i<0?a.childCount:0,i,s);if(l)return l}t+=a.nodeSize*i}return null}function Xo(n,e,t){let r=n.steps.length-1;if(r{o==null&&(o=u)}),n.setSelection(z.near(n.doc.resolve(o),t))}const Qo=1,zr=2,Zo=4;class gd extends Gl{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=zr,this}ensureMarks(e){return U.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&zr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~zr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||U.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),this.selection.empty||this.setSelection(z.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Zo,this}get scrolledIntoView(){return(this.updated&Zo)>0}}function ea(n,e){return!e||!n?n:n.bind(e)}class Gn{constructor(e,t,r){this.name=e,this.init=ea(t.init,r),this.apply=ea(t.apply,r)}}const yd=[new Gn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Gn("selection",{init(n,e){return n.selection||z.atStart(e.doc)},apply(n){return n.selection}}),new Gn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Gn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Zi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=yd.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Gn(r.key,r.spec.state,r))})}}class bn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Zi(e.schema,e.plugins),s=new bn(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Gt.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=z.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){s[o.name]=c.fromJSON.call(l,e,t[a],s);return}}s[o.name]=o.init(e,s)}}),s}}function Yl(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Yl(i,e,{})),t[r]=i}return t}class re{constructor(e){this.spec=e,this.props={},e.props&&Yl(e.props,this,this.props),this.key=e.key?e.key.key:Xl("plugin")}getState(e){return e[this.key]}}const es=Object.create(null);function Xl(n){return n in es?n+"$"+ ++es[n]:(es[n]=0,n+"$")}class he{constructor(e="key"){this.key=Xl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ke=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},cr=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let ta=null;const ut=function(n,e,t){let r=ta||(ta=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},en=function(n,e,t,r){return t&&(na(n,e,t,r,-1)||na(n,e,t,r,1))},bd=/^(img|br|input|textarea|hr)$/i;function na(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Xe(n))){let s=n.parentNode;if(!s||s.nodeType!=1||io(n)||bd.test(n.nodeName)||n.contentEditable=="false")return!1;e=ke(n)+(i<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?Xe(n):0}else return!1}}function Xe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function vd(n,e,t){for(let r=e==0,i=e==Xe(n);r||i;){if(n==t)return!0;let s=ke(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Xe(n)}}function io(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Di=function(n){return n.focusNode&&en(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Vt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function kd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function xd(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:r.startOffset}}}const tt=typeof navigator<"u"?navigator:null,ra=typeof document<"u"?document:null,Pt=tt&&tt.userAgent||"",Es=/Edge\/(\d+)/.exec(Pt),Ql=/MSIE \d/.exec(Pt),As=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Pt),Oe=!!(Ql||As||Es),Tt=Ql?document.documentMode:As?+As[1]:Es?+Es[1]:0,Ke=!Oe&&/gecko\/(\d+)/i.test(Pt);Ke&&+(/Firefox\/(\d+)/.exec(Pt)||[0,0])[1];const Ns=!Oe&&/Chrome\/(\d+)/.exec(Pt),ge=!!Ns,Sd=Ns?+Ns[1]:0,xe=!Oe&&!!tt&&/Apple Computer/.test(tt.vendor),Nn=xe&&(/Mobile\/\w+/.test(Pt)||!!tt&&tt.maxTouchPoints>2),Le=Nn||(tt?/Mac/.test(tt.platform):!1),wd=tt?/Win/.test(tt.platform):!1,je=/Android \d/.test(Pt),kr=!!ra&&"webkitFontSmoothing"in ra.documentElement.style,Md=kr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Cd(n){return{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function lt(n,e){return typeof n=="number"?n:n[e]}function Od(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function ia(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;o=cr(o)){if(o.nodeType!=1)continue;let a=o,l=a==s.body,c=l?Cd(s):Od(a),u=0,d=0;if(e.topc.bottom-lt(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+lt(i,"top")-c.top:e.bottom-c.bottom+lt(i,"bottom")),e.leftc.right-lt(r,"right")&&(u=e.right-c.right+lt(i,"right")),u||d)if(l)s.defaultView.scrollBy(u,d);else{let f=a.scrollLeft,h=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let p=a.scrollLeft-f,m=a.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(l||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function Td(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o=t-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:Zl(n.dom)}}function Zl(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=cr(r));return e}function Ed({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;ec(t,r==0?0:r-e)}function ec(n,e){for(let t=0;t=a){o=Math.max(p.bottom,o),a=Math.min(p.top,a);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!l&&p.left<=e.left&&p.right>=e.left&&(l=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!t&&l&&(t=l,i=c,r=0),t&&t.nodeType==3?Nd(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:tc(t,i)}function Nd(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function so(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Dd(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function Rd(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let a=n.docView.nearestDesc(s,!0);if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent&&!o||!a.contentDOM)){let l=a.dom.getBoundingClientRect();if(a.node.isBlock&&a.parent&&!o&&(o=!0,l.left>r.left||l.top>r.top?i=a.posBefore:(l.right-1?i:n.docView.posFromDOM(e,t,-1)}function nc(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let c;kr&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=Rd(n,r,i,e))}a==null&&(a=Id(n,o,e));let l=n.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function sa(n){return n.top=0&&i==r.nodeValue.length?(l--,u=1):t<0?l--:c++,Kn(bt(ut(r,l,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Xe(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return ts(l.getBoundingClientRect(),!1)}if(s==null&&i=0)}if(s==null&&i&&(t<0||i==Xe(r))){let l=r.childNodes[i-1],c=l.nodeType==3?ut(l,Xe(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Kn(bt(c,1),!1)}if(s==null&&i=0)}function Kn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function ts(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function ic(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Bd(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return ic(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let o=rc(n,i.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=ut(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const zd=/[\u0590-\u08ac]/;function Hd(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=n.domSelection();return!zd.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?s:o:ic(n,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||l==p&&c==m;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return f!=null&&(a.caretBidiLevel=f),g})}let oa=null,aa=null,la=!1;function Fd(n,e,t){return oa==e&&aa==t?la:(oa=e,aa=t,la=t=="up"||t=="down"?Bd(n,e,t):Hd(n,e,t))}const Be=0,ca=1,qt=2,nt=3;class xr{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Be,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tke(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||o instanceof oc){i=e-s;break}s=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof sc&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?ke(s.dom)+1:0}}else{let s,o=!0;for(;s=r=u&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,u);e=o;for(let d=a;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=ke(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||a==this.children.length-1)){t=c;for(let u=a+1;uh&&ot){let h=a;a=l,l=h}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i=r:er){let a=r+s.border,l=o-s.border;if(e>=a&&t<=l){this.dirty=e==r||t==o?qt:ca,e==a&&t==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=nt:s.markDirty(e-a,t-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?qt:nt}r=o}this.dirty=qt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?qt:ca;t.dirty{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let a=document.createElement("span");a.appendChild(o),o=a}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Be&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class $d extends xr{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class tn extends xr{constructor(e,t,r,i){super(e,[],r,i),this.mark=t}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=Qe.renderSpec(document,t.type.spec.toDOM(t,r))),new tn(e,t,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&nt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=nt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Be){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(s=Rs(s,0,e,r));for(let a=0;a{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Qe.renderSpec(document,t.type.spec.toDOM(t)));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=cc(u,r,t),c?l=new Vd(e,t,r,i,u,d||null,f,c,s,o+1):t.isText?new Ii(e,t,r,i,u,f,s):new Et(e,t,r,i,u,d||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,r){return this.dirty==Be&&e.eq(this.node)&&Is(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new Wd(this,o&&o.node,e);Ud(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?U.none:this.node.child(u).marks,r,e),l.placeWidget(c,e,i)},(c,u,d,f)=>{l.syncToMarks(c.marks,r,e);let h;l.findNodeMatch(c,u,d,f)||a&&e.state.selection.from>i&&e.state.selection.to-1&&l.updateNodeAt(c,u,d,h,e)||l.updateNextNode(c,u,d,e,f,i)||l.addNode(c,u,d,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==qt)&&(o&&this.protectLocalComposition(e,o),ac(this.contentDOM,this.children,e),Nn&&Jd(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof L)||rt+this.node.content.size)return null;let s=e.domSelectionRange(),o=_d(s.focusNode,s.focusOffset);if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let a=o.nodeValue,l=Gd(this.node.content,a,r-t,i-t);return l<0?null:{node:o,pos:l,text:a}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new $d(this,s,t,i);e.input.compositionNodes.push(o),this.children=Rs(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==nt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Be}updateOuterDeco(e){if(Is(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=lc(this.dom,this.nodeDOM,Ds(this.outerDeco,this.node,t),Ds(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function ua(n,e,t,r,i){cc(r,e,n);let s=new Et(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Ii extends Et{constructor(e,t,r,i,s,o,a){super(e,t,r,i,s,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==nt||this.dirty!=Be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Be||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Be,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new Ii(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=nt)}get domAtom(){return!1}}class oc extends xr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Vd extends Et{constructor(e,t,r,i,s,o,a,l,c,u){super(e,t,r,i,s,o,a,c,u),this.spec=l}update(e,t,r,i){if(this.dirty==nt)return!1;if(this.spec.update){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ac(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s>1,o=Math.min(s,e.length);for(;i-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=tn.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a0;){let a;for(;;)if(r){let c=t.children[r-1];if(c instanceof tn)t=c,r=c.children.length;else{a=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=n.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}function Kd(n,e){return n.type.side-e.type.side}function Ud(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let c=0;cs;)a.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o!g.inline):a.slice();r(f,m,e.forChild(s,f),h),s=p}}function Jd(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function _d(n,e){for(;;){if(n.nodeType==3)return n;if(n.nodeType==1&&e>0){if(n.childNodes.length>e&&n.childNodes[e].nodeType==3)return n.childNodes[e];n=n.childNodes[e-1],e=Xe(n)}else if(n.nodeType==1&&e=t){if(s>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a=0&&c+e.length+a>=t)return a+c;if(t==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Rs(n,e,t,r,i){let s=[];for(let o=0,a=0;o=t||u<=e?s.push(l):(ct&&s.push(l.slice(t-c,l.size,r)))}return s}function oo(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,c;if(Di(t)){for(l=a;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&R.isSelectable(u)&&i.parent&&!(u.isInline&&vd(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new R(o==d?a:r.resolve(d))}}else{let u=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(u<0)return null;l=r.resolve(u)}if(!c){let u=e=="pointer"||n.state.selection.head{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!uc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Xd(n){let e=n.domSelection(),t=document.createRange(),r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setEnd(r.parentNode,ke(r)+1):t.setEnd(r,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&Oe&&Tt<=11&&(r.disabled=!0,r.disabled=!1)}function dc(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ma(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ma(n)}function ma(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ao(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||L.between(e,t,r)}function ga(n){return n.editable&&!n.hasFocus()?!1:fc(n)}function fc(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Qd(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return en(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ps(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&z.findFrom(s,e)}function vt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ya(n,e,t){let r=n.state.selection;if(r instanceof L)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return vt(n,new L(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Ps(n.state,e);return i&&i instanceof R?vt(n,i):!1}else if(!(Le&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let a=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(a))&&!o.contentDOM?R.isSelectable(s)?vt(n,new R(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):kr?vt(n,new L(n.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof R&&r.node.isInline)return vt(n,new L(e>0?r.$to:r.$from));{let i=Ps(n.state,e);return i?vt(n,i):!1}}}function ri(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Zn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function dn(n,e){return e<0?Zd(n):ef(n)}function Zd(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Ke&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(Zn(a,-1))i=t,s=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(hc(t))break;{let a=t.previousSibling;for(;a&&Zn(a,-1);)i=t.parentNode,s=ke(a),a=a.previousSibling;if(a)t=a,r=ri(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Ls(n,t,r):i&&Ls(n,i,s)}function ef(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=ri(t),s,o;for(;;)if(r{n.state==i&&ht(n)},50)}function ba(n,e){let t=n.state.doc.resolve(e);if(!(ge||wd)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o1)return s.lefti.top&&o1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function va(n,e,t){let r=n.state.selection;if(r instanceof L&&!r.empty||t.indexOf("s")>-1||Le&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Ps(n.state,e);if(o&&o instanceof R)return vt(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,a=r instanceof qe?z.near(o,e):z.findFrom(o,e);return a?vt(n,a):!1}return!1}function ka(n,e){if(!(n.state.selection instanceof L))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function xa(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function rf(n){if(!xe||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;xa(n,r,"true"),setTimeout(()=>xa(n,r,"false"),20)}return!1}function sf(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function of(n,e){let t=e.keyCode,r=sf(e);if(t==8||Le&&t==72&&r=="c")return ka(n,-1)||dn(n,-1);if(t==46&&!e.shiftKey||Le&&t==68&&r=="c")return ka(n,1)||dn(n,1);if(t==13||t==27)return!0;if(t==37||Le&&t==66&&r=="c"){let i=t==37?ba(n,n.state.selection.from)=="ltr"?-1:1:-1;return ya(n,i,r)||dn(n,i)}else if(t==39||Le&&t==70&&r=="c"){let i=t==39?ba(n,n.state.selection.from)=="ltr"?1:-1:1;return ya(n,i,r)||dn(n,i)}else{if(t==38||Le&&t==80&&r=="c")return va(n,-1,r)||dn(n,-1);if(t==40||Le&&t==78&&r=="c")return rf(n)||va(n,1,r)||dn(n,1);if(r==(Le?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function pc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||Qe.fromSchema(n.state.schema),a=kc(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=vc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=a.createElement(u[h]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` `);return{dom:l,text:f}}function mc(n,e,t,r,i){let s=i.parent.type.spec.code,o,a;if(!t&&!e)return null;let l=e&&(r||s||!t);if(l){if(n.someProp("transformPastedText",f=>{e=f(e,s||r,n)}),s)return e?new O(S.from(n.state.schema.text(e.replace(/\r\n?/g,` `))),0,0):O.empty;let d=n.someProp("clipboardTextParser",f=>f(e,i,r,n));if(d)a=d;else{let f=i.marks(),{schema:h}=n.state,p=Qe.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=cf(t),kr&&uf(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||Tn.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!af.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=df(Sa(a,+u[1],+u[2]),u[4]);else if(a=O.maxOpen(lf(a.content,i),!0),a.openStart||a.openEnd){let d=0,f=0;for(let h=a.content.firstChild;d{a=d(a,n)}),a}const af=/^(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,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(a=>{if(!o)return;let l=i.findWrapping(a.type),c;if(!l)return o=null;if(c=o.length&&s.length&&yc(l,s,a,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=bc(o[o.length-1],s.length));let u=gc(a,l);o.push(u),i=i.matchType(u.type),s=l}}),o)return S.from(o)}return n}function gc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function yc(n,e,t,r,i){if(i1&&(s=0),i=t&&(a=e<0?o.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(a))}function Sa(n,e,t){return e]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=kc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&vc[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"").reverse().join("")),t.innerHTML=n,i)for(let s=0;s=0;a-=2){let l=t.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=S.from(l.create(r[a+1],i)),s++,o++}return new O(i,s,o)}const Se={},we={},ff={touchstart:!0,touchmove:!0};class hf{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function pf(n){for(let e in Se){let t=Se[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{gf(n,r)&&!lo(n,r)&&(n.editable||!(r.type in we))&&t(n,r)},ff[e]?{passive:!0}:void 0)}xe&&n.dom.addEventListener("input",()=>null),zs(n)}function Ot(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function mf(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function zs(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>lo(n,r))})}function lo(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function gf(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function yf(n,e){!lo(n,e)&&Se[e.type]&&(n.editable||!(e.type in we))&&Se[e.type](n,e)}we.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Sc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(je&&ge&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Nn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Vt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||of(n,t)?t.preventDefault():Ot(n,"key")};we.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};we.keypress=(n,e)=>{let t=e;if(Sc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Le&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof L)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function Ri(n){return{left:n.clientX,top:n.clientY}}function bf(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function co(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,a=>o>s.depth?a(n,t,s.nodeAfter,s.before(o),i,!0):a(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function On(n,e,t){n.focused||n.focus();let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function vf(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&R.isSelectable(r)?(On(n,new R(t),"pointer"),!0):!1}function kf(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof R&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let a=o>s.depth?s.nodeAfter:s.node(o);if(R.isSelectable(a)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(On(n,R.create(n.state.doc,i),"pointer"),!0):!1}function xf(n,e,t,r,i){return co(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?kf(n,t):vf(n,t))}function Sf(n,e,t,r){return co(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function wf(n,e,t,r){return co(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Mf(n,t,r)}function Mf(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(On(n,L.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),a=i.before(s);if(o.inlineContent)On(n,L.create(r,a+1,a+1+o.content.size),"pointer");else if(R.isSelectable(o))On(n,R.create(r,a),"pointer");else continue;return!0}}function uo(n){return ii(n)}const xc=Le?"metaKey":"ctrlKey";Se.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=uo(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&bf(t,n.input.lastClick)&&!t[xc]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=n.posAtCoords(Ri(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Cf(n,o,t,!!r)):(s=="doubleClick"?Sf:wf)(n,o.pos,o.inside,t)?t.preventDefault():Ot(n,"pointer"))};class Cf{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[xc],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,o=u.depth?u.before():0}const a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l?l.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof R&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ke&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ot(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ht(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Ri(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ot(this.view,"pointer"):xf(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||xe&&this.mightDrag&&!this.mightDrag.node.isAtom||ge&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(On(this.view,z.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ot(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ot(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Se.touchstart=n=>{n.input.lastTouch=Date.now(),uo(n),Ot(n,"pointer")};Se.touchmove=n=>{n.input.lastTouch=Date.now(),Ot(n,"pointer")};Se.contextmenu=n=>uo(n);function Sc(n,e){return n.composing?!0:xe&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Of=je?5e3:-1;we.compositionstart=we.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),ii(n,!0),n.markCursor=null;else if(ii(n),Ke&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){n.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}wc(n,Of)};we.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,wc(n,20))};function wc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ii(n),e))}function Mc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Tf());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Tf(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ii(n,e=!1){if(!(je&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Mc(n),e||n.docView&&n.docView.dirty){let t=oo(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):n.updateState(n.state),!0}return!1}}function Ef(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Dn=Oe&&Tt<15||Nn&&Md<604;Se.copy=we.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=Dn?null:t.clipboardData,o=r.content(),{dom:a,text:l}=pc(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):Ef(n,a),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Af(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Nf(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?ur(n,r.value,null,i,e):ur(n,r.textContent,r.innerHTML,i,e)},50)}function ur(n,e,t,r,i){let s=mc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,i,s||O.empty)))return!0;if(!s)return!1;let o=Af(s),a=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}we.paste=(n,e)=>{let t=e;if(n.composing&&!je)return;let r=Dn?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&ur(n,r.getData("text/plain"),r.getData("text/html"),i,t)?t.preventDefault():Nf(n,t)};class Df{constructor(e,t){this.slice=e,this.move=t}}const Cc=Le?"altKey":"ctrlKey";Se.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(Ri(t));if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof R?i.to-1:i.to))){if(r&&r.mightDrag)n.dispatch(n.state.tr.setSelection(R.create(n.state.doc,r.mightDrag.pos)));else if(t.target&&t.target.nodeType==1){let c=n.docView.nearestDesc(t.target,!0);c&&c.node.type.spec.draggable&&c!=n.docView&&n.dispatch(n.state.tr.setSelection(R.create(n.state.doc,c.posBefore)))}}let o=n.state.selection.content(),{dom:a,text:l}=pc(n,o);t.dataTransfer.clearData(),t.dataTransfer.setData(Dn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Dn||t.dataTransfer.setData("text/plain",l),n.dragging=new Df(o,!t[Cc])};Se.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};we.dragover=we.dragenter=(n,e)=>e.preventDefault();we.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(Ri(t));if(!i)return;let s=n.state.doc.resolve(i.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=mc(n,t.dataTransfer.getData(Dn?"Text":"text/plain"),Dn?null:t.dataTransfer.getData("text/html"),!1,s);let a=!!(r&&!t[Cc]);if(n.someProp("handleDrop",p=>p(n,t,o||O.empty,a))){t.preventDefault();return}if(!o)return;t.preventDefault();let l=o?ql(n.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let c=n.state.tr;a&&c.deleteSelection();let u=c.mapping.map(l),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&R.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new R(h));else{let p=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,x)=>p=x),c.setSelection(ao(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};Se.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())&&ht(n)},20))};Se.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Se.beforeinput=(n,e)=>{if(ge&&je&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Vt(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in we)Se[n]=we[n];function dr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class si{constructor(e,t){this.toDOM=e,this.spec=t||Yt,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Ce(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof si&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&dr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class At{constructor(e,t){this.attrs=e,this.spec=t||Yt}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Ce(s,o,this)}valid(e,t){return t.from=e&&(!s||s(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let o=0;oe){let a=this.children[o]+1;this.children[o+2].findInner(e-a,t-a,r,i+a,s)}}map(e,t,r){return this==me||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Yt)}mapInner(e,t,r,i,s){let o;for(let a=0;a{let c=l+r,u;if(u=Tc(t,a,c)){for(i||(i=this.children.slice());sa&&d.to=e){this.children[a]==e&&(r=this.children[a+2]);break}let s=e+1,o=s+t.content.size;for(let a=0;as&&l.type instanceof At){let c=Math.max(s,l.from)-s,u=Math.min(o,l.to)-s;ci.map(e,t,Yt));return St.from(r)}forChild(e,t){if(t.isLeaf)return ee.empty;let r=[];for(let i=0;it instanceof ee)?e:e.reduce((t,r)=>t.concat(r instanceof ee?r:r.members),[]))}}}function If(n,e,t,r,i,s,o){let a=n.slice();for(let c=0,u=s;c{let g=m-p-(h-f);for(let b=0;bx+u-d)continue;let M=a[b]+u-d;h>=M?a[b+1]=f<=M?-2:-1:p>=i&&g&&(a[b]+=g,a[b+1]+=g)}d+=g}),u=t.maps[c].map(u,-1)}let l=!1;for(let c=0;c=r.content.size){l=!0;continue}let f=t.map(n[c+1]+s,-1),h=f-i,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let b=a[c+2].mapInner(t,g,u+1,n[c]+s+1,o);b!=me?(a[c]=d,a[c+1]=h,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Rf(a,n,e,t,i,s,o),u=oi(c,r,0,o);e=u.local;for(let d=0;dt&&o.to{let c=Tc(n,a,l+t);if(c){s=!0;let u=oi(c,a,t+l+1,r);u!=me&&i.push(l,l+a.nodeSize,u)}});let o=Oc(s?Ec(n):n,-t).sort(Xt);for(let a=0;a0;)e++;n.splice(e,0,t)}function rs(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=me&&e.push(r)}),n.cursorWrapper&&e.push(ee.create(n.state.doc,[n.cursorWrapper.deco])),St.from(e)}const Pf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Lf=Oe&&Tt<=11;class Bf{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class zf{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Bf,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Lf&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Pf)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.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(ga(this.view)){if(this.suppressingSelectionUpdates)return ht(this.view);if(Oe&&Tt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&en(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=cr(s))t.add(s);for(let s=e.anchorNode;s;s=cr(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ga(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,a=!1,l=[];if(e.editable)for(let u=0;u1){let u=l.filter(d=>d.nodeName=="BR");if(u.length==2){let d=u[0],f=u[1];d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Hf(e)),this.handleDOMChange(s,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ht(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;ui;g--){let b=r.childNodes[g-1],x=b.pmViewDesc;if(b.nodeName=="BR"&&!x){s=g;break}if(!x||x.size)break}let d=n.state.doc,f=n.someProp("domParser")||Tn.fromSchema(n.state.schema),h=d.resolve(o),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Vf,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:m,sel:p,from:o,to:a}}function Vf(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(xe&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||xe&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const jf=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Wf(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let C=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,H=oo(n,C);if(H&&!n.state.selection.eq(H)){if(ge&&je&&n.input.lastKeyCode===13&&Date.now()-100F(n,Vt(13,"Enter"))))return;let V=n.state.tr.setSelection(H);C=="pointer"?V.setMeta("pointer",!0):C=="key"&&V.scrollIntoView(),s&&V.setMeta("composition",s),n.dispatch(V)}return}let o=n.state.doc.resolve(e),a=o.sharedDepth(t);e=o.before(a+1),t=n.state.doc.resolve(t).after(a+1);let l=n.state.selection,c=$f(n,e,t),u=n.state.doc,d=u.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||je)&&i.some(C=>C.nodeType==1&&!jf.test(C.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",C=>C(n,Vt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&l instanceof L&&!l.empty&&l.$head.sameParent(l.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let C=Ta(n,n.state.doc,c.sel);if(C&&!C.eq(n.state.selection)){let H=n.state.tr.setSelection(C);s&&H.setMeta("composition",s),n.dispatch(H)}}return}if(ge&&n.cursorWrapper&&c.sel&&c.sel.anchor==n.cursorWrapper.deco.from&&c.sel.head==c.sel.anchor){let C=p.endB-p.start;c.sel={anchor:c.sel.anchor+C,head:c.sel.anchor+C}}n.input.domChangeCount++,n.state.selection.fromn.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Oe&&Tt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),x=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA,M;if((Nn&&n.input.lastIOSEnter>Date.now()-225&&(!x||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!x&&m.posC(n,Vt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Kf(u,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",C=>C(n,Vt(8,"Backspace")))){je&&ge&&n.domObserver.suppressSelectionUpdates();return}ge&&je&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),je&&!x&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(C){return C(n,Vt(13,"Enter"))})},20));let y=p.start,T=p.endA,v,N,I;if(x){if(m.pos==g.pos)Oe&&Tt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ht(n),20)),v=n.state.tr.delete(y,T),N=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&(I=qf(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))v=n.state.tr,I.type=="add"?v.addMark(y,T,I.mark):v.removeMark(y,T,I.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let C=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",H=>H(n,y,T,C)))return;v=n.state.tr.insertText(C,y,T)}}if(v||(v=n.state.tr.replace(y,T,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let C=Ta(n,v.doc,c.sel);C&&!(ge&&je&&n.composing&&C.empty&&(p.start!=p.endB||n.input.lastAndroidDeletee.content.size?null:ao(n,e.resolve(t.anchor),e.resolve(t.head))}function qf(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,a,l;for(let u=0;uu.mark(a.addToSet(u.marks));else if(i.length==0&&s.length==1)a=s[0],o="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;ut||is(o,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Uf(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:a}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let l=Math.max(0,s-Math.min(o,a));r-=o+l-s}if(o=o?s-r:0;s-=l,a=s+(a-o),o=s}else if(a=a?s-r:0;s-=l,o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}class Jf{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new hf,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ia),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Na(this),Aa(this),this.nodeViews=Da(this),this.docView=ua(this.state.doc,Ea(this),rs(this),this.dom,this),this.domObserver=new zf(this,(r,i,s,o)=>Wf(this,r,i,s,o)),this.domObserver.start(),pf(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&zs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ia),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let r=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Mc(this),s=!0),this.state=e;let o=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(o||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=Da(this);Gf(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(o||t.handleDOMEvents!=this._props.handleDOMEvents)&&zs(this),this.editable=Na(this),Aa(this);let a=rs(this),l=Ea(this),c=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,l,a);(u||!e.selection.eq(r.selection))&&(s=!0);let d=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Td(this);if(s){this.domObserver.stop();let f=u&&(Oe||ge)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&_f(r.selection,e.selection);if(u){let h=ge?this.trackWrites=this.domSelectionRange().focusNode:null;(i||!this.docView.update(e.doc,l,a,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=ua(e.doc,l,a,this.dom,this)),h&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Qd(this))?ht(this,f):(dc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&Ed(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ia(this,t.getBoundingClientRect(),e)}else ia(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;tt.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Pd(this,e)}coordsAtPos(e,t=1){return rc(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Fd(this,t||this.state,e)}pasteHTML(e,t){return ur(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ur(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(mf(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],rs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return this.docView==null}dispatchEvent(e){return yf(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return xe&&this.root.nodeType===11&&kd(this.dom.ownerDocument)==this.dom?Ff(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function Ea(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ce.node(0,n.state.doc.content.size,e)]}function Aa(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ce.widget(n.state.selection.head,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Na(n){return!n.someProp("editable",e=>e(n.state)===!1)}function _f(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Da(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Gf(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Ia(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Dt={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:"'"},ai={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Yf=typeof navigator<"u"&&/Mac/.test(navigator.platform),Xf=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var de=0;de<10;de++)Dt[48+de]=Dt[96+de]=String(de);for(var de=1;de<=24;de++)Dt[de+111]="F"+de;for(var de=65;de<=90;de++)Dt[de]=String.fromCharCode(de+32),ai[de]=String.fromCharCode(de);for(var ss in Dt)ai.hasOwnProperty(ss)||(ai[ss]=Dt[ss]);function Qf(n){var e=Yf&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Xf&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?ai:Dt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Zf=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function eh(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let a=0;a127)&&(s=Dt[r.keyCode])&&s!=i){let a=e[as(s,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}const rh=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function ih(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const sh=(n,e,t)=>{let r=ih(n,t);if(!r)return!1;let i=Nc(r);if(!i){let o=r.blockRange(),a=o&&Hn(o);return a==null?!1:(e&&e(n.tr.lift(o,a).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&Rc(n,i,e))return!0;if(r.parent.content.size==0&&(In(s,"end")||R.isSelectable(s))){let o=no(n.doc,r.before(),r.after(),O.empty);if(o&&o.slice.size{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Nc(r)}let o=s&&s.nodeBefore;return!o||!R.isSelectable(o)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Nc(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function ah(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=ah(n,t);if(!r)return!1;let i=Dc(r);if(!i)return!1;let s=i.nodeAfter;if(Rc(n,i,e))return!0;if(r.parent.content.size==0&&(In(s,"start")||R.isSelectable(s))){let o=no(n.doc,r.before(),r.after(),O.empty);if(o&&o.slice.size{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,r=t instanceof R,i;if(r){if(t.node.isTextblock||!Rt(n.doc,t.from))return!1;i=t.from}else if(i=Ai(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(R.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},dh=(n,e)=>{let t=n.selection,r;if(t instanceof R){if(t.node.isTextblock||!Rt(n.doc,t.to))return!1;r=t.to}else if(r=Ai(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},fh=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&Hn(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},hh=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` `).scrollIntoView()),!0)};function Ic(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Ic(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let a=t.after(),l=n.tr.replaceWith(a,a,o.createAndFill());l.setSelection(z.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},mh=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof qe||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Ic(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Mn(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Hn(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)},yh=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(R.create(n.doc,i))),!0)};function bh(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Rt(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function Rc(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s,o;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(bh(n,e,t))return!0;let a=e.parent.canReplace(e.index(),e.index()+1);if(a&&(s=(o=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(t){let d=e.pos+i.nodeSize,f=S.empty;for(let m=s.length-1;m>=0;m--)f=S.from(s[m].create(null,f));f=S.from(r.copy(f));let h=n.tr.step(new oe(e.pos-1,d,e.pos,d,new O(f,1,0),s.length,!0)),p=d+2*s.length;Rt(h.doc,p)&&h.join(p),t(h.scrollIntoView())}return!0}let l=z.findFrom(e,1),c=l&&l.$from.blockRange(l.$to),u=c&&Hn(c);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(c,u).scrollIntoView()),!0;if(a&&In(i,"start",!0)&&In(r,"end")){let d=r,f=[];for(;f.push(d),!d.isTextblock;)d=d.lastChild;let h=i,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(d.canReplace(d.childCount,d.childCount,h.content)){if(t){let m=S.empty;for(let b=f.length-1;b>=0;b--)m=S.from(f[b].copy(m));let g=n.tr.step(new oe(e.pos-f.length,e.pos+i.nodeSize,e.pos+p,e.pos+i.nodeSize-p,new O(m,f.length,0),0,!0));t(g.scrollIntoView())}return!0}}return!1}function Pc(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(L.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const vh=Pc(-1),kh=Pc(1);function xh(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),a=o&&to(o,n,e);return a?(r&&r(t.tr.wrap(o,a).scrollIntoView()),!0):!1}}function Ra(n,e=null){return function(t,r){let i=!1;for(let s=0;s{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(n,e)))if(l.type==n)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o=2&&i.node(o.depth-1).type.compatibleContent(n)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let u=t.doc.resolve(o.start-2);l=new Zr(u,u,o.depth),o.endIndex=0;u--)s=S.from(t[u].type.create(t[u].attrs,s));n.step(new oe(e.start-(r?2:0),e.end,e.start,e.end,new O(s,0,0),t.length,!0));let o=0;for(let u=0;uo.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Ch(e,t,n,s):Oh(e,t,s):!0:!1}}function Ch(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);sm;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(a?0:1),u+1,o.content.append(l?S.empty:S.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new oe(d-(a?1:0),f+(l?1:0),d+1,f-1,new O((a?S.empty:S.from(i.copy(S.empty))).append(l?S.empty:S.from(i.copy(S.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function Th(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=n)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,u=S.from(c?n.create():null),d=new O(S.from(n.create(null,S.from(a.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new oe(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}function Pi(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),filterTransaction:e.filterTransaction,plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}class Li{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:i}=t,{tr:s}=r,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...u)=>{const d=l(...u)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,a=[],l=!!e,c=e||s.tr,u=()=>(!l&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),a.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(c,t),b=h(...m)(g);return a.push(b),d}])),run:u};return d}createCan(e){const{rawCommands:t,state:r}=this,i=!1,s=e||r.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...u)=>c(...u)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,a={tr:e,editor:i,view:o,state:Pi({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}}class Eh{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}function E(n,e,t){return n.config[e]===void 0&&n.parent?E(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?E(n.parent,e,t):null}):n.config[e]}function Bi(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Lc(n){const e=[],{nodeExtensions:t,markExtensions:r}=Bi(n),i=[...t,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage},l=E(o,"addGlobalAttributes",a);if(!l)return;l().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...s,...h}})})})})}),i.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage},l=E(o,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([u,d])=>{const f={...s,...d};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:o.name,name:u,attribute:f})})}),e}function le(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function _(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const a=s?s.split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(u=>!l.includes(u));r[i]=[...l,...c].join(" ")}else i==="style"?r[i]=[r[i],s].join("; "):r[i]=s}),r},{})}function Hs(n,e){return e.filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>_(t,r),{})}function Bc(n){return typeof n=="function"}function B(n,e=void 0,...t){return Bc(n)?e?n.bind(e)(...t):n(...t):n}function Ah(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Nh(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Pa(n,e){return n.style?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(t):Nh(t.getAttribute(o.name));return a==null?s:{...s,[o.name]:a}},{});return{...r,...i}}}}function La(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Ah(t)?!1:t!=null))}function Dh(n,e){var t;const r=Lc(n),{nodeExtensions:i,markExtensions:s}=Bi(n),o=(t=i.find(c=>E(c,"topNode")))===null||t===void 0?void 0:t.name,a=Object.fromEntries(i.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((b,x)=>{const M=E(x,"extendNodeSchema",d);return{...b,...M?M(c):{}}},{}),h=La({...f,content:B(E(c,"content",d)),marks:B(E(c,"marks",d)),group:B(E(c,"group",d)),inline:B(E(c,"inline",d)),atom:B(E(c,"atom",d)),selectable:B(E(c,"selectable",d)),draggable:B(E(c,"draggable",d)),code:B(E(c,"code",d)),defining:B(E(c,"defining",d)),isolating:B(E(c,"isolating",d)),attrs:Object.fromEntries(u.map(b=>{var x;return[b.name,{default:(x=b==null?void 0:b.attribute)===null||x===void 0?void 0:x.default}]}))}),p=B(E(c,"parseHTML",d));p&&(h.parseDOM=p.map(b=>Pa(b,u)));const m=E(c,"renderHTML",d);m&&(h.toDOM=b=>m({node:b,HTMLAttributes:Hs(b,u)}));const g=E(c,"renderText",d);return g&&(h.toText=g),[c.name,h]})),l=Object.fromEntries(s.map(c=>{const u=r.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,b)=>{const x=E(b,"extendMarkSchema",d);return{...g,...x?x(c):{}}},{}),h=La({...f,inclusive:B(E(c,"inclusive",d)),excludes:B(E(c,"excludes",d)),group:B(E(c,"group",d)),spanning:B(E(c,"spanning",d)),code:B(E(c,"code",d)),attrs:Object.fromEntries(u.map(g=>{var b;return[g.name,{default:(b=g==null?void 0:g.attribute)===null||b===void 0?void 0:b.default}]}))}),p=B(E(c,"parseHTML",d));p&&(h.parseDOM=p.map(g=>Pa(g,u)));const m=E(c,"renderHTML",d);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:Hs(g,u)})),[c.name,h]}));return new Fu({topNode:o,nodes:a,marks:l})}function ls(n,e){return e.nodes[n]||e.marks[n]||null}function Ba(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}const Ih=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,a)=>{var l,c;const u=((c=(l=i.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:i,pos:s,parent:o,index:a}))||i.textContent||"%leaf%";t+=u.slice(0,Math.max(0,r-s))}),t};function po(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class zi{constructor(e){this.find=e.find,this.handler=e.handler}}const Rh=(n,e)=>{if(po(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function cs(n){var e;const{editor:t,from:r,to:i,text:s,rules:o,plugin:a}=n,{view:l}=t;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const d=Ih(c)+s;return o.forEach(f=>{if(u)return;const h=Rh(d,f.find);if(!h)return;const p=l.state.tr,m=Pi({state:l.state,transaction:p}),g={from:r-(h[0].length-s.length),to:i},{commands:b,chain:x,can:M}=new Li({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:b,chain:x,can:M})===null||!p.steps.length||(p.setMeta(a,{transform:p,from:r,to:i,text:s}),l.dispatch(p),u=!0)}),u}function Ph(n){const{editor:e,rules:t}=n,r=new re({state:{init(){return null},apply(i,s){const o=i.getMeta(r);return o||(i.selectionSet||i.docChanged?null:s)}},props:{handleTextInput(i,s,o,a){return cs({editor:e,from:s,to:o,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&cs({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?cs({editor:e,from:o.pos,to:o.pos,text:` `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Lh(n){return typeof n=="number"}class Bh{constructor(e){this.find=e.find,this.handler=e.handler}}const zh=(n,e)=>{if(po(e))return[...n.matchAll(e)];const t=e(n);return t?t.map(r=>{const i=[r.text];return i.index=r.index,i.input=n,i.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(r.replaceWith)),i}):[]};function Hh(n){const{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:o,dropEvent:a}=n,{commands:l,chain:c,can:u}=new Li({editor:e,state:t}),d=[];return t.doc.nodesBetween(r,i,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(r,p),g=Math.min(i,p+h.content.size),b=h.textBetween(m-p,g-p,void 0,"");zh(b,s.find).forEach(M=>{if(M.index===void 0)return;const y=m+M.index+1,T=y+M[0].length,v={from:t.tr.mapping.map(y),to:t.tr.mapping.map(T)},N=s.handler({state:t,range:v,match:M,commands:l,chain:c,can:u,pasteEvent:o,dropEvent:a});d.push(N)})}),d.every(h=>h!==null)}function Fh(n){const{editor:e,rules:t}=n;let r=null,i=!1,s=!1,o=new ClipboardEvent("paste"),a=new DragEvent("drop");return t.map(c=>new re({view(u){const d=f=>{var h;r=!((h=u.dom.parentElement)===null||h===void 0)&&h.contains(f.target)?u.dom.parentElement:null};return window.addEventListener("dragstart",d),{destroy(){window.removeEventListener("dragstart",d)}}},props:{handleDOMEvents:{drop:(u,d)=>(s=r===u.dom.parentElement,a=d,!1),paste:(u,d)=>{var f;const h=(f=d.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return o=d,i=!!(h!=null&&h.includes("data-pm-slice")),!1}}},appendTransaction:(u,d,f)=>{const h=u[0],p=h.getMeta("uiEvent")==="paste"&&!i,m=h.getMeta("uiEvent")==="drop"&&!s;if(!p&&!m)return;const g=d.doc.content.findDiffStart(f.doc.content),b=d.doc.content.findDiffEnd(f.doc.content);if(!Lh(g)||!b||g===b.b)return;const x=f.tr,M=Pi({state:f,transaction:x});if(!(!Hh({editor:e,state:M,from:Math.max(g-1,0),to:b.b-1,rule:c,pasteEvent:o,dropEvent:a})||!x.steps.length))return a=new DragEvent("drop"),o=new ClipboardEvent("paste"),x}}))}function $h(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return[...new Set(e)]}class vn{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=vn.resolve(e),this.schema=Dh(this.extensions,t),this.extensions.forEach(r=>{var i;this.editor.extensionStorage[r.name]=r.storage;const s={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:ls(r.name,this.schema)};r.type==="mark"&&(!((i=B(E(r,"keepOnSplit",s)))!==null&&i!==void 0)||i)&&this.splittableMarks.push(r.name);const o=E(r,"onBeforeCreate",s);o&&this.editor.on("beforeCreate",o);const a=E(r,"onCreate",s);a&&this.editor.on("create",a);const l=E(r,"onUpdate",s);l&&this.editor.on("update",l);const c=E(r,"onSelectionUpdate",s);c&&this.editor.on("selectionUpdate",c);const u=E(r,"onTransaction",s);u&&this.editor.on("transaction",u);const d=E(r,"onFocus",s);d&&this.editor.on("focus",d);const f=E(r,"onBlur",s);f&&this.editor.on("blur",f);const h=E(r,"onDestroy",s);h&&this.editor.on("destroy",h)})}static resolve(e){const t=vn.sort(vn.flatten(e)),r=$h(t.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},i=E(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((r,i)=>{const s=E(r,"priority")||100,o=E(i,"priority")||100;return s>o?-1:s{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:ls(t.name,this.schema)},i=E(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=vn.sort([...this.extensions].reverse()),r=[],i=[],s=t.map(o=>{const a={name:o.name,options:o.options,storage:o.storage,editor:e,type:ls(o.name,this.schema)},l=[],c=E(o,"addKeyboardShortcuts",a);let u={};if(o.type==="mark"&&o.config.exitable&&(u.ArrowRight=()=>He.handleExit({editor:e,mark:o})),c){const m=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));u={...u,...m}}const d=nh(u);l.push(d);const f=E(o,"addInputRules",a);Ba(o,e.options.enableInputRules)&&f&&r.push(...f());const h=E(o,"addPasteRules",a);Ba(o,e.options.enablePasteRules)&&h&&i.push(...h());const p=E(o,"addProseMirrorPlugins",a);if(p){const m=p();l.push(...m)}return l}).flat();return[Ph({editor:e,rules:r}),...Fh({editor:e,rules:i}),...s]}get attributes(){return Lc(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Bi(this.extensions);return Object.fromEntries(t.filter(r=>!!E(r,"addNodeView")).map(r=>{const i=this.attributes.filter(l=>l.type===r.name),s={name:r.name,options:r.options,storage:r.storage,editor:e,type:le(r.name,this.schema)},o=E(r,"addNodeView",s);if(!o)return[];const a=(l,c,u,d)=>{const f=Hs(l,i);return o()({editor:e,node:l,getPos:u,decorations:d,HTMLAttributes:f,extension:r})};return[r.name,a]}))}}function Vh(n){return Object.prototype.toString.call(n).slice(8,-1)}function us(n){return Vh(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Hi(n,e){const t={...n};return us(n)&&us(e)&&Object.keys(e).forEach(r=>{us(e[r])?r in n?t[r]=Hi(n[r],e[r]):Object.assign(t,{[r]:e[r]}):Object.assign(t,{[r]:e[r]})}),t}class fe{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=B(E(this,"addOptions",{name:this.name}))),this.storage=B(E(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new fe(e)}configure(e={}){const t=this.extend();return t.options=Hi(this.options,e),t.storage=B(E(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new fe(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=B(E(t,"addOptions",{name:t.name})),t.storage=B(E(t,"addStorage",{name:t.name,options:t.options})),t}}function zc(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=` `,textSerializers:o={}}=t||{};let a="",l=!0;return n.nodesBetween(r,i,(c,u,d,f)=>{var h;const p=o==null?void 0:o[c.type.name];p?(c.isBlock&&!l&&(a+=s,l=!0),d&&(a+=p({node:c,pos:u,parent:d,index:f,range:e}))):c.isText?(a+=(h=c==null?void 0:c.text)===null||h===void 0?void 0:h.slice(Math.max(r,u)-u,i-u),l=!1):c.isBlock&&!l&&(a+=s,l=!0)}),a}function Hc(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const jh=fe.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new re({key:new he("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),a=Math.max(...s.map(u=>u.$to.pos)),l=Hc(t);return zc(r,{from:o,to:a},{textSerializers:l})}}})]}}),Wh=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),qh=(n=!1)=>({commands:e})=>e.setContent("",n),Kh=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(l)),f=c.resolve(u.map(l+a.nodeSize)),h=d.blockRange(f);if(!h)return;const p=Hn(h);if(a.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Uh=n=>e=>n(e),Jh=()=>({state:n,dispatch:e})=>mh(n,e),_h=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new L(r.doc.resolve(o-1))),!0},Gh=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const a=i.before(s),l=i.after(s);n.delete(a,l).scrollIntoView()}return!0}return!1},Yh=n=>({tr:e,state:t,dispatch:r})=>{const i=le(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const l=s.before(o),c=s.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},Xh=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},Qh=()=>({state:n,dispatch:e})=>rh(n,e),Zh=()=>({commands:n})=>n.keyboardShortcut("Enter"),ep=()=>({state:n,dispatch:e})=>ph(n,e);function li(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:po(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function Fs(n,e,t={}){return n.find(r=>r.type===e&&li(r.attrs,t))}function tp(n,e,t={}){return!!Fs(n,e,t)}function mo(n,e,t={}){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if(n.parentOffset===r.offset&&r.offset!==0&&(r=n.parent.childBefore(n.parentOffset)),!r.node)return;const i=Fs([...r.node.marks],e,t);if(!i)return;let s=r.index,o=n.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(Fs([...r.node.marks],e,t);s>0&&i.isInSet(n.parent.child(s-1).marks);)s-=1,o-=n.parent.child(s).nodeSize;for(;a({tr:t,state:r,dispatch:i})=>{const s=Lt(n,r.schema),{doc:o,selection:a}=t,{$from:l,from:c,to:u}=a;if(i){const d=mo(l,s,e);if(d&&d.from<=c&&d.to>=u){const f=L.create(o,d.from,d.to);t.setSelection(f)}}return!0},rp=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{yo()&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!go(t.state.selection))return o(),!0;const a=Fc(i.doc,n)||t.state.selection,l=t.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},sp=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),op=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e);function za(n){const e=`${n}`;return new window.DOMParser().parseFromString(e,"text/html").body}function ci(n,e,t){if(t={slice:!0,parseOptions:{},...t},typeof n=="object"&&n!==null)try{return Array.isArray(n)&&n.length>0?S.fromArray(n.map(r=>e.nodeFromJSON(r))):e.nodeFromJSON(n)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",r),ci("",e,t)}if(typeof n=="string"){const r=Tn.fromSchema(e);return t.slice?r.parseSlice(za(n),t.parseOptions).content:r.parse(za(n),t.parseOptions)}return ci("",e,t)}function ap(n,e,t){const r=n.steps.length-1;if(r{o===0&&(o=u)}),n.setSelection(z.near(n.doc.resolve(o),t))}const lp=n=>n.toString().startsWith("<"),cp=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{if(i){t={parseOptions:{},updateSelection:!0,...t};const o=ci(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions}});if(o.toString()==="<>")return!0;let{from:a,to:l}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},c=!0,u=!0;if((lp(o)?o:[o]).forEach(f=>{f.check(),c=c?f.isText&&f.marks.length===0:!1,u=u?f.isBlock:!1}),a===l&&u){const{parent:f}=r.doc.resolve(a);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(a-=1,l+=1)}c?Array.isArray(e)?r.insertText(e.map(f=>f.text||"").join(""),a,l):typeof e=="object"&&e&&e.text?r.insertText(e.text,a,l):r.insertText(e,a,l):r.replaceWith(a,l,o),t.updateSelection&&ap(r,r.steps.length-1,-1)}return!0},up=()=>({state:n,dispatch:e})=>uh(n,e),dp=()=>({state:n,dispatch:e})=>dh(n,e),fp=()=>({state:n,dispatch:e})=>sh(n,e),hp=()=>({state:n,dispatch:e})=>lh(n,e),pp=()=>({tr:n,state:e,dispatch:t})=>{try{const r=Ai(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},mp=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ai(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}};function bo(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function gp(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,o;for(let a=0;a({editor:e,view:t,tr:r,dispatch:i})=>{const s=gp(n).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,a))});return l==null||l.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function fr(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,o=e?le(e,n.schema):null,a=[];n.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(i,f+d.nodeSize);a.push({node:d,from:h,to:p})});const l=i-r,c=a.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>li(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=l}const bp=(n,e={})=>({state:t,dispatch:r})=>{const i=le(n,t.schema);return fr(t,i,e)?fh(t,r):!1},vp=()=>({state:n,dispatch:e})=>gh(n,e),kp=n=>({state:e,dispatch:t})=>{const r=le(n,e.schema);return Mh(r)(e,t)},xp=()=>({state:n,dispatch:e})=>hh(n,e);function Fi(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Ha(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}const Sp=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const a=Fi(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(s=le(n,r.schema)),a==="mark"&&(o=Lt(n,r.schema)),i&&t.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,u)=>{s&&s===c.type&&t.setNodeMarkup(u,void 0,Ha(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&t.addMark(u,u+c.nodeSize,o.create(Ha(d.attrs,e)))})})}),!0):!1},wp=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Mp=()=>({tr:n,commands:e})=>e.setTextSelection({from:0,to:n.doc.content.size}),Cp=()=>({state:n,dispatch:e})=>oh(n,e),Op=()=>({state:n,dispatch:e})=>ch(n,e),Tp=()=>({state:n,dispatch:e})=>yh(n,e),Ep=()=>({state:n,dispatch:e})=>kh(n,e),Ap=()=>({state:n,dispatch:e})=>vh(n,e);function $c(n,e,t={}){return ci(n,e,{slice:!1,parseOptions:t})}const Np=(n,e=!1,t={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,a=$c(n,i.schema,t);return s&&r.replaceWith(0,o.content.size,a).setMeta("preventUpdate",!e),!0};function $i(n,e){const t=Lt(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===t.name);return a?{...a.attrs}:{}}function Dp(n,e){const t=new Gl(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function Ip(n){for(let e=0;e{t(i)&&r.push({node:i,pos:s})}),r}function Pp(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function vo(n){return e=>Pp(e.$from,n)}function Lp(n,e){const t=Qe.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}function Bp(n,e){const t={from:0,to:n.content.size};return zc(n,t,e)}function zp(n,e){const t=le(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,a=>{s.push(a)});const o=s.reverse().find(a=>a.type.name===t.name);return o?{...o.attrs}:{}}function Vc(n,e){const t=Fi(typeof e=="string"?e:e.name,n.schema);return t==="node"?zp(n,e):t==="mark"?$i(n,e):{}}function Hp(n,e=JSON.stringify){const t={};return n.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Fp(n){const e=Hp(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,o)=>o!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function $p(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((a,l)=>{o.push({from:a,to:l})});else{const{from:a,to:l}=t[s];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{const c=e.slice(s).map(a,-1),u=e.slice(s).map(l),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),Fp(r)}function ko(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n-1),o=mo(s,i.type);o&&r.push({mark:i,...o})}):t.nodesBetween(n,e,(i,s)=>{r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}function Kr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function $s(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?Lt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>li(d.attrs,t,{strict:!1}));let o=0;const a=[];if(i.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;n.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const b=Math.max(h,g),x=Math.min(p,g+m.nodeSize),M=x-b;o+=M,a.push(...m.marks.map(y=>({mark:y,from:b,to:x})))})}),o===0)return!1;const l=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>li(d.mark.attrs,t,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=a.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(l>0?l+c:l)>=o}function Vp(n,e,t={}){if(!e)return fr(n,null,t)||$s(n,null,t);const r=Fi(e,n.schema);return r==="node"?fr(n,e,t):r==="mark"?$s(n,e,t):!1}function Fa(n,e){const{nodeExtensions:t}=Bi(e),r=t.find(o=>o.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=B(E(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function jp(n){var e;const t=(e=n.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),r=n.toJSON();return JSON.stringify(t)===JSON.stringify(r)}function Wp(n){return n instanceof R}function qp(n,e,t){const i=n.state.doc.content.size,s=ft(e,0,i),o=ft(t,0,i),a=n.coordsAtPos(s),l=n.coordsAtPos(o,-1),c=Math.min(a.top,l.top),u=Math.max(a.bottom,l.bottom),d=Math.min(a.left,l.left),f=Math.max(a.right,l.right),h=f-d,p=u-c,b={top:c,bottom:u,left:d,right:f,width:h,height:p,x:d,y:c};return{...b,toJSON:()=>b}}function Kp(n,e,t){var r;const{selection:i}=e;let s=null;if(go(i)&&(s=i.$cursor),s){const a=(r=n.storedMarks)!==null&&r!==void 0?r:s.marks();return!!t.isInSet(a)||!a.some(l=>l.type.excludes(t))}const{ranges:o}=i;return o.some(({$from:a,$to:l})=>{let c=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(a.pos,l.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const Up=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:a}=s,l=Lt(n,r.schema);if(i)if(o){const c=$i(r,l);t.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(b=>b.type===l)?f.marks.forEach(b=>{l===b.type&&t.addMark(p,m,l.create({...b.attrs,...e}))}):t.addMark(p,m,l.create(e))})});return Kp(r,t,l)},Jp=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),_p=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=le(n,t.schema);return s.isTextblock?i().command(({commands:o})=>Ra(s,e)(t)?!0:o.clearNodes()).command(({state:o})=>Ra(s,e)(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Gp=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=ft(n,0,r.content.size),s=R.create(r,i);e.setSelection(s)}return!0},Yp=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,o=L.atStart(r).from,a=L.atEnd(r).to,l=ft(i,o,a),c=ft(s,o,a),u=L.create(r,l,c);e.setSelection(u)}return!0},Xp=n=>({state:e,dispatch:t})=>{const r=le(n,e.schema);return Th(r)(e,t)};function $a(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(r)}}const Qp=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:a,$to:l}=s,c=i.extensionManager.attributes,u=Kr(c,a.node().type.name,a.node().attrs);if(s instanceof R&&s.node.isBlock)return!a.parentOffset||!Mn(o,a.pos)?!1:(r&&(n&&$a(t,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(r){const d=l.parentOffset===l.parent.content.size;s instanceof L&&e.deleteSelection();const f=a.depth===0?void 0:Ip(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=Mn(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!p&&Mn(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),p&&(e.split(e.mapping.map(a.pos),1,h),f&&!d&&!a.parentOffset&&a.parent.type!==f)){const m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}n&&$a(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Zp=n=>({tr:e,state:t,dispatch:r,editor:i})=>{var s;const o=le(n,t.schema),{$from:a,$to:l}=t.selection,c=t.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const u=a.node(-1);if(u.type!==o)return!1;const d=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==o||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let g=S.empty;const b=a.index(-1)?1:a.index(-2)?2:3;for(let N=a.depth-b;N>=a.depth-3;N-=1)g=S.from(a.node(N).copy(g));const x=a.indexAfter(-1){if(v>-1)return!1;N.isTextblock&&N.content.size===0&&(v=I+1)}),v>-1&&e.setSelection(L.near(e.doc.resolve(v))),e.scrollIntoView()}return!0}const f=l.pos===a.end()?u.contentMatchAt(0).defaultType:null,h=Kr(d,u.type.name,u.attrs),p=Kr(d,a.node().type.name,a.node().attrs);e.delete(a.pos,l.pos);const m=f?[{type:o,attrs:h},{type:f,attrs:p}]:[{type:o,attrs:h}];if(!Mn(e.doc,a.pos,2))return!1;if(r){const{selection:g,storedMarks:b}=t,{splittableMarks:x}=i.extensionManager,M=b||g.$to.parentOffset&&g.$from.marks();if(e.split(a.pos,2,m).scrollIntoView(),!M||!r)return!0;const y=M.filter(T=>x.includes(T.type.name));e.ensureMarks(y)}return!0},ds=(n,e)=>{const t=vo(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Rt(n.doc,t.pos)&&n.join(t.pos),!0},fs=(n,e)=>{const t=vo(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Rt(n.doc,r)&&n.join(r),!0},em=(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=i.extensionManager,h=le(n,o.schema),p=le(e,o.schema),{selection:m,storedMarks:g}=o,{$from:b,$to:x}=m,M=b.blockRange(x),y=g||m.$to.parentOffset&&m.$from.marks();if(!M)return!1;const T=vo(v=>Fa(v.type.name,d))(m);if(M.depth>=1&&T&&M.depth-T.depth<=1){if(T.node.type===h)return c.liftListItem(p);if(Fa(T.node.type.name,d)&&h.validContent(T.node.content)&&a)return l().command(()=>(s.setNodeMarkup(T.pos,h),!0)).command(()=>ds(s,h)).command(()=>fs(s,h)).run()}return!t||!y||!a?l().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>ds(s,h)).command(()=>fs(s,h)).run():l().command(()=>{const v=u().wrapInList(h,r),N=y.filter(I=>f.includes(I.type.name));return s.ensureMarks(N),v?!0:c.clearNodes()}).wrapInList(h,r).command(()=>ds(s,h)).command(()=>fs(s,h)).run()},tm=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Lt(n,r.schema);return $s(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},nm=(n,e,t={})=>({state:r,commands:i})=>{const s=le(n,r.schema),o=le(e,r.schema);return fr(r,s,t)?i.setNode(o):i.setNode(s,t)},rm=(n,e={})=>({state:t,commands:r})=>{const i=le(n,t.schema);return fr(t,i,e)?r.lift(i):r.wrapIn(i,e)},im=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(s.text){const l=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,l))}else o.delete(s.from,s.to)}return!0}}return!1},sm=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},om=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=t,l=Lt(n,r.schema),{$from:c,empty:u,ranges:d}=a;if(!i)return!0;if(u&&o){let{from:f,to:h}=a;const p=(s=c.marks().find(g=>g.type===l))===null||s===void 0?void 0:s.attrs,m=mo(c,l,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,l)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,l)});return t.removeStoredMark(l),!0},am=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const a=Fi(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(s=le(n,r.schema)),a==="mark"&&(o=Lt(n,r.schema)),i&&t.selection.ranges.forEach(l=>{const c=l.$from.pos,u=l.$to.pos;r.doc.nodesBetween(c,u,(d,f)=>{s&&s===d.type&&t.setNodeMarkup(f,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(h=>{if(o===h.type){const p=Math.max(f,c),m=Math.min(f+d.nodeSize,u);t.addMark(p,m,o.create({...h.attrs,...e}))}})})}),!0):!1},lm=(n,e={})=>({state:t,dispatch:r})=>{const i=le(n,t.schema);return xh(i,e)(t,r)},cm=(n,e={})=>({state:t,dispatch:r})=>{const i=le(n,t.schema);return Sh(i,e)(t,r)};var um=Object.freeze({__proto__:null,blur:Wh,clearContent:qh,clearNodes:Kh,command:Uh,createParagraphNear:Jh,cut:_h,deleteCurrentNode:Gh,deleteNode:Yh,deleteRange:Xh,deleteSelection:Qh,enter:Zh,exitCode:ep,extendMarkRange:np,first:rp,focus:ip,forEach:sp,insertContent:op,insertContentAt:cp,joinUp:up,joinDown:dp,joinBackward:fp,joinForward:hp,joinItemBackward:pp,joinItemForward:mp,keyboardShortcut:yp,lift:bp,liftEmptyBlock:vp,liftListItem:kp,newlineInCode:xp,resetAttributes:Sp,scrollIntoView:wp,selectAll:Mp,selectNodeBackward:Cp,selectNodeForward:Op,selectParentNode:Tp,selectTextblockEnd:Ep,selectTextblockStart:Ap,setContent:Np,setMark:Up,setMeta:Jp,setNode:_p,setNodeSelection:Gp,setTextSelection:Yp,sinkListItem:Xp,splitBlock:Qp,splitListItem:Zp,toggleList:em,toggleMark:tm,toggleNode:nm,toggleWrap:rm,undoInputRule:im,unsetAllMarks:sm,unsetMark:om,updateAttributes:am,wrapIn:lm,wrapInList:cm});const dm=fe.create({name:"commands",addCommands(){return{...um}}}),fm=fe.create({name:"editable",addProseMirrorPlugins(){return[new re({key:new he("editable"),props:{editable:()=>this.editor.options.editable}})]}}),hm=fe.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new re({key:new he("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),pm=fe.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:u,$anchor:d}=l,{pos:f,parent:h}=d,p=d.parent.isTextblock?a.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,b=m&&p.parent.childCount===1?g===d.pos:z.atStart(c).from===f;return!u||!b||!h.type.isTextblock||h.textContent.length?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return yo()||bo()?s:i},addProseMirrorPlugins(){return[new re({key:new he("clearDocument"),appendTransaction:(n,e,t)=>{if(!(n.some(p=>p.docChanged)&&!e.doc.eq(t.doc)))return;const{empty:i,from:s,to:o}=e.selection,a=z.atStart(e.doc).from,l=z.atEnd(e.doc).to;if(i||!(s===a&&o===l)||!(t.doc.textBetween(0,t.doc.content.size," "," ").length===0))return;const d=t.tr,f=Pi({state:t,transaction:d}),{commands:h}=new Li({editor:this.editor,state:f});if(h.clearNodes(),!!d.steps.length)return d}})]}}),mm=fe.create({name:"tabindex",addProseMirrorPlugins(){return[new re({key:new he("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var gm=Object.freeze({__proto__:null,ClipboardTextSerializer:jh,Commands:dm,Editable:fm,FocusEvents:hm,Keymap:pm,Tabindex:mm});const ym=`.ProseMirror { position: relative; } .ProseMirror { word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces; -webkit-font-variant-ligatures: none; font-variant-ligatures: none; font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ } .ProseMirror [contenteditable="false"] { white-space: normal; } .ProseMirror [contenteditable="false"] [contenteditable="true"] { white-space: pre-wrap; } .ProseMirror pre { white-space: pre-wrap; } img.ProseMirror-separator { display: inline !important; border: none !important; margin: 0 !important; width: 1px !important; height: 1px !important; } .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; margin: 0; } .ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid black; animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; } @keyframes ProseMirror-cursor-blink { to { visibility: hidden; } } .ProseMirror-hideselection *::selection { background: transparent; } .ProseMirror-hideselection *::-moz-selection { background: transparent; } .ProseMirror-hideselection * { caret-color: transparent; } .ProseMirror-focused .ProseMirror-gapcursor { display: block; } .tippy-box[data-animation=fade][data-state=hidden] { opacity: 0 }`;function bm(n,e,t){const r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}class vm extends Eh{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=bm(ym,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=Bc(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});this.view.updateState(i)}unregisterPlugin(e){if(this.isDestroyed)return;const t=typeof e=="string"?`${e}$`:e.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(i=>!i.key.startsWith(t))});this.view.updateState(r)}createExtensionManager(){const t=[...this.options.enableCoreExtensions?Object.values(gm):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r==null?void 0:r.type));this.extensionManager=new vn(t,this)}createCommandManager(){this.commandManager=new Li({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=$c(this.options.content,this.schema,this.options.parseOptions),t=Fc(e,this.options.autofocus);this.view=new Jf(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:bn.create({doc:e,selection:t||void 0})});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(o)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),s=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),s&&this.emit("blur",{editor:this,event:s.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return Vc(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return Vp(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Lp(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=` `,textSerializers:r={}}=e||{};return Bp(this.state.doc,{blockSeparator:t,textSerializers:{...Hc(this.schema),...r}})}get isEmpty(){return jp(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}}function nn(n){return new zi({find:n.find,handler:({state:e,range:t,match:r})=>{const i=B(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),c=t.from+a.indexOf(o),u=c+o.length;if(ko(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===n.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;ut.from&&s.delete(t.from+l,c);const f=t.from+l+o.length;s.addMark(t.from+l,f,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function jc(n){return new zi({find:n.find,handler:({state:e,range:t,match:r})=>{const i=B(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let a=t.to;const l=n.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>a?u=a:a=u+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,o+r[0].length-1),s.replaceWith(u,a,l)}else r[0]&&s.insert(o-1,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(a));s.scrollIntoView()}})}function Vs(n){return new zi({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=B(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function hr(n){return new zi({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=B(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),l=o.doc.resolve(t.from).blockRange(),c=l&&to(l,n.type,s);if(!c)return null;if(o.wrap(l,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Rt(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)}})}class He{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=B(E(this,"addOptions",{name:this.name}))),this.storage=B(E(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new He(e)}configure(e={}){const t=this.extend();return t.options=Hi(this.options,e),t.storage=B(E(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new He(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=B(E(t,"addOptions",{name:t.name})),t.storage=B(E(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const l=o.find(c=>(c==null?void 0:c.type.name)===t.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}class ne{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=B(E(this,"addOptions",{name:this.name}))),this.storage=B(E(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ne(e)}configure(e={}){const t=this.extend();return t.options=Hi(this.options,e),t.storage=B(E(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new ne(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=B(E(t,"addOptions",{name:t.name})),t.storage=B(E(t,"addStorage",{name:t.name,options:t.options})),t}}function It(n){return new Bh({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=B(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let c=t.to;if(a){const u=l.search(/\S/),d=t.from+l.indexOf(a),f=d+a.length;if(ko(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>d).length)return null;ft.from&&o.delete(t.from+u,d),c=t.from+u+a.length,o.addMark(t.from+u,c,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}function km(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Te="top",Fe="bottom",$e="right",Ee="left",xo="auto",Sr=[Te,Fe,$e,Ee],Rn="start",pr="end",xm="clippingParents",Wc="viewport",Un="popper",Sm="reference",Va=Sr.reduce(function(n,e){return n.concat([e+"-"+Rn,e+"-"+pr])},[]),qc=[].concat(Sr,[xo]).reduce(function(n,e){return n.concat([e,e+"-"+Rn,e+"-"+pr])},[]),wm="beforeRead",Mm="read",Cm="afterRead",Om="beforeMain",Tm="main",Em="afterMain",Am="beforeWrite",Nm="write",Dm="afterWrite",Im=[wm,Mm,Cm,Om,Tm,Em,Am,Nm,Dm];function rt(n){return n?(n.nodeName||"").toLowerCase():null}function De(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var e=n.ownerDocument;return e&&e.defaultView||window}return n}function rn(n){var e=De(n).Element;return n instanceof e||n instanceof Element}function ze(n){var e=De(n).HTMLElement;return n instanceof e||n instanceof HTMLElement}function So(n){if(typeof ShadowRoot>"u")return!1;var e=De(n).ShadowRoot;return n instanceof e||n instanceof ShadowRoot}function Rm(n){var e=n.state;Object.keys(e.elements).forEach(function(t){var r=e.styles[t]||{},i=e.attributes[t]||{},s=e.elements[t];!ze(s)||!rt(s)||(Object.assign(s.style,r),Object.keys(i).forEach(function(o){var a=i[o];a===!1?s.removeAttribute(o):s.setAttribute(o,a===!0?"":a)}))})}function Pm(n){var e=n.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(r){var i=e.elements[r],s=e.attributes[r]||{},o=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:t[r]),a=o.reduce(function(l,c){return l[c]="",l},{});!ze(i)||!rt(i)||(Object.assign(i.style,a),Object.keys(s).forEach(function(l){i.removeAttribute(l)}))})}}const Kc={name:"applyStyles",enabled:!0,phase:"write",fn:Rm,effect:Pm,requires:["computeStyles"]};function et(n){return n.split("-")[0]}var Qt=Math.max,ui=Math.min,Pn=Math.round;function js(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Uc(){return!/^((?!chrome|android).)*safari/i.test(js())}function Ln(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var r=n.getBoundingClientRect(),i=1,s=1;e&&ze(n)&&(i=n.offsetWidth>0&&Pn(r.width)/n.offsetWidth||1,s=n.offsetHeight>0&&Pn(r.height)/n.offsetHeight||1);var o=rn(n)?De(n):window,a=o.visualViewport,l=!Uc()&&t,c=(r.left+(l&&a?a.offsetLeft:0))/i,u=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/i,f=r.height/s;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}function wo(n){var e=Ln(n),t=n.offsetWidth,r=n.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:n.offsetLeft,y:n.offsetTop,width:t,height:r}}function Jc(n,e){var t=e.getRootNode&&e.getRootNode();if(n.contains(e))return!0;if(t&&So(t)){var r=e;do{if(r&&n.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function pt(n){return De(n).getComputedStyle(n)}function Lm(n){return["table","td","th"].indexOf(rt(n))>=0}function Bt(n){return((rn(n)?n.ownerDocument:n.document)||window.document).documentElement}function Vi(n){return rt(n)==="html"?n:n.assignedSlot||n.parentNode||(So(n)?n.host:null)||Bt(n)}function ja(n){return!ze(n)||pt(n).position==="fixed"?null:n.offsetParent}function Bm(n){var e=/firefox/i.test(js()),t=/Trident/i.test(js());if(t&&ze(n)){var r=pt(n);if(r.position==="fixed")return null}var i=Vi(n);for(So(i)&&(i=i.host);ze(i)&&["html","body"].indexOf(rt(i))<0;){var s=pt(i);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return i;i=i.parentNode}return null}function wr(n){for(var e=De(n),t=ja(n);t&&Lm(t)&&pt(t).position==="static";)t=ja(t);return t&&(rt(t)==="html"||rt(t)==="body"&&pt(t).position==="static")?e:t||Bm(n)||e}function Mo(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function er(n,e,t){return Qt(n,ui(e,t))}function zm(n,e,t){var r=er(n,e,t);return r>t?t:r}function _c(){return{top:0,right:0,bottom:0,left:0}}function Gc(n){return Object.assign({},_c(),n)}function Yc(n,e){return e.reduce(function(t,r){return t[r]=n,t},{})}var Hm=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,Gc(typeof e!="number"?e:Yc(e,Sr))};function Fm(n){var e,t=n.state,r=n.name,i=n.options,s=t.elements.arrow,o=t.modifiersData.popperOffsets,a=et(t.placement),l=Mo(a),c=[Ee,$e].indexOf(a)>=0,u=c?"height":"width";if(!(!s||!o)){var d=Hm(i.padding,t),f=wo(s),h=l==="y"?Te:Ee,p=l==="y"?Fe:$e,m=t.rects.reference[u]+t.rects.reference[l]-o[l]-t.rects.popper[u],g=o[l]-t.rects.reference[l],b=wr(s),x=b?l==="y"?b.clientHeight||0:b.clientWidth||0:0,M=m/2-g/2,y=d[h],T=x-f[u]-d[p],v=x/2-f[u]/2+M,N=er(y,v,T),I=l;t.modifiersData[r]=(e={},e[I]=N,e.centerOffset=N-v,e)}}function $m(n){var e=n.state,t=n.options,r=t.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||Jc(e.elements.popper,i)&&(e.elements.arrow=i))}const Vm={name:"arrow",enabled:!0,phase:"main",fn:Fm,effect:$m,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Bn(n){return n.split("-")[1]}var jm={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Wm(n,e){var t=n.x,r=n.y,i=e.devicePixelRatio||1;return{x:Pn(t*i)/i||0,y:Pn(r*i)/i||0}}function Wa(n){var e,t=n.popper,r=n.popperRect,i=n.placement,s=n.variation,o=n.offsets,a=n.position,l=n.gpuAcceleration,c=n.adaptive,u=n.roundOffsets,d=n.isFixed,f=o.x,h=f===void 0?0:f,p=o.y,m=p===void 0?0:p,g=typeof u=="function"?u({x:h,y:m}):{x:h,y:m};h=g.x,m=g.y;var b=o.hasOwnProperty("x"),x=o.hasOwnProperty("y"),M=Ee,y=Te,T=window;if(c){var v=wr(t),N="clientHeight",I="clientWidth";if(v===De(t)&&(v=Bt(t),pt(v).position!=="static"&&a==="absolute"&&(N="scrollHeight",I="scrollWidth")),v=v,i===Te||(i===Ee||i===$e)&&s===pr){y=Fe;var C=d&&v===T&&T.visualViewport?T.visualViewport.height:v[N];m-=C-r.height,m*=l?1:-1}if(i===Ee||(i===Te||i===Fe)&&s===pr){M=$e;var H=d&&v===T&&T.visualViewport?T.visualViewport.width:v[I];h-=H-r.width,h*=l?1:-1}}var V=Object.assign({position:a},c&&jm),F=u===!0?Wm({x:h,y:m},De(t)):{x:h,y:m};if(h=F.x,m=F.y,l){var W;return Object.assign({},V,(W={},W[y]=x?"0":"",W[M]=b?"0":"",W.transform=(T.devicePixelRatio||1)<=1?"translate("+h+"px, "+m+"px)":"translate3d("+h+"px, "+m+"px, 0)",W))}return Object.assign({},V,(e={},e[y]=x?m+"px":"",e[M]=b?h+"px":"",e.transform="",e))}function qm(n){var e=n.state,t=n.options,r=t.gpuAcceleration,i=r===void 0?!0:r,s=t.adaptive,o=s===void 0?!0:s,a=t.roundOffsets,l=a===void 0?!0:a,c={placement:et(e.placement),variation:Bn(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,Wa(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Wa(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const Km={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:qm,data:{}};var Hr={passive:!0};function Um(n){var e=n.state,t=n.instance,r=n.options,i=r.scroll,s=i===void 0?!0:i,o=r.resize,a=o===void 0?!0:o,l=De(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",t.update,Hr)}),a&&l.addEventListener("resize",t.update,Hr),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",t.update,Hr)}),a&&l.removeEventListener("resize",t.update,Hr)}}const Jm={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Um,data:{}};var _m={left:"right",right:"left",bottom:"top",top:"bottom"};function Ur(n){return n.replace(/left|right|bottom|top/g,function(e){return _m[e]})}var Gm={start:"end",end:"start"};function qa(n){return n.replace(/start|end/g,function(e){return Gm[e]})}function Co(n){var e=De(n),t=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:t,scrollTop:r}}function Oo(n){return Ln(Bt(n)).left+Co(n).scrollLeft}function Ym(n,e){var t=De(n),r=Bt(n),i=t.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;var c=Uc();(c||!c&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a+Oo(n),y:l}}function Xm(n){var e,t=Bt(n),r=Co(n),i=(e=n.ownerDocument)==null?void 0:e.body,s=Qt(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=Qt(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+Oo(n),l=-r.scrollTop;return pt(i||t).direction==="rtl"&&(a+=Qt(t.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:a,y:l}}function To(n){var e=pt(n),t=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+r)}function Xc(n){return["html","body","#document"].indexOf(rt(n))>=0?n.ownerDocument.body:ze(n)&&To(n)?n:Xc(Vi(n))}function tr(n,e){var t;e===void 0&&(e=[]);var r=Xc(n),i=r===((t=n.ownerDocument)==null?void 0:t.body),s=De(r),o=i?[s].concat(s.visualViewport||[],To(r)?r:[]):r,a=e.concat(o);return i?a:a.concat(tr(Vi(o)))}function Ws(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function Qm(n,e){var t=Ln(n,!1,e==="fixed");return t.top=t.top+n.clientTop,t.left=t.left+n.clientLeft,t.bottom=t.top+n.clientHeight,t.right=t.left+n.clientWidth,t.width=n.clientWidth,t.height=n.clientHeight,t.x=t.left,t.y=t.top,t}function Ka(n,e,t){return e===Wc?Ws(Ym(n,t)):rn(e)?Qm(e,t):Ws(Xm(Bt(n)))}function Zm(n){var e=tr(Vi(n)),t=["absolute","fixed"].indexOf(pt(n).position)>=0,r=t&&ze(n)?wr(n):n;return rn(r)?e.filter(function(i){return rn(i)&&Jc(i,r)&&rt(i)!=="body"}):[]}function eg(n,e,t,r){var i=e==="clippingParents"?Zm(n):[].concat(e),s=[].concat(i,[t]),o=s[0],a=s.reduce(function(l,c){var u=Ka(n,c,r);return l.top=Qt(u.top,l.top),l.right=ui(u.right,l.right),l.bottom=ui(u.bottom,l.bottom),l.left=Qt(u.left,l.left),l},Ka(n,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function Qc(n){var e=n.reference,t=n.element,r=n.placement,i=r?et(r):null,s=r?Bn(r):null,o=e.x+e.width/2-t.width/2,a=e.y+e.height/2-t.height/2,l;switch(i){case Te:l={x:o,y:e.y-t.height};break;case Fe:l={x:o,y:e.y+e.height};break;case $e:l={x:e.x+e.width,y:a};break;case Ee:l={x:e.x-t.width,y:a};break;default:l={x:e.x,y:e.y}}var c=i?Mo(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case Rn:l[c]=l[c]-(e[u]/2-t[u]/2);break;case pr:l[c]=l[c]+(e[u]/2-t[u]/2);break}}return l}function mr(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=r===void 0?n.placement:r,s=t.strategy,o=s===void 0?n.strategy:s,a=t.boundary,l=a===void 0?xm:a,c=t.rootBoundary,u=c===void 0?Wc:c,d=t.elementContext,f=d===void 0?Un:d,h=t.altBoundary,p=h===void 0?!1:h,m=t.padding,g=m===void 0?0:m,b=Gc(typeof g!="number"?g:Yc(g,Sr)),x=f===Un?Sm:Un,M=n.rects.popper,y=n.elements[p?x:f],T=eg(rn(y)?y:y.contextElement||Bt(n.elements.popper),l,u,o),v=Ln(n.elements.reference),N=Qc({reference:v,element:M,strategy:"absolute",placement:i}),I=Ws(Object.assign({},M,N)),C=f===Un?I:v,H={top:T.top-C.top+b.top,bottom:C.bottom-T.bottom+b.bottom,left:T.left-C.left+b.left,right:C.right-T.right+b.right},V=n.modifiersData.offset;if(f===Un&&V){var F=V[i];Object.keys(H).forEach(function(W){var G=[$e,Fe].indexOf(W)>=0?1:-1,X=[Te,Fe].indexOf(W)>=0?"y":"x";H[W]+=F[X]*G})}return H}function tg(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=t.boundary,s=t.rootBoundary,o=t.padding,a=t.flipVariations,l=t.allowedAutoPlacements,c=l===void 0?qc:l,u=Bn(r),d=u?a?Va:Va.filter(function(p){return Bn(p)===u}):Sr,f=d.filter(function(p){return c.indexOf(p)>=0});f.length===0&&(f=d);var h=f.reduce(function(p,m){return p[m]=mr(n,{placement:m,boundary:i,rootBoundary:s,padding:o})[et(m)],p},{});return Object.keys(h).sort(function(p,m){return h[p]-h[m]})}function ng(n){if(et(n)===xo)return[];var e=Ur(n);return[qa(n),e,qa(e)]}function rg(n){var e=n.state,t=n.options,r=n.name;if(!e.modifiersData[r]._skip){for(var i=t.mainAxis,s=i===void 0?!0:i,o=t.altAxis,a=o===void 0?!0:o,l=t.fallbackPlacements,c=t.padding,u=t.boundary,d=t.rootBoundary,f=t.altBoundary,h=t.flipVariations,p=h===void 0?!0:h,m=t.allowedAutoPlacements,g=e.options.placement,b=et(g),x=b===g,M=l||(x||!p?[Ur(g)]:ng(g)),y=[g].concat(M).reduce(function(it,Ve){return it.concat(et(Ve)===xo?tg(e,{placement:Ve,boundary:u,rootBoundary:d,padding:c,flipVariations:p,allowedAutoPlacements:m}):Ve)},[]),T=e.rects.reference,v=e.rects.popper,N=new Map,I=!0,C=y[0],H=0;H=0,X=G?"width":"height",J=mr(e,{placement:V,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),j=G?W?$e:Ee:W?Fe:Te;T[X]>v[X]&&(j=Ur(j));var K=Ur(j),Y=[];if(s&&Y.push(J[F]<=0),a&&Y.push(J[j]<=0,J[K]<=0),Y.every(function(it){return it})){C=V,I=!1;break}N.set(V,Y)}if(I)for(var ie=p?3:1,pe=function(Ve){var st=y.find(function(sn){var ot=N.get(sn);if(ot)return ot.slice(0,Ve).every(function(on){return on})});if(st)return C=st,"break"},be=ie;be>0;be--){var Ie=pe(be);if(Ie==="break")break}e.placement!==C&&(e.modifiersData[r]._skip=!0,e.placement=C,e.reset=!0)}}const ig={name:"flip",enabled:!0,phase:"main",fn:rg,requiresIfExists:["offset"],data:{_skip:!1}};function Ua(n,e,t){return t===void 0&&(t={x:0,y:0}),{top:n.top-e.height-t.y,right:n.right-e.width+t.x,bottom:n.bottom-e.height+t.y,left:n.left-e.width-t.x}}function Ja(n){return[Te,$e,Fe,Ee].some(function(e){return n[e]>=0})}function sg(n){var e=n.state,t=n.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=mr(e,{elementContext:"reference"}),a=mr(e,{altBoundary:!0}),l=Ua(o,r),c=Ua(a,i,s),u=Ja(l),d=Ja(c);e.modifiersData[t]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const og={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:sg};function ag(n,e,t){var r=et(n),i=[Ee,Te].indexOf(r)>=0?-1:1,s=typeof t=="function"?t(Object.assign({},e,{placement:n})):t,o=s[0],a=s[1];return o=o||0,a=(a||0)*i,[Ee,$e].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}function lg(n){var e=n.state,t=n.options,r=n.name,i=t.offset,s=i===void 0?[0,0]:i,o=qc.reduce(function(u,d){return u[d]=ag(d,e.rects,s),u},{}),a=o[e.placement],l=a.x,c=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=o}const cg={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:lg};function ug(n){var e=n.state,t=n.name;e.modifiersData[t]=Qc({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const dg={name:"popperOffsets",enabled:!0,phase:"read",fn:ug,data:{}};function fg(n){return n==="x"?"y":"x"}function hg(n){var e=n.state,t=n.options,r=n.name,i=t.mainAxis,s=i===void 0?!0:i,o=t.altAxis,a=o===void 0?!1:o,l=t.boundary,c=t.rootBoundary,u=t.altBoundary,d=t.padding,f=t.tether,h=f===void 0?!0:f,p=t.tetherOffset,m=p===void 0?0:p,g=mr(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),b=et(e.placement),x=Bn(e.placement),M=!x,y=Mo(b),T=fg(y),v=e.modifiersData.popperOffsets,N=e.rects.reference,I=e.rects.popper,C=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,H=typeof C=="number"?{mainAxis:C,altAxis:C}:Object.assign({mainAxis:0,altAxis:0},C),V=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,F={x:0,y:0};if(v){if(s){var W,G=y==="y"?Te:Ee,X=y==="y"?Fe:$e,J=y==="y"?"height":"width",j=v[y],K=j+g[G],Y=j-g[X],ie=h?-I[J]/2:0,pe=x===Rn?N[J]:I[J],be=x===Rn?-I[J]:-N[J],Ie=e.elements.arrow,it=h&&Ie?wo(Ie):{width:0,height:0},Ve=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:_c(),st=Ve[G],sn=Ve[X],ot=er(0,N[J],it[J]),on=M?N[J]/2-ie-ot-st-H.mainAxis:pe-ot-st-H.mainAxis,mt=M?-N[J]/2+ie+ot+sn+H.mainAxis:be+ot+sn+H.mainAxis,an=e.elements.arrow&&wr(e.elements.arrow),Mr=an?y==="y"?an.clientTop||0:an.clientLeft||0:0,$n=(W=V==null?void 0:V[y])!=null?W:0,Cr=j+on-$n-Mr,Or=j+mt-$n,Vn=er(h?ui(K,Cr):K,j,h?Qt(Y,Or):Y);v[y]=Vn,F[y]=Vn-j}if(a){var jn,Tr=y==="x"?Te:Ee,Er=y==="x"?Fe:$e,at=v[T],gt=T==="y"?"height":"width",Wn=at+g[Tr],zt=at-g[Er],qn=[Te,Ee].indexOf(b)!==-1,Ar=(jn=V==null?void 0:V[T])!=null?jn:0,Nr=qn?Wn:at-N[gt]-I[gt]-Ar+H.altAxis,Dr=qn?at+N[gt]+I[gt]-Ar-H.altAxis:zt,Ir=h&&qn?zm(Nr,at,Dr):er(h?Nr:Wn,at,h?Dr:zt);v[T]=Ir,F[T]=Ir-at}e.modifiersData[r]=F}}const pg={name:"preventOverflow",enabled:!0,phase:"main",fn:hg,requiresIfExists:["offset"]};function mg(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function gg(n){return n===De(n)||!ze(n)?Co(n):mg(n)}function yg(n){var e=n.getBoundingClientRect(),t=Pn(e.width)/n.offsetWidth||1,r=Pn(e.height)/n.offsetHeight||1;return t!==1||r!==1}function bg(n,e,t){t===void 0&&(t=!1);var r=ze(e),i=ze(e)&&yg(e),s=Bt(e),o=Ln(n,i,t),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!t)&&((rt(e)!=="body"||To(s))&&(a=gg(e)),ze(e)?(l=Ln(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=Oo(s))),{x:o.left+a.scrollLeft-l.x,y:o.top+a.scrollTop-l.y,width:o.width,height:o.height}}function vg(n){var e=new Map,t=new Set,r=[];n.forEach(function(s){e.set(s.name,s)});function i(s){t.add(s.name);var o=[].concat(s.requires||[],s.requiresIfExists||[]);o.forEach(function(a){if(!t.has(a)){var l=e.get(a);l&&i(l)}}),r.push(s)}return n.forEach(function(s){t.has(s.name)||i(s)}),r}function kg(n){var e=vg(n);return Im.reduce(function(t,r){return t.concat(e.filter(function(i){return i.phase===r}))},[])}function xg(n){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(n())})})),e}}function Sg(n){var e=n.reduce(function(t,r){var i=t[r.name];return t[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,t},{});return Object.keys(e).map(function(t){return e[t]})}var _a={placement:"bottom",modifiers:[],strategy:"absolute"};function Ga(){for(var n=arguments.length,e=new Array(n),t=0;t-1}function ru(n,e){return typeof n=="function"?n.apply(void 0,e):n}function Ya(n,e){if(e===0)return n;var t;return function(r){clearTimeout(t),t=setTimeout(function(){n(r)},e)}}function Ag(n,e){var t=Object.assign({},n);return e.forEach(function(r){delete t[r]}),t}function Ng(n){return n.split(/\s+/).filter(Boolean)}function gn(n){return[].concat(n)}function Xa(n,e){n.indexOf(e)===-1&&n.push(e)}function Dg(n){return n.filter(function(e,t){return n.indexOf(e)===t})}function Ig(n){return n.split("-")[0]}function di(n){return[].slice.call(n)}function Qa(n){return Object.keys(n).reduce(function(e,t){return n[t]!==void 0&&(e[t]=n[t]),e},{})}function nr(){return document.createElement("div")}function gr(n){return["Element","Fragment"].some(function(e){return Eo(n,e)})}function Rg(n){return Eo(n,"NodeList")}function Pg(n){return Eo(n,"MouseEvent")}function Lg(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function Bg(n){return gr(n)?[n]:Rg(n)?di(n):Array.isArray(n)?n:di(document.querySelectorAll(n))}function ps(n,e){n.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function Za(n,e){n.forEach(function(t){t&&t.setAttribute("data-state",e)})}function zg(n){var e,t=gn(n),r=t[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function Hg(n,e){var t=e.clientX,r=e.clientY;return n.every(function(i){var s=i.popperRect,o=i.popperState,a=i.props,l=a.interactiveBorder,c=Ig(o.placement),u=o.modifiersData.offset;if(!u)return!0;var d=c==="bottom"?u.top.y:0,f=c==="top"?u.bottom.y:0,h=c==="right"?u.left.x:0,p=c==="left"?u.right.x:0,m=s.top-r+d>l,g=r-s.bottom-f>l,b=s.left-t+h>l,x=t-s.right-p>l;return m||g||b||x})}function ms(n,e,t){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){n[r](i,t)})}function el(n,e){for(var t=e;t;){var r;if(n.contains(t))return!0;t=t.getRootNode==null||(r=t.getRootNode())==null?void 0:r.host}return!1}var Ye={isTouch:!1},tl=0;function Fg(){Ye.isTouch||(Ye.isTouch=!0,window.performance&&document.addEventListener("mousemove",iu))}function iu(){var n=performance.now();n-tl<20&&(Ye.isTouch=!1,document.removeEventListener("mousemove",iu)),tl=n}function $g(){var n=document.activeElement;if(Lg(n)){var e=n._tippy;n.blur&&!e.state.isVisible&&n.blur()}}function Vg(){document.addEventListener("touchstart",Fg,$t),window.addEventListener("blur",$g)}var jg=typeof window<"u"&&typeof document<"u",Wg=jg?!!window.msCrypto:!1;function fn(n){var e=n==="destroy"?"n already-":" ";return[n+"() was called on a"+e+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function nl(n){var e=/[ \t]{2,}/g,t=/^[ \t]*/gm;return n.replace(e," ").replace(t,"").trim()}function qg(n){return nl(` %ctippy.js %c`+nl(n)+` %c👷‍ This is a development-only message. It will be removed in production. `)}function su(n){return[qg(n),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var yr;Kg();function Kg(){yr=new Set}function dt(n,e){if(n&&!yr.has(e)){var t;yr.add(e),(t=console).warn.apply(t,su(e))}}function qs(n,e){if(n&&!yr.has(e)){var t;yr.add(e),(t=console).error.apply(t,su(e))}}function Ug(n){var e=!n,t=Object.prototype.toString.call(n)==="[object Object]"&&!n.addEventListener;qs(e,["tippy() was passed","`"+String(n)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),qs(t,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var ou={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Jg={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Ne=Object.assign({appendTo:nu,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},ou,Jg),_g=Object.keys(Ne),Gg=function(e){lu(e,[]);var t=Object.keys(e);t.forEach(function(r){Ne[r]=e[r]})};function au(n){var e=n.plugins||[],t=e.reduce(function(r,i){var s=i.name,o=i.defaultValue;if(s){var a;r[s]=n[s]!==void 0?n[s]:(a=Ne[s])!=null?a:o}return r},{});return Object.assign({},n,t)}function Yg(n,e){var t=e?Object.keys(au(Object.assign({},Ne,{plugins:e}))):_g,r=t.reduce(function(i,s){var o=(n.getAttribute("data-tippy-"+s)||"").trim();if(!o)return i;if(s==="content")i[s]=o;else try{i[s]=JSON.parse(o)}catch{i[s]=o}return i},{});return r}function rl(n,e){var t=Object.assign({},e,{content:ru(e.content,[n])},e.ignoreAttributes?{}:Yg(n,e.plugins));return t.aria=Object.assign({},Ne.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}function lu(n,e){n===void 0&&(n={}),e===void 0&&(e=[]);var t=Object.keys(n);t.forEach(function(r){var i=Ag(Ne,Object.keys(ou)),s=!Eg(i,r);s&&(s=e.filter(function(o){return o.name===r}).length===0),dt(s,["`"+r+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",` `,`All props: https://atomiks.github.io/tippyjs/v6/all-props/ `,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var Xg=function(){return"innerHTML"};function Ks(n,e){n[Xg()]=e}function il(n){var e=nr();return n===!0?e.className=eu:(e.className=tu,gr(n)?e.appendChild(n):Ks(e,n)),e}function sl(n,e){gr(e.content)?(Ks(n,""),n.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?Ks(n,e.content):n.textContent=e.content)}function Us(n){var e=n.firstElementChild,t=di(e.children);return{box:e,content:t.find(function(r){return r.classList.contains(Zc)}),arrow:t.find(function(r){return r.classList.contains(eu)||r.classList.contains(tu)}),backdrop:t.find(function(r){return r.classList.contains(Tg)})}}function cu(n){var e=nr(),t=nr();t.className=Og,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var r=nr();r.className=Zc,r.setAttribute("data-state","hidden"),sl(r,n.props),e.appendChild(t),t.appendChild(r),i(n.props,n.props);function i(s,o){var a=Us(e),l=a.box,c=a.content,u=a.arrow;o.theme?l.setAttribute("data-theme",o.theme):l.removeAttribute("data-theme"),typeof o.animation=="string"?l.setAttribute("data-animation",o.animation):l.removeAttribute("data-animation"),o.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof o.maxWidth=="number"?o.maxWidth+"px":o.maxWidth,o.role?l.setAttribute("role",o.role):l.removeAttribute("role"),(s.content!==o.content||s.allowHTML!==o.allowHTML)&&sl(c,n.props),o.arrow?u?s.arrow!==o.arrow&&(l.removeChild(u),l.appendChild(il(o.arrow))):l.appendChild(il(o.arrow)):u&&l.removeChild(u)}return{popper:e,onUpdate:i}}cu.$$tippy=!0;var Qg=1,Fr=[],gs=[];function Zg(n,e){var t=rl(n,Object.assign({},Ne,au(Qa(e)))),r,i,s,o=!1,a=!1,l=!1,c=!1,u,d,f,h=[],p=Ya(Cr,t.interactiveDebounce),m,g=Qg++,b=null,x=Dg(t.plugins),M={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:g,reference:n,popper:nr(),popperInstance:b,props:t,state:M,plugins:x,clearDelayTimeouts:Nr,setProps:Dr,setContent:Ir,show:vu,hide:ku,hideWithInteractivity:xu,enable:qn,disable:Ar,unmount:Su,destroy:wu};if(!t.render)return qs(!0,"render() function has not been supplied."),y;var T=t.render(y),v=T.popper,N=T.onUpdate;v.setAttribute("data-tippy-root",""),v.id="tippy-"+y.id,y.popper=v,n._tippy=y,v._tippy=y;var I=x.map(function(k){return k.fn(y)}),C=n.hasAttribute("aria-expanded");return an(),ie(),j(),K("onCreate",[y]),t.showOnCreate&&Wn(),v.addEventListener("mouseenter",function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),v.addEventListener("mouseleave",function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&G().addEventListener("mousemove",p)}),y;function H(){var k=y.props.touch;return Array.isArray(k)?k:[k,0]}function V(){return H()[0]==="hold"}function F(){var k;return!!((k=y.props.render)!=null&&k.$$tippy)}function W(){return m||n}function G(){var k=W().parentNode;return k?zg(k):document}function X(){return Us(v)}function J(k){return y.state.isMounted&&!y.state.isVisible||Ye.isTouch||u&&u.type==="focus"?0:hs(y.props.delay,k?0:1,Ne.delay)}function j(k){k===void 0&&(k=!1),v.style.pointerEvents=y.props.interactive&&!k?"":"none",v.style.zIndex=""+y.props.zIndex}function K(k,A,P){if(P===void 0&&(P=!0),I.forEach(function($){$[k]&&$[k].apply($,A)}),P){var q;(q=y.props)[k].apply(q,A)}}function Y(){var k=y.props.aria;if(k.content){var A="aria-"+k.content,P=v.id,q=gn(y.props.triggerTarget||n);q.forEach(function($){var ve=$.getAttribute(A);if(y.state.isVisible)$.setAttribute(A,ve?ve+" "+P:P);else{var Re=ve&&ve.replace(P,"").trim();Re?$.setAttribute(A,Re):$.removeAttribute(A)}})}}function ie(){if(!(C||!y.props.aria.expanded)){var k=gn(y.props.triggerTarget||n);k.forEach(function(A){y.props.interactive?A.setAttribute("aria-expanded",y.state.isVisible&&A===W()?"true":"false"):A.removeAttribute("aria-expanded")})}}function pe(){G().removeEventListener("mousemove",p),Fr=Fr.filter(function(k){return k!==p})}function be(k){if(!(Ye.isTouch&&(l||k.type==="mousedown"))){var A=k.composedPath&&k.composedPath()[0]||k.target;if(!(y.props.interactive&&el(v,A))){if(gn(y.props.triggerTarget||n).some(function(P){return el(P,A)})){if(Ye.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else K("onClickOutside",[y,k]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),a=!0,setTimeout(function(){a=!1}),y.state.isMounted||st())}}}function Ie(){l=!0}function it(){l=!1}function Ve(){var k=G();k.addEventListener("mousedown",be,!0),k.addEventListener("touchend",be,$t),k.addEventListener("touchstart",it,$t),k.addEventListener("touchmove",Ie,$t)}function st(){var k=G();k.removeEventListener("mousedown",be,!0),k.removeEventListener("touchend",be,$t),k.removeEventListener("touchstart",it,$t),k.removeEventListener("touchmove",Ie,$t)}function sn(k,A){on(k,function(){!y.state.isVisible&&v.parentNode&&v.parentNode.contains(v)&&A()})}function ot(k,A){on(k,A)}function on(k,A){var P=X().box;function q($){$.target===P&&(ms(P,"remove",q),A())}if(k===0)return A();ms(P,"remove",d),ms(P,"add",q),d=q}function mt(k,A,P){P===void 0&&(P=!1);var q=gn(y.props.triggerTarget||n);q.forEach(function($){$.addEventListener(k,A,P),h.push({node:$,eventType:k,handler:A,options:P})})}function an(){V()&&(mt("touchstart",$n,{passive:!0}),mt("touchend",Or,{passive:!0})),Ng(y.props.trigger).forEach(function(k){if(k!=="manual")switch(mt(k,$n),k){case"mouseenter":mt("mouseleave",Or);break;case"focus":mt(Wg?"focusout":"blur",Vn);break;case"focusin":mt("focusout",Vn);break}})}function Mr(){h.forEach(function(k){var A=k.node,P=k.eventType,q=k.handler,$=k.options;A.removeEventListener(P,q,$)}),h=[]}function $n(k){var A,P=!1;if(!(!y.state.isEnabled||jn(k)||a)){var q=((A=u)==null?void 0:A.type)==="focus";u=k,m=k.currentTarget,ie(),!y.state.isVisible&&Pg(k)&&Fr.forEach(function($){return $(k)}),k.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||o)&&y.props.hideOnClick!==!1&&y.state.isVisible?P=!0:Wn(k),k.type==="click"&&(o=!P),P&&!q&&zt(k)}}function Cr(k){var A=k.target,P=W().contains(A)||v.contains(A);if(!(k.type==="mousemove"&&P)){var q=gt().concat(v).map(function($){var ve,Re=$._tippy,ln=(ve=Re.popperInstance)==null?void 0:ve.state;return ln?{popperRect:$.getBoundingClientRect(),popperState:ln,props:t}:null}).filter(Boolean);Hg(q,k)&&(pe(),zt(k))}}function Or(k){var A=jn(k)||y.props.trigger.indexOf("click")>=0&&o;if(!A){if(y.props.interactive){y.hideWithInteractivity(k);return}zt(k)}}function Vn(k){y.props.trigger.indexOf("focusin")<0&&k.target!==W()||y.props.interactive&&k.relatedTarget&&v.contains(k.relatedTarget)||zt(k)}function jn(k){return Ye.isTouch?V()!==k.type.indexOf("touch")>=0:!1}function Tr(){Er();var k=y.props,A=k.popperOptions,P=k.placement,q=k.offset,$=k.getReferenceClientRect,ve=k.moveTransition,Re=F()?Us(v).arrow:null,ln=$?{getBoundingClientRect:$,contextElement:$.contextElement||W()}:n,Ho={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Rr){var cn=Rr.state;if(F()){var Mu=X(),qi=Mu.box;["placement","reference-hidden","escaped"].forEach(function(Pr){Pr==="placement"?qi.setAttribute("data-placement",cn.placement):cn.attributes.popper["data-popper-"+Pr]?qi.setAttribute("data-"+Pr,""):qi.removeAttribute("data-"+Pr)}),cn.attributes.popper={}}}},Ht=[{name:"offset",options:{offset:q}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ve}},Ho];F()&&Re&&Ht.push({name:"arrow",options:{element:Re,padding:3}}),Ht.push.apply(Ht,(A==null?void 0:A.modifiers)||[]),y.popperInstance=Cg(ln,v,Object.assign({},A,{placement:P,onFirstUpdate:f,modifiers:Ht}))}function Er(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function at(){var k=y.props.appendTo,A,P=W();y.props.interactive&&k===nu||k==="parent"?A=P.parentNode:A=ru(k,[P]),A.contains(v)||A.appendChild(v),y.state.isMounted=!0,Tr(),dt(y.props.interactive&&k===Ne.appendTo&&P.nextElementSibling!==v,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",` `,"Using a wrapper
or tag around the reference element","solves this by creating a new parentNode context.",` `,"Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.",` `,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function gt(){return di(v.querySelectorAll("[data-tippy-root]"))}function Wn(k){y.clearDelayTimeouts(),k&&K("onTrigger",[y,k]),Ve();var A=J(!0),P=H(),q=P[0],$=P[1];Ye.isTouch&&q==="hold"&&$&&(A=$),A?r=setTimeout(function(){y.show()},A):y.show()}function zt(k){if(y.clearDelayTimeouts(),K("onUntrigger",[y,k]),!y.state.isVisible){st();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(k.type)>=0&&o)){var A=J(!1);A?i=setTimeout(function(){y.state.isVisible&&y.hide()},A):s=requestAnimationFrame(function(){y.hide()})}}function qn(){y.state.isEnabled=!0}function Ar(){y.hide(),y.state.isEnabled=!1}function Nr(){clearTimeout(r),clearTimeout(i),cancelAnimationFrame(s)}function Dr(k){if(dt(y.state.isDestroyed,fn("setProps")),!y.state.isDestroyed){K("onBeforeUpdate",[y,k]),Mr();var A=y.props,P=rl(n,Object.assign({},A,Qa(k),{ignoreAttributes:!0}));y.props=P,an(),A.interactiveDebounce!==P.interactiveDebounce&&(pe(),p=Ya(Cr,P.interactiveDebounce)),A.triggerTarget&&!P.triggerTarget?gn(A.triggerTarget).forEach(function(q){q.removeAttribute("aria-expanded")}):P.triggerTarget&&n.removeAttribute("aria-expanded"),ie(),j(),N&&N(A,P),y.popperInstance&&(Tr(),gt().forEach(function(q){requestAnimationFrame(q._tippy.popperInstance.forceUpdate)})),K("onAfterUpdate",[y,k])}}function Ir(k){y.setProps({content:k})}function vu(){dt(y.state.isDestroyed,fn("show"));var k=y.state.isVisible,A=y.state.isDestroyed,P=!y.state.isEnabled,q=Ye.isTouch&&!y.props.touch,$=hs(y.props.duration,0,Ne.duration);if(!(k||A||P||q)&&!W().hasAttribute("disabled")&&(K("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,F()&&(v.style.visibility="visible"),j(),Ve(),y.state.isMounted||(v.style.transition="none"),F()){var ve=X(),Re=ve.box,ln=ve.content;ps([Re,ln],0)}f=function(){var Ht;if(!(!y.state.isVisible||c)){if(c=!0,v.offsetHeight,v.style.transition=y.props.moveTransition,F()&&y.props.animation){var Wi=X(),Rr=Wi.box,cn=Wi.content;ps([Rr,cn],$),Za([Rr,cn],"visible")}Y(),ie(),Xa(gs,y),(Ht=y.popperInstance)==null||Ht.forceUpdate(),K("onMount",[y]),y.props.animation&&F()&&ot($,function(){y.state.isShown=!0,K("onShown",[y])})}},at()}}function ku(){dt(y.state.isDestroyed,fn("hide"));var k=!y.state.isVisible,A=y.state.isDestroyed,P=!y.state.isEnabled,q=hs(y.props.duration,1,Ne.duration);if(!(k||A||P)&&(K("onHide",[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,c=!1,o=!1,F()&&(v.style.visibility="hidden"),pe(),st(),j(!0),F()){var $=X(),ve=$.box,Re=$.content;y.props.animation&&(ps([ve,Re],q),Za([ve,Re],"hidden"))}Y(),ie(),y.props.animation?F()&&sn(q,y.unmount):y.unmount()}}function xu(k){dt(y.state.isDestroyed,fn("hideWithInteractivity")),G().addEventListener("mousemove",p),Xa(Fr,p),p(k)}function Su(){dt(y.state.isDestroyed,fn("unmount")),y.state.isVisible&&y.hide(),y.state.isMounted&&(Er(),gt().forEach(function(k){k._tippy.unmount()}),v.parentNode&&v.parentNode.removeChild(v),gs=gs.filter(function(k){return k!==y}),y.state.isMounted=!1,K("onHidden",[y]))}function wu(){dt(y.state.isDestroyed,fn("destroy")),!y.state.isDestroyed&&(y.clearDelayTimeouts(),y.unmount(),Mr(),delete n._tippy,y.state.isDestroyed=!0,K("onDestroy",[y]))}}function Fn(n,e){e===void 0&&(e={});var t=Ne.plugins.concat(e.plugins||[]);Ug(n),lu(e,t),Vg();var r=Object.assign({},e,{plugins:t}),i=Bg(n);{var s=gr(r.content),o=i.length>1;dt(s&&o,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",` `,"Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.",` `,`1) content: element.innerHTML `,"2) content: () => element.cloneNode(true)"].join(" "))}var a=i.reduce(function(l,c){var u=c&&Zg(c,r);return u&&l.push(u),l},[]);return gr(n)?a[0]:a}Fn.defaultProps=Ne;Fn.setDefaultProps=Gg;Fn.currentInput=Ye;Object.assign({},Kc,{effect:function(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow)}});Fn.setDefaultProps({render:cu});class ey{constructor({editor:e,element:t,view:r,tippyOptions:i={},updateDelay:s=250,shouldShow:o}){this.preventHide=!1,this.shouldShow=({view:a,state:l,from:c,to:u})=>{const{doc:d,selection:f}=l,{empty:h}=f,p=!d.textBetween(c,u).length&&go(l.selection),m=this.element.contains(document.activeElement);return!(!(a.hasFocus()||m)||h||p||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:a})=>{var l;if(this.preventHide){this.preventHide=!1;return}a!=null&&a.relatedTarget&&(!((l=this.element.parentNode)===null||l===void 0)&&l.contains(a.relatedTarget))||this.hide()},this.tippyBlurHandler=a=>{this.blurHandler({event:a})},this.handleDebouncedUpdate=(a,l)=>{const c=!(l!=null&&l.selection.eq(a.state.selection)),u=!(l!=null&&l.doc.eq(a.state.doc));!c&&!u||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(a,c,u,l)},this.updateDelay))},this.updateHandler=(a,l,c,u)=>{var d,f,h;const{state:p,composing:m}=a,{selection:g}=p;if(m||!l&&!c)return;this.createTooltip();const{ranges:x}=g,M=Math.min(...x.map(v=>v.$from.pos)),y=Math.max(...x.map(v=>v.$to.pos));if(!((d=this.shouldShow)===null||d===void 0?void 0:d.call(this,{editor:this.editor,view:a,state:p,oldState:u,from:M,to:y}))){this.hide();return}(f=this.tippy)===null||f===void 0||f.setProps({getReferenceClientRect:((h=this.tippyOptions)===null||h===void 0?void 0:h.getReferenceClientRect)||(()=>{if(Wp(p.selection)){let v=a.nodeDOM(M);const N=v.dataset.nodeViewWrapper?v:v.querySelector("[data-node-view-wrapper]");if(N&&(v=N.firstChild),v)return v.getBoundingClientRect()}return qp(a,M,y)})}),this.show()},this.editor=e,this.element=t,this.view=r,this.updateDelay=s,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;this.tippy||!t||(this.tippy=Fn(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,t){const{state:r}=e,i=r.selection.$from.pos!==r.selection.$to.pos;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,t);return}const s=!(t!=null&&t.selection.eq(e.state.selection)),o=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,s,o,t)}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const ty=n=>new re({key:typeof n.pluginKey=="string"?new he(n.pluginKey):n.pluginKey,view:e=>new ey({view:e,...n})}),ny=fe.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[ty({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}}),ry=/^\s*>\s$/,iy=ne.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",_(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[hr({find:ry,type:this.type})]}}),sy=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/,oy=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g,ay=/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/,ly=/(?:^|\s)((?:__)((?:[^__]+))(?:__))/g,cy=He.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",_(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[nn({find:sy,type:this.type}),nn({find:ay,type:this.type})]},addPasteRules(){return[It({find:oy,type:this.type}),It({find:ly,type:this.type})]}}),uy=ne.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",_(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ol=He.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",_(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=$i(n,this.type);return Object.entries(t).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),al=/^\s*([-+*])\s$/,dy=ne.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",_(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(uy.name,this.editor.getAttributes(ol.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=hr({find:al,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=hr({find:al,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ol.name),editor:this.editor})),[n]}}),fy=/(?:^|\s)((?:`)((?:[^`]+))(?:`))$/,hy=/(?:^|\s)((?:`)((?:[^`]+))(?:`))/g,py=He.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",_(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[nn({find:fy,type:this.type})]},addPasteRules(){return[It({find:hy,type:this.type})]}}),my=/^```([a-z]+)?[\s\n]$/,gy=/^~~~([a-z]+)?[\s\n]$/,yy=ne.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",_(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` `);return!s||!o?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const a=i.after();return a===void 0||r.nodeAt(a)?!1:n.commands.exitCode()}}},addInputRules(){return[Vs({find:my,type:this.type,getAttributes:n=>({language:n[1]})}),Vs({find:gy,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new re({key:new he("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i==null?void 0:i.mode;if(!t||!s)return!1;const{tr:o}=n.state;return o.replaceSelectionWith(this.type.create({language:s})),o.setSelection(L.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.insertText(t.replace(/\r\n?/g,` `)),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),by=ne.create({name:"doc",topNode:!0,content:"block+"});function vy(n={}){return new re({view(e){return new ky(e,n)}})}class ky{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r;if(t){let a=e.nodeBefore,l=e.nodeAfter;if(a||l){let c=this.editorView.nodeDOM(this.cursorPos-(a?a.nodeSize:0));if(c){let u=c.getBoundingClientRect(),d=a?u.bottom:u.top;a&&l&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:u.left,right:u.right,top:d-this.width/2,bottom:d+this.width/2}}}}if(!r){let a=this.editorView.coordsAtPos(this.cursorPos);r={left:a.left-this.width/2,right:a.left+this.width/2,top:a.top,bottom:a.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let s,o;if(!i||i==document.body&&getComputedStyle(i).position=="static")s=-pageXOffset,o=-pageYOffset;else{let a=i.getBoundingClientRect();s=a.left-i.scrollLeft,o=a.top-i.scrollTop}this.element.style.left=r.left-s+"px",this.element.style.top=r.top-o+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=ql(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const xy=fe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[vy(this.options)]}});class Z extends z{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return Z.valid(r)?new Z(r):z.near(r)}content(){return O.empty}eq(e){return e instanceof Z&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Z(e.resolve(t.pos))}getBookmark(){return new Ao(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Sy(e)||!wy(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&Z.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let a=e.node(o);if(t>0?e.indexAfter(o)0){s=a.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let l=e.doc.resolve(i);if(Z.valid(l))return l}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!R.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let a=e.doc.resolve(i);if(Z.valid(a))return a}return null}}}Z.prototype.visible=!1;Z.findFrom=Z.findGapCursorFrom;z.jsonID("gapcursor",Z);class Ao{constructor(e){this.pos=e}map(e){return new Ao(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Z.valid(t)?new Z(t):z.near(t)}}function Sy(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function wy(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function My(){return new re({props:{decorations:Ey,createSelectionBetween(n,e,t){return e.pos==t.pos&&Z.valid(t)?new Z(t):null},handleClick:Oy,handleKeyDown:Cy,handleDOMEvents:{beforeinput:Ty}}})}const Cy=Ac({ArrowLeft:$r("horiz",-1),ArrowRight:$r("horiz",1),ArrowUp:$r("vert",-1),ArrowDown:$r("vert",1)});function $r(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof L){if(!s.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=Z.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new Z(c))),!0):!1}}function Oy(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Z.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&R.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Z(r))),!0)}function Ty(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Z))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=S.empty;for(let o=r.length-1;o>=0;o--)i=S.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new O(i,0,0));return s.setSelection(L.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Ey(n){if(!(n.selection instanceof Z))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ee.create(n.doc,[Ce.widget(n.selection.head,e,{key:"gapcursor"})])}const Ay=fe.create({name:"gapCursor",addProseMirrorPlugins(){return[My()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=B(E(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Ny=ne.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",_(this.options.HTMLAttributes,n)]},renderText(){return` `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&o){const d=l.filter(f=>a.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Dy=ne.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,_(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Vs({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var fi=200,ae=function(){};ae.prototype.append=function(e){return e.length?(e=ae.from(e),!this.length&&e||e.length=t?ae.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ae.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ae.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ae.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i};ae.from=function(e){return e instanceof ae?e:e&&e.length?new uu(e):ae.empty};var uu=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,a){for(var l=s;l=o;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=fi)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=fi)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(ae);ae.empty=new uu([]);var Iy=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return ra&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,s)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(s,a)-a,o+a)===!1||s=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(ae);const Ry=500;class We{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,a,l,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,u.push(d);return}if(i){u.push(new Ue(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Ue(p,void 0,void 0,c.length+u.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return a=i?d.selection.map(i.slice(s)):d.selection,l=new We(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,t,r,i){let s=[],o=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let u=0;uLy&&(a=Py(a,c),o-=c),new We(a.append(s),o)}remapping(e,t){let r=new wn;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new We(this.items.append(e.map(t=>new Ue(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},i);let l=t;this.items.forEach(f=>{let h=s.getMirror(--l);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(l+1,h));g&&a++,r.push(new Ue(p,m,g))}else r.push(new Ue(p))},i);let c=[];for(let f=t;fRy&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,a)=>{if(a>=e)i.push(o),o.selection&&s++;else if(o.step){let l=o.step.map(t.slice(r)),c=l&&l.getMap();if(r--,c&&t.appendMap(c,r),l){let u=o.selection&&o.selection.map(t.slice(r));u&&s++;let d=new Ue(c.invert(),l,u),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new We(ae.from(i.reverse()),s)}}We.empty=new We(ae.empty,0);function Py(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class Ue{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ue(t.getMap().invert(),t,this.selection)}}}class kt{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const Ly=20;function By(n,e,t,r){let i=t.getMeta(Nt),s;if(i)return i.historyState;t.getMeta(Hy)&&(n=new kt(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Nt))return o.getMeta(Nt).redo?new kt(n.done.addTransform(t,void 0,r,Jr(e)),n.undone,ll(t.mapping.maps[t.steps.length-1]),n.prevTime,n.prevComposition):new kt(n.done,n.undone.addTransform(t,void 0,r,Jr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!o&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!zy(t,n.prevRanges)),c=o?ys(n.prevRanges,t.mapping):ll(t.mapping.maps[t.steps.length-1]);return new kt(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,Jr(e)),We.empty,c,t.time,a??n.prevComposition)}else return(s=t.getMeta("rebased"))?new kt(n.done.rebased(t,s),n.undone.rebased(t,s),ys(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new kt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),ys(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function zy(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s=e[s]&&(t=!0)}),t}function ll(n){let e=[];return n.forEach((t,r,i,s)=>e.push(i,s)),e}function ys(n,e){if(!n)return null;let t=[];for(let r=0;r{let t=Nt.getState(n);return!t||t.done.eventCount==0?!1:(e&&du(t,n,e,!1),!0)},hu=(n,e)=>{let t=Nt.getState(n);return!t||t.undone.eventCount==0?!1:(e&&du(t,n,e,!0),!0)},$y=fe.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>fu(n,e),redo:()=>({state:n,dispatch:e})=>hu(n,e)}},addProseMirrorPlugins(){return[Fy(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-Z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-Y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Shift-Mod-Z":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Vy=ne.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",_(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{$to:t}=e.selection,r=n();return t.parentOffset===0?r.insertContentAt(Math.max(t.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:i,dispatch:s})=>{var o;if(s){const{$to:a}=i.selection,l=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(L.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(R.create(i.doc,a.pos)):i.setSelection(L.create(i.doc,a.pos));else{const c=(o=a.parent.type.contentMatch.defaultType)===null||o===void 0?void 0:o.create();c&&(i.insert(l,c),i.setSelection(L.create(i.doc,l+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[jc({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),jy=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/,Wy=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/g,qy=/(?:^|\s)((?:_)((?:[^_]+))(?:_))$/,Ky=/(?:^|\s)((?:_)((?:[^_]+))(?:_))/g,Uy=He.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",_(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[nn({find:jy,type:this.type}),nn({find:qy,type:this.type})]},addPasteRules(){return[It({find:Wy,type:this.type}),It({find:Ky,type:this.type})]}}),Jy=ne.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",_(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),_y=ne.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",_(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ul=He.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",_(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=$i(n,this.type);return Object.entries(t).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),dl=/^(\d+)\.\s$/,Gy=ne.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",_(this.options.HTMLAttributes,t),0]:["ol",_(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(_y.name,this.editor.getAttributes(ul.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=hr({find:dl,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=hr({find:dl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(ul.name)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Yy=ne.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",_(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Xy=/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/,Qy=/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/g,Zy=He.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",_(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){const n={};return bo()?n["Mod-Shift-s"]=()=>this.editor.commands.toggleStrike():n["Ctrl-Shift-s"]=()=>this.editor.commands.toggleStrike(),n},addInputRules(){return[nn({find:Xy,type:this.type})]},addPasteRules(){return[It({find:Qy,type:this.type})]}}),e0=ne.create({name:"text",group:"inline"}),t0=fe.create({name:"starterKit",addExtensions(){var n,e,t,r,i,s,o,a,l,c,u,d,f,h,p,m,g,b;const x=[];return this.options.blockquote!==!1&&x.push(iy.configure((n=this.options)===null||n===void 0?void 0:n.blockquote)),this.options.bold!==!1&&x.push(cy.configure((e=this.options)===null||e===void 0?void 0:e.bold)),this.options.bulletList!==!1&&x.push(dy.configure((t=this.options)===null||t===void 0?void 0:t.bulletList)),this.options.code!==!1&&x.push(py.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&x.push(yy.configure((i=this.options)===null||i===void 0?void 0:i.codeBlock)),this.options.document!==!1&&x.push(by.configure((s=this.options)===null||s===void 0?void 0:s.document)),this.options.dropcursor!==!1&&x.push(xy.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor)),this.options.gapcursor!==!1&&x.push(Ay.configure((a=this.options)===null||a===void 0?void 0:a.gapcursor)),this.options.hardBreak!==!1&&x.push(Ny.configure((l=this.options)===null||l===void 0?void 0:l.hardBreak)),this.options.heading!==!1&&x.push(Dy.configure((c=this.options)===null||c===void 0?void 0:c.heading)),this.options.history!==!1&&x.push($y.configure((u=this.options)===null||u===void 0?void 0:u.history)),this.options.horizontalRule!==!1&&x.push(Vy.configure((d=this.options)===null||d===void 0?void 0:d.horizontalRule)),this.options.italic!==!1&&x.push(Uy.configure((f=this.options)===null||f===void 0?void 0:f.italic)),this.options.listItem!==!1&&x.push(Jy.configure((h=this.options)===null||h===void 0?void 0:h.listItem)),this.options.orderedList!==!1&&x.push(Gy.configure((p=this.options)===null||p===void 0?void 0:p.orderedList)),this.options.paragraph!==!1&&x.push(Yy.configure((m=this.options)===null||m===void 0?void 0:m.paragraph)),this.options.strike!==!1&&x.push(Zy.configure((g=this.options)===null||g===void 0?void 0:g.strike)),this.options.text!==!1&&x.push(e0.configure((b=this.options)===null||b===void 0?void 0:b.text)),x}}),n0=({key:n,editor:e,onPaste:t,onDrop:r,allowedMimeTypes:i})=>new re({key:n||new he("fileHandler"),props:{handleDrop(s,o){var a;if(!r||!(!((a=o.dataTransfer)===null||a===void 0)&&a.files.length))return!1;const l=s.posAtCoords({left:o.clientX,top:o.clientY});let c=Array.from(o.dataTransfer.files);return i&&(c=c.filter(u=>i.includes(u.type))),c.length!==0&&(o.preventDefault(),o.stopPropagation(),r(e,c,(l==null?void 0:l.pos)||0),!0)},handlePaste(s,o){var a;if(!t||!(!((a=o.clipboardData)===null||a===void 0)&&a.files.length))return!1;let l=Array.from(o.clipboardData.files);const c=o.clipboardData.getData("text/html");return i&&(l=l.filter(u=>i.includes(u.type))),l.length!==0&&(o.preventDefault(),o.stopPropagation(),t(e,l,c),!(c.length>0))}}}),r0=fe.create({name:"fileHandler",addOptions:()=>({onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}),addProseMirrorPlugins(){return[n0({key:new he(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),i0="aaa1rp3barth4b0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0faromeo7ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re2s2c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y0eats7k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking0channel11l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t0isalat7u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0at2delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d0network8tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntdoor4ier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5gtv3iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0eles2s3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1nder2le4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster5ia3d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4de2k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0cys3drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7serati6ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic3tual5v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rthwesternmutual14on4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3ssagens7y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cher3ks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w0time7i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ffany5ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0channel7ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lkswagen7vo3te1ing3o2yage5u0elos6wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",s0="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5تصالات6رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",zn=(n,e)=>{for(const t in e)n[t]=e[t];return n},Js="numeric",_s="ascii",Gs="alpha",_r="asciinumeric",Vr="alphanumeric",Ys="domain",pu="emoji",o0="scheme",a0="slashscheme",fl="whitespace";function l0(n,e){return n in e||(e[n]=[]),e[n]}function Ut(n,e,t){e[Js]&&(e[_r]=!0,e[Vr]=!0),e[_s]&&(e[_r]=!0,e[Gs]=!0),e[_r]&&(e[Vr]=!0),e[Gs]&&(e[Vr]=!0),e[Vr]&&(e[Ys]=!0),e[pu]&&(e[Ys]=!0);for(const r in e){const i=l0(r,t);i.indexOf(n)<0&&i.push(n)}}function c0(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Me(n){n===void 0&&(n=null),this.j={},this.jr=[],this.jd=null,this.t=n}Me.groups={};Me.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;rn.ta(e,t,r,i),Pe=(n,e,t,r,i)=>n.tr(e,t,r,i),hl=(n,e,t,r,i)=>n.ts(e,t,r,i),w=(n,e,t,r,i)=>n.tt(e,t,r,i),ct="WORD",Xs="UWORD",br="LOCALHOST",Qs="TLD",Zs="UTLD",Gr="SCHEME",yn="SLASH_SCHEME",No="NUM",mu="WS",Do="NL",kn="OPENBRACE",rr="OPENBRACKET",ir="OPENANGLEBRACKET",sr="OPENPAREN",jt="CLOSEBRACE",xn="CLOSEBRACKET",Sn="CLOSEANGLEBRACKET",Wt="CLOSEPAREN",hi="AMPERSAND",pi="APOSTROPHE",mi="ASTERISK",xt="AT",gi="BACKSLASH",yi="BACKTICK",bi="CARET",wt="COLON",Io="COMMA",vi="DOLLAR",Je="DOT",ki="EQUALS",Ro="EXCLAMATION",_e="HYPHEN",xi="PERCENT",Si="PIPE",wi="PLUS",Mi="POUND",Ci="QUERY",Po="QUOTE",Lo="SEMI",Ge="SLASH",or="TILDE",Oi="UNDERSCORE",gu="EMOJI",Ti="SYM";var yu=Object.freeze({__proto__:null,WORD:ct,UWORD:Xs,LOCALHOST:br,TLD:Qs,UTLD:Zs,SCHEME:Gr,SLASH_SCHEME:yn,NUM:No,WS:mu,NL:Do,OPENBRACE:kn,OPENBRACKET:rr,OPENANGLEBRACKET:ir,OPENPAREN:sr,CLOSEBRACE:jt,CLOSEBRACKET:xn,CLOSEANGLEBRACKET:Sn,CLOSEPAREN:Wt,AMPERSAND:hi,APOSTROPHE:pi,ASTERISK:mi,AT:xt,BACKSLASH:gi,BACKTICK:yi,CARET:bi,COLON:wt,COMMA:Io,DOLLAR:vi,DOT:Je,EQUALS:ki,EXCLAMATION:Ro,HYPHEN:_e,PERCENT:xi,PIPE:Si,PLUS:wi,POUND:Mi,QUERY:Ci,QUOTE:Po,SEMI:Lo,SLASH:Ge,TILDE:or,UNDERSCORE:Oi,EMOJI:gu,SYM:Ti});const hn=/[a-z]/,vs=new RegExp("\\p{L}","u"),ks=new RegExp("\\p{Emoji}","u"),xs=/\d/,pl=/\s/,ml=` `,u0="️",d0="‍";let jr=null,Wr=null;function f0(n){n===void 0&&(n=[]);const e={};Me.groups=e;const t=new Me;jr==null&&(jr=gl(i0)),Wr==null&&(Wr=gl(s0)),w(t,"'",pi),w(t,"{",kn),w(t,"[",rr),w(t,"<",ir),w(t,"(",sr),w(t,"}",jt),w(t,"]",xn),w(t,">",Sn),w(t,")",Wt),w(t,"&",hi),w(t,"*",mi),w(t,"@",xt),w(t,"`",yi),w(t,"^",bi),w(t,":",wt),w(t,",",Io),w(t,"$",vi),w(t,".",Je),w(t,"=",ki),w(t,"!",Ro),w(t,"-",_e),w(t,"%",xi),w(t,"|",Si),w(t,"+",wi),w(t,"#",Mi),w(t,"?",Ci),w(t,'"',Po),w(t,"/",Ge),w(t,";",Lo),w(t,"~",or),w(t,"_",Oi),w(t,"\\",gi);const r=Pe(t,xs,No,{[Js]:!0});Pe(r,xs,r);const i=Pe(t,hn,ct,{[_s]:!0});Pe(i,hn,i);const s=Pe(t,vs,Xs,{[Gs]:!0});Pe(s,hn),Pe(s,vs,s);const o=Pe(t,pl,mu,{[fl]:!0});w(t,ml,Do,{[fl]:!0}),w(o,ml),Pe(o,pl,o);const a=Pe(t,ks,gu,{[pu]:!0});Pe(a,ks,a),w(a,u0,a);const l=w(a,d0);Pe(l,ks,a);const c=[[hn,i]],u=[[hn,null],[vs,s]];for(let d=0;dd[0]>f[0]?1:-1);for(let d=0;d=0?p[Ys]=!0:hn.test(f)?xs.test(f)?p[_r]=!0:p[_s]=!0:p[Js]=!0,hl(t,f,f,p)}return hl(t,"localhost",br,{ascii:!0}),t.jd=new Me(Ti),{start:t,tokens:zn({groups:e},yu)}}function h0(n,e){const t=p0(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,i=[];let s=0,o=0;for(;o=0&&(d+=t[o].length,f++),c+=t[o].length,s+=t[o].length,o++;s-=d,o-=f,c-=d,i.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function p0(n){const e=[],t=n.length;let r=0;for(;r56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function yt(n,e,t,r,i){let s;const o=e.length;for(let a=0;a=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}const vr={defaultProtocol:"http",events:null,format:yl,formatHref:yl,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Bo(n,e){e===void 0&&(e=null);let t=zn({},vr);n&&(t=zn(t,n instanceof Bo?n.o:n));const r=t.ignoreTags,i=[];for(let s=0;st?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n){return n===void 0&&(n=vr.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},a=n.get("className",t,e),l=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),u&&zn(o,u),{tagName:i,attributes:o,content:s,eventListeners:d}}};function ji(n,e){class t extends bu{constructor(i,s){super(i,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const bl=ji("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),vl=ji("text"),m0=ji("nl"),Ft=ji("url",{isLink:!0,toHref(n){return n===void 0&&(n=vr.defaultProtocol),this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==br&&n[1].t===wt}}),se=n=>new Me(n);function g0(n){let{groups:e}=n;const t=e.domain.concat([hi,mi,xt,gi,yi,bi,vi,ki,_e,No,xi,Si,wi,Mi,Ge,Ti,or,Oi]),r=[pi,Sn,jt,xn,Wt,wt,Io,Je,Ro,ir,kn,rr,sr,Ci,Po,Lo],i=[hi,pi,mi,gi,yi,bi,jt,vi,ki,_e,kn,xi,Si,wi,Mi,Ci,Ge,Ti,or,Oi],s=se(),o=w(s,or);D(o,i,o),D(o,e.domain,o);const a=se(),l=se(),c=se();D(s,e.domain,a),D(s,e.scheme,l),D(s,e.slashscheme,c),D(a,i,o),D(a,e.domain,a);const u=w(a,xt);w(o,xt,u),w(l,xt,u),w(c,xt,u);const d=w(o,Je);D(d,i,o),D(d,e.domain,o);const f=se();D(u,e.domain,f),D(f,e.domain,f);const h=w(f,Je);D(h,e.domain,f);const p=se(bl);D(h,e.tld,p),D(h,e.utld,p),w(u,br,p);const m=w(f,_e);D(m,e.domain,f),D(p,e.domain,f),w(p,Je,h),w(p,_e,m);const g=w(p,wt);D(g,e.numeric,bl);const b=w(a,_e),x=w(a,Je);D(b,e.domain,a),D(x,i,o),D(x,e.domain,a);const M=se(Ft);D(x,e.tld,M),D(x,e.utld,M),D(M,e.domain,a),D(M,i,o),w(M,Je,x),w(M,_e,b),w(M,xt,u);const y=w(M,wt),T=se(Ft);D(y,e.numeric,T);const v=se(Ft),N=se();D(v,t,v),D(v,r,N),D(N,t,v),D(N,r,N),w(M,Ge,v),w(T,Ge,v);const I=w(l,wt),C=w(c,wt),H=w(C,Ge),V=w(H,Ge);D(l,e.domain,a),w(l,Je,x),w(l,_e,b),D(c,e.domain,a),w(c,Je,x),w(c,_e,b),D(I,e.domain,v),w(I,Ge,v),D(V,e.domain,v),D(V,t,v),w(V,Ge,v);const F=w(v,kn),W=w(v,rr),G=w(v,ir),X=w(v,sr);w(N,kn,F),w(N,rr,W),w(N,ir,G),w(N,sr,X),w(F,jt,v),w(W,xn,v),w(G,Sn,v),w(X,Wt,v),w(F,jt,v);const J=se(Ft),j=se(Ft),K=se(Ft),Y=se(Ft);D(F,t,J),D(W,t,j),D(G,t,K),D(X,t,Y);const ie=se(),pe=se(),be=se(),Ie=se();return D(F,r),D(W,r),D(G,r),D(X,r),D(J,t,J),D(j,t,j),D(K,t,K),D(Y,t,Y),D(J,r,J),D(j,r,j),D(K,r,K),D(Y,r,Y),D(ie,t,ie),D(pe,t,j),D(be,t,K),D(Ie,t,Y),D(ie,r,ie),D(pe,r,pe),D(be,r,be),D(Ie,r,Ie),w(j,xn,v),w(K,Sn,v),w(Y,Wt,v),w(J,jt,v),w(pe,xn,v),w(be,Sn,v),w(Ie,Wt,v),w(ie,Wt,v),w(s,br,M),w(s,Do,m0),{start:s,tokens:yu}}function y0(n,e,t){let r=t.length,i=0,s=[],o=[];for(;i=0&&f++,i++,u++;if(f<0)i-=u,i0&&(s.push(Ss(vl,e,o)),o=[]),i-=f,u-=f;const h=d.t,p=t.slice(i-u,i);s.push(Ss(h,e,p))}}return o.length>0&&s.push(Ss(vl,e,o)),s}function Ss(n,e,t){const r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}const b0=typeof console<"u"&&console&&console.warn||(()=>{}),v0="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Q={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function k0(){Me.groups={},Q.scanner=null,Q.parser=null,Q.tokenQueue=[],Q.pluginQueue=[],Q.customSchemes=[],Q.initialized=!1}function kl(n,e){if(e===void 0&&(e=!1),Q.initialized&&b0(`linkifyjs: already initialized - will not register custom scheme "${n}" ${v0}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" 3. "-" cannot repeat`);Q.customSchemes.push([n,e])}function x0(){Q.scanner=f0(Q.customSchemes);for(let n=0;n{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,a=Dp(t.doc,[...e]);if($p(a).forEach(({newRange:c})=>{const u=Rp(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1?(d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")),d&&f){const h=f.split(" ").filter(g=>g!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=d.pos+f.lastIndexOf(p);if(!p)return!1;zo(p).filter(g=>g.isLink).map(g=>({...g,from:m+g.start+1,to:m+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>n.validate?n.validate(g.value):!0).forEach(g=>{ko(g.from,g.to,r.doc).some(b=>b.mark.type===n.type)||o.addMark(g.from,g.to,n.type.create({href:g.href}))})}}),!!o.steps.length)return o}})}function M0(n){return new re({key:new he("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||r.target.nodeName!=="A")return!1;const a=Vc(e.state,n.type.name),l=r.target,c=(i=l==null?void 0:l.href)!==null&&i!==void 0?i:a.href,u=(s=l==null?void 0:l.target)!==null&&s!==void 0?s:a.target;return l&&c?(e.editable&&window.open(c,u),!0):!1}}})}function C0(n){return new re({key:new he("handlePasteLink"),props:{handlePaste:(e,t,r)=>{var i;const{state:s}=e,{selection:o}=s,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(p=>{l+=p.textContent});const c=zo(l).find(p=>p.isLink&&p.value===l);if(!l||!c)return!1;const u=(i=t.clipboardData)===null||i===void 0?void 0:i.getData("text/html"),d=/href="([^"]*)"/,f=u==null?void 0:u.match(d),h=f?f[1]:c.href;return n.editor.commands.setMark(n.type,{href:h}),!0}}})}const O0=He.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){kl(n);return}kl(n.scheme,n.optionalSlashes)})},onDestroy(){k0()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){return["a",_(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[It({find:n=>zo(n).filter(e=>this.options.validate?this.options.validate(e.value):!0).filter(e=>e.isLink).map(e=>({text:e.value,index:e.start,data:e})),type:this.type,getAttributes:(n,e)=>{var t,r;const i=(t=e==null?void 0:e.clipboardData)===null||t===void 0?void 0:t.getData("text/html"),s=/href="([^"]*)"/,o=i==null?void 0:i.match(s);return o?{href:o[1]}:{href:(r=n.data)===null||r===void 0?void 0:r.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(w0({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(M0({type:this.type})),this.options.linkOnPaste&&n.push(C0({editor:this.editor,type:this.type})),n}}),T0=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))$/,E0=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))/g,A0=He.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",_(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[nn({find:T0,type:this.type})]},addPasteRules(){return[It({find:E0,type:this.type})]}}),N0=fe.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new re({key:new he("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!t)return null;const s=n.type.createAndFill(),o=(s==null?void 0:s.sameMarkup(n))&&s.content.findDiffStart(n.content)===null;return n.descendants((a,l)=>{const c=r>=l&&r<=l+a.nodeSize,u=!a.isLeaf&&!a.childCount;if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const f=Ce.node(l,l+a.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),ee.create(n,i)}}})]}});function D0(n){var e;const{char:t,allowSpaces:r,allowedPrefixes:i,startOfLine:s,$position:o}=n,a=km(t),l=new RegExp(`\\s${a}$`),c=s?"^":"",u=r?new RegExp(`${c}${a}.*?(?=\\s${a}|$)`,"gm"):new RegExp(`${c}(?:^)?${a}[^\\s${a}]*`,"gm"),d=((e=o.nodeBefore)===null||e===void 0?void 0:e.isText)&&o.nodeBefore.text;if(!d)return null;const f=o.pos-d.length,h=Array.from(d.matchAll(u)).pop();if(!h||h.input===void 0||h.index===void 0)return null;const p=h.input.slice(Math.max(0,h.index-1),h.index),m=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(p);if(i!==null&&!m)return null;const g=f+h.index;let b=g+h[0].length;return r&&l.test(d.slice(b-1,b+1))&&(h[0]+=" ",b+=1),g=o.pos?{range:{from:g,to:b},query:h[0].slice(t.length),text:h[0]}:null}const I0=new he("suggestion");function R0({pluginKey:n=I0,editor:e,char:t="@",allowSpaces:r=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:o="span",decorationClass:a="suggestion",command:l=()=>null,items:c=()=>[],render:u=()=>({}),allow:d=()=>!0}){let f;const h=u==null?void 0:u(),p=new re({key:n,view(){return{update:async(m,g)=>{var b,x,M,y,T,v,N;const I=(b=this.key)===null||b===void 0?void 0:b.getState(g),C=(x=this.key)===null||x===void 0?void 0:x.getState(m.state),H=I.active&&C.active&&I.range.from!==C.range.from,V=!I.active&&C.active,F=I.active&&!C.active,W=!V&&!F&&I.query!==C.query,G=V||H,X=W&&!H,J=F||H;if(!G&&!X&&!J)return;const j=J&&!G?I:C,K=m.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`);f={editor:e,range:j.range,query:j.query,text:j.text,items:[],command:Y=>{l({editor:e,range:j.range,props:Y})},decorationNode:K,clientRect:K?()=>{var Y;const{decorationId:ie}=(Y=this.key)===null||Y===void 0?void 0:Y.getState(e.state),pe=m.dom.querySelector(`[data-decoration-id="${ie}"]`);return(pe==null?void 0:pe.getBoundingClientRect())||null}:null},G&&((M=h==null?void 0:h.onBeforeStart)===null||M===void 0||M.call(h,f)),X&&((y=h==null?void 0:h.onBeforeUpdate)===null||y===void 0||y.call(h,f)),(X||G)&&(f.items=await c({editor:e,query:j.query})),J&&((T=h==null?void 0:h.onExit)===null||T===void 0||T.call(h,f)),X&&((v=h==null?void 0:h.onUpdate)===null||v===void 0||v.call(h,f)),G&&((N=h==null?void 0:h.onStart)===null||N===void 0||N.call(h,f))},destroy:()=>{var m;f&&((m=h==null?void 0:h.onExit)===null||m===void 0||m.call(h,f))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(m,g,b,x){const{isEditable:M}=e,{composing:y}=e.view,{selection:T}=m,{empty:v,from:N}=T,I={...g};if(I.composing=y,M&&(v||e.view.composing)){(Ng.range.to)&&!y&&!g.composing&&(I.active=!1);const C=D0({char:t,allowSpaces:r,allowedPrefixes:i,startOfLine:s,$position:T.$from}),H=`id_${Math.floor(Math.random()*4294967295)}`;C&&d({editor:e,state:x,range:C.range})?(I.active=!0,I.decorationId=g.decorationId?g.decorationId:H,I.range=C.range,I.query=C.query,I.text=C.text):I.active=!1}else I.active=!1;return I.active||(I.decorationId=null,I.range={from:0,to:0},I.query=null,I.text=null),I}},props:{handleKeyDown(m,g){var b;const{active:x,range:M}=p.getState(m.state);return x&&((b=h==null?void 0:h.onKeyDown)===null||b===void 0?void 0:b.call(h,{view:m,event:g,range:M}))||!1},decorations(m){const{active:g,range:b,decorationId:x}=p.getState(m);return g?ee.create(m.doc,[Ce.inline(b.from,b.to,{nodeName:o,class:a,"data-decoration-id":x})]):null}}});return p}const P0=new he("mention"),L0=ne.create({name:"mention",addOptions(){return{HTMLAttributes:{},renderLabel({options:n,node:e}){var t;return`${n.suggestion.char}${(t=e.attrs.label)!==null&&t!==void 0?t:e.attrs.id}`},suggestion:{char:"@",pluginKey:P0,command:({editor:n,range:e,props:t})=>{var r,i;const s=n.view.state.selection.$to.nodeAfter;((r=s==null?void 0:s.text)===null||r===void 0?void 0:r.startsWith(" "))&&(e.to+=1),n.chain().focus().insertContentAt(e,[{type:this.name,attrs:t},{type:"text",text:" "}]).run(),(i=window.getSelection())===null||i===void 0||i.collapseToEnd()},allow:({state:n,range:e})=>{const t=n.doc.resolve(e.from),r=n.schema.nodes[this.name];return!!t.parent.type.contentMatch.matchType(r)}}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id"),renderHTML:n=>n.id?{"data-id":n.id}:{}},label:{default:null,parseHTML:n=>n.getAttribute("data-label"),renderHTML:n=>n.label?{"data-label":n.label}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:n,HTMLAttributes:e}){return["span",_({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:n})]},renderText({node:n}){return this.options.renderLabel({options:this.options,node:n})},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:n,state:e})=>{let t=!1;const{selection:r}=e,{empty:i,anchor:s}=r;return i?(e.doc.nodesBetween(s-1,s,(o,a)=>{if(o.type.name===this.name)return t=!0,n.insertText(this.options.suggestion.char||"",a,a+o.nodeSize),!1}),t):!1})}},addProseMirrorPlugins(){return[R0({editor:this.editor,...this.options.suggestion})]}}),B0=ne.create({name:"video",group:"block",selectable:!0,draggable:!0,atom:!0,parseHTML(){return[{tag:"video"}]},addAttributes(){return{src:{default:null},controls:{default:!0}}},renderHTML({HTMLAttributes:n}){return["video",_(n)]},addCommands(){return{setVideo:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}}}),xl=n=>{let e=n.items.length,t=document.createElement("ul");t.className="menu";let r=0;function i(o){let a=n.items.find(l=>l.id===o);n.command({id:a.id,label:a.name})}function s(){t.querySelectorAll("li").forEach((a,l)=>{var c,u;l===r?(c=a.children[0])==null||c.classList.add("active"):(u=a.children[0])==null||u.classList.remove("active")})}return t.addEventListener("keydown",o=>{var a;if(o.key==="Enter")return i((a=n.items[r])==null?void 0:a.id),!0;if(o.key==="ArrowUp"){let l=r-1;return r=l<0?e-1:l,s(),!0}if(o.key==="ArrowDown"){let l=r+1;return r=l>=e?0:l,s(),!0}}),n.items.forEach((o,a)=>{let l=document.createElement("li"),c=document.createElement("button");c.dataset.id=o.id,c.innerText=o.name,a===r&&(c.className="active"),c.addEventListener("click",()=>{i(o.id)}),l.append(c),t.appendChild(l)}),t},z0={items:async({query:n})=>{let e=`/api/companies/${company_id}/users`,t=await fetch(e);if(t.ok)return(await t.json()).filter(i=>i.name.toLowerCase().startsWith(n.toLowerCase())).slice(0,5).filter(i=>i.id!==user_id)},render:()=>{let n=document.createElement("div");n.className="bg-white rounded-box shadow";let e;return{onStart:t=>{n.replaceChildren(xl(t)),e=Fn("body",{getReferenceClientRect:t.clientRect,content:n,appendTo:()=>document.body,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"top-start"})},onUpdate(t){t.clientRect&&(n.replaceChildren(xl(t)),e[0].setProps({getReferenceClientRect:t.clientRect}))},onKeyDown(t){var o,a;let{event:r}=t,{key:i}=r;if(i==="Escape")return e[0].hide(),!0;let s=new KeyboardEvent("keydown",r);if((a=(o=n.children)==null?void 0:o[0])==null||a.dispatchEvent(s),i==="Enter"||i==="ArrowDown"||i==="ArrowUp")return!0},onExit(){e[0].destroy(),n.remove()}}}},H0=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,F0=ne.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",_(this.options.HTMLAttributes,n)]},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[jc({find:H0,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),$0=F0.extend({name:"extended-image",addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},srcset:{default:null},width:{default:null},height:{default:null},sizes:{isRequired:!1,default:"(max-width: 500px) 320px, (max-width: 1320px) 640px, 1280px"},loading:{isRequired:!1,default:"lazy"},class:{isRequired:!1,default:"h-auto w-full"},layout:{isRequired:!1,default:"boxed"},position:{isRequired:!1,default:"left"}}},renderHTML:({HTMLAttributes:n})=>{const e=n.layout,t=n.position;return["picture",{class:`image-wrapper cursor-pointer rounded-box ${e} ${t==="center"?"mx-auto":t==="right"?"ml-auto":"mr-auto"}`},["img",{..._(n),"hx-get":"/api/files/image?url="+n.src,"hx-trigger":"click","hx-target":"#popup"}]]}});document.addEventListener("alpine:init",()=>{Alpine.data("editor",(n,e,t)=>{const r=fe.create({addKeyboardShortcuts(){return{Enter:({editor:a})=>a.isActive("codeBlock")||a.isActive("blockquote")||a.isActive("bulletList")||a.isActive("orderedList")?!1:(t==null?void 0:t.disableEnter)||!1}}});let i=!1,s;const o=async a=>{const l=new FormData;return l.append("files",a),await fetch("/api/files?company_id="+company_id,{method:"POST",body:l}).then(u=>u.json())};return{updatedAt:Date.now(),init(){const a=this;s=new vm({element:this.$refs.element,extensions:[ny.configure({element:document.getElementById("bubble_menu"),shouldShow:({editor:l,state:c})=>{const{from:u,to:d}=c.selection;return d-u>0&&!l.isActive("image")}}),r,r0.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(l,c,u)=>{c.forEach(async d=>{let f=await o(d);f&&this.setImage(f.url)})},onPaste:(l,c,u)=>{c.forEach(async d=>{if(u)return!1;let f=await o(d);f&&this.setImage(f.url)})}}),A0,$0.configure({HTMLAttributes:{loading:"async"}}),O0.configure({openOnClick:!1}),L0.configure({HTMLAttributes:{class:"suggestion"},renderLabel({options:l,node:c}){return`${l.suggestion.char}${c.attrs.label??c.attrs.id}`},suggestion:z0}),N0.configure({placeholder:e||"Content here..."}),t0.configure({gapcursor:!0}),B0],content:n,editorProps:{attributes:{class:(t==null?void 0:t.class)||"prose max-w-none mx-auto p-4 focus:outline-none"}},onCreate(){a.updatedAt=Date.now()},onBeforeCreate(){document.querySelectorAll(".editor_loading").forEach(c=>c.remove())},onUpdate({editor:l}){var c;l.isActive("codeBlock")||l.isActive("blockquote")||l.isActive("bulletList")||l.isActive("orderedList")||(c=l.state.mention$)!=null&&c.active||l.getHTML().length<8?i=!1:setTimeout(()=>i=!0,100),a.updatedAt=Date.now()},onSelectionUpdate(){a.updatedAt=Date.now()}})},editor(){return s},getAttributes(a){return s.getAttributes(a)},getHTML(){return s.getHTML()},canSend(){return i},isActive(a,l={}){return s.isActive(a,l)},can(){return s.can()},isLoaded(){return s},undo(){s.chain().focus().undo().run()},redo(){s.chain().focus().redo().run()},selectedText(){const{selection:a,doc:l}=s.state,{from:c,to:u}=a;return l.textBetween(c,u," ")},setImage(a){s.chain().setImage({src:`${thumbor_url?thumbor_url+"/unsafe/":""}${a}`}).createParagraphNear().focus().run()},setLink({href:a,title:l,new_tab:c,nofollow:u}){var d=s.isActive("link");s.chain().focus().extendMarkRange("link").setLink({href:a,target:c?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).command(({tr:f})=>(!d&&f.insertText(l),!0)).run()},toggleHeading(a){s.chain().toggleHeading(a).focus().run()},uploadFile(a){return o(a)}}})});