var Zp=Object.defineProperty;var to=(t,e)=>{for(var n in e)Zp(t,n,{get:e[n],enumerable:!0})};var Qo={};to(Qo,{CommandManager:()=>Nr,Editor:()=>a0,Extendable:()=>Ko,Extension:()=>U,Fragment:()=>d0,InputRule:()=>Fn,MappablePosition:()=>Fl,Mark:()=>te,MarkView:()=>x0,Node:()=>V,NodePos:()=>lf,NodeView:()=>k0,PasteRule:()=>qo,ResizableNodeView:()=>Go,ResizableNodeview:()=>h0,Tracker:()=>v0,callOrReturn:()=>J,canInsertNode:()=>Wl,combineTransactionSteps:()=>zo,commands:()=>Al,createAtomBlockMarkdownSpec:()=>df,createBlockMarkdownSpec:()=>Ht,createChainableState:()=>Er,createDocument:()=>Io,createElement:()=>u0,createInlineMarkdownSpec:()=>uf,createMappablePosition:()=>_u,createNodeFromContent:()=>zn,createStyleTag:()=>af,decodeHtmlEntities:()=>p0,defaultBlockAt:()=>$n,deleteProps:()=>Cl,elementFromString:()=>Ln,encodeHtmlEntities:()=>m0,escapeForRegEx:()=>jl,extensions:()=>qu,findChildren:()=>sn,findChildrenInRange:()=>Rl,findDuplicates:()=>Pu,findParentNode:()=>Je,findParentNodeClosestToPos:()=>Ho,flattenExtensions:()=>$o,fromString:()=>Iu,generateHTML:()=>Ab,generateJSON:()=>Eb,generateText:()=>Nb,getAttributes:()=>Wo,getAttributesFromExtensions:()=>Il,getChangedRanges:()=>jo,getDebugJSON:()=>zu,getExtensionField:()=>$,getHTMLFromFragment:()=>Rr,getMarkAttributes:()=>Ol,getMarkRange:()=>Bo,getMarkType:()=>rt,getMarksBetween:()=>Dr,getNodeAtPosition:()=>zl,getNodeAttributes:()=>Lu,getNodeType:()=>oe,getRenderedAttributes:()=>on,getSchema:()=>_o,getSchemaByResolvedExtensions:()=>Pl,getSchemaTypeByName:()=>Pn,getSchemaTypeNameByName:()=>Or,getSplittedAttributes:()=>Mr,getStyleProperty:()=>Ul,getText:()=>Bl,getTextBetween:()=>Ll,getTextContentFromNodes:()=>Hu,getTextSerializersFromSchema:()=>Vo,getUpdatedPosition:()=>Fu,h:()=>u0,injectExtensionAttributesToParseRule:()=>vl,inputRulesPlugin:()=>Wu,isActive:()=>Uo,isAndroid:()=>Ar,isAtEndOfNode:()=>Hl,isAtStartOfNode:()=>$l,isEmptyObject:()=>Du,isExtensionRulesEnabled:()=>Ml,isFirefox:()=>g0,isFunction:()=>Dl,isList:()=>Do,isMacOS:()=>Nl,isMarkActive:()=>Po,isNodeActive:()=>qe,isNodeEmpty:()=>ln,isNodeSelection:()=>Ir,isNodeViewSelected:()=>Rb,isNumber:()=>Uu,isPlainObject:()=>Cr,isRegExp:()=>Lo,isSafari:()=>Nu,isString:()=>y0,isTextSelection:()=>Hn,isiOS:()=>nn,markInputRule:()=>De,markPasteRule:()=>Te,markdown:()=>cf,mergeAttributes:()=>N,mergeDeep:()=>Vl,minMax:()=>nt,nodeInputRule:()=>Pr,nodePasteRule:()=>S0,objectIncludes:()=>Tr,parseAttributes:()=>Xo,parseIndentedBlocks:()=>Lr,pasteRulesPlugin:()=>Ku,posToDOMRect:()=>_l,removeDuplicates:()=>Bu,renderNestedMarkdownContent:()=>Vn,resolveExtensions:()=>Fo,resolveFocusPosition:()=>El,rewriteUnknownContent:()=>Db,selectionToInsertionEnd:()=>Ru,serializeAttributes:()=>Yo,sortExtensions:()=>Bn,splitExtensions:()=>rn,textInputRule:()=>c0,textPasteRule:()=>C0,textblockTypeInputRule:()=>_n,updateMarkViewAttributes:()=>Kl,wrappingInputRule:()=>Ge});function we(t){this.content=t}we.prototype={constructor:we,find:function(t){for(var e=0;e>1}};we.from=function(t){if(t instanceof we)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new we(e)};var ss=we;function dc(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){let s=dc(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function uc(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=0,d=Math.min(s.text.length,l.text.length);for(;ce&&r(a,o+l,i||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,n-d),r,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);ie)for(let i=0,s=0;se&&((sn)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new t(r,o)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new t(o,i)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),i=r+o.nodeSize;if(i>=e)return i==e?no(n+1,i):no(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return t.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let o=0;othis.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-o.type.rank),n}};G.none=[];var At=class extends Error{},E=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=hc(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(fc(this.content,e+this.openStart,n+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,n){if(!n)return t.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new t(C.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new t(e,r,o)}};E.empty=new E(C.empty,0,0);function fc(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(fc(i.content,e-o-1,n-o-1)))}function hc(t,e,n,r,o,i){let{index:s,offset:l}=t.findIndex(e),a=t.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=hc(a.content,e-l-1,n,s==0?r-1:0,s==t.childCount-1?o-1:0,a);return c&&t.replaceChild(s,a.copy(c))}function em(t,e,n){if(n.openStart>t.depth)throw new At("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new At("Inconsistent open depths");return pc(t,e,n,0)}function pc(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Zn(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Vt(t.nodeAfter,r),i++));for(let l=i;lo&&as(t,e,o+1),s=r.depth>o&&as(n,r,o+1),l=[];return Zn(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(mc(i,s),Vt(Wt(i,gc(t,e,n,r,o+1)),l)):(i&&Vt(Wt(i,so(t,e,o+1)),l),Zn(e,n,o,l),s&&Vt(Wt(s,so(n,r,o+1)),l)),Zn(r,null,o,l),new C(l)}function so(t,e,n){let r=[];if(Zn(null,t,n,r),t.depth>n){let o=as(t,e,n+1);Vt(Wt(o,so(t,e,n+1)),r)}return Zn(e,null,n,r),new C(r)}function tm(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(C.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}var tr=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.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,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Et(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&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new t(n,r,i)}static resolveCached(e,n){let r=tc.get(e);if(r)for(let i=0;ie&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),yc(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=C.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;an.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n 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(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=C.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};ne.prototype.text=void 0;var ds=class t extends ne{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):yc(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function yc(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var Nt=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new us(e,n);if(r.next==null)return t.empty;let o=bc(r);r.next&&r.err("Unexpected trailing text");let i=dm(cm(o));return um(i,r),i}matchType(e){for(let n=0;nc.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 n(r){e.push(r);for(let o=0;o{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return i}).join(` `)}};Nt.empty=new Nt(!0);var us=class{constructor(e,n){this.string=e,this.nodeTypes=n,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 bc(t){let e=[];do e.push(om(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function om(t){let e=[];do e.push(im(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function im(t){let e=am(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=sm(t,e);else break;return e}function nc(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function sm(t,e){let n=nc(t),r=n;return t.eat(",")&&(t.next!="}"?r=nc(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function lm(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function am(t){if(t.eat("(")){let e=bc(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=lm(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function cm(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Nt(r.indexOf(t.length-1)>-1);for(let s=0;s-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:kc(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ne(this,this.computeAttrs(e),C.from(n),G.setFrom(r))}createChecked(e=null,n,r){return n=C.from(n),this.checkContent(n),new ne(this,this.computeAttrs(e),n,G.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=C.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let o=this.contentMatch.matchFragment(n),i=o&&o.fillBefore(C.empty,!0);return i?new ne(this,e,n.append(i),G.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[i]=new t(i,n,s));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function fm(t,e,n){let r=n.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}var fs=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?fm(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},xn=class t{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=Cc(e,o.attrs),this.excluded=null;let i=xc(this.attrs);this.instance=i?new G(this,i):null}create(e=null){return!e&&this.instance?this.instance:new G(this,kc(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new t(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n-1}},jt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=ss.from(e.nodes),n.marks=ss.from(e.marks||{}),this.nodes=nr.compile(this.spec.nodes,this),this.marks=xn.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Nt.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?oc(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:oc(this,s.split(" "))}this.nodeFromJSON=o=>ne.fromJSON(this,o),this.markFromJSON=o=>G.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof nr){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(n,r,o)}text(e,n){let r=this.nodes.text;return new ds(r,r.defaultAttrs,e,G.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function oc(t,e){let n=[];for(let r=0;r-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function hm(t){return t.tag!=null}function pm(t){return t.style!=null}var Ae=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(hm(o))this.tags.push(o);else if(pm(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new lo(this,n,!1);return r.addAll(e,G.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new lo(this,n,!0);return r.addAll(e,G.none,n.from,n.to),E.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;oe.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s{r(s=sc(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=sc(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},vc={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},mm={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Mc={ol:!0,ul:!0},rr=1,hs=2,er=4;function ic(t,e,n){return e!=null?(e?rr:0)|(e==="full"?hs:0):t&&t.whitespace=="pre"?rr|hs:n&~er}var wn=class{constructor(e,n,r,o,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=G.none,this.match=i||(s&er?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(C.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&rr)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=C.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(C.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!vc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},lo=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,i,s=ic(null,n.preserveWhitespace,0)|(r?er:0);o?i=new wn(o.type,o.attrs,G.none,!0,n.topMatch||o.type.contentMatch,s):r?i=new wn(null,null,G.none,!0,null,s):i=new wn(e.schema.topNodeType,null,G.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,i=o.options&hs?"full":this.localPreserveWS||(o.options&rr)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,` `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,o){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s(s.type?s.type.allowsMarkType(c.type):lc(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new wn(e,n,a,o,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=rr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}};function gm(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Mc.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ym(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function sc(t){let e={};for(let n in t)e[n]=t[n];return e}function lc(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a{if(i.length||s.marks.length){let l=0,a=0;for(;l=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&oo(ro(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return typeof n=="string"?{dom:e.createTextNode(n)}:oo(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ac(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ac(e.marks)}};function ac(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function ro(t){return t.document||window.document}var cc=new WeakMap;function bm(t){let e=cc.get(t);return e===void 0&&cc.set(t,e=wm(t)),e}function wm(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));let l,a=n?t.createElementNS(n,o):t.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;ud)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(t.createTextNode(f));else{let{dom:h,contentDOM:p}=oo(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var Ec=65535,Nc=Math.pow(2,16);function xm(t,e){return t+e*Nc}function Tc(t){return t&Ec}function km(t){return(t-(t&Ec))/Nc}var Oc=1,Rc=2,ao=4,Dc=8,sr=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Dc)>0}get deletedBefore(){return(this.delInfo&(Oc|ao))>0}get deletedAfter(){return(this.delInfo&(Rc|ao))>0}get deletedAcross(){return(this.delInfo&ao)>0}},ht=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=Tc(e);if(!this.inverted)for(let o=0;oe)break;let c=this.ranges[l+i],d=this.ranges[l+s],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:n:n,h=a+o+(f<0?0:d);if(r)return h;let p=e==(n<0?a:u)?null:xm(l/3,e-a),m=e==a?Rc:e==u?Oc:ao;return(n<0?e!=a:e!=u)&&(m|=Dc),new sr(h,m,p)}o+=d-c}return r?e+o:new sr(e+o,0,null)}touches(e,n){let r=0,o=Tc(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o=0;n--){let o=e.getMirror(n);this.appendMap(e._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,i)}invert(){return new pt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};ue.jsonID("addMark",ar);var pt=class t extends ue{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new E(ws(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,r)}invert(){return new ar(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};ue.jsonID("removeMark",pt);var cr=class t extends ue{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new E(C.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;or.pos?null:new t(n.pos,r.pos,o,i,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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,E.fromJSON(e,n.slice),n.insert,!!n.structure)}};ue.jsonID("replaceAround",le);function ys(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function Sm(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,n),p=r.addToSet(u);for(let m=0;mt.step(a)),i.forEach(a=>t.step(a))}function Cm(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof xn){let c=s.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let d=0;dt.step(new pt(s.from,s.to,s.style)))}function xs(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a=0;a--)t.step(s[a])}function vm(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function mt(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,o=0,i=0;;--r){let s=t.$from.node(r),l=t.$from.index(r)+o,a=t.$to.indexAfter(r)-i;if(rn;p--)m||r.index(p)>0?(m=!0,d=C.from(r.node(p).copy(d)),u++):a--;let f=C.empty,h=0;for(let p=i,m=!1;p>n;p--)m||o.after(p+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=C.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new le(o,i,o,i,new E(r,0,0),n.length,!0))}function Nm(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&Om(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Pc(t,s,l,i),xs(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let d=t.mapping.slice(i),u=d.map(l,1),f=d.map(l+s.nodeSize,1);return t.step(new le(u,f,u+1,f-1,new E(C.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Ic(t,s,l,i),!1}})}function Ic(t,e,n,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Pc(t,e,n,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(` `))}})}function Om(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function Rm(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new le(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new E(C.from(s),0,0),1,!0))}function Re(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=n-2;c>i;c--,d--){let u=o.node(c),f=o.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(h))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function Dm(t,e,n=1,r){let o=t.doc.resolve(e),i=C.empty,s=C.empty;for(let l=o.depth,a=o.depth-n,c=n-1;l>a;l--,c--){i=C.from(o.node(l).copy(i));let d=r&&r[c];s=C.from(d?d.type.create(d.attrs,s):o.node(l).copy(s))}t.step(new pe(e,e,new E(i.append(s),n,n),!0))}function Le(t,e){let n=t.resolve(e),r=n.index();return Lc(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Im(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&Lc(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function Pm(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(o&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);Pc(t,d.node(),d.before(),l)}s.inlineContent&&xs(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new pe(c,a.map(e+n,-1),E.empty,!0)),r===!0){let d=t.doc.resolve(c);Ic(t,d.node(),d.before(),t.steps.length)}return t}function Lm(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function dr(t,e,n=e,r=E.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return Bc(o,i,r)?new pe(e,n,r):new bs(o,i,r).fit()}function Bc(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var bs=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=C.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=C.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new E(i,s,l);return e>-1?new le(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new pe(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=ms(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(n==1&&(s?c.matchType(s.type)||(u=c.fillBefore(C.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(n==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=ms(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new E(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=ms(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new E(or(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new E(or(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m1||a==0||m.content.size)&&(u=g,d.push(zc(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=ir(this.placed,n,C.from(d)),this.frontier[n].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n=0;l--){let{match:a,type:c}=this.frontier[l],d=gs(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=ir(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=ir(this.placed,this.depth,C.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(C.empty,!0);n.childCount&&(this.placed=ir(this.placed,this.frontier.length,n))}};function or(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(or(t.firstChild.content,e-1,n)))}function ir(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ir(t.lastChild.content,e-1,n)))}function ms(t,e){for(let n=0;n1&&(r=r.replaceChild(0,zc(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(C.empty,!0)))),t.copy(r)}function gs(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!Bm(n,i.content,s)?l:null}function Bm(t,e,n){for(let r=n;r0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],d=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=d-1;f>=0;f--){let h=c[f],p=zm(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m=0&&(t.replace(e,n,r),!(t.steps.length>u));f--){let h=s[f];h<0||(e=o.before(h),n=i.after(h))}}function Hc(t,e,n,r,o){if(er){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(C.empty,!0))}return t}function $m(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=Lm(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new E(C.from(r),0,0))}function Fm(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(n),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&n==o.start(a);a--)n=o.before(a);r=t.doc.resolve(e),o=t.doc.resolve(n)}}let i=$c(r,o);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function $c(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(ie.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}var co=class t extends ue{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return he.fromReplace(e,this.pos,this.pos+1,new E(C.from(o),0,n.isLeaf?0:1))}getMap(){return ht.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};ue.jsonID("attr",co);var uo=class t extends ue{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return he.ok(r)}getMap(){return ht.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};ue.jsonID("docAttr",uo);var Sn=class extends Error{};Sn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Sn.prototype=Object.create(Error.prototype);Sn.prototype.constructor=Sn;Sn.prototype.name="TransformError";var Ot=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new lr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Sn(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=E.empty){let o=dr(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new E(C.from(r),0,0))}delete(e,n){return this.replace(e,n,E.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Hm(this,e,n,r),this}replaceRangeWith(e,n,r){return $m(this,e,n,r),this}deleteRange(e,n){return Fm(this,e,n),this}lift(e,n){return Mm(this,e,n),this}join(e,n=1){return Pm(this,e,n),this}wrap(e,n){return Em(this,e,n),this}setBlockType(e,n=e,r,o=null){return Nm(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return Rm(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new co(e,n,r)),this}setDocAttribute(e,n){return this.step(new uo(e,n)),this}addNodeMark(e,n){return this.step(new cr(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof G)n.isInSet(r.marks)&&this.step(new kn(e,n));else{let o=r.marks,i,s=[];for(;i=n.isInSet(o);)s.push(new kn(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return Dm(this,e,n,r),this}addMark(e,n,r){return Sm(this,e,n,r),this}removeMark(e,n,r){return Cm(this,e,n,r),this}clearIncompatible(e,n,r){return xs(this,e,n,r),this}};var ks=Object.create(null),z=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new qt(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let s=n<0?vn(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):vn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new xe(e.node(0))}static atStart(e){return vn(e,e,0,0,1)||new xe(e)}static atEnd(e){return vn(e,e,e.content.size,e.childCount,-1)||new xe(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ks[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in ks)throw new RangeError("Duplicate use of selection JSON ID "+e);return ks[e]=n,n.prototype.jsonID=e,n}getBookmark(){return I.between(this.$anchor,this.$head).getBookmark()}};z.prototype.visible=!0;var qt=class{constructor(e,n){this.$from=e,this.$to=n}},Fc=!1;function _c(t){!Fc&&!t.parent.inlineContent&&(Fc=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var I=class t extends z{constructor(e,n=e){_c(e),_c(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return z.near(r);let o=e.resolve(n.map(this.anchor));return new t(o.parent.inlineContent?o:r,r)}replace(e,n=E.empty){if(super.replace(e,n),n==E.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new po(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=z.findFrom(n,r,!0)||z.findFrom(n,-r,!0);if(i)n=i.$head;else return z.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(z.findFrom(e,-r,!0)||z.findFrom(e,r,!0)).$anchor,e.pos0?0:1);o>0?s=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&L.isSelectable(l))return L.create(t,n-(o<0?l.nodeSize:0))}else{let a=vn(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function Vc(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=d)}),t.setSelection(z.near(t.doc.resolve(s),n))}var Wc=1,ho=2,jc=4,mo=class extends Ot{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|=ho,this}ensureMarks(e){return G.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&ho)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~ho,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||G.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(z.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=jc,this}get scrolledIntoView(){return(this.updated&jc)>0}};function Uc(t,e){return!e||!t?t:t.bind(e)}var Kt=class{constructor(e,n,r){this.name=e,this.init=Uc(n.init,r),this.apply=Uc(n.apply,r)}},Vm=[new Kt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Kt("selection",{init(t,e){return t.selection||z.atStart(e.doc)},apply(t){return t.selection}}),new Kt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Kt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],ur=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Vm.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Kt(r.key,r.spec.state,r))})}},fr=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new ur(e.schema,e.plugins),i=new t(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=ne.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=z.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=c.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function Kc(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Kc(o,e,{})),n[r]=o}return n}var B=class{constructor(e){this.spec=e,this.props={},e.props&&Kc(e.props,this,this.props),this.key=e.key?e.key.key:qc("plugin")}getState(e){return e[this.key]}},Ss=Object.create(null);function qc(t){return t in Ss?t+"$"+ ++Ss[t]:(Ss[t]=0,t+"$")}var _=class{constructor(e="key"){this.key=qc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Gc=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Xc(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var Ms=(t,e,n)=>{let r=Xc(t,n);if(!r)return!1;let o=As(r);if(!o){let s=r.blockRange(),l=s&&mt(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(id(t,o,e,-1))return!0;if(r.parent.content.size==0&&(Mn(i,"end")||L.isSelectable(i)))for(let s=r.depth;;s--){let l=dr(t.doc,r.before(s),r.after(s),E.empty);if(l&&l.slice.size1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},Yc=(t,e,n)=>{let r=Xc(t,n);if(!r)return!1;let o=As(r);return o?Zc(t,o,e):!1},Qc=(t,e,n)=>{let r=ed(t,n);if(!r)return!1;let o=Os(r);return o?Zc(t,o,e):!1};function Zc(t,e,n){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let d=o.lastChild;if(!d)return!1;o=d}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=dr(t.doc,i,a,E.empty);if(!c||c.from!=i||c instanceof pe&&c.slice.size>=a-i)return!1;if(n){let d=t.tr.step(c);d.setSelection(I.create(d.doc,i)),n(d.scrollIntoView())}return!0}function Mn(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Ts=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=As(r)}let s=i&&i.nodeBefore;return!s||!L.isSelectable(s)?!1:(e&&e(t.tr.setSelection(L.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function As(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function ed(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=ed(t,n);if(!r)return!1;let o=Os(r);if(!o)return!1;let i=o.nodeAfter;if(id(t,o,e,1))return!0;if(r.parent.content.size==0&&(Mn(i,"start")||L.isSelectable(i))){let s=dr(t.doc,r.before(),r.after(),E.empty);if(s&&s.slice.size{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof L,o;if(r){if(n.node.isTextblock||!Le(t.doc,n.from))return!1;o=n.from}else if(o=Ut(t.doc,n.from,-1),o==null)return!1;if(e){let i=t.tr.join(o);r&&i.setSelection(L.create(i.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},nd=(t,e)=>{let n=t.selection,r;if(n instanceof L){if(n.node.isTextblock||!Le(t.doc,n.to))return!1;r=n.to}else if(r=Ut(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},rd=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&mt(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)},Rs=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` `).scrollIntoView()),!0)};function Ds(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Ds(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(z.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Ps=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof xe||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ds(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Re(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&mt(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function Wm(t){return(e,n)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof L&&e.selection.node.isBlock)return!r.parentOffset||!Re(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=Ds(r.node(h-1).contentMatchAt(r.indexAfter(h-1)));let m=t&&t(o.parent,a,r);i.unshift(m||(a&&l?{type:l}:null)),s=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof I||e.selection instanceof xe)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=Re(d.doc,u,i.length,i);if(f||(i[0]=l?{type:l}:null,f=Re(d.doc,u,i.length,i)),!f)return!1;if(d.split(u,i.length,i),!a&&c&&r.node(s).type!=l){let h=d.mapping.map(r.before(s)),p=d.doc.resolve(h);l&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(s)),l)}return n&&n(d.scrollIntoView()),!0}}var jm=Wm();var od=(t,e)=>{let{$from:n,to:r}=t.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),e&&e(t.tr.setSelection(L.create(t.doc,o))),!0)},Um=(t,e)=>(e&&e(t.tr.setSelection(new xe(t.doc))),!0);function Km(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||Le(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function id(t,e,n,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Km(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,p=C.empty;for(let y=s.length-1;y>=0;y--)p=C.from(s[y].create(null,p));p=C.from(o.copy(p));let m=t.tr.step(new le(e.pos-1,h,e.pos,h,new E(p,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Le(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:z.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&mt(u);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(u,f).scrollIntoView()),!0;if(c&&Mn(i,"start",!0)&&Mn(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let y=C.empty;for(let b=p.length-1;b>=0;b--)y=C.from(p[b].copy(y));let w=t.tr.step(new le(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new E(y,p.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function sd(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(e.tr.setSelection(I.create(e.doc,t<0?o.start(i):o.end(i)))),!0):!1}}var Bs=sd(-1),zs=sd(1);function ld(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&Cn(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Hs(t,e=null){return function(n,r){let o=!1;for(let i=0;i{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)o=!0;else{let d=n.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,t)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;sxe,EditorState:()=>fr,NodeSelection:()=>L,Plugin:()=>B,PluginKey:()=>_,Selection:()=>z,SelectionRange:()=>qt,TextSelection:()=>I,Transaction:()=>mo});var Fs={};to(Fs,{ContentMatch:()=>Nt,DOMParser:()=>Ae,DOMSerializer:()=>Ze,Fragment:()=>C,Mark:()=>G,MarkType:()=>xn,Node:()=>ne,NodeRange:()=>Et,NodeType:()=>nr,ReplaceError:()=>At,ResolvedPos:()=>tr,Schema:()=>jt,Slice:()=>E});function ad(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return Jm(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Jm(t,e,n,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Et(a,a,e.depth),e.endIndex=0;d--)i=C.from(n[d].type.create(n[d].attrs,i));t.step(new le(e.start-(r?2:0),e.end,e.start,e.end,new E(i,0,0),n.length,!0));let s=0;for(let d=0;ds.childCount>0&&s.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?Xm(e,n,t,i):Ym(e,n,i):!0:!1}}function Xm(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);im;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?C.empty:C.from(o))))return!1;let u=i.pos,f=u+s.nodeSize;return r.step(new le(u-(l?1:0),f+(a?1:0),u+1,f-1,new E((l?C.empty:C.from(o.copy(C.empty))).append(a?C.empty:C.from(o.copy(C.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function dd(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,d=C.from(c?t.create():null),u=new E(C.from(t.create(null,C.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;n(e.tr.step(new le(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}var wl={};to(wl,{Decoration:()=>re,DecorationSet:()=>Z,EditorView:()=>In,__endComposition:()=>Ty,__parseFromClipboard:()=>My});var me=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},On=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},Ks=null,yt=function(t,e,n){let r=Ks||(Ks=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Qm=function(){Ks=null},en=function(t,e,n,r){return n&&(ud(t,e,n,r,-1)||ud(t,e,n,r,1))},Zm=/^(img|br|input|textarea|hr)$/i;function ud(t,e,n,r,o){for(var i;;){if(t==n&&e==r)return!0;if(e==(o<0?0:ze(t))){let s=t.parentNode;if(!s||s.nodeType!=1||xr(t)||Zm.test(t.nodeName)||t.contentEditable=="false")return!1;e=me(t)+(o<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(o<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else t=s,e=o<0?ze(t):0}else return!1}}function ze(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function eg(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=ze(t)}else if(t.parentNode&&!xr(t))e=me(t),t=t.parentNode;else return null}}function tg(t,e){for(;;){if(t.nodeType==3&&e2),Be=Rn||(et?/Mac/.test(et.platform):!1),Kd=et?/Win/.test(et.platform):!1,bt=/Android \d/.test(zt),kr=!!fd&&"webkitFontSmoothing"in fd.documentElement.style,ig=kr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function sg(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function gt(t,e){return typeof t=="number"?t:t[e]}function lg(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function hd(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=On(s);continue}let l=s,a=l==i.body,c=a?sg(i):lg(l),d=0,u=0;if(e.topc.bottom-gt(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+gt(o,"top")-c.top:e.bottom-c.bottom+gt(o,"bottom")),e.leftc.right-gt(r,"right")&&(d=e.right-c.right+gt(o,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:On(s)}}function ag(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:qd(t.dom)}}function qd(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=On(r));return e}function cg({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Jd(n,r==0?0:r-e)}function Jd(t,e){for(let n=0;n=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);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&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!n&&a&&(n=a,o=c,r=0),n&&n.nodeType==3?ug(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:Gd(n,o)}function ug(t,e){let n=t.nodeValue.length,r=document.createRange(),o;for(let i=0;i=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:t,offset:0}}function dl(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function fg(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function pg(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right-1?o:t.docView.posFromDOM(e,n,-1)}function Xd(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&o++}let c;kr&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=pg(t,r,o,e))}l==null&&(l=hg(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function pd(t){return t.top=0&&o==r.nodeValue.length?(a--,d=1):n<0?a--:c++,hr(Dt(yt(r,a,c),d),d<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==ze(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return _s(a.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(n<0||o==ze(r))){let a=r.childNodes[o-1],c=a.nodeType==3?yt(a,ze(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return hr(Dt(c,1),!1)}if(i==null&&o=0)}function hr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function _s(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Qd(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function yg(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return Qd(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Yd(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=yt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cd.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}var bg=/[\u0590-\u08ac]/;function wg(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return l?!bg.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:Qd(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var md=null,gd=null,yd=!1;function xg(t,e,n){return md==e&&gd==n?yd:(md=e,gd=n,yd=n=="up"||n=="down"?yg(t,e,n):wg(t,e,n))}var $e=0,bd=1,Gt=2,tt=3,tn=class{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=$e,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nme(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof wo){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof yo&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?me(i.dom)+1:0}}else{let i,s=!0;for(;i=r=d&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,d);e=s;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=me(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let d=l+1;dp&&sn){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o=r:er){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Gt:bd,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=tt:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Gt:tt}r=s}this.dirty=Gt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Gt:bd;n.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==$e&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Xs=class extends tn{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Dn=class t extends tn{constructor(e,n,r,o,i){super(e,[],r,o),this.mark=n,this.spec=i}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=Ze.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&tt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=tt&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=$e){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=el(i,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Ze.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!u&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let f=d;return d=tu(d,r,n),c?a=new Ys(e,n,r,o,d,u||null,f,c,i,s+1):n.isText?new bo(e,n,r,o,d,f,i):new t(e,n,r,o,d,u||null,f,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>C.empty)}return e}matchesNode(e,n,r){return this.dirty==$e&&e.eq(this.node)&&xo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Zs(this,s&&s.node,e);vg(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?G.none:this.node.child(d).marks,r,e,d),a.placeWidget(c,e,o)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e,f);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>o&&e.state.selection.to-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,o)||a.addNode(c,d,u,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Gt)&&(s&&this.protectLocalComposition(e,s),Zd(this.contentDOM,this.children,e),Rn&&Mg(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof I)||rn+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=Tg(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Xs(this,i,n,o);e.input.compositionNodes.push(s),this.children=el(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==tt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=$e}updateOuterDeco(e){if(xo(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=eu(this.dom,this.nodeDOM,Qs(this.outerDeco,this.node,n),Qs(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function wd(t,e,n,r,o){tu(r,e,t);let i=new Bt(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}var bo=class t extends Bt{constructor(e,n,r,o,i,s,l){super(e,n,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==tt||this.dirty!=$e&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=$e||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=$e,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let o=this.node.cut(e,n),i=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=tt)}get domAtom(){return!1}isText(e){return this.node.text==e}},wo=class extends tn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==$e&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Ys=class extends Bt{constructor(e,n,r,o,i,s,l,a,c,d){super(e,n,r,o,i,s,l,c,d),this.spec=a}update(e,n,r,o){if(this.dirty==tt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,o)}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 Zd(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i>1,l=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 d=Dn.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof Dn)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function Cg(t,e){return t.type.side-e.type.side}function vg(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let c=0;ci;)l.push(o[s++]);let p=i+f.nodeSize;if(f.isText){let g=p;s!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function Mg(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function Tg(t,e,n,r){for(let o=0,i=0;o=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function el(t,e,n,r,o){let i=[];for(let s=0,l=0;s=n||d<=e?i.push(a):(cn&&i.push(a.slice(n-c,a.size,r)))}return i}function ul(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(To(n)){for(a=s;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&L.isSelectable(u)&&o.parent&&!(u.isInline&&ng(n.focusNode,n.focusOffset,o.dom))){let f=o.posBefore;c=new L(s==f?l:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let u=s,f=s;for(let h=0;h{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!nu(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Eg(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,me(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ee&&Lt<=11&&(n.disabled=!0,n.disabled=!1)}function ru(t,e){if(e instanceof L){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(vd(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else vd(t)}function vd(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function fl(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||I.between(e,n,r)}function Md(t){return t.editable&&!t.hasFocus()?!1:ou(t)}function ou(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ng(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return en(e.node,e.offset,n.anchorNode,n.anchorOffset)}function tl(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&z.findFrom(i,e)}function It(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Td(t,e,n){let r=t.state.selection;if(r instanceof I)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return It(t,new I(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=tl(t.state,e);return o&&o instanceof L?It(t,o):!1}else if(!(Be&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?L.isSelectable(i)?It(t,new L(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):kr?It(t,new I(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof L&&r.node.isInline)return It(t,new I(e>0?r.$to:r.$from));{let o=tl(t.state,e);return o?It(t,o):!1}}}function ko(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function mr(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function An(t,e){return e<0?Og(t):Rg(t)}function Og(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(He&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(mr(l,-1))o=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(iu(n))break;{let l=n.previousSibling;for(;l&&mr(l,-1);)o=n.parentNode,i=me(l),l=l.previousSibling;if(l)n=l,r=ko(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?nl(t,n,r):o&&nl(t,o,i)}function Rg(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=ko(n),i,s;for(;;)if(r{t.state==o&&wt(t)},50)}function Ad(t,e){let n=t.state.doc.resolve(e);if(!(ge||Kd)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Ed(t,e,n){let r=t.state.selection;if(r instanceof I&&!r.empty||n.indexOf("s")>-1||Be&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=tl(t.state,e);if(s&&s instanceof L)return It(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof xe?z.near(s,e):z.findFrom(s,e);return l?It(t,l):!1}return!1}function Nd(t,e){if(!(t.state.selection instanceof I))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function Od(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Pg(t){if(!Se||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Od(t,r,"true"),setTimeout(()=>Od(t,r,"false"),20)}return!1}function Lg(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Bg(t,e){let n=e.keyCode,r=Lg(e);if(n==8||Be&&n==72&&r=="c")return Nd(t,-1)||An(t,-1);if(n==46&&!e.shiftKey||Be&&n==68&&r=="c")return Nd(t,1)||An(t,1);if(n==13||n==27)return!0;if(n==37||Be&&n==66&&r=="c"){let o=n==37?Ad(t,t.state.selection.from)=="ltr"?-1:1:-1;return Td(t,o,r)||An(t,o)}else if(n==39||Be&&n==70&&r=="c"){let o=n==39?Ad(t,t.state.selection.from)=="ltr"?1:-1:1;return Td(t,o,r)||An(t,o)}else{if(n==38||Be&&n==80&&r=="c")return Ed(t,-1,r)||An(t,-1);if(n==40||Be&&n==78&&r=="c")return Pg(t)||Ed(t,1,r)||An(t,1);if(r==(Be?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function hl(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp("clipboardSerializer")||Ze.fromSchema(t.state.schema),l=du(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=cu[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,` `);return{dom:a,text:f,slice:e}}function pl(t,e,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,i||r,t)}),i)return l=new E(C.from(t.state.schema.text(e.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let u=t.someProp("clipboardTextParser",f=>f(e,o,r,t));if(u)l=u;else{let f=o.marks(),{schema:h}=t.state,p=Ze.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",u=>{n=u(n,t)}),s=Fg(n),kr&&_g(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Ae.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!zg.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Vg(Rd(l,+d[1],+d[2]),d[4]);else if(l=E.maxOpen(Hg(l.content,o),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u{l=u(l,t,a)}),l}var zg=/^(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 Hg(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&lu(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=au(s[s.length-1],i.length));let d=su(l,a);s.push(d),o=o.matchType(d.type),i=a}}),s)return C.from(s)}return t}function su(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,C.from(t));return t}function lu(t,e,n,r,o){if(o1&&(i=0),o=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(C.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Rd(t,e,n){return en})),Ws.createHTML(t)):t}function Fg(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=du().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),o;if((o=r&&cu[r[1].toLowerCase()])&&(t=o.map(i=>"<"+i+">").join("")+t+o.map(i=>"").reverse().join("")),n.innerHTML=$g(t),o)for(let i=0;i=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=C.from(a.create(r[l+1],o)),i++,s++}return new E(o,i,s)}var ve={},Me={},Wg={touchstart:!0,touchmove:!0},ol=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function jg(t){for(let e in ve){let n=ve[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Kg(t,r)&&!ml(t,r)&&(t.editable||!(r.type in Me))&&n(t,r)},Wg[e]?{passive:!0}:void 0)}Se&&t.dom.addEventListener("input",()=>null),il(t)}function Pt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Ug(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function il(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ml(t,r))})}function ml(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Kg(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function qg(t,e){!ml(t,e)&&ve[e.type]&&(t.editable||!(e.type in Me))&&ve[e.type](t,e)}Me.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!fu(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(bt&&ge&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Rn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",o=>o(t,Jt(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Bg(t,n)?n.preventDefault():Pt(t,"key")};Me.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Me.keypress=(t,e)=>{let n=e;if(fu(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Be&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof I)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,o,i))&&t.dispatch(i()),n.preventDefault()}};function Ao(t){return{left:t.clientX,top:t.clientY}}function Jg(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function gl(t,e,n,r,o){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,l=>s>i.depth?l(t,n,i.nodeAfter,i.before(s),o,!0):l(t,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function Nn(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function Gg(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&L.isSelectable(r)?(Nn(t,new L(n),"pointer"),!0):!1}function Xg(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof L&&(r=n.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(L.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(Nn(t,L.create(t.state.doc,o),"pointer"),!0):!1}function Yg(t,e,n,r,o){return gl(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(o?Xg(t,n):Gg(t,n))}function Qg(t,e,n,r){return gl(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function Zg(t,e,n,r){return gl(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))||ey(t,n,r)}function ey(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Nn(t,I.create(r,0,r.content.size),"pointer"),!0):!1;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)Nn(t,I.create(r,l+1,l+1+s.content.size),"pointer");else if(L.isSelectable(s))Nn(t,L.create(r,l),"pointer");else continue;return!0}}function yl(t){return gr(t)}var uu=Be?"metaKey":"ctrlKey";ve.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=yl(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&Jg(n,t.input.lastClick)&&!n[uu]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=t.posAtCoords(Ao(n));s&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new sl(t,s,n,!!r)):(i=="doubleClick"?Qg:Zg)(t,s.pos,s.inside,n)?n.preventDefault():Pt(t,"pointer"))};var sl=class{constructor(e,n,r,o){this.view=e,this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[uu],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,s=d.depth?d.before():0}let l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof L&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&He&&!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)),Pt(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(()=>wt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Ao(e))),this.updateAllowDefault(e),this.allowDefault||!n?Pt(this.view,"pointer"):Yg(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Se&&this.mightDrag&&!this.mightDrag.node.isAtom||ge&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Nn(this.view,z.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):Pt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Pt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};ve.touchstart=t=>{t.input.lastTouch=Date.now(),yl(t),Pt(t,"pointer")};ve.touchmove=t=>{t.input.lastTouch=Date.now(),Pt(t,"pointer")};ve.contextmenu=t=>yl(t);function fu(t,e){return t.composing?!0:Se&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var ty=bt?5e3:-1;Me.compositionstart=Me.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof I&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ge&&Kd&&ny(t)))t.markCursor=t.state.storedMarks||n.marks(),gr(t,!0),t.markCursor=null;else if(gr(t,!e.selection.empty),He&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}t.input.composing=!0}hu(t,ty)};function ny(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Me.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,hu(t,20))};function hu(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>gr(t),e))}function pu(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=oy());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function ry(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=eg(e.focusNode,e.focusOffset),r=tg(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function oy(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function gr(t,e=!1){if(!(bt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),pu(t),e||t.docView&&t.docView.dirty){let n=ul(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function iy(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var yr=Ee&&Lt<15||Rn&&ig<604;ve.copy=Me.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let i=yr?null:n.clipboardData,s=r.content(),{dom:l,text:a}=hl(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):iy(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function sy(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function ly(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?br(t,r.value,null,o,e):br(t,r.textContent,r.innerHTML,o,e)},50)}function br(t,e,n,r,o){let i=pl(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,o,i||E.empty)))return!0;if(!i)return!1;let s=sy(i),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function mu(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Me.paste=(t,e)=>{let n=e;if(t.composing&&!bt)return;let r=yr?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&br(t,mu(r),r.getData("text/html"),o,n)?n.preventDefault():ly(t,n)};var So=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},ay=Be?"altKey":"ctrlKey";function gu(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[ay]}ve.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(Ao(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof L?o.to-1:o.to))){if(r&&r.mightDrag)s=L.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&(s=L.create(t.state.doc,u.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:d}=hl(t,l);(!n.dataTransfer.files.length||!ge||Ud>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(yr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",yr||n.dataTransfer.setData("text/plain",c),t.dragging=new So(d,gu(t,n),s)};ve.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Me.dragover=Me.dragenter=(t,e)=>e.preventDefault();Me.drop=(t,e)=>{try{cy(t,e,t.dragging)}finally{t.dragging=null}};function cy(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Ao(e));if(!r)return;let o=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",h=>{i=h(i,t,!1)}):i=pl(t,mu(e.dataTransfer),yr?null:e.dataTransfer.getData("text/html"),!1,o);let s=!!(n&&gu(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||E.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?fo(t.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=t.state.tr;if(s){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&L.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new L(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(fl(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}ve.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&wt(t)},20))};ve.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};ve.beforeinput=(t,e)=>{if(ge&&bt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Jt(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in Me)ve[t]=Me[t];function wr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var Co=class t{constructor(e,n){this.toDOM=e,this.spec=n||Qt,this.side=this.spec.side||0}map(e,n,r,o){let{pos:i,deleted:s}=e.mapResult(n.from+o,this.side<0?-1:1);return s?null:new re(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&wr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Yt=class t{constructor(e,n){this.attrs=e,this.spec=n||Qt}map(e,n,r,o){let i=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new re(i,s,this)}valid(e,n){return n.from=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,o+l,i)}}map(e,n,r){return this==ke||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Qt)}mapInner(e,n,r,o,i){let s;for(let l=0;l{let c=a+r,d;if(d=bu(n,l,c)){for(o||(o=this.children.slice());il&&u.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+n.content.size;for(let l=0;li&&a.type instanceof Yt){let c=Math.max(i,a.from)-i,d=Math.min(s,a.to)-i;co.map(e,n,Qt));return t.from(r)}forChild(e,n){if(n.isLeaf)return Z.empty;let r=[];for(let o=0;on instanceof Z)?e:e.reduce((n,r)=>n.concat(r instanceof Z?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let g=m-p-(h-f);for(let y=0;yw+d-u)continue;let b=l[y]+d-u;h>=b?l[y+1]=f<=b?-2:-1:f>=d&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),d=n.maps[c].map(d,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let f=n.map(t[c+1]+i,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let y=l[c+2].mapInner(n,g,d+1,t[c]+i+1,s);y!=ke?(l[c]=u,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=uy(l,t,e,n,o,i,s),d=Mo(c,r,0,s);e=d.local;for(let u=0;un&&s.to{let c=bu(t,l,a+n);if(c){i=!0;let d=Mo(c,l,n+a+1,r);d!=ke&&o.push(a,a+l.nodeSize,d)}});let s=yu(i?wu(t):t,-n).sort(Zt);for(let l=0;l0;)e++;t.splice(e,0,n)}function js(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ke&&e.push(r)}),t.cursorWrapper&&e.push(Z.create(t.state.doc,[t.cursorWrapper.deco])),vo.from(e)}var fy={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hy=Ee&&Lt<=11,al=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},cl=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new al,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;oo.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():Se&&e.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),hy&&(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,fy)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Md(this.view)){if(this.suppressingSelectionUpdates)return wt(this.view);if(Ee&&Lt<=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 n=new Set,r;for(let i=e.focusNode;i;i=On(i))n.add(i);for(let i=e.anchorNode;i;i=On(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Md(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;dd.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(He&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||gy(e,u)!=h)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||o)&&(i>-1&&(e.docView.markDirty(i,s),py(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,yy(e,a)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||wt(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;do;g--){let y=r.childNodes[g-1],w=y.pmViewDesc;if(y.nodeName=="BR"&&!w){i=g;break}if(!w||w.size)break}let u=t.state.doc,f=t.someProp("domParser")||Ae.fromSchema(t.state.schema),h=u.resolve(s),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:wy,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+s,head:y+s}}return{doc:m,sel:p,from:s,to:l}}function wy(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Se&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Se&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}var xy=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function ky(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let S=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,P=ul(t,S);if(P&&!t.state.selection.eq(P)){if(ge&&bt&&t.input.lastKeyCode===13&&Date.now()-100v(t,Jt(13,"Enter"))))return;let A=t.state.tr.setSelection(P);S=="pointer"?A.setMeta("pointer",!0):S=="key"&&A.scrollIntoView(),i&&A.setMeta("composition",i),t.dispatch(A)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=by(t,e,n),d=t.state.doc,u=d.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||bt)&&o.some(S=>S.nodeType==1&&!xy.test(S.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",S=>S(t,Jt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof I&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let S=zd(t,t.state.doc,c.sel);if(S&&!S.eq(t.state.selection)){let P=t.state.tr.setSelection(S);i&&P.setMeta("composition",i),t.dispatch(P)}}return}t.state.selection.fromt.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Ee&&Lt<=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)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),w=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Rn&&t.input.lastIOSEnter>Date.now()-225&&(!w||o.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!w&&m.posS(t,Jt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Cy(d,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",S=>S(t,Jt(8,"Backspace")))){bt&&ge&&t.domObserver.suppressSelectionUpdates();return}ge&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),bt&&!w&&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(()=>{t.someProp("handleKeyDown",function(S){return S(t,Jt(13,"Enter"))})},20));let b=p.start,x=p.endA,k=S=>{let P=S||t.state.tr.replace(b,x,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let A=zd(t,P.doc,c.sel);A&&!(ge&&t.composing&&A.empty&&(p.start!=p.endB||t.input.lastChromeDeletewt(t),20));let S=k(t.state.tr.delete(b,x)),P=d.resolve(p.start).marksAcross(d.resolve(p.endA));P&&S.ensureMarks(P),t.dispatch(S)}else if(p.endA==p.endB&&(M=Sy(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let S=k(t.state.tr);M.type=="add"?S.addMark(b,x,M.mark):S.removeMark(b,x,M.mark),t.dispatch(S)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let S=m.parent.textBetween(m.parentOffset,g.parentOffset),P=()=>k(t.state.tr.insertText(S,b,x));t.someProp("handleTextInput",A=>A(t,b,x,S,P))||t.dispatch(P())}else t.dispatch(k());else t.dispatch(k())}function zd(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:fl(t,e.resolve(n.anchor),e.resolve(n.head))}function Sy(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,i=r,s,l,a;for(let d=0;dd.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;dn||Us(s,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function vy(t,e,n,r,o){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(o=="end"){let a=Math.max(0,i-Math.min(s,l));r-=s+a-i}if(s=s?i-r:0;i-=a,i&&i=l?i-r:0;i-=a,i&&i=56320&&e<=57343&&n>=55296&&n<=56319}var My=pl,Ty=gr,In=class{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ol,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Wd),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=_d(this),Fd(this),this.nodeViews=Vd(this),this.docView=wd(this.state.doc,$d(this),js(this),this.dom,this),this.domObserver=new cl(this,(r,o,i,s)=>ky(this,r,o,i,s)),this.domObserver.start(),jg(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&il(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Wd),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(pu(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Vd(this);Ey(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&il(this),this.editable=_d(this),Fd(this);let a=js(this),c=$d(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(s=!0);let f=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&ag(this);if(s){this.domObserver.stop();let h=u&&(Ee||ge)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Ay(o.selection,e.selection);if(u){let p=ge?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ry(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=wd(e.doc,c,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ng(this))?wt(this,h):(ru(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&cg(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof L){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&hd(this,n.getBoundingClientRect(),e)}else hd(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&in.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return mg(this,e)}coordsAtPos(e,n=1){return Yd(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,n){return xg(this,n||this.state,e)}pasteHTML(e,n){return br(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return br(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return hl(this,e)}destroy(){this.docView&&(Ug(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],js(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Qm())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return qg(this,e)}domSelectionRange(){let e=this.domSelection();return e?Se&&this.root.nodeType===11&&rg(this.dom.ownerDocument)==this.dom&&my(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};In.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function $d(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[re.node(0,t.state.doc.content.size,e)]}function Fd(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:re.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function _d(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Ay(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Vd(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Ey(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function Wd(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var xt={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:"'"},No={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ny=typeof navigator<"u"&&/Mac/.test(navigator.platform),Oy=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ae=0;ae<10;ae++)xt[48+ae]=xt[96+ae]=String(ae);var ae;for(ae=1;ae<=24;ae++)xt[ae+111]="F"+ae;var ae;for(ae=65;ae<=90;ae++)xt[ae]=String.fromCharCode(ae+32),No[ae]=String.fromCharCode(ae);var ae;for(Eo in xt)No.hasOwnProperty(Eo)||(No[Eo]=xt[Eo]);var Eo;function xu(t){var e=Ny&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Oy&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?No:xt)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var Ry=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Dy=typeof navigator<"u"&&/Win/.test(navigator.platform);function Iy(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,o,i,s;for(let l=0;l{for(var n in e)Ly(t,n,{get:e[n],enumerable:!0})};function Er(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var Nr=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([s,l])=>[s,(...c)=>{let d=l(...c)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){let{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s=[],l=!!t,a=t||o.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),s.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(n).map(([u,f])=>[u,(...p)=>{let m=this.buildProps(a,e),g=f(...p)(m);return s.push(g),d}])),run:c};return d}createCan(t){let{rawCommands:e,state:n}=this,r=!1,o=t||n.tr,i=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(t,e=!0){let{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s={tr:t,editor:r,view:i,state:Er({state:o,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(s)]))}};return s}},Al={};Tl(Al,{blur:()=>By,clearContent:()=>zy,clearNodes:()=>Hy,command:()=>$y,createParagraphNear:()=>Fy,cut:()=>_y,deleteCurrentNode:()=>Vy,deleteNode:()=>Wy,deleteRange:()=>jy,deleteSelection:()=>qy,enter:()=>Jy,exitCode:()=>Gy,extendMarkRange:()=>Xy,first:()=>Yy,focus:()=>Qy,forEach:()=>Zy,insertContent:()=>eb,insertContentAt:()=>nb,joinBackward:()=>ib,joinDown:()=>ob,joinForward:()=>sb,joinItemBackward:()=>lb,joinItemForward:()=>ab,joinTextblockBackward:()=>cb,joinTextblockForward:()=>db,joinUp:()=>rb,keyboardShortcut:()=>fb,lift:()=>hb,liftEmptyBlock:()=>pb,liftListItem:()=>mb,newlineInCode:()=>gb,resetAttributes:()=>yb,scrollIntoView:()=>bb,selectAll:()=>wb,selectNodeBackward:()=>xb,selectNodeForward:()=>kb,selectParentNode:()=>Sb,selectTextblockEnd:()=>Cb,selectTextblockStart:()=>vb,setContent:()=>Mb,setMark:()=>Pb,setMeta:()=>Lb,setNode:()=>Bb,setNodeSelection:()=>zb,setTextDirection:()=>Hb,setTextSelection:()=>$b,sinkListItem:()=>Fb,splitBlock:()=>_b,splitListItem:()=>Vb,toggleList:()=>jb,toggleMark:()=>Ub,toggleNode:()=>Kb,toggleWrap:()=>qb,undoInputRule:()=>Jb,unsetAllMarks:()=>Gb,unsetMark:()=>Xb,unsetTextDirection:()=>Yb,updateAttributes:()=>Qb,wrapIn:()=>Zb,wrapInList:()=>e0});var By=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),zy=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),Hy=()=>({state:t,tr:e,dispatch:n})=>{let{selection:r}=e,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{t.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;let p=mt(h);if(l.type.isTextblock){let{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},$y=t=>e=>t(e),Fy=()=>({state:t,dispatch:e})=>Ps(t,e),_y=(t,e)=>({editor:n,tr:r})=>{let{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new I(r.doc.resolve(Math.max(s-1,0)))),!0},Vy=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){let l=o.before(i),a=o.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function oe(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var Wy=t=>({tr:e,state:n,dispatch:r})=>{let o=oe(t,n.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let a=i.before(s),c=i.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},jy=t=>({tr:e,dispatch:n})=>{let{from:r,to:o}=t;return n&&e.delete(r,o),!0},Uy=t=>t.content?/^text(\*|\+)/.test(t.content):!1,Su=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos{let r=Su(t,n,"left"),o=Su(e,n,"right");return{from:r,to:o}},qy=()=>({state:t,dispatch:e})=>{let{$from:n,$to:r}=t.selection;if(t.selection.empty)return!1;let{from:o,to:i}=Ky(n,r,t.schema);return e&&(t.tr.deleteRange(o,i).scrollIntoView(),e(t.tr)),!0},Jy=()=>({commands:t})=>t.keyboardShortcut("Enter"),Gy=()=>({state:t,dispatch:e})=>Is(t,e);function Lo(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Tr(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:Lo(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function Eu(t,e,n={}){return t.find(r=>r.type===e&&Tr(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function Cu(t,e,n={}){return!!Eu(t,e,n)}function Bo(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!n){let c=r.node.marks.find(d=>d.type===e);c&&(n=c.attrs)}if(!Eu([...r.node.marks],e,n))return;let i=r.index,s=t.start()+r.offset,l=i+1,a=s+r.node.nodeSize;for(;i>0&&Cu([...t.parent.child(i-1).marks],e,n);)i-=1,s-=t.parent.child(i).nodeSize;for(;l({tr:n,state:r,dispatch:o})=>{let i=rt(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:d}=l;if(o){let u=Bo(a,i,e);if(u&&u.from<=c&&u.to>=d){let f=I.create(s,u.from,u.to);n.setSelection(f)}}return!0},Yy=t=>e=>{let n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};let s=()=>{(nn()||Ar())&&r.dom.focus(),Nu()&&!nn()&&!Ar()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!Hn(n.state.selection))return s(),!0;let l=El(o.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},Zy=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),eb=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Ou=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Ou(r)}return t};function Ln(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Ou(n)}function zn(t,e,n){if(t instanceof ne||t instanceof C)return t;n={slice:!0,parseOptions:{},...n};let r=typeof t=="object"&&t!==null,o=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return C.fromArray(t.map(l=>e.nodeFromJSON(l)));let s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),zn("",e,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="",a=new jt({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Ae.fromSchema(a).parseSlice(Ln(t),n.parseOptions):Ae.fromSchema(a).parse(Ln(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Ae.fromSchema(e);return n.slice?i.parseSlice(Ln(t),n.parseOptions).content:i.parse(Ln(t),n.parseOptions)}return zn("",e,n)}function Ru(t,e,n){let r=t.steps.length-1;if(r{s===0&&(s=d)}),t.setSelection(z.near(t.doc.resolve(s),n))}var tb=t=>!("type"in t),nb=(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=g=>{i.emit("contentError",{editor:i,error:g,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{zn(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=zn(e,i.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:i.options.enableContentCheck})}catch(g){return a(g),!1}let{from:d,to:u}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;if((tb(l)?l:[l]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),d===u&&h){let{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let m;if(f){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof C){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,d,u)}else{m=l;let g=r.doc.resolve(d),y=g.node(),w=g.parentOffset===0,b=y.isText||y.isTextblock,x=y.content.size>0;w&&b&&x&&h&&(d=Math.max(0,d-1)),r.replaceWith(d,u,m)}n.updateSelection&&Ru(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:m})}return!0},rb=()=>({state:t,dispatch:e})=>td(t,e),ob=()=>({state:t,dispatch:e})=>nd(t,e),ib=()=>({state:t,dispatch:e})=>Ms(t,e),sb=()=>({state:t,dispatch:e})=>Es(t,e),lb=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Ut(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},ab=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Ut(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},cb=()=>({state:t,dispatch:e})=>Yc(t,e),db=()=>({state:t,dispatch:e})=>Qc(t,e);function Nl(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function ub(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==="Space"&&(n=" ");let r,o,i,s;for(let l=0;l({editor:e,view:n,tr:r,dispatch:o})=>{let i=ub(t).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{let d=c.map(r.mapping);d&&o&&r.maybeStep(d)}),!0};function qe(t,e,n={}){let{from:r,to:o,empty:i}=t.selection,s=e?oe(e,t.schema):null,l=[];t.doc.nodesBetween(r,o,(u,f)=>{if(u.isText)return;let h=Math.max(r,f),p=Math.min(o,f+u.nodeSize);l.push({node:u,from:h,to:p})});let a=o-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>Tr(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}var hb=(t,e={})=>({state:n,dispatch:r})=>{let o=oe(t,n.schema);return qe(n,o,e)?rd(n,r):!1},pb=()=>({state:t,dispatch:e})=>Ls(t,e),mb=t=>({state:e,dispatch:n})=>{let r=oe(t,e.schema);return cd(r)(e,n)},gb=()=>({state:t,dispatch:e})=>Rs(t,e);function Or(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Cl(t,e){let n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var yb=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=Or(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=oe(t,r.schema)),l==="mark"&&(s=rt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{i&&i===d.type&&(a=!0,o&&n.setNodeMarkup(u,void 0,Cl(d.attrs,e))),s&&d.marks.length&&d.marks.forEach(f=>{s===f.type&&(a=!0,o&&n.addMark(u,u+d.nodeSize,s.create(Cl(f.attrs,e))))})})}),a},bb=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),wb=()=>({tr:t,dispatch:e})=>{if(e){let n=new xe(t.doc);t.setSelection(n)}return!0},xb=()=>({state:t,dispatch:e})=>Ts(t,e),kb=()=>({state:t,dispatch:e})=>Ns(t,e),Sb=()=>({state:t,dispatch:e})=>od(t,e),Cb=()=>({state:t,dispatch:e})=>zs(t,e),vb=()=>({state:t,dispatch:e})=>Bs(t,e);function Io(t,e,n={},r={}){return zn(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Mb=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!=="full"){let c=Io(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});return s&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function Ol(t,e){let n=rt(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function zo(t,e){let n=new Ot(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function $n(t){for(let e=0;e{e(r)&&n.push({node:r,pos:o})}),n}function Rl(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function Ho(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Je(t){return e=>Ho(e.$from,t)}function $(t,e,n){return t.config[e]===void 0&&t.parent?$(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?$(t.parent,e,n):null}):t.config[e]}function $o(t){return t.map(e=>{let n={name:e.name,options:e.options,storage:e.storage},r=$(e,"addExtensions",n);return r?[e,...$o(r())]:e}).flat(10)}function Rr(t,e){let n=Ze.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function Dl(t){return typeof t=="function"}function J(t,e=void 0,...n){return Dl(t)?e?t.bind(e)(...n):t(...n):t}function Du(t={}){return Object.keys(t).length===0&&t.constructor===Object}function rn(t){let e=t.filter(o=>o.type==="extension"),n=t.filter(o=>o.type==="node"),r=t.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Il(t){let e=[],{nodeExtensions:n,markExtensions:r}=rn(t),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...s,...l];return t.forEach(c=>{let d={name:c.name,options:c.options,storage:c.storage,extensions:o},u=$(c,"addGlobalAttributes",d);if(!u)return;u().forEach(h=>{let p;Array.isArray(h.types)?p=h.types:h.types==="*"?p=a:h.types==="nodes"?p=s:h.types==="marks"?p=l:p=[],p.forEach(m=>{Object.entries(h.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...i,...y}})})})})}),o.forEach(c=>{let d={name:c.name,options:c.options,storage:c.storage},u=$(c,"addAttributes",d);if(!u)return;let f=u();Object.entries(f).forEach(([h,p])=>{let m={...i,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:c.name,name:h,attribute:m})})}),e}function Tb(t){let e=[],n="",r=!1,o=!1,i=0,s=t.length;for(let l=0;l0){i-=1,n+=a;continue}if(a===";"&&i===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function vu(t){let e=[],n=Tb(t||""),r=n.length;for(let o=0;o!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){let l=i?String(i).split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(d=>!a.includes(d));r[o]=[...a,...c].join(" ")}else if(o==="style"){let l=new Map([...vu(r[o]),...vu(i)]);r[o]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else r[o]=i}),r},{})}function on(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>N(n,r),{})}function Iu(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function vl(t,e){return"style"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let o=e.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(n):Iu(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function Mu(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Du(n)?!1:n!=null))}function Tu(t){var e,n;let r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function Pl(t,e){var n;let r=Il(t),{nodeExtensions:o,markExtensions:i}=rn(t),s=(n=o.find(c=>$(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(o.map(c=>{let d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((y,w)=>{let b=$(w,"extendNodeSchema",u);return{...y,...b?b(c):{}}},{}),h=Mu({...f,content:J($(c,"content",u)),marks:J($(c,"marks",u)),group:J($(c,"group",u)),inline:J($(c,"inline",u)),atom:J($(c,"atom",u)),selectable:J($(c,"selectable",u)),draggable:J($(c,"draggable",u)),code:J($(c,"code",u)),whitespace:J($(c,"whitespace",u)),linebreakReplacement:J($(c,"linebreakReplacement",u)),defining:J($(c,"defining",u)),isolating:J($(c,"isolating",u)),attrs:Object.fromEntries(d.map(Tu))}),p=J($(c,"parseHTML",u));p&&(h.parseDOM=p.map(y=>vl(y,d)));let m=$(c,"renderHTML",u);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:on(y,d)}));let g=$(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(i.map(c=>{let d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((g,y)=>{let w=$(y,"extendMarkSchema",u);return{...g,...w?w(c):{}}},{}),h=Mu({...f,inclusive:J($(c,"inclusive",u)),excludes:J($(c,"excludes",u)),group:J($(c,"group",u)),spanning:J($(c,"spanning",u)),code:J($(c,"code",u)),attrs:Object.fromEntries(d.map(Tu))}),p=J($(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>vl(g,d)));let m=$(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:on(g,d)})),[c.name,h]}));return new jt({topNode:s,nodes:l,marks:a})}function Pu(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Bn(t){return t.sort((n,r)=>{let o=$(n,"priority")||100,i=$(r,"priority")||100;return o>i?-1:or.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function _o(t,e){let n=Fo(t);return Pl(n,e)}function Ab(t,e){let n=_o(e),r=ne.fromJSON(n,t);return Rr(r.content,n)}function Eb(t,e){let n=_o(e),r=Ln(t);return Ae.fromSchema(n).parse(r).toJSON()}function Ll(t,e,n){let{from:r,to:o}=e,{blockSeparator:i=` `,textSerializers:s={}}=n||{},l="";return t.nodesBetween(r,o,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=i);let h=s?.[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,o-c))}),l}function Bl(t,e){let n={from:0,to:t.content.size};return Ll(t,n,e)}function Vo(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Nb(t,e,n){let{blockSeparator:r=` `,textSerializers:o={}}=n||{},i=_o(e),s=ne.fromJSON(i,t);return Bl(s,{blockSeparator:r,textSerializers:{...Vo(i),...o}})}function Lu(t,e){let n=oe(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function Wo(t,e){let n=Or(typeof e=="string"?e:e.name,t.schema);return n==="node"?Lu(t,e):n==="mark"?Ol(t,e):{}}function Bu(t,e=JSON.stringify){let n={};return t.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function Ob(t){let e=Bu(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,s)=>s!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function jo(t){let{mapping:e,steps:n}=t,r=[];return e.maps.forEach((o,i)=>{let s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),Ob(r)}function zu(t,e=0){let r=t.type===t.type.schema.topNodeType?0:1,o=e,i=o+t.nodeSize,s=t.marks.map(c=>{let d={type:c.type.name};return Object.keys(c.attrs).length&&(d.attrs={...c.attrs}),d}),l={...t.attrs},a={type:t.type.name,from:o,to:i};return Object.keys(l).length&&(a.attrs=l),s.length&&(a.marks=s),t.content.childCount&&(a.content=[],t.forEach((c,d)=>{var u;(u=a.content)==null||u.push(zu(c,e+d+r))})),t.text&&(a.text=t.text),a}function Dr(t,e,n){let r=[];return t===e?n.resolve(t).marks().forEach(o=>{let i=n.resolve(t),s=Bo(i,o.type);s&&r.push({mark:o,...s})}):n.nodesBetween(t,e,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var zl=(t,e,n,r=20)=>{let o=t.doc.resolve(n),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);l?.type.name===e?s=l:i-=1}return[s,i]};function Pn(t,e){return e.nodes[t]||e.marks[t]||null}function Mr(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let o=t.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var Hu=(t,e=500)=>{let n="",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;let d=((c=(a=o.type.spec).toText)==null?void 0:c.call(a,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?d:d.slice(0,Math.max(0,r-i))}),n};function Po(t,e,n={}){let{empty:r,ranges:o}=t.selection,i=e?rt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>Tr(u.attrs,n,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:u,$to:f})=>{let h=u.pos,p=f.pos;t.doc.nodesBetween(h,p,(m,g)=>{if(i&&m.inlineContent&&!m.type.allowsMarkType(i))return!1;if(!m.isText&&!m.marks.length)return;let y=Math.max(h,g),w=Math.min(p,g+m.nodeSize),b=w-y;s+=b,l.push(...m.marks.map(x=>({mark:x,from:y,to:w})))})}),s===0)return!1;let a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>Tr(u.mark.attrs,n,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=s}function Uo(t,e,n={}){if(!e)return qe(t,null,n)||Po(t,null,n);let r=Or(e,t.schema);return r==="node"?qe(t,e,n):r==="mark"?Po(t,e,n):!1}var Hl=(t,e)=>{let{$from:n,$to:r,$anchor:o}=t.selection;if(e){let i=Je(l=>l.type.name===e)(t.selection);if(!i)return!1;let s=t.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset{let{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Ml(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Do(t,e){let{nodeExtensions:n}=rn(e),r=n.find(s=>s.name===t);if(!r)return!1;let o={name:r.name,options:r.options,storage:r.storage},i=J($(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function ln(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(i=>{o!==!1&&(ln(i,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function Ir(t){return t instanceof L}function Rb({selection:t,pos:e,nodeSize:n,selectedOnTextSelection:r=!1}){let{from:o,to:i}=t;return!!(o<=e&&i>=e+n||r&&Hn(t)&&o>e&&iy}}function Vu({json:t,validMarks:e,validNodes:n,options:r,rewrittenContent:o=[]}){return t.marks&&Array.isArray(t.marks)&&(t.marks=t.marks.filter(i=>{let s=typeof i=="string"?i:i.type;return e.has(s)?!0:(o.push({original:JSON.parse(JSON.stringify(i)),unsupported:s}),!1)})),t.content&&Array.isArray(t.content)&&(t.content=t.content.map(i=>Vu({json:i,validMarks:e,validNodes:n,options:r,rewrittenContent:o}).json).filter(i=>i!=null)),t.type&&!n.has(t.type)?(o.push({original:JSON.parse(JSON.stringify(t)),unsupported:t.type}),t.content&&Array.isArray(t.content)&&r?.fallbackToParagraph!==!1?(t.type="paragraph",{json:t,rewrittenContent:o}):{json:null,rewrittenContent:o}):{json:t,rewrittenContent:o}}function Db(t,e,n){return Vu({json:t,validNodes:new Set(Object.keys(e.nodes)),validMarks:new Set(Object.keys(e.marks)),options:n})}function Ib(t,e,n){var r;let{selection:o}=e,i=null;if(Hn(o)&&(i=o.$cursor),i){let l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}let{ranges:s}=o;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var Pb=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=rt(t,r.schema);if(o)if(s){let c=Ol(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{let p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&n.addMark(p,m,a.create({...y.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return Ib(r,n,a)},Lb=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Bb=(t,e={})=>({state:n,dispatch:r,chain:o})=>{let i=oe(t,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Hs(i,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Hs(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},zb=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,o=nt(t,0,r.content.size),i=L.create(r,o);e.setSelection(i)}return!0},Hb=(t,e)=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=r,s,l;return typeof e=="number"?(s=e,l=e):e&&"from"in e&&"to"in e?(s=e.from,l=e.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},$b=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:o,to:i}=typeof t=="number"?{from:t,to:t}:t,s=I.atStart(r).from,l=I.atEnd(r).to,a=nt(o,s,l),c=nt(i,s,l),d=I.create(r,a,c);e.setSelection(d)}return!0},Fb=t=>({state:e,dispatch:n})=>{let r=oe(t,e.schema);return dd(r)(e,n)};function Au(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(o=>e?.includes(o.type.name));t.tr.ensureMarks(r)}}var _b=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{let{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,d=Mr(c,l.node().type.name,l.node().attrs);if(i instanceof L&&i.node.isBlock)return!l.parentOffset||!Re(s,l.pos)?!1:(r&&(t&&Au(n,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:$n(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=u&&f?[{type:f,attrs:d}]:void 0,p=Re(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Re(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(i instanceof I&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){let m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&Au(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},Vb=(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{var s;let l=oe(t,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;let u=a.node(-1);if(u.type!==l)return!1;let f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){let y=C.empty,w=a.index(-1)?1:a.index(-2)?2:3;for(let P=a.depth-w;P>=a.depth-3;P-=1)y=C.from(a.node(P).copy(y));let b=a.indexAfter(-1){if(S>-1)return!1;P.isTextblock&&P.content.size===0&&(S=A+1)}),S>-1&&n.setSelection(I.near(n.doc.resolve(S))),n.scrollIntoView()}return!0}let h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Mr(f,u.type.name,u.attrs),...e},m={...Mr(f,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);let g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!Re(n.doc,a.pos,2))return!1;if(o){let{selection:y,storedMarks:w}=r,{splittableMarks:b}=i.extensionManager,x=w||y.$to.parentOffset&&y.$from.marks();if(n.split(a.pos,2,g).scrollIntoView(),!x||!o)return!0;let k=x.filter(M=>b.includes(M.type.name));n.ensureMarks(k)}return!0},kl=(t,e)=>{let n=Je(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return n.node.type===o?.type&&Le(t.doc,n.pos)&&t.join(n.pos),!0},Sl=(t,e)=>{let n=Je(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return n.node.type===o?.type&&Le(t.doc,r)&&t.join(r),!0};function Wb(t){let e=t.doc,n=e.firstChild;if(!n)return null;let r=e.resolve(1),o=e.resolve(n.nodeSize-1);return I.between(r,o)}var jb=(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:d})=>{let{extensions:u,splittableMarks:f}=o.extensionManager,h=oe(t,s.schema),p=oe(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:w}=m,b=y.blockRange(w),x=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;let k=Je(D=>Do(D.type.name,u))(m),M=m.from===0&&m.to===s.doc.content.size,S=s.doc.content.content,P=S.length===1?S[0]:null,A=M&&P&&Do(P.type.name,u)?{node:P,pos:0,depth:0}:null,v=k??A,R=!!k&&b.depth>=1&&b.depth-k.depth<=1,j=!!A;if((R||j)&&v){if(v.node.type===h)return M&&j?a().command(({tr:D,dispatch:O})=>{let H=Wb(D);return H?(D.setSelection(H),O&&O(D),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Do(v.node.type.name,u)&&h.validContent(v.node.content))return a().command(()=>(i.setNodeMarkup(v.pos,h),!0)).command(()=>kl(i,h)).command(()=>Sl(i,h)).run()}return!n||!x||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>kl(i,h)).command(()=>Sl(i,h)).run():a().command(()=>{let D=d().wrapInList(h,r),O=x.filter(H=>f.includes(H.type.name));return i.ensureMarks(O),D?!0:c.clearNodes()}).wrapInList(h,r).command(()=>kl(i,h)).command(()=>Sl(i,h)).run()},Ub=(t,e={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=rt(t,r.schema);return Po(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},Kb=(t,e,n={})=>({state:r,commands:o})=>{let i=oe(t,r.schema),s=oe(e,r.schema),l=qe(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},qb=(t,e={})=>({state:n,commands:r})=>{let o=oe(t,n.schema);return qe(n,o,e)?r.lift(o):r.wrapIn(o,e)},Jb=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},Gb=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,{empty:r,ranges:o}=n;return r||e&&o.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},Xb=(t,e={})=>({tr:n,state:r,dispatch:o})=>{var i;let{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,a=rt(t,r.schema),{$from:c,empty:d,ranges:u}=l;if(!o)return!0;if(d&&s){let{from:f,to:h}=l,p=(i=c.marks().find(g=>g.type===a))==null?void 0:i.attrs,m=Bo(c,a,p);m&&(f=m.from,h=m.to),n.removeMark(f,h,a)}else u.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},Yb=t=>({tr:e,state:n,dispatch:r})=>{let{selection:o}=n,i,s;return typeof t=="number"?(i=t,s=t):t&&"from"in t&&"to"in t?(i=t.from,s=t.to):(i=o.from,s=o.to),r&&e.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Qb=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=Or(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=oe(t,r.schema)),l==="mark"&&(s=rt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{let d=c.$from.pos,u=c.$to.pos,f,h,p,m;n.selection.empty?r.doc.nodesBetween(d,u,(g,y)=>{i&&i===g.type&&(a=!0,p=Math.max(y,d),m=Math.min(y+g.nodeSize,u),f=y,h=g)}):r.doc.nodesBetween(d,u,(g,y)=>{y=d&&y<=u&&(i&&i===g.type&&(a=!0,o&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),s&&g.marks.length&&g.marks.forEach(w=>{if(s===w.type&&(a=!0,o)){let b=Math.max(y,d),x=Math.min(y+g.nodeSize,u);n.addMark(b,x,s.create({...w.attrs,...e}))}}))}),h&&(f!==void 0&&o&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(g=>{s===g.type&&o&&n.addMark(p,m,s.create({...g.attrs,...e}))}))}),a},Zb=(t,e={})=>({state:n,dispatch:r})=>{let o=oe(t,n.schema);return ld(o,e)(n,r)},e0=(t,e={})=>({state:n,dispatch:r})=>{let o=oe(t,n.schema);return ad(o,e)(n,r)},t0=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){let n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){let n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){let n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Fn=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},n0=(t,e)=>{if(Lo(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Oo(t){var e;let{editor:n,from:r,to:o,text:i,rules:s,plugin:l}=t,{view:a}=n;if(a.composing)return!1;let c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1,u=Hu(c)+i;return s.forEach(f=>{if(d)return;let h=n0(u,f.find);if(!h)return;let p=a.state.tr,m=Er({state:a.state,transaction:p}),g={from:r-(h[0].length-i.length),to:o},{commands:y,chain:w,can:b}=new Nr({editor:n,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:w,can:b})===null||!p.steps.length||(f.undoable&&p.setMeta(l,{transform:p,from:r,to:o,text:i}),a.dispatch(p),d=!0)}),d}function Wu(t){let{editor:e,rules:n}=t,r=new B({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=Rr(C.from(d),s.schema);let{from:u}=a,f=u+d.length;Oo({editor:e,from:u,to:f,text:d,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return Oo({editor:e,from:i,to:s,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&Oo({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;let{$cursor:s}=o.state.selection;return s?Oo({editor:e,from:s.pos,to:s.pos,text:` `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function r0(t){return Object.prototype.toString.call(t).slice(8,-1)}function Cr(t){return r0(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Vl(t,e){let n={...t};return Cr(t)&&Cr(e)&&Object.keys(e).forEach(r=>{Cr(e[r])&&Cr(t[r])?n[r]=Vl(t[r],e[r]):n[r]=e[r]}),n}var Ko=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...J($(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...J($(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){let e=this.extend({...this.config,addOptions:()=>Vl(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){let e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},te=class ju extends Ko{constructor(){super(...arguments),this.type="mark"}static create(e={}){let n=typeof e=="function"?e():e;return new ju(n)}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){let s=o.marks();if(!!!s.find(c=>c?.type.name===n.name))return!1;let a=s.find(c=>c?.type.name===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}};function Uu(t){return typeof t=="number"}var qo=class{constructor(t){this.find=t.find,this.handler=t.handler}},o0=(t,e,n)=>{if(Lo(e))return[...t.matchAll(e)];let r=e(t,n);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=t,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function i0(t){let{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:d}=new Nr({editor:e,state:n}),u=[];return n.doc.nodesBetween(r,o,(h,p)=>{var m,g,y,w,b;if((g=(m=h.type)==null?void 0:m.spec)!=null&&g.code||!(h.isText||h.isTextblock||h.isInline))return;let x=(b=(w=(y=h.content)==null?void 0:y.size)!=null?w:h.nodeSize)!=null?b:0,k=Math.max(r,p),M=Math.min(o,p+x);if(k>=M)return;let S=h.isText?h.text||"":h.textBetween(k-p,M-p,void 0,"\uFFFC");o0(S,i.find,s).forEach(A=>{if(A.index===void 0)return;let v=k+A.index+1,R=v+A[0].length,j={from:n.tr.mapping.map(v),to:n.tr.mapping.map(R)},D=i.handler({state:n,range:j,match:A,commands:a,chain:c,can:d,pasteEvent:s,dropEvent:l});u.push(D)})}),u.every(h=>h!==null)}var Ro=null,s0=t=>{var e;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function Ku(t){let{editor:e,rules:n}=t,r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{let m=d.tr,g=Er({state:d,transaction:m});if(!(!i0({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(d=>new B({view(u){let f=p=>{var m;r=(m=u.dom.parentElement)!=null&&m.contains(p.target)?u.dom.parentElement:null,r&&(Ro=e)},h=()=>{Ro&&(Ro=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(i=r===u.dom.parentElement,l=f,!i){let h=Ro;h?.isEditable&&setTimeout(()=>{let p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;let p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return s=f,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,f,h)=>{let p=u[0],m=p.getMeta("uiEvent")==="paste"&&!o,g=p.getMeta("uiEvent")==="drop"&&!i,y=p.getMeta("applyPasteRules"),w=!!y;if(!m&&!g&&!w)return;if(w){let{text:k}=y;typeof k=="string"?k=k:k=Rr(C.from(k),h.schema);let{from:M}=y,S=M+k.length,P=s0(k);return a({rule:d,state:h,from:M,to:{b:S},pasteEvt:P})}let b=f.doc.content.findDiffStart(h.doc.content),x=f.doc.content.findDiffEnd(h.doc.content);if(!(!Uu(b)||!x||b===x.b))return a({rule:d,state:h,from:b,to:x,pasteEvt:s})}}))}var Jo=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Fo(t),this.schema=Pl(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Pn(e.name,this.schema)},r=$(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){let{editor:t}=this;return Bn([...this.extensions].reverse()).flatMap(r=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Pn(r.name,this.schema)},i=[],s=$(r,"addKeyboardShortcuts",o),l={};if(r.type==="mark"&&$(r,"exitable",o)&&(l.ArrowRight=()=>te.handleExit({editor:t,mark:r})),s){let f=Object.fromEntries(Object.entries(s()).map(([h,p])=>[h,()=>p({editor:t})]));l={...l,...f}}let a=ku(l);i.push(a);let c=$(r,"addInputRules",o);if(Ml(r,t.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=Wu({editor:t,rules:f}),p=Array.isArray(h)?h:[h];i.push(...p)}}let d=$(r,"addPasteRules",o);if(Ml(r,t.options.enablePasteRules)&&d){let f=d();if(f&&f.length){let h=Ku({editor:t,rules:f});i.push(...h)}}let u=$(r,"addProseMirrorPlugins",o);if(u){let f=u();i.push(...f)}return i})}get attributes(){return Il(this.extensions)}get nodeViews(){let{editor:t}=this,{nodeExtensions:e}=rn(this.extensions);return Object.fromEntries(e.filter(n=>!!$(n,"addNodeView")).map(n=>{let r=this.attributes.filter(a=>a.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:oe(n.name,this.schema)},i=$(n,"addNodeView",o);if(!i)return[];let s=i();if(!s)return[];let l=(a,c,d,u,f)=>{let h=on(a,r);return s({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:t,extension:n,HTMLAttributes:h})};return[n.name,l]}))}dispatchTransaction(t){let{editor:e}=this;return Bn([...this.extensions].reverse()).reduceRight((r,o)=>{let i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:Pn(o.name,this.schema)},s=$(o,"dispatchTransaction",i);return s?l=>{s.call(i,{transaction:l,next:r})}:r},t)}transformPastedHTML(t){let{editor:e}=this;return Bn([...this.extensions]).reduce((r,o)=>{let i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:Pn(o.name,this.schema)},s=$(o,"transformPastedHTML",i);return s?(l,a)=>{let c=r(l,a);return s.call(i,c)}:r},t||(r=>r))}get markViews(){let{editor:t}=this,{markExtensions:e}=rn(this.extensions);return Object.fromEntries(e.filter(n=>!!$(n,"addMarkView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:rt(n.name,this.schema)},i=$(n,"addMarkView",o);if(!i)return[];let s=(l,a,c)=>{let d=on(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:d,updateAttributes:u=>{Kl(l,t,u)}})};return[n.name,s]}))}destroy(){this.extensions.forEach(t=>{let e=t;for(;e.parent;){let n=e.parent;n.child===e&&(n.child=null),e=n}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){let t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;let r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Pn(e.name,this.schema)};e.type==="mark"&&((n=J($(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);let o=$(e,"onBeforeCreate",r),i=$(e,"onCreate",r),s=$(e,"onUpdate",r),l=$(e,"onSelectionUpdate",r),a=$(e,"onTransaction",r),c=$(e,"onFocus",r),d=$(e,"onBlur",r),u=$(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),i&&this.editor.on("create",i),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};Jo.resolve=Fo;Jo.sort=Bn;Jo.flatten=$o;var qu={};Tl(qu,{ClipboardTextSerializer:()=>Gu,Commands:()=>Xu,Delete:()=>Yu,Drop:()=>Qu,Editable:()=>Zu,FocusEvents:()=>tf,Keymap:()=>nf,Paste:()=>rf,Tabindex:()=>of,TextDirection:()=>sf,focusEventsPluginKey:()=>ef});var U=class Ju extends Ko{constructor(){super(...arguments),this.type="extension"}static create(e={}){let n=typeof e=="function"?e():e;return new Ju(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},Gu=U.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new B({key:new _("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,{ranges:i}=o,s=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=Vo(n);return Ll(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Xu=U.create({name:"commands",addCommands(){return{...Al}}}),Yu=U.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,o;let i=()=>{var s,l,a,c;if((c=(a=(l=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;let d=zo(t.before,[t,...e]);jo(d).forEach(h=>{d.mapping.mapResult(h.oldRange.from).deletedAfter&&d.mapping.mapResult(h.oldRange.to).deletedBefore&&d.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,m)=>{let g=m+p.nodeSize-2,y=h.oldRange.from<=m&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:d.mapping.map(m),newTo:d.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});let f=d.mapping;d.steps.forEach((h,p)=>{var m,g;if(h instanceof pt){let y=f.slice(p).map(h.from,-1),w=f.slice(p).map(h.to),b=f.invert().map(y,-1),x=f.invert().map(w),k=y>0?(m=d.doc.nodeAt(y-1))==null?void 0:m.marks.some(S=>S.eq(h.mark)):!1,M=(g=d.doc.nodeAt(w))==null?void 0:g.marks.some(S=>S.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:b,to:x},newRange:{from:y,to:w},partial:!!(M||k),editor:this.editor,transaction:t,combinedTransform:d})}})};(o=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||o?setTimeout(i,0):i()}}),Qu=U.create({name:"drop",addProseMirrorPlugins(){return[new B({key:new _("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Zu=U.create({name:"editable",addProseMirrorPlugins(){return[new B({key:new _("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ef=new _("focusEvents"),tf=U.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:t}=this;return[new B({key:ef,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),nf=U.create({name:"keymap",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:z.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return nn()||Nl()?i:o},addProseMirrorPlugins(){return[new B({key:new _("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;let r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),o=t.some(m=>m.getMeta("preventClearDocument"));if(!r||o)return;let{empty:i,from:s,to:l}=e.selection,a=z.atStart(e.doc).from,c=z.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!ln(n.doc))return;let f=n.tr,h=Er({state:n,transaction:f}),{commands:p}=new Nr({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),rf=U.create({name:"paste",addProseMirrorPlugins(){return[new B({key:new _("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),of=U.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new B({key:new _("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),sf=U.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:t}=rn(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new B({key:new _("textDirection"),props:{attributes:()=>{let t=this.options.direction;return t?{dir:t}:{}}}})]}}),lf=class vr{constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new vr(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new vr(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new vr(e,this.editor)}get children(){let e=[];return this.node.content.forEach((n,r)=>{let o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!o&&!s&&a.depth<=this.depth)return;let c=new vr(a,this.editor,o,o||s?n:null);o&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){let i=o.node.attrs,s=Object.keys(n);for(let l=0;l{r&&o.length>0||(s.node.type.name===e&&i.every(a=>n[a]===s.node.attrs[a])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,n,r))))}),o}setAttribute(e){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},l0=`.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: 0 !important; height: 0 !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; }`;function af(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}var a0=class extends t0{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Fu,createMappablePosition:_u},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),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),this.on("drop",({event:r,slice:o,moved:i})=>this.options.onDrop(r,o,i)),this.on("paste",({event:r,slice:o})=>this.options.onPaste(r,o)),this.on("delete",this.options.onDelete);let e=this.createDoc(),n=El(e,this.options.autofocus);this.editorState=fr.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}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&&typeof document<"u"&&(this.css=af(l0,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){let n=Dl(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;let e=this.state.plugins,n=e;if([].concat(t).forEach(o=>{let i=typeof o=="string"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),e.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e,n,r;let i=[...this.options.enableCoreExtensions?[Zu,Gu.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Xu,tf,nf,of.configure({value:(r=(n=this.options.coreExtensionOptions)==null?void 0:n.tabindex)==null?void 0:r.value}),Qu,rf,Yu,sf.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s?.type));this.extensionManager=new Jo(i,this)}createCommandManager(){this.commandManager=new Nr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Io(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Io(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){let{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new In(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}let{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});let s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s?.getMeta("focus"),a=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Wo(this.state,t)}isActive(t,e){let n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return Uo(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Rr(this.state.doc.content,this.schema)}getText(t){let{blockSeparator:e=` `,textSerializers:n={}}=t||{};return Bl(this.state.doc,{blockSeparator:e,textSerializers:{...Vo(this.schema),...n}})}get isEmpty(){return ln(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText?e.nodeAfter:null;return new lf(e,this,!1,n)}get $doc(){return this.$pos(0)}};function De(t){return new Fn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=J(t.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=n.from+l.indexOf(s),d=c+s.length;if(Dr(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===t.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;dn.from&&i.delete(n.from+a,c);let f=n.from+a+s.length;i.addMark(n.from+a,f,t.type.create(o||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function Pr(t){return new Fn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=J(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from,l=n.to,a=t.type.create(o);if(r[1]){let c=r[0].lastIndexOf(r[1]),d=s+c;d>l?d=l:l=d+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,s+r[0].length-1),i.replaceWith(d,l,a)}else if(r[0]){let c=t.type.isInline?s:s-1;i.insert(c,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function _n(t){return new Fn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=e.doc.resolve(n.from),i=J(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function c0(t){return new Fn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=t.replace,i=n.from,s=n.to;if(r[1]){let l=r[0].lastIndexOf(r[1]);o+=r[0].slice(l+r[1].length),i+=l;let a=i-s;a>0&&(o=r[0].slice(l-a,l)+o,i=s)}e.tr.insertText(o,i,s)},undoable:t.undoable})}function Ge(t){return new Fn({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{let i=J(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),c=a&&Cn(a,t.type,i);if(!c)return null;if(s.wrap(a,c),t.keepMarks&&t.editor){let{selection:u,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){let m=p.filter(g=>h.includes(g.type.name));s.ensureMarks(m)}}if(t.keepAttributes){let u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(u,i).run()}let d=s.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&Le(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)},undoable:t.undoable})}function d0(t){return t.children}var u0=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},f0=t=>"touches"in t,Go=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let c=a.clientX-this.startX,d=a.clientY-this.startY;this.handleResize(c,d)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,o,i,s;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(o=t.options)!=null&&o.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(s=t.options)!=null&&s.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){let t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){let t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){let e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){let n=e.includes("top"),r=e.includes("bottom"),o=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),o&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){let t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,f0(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight);let n=this.getPos();this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,o,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,o=this.startHeight,i=t.includes("right"),s=t.includes("left"),l=t.includes("bottom"),a=t.includes("top");return i?r=this.startWidth+e:s&&(r=this.startWidth-e),l?o=this.startHeight+n:a&&(o=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(o=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,t):{width:r,height:o}}applyConstraints(t,e,n){var r,o,i,s;if(!n){let c=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(o=this.maxSize)!=null&&o.height&&(d=Math.min(this.maxSize.height,d)),{width:c,height:d}}let l=t,a=e;return lthis.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(s=this.maxSize)!=null&&s.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){let r=n==="left"||n==="right",o=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:o?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}},h0=Go;function Wl(t,e){let{selection:n}=t,{$from:r}=n;if(n instanceof L){let i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let o=r.depth;for(;o>=0;){let i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(e))return!0;o-=1}return!1}function jl(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Ul(t,e){let n=t.getAttribute("style");if(!n)return null;let r=n.split(";").map(i=>i.trim()).filter(Boolean),o=e.toLowerCase();for(let i=r.length-1;i>=0;i-=1){let s=r[i],l=s.indexOf(":");if(l===-1)continue;if(s.slice(0,l).trim().toLowerCase()===o)return s.slice(l+1).trim()}return null}function p0(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")}function m0(t){return t.replace(/&/g,"&").replace(//g,">")}function g0(){return typeof navigator<"u"?/Firefox/.test(navigator.userAgent):!1}function y0(t){return typeof t=="string"}var cf={};Tl(cf,{createAtomBlockMarkdownSpec:()=>df,createBlockMarkdownSpec:()=>Ht,createInlineMarkdownSpec:()=>uf,parseAttributes:()=>Xo,parseIndentedBlocks:()=>Lr,renderNestedMarkdownContent:()=>Vn,serializeAttributes:()=>Yo});function Xo(t){if(!t?.trim())return{};let e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),o=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(o){let c=o.map(d=>d.trim().slice(1));e.class=c.join(" ")}let i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);let s=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(s)).forEach(([,c,d])=>{var u;let f=parseInt(((u=d.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),h=n[f];h&&(e[c]=h.slice(1,-1))});let a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function Yo(t){if(!t||Object.keys(t).length===0)return"";let e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function df(t){let{nodeName:e,name:n,parseAttributes:r=Xo,serializeAttributes:o=Yo,defaultAttributes:i={},requiredAttributes:s=[],allowedAttributes:l}=t,a=n||e,c=d=>{if(!l)return d;let u={};return l.forEach(f=>{f in d&&(u[f]=d[f])}),u};return{parseMarkdown:(d,u)=>{let f={...i,...d.attributes};return u.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;let f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(u=d.match(f))==null?void 0:u.index;return h!==void 0?h:-1},tokenize(d,u,f){let h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=d.match(h);if(!p)return;let m=p[1]||"",g=r(m);if(!s.find(w=>!(w in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:d=>{let u=c(d.attrs||{}),f=o(u),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function Ht(t){let{nodeName:e,name:n,getContent:r,parseAttributes:o=Xo,serializeAttributes:i=Yo,defaultAttributes:s={},content:l="block",allowedAttributes:a}=t,c=n||e,d=u=>{if(!a)return u;let f={};return a.forEach(h=>{h in u&&(f[h]=u[h])}),f};return{parseMarkdown:(u,f)=>{let h;if(r){let m=r(u);h=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?h=f.parseChildren(u.tokens||[]):h=f.parseInline(u.tokens||[]);let p={...s,...u.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(u){var f;let h=new RegExp(`^:::${c}`,"m"),p=(f=u.match(h))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(u,f,h){var p;let m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(m);if(!g)return;let[y,w=""]=g,b=o(w),x=1,k=y.length,M="",S=/^:::([\w-]*)(\s.*)?/gm,P=u.slice(k);for(S.lastIndex=0;;){let A=S.exec(P);if(A===null)break;let v=A.index,R=A[1];if(!((p=A[2])!=null&&p.endsWith(":::"))){if(R)x+=1;else if(x-=1,x===0){let j=P.slice(0,v);M=j.trim();let D=u.slice(0,k+v+A[0].length),O=[];if(M)if(l==="block")for(O=h.blockTokens(j),O.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=h.inlineTokens(H.text))});O.length>0;){let H=O[O.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))O.pop();else break}else O=h.inlineTokens(M);return{type:e,raw:D,attributes:b,content:M,tokens:O}}}}}},renderMarkdown:(u,f)=>{let h=d(u.attrs||{}),p=i(h),m=p?` {${p}}`:"",g=f.renderChildren(u.content||[],` `);return`:::${c}${m} ${g} :::`}}}function b0(t){if(!t.trim())return{};let e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(t);for(;r!==null;){let[,o,i,s]=r;e[o]=i||s,r=n.exec(t)}return e}function w0(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function uf(t){let{nodeName:e,name:n,getContent:r,parseAttributes:o=b0,serializeAttributes:i=w0,defaultAttributes:s={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,d=f=>{if(!a)return f;let h={};return a.forEach(p=>{let m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in f){let y=f[m];if(g!==void 0&&y===g)return;h[m]=y}}),h},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{let p={...s,...f.attributes};if(l)return h.createNode(e,p);let m=r?r(f):f.content||"";return m?h.createNode(e,p,[h.createTextNode(m)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){let h=l?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),p=f.match(h),m=p?.index;return m!==void 0?m:-1},tokenize(f,h,p){let m=l?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),g=f.match(m);if(!g)return;let y="",w="";if(l){let[,x]=g;w=x}else{let[,x,k]=g;w=x,y=k||""}let b=o(w.trim());return{type:e,raw:g[0],content:y.trim(),attributes:b}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(y=>y.type==="text").map(y=>y.text).join(""));let p=d(f.attrs||{}),m=i(p),g=m?` ${m}`:"";return l?`[${c}${g}]`:`[${c}${g}]${h}[/${c}]`}}}function Lr(t,e,n){var r,o,i,s;let l=t.split(` `),a=[],c="",d=0,u=e.baseIndentSize||2;for(;d0)break;if(f.trim()===""){d+=1,c=`${c}${f} `;continue}else return}let p=e.extractItemData(h),{indentLevel:m,mainContent:g}=p;c=`${c}${f} `;let y=[g];for(d+=1;dv.trim()!=="");if(S===-1)break;if((((o=(r=l[d+1+S].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:o.length)||0)>m){y.push(k),c=`${c}${k} `,d+=1;continue}else break}if((((s=(i=k.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:s.length)||0)>m)y.push(k),c=`${c}${k} `,d+=1;else break}let w,b=y.slice(1);if(b.length>0){let k=b.map(M=>M.slice(m+u)).join(` `);k.trim()&&(e.customNestedParser?w=e.customNestedParser(k):w=n.blockTokens(k))}let x=e.createToken(p,w);a.push(x)}if(a.length!==0)return{items:a,raw:c}}function Vn(t,e,n,r){if(!t||!Array.isArray(t.content))return"";let o=typeof n=="function"?n(r):n,[i,...s]=t.content,l=e.renderChildren([i]),a=`${o}${l}`;return s&&s.length>0&&s.forEach((c,d)=>{var u,f;let h=(f=(u=e.renderChild)==null?void 0:u.call(e,c,d+1))!=null?f:e.renderChildren([c]);if(h!=null){let p=h.split(` `).map(m=>m?e.indent(m):e.indent("")).join(` `);a+=c.type==="paragraph"?` ${p}`:` ${p}`}}),a}function Kl(t,e,n={}){let{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendants((l,a)=>{let c=i.mapping.map(a),d=i.mapping.map(a)+l.nodeSize,u=null;if(l.marks.forEach(h=>{if(h!==s)return!1;u=h}),!u)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==u.attrs[h]&&(f=!0)}),f){let h=t.type.create({...t.attrs,...n});i.removeMark(c,d,t.type),i.addMark(c,d,h)}}),i.docChanged&&e.view.dispatch(i)}var x0=class{constructor(t,e,n){this.component=t,this.editor=e.editor,this.options={...n},this.mark=e.mark,this.HTMLAttributes=e.HTMLAttributes}get dom(){return this.editor.view.dom}get contentDOM(){return null}updateAttributes(t,e){Kl(e||this.mark,this.editor,t)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(nn()||Ar())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}},V=class ff extends Ko{constructor(){super(...arguments),this.type="node"}static create(e={}){let n=typeof e=="function"?e():e;return new ff(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},k0=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,o,i,s,l;let{view:a}=this.editor,c=t.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!d)return;let u=0,f=0;if(this.dom!==d){let w=this.dom.getBoundingClientRect(),b=d.getBoundingClientRect(),x=(o=t.offsetX)!=null?o:(r=t.nativeEvent)==null?void 0:r.offsetX,k=(s=t.offsetY)!=null?s:(i=t.nativeEvent)==null?void 0:i.offsetY;u=b.x-w.x+x,f=b.y-w.y+k}let h=this.dom.cloneNode(!0);try{let w=this.dom.getBoundingClientRect();h.style.width=`${Math.round(w.width)}px`,h.style.height=`${Math.round(w.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(h),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(h,u,f)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}let m=this.getPos();if(typeof m!="number")return;let g=L.create(a.state.doc,m),y=a.state.tr.setSelection(g);a.dispatch(y)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});let n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;let o=t.type.startsWith("drag"),i=t.type==="dragover"||t.type==="dragenter",s=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!s&&!o)return!0;let{isEditable:a}=this.editor,{isDragging:c}=this,d=!!this.node.type.spec.draggable,u=L.isSelectable(this.node),f=t.type==="copy",h=t.type==="paste",p=t.type==="cut",m=t.type==="mousedown";if(!d&&u&&o&&t.target===this.dom&&t.preventDefault(),d&&o&&!c&&t.target===this.dom)return t.preventDefault(),!1;if(d&&a&&!c&&m){let g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||i||s||f||h||p||m&&u)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(nn()||Ar())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{let n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){let t=this.getPos();if(typeof t!="number")return;let e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function Te(t){return new qo({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{let i=J(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=n.to;if(l){let d=a.search(/\S/),u=n.from+a.indexOf(l),f=u+l.length;if(Dr(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>u).length)return null;fn.from&&s.delete(n.from+d,u),c=n.from+d+l.length,s.addMark(n.from+d,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(t.type)}}})}function S0(t){return new qo({find:t.find,handler({match:e,chain:n,range:r,pasteEvent:o}){let i=J(t.getAttributes,void 0,e,o),s=J(t.getContent,void 0,i);if(i===!1||i===null)return null;let l={type:t.type.name,attrs:i};s&&(l.content=s),e.input&&n().deleteRange(r).insertContentAt(r.from,l)}})}function C0(t){return new qo({find:t.find,handler:({state:e,range:n,match:r})=>{let o=t.replace,i=n.from,s=n.to;if(r[1]){let l=r[0].lastIndexOf(r[1]);o+=r[0].slice(l+r[1].length),i+=l;let a=i-s;a>0&&(o=r[0].slice(l-a,l)+o,i=s)}e.tr.insertText(o,i,s)}})}var v0=class{constructor(t){this.transaction=t,this.currentStep=this.transaction.steps.length}map(t){let e=!1;return{position:this.transaction.steps.slice(this.currentStep).reduce((r,o)=>{let i=o.getMap().mapResult(r);return i.deleted&&(e=!0),i.pos},t),deleted:e}}};function hf(t={}){return new B({view(e){return new ql(e,t)}})}var ql=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.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),n=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=u?p.bottom:p.top;u&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!i){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=fo(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var de=class t extends z{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):z.near(r)}content(){return E.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new Jl(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!M0(e)||!T0(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(t.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!L.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(t.valid(l))return l}return null}}};de.prototype.visible=!1;de.findFrom=de.findGapCursorFrom;z.jsonID("gapcursor",de);var Jl=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return de.valid(n)?new de(n):z.near(n)}};function pf(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function M0(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||pf(o.type))return!0;if(o.inlineContent)return!1}}return!0}function T0(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||pf(o.type))return!0;if(o.inlineContent)return!1}}return!0}function mf(){return new B({props:{decorations:O0,createSelectionBetween(t,e,n){return e.pos==n.pos&&de.valid(n)?new de(n):null},handleClick:E0,handleKeyDown:A0,handleDOMEvents:{beforeinput:N0}}})}var A0=Sr({ArrowLeft:Zo("horiz",-1),ArrowRight:Zo("horiz",1),ArrowUp:Zo("vert",-1),ArrowDown:Zo("vert",1)});function Zo(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof I){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=de.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new de(c))),!0):!1}}function E0(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!de.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&L.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new de(r))),!0)}function N0(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof de))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=C.empty;for(let s=r.length-1;s>=0;s--)o=C.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new E(o,0,0));return i.setSelection(I.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function O0(t){if(!(t.selection instanceof de))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Z.create(t.doc,[re.widget(t.selection.head,e,{key:"gapcursor"})])}var ei=200,ye=function(){};ye.prototype.append=function(e){return e.length?(e=ye.from(e),!this.length&&e||e.length=n?ye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ye.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};ye.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},n,r),o};ye.from=function(e){return e instanceof ye?e:e&&e.length?new gf(e):ye.empty};var gf=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=ei)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=ei)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(ye);ye.empty=new gf([]);var R0=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,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})(ye),Gl=ye;var D0=500,cn=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new ot(u.map));let h=u.step.map(o.slice(i)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new ot(p,void 0,void 0,c.length+d.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(u.step);if(u.selection)return l=o?u.selection.map(o.slice(i)):u.selection,a=new t(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let d=0;dP0&&(l=I0(l,c),s-=c),new t(l.append(i),s)}remapping(e,n){let r=new lr;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new ot(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=n;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new ot(p,m,g))}else r.push(new ot(p))},o);let c=[];for(let f=n;fD0&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let d=s.selection&&s.selection.map(n.slice(r));d&&i++;let u=new ot(c.invert(),a,d),f,h=o.length-1;(f=o.length&&o[h].merge(u))?o[h]=f:o.push(u)}}else s.map&&r--},this.items.length,0),new t(Gl.from(o.reverse()),i)}};cn.empty=new cn(Gl.empty,0);function I0(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}var ot=class t{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},it=class{constructor(e,n,r,o,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},P0=20;function L0(t,e,n,r){let o=n.getMeta(an),i;if(o)return o.historyState;n.getMeta(H0)&&(t=new it(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(an))return s.getMeta(an).redo?new it(t.done.addTransform(n,void 0,r,ti(e)),t.undone,yf(n.mapping.maps),t.prevTime,t.prevComposition):new it(t.done,t.undone.addTransform(n,void 0,r,ti(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!B0(n,t.prevRanges)),c=s?Xl(t.prevRanges,n.mapping):yf(n.mapping.maps);return new it(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,ti(e)),cn.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new it(t.done.rebased(n,i),t.undone.rebased(n,i),Xl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new it(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Xl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function B0(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let i=0;i=e[i]&&(n=!0)}),n}function yf(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,i,s)=>e.push(i,s));return e}function Xl(t,e){if(!t)return null;let n=[];for(let r=0;r{let o=an.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let i=z0(o,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}var Ql=ni(!1,!0),Zl=ni(!0,!0),CC=ni(!1,!1),vC=ni(!0,!1);var OC=U.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){let r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new B({key:new _("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;let o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){t=!0;return}let s=this.storage.characters({node:r.doc});if(s>o){let l=s-o,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let d=r.tr.deleteRange(a,c);return t=!0,d}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta("paste"))return!1;let l=e.selection.$head.pos,a=i-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}}),Cf=U.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[hf(this.options)]}}),BC=U.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new B({key:new _("focus"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!n||!r)return Z.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(re.node(c,c+a.nodeSize,{class:this.options.className}))}),Z.create(t,i)}}})]}}),vf=U.create({name:"gapCursor",addProseMirrorPlugins(){return[mf()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=J($(t,"allowGapCursor",n)))!=null?e:null}}});function xf(t){let{editor:e,placeholder:n,dataAttribute:r,pos:o,node:i,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,d=[a];return s&&d.push(c),re.node(o,o+i.nodeSize,{class:d.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:o,hasAnchor:l}):n})}function $0(t){let e=getComputedStyle(t),n=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(n)}function F0(t){let e=t;for(;e;){if($0(e))return e;let n=e.parentElement;if(!n){let r=e.getRootNode();if(r instanceof ShadowRoot){e=r.host;continue}return window}e=n}return window}function _0(t){return t===window?{top:0,bottom:window.innerHeight}:t.getBoundingClientRect()}function V0({doc:t,view:e,scrollContainer:n}){let r=e.dom.getBoundingClientRect(),o=n?_0(n):{top:0,bottom:window.innerHeight},i=Math.max(r.top,o.top),s=Math.min(r.bottom,o.bottom);if(i>=s)return{top:0,bottom:t.content.size};let a=getComputedStyle(e.dom).direction==="rtl"?Math.max(r.right-2,r.left+2):r.left+2,c=e.posAtCoords({left:a,top:i+2}),d=e.posAtCoords({left:a,top:s-2});return{top:c?c.pos:0,bottom:d?d.pos:t.content.size}}function W0(t,e){let n=null;return{call:((...i)=>{n||(t(...i),n=setTimeout(()=>{n=null},e))}),cancel:()=>{n&&(clearTimeout(n),n=null)}}}var kf="placeholder";function j0(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Br=new _("tiptap__placeholder"),ea=U.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:kf,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let t=this.options.dataAttribute?`data-${j0(this.options.dataAttribute)}`:`data-${kf}`;return[new B({state:{init(){return{topPos:null,bottomPos:null}},apply(e,n){let r=e.getMeta(Br);return r?.positions?{topPos:r.positions.top,bottomPos:r.positions.bottom}:e.docChanged?{topPos:n.topPos!==null?e.mapping.map(n.topPos):null,bottomPos:n.bottomPos!==null?e.mapping.map(n.bottomPos):null}:n}},key:Br,view(e){let n=F0(e.dom),r=()=>{let l=V0({view:e,doc:e.state.doc,scrollContainer:n}),a=Br.getState(e.state);if(a.topPos===l.top&&a.bottomPos===l.bottom)return;let c=e.state.tr.setMeta(Br,{positions:l}).setMeta("tiptap__viewportUpdate",!0);e.dispatch(c)},{call:o,cancel:i}=W0(r,250),s=n;return s.addEventListener("scroll",o,{passive:!0}),r(),{update(l,a){e.state.doc.content.size!==a.doc.content.size&&r()},destroy:()=>{i(),s.removeEventListener("scroll",o)}}},props:{decorations:({doc:e,selection:n})=>{var r,o;if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;let{anchor:s}=n,l=[],a=this.editor.isEmpty;if(this.options.showOnlyCurrent&&!this.options.includeChildren){let d=e.resolve(s);if(d.depth>0){let u=d.node(1),f=d.before(1);if(u.type.isTextblock&&ln(u)){let h=s>=f&&s<=f+u.nodeSize,p=xf({node:u,dataAttribute:t,hasAnchor:h,placeholder:this.options.placeholder,classes:{emptyEditor:this.options.emptyEditorClass,emptyNode:this.options.emptyNodeClass},editor:this.editor,isEmptyDoc:a,pos:d.before(1)});l.push(p)}}}else{let d=Br.getState(this.editor.state),u=(r=d.topPos)!=null?r:0,f=(o=d.bottomPos)!=null?o:e.content.size;e.nodesBetween(u,f,(h,p)=>{let m=s>=p&&s<=p+h.nodeSize,g=!h.isLeaf&&ln(h);if(!h.type.isTextblock)return this.options.includeChildren;if((m||!this.options.showOnlyCurrent)&&g){let y=xf({classes:{emptyEditor:this.options.emptyEditorClass,emptyNode:this.options.emptyNodeClass},editor:this.editor,isEmptyDoc:a,dataAttribute:t,hasAnchor:m,placeholder:this.options.placeholder,node:h,pos:p});l.push(y)}return this.options.includeChildren})}return Z.create(e,l)}}})]}}),KC=U.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new B({key:new _("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Ir(n.selection)||t.view.dragging?null:Z.create(n.doc,[re.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}}),U0="skipTrailingNode";function Sf({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var GC=U.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;let e=new _(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new B({key:e,appendTransaction:(o,i,s)=>{let{doc:l,tr:a,schema:c}=s,d=e.getState(s),u=l.content.size,f=c.nodes[n];if(!o.some(h=>h.getMeta(U0))&&d)return a.insert(u,f.create())},state:{init:(o,i)=>{let s=i.tr.doc.lastChild;return!Sf({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;let s=o.doc.lastChild;return!Sf({node:s,types:r})}}})]}}),Mf=U.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Ql(t,e),redo:()=>({state:t,dispatch:e})=>Zl(t,e)}},addProseMirrorPlugins(){return[wf(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Wn=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]};var K0=/^\s*>\s$/,q0=V.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Wn("blockquote",{...N(this.options.HTMLAttributes,t),children:Wn("slot",{})})},parseMarkdown:(t,e)=>{var n;let r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";let n=">",r=[];return t.content.forEach((o,i)=>{var s,l;let d=((l=(s=e.renderChild)==null?void 0:s.call(e,o,i))!=null?l:e.renderChildren([o])).split(` `).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(d.join(` `))}),r.join(` ${n} `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ge({find:K0,type:this.type})]}}),Tf=q0;var J0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,G0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,X0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Y0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Q0=te.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Wn("strong",{...N(this.options.HTMLAttributes,t),children:Wn("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[De({find:J0,type:this.type}),De({find:X0,type:this.type})]},addPasteRules(){return[Te({find:G0,type:this.type}),Te({find:Y0,type:this.type})]}}),Af=Q0;var Z0=/(^|[^`])`([^`]+)`(?!`)$/,ew=/(^|[^`])`([^`]+)`(?!`)/g,tw=te.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",N(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[De({find:Z0,type:this.type})]},addPasteRules(){return[Te({find:ew,type:this.type})]}}),Ef=tw;var ta=4,nw=/^```([a-z]+)?[\s\n]$/,rw=/^~~~([a-z]+)?[\s\n]$/,ow=V.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ta,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options;if(!n)return null;let i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",N(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="",o=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${o}`,e.renderChildren(t.content),"```"].join(` `):r=`\`\`\`${o} \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!=null?e:ta,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;if(i.parent.type!==this.type)return!1;let l=" ".repeat(n);return s?t.commands.insertContent(l):t.commands.command(({tr:a})=>{let{from:c,to:d}=o,h=r.doc.textBetween(c,d,` `,` `).split(` `).map(p=>l+p).join(` `);return a.replaceWith(c,d,r.schema.text(h)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!=null?e:ta,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;return i.parent.type!==this.type?!1:s?t.commands.command(({tr:l})=>{var a;let{pos:c}=i,d=i.start(),u=i.end(),h=r.doc.textBetween(d,u,` `,` `).split(` `),p=0,m=0,g=c-d;for(let M=0;M=g){p=M;break}m+=h[M].length+1}let w=((a=h[p].match(/^ */))==null?void 0:a[0])||"",b=Math.min(w.length,n);if(b===0)return!0;let x=d;for(let M=0;M{let{from:a,to:c}=o,f=r.doc.textBetween(a,c,` `,` `).split(` `).map(h=>{var p;let m=((p=h.match(/^ */))==null?void 0:p[0])||"",g=Math.min(m.length,n);return h.slice(g)}).join(` `);return l.replaceWith(a,c,r.schema.text(f)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(` `);return!i||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;let l=o.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(z.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[_n({find:nw,type:this.type,getAttributes:t=>({language:t[1]})}),_n({find:rw,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new B({key:new _("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;let{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,` `));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(I.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),Nf=ow;var Of=V.create({name:"customBlock",group:"block",atom:!0,defining:!0,draggable:!0,selectable:!0,isolating:!0,allowGapCursor:!0,inline:!1,addNodeView(){return({editor:t,node:e,getPos:n,HTMLAttributes:r,decorations:o,extension:i})=>{let s=document.createElement("div");s.setAttribute("data-config",JSON.stringify(e.attrs.config)),s.setAttribute("data-id",e.attrs.id),s.setAttribute("data-type","customBlock");let l=document.createElement("div");if(l.className="fi-fo-rich-editor-custom-block-header fi-not-prose",s.appendChild(l),t.isEditable&&typeof e.attrs.config=="object"&&e.attrs.config!==null&&Object.keys(e.attrs.config).length>0){let c=document.createElement("div");c.className="fi-fo-rich-editor-custom-block-edit-btn-ctn",l.appendChild(c);let d=document.createElement("button");d.className="fi-icon-btn",d.type="button",d.innerHTML=i.options.editCustomBlockButtonIconHtml,d.addEventListener("click",()=>i.options.editCustomBlockUsing(e.attrs.id,e.attrs.config)),c.appendChild(d)}let a=document.createElement("p");if(a.className="fi-fo-rich-editor-custom-block-heading",a.textContent=e.attrs.label,l.appendChild(a),t.isEditable){let c=document.createElement("div");c.className="fi-fo-rich-editor-custom-block-delete-btn-ctn",l.appendChild(c);let d=document.createElement("button");d.className="fi-icon-btn",d.type="button",d.innerHTML=i.options.deleteCustomBlockButtonIconHtml,d.addEventListener("click",()=>t.chain().setNodeSelection(n()).deleteSelection().run()),c.appendChild(d)}if(e.attrs.preview){let c=document.createElement("div"),d=["fi-fo-rich-editor-custom-block-preview"];e.attrs.shouldApplyProseStylingToPreview||d.push("fi-not-prose"),c.className=d.join(" "),c.innerHTML=new TextDecoder().decode(Uint8Array.from(atob(e.attrs.preview),u=>u.charCodeAt(0))),s.appendChild(c)}return{dom:s}}},addOptions(){return{deleteCustomBlockButtonIconHtml:null,editCustomBlockButtonIconHtml:null,editCustomBlockUsing:()=>{},insertCustomBlockUsing:()=>{}}},addAttributes(){return{config:{default:null,parseHTML:t=>JSON.parse(t.getAttribute("data-config")),renderHTML:t=>t.config?{"data-config":JSON.stringify(t.config)}:{}},id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),rendered:!1},preview:{default:null,parseHTML:t=>t.getAttribute("data-preview"),rendered:!1},shouldApplyProseStylingToPreview:{default:!1,rendered:!1}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",N({"data-type":"customBlock"},t)]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1,{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;let s=new ne,l=0;return e.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return n=!0,s=a,l=c,!1}),n})}},addProseMirrorPlugins(){let{insertCustomBlockUsing:t}=this.options;return[new B({props:{handleDrop(e,n){if(!n||(n.preventDefault(),!n.dataTransfer.getData("customBlock")))return!1;let r=n.dataTransfer.getData("customBlock");return t(r,e.posAtCoords({left:n.clientX,top:n.clientY}).pos),!1}}})]}});var ri=(t,e)=>e.view.domAtPos(t).node.offsetParent!==null,iw=(t,e,n)=>{for(let r=t.depth;r>0;r-=1){let o=t.node(r),i=e(o),s=ri(t.start(r),n);if(i&&s)return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:o}}},Rf=(t,e)=>{let{state:n,view:r,extensionManager:o}=t,{schema:i,selection:s}=n,{empty:l,$anchor:a}=s,c=!!o.extensions.find(y=>y.name==="gapCursor");if(!l||a.parent.type!==i.nodes.detailsSummary||!c||e==="right"&&a.parentOffset!==a.parent.nodeSize-2)return!1;let d=Je(y=>y.type===i.nodes.details)(s);if(!d)return!1;let u=sn(d.node,y=>y.type===i.nodes.detailsContent);if(!u.length||ri(d.start+u[0].pos+1,t))return!1;let h=n.doc.resolve(d.pos+d.node.nodeSize),p=de.findFrom(h,1,!1);if(!p)return!1;let{tr:m}=n,g=new de(p);return m.setSelection(g),m.scrollIntoView(),r.dispatch(m),!0},Df=V.create({name:"details",content:"detailsSummary detailsContent",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:"is-open",HTMLAttributes:{},renderToggleButton:({element:t,isOpen:e})=>{t.setAttribute("aria-label",e?"Collapse details content":"Expand details content")}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:({open:t})=>t?{open:""}:{}}}:[]},parseHTML(){return[{tag:"details"}]},renderHTML({HTMLAttributes:t}){return["details",N(this.options.HTMLAttributes,t),0]},...Ht({nodeName:"details",content:"block"}),addNodeView(){return({editor:t,getPos:e,node:n,HTMLAttributes:r})=>{let o=document.createElement("div"),i=N(this.options.HTMLAttributes,r,{"data-type":this.name});Object.entries(i).forEach(([d,u])=>o.setAttribute(d,u));let s=document.createElement("button");s.type="button";let l=d=>{this.options.renderToggleButton({element:s,...d})};o.append(s);let a=document.createElement("div");o.append(a);let c=d=>{let{setToValue:u,node:f=n}=d||{};if(u!==void 0)if(u){if(o.classList.contains(this.options.openClassName))return;o.classList.add(this.options.openClassName)}else{if(!o.classList.contains(this.options.openClassName))return;o.classList.remove(this.options.openClassName)}else o.classList.toggle(this.options.openClassName);let h=o.classList.contains(this.options.openClassName);l({isOpen:h,node:f});let p=new Event("toggleDetailsContent"),m=a.querySelector(':scope > div[data-type="detailsContent"]');m?.dispatchEvent(p)};return l({isOpen:!!n.attrs.open,node:n}),n.attrs.open&&setTimeout(()=>c()),s.addEventListener("click",()=>{if(c(),!this.options.persist){t.commands.focus(void 0,{scrollIntoView:!1});return}if(t.isEditable&&typeof e=="function"){let{from:d,to:u}=t.state.selection;t.chain().command(({tr:f})=>{let h=e();if(!h)return!1;let p=f.doc.nodeAt(h);return p?.type!==this.type?!1:(f.setNodeMarkup(h,void 0,{open:!p.attrs.open}),!0)}).setTextSelection({from:d,to:u}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:o,contentDOM:a,ignoreMutation(d){if(d.type==="selection")return!1;let u=d.target,f=o.contains(u);return s.contains(u)||!f||o===u},update:d=>d.type!==this.type?!1:(d.attrs.open!==void 0?c({setToValue:d.attrs.open,node:d}):l({isOpen:o.classList.contains(this.options.openClassName),node:d}),!0)}}},addCommands(){return{setDetails:()=>({state:t,chain:e})=>{var n;let{schema:r,selection:o}=t,{$from:i,$to:s}=o,l=i.blockRange(s);if(!l)return!1;let a=t.doc.slice(l.start,l.end);if(!r.nodes.detailsContent.contentMatch.matchFragment(a.content))return!1;let d=((n=a.toJSON())==null?void 0:n.content)||[];return e().insertContentAt({from:l.start,to:l.end},{type:this.name,content:[{type:"detailsSummary"},{type:"detailsContent",content:d}]}).setTextSelection(l.start+2).run()},unsetDetails:()=>({state:t,chain:e})=>{let{selection:n,schema:r}=t,o=Je(y=>y.type===this.type)(n);if(!o)return!1;let i=sn(o.node,y=>y.type===r.nodes.detailsSummary),s=sn(o.node,y=>y.type===r.nodes.detailsContent);if(!i.length||!s.length)return!1;let l=i[0],a=s[0],c=o.pos,d=t.doc.resolve(c),u=c+o.node.nodeSize,f={from:c,to:u},h=a.node.content.toJSON()||[],p=d.parent.type.contentMatch.defaultType,g=[p?.create(null,l.node.content).toJSON(),...h];return e().insertContentAt(f,g).setTextSelection(c+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{let{schema:t,selection:e}=this.editor.state,{empty:n,$anchor:r}=e;return!n||r.parent.type!==t.nodes.detailsSummary?!1:r.parentOffset!==0?this.editor.commands.command(({tr:o})=>{let i=r.pos-1,s=r.pos;return o.delete(i,s),!0}):this.editor.commands.unsetDetails()},Enter:({editor:t})=>{let{state:e,view:n}=t,{schema:r,selection:o}=e,{$head:i}=o;if(i.parent.type!==r.nodes.detailsSummary)return!1;let s=ri(i.after()+1,t),l=s?e.doc.nodeAt(i.after()):i.node(-2);if(!l)return!1;let a=s?0:i.indexAfter(-1),c=$n(l.contentMatchAt(a));if(!c||!l.canReplaceWith(a,a,c))return!1;let d=c.createAndFill();if(!d)return!1;let u=s?i.after()+1:i.after(-1),f=e.tr.replaceWith(u,u,d),h=f.doc.resolve(u),p=z.near(h,1);return f.setSelection(p),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:t})=>Rf(t,"right"),ArrowDown:({editor:t})=>Rf(t,"down")}},addProseMirrorPlugins(){return[new B({key:new _("detailsSelection"),appendTransaction:(t,e,n)=>{let{editor:r,type:o}=this;if(r.view.composing||!t.some(y=>y.selectionSet)||!e.selection.empty||!n.selection.empty||!Uo(n,o.name))return;let{$from:a}=n.selection;if(ri(a.pos,r))return;let d=iw(a,y=>y.type===o,r);if(!d)return;let u=sn(d.node,y=>y.type===n.schema.nodes.detailsSummary);if(!u.length)return;let f=u[0],p=(e.selection.from{let e=document.createElement("div"),n=N(this.options.HTMLAttributes,t,{"data-type":this.name,hidden:"hidden"});return Object.entries(n).forEach(([r,o])=>e.setAttribute(r,o)),e.addEventListener("toggleDetailsContent",()=>{e.toggleAttribute("hidden")}),{dom:e,contentDOM:e,ignoreMutation(r){return r.type==="selection"?!1:!e.contains(r.target)||e===r.target},update:r=>r.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{let{state:e,view:n}=t,{selection:r}=e,{$from:o,empty:i}=r,s=Je(R=>R.type===this.type)(r);if(!i||!s||!s.node.childCount)return!1;let l=o.index(s.depth),{childCount:a}=s.node;if(!(a===l+1))return!1;let d=s.node.type.contentMatch.defaultType,u=d?.createAndFill();if(!u)return!1;let f=e.doc.resolve(s.pos+1),h=a-1,p=s.node.child(h),m=f.posAtIndex(h,s.depth);if(!p.eq(u))return!1;let y=o.node(-3);if(!y)return!1;let w=o.indexAfter(-3),b=$n(y.contentMatchAt(w));if(!b||!y.canReplaceWith(w,w,b))return!1;let x=b.createAndFill();if(!x)return!1;let{tr:k}=e,M=o.after(-2);k.replaceWith(M,M,x);let S=k.doc.resolve(M),P=z.near(S,1);k.setSelection(P);let A=m,v=m+p.nodeSize;return k.delete(A,v),k.scrollIntoView(),n.dispatch(k),!0}}},...Ht({nodeName:"detailsContent"})}),Pf=V.create({name:"detailsSummary",content:"text*",defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"summary"}]},renderHTML({HTMLAttributes:t}){return["summary",N(this.options.HTMLAttributes,t),0]},...Ht({nodeName:"detailsSummary",content:"inline"})});var sw=V.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` `):""}),Lf=sw;var Bf=V.create({name:"grid",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"gridColumn+",addOptions(){return{HTMLAttributes:{class:"grid-layout"}}},addAttributes(){return{"data-cols":{default:2,parseHTML:t=>t.getAttribute("data-cols")},"data-from-breakpoint":{default:"md",parseHTML:t=>t.getAttribute("data-from-breakpoint")},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>({style:`grid-template-columns: repeat(${t["data-cols"]}, 1fr)`})}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("grid-layout")&&null}]},renderHTML({HTMLAttributes:t}){return["div",N(this.options.HTMLAttributes,t),0]},addCommands(){return{insertGrid:({columns:t=[1,1],fromBreakpoint:e,coordinates:n=null}={})=>({tr:r,dispatch:o,editor:i})=>{let s=i.schema.nodes.gridColumn,l=Array.isArray(t)&&t.length?t:[1,1],a=[];for(let u=0;uNumber(u)||1).reduce((u,f)=>u+f,0),d=i.schema.nodes.grid.createChecked({"data-cols":c,"data-from-breakpoint":e},a);if(o){let u=r.selection.anchor+1;[null,void 0].includes(n?.from)?r.replaceSelectionWith(d).scrollIntoView().setSelection(I.near(r.doc.resolve(u))):r.replaceRangeWith(n.from,n.to,d).scrollIntoView().setSelection(I.near(r.doc.resolve(n.from)))}return!0}}}});var zf=V.create({name:"gridColumn",content:"block+",isolating:!0,addOptions(){return{HTMLAttributes:{class:"grid-layout-col"}}},addAttributes(){return{"data-col-span":{default:1,parseHTML:t=>t.getAttribute("data-col-span"),renderHTML:t=>({"data-col-span":t["data-col-span"]??1})},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>({style:`grid-column: span ${t["data-col-span"]??1};`})}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("grid-layout-col")&&null}]},renderHTML({HTMLAttributes:t}){return["div",N(this.options.HTMLAttributes,t),0]}});var lw=V.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",N(this.options.HTMLAttributes,t)]},renderText(){return` `},renderMarkdown:()=>` `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&s){let u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Hf=lw;var aw=V.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(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,N(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;let r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,o="#".repeat(r);return t.content?`${o} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>_n({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),$f=aw;var cw=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,dw=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,uw=te.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||Ul(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",N(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){let o=/^(==)([^=]+)(==)/.exec(t);if(o){let i=o[2].trim(),s=n.inlineTokens(i);return{type:"highlight",raw:o[0],text:i,tokens:s}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[De({find:cw,type:this.type})]},addPasteRules(){return[Te({find:dw,type:this.type})]}}),Ff=uw;var fw=V.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",N(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Wl(e,e.schema.nodes[this.name]))return!1;let{selection:n}=e,{$to:r}=n,o=t();return Ir(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:i,tr:s,dispatch:l})=>{if(l){let{$to:a}=s.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(I.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(L.create(s.doc,a.pos)):s.setSelection(I.create(s.doc,a.pos));else{let d=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(s.insert(c,u),s.setSelection(I.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Pr({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),_f=fw;var hw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,pw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,mw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,gw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,yw=te.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",N(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[De({find:hw,type:this.type}),De({find:mw,type:this.type})]},addPasteRules(){return[Te({find:pw,type:this.type}),Te({find:gw,type:this.type})]}}),Vf=yw;var bw=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,ww=V.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},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},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",N(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,o,i,s;let l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",a=(o=(r=t.attrs)==null?void 0:r.alt)!=null?o:"",c=(s=(i=t.attrs)==null?void 0:i.title)!=null?s:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;let{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:o,getPos:i,HTMLAttributes:s,editor:l})=>{let a=document.createElement("img");Object.entries(s).forEach(([u,f])=>{if(f!=null)switch(u){case"width":case"height":break;default:a.setAttribute(u,f);break}}),a.src=s.src;let c=new Go({element:a,editor:l,node:o,getPos:i,onResize:(u,f)=>{a.style.width=`${u}px`,a.style.height=`${f}px`},onCommit:(u,f)=>{let h=i();h!==void 0&&this.editor.chain().setNodeSelection(h).updateAttributes(this.name,{width:u,height:f}).run()},onUpdate:(u,f,h)=>u.type===o.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),d=c.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",a.onload=()=>{d.style.visibility="",d.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Pr({find:bw,type:this.type,getAttributes:t=>{let[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Wf=ww;var jf=Wf.extend({addAttributes(){return{...this.parent?.(),id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},width:{default:null,parseHTML:t=>t.getAttribute("width")||t.style.width||null,renderHTML:t=>t.width?{width:t.width,style:`width: ${t.width}`}:{}},height:{default:null,parseHTML:t=>t.getAttribute("height")||t.style.height||null,renderHTML:t=>t.height?{height:t.height,style:`height: ${t.height}`}:{}}}}});var Uf=V.create({name:"lead",group:"block",content:"block+",addOptions(){return{HTMLAttributes:{class:"lead"}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("lead")}]},renderHTML({HTMLAttributes:t}){return["div",N(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleLead:()=>({commands:t})=>t.toggleWrap(this.name)}}});var xw="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",kw="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",aa="numeric",ca="ascii",da="alpha",$r="asciinumeric",Hr="alphanumeric",ua="domain",Yf="emoji",Sw="scheme",Cw="slashscheme",na="whitespace";function vw(t,e){return t in e||(e[t]=[]),e[t]}function dn(t,e,n){e[aa]&&(e[$r]=!0,e[Hr]=!0),e[ca]&&(e[$r]=!0,e[da]=!0),e[$r]&&(e[Hr]=!0),e[da]&&(e[Hr]=!0),e[Hr]&&(e[ua]=!0),e[Yf]&&(e[ua]=!0);for(let r in e){let o=vw(r,n);o.indexOf(t)<0&&o.push(t)}}function Mw(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ne(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ne.groups={};Ne.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,o),ie=(t,e,n,r,o)=>t.tr(e,n,r,o),Kf=(t,e,n,r,o)=>t.ts(e,n,r,o),T=(t,e,n,r,o)=>t.tt(e,n,r,o),Ct="WORD",fa="UWORD",Qf="ASCIINUMERICAL",Zf="ALPHANUMERICAL",Ur="LOCALHOST",ha="TLD",pa="UTLD",li="SCHEME",jn="SLASH_SCHEME",ga="NUM",ma="WS",ya="NL",Fr="OPENBRACE",_r="CLOSEBRACE",ai="OPENBRACKET",ci="CLOSEBRACKET",di="OPENPAREN",ui="CLOSEPAREN",fi="OPENANGLEBRACKET",hi="CLOSEANGLEBRACKET",pi="FULLWIDTHLEFTPAREN",mi="FULLWIDTHRIGHTPAREN",gi="LEFTCORNERBRACKET",yi="RIGHTCORNERBRACKET",bi="LEFTWHITECORNERBRACKET",wi="RIGHTWHITECORNERBRACKET",xi="FULLWIDTHLESSTHAN",ki="FULLWIDTHGREATERTHAN",Si="AMPERSAND",Ci="APOSTROPHE",vi="ASTERISK",Ft="AT",Mi="BACKSLASH",Ti="BACKTICK",Ai="CARET",un="COLON",ba="COMMA",Ei="DOLLAR",st="DOT",Ni="EQUALS",wa="EXCLAMATION",_e="HYPHEN",Vr="PERCENT",Oi="PIPE",Ri="PLUS",Di="POUND",Wr="QUERY",xa="QUOTE",eh="FULLWIDTHMIDDLEDOT",ka="SEMI",lt="SLASH",jr="TILDE",Ii="UNDERSCORE",th="EMOJI",Pi="SYM",nh=Object.freeze({__proto__:null,ALPHANUMERICAL:Zf,AMPERSAND:Si,APOSTROPHE:Ci,ASCIINUMERICAL:Qf,ASTERISK:vi,AT:Ft,BACKSLASH:Mi,BACKTICK:Ti,CARET:Ai,CLOSEANGLEBRACKET:hi,CLOSEBRACE:_r,CLOSEBRACKET:ci,CLOSEPAREN:ui,COLON:un,COMMA:ba,DOLLAR:Ei,DOT:st,EMOJI:th,EQUALS:Ni,EXCLAMATION:wa,FULLWIDTHGREATERTHAN:ki,FULLWIDTHLEFTPAREN:pi,FULLWIDTHLESSTHAN:xi,FULLWIDTHMIDDLEDOT:eh,FULLWIDTHRIGHTPAREN:mi,HYPHEN:_e,LEFTCORNERBRACKET:gi,LEFTWHITECORNERBRACKET:bi,LOCALHOST:Ur,NL:ya,NUM:ga,OPENANGLEBRACKET:fi,OPENBRACE:Fr,OPENBRACKET:ai,OPENPAREN:di,PERCENT:Vr,PIPE:Oi,PLUS:Ri,POUND:Di,QUERY:Wr,QUOTE:xa,RIGHTCORNERBRACKET:yi,RIGHTWHITECORNERBRACKET:wi,SCHEME:li,SEMI:ka,SLASH:lt,SLASH_SCHEME:jn,SYM:Pi,TILDE:jr,TLD:ha,UNDERSCORE:Ii,UTLD:pa,UWORD:fa,WORD:Ct,WS:ma}),kt=/[a-z]/,zr=/\p{L}/u,ra=/\p{Emoji}/u;var St=/\d/,oa=/\s/;var qf="\r",ia=` `,Tw="\uFE0F",Aw="\u200D",sa="\uFFFC",oi=null,ii=null;function Ew(t=[]){let e={};Ne.groups=e;let n=new Ne;oi==null&&(oi=Jf(xw)),ii==null&&(ii=Jf(kw)),T(n,"'",Ci),T(n,"{",Fr),T(n,"}",_r),T(n,"[",ai),T(n,"]",ci),T(n,"(",di),T(n,")",ui),T(n,"<",fi),T(n,">",hi),T(n,"\uFF08",pi),T(n,"\uFF09",mi),T(n,"\u300C",gi),T(n,"\u300D",yi),T(n,"\u300E",bi),T(n,"\u300F",wi),T(n,"\uFF1C",xi),T(n,"\uFF1E",ki),T(n,"&",Si),T(n,"*",vi),T(n,"@",Ft),T(n,"`",Ti),T(n,"^",Ai),T(n,":",un),T(n,",",ba),T(n,"$",Ei),T(n,".",st),T(n,"=",Ni),T(n,"!",wa),T(n,"-",_e),T(n,"%",Vr),T(n,"|",Oi),T(n,"+",Ri),T(n,"#",Di),T(n,"?",Wr),T(n,'"',xa),T(n,"/",lt),T(n,";",ka),T(n,"~",jr),T(n,"_",Ii),T(n,"\\",Mi),T(n,"\u30FB",eh);let r=ie(n,St,ga,{[aa]:!0});ie(r,St,r);let o=ie(r,kt,Qf,{[$r]:!0}),i=ie(r,zr,Zf,{[Hr]:!0}),s=ie(n,kt,Ct,{[ca]:!0});ie(s,St,o),ie(s,kt,s),ie(o,St,o),ie(o,kt,o);let l=ie(n,zr,fa,{[da]:!0});ie(l,kt),ie(l,St,i),ie(l,zr,l),ie(i,St,i),ie(i,kt),ie(i,zr,i);let a=T(n,ia,ya,{[na]:!0}),c=T(n,qf,ma,{[na]:!0}),d=ie(n,oa,ma,{[na]:!0});T(n,sa,d),T(c,ia,a),T(c,sa,d),ie(c,oa,d),T(d,qf),T(d,ia),ie(d,oa,d),T(d,sa,d);let u=ie(n,ra,th,{[Yf]:!0});T(u,"#"),ie(u,ra,u),T(u,Tw,u);let f=T(u,Aw);T(f,"#"),ie(f,ra,u);let h=[[kt,s],[St,o]],p=[[kt,null],[zr,l],[St,i]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?w[ua]=!0:kt.test(g)?St.test(g)?w[$r]=!0:w[ca]=!0:w[aa]=!0,Kf(n,g,g,w)}return Kf(n,"localhost",Ur,{ascii:!0}),n.jd=new Ne(Pi),{start:n,tokens:Object.assign({groups:e},nh)}}function rh(t,e){let n=Nw(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],i=0,s=0;for(;s=0&&(u+=n[s].length,f++),c+=n[s].length,i+=n[s].length,s++;i-=u,s-=f,c-=u,o.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function Nw(t){let e=[],n=t.length,r=0;for(;r56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function $t(t,e,n,r,o){let i,s=e.length;for(let l=0;l=0;)i++;if(i>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(t[r]),r++}return e}var Kr={defaultProtocol:"http",events:null,format:Gf,formatHref:Gf,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Sa(t,e=null){let n=Object.assign({},Kr);t&&(n=Object.assign(n,t instanceof Sa?t.o:t));let r=n.ignoreTags,o=[];for(let i=0;in?r.substring(0,n)+"\u2026":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Kr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){let e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),u=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:o,attributes:s,content:i,eventListeners:u}}};function Li(t,e){class n extends oh{constructor(o,i){super(o,i),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var Ow=Li("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Xf=Li("text"),Rw=Li("nl"),si=Li("url",{isLink:!0,toHref(t=Kr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==Ur&&t[1].t===un}});var Fe=t=>new Ne(t);function Dw({groups:t}){let e=t.domain.concat([Si,vi,Ft,Mi,Ti,Ai,Ei,Ni,_e,ga,Vr,Oi,Ri,Di,lt,Pi,jr,Ii]),n=[Ci,un,ba,st,wa,Vr,Wr,xa,ka,fi,hi,Fr,_r,ci,ai,di,ui,pi,mi,gi,yi,bi,wi,xi,ki],r=[Si,Ci,vi,Mi,Ti,Ai,Ei,Ni,_e,Fr,_r,Vr,Oi,Ri,Di,Wr,lt,Pi,jr,Ii],o=Fe(),i=T(o,jr);K(i,r,i),K(i,t.domain,i);let s=Fe(),l=Fe(),a=Fe();K(o,t.domain,s),K(o,t.scheme,l),K(o,t.slashscheme,a),K(s,r,i),K(s,t.domain,s);let c=T(s,Ft);T(i,Ft,c),T(l,Ft,c),T(a,Ft,c);let d=T(i,st);K(d,r,i),K(d,t.domain,i);let u=Fe();K(c,t.domain,u),K(u,t.domain,u);let f=T(u,st);K(f,t.domain,u);let h=Fe(Ow);K(f,t.tld,h),K(f,t.utld,h),T(c,Ur,h);let p=T(u,_e);T(p,_e,p),K(p,t.domain,u),K(h,t.domain,u),T(h,st,f),T(h,_e,p);let m=T(s,_e),g=T(s,st);T(m,_e,m),K(m,t.domain,s),K(g,r,i),K(g,t.domain,s);let y=Fe(si);K(g,t.tld,y),K(g,t.utld,y),K(y,t.domain,s),K(y,r,i),T(y,st,g),T(y,_e,m),T(y,Ft,c);let w=T(y,un),b=Fe(si);K(w,t.numeric,b);let x=Fe(si),k=Fe();K(x,e,x),K(x,n,k),K(k,e,x),K(k,n,k),T(y,lt,x),T(b,lt,x);let M=T(l,un),S=T(a,un),P=T(S,lt),A=T(P,lt);K(l,t.domain,s),T(l,st,g),T(l,_e,m),K(a,t.domain,s),T(a,st,g),T(a,_e,m),K(M,t.domain,x),T(M,lt,x),T(M,Wr,x),K(A,t.domain,x),K(A,e,x),T(A,lt,x);let v=[[Fr,_r],[ai,ci],[di,ui],[fi,hi],[pi,mi],[gi,yi],[bi,wi],[xi,ki]];for(let R=0;R=0&&f++,o++,d++;if(f<0)o-=d,o0&&(i.push(la(Xf,e,s)),s=[]),o-=f,d-=f;let h=u.t,p=n.slice(o-d,o);i.push(la(h,e,p))}}return s.length>0&&i.push(la(Xf,e,s)),i}function la(t,e,n){let r=n[0].s,o=n[n.length-1].e,i=e.slice(r,o);return new t(i,n)}var Pw=typeof console<"u"&&console&&console.warn||(()=>{}),Lw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ee={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ih(){return Ne.groups={},ee.scanner=null,ee.parser=null,ee.tokenQueue=[],ee.pluginQueue=[],ee.customSchemes=[],ee.initialized=!1,ee}function Ca(t,e=!1){if(ee.initialized&&Pw(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Lw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))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`);ee.customSchemes.push([t,e])}function Bw(){ee.scanner=Ew(ee.customSchemes);for(let t=0;t{let o=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=zo(n.doc,[...e]);if(jo(l).forEach(({newRange:c})=>{let d=Rl(r.doc,c,h=>h.isTextblock),u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){let h=r.doc.textBetween(c.from,c.to," "," ");if(!Hw.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&f){let h=f.split(zw).filter(Boolean);if(h.length<=0)return!1;let p=h[h.length-1],m=u.pos+f.lastIndexOf(p);if(!p)return!1;let g=Bi(p).map(y=>y.toObject(t.defaultProtocol));if(!Fw(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{Dr(y.from,y.to,r.doc).some(w=>w.mark.type===t.type)||s.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function Vw(t){return new B({key:new _("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let a=r.target;if(!a)return!1;let c=t.editor.view.dom;s=a.closest("a"),s&&!c.contains(s)&&(s=null)}if(!s)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){let a=Wo(e.state,t.type.name),c=(o=s.href)!=null?o:a.href,d=(i=s.target)!=null?i:a.target;c&&(window.open(c,d),l=!0)}return l}}})}function Ww(t){return new B({key:new _("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:o}=t,{state:i}=e,{selection:s}=i,{empty:l}=s;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});let c=zi(a,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||o!==void 0&&!o(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function fn(t,e){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace($w,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var jw=te.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Ca(t);return}Ca(t.scheme,t.optionalSlashes)})},onDestroy(){ih()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!fn(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;let o=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(o)||!/\./.test(o))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{let e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!fn(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!fn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",N(this.options.HTMLAttributes,t),0]:["a",N(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,o,i;let s=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",l=(i=(o=t.attrs)==null?void 0:o.title)!=null?i:"",a=e.renderChildren(t);return l?`[${a}](${s} "${l}")`:`[${a}](${s})`},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!fn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!fn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Te({find:t=>{let e=[];if(t){let{protocols:n,defaultProtocol:r}=this.options,o=zi(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!fn(s,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(_w({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!fn(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(Vw({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Ww({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),sh=jw;var Uw=Object.defineProperty,Kw=(t,e)=>{for(var n in e)Uw(t,n,{get:e[n],enumerable:!0})},qw="listItem",lh="textStyle",ah=/^\s*([-+*])\s$/,Aa=V.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:t}){return["ul",N(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(qw,this.editor.getAttributes(lh)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ge({find:ah,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ge({find:ah,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(lh),editor:this.editor})),[t]}});function Jw(t){var e,n;let r=(e=t.tokens)==null?void 0:e[0];return!!(t.text&&((n=t.tokens)==null?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function Gw(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var Ea=V.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",N(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];let r=(n=e.parseBlockChildren)!=null?n:e.parseChildren,o=[];if(t.tokens&&t.tokens.length>0){if(Jw(t))return{type:"listItem",content:[{type:"paragraph",content:Gw(t.text||"",e)}]};if(t.tokens.some(s=>s.type==="paragraph"))o=r(t.tokens);else{let s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(o=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){let a=t.tokens.slice(1),c=r(a);o.push(...c)}}else o=r(t.tokens)}}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:o}},renderMarkdown:(t,e,n)=>Vn(t,e,r=>{var o,i;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((i=(o=r.meta)==null?void 0:o.parentAttrs)==null?void 0:i.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Xw={};Kw(Xw,{findListItemPos:()=>qr,getNextListDepth:()=>Na,handleBackspace:()=>Ma,handleDelete:()=>Ta,hasListBefore:()=>fh,hasListItemAfter:()=>Yw,hasListItemBefore:()=>hh,listItemHasSubList:()=>ph,nextListIsDeeper:()=>mh,nextListIsHigher:()=>gh});var qr=(t,e)=>{let{$from:n}=e.selection,r=oe(t,e.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},Na=(t,e)=>{let n=qr(t,e);if(!n)return!1;let[,r]=zl(e,t,n.$pos.pos+4);return r},fh=(t,e,n)=>{let{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),i=t.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},hh=(t,e)=>{var n;let{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-2);return!(o.index()===0||((n=o.nodeBefore)==null?void 0:n.type.name)!==t)},ph=(t,e,n)=>{if(!n)return!1;let r=oe(t,e.schema),o=!1;return n.descendants(i=>{i.type===r&&(o=!0)}),o},Ma=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!qe(t.state,e)&&fh(t.state,e,n)){let{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});let d=c.at(-1);if(!d)return!1;let u=t.state.doc.resolve(a.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},u.end()).joinForward().run()}if(!qe(t.state,e)||!$l(t.state))return!1;let r=qr(e,t.state);if(!r)return!1;let i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=ph(e,t.state,i);return hh(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},mh=(t,e)=>{let n=Na(t,e),r=qr(t,e);return!r||!n?!1:n>r.depth},gh=(t,e)=>{let n=Na(t,e),r=qr(t,e);return!r||!n?!1:n{if(!qe(t.state,e)||!Hl(t.state,e))return!1;let{selection:n}=t.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:mh(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():gh(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Yw=(t,e)=>{var n;let{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((n=o.nodeAfter)==null?void 0:n.type.name)!==t)},Qw=U.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Ta(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Ta(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ma(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ma(t,n,r)&&(e=!0)}),e}}}}),ch=/^(\s*)(\d+)\.\s+(.*)$/,Zw=/^\s/;function ex(t){let e=t.trimStart();return/^[-+*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function tx(t){let e=[],n=[],r=!1;return t.forEach(o=>{if(r){n.push(o);return}if(o.trim()===""){r=!0,n.push(o);return}if(e.length>0&&ex(o)){r=!0,n.push(o);return}e.push(o)}),{paragraphLines:e,blockLines:n}}function nx(t){let e=[],n=0,r=0;for(;ne;)f.push(t[u]),u+=1;if(f.length>0){let h=Math.min(...f.map(m=>m.indent)),p=yh(f,h,n);c.push({type:"list",ordered:!0,start:f[0].number,items:p,raw:f.map(m=>m.raw).join(` `)})}r.push({type:"list_item",raw:i.raw,tokens:c}),o=u}else o+=1}return r}function rx(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...e.parseChildren([o]));else if(o.type==="text"&&o.tokens){let i=e.parseChildren([o]);r.push({type:"paragraph",content:i})}else{let i=e.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var ox="listItem",dh="textStyle",uh=/^(\d+)\.\s$/,Oa=V.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:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,...n}=t;return e===1?["ol",N(this.options.HTMLAttributes,n),0]:["ol",N(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];let n=t.start||1,r=t.items?rx(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{let e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;let o=t.split(` `),[i,s]=nx(o);if(i.length===0)return;let l=yh(i,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:o.slice(0,s).join(` `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ox,this.editor.getAttributes(dh)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ge({find:uh,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ge({find:uh,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(dh)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),ix=/^\s*(\[([( |x])?\])\s$/,sx=V.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",N(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{let n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){let r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;let o=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Vn(t,e,o)},addKeyboardShortcuts(){let t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=n();if(typeof p!="number")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{o.setAttribute(u,f)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([u,f])=>{o.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:o,contentDOM:a,update:u=>{if(u.type!==this.type)return!1;o.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u);let f=r.extensionManager.attributes,h=on(u,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return d.forEach(g=>{p.has(g)||(g in m?o.setAttribute(g,m[g]):o.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?o.setAttribute(g,m[g]):o.removeAttribute(g):o.setAttribute(g,y)}),d=p,!0}}}},addInputRules(){return[Ge({find:ix,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),lx=V.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",N(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;let n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=i=>{let s=Lr(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(i)},o=Lr(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,s)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),gM=U.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(Aa.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Ea.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Qw.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Oa.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(sx.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(lx.configure(this.options.taskList)),t}});var Un=(t,e,n={})=>{t.dom.closest("form")?.dispatchEvent(new CustomEvent(e,{composed:!0,cancelable:!0,detail:n}))},Ra=({files:t,acceptedTypes:e,acceptedTypesValidationMessage:n,maxSize:r,maxSizeValidationMessage:o})=>{for(let i of t){if(e&&!e.includes(i.type))return n;if(r&&i.size>+r*1024)return o}return null},Da=()=>("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)),ax=({editor:t,acceptedTypes:e,acceptedTypesValidationMessage:n,get$WireUsing:r,key:o,maxSize:i,maxSizeValidationMessage:s,statePath:l,uploadingMessage:a})=>{let c=d=>Livewire.fireAction(r().__instance,"callSchemaComponentMethod",[o,"getUploadedFileAttachmentTemporaryUrl",{attachment:d}],{async:!0});return new B({key:new _("localFiles"),props:{handleDrop(d,u){if(!u.dataTransfer?.files.length)return!1;let f=Array.from(u.dataTransfer.files),h=Ra({files:f,acceptedTypes:e,acceptedTypesValidationMessage:n,maxSize:i,maxSizeValidationMessage:s});if(h)return d.dom.dispatchEvent(new CustomEvent("rich-editor-file-validation-message",{bubbles:!0,detail:{key:o,livewireId:r().id,validationMessage:h}})),!1;if(!f.length)return!1;Un(d,"form-processing-started",{message:a}),u.preventDefault(),u.stopPropagation();let p=d.posAtCoords({left:u.clientX,top:u.clientY});return f.forEach((m,g)=>{t.setEditable(!1),d.dom.dispatchEvent(new CustomEvent("rich-editor-uploading-file",{bubbles:!0,detail:{key:o,livewireId:r().id}}));let y=Da();r().upload(`componentFileAttachments.${l}.${y}`,m,()=>{c(y).then(w=>{w&&(t.chain().insertContentAt(p?.pos??0,{type:"image",attrs:{id:y,src:w}}).run(),t.setEditable(!0),d.dom.dispatchEvent(new CustomEvent("rich-editor-uploaded-file",{bubbles:!0,detail:{key:o,livewireId:r().id}})),g===f.length-1&&Un(d,"form-processing-finished"))})})}),!0},handlePaste(d,u){let f=u.clipboardData?.files?.length?Array.from(u.clipboardData.files):[],h=u.clipboardData?.getData("text")?.length>0,p=u.clipboardData?.getData("text/html")||"";if(f.length&&!h){let m=Ra({files:f,acceptedTypes:e,acceptedTypesValidationMessage:n,maxSize:i,maxSizeValidationMessage:s});return m?(d.dom.dispatchEvent(new CustomEvent("rich-editor-file-validation-message",{bubbles:!0,detail:{key:o,livewireId:r().id,validationMessage:m}})),!1):(u.preventDefault(),u.stopPropagation(),Un(d,"form-processing-started",{message:a}),f.forEach((g,y)=>{t.setEditable(!1),d.dom.dispatchEvent(new CustomEvent("rich-editor-uploading-file",{bubbles:!0,detail:{key:o,livewireId:r().id}}));let w=Da();r().upload(`componentFileAttachments.${l}.${w}`,g,()=>{c(w).then(b=>{b&&(t.chain().insertContentAt(t.state.selection.anchor,{type:"image",attrs:{id:w,src:b}}).run(),t.setEditable(!0),d.dom.dispatchEvent(new CustomEvent("rich-editor-uploaded-file",{bubbles:!0,detail:{key:o,livewireId:r().id}})),y===f.length-1&&Un(d,"form-processing-finished"))})})}),!0)}if(p){let g=new DOMParser().parseFromString(p,"text/html"),y=g.querySelectorAll("img[src]");if(y.length){u.stopPropagation();let{from:w,to:b}=t.state.selection;return Un(d,"form-processing-started",{message:a}),t.setEditable(!1),d.dom.dispatchEvent(new CustomEvent("rich-editor-uploading-file",{bubbles:!0,detail:{key:o,livewireId:r().id}})),(async()=>{for(let S of y){let P=S.getAttribute("src");if(!P.startsWith("data:image/"))continue;let A;try{let[H,W]=P.split(","),X=H.match(/:(.*?);/)[1],Y=atob(W),F=new Uint8Array(Y.length);for(let ce=0;ce{r().upload(`componentFileAttachments.${l}.${D}`,R,()=>{c(D).then(W=>H(W??null))},()=>H(null))});O&&(S.setAttribute("src",O),S.setAttribute("data-id",D))}for(let S of Array.from(g.querySelectorAll("img[src]"))){let P=g.createElement("p");S.replaceWith(P),P.appendChild(S)}let x=g.body.innerHTML;t.view.someProp("transformPastedHTML",S=>{x=S(x)});let k=document.createElement("div");k.innerHTML=x;let M=Ae.fromSchema(t.state.schema).parseSlice(k,{preserveWhitespace:!1});t.view.dispatch(t.state.tr.replaceRange(w,b,M)),t.setEditable(!0),d.dom.dispatchEvent(new CustomEvent("rich-editor-uploaded-file",{bubbles:!0,detail:{key:o,livewireId:r().id}})),Un(d,"form-processing-finished")})(),!0}}return!1}}})},bh=U.create({name:"localFiles",addOptions(){return{acceptedTypes:[],acceptedTypesValidationMessage:null,key:null,maxSize:null,maxSizeValidationMessage:null,statePath:null,uploadingMessage:null,get$WireUsing:null}},addProseMirrorPlugins(){return[ax({editor:this.editor,...this.options})]}});function cx(t){var e;let{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:l}=t,a=r&&!o,c=jl(n),d=new RegExp(`\\s${c}$`),u=s?"^":"",f=o?"":c,h=a?new RegExp(`${u}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;let m=l.pos-p.length,g=Array.from(p.matchAll(h)).pop();if(!g||g.input===void 0||g.index===void 0)return null;let y=g.input.slice(Math.max(0,g.index-1),g.index),w=new RegExp(`^[${i?.join("")}\0]?$`).test(y);if(i!==null&&!w)return null;let b=m+g.index,x=b+g[0].length;return a&&d.test(p.slice(x-1,x+1))&&(g[0]+=" ",x+=1),b=l.pos?{range:{from:b,to:x},query:g[0].slice(n.length),text:g[0]}:null}function dx(t){return t.docChanged?t.steps.some(e=>{let n=e.slice;if(!n?.content)return!1;let r=n.content.textBetween(0,n.content.size,` `);return/\s/.test(r)}):!1}var ux=new _("suggestion");function fx({pluginKey:t=ux,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:m=cx,shouldShow:g,shouldResetDismissed:y}){let w,b=h?.(),x=r&&!o,k=()=>{let v=e.state.selection.$anchor.pos,R=e.view.coordsAtPos(v),{top:j,right:D,bottom:O,left:H}=R;try{return new DOMRect(H,j,D-H,O-j)}catch{return null}},M=(v,R)=>R?()=>{let j=t.getState(e.state),D=j?.decorationId,O=v.dom.querySelector(`[data-decoration-id="${D}"]`);return O?.getBoundingClientRect()||null}:k,S=({match:v,dismissedRange:R,state:j,transaction:D})=>y?.({editor:e,state:j,range:R,match:v,transaction:D,allowSpaces:x})?!1:x?v.range.from===R.from:v.range.from===R.from&&!dx(D);function P(v,R){var j;try{let O=t.getState(v.state),H=O?.decorationId?v.dom.querySelector(`[data-decoration-id="${O.decorationId}"]`):null,W={editor:e,range:O?.range||{from:0,to:0},query:O?.query||null,text:O?.text||null,items:[],command:X=>u({editor:e,range:O?.range||{from:0,to:0},props:X}),decorationNode:H,clientRect:M(v,H)};(j=b?.onExit)==null||j.call(b,W)}catch{}let D=v.state.tr.setMeta(R,{exit:!0});v.dispatch(D)}let A=new B({key:t,view(){return{update:async(v,R)=>{var j,D,O,H,W,X,Y;let F=(j=this.key)==null?void 0:j.getState(R),ce=(D=this.key)==null?void 0:D.getState(v.state),fe=F.active&&ce.active&&F.range.from!==ce.range.from,q=!F.active&&ce.active,ft=F.active&&!ce.active,Ke=!q&&!ft&&F.query!==ce.query,Qn=q||fe&&Ke,eo=Ke||fe,is=ft||fe&&Ke;if(!Qn&&!eo&&!is)return;let bn=is&&!Qn?F:ce,ec=v.dom.querySelector(`[data-decoration-id="${bn.decorationId}"]`);w={editor:e,range:bn.range,query:bn.query,text:bn.text,items:[],command:Qp=>u({editor:e,range:bn.range,props:Qp}),decorationNode:ec,clientRect:M(v,ec)},Qn&&((O=b?.onBeforeStart)==null||O.call(b,w)),eo&&((H=b?.onBeforeUpdate)==null||H.call(b,w)),(eo||Qn)&&(w.items=await f({editor:e,query:bn.query})),is&&((W=b?.onExit)==null||W.call(b,w)),eo&&((X=b?.onUpdate)==null||X.call(b,w)),Qn&&((Y=b?.onStart)==null||Y.call(b,w))},destroy:()=>{var v;w&&((v=b?.onExit)==null||v.call(b,w))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(v,R,j,D){let{isEditable:O}=e,{composing:H}=e.view,{selection:W}=v,{empty:X,from:Y}=W,F={...R},ce=v.getMeta(t);if(ce&&ce.exit)return F.active=!1,F.decorationId=null,F.range={from:0,to:0},F.query=null,F.text=null,F.dismissedRange=R.active?{...R.range}:R.dismissedRange,F;if(F.composing=H,v.docChanged&&F.dismissedRange!==null&&(F.dismissedRange={from:v.mapping.map(F.dismissedRange.from),to:v.mapping.map(F.dismissedRange.to)}),O&&(X||e.view.composing)){(YR.range.to)&&!H&&!R.composing&&(F.active=!1);let fe=m({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:W.$from}),q=`id_${Math.floor(Math.random()*4294967295)}`;fe&&p({editor:e,state:D,range:fe.range,isActive:R.active})&&(!g||g({editor:e,range:fe.range,query:fe.query,text:fe.text,transaction:v}))?(F.dismissedRange!==null&&!S({match:fe,dismissedRange:F.dismissedRange,state:D,transaction:v})&&(F.dismissedRange=null),F.dismissedRange===null?(F.active=!0,F.decorationId=R.decorationId?R.decorationId:q,F.range=fe.range,F.query=fe.query,F.text=fe.text):F.active=!1):(fe||(F.dismissedRange=null),F.active=!1)}else F.active=!1;return F.active||(F.decorationId=null,F.range={from:0,to:0},F.query=null,F.text=null),F}},props:{handleKeyDown(v,R){var j,D;let{active:O,range:H}=A.getState(v.state);if(!O)return!1;if(R.key==="Escape"||R.key==="Esc"){let X=A.getState(v.state);return(j=b?.onKeyDown)==null||j.call(b,{view:v,event:R,range:X.range}),P(v,t),!0}return((D=b?.onKeyDown)==null?void 0:D.call(b,{view:v,event:R,range:H}))||!1},decorations(v){let{active:R,range:j,decorationId:D,query:O}=A.getState(v);if(!R)return null;let H=!O?.length,W=[a];return H&&W.push(d),Z.create(v.doc,[re.inline(j.from,j.to,{nodeName:l,class:W.join(" "),"data-decoration-id":D,"data-decoration-content":c})])}}});return A}var Hi=fx;var hx=function({editor:t,overrideSuggestionOptions:e,extensionName:n}){let r=new _;return{editor:t,char:"{{",pluginKey:r,command:({editor:o,range:i,props:s})=>{o.view.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:n,attrs:{...s}},{type:"text",text:" "}]).run(),o.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()},allow:({state:o,range:i})=>{let s=o.doc.resolve(i.from),l=o.schema.nodes[n];return!!s.parent.type.contentMatch.matchType(l)},...e}},wh=V.create({name:"mergeTag",priority:101,addStorage(){return{mergeTags:[],suggestions:[],getSuggestionFromChar:()=>null}},addOptions(){return{HTMLAttributes:{},renderText({node:t}){return`{{ ${this.mergeTags[t.attrs.id]} }}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e}){return["span",N(this.HTMLAttributes,t.HTMLAttributes),`${this.mergeTags[e.attrs.id]}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){let n=this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar("{{"),r={...this.options};r.HTMLAttributes=N({"data-type":this.name},this.options.HTMLAttributes,e);let o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",N({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){let e={options:this.options,node:t,suggestion:this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar("{{")};return this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1,{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;let s=new ne,l=0;return e.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return n=!0,s=a,l=c,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":"{{",l,l+s.nodeSize),n})}},addProseMirrorPlugins(){return[...this.storage.suggestions.map(Hi),new B({props:{handleDrop(t,e){if(!e||(e.preventDefault(),!e.dataTransfer.getData("mergeTag")))return!1;let n=e.dataTransfer.getData("mergeTag");return t.dispatch(t.state.tr.insert(t.posAtCoords({left:e.clientX,top:e.clientY}).pos,t.state.schema.nodes.mergeTag.create({id:n}))),!1}}})]},onBeforeCreate(){this.storage.suggestions=(this.options.suggestions.length?this.options.suggestions:[this.options.suggestion]).map(t=>hx({editor:this.editor,overrideSuggestionOptions:t,extensionName:this.name})),this.storage.getSuggestionFromChar=t=>{let e=this.storage.suggestions.find(n=>n.char===t);return e||(this.storage.suggestions.length?this.storage.suggestions[0]:null)}}});var Ia=["top","right","bottom","left"],xh=["start","end"],Pa=Ia.reduce((t,e)=>t.concat(e,e+"-"+xh[0],e+"-"+xh[1]),[]),Ve=Math.min,be=Math.max,Xr=Math.round;var Xe=t=>({x:t,y:t}),px={left:"right",right:"left",bottom:"top",top:"bottom"};function $i(t,e,n){return be(t,Ve(e,n))}function at(t,e){return typeof t=="function"?t(e):t}function Ie(t){return t.split("-")[0]}function We(t){return t.split("-")[1]}function La(t){return t==="x"?"y":"x"}function Fi(t){return t==="y"?"height":"width"}function Ye(t){let e=t[0];return e==="t"||e==="b"?"y":"x"}function _i(t){return La(Ye(t))}function Ba(t,e,n){n===void 0&&(n=!1);let r=We(t),o=_i(t),i=Fi(o),s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=Gr(s)),[s,Gr(s)]}function Ch(t){let e=Gr(t);return[Jr(t),e,Jr(e)]}function Jr(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}var kh=["left","right"],Sh=["right","left"],mx=["top","bottom"],gx=["bottom","top"];function yx(t,e,n){switch(t){case"top":case"bottom":return n?e?Sh:kh:e?kh:Sh;case"left":case"right":return e?mx:gx;default:return[]}}function vh(t,e,n,r){let o=We(t),i=yx(Ie(t),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),e&&(i=i.concat(i.map(Jr)))),i}function Gr(t){let e=Ie(t);return px[e]+t.slice(e.length)}function bx(t){return{top:0,right:0,bottom:0,left:0,...t}}function Vi(t){return typeof t!="number"?bx(t):{top:t,right:t,bottom:t,left:t}}function vt(t){let{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function Mh(t,e,n){let{reference:r,floating:o}=t,i=Ye(e),s=_i(e),l=Fi(s),a=Ie(e),c=i==="y",d=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,f=r[l]/2-o[l]/2,h;switch(a){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:u};break;case"left":h={x:r.x-o.width,y:u};break;default:h={x:r.x,y:r.y}}switch(We(e)){case"start":h[s]-=f*(n&&c?-1:1);break;case"end":h[s]+=f*(n&&c?-1:1);break}return h}async function Eh(t,e){var n;e===void 0&&(e={});let{x:r,y:o,platform:i,rects:s,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:f=!1,padding:h=0}=at(e,t),p=Vi(h),g=l[f?u==="floating"?"reference":"floating":u],y=vt(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(g)))==null||n?g:g.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:a})),w=u==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),x=await(i.isElement==null?void 0:i.isElement(b))?await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1}:{x:1,y:1},k=vt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:b,strategy:a}):w);return{top:(y.top-k.top+p.top)/x.y,bottom:(k.bottom-y.bottom+p.bottom)/x.y,left:(y.left-k.left+p.left)/x.x,right:(k.right-y.right+p.right)/x.x}}var wx=50,Nh=async(t,e,n)=>{let{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=s.detectOverflow?s:{...s,detectOverflow:Eh},a=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:d,y:u}=Mh(c,r,a),f=r,h=0,p={};for(let m=0;m({name:"arrow",options:t,async fn(e){let{x:n,y:r,placement:o,rects:i,platform:s,elements:l,middlewareData:a}=e,{element:c,padding:d=0}=at(t,e)||{};if(c==null)return{};let u=Vi(d),f={x:n,y:r},h=_i(o),p=Fi(h),m=await s.getDimensions(c),g=h==="y",y=g?"top":"left",w=g?"bottom":"right",b=g?"clientHeight":"clientWidth",x=i.reference[p]+i.reference[h]-f[h]-i.floating[p],k=f[h]-i.reference[h],M=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),S=M?M[b]:0;(!S||!await(s.isElement==null?void 0:s.isElement(M)))&&(S=l.floating[b]||i.floating[p]);let P=x/2-k/2,A=S/2-m[p]/2-1,v=Ve(u[y],A),R=Ve(u[w],A),j=v,D=S-m[p]-R,O=S/2-m[p]/2+P,H=$i(j,O,D),W=!a.arrow&&We(o)!=null&&O!==H&&i.reference[p]/2-(OWe(o)===t),...n.filter(o=>We(o)!==t)]:n.filter(o=>Ie(o)===o)).filter(o=>t?We(o)===t||(e?Jr(o)!==o:!1):!0)}var Rh=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,o;let{rects:i,middlewareData:s,placement:l,platform:a,elements:c}=e,{crossAxis:d=!1,alignment:u,allowedPlacements:f=Pa,autoAlignment:h=!0,...p}=at(t,e),m=u!==void 0||f===Pa?xx(u||null,h,f):f,g=await a.detectOverflow(e,p),y=((n=s.autoPlacement)==null?void 0:n.index)||0,w=m[y];if(w==null)return{};let b=Ba(w,i,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==w)return{reset:{placement:m[0]}};let x=[g[Ie(w)],g[b[0]],g[b[1]]],k=[...((r=s.autoPlacement)==null?void 0:r.overflows)||[],{placement:w,overflows:x}],M=m[y+1];if(M)return{data:{index:y+1,overflows:k},reset:{placement:M}};let S=k.map(v=>{let R=We(v.placement);return[v.placement,R&&d?v.overflows.slice(0,2).reduce((j,D)=>j+D,0):v.overflows[0],v.overflows]}).sort((v,R)=>v[1]-R[1]),A=((o=S.filter(v=>v[2].slice(0,We(v[0])?2:3).every(R=>R<=0))[0])==null?void 0:o[0])||S[0][0];return A!==l?{data:{index:y+1,overflows:k},reset:{placement:A}}:{}}}},Dh=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;let{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=at(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let y=Ie(o),w=Ye(l),b=Ie(l)===l,x=await(a.isRTL==null?void 0:a.isRTL(c.floating)),k=f||(b||!m?[Gr(l)]:Ch(l)),M=p!=="none";!f&&M&&k.push(...vh(l,m,p,x));let S=[l,...k],P=await a.detectOverflow(e,g),A=[],v=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&A.push(P[y]),u){let O=Ba(o,s,x);A.push(P[O[0]],P[O[1]])}if(v=[...v,{placement:o,overflows:A}],!A.every(O=>O<=0)){var R,j;let O=(((R=i.flip)==null?void 0:R.index)||0)+1,H=S[O];if(H&&(!(u==="alignment"?w!==Ye(H):!1)||v.every(Y=>Ye(Y.placement)===w?Y.overflows[0]>0:!0)))return{data:{index:O,overflows:v},reset:{placement:H}};let W=(j=v.filter(X=>X.overflows[0]<=0).sort((X,Y)=>X.overflows[1]-Y.overflows[1])[0])==null?void 0:j.placement;if(!W)switch(h){case"bestFit":{var D;let X=(D=v.filter(Y=>{if(M){let F=Ye(Y.placement);return F===w||F==="y"}return!0}).map(Y=>[Y.placement,Y.overflows.filter(F=>F>0).reduce((F,ce)=>F+ce,0)]).sort((Y,F)=>Y[1]-F[1])[0])==null?void 0:D[0];X&&(W=X);break}case"initialPlacement":W=l;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function Th(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Ah(t){return Ia.some(e=>t[e]>=0)}var Ih=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){let{rects:n,platform:r}=e,{strategy:o="referenceHidden",...i}=at(t,e);switch(o){case"referenceHidden":{let s=await r.detectOverflow(e,{...i,elementContext:"reference"}),l=Th(s,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Ah(l)}}}case"escaped":{let s=await r.detectOverflow(e,{...i,altBoundary:!0}),l=Th(s,n.floating);return{data:{escapedOffsets:l,escaped:Ah(l)}}}default:return{}}}}};function Ph(t){let e=Ve(...t.map(i=>i.left)),n=Ve(...t.map(i=>i.top)),r=be(...t.map(i=>i.right)),o=be(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:o-n}}function kx(t){let e=t.slice().sort((o,i)=>o.y-i.y),n=[],r=null;for(let o=0;or.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(o=>vt(Ph(o)))}var Lh=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){let{placement:n,elements:r,rects:o,platform:i,strategy:s}=e,{padding:l=2,x:a,y:c}=at(t,e),d=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),u=kx(d),f=vt(Ph(d)),h=Vi(l);function p(){if(u.length===2&&u[0].left>u[1].right&&a!=null&&c!=null)return u.find(g=>a>g.left-h.left&&ag.top-h.top&&c=2){if(Ye(n)==="y"){let v=u[0],R=u[u.length-1],j=Ie(n)==="top",D=v.top,O=R.bottom,H=j?v.left:R.left,W=j?v.right:R.right,X=W-H,Y=O-D;return{top:D,bottom:O,left:H,right:W,width:X,height:Y,x:H,y:D}}let g=Ie(n)==="left",y=be(...u.map(v=>v.right)),w=Ve(...u.map(v=>v.left)),b=u.filter(v=>g?v.left===w:v.right===y),x=b[0].top,k=b[b.length-1].bottom,M=w,S=y,P=S-M,A=k-x;return{top:x,bottom:k,left:M,right:S,width:P,height:A,x:M,y:x}}return f}let m=await i.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:s});return o.reference.x!==m.reference.x||o.reference.y!==m.reference.y||o.reference.width!==m.reference.width||o.reference.height!==m.reference.height?{reset:{rects:m}}:{}}}},Sx=new Set(["left","top"]);async function Cx(t,e){let{placement:n,platform:r,elements:o}=t,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Ie(n),l=We(n),a=Ye(n)==="y",c=Sx.has(s)?-1:1,d=i&&a?-1:1,u=at(e,t),{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*d,y:f*c}:{x:f*c,y:h*d}}var Bh=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;let{x:o,y:i,placement:s,middlewareData:l}=e,a=await Cx(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:s}}}}},zh=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:r,placement:o,platform:i}=e,{mainAxis:s=!0,crossAxis:l=!1,limiter:a={fn:y=>{let{x:w,y:b}=y;return{x:w,y:b}}},...c}=at(t,e),d={x:n,y:r},u=await i.detectOverflow(e,c),f=Ye(Ie(o)),h=La(f),p=d[h],m=d[f];if(s){let y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",b=p+u[y],x=p-u[w];p=$i(b,p,x)}if(l){let y=f==="y"?"top":"left",w=f==="y"?"bottom":"right",b=m+u[y],x=m-u[w];m=$i(b,m,x)}let g=a.fn({...e,[h]:p,[f]:m});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:s,[f]:l}}}}}};var Hh=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;let{placement:o,rects:i,platform:s,elements:l}=e,{apply:a=()=>{},...c}=at(t,e),d=await s.detectOverflow(e,c),u=Ie(o),f=We(o),h=Ye(o)==="y",{width:p,height:m}=i.floating,g,y;u==="top"||u==="bottom"?(g=u,y=f===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(y=u,g=f==="end"?"top":"bottom");let w=m-d.top-d.bottom,b=p-d.left-d.right,x=Ve(m-d[g],w),k=Ve(p-d[y],b),M=!e.middlewareData.shift,S=x,P=k;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(P=b),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(S=w),M&&!f){let v=be(d.left,0),R=be(d.right,0),j=be(d.top,0),D=be(d.bottom,0);h?P=p-2*(v!==0||R!==0?v+R:be(d.left,d.right)):S=m-2*(j!==0||D!==0?j+D:be(d.top,d.bottom))}await a({...e,availableWidth:P,availableHeight:S});let A=await s.getDimensions(l.floating);return p!==A.width||m!==A.height?{reset:{rects:!0}}:{}}}};function ji(){return typeof window<"u"}function pn(t){return Fh(t)?(t.nodeName||"").toLowerCase():"#document"}function Oe(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ct(t){var e;return(e=(Fh(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Fh(t){return ji()?t instanceof Node||t instanceof Oe(t).Node:!1}function je(t){return ji()?t instanceof Element||t instanceof Oe(t).Element:!1}function dt(t){return ji()?t instanceof HTMLElement||t instanceof Oe(t).HTMLElement:!1}function $h(t){return!ji()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Oe(t).ShadowRoot}function Kn(t){let{overflow:e,overflowX:n,overflowY:r,display:o}=Ue(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&o!=="inline"&&o!=="contents"}function _h(t){return/^(table|td|th)$/.test(pn(t))}function Yr(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}var vx=/transform|translate|scale|rotate|perspective|filter/,Mx=/paint|layout|strict|content/,hn=t=>!!t&&t!=="none",za;function Ui(t){let e=je(t)?Ue(t):t;return hn(e.transform)||hn(e.translate)||hn(e.scale)||hn(e.rotate)||hn(e.perspective)||!Ki()&&(hn(e.backdropFilter)||hn(e.filter))||vx.test(e.willChange||"")||Mx.test(e.contain||"")}function Vh(t){let e=Mt(t);for(;dt(e)&&!mn(e);){if(Ui(e))return e;if(Yr(e))return null;e=Mt(e)}return null}function Ki(){return za==null&&(za=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),za}function mn(t){return/^(html|body|#document)$/.test(pn(t))}function Ue(t){return Oe(t).getComputedStyle(t)}function Qr(t){return je(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Mt(t){if(pn(t)==="html")return t;let e=t.assignedSlot||t.parentNode||$h(t)&&t.host||ct(t);return $h(e)?e.host:e}function Wh(t){let e=Mt(t);return mn(e)?t.ownerDocument?t.ownerDocument.body:t.body:dt(e)&&Kn(e)?e:Wh(e)}function Wi(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);let o=Wh(t),i=o===((r=t.ownerDocument)==null?void 0:r.body),s=Oe(o);if(i){let l=qi(s);return e.concat(s,s.visualViewport||[],Kn(o)?o:[],l&&n?Wi(l):[])}else return e.concat(o,Wi(o,[],n))}function qi(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function qh(t){let e=Ue(t),n=parseFloat(e.width)||0,r=parseFloat(e.height)||0,o=dt(t),i=o?t.offsetWidth:n,s=o?t.offsetHeight:r,l=Xr(n)!==i||Xr(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function Jh(t){return je(t)?t:t.contextElement}function qn(t){let e=Jh(t);if(!dt(e))return Xe(1);let n=e.getBoundingClientRect(),{width:r,height:o,$:i}=qh(e),s=(i?Xr(n.width):n.width)/r,l=(i?Xr(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}var Tx=Xe(0);function Gh(t){let e=Oe(t);return!Ki()||!e.visualViewport?Tx:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Ax(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Oe(t)?!1:e}function Zr(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);let o=t.getBoundingClientRect(),i=Jh(t),s=Xe(1);e&&(r?je(r)&&(s=qn(r)):s=qn(t));let l=Ax(i,n,r)?Gh(i):Xe(0),a=(o.left+l.x)/s.x,c=(o.top+l.y)/s.y,d=o.width/s.x,u=o.height/s.y;if(i){let f=Oe(i),h=r&&je(r)?Oe(r):r,p=f,m=qi(p);for(;m&&r&&h!==p;){let g=qn(m),y=m.getBoundingClientRect(),w=Ue(m),b=y.left+(m.clientLeft+parseFloat(w.paddingLeft))*g.x,x=y.top+(m.clientTop+parseFloat(w.paddingTop))*g.y;a*=g.x,c*=g.y,d*=g.x,u*=g.y,a+=b,c+=x,p=Oe(m),m=qi(p)}}return vt({width:d,height:u,x:a,y:c})}function Ji(t,e){let n=Qr(t).scrollLeft;return e?e.left+n:Zr(ct(t)).left+n}function Xh(t,e){let n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Ji(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function Ex(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t,i=o==="fixed",s=ct(r),l=e?Yr(e.floating):!1;if(r===s||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=Xe(1),d=Xe(0),u=dt(r);if((u||!u&&!i)&&((pn(r)!=="body"||Kn(s))&&(a=Qr(r)),u)){let h=Zr(r);c=qn(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}let f=s&&!u&&!i?Xh(s,a):Xe(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+d.x+f.x,y:n.y*c.y-a.scrollTop*c.y+d.y+f.y}}function Nx(t){return Array.from(t.getClientRects())}function Ox(t){let e=ct(t),n=Qr(t),r=t.ownerDocument.body,o=be(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=be(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight),s=-n.scrollLeft+Ji(t),l=-n.scrollTop;return Ue(r).direction==="rtl"&&(s+=be(e.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}var jh=25;function Rx(t,e){let n=Oe(t),r=ct(t),o=n.visualViewport,i=r.clientWidth,s=r.clientHeight,l=0,a=0;if(o){i=o.width,s=o.height;let d=Ki();(!d||d&&e==="fixed")&&(l=o.offsetLeft,a=o.offsetTop)}let c=Ji(r);if(c<=0){let d=r.ownerDocument,u=d.body,f=getComputedStyle(u),h=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-u.clientWidth-h);p<=jh&&(i-=p)}else c<=jh&&(i+=c);return{width:i,height:s,x:l,y:a}}function Dx(t,e){let n=Zr(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,i=dt(t)?qn(t):Xe(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,a=o*i.x,c=r*i.y;return{width:s,height:l,x:a,y:c}}function Uh(t,e,n){let r;if(e==="viewport")r=Rx(t,n);else if(e==="document")r=Ox(ct(t));else if(je(e))r=Dx(e,n);else{let o=Gh(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return vt(r)}function Yh(t,e){let n=Mt(t);return n===e||!je(n)||mn(n)?!1:Ue(n).position==="fixed"||Yh(n,e)}function Ix(t,e){let n=e.get(t);if(n)return n;let r=Wi(t,[],!1).filter(l=>je(l)&&pn(l)!=="body"),o=null,i=Ue(t).position==="fixed",s=i?Mt(t):t;for(;je(s)&&!mn(s);){let l=Ue(s),a=Ui(s);!a&&l.position==="fixed"&&(o=null),(i?!a&&!o:!a&&l.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Kn(s)&&!a&&Yh(t,s))?r=r.filter(d=>d!==s):o=l,s=Mt(s)}return e.set(t,r),r}function Px(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t,s=[...n==="clippingAncestors"?Yr(e)?[]:Ix(e,this._c):[].concat(n),r],l=Uh(e,s[0],o),a=l.top,c=l.right,d=l.bottom,u=l.left;for(let f=1;f{let r=new Map,o={platform:$x,...n},i={...o.platform,_c:r};return Nh(t,e,{...o,platform:i})};var ip=(t,e)=>{Xn({getBoundingClientRect:()=>{let{from:r,to:o}=t.state.selection,i=t.view.coordsAtPos(r),s=t.view.coordsAtPos(o);return{top:Math.min(i.top,s.top),bottom:Math.max(i.bottom,s.bottom),left:Math.min(i.left,s.left),right:Math.max(i.right,s.right),width:Math.abs(s.right-i.left),height:Math.abs(s.bottom-i.top),x:Math.min(i.left,s.left),y:Math.min(i.top,s.top)}}},e,{placement:"bottom-start",strategy:"absolute",middleware:[Jn(),Gn()]}).then(({x:r,y:o,strategy:i})=>{e.style.width="max-content",e.style.position=i,e.style.left=`${r}px`,e.style.top=`${o}px`})},sp=({items:t=[],noOptionsMessage:e=null,noSearchResultsMessage:n=null,searchPrompt:r=null,searchingMessage:o=null,isSearchable:i=!1})=>{let s=null;return{items:async({query:l})=>{if(typeof t=="function"){s&&i&&s.setLoading(!0);try{let c=t({query:l}),d=Array.isArray(c)?c:await c;return s&&s.setLoading(!1),d}catch{return s&&s.setLoading(!1),[]}}if(!l)return t;let a=String(l).toLowerCase();return t.filter(c=>{let d=typeof c=="string"?c:c?.label??c?.name??"";return String(d).toLowerCase().includes(a)})},render:()=>{let l,a=0,c=null,d=!1;s={setLoading:b=>{d=b,f()}};let u=()=>{let b=document.createElement("div");return b.className="fi-dropdown-panel fi-dropdown-list fi-scrollable",b.style.maxHeight="15rem",b.style.minWidth="12rem",b},f=()=>{if(!l||!c)return;let b=Array.isArray(c.items)?c.items:[],x=c.query??"";if(l.innerHTML="",d){let k=o??"Searching...",M=document.createElement("div");M.className="fi-dropdown-header";let S=document.createElement("span");S.style.whiteSpace="normal",S.textContent=k,M.appendChild(S),l.appendChild(M);return}if(b.length)b.forEach((k,M)=>{let S=typeof k=="string"?k:k?.label??k?.name??String(k?.id??""),P=typeof k=="object"?k?.id??S:S,A=document.createElement("button");A.className=`fi-dropdown-list-item ${M===a?"fi-selected":""}`,A.type="button",A.addEventListener("click",()=>p(P,S));let v=document.createElement("span");v.className="fi-dropdown-list-item-label",v.textContent=S,A.appendChild(v),l.appendChild(A)});else{let k=h(x);if(k){let M=document.createElement("div");M.className="fi-dropdown-header";let S=document.createElement("span");S.style.whiteSpace="normal",S.textContent=k,M.appendChild(S),l.appendChild(M)}}},h=b=>b?n:i?r:e,p=(b,x)=>{c&&c.command({id:b,label:x})},m=()=>{if(!l||!c||(c.items||[]).length===0)return;let x=l.children[a];if(x){let k=x.getBoundingClientRect(),M=l.getBoundingClientRect();(k.topM.bottom)&&x.scrollIntoView({block:"nearest"})}},g=()=>{if(!c)return;let b=Array.isArray(c.items)?c.items:[];b.length!==0&&(a=(a+b.length-1)%b.length,f(),m())},y=()=>{if(!c)return;let b=c.items||[];b.length!==0&&(a=(a+1)%b.length,f(),m())},w=()=>{let b=c?.items||[];if(b.length===0)return;let x=b[a],k=typeof x=="string"?x:x?.label??x?.name??String(x?.id??""),M=typeof x=="object"?x?.id??k:k;p(M,k)};return{onStart:b=>{c=b,a=0,l=u(),l.style.position="absolute",l.style.zIndex="50",f(),document.body.appendChild(l),b.clientRect&&ip(b.editor,l)},onUpdate:b=>{c=b,a=0,f(),m(),b.clientRect&&ip(b.editor,l)},onKeyDown:b=>b.event.key==="Escape"?(l&&l.parentNode&&l.parentNode.removeChild(l),!0):b.event.key==="ArrowUp"?(g(),!0):b.event.key==="ArrowDown"?(y(),!0):b.event.key==="Enter"?(w(),!0):!1,onExit:()=>{l&&l.parentNode&&l.parentNode.removeChild(l),s=null}}}}};var Fx=function({editor:t,overrideSuggestionOptions:e,extensionName:n}){let r=new _,o=e?.char??"@",i=e?.extraAttributes??{};return{editor:t,char:o,pluginKey:r,command:({editor:s,range:l,props:a})=>{s.view.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(l.to+=1);let u={...a,char:o,extra:i};s.chain().focus().insertContentAt(l,[{type:n,attrs:u},{type:"text",text:" "}]).run(),s.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()},allow:({state:s,range:l})=>{let a=s.doc.resolve(l.from),c=s.schema.nodes[n];return!!a.parent.type.contentMatch.matchType(c)},...e}},lp=V.create({name:"mention",priority:101,addStorage(){return{suggestions:[],getSuggestionFromChar:()=>null}},addOptions(){return{HTMLAttributes:{},renderText({node:t}){return`${t.attrs.char??"@"}`},deleteTriggerWithBackspace:!0,renderHTML({options:t,node:e}){return["span",N(this.HTMLAttributes,t.HTMLAttributes),`${e.attrs.char??"@"}${e.attrs.label??""}`]},suggestions:[],suggestion:{},getMentionLabelsUsing:null}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,keepOnSplit:!1,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},char:{default:"@",parseHTML:t=>t.getAttribute("data-char")??"@",renderHTML:t=>t.char?{"data-char":t.char}:{}},extra:{default:null,renderHTML:t=>{let e=t?.extra;return!e||typeof e!="object"?{}:e}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){let n=this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar(t?.attrs?.char??"@"),r={...this.options};r.HTMLAttributes=N({"data-type":this.name},this.options.HTMLAttributes,e);let o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",N({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){let e={options:this.options,node:t,suggestion:this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar(t?.attrs?.char??"@")};return this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1,{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;let s=new ne,l=0;if(e.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return n=!0,s=a,l=c,!1}),n){let a=s?.attrs?.char??"@";t.insertText(this.options.deleteTriggerWithBackspace?"":a,l,l+s.nodeSize)}return n})}},addProseMirrorPlugins(){let t=async e=>{let{state:n,dispatch:r}=e,o=[];if(n.doc.descendants((s,l)=>{if(s.type.name!==this.name||s.attrs?.label)return;let a=s.attrs?.id,c=s.attrs?.char??"@";a&&o.push({id:a,char:c,pos:l})}),o.length===0)return;let i=this.options.getMentionLabelsUsing;if(typeof i=="function")try{let s=o.map(({id:a,char:c})=>({id:a,char:c})),l=await i(s);o.forEach(({id:a,pos:c})=>{let d=l[a];if(!d)return;let u=e.state.doc.nodeAt(c);if(!u||u.type.name!==this.name)return;let f={...u.attrs,label:d},h=e.state.tr.setNodeMarkup(c,void 0,f);r(h)})}catch{}};return[...this.storage.suggestions.map(Hi),new B({view:e=>(setTimeout(()=>t(e),0),{update:n=>t(n)})})]},onBeforeCreate(){let t=n=>Array.isArray(n)?n:n&&typeof n=="object"?Object.entries(n).map(([r,o])=>({id:r,label:o})):[],e=this.options.suggestions.length?this.options.suggestions:[this.options.suggestion];this.storage.suggestions=e.map(n=>{let r=n?.char??"@",o=n?.items??[],i=n?.noOptionsMessage??null,s=n?.noSearchResultsMessage??null,l=n?.isSearchable??!1,a=this.options.getMentionSearchResultsUsing,c;if(typeof n?.items=="function"){let d=n.items;c={...n,items:async u=>{if(u?.query&&typeof a=="function")try{let f=await a(u?.query,r);return t(f)}catch{}return await d(u)}}}else{let d=n?.extraAttributes,u=n?.searchPrompt??null,f=n?.searchingMessage??null;c={...sp({items:async({query:h})=>{if(!(Array.isArray(o)?o.length>0:o&&typeof o=="object"&&Object.keys(o).length>0)&&!h)return[];let m=t(o);if(h&&typeof a=="function")try{let y=await a(h,r);return t(y)}catch{}if(!h)return m;let g=String(h).toLowerCase();return m.filter(y=>{let w=typeof y=="string"?y:y?.label??y?.name??"";return String(w).toLowerCase().includes(g)})},isSearchable:l,noOptionsMessage:i,noSearchResultsMessage:s,searchPrompt:u,searchingMessage:f}),char:r,...d?{extraAttributes:d}:{}}}return Fx({editor:this.editor,overrideSuggestionOptions:c,extensionName:this.name})}),this.storage.getSuggestionFromChar=n=>this.storage.suggestions.find(r=>r.char===n)??this.storage.suggestions[0]??null}});var Gi=" ",$a="\xA0",_x=V.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",N(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{let n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);let r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===Gi||n[0].text===Gi||n[0].raw===$a||n[0].text===$a)&&r.length===1&&r[0].type==="text"&&(r[0].text===Gi||r[0].text===$a)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,o;if(!t)return"";let i=Array.isArray(t.content)?t.content:[];if(i.length===0){let s=Array.isArray((r=n?.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((o=n?.previousNode)==null?void 0:o.type)==="paragraph"&&s.length===0?Gi:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ap=_x;var Fa=ea;var cp=te.create({name:"small",parseHTML(){return[{tag:"small"}]},renderHTML({HTMLAttributes:t}){return["small",t,0]},addCommands(){return{setSmall:()=>({commands:t})=>t.setMark(this.name),toggleSmall:()=>({commands:t})=>t.toggleMark(this.name),unsetSmall:()=>({commands:t})=>t.unsetMark(this.name)}}});var dp=te.create({name:"textColor",addOptions(){return{textColors:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.classList?.contains("color")}]},renderHTML({HTMLAttributes:t}){let e={...t},n=t.class;e.class=["color",n].filter(Boolean).join(" ");let r=t["data-color"],i=(this.options.textColors||{})[r],s=typeof r=="string"&&r.length>0,l=i?`--color: ${i.color}; --dark-color: ${i.darkColor}`:s?`--color: ${r}; --dark-color: ${r}`:null;if(l){let a=typeof t.style=="string"?t.style:"";e.style=a?`${l}; ${a}`:l}return["span",e,0]},addAttributes(){return{"data-color":{default:null,parseHTML:t=>t.getAttribute("data-color"),renderHTML:t=>t["data-color"]?{"data-color":t["data-color"]}:{}}}},addCommands(){return{setTextColor:({color:t})=>({commands:e})=>e.setMark(this.name,{"data-color":t}),unsetTextColor:()=>({commands:t})=>t.unsetMark(this.name)}}});var Vx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Wx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,jx=te.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",N(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[De({find:Vx,type:this.type})]},addPasteRules(){return[Te({find:Wx,type:this.type})]}}),up=jx;var Ux=te.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",N(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),fp=Ux;var Kx=te.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",N(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),hp=Kx;var Va,Wa;if(typeof WeakMap<"u"){let t=new WeakMap;Va=e=>t.get(e),Wa=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;Va=r=>{for(let o=0;o(n==10&&(n=0),t[n++]=r,t[n++]=o)}var se=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:y-b});break}let x=o+b*e;for(let k=0;kr&&(i+=c.attrs.colspan)}}for(let s=0;s1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function Gx(t,e,n){t.problems||(t.problems=[]);let r={};for(let o=0;o0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Yx(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Qe(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function ts(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=gn(e.$head)||Qx(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Qx(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function ja(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Zx(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function qa(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Cp(t,e,n){let r=t.node(-1),o=se.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function yn(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function vp(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;od!=n.pos-i);a.unshift(n.pos-i);let c=a.map(d=>{let u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);let f=i+d+1;return new qt(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(ja(r)&&ja(o)&&qa(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Tt.rowSelection(r,o):i&&this.isColSelection()?Tt.colSelection(r,o):new Tt(r,o)}return I.between(r,o)}content(){let e=this.$anchorCell.node(-1),n=se.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a0||g>0){let y=p.attrs;if(m>0&&(y=yn(y,0,m)),g>0&&(y=yn(y,y.colspan-g,g)),h.lefto.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),o=se.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom0&&(n=a.resolve(i+o.map[l.left])),s.bottom0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof Tt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),o=se.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right{e.push(re.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Z.create(t.doc,e)}function rk({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(o+1)=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function ok({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function ik(t,e,n){let r=(e||t).selection,o=(e||t).doc,i,s;if(r instanceof L&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=Q.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=Q.rowSelection(l,l)}else if(!n){let l=se.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=Q.create(o,a+1,c)}}else r instanceof I&&rk(r)?i=I.create(o,r.from):r instanceof I&&ok(r)&&(i=I.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var sk=new _("fix-tables");function Tp(t,e,n,r){let o=t.childCount,i=e.childCount;e:for(let s=0,l=0;s{o.type.spec.tableRole=="table"&&(n=lk(t,o,i,n))};return e?e.doc!=t.doc&&Tp(e.doc,t.doc,0,r):t.doc.descendants(r),n}function lk(t,e,n,r){let o=se.get(e);if(!o.problems)return r;r||(r=t.tr);let i=[];for(let a=0;a0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);let p=[];for(let g=0;g0?-1:0;ek(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s0&&o0&&e.map[l-1]==a||o0?-1:0;ck(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,d=e.width*o;c0&&o0&&u==e.map[d-e.width]){let f=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o0&&n[i]==n[i-1]||r.right0&&n[o]==n[o-t]||r.bottom0){let d=a+1+c.content.size,u=pp(c)?a+1:d;i.replaceWith(u+r.tableStart,d+r.tableStart,l)}i.setSelection(new Q(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Xa(t,e){let n=Ce(t.schema);return fk(({node:r})=>n[r.type.spec.tableRole])(t,e)}function fk(t){return(e,n)=>{let r=e.selection,o,i;if(r instanceof Q){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=Yx(r.$from),!o)return!1;i=(s=gn(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let d=ut(e),u=e.tr;for(let h=0;h{s.attrs[t]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function hk(t){return function(e,n){if(!Qe(e))return!1;if(n){let r=Ce(e.schema),o=ut(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a{let h=f+i.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,u,p.attrs)}),r(s)}return!0}}var gT=Yn("row",{useDeprecatedLogic:!0}),yT=Yn("column",{useDeprecatedLogic:!0}),Bp=Yn("cell",{useDeprecatedLogic:!0});function pk(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){let i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Xi(t,e){let n=t.selection;if(!(n instanceof Q))return!1;if(e){let r=t.tr,o=Ce(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new E(o,0,0))}),r.docChanged&&e(r)}return!0}function mk(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c=e.length&&e.push(C.empty),n[o]r&&(f=f.type.createChecked(yn(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;ho&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,o-u.attrs.rowspan)},u.content)),a.push(u)}i.push(C.from(a))}n=i,e=o}return{width:t,height:e,rows:n}}function bk(t,e,n,r,o,i,s){let l=t.doc.type.schema,a=Ce(l),c,d;if(o>e.width)for(let u=0,f=0;ue.height){let u=[];for(let p=0,m=(e.height-1)*e.width;p=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,C.from(u)),h=[];for(let p=e.height;p{if(!o)return!1;let i=n.selection;if(i instanceof Q)return Zi(n,r,z.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;let s=Hp(o,t,e);if(s==null)return!1;if(t=="horiz")return Zi(n,r,z.near(n.doc.resolve(i.head+e),e));{let l=n.doc.resolve(s),a=Cp(l,t,e),c;return a?c=z.near(a,1):e<0?c=z.near(n.doc.resolve(l.before(-1)),-1):c=z.near(n.doc.resolve(l.after(-1)),1),Zi(n,r,c)}}}function Qi(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof Q)s=i;else{let a=Hp(o,t,e);if(a==null)return!1;s=new Q(n.doc.resolve(a))}let l=Cp(s.$headCell,t,e);return l?Zi(n,r,new Q(s.$anchorCell,l)):!1}}function xk(t,e){let n=t.state.doc,r=gn(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Q(r))),!0):!1}function kk(t,e,n){if(!Qe(t.state))return!1;let r=mk(n),o=t.state.selection;if(o instanceof Q){r||(r={width:1,height:1,rows:[C.from(Ua(Ce(t.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=se.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=yk(r,l.right-l.left,l.bottom-l.top),bp(t.state,t.dispatch,s,l,r),!0}else if(r){let i=ts(t.state),s=i.start(-1);return bp(t.state,t.dispatch,s,se.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function Sk(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=wp(t,e.target),o;if(e.shiftKey&&t.state.selection instanceof Q)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=gn(t.state.selection.$anchor))!=null&&((n=_a(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let d=_a(t,c),u=_t.getState(t.state)==null;if(!d||!qa(a,d))if(u)d=a;else return;let f=new Q(a,d);if(u||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);u&&h.setMeta(_t,a.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),_t.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(_t,-1))}function l(a){let c=a,d=_t.getState(t.state),u;if(d!=null)u=t.state.doc.resolve(d);else if(wp(t,c.target)!=r&&(u=_a(t,e),!u))return s();u&&i(u,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Hp(t,e,n){if(!(t.state.selection instanceof I))return null;let{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let s=r.before(o),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?s:null}}return null}function wp(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function _a(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&gn(t.state.doc.resolve(r))||gn(t.state.doc.resolve(o))}var Ck=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ka(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Ka(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Ka(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c){for(let u=0,f=0;unew r(u,n,f)),new vk(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=Pe.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{Mk(s,l,t,o)},mouseleave:s=>{Tk(s)},mousedown:(s,l)=>{Ak(s,l,e,n)}},decorations:s=>{let l=Pe.getState(s);if(l&&l.activeHandle>-1)return Dk(s,l.activeHandle)},nodeViews:{}}});return i}var vk=class es{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(Pe);if(r&&r.setHandle!=null)return new es(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new es(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return ja(e.doc.resolve(o))||(o=-1),new es(o,n.dragging)}return n}};function Mk(t,e,n,r){if(!t.editable)return;let o=Pe.getState(t.state);if(o&&!o.dragging){let i=Nk(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?s=xp(t,e,"left",n):a-e.clientX<=n&&(s=xp(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=t.state.doc.resolve(s),a=l.node(-1),c=se.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Fp(t,s)}}}function Tk(t){if(!t.editable)return;let e=Pe.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Fp(t,-1)}function Ak(t,e,n,r){var o;if(!t.editable)return!1;let i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Pe.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=t.state.doc.nodeAt(s.activeHandle),a=Ek(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Pe,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);let f=Pe.getState(t.state);f?.dragging&&(Ok(t,f.activeHandle,kp(f.dragging,u,n)),t.dispatch(t.state.tr.setMeta(Pe,{setDragging:null})))}function d(u){if(!u.which)return c(u);let f=Pe.getState(t.state);if(f&&f.dragging){let h=kp(f.dragging,u,n);Sp(t,f.activeHandle,h,r)}}return Sp(t,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function Ek(t,e,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=t.domAtPos(e),s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;aIk(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var Lk=V.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;let r=t.getAttribute("colwidth"),o=r?r.split(",").map(i=>parseInt(i,10)):null;if(!o){let i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),s=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(s&&s>-1&&i&&i[s]){let l=i[s].getAttribute("width");return l?[parseInt(l,10)]:null}}return o}},align:jp()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",N(this.options.HTMLAttributes,t),0]}}),Bk=V.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{let e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}},align:jp()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",N(this.options.HTMLAttributes,t),0]}}),zk=V.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",N(this.options.HTMLAttributes,t),0]}});function Qa(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Vp(t,e,n,r,o,i){var s;let l=0,a=!0,c=e.firstChild,d=t.firstChild;if(d!==null)for(let f=0,h=0;f{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function _k(t,e,n,r,o){let i=Fk(t),s=[],l=[];for(let c=0;c{let{selection:e}=t.state;if(!Vk(e))return!1;let n=0,r=Ho(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},Wk="";function jk(t){return(t||"").replace(/\s+/g," ").trim()}function Uk(t,e,n={}){var r;let o=(r=n.cellLineSeparator)!=null?r:Wk;if(!t||!t.content||t.content.length===0)return"";let i=[];t.content.forEach(m=>{let g=[];m.content&&m.content.forEach(y=>{let w="";y.content&&Array.isArray(y.content)&&y.content.length>1?w=y.content.map(S=>e.renderChildren(S)).join(o):w=y.content?e.renderChildren(y.content):"";let b=jk(w),x=y.type==="tableHeader",k=Pk(y.attrs);g.push({text:b,isHeader:x,align:k})}),i.push(g)});let s=i.reduce((m,g)=>Math.max(m,g.length),0);if(s===0)return"";let l=new Array(s).fill(0);i.forEach(m=>{var g;for(let y=0;yl[y]&&(l[y]=b),l[y]<3&&(l[y]=3)}});let a=(m,g)=>m+" ".repeat(Math.max(0,g-m.length)),c=i[0],d=c.some(m=>m.isHeader),u=new Array(s).fill(null);i.forEach(m=>{var g;for(let y=0;yd&&c[g]&&c[g].text||"");return f+=`| ${h.map((m,g)=>a(m,l[g])).join(" | ")} | `,f+=`| ${l.map((m,g)=>{let y=Math.max(3,m),w=u[g];return w==="left"?`:${"-".repeat(y)}`:w==="right"?`${"-".repeat(y)}:`:w==="center"?`:${"-".repeat(y)}:`:"-".repeat(y)}).join(" | ")} | `,(d?i.slice(1):i).forEach(m=>{f+=`| ${new Array(s).fill(0).map((g,y)=>a(m[y]&&m[y].text||"",l[y])).join(" | ")} | `}),f}var Kk=Uk,qk=V.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Hk,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=$k(t,this.options.cellMinWidth),i=e.style;function s(){return i||(r?`width: ${r}`:`min-width: ${o}`)}let l=["table",N(this.options.HTMLAttributes,e,{style:s()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{let n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){let o=[];t.header.forEach((i,s)=>{var l;let a=rs((l=r[s])!=null?l:i.align),c=a?{align:a}:{};o.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},o))}return t.rows&&t.rows.forEach(o=>{let i=[];o.forEach((s,l)=>{var a;let c=rs((a=r[l])!=null?a:s.align),d=c?{align:c}:{};i.push(e.createNode("tableCell",d,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>Kk(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=_k(i.schema,t,e,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(I.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Ep(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Np(t,e),deleteColumn:()=>({state:t,dispatch:e})=>Op(t,e),addRowBefore:()=>({state:t,dispatch:e})=>Dp(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Ip(t,e),deleteRow:()=>({state:t,dispatch:e})=>Pp(t,e),deleteTable:()=>({state:t,dispatch:e})=>zp(t,e),mergeCells:()=>({state:t,dispatch:e})=>Ga(t,e),splitCell:()=>({state:t,dispatch:e})=>Xa(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Yn("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Yn("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>Bp(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Ga(t,e)?!0:Xa(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>Lp(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Ya(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Ya(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Ja(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=Q.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ns,"Mod-Backspace":ns,Delete:ns,"Mod-Delete":ns}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[$p({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],_p({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){let t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:r})=>new e(n,this.options.cellMinWidth,r)},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:J($(t,"tableRole",e))}}}),Up=U.create({name:"tableKit",addExtensions(){let t=[];return this.options.table!==!1&&t.push(qk.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Lk.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(Bk.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(zk.configure(this.options.tableRow)),t}});var Jk=V.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Kp=Jk;var Gk=U.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{let e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),qp=Gk;var Xk=te.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",N(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){let o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!o)return;let i=o[2].trim();return{type:"underline",raw:o[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Jp=Xk;var Gp=(t,e)=>{Xn({getBoundingClientRect:()=>{let{from:r,to:o}=t.state.selection,i=t.view.coordsAtPos(r),s=t.view.coordsAtPos(o);return{top:Math.min(i.top,s.top),bottom:Math.max(i.bottom,s.bottom),left:Math.min(i.left,s.left),right:Math.max(i.right,s.right),width:Math.abs(s.right-i.left),height:Math.abs(s.bottom-i.top),x:Math.min(i.left,s.left),y:Math.min(i.top,s.top)}}},e,{placement:"bottom-start",strategy:"absolute",middleware:[Jn(),Gn()]}).then(({x:r,y:o,strategy:i})=>{e.style.width="max-content",e.style.position=i,e.style.left=`${r}px`,e.style.top=`${o}px`})},Xp=({mergeTags:t,noMergeTagSearchResultsMessage:e})=>({items:({query:n})=>Object.entries(t).filter(([r,o])=>r.toLowerCase().replace(/\s/g,"").includes(n.toLowerCase())||o.toLowerCase().replace(/\s/g,"").includes(n.toLowerCase())).map(([r,o])=>({id:r,label:o})),render:()=>{let n,r=0,o=null,i=()=>{let f=document.createElement("div");return f.className="fi-dropdown-panel fi-dropdown-list",f.style.minWidth="12rem",f},s=()=>{if(!n||!o)return;let f=o.items||[];if(n.innerHTML="",f.length)f.forEach((h,p)=>{let m=document.createElement("button");m.className=`fi-dropdown-list-item fi-dropdown-list-item-label ${p===r?"fi-selected":""}`,m.textContent=h.label,m.type="button",m.addEventListener("click",()=>l(p)),n.appendChild(m)});else{let h=document.createElement("div");h.className="fi-dropdown-header";let p=document.createElement("span");p.style.whiteSpace="normal",p.textContent=e,h.appendChild(p),n.appendChild(h)}},l=f=>{if(!o)return;let p=(o.items||[])[f];p&&o.command({id:p.id})},a=()=>{if(!n||!o||o.items.length===0)return;let f=n.children[r];if(f){let h=f.getBoundingClientRect(),p=n.getBoundingClientRect();(h.topp.bottom)&&f.scrollIntoView({block:"nearest"})}},c=()=>{if(!o)return;let f=o.items||[];f.length!==0&&(r=(r+f.length-1)%f.length,s(),a())},d=()=>{if(!o)return;let f=o.items||[];f.length!==0&&(r=(r+1)%f.length,s(),a())},u=()=>{l(r)};return{onStart:f=>{o=f,r=0,n=i(),n.style.position="absolute",n.style.zIndex="50",s(),document.body.appendChild(n),f.clientRect&&Gp(f.editor,n)},onUpdate:f=>{o=f,r=0,s(),a(),f.clientRect&&Gp(f.editor,n)},onKeyDown:f=>f.event.key==="Escape"?(n&&n.parentNode&&n.parentNode.removeChild(n),!0):f.event.key==="ArrowUp"?(c(),!0):f.event.key==="ArrowDown"?(d(),!0):f.event.key==="Enter"?(u(),!0):!1,onExit:()=>{n&&n.parentNode&&n.parentNode.removeChild(n)}}}});var Yp=async({$wire:t,acceptedFileTypes:e,acceptedFileTypesValidationMessage:n,canAttachFiles:r,customExtensionUrls:o,deleteCustomBlockButtonIconHtml:i,editCustomBlockButtonIconHtml:s,editCustomBlockUsing:l,getMentionLabelsUsing:a,getMentionSearchResultsUsing:c,hasResizableImages:d,insertCustomBlockUsing:u,key:f,linkProtocols:h,maxFileSize:p,maxFileSizeValidationMessage:m,mentions:g,mergeTags:y,noMergeTagSearchResultsMessage:w,placeholder:b,statePath:x,textColors:k,uploadingFileMessage:M})=>{let S=[Tf,Af,Aa,Ef,Nf,Of.configure({deleteCustomBlockButtonIconHtml:i,editCustomBlockButtonIconHtml:s,editCustomBlockUsing:l,insertCustomBlockUsing:u}),Df,Pf,If,Lf,Cf.configure({class:"fi-not-prose"}),vf,Bf,zf,Hf,$f,Ff,_f,Vf,jf.configure({inline:!0,resize:{enabled:d,alwaysPreserveAspectRatio:!0,allowBase64:!0}}),Uf,sh.configure({autolink:!0,HTMLAttributes:{target:null,rel:null},openOnClick:!1,protocols:h}),Ea,...r?[bh.configure({acceptedTypes:e,acceptedTypesValidationMessage:n,get$WireUsing:()=>t,key:f,maxSize:p,maxSizeValidationMessage:m,statePath:x,uploadingMessage:M})]:[],...Object.keys(y).length?[wh.configure({deleteTriggerWithBackspace:!0,suggestion:Xp({mergeTags:y,noMergeTagSearchResultsMessage:w}),mergeTags:y})]:[],...g.length?[lp.configure({HTMLAttributes:{class:"fi-fo-rich-editor-mention"},suggestions:g,getMentionSearchResultsUsing:c,getMentionLabelsUsing:a})]:[],Oa,ap,Fa.configure({placeholder:b}),dp.configure({textColors:k}),cp,up,fp,hp,Up.configure({table:{resizable:!0}}),Kp,qp.configure({types:["heading","paragraph"],alignments:["start","center","end","justify"],defaultAlignment:"start"}),Jp,Mf],P=await Promise.all(o.map(async A=>{new RegExp("^(?:[a-z+]+:)?//","i").test(A)||(A=new URL(A,document.baseURI).href);try{let R=(await import(A)).default;return typeof R=="function"?R():R}catch(R){return console.error(`Failed to load rich editor custom extension from [${A}]:`,R),null}}));for(let A of P){if(!A||!A.name)continue;let v=S.findIndex(R=>R.name===A.name);A.name==="placeholder"&&A.parent===null&&(A=Fa.configure(A.options)),v!==-1?S[v]=A:S.push(A)}return S};function Yk(t,e){let n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),o=Math.min(t.left,e.left),s=Math.max(t.right,e.right)-o,l=r-n,a=o,c=n;return new DOMRect(a,c,s,l)}var Qk=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:o=250,resizeDelay:i=60,shouldShow:s,appendTo:l,getReferencedVirtualElement:a,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:u,state:f,from:h,to:p})=>{let{doc:m,selection:g}=f,{empty:y}=g,w=!m.textBetween(h,p).length&&Hn(f.selection),b=this.element.contains(document.activeElement);return!(!(u.hasFocus()||b)||y||w||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var f;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u?.relatedTarget&&((f=this.element.parentNode)!=null&&f.contains(u.relatedTarget))||u?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,f)=>{let h=!f?.selection.eq(u.state.selection),p=!f?.doc.eq(u.state.doc);!h&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,h,p,f)},this.updateDelay))},this.updateHandler=(u,f,h,p)=>{let{composing:m}=u;if(m||!f&&!h)return;if(!this.getShouldShow(p)){this.hide();return}this.show(),this.updatePosition()},this.transactionHandler=({transaction:u})=>{let f=u.getMeta(this.pluginKey);f==="updatePosition"?this.updatePosition():f&&typeof f=="object"&&f.type==="updateOptions"?this.updateOptions(f.options):f==="hide"?this.hide():f==="show"&&(this.updatePosition(),this.show())};var d;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=o,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(d=c?.scrollTarget)!=null?d:window,this.getReferencedVirtualElement=a,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,s&&(this.shouldShow=s),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.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let t=[];return this.floatingUIOptions.flip&&t.push(Gn(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(Jn(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(Zh(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(rp(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(tp(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(ep(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(np(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(op(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;let{selection:r}=this.editor.state,o=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(o)return o;if(!((n=(e=this.view)==null?void 0:e.dom)!=null&&n.parentNode))return;let i=_l(this.view,r.from,r.to),s={getBoundingClientRect:()=>i,getClientRects:()=>[i]};if(r instanceof L){let l=this.view.nodeDOM(r.from),a=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");a&&(l=a),l&&(s={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(r instanceof Q){let{$anchorCell:l,$headCell:a}=r,c=l?l.pos:a.pos,d=a?a.pos:l.pos,u=this.view.nodeDOM(c),f=this.view.nodeDOM(d);if(!u||!f)return;let h=u===f?u.getBoundingClientRect():Yk(u.getBoundingClientRect(),f.getBoundingClientRect());s={getBoundingClientRect:()=>h,getClientRects:()=>[h]}}return s}updatePosition(){if(!this.isVisible)return;let t=this.virtualElement;t&&Xn(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r,middlewareData:o})=>{var i,s;if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if((i=o.hide)!=null&&i.referenceHidden||(s=o.hide)!=null&&s.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(t,e){let{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}let o=!e?.selection.eq(t.state.selection),i=!e?.doc.eq(t.state.doc);this.updateHandler(t,o,i,e)}getShouldShow(t){var e;let{state:n}=this.view,{selection:r}=n,{ranges:o}=r,i=Math.min(...o.map(a=>a.$from.pos)),s=Math.max(...o.map(a=>a.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:s}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";let e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){let n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Za=t=>new B({key:typeof t.pluginKey=="string"?new _(t.pluginKey):t.pluginKey,view:e=>new Qk({view:e,...t})}),EA=U.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Za({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var{Editor:Zk}=Qo,{Selection:eS}=go;window.FilamentRichEditor=window.FilamentRichEditor||{};window.FilamentRichEditor.tiptap={core:Qo,pmState:go,pmView:wl,pmModel:Fs};function tS({acceptedFileTypes:t,acceptedFileTypesValidationMessage:e,activePanel:n,canAttachFiles:r,deleteCustomBlockButtonIconHtml:o,editCustomBlockButtonIconHtml:i,extensions:s,floatingToolbars:l,hasResizableImages:a,isDisabled:c,isLiveDebounced:d,isLiveOnBlur:u,key:f,label:h,linkProtocols:p,liveDebounce:m,livewireId:g,maxFileSize:y,maxFileSizeValidationMessage:w,mergeTags:b,mentions:x,getMentionSearchResultsUsing:k,getMentionLabelsUsing:M,noMergeTagSearchResultsMessage:S,placeholder:P,state:A,statePath:v,textColors:R,uploadingFileMessage:j}){let D,O=[],H=!1;return{state:A,activePanel:n,editorSelection:{type:"text",anchor:1,head:1},isUploadingFile:!1,fileValidationMessage:null,shouldUpdateState:!0,editorUpdatedAt:Date.now(),async init(){D=new Zk({editable:!c,element:this.$refs.editor,editorProps:{attributes:{...h?{"aria-label":h}:{}}},extensions:await Yp({acceptedFileTypes:t,acceptedFileTypesValidationMessage:e,canAttachFiles:r,customExtensionUrls:s,deleteCustomBlockButtonIconHtml:o,editCustomBlockButtonIconHtml:i,editCustomBlockUsing:(q,ft)=>this.$wire.mountAction("customBlock",{editorSelection:this.editorSelection,id:q,config:ft,mode:"edit"},{schemaComponent:f}),floatingToolbars:l,hasResizableImages:a,insertCustomBlockUsing:(q,ft=null)=>this.$wire.mountAction("customBlock",{id:q,dragPosition:ft,mode:"insert"},{schemaComponent:f}),key:f,linkProtocols:p,maxFileSize:y,maxFileSizeValidationMessage:w,mergeTags:b,mentions:x,getMentionSearchResultsUsing:k,getMentionLabelsUsing:M,noMergeTagSearchResultsMessage:S,placeholder:P,statePath:v,textColors:R,uploadingFileMessage:j,$wire:this.$wire}),content:this.state});let W="paragraph"in l;Object.keys(l).forEach(q=>{let ft=this.$refs[`floatingToolbar::${q}`];if(!ft){console.warn(`Floating toolbar [${q}] not found.`);return}D.registerPlugin(Za({editor:D,element:ft,pluginKey:`floatingToolbar::${q}`,shouldShow:({editor:Ke})=>q==="paragraph"?Ke.isFocused&&Ke.isActive(q)&&!Ke.state.selection.empty:W&&!Ke.state.selection.empty&&Ke.isActive("paragraph")?!1:Ke.isFocused&&Ke.isActive(q),options:{placement:"bottom",offset:15}}))}),D.on("create",()=>{this.editorUpdatedAt=Date.now()});let X=Alpine.debounce(()=>{H||this.$wire.commit()},m??300);D.on("update",({editor:q})=>this.$nextTick(()=>{H||(this.editorUpdatedAt=Date.now(),this.state=q.getJSON(),this.shouldUpdateState=!1,this.fileValidationMessage=null,d&&X())})),D.on("selectionUpdate",({transaction:q})=>{H||(this.editorUpdatedAt=Date.now(),this.editorSelection=q.selection.toJSON())}),D.on("transaction",()=>{H||(this.editorUpdatedAt=Date.now())}),u&&D.on("blur",()=>{H||this.$wire.commit()}),this.$watch("state",()=>{if(!H){if(!this.shouldUpdateState){this.shouldUpdateState=!0;return}D.commands.setContent(this.state)}});let Y=q=>{q.detail.livewireId===g&&q.detail.key===f&&this.runEditorCommands(q.detail)};window.addEventListener("run-rich-editor-commands",Y),O.push(["run-rich-editor-commands",Y]);let F=q=>{q.detail.livewireId===g&&q.detail.key===f&&(this.isUploadingFile=!0,this.fileValidationMessage=null,q.stopPropagation())};window.addEventListener("rich-editor-uploading-file",F),O.push(["rich-editor-uploading-file",F]);let ce=q=>{q.detail.livewireId===g&&q.detail.key===f&&(this.isUploadingFile=!1,q.stopPropagation())};window.addEventListener("rich-editor-uploaded-file",ce),O.push(["rich-editor-uploaded-file",ce]);let fe=q=>{q.detail.livewireId===g&&q.detail.key===f&&(this.isUploadingFile=!1,this.fileValidationMessage=q.detail.validationMessage,q.stopPropagation())};window.addEventListener("rich-editor-file-validation-message",fe),O.push(["rich-editor-file-validation-message",fe]),window.dispatchEvent(new CustomEvent(`schema-component-${g}-${f}-loaded`))},getEditor(){return D},$getEditor(){return this.getEditor()},setEditorSelection(W){W&&(this.editorSelection=W,D.chain().command(({tr:X})=>(X.setSelection(eS.fromJSON(D.state.doc,this.editorSelection)),!0)).run())},runEditorCommands({commands:W,editorSelection:X}){this.setEditorSelection(X);let Y=D.chain();W.forEach(F=>Y=Y[F.name](...F.arguments??[])),Y.run()},togglePanel(W=null){if(this.isPanelActive(W)){this.activePanel=null;return}this.activePanel=W},isPanelActive(W=null){return W===null?this.activePanel!==null:this.activePanel===W},insertMergeTag(W){D.chain().focus().insertContent([{type:"mergeTag",attrs:{id:W}},{type:"text",text:" "}]).run()},destroy(){H=!0,O.forEach(([W,X])=>{window.removeEventListener(W,X)}),O=[],D&&(D.destroy(),D=null),this.shouldUpdateState=!0}}}export{tS as default};