@ahzoo/sus 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/t/index.d.ts +5 -1
- package/dist/t/index.js +441 -422
- package/dist/t/index.umd.cjs +17 -17
- package/dist/t/style.css +1 -1
- package/dist/t/types/list.d.ts +9 -9
- package/dist/v/{types/index.d.ts → index.d.ts} +5 -1
- package/dist/v/index.js +1409 -1386
- package/dist/v/index.umd.cjs +79 -79
- package/dist/v/style.css +1 -1
- package/dist/v/types/list.d.ts +11 -10
- package/package.json +1 -1
package/dist/t/index.umd.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(function(je,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("vue"),require("lowlight"),require("@ahzoo/ouo")):typeof define=="function"&&define.amd?define(["exports","vue","lowlight","@ahzoo/ouo"],m):(je=typeof globalThis<"u"?globalThis:je||self,m(je.SuSComment={},je.vue,je.lowlight$1,je.ouo))})(this,(function(je,m,Lf,qn){"use strict";function Te(n){this.content=n}Te.prototype={constructor:Te,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new Te(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Te(t)},addToStart:function(n,e){return new Te([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Te(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new Te(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Te.from(n),n.size?new Te(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Te.from(n),n.size?new Te(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Te.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Te.from=function(n){if(n instanceof Te)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Te(e)};function El(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=El(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Ml(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Ml(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class S{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new S(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new S(r,i)}cutByIndex(e,t){return e==t?S.empty:e==0&&t==this.content.length?this:new S(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new S(i,s)}addToStart(e){return new S([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new S(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return El(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Ml(this,e,t,r)}findIndex(e){if(e==0)return Or(0,e);if(e==this.size)return Or(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?Or(t+1,s):Or(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return S.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new S(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return S.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new S(t||e,r)}static from(e){if(!e)return S.empty;if(e instanceof S)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new S([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}S.empty=new S([],0);const hs={index:0,offset:0};function Or(n,e){return hs.index=n,hs.offset=e,hs}function Nr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Nr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Nr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let ne=class Sl{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Nr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Sl.none;if(e instanceof Sl)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};ne.none=[];class Ar extends Error{}class N{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Tl(this.content,e+this.openStart,t);return r&&new N(r,this.openStart,this.openEnd)}removeBetween(e,t){return new N(vl(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return N.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new N(S.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new N(e,r,i)}}N.empty=new N(S.empty,0,0);function vl(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(vl(s.content,e-i-1,t-i-1)))}function Tl(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Tl(o.content,e-s-1,t,o);return l&&n.replaceChild(i,o.copy(l))}function Bf(n,e,t){if(t.openStart>n.depth)throw new Ar("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ar("Inconsistent open depths");return Ol(n,e,t,0)}function Ol(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Ol(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return sn(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=_f(t,n);return sn(s,Al(n,o,l,e,r))}else return sn(s,Rr(n,e,r))}function Nl(n,e){if(!e.type.compatibleContent(n.type))throw new Ar("Cannot join "+e.type.name+" onto "+n.type.name)}function ps(n,e,t){let r=n.node(t);return Nl(r,e.node(t)),r}function rn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Jn(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(rn(n.nodeAfter,r),s++));for(let l=s;l<o;l++)rn(i.child(l),r);e&&e.depth==t&&e.textOffset&&rn(e.nodeBefore,r)}function sn(n,e){return n.type.checkContent(e),n.copy(e)}function Al(n,e,t,r,i){let s=n.depth>i&&ps(n,e,i+1),o=r.depth>i&&ps(t,r,i+1),l=[];return Jn(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Nl(s,o),rn(sn(s,Al(n,e,t,r,i+1)),l)):(s&&rn(sn(s,Rr(n,e,i+1)),l),Jn(e,t,i,l),o&&rn(sn(o,Rr(t,r,i+1)),l)),Jn(r,null,i,l),new S(l)}function Rr(n,e,t){let r=[];if(Jn(null,n,t,r),n.depth>t){let i=ps(n,e,t+1);rn(sn(i,Rr(n,e,t+1)),r)}return Jn(e,null,t,r),new S(r)}function _f(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(S.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Gn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ne.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Dr(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<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Gn(t,r,s)}static resolveCached(e,t){let r=Rl.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else Rl.set(e,r=new Vf);let i=r.elts[r.i]=Gn.resolve(e,t);return r.i=(r.i+1)%$f,i}}class Vf{constructor(){this.elts=[],this.i=0}}const $f=12,Rl=new WeakMap;class Dr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const zf=Object.create(null);let Lt=class Cl{constructor(e,t,r,i=ne.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Nr(this.attrs,t||e.defaultAttrs||zf)&&ne.sameSet(this.marks,r||ne.none)}copy(e=null){return e==this.content?this:new Cl(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Cl(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return N.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new N(c,i.depth-o,s.depth-o)}replace(e,t,r){return Bf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Gn.resolveCached(this,e)}resolveNoCache(e){return Gn.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Dl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=S.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ne.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ne.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=S.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Lt.prototype.text=void 0;class Ir extends Lt{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Dl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Ir(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ir(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Dl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class on{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Hf(e,t);if(r.next==null)return on.empty;let i=Il(r);r.next&&r.err("Unexpected trailing text");let s=Jf(qf(i));return Gf(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return S.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=s(d,l.concat(u));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
|
|
2
|
-
`)}}on.empty=new on(!0);class Hf{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Il(n){let e=[];do e.push(Ff(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ff(n){let e=[];do e.push(jf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function jf(n){let e=Kf(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Uf(n,e);else break;return e}function Pl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Uf(n,e){let t=Pl(n),r=t;return n.eat(",")&&(n.next!="}"?r=Pl(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Wf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Kf(n){if(n.eat("(")){let e=Il(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Wf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function qf(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=t();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=t();r(a,u),i(s(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Ll(n,e){return e-n}function Bl(n,e){let t=[];return r(e),t.sort(Ll);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function Jf(n){let e=Object.create(null);return t(Bl(n,0));function t(r){let i=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Bl(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new on(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Ll);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function Gf(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function _l(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Vl(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function $l(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function zl(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Xf(n,r,e[r]);return t}let Hl=class Af{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=zl(e,r.attrs),this.defaultAttrs=_l(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==on.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-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:Vl(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Lt(this,this.computeAttrs(e),S.from(t),ne.setFrom(r))}createChecked(e=null,t,r){return t=S.from(t),this.checkContent(t),new Lt(this,this.computeAttrs(e),t,ne.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=S.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(S.empty,!0);return s?new Lt(this,e,t.append(s),ne.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){$l(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:ne.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Af(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Yf(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class Xf{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Yf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Pr{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=zl(e,i.attrs),this.excluded=null;let s=_l(this.attrs);this.instance=s?new ne(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ne(this,Vl(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new Pr(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){$l(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Fl{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Te.from(e.nodes),t.marks=Te.from(e.marks||{}),this.nodes=Hl.compile(this.spec.nodes,this),this.marks=Pr.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=on.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?jl(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:jl(this,o.split(" "))}this.nodeFromJSON=i=>Lt.fromJSON(this,i),this.markFromJSON=i=>ne.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Hl){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Ir(r,r.defaultAttrs,e,ne.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function jl(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Qf(n){return n.tag!=null}function Zf(n){return n.style!=null}class Bt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Qf(i))this.tags.push(i);else if(Zf(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new ql(this,t,!1);return r.addAll(e,ne.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ql(this,t,!0);return r.addAll(e,ne.none,t.from,t.to),N.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(nh(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Jl(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Jl(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Bt(e,Bt.schemaRules(e)))}}const Ul={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},eh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Wl={ol:!0,ul:!0},Yn=1,ms=2,Xn=4;function Kl(n,e,t){return e!=null?(e?Yn:0)|(e==="full"?ms:0):n&&n.whitespace=="pre"?Yn|ms:t&~Xn}class Lr{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=ne.none,this.match=s||(o&Xn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Yn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ul.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ql{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=Kl(null,t.preserveWhitespace,0)|(r?Xn:0);i?s=new Lr(i.type,i.attrs,ne.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new Lr(null,null,ne.none,!0,null,o):s=new Lr(e.schema.topNodeType,null,ne.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&ms?"full":this.localPreserveWS||(i.options&Yn)>0;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
1
|
+
(function(je,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("vue"),require("lowlight"),require("@ahzoo/ouo")):typeof define=="function"&&define.amd?define(["exports","vue","lowlight","@ahzoo/ouo"],m):(je=typeof globalThis<"u"?globalThis:je||self,m(je.SuSComment={},je.vue,je.lowlight$1,je.ouo))})(this,(function(je,m,Lf,qn){"use strict";function Te(n){this.content=n}Te.prototype={constructor:Te,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new Te(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Te(t)},addToStart:function(n,e){return new Te([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Te(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new Te(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Te.from(n),n.size?new Te(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Te.from(n),n.size?new Te(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Te.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Te.from=function(n){if(n instanceof Te)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Te(e)};function El(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=El(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Ml(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Ml(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class S{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new S(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new S(r,i)}cutByIndex(e,t){return e==t?S.empty:e==0&&t==this.content.length?this:new S(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new S(i,s)}addToStart(e){return new S([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new S(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return El(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Ml(this,e,t,r)}findIndex(e){if(e==0)return Or(0,e);if(e==this.size)return Or(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?Or(t+1,s):Or(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return S.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new S(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return S.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new S(t||e,r)}static from(e){if(!e)return S.empty;if(e instanceof S)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new S([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}S.empty=new S([],0);const hs={index:0,offset:0};function Or(n,e){return hs.index=n,hs.offset=e,hs}function Nr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Nr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Nr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let ne=class Sl{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Nr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Sl.none;if(e instanceof Sl)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};ne.none=[];class Ar extends Error{}class N{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Tl(this.content,e+this.openStart,t);return r&&new N(r,this.openStart,this.openEnd)}removeBetween(e,t){return new N(vl(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return N.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new N(S.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new N(e,r,i)}}N.empty=new N(S.empty,0,0);function vl(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(vl(s.content,e-i-1,t-i-1)))}function Tl(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Tl(o.content,e-s-1,t,o);return l&&n.replaceChild(i,o.copy(l))}function Bf(n,e,t){if(t.openStart>n.depth)throw new Ar("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ar("Inconsistent open depths");return Ol(n,e,t,0)}function Ol(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Ol(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return sn(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Vf(t,n);return sn(s,Al(n,o,l,e,r))}else return sn(s,Rr(n,e,r))}function Nl(n,e){if(!e.type.compatibleContent(n.type))throw new Ar("Cannot join "+e.type.name+" onto "+n.type.name)}function ps(n,e,t){let r=n.node(t);return Nl(r,e.node(t)),r}function rn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Jn(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(rn(n.nodeAfter,r),s++));for(let l=s;l<o;l++)rn(i.child(l),r);e&&e.depth==t&&e.textOffset&&rn(e.nodeBefore,r)}function sn(n,e){return n.type.checkContent(e),n.copy(e)}function Al(n,e,t,r,i){let s=n.depth>i&&ps(n,e,i+1),o=r.depth>i&&ps(t,r,i+1),l=[];return Jn(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Nl(s,o),rn(sn(s,Al(n,e,t,r,i+1)),l)):(s&&rn(sn(s,Rr(n,e,i+1)),l),Jn(e,t,i,l),o&&rn(sn(o,Rr(t,r,i+1)),l)),Jn(r,null,i,l),new S(l)}function Rr(n,e,t){let r=[];if(Jn(null,n,t,r),n.depth>t){let i=ps(n,e,t+1);rn(sn(i,Rr(n,e,t+1)),r)}return Jn(e,null,t,r),new S(r)}function Vf(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(S.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Gn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ne.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Dr(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<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Gn(t,r,s)}static resolveCached(e,t){let r=Rl.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else Rl.set(e,r=new $f);let i=r.elts[r.i]=Gn.resolve(e,t);return r.i=(r.i+1)%zf,i}}class $f{constructor(){this.elts=[],this.i=0}}const zf=12,Rl=new WeakMap;class Dr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const _f=Object.create(null);let Lt=class Cl{constructor(e,t,r,i=ne.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Nr(this.attrs,t||e.defaultAttrs||_f)&&ne.sameSet(this.marks,r||ne.none)}copy(e=null){return e==this.content?this:new Cl(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Cl(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return N.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new N(c,i.depth-o,s.depth-o)}replace(e,t,r){return Bf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Gn.resolveCached(this,e)}resolveNoCache(e){return Gn.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Dl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=S.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ne.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ne.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=S.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Lt.prototype.text=void 0;class Ir extends Lt{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Dl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Ir(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ir(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Dl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class on{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Hf(e,t);if(r.next==null)return on.empty;let i=Il(r);r.next&&r.err("Unexpected trailing text");let s=Jf(qf(i));return Gf(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return S.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=s(d,l.concat(u));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
|
|
2
|
+
`)}}on.empty=new on(!0);class Hf{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Il(n){let e=[];do e.push(Ff(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ff(n){let e=[];do e.push(jf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function jf(n){let e=Kf(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Uf(n,e);else break;return e}function Pl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Uf(n,e){let t=Pl(n),r=t;return n.eat(",")&&(n.next!="}"?r=Pl(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Wf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Kf(n){if(n.eat("(")){let e=Il(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Wf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function qf(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=t();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=t();r(a,u),i(s(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Ll(n,e){return e-n}function Bl(n,e){let t=[];return r(e),t.sort(Ll);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function Jf(n){let e=Object.create(null);return t(Bl(n,0));function t(r){let i=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Bl(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new on(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Ll);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function Gf(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Vl(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function $l(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function zl(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function _l(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Xf(n,r,e[r]);return t}let Hl=class Af{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=_l(e,r.attrs),this.defaultAttrs=Vl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==on.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-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:$l(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Lt(this,this.computeAttrs(e),S.from(t),ne.setFrom(r))}createChecked(e=null,t,r){return t=S.from(t),this.checkContent(t),new Lt(this,this.computeAttrs(e),t,ne.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=S.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(S.empty,!0);return s?new Lt(this,e,t.append(s),ne.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){zl(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:ne.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Af(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Yf(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class Xf{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Yf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Pr{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=_l(e,i.attrs),this.excluded=null;let s=Vl(this.attrs);this.instance=s?new ne(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ne(this,$l(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new Pr(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){zl(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Fl{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Te.from(e.nodes),t.marks=Te.from(e.marks||{}),this.nodes=Hl.compile(this.spec.nodes,this),this.marks=Pr.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=on.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?jl(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:jl(this,o.split(" "))}this.nodeFromJSON=i=>Lt.fromJSON(this,i),this.markFromJSON=i=>ne.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Hl){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Ir(r,r.defaultAttrs,e,ne.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function jl(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Qf(n){return n.tag!=null}function Zf(n){return n.style!=null}class Bt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Qf(i))this.tags.push(i);else if(Zf(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new ql(this,t,!1);return r.addAll(e,ne.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ql(this,t,!0);return r.addAll(e,ne.none,t.from,t.to),N.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(nh(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Jl(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Jl(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Bt(e,Bt.schemaRules(e)))}}const Ul={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},eh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Wl={ol:!0,ul:!0},Yn=1,ms=2,Xn=4;function Kl(n,e,t){return e!=null?(e?Yn:0)|(e==="full"?ms:0):n&&n.whitespace=="pre"?Yn|ms:t&~Xn}class Lr{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=ne.none,this.match=s||(o&Xn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Yn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ul.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ql{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=Kl(null,t.preserveWhitespace,0)|(r?Xn:0);i?s=new Lr(i.type,i.attrs,ne.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new Lr(null,null,ne.none,!0,null,o):s=new Lr(e.schema.topNodeType,null,ne.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&ms?"full":this.localPreserveWS||(i.options&Yn)>0;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
3
3
|
`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Wl.hasOwnProperty(o)&&this.parser.normalizeLists&&th(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:eh.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Ul.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=ne.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Gl(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Kl(e,s,o.options);o.options&Xn&&o.content.length==0&&(l|=Xn);let a=ne.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Gl(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Lr(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Yn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function th(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Wl.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function nh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Jl(n){let e={};for(let t in n)e[t]=n[t];return e}function Gl(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}class ln{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=gs(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=Br(gs(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Br(gs(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Br(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ln(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Yl(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Yl(e.marks)}}function Yl(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function gs(n){return n.document||window.document}const Xl=new WeakMap;function rh(n){let e=Xl.get(n);return e===void 0&&Xl.set(n,e=ih(n)),e}function ih(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function Br(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=rh(r))&&s.indexOf(e)>-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 o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=Br(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Ql=65535,Zl=Math.pow(2,16);function sh(n,e){return n+e*Zl}function ea(n){return n&Ql}function oh(n){return(n-(n&Ql))/Zl}const ta=1,na=2,_r=4,ra=8;class ys{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&ra)>0}get deletedBefore(){return(this.delInfo&(ta|_r))>0}get deletedAfter(){return(this.delInfo&(na|_r))>0}get deletedAcross(){return(this.delInfo&_r)>0}}class Ue{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ue.empty)return Ue.empty}recover(e){let t=0,r=ea(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+oh(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+i+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:sh(l/3,e-a),g=e==a?na:e==d?ta:_r;return(t<0?e!=a:e!=d)&&(g|=ra),new ys(h,g,p)}i+=u-c}return r?e+i:new ys(e+i,0,null)}touches(e,t){let r=0,i=ea(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new Ue(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ue.empty:new Ue(e<0?[0,-e,0]:[0,0,e])}}Ue.empty=new Ue([]);class Qn{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Qn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Qn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new ys(e,i,null)}}const bs=Object.create(null);class Re{getMap(){return Ue.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=bs[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in bs)throw new RangeError("Duplicate use of step JSON ID "+e);return bs[e]=t,t.prototype.jsonID=e,t}}class ye{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ye(e,null)}static fail(e){return new ye(null,e)}static fromReplace(e,t,r,i){try{return ye.ok(e.replace(t,r,i))}catch(s){if(s instanceof Ar)return ye.fail(s.message);throw s}}}function ws(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(ws(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return S.fromArray(r)}class _t extends Re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new N(ws(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return ye.fromReplace(e,this.from,this.to,s)}invert(){return new tt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new _t(t.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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new _t(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("addMark",_t);class tt extends Re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new N(ws(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ye.fromReplace(e,this.from,this.to,r)}invert(){return new _t(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new tt(t.pos,r.pos,this.mark)}merge(e){return e instanceof tt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new tt(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("removeMark",tt);class Vt extends Re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ye.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ye.fromReplace(e,this.pos,this.pos+1,new N(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Vt(this.pos,t.marks[i]);return new Vt(this.pos,this.mark)}}return new an(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Vt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Vt(t.pos,e.markFromJSON(t.mark))}}Re.jsonID("addNodeMark",Vt);class an extends Re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ye.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ye.fromReplace(e,this.pos,this.pos+1,new N(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Vt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new an(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new an(t.pos,e.markFromJSON(t.mark))}}Re.jsonID("removeNodeMark",an);class Se extends Re{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&ks(e,this.from,this.to)?ye.fail("Structure replace would overwrite content"):ye.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ue([this.from,this.to-this.from,this.slice.size])}invert(e){return new Se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Se(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?N.empty:new N(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?N.empty:new N(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Se(t.from,t.to,N.fromJSON(e,t.slice),!!t.structure)}}Re.jsonID("replace",Se);class Ce extends Re{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(ks(e,this.from,this.gapFrom)||ks(e,this.gapTo,this.to)))return ye.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ye.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?ye.fromReplace(e,this.from,this.to,r):ye.fail("Content does not fit in gap")}getMap(){return new Ue([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ce(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new Ce(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ce(t.from,t.to,t.gapFrom,t.gapTo,N.fromJSON(e,t.slice),t.insert,!!t.structure)}}Re.jsonID("replaceAround",Ce);function ks(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function lh(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(p)||(o&&o.to==f&&o.mark.eq(d[g])?o.to=h:i.push(o=new tt(f,h,d[g])));l&&l.to==f?l.to=h:s.push(l=new _t(f,h,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function ah(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof Pr){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&d.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>n.step(new tt(o.from,o.to,o.style)))}function xs(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new Se(l,u,N.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new tt(l,u,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new N(S.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new Se(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(S.empty,!0);n.replace(l,l,new N(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function ch(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function En(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,o,t))return r;if(r==0||i.type.spec.isolating||!ch(i,s,o))break}return null}function uh(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=S.empty,d=0;for(let p=s,g=!1;p>t;p--)g||r.index(p)>0?(g=!0,u=S.from(r.node(p).copy(u)),d++):a--;let f=S.empty,h=0;for(let p=s,g=!1;p>t;p--)g||i.after(p+1)<i.end(p)?(g=!0,f=S.from(i.node(p).copy(f)),h++):c++;n.step(new Ce(a,c,o,l,new N(u.append(f),d,h),u.size-d,!0))}function Ss(n,e,t=null,r=n){let i=dh(n,e),s=i&&fh(r,e);return s?i.map(ia).concat({type:e,attrs:t}).concat(s.map(ia)):null}function ia(n){return{type:n,attrs:null}}function dh(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function fh(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function hh(n,e,t){let r=S.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].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=S.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new Ce(i,s,i,s,new N(r,0,0),t.length,!0))}function ph(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&mh(n.doc,n.mapping.slice(s).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&&oa(n,o,l,s),xs(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new Ce(d,f,d+1,f-1,new N(S.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&sa(n,o,l,s),!1}})}function sa(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function oa(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
|
|
5
|
-
`))}})}function mh(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function gh(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Ce(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new N(S.from(o),0,0),1,!0))}function kt(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function yh(n,e,t=1,r){let i=n.doc.resolve(e),s=S.empty,o=S.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=S.from(i.node(l).copy(s));let u=r&&r[c];o=S.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new Se(e,e,new N(s.append(o),t,t),!0))}function $t(n,e){let t=n.resolve(e),r=t.index();return la(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function bh(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function la(n,e){return!!(n&&e&&!n.isLeaf&&bh(n,e))}function Vr(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):t>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&la(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function wh(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(i);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);oa(n,u.node(),u.before(),l)}o.inlineContent&&xs(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new Se(c,a.map(e+t,-1),N.empty,!0)),r===!0){let u=n.doc.resolve(c);sa(n,u.node(),u.before(),n.steps.length)}return n}function kh(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function aa(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function $r(n,e,t=e,r=N.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return ca(i,s,r)?new Se(e,t,r):new xh(i,s,r).fit()}function ca(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class xh{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=S.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=S.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new N(s,o,l);return e>-1?new Ce(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Se(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Cs(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(o?c.matchType(o.type)||(d=c.fillBefore(S.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Cs(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new N(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Cs(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new N(Zn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new N(Zn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(i){for(let g=0;g<i.childCount;g++)u.push(i.child(g));d=d.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=d.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(d=y,u.push(ua(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=er(this.placed,t,S.from(u)),this.frontier[t].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let w=y.lastChild;this.frontier.push({type:w.type,match:w.contentMatchAt(w.childCount)}),y=w.content}this.unplaced=p?e==0?N.empty:new N(Zn(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new N(Zn(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Es(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Es(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Es(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=er(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=er(this.placed,this.depth,S.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=er(this.placed,this.frontier.length,t))}}function Zn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Zn(n.firstChild.content,e-1,t)))}function er(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(er(n.lastChild.content,e-1,t)))}function Cs(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function ua(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,ua(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(S.empty,!0)))),n.copy(r)}function Es(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!Sh(t,s.content,o)?l:null}function Sh(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Ch(n){return n.spec.defining||n.spec.definingForContent}function Eh(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(ca(i,s,r))return n.step(new Se(e,t,r));let o=fa(i,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Ch(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],w=!0;y<0&&(w=!1,y=-y);let k=i.node(y-1),C=i.index(y-1);if(k.canReplaceWith(C,C,p.type,p.marks))return n.replace(i.before(y),w?s.after(y):t,new N(da(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function da(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(da(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(S.empty,!0))}return n}function Mh(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=kh(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new N(S.from(r),0,0))}function vh(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=fa(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function fa(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class Mn extends Re{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return ye.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return ye.fromReplace(e,this.pos,this.pos+1,new N(S.from(i),0,t.isLeaf?0:1))}getMap(){return Ue.empty}invert(e){return new Mn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Mn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Mn(t.pos,t.attr,t.value)}}Re.jsonID("attr",Mn);class tr extends Re{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return ye.ok(r)}getMap(){return Ue.empty}invert(e){return new tr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new tr(t.attr,t.value)}}Re.jsonID("docAttr",tr);let vn=class extends Error{};vn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},vn.prototype=Object.create(Error.prototype),vn.prototype.constructor=vn,vn.prototype.name="TransformError";class ha{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Qn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new vn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=N.empty){let i=$r(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new N(S.from(r),0,0))}delete(e,t){return this.replace(e,t,N.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Eh(this,e,t,r),this}replaceRangeWith(e,t,r){return Mh(this,e,t,r),this}deleteRange(e,t){return vh(this,e,t),this}lift(e,t){return uh(this,e,t),this}join(e,t=1){return wh(this,e,t),this}wrap(e,t){return hh(this,e,t),this}setBlockType(e,t=e,r,i=null){return ph(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return gh(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Mn(e,t,r)),this}setDocAttribute(e,t){return this.step(new tr(e,t)),this}addNodeMark(e,t){return this.step(new Vt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof ne)t.isInSet(r.marks)&&this.step(new an(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new an(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return yh(this,e,t,r),this}addMark(e,t,r){return lh(this,e,t,r),this}removeMark(e,t,r){return ah(this,e,t,r),this}clearIncompatible(e,t,r){return xs(this,e,t,r),this}}const Ms=Object.create(null);class H{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new pa(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=N.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?N.empty:t),l==0&&ya(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),ya(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new F(e):Tn(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?Tn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Tn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new We(e.node(0))}static atStart(e){return Tn(e,e,0,0,1)||new We(e)}static atEnd(e){return Tn(e,e,e.content.size,e.childCount,-1)||new We(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ms[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ms)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ms[e]=t,t.prototype.jsonID=e,t}getBookmark(){return F.between(this.$anchor,this.$head).getBookmark()}}H.prototype.visible=!0;class pa{constructor(e,t){this.$from=e,this.$to=t}}let ma=!1;function ga(n){!ma&&!n.parent.inlineContent&&(ma=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class F extends H{constructor(e,t=e){ga(e),ga(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return H.near(r);let i=e.resolve(t.map(this.anchor));return new F(i.parent.inlineContent?i:r,r)}replace(e,t=N.empty){if(super.replace(e,t),t==N.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof F&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new zr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new F(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=H.findFrom(t,r,!0)||H.findFrom(t,-r,!0);if(s)t=s.$head;else return H.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(H.findFrom(e,-r,!0)||H.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new F(e,t)}}H.jsonID("text",F);class zr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new zr(e.map(this.anchor),e.map(this.head))}resolve(e){return F.between(e.resolve(this.anchor),e.resolve(this.head))}}class V extends H{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?H.near(s):new V(s)}content(){return new N(S.from(this.node),0,0)}eq(e){return e instanceof V&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new vs(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new V(e.resolve(t.anchor))}static create(e,t){return new V(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}V.prototype.visible=!1,H.jsonID("node",V);class vs{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new zr(r,r):new vs(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&V.isSelectable(r)?new V(t):H.near(t)}}class We extends H{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=N.empty){if(t==N.empty){e.delete(0,e.doc.content.size);let r=H.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new We(e)}map(e){return new We(e)}eq(e){return e instanceof We}getBookmark(){return Th}}H.jsonID("all",We);const Th={map(){return this},resolve(n){return new We(n)}};function Tn(n,e,t,r,i,s=!1){if(e.inlineContent)return F.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&V.isSelectable(l))return V.create(n,t-(i<0?l.nodeSize:0))}else{let a=Tn(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function ya(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof Se||i instanceof Ce))return;let s=n.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(H.near(n.doc.resolve(o),t))}const ba=1,Hr=2,wa=4;class Oh extends ha{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.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ba)&~Hr,this.storedMarks=null,this}get selectionSet(){return(this.updated&ba)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Hr,this}ensureMarks(e){return ne.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&Hr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Hr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ne.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),this.selection.empty||this.setSelection(H.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=wa,this}get scrolledIntoView(){return(this.updated&wa)>0}}function ka(n,e){return!e||!n?n:n.bind(e)}class nr{constructor(e,t,r){this.name=e,this.init=ka(t.init,r),this.apply=ka(t.apply,r)}}const Nh=[new nr("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new nr("selection",{init(n,e){return n.selection||H.atStart(e.doc)},apply(n){return n.selection}}),new nr("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new nr("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Ts{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Nh.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new nr(r.key,r.spec.state,r))})}}class On{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[o].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<o?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new On(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Oh(this)}static create(e){let t=new Ts(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new On(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new Ts(this.schema,e.plugins),r=t.fields,i=new On(t);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Ts(e.schema,e.plugins),s=new On(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Lt.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=H.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function xa(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=xa(i,e,{})),t[r]=i}return t}class se{constructor(e){this.spec=e,this.props={},e.props&&xa(e.props,this,this.props),this.key=e.key?e.key.key:Sa("plugin")}getState(e){return e[this.key]}}const Os=Object.create(null);function Sa(n){return n in Os?n+"$"+ ++Os[n]:(Os[n]=0,n+"$")}class le{constructor(e="key"){this.key=Sa(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Oe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Nn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Ns=null;const xt=function(n,e,t){let r=Ns||(Ns=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Ah=function(){Ns=null},cn=function(n,e,t,r){return t&&(Ca(n,e,t,r,-1)||Ca(n,e,t,r,1))},Rh=/^(img|br|input|textarea|hr)$/i;function Ca(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Je(n))){let o=n.parentNode;if(!o||o.nodeType!=1||rr(n)||Rh.test(n.nodeName)||n.contentEditable=="false")return!1;e=Oe(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?Je(n):0}else return!1}}function Je(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Dh(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Je(n)}else if(n.parentNode&&!rr(n))e=Oe(n),n=n.parentNode;else return null}}function Ih(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!rr(n))e=Oe(n)+1,n=n.parentNode;else return null}}function Ph(n,e,t){for(let r=e==0,i=e==Je(n);r||i;){if(n==t)return!0;let s=Oe(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Je(n)}}function rr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Fr=function(n){return n.focusNode&&cn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function un(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Lh(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Bh(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Je(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Je(r.startContainer),r.startOffset)}}}const lt=typeof navigator<"u"?navigator:null,Ea=typeof document<"u"?document:null,zt=lt&<.userAgent||"",As=/Edge\/(\d+)/.exec(zt),Ma=/MSIE \d/.exec(zt),Rs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(zt),He=!!(Ma||Rs||As),Ht=Ma?document.documentMode:Rs?+Rs[1]:As?+As[1]:0,Ge=!He&&/gecko\/(\d+)/i.test(zt);Ge&&+(/Firefox\/(\d+)/.exec(zt)||[0,0])[1];const Ds=!He&&/Chrome\/(\d+)/.exec(zt),De=!!Ds,va=Ds?+Ds[1]:0,Be=!He&&!!lt&&/Apple Computer/.test(lt.vendor),An=Be&&(/Mobile\/\w+/.test(zt)||!!lt&<.maxTouchPoints>2),Ye=An||(lt?/Mac/.test(lt.platform):!1),_h=lt?/Win/.test(lt.platform):!1,St=/Android \d/.test(zt),ir=!!Ea&&"webkitFontSmoothing"in Ea.documentElement.style,Vh=ir?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function $h(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ct(n,e){return typeof n=="number"?n:n[e]}function zh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Ta(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Nn(o);continue}let l=o,a=l==s.body,c=a?$h(s):zh(l),u=0,d=0;if(e.top<c.top+Ct(r,"top")?d=-(c.top-e.top+Ct(i,"top")):e.bottom>c.bottom-Ct(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Ct(i,"top")-c.top:e.bottom-c.bottom+Ct(i,"bottom")),e.left<c.left+Ct(r,"left")?u=-(c.left-e.left+Ct(i,"left")):e.right>c.right-Ct(r,"right")&&(u=e.right-c.right+Ct(i,"right")),u||d)if(a)s.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,y=l.scrollTop-p;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Nn(o)}}function Hh(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Oa(n.dom)}}function Oa(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Nn(r));return e}function Fh({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Na(t,r==0?0:r-e)}function Na(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Rn=null;function jh(n){if(n.setActive)return n.setActive();if(Rn)return n.focus(Rn);let e=Oa(n);n.focus(Rn==null?{get preventScroll(){return Rn={preventScroll:!0},!0}}:void 0),Rn||(Rn=!1,Na(e,0))}function Aa(n,e){let t,r=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=xt(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){t=u,r=g,i=g&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&g&&(s=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?Uh(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Aa(t,i)}function Uh(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Ft(r,1);if(s.top!=s.bottom&&Is(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Is(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Wh(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Kh(n,e,t){let{node:r,offset:i}=Aa(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function qh(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!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)&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function Ra(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Is(e,c))return Ra(o,e,c)}}if((s=(s+1)%r)==i)break}return n}function Jh(n,e){let t=n.dom.ownerDocument,r,i=0,s=Bh(t,e.left,e.top);s&&({node:r,offset:i}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!Is(e,c)||(o=Ra(n.dom,e,c),!o))return null}if(Be)for(let c=o;r&&c;c=Nn(c))c.draggable&&(r=void 0);if(o=Wh(o,e),r){if(Ge&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;ir&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=qh(n,r,i,e))}l==null&&(l=Kh(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Da(n){return n.top<n.bottom||n.left<n.right}function Ft(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Da(r))return r}return Array.prototype.find.call(t,Da)||n.getBoundingClientRect()}const Gh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ia(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=ir||Ge;if(r.nodeType==3)if(o&&(Gh.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=Ft(xt(r,i,i),t);if(Ge&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Ft(xt(r,i-1,i-1),-1);if(c.top==a.top){let u=Ft(xt(r,i,i+1),-1);if(u.top!=a.top)return sr(u,u.left<c.left)}}return a}else{let a=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,sr(Ft(xt(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Je(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Ps(a.getBoundingClientRect(),!1)}if(s==null&&i<Je(r)){let a=r.childNodes[i];if(a.nodeType==1)return Ps(a.getBoundingClientRect(),!0)}return Ps(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Je(r))){let a=r.childNodes[i-1],c=a.nodeType==3?xt(a,Je(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return sr(Ft(c,1),!1)}if(s==null&&i<Je(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?xt(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return sr(Ft(c,-1),!0)}return sr(Ft(r.nodeType==3?xt(r):r,-t),t>=0)}function sr(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ps(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Pa(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Yh(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Pa(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Ia(n,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=xt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const Xh=/[\u0590-\u08ac]/;function Qh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return l?!Xh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Pa(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:g}=n.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):r.pos==r.start()||r.pos==r.end()}let La=null,Ba=null,_a=!1;function Zh(n,e,t){return La==e&&Ba==t?_a:(La=e,Ba=t,_a=t=="up"||t=="down"?Yh(n,e,t):Qh(n,e,t))}const Xe=0,Va=1,dn=2,at=3;class or{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Xe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Oe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof Ha){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof $a&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Oe(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Oe(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-1&&e<=c){let u=o+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Oe(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=Oe(d.dom);break}t+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let g=this.children[h],y=p+g.size;if(s>p&&o<y)return g.setSelection(e-p-g.border,t-p-g.border,r,i);p=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Ge||Be)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
|
|
6
|
-
`),d&&p==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:Oe(y)+1});break}let w=g.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{let g=h.childNodes[p-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Ge&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||d&&Be)&&cn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&cn(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(d&&Ge)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){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,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?dn:Va,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=at:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?dn:at}r=o}this.dirty=dn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?dn:Va;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class $a extends or{constructor(e,t,r,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Xe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class ep extends or{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class fn extends or{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=ln.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new fn(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&at||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=at&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Xe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xe}}slice(e,t,r){let i=fn.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=Bs(s,t,o,r)),e>0&&(s=Bs(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class jt extends or{constructor(e,t,r,i,s,o,l,a,c){super(e,[],s,o),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=ln.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Ua(u,r,t),c?a=new tp(e,t,r,i,u,d||null,f,c,s,o+1):t.isText?new jr(e,t,r,i,u,f,s):new jt(e,t,r,i,u,d||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,r){return this.dirty==Xe&&e.eq(this.node)&&Ur(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new rp(this,o&&o.node,e);op(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?ne.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,i)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,i)||a.addNode(c,u,d,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==dn)&&(o&&this.protectLocalComposition(e,o),Fa(this.contentDOM,this.children,e),An&&lp(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof F)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=ap(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new ep(this,s,t,i);e.input.compositionNodes.push(o),this.children=Bs(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==at||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Xe}updateOuterDeco(e){if(Ur(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ja(this.dom,this.nodeDOM,Ls(this.outerDeco,this.node,t),Ls(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.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 za(n,e,t,r,i){Ua(r,e,n);let s=new jt(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class jr extends jt{constructor(e,t,r,i,s,o,l){super(e,t,r,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==at||this.dirty!=Xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Xe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Xe,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new jr(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=at)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ha extends or{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class tp extends jt{constructor(e,t,r,i,s,o,l,a,c,u){super(e,t,r,i,s,o,l,c,u),this.spec=a}update(e,t,r,i){if(this.dirty==at)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Fa(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=Wa(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof fn){let a=r?r.previousSibling:n.lastChild;Fa(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Wa(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const lr=function(n){n&&(this.nodeName=n)};lr.prototype=Object.create(null);const hn=[new lr];function Ls(n,e,t){if(n.length==0)return hn;let r=t?hn[0]:new lr,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new lr(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(r=new lr(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function ja(n,e,t,r){if(t==hn&&r==hn)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=hn[0]),i=a}np(i,l||hn[0],o)}return i}function np(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Ua(n,e,t){return ja(n,n,hn,Ls(e,t,n.nodeType!=1))}function Ur(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Wa(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class rp{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ip(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Xe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=fn.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let o=this.top.children[i];return o.dirty==at&&o.dom==o.contentDOM&&(o.dirty=dn),o.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof jt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=at&&Ur(t,a.outerDeco));if(!f&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=dn,d.updateChildren(i,o+1),d.dirty=Xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ur(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=jt.create(this.top,t,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,i,s){let o=jt.create(this.top,e,t,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new $a(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof fn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof jr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Be||De)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Ha(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function ip(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof fn)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function sp(n,e){return n.type.side-e.type.side}function op(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,i,e.forChild(s,u),c),s+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<i.length&&i[o].to==s;){let y=i[o++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(sp);for(let y=0;y<d.length;y++)t(d[y],c,!!a)}else t(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=s&&l.splice(y--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let y=p;o<i.length&&i[o].from<y&&(y=i[o].from);for(let w=0;w<l.length;w++)l[w].to<y&&(y=l[w].to);y<p&&(a=f.cut(y-s),f=f.cut(0,y-s),p=y,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();r(f,g,e.forChild(s,f),h),s=p}}function lp(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function ap(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let o=n.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<n.childCount;){let c=n.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Bs(n,e,t,r,i){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,u=l+=a.size;c>=t||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),i&&(s.push(i),i=void 0),u>t&&s.push(a.slice(t-c,a.size,r)))}return s}function _s(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Fr(t)){for(a=o;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&V.isSelectable(d)&&i.parent&&!(d.isInline&&Ph(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new V(o==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,f=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);d=Math.min(d,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=f==n.state.selection.anchor?[f,d]:[d,f],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=$s(n,u,l,d)}return c}function Ka(n){return n.editable?n.hasFocus():Za(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Et(n,e=!1){let t=n.state.selection;if(Ya(n,t),!!Ka(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&De){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&cn(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)up(n);else{let{anchor:r,head:i}=t,s,o;qa&&!(t instanceof F)&&(t.$from.parent.inlineContent||(s=Ja(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Ja(n,t.to))),n.docView.setSelection(r,i,n,e),qa&&(s&&Ga(s),o&&Ga(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&cp(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const qa=Be||De&&va<63;function Ja(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Be&&i&&i.contentEditable=="false")return Vs(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Vs(i);if(s)return Vs(s)}}function Vs(n){return n.contentEditable="true",Be&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ga(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function cp(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ka(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function up(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,Oe(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&He&&Ht<=11&&(t.disabled=!0,t.disabled=!1)}function Ya(n,e){if(e instanceof V){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Xa(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Xa(n)}function Xa(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function $s(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||F.between(e,t,r)}function Qa(n){return n.editable&&!n.hasFocus()?!1:Za(n)}function Za(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function dp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return cn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function zs(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&H.findFrom(s,e)}function Ut(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ec(n,e,t){let r=n.state.selection;if(r instanceof F)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Ut(n,new F(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=zs(n.state,e);return i&&i instanceof V?Ut(n,i):!1}else if(!(Ye&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?V.isSelectable(s)?Ut(n,new V(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):ir?Ut(n,new F(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof V&&r.node.isInline)return Ut(n,new F(e>0?r.$to:r.$from));{let i=zs(n.state,e);return i?Ut(n,i):!1}}}function Wr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ar(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Dn(n,e){return e<0?fp(n):hp(n)}function fp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Ge&&t.nodeType==1&&r<Wr(t)&&ar(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(ar(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(tc(t))break;{let l=t.previousSibling;for(;l&&ar(l,-1);)i=t.parentNode,s=Oe(l),l=l.previousSibling;if(l)t=l,r=Wr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Hs(n,t,r):i&&Hs(n,i,s)}function hp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Wr(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(ar(l,1))s=t,o=++r;else break}else{if(tc(t))break;{let l=t.nextSibling;for(;l&&ar(l,1);)s=l.parentNode,o=Oe(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=Wr(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&Hs(n,s,o)}function tc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function pp(n,e){for(;n&&e==n.childNodes.length&&!rr(n);)e=Oe(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function mp(n,e){for(;n&&!e&&!rr(n);)e=Oe(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Hs(n,e,t){if(e.nodeType!=3){let s,o;(o=pp(e,t))?(e=o,t=0):(s=mp(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Fr(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&Et(n)},50)}function nc(n,e){let t=n.state.doc.resolve(e);if(!(De||_h)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function rc(n,e,t){let r=n.state.selection;if(r instanceof F&&!r.empty||t.indexOf("s")>-1||Ye&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=zs(n.state,e);if(o&&o instanceof V)return Ut(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof We?H.near(o,e):H.findFrom(o,e);return l?Ut(n,l):!1}return!1}function ic(n,e){if(!(n.state.selection instanceof F))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function sc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function gp(n){if(!Be||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;sc(n,r,"true"),setTimeout(()=>sc(n,r,"false"),20)}return!1}function yp(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function bp(n,e){let t=e.keyCode,r=yp(e);if(t==8||Ye&&t==72&&r=="c")return ic(n,-1)||Dn(n,-1);if(t==46&&!e.shiftKey||Ye&&t==68&&r=="c")return ic(n,1)||Dn(n,1);if(t==13||t==27)return!0;if(t==37||Ye&&t==66&&r=="c"){let i=t==37?nc(n,n.state.selection.from)=="ltr"?-1:1:-1;return ec(n,i,r)||Dn(n,i)}else if(t==39||Ye&&t==70&&r=="c"){let i=t==39?nc(n,n.state.selection.from)=="ltr"?1:-1:1;return ec(n,i,r)||Dn(n,i)}else{if(t==38||Ye&&t==80&&r=="c")return rc(n,-1,r)||Dn(n,-1);if(t==40||Ye&&t==78&&r=="c")return gp(n)||rc(n,1,r)||Dn(n,1);if(r==(Ye?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Fs(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||ln.fromSchema(n.state.schema),l=hc(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=dc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
4
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=ne.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Gl(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Kl(e,s,o.options);o.options&Xn&&o.content.length==0&&(l|=Xn);let a=ne.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Gl(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Lr(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Yn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function th(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Wl.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function nh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Jl(n){let e={};for(let t in n)e[t]=n[t];return e}function Gl(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}class ln{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=gs(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=Br(gs(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Br(gs(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Br(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ln(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Yl(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Yl(e.marks)}}function Yl(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function gs(n){return n.document||window.document}const Xl=new WeakMap;function rh(n){let e=Xl.get(n);return e===void 0&&Xl.set(n,e=ih(n)),e}function ih(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function Br(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=rh(r))&&s.indexOf(e)>-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 o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=Br(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Ql=65535,Zl=Math.pow(2,16);function sh(n,e){return n+e*Zl}function ea(n){return n&Ql}function oh(n){return(n-(n&Ql))/Zl}const ta=1,na=2,Vr=4,ra=8;class ys{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&ra)>0}get deletedBefore(){return(this.delInfo&(ta|Vr))>0}get deletedAfter(){return(this.delInfo&(na|Vr))>0}get deletedAcross(){return(this.delInfo&Vr)>0}}class Ue{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ue.empty)return Ue.empty}recover(e){let t=0,r=ea(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+oh(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+i+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:sh(l/3,e-a),g=e==a?na:e==d?ta:Vr;return(t<0?e!=a:e!=d)&&(g|=ra),new ys(h,g,p)}i+=u-c}return r?e+i:new ys(e+i,0,null)}touches(e,t){let r=0,i=ea(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new Ue(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ue.empty:new Ue(e<0?[0,-e,0]:[0,0,e])}}Ue.empty=new Ue([]);class Qn{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Qn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Qn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new ys(e,i,null)}}const bs=Object.create(null);class Re{getMap(){return Ue.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=bs[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in bs)throw new RangeError("Duplicate use of step JSON ID "+e);return bs[e]=t,t.prototype.jsonID=e,t}}class ye{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ye(e,null)}static fail(e){return new ye(null,e)}static fromReplace(e,t,r,i){try{return ye.ok(e.replace(t,r,i))}catch(s){if(s instanceof Ar)return ye.fail(s.message);throw s}}}function ws(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(ws(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return S.fromArray(r)}class Vt extends Re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new N(ws(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return ye.fromReplace(e,this.from,this.to,s)}invert(){return new tt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Vt(t.pos,r.pos,this.mark)}merge(e){return e instanceof Vt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Vt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Vt(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("addMark",Vt);class tt extends Re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new N(ws(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ye.fromReplace(e,this.from,this.to,r)}invert(){return new Vt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new tt(t.pos,r.pos,this.mark)}merge(e){return e instanceof tt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new tt(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("removeMark",tt);class $t extends Re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ye.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ye.fromReplace(e,this.pos,this.pos+1,new N(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new $t(this.pos,t.marks[i]);return new $t(this.pos,this.mark)}}return new an(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new $t(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new $t(t.pos,e.markFromJSON(t.mark))}}Re.jsonID("addNodeMark",$t);class an extends Re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ye.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ye.fromReplace(e,this.pos,this.pos+1,new N(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new $t(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new an(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new an(t.pos,e.markFromJSON(t.mark))}}Re.jsonID("removeNodeMark",an);class Se extends Re{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&ks(e,this.from,this.to)?ye.fail("Structure replace would overwrite content"):ye.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ue([this.from,this.to-this.from,this.slice.size])}invert(e){return new Se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Se(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?N.empty:new N(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?N.empty:new N(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Se(t.from,t.to,N.fromJSON(e,t.slice),!!t.structure)}}Re.jsonID("replace",Se);class Ce extends Re{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(ks(e,this.from,this.gapFrom)||ks(e,this.gapTo,this.to)))return ye.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ye.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?ye.fromReplace(e,this.from,this.to,r):ye.fail("Content does not fit in gap")}getMap(){return new Ue([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ce(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new Ce(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ce(t.from,t.to,t.gapFrom,t.gapTo,N.fromJSON(e,t.slice),t.insert,!!t.structure)}}Re.jsonID("replaceAround",Ce);function ks(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function lh(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(p)||(o&&o.to==f&&o.mark.eq(d[g])?o.to=h:i.push(o=new tt(f,h,d[g])));l&&l.to==f?l.to=h:s.push(l=new Vt(f,h,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function ah(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof Pr){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&d.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>n.step(new tt(o.from,o.to,o.style)))}function xs(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new Se(l,u,N.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new tt(l,u,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new N(S.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new Se(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(S.empty,!0);n.replace(l,l,new N(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function ch(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function En(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,o,t))return r;if(r==0||i.type.spec.isolating||!ch(i,s,o))break}return null}function uh(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=S.empty,d=0;for(let p=s,g=!1;p>t;p--)g||r.index(p)>0?(g=!0,u=S.from(r.node(p).copy(u)),d++):a--;let f=S.empty,h=0;for(let p=s,g=!1;p>t;p--)g||i.after(p+1)<i.end(p)?(g=!0,f=S.from(i.node(p).copy(f)),h++):c++;n.step(new Ce(a,c,o,l,new N(u.append(f),d,h),u.size-d,!0))}function Ss(n,e,t=null,r=n){let i=dh(n,e),s=i&&fh(r,e);return s?i.map(ia).concat({type:e,attrs:t}).concat(s.map(ia)):null}function ia(n){return{type:n,attrs:null}}function dh(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function fh(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function hh(n,e,t){let r=S.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].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=S.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new Ce(i,s,i,s,new N(r,0,0),t.length,!0))}function ph(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&mh(n.doc,n.mapping.slice(s).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&&oa(n,o,l,s),xs(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new Ce(d,f,d+1,f-1,new N(S.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&sa(n,o,l,s),!1}})}function sa(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function oa(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
|
|
5
|
+
`))}})}function mh(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function gh(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Ce(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new N(S.from(o),0,0),1,!0))}function kt(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function yh(n,e,t=1,r){let i=n.doc.resolve(e),s=S.empty,o=S.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=S.from(i.node(l).copy(s));let u=r&&r[c];o=S.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new Se(e,e,new N(s.append(o),t,t),!0))}function zt(n,e){let t=n.resolve(e),r=t.index();return la(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function bh(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function la(n,e){return!!(n&&e&&!n.isLeaf&&bh(n,e))}function $r(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):t>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&la(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function wh(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(i);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);oa(n,u.node(),u.before(),l)}o.inlineContent&&xs(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new Se(c,a.map(e+t,-1),N.empty,!0)),r===!0){let u=n.doc.resolve(c);sa(n,u.node(),u.before(),n.steps.length)}return n}function kh(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function aa(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function zr(n,e,t=e,r=N.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return ca(i,s,r)?new Se(e,t,r):new xh(i,s,r).fit()}function ca(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class xh{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=S.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=S.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new N(s,o,l);return e>-1?new Ce(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Se(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Cs(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(o?c.matchType(o.type)||(d=c.fillBefore(S.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Cs(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new N(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Cs(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new N(Zn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new N(Zn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(i){for(let g=0;g<i.childCount;g++)u.push(i.child(g));d=d.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=d.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(d=y,u.push(ua(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=er(this.placed,t,S.from(u)),this.frontier[t].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let w=y.lastChild;this.frontier.push({type:w.type,match:w.contentMatchAt(w.childCount)}),y=w.content}this.unplaced=p?e==0?N.empty:new N(Zn(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new N(Zn(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Es(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Es(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Es(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=er(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=er(this.placed,this.depth,S.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=er(this.placed,this.frontier.length,t))}}function Zn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Zn(n.firstChild.content,e-1,t)))}function er(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(er(n.lastChild.content,e-1,t)))}function Cs(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function ua(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,ua(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(S.empty,!0)))),n.copy(r)}function Es(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!Sh(t,s.content,o)?l:null}function Sh(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Ch(n){return n.spec.defining||n.spec.definingForContent}function Eh(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(ca(i,s,r))return n.step(new Se(e,t,r));let o=fa(i,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Ch(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],w=!0;y<0&&(w=!1,y=-y);let k=i.node(y-1),C=i.index(y-1);if(k.canReplaceWith(C,C,p.type,p.marks))return n.replace(i.before(y),w?s.after(y):t,new N(da(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function da(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(da(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(S.empty,!0))}return n}function Mh(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=kh(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new N(S.from(r),0,0))}function vh(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=fa(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function fa(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class Mn extends Re{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return ye.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return ye.fromReplace(e,this.pos,this.pos+1,new N(S.from(i),0,t.isLeaf?0:1))}getMap(){return Ue.empty}invert(e){return new Mn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Mn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Mn(t.pos,t.attr,t.value)}}Re.jsonID("attr",Mn);class tr extends Re{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return ye.ok(r)}getMap(){return Ue.empty}invert(e){return new tr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new tr(t.attr,t.value)}}Re.jsonID("docAttr",tr);let vn=class extends Error{};vn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},vn.prototype=Object.create(Error.prototype),vn.prototype.constructor=vn,vn.prototype.name="TransformError";class ha{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Qn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new vn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=N.empty){let i=zr(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new N(S.from(r),0,0))}delete(e,t){return this.replace(e,t,N.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Eh(this,e,t,r),this}replaceRangeWith(e,t,r){return Mh(this,e,t,r),this}deleteRange(e,t){return vh(this,e,t),this}lift(e,t){return uh(this,e,t),this}join(e,t=1){return wh(this,e,t),this}wrap(e,t){return hh(this,e,t),this}setBlockType(e,t=e,r,i=null){return ph(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return gh(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Mn(e,t,r)),this}setDocAttribute(e,t){return this.step(new tr(e,t)),this}addNodeMark(e,t){return this.step(new $t(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof ne)t.isInSet(r.marks)&&this.step(new an(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new an(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return yh(this,e,t,r),this}addMark(e,t,r){return lh(this,e,t,r),this}removeMark(e,t,r){return ah(this,e,t,r),this}clearIncompatible(e,t,r){return xs(this,e,t,r),this}}const Ms=Object.create(null);class H{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new pa(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=N.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?N.empty:t),l==0&&ya(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),ya(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new F(e):Tn(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?Tn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Tn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new We(e.node(0))}static atStart(e){return Tn(e,e,0,0,1)||new We(e)}static atEnd(e){return Tn(e,e,e.content.size,e.childCount,-1)||new We(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ms[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ms)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ms[e]=t,t.prototype.jsonID=e,t}getBookmark(){return F.between(this.$anchor,this.$head).getBookmark()}}H.prototype.visible=!0;class pa{constructor(e,t){this.$from=e,this.$to=t}}let ma=!1;function ga(n){!ma&&!n.parent.inlineContent&&(ma=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class F extends H{constructor(e,t=e){ga(e),ga(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return H.near(r);let i=e.resolve(t.map(this.anchor));return new F(i.parent.inlineContent?i:r,r)}replace(e,t=N.empty){if(super.replace(e,t),t==N.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof F&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new _r(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new F(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=H.findFrom(t,r,!0)||H.findFrom(t,-r,!0);if(s)t=s.$head;else return H.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(H.findFrom(e,-r,!0)||H.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new F(e,t)}}H.jsonID("text",F);class _r{constructor(e,t){this.anchor=e,this.head=t}map(e){return new _r(e.map(this.anchor),e.map(this.head))}resolve(e){return F.between(e.resolve(this.anchor),e.resolve(this.head))}}class $ extends H{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?H.near(s):new $(s)}content(){return new N(S.from(this.node),0,0)}eq(e){return e instanceof $&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new vs(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new $(e.resolve(t.anchor))}static create(e,t){return new $(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}$.prototype.visible=!1,H.jsonID("node",$);class vs{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new _r(r,r):new vs(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&$.isSelectable(r)?new $(t):H.near(t)}}class We extends H{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=N.empty){if(t==N.empty){e.delete(0,e.doc.content.size);let r=H.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new We(e)}map(e){return new We(e)}eq(e){return e instanceof We}getBookmark(){return Th}}H.jsonID("all",We);const Th={map(){return this},resolve(n){return new We(n)}};function Tn(n,e,t,r,i,s=!1){if(e.inlineContent)return F.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&$.isSelectable(l))return $.create(n,t-(i<0?l.nodeSize:0))}else{let a=Tn(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function ya(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof Se||i instanceof Ce))return;let s=n.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(H.near(n.doc.resolve(o),t))}const ba=1,Hr=2,wa=4;class Oh extends ha{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.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ba)&~Hr,this.storedMarks=null,this}get selectionSet(){return(this.updated&ba)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Hr,this}ensureMarks(e){return ne.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&Hr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Hr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ne.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),this.selection.empty||this.setSelection(H.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=wa,this}get scrolledIntoView(){return(this.updated&wa)>0}}function ka(n,e){return!e||!n?n:n.bind(e)}class nr{constructor(e,t,r){this.name=e,this.init=ka(t.init,r),this.apply=ka(t.apply,r)}}const Nh=[new nr("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new nr("selection",{init(n,e){return n.selection||H.atStart(e.doc)},apply(n){return n.selection}}),new nr("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new nr("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Ts{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Nh.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new nr(r.key,r.spec.state,r))})}}class On{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[o].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<o?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new On(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Oh(this)}static create(e){let t=new Ts(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new On(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new Ts(this.schema,e.plugins),r=t.fields,i=new On(t);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Ts(e.schema,e.plugins),s=new On(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Lt.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=H.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function xa(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=xa(i,e,{})),t[r]=i}return t}class se{constructor(e){this.spec=e,this.props={},e.props&&xa(e.props,this,this.props),this.key=e.key?e.key.key:Sa("plugin")}getState(e){return e[this.key]}}const Os=Object.create(null);function Sa(n){return n in Os?n+"$"+ ++Os[n]:(Os[n]=0,n+"$")}class le{constructor(e="key"){this.key=Sa(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Oe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Nn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Ns=null;const xt=function(n,e,t){let r=Ns||(Ns=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Ah=function(){Ns=null},cn=function(n,e,t,r){return t&&(Ca(n,e,t,r,-1)||Ca(n,e,t,r,1))},Rh=/^(img|br|input|textarea|hr)$/i;function Ca(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Je(n))){let o=n.parentNode;if(!o||o.nodeType!=1||rr(n)||Rh.test(n.nodeName)||n.contentEditable=="false")return!1;e=Oe(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?Je(n):0}else return!1}}function Je(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Dh(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Je(n)}else if(n.parentNode&&!rr(n))e=Oe(n),n=n.parentNode;else return null}}function Ih(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!rr(n))e=Oe(n)+1,n=n.parentNode;else return null}}function Ph(n,e,t){for(let r=e==0,i=e==Je(n);r||i;){if(n==t)return!0;let s=Oe(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Je(n)}}function rr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Fr=function(n){return n.focusNode&&cn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function un(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Lh(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Bh(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Je(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Je(r.startContainer),r.startOffset)}}}const lt=typeof navigator<"u"?navigator:null,Ea=typeof document<"u"?document:null,_t=lt&<.userAgent||"",As=/Edge\/(\d+)/.exec(_t),Ma=/MSIE \d/.exec(_t),Rs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(_t),He=!!(Ma||Rs||As),Ht=Ma?document.documentMode:Rs?+Rs[1]:As?+As[1]:0,Ge=!He&&/gecko\/(\d+)/i.test(_t);Ge&&+(/Firefox\/(\d+)/.exec(_t)||[0,0])[1];const Ds=!He&&/Chrome\/(\d+)/.exec(_t),De=!!Ds,va=Ds?+Ds[1]:0,Be=!He&&!!lt&&/Apple Computer/.test(lt.vendor),An=Be&&(/Mobile\/\w+/.test(_t)||!!lt&<.maxTouchPoints>2),Ye=An||(lt?/Mac/.test(lt.platform):!1),Vh=lt?/Win/.test(lt.platform):!1,St=/Android \d/.test(_t),ir=!!Ea&&"webkitFontSmoothing"in Ea.documentElement.style,$h=ir?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zh(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ct(n,e){return typeof n=="number"?n:n[e]}function _h(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Ta(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Nn(o);continue}let l=o,a=l==s.body,c=a?zh(s):_h(l),u=0,d=0;if(e.top<c.top+Ct(r,"top")?d=-(c.top-e.top+Ct(i,"top")):e.bottom>c.bottom-Ct(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Ct(i,"top")-c.top:e.bottom-c.bottom+Ct(i,"bottom")),e.left<c.left+Ct(r,"left")?u=-(c.left-e.left+Ct(i,"left")):e.right>c.right-Ct(r,"right")&&(u=e.right-c.right+Ct(i,"right")),u||d)if(a)s.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,y=l.scrollTop-p;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Nn(o)}}function Hh(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Oa(n.dom)}}function Oa(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Nn(r));return e}function Fh({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Na(t,r==0?0:r-e)}function Na(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Rn=null;function jh(n){if(n.setActive)return n.setActive();if(Rn)return n.focus(Rn);let e=Oa(n);n.focus(Rn==null?{get preventScroll(){return Rn={preventScroll:!0},!0}}:void 0),Rn||(Rn=!1,Na(e,0))}function Aa(n,e){let t,r=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=xt(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){t=u,r=g,i=g&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&g&&(s=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?Uh(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Aa(t,i)}function Uh(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Ft(r,1);if(s.top!=s.bottom&&Is(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Is(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Wh(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Kh(n,e,t){let{node:r,offset:i}=Aa(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function qh(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!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)&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function Ra(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Is(e,c))return Ra(o,e,c)}}if((s=(s+1)%r)==i)break}return n}function Jh(n,e){let t=n.dom.ownerDocument,r,i=0,s=Bh(t,e.left,e.top);s&&({node:r,offset:i}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!Is(e,c)||(o=Ra(n.dom,e,c),!o))return null}if(Be)for(let c=o;r&&c;c=Nn(c))c.draggable&&(r=void 0);if(o=Wh(o,e),r){if(Ge&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;ir&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=qh(n,r,i,e))}l==null&&(l=Kh(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Da(n){return n.top<n.bottom||n.left<n.right}function Ft(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Da(r))return r}return Array.prototype.find.call(t,Da)||n.getBoundingClientRect()}const Gh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ia(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=ir||Ge;if(r.nodeType==3)if(o&&(Gh.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=Ft(xt(r,i,i),t);if(Ge&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Ft(xt(r,i-1,i-1),-1);if(c.top==a.top){let u=Ft(xt(r,i,i+1),-1);if(u.top!=a.top)return sr(u,u.left<c.left)}}return a}else{let a=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,sr(Ft(xt(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Je(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Ps(a.getBoundingClientRect(),!1)}if(s==null&&i<Je(r)){let a=r.childNodes[i];if(a.nodeType==1)return Ps(a.getBoundingClientRect(),!0)}return Ps(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Je(r))){let a=r.childNodes[i-1],c=a.nodeType==3?xt(a,Je(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return sr(Ft(c,1),!1)}if(s==null&&i<Je(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?xt(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return sr(Ft(c,-1),!0)}return sr(Ft(r.nodeType==3?xt(r):r,-t),t>=0)}function sr(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ps(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Pa(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Yh(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Pa(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Ia(n,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=xt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const Xh=/[\u0590-\u08ac]/;function Qh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return l?!Xh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Pa(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:g}=n.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):r.pos==r.start()||r.pos==r.end()}let La=null,Ba=null,Va=!1;function Zh(n,e,t){return La==e&&Ba==t?Va:(La=e,Ba=t,Va=t=="up"||t=="down"?Yh(n,e,t):Qh(n,e,t))}const Xe=0,$a=1,dn=2,at=3;class or{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Xe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Oe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof Ha){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof za&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Oe(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Oe(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-1&&e<=c){let u=o+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Oe(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=Oe(d.dom);break}t+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let g=this.children[h],y=p+g.size;if(s>p&&o<y)return g.setSelection(e-p-g.border,t-p-g.border,r,i);p=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Ge||Be)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
|
|
6
|
+
`),d&&p==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:Oe(y)+1});break}let w=g.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{let g=h.childNodes[p-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Ge&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||d&&Be)&&cn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&cn(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(d&&Ge)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){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,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?dn:$a,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=at:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?dn:at}r=o}this.dirty=dn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?dn:$a;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class za extends or{constructor(e,t,r,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Xe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class ep extends or{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class fn extends or{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=ln.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new fn(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&at||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=at&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Xe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xe}}slice(e,t,r){let i=fn.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=Bs(s,t,o,r)),e>0&&(s=Bs(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class jt extends or{constructor(e,t,r,i,s,o,l,a,c){super(e,[],s,o),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=ln.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Ua(u,r,t),c?a=new tp(e,t,r,i,u,d||null,f,c,s,o+1):t.isText?new jr(e,t,r,i,u,f,s):new jt(e,t,r,i,u,d||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,r){return this.dirty==Xe&&e.eq(this.node)&&Ur(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new rp(this,o&&o.node,e);op(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?ne.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,i)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,i)||a.addNode(c,u,d,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==dn)&&(o&&this.protectLocalComposition(e,o),Fa(this.contentDOM,this.children,e),An&&lp(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof F)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=ap(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new ep(this,s,t,i);e.input.compositionNodes.push(o),this.children=Bs(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==at||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Xe}updateOuterDeco(e){if(Ur(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ja(this.dom,this.nodeDOM,Ls(this.outerDeco,this.node,t),Ls(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.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 _a(n,e,t,r,i){Ua(r,e,n);let s=new jt(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class jr extends jt{constructor(e,t,r,i,s,o,l){super(e,t,r,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==at||this.dirty!=Xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Xe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Xe,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new jr(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=at)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ha extends or{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class tp extends jt{constructor(e,t,r,i,s,o,l,a,c,u){super(e,t,r,i,s,o,l,c,u),this.spec=a}update(e,t,r,i){if(this.dirty==at)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Fa(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=Wa(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof fn){let a=r?r.previousSibling:n.lastChild;Fa(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Wa(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const lr=function(n){n&&(this.nodeName=n)};lr.prototype=Object.create(null);const hn=[new lr];function Ls(n,e,t){if(n.length==0)return hn;let r=t?hn[0]:new lr,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new lr(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(r=new lr(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function ja(n,e,t,r){if(t==hn&&r==hn)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=hn[0]),i=a}np(i,l||hn[0],o)}return i}function np(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Ua(n,e,t){return ja(n,n,hn,Ls(e,t,n.nodeType!=1))}function Ur(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Wa(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class rp{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ip(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Xe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=fn.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let o=this.top.children[i];return o.dirty==at&&o.dom==o.contentDOM&&(o.dirty=dn),o.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof jt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=at&&Ur(t,a.outerDeco));if(!f&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=dn,d.updateChildren(i,o+1),d.dirty=Xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ur(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=jt.create(this.top,t,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,i,s){let o=jt.create(this.top,e,t,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new za(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof fn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof jr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Be||De)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Ha(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function ip(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof fn)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function sp(n,e){return n.type.side-e.type.side}function op(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,i,e.forChild(s,u),c),s+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<i.length&&i[o].to==s;){let y=i[o++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(sp);for(let y=0;y<d.length;y++)t(d[y],c,!!a)}else t(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=s&&l.splice(y--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let y=p;o<i.length&&i[o].from<y&&(y=i[o].from);for(let w=0;w<l.length;w++)l[w].to<y&&(y=l[w].to);y<p&&(a=f.cut(y-s),f=f.cut(0,y-s),p=y,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();r(f,g,e.forChild(s,f),h),s=p}}function lp(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function ap(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let o=n.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<n.childCount;){let c=n.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Bs(n,e,t,r,i){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,u=l+=a.size;c>=t||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),i&&(s.push(i),i=void 0),u>t&&s.push(a.slice(t-c,a.size,r)))}return s}function Vs(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Fr(t)){for(a=o;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&$.isSelectable(d)&&i.parent&&!(d.isInline&&Ph(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new $(o==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,f=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);d=Math.min(d,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=f==n.state.selection.anchor?[f,d]:[d,f],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=zs(n,u,l,d)}return c}function Ka(n){return n.editable?n.hasFocus():Za(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Et(n,e=!1){let t=n.state.selection;if(Ya(n,t),!!Ka(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&De){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&cn(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)up(n);else{let{anchor:r,head:i}=t,s,o;qa&&!(t instanceof F)&&(t.$from.parent.inlineContent||(s=Ja(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Ja(n,t.to))),n.docView.setSelection(r,i,n,e),qa&&(s&&Ga(s),o&&Ga(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&cp(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const qa=Be||De&&va<63;function Ja(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Be&&i&&i.contentEditable=="false")return $s(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return $s(i);if(s)return $s(s)}}function $s(n){return n.contentEditable="true",Be&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ga(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function cp(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ka(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function up(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,Oe(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&He&&Ht<=11&&(t.disabled=!0,t.disabled=!1)}function Ya(n,e){if(e instanceof $){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Xa(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Xa(n)}function Xa(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function zs(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||F.between(e,t,r)}function Qa(n){return n.editable&&!n.hasFocus()?!1:Za(n)}function Za(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function dp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return cn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function _s(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&H.findFrom(s,e)}function Ut(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ec(n,e,t){let r=n.state.selection;if(r instanceof F)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Ut(n,new F(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=_s(n.state,e);return i&&i instanceof $?Ut(n,i):!1}else if(!(Ye&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?$.isSelectable(s)?Ut(n,new $(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):ir?Ut(n,new F(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof $&&r.node.isInline)return Ut(n,new F(e>0?r.$to:r.$from));{let i=_s(n.state,e);return i?Ut(n,i):!1}}}function Wr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ar(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Dn(n,e){return e<0?fp(n):hp(n)}function fp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Ge&&t.nodeType==1&&r<Wr(t)&&ar(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(ar(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(tc(t))break;{let l=t.previousSibling;for(;l&&ar(l,-1);)i=t.parentNode,s=Oe(l),l=l.previousSibling;if(l)t=l,r=Wr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Hs(n,t,r):i&&Hs(n,i,s)}function hp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Wr(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(ar(l,1))s=t,o=++r;else break}else{if(tc(t))break;{let l=t.nextSibling;for(;l&&ar(l,1);)s=l.parentNode,o=Oe(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=Wr(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&Hs(n,s,o)}function tc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function pp(n,e){for(;n&&e==n.childNodes.length&&!rr(n);)e=Oe(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function mp(n,e){for(;n&&!e&&!rr(n);)e=Oe(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Hs(n,e,t){if(e.nodeType!=3){let s,o;(o=pp(e,t))?(e=o,t=0):(s=mp(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Fr(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&Et(n)},50)}function nc(n,e){let t=n.state.doc.resolve(e);if(!(De||Vh)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function rc(n,e,t){let r=n.state.selection;if(r instanceof F&&!r.empty||t.indexOf("s")>-1||Ye&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=_s(n.state,e);if(o&&o instanceof $)return Ut(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof We?H.near(o,e):H.findFrom(o,e);return l?Ut(n,l):!1}return!1}function ic(n,e){if(!(n.state.selection instanceof F))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function sc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function gp(n){if(!Be||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;sc(n,r,"true"),setTimeout(()=>sc(n,r,"false"),20)}return!1}function yp(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function bp(n,e){let t=e.keyCode,r=yp(e);if(t==8||Ye&&t==72&&r=="c")return ic(n,-1)||Dn(n,-1);if(t==46&&!e.shiftKey||Ye&&t==68&&r=="c")return ic(n,1)||Dn(n,1);if(t==13||t==27)return!0;if(t==37||Ye&&t==66&&r=="c"){let i=t==37?nc(n,n.state.selection.from)=="ltr"?-1:1:-1;return ec(n,i,r)||Dn(n,i)}else if(t==39||Ye&&t==70&&r=="c"){let i=t==39?nc(n,n.state.selection.from)=="ltr"?1:-1:1;return ec(n,i,r)||Dn(n,i)}else{if(t==38||Ye&&t==80&&r=="c")return rc(n,-1,r)||Dn(n,-1);if(t==40||Ye&&t==78&&r=="c")return gp(n)||rc(n,1,r)||Dn(n,1);if(r==(Ye?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Fs(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||ln.fromSchema(n.state.schema),l=hc(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=dc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
7
7
|
|
|
8
8
|
`);return{dom:a,text:f,slice:e}}function oc(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,s||r,n)}),s)return l=new N(S.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
9
|
-
`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",f=>f(e,i,r,n));if(d)l=d;else{let f=i.marks(),{schema:h}=n.state,p=ln.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(h.text(g,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=Sp(t),ir&&Cp(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Bt.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!wp.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Ep(uc(l,+u[1],+u[2]),u[4]);else if(l=N.maxOpen(kp(l.content,i),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=uc(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n,a)}),l}const wp=/^(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 kp(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&ac(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=cc(o[o.length-1],s.length));let u=lc(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return S.from(o)}return n}function lc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function ac(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=ac(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(S.from(lc(t,n,i+1))))}}function cc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,cc(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(S.empty,!0);return n.copy(t.append(r))}function js(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=js(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function uc(n,e,t){return e<n.openStart&&(n=new N(js(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new N(js(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const dc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let fc=null;function hc(){return fc||(fc=document.implementation.createHTMLDocument("title"))}let Us=null;function xp(n){let e=window.trustedTypes;return e?(Us||(Us=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Us.createHTML(n)):n}function Sp(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=hc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&dc[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=xp(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function Cp(n){let e=n.querySelectorAll(De?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Ep(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=S.from(a.create(r[l+1],i)),s++,o++}return new N(i,s,o)}const _e={},Ve={},Mp={touchstart:!0,touchmove:!0};class vp{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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Tp(n){for(let e in _e){let t=_e[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Np(n,r)&&!Ks(n,r)&&(n.editable||!(r.type in Ve))&&t(n,r)},Mp[e]?{passive:!0}:void 0)}Be&&n.dom.addEventListener("input",()=>null),Ws(n)}function Wt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Op(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Ws(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Ks(n,r))})}function Ks(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Np(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Ap(n,e){!Ks(n,e)&&_e[e.type]&&(n.editable||!(e.type in Ve))&&_e[e.type](n,e)}Ve.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!mc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(St&&De&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),An&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,un(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||bp(n,t)?t.preventDefault():Wt(n,"key")},Ve.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},Ve.keypress=(n,e)=>{let t=e;if(mc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ye&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof F)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function Kr(n){return{left:n.clientX,top:n.clientY}}function Rp(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function qs(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function In(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Dp(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&V.isSelectable(r)?(In(n,new V(t)),!0):!1}function Ip(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof V&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(V.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(In(n,V.create(n.state.doc,i)),!0):!1}function Pp(n,e,t,r,i){return qs(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Ip(n,t):Dp(n,t))}function Lp(n,e,t,r){return qs(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Bp(n,e,t,r){return qs(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||_p(n,t,r)}function _p(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(In(n,F.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)In(n,F.create(r,l+1,l+1+o.content.size));else if(V.isSelectable(o))In(n,V.create(r,l));else continue;return!0}}function Js(n){return qr(n)}const pc=Ye?"metaKey":"ctrlKey";_e.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Js(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Rp(t,n.input.lastClick)&&!t[pc]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button};let o=n.posAtCoords(Kr(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Vp(n,o,t,!!r)):(s=="doubleClick"?Lp:Bp)(n,o.pos,o.inside,t)?t.preventDefault():Wt(n,"pointer"))};class Vp{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[pc],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,o=u.depth?u.before():0}const l=i?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&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof V&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ge&&!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)),Wt(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(()=>Et(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Kr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Wt(this.view,"pointer"):Pp(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Be&&this.mightDrag&&!this.mightDrag.node.isAtom||De&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(In(this.view,H.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Wt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Wt(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)}}_e.touchstart=n=>{n.input.lastTouch=Date.now(),Js(n),Wt(n,"pointer")},_e.touchmove=n=>{n.input.lastTouch=Date.now(),Wt(n,"pointer")},_e.contextmenu=n=>Js(n);function mc(n,e){return n.composing?!0:Be&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const $p=St?5e3:-1;Ve.compositionstart=Ve.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof F&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),qr(n,!0),n.markCursor=null;else if(qr(n,!e.selection.empty),Ge&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}gc(n,$p)},Ve.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,gc(n,20))};function gc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>qr(n),e))}function yc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Hp());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function zp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Dh(e.focusNode,e.focusOffset),r=Ih(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Hp(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function qr(n,e=!1){if(!(St&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),yc(n),e||n.docView&&n.docView.dirty){let t=_s(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Fp(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const cr=He&&Ht<15||An&&Vh<604;_e.copy=Ve.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=cr?null:t.clipboardData,o=r.content(),{dom:l,text:a}=Fs(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Fp(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function jp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Up(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?ur(n,r.value,null,i,e):ur(n,r.textContent,r.innerHTML,i,e)},50)}function ur(n,e,t,r,i){let s=oc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||N.empty)))return!0;if(!s)return!1;let o=jp(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function bc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Ve.paste=(n,e)=>{let t=e;if(n.composing&&!St)return;let r=cr?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&ur(n,bc(r),r.getData("text/html"),i,t)?t.preventDefault():Up(n,t)};class wc{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Wp=Ye?"altKey":"ctrlKey";function kc(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[Wp]}_e.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(Kr(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof V?i.to-1:i.to))){if(r&&r.mightDrag)o=V.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=V.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=Fs(n,l);(!t.dataTransfer.files.length||!De||va>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(cr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",cr||t.dataTransfer.setData("text/plain",c),n.dragging=new wc(u,kc(n,t),o)},_e.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},Ve.dragover=Ve.dragenter=(n,e)=>e.preventDefault(),Ve.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(Kr(t));if(!i)return;let s=n.state.doc.resolve(i.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n,!1)}):o=oc(n,bc(t.dataTransfer),cr?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&kc(n,t));if(n.someProp("handleDrop",p=>p(n,t,o||N.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?aa(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&V.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new V(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,y,w,k)=>p=k),c.setSelection($s(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},_e.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Et(n)},20))},_e.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},_e.beforeinput=(n,e)=>{if(De&&St&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,un(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Ve)_e[n]=Ve[n];function dr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Jr{constructor(e,t){this.toDOM=e,this.spec=t||pn,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Ie(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Jr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&dr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Kt{constructor(e,t){this.attrs=e,this.spec=t||pn}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Ie(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Kt&&dr(this.attrs,e.attrs)&&dr(this.spec,e.spec)}static is(e){return e.type instanceof Kt}destroy(){}}class Gs{constructor(e,t){this.attrs=e,this.spec=t||pn}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Ie(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof Gs&&dr(this.attrs,e.attrs)&&dr(this.spec,e.spec)}destroy(){}}class Ie{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Ie(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Ie(e,e,new Jr(t,r))}static inline(e,t,r,i){return new Ie(e,t,new Kt(r,i))}static node(e,t,r,i){return new Ie(e,t,new Gs(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Kt}get widget(){return this.type instanceof Jr}}const Pn=[],pn={};class ae{constructor(e,t){this.local=e.length?e:Pn,this.children=t.length?t:Pn}static create(e,t){return t.length?Gr(t,e,0,pn):Pe}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==Pe||e.maps.length==0?this:this.mapInner(e,t,0,0,r||pn)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Kp(this.children,o||[],e,t,r,i,s):o?new ae(o.sort(mn),Pn):Pe}add(e,t){return t.length?this==Pe?ae.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Sc(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,u,c+1):i.splice(s,0,a,a+l.nodeSize,Gr(u,l,c+1,pn)),s+=3}});let o=xc(s?Cc(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ae(o.length?this.local.concat(o).sort(mn):this.local,i||this.children)}remove(e){return e.length==0||this==Pe?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=Pe?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new ae(i,r):Pe}forChild(e,t){if(this==Pe)return this;if(t.isLeaf)return ae.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Kt){let c=Math.max(s,a.from)-s,u=Math.min(o,a.to)-s;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new ae(i.sort(mn),Pn);return r?new qt([l,r]):l}return r||Pe}eq(e){if(this==e)return!0;if(!(e instanceof ae)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ys(this.localsInner(e))}localsInner(e){if(this==Pe)return Pn;if(e.inlineContent||!this.local.some(Kt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Kt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}ae.empty=new ae([],[]),ae.removeOverlap=Ys;const Pe=ae.empty;class qt{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,pn));return qt.from(r)}forChild(e,t){if(t.isLeaf)return ae.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=Pe&&(s instanceof qt?r=r.concat(s.members):r.push(s))}return qt.from(r)}eq(e){if(!(e instanceof qt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Ys(r?t:t.sort(mn)):Pn}static from(e){switch(e.length){case 0:return Pe;case 1:return e[0];default:return new qt(e.every(t=>t instanceof ae)?e:e.reduce((t,r)=>t.concat(r instanceof ae?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Kp(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,p,g)=>{let y=g-p-(h-f);for(let w=0;w<l.length;w+=3){let k=l[w+1];if(k<0||f>k+u-d)continue;let C=l[w]+u-d;h>=C?l[w+1]=f<=C?-2:-1:f>=u&&y&&(l[w]+=y,l[w+1]+=y)}d+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),d=u-i;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),h=f-i,{index:p,offset:g}=r.content.findIndex(d),y=r.maybeChild(p);if(y&&g==d&&g+y.nodeSize==h){let w=l[c+2].mapInner(t,y,u+1,n[c]+s+1,o);w!=Pe?(l[c]=d,l[c+1]=h,l[c+2]=w):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=qp(l,n,e,t,i,s,o),u=Gr(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new ae(e.sort(mn),l)}function xc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new Ie(i.from+e,i.to+e,i.type))}return t}function qp(n,e,t,r,i,s,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,i,c);d?t.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Sc(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function Cc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Gr(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=Sc(n,l,a+t);if(c){s=!0;let u=Gr(c,l,t+a+1,r);u!=Pe&&i.push(a,a+l.nodeSize,u)}});let o=xc(s?Cc(n):n,-t).sort(mn);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new ae(o,i):Pe}function mn(n,e){return n.from-e.from||n.to-e.to}function Ys(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),Ec(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Ec(e,i,r.copy(s.from,r.to)));break}}}return e}function Ec(n,e,t){for(;e<n.length&&mn(t,n[e])>0;)e++;n.splice(e,0,t)}function Xs(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Pe&&e.push(r)}),n.cursorWrapper&&e.push(ae.create(n.state.doc,[n.cursorWrapper.deco])),qt.from(e)}const Jp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Gp=He&&Ht<=11;class Yp{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Xp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Yp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);He&&Ht<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Gp&&(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,Jp)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.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(Qa(this.view)){if(this.suppressingSelectionUpdates)return Et(this.view);if(He&&Ht<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&cn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Nn(s))t.add(s);for(let s=e.anchorNode;s;s=Nn(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Qa(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],a);d&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(Ge&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||em(e,d)!=h)&&f.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Fr(r)&&(c=_s(e))&&c.eq(H.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Et(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Qp(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Et(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(He&&Ht<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?Oe(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?Oe(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Mc=new WeakMap,vc=!1;function Qp(n){if(!Mc.has(n)&&(Mc.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ge,vc)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),vc=!0}}function Tc(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return cn(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Zp(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Tc(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Tc(n,t):null}function em(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function tm(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Fr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),De&&n.input.lastKeyCode===8)for(let y=s;y>i;y--){let w=r.childNodes[y-1],k=w.pmViewDesc;if(w.nodeName=="BR"&&!k){s=y;break}if(!k||k.size)break}let d=n.state.doc,f=n.someProp("domParser")||Bt.fromSchema(n.state.schema),h=d.resolve(o),p=null,g=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:nm,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,w=c[1]&&c[1].pos;w==null&&(w=y),p={anchor:y+o,head:w+o}}return{doc:g,sel:p,from:o,to:l}}function nm(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Be&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Be&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const rm=/^(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 im(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,_=_s(n,T);if(_&&!n.state.selection.eq(_)){if(De&&St&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",j=>j(n,un(13,"Enter"))))return;let W=n.state.tr.setSelection(_);T=="pointer"?W.setMeta("pointer",!0):T=="key"&&W.scrollIntoView(),s&&W.setMeta("composition",s),n.dispatch(W)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=tm(n,e,t),u=n.state.doc,d=u.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=lm(d.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(An&&n.input.lastIOSEnter>Date.now()-225||St)&&i.some(T=>T.nodeType==1&&!rm.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,un(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof F&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Oc(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let _=n.state.tr.setSelection(T);s&&_.setMeta("composition",s),n.dispatch(_)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof F&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),He&&Ht<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),w=u.resolve(p.start),k=g.sameParent(y)&&g.parent.inlineContent&&w.end()>=p.endA;if((An&&n.input.lastIOSEnter>Date.now()-225&&(!k||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!k&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&n.someProp("handleKeyDown",T=>T(n,un(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&om(u,p.start,p.endA,g,y)&&n.someProp("handleKeyDown",T=>T(n,un(8,"Backspace")))){St&&De&&n.domObserver.suppressSelectionUpdates();return}De&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),St&&!k&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,un(13,"Enter"))})},20));let C=p.start,R=p.endA,M=T=>{let _=T||n.state.tr.replace(C,R,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let W=Oc(n,_.doc,c.sel);W&&!(De&&n.composing&&W.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(W.head==C||W.head==_.mapping.map(R)-1)||He&&W.empty&&W.head==C)&&_.setSelection(W)}return s&&_.setMeta("composition",s),_.scrollIntoView()},I;if(k){if(g.pos==y.pos){He&&Ht<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Et(n),20));let T=M(n.state.tr.delete(C,R)),_=u.resolve(p.start).marksAcross(u.resolve(p.endA));_&&T.ensureMarks(_),n.dispatch(T)}else if(p.endA==p.endB&&(I=sm(g.parent.content.cut(g.parentOffset,y.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start())))){let T=M(n.state.tr);I.type=="add"?T.addMark(C,R,I.mark):T.removeMark(C,R,I.mark),n.dispatch(T)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let T=g.parent.textBetween(g.parentOffset,y.parentOffset),_=()=>M(n.state.tr.insertText(T,C,R));n.someProp("handleTextInput",W=>W(n,C,R,T,_))||n.dispatch(_())}}else n.dispatch(M())}function Oc(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:$s(n,e.resolve(t.anchor),e.resolve(t.head))}function sm(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(S.from(c).eq(n))return{mark:l,type:o}}function om(n,e,t,r,i){if(t-e<=i.pos-r.pos||Qs(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(Qs(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Qs(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Qs(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function lm(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&n.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&Nc(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&Nc(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function Nc(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Ac{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new vp,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Lc),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=Ic(this),Dc(this),this.nodeViews=Pc(this),this.docView=za(this.state.doc,Rc(this),Xs(this),this.dom,this),this.domObserver=new Xp(this,(r,i,s,o)=>im(this,r,i,s,o)),this.domObserver.start(),Tp(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ws(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Lc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(yc(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Pc(this);cm(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ws(this),this.editable=Ic(this),Dc(this);let a=Xs(this),c=Rc(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Hh(this);if(o){this.domObserver.stop();let h=d&&(He||De)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&am(i.selection,e.selection);if(d){let p=De?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=zp(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=za(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&dp(this))?Et(this,h):(Ya(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Fh(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof V){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ta(this,t.getBoundingClientRect(),e)}else Ta(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new wc(e.slice,e.move,i<0?void 0:V.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(He){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&jh(this.dom),Et(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Jh(this,e)}coordsAtPos(e,t=1){return Ia(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Zh(this,t||this.state,e)}pasteHTML(e,t){return ur(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ur(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Fs(this,e)}destroy(){this.docView&&(Op(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Xs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ah())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ap(this,e)}domSelectionRange(){let e=this.domSelection();return e?Be&&this.root.nodeType===11&&Lh(this.dom.ownerDocument)==this.dom&&Zp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Ac.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Rc(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ie.node(0,n.state.doc.content.size,e)]}function Dc(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ie.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ic(n){return!n.someProp("editable",e=>e(n.state)===!1)}function am(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Pc(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function cm(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Lc(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var Jt={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:"'"},Yr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},um=typeof navigator<"u"&&/Mac/.test(navigator.platform),dm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ne=0;Ne<10;Ne++)Jt[48+Ne]=Jt[96+Ne]=String(Ne);for(var Ne=1;Ne<=24;Ne++)Jt[Ne+111]="F"+Ne;for(var Ne=65;Ne<=90;Ne++)Jt[Ne]=String.fromCharCode(Ne+32),Yr[Ne]=String.fromCharCode(Ne);for(var Zs in Jt)Yr.hasOwnProperty(Zs)||(Yr[Zs]=Jt[Zs]);function fm(n){var e=um&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||dm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Yr:Jt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const hm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),pm=typeof navigator<"u"&&/Win/.test(navigator.platform);function mm(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))hm?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function gm(n){let e=Object.create(null);for(let t in n)e[mm(t)]=n[t];return e}function eo(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function ym(n){return new se({props:{handleKeyDown:to(n)}})}function to(n){let e=gm(n);return function(t,r){let i=fm(r),s,o=e[eo(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[eo(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(pm&&r.ctrlKey&&r.altKey)&&(s=Jt[r.keyCode])&&s!=i){let l=e[eo(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const no=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Bc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const _c=(n,e,t)=>{let r=Bc(n,t);if(!r)return!1;let i=ro(r);if(!i){let o=r.blockRange(),l=o&&En(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Kc(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Ln(s,"end")||V.isSelectable(s)))for(let o=r.depth;;o--){let l=$r(n.doc,r.before(o),r.after(o),N.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Ln(s,"end")?H.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):V.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},bm=(n,e,t)=>{let r=Bc(n,t);if(!r)return!1;let i=ro(r);return i?Vc(n,i,e):!1},wm=(n,e,t)=>{let r=zc(n,t);if(!r)return!1;let i=io(r);return i?Vc(n,i,e):!1};function Vc(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=$r(n.doc,s,a,N.empty);if(!c||c.from!=s||c instanceof Se&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(F.create(u.doc,s)),t(u.scrollIntoView())}return!0}function Ln(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const $c=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=ro(r)}let o=s&&s.nodeBefore;return!o||!V.isSelectable(o)?!1:(e&&e(n.tr.setSelection(V.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function ro(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function zc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Hc=(n,e,t)=>{let r=zc(n,t);if(!r)return!1;let i=io(r);if(!i)return!1;let s=i.nodeAfter;if(Kc(n,i,e,1))return!0;if(r.parent.content.size==0&&(Ln(s,"start")||V.isSelectable(s))){let o=$r(n.doc,r.before(),r.after(),N.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Ln(s,"start")?H.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):V.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Fc=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=io(r)}let o=s&&s.nodeAfter;return!o||!V.isSelectable(o)?!1:(e&&e(n.tr.setSelection(V.create(n.doc,s.pos)).scrollIntoView()),!0)};function io(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const km=(n,e)=>{let t=n.selection,r=t instanceof V,i;if(r){if(t.node.isTextblock||!$t(n.doc,t.from))return!1;i=t.from}else if(i=Vr(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(V.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},xm=(n,e)=>{let t=n.selection,r;if(t instanceof V){if(t.node.isTextblock||!$t(n.doc,t.to))return!1;r=t.to}else if(r=Vr(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Sm=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&En(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},jc=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
10
|
-
`).scrollIntoView()),!0)};function so(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Cm=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=so(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(H.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Uc=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof We||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=so(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(F.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Wc=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(kt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&En(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Em(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof V&&e.selection.node.isBlock)return!r.parentOffset||!kt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,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=so(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof F||e.selection instanceof We)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=kt(u.doc,d,s.length,s);if(f||(s[0]=l?{type:l}:null,f=kt(u.doc,d,s.length,s)),!f)return!1;if(u.split(d,s.length,s),!a&&c&&r.node(o).type!=l){let h=u.mapping.map(r.before(o)),p=u.doc.resolve(h);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return t&&t(u.scrollIntoView()),!0}}const Mm=Em(),vm=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(V.create(n.doc,i))),!0)};function Tm(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||$t(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Kc(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Tm(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=S.empty;for(let w=o.length-1;w>=0;w--)p=S.from(o[w].create(null,p));p=S.from(i.copy(p));let g=n.tr.step(new Ce(e.pos-1,h,e.pos,h,new N(p,1,0),o.length,!0)),y=g.doc.resolve(h+2*o.length);y.nodeAfter&&y.nodeAfter.type==i.type&&$t(g.doc,y.pos)&&g.join(y.pos),t(g.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:H.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&En(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&Ln(s,"start",!0)&&Ln(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let g=s,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let w=S.empty;for(let C=p.length-1;C>=0;C--)w=S.from(p[C].copy(w));let k=n.tr.step(new Ce(e.pos-p.length,e.pos+s.nodeSize,e.pos+y,e.pos+s.nodeSize-y,new N(w,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function qc(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(F.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const Om=qc(-1),Nm=qc(1);function Am(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Ss(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Jc(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function oo(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}oo(no,_c,$c),oo(no,Hc,Fc),oo(jc,Uc,Wc,Mm),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Rm(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=r?t.tr:null;return Dm(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Dm(n,e,t,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new Dr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Dr(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=Ss(s,t,r,e);return l?(n&&Im(n,e,l,i,t),!0):!1}function Im(n,e,t,r,i){let s=S.empty;for(let u=t.length-1;u>=0;u--)s=S.from(t[u].type.create(t[u].attrs,s));n.step(new Ce(e.start-(r?2:0),e.end,e.start,e.end,new N(s,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==i&&(o=u+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&kt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Pm(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Lm(e,t,n,s):Bm(e,t,s):!0:!1}}function Lm(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Ce(s-1,o,s,o,new N(S.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Dr(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=En(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return $t(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Bm(n,e,t){let r=n.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,g=t.startIndex;p>g;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?S.empty:S.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new Ce(d-(l?1:0),f+(a?1:0),d+1,f-1,new N((l?S.empty:S.from(i.copy(S.empty))).append(a?S.empty:S.from(i.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function _m(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=S.from(c?n.create():null),d=new N(S.from(n.create(null,S.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new Ce(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var Vm=Object.defineProperty,Gc=(n,e)=>{for(var t in e)Vm(n,t,{get:e[t],enumerable:!0})};function Xr(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}var Qr=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:i}=t,s=this.buildProps(i);return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...c)=>{const u=l(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o=[],l=!!n,a=n||i.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(t).map(([d,f])=>[d,(...p)=>{const g=this.buildProps(a,e),y=f(...p)(g);return o.push(y),u}])),run:c};return u}createCan(n){const{rawCommands:e,state:t}=this,r=!1,i=n||t.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o={tr:n,editor:r,view:s,state:Xr({state:i,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},$m=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}};function Yc(n,e){const t=new ha(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}var Xc=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Xc(r)}return n};function Zr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Xc(t)}function fr(n,e,t){if(n instanceof Lt||n instanceof S)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return S.fromArray(n.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),fr("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Fl({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=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Bt.fromSchema(a).parseSlice(Zr(n),t.parseOptions):Bt.fromSchema(a).parse(Zr(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Bt.fromSchema(e);return t.slice?s.parseSlice(Zr(n),t.parseOptions).content:s.parse(Zr(n),t.parseOptions)}return fr("",e,t)}function lo(n,e,t={},r={}){return fr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}function zm(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function ao(n,e){const t=[];return n.descendants((r,i)=>{e(r)&&t.push({node:r,pos:i})}),t}function Hm(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&r.push({node:i,pos:s})}),r}function Fm(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function ei(n){return e=>Fm(e.$from,n)}function $(n,e,t){return n.config[e]===void 0&&n.parent?$(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?$(n.parent,e,t):null}):n.config[e]}function co(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=$(e,"addExtensions",t);return r?[e,...co(r())]:e}).flat(10)}function uo(n,e){const t=ln.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}function Qc(n){return typeof n=="function"}function ee(n,e=void 0,...t){return Qc(n)?e?n.bind(e)(...t):n(...t):n}function jm(n={}){return Object.keys(n).length===0&&n.constructor===Object}function hr(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Zc(n){const e=[],{nodeExtensions:t,markExtensions:r}=hr(n),i=[...t,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},a=$(o,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...s,...h}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=$(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([u,d])=>{const f={...s,...d};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:o.name,name:u,attribute:f})})}),e}function ce(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else if(i==="style"){const l=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),l.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),r[i]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[i]=s}),r},{})}function ti(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>ce(t,r),{})}function Um(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function eu(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):Um(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function tu(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&jm(t)?!1:t!=null))}function Wm(n,e){var t;const r=Zc(n),{nodeExtensions:i,markExtensions:s}=hr(n),o=(t=i.find(c=>$(c,"topNode")))==null?void 0:t.name,l=Object.fromEntries(i.map(c=>{const u=r.filter(w=>w.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((w,k)=>{const C=$(k,"extendNodeSchema",d);return{...w,...C?C(c):{}}},{}),h=tu({...f,content:ee($(c,"content",d)),marks:ee($(c,"marks",d)),group:ee($(c,"group",d)),inline:ee($(c,"inline",d)),atom:ee($(c,"atom",d)),selectable:ee($(c,"selectable",d)),draggable:ee($(c,"draggable",d)),code:ee($(c,"code",d)),whitespace:ee($(c,"whitespace",d)),linebreakReplacement:ee($(c,"linebreakReplacement",d)),defining:ee($(c,"defining",d)),isolating:ee($(c,"isolating",d)),attrs:Object.fromEntries(u.map(w=>{var k,C;return[w.name,{default:(k=w?.attribute)==null?void 0:k.default,validate:(C=w?.attribute)==null?void 0:C.validate}]}))}),p=ee($(c,"parseHTML",d));p&&(h.parseDOM=p.map(w=>eu(w,u)));const g=$(c,"renderHTML",d);g&&(h.toDOM=w=>g({node:w,HTMLAttributes:ti(w,u)}));const y=$(c,"renderText",d);return y&&(h.toText=y),[c.name,h]})),a=Object.fromEntries(s.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,w)=>{const k=$(w,"extendMarkSchema",d);return{...y,...k?k(c):{}}},{}),h=tu({...f,inclusive:ee($(c,"inclusive",d)),excludes:ee($(c,"excludes",d)),group:ee($(c,"group",d)),spanning:ee($(c,"spanning",d)),code:ee($(c,"code",d)),attrs:Object.fromEntries(u.map(y=>{var w,k;return[y.name,{default:(w=y?.attribute)==null?void 0:w.default,validate:(k=y?.attribute)==null?void 0:k.validate}]}))}),p=ee($(c,"parseHTML",d));p&&(h.parseDOM=p.map(y=>eu(y,u)));const g=$(c,"renderHTML",d);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:ti(y,u)})),[c.name,h]}));return new Fl({topNode:o,nodes:l,marks:a})}function Km(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function fo(n){return n.sort((t,r)=>{const i=$(t,"priority")||100,s=$(r,"priority")||100;return i>s?-1:i<s?1:0})}function nu(n){const e=fo(co(n)),t=Km(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function ru(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
|
|
9
|
+
`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",f=>f(e,i,r,n));if(d)l=d;else{let f=i.marks(),{schema:h}=n.state,p=ln.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(h.text(g,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=Sp(t),ir&&Cp(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Bt.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!wp.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Ep(uc(l,+u[1],+u[2]),u[4]);else if(l=N.maxOpen(kp(l.content,i),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=uc(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n,a)}),l}const wp=/^(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 kp(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&ac(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=cc(o[o.length-1],s.length));let u=lc(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return S.from(o)}return n}function lc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function ac(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=ac(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(S.from(lc(t,n,i+1))))}}function cc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,cc(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(S.empty,!0);return n.copy(t.append(r))}function js(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=js(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function uc(n,e,t){return e<n.openStart&&(n=new N(js(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new N(js(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const dc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let fc=null;function hc(){return fc||(fc=document.implementation.createHTMLDocument("title"))}let Us=null;function xp(n){let e=window.trustedTypes;return e?(Us||(Us=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Us.createHTML(n)):n}function Sp(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=hc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&dc[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=xp(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function Cp(n){let e=n.querySelectorAll(De?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Ep(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=S.from(a.create(r[l+1],i)),s++,o++}return new N(i,s,o)}const Ve={},$e={},Mp={touchstart:!0,touchmove:!0};class vp{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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Tp(n){for(let e in Ve){let t=Ve[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Np(n,r)&&!Ks(n,r)&&(n.editable||!(r.type in $e))&&t(n,r)},Mp[e]?{passive:!0}:void 0)}Be&&n.dom.addEventListener("input",()=>null),Ws(n)}function Wt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Op(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Ws(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Ks(n,r))})}function Ks(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Np(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Ap(n,e){!Ks(n,e)&&Ve[e.type]&&(n.editable||!(e.type in $e))&&Ve[e.type](n,e)}$e.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!mc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(St&&De&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),An&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,un(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||bp(n,t)?t.preventDefault():Wt(n,"key")},$e.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},$e.keypress=(n,e)=>{let t=e;if(mc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ye&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof F)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function Kr(n){return{left:n.clientX,top:n.clientY}}function Rp(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function qs(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function In(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Dp(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&$.isSelectable(r)?(In(n,new $(t)),!0):!1}function Ip(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof $&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if($.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(In(n,$.create(n.state.doc,i)),!0):!1}function Pp(n,e,t,r,i){return qs(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Ip(n,t):Dp(n,t))}function Lp(n,e,t,r){return qs(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Bp(n,e,t,r){return qs(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Vp(n,t,r)}function Vp(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(In(n,F.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)In(n,F.create(r,l+1,l+1+o.content.size));else if($.isSelectable(o))In(n,$.create(r,l));else continue;return!0}}function Js(n){return qr(n)}const pc=Ye?"metaKey":"ctrlKey";Ve.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Js(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Rp(t,n.input.lastClick)&&!t[pc]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button};let o=n.posAtCoords(Kr(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new $p(n,o,t,!!r)):(s=="doubleClick"?Lp:Bp)(n,o.pos,o.inside,t)?t.preventDefault():Wt(n,"pointer"))};class $p{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[pc],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,o=u.depth?u.before():0}const l=i?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&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof $&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ge&&!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)),Wt(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(()=>Et(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Kr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Wt(this.view,"pointer"):Pp(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Be&&this.mightDrag&&!this.mightDrag.node.isAtom||De&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(In(this.view,H.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Wt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Wt(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=n=>{n.input.lastTouch=Date.now(),Js(n),Wt(n,"pointer")},Ve.touchmove=n=>{n.input.lastTouch=Date.now(),Wt(n,"pointer")},Ve.contextmenu=n=>Js(n);function mc(n,e){return n.composing?!0:Be&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const zp=St?5e3:-1;$e.compositionstart=$e.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof F&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),qr(n,!0),n.markCursor=null;else if(qr(n,!e.selection.empty),Ge&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}gc(n,zp)},$e.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,gc(n,20))};function gc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>qr(n),e))}function yc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Hp());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function _p(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Dh(e.focusNode,e.focusOffset),r=Ih(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Hp(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function qr(n,e=!1){if(!(St&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),yc(n),e||n.docView&&n.docView.dirty){let t=Vs(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Fp(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const cr=He&&Ht<15||An&&$h<604;Ve.copy=$e.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=cr?null:t.clipboardData,o=r.content(),{dom:l,text:a}=Fs(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Fp(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function jp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Up(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?ur(n,r.value,null,i,e):ur(n,r.textContent,r.innerHTML,i,e)},50)}function ur(n,e,t,r,i){let s=oc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||N.empty)))return!0;if(!s)return!1;let o=jp(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function bc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}$e.paste=(n,e)=>{let t=e;if(n.composing&&!St)return;let r=cr?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&ur(n,bc(r),r.getData("text/html"),i,t)?t.preventDefault():Up(n,t)};class wc{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Wp=Ye?"altKey":"ctrlKey";function kc(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[Wp]}Ve.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(Kr(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof $?i.to-1:i.to))){if(r&&r.mightDrag)o=$.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=$.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=Fs(n,l);(!t.dataTransfer.files.length||!De||va>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(cr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",cr||t.dataTransfer.setData("text/plain",c),n.dragging=new wc(u,kc(n,t),o)},Ve.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},$e.dragover=$e.dragenter=(n,e)=>e.preventDefault(),$e.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(Kr(t));if(!i)return;let s=n.state.doc.resolve(i.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n,!1)}):o=oc(n,bc(t.dataTransfer),cr?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&kc(n,t));if(n.someProp("handleDrop",p=>p(n,t,o||N.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?aa(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&$.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new $(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,y,w,k)=>p=k),c.setSelection(zs(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},Ve.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Et(n)},20))},Ve.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Ve.beforeinput=(n,e)=>{if(De&&St&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,un(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in $e)Ve[n]=$e[n];function dr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Jr{constructor(e,t){this.toDOM=e,this.spec=t||pn,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Ie(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Jr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&dr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Kt{constructor(e,t){this.attrs=e,this.spec=t||pn}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Ie(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Kt&&dr(this.attrs,e.attrs)&&dr(this.spec,e.spec)}static is(e){return e.type instanceof Kt}destroy(){}}class Gs{constructor(e,t){this.attrs=e,this.spec=t||pn}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Ie(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof Gs&&dr(this.attrs,e.attrs)&&dr(this.spec,e.spec)}destroy(){}}class Ie{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Ie(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Ie(e,e,new Jr(t,r))}static inline(e,t,r,i){return new Ie(e,t,new Kt(r,i))}static node(e,t,r,i){return new Ie(e,t,new Gs(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Kt}get widget(){return this.type instanceof Jr}}const Pn=[],pn={};class ae{constructor(e,t){this.local=e.length?e:Pn,this.children=t.length?t:Pn}static create(e,t){return t.length?Gr(t,e,0,pn):Pe}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==Pe||e.maps.length==0?this:this.mapInner(e,t,0,0,r||pn)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Kp(this.children,o||[],e,t,r,i,s):o?new ae(o.sort(mn),Pn):Pe}add(e,t){return t.length?this==Pe?ae.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Sc(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,u,c+1):i.splice(s,0,a,a+l.nodeSize,Gr(u,l,c+1,pn)),s+=3}});let o=xc(s?Cc(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ae(o.length?this.local.concat(o).sort(mn):this.local,i||this.children)}remove(e){return e.length==0||this==Pe?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=Pe?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new ae(i,r):Pe}forChild(e,t){if(this==Pe)return this;if(t.isLeaf)return ae.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Kt){let c=Math.max(s,a.from)-s,u=Math.min(o,a.to)-s;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new ae(i.sort(mn),Pn);return r?new qt([l,r]):l}return r||Pe}eq(e){if(this==e)return!0;if(!(e instanceof ae)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ys(this.localsInner(e))}localsInner(e){if(this==Pe)return Pn;if(e.inlineContent||!this.local.some(Kt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Kt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}ae.empty=new ae([],[]),ae.removeOverlap=Ys;const Pe=ae.empty;class qt{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,pn));return qt.from(r)}forChild(e,t){if(t.isLeaf)return ae.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=Pe&&(s instanceof qt?r=r.concat(s.members):r.push(s))}return qt.from(r)}eq(e){if(!(e instanceof qt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Ys(r?t:t.sort(mn)):Pn}static from(e){switch(e.length){case 0:return Pe;case 1:return e[0];default:return new qt(e.every(t=>t instanceof ae)?e:e.reduce((t,r)=>t.concat(r instanceof ae?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Kp(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,p,g)=>{let y=g-p-(h-f);for(let w=0;w<l.length;w+=3){let k=l[w+1];if(k<0||f>k+u-d)continue;let C=l[w]+u-d;h>=C?l[w+1]=f<=C?-2:-1:f>=u&&y&&(l[w]+=y,l[w+1]+=y)}d+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),d=u-i;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),h=f-i,{index:p,offset:g}=r.content.findIndex(d),y=r.maybeChild(p);if(y&&g==d&&g+y.nodeSize==h){let w=l[c+2].mapInner(t,y,u+1,n[c]+s+1,o);w!=Pe?(l[c]=d,l[c+1]=h,l[c+2]=w):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=qp(l,n,e,t,i,s,o),u=Gr(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new ae(e.sort(mn),l)}function xc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new Ie(i.from+e,i.to+e,i.type))}return t}function qp(n,e,t,r,i,s,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,i,c);d?t.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Sc(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function Cc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Gr(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=Sc(n,l,a+t);if(c){s=!0;let u=Gr(c,l,t+a+1,r);u!=Pe&&i.push(a,a+l.nodeSize,u)}});let o=xc(s?Cc(n):n,-t).sort(mn);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new ae(o,i):Pe}function mn(n,e){return n.from-e.from||n.to-e.to}function Ys(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),Ec(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Ec(e,i,r.copy(s.from,r.to)));break}}}return e}function Ec(n,e,t){for(;e<n.length&&mn(t,n[e])>0;)e++;n.splice(e,0,t)}function Xs(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Pe&&e.push(r)}),n.cursorWrapper&&e.push(ae.create(n.state.doc,[n.cursorWrapper.deco])),qt.from(e)}const Jp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Gp=He&&Ht<=11;class Yp{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Xp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Yp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);He&&Ht<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Gp&&(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,Jp)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.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(Qa(this.view)){if(this.suppressingSelectionUpdates)return Et(this.view);if(He&&Ht<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&cn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Nn(s))t.add(s);for(let s=e.anchorNode;s;s=Nn(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Qa(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],a);d&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(Ge&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||em(e,d)!=h)&&f.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Fr(r)&&(c=Vs(e))&&c.eq(H.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Et(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Qp(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Et(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(He&&Ht<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?Oe(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?Oe(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Mc=new WeakMap,vc=!1;function Qp(n){if(!Mc.has(n)&&(Mc.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ge,vc)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),vc=!0}}function Tc(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return cn(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Zp(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Tc(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Tc(n,t):null}function em(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function tm(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Fr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),De&&n.input.lastKeyCode===8)for(let y=s;y>i;y--){let w=r.childNodes[y-1],k=w.pmViewDesc;if(w.nodeName=="BR"&&!k){s=y;break}if(!k||k.size)break}let d=n.state.doc,f=n.someProp("domParser")||Bt.fromSchema(n.state.schema),h=d.resolve(o),p=null,g=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:nm,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,w=c[1]&&c[1].pos;w==null&&(w=y),p={anchor:y+o,head:w+o}}return{doc:g,sel:p,from:o,to:l}}function nm(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Be&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Be&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const rm=/^(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 im(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,V=Vs(n,T);if(V&&!n.state.selection.eq(V)){if(De&&St&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",j=>j(n,un(13,"Enter"))))return;let W=n.state.tr.setSelection(V);T=="pointer"?W.setMeta("pointer",!0):T=="key"&&W.scrollIntoView(),s&&W.setMeta("composition",s),n.dispatch(W)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=tm(n,e,t),u=n.state.doc,d=u.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=lm(d.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(An&&n.input.lastIOSEnter>Date.now()-225||St)&&i.some(T=>T.nodeType==1&&!rm.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,un(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof F&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Oc(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let V=n.state.tr.setSelection(T);s&&V.setMeta("composition",s),n.dispatch(V)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof F&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),He&&Ht<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),w=u.resolve(p.start),k=g.sameParent(y)&&g.parent.inlineContent&&w.end()>=p.endA;if((An&&n.input.lastIOSEnter>Date.now()-225&&(!k||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!k&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&n.someProp("handleKeyDown",T=>T(n,un(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&om(u,p.start,p.endA,g,y)&&n.someProp("handleKeyDown",T=>T(n,un(8,"Backspace")))){St&&De&&n.domObserver.suppressSelectionUpdates();return}De&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),St&&!k&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,un(13,"Enter"))})},20));let C=p.start,R=p.endA,M=T=>{let V=T||n.state.tr.replace(C,R,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let W=Oc(n,V.doc,c.sel);W&&!(De&&n.composing&&W.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(W.head==C||W.head==V.mapping.map(R)-1)||He&&W.empty&&W.head==C)&&V.setSelection(W)}return s&&V.setMeta("composition",s),V.scrollIntoView()},I;if(k){if(g.pos==y.pos){He&&Ht<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Et(n),20));let T=M(n.state.tr.delete(C,R)),V=u.resolve(p.start).marksAcross(u.resolve(p.endA));V&&T.ensureMarks(V),n.dispatch(T)}else if(p.endA==p.endB&&(I=sm(g.parent.content.cut(g.parentOffset,y.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start())))){let T=M(n.state.tr);I.type=="add"?T.addMark(C,R,I.mark):T.removeMark(C,R,I.mark),n.dispatch(T)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let T=g.parent.textBetween(g.parentOffset,y.parentOffset),V=()=>M(n.state.tr.insertText(T,C,R));n.someProp("handleTextInput",W=>W(n,C,R,T,V))||n.dispatch(V())}}else n.dispatch(M())}function Oc(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:zs(n,e.resolve(t.anchor),e.resolve(t.head))}function sm(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(S.from(c).eq(n))return{mark:l,type:o}}function om(n,e,t,r,i){if(t-e<=i.pos-r.pos||Qs(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(Qs(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Qs(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Qs(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function lm(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&n.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&Nc(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&Nc(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function Nc(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Ac{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new vp,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Lc),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=Ic(this),Dc(this),this.nodeViews=Pc(this),this.docView=_a(this.state.doc,Rc(this),Xs(this),this.dom,this),this.domObserver=new Xp(this,(r,i,s,o)=>im(this,r,i,s,o)),this.domObserver.start(),Tp(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ws(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Lc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(yc(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Pc(this);cm(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ws(this),this.editable=Ic(this),Dc(this);let a=Xs(this),c=Rc(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Hh(this);if(o){this.domObserver.stop();let h=d&&(He||De)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&am(i.selection,e.selection);if(d){let p=De?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=_p(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=_a(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&dp(this))?Et(this,h):(Ya(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Fh(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof $){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ta(this,t.getBoundingClientRect(),e)}else Ta(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new wc(e.slice,e.move,i<0?void 0:$.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(He){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&jh(this.dom),Et(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Jh(this,e)}coordsAtPos(e,t=1){return Ia(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Zh(this,t||this.state,e)}pasteHTML(e,t){return ur(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ur(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Fs(this,e)}destroy(){this.docView&&(Op(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Xs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ah())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ap(this,e)}domSelectionRange(){let e=this.domSelection();return e?Be&&this.root.nodeType===11&&Lh(this.dom.ownerDocument)==this.dom&&Zp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Ac.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Rc(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ie.node(0,n.state.doc.content.size,e)]}function Dc(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ie.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ic(n){return!n.someProp("editable",e=>e(n.state)===!1)}function am(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Pc(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function cm(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Lc(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var Jt={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:"'"},Yr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},um=typeof navigator<"u"&&/Mac/.test(navigator.platform),dm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ne=0;Ne<10;Ne++)Jt[48+Ne]=Jt[96+Ne]=String(Ne);for(var Ne=1;Ne<=24;Ne++)Jt[Ne+111]="F"+Ne;for(var Ne=65;Ne<=90;Ne++)Jt[Ne]=String.fromCharCode(Ne+32),Yr[Ne]=String.fromCharCode(Ne);for(var Zs in Jt)Yr.hasOwnProperty(Zs)||(Yr[Zs]=Jt[Zs]);function fm(n){var e=um&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||dm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Yr:Jt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const hm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),pm=typeof navigator<"u"&&/Win/.test(navigator.platform);function mm(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))hm?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function gm(n){let e=Object.create(null);for(let t in n)e[mm(t)]=n[t];return e}function eo(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function ym(n){return new se({props:{handleKeyDown:to(n)}})}function to(n){let e=gm(n);return function(t,r){let i=fm(r),s,o=e[eo(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[eo(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(pm&&r.ctrlKey&&r.altKey)&&(s=Jt[r.keyCode])&&s!=i){let l=e[eo(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const no=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Bc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Vc=(n,e,t)=>{let r=Bc(n,t);if(!r)return!1;let i=ro(r);if(!i){let o=r.blockRange(),l=o&&En(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Kc(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Ln(s,"end")||$.isSelectable(s)))for(let o=r.depth;;o--){let l=zr(n.doc,r.before(o),r.after(o),N.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Ln(s,"end")?H.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):$.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},bm=(n,e,t)=>{let r=Bc(n,t);if(!r)return!1;let i=ro(r);return i?$c(n,i,e):!1},wm=(n,e,t)=>{let r=_c(n,t);if(!r)return!1;let i=io(r);return i?$c(n,i,e):!1};function $c(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=zr(n.doc,s,a,N.empty);if(!c||c.from!=s||c instanceof Se&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(F.create(u.doc,s)),t(u.scrollIntoView())}return!0}function Ln(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const zc=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=ro(r)}let o=s&&s.nodeBefore;return!o||!$.isSelectable(o)?!1:(e&&e(n.tr.setSelection($.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function ro(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function _c(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Hc=(n,e,t)=>{let r=_c(n,t);if(!r)return!1;let i=io(r);if(!i)return!1;let s=i.nodeAfter;if(Kc(n,i,e,1))return!0;if(r.parent.content.size==0&&(Ln(s,"start")||$.isSelectable(s))){let o=zr(n.doc,r.before(),r.after(),N.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Ln(s,"start")?H.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):$.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Fc=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=io(r)}let o=s&&s.nodeAfter;return!o||!$.isSelectable(o)?!1:(e&&e(n.tr.setSelection($.create(n.doc,s.pos)).scrollIntoView()),!0)};function io(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const km=(n,e)=>{let t=n.selection,r=t instanceof $,i;if(r){if(t.node.isTextblock||!zt(n.doc,t.from))return!1;i=t.from}else if(i=$r(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection($.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},xm=(n,e)=>{let t=n.selection,r;if(t instanceof $){if(t.node.isTextblock||!zt(n.doc,t.to))return!1;r=t.to}else if(r=$r(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Sm=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&En(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},jc=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
10
|
+
`).scrollIntoView()),!0)};function so(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Cm=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=so(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(H.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Uc=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof We||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=so(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(F.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Wc=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(kt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&En(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Em(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof $&&e.selection.node.isBlock)return!r.parentOffset||!kt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,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=so(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof F||e.selection instanceof We)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=kt(u.doc,d,s.length,s);if(f||(s[0]=l?{type:l}:null,f=kt(u.doc,d,s.length,s)),!f)return!1;if(u.split(d,s.length,s),!a&&c&&r.node(o).type!=l){let h=u.mapping.map(r.before(o)),p=u.doc.resolve(h);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return t&&t(u.scrollIntoView()),!0}}const Mm=Em(),vm=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection($.create(n.doc,i))),!0)};function Tm(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||zt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Kc(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Tm(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=S.empty;for(let w=o.length-1;w>=0;w--)p=S.from(o[w].create(null,p));p=S.from(i.copy(p));let g=n.tr.step(new Ce(e.pos-1,h,e.pos,h,new N(p,1,0),o.length,!0)),y=g.doc.resolve(h+2*o.length);y.nodeAfter&&y.nodeAfter.type==i.type&&zt(g.doc,y.pos)&&g.join(y.pos),t(g.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:H.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&En(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&Ln(s,"start",!0)&&Ln(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let g=s,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let w=S.empty;for(let C=p.length-1;C>=0;C--)w=S.from(p[C].copy(w));let k=n.tr.step(new Ce(e.pos-p.length,e.pos+s.nodeSize,e.pos+y,e.pos+s.nodeSize-y,new N(w,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function qc(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(F.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const Om=qc(-1),Nm=qc(1);function Am(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Ss(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Jc(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function oo(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}oo(no,Vc,zc),oo(no,Hc,Fc),oo(jc,Uc,Wc,Mm),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Rm(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=r?t.tr:null;return Dm(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Dm(n,e,t,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new Dr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Dr(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=Ss(s,t,r,e);return l?(n&&Im(n,e,l,i,t),!0):!1}function Im(n,e,t,r,i){let s=S.empty;for(let u=t.length-1;u>=0;u--)s=S.from(t[u].type.create(t[u].attrs,s));n.step(new Ce(e.start-(r?2:0),e.end,e.start,e.end,new N(s,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==i&&(o=u+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&kt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Pm(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Lm(e,t,n,s):Bm(e,t,s):!0:!1}}function Lm(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Ce(s-1,o,s,o,new N(S.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Dr(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=En(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return zt(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Bm(n,e,t){let r=n.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,g=t.startIndex;p>g;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?S.empty:S.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new Ce(d-(l?1:0),f+(a?1:0),d+1,f-1,new N((l?S.empty:S.from(i.copy(S.empty))).append(a?S.empty:S.from(i.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Vm(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=S.from(c?n.create():null),d=new N(S.from(n.create(null,S.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new Ce(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var $m=Object.defineProperty,Gc=(n,e)=>{for(var t in e)$m(n,t,{get:e[t],enumerable:!0})};function Xr(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}var Qr=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:i}=t,s=this.buildProps(i);return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...c)=>{const u=l(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o=[],l=!!n,a=n||i.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(t).map(([d,f])=>[d,(...p)=>{const g=this.buildProps(a,e),y=f(...p)(g);return o.push(y),u}])),run:c};return u}createCan(n){const{rawCommands:e,state:t}=this,r=!1,i=n||t.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o={tr:n,editor:r,view:s,state:Xr({state:i,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},zm=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}};function Yc(n,e){const t=new ha(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}var Xc=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Xc(r)}return n};function Zr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Xc(t)}function fr(n,e,t){if(n instanceof Lt||n instanceof S)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return S.fromArray(n.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),fr("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Fl({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=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Bt.fromSchema(a).parseSlice(Zr(n),t.parseOptions):Bt.fromSchema(a).parse(Zr(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Bt.fromSchema(e);return t.slice?s.parseSlice(Zr(n),t.parseOptions).content:s.parse(Zr(n),t.parseOptions)}return fr("",e,t)}function lo(n,e,t={},r={}){return fr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}function _m(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function ao(n,e){const t=[];return n.descendants((r,i)=>{e(r)&&t.push({node:r,pos:i})}),t}function Hm(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&r.push({node:i,pos:s})}),r}function Fm(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function ei(n){return e=>Fm(e.$from,n)}function z(n,e,t){return n.config[e]===void 0&&n.parent?z(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?z(n.parent,e,t):null}):n.config[e]}function co(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=z(e,"addExtensions",t);return r?[e,...co(r())]:e}).flat(10)}function uo(n,e){const t=ln.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}function Qc(n){return typeof n=="function"}function ee(n,e=void 0,...t){return Qc(n)?e?n.bind(e)(...t):n(...t):n}function jm(n={}){return Object.keys(n).length===0&&n.constructor===Object}function hr(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Zc(n){const e=[],{nodeExtensions:t,markExtensions:r}=hr(n),i=[...t,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},a=z(o,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...s,...h}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=z(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([u,d])=>{const f={...s,...d};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:o.name,name:u,attribute:f})})}),e}function ce(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else if(i==="style"){const l=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),l.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),r[i]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[i]=s}),r},{})}function ti(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>ce(t,r),{})}function Um(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function eu(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):Um(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function tu(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&jm(t)?!1:t!=null))}function Wm(n,e){var t;const r=Zc(n),{nodeExtensions:i,markExtensions:s}=hr(n),o=(t=i.find(c=>z(c,"topNode")))==null?void 0:t.name,l=Object.fromEntries(i.map(c=>{const u=r.filter(w=>w.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((w,k)=>{const C=z(k,"extendNodeSchema",d);return{...w,...C?C(c):{}}},{}),h=tu({...f,content:ee(z(c,"content",d)),marks:ee(z(c,"marks",d)),group:ee(z(c,"group",d)),inline:ee(z(c,"inline",d)),atom:ee(z(c,"atom",d)),selectable:ee(z(c,"selectable",d)),draggable:ee(z(c,"draggable",d)),code:ee(z(c,"code",d)),whitespace:ee(z(c,"whitespace",d)),linebreakReplacement:ee(z(c,"linebreakReplacement",d)),defining:ee(z(c,"defining",d)),isolating:ee(z(c,"isolating",d)),attrs:Object.fromEntries(u.map(w=>{var k,C;return[w.name,{default:(k=w?.attribute)==null?void 0:k.default,validate:(C=w?.attribute)==null?void 0:C.validate}]}))}),p=ee(z(c,"parseHTML",d));p&&(h.parseDOM=p.map(w=>eu(w,u)));const g=z(c,"renderHTML",d);g&&(h.toDOM=w=>g({node:w,HTMLAttributes:ti(w,u)}));const y=z(c,"renderText",d);return y&&(h.toText=y),[c.name,h]})),a=Object.fromEntries(s.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,w)=>{const k=z(w,"extendMarkSchema",d);return{...y,...k?k(c):{}}},{}),h=tu({...f,inclusive:ee(z(c,"inclusive",d)),excludes:ee(z(c,"excludes",d)),group:ee(z(c,"group",d)),spanning:ee(z(c,"spanning",d)),code:ee(z(c,"code",d)),attrs:Object.fromEntries(u.map(y=>{var w,k;return[y.name,{default:(w=y?.attribute)==null?void 0:w.default,validate:(k=y?.attribute)==null?void 0:k.validate}]}))}),p=ee(z(c,"parseHTML",d));p&&(h.parseDOM=p.map(y=>eu(y,u)));const g=z(c,"renderHTML",d);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:ti(y,u)})),[c.name,h]}));return new Fl({topNode:o,nodes:l,marks:a})}function Km(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function fo(n){return n.sort((t,r)=>{const i=z(t,"priority")||100,s=z(r,"priority")||100;return i>s?-1:i<s?1:0})}function nu(n){const e=fo(co(n)),t=Km(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function ru(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
|
|
11
11
|
|
|
12
|
-
`,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(r,i,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=s);const h=o?.[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,i-c))}),l}function iu(n,e){const t={from:0,to:n.content.size};return ru(n,t,e)}function ho(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Mt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}function su(n,e){const t=Mt(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function be(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function qm(n,e){const t=be(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function ni(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function ou(n,e){const t=ni(typeof e=="string"?e:e.name,n.schema);return t==="node"?qm(n,e):t==="mark"?su(n,e):{}}function Jm(n,e=JSON.stringify){const t={};return n.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Gm(n){const e=Jm(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,o)=>o!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function lu(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),u=e.slice(s).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),Gm(r)}function po(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function ri(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:po(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function au(n,e,t={}){return n.find(r=>r.type===e&&ri(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function cu(n,e,t={}){return!!au(n,e,t)}function mo(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(t=t||((r=i.node.marks[0])==null?void 0:r.attrs),!au([...i.node.marks],e,t)))return;let o=i.index,l=n.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&cu([...n.parent.child(o-1).marks],e,t);)o-=1,l-=n.parent.child(o).nodeSize;for(;a<n.parent.childCount&&cu([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function go(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n),o=mo(s,i.type);o&&r.push({mark:i,...o})}):t.nodesBetween(n,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var Ym=(n,e,t,r=20)=>{const i=n.doc.resolve(t);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function yo(n,e){return e.nodes[n]||e.marks[n]||null}function ii(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var Xm=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var a,c;const u=((c=(a=i.type.spec).toText)==null?void 0:c.call(a,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-s))}),t};function bo(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?Mt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>ri(d.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;n.doc.nodesBetween(h,p,(g,y)=>{if(!g.isText&&!g.marks.length)return;const w=Math.max(h,y),k=Math.min(p,y+g.nodeSize),C=k-w;o+=C,l.push(...g.marks.map(R=>({mark:R,from:w,to:k})))})}),o===0)return!1;const a=l.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>ri(d.mark.attrs,t,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=o}function Gt(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,o=e?be(e,n.schema):null,l=[];n.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(i,f+d.nodeSize);l.push({node:d,from:h,to:p})});const a=i-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>ri(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}function Qm(n,e,t={}){if(!e)return Gt(n,null,t)||bo(n,null,t);const r=ni(e,n.schema);return r==="node"?Gt(n,e,t):r==="mark"?bo(n,e,t):!1}var Zm=(n,e)=>{const{$from:t,$to:r,$anchor:i}=n.selection;if(e){const s=ei(l=>l.type.name===e)(n.selection);if(!s)return!1;const o=n.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},eg=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function uu(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function du(n,e){const{nodeExtensions:t}=hr(e),r=t.find(o=>o.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=ee(
|
|
13
|
-
`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function ig(n){return Object.prototype.toString.call(n).slice(8,-1)}function ai(n){return ig(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function mu(n,e){const t={...n};return ai(n)&&ai(e)&&Object.keys(e).forEach(r=>{ai(e[r])&&ai(n[r])?t[r]=mu(n[r],e[r]):t[r]=e[r]}),t}var ko=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...ee($(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ee($(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>mu(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},gn=class Rf extends ko{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new Rf(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>c?.type.name===t.name))return!1;const a=o.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function sg(n){return typeof n=="number"}var og=class{constructor(n){this.find=n.find,this.handler=n.handler}},lg=(n,e,t)=>{if(po(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=n,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function ag(n){const{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:u}=new Qr({editor:e,state:t}),d=[];return t.doc.nodesBetween(r,i,(h,p)=>{var g,y,w,k,C;if((y=(g=h.type)==null?void 0:g.spec)!=null&&y.code||!(h.isText||h.isTextblock||h.isInline))return;const R=(C=(k=(w=h.content)==null?void 0:w.size)!=null?k:h.nodeSize)!=null?C:0,M=Math.max(r,p),I=Math.min(i,p+R);if(M>=I)return;const T=h.isText?h.text||"":h.textBetween(M-p,I-p,void 0,"");lg(T,s.find,o).forEach(W=>{if(W.index===void 0)return;const j=M+W.index+1,K=j+W[0].length,P={from:t.tr.mapping.map(j),to:t.tr.mapping.map(K)},Q=s.handler({state:t,range:P,match:W,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(Q)})}),d.every(h=>h!==null)}var ci=null,cg=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function ug(n){const{editor:e,rules:t}=n;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:f,rule:h,pasteEvt:p})=>{const g=u.tr,y=Xr({state:u,transaction:g});if(!(!ag({editor:e,state:y,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(u=>new se({view(d){const f=p=>{var g;r=(g=d.dom.parentElement)!=null&&g.contains(p.target)?d.dom.parentElement:null,r&&(ci=e)},h=()=>{ci&&(ci=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(s=r===d.dom.parentElement,l=f,!s){const h=ci;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,f)=>{var h;const p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return o=f,i=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{const p=d[0],g=p.getMeta("uiEvent")==="paste"&&!i,y=p.getMeta("uiEvent")==="drop"&&!s,w=p.getMeta("applyPasteRules"),k=!!w;if(!g&&!y&&!k)return;if(k){let{text:M}=w;typeof M=="string"?M=M:M=uo(S.from(M),h.schema);const{from:I}=w,T=I+M.length,_=cg(M);return a({rule:u,state:h,from:I,to:{b:T},pasteEvt:_})}const C=f.doc.content.findDiffStart(h.doc.content),R=f.doc.content.findDiffEnd(h.doc.content);if(!(!sg(C)||!R||C===R.b))return a({rule:u,state:h,from:C,to:R,pasteEvt:o})}}))}var ui=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.extensions=nu(n),this.schema=Wm(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:yo(e.name,this.schema)},r=$(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return fo([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:yo(r.name,this.schema)},s=[],o=$(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&$(r,"exitable",i)&&(l.ArrowRight=()=>gn.handleExit({editor:n,mark:r})),o){const f=Object.fromEntries(Object.entries(o()).map(([h,p])=>[h,()=>p({editor:n})]));l={...l,...f}}const a=ym(l);s.push(a);const c=$(r,"addInputRules",i);if(uu(r,n.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=rg({editor:n,rules:f}),p=Array.isArray(h)?h:[h];s.push(...p)}}const u=$(r,"addPasteRules",i);if(uu(r,n.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=ug({editor:n,rules:f});s.push(...h)}}const d=$(r,"addProseMirrorPlugins",i);if(d){const f=d();s.push(...f)}return s})}get attributes(){return Zc(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=hr(this.extensions);return Object.fromEntries(e.filter(t=>!!$(t,"addNodeView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),i={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:be(t.name,this.schema)},s=$(t,"addNodeView",i);if(!s)return[];const o=(l,a,c,u,d)=>{const f=ti(l,r);return s()({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:n,extension:t,HTMLAttributes:f})};return[t.name,o]}))}get markViews(){const{editor:n}=this,{markExtensions:e}=hr(this.extensions);return Object.fromEntries(e.filter(t=>!!$(t,"addMarkView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),i={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:Mt(t.name,this.schema)},s=$(t,"addMarkView",i);if(!s)return[];const o=(l,a,c)=>{const u=ti(l,r);return s()({mark:l,view:a,inline:c,editor:n,extension:t,HTMLAttributes:u,updateAttributes:d=>{My(l,n,d)}})};return[t.name,o]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:yo(e.name,this.schema)};e.type==="mark"&&((t=ee($(e,"keepOnSplit",r)))==null||t)&&this.splittableMarks.push(e.name);const i=$(e,"onBeforeCreate",r),s=$(e,"onCreate",r),o=$(e,"onUpdate",r),l=$(e,"onSelectionUpdate",r),a=$(e,"onTransaction",r),c=$(e,"onFocus",r),u=$(e,"onBlur",r),d=$(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};ui.resolve=nu,ui.sort=fo,ui.flatten=co;var dg={};Gc(dg,{ClipboardTextSerializer:()=>gu,Commands:()=>xu,Delete:()=>Su,Drop:()=>Cu,Editable:()=>Eu,FocusEvents:()=>vu,Keymap:()=>Tu,Paste:()=>Ou,Tabindex:()=>Nu,focusEventsPluginKey:()=>Mu});var ue=class Df extends ko{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new Df(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},gu=ue.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new se({key:new le("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),a=ho(t);return ru(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),yu={};Gc(yu,{blur:()=>fg,clearContent:()=>hg,clearNodes:()=>pg,command:()=>mg,createParagraphNear:()=>gg,cut:()=>yg,deleteCurrentNode:()=>bg,deleteNode:()=>wg,deleteRange:()=>kg,deleteSelection:()=>xg,enter:()=>Sg,exitCode:()=>Cg,extendMarkRange:()=>Eg,first:()=>Mg,focus:()=>Tg,forEach:()=>Og,insertContent:()=>Ng,insertContentAt:()=>Rg,joinBackward:()=>Pg,joinDown:()=>Ig,joinForward:()=>Lg,joinItemBackward:()=>Bg,joinItemForward:()=>_g,joinTextblockBackward:()=>Vg,joinTextblockForward:()=>$g,joinUp:()=>Dg,keyboardShortcut:()=>Hg,lift:()=>Fg,liftEmptyBlock:()=>jg,liftListItem:()=>Ug,newlineInCode:()=>Wg,resetAttributes:()=>Kg,scrollIntoView:()=>qg,selectAll:()=>Jg,selectNodeBackward:()=>Gg,selectNodeForward:()=>Yg,selectParentNode:()=>Xg,selectTextblockEnd:()=>Qg,selectTextblockStart:()=>Zg,setContent:()=>ey,setMark:()=>ny,setMeta:()=>ry,setNode:()=>iy,setNodeSelection:()=>sy,setTextSelection:()=>oy,sinkListItem:()=>ly,splitBlock:()=>ay,splitListItem:()=>cy,toggleList:()=>uy,toggleMark:()=>dy,toggleNode:()=>fy,toggleWrap:()=>hy,undoInputRule:()=>py,unsetAllMarks:()=>my,unsetMark:()=>gy,updateAttributes:()=>yy,wrapIn:()=>by,wrapInList:()=>wy});var fg=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),hg=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),pg=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const p=En(h);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(p||p===0)&&e.lift(h,p)})}),!0},mg=n=>e=>n(e),gg=()=>({state:n,dispatch:e})=>Uc(n,e),yg=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new F(r.doc.resolve(Math.max(o-1,0)))),!0},bg=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),a=i.after(s);n.delete(l,a).scrollIntoView()}return!0}return!1},wg=n=>({tr:e,state:t,dispatch:r})=>{const i=be(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},kg=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},xg=()=>({state:n,dispatch:e})=>no(n,e),Sg=()=>({commands:n})=>n.keyboardShortcut("Enter"),Cg=()=>({state:n,dispatch:e})=>Cm(n,e),Eg=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const s=Mt(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){const d=mo(a,s,e);if(d&&d.from<=c&&d.to>=u){const f=F.create(o,d.from,d.to);t.setSelection(f)}}return!0},Mg=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function vg(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function xo(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Tg=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(xo()||vg())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!wo(t.state.selection))return o(),!0;const l=pu(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Og=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),Ng=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Ag=n=>!("type"in n),Rg=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=y=>{s.emit("contentError",{editor:s,error:y,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{fr(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=fr(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:d}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if((Ag(l)?l:[l]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===d&&h){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,d+=1)}let g;if(f){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof S){let y="";e.forEach(w=>{w.text&&(y+=w.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else{g=l;const y=r.doc.resolve(u),w=y.node(),k=y.parentOffset===0,C=w.isText||w.isTextblock,R=w.content.size>0;k&&C&&R&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}t.updateSelection&&tg(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},Dg=()=>({state:n,dispatch:e})=>km(n,e),Ig=()=>({state:n,dispatch:e})=>xm(n,e),Pg=()=>({state:n,dispatch:e})=>_c(n,e),Lg=()=>({state:n,dispatch:e})=>Hc(n,e),Bg=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Vr(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},_g=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Vr(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Vg=()=>({state:n,dispatch:e})=>bm(n,e),$g=()=>({state:n,dispatch:e})=>wm(n,e);function bu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function zg(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))xo()||bu()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var Hg=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=zg(n).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0},Fg=(n,e={})=>({state:t,dispatch:r})=>{const i=be(n,t.schema);return Gt(t,i,e)?Sm(t,r):!1},jg=()=>({state:n,dispatch:e})=>Wc(n,e),Ug=n=>({state:e,dispatch:t})=>{const r=be(n,e.schema);return Pm(r)(e,t)},Wg=()=>({state:n,dispatch:e})=>jc(n,e);function wu(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}var Kg=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=ni(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=be(n,r.schema)),l==="mark"&&(o=Mt(n,r.schema)),i&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{s&&s===c.type&&t.setNodeMarkup(u,void 0,wu(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&t.addMark(u,u+c.nodeSize,o.create(wu(d.attrs,e)))})})}),!0):!1},qg=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Jg=()=>({tr:n,dispatch:e})=>{if(e){const t=new We(n.doc);n.setSelection(t)}return!0},Gg=()=>({state:n,dispatch:e})=>$c(n,e),Yg=()=>({state:n,dispatch:e})=>Fc(n,e),Xg=()=>({state:n,dispatch:e})=>vm(n,e),Qg=()=>({state:n,dispatch:e})=>Nm(n,e),Zg=()=>({state:n,dispatch:e})=>Om(n,e),ey=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:a}=s;if(r.preserveWhitespace!=="full"){const c=lo(n,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function ty(n,e,t){var r;const{selection:i}=e;let s=null;if(wo(i)&&(s=i.$cursor),s){const l=(r=n.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));c=h&&p}return!c}),c})}var ny=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Mt(n,r.schema);if(i)if(o){const c=su(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const p=Math.max(h,u),g=Math.min(h+f.nodeSize,d);f.marks.find(w=>w.type===a)?f.marks.forEach(w=>{a===w.type&&t.addMark(p,g,a.create({...w.attrs,...e}))}):t.addMark(p,g,a.create(e))})});return ty(r,t,a)},ry=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),iy=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=be(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>Jc(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Jc(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},sy=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=vt(n,0,r.content.size),s=V.create(r,i);e.setSelection(s)}return!0},oy=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,o=F.atStart(r).from,l=F.atEnd(r).to,a=vt(i,o,l),c=vt(s,o,l),u=F.create(r,a,c);e.setSelection(u)}return!0},ly=n=>({state:e,dispatch:t})=>{const r=be(n,e.schema);return _m(r)(e,t)};function ku(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e?.includes(i.type.name));n.tr.ensureMarks(r)}}var ay=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=ii(c,l.node().type.name,l.node().attrs);if(s instanceof V&&s.node.isBlock)return!l.parentOffset||!kt(o,l.pos)?!1:(r&&(n&&ku(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:zm(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=kt(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&kt(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(p&&(s instanceof F&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&ku(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},cy=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{var o;const l=be(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const f=s.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(i){let w=S.empty;const k=a.index(-1)?1:a.index(-2)?2:3;for(let _=a.depth-k;_>=a.depth-3;_-=1)w=S.from(a.node(_).copy(w));const C=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,R={...ii(f,a.node().type.name,a.node().attrs),...e},M=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(R))||void 0;w=w.append(S.from(l.createAndFill(null,M)||void 0));const I=a.before(a.depth-(k-1));t.replace(I,a.after(-C),new N(w,4-k,0));let T=-1;t.doc.nodesBetween(I,t.doc.content.size,(_,W)=>{if(T>-1)return!1;_.isTextblock&&_.content.size===0&&(T=W+1)}),T>-1&&t.setSelection(F.near(t.doc.resolve(T))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...ii(f,d.type.name,d.attrs),...e},g={...ii(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const y=h?[{type:l,attrs:p},{type:h,attrs:g}]:[{type:l,attrs:p}];if(!kt(t.doc,a.pos,2))return!1;if(i){const{selection:w,storedMarks:k}=r,{splittableMarks:C}=s.extensionManager,R=k||w.$to.parentOffset&&w.$from.marks();if(t.split(a.pos,2,y).scrollIntoView(),!R||!i)return!0;const M=R.filter(I=>C.includes(I.type.name));t.ensureMarks(M)}return!0},So=(n,e)=>{const t=ei(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===i?.type&&$t(n.doc,t.pos)&&n.join(t.pos),!0},Co=(n,e)=>{const t=ei(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===i?.type&&$t(n.doc,r)&&n.join(r),!0},uy=(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=i.extensionManager,h=be(n,o.schema),p=be(e,o.schema),{selection:g,storedMarks:y}=o,{$from:w,$to:k}=g,C=w.blockRange(k),R=y||g.$to.parentOffset&&g.$from.marks();if(!C)return!1;const M=ei(I=>du(I.type.name,d))(g);if(C.depth>=1&&M&&C.depth-M.depth<=1){if(M.node.type===h)return c.liftListItem(p);if(du(M.node.type.name,d)&&h.validContent(M.node.content)&&l)return a().command(()=>(s.setNodeMarkup(M.pos,h),!0)).command(()=>So(s,h)).command(()=>Co(s,h)).run()}return!t||!R||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>So(s,h)).command(()=>Co(s,h)).run():a().command(()=>{const I=u().wrapInList(h,r),T=R.filter(_=>f.includes(_.type.name));return s.ensureMarks(T),I?!0:c.clearNodes()}).wrapInList(h,r).command(()=>So(s,h)).command(()=>Co(s,h)).run()},dy=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Mt(n,r.schema);return bo(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},fy=(n,e,t={})=>({state:r,commands:i})=>{const s=be(n,r.schema),o=be(e,r.schema),l=Gt(r,s,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},hy=(n,e={})=>({state:t,commands:r})=>{const i=be(n,t.schema);return Gt(t,i,e)?r.lift(i):r.wrapIn(i,e)},py=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const o=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},my=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},gy=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Mt(n,r.schema),{$from:c,empty:u,ranges:d}=l;if(!i)return!0;if(u&&o){let{from:f,to:h}=l;const p=(s=c.marks().find(y=>y.type===a))==null?void 0:s.attrs,g=mo(c,a,p);g&&(f=g.from,h=g.to),t.removeMark(f,h,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},yy=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=ni(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=be(n,r.schema)),l==="mark"&&(o=Mt(n,r.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;let d,f,h,p;t.selection.empty?r.doc.nodesBetween(c,u,(g,y)=>{s&&s===g.type&&(h=Math.max(y,c),p=Math.min(y+g.nodeSize,u),d=y,f=g)}):r.doc.nodesBetween(c,u,(g,y)=>{y<c&&s&&s===g.type&&(h=Math.max(y,c),p=Math.min(y+g.nodeSize,u),d=y,f=g),y>=c&&y<=u&&(s&&s===g.type&&t.setNodeMarkup(y,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(w=>{if(o===w.type){const k=Math.max(y,c),C=Math.min(y+g.nodeSize,u);t.addMark(k,C,o.create({...w.attrs,...e}))}}))}),f&&(d!==void 0&&t.setNodeMarkup(d,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&t.addMark(h,p,o.create({...g.attrs,...e}))}))}),!0):!1},by=(n,e={})=>({state:t,dispatch:r})=>{const i=be(n,t.schema);return Am(i,e)(t,r)},wy=(n,e={})=>({state:t,dispatch:r})=>{const i=be(n,t.schema);return Rm(i,e)(t,r)},xu=ue.create({name:"commands",addCommands(){return{...yu}}}),Su=ue.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,i;const s=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,n))!=null?c:n.getMeta("y-sync$"))return;const u=Yc(n.before,[n,...e]);lu(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,g)=>{const y=g+p.nodeSize-2,w=h.oldRange.from<=g&&y<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:g,to:y,newFrom:u.mapping.map(g),newTo:u.mapping.map(y),deletedRange:h.oldRange,newRange:h.newRange,partial:!w,editor:this.editor,transaction:n,combinedTransform:u})})});const f=u.mapping;u.steps.forEach((h,p)=>{var g,y;if(h instanceof tt){const w=f.slice(p).map(h.from,-1),k=f.slice(p).map(h.to),C=f.invert().map(w,-1),R=f.invert().map(k),M=(g=u.doc.nodeAt(w-1))==null?void 0:g.marks.some(T=>T.eq(h.mark)),I=(y=u.doc.nodeAt(k))==null?void 0:y.marks.some(T=>T.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:C,to:R},newRange:{from:w,to:k},partial:!!(I||M),editor:this.editor,transaction:n,combinedTransform:u})}})};(i=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),Cu=ue.create({name:"drop",addProseMirrorPlugins(){return[new se({key:new le("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Eu=ue.create({name:"editable",addProseMirrorPlugins(){return[new se({key:new le("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Mu=new le("focusEvents"),vu=ue.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new se({key:Mu,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Tu=ue.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=p.parent.type.spec.isolating,y=d.pos-d.parentOffset,w=g&&p.parent.childCount===1?y===d.pos:H.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!w||w&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return xo()||bu()?s:i},addProseMirrorPlugins(){return[new se({key:new le("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),i=n.some(g=>g.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,a=H.atStart(e.doc).from,c=H.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!si(t.doc))return;const f=t.tr,h=Xr({state:t,transaction:f}),{commands:p}=new Qr({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),Ou=ue.create({name:"paste",addProseMirrorPlugins(){return[new se({key:new le("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Nu=ue.create({name:"tabindex",addProseMirrorPlugins(){return[new se({key:new le("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ky=class Kn{constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}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 t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,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;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Kn(t,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 Kn(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 Kn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=this.pos+r+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const a=new Kn(l,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new Kn(l,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==t[a])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,r))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},xy=`.ProseMirror {
|
|
12
|
+
`,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(r,i,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=s);const h=o?.[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,i-c))}),l}function iu(n,e){const t={from:0,to:n.content.size};return ru(n,t,e)}function ho(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Mt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}function su(n,e){const t=Mt(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function be(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function qm(n,e){const t=be(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function ni(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function ou(n,e){const t=ni(typeof e=="string"?e:e.name,n.schema);return t==="node"?qm(n,e):t==="mark"?su(n,e):{}}function Jm(n,e=JSON.stringify){const t={};return n.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Gm(n){const e=Jm(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,o)=>o!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function lu(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),u=e.slice(s).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),Gm(r)}function po(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function ri(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:po(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function au(n,e,t={}){return n.find(r=>r.type===e&&ri(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function cu(n,e,t={}){return!!au(n,e,t)}function mo(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(t=t||((r=i.node.marks[0])==null?void 0:r.attrs),!au([...i.node.marks],e,t)))return;let o=i.index,l=n.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&cu([...n.parent.child(o-1).marks],e,t);)o-=1,l-=n.parent.child(o).nodeSize;for(;a<n.parent.childCount&&cu([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function go(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n),o=mo(s,i.type);o&&r.push({mark:i,...o})}):t.nodesBetween(n,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var Ym=(n,e,t,r=20)=>{const i=n.doc.resolve(t);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function yo(n,e){return e.nodes[n]||e.marks[n]||null}function ii(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var Xm=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var a,c;const u=((c=(a=i.type.spec).toText)==null?void 0:c.call(a,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-s))}),t};function bo(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?Mt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>ri(d.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;n.doc.nodesBetween(h,p,(g,y)=>{if(!g.isText&&!g.marks.length)return;const w=Math.max(h,y),k=Math.min(p,y+g.nodeSize),C=k-w;o+=C,l.push(...g.marks.map(R=>({mark:R,from:w,to:k})))})}),o===0)return!1;const a=l.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>ri(d.mark.attrs,t,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=o}function Gt(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,o=e?be(e,n.schema):null,l=[];n.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(i,f+d.nodeSize);l.push({node:d,from:h,to:p})});const a=i-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>ri(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}function Qm(n,e,t={}){if(!e)return Gt(n,null,t)||bo(n,null,t);const r=ni(e,n.schema);return r==="node"?Gt(n,e,t):r==="mark"?bo(n,e,t):!1}var Zm=(n,e)=>{const{$from:t,$to:r,$anchor:i}=n.selection;if(e){const s=ei(l=>l.type.name===e)(n.selection);if(!s)return!1;const o=n.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},eg=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function uu(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function du(n,e){const{nodeExtensions:t}=hr(e),r=t.find(o=>o.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=ee(z(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function si(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(s=>{i!==!1&&(si(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function fu(n){return n instanceof $}function wo(n){return n instanceof F}function vt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function hu(n,e,t){const i=n.state.doc.content.size,s=vt(e,0,i),o=vt(t,0,i),l=n.coordsAtPos(s),a=n.coordsAtPos(o,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),d=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h=f-d,p=u-c,w={top:c,bottom:u,left:d,right:f,width:h,height:p,x:d,y:c};return{...w,toJSON:()=>w}}function pu(n,e=null){if(!e)return null;const t=H.atStart(n),r=H.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,s=r.to;return e==="all"?F.create(n,vt(0,i,s),vt(n.content.size,i,s)):F.create(n,vt(e,i,s),vt(e,i,s))}function tg(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof Se||i instanceof Ce))return;const s=n.mapping.maps[r];let o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),n.setSelection(H.near(n.doc.resolve(o),t))}var oi=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},ng=(n,e)=>{if(po(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function li(n){var e;const{editor:t,from:r,to:i,text:s,rules:o,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const 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 u=!1;const d=Xm(c)+s;return o.forEach(f=>{if(u)return;const h=ng(d,f.find);if(!h)return;const p=a.state.tr,g=Xr({state:a.state,transaction:p}),y={from:r-(h[0].length-s.length),to:i},{commands:w,chain:k,can:C}=new Qr({editor:t,state:g});f.handler({state:g,range:y,match:h,commands:w,chain:k,can:C})===null||!p.steps.length||(f.undoable&&p.setMeta(l,{transform:p,from:r,to:i,text:s}),a.dispatch(p),u=!0)}),u}function rg(n){const{editor:e,rules:t}=n,r=new se({state:{init(){return null},apply(i,s,o){const l=i.getMeta(r);if(l)return l;const a=i.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=uo(S.from(u),o.schema);const{from:d}=a,f=d+u.length;li({editor:e,from:d,to:f,text:u,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return li({editor:e,from:s,to:o,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&li({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?li({editor:e,from:o.pos,to:o.pos,text:`
|
|
13
|
+
`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function ig(n){return Object.prototype.toString.call(n).slice(8,-1)}function ai(n){return ig(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function mu(n,e){const t={...n};return ai(n)&&ai(e)&&Object.keys(e).forEach(r=>{ai(e[r])&&ai(n[r])?t[r]=mu(n[r],e[r]):t[r]=e[r]}),t}var ko=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...ee(z(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ee(z(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>mu(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},gn=class Rf extends ko{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new Rf(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>c?.type.name===t.name))return!1;const a=o.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function sg(n){return typeof n=="number"}var og=class{constructor(n){this.find=n.find,this.handler=n.handler}},lg=(n,e,t)=>{if(po(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=n,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function ag(n){const{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:u}=new Qr({editor:e,state:t}),d=[];return t.doc.nodesBetween(r,i,(h,p)=>{var g,y,w,k,C;if((y=(g=h.type)==null?void 0:g.spec)!=null&&y.code||!(h.isText||h.isTextblock||h.isInline))return;const R=(C=(k=(w=h.content)==null?void 0:w.size)!=null?k:h.nodeSize)!=null?C:0,M=Math.max(r,p),I=Math.min(i,p+R);if(M>=I)return;const T=h.isText?h.text||"":h.textBetween(M-p,I-p,void 0,"");lg(T,s.find,o).forEach(W=>{if(W.index===void 0)return;const j=M+W.index+1,K=j+W[0].length,P={from:t.tr.mapping.map(j),to:t.tr.mapping.map(K)},Q=s.handler({state:t,range:P,match:W,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(Q)})}),d.every(h=>h!==null)}var ci=null,cg=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function ug(n){const{editor:e,rules:t}=n;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:f,rule:h,pasteEvt:p})=>{const g=u.tr,y=Xr({state:u,transaction:g});if(!(!ag({editor:e,state:y,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(u=>new se({view(d){const f=p=>{var g;r=(g=d.dom.parentElement)!=null&&g.contains(p.target)?d.dom.parentElement:null,r&&(ci=e)},h=()=>{ci&&(ci=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(s=r===d.dom.parentElement,l=f,!s){const h=ci;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,f)=>{var h;const p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return o=f,i=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{const p=d[0],g=p.getMeta("uiEvent")==="paste"&&!i,y=p.getMeta("uiEvent")==="drop"&&!s,w=p.getMeta("applyPasteRules"),k=!!w;if(!g&&!y&&!k)return;if(k){let{text:M}=w;typeof M=="string"?M=M:M=uo(S.from(M),h.schema);const{from:I}=w,T=I+M.length,V=cg(M);return a({rule:u,state:h,from:I,to:{b:T},pasteEvt:V})}const C=f.doc.content.findDiffStart(h.doc.content),R=f.doc.content.findDiffEnd(h.doc.content);if(!(!sg(C)||!R||C===R.b))return a({rule:u,state:h,from:C,to:R,pasteEvt:o})}}))}var ui=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.extensions=nu(n),this.schema=Wm(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:yo(e.name,this.schema)},r=z(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return fo([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:yo(r.name,this.schema)},s=[],o=z(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&z(r,"exitable",i)&&(l.ArrowRight=()=>gn.handleExit({editor:n,mark:r})),o){const f=Object.fromEntries(Object.entries(o()).map(([h,p])=>[h,()=>p({editor:n})]));l={...l,...f}}const a=ym(l);s.push(a);const c=z(r,"addInputRules",i);if(uu(r,n.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=rg({editor:n,rules:f}),p=Array.isArray(h)?h:[h];s.push(...p)}}const u=z(r,"addPasteRules",i);if(uu(r,n.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=ug({editor:n,rules:f});s.push(...h)}}const d=z(r,"addProseMirrorPlugins",i);if(d){const f=d();s.push(...f)}return s})}get attributes(){return Zc(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=hr(this.extensions);return Object.fromEntries(e.filter(t=>!!z(t,"addNodeView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),i={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:be(t.name,this.schema)},s=z(t,"addNodeView",i);if(!s)return[];const o=(l,a,c,u,d)=>{const f=ti(l,r);return s()({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:n,extension:t,HTMLAttributes:f})};return[t.name,o]}))}get markViews(){const{editor:n}=this,{markExtensions:e}=hr(this.extensions);return Object.fromEntries(e.filter(t=>!!z(t,"addMarkView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),i={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:Mt(t.name,this.schema)},s=z(t,"addMarkView",i);if(!s)return[];const o=(l,a,c)=>{const u=ti(l,r);return s()({mark:l,view:a,inline:c,editor:n,extension:t,HTMLAttributes:u,updateAttributes:d=>{My(l,n,d)}})};return[t.name,o]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:yo(e.name,this.schema)};e.type==="mark"&&((t=ee(z(e,"keepOnSplit",r)))==null||t)&&this.splittableMarks.push(e.name);const i=z(e,"onBeforeCreate",r),s=z(e,"onCreate",r),o=z(e,"onUpdate",r),l=z(e,"onSelectionUpdate",r),a=z(e,"onTransaction",r),c=z(e,"onFocus",r),u=z(e,"onBlur",r),d=z(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};ui.resolve=nu,ui.sort=fo,ui.flatten=co;var dg={};Gc(dg,{ClipboardTextSerializer:()=>gu,Commands:()=>xu,Delete:()=>Su,Drop:()=>Cu,Editable:()=>Eu,FocusEvents:()=>vu,Keymap:()=>Tu,Paste:()=>Ou,Tabindex:()=>Nu,focusEventsPluginKey:()=>Mu});var ue=class Df extends ko{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new Df(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},gu=ue.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new se({key:new le("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),a=ho(t);return ru(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),yu={};Gc(yu,{blur:()=>fg,clearContent:()=>hg,clearNodes:()=>pg,command:()=>mg,createParagraphNear:()=>gg,cut:()=>yg,deleteCurrentNode:()=>bg,deleteNode:()=>wg,deleteRange:()=>kg,deleteSelection:()=>xg,enter:()=>Sg,exitCode:()=>Cg,extendMarkRange:()=>Eg,first:()=>Mg,focus:()=>Tg,forEach:()=>Og,insertContent:()=>Ng,insertContentAt:()=>Rg,joinBackward:()=>Pg,joinDown:()=>Ig,joinForward:()=>Lg,joinItemBackward:()=>Bg,joinItemForward:()=>Vg,joinTextblockBackward:()=>$g,joinTextblockForward:()=>zg,joinUp:()=>Dg,keyboardShortcut:()=>Hg,lift:()=>Fg,liftEmptyBlock:()=>jg,liftListItem:()=>Ug,newlineInCode:()=>Wg,resetAttributes:()=>Kg,scrollIntoView:()=>qg,selectAll:()=>Jg,selectNodeBackward:()=>Gg,selectNodeForward:()=>Yg,selectParentNode:()=>Xg,selectTextblockEnd:()=>Qg,selectTextblockStart:()=>Zg,setContent:()=>ey,setMark:()=>ny,setMeta:()=>ry,setNode:()=>iy,setNodeSelection:()=>sy,setTextSelection:()=>oy,sinkListItem:()=>ly,splitBlock:()=>ay,splitListItem:()=>cy,toggleList:()=>uy,toggleMark:()=>dy,toggleNode:()=>fy,toggleWrap:()=>hy,undoInputRule:()=>py,unsetAllMarks:()=>my,unsetMark:()=>gy,updateAttributes:()=>yy,wrapIn:()=>by,wrapInList:()=>wy});var fg=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),hg=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),pg=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const p=En(h);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(p||p===0)&&e.lift(h,p)})}),!0},mg=n=>e=>n(e),gg=()=>({state:n,dispatch:e})=>Uc(n,e),yg=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new F(r.doc.resolve(Math.max(o-1,0)))),!0},bg=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),a=i.after(s);n.delete(l,a).scrollIntoView()}return!0}return!1},wg=n=>({tr:e,state:t,dispatch:r})=>{const i=be(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},kg=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},xg=()=>({state:n,dispatch:e})=>no(n,e),Sg=()=>({commands:n})=>n.keyboardShortcut("Enter"),Cg=()=>({state:n,dispatch:e})=>Cm(n,e),Eg=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const s=Mt(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){const d=mo(a,s,e);if(d&&d.from<=c&&d.to>=u){const f=F.create(o,d.from,d.to);t.setSelection(f)}}return!0},Mg=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function vg(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function xo(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Tg=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(xo()||vg())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!wo(t.state.selection))return o(),!0;const l=pu(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Og=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),Ng=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Ag=n=>!("type"in n),Rg=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=y=>{s.emit("contentError",{editor:s,error:y,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{fr(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=fr(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:d}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if((Ag(l)?l:[l]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===d&&h){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,d+=1)}let g;if(f){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof S){let y="";e.forEach(w=>{w.text&&(y+=w.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else{g=l;const y=r.doc.resolve(u),w=y.node(),k=y.parentOffset===0,C=w.isText||w.isTextblock,R=w.content.size>0;k&&C&&R&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}t.updateSelection&&tg(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},Dg=()=>({state:n,dispatch:e})=>km(n,e),Ig=()=>({state:n,dispatch:e})=>xm(n,e),Pg=()=>({state:n,dispatch:e})=>Vc(n,e),Lg=()=>({state:n,dispatch:e})=>Hc(n,e),Bg=()=>({state:n,dispatch:e,tr:t})=>{try{const r=$r(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Vg=()=>({state:n,dispatch:e,tr:t})=>{try{const r=$r(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},$g=()=>({state:n,dispatch:e})=>bm(n,e),zg=()=>({state:n,dispatch:e})=>wm(n,e);function bu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function _g(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))xo()||bu()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var Hg=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=_g(n).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0},Fg=(n,e={})=>({state:t,dispatch:r})=>{const i=be(n,t.schema);return Gt(t,i,e)?Sm(t,r):!1},jg=()=>({state:n,dispatch:e})=>Wc(n,e),Ug=n=>({state:e,dispatch:t})=>{const r=be(n,e.schema);return Pm(r)(e,t)},Wg=()=>({state:n,dispatch:e})=>jc(n,e);function wu(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}var Kg=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=ni(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=be(n,r.schema)),l==="mark"&&(o=Mt(n,r.schema)),i&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{s&&s===c.type&&t.setNodeMarkup(u,void 0,wu(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&t.addMark(u,u+c.nodeSize,o.create(wu(d.attrs,e)))})})}),!0):!1},qg=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Jg=()=>({tr:n,dispatch:e})=>{if(e){const t=new We(n.doc);n.setSelection(t)}return!0},Gg=()=>({state:n,dispatch:e})=>zc(n,e),Yg=()=>({state:n,dispatch:e})=>Fc(n,e),Xg=()=>({state:n,dispatch:e})=>vm(n,e),Qg=()=>({state:n,dispatch:e})=>Nm(n,e),Zg=()=>({state:n,dispatch:e})=>Om(n,e),ey=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:a}=s;if(r.preserveWhitespace!=="full"){const c=lo(n,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function ty(n,e,t){var r;const{selection:i}=e;let s=null;if(wo(i)&&(s=i.$cursor),s){const l=(r=n.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));c=h&&p}return!c}),c})}var ny=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Mt(n,r.schema);if(i)if(o){const c=su(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const p=Math.max(h,u),g=Math.min(h+f.nodeSize,d);f.marks.find(w=>w.type===a)?f.marks.forEach(w=>{a===w.type&&t.addMark(p,g,a.create({...w.attrs,...e}))}):t.addMark(p,g,a.create(e))})});return ty(r,t,a)},ry=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),iy=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=be(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>Jc(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Jc(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},sy=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=vt(n,0,r.content.size),s=$.create(r,i);e.setSelection(s)}return!0},oy=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,o=F.atStart(r).from,l=F.atEnd(r).to,a=vt(i,o,l),c=vt(s,o,l),u=F.create(r,a,c);e.setSelection(u)}return!0},ly=n=>({state:e,dispatch:t})=>{const r=be(n,e.schema);return Vm(r)(e,t)};function ku(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e?.includes(i.type.name));n.tr.ensureMarks(r)}}var ay=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=ii(c,l.node().type.name,l.node().attrs);if(s instanceof $&&s.node.isBlock)return!l.parentOffset||!kt(o,l.pos)?!1:(r&&(n&&ku(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:_m(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=kt(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&kt(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(p&&(s instanceof F&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&ku(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},cy=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{var o;const l=be(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const f=s.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(i){let w=S.empty;const k=a.index(-1)?1:a.index(-2)?2:3;for(let V=a.depth-k;V>=a.depth-3;V-=1)w=S.from(a.node(V).copy(w));const C=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,R={...ii(f,a.node().type.name,a.node().attrs),...e},M=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(R))||void 0;w=w.append(S.from(l.createAndFill(null,M)||void 0));const I=a.before(a.depth-(k-1));t.replace(I,a.after(-C),new N(w,4-k,0));let T=-1;t.doc.nodesBetween(I,t.doc.content.size,(V,W)=>{if(T>-1)return!1;V.isTextblock&&V.content.size===0&&(T=W+1)}),T>-1&&t.setSelection(F.near(t.doc.resolve(T))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...ii(f,d.type.name,d.attrs),...e},g={...ii(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const y=h?[{type:l,attrs:p},{type:h,attrs:g}]:[{type:l,attrs:p}];if(!kt(t.doc,a.pos,2))return!1;if(i){const{selection:w,storedMarks:k}=r,{splittableMarks:C}=s.extensionManager,R=k||w.$to.parentOffset&&w.$from.marks();if(t.split(a.pos,2,y).scrollIntoView(),!R||!i)return!0;const M=R.filter(I=>C.includes(I.type.name));t.ensureMarks(M)}return!0},So=(n,e)=>{const t=ei(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===i?.type&&zt(n.doc,t.pos)&&n.join(t.pos),!0},Co=(n,e)=>{const t=ei(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===i?.type&&zt(n.doc,r)&&n.join(r),!0},uy=(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=i.extensionManager,h=be(n,o.schema),p=be(e,o.schema),{selection:g,storedMarks:y}=o,{$from:w,$to:k}=g,C=w.blockRange(k),R=y||g.$to.parentOffset&&g.$from.marks();if(!C)return!1;const M=ei(I=>du(I.type.name,d))(g);if(C.depth>=1&&M&&C.depth-M.depth<=1){if(M.node.type===h)return c.liftListItem(p);if(du(M.node.type.name,d)&&h.validContent(M.node.content)&&l)return a().command(()=>(s.setNodeMarkup(M.pos,h),!0)).command(()=>So(s,h)).command(()=>Co(s,h)).run()}return!t||!R||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>So(s,h)).command(()=>Co(s,h)).run():a().command(()=>{const I=u().wrapInList(h,r),T=R.filter(V=>f.includes(V.type.name));return s.ensureMarks(T),I?!0:c.clearNodes()}).wrapInList(h,r).command(()=>So(s,h)).command(()=>Co(s,h)).run()},dy=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Mt(n,r.schema);return bo(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},fy=(n,e,t={})=>({state:r,commands:i})=>{const s=be(n,r.schema),o=be(e,r.schema),l=Gt(r,s,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},hy=(n,e={})=>({state:t,commands:r})=>{const i=be(n,t.schema);return Gt(t,i,e)?r.lift(i):r.wrapIn(i,e)},py=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const o=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},my=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},gy=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Mt(n,r.schema),{$from:c,empty:u,ranges:d}=l;if(!i)return!0;if(u&&o){let{from:f,to:h}=l;const p=(s=c.marks().find(y=>y.type===a))==null?void 0:s.attrs,g=mo(c,a,p);g&&(f=g.from,h=g.to),t.removeMark(f,h,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},yy=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=ni(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=be(n,r.schema)),l==="mark"&&(o=Mt(n,r.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;let d,f,h,p;t.selection.empty?r.doc.nodesBetween(c,u,(g,y)=>{s&&s===g.type&&(h=Math.max(y,c),p=Math.min(y+g.nodeSize,u),d=y,f=g)}):r.doc.nodesBetween(c,u,(g,y)=>{y<c&&s&&s===g.type&&(h=Math.max(y,c),p=Math.min(y+g.nodeSize,u),d=y,f=g),y>=c&&y<=u&&(s&&s===g.type&&t.setNodeMarkup(y,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(w=>{if(o===w.type){const k=Math.max(y,c),C=Math.min(y+g.nodeSize,u);t.addMark(k,C,o.create({...w.attrs,...e}))}}))}),f&&(d!==void 0&&t.setNodeMarkup(d,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&t.addMark(h,p,o.create({...g.attrs,...e}))}))}),!0):!1},by=(n,e={})=>({state:t,dispatch:r})=>{const i=be(n,t.schema);return Am(i,e)(t,r)},wy=(n,e={})=>({state:t,dispatch:r})=>{const i=be(n,t.schema);return Rm(i,e)(t,r)},xu=ue.create({name:"commands",addCommands(){return{...yu}}}),Su=ue.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,i;const s=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,n))!=null?c:n.getMeta("y-sync$"))return;const u=Yc(n.before,[n,...e]);lu(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,g)=>{const y=g+p.nodeSize-2,w=h.oldRange.from<=g&&y<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:g,to:y,newFrom:u.mapping.map(g),newTo:u.mapping.map(y),deletedRange:h.oldRange,newRange:h.newRange,partial:!w,editor:this.editor,transaction:n,combinedTransform:u})})});const f=u.mapping;u.steps.forEach((h,p)=>{var g,y;if(h instanceof tt){const w=f.slice(p).map(h.from,-1),k=f.slice(p).map(h.to),C=f.invert().map(w,-1),R=f.invert().map(k),M=(g=u.doc.nodeAt(w-1))==null?void 0:g.marks.some(T=>T.eq(h.mark)),I=(y=u.doc.nodeAt(k))==null?void 0:y.marks.some(T=>T.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:C,to:R},newRange:{from:w,to:k},partial:!!(I||M),editor:this.editor,transaction:n,combinedTransform:u})}})};(i=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),Cu=ue.create({name:"drop",addProseMirrorPlugins(){return[new se({key:new le("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Eu=ue.create({name:"editable",addProseMirrorPlugins(){return[new se({key:new le("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Mu=new le("focusEvents"),vu=ue.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new se({key:Mu,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Tu=ue.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=p.parent.type.spec.isolating,y=d.pos-d.parentOffset,w=g&&p.parent.childCount===1?y===d.pos:H.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!w||w&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return xo()||bu()?s:i},addProseMirrorPlugins(){return[new se({key:new le("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),i=n.some(g=>g.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,a=H.atStart(e.doc).from,c=H.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!si(t.doc))return;const f=t.tr,h=Xr({state:t,transaction:f}),{commands:p}=new Qr({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),Ou=ue.create({name:"paste",addProseMirrorPlugins(){return[new se({key:new le("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Nu=ue.create({name:"tabindex",addProseMirrorPlugins(){return[new se({key:new le("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ky=class Kn{constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}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 t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,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;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Kn(t,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 Kn(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 Kn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=this.pos+r+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const a=new Kn(l,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new Kn(l,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==t[a])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,r))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},xy=`.ProseMirror {
|
|
14
14
|
position: relative;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -80,9 +80,9 @@ img.ProseMirror-separator {
|
|
|
80
80
|
|
|
81
81
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
82
82
|
display: block;
|
|
83
|
-
}`;function Sy(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}var Cy=class extends
|
|
83
|
+
}`;function Sy(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}var Cy=class extends zm{constructor(e={}){super(),this.css=null,this.editorView=null,this.isFocused=!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,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:i})=>{throw i},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.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:i,slice:s,moved:o})=>this.options.onDrop(i,s,o)),this.on("paste",({event:i,slice:s})=>this.options.onPaste(i,s)),this.on("delete",this.options.onDelete);const t=this.createDoc(),r=pu(t,this.options.autofocus);this.editorState=On.create({doc:t,schema:this.schema,selection:r||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){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(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}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=Sy(xy,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,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:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t==="state")return this.editorState;if(t in e)return Reflect.get(e,t);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){const r=Qc(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;r=r.filter(l=>!l.key.startsWith(o))}),t.length===r.length)return;const i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,t;const i=[...this.options.enableCoreExtensions?[Eu,gu.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)==null?void 0:e.clipboardTextSerializer)==null?void 0:t.blockSeparator}),xu,vu,Tu,Nu,Cu,Ou,Su].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 ui(i,this)}createCommandManager(){this.commandManager=new Qr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=lo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message))throw t;this.emit("contentError",{editor:this,error:t,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(r=>r.name!=="collaboration"),this.createExtensionManager()}}),e=lo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){var t;this.editorView=new Ac(e,{...this.options.editorProps,attributes:{role:"textbox",...(t=this.options.editorProps)==null?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.prependClass(),this.injectCSS();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:t,transactions:r}=this.state.applyTransaction(e),i=!this.state.selection.eq(t.selection),s=r.includes(e),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!s)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:r.slice(1)}),i&&this.emit("selectionUpdate",{editor:this,transaction:e});const l=r.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),a=l?.getMeta("focus"),c=l?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:l}),c&&this.emit("blur",{editor:this,event:c.event,transaction:l}),!(e.getMeta("preventUpdate")||!r.some(u=>u.docChanged)||o.doc.eq(t.doc))&&this.emit("update",{editor:this,transaction:e,appendedTransactions:r.slice(1)})}getAttributes(e){return ou(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return Qm(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return uo(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
|
|
84
84
|
|
|
85
|
-
`,textSerializers:r={}}=e||{};return iu(this.state.doc,{blockSeparator:t,textSerializers:{...ho(this.schema),...r}})}get isEmpty(){return si(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var e,t;return(t=(e=this.editorView)==null?void 0:e.isDestroyed)!=null?t:!0}$node(e,t){var r;return((r=this.$doc)==null?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)==null?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new ky(t,this)}get $doc(){return this.$pos(0)}};function Bn(n){return new oi({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ee(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),u=c+o.length;if(go(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&s.delete(u,t.to),c>t.from&&s.delete(t.from+a,c);const f=t.from+a+o.length;s.addMark(t.from+a,f,n.type.create(i||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function Au(n){return new oi({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ee(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let l=t.to;const a=n.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,o+r[0].length-1),s.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;s.insert(c,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:n.undoable})}function Eo(n){return new oi({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=ee(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function _n(n){return new oi({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=ee(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&Ss(a,n.type,s);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const g=p.filter(y=>h.includes(y.type.name));o.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&$t(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)},undoable:n.undoable})}function Ey(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof V){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function My(n,e,t={}){const{state:r}=e,{doc:i,tr:s}=r,o=n;i.descendants((l,a)=>{const c=s.mapping.map(a),u=s.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==o)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});s.removeMark(c,u,n.type),s.addMark(c,u,h)}}),s.docChanged&&e.view.dispatch(s)}var $e=class If extends ko{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new If(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function yn(n){return new og({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=ee(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(go(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===n.type&&y!==p.mark.type)).filter(p=>p.to>d).length)return null;f<t.to&&o.delete(f,t.to),d>t.from&&o.delete(t.from+u,d),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}function Ru(n){return m.customRef((e,t)=>({get(){return e(),n},set(r){n=r,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}}))}var vy=class extends Cy{constructor(n={}){return super(n),this.contentComponent=null,this.appContext=null,this.reactiveState=Ru(this.view.state),this.reactiveExtensionStorage=Ru(this.extensionStorage),this.on("beforeTransaction",({nextState:e})=>{this.reactiveState.value=e,this.reactiveExtensionStorage.value=this.extensionStorage}),m.markRaw(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(n,e){const t=super.registerPlugin(n,e);return this.reactiveState&&(this.reactiveState.value=t),t}unregisterPlugin(n){const e=super.unregisterPlugin(n);return this.reactiveState&&e&&(this.reactiveState.value=e),e}},Ty=m.defineComponent({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(n){const e=m.ref(),t=m.getCurrentInstance();return m.watchEffect(()=>{const r=n.editor;r&&r.options.element&&e.value&&m.nextTick(()=>{var i;if(!e.value||!((i=r.view.dom)!=null&&i.firstChild))return;const s=m.unref(e.value);e.value.append(r.view.dom),r.contentComponent=t.ctx._,t&&(r.appContext={...t.appContext,provides:t.provides}),r.setOptions({element:s}),r.createNodeViews()})}),m.onBeforeUnmount(()=>{const r=n.editor;r&&(r.contentComponent=null,r.appContext=null)}),{rootEl:e}},render(){return m.h("div",{ref:n=>{this.rootEl=n}})}});m.defineComponent({name:"NodeViewContent",props:{as:{type:String,default:"div"}},render(){return m.h(this.as,{style:{whiteSpace:"pre-wrap"},"data-node-view-content":""})}}),m.defineComponent({name:"NodeViewWrapper",props:{as:{type:String,default:"div"}},inject:["onDragStart","decorationClasses"],render(){var n,e;return m.h(this.as,{class:this.decorationClasses,style:{whiteSpace:"normal"},"data-node-view-wrapper":"",onDragstart:this.onDragStart},(e=(n=this.$slots).default)==null?void 0:e.call(n))}});var Oy=(n={})=>{const e=m.shallowRef();return m.onMounted(()=>{e.value=new vy(n)}),m.onBeforeUnmount(()=>{var t,r,i;const s=(t=e.value)==null?void 0:t.view.dom,o=s?.cloneNode(!0);(r=s?.parentNode)==null||r.replaceChild(o,s),(i=e.value)==null||i.destroy()}),e};m.defineComponent({name:"MarkViewContent",props:{as:{type:String,default:"span"}},render(){return m.h(this.as,{style:{whiteSpace:"inherit"},"data-mark-view-content":""})}});const Ny={class:"sus-emoji-panel grid"},Ay=["onClick","src","alt","title"],Ry=m.defineComponent({__name:"index",props:{emoji:{},editor:{}},setup(n){const e=n;function t(r){e.editor?.commands.insertContent({type:"emoji",attrs:{name:r.name,src:r.fallbackImage}}),e.emoji.showPanel=!1}return(r,i)=>(m.openBlock(),m.createElementBlock("div",Ny,[(m.openBlock(!0),m.createElementBlock(m.Fragment,null,m.renderList(n.emoji.emojis,s=>(m.openBlock(),m.createElementBlock("div",null,[m.createElementVNode("img",{onClick:o=>t(s),class:"sus-emoji-item",src:s.fallbackImage,alt:s.name,title:`:${s.name}:`},null,8,Ay)]))),256))]))}}),bn=(n,e)=>{const t=n.__vccOpts||n;for(const[r,i]of e)t[r]=i;return t},Dy=bn(Ry,[["__scopeId","data-v-4b6da5f8"]]);var di=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},Iy=/^\s*>\s$/,Py=$e.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return di("blockquote",{...ce(this.options.HTMLAttributes,n),children:di("slot",{})})},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[_n({find:Iy,type:this.type})]}}),Ly=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,By=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,_y=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Vy=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,$y=gn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return di("strong",{...ce(this.options.HTMLAttributes,n),children:di("slot",{})})},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Bn({find:Ly,type:this.type}),Bn({find:_y,type:this.type})]},addPasteRules(){return[yn({find:By,type:this.type}),yn({find:Vy,type:this.type})]}}),zy=/(^|[^`])`([^`]+)`(?!`)$/,Hy=/(^|[^`])`([^`]+)`(?!`)/g,Fy=gn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Bn({find:zy,type:this.type})]},addPasteRules(){return[yn({find:Hy,type:this.type})]}}),Mo=4,jy=/^```([a-z]+)?[\s\n]$/,Uy=/^~~~([a-z]+)?[\s\n]$/,Du=$e.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Mo,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const s=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",ce(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Mo,{state:r}=n,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(t);return o?n.commands.insertContent(l):n.commands.command(({tr:a})=>{const{from:c,to:u}=i,h=r.doc.textBetween(c,u,`
|
|
85
|
+
`,textSerializers:r={}}=e||{};return iu(this.state.doc,{blockSeparator:t,textSerializers:{...ho(this.schema),...r}})}get isEmpty(){return si(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var e,t;return(t=(e=this.editorView)==null?void 0:e.isDestroyed)!=null?t:!0}$node(e,t){var r;return((r=this.$doc)==null?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)==null?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new ky(t,this)}get $doc(){return this.$pos(0)}};function Bn(n){return new oi({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ee(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),u=c+o.length;if(go(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&s.delete(u,t.to),c>t.from&&s.delete(t.from+a,c);const f=t.from+a+o.length;s.addMark(t.from+a,f,n.type.create(i||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function Au(n){return new oi({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ee(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let l=t.to;const a=n.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,o+r[0].length-1),s.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;s.insert(c,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:n.undoable})}function Eo(n){return new oi({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=ee(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function Vn(n){return new oi({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=ee(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&Ss(a,n.type,s);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const g=p.filter(y=>h.includes(y.type.name));o.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&zt(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)},undoable:n.undoable})}function Ey(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof $){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function My(n,e,t={}){const{state:r}=e,{doc:i,tr:s}=r,o=n;i.descendants((l,a)=>{const c=s.mapping.map(a),u=s.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==o)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});s.removeMark(c,u,n.type),s.addMark(c,u,h)}}),s.docChanged&&e.view.dispatch(s)}var ze=class If extends ko{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new If(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function yn(n){return new og({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=ee(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(go(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===n.type&&y!==p.mark.type)).filter(p=>p.to>d).length)return null;f<t.to&&o.delete(f,t.to),d>t.from&&o.delete(t.from+u,d),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}function Ru(n){return m.customRef((e,t)=>({get(){return e(),n},set(r){n=r,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}}))}var vy=class extends Cy{constructor(n={}){return super(n),this.contentComponent=null,this.appContext=null,this.reactiveState=Ru(this.view.state),this.reactiveExtensionStorage=Ru(this.extensionStorage),this.on("beforeTransaction",({nextState:e})=>{this.reactiveState.value=e,this.reactiveExtensionStorage.value=this.extensionStorage}),m.markRaw(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(n,e){const t=super.registerPlugin(n,e);return this.reactiveState&&(this.reactiveState.value=t),t}unregisterPlugin(n){const e=super.unregisterPlugin(n);return this.reactiveState&&e&&(this.reactiveState.value=e),e}},Ty=m.defineComponent({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(n){const e=m.ref(),t=m.getCurrentInstance();return m.watchEffect(()=>{const r=n.editor;r&&r.options.element&&e.value&&m.nextTick(()=>{var i;if(!e.value||!((i=r.view.dom)!=null&&i.firstChild))return;const s=m.unref(e.value);e.value.append(r.view.dom),r.contentComponent=t.ctx._,t&&(r.appContext={...t.appContext,provides:t.provides}),r.setOptions({element:s}),r.createNodeViews()})}),m.onBeforeUnmount(()=>{const r=n.editor;r&&(r.contentComponent=null,r.appContext=null)}),{rootEl:e}},render(){return m.h("div",{ref:n=>{this.rootEl=n}})}});m.defineComponent({name:"NodeViewContent",props:{as:{type:String,default:"div"}},render(){return m.h(this.as,{style:{whiteSpace:"pre-wrap"},"data-node-view-content":""})}}),m.defineComponent({name:"NodeViewWrapper",props:{as:{type:String,default:"div"}},inject:["onDragStart","decorationClasses"],render(){var n,e;return m.h(this.as,{class:this.decorationClasses,style:{whiteSpace:"normal"},"data-node-view-wrapper":"",onDragstart:this.onDragStart},(e=(n=this.$slots).default)==null?void 0:e.call(n))}});var Oy=(n={})=>{const e=m.shallowRef();return m.onMounted(()=>{e.value=new vy(n)}),m.onBeforeUnmount(()=>{var t,r,i;const s=(t=e.value)==null?void 0:t.view.dom,o=s?.cloneNode(!0);(r=s?.parentNode)==null||r.replaceChild(o,s),(i=e.value)==null||i.destroy()}),e};m.defineComponent({name:"MarkViewContent",props:{as:{type:String,default:"span"}},render(){return m.h(this.as,{style:{whiteSpace:"inherit"},"data-mark-view-content":""})}});const Ny={class:"sus-emoji-panel grid"},Ay=["onClick","src","alt","title"],Ry=m.defineComponent({__name:"index",props:{emoji:{},editor:{}},setup(n){const e=n;function t(r){e.editor?.commands.insertContent({type:"emoji",attrs:{name:r.name,src:r.fallbackImage}}),e.emoji.showPanel=!1}return(r,i)=>(m.openBlock(),m.createElementBlock("div",Ny,[(m.openBlock(!0),m.createElementBlock(m.Fragment,null,m.renderList(n.emoji.emojis,s=>(m.openBlock(),m.createElementBlock("div",null,[m.createElementVNode("img",{onClick:o=>t(s),class:"sus-emoji-item",src:s.fallbackImage,alt:s.name,title:`:${s.name}:`},null,8,Ay)]))),256))]))}}),bn=(n,e)=>{const t=n.__vccOpts||n;for(const[r,i]of e)t[r]=i;return t},Dy=bn(Ry,[["__scopeId","data-v-4b6da5f8"]]);var di=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},Iy=/^\s*>\s$/,Py=ze.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return di("blockquote",{...ce(this.options.HTMLAttributes,n),children:di("slot",{})})},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Vn({find:Iy,type:this.type})]}}),Ly=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,By=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Vy=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,$y=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,zy=gn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return di("strong",{...ce(this.options.HTMLAttributes,n),children:di("slot",{})})},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Bn({find:Ly,type:this.type}),Bn({find:Vy,type:this.type})]},addPasteRules(){return[yn({find:By,type:this.type}),yn({find:$y,type:this.type})]}}),_y=/(^|[^`])`([^`]+)`(?!`)$/,Hy=/(^|[^`])`([^`]+)`(?!`)/g,Fy=gn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Bn({find:_y,type:this.type})]},addPasteRules(){return[yn({find:Hy,type:this.type})]}}),Mo=4,jy=/^```([a-z]+)?[\s\n]$/,Uy=/^~~~([a-z]+)?[\s\n]$/,Du=ze.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Mo,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const s=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",ce(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Mo,{state:r}=n,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(t);return o?n.commands.insertContent(l):n.commands.command(({tr:a})=>{const{from:c,to:u}=i,h=r.doc.textBetween(c,u,`
|
|
86
86
|
`,`
|
|
87
87
|
`).split(`
|
|
88
88
|
`).map(p=>l+p).join(`
|
|
@@ -96,11 +96,11 @@ img.ProseMirror-separator {
|
|
|
96
96
|
`);return l.replaceWith(a,c,r.schema.text(f)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
97
97
|
|
|
98
98
|
`);return!s||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(H.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[Eo({find:jy,type:this.type,getAttributes:n=>({language:n[1]})}),Eo({find:Uy,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new se({key:new le("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!t||!s)return!1;const{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
|
|
99
|
-
`));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(F.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),Wy=Du,Ky
|
|
100
|
-
`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Jy=$e.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ce(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Eo({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),Gy=$e.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ce(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Ey(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,i=n();return fu(t)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:s,dispatch:o})=>{var l;if(o){const{$to:a}=s.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(F.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(V.create(s.doc,a.pos)):s.setSelection(F.create(s.doc,a.pos));else{const u=(l=a.parent.type.contentMatch.defaultType)==null?void 0:l.create();u&&(s.insert(c,u),s.setSelection(F.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Au({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Yy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Xy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Qy=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Zy=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,e0=gn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Bn({find:Yy,type:this.type}),Bn({find:Qy,type:this.type})]},addPasteRules(){return[yn({find:Xy,type:this.type}),yn({find:Zy,type:this.type})]}});const t0="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",n0="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",vo="numeric",To="ascii",Oo="alpha",pr="asciinumeric",mr="alphanumeric",No="domain",Iu="emoji",r0="scheme",i0="slashscheme",Ao="whitespace";function s0(n,e){return n in e||(e[n]=[]),e[n]}function wn(n,e,t){e[vo]&&(e[pr]=!0,e[mr]=!0),e[To]&&(e[pr]=!0,e[Oo]=!0),e[pr]&&(e[mr]=!0),e[Oo]&&(e[mr]=!0),e[mr]&&(e[No]=!0),e[Iu]&&(e[No]=!0);for(const r in e){const i=s0(r,t);i.indexOf(n)<0&&i.push(n)}}function o0(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Fe(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Fe.groups={},Fe.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(n))return s}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let i=0;i<n.length;i++)this.tt(n[i],e,t,r)},tr(n,e,t,r){r=r||Fe.groups;let i;return e&&e.j?i=e:(i=new Fe(e),t&&r&&wn(e,t,r)),this.jr.push([n,i]),i},ts(n,e,t,r){let i=this;const s=n.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(n[o]);return i.tt(n[s-1],e,t,r)},tt(n,e,t,r){r=r||Fe.groups;const i=this;if(e&&e.j)return i.j[n]=e,e;const s=e;let o,l=i.go(n);if(l?(o=new Fe,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Fe,s){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(o0(o.t,r),t);wn(s,a,r)}else t&&wn(s,t,r);o.t=s}return i.j[n]=o,o}};const G=(n,e,t,r,i)=>n.ta(e,t,r,i),de=(n,e,t,r,i)=>n.tr(e,t,r,i),Pu=(n,e,t,r,i)=>n.ts(e,t,r,i),E=(n,e,t,r,i)=>n.tt(e,t,r,i),Tt="WORD",Ro="UWORD",Lu="ASCIINUMERICAL",Bu="ALPHANUMERICAL",gr="LOCALHOST",Do="TLD",Io="UTLD",fi="SCHEME",Vn="SLASH_SCHEME",Po="NUM",Lo="WS",Bo="NL",yr="OPENBRACE",br="CLOSEBRACE",hi="OPENBRACKET",pi="CLOSEBRACKET",mi="OPENPAREN",gi="CLOSEPAREN",yi="OPENANGLEBRACKET",bi="CLOSEANGLEBRACKET",wi="FULLWIDTHLEFTPAREN",ki="FULLWIDTHRIGHTPAREN",xi="LEFTCORNERBRACKET",Si="RIGHTCORNERBRACKET",Ci="LEFTWHITECORNERBRACKET",Ei="RIGHTWHITECORNERBRACKET",Mi="FULLWIDTHLESSTHAN",vi="FULLWIDTHGREATERTHAN",Ti="AMPERSAND",Oi="APOSTROPHE",Ni="ASTERISK",Yt="AT",Ai="BACKSLASH",Ri="BACKTICK",Di="CARET",Xt="COLON",_o="COMMA",Ii="DOLLAR",ct="DOT",Pi="EQUALS",Vo="EXCLAMATION",Qe="HYPHEN",wr="PERCENT",Li="PIPE",Bi="PLUS",_i="POUND",kr="QUERY",$o="QUOTE",_u="FULLWIDTHMIDDLEDOT",zo="SEMI",ut="SLASH",xr="TILDE",Vi="UNDERSCORE",Vu="EMOJI",$i="SYM";var $u=Object.freeze({__proto__:null,ALPHANUMERICAL:Bu,AMPERSAND:Ti,APOSTROPHE:Oi,ASCIINUMERICAL:Lu,ASTERISK:Ni,AT:Yt,BACKSLASH:Ai,BACKTICK:Ri,CARET:Di,CLOSEANGLEBRACKET:bi,CLOSEBRACE:br,CLOSEBRACKET:pi,CLOSEPAREN:gi,COLON:Xt,COMMA:_o,DOLLAR:Ii,DOT:ct,EMOJI:Vu,EQUALS:Pi,EXCLAMATION:Vo,FULLWIDTHGREATERTHAN:vi,FULLWIDTHLEFTPAREN:wi,FULLWIDTHLESSTHAN:Mi,FULLWIDTHMIDDLEDOT:_u,FULLWIDTHRIGHTPAREN:ki,HYPHEN:Qe,LEFTCORNERBRACKET:xi,LEFTWHITECORNERBRACKET:Ci,LOCALHOST:gr,NL:Bo,NUM:Po,OPENANGLEBRACKET:yi,OPENBRACE:yr,OPENBRACKET:hi,OPENPAREN:mi,PERCENT:wr,PIPE:Li,PLUS:Bi,POUND:_i,QUERY:kr,QUOTE:$o,RIGHTCORNERBRACKET:Si,RIGHTWHITECORNERBRACKET:Ei,SCHEME:fi,SEMI:zo,SLASH:ut,SLASH_SCHEME:Vn,SYM:$i,TILDE:xr,TLD:Do,UNDERSCORE:Vi,UTLD:Io,UWORD:Ro,WORD:Tt,WS:Lo});const Ot=/[a-z]/,Sr=new RegExp("\\p{L}","u"),Ho=new RegExp("\\p{Emoji}","u"),Nt=/\d/,Fo=/\s/,zu="\r",jo=`
|
|
101
|
-
`,l0="️",a0="",Uo="";let
|
|
99
|
+
`));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(F.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),Wy=Du,Ky=ze.create({name:"doc",topNode:!0,content:"block+"}),qy=ze.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",ce(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
100
|
+
`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Jy=ze.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ce(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Eo({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),Gy=ze.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ce(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Ey(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,i=n();return fu(t)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(F.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection($.create(o.doc,a.pos)):o.setSelection(F.create(o.doc,a.pos));else{const u=s.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(o.insert(c,d),o.setSelection(F.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Au({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Yy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Xy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Qy=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Zy=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,e0=gn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Bn({find:Yy,type:this.type}),Bn({find:Qy,type:this.type})]},addPasteRules(){return[yn({find:Xy,type:this.type}),yn({find:Zy,type:this.type})]}});const t0="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",n0="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",vo="numeric",To="ascii",Oo="alpha",pr="asciinumeric",mr="alphanumeric",No="domain",Iu="emoji",r0="scheme",i0="slashscheme",Ao="whitespace";function s0(n,e){return n in e||(e[n]=[]),e[n]}function wn(n,e,t){e[vo]&&(e[pr]=!0,e[mr]=!0),e[To]&&(e[pr]=!0,e[Oo]=!0),e[pr]&&(e[mr]=!0),e[Oo]&&(e[mr]=!0),e[mr]&&(e[No]=!0),e[Iu]&&(e[No]=!0);for(const r in e){const i=s0(r,t);i.indexOf(n)<0&&i.push(n)}}function o0(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Fe(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Fe.groups={},Fe.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(n))return s}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let i=0;i<n.length;i++)this.tt(n[i],e,t,r)},tr(n,e,t,r){r=r||Fe.groups;let i;return e&&e.j?i=e:(i=new Fe(e),t&&r&&wn(e,t,r)),this.jr.push([n,i]),i},ts(n,e,t,r){let i=this;const s=n.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(n[o]);return i.tt(n[s-1],e,t,r)},tt(n,e,t,r){r=r||Fe.groups;const i=this;if(e&&e.j)return i.j[n]=e,e;const s=e;let o,l=i.go(n);if(l?(o=new Fe,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Fe,s){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(o0(o.t,r),t);wn(s,a,r)}else t&&wn(s,t,r);o.t=s}return i.j[n]=o,o}};const G=(n,e,t,r,i)=>n.ta(e,t,r,i),de=(n,e,t,r,i)=>n.tr(e,t,r,i),Pu=(n,e,t,r,i)=>n.ts(e,t,r,i),E=(n,e,t,r,i)=>n.tt(e,t,r,i),Tt="WORD",Ro="UWORD",Lu="ASCIINUMERICAL",Bu="ALPHANUMERICAL",gr="LOCALHOST",Do="TLD",Io="UTLD",fi="SCHEME",$n="SLASH_SCHEME",Po="NUM",Lo="WS",Bo="NL",yr="OPENBRACE",br="CLOSEBRACE",hi="OPENBRACKET",pi="CLOSEBRACKET",mi="OPENPAREN",gi="CLOSEPAREN",yi="OPENANGLEBRACKET",bi="CLOSEANGLEBRACKET",wi="FULLWIDTHLEFTPAREN",ki="FULLWIDTHRIGHTPAREN",xi="LEFTCORNERBRACKET",Si="RIGHTCORNERBRACKET",Ci="LEFTWHITECORNERBRACKET",Ei="RIGHTWHITECORNERBRACKET",Mi="FULLWIDTHLESSTHAN",vi="FULLWIDTHGREATERTHAN",Ti="AMPERSAND",Oi="APOSTROPHE",Ni="ASTERISK",Yt="AT",Ai="BACKSLASH",Ri="BACKTICK",Di="CARET",Xt="COLON",Vo="COMMA",Ii="DOLLAR",ct="DOT",Pi="EQUALS",$o="EXCLAMATION",Qe="HYPHEN",wr="PERCENT",Li="PIPE",Bi="PLUS",Vi="POUND",kr="QUERY",zo="QUOTE",Vu="FULLWIDTHMIDDLEDOT",_o="SEMI",ut="SLASH",xr="TILDE",$i="UNDERSCORE",$u="EMOJI",zi="SYM";var zu=Object.freeze({__proto__:null,ALPHANUMERICAL:Bu,AMPERSAND:Ti,APOSTROPHE:Oi,ASCIINUMERICAL:Lu,ASTERISK:Ni,AT:Yt,BACKSLASH:Ai,BACKTICK:Ri,CARET:Di,CLOSEANGLEBRACKET:bi,CLOSEBRACE:br,CLOSEBRACKET:pi,CLOSEPAREN:gi,COLON:Xt,COMMA:Vo,DOLLAR:Ii,DOT:ct,EMOJI:$u,EQUALS:Pi,EXCLAMATION:$o,FULLWIDTHGREATERTHAN:vi,FULLWIDTHLEFTPAREN:wi,FULLWIDTHLESSTHAN:Mi,FULLWIDTHMIDDLEDOT:Vu,FULLWIDTHRIGHTPAREN:ki,HYPHEN:Qe,LEFTCORNERBRACKET:xi,LEFTWHITECORNERBRACKET:Ci,LOCALHOST:gr,NL:Bo,NUM:Po,OPENANGLEBRACKET:yi,OPENBRACE:yr,OPENBRACKET:hi,OPENPAREN:mi,PERCENT:wr,PIPE:Li,PLUS:Bi,POUND:Vi,QUERY:kr,QUOTE:zo,RIGHTCORNERBRACKET:Si,RIGHTWHITECORNERBRACKET:Ei,SCHEME:fi,SEMI:_o,SLASH:ut,SLASH_SCHEME:$n,SYM:zi,TILDE:xr,TLD:Do,UNDERSCORE:$i,UTLD:Io,UWORD:Ro,WORD:Tt,WS:Lo});const Ot=/[a-z]/,Sr=new RegExp("\\p{L}","u"),Ho=new RegExp("\\p{Emoji}","u"),Nt=/\d/,Fo=/\s/,_u="\r",jo=`
|
|
101
|
+
`,l0="️",a0="",Uo="";let _i=null,Hi=null;function c0(n=[]){const e={};Fe.groups=e;const t=new Fe;_i==null&&(_i=Fu(t0)),Hi==null&&(Hi=Fu(n0)),E(t,"'",Oi),E(t,"{",yr),E(t,"}",br),E(t,"[",hi),E(t,"]",pi),E(t,"(",mi),E(t,")",gi),E(t,"<",yi),E(t,">",bi),E(t,"(",wi),E(t,")",ki),E(t,"「",xi),E(t,"」",Si),E(t,"『",Ci),E(t,"』",Ei),E(t,"<",Mi),E(t,">",vi),E(t,"&",Ti),E(t,"*",Ni),E(t,"@",Yt),E(t,"`",Ri),E(t,"^",Di),E(t,":",Xt),E(t,",",Vo),E(t,"$",Ii),E(t,".",ct),E(t,"=",Pi),E(t,"!",$o),E(t,"-",Qe),E(t,"%",wr),E(t,"|",Li),E(t,"+",Bi),E(t,"#",Vi),E(t,"?",kr),E(t,'"',zo),E(t,"/",ut),E(t,";",_o),E(t,"~",xr),E(t,"_",$i),E(t,"\\",Ai),E(t,"・",Vu);const r=de(t,Nt,Po,{[vo]:!0});de(r,Nt,r);const i=de(r,Ot,Lu,{[pr]:!0}),s=de(r,Sr,Bu,{[mr]:!0}),o=de(t,Ot,Tt,{[To]:!0});de(o,Nt,i),de(o,Ot,o),de(i,Nt,i),de(i,Ot,i);const l=de(t,Sr,Ro,{[Oo]:!0});de(l,Ot),de(l,Nt,s),de(l,Sr,l),de(s,Nt,s),de(s,Ot),de(s,Sr,s);const a=E(t,jo,Bo,{[Ao]:!0}),c=E(t,_u,Lo,{[Ao]:!0}),u=de(t,Fo,Lo,{[Ao]:!0});E(t,Uo,u),E(c,jo,a),E(c,Uo,u),de(c,Fo,u),E(u,_u),E(u,jo),de(u,Fo,u),E(u,Uo,u);const d=de(t,Ho,$u,{[Iu]:!0});E(d,"#"),de(d,Ho,d),E(d,l0,d);const f=E(d,a0);E(f,"#"),de(f,Ho,d);const h=[[Ot,o],[Nt,i]],p=[[Ot,null],[Sr,l],[Nt,s]];for(let g=0;g<_i.length;g++)Qt(t,_i[g],Do,Tt,h);for(let g=0;g<Hi.length;g++)Qt(t,Hi[g],Io,Ro,p);wn(Do,{tld:!0,ascii:!0},e),wn(Io,{utld:!0,alpha:!0},e),Qt(t,"file",fi,Tt,h),Qt(t,"mailto",fi,Tt,h),Qt(t,"http",$n,Tt,h),Qt(t,"https",$n,Tt,h),Qt(t,"ftp",$n,Tt,h),Qt(t,"ftps",$n,Tt,h),wn(fi,{scheme:!0,ascii:!0},e),wn($n,{slashscheme:!0,ascii:!0},e),n=n.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<n.length;g++){const y=n[g][0],k=n[g][1]?{[r0]:!0}:{[i0]:!0};y.indexOf("-")>=0?k[No]=!0:Ot.test(y)?Nt.test(y)?k[pr]=!0:k[To]=!0:k[vo]=!0,Pu(t,y,y,k)}return Pu(t,"localhost",gr,{ascii:!0}),t.jd=new Fe(zi),{start:t,tokens:Object.assign({groups:e},zu)}}function Hu(n,e){const t=u0(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[];let s=0,o=0;for(;o<r;){let l=n,a=null,c=0,u=null,d=-1,f=-1;for(;o<r&&(a=l.go(t[o]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=t[o].length,f++),c+=t[o].length,s+=t[o].length,o++;s-=d,o-=f,c-=d,i.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function u0(n){const e=[],t=n.length;let r=0;for(;r<t;){let i=n.charCodeAt(r),s,o=i<55296||i>56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function Qt(n,e,t,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];n.j[a]?s=n.j[a]:(s=new Fe(r),s.jr=i.slice(),n.j[a]=s),n=s}return s=new Fe(t),s.jr=i.slice(),n.j[e[o-1]]=s,s}function Fu(n){const e=[],t=[];let r=0,i="0123456789";for(;r<n.length;){let s=0;for(;i.indexOf(n[r+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}const Cr={defaultProtocol:"http",events:null,format:ju,formatHref:ju,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Wo(n,e=null){let t=Object.assign({},Cr);n&&(t=Object.assign(t,n instanceof Wo?n.o:n));const r=t.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=i}Wo.prototype={o:Cr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let i=this.o[n];return i&&(typeof i=="object"?(i=t.t in i?i[t.t]:Cr[n],typeof i=="function"&&r&&(i=i(e,t))):typeof i=="function"&&r&&(i=i(e,t.t,t)),i)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function ju(n){return n}function Uu(n,e){this.t="token",this.v=n,this.tk=e}Uu.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Cr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:i,attributes:o,content:s,eventListeners:d}}};function Fi(n,e){class t extends Uu{constructor(i,s){super(i,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const Wu=Fi("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ku=Fi("text"),d0=Fi("nl"),ji=Fi("url",{isLink:!0,toHref(n=Cr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==gr&&n[1].t===Xt}}),Ze=n=>new Fe(n);function f0({groups:n}){const e=n.domain.concat([Ti,Ni,Yt,Ai,Ri,Di,Ii,Pi,Qe,Po,wr,Li,Bi,Vi,ut,zi,xr,$i]),t=[Oi,Xt,Vo,ct,$o,wr,kr,zo,_o,yi,bi,yr,br,pi,hi,mi,gi,wi,ki,xi,Si,Ci,Ei,Mi,vi],r=[Ti,Oi,Ni,Ai,Ri,Di,Ii,Pi,Qe,yr,br,wr,Li,Bi,Vi,kr,ut,zi,xr,$i],i=Ze(),s=E(i,xr);G(s,r,s),G(s,n.domain,s);const o=Ze(),l=Ze(),a=Ze();G(i,n.domain,o),G(i,n.scheme,l),G(i,n.slashscheme,a),G(o,r,s),G(o,n.domain,o);const c=E(o,Yt);E(s,Yt,c),E(l,Yt,c),E(a,Yt,c);const u=E(s,ct);G(u,r,s),G(u,n.domain,s);const d=Ze();G(c,n.domain,d),G(d,n.domain,d);const f=E(d,ct);G(f,n.domain,d);const h=Ze(Wu);G(f,n.tld,h),G(f,n.utld,h),E(c,gr,h);const p=E(d,Qe);E(p,Qe,p),G(p,n.domain,d),G(h,n.domain,d),E(h,ct,f),E(h,Qe,p);const g=E(h,Xt);G(g,n.numeric,Wu);const y=E(o,Qe),w=E(o,ct);E(y,Qe,y),G(y,n.domain,o),G(w,r,s),G(w,n.domain,o);const k=Ze(ji);G(w,n.tld,k),G(w,n.utld,k),G(k,n.domain,o),G(k,r,s),E(k,ct,w),E(k,Qe,y),E(k,Yt,c);const C=E(k,Xt),R=Ze(ji);G(C,n.numeric,R);const M=Ze(ji),I=Ze();G(M,e,M),G(M,t,I),G(I,e,M),G(I,t,I),E(k,ut,M),E(R,ut,M);const T=E(l,Xt),V=E(a,Xt),W=E(V,ut),j=E(W,ut);G(l,n.domain,o),E(l,ct,w),E(l,Qe,y),G(a,n.domain,o),E(a,ct,w),E(a,Qe,y),G(T,n.domain,M),E(T,ut,M),E(T,kr,M),G(j,n.domain,M),G(j,e,M),E(j,ut,M);const K=[[yr,br],[hi,pi],[mi,gi],[yi,bi],[wi,ki],[xi,Si],[Ci,Ei],[Mi,vi]];for(let P=0;P<K.length;P++){const[Q,Z]=K[P],ke=E(M,Q);E(I,Q,ke),E(ke,Z,M);const he=Ze(ji);G(ke,e,he);const pe=Ze();G(ke,t),G(he,e,he),G(he,t,pe),G(pe,e,he),G(pe,t,pe),E(he,Z,M),E(pe,Z,M)}return E(i,gr,k),E(i,Bo,d0),{start:i,tokens:zu}}function h0(n,e,t){let r=t.length,i=0,s=[],o=[];for(;i<r;){let l=n,a=null,c=null,u=0,d=null,f=-1;for(;i<r&&!(a=l.go(t[i].t));)o.push(t[i++]);for(;i<r&&(c=a||l.go(t[i].t));)a=null,l=c,l.accepts()?(f=0,d=l):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(t[i]),i++);else{o.length>0&&(s.push(Ko(Ku,e,o)),o=[]),i-=f,u-=f;const h=d.t,p=t.slice(i-u,i);s.push(Ko(h,e,p))}}return o.length>0&&s.push(Ko(Ku,e,o)),s}function Ko(n,e,t){const r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}const p0=typeof console<"u"&&console&&console.warn||(()=>{}),m0="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",oe={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function g0(){return Fe.groups={},oe.scanner=null,oe.parser=null,oe.tokenQueue=[],oe.pluginQueue=[],oe.customSchemes=[],oe.initialized=!1,oe}function qu(n,e=!1){if(oe.initialized&&p0(`linkifyjs: already initialized - will not register custom scheme "${n}" ${m0}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
102
102
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
103
103
|
2. Cannot start or end with "-"
|
|
104
|
-
3. "-" cannot repeat`);oe.customSchemes.push([n,e])}function y0(){oe.scanner=c0(oe.customSchemes);for(let n=0;n<oe.tokenQueue.length;n++)oe.tokenQueue[n][1]({scanner:oe.scanner});oe.parser=f0(oe.scanner.tokens);for(let n=0;n<oe.pluginQueue.length;n++)oe.pluginQueue[n][1]({scanner:oe.scanner,parser:oe.parser});return oe.initialized=!0,oe}function qo(n){return oe.initialized||y0(),h0(oe.parser.start,n,Hu(oe.scanner.start,n))}qo.scan=Hu;function Ju(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Wo(t),i=qo(n),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}var Jo="[\0- -\u2029 ]",b0=new RegExp(Jo),w0=new RegExp(`${Jo}$`),k0=new RegExp(Jo,"g");function x0(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function S0(n){return new se({key:new le("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=Yc(t.doc,[...e]);if(lu(l).forEach(({newRange:c})=>{const u=Hm(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!w0.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(b0).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],g=d.pos+f.lastIndexOf(p);if(!p)return!1;const y=qo(p).map(w=>w.toObject(n.defaultProtocol));if(!x0(y))return!1;y.filter(w=>w.isLink).map(w=>({...w,from:g+w.start+1,to:g+w.end+1})).filter(w=>r.schema.marks.code?!r.doc.rangeHasMark(w.from,w.to,r.schema.marks.code):!0).filter(w=>n.validate(w.value)).filter(w=>n.shouldAutoLink(w.value)).forEach(w=>{go(w.from,w.to,r.doc).some(k=>k.mark.type===n.type)||o.addMark(w.from,w.to,n.type.create({href:w.href}))})}}),!!o.steps.length)return o}})}function C0(n){return new se({key:new le("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let u=r.target;const d=[];for(;u.nodeName!=="DIV";)d.push(u),u=u.parentNode;o=d.find(f=>f.nodeName==="A")}if(!o)return!1;const l=ou(e.state,n.type.name),a=(i=o?.href)!=null?i:l.href,c=(s=o?.target)!=null?s:l.target;return n.enableClickSelection&&n.editor.commands.extendMarkRange(n.type.name),o&&a?(window.open(a,c),!0):!1}}})}function E0(n){return new se({key:new le("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:i}=e,{selection:s}=i,{empty:o}=s;if(o)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Ju(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}function kn(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(k0,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Gu=gn.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(n=>{if(typeof n=="string"){qu(n);return}qu(n.scheme,n.optionalSlashes)})},onDestroy(){g0()},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:(n,e)=>!!kn(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!kn(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!kn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ce(this.options.HTMLAttributes,n),0]:["a",ce(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!kn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!kn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[yn({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=Ju(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!kn(o,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(s=>e.push({text:s.value,data:{href:s.href},index:s.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(S0({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!kn(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(C0({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(E0({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),M0=Gu,v0=Object.defineProperty,T0=(n,e)=>{for(var t in e)v0(n,t,{get:e[t],enumerable:!0})},O0="listItem",Yu="textStyle",Xu=/^\s*([-+*])\s$/,Qu=$e.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(O0,this.editor.getAttributes(Yu)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=_n({find:Xu,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=_n({find:Xu,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Yu),editor:this.editor})),[n]}}),Zu=$e.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",ce(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),N0={};T0(N0,{findListItemPos:()=>Er,getNextListDepth:()=>Go,handleBackspace:()=>Yo,handleDelete:()=>Xo,hasListBefore:()=>ed,hasListItemAfter:()=>A0,hasListItemBefore:()=>td,listItemHasSubList:()=>nd,nextListIsDeeper:()=>rd,nextListIsHigher:()=>id});var Er=(n,e)=>{const{$from:t}=e.selection,r=be(n,e.schema);let i=null,s=t.depth,o=t.pos,l=null;for(;s>0&&l===null;)i=t.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},Go=(n,e)=>{const t=Er(n,e);if(!t)return!1;const[,r]=Ym(e,n,t.$pos.pos+4);return r},ed=(n,e,t)=>{const{$anchor:r}=n.selection,i=Math.max(0,r.pos-2),s=n.doc.resolve(i).node();return!(!s||!t.includes(s.type.name))},td=(n,e)=>{var t;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((t=i.nodeBefore)==null?void 0:t.type.name)!==n)},nd=(n,e,t)=>{if(!t)return!1;const r=be(n,e.schema);let i=!1;return t.descendants(s=>{s.type===r&&(i=!0)}),i},Yo=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Gt(n.state,e)&&ed(n.state,e,t)){const{$anchor:l}=n.state.selection,a=n.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const u=c.at(-1);if(!u)return!1;const d=n.state.doc.resolve(a.start()+u.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!Gt(n.state,e)||!eg(n.state))return!1;const r=Er(e,n.state);if(!r)return!1;const s=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=nd(e,n.state,s);return td(e,n.state)&&!o?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},rd=(n,e)=>{const t=Go(n,e),r=Er(n,e);return!r||!t?!1:t>r.depth},id=(n,e)=>{const t=Go(n,e),r=Er(n,e);return!r||!t?!1:t<r.depth},Xo=(n,e)=>{if(!Gt(n.state,e)||!Zm(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:i}=t;return!t.empty&&r.sameParent(i)?!1:rd(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():id(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},A0=(n,e)=>{var t;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((t=i.nodeAfter)==null?void 0:t.type.name)!==n)},sd=ue.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Xo(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Xo(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Yo(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Yo(n,t,r)&&(e=!0)}),e}}}}),R0="listItem",od="textStyle",ld=/^(\d+)\.\s$/,ad=$e.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",ce(this.options.HTMLAttributes,t),0]:["ol",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(R0,this.editor.getAttributes(od)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=_n({find:ld,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=_n({find:ld,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(od)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),D0=/^\s*(\[([( |x])?\])\s$/,I0=$e.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:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",ce(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var d,f;l.ariaLabel=((f=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:f.call(d,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(n),s.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}const{checked:d}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const h=t();if(typeof h!="number")return!1;const p=f.doc.nodeAt(h);return f.setNodeMarkup(h,void 0,{...p?.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{i.setAttribute(u,d)}),i.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,s.append(l,o),i.append(s,a),Object.entries(e).forEach(([u,d])=>{i.setAttribute(u,d)}),{dom:i,contentDOM:a,update:u=>u.type!==this.type?!1:(i.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[_n({find:D0,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),P0=$e.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:n}){return["ul",ce(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ue.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Qu.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(Zu.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(sd.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(ad.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(I0.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(P0.configure(this.options.taskList)),n}});var L0=$e.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),B0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,_0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,V0=gn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Bn({find:B0,type:this.type})]},addPasteRules(){return[yn({find:_0,type:this.type})]}}),$0=$e.create({name:"text",group:"inline"}),z0=gn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function H0(n={}){return new se({view(e){return new F0(e,n)}})}class F0{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),g=d?p.bottom:p.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"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 t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=aa(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class fe extends H{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return fe.valid(r)?new fe(r):H.near(r)}content(){return N.empty}eq(e){return e instanceof fe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new fe(e.resolve(t.pos))}getBookmark(){return new Qo(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!j0(e)||!U0(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&fe.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(fe.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!V.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(fe.valid(l))return l}return null}}}fe.prototype.visible=!1,fe.findFrom=fe.findGapCursorFrom,H.jsonID("gapcursor",fe);class Qo{constructor(e){this.pos=e}map(e){return new Qo(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return fe.valid(t)?new fe(t):H.near(t)}}function j0(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function U0(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function W0(){return new se({props:{decorations:G0,createSelectionBetween(n,e,t){return e.pos==t.pos&&fe.valid(t)?new fe(t):null},handleClick:q0,handleKeyDown:K0,handleDOMEvents:{beforeinput:J0}}})}const K0=to({ArrowLeft:Ui("horiz",-1),ArrowRight:Ui("horiz",1),ArrowUp:Ui("vert",-1),ArrowDown:Ui("vert",1)});function Ui(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof F){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=fe.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new fe(c))),!0):!1}}function q0(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!fe.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&V.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new fe(r))),!0)}function J0(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof fe))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=S.empty;for(let o=r.length-1;o>=0;o--)i=S.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new N(i,0,0));return s.setSelection(F.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function G0(n){if(!(n.selection instanceof fe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ae.create(n.doc,[Ie.widget(n.selection.head,e,{key:"gapcursor"})])}var Wi=200,Ee=function(){};Ee.prototype.append=function(e){return e.length?(e=Ee.from(e),!this.length&&e||e.length<Wi&&this.leafAppend(e)||this.length<Wi&&e.leafPrepend(this)||this.appendInner(e)):this},Ee.prototype.prepend=function(e){return e.length?Ee.from(e).append(this):this},Ee.prototype.appendInner=function(e){return new Y0(this,e)},Ee.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Ee.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ee.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ee.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},Ee.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i},Ee.from=function(e){return e instanceof Ee?e:e&&e.length?new cd(e):Ee.empty};var cd=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Wi)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Wi)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(Ee);Ee.empty=new cd([]);var Y0=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ee);const X0=500;class nt{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,u.push(d);return}if(i){u.push(new dt(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new dt(p,void 0,void 0,c.length+u.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new nt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new dt(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),i||(a=f)}let c=o-r.depth;return c>Z0&&(l=Q0(l,c),o-=c),new nt(l.append(s),o)}remapping(e,t){let r=new Qn;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new nt(this.items.append(e.map(t=>new dt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(s.slice(a+1,h));y&&l++,r.push(new dt(p,g,y))}else r.push(new dt(p))},i);let c=[];for(let f=t;f<o;f++)c.push(new dt(s.maps[f]));let u=this.items.slice(0,i).append(c).append(r),d=new nt(u,l);return d.emptyItemCount()>X0&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.slice(r));u&&s++;let d=new dt(c.invert(),a,u),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new nt(Ee.from(i.reverse()),s)}}nt.empty=new nt(Ee.empty,0);function Q0(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class dt{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new dt(t.getMap().invert(),t,this.selection)}}}class Zt{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const Z0=20;function e1(n,e,t,r){let i=t.getMeta(xn),s;if(i)return i.historyState;t.getMeta(r1)&&(n=new Zt(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(xn))return o.getMeta(xn).redo?new Zt(n.done.addTransform(t,void 0,r,Ki(e)),n.undone,ud(t.mapping.maps),n.prevTime,n.prevComposition):new Zt(n.done,n.undone.addTransform(t,void 0,r,Ki(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!t1(t,n.prevRanges)),c=o?Zo(n.prevRanges,t.mapping):ud(t.mapping.maps);return new Zt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Ki(e)),nt.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Zt(n.done.rebased(t,s),n.undone.rebased(t,s),Zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Zt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function t1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function ud(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,o)=>e.push(s,o));return e}function Zo(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function n1(n,e,t){let r=Ki(e),i=xn.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new Zt(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(xn,{redo:t,historyState:a})}let el=!1,dd=null;function Ki(n){let e=n.plugins;if(dd!=e){el=!1,dd=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){el=!0;break}}return el}const xn=new le("history"),r1=new le("closeHistory");function i1(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new se({key:xn,state:{init(){return new Zt(nt.empty,nt.empty,null,0,-1)},apply(e,t,r){return e1(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?hd:r=="historyRedo"?pd:null;return i?(t.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function fd(n,e){return(t,r)=>{let i=xn.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=n1(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const hd=fd(!1,!0),pd=fd(!0,!0);ue.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new se({key:new le("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const i=this.options.limit;if(i==null||i===0){n=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const o=s-i,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=s-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var s1=ue.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[H0(this.options)]}});ue.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new se({key:new le("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return ae.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(i>=c&&i<=c+a.nodeSize-1))return!1;o+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(Ie.node(c,c+a.nodeSize,{class:this.options.className}))}),ae.create(n,s)}}})]}});var o1=ue.create({name:"gapCursor",addProseMirrorPlugins(){return[W0()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ee($(n,"allowGapCursor",t)))!=null?e:null}}}),l1=ue.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new se({key:new le("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!t)return null;const s=this.editor.isEmpty;return n.descendants((o,l)=>{const a=r>=l&&r<=l+o.nodeSize,c=!o.isLeaf&&si(o);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];s&&u.push(this.options.emptyEditorClass);const d=Ie.node(l,l+o.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:a}):this.options.placeholder});i.push(d)}return this.options.includeChildren}),ae.create(n,i)}}})]}});ue.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new se({key:new le("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||fu(t.selection)||n.view.dragging?null:ae.create(t.doc,[Ie.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function md({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var a1=ue.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const n=new le(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>(this.options.notAfter||[]).concat(this.options.node).includes(t.name));return[new se({key:n,appendTransaction:(t,r,i)=>{const{doc:s,tr:o,schema:l}=i,a=n.getState(i),c=s.content.size,u=l.nodes[this.options.node];if(a)return o.insert(c,u.create())},state:{init:(t,r)=>{const i=r.tr.doc.lastChild;return!md({node:i,types:e})},apply:(t,r)=>{if(!t.docChanged)return r;const i=t.doc.lastChild;return!md({node:i,types:e})}}})]}}),c1=ue.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>hd(n,e),redo:()=>({state:n,dispatch:e})=>pd(n,e)}},addProseMirrorPlugins(){return[i1(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),u1=ue.create({name:"starterKit",addExtensions(){var n,e,t,r;const i=[];return this.options.bold!==!1&&i.push($y.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(Py.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Qu.configure(this.options.bulletList)),this.options.code!==!1&&i.push(Fy.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(Du.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(Ky.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(s1.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(o1.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(qy.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(Jy.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(c1.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(Gy.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(e0.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Zu.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(sd.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&i.push(Gu.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(ad.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(L0.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(V0.configure(this.options.strike)),this.options.text!==!1&&i.push($0.configure(this.options.text)),this.options.underline!==!1&&i.push(z0.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&i.push(a1.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),d1=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,f1=$e.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",ce(this.options.HTMLAttributes,n)]},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[Au({find:d1,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),h1=f1;function p1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var tl,gd;function m1(){if(gd)return tl;gd=1;function n(b){return b instanceof Map?b.clear=b.delete=b.set=function(){throw new Error("map is read-only")}:b instanceof Set&&(b.add=b.clear=b.delete=function(){throw new Error("set is read-only")}),Object.freeze(b),Object.getOwnPropertyNames(b).forEach(x=>{const O=b[x],q=typeof O;(q==="object"||q==="function")&&!Object.isFrozen(O)&&n(O)}),b}class e{constructor(x){x.data===void 0&&(x.data={}),this.data=x.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function t(b){return b.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(b,...x){const O=Object.create(null);for(const q in b)O[q]=b[q];return x.forEach(function(q){for(const me in q)O[me]=q[me]}),O}const i="</span>",s=b=>!!b.scope,o=(b,{prefix:x})=>{if(b.startsWith("language:"))return b.replace("language:","language-");if(b.includes(".")){const O=b.split(".");return[`${x}${O.shift()}`,...O.map((q,me)=>`${q}${"_".repeat(me+1)}`)].join(" ")}return`${x}${b}`};class l{constructor(x,O){this.buffer="",this.classPrefix=O.classPrefix,x.walk(this)}addText(x){this.buffer+=t(x)}openNode(x){if(!s(x))return;const O=o(x.scope,{prefix:this.classPrefix});this.span(O)}closeNode(x){s(x)&&(this.buffer+=i)}value(){return this.buffer}span(x){this.buffer+=`<span class="${x}">`}}const a=(b={})=>{const x={children:[]};return Object.assign(x,b),x};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(x){this.top.children.push(x)}openNode(x){const O=a({scope:x});this.add(O),this.stack.push(O)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(x){return this.constructor._walk(x,this.rootNode)}static _walk(x,O){return typeof O=="string"?x.addText(O):O.children&&(x.openNode(O),O.children.forEach(q=>this._walk(x,q)),x.closeNode(O)),x}static _collapse(x){typeof x!="string"&&x.children&&(x.children.every(O=>typeof O=="string")?x.children=[x.children.join("")]:x.children.forEach(O=>{c._collapse(O)}))}}class u extends c{constructor(x){super(),this.options=x}addText(x){x!==""&&this.add(x)}startScope(x){this.openNode(x)}endScope(){this.closeNode()}__addSublanguage(x,O){const q=x.root;O&&(q.scope=`language:${O}`),this.add(q)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(b){return b?typeof b=="string"?b:b.source:null}function f(b){return g("(?=",b,")")}function h(b){return g("(?:",b,")*")}function p(b){return g("(?:",b,")?")}function g(...b){return b.map(O=>d(O)).join("")}function y(b){const x=b[b.length-1];return typeof x=="object"&&x.constructor===Object?(b.splice(b.length-1,1),x):{}}function w(...b){return"("+(y(b).capture?"":"?:")+b.map(q=>d(q)).join("|")+")"}function k(b){return new RegExp(b.toString()+"|").exec("").length-1}function C(b,x){const O=b&&b.exec(x);return O&&O.index===0}const R=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function M(b,{joinWith:x}){let O=0;return b.map(q=>{O+=1;const me=O;let ge=d(q),L="";for(;ge.length>0;){const D=R.exec(ge);if(!D){L+=ge;break}L+=ge.substring(0,D.index),ge=ge.substring(D.index+D[0].length),D[0][0]==="\\"&&D[1]?L+="\\"+String(Number(D[1])+me):(L+=D[0],D[0]==="("&&O++)}return L}).map(q=>`(${q})`).join(x)}const I=/\b\B/,T="[a-zA-Z]\\w*",_="[a-zA-Z_]\\w*",W="\\b\\d+(\\.\\d+)?",j="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",K="\\b(0b[01]+)",P="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Q=(b={})=>{const x=/^#![ ]*\//;return b.binary&&(b.begin=g(x,/.*\b/,b.binary,/\b.*/)),r({scope:"meta",begin:x,end:/$/,relevance:0,"on:begin":(O,q)=>{O.index!==0&&q.ignoreMatch()}},b)},Z={begin:"\\\\[\\s\\S]",relevance:0},ke={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Z]},he={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Z]},pe={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Me=function(b,x,O={}){const q=r({scope:"comment",begin:b,end:x,contains:[]},O);q.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const me=w("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return q.contains.push({begin:g(/[ ]+/,"(",me,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),q},yt=Me("//","$"),pl=Me("/\\*","\\*/"),Vw=Me("#","$"),$w={scope:"number",begin:W,relevance:0},zw={scope:"number",begin:j,relevance:0},Hw={scope:"number",begin:K,relevance:0},Fw={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Z,{begin:/\[/,end:/\]/,relevance:0,contains:[Z]}]},jw={scope:"title",begin:T,relevance:0},Uw={scope:"title",begin:_,relevance:0},Ww={begin:"\\.\\s*"+_,relevance:0};var ss=Object.freeze({__proto__:null,APOS_STRING_MODE:ke,BACKSLASH_ESCAPE:Z,BINARY_NUMBER_MODE:Hw,BINARY_NUMBER_RE:K,COMMENT:Me,C_BLOCK_COMMENT_MODE:pl,C_LINE_COMMENT_MODE:yt,C_NUMBER_MODE:zw,C_NUMBER_RE:j,END_SAME_AS_BEGIN:function(b){return Object.assign(b,{"on:begin":(x,O)=>{O.data._beginMatch=x[1]},"on:end":(x,O)=>{O.data._beginMatch!==x[1]&&O.ignoreMatch()}})},HASH_COMMENT_MODE:Vw,IDENT_RE:T,MATCH_NOTHING_RE:I,METHOD_GUARD:Ww,NUMBER_MODE:$w,NUMBER_RE:W,PHRASAL_WORDS_MODE:pe,QUOTE_STRING_MODE:he,REGEXP_MODE:Fw,RE_STARTERS_RE:P,SHEBANG:Q,TITLE_MODE:jw,UNDERSCORE_IDENT_RE:_,UNDERSCORE_TITLE_MODE:Uw});function Kw(b,x){b.input[b.index-1]==="."&&x.ignoreMatch()}function qw(b,x){b.className!==void 0&&(b.scope=b.className,delete b.className)}function Jw(b,x){x&&b.beginKeywords&&(b.begin="\\b("+b.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",b.__beforeBegin=Kw,b.keywords=b.keywords||b.beginKeywords,delete b.beginKeywords,b.relevance===void 0&&(b.relevance=0))}function Gw(b,x){Array.isArray(b.illegal)&&(b.illegal=w(...b.illegal))}function Yw(b,x){if(b.match){if(b.begin||b.end)throw new Error("begin & end are not supported with match");b.begin=b.match,delete b.match}}function Xw(b,x){b.relevance===void 0&&(b.relevance=1)}const Qw=(b,x)=>{if(!b.beforeMatch)return;if(b.starts)throw new Error("beforeMatch cannot be used with starts");const O=Object.assign({},b);Object.keys(b).forEach(q=>{delete b[q]}),b.keywords=O.keywords,b.begin=g(O.beforeMatch,f(O.begin)),b.starts={relevance:0,contains:[Object.assign(O,{endsParent:!0})]},b.relevance=0,delete O.beforeMatch},Zw=["of","and","for","in","not","or","if","then","parent","list","value"],ek="keyword";function pf(b,x,O=ek){const q=Object.create(null);return typeof b=="string"?me(O,b.split(" ")):Array.isArray(b)?me(O,b):Object.keys(b).forEach(function(ge){Object.assign(q,pf(b[ge],x,ge))}),q;function me(ge,L){x&&(L=L.map(D=>D.toLowerCase())),L.forEach(function(D){const U=D.split("|");q[U[0]]=[ge,tk(U[0],U[1])]})}}function tk(b,x){return x?Number(x):nk(b)?0:1}function nk(b){return Zw.includes(b.toLowerCase())}const mf={},Sn=b=>{console.error(b)},gf=(b,...x)=>{console.log(`WARN: ${b}`,...x)},Un=(b,x)=>{mf[`${b}/${x}`]||(console.log(`Deprecated as of ${b}. ${x}`),mf[`${b}/${x}`]=!0)},ls=new Error;function yf(b,x,{key:O}){let q=0;const me=b[O],ge={},L={};for(let D=1;D<=x.length;D++)L[D+q]=me[D],ge[D+q]=!0,q+=k(x[D-1]);b[O]=L,b[O]._emit=ge,b[O]._multi=!0}function rk(b){if(Array.isArray(b.begin)){if(b.skip||b.excludeBegin||b.returnBegin)throw Sn("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ls;if(typeof b.beginScope!="object"||b.beginScope===null)throw Sn("beginScope must be object"),ls;yf(b,b.begin,{key:"beginScope"}),b.begin=M(b.begin,{joinWith:""})}}function ik(b){if(Array.isArray(b.end)){if(b.skip||b.excludeEnd||b.returnEnd)throw Sn("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ls;if(typeof b.endScope!="object"||b.endScope===null)throw Sn("endScope must be object"),ls;yf(b,b.end,{key:"endScope"}),b.end=M(b.end,{joinWith:""})}}function sk(b){b.scope&&typeof b.scope=="object"&&b.scope!==null&&(b.beginScope=b.scope,delete b.scope)}function ok(b){sk(b),typeof b.beginScope=="string"&&(b.beginScope={_wrap:b.beginScope}),typeof b.endScope=="string"&&(b.endScope={_wrap:b.endScope}),rk(b),ik(b)}function lk(b){function x(L,D){return new RegExp(d(L),"m"+(b.case_insensitive?"i":"")+(b.unicodeRegex?"u":"")+(D?"g":""))}class O{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(D,U){U.position=this.position++,this.matchIndexes[this.matchAt]=U,this.regexes.push([U,D]),this.matchAt+=k(D)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const D=this.regexes.map(U=>U[1]);this.matcherRe=x(M(D,{joinWith:"|"}),!0),this.lastIndex=0}exec(D){this.matcherRe.lastIndex=this.lastIndex;const U=this.matcherRe.exec(D);if(!U)return null;const ve=U.findIndex((Tr,gl)=>gl>0&&Tr!==void 0),we=this.matchIndexes[ve];return U.splice(0,ve),Object.assign(U,we)}}class q{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(D){if(this.multiRegexes[D])return this.multiRegexes[D];const U=new O;return this.rules.slice(D).forEach(([ve,we])=>U.addRule(ve,we)),U.compile(),this.multiRegexes[D]=U,U}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(D,U){this.rules.push([D,U]),U.type==="begin"&&this.count++}exec(D){const U=this.getMatcher(this.regexIndex);U.lastIndex=this.lastIndex;let ve=U.exec(D);if(this.resumingScanAtSamePosition()&&!(ve&&ve.index===this.lastIndex)){const we=this.getMatcher(0);we.lastIndex=this.lastIndex+1,ve=we.exec(D)}return ve&&(this.regexIndex+=ve.position+1,this.regexIndex===this.count&&this.considerAll()),ve}}function me(L){const D=new q;return L.contains.forEach(U=>D.addRule(U.begin,{rule:U,type:"begin"})),L.terminatorEnd&&D.addRule(L.terminatorEnd,{type:"end"}),L.illegal&&D.addRule(L.illegal,{type:"illegal"}),D}function ge(L,D){const U=L;if(L.isCompiled)return U;[qw,Yw,ok,Qw].forEach(we=>we(L,D)),b.compilerExtensions.forEach(we=>we(L,D)),L.__beforeBegin=null,[Jw,Gw,Xw].forEach(we=>we(L,D)),L.isCompiled=!0;let ve=null;return typeof L.keywords=="object"&&L.keywords.$pattern&&(L.keywords=Object.assign({},L.keywords),ve=L.keywords.$pattern,delete L.keywords.$pattern),ve=ve||/\w+/,L.keywords&&(L.keywords=pf(L.keywords,b.case_insensitive)),U.keywordPatternRe=x(ve,!0),D&&(L.begin||(L.begin=/\B|\b/),U.beginRe=x(U.begin),!L.end&&!L.endsWithParent&&(L.end=/\B|\b/),L.end&&(U.endRe=x(U.end)),U.terminatorEnd=d(U.end)||"",L.endsWithParent&&D.terminatorEnd&&(U.terminatorEnd+=(L.end?"|":"")+D.terminatorEnd)),L.illegal&&(U.illegalRe=x(L.illegal)),L.contains||(L.contains=[]),L.contains=[].concat(...L.contains.map(function(we){return ak(we==="self"?L:we)})),L.contains.forEach(function(we){ge(we,U)}),L.starts&&ge(L.starts,D),U.matcher=me(U),U}if(b.compilerExtensions||(b.compilerExtensions=[]),b.contains&&b.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return b.classNameAliases=r(b.classNameAliases||{}),ge(b)}function bf(b){return b?b.endsWithParent||bf(b.starts):!1}function ak(b){return b.variants&&!b.cachedVariants&&(b.cachedVariants=b.variants.map(function(x){return r(b,{variants:null},x)})),b.cachedVariants?b.cachedVariants:bf(b)?r(b,{starts:b.starts?r(b.starts):null}):Object.isFrozen(b)?r(b):b}var ck="11.11.1";class uk extends Error{constructor(x,O){super(x),this.name="HTMLInjectionError",this.html=O}}const ml=t,wf=r,kf=Symbol("nomatch"),dk=7,xf=function(b){const x=Object.create(null),O=Object.create(null),q=[];let me=!0;const ge="Could not find the language '{}', did you forget to load/include a language module?",L={disableAutodetect:!0,name:"Plain text",contains:[]};let D={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function U(v){return D.noHighlightRe.test(v)}function ve(v){let z=v.className+" ";z+=v.parentNode?v.parentNode.className:"";const X=D.languageDetectRe.exec(z);if(X){const re=tn(X[1]);return re||(gf(ge.replace("{}",X[1])),gf("Falling back to no-highlight mode for this block.",v)),re?X[1]:"no-highlight"}return z.split(/\s+/).find(re=>U(re)||tn(re))}function we(v,z,X){let re="",xe="";typeof z=="object"?(re=v,X=z.ignoreIllegals,xe=z.language):(Un("10.7.0","highlight(lang, code, ...args) has been deprecated."),Un("10.7.0",`Please use highlight(code, options) instead.
|
|
105
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),xe=v,re=
|
|
106
|
-
`,1;if(kl>1e5&&kl>B.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ie+=Y,Y.length}const wt=tn(v);if(!wt)throw Sn(ge.replace("{}",v)),new Error('Unknown language: "'+v+'"');const Tk=lk(wt);let wl="",J=re||Tk;const Nf={},Ae=new D.__emitter(D);vk();let ie="",fs=0,Cn=0,kl=0,xl=!1;try{if(wt.__emitTokens)wt.__emitTokens(z,Ae);else{for(J.matcher.considerAll();;){kl++,xl?xl=!1:J.matcher.considerAll(),J.matcher.lastIndex=Cn;const A=J.matcher.exec(z);if(!A)break;const B=z.substring(Cn,A.index),Y=Of(B,A);Cn=A.index+Y}Of(z.substring(Cn))}return Ae.finalize(),wl=Ae.toHTML(),{language:v,value:wl,relevance:fs,illegal:!1,_emitter:Ae,_top:J}}catch(A){if(A.message&&A.message.includes("Illegal"))return{language:v,value:ml(z),illegal:!0,relevance:0,_illegalBy:{message:A.message,index:Cn,context:z.slice(Cn-100,Cn+100),mode:A.mode,resultSoFar:wl},_emitter:Ae};if(me)return{language:v,value:ml(z),illegal:!1,relevance:0,errorRaised:A,_emitter:Ae,_top:J};throw A}}function gl(v){const z={value:ml(v),illegal:!1,relevance:0,_top:L,_emitter:new D.__emitter(D)};return z._emitter.addText(v),z}function yl(v,z){z=z||D.languages||Object.keys(x);const X=gl(v),re=z.filter(tn).filter(Ef).map(qe=>Tr(qe,v,!1));re.unshift(X);const xe=re.sort((qe,bt)=>{if(qe.relevance!==bt.relevance)return bt.relevance-qe.relevance;if(qe.language&&bt.language){if(tn(qe.language).supersetOf===bt.language)return 1;if(tn(bt.language).supersetOf===qe.language)return-1}return 0}),[ot,nn]=xe,us=ot;return us.secondBest=nn,us}function fk(v,z,X){const re=z&&O[z]||X;v.classList.add("hljs"),v.classList.add(`language-${re}`)}function bl(v){let z=null;const X=ve(v);if(U(X))return;if(cs("before:highlightElement",{el:v,language:X}),v.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",v);return}if(v.children.length>0&&(D.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(v)),D.throwUnescapedHTML))throw new uk("One of your code blocks includes unescaped HTML.",v.innerHTML);z=v;const re=z.textContent,xe=X?we(re,{language:X,ignoreIllegals:!0}):yl(re);v.innerHTML=xe.value,v.dataset.highlighted="yes",fk(v,X,xe.language),v.result={language:xe.language,re:xe.relevance,relevance:xe.relevance},xe.secondBest&&(v.secondBest={language:xe.secondBest.language,relevance:xe.secondBest.relevance}),cs("after:highlightElement",{el:v,result:xe,text:re})}function hk(v){D=wf(D,v)}const pk=()=>{as(),Un("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function mk(){as(),Un("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Sf=!1;function as(){function v(){as()}if(document.readyState==="loading"){Sf||window.addEventListener("DOMContentLoaded",v,!1),Sf=!0;return}document.querySelectorAll(D.cssSelector).forEach(bl)}function gk(v,z){let X=null;try{X=z(b)}catch(re){if(Sn("Language definition for '{}' could not be registered.".replace("{}",v)),me)Sn(re);else throw re;X=L}X.name||(X.name=v),x[v]=X,X.rawDefinition=z.bind(null,b),X.aliases&&Cf(X.aliases,{languageName:v})}function yk(v){delete x[v];for(const z of Object.keys(O))O[z]===v&&delete O[z]}function bk(){return Object.keys(x)}function tn(v){return v=(v||"").toLowerCase(),x[v]||x[O[v]]}function Cf(v,{languageName:z}){typeof v=="string"&&(v=[v]),v.forEach(X=>{O[X.toLowerCase()]=z})}function Ef(v){const z=tn(v);return z&&!z.disableAutodetect}function wk(v){v["before:highlightBlock"]&&!v["before:highlightElement"]&&(v["before:highlightElement"]=z=>{v["before:highlightBlock"](Object.assign({block:z.el},z))}),v["after:highlightBlock"]&&!v["after:highlightElement"]&&(v["after:highlightElement"]=z=>{v["after:highlightBlock"](Object.assign({block:z.el},z))})}function kk(v){wk(v),q.push(v)}function xk(v){const z=q.indexOf(v);z!==-1&&q.splice(z,1)}function cs(v,z){const X=v;q.forEach(function(re){re[X]&&re[X](z)})}function Sk(v){return Un("10.7.0","highlightBlock will be removed entirely in v12.0"),Un("10.7.0","Please use highlightElement now."),bl(v)}Object.assign(b,{highlight:we,highlightAuto:yl,highlightAll:as,highlightElement:bl,highlightBlock:Sk,configure:hk,initHighlighting:pk,initHighlightingOnLoad:mk,registerLanguage:gk,unregisterLanguage:yk,listLanguages:bk,getLanguage:tn,registerAliases:Cf,autoDetection:Ef,inherit:wf,addPlugin:kk,removePlugin:xk}),b.debugMode=function(){me=!1},b.safeMode=function(){me=!0},b.versionString=ck,b.regex={concat:g,lookahead:f,either:w,optional:p,anyNumberOfTimes:h};for(const v in ss)typeof ss[v]=="object"&&n(ss[v]);return Object.assign(b,ss),b},Wn=xf({});return Wn.newInstance=()=>xf({}),tl=Wn,Wn.HighlightJS=Wn,Wn.default=Wn,tl}var g1=m1();const y1=p1(g1);function yd(n,e=[]){return n.flatMap(t=>{const r=[...e,...t.properties?t.properties.className:[]];return t.children?yd(t.children,r):{text:t.value,classes:r}})}function bd(n){return n.value||n.children||[]}function b1(n){return!!y1.getLanguage(n)}function wd({doc:n,name:e,lowlight:t,defaultLanguage:r}){const i=[];return ao(n,s=>s.type.name===e).forEach(s=>{var o;let l=s.pos+1;const a=s.node.attrs.language||r,c=t.listLanguages(),u=a&&(c.includes(a)||b1(a)||(o=t.registered)!=null&&o.call(t,a))?bd(t.highlight(a,s.node.textContent)):bd(t.highlightAuto(s.node.textContent));yd(u).forEach(d=>{const f=l+d.text.length;if(d.classes.length){const h=Ie.inline(l,f,{class:d.classes.join(" ")});i.push(h)}l=f})}),ae.create(n,i)}function w1(n){return typeof n=="function"}function k1({name:n,lowlight:e,defaultLanguage:t}){if(!["highlight","highlightAuto","listLanguages"].every(i=>w1(e[i])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new se({key:new le("lowlight"),state:{init:(i,{doc:s})=>wd({doc:s,name:n,lowlight:e,defaultLanguage:t}),apply:(i,s,o,l)=>{const a=o.selection.$head.parent.type.name,c=l.selection.$head.parent.type.name,u=ao(o.doc,f=>f.type.name===n),d=ao(l.doc,f=>f.type.name===n);return i.docChanged&&([a,c].includes(n)||d.length!==u.length||i.steps.some(f=>f.from!==void 0&&f.to!==void 0&&u.some(h=>h.pos>=f.from&&h.pos+h.node.nodeSize<=f.to)))?wd({doc:i.doc,name:n,lowlight:e,defaultLanguage:t}):s.map(i.mapping,i.doc)}},props:{decorations(i){return r.getState(i)}}});return r}var x1=Wy.extend({addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var n;return[...((n=this.parent)==null?void 0:n.call(this))||[],k1({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});const S1=Lf.createLowlight(),C1=x1.extend({addNodeView(){return({node:n,getPos:e,editor:t})=>{const r=document.createElement("div"),i=document.createElement("pre"),s=document.createElement("code"),o=document.createElement("select");o.setAttribute("class","code-select"),r.setAttribute("class","code-box");const l=["plaintext","java","javascript","html","shell"];return n.attrs.language&&l.lastIndexOf(n.attrs.language)<0&&l.push(n.attrs.language),l.forEach(a=>{const c=document.createElement("option");c.value=a,c.textContent=a,n.attrs.language===a&&(c.selected=!0),o.appendChild(c)}),o.addEventListener("change",a=>{const{value:c}=a.target;t.commands.updateAttributes("codeBlock",{language:c})}),i.appendChild(s),r.appendChild(o),r.appendChild(i),{dom:r,contentDOM:s}}}}).configure({lowlight:S1}),kd=["top","right","bottom","left"],xd=["start","end"],Sd=kd.reduce((n,e)=>n.concat(e,e+"-"+xd[0],e+"-"+xd[1]),[]),ft=Math.min,ze=Math.max,qi=Math.round,ht=n=>({x:n,y:n}),E1={left:"right",right:"left",bottom:"top",top:"bottom"},M1={start:"end",end:"start"};function nl(n,e,t){return ze(n,ft(e,t))}function At(n,e){return typeof n=="function"?n(e):n}function et(n){return n.split("-")[0]}function rt(n){return n.split("-")[1]}function Cd(n){return n==="x"?"y":"x"}function rl(n){return n==="y"?"height":"width"}const v1=new Set(["top","bottom"]);function pt(n){return v1.has(et(n))?"y":"x"}function il(n){return Cd(pt(n))}function Ed(n,e,t){t===void 0&&(t=!1);const r=rt(n),i=il(n),s=rl(i);let o=i==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Gi(o)),[o,Gi(o)]}function T1(n){const e=Gi(n);return[Ji(n),e,Ji(e)]}function Ji(n){return n.replace(/start|end/g,e=>M1[e])}const Md=["left","right"],vd=["right","left"],O1=["top","bottom"],N1=["bottom","top"];function A1(n,e,t){switch(n){case"top":case"bottom":return t?e?vd:Md:e?Md:vd;case"left":case"right":return e?O1:N1;default:return[]}}function R1(n,e,t,r){const i=rt(n);let s=A1(et(n),t==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(Ji)))),s}function Gi(n){return n.replace(/left|right|bottom|top/g,e=>E1[e])}function D1(n){return{top:0,right:0,bottom:0,left:0,...n}}function sl(n){return typeof n!="number"?D1(n):{top:n,right:n,bottom:n,left:n}}function $n(n){const{x:e,y:t,width:r,height:i}=n;return{width:r,height:i,top:t,left:e,right:e+r,bottom:t+i,x:e,y:t}}function Td(n,e,t){let{reference:r,floating:i}=n;const s=pt(e),o=il(e),l=rl(o),a=et(e),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[l]/2-i[l]/2;let h;switch(a){case"top":h={x:u,y:r.y-i.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-i.width,y:d};break;default:h={x:r.x,y:r.y}}switch(rt(e)){case"start":h[o]-=f*(t&&c?-1:1);break;case"end":h[o]+=f*(t&&c?-1:1);break}return h}const I1=async(n,e,t)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=t,l=s.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:n,floating:e,strategy:i}),{x:u,y:d}=Td(c,r,a),f=r,h={},p=0;for(let g=0;g<l.length;g++){const{name:y,fn:w}=l[g],{x:k,y:C,data:R,reset:M}=await w({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:h,rects:c,platform:o,elements:{reference:n,floating:e}});u=k??u,d=C??d,h={...h,[y]:{...h[y],...R}},M&&p<=50&&(p++,typeof M=="object"&&(M.placement&&(f=M.placement),M.rects&&(c=M.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:i}):M.rects),{x:u,y:d}=Td(c,f,a)),g=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:h}};async function zn(n,e){var t;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:a}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=At(e,n),p=sl(h),y=l[f?d==="floating"?"reference":"floating":d],w=$n(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(y)))==null||t?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),k=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),R=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},M=$n(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:C,strategy:a}):k);return{top:(w.top-M.top+p.top)/R.y,bottom:(M.bottom-w.bottom+p.bottom)/R.y,left:(w.left-M.left+p.left)/R.x,right:(M.right-w.right+p.right)/R.x}}const P1=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=At(n,e)||{};if(c==null)return{};const d=sl(u),f={x:t,y:r},h=il(i),p=rl(h),g=await o.getDimensions(c),y=h==="y",w=y?"top":"left",k=y?"bottom":"right",C=y?"clientHeight":"clientWidth",R=s.reference[p]+s.reference[h]-f[h]-s.floating[p],M=f[h]-s.reference[h],I=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let T=I?I[C]:0;(!T||!await(o.isElement==null?void 0:o.isElement(I)))&&(T=l.floating[C]||s.floating[p]);const _=R/2-M/2,W=T/2-g[p]/2-1,j=ft(d[w],W),K=ft(d[k],W),P=j,Q=T-g[p]-K,Z=T/2-g[p]/2+_,ke=nl(P,Z,Q),he=!a.arrow&&rt(i)!=null&&Z!==ke&&s.reference[p]/2-(Z<P?j:K)-g[p]/2<0,pe=he?Z<P?Z-P:Z-Q:0;return{[h]:f[h]+pe,data:{[h]:ke,centerOffset:Z-ke-pe,...he&&{alignmentOffset:pe}},reset:he}}});function L1(n,e,t){return(n?[...t.filter(i=>rt(i)===n),...t.filter(i=>rt(i)!==n)]:t.filter(i=>et(i)===i)).filter(i=>n?rt(i)===n||(e?Ji(i)!==i:!1):!0)}const B1=function(n){return n===void 0&&(n={}),{name:"autoPlacement",options:n,async fn(e){var t,r,i;const{rects:s,middlewareData:o,placement:l,platform:a,elements:c}=e,{crossAxis:u=!1,alignment:d,allowedPlacements:f=Sd,autoAlignment:h=!0,...p}=At(n,e),g=d!==void 0||f===Sd?L1(d||null,h,f):f,y=await zn(e,p),w=((t=o.autoPlacement)==null?void 0:t.index)||0,k=g[w];if(k==null)return{};const C=Ed(k,s,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==k)return{reset:{placement:g[0]}};const R=[y[et(k)],y[C[0]],y[C[1]]],M=[...((r=o.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:R}],I=g[w+1];if(I)return{data:{index:w+1,overflows:M},reset:{placement:I}};const T=M.map(j=>{const K=rt(j.placement);return[j.placement,K&&u?j.overflows.slice(0,2).reduce((P,Q)=>P+Q,0):j.overflows[0],j.overflows]}).sort((j,K)=>j[1]-K[1]),W=((i=T.filter(j=>j[2].slice(0,rt(j[0])?2:3).every(K=>K<=0))[0])==null?void 0:i[0])||T[0][0];return W!==l?{data:{index:w+1,overflows:M},reset:{placement:W}}:{}}}},_1=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=At(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const w=et(i),k=pt(l),C=et(l)===l,R=await(a.isRTL==null?void 0:a.isRTL(c.floating)),M=f||(C||!g?[Gi(l)]:T1(l)),I=p!=="none";!f&&I&&M.push(...R1(l,g,p,R));const T=[l,...M],_=await zn(e,y),W=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&W.push(_[w]),d){const Z=Ed(i,o,R);W.push(_[Z[0]],_[Z[1]])}if(j=[...j,{placement:i,overflows:W}],!W.every(Z=>Z<=0)){var K,P;const Z=(((K=s.flip)==null?void 0:K.index)||0)+1,ke=T[Z];if(ke&&(!(d==="alignment"?k!==pt(ke):!1)||j.every(Me=>pt(Me.placement)===k?Me.overflows[0]>0:!0)))return{data:{index:Z,overflows:j},reset:{placement:ke}};let he=(P=j.filter(pe=>pe.overflows[0]<=0).sort((pe,Me)=>pe.overflows[1]-Me.overflows[1])[0])==null?void 0:P.placement;if(!he)switch(h){case"bestFit":{var Q;const pe=(Q=j.filter(Me=>{if(I){const yt=pt(Me.placement);return yt===k||yt==="y"}return!0}).map(Me=>[Me.placement,Me.overflows.filter(yt=>yt>0).reduce((yt,pl)=>yt+pl,0)]).sort((Me,yt)=>Me[1]-yt[1])[0])==null?void 0:Q[0];pe&&(he=pe);break}case"initialPlacement":he=l;break}if(i!==he)return{reset:{placement:he}}}return{}}}};function Od(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function Nd(n){return kd.some(e=>n[e]>=0)}const V1=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:r="referenceHidden",...i}=At(n,e);switch(r){case"referenceHidden":{const s=await zn(e,{...i,elementContext:"reference"}),o=Od(s,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Nd(o)}}}case"escaped":{const s=await zn(e,{...i,altBoundary:!0}),o=Od(s,t.floating);return{data:{escapedOffsets:o,escaped:Nd(o)}}}default:return{}}}}};function Ad(n){const e=ft(...n.map(s=>s.left)),t=ft(...n.map(s=>s.top)),r=ze(...n.map(s=>s.right)),i=ze(...n.map(s=>s.bottom));return{x:e,y:t,width:r-e,height:i-t}}function $1(n){const e=n.slice().sort((i,s)=>i.y-s.y),t=[];let r=null;for(let i=0;i<e.length;i++){const s=e[i];!r||s.y-r.y>r.height/2?t.push([s]):t[t.length-1].push(s),r=s}return t.map(i=>$n(Ad(i)))}const z1=function(n){return n===void 0&&(n={}),{name:"inline",options:n,async fn(e){const{placement:t,elements:r,rects:i,platform:s,strategy:o}=e,{padding:l=2,x:a,y:c}=At(n,e),u=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(r.reference))||[]),d=$1(u),f=$n(Ad(u)),h=sl(l);function p(){if(d.length===2&&d[0].left>d[1].right&&a!=null&&c!=null)return d.find(y=>a>y.left-h.left&&a<y.right+h.right&&c>y.top-h.top&&c<y.bottom+h.bottom)||f;if(d.length>=2){if(pt(t)==="y"){const j=d[0],K=d[d.length-1],P=et(t)==="top",Q=j.top,Z=K.bottom,ke=P?j.left:K.left,he=P?j.right:K.right,pe=he-ke,Me=Z-Q;return{top:Q,bottom:Z,left:ke,right:he,width:pe,height:Me,x:ke,y:Q}}const y=et(t)==="left",w=ze(...d.map(j=>j.right)),k=ft(...d.map(j=>j.left)),C=d.filter(j=>y?j.left===k:j.right===w),R=C[0].top,M=C[C.length-1].bottom,I=k,T=w,_=T-I,W=M-R;return{top:R,bottom:M,left:I,right:T,width:_,height:W,x:I,y:R}}return f}const g=await s.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:o});return i.reference.x!==g.reference.x||i.reference.y!==g.reference.y||i.reference.width!==g.reference.width||i.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},H1=new Set(["left","top"]);async function F1(n,e){const{placement:t,platform:r,elements:i}=n,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=et(t),l=rt(t),a=pt(t)==="y",c=H1.has(o)?-1:1,u=s&&a?-1:1,d=At(e,n);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const j1=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:i,y:s,placement:o,middlewareData:l}=e,a=await F1(e,n);return o===((t=l.offset)==null?void 0:t.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+a.x,y:s+a.y,data:{...a,placement:o}}}}},U1=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:l={fn:y=>{let{x:w,y:k}=y;return{x:w,y:k}}},...a}=At(n,e),c={x:t,y:r},u=await zn(e,a),d=pt(et(i)),f=Cd(d);let h=c[f],p=c[d];if(s){const y=f==="y"?"top":"left",w=f==="y"?"bottom":"right",k=h+u[y],C=h-u[w];h=nl(k,h,C)}if(o){const y=d==="y"?"top":"left",w=d==="y"?"bottom":"right",k=p+u[y],C=p-u[w];p=nl(k,p,C)}const g=l.fn({...e,[f]:h,[d]:p});return{...g,data:{x:g.x-t,y:g.y-r,enabled:{[f]:s,[d]:o}}}}}},W1=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){var t,r;const{placement:i,rects:s,platform:o,elements:l}=e,{apply:a=()=>{},...c}=At(n,e),u=await zn(e,c),d=et(i),f=rt(i),h=pt(i)==="y",{width:p,height:g}=s.floating;let y,w;d==="top"||d==="bottom"?(y=d,w=f===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(w=d,y=f==="end"?"top":"bottom");const k=g-u.top-u.bottom,C=p-u.left-u.right,R=ft(g-u[y],k),M=ft(p-u[w],C),I=!e.middlewareData.shift;let T=R,_=M;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(_=C),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(T=k),I&&!f){const j=ze(u.left,0),K=ze(u.right,0),P=ze(u.top,0),Q=ze(u.bottom,0);h?_=p-2*(j!==0||K!==0?j+K:ze(u.left,u.right)):T=g-2*(P!==0||Q!==0?P+Q:ze(u.top,u.bottom))}await a({...e,availableWidth:_,availableHeight:T});const W=await o.getDimensions(l.floating);return p!==W.width||g!==W.height?{reset:{rects:!0}}:{}}}};function Yi(){return typeof window<"u"}function Hn(n){return Rd(n)?(n.nodeName||"").toLowerCase():"#document"}function Ke(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Rt(n){var e;return(e=(Rd(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Rd(n){return Yi()?n instanceof Node||n instanceof Ke(n).Node:!1}function it(n){return Yi()?n instanceof Element||n instanceof Ke(n).Element:!1}function mt(n){return Yi()?n instanceof HTMLElement||n instanceof Ke(n).HTMLElement:!1}function Dd(n){return!Yi()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Ke(n).ShadowRoot}const K1=new Set(["inline","contents"]);function Mr(n){const{overflow:e,overflowX:t,overflowY:r,display:i}=st(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&!K1.has(i)}const q1=new Set(["table","td","th"]);function J1(n){return q1.has(Hn(n))}const G1=[":popover-open",":modal"];function Xi(n){return G1.some(e=>{try{return n.matches(e)}catch{return!1}})}const Y1=["transform","translate","scale","rotate","perspective"],X1=["transform","translate","scale","rotate","perspective","filter"],Q1=["paint","layout","strict","content"];function ol(n){const e=ll(),t=it(n)?st(n):n;return Y1.some(r=>t[r]?t[r]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||X1.some(r=>(t.willChange||"").includes(r))||Q1.some(r=>(t.contain||"").includes(r))}function Z1(n){let e=en(n);for(;mt(e)&&!Fn(e);){if(ol(e))return e;if(Xi(e))return null;e=en(e)}return null}function ll(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const eb=new Set(["html","body","#document"]);function Fn(n){return eb.has(Hn(n))}function st(n){return Ke(n).getComputedStyle(n)}function Qi(n){return it(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function en(n){if(Hn(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Dd(n)&&n.host||Rt(n);return Dd(e)?e.host:e}function Id(n){const e=en(n);return Fn(e)?n.ownerDocument?n.ownerDocument.body:n.body:mt(e)&&Mr(e)?e:Id(e)}function Pd(n,e,t){var r;e===void 0&&(e=[]);const i=Id(n),s=i===((r=n.ownerDocument)==null?void 0:r.body),o=Ke(i);return s?(al(o),e.concat(o,o.visualViewport||[],Mr(i)?i:[],[])):e.concat(i,Pd(i,[]))}function al(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Ld(n){const e=st(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=mt(n),s=i?n.offsetWidth:t,o=i?n.offsetHeight:r,l=qi(t)!==s||qi(r)!==o;return l&&(t=s,r=o),{width:t,height:r,$:l}}function Bd(n){return it(n)?n:n.contextElement}function jn(n){const e=Bd(n);if(!mt(e))return ht(1);const t=e.getBoundingClientRect(),{width:r,height:i,$:s}=Ld(e);let o=(s?qi(t.width):t.width)/r,l=(s?qi(t.height):t.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const tb=ht(0);function _d(n){const e=Ke(n);return!ll()||!e.visualViewport?tb:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function nb(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==Ke(n)?!1:e}function vr(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const i=n.getBoundingClientRect(),s=Bd(n);let o=ht(1);e&&(r?it(r)&&(o=jn(r)):o=jn(n));const l=nb(s,t,r)?_d(s):ht(0);let a=(i.left+l.x)/o.x,c=(i.top+l.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(s){const f=Ke(s),h=r&&it(r)?Ke(r):r;let p=f,g=al(p);for(;g&&r&&h!==p;){const y=jn(g),w=g.getBoundingClientRect(),k=st(g),C=w.left+(g.clientLeft+parseFloat(k.paddingLeft))*y.x,R=w.top+(g.clientTop+parseFloat(k.paddingTop))*y.y;a*=y.x,c*=y.y,u*=y.x,d*=y.y,a+=C,c+=R,p=Ke(g),g=al(p)}}return $n({width:u,height:d,x:a,y:c})}function Zi(n,e){const t=Qi(n).scrollLeft;return e?e.left+t:vr(Rt(n)).left+t}function Vd(n,e){const t=n.getBoundingClientRect(),r=t.left+e.scrollLeft-Zi(n,t),i=t.top+e.scrollTop;return{x:r,y:i}}function rb(n){let{elements:e,rect:t,offsetParent:r,strategy:i}=n;const s=i==="fixed",o=Rt(r),l=e?Xi(e.floating):!1;if(r===o||l&&s)return t;let a={scrollLeft:0,scrollTop:0},c=ht(1);const u=ht(0),d=mt(r);if((d||!d&&!s)&&((Hn(r)!=="body"||Mr(o))&&(a=Qi(r)),mt(r))){const h=vr(r);c=jn(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=o&&!d&&!s?Vd(o,a):ht(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-a.scrollLeft*c.x+u.x+f.x,y:t.y*c.y-a.scrollTop*c.y+u.y+f.y}}function ib(n){return Array.from(n.getClientRects())}function sb(n){const e=Rt(n),t=Qi(n),r=n.ownerDocument.body,i=ze(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=ze(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-t.scrollLeft+Zi(n);const l=-t.scrollTop;return st(r).direction==="rtl"&&(o+=ze(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}const $d=25;function ob(n,e){const t=Ke(n),r=Rt(n),i=t.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,a=0;if(i){s=i.width,o=i.height;const u=ll();(!u||u&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}const c=Zi(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-h);p<=$d&&(s-=p)}else c<=$d&&(s+=c);return{width:s,height:o,x:l,y:a}}const lb=new Set(["absolute","fixed"]);function ab(n,e){const t=vr(n,!0,e==="fixed"),r=t.top+n.clientTop,i=t.left+n.clientLeft,s=mt(n)?jn(n):ht(1),o=n.clientWidth*s.x,l=n.clientHeight*s.y,a=i*s.x,c=r*s.y;return{width:o,height:l,x:a,y:c}}function zd(n,e,t){let r;if(e==="viewport")r=ob(n,t);else if(e==="document")r=sb(Rt(n));else if(it(e))r=ab(e,t);else{const i=_d(n);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return $n(r)}function Hd(n,e){const t=en(n);return t===e||!it(t)||Fn(t)?!1:st(t).position==="fixed"||Hd(t,e)}function cb(n,e){const t=e.get(n);if(t)return t;let r=Pd(n,[]).filter(l=>it(l)&&Hn(l)!=="body"),i=null;const s=st(n).position==="fixed";let o=s?en(n):n;for(;it(o)&&!Fn(o);){const l=st(o),a=ol(o);!a&&l.position==="fixed"&&(i=null),(s?!a&&!i:!a&&l.position==="static"&&!!i&&lb.has(i.position)||Mr(o)&&!a&&Hd(n,o))?r=r.filter(u=>u!==o):i=l,o=en(o)}return e.set(n,r),r}function ub(n){let{element:e,boundary:t,rootBoundary:r,strategy:i}=n;const o=[...t==="clippingAncestors"?Xi(e)?[]:cb(e,this._c):[].concat(t),r],l=o[0],a=o.reduce((c,u)=>{const d=zd(e,u,i);return c.top=ze(d.top,c.top),c.right=ft(d.right,c.right),c.bottom=ft(d.bottom,c.bottom),c.left=ze(d.left,c.left),c},zd(e,l,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function db(n){const{width:e,height:t}=Ld(n);return{width:e,height:t}}function fb(n,e,t){const r=mt(e),i=Rt(e),s=t==="fixed",o=vr(n,!0,s,e);let l={scrollLeft:0,scrollTop:0};const a=ht(0);function c(){a.x=Zi(i)}if(r||!r&&!s)if((Hn(e)!=="body"||Mr(i))&&(l=Qi(e)),r){const h=vr(e,!0,s,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else i&&c();s&&!r&&i&&c();const u=i&&!r&&!s?Vd(i,l):ht(0),d=o.left+l.scrollLeft-a.x-u.x,f=o.top+l.scrollTop-a.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function cl(n){return st(n).position==="static"}function Fd(n,e){if(!mt(n)||st(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return Rt(n)===t&&(t=t.ownerDocument.body),t}function jd(n,e){const t=Ke(n);if(Xi(n))return t;if(!mt(n)){let i=en(n);for(;i&&!Fn(i);){if(it(i)&&!cl(i))return i;i=en(i)}return t}let r=Fd(n,e);for(;r&&J1(r)&&cl(r);)r=Fd(r,e);return r&&Fn(r)&&cl(r)&&!ol(r)?t:r||Z1(n)||t}const hb=async function(n){const e=this.getOffsetParent||jd,t=this.getDimensions,r=await t(n.floating);return{reference:fb(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function pb(n){return st(n).direction==="rtl"}const mb={convertOffsetParentRelativeRectToViewportRelativeRect:rb,getDocumentElement:Rt,getClippingRect:ub,getOffsetParent:jd,getElementRects:hb,getClientRects:ib,getDimensions:db,getScale:jn,isElement:it,isRTL:pb},Ud=j1,Wd=B1,Kd=U1,qd=_1,Jd=W1,Gd=V1,Yd=P1,Xd=z1,Qd=(n,e,t)=>{const r=new Map,i={platform:mb,...t},s={...i.platform,_c:r};return I1(n,e,{...i,platform:s})};var ul,dl;if(typeof WeakMap<"u"){let n=new WeakMap;ul=e=>n.get(e),dl=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;ul=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},dl=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var Dt=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,i=e/this.width|0;let s=r+1,o=i+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:r,top:i,right:s,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:i,top:s,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?r==0:i==this.width)?null:this.map[s*this.width+(t<0?r-1:i)]:(t<0?s==0:o==this.height)?null:this.map[r+this.width*(t<0?s-1:o)]}rectBetween(n,e){const{left:t,right:r,top:i,bottom:s}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(i,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let i=n.left;i<n.right;i++){const s=r*this.width+i,o=this.map[s];t[o]||(t[o]=!0,!(i==n.left&&i&&this.map[s-1]==o||r==n.top&&r&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let r=0,i=0;;r++){const s=i+t.child(r).nodeSize;if(r==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<i;)o++;return o==l?s-1:this.map[o]}i=s}}static get(n){return ul(n)||dl(n,gb(n))}};function gb(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=yb(n),t=n.childCount,r=[];let i=0,s=null;const o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const d=n.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==d.childCount)break;const g=d.child(p),{colspan:y,rowspan:w,colwidth:k}=g.attrs;for(let C=0;C<w;C++){if(C+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-C});break}const R=i+C*e;for(let M=0;M<y;M++){r[R+M]==0?r[R+M]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:y-M});const I=k&&k[M];if(I){const T=(R+M)%e*2,_=o[T];_==null||_!=I&&o[T+1]==1?(o[T]=I,o[T+1]=1):_==I&&o[T+1]++}}}i+=y,u+=g.nodeSize}const f=(c+1)*e;let h=0;for(;i<f;)r[i++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new Dt(e,t,r,s);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&bb(l,o,n),l}function yb(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const i=n.child(r);let s=0;if(t)for(let o=0;o<r;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){const l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function bb(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;i<n.map.length;i++){const s=n.map[i];if(r[s])continue;r[s]=!0;const o=t.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const u=(i+c)%n.width,d=e[u*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=wb(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function wb(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function fl(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}new le("selectingCells");function kb(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Zd(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function xb(n){const e=n.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;const t=kb(e.$head)||Sb(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Sb(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ef(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function tf(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function nf(n,e,t){const r=n.node(-1),i=Dt.get(r),s=n.start(-1),o=i.nextCell(n.pos-s,e,t);return o==null?null:n.node(0).resolve(s+o)}function rf(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}var gt=class Pt extends H{constructor(e,t=e){const r=e.node(-1),i=Dt.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=s+u+1;return new pa(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(ef(r)&&ef(i)&&tf(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Pt.rowSelection(r,i):s&&this.isColSelection()?Pt.colSelection(r,i):new Pt(r,i)}return F.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=Dt.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let u=a*t.width+i.left,d=i.left;d<i.right;d++,u++){const f=t.map[u];if(s[f])continue;s[f]=!0;const h=t.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const g=i.left-h.left,y=h.right-i.right;if(g>0||y>0){let w=p.attrs;if(g>0&&(w=rf(w,0,g)),y>0&&(w=rf(w,w.colspan-y,y)),h.left<i.left){if(p=p.type.createAndFill(w),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(w)}`)}else p=p.type.create(w,p.content)}if(h.top<i.top||h.bottom>i.bottom){const w={...p.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top<i.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}c.push(p)}o.push(e.child(a).copy(S.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new N(S.from(l),1,1)}replace(e,t=N.empty){const r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){const{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?N.empty:t)}const s=H.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new N(S.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Dt.get(t),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),i+s[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=Dt.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(s+i.map[o.left])),l.bottom<i.height&&(t=a.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+i.map[l.left])),o.bottom<i.height&&(e=a.resolve(s+i.map[i.width*(i.height-1)+o.right-1]))),new Pt(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Dt.get(e),r=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(i,s)>0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof Pt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=Dt.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(s+i.map[o.top*i.width])),l.right<i.width&&(t=a.resolve(s+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+i.map[l.top*i.width])),o.right<i.width&&(e=a.resolve(s+i.map[i.width*(o.top+1)-1]))),new Pt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Pt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Pt(e.resolve(t),e.resolve(r))}getBookmark(){return new Cb(this.$anchorCell.pos,this.$headCell.pos)}};gt.prototype.visible=!1,H.jsonID("cell",gt);var Cb=class Pf{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Pf(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&tf(t,r)?new gt(t,r):H.near(r,1)}};new le("fix-tables");function sf(n){const e=n.selection,t=xb(n),r=t.node(-1),i=t.start(-1),s=Dt.get(r);return{...e instanceof gt?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(t.pos-i),tableStart:i,map:s,table:r}}function Eb(n){return function(e,t){if(!Zd(e))return!1;if(t){const r=fl(e.schema),i=sf(e),s=e.tr,o=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);t(s)}return!0}}function of(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function hl(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Eb(n):function(t,r){if(!Zd(t))return!1;if(r){const i=fl(t.schema),s=sf(t),o=t.tr,l=of("row",s,i),a=of("column",s,i),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?{left:0,top:u,right:1,bottom:s.map.height}:n=="row"?{left:u,top:0,right:s.map.width,bottom:1}:s,f=n=="column"?a?i.cell:i.header_cell:n=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,f,g.attrs)}),r(o)}return!0}}hl("row",{useDeprecatedLogic:!0}),hl("column",{useDeprecatedLogic:!0}),hl("cell",{useDeprecatedLogic:!0});function es(n,e){const t=n.selection;if(!(t instanceof gt))return!1;if(e){const r=n.tr,i=fl(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new N(i,0,0))}),r.docChanged&&e(r)}return!0}to({ArrowLeft:ns("horiz",-1),ArrowRight:ns("horiz",1),ArrowUp:ns("vert",-1),ArrowDown:ns("vert",1),"Shift-ArrowLeft":rs("horiz",-1),"Shift-ArrowRight":rs("horiz",1),"Shift-ArrowUp":rs("vert",-1),"Shift-ArrowDown":rs("vert",1),Backspace:es,"Mod-Backspace":es,Delete:es,"Mod-Delete":es});function ts(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function ns(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;if(s instanceof gt)return ts(t,r,H.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=lf(i,n,e);if(o==null)return!1;if(n=="horiz")return ts(t,r,H.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=nf(l,n,e);let c;return a?c=H.near(a,1):e<0?c=H.near(t.doc.resolve(l.before(-1)),-1):c=H.near(t.doc.resolve(l.after(-1)),1),ts(t,r,c)}}}function rs(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;let o;if(s instanceof gt)o=s;else{const a=lf(i,n,e);if(a==null)return!1;o=new gt(t.doc.resolve(a))}const l=nf(o.$headCell,n,e);return l?ts(t,r,new gt(o.$anchorCell,l)):!1}}function lf(n,e,t){if(!(n.state.selection instanceof F))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}new le("tableColumnResizing");function Mb(n,e){const t=Math.min(n.top,e.top),r=Math.max(n.bottom,e.bottom),i=Math.min(n.left,e.left),o=Math.max(n.right,e.right)-i,l=r-t,a=i,c=t;return new DOMRect(a,c,o,l)}var vb=class{constructor({editor:n,element:e,view:t,updateDelay:r=250,resizeDelay:i=60,shouldShow:s,appendTo:o,getReferencedVirtualElement:l,options:a}){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:d,from:f,to:h})=>{const{doc:p,selection:g}=d,{empty:y}=g,w=!p.textBetween(f,h).length&&wo(d.selection),k=this.element.contains(document.activeElement);return!(!(u.hasFocus()||k)||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 d;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u?.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||u?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,d)=>{const f=!d?.selection.eq(u.state.selection),h=!d?.doc.eq(u.state.doc);!f&&!h||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,f,h,d)},this.updateDelay))},this.updateHandler=(u,d,f,h)=>{const{composing:p}=u;if(p||!d&&!f)return;if(!this.getShouldShow(h)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:u})=>{u.getMeta("bubbleMenu")==="updatePosition"&&this.updatePosition()};var c;this.editor=n,this.element=e,this.view=t,this.updateDelay=r,this.resizeDelay=i,this.appendTo=o,this.scrollTarget=(c=a?.scrollTarget)!=null?c:window,this.getReferencedVirtualElement=l,this.floatingUIOptions={...this.floatingUIOptions,...a},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(t,t.state),this.getShouldShow()&&this.show()}get middlewares(){const n=[];return this.floatingUIOptions.flip&&n.push(qd(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&n.push(Kd(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&n.push(Ud(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&n.push(Yd(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&n.push(Jd(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&n.push(Wd(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&n.push(Gd(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&n.push(Xd(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),n}get virtualElement(){var n;const{selection:e}=this.editor.state,t=(n=this.getReferencedVirtualElement)==null?void 0:n.call(this);if(t)return t;const r=hu(this.view,e.from,e.to);let i={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(e instanceof V){let s=this.view.nodeDOM(e.from);const o=s.dataset.nodeViewWrapper?s:s.querySelector("[data-node-view-wrapper]");o&&(s=o),s&&(i={getBoundingClientRect:()=>s.getBoundingClientRect(),getClientRects:()=>[s.getBoundingClientRect()]})}if(e instanceof gt){const{$anchorCell:s,$headCell:o}=e,l=s?s.pos:o.pos,a=o?o.pos:s.pos,c=this.view.nodeDOM(l),u=this.view.nodeDOM(a);if(!c||!u)return;const d=c===u?c.getBoundingClientRect():Mb(c.getBoundingClientRect(),u.getBoundingClientRect());i={getBoundingClientRect:()=>d,getClientRects:()=>[d]}}return i}updatePosition(){const n=this.virtualElement;n&&Qd(n,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:r})=>{this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(n,e){const{state:t}=n,r=t.selection.from!==t.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(n,e);return}const i=!e?.selection.eq(n.state.selection),s=!e?.doc.eq(n.state.doc);this.updateHandler(n,i,s,e)}getShouldShow(n){var e;const{state:t}=this.view,{selection:r}=t,{ranges:i}=r,s=Math.min(...i.map(a=>a.$from.pos)),o=Math.max(...i.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:t,oldState:n,from:s,to:o})}show(){var n;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(n=e??this.view.dom.parentElement)==null||n.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)}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()}},af=n=>new se({key:typeof n.pluginKey=="string"?new le(n.pluginKey):n.pluginKey,view:e=>new vb({view:e,...n})});ue.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[af({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 Tb=m.defineComponent({name:"BubbleMenu",inheritAttrs:!1,props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:Object,default:void 0},shouldShow:{type:Function,default:null},getReferencedVirtualElement:{type:Function,default:void 0}},setup(n,{slots:e,attrs:t}){const r=m.ref(null);return m.onMounted(()=>{const{editor:i,options:s,pluginKey:o,resizeDelay:l,appendTo:a,shouldShow:c,getReferencedVirtualElement:u,updateDelay:d}=n;r.value&&(r.value.style.visibility="hidden",r.value.style.position="absolute",r.value.remove(),i.registerPlugin(af({editor:i,element:r.value,options:s,pluginKey:o,resizeDelay:l,appendTo:a,shouldShow:c,getReferencedVirtualElement:u,updateDelay:d})))}),m.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=n;s.unregisterPlugin(i)}),()=>{var i;return m.h(m.Teleport,{to:"body"},m.h("div",{...t,ref:r},(i=e.default)==null?void 0:i.call(e)))}}}),Ob=class{constructor({editor:n,element:e,view:t,options:r,appendTo:i,shouldShow:s}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:o,state:l})=>{const{selection:a}=l,{$anchor:c,empty:u}=a,d=c.depth===1,f=c.parent.isTextblock&&!c.parent.type.spec.code&&!c.parent.textContent&&c.parent.childCount===0&&!this.getTextContent(c.parent);return!(!o.hasFocus()||!u||!d||!f||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(o,l,a,c)=>{const{composing:u}=o;if(u||!l&&!a)return;if(!this.getShouldShow(c)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:o})=>{var l;if(this.preventHide){this.preventHide=!1;return}o?.relatedTarget&&((l=this.element.parentNode)!=null&&l.contains(o.relatedTarget))||o?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=n,this.element=e,this.view=t,this.appendTo=i,this.floatingUIOptions={...this.floatingUIOptions,...r},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(t,t.state),this.getShouldShow()&&this.show()}getTextContent(n){return iu(n,{textSerializers:ho(this.editor.schema)})}get middlewares(){const n=[];return this.floatingUIOptions.flip&&n.push(qd(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&n.push(Kd(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&n.push(Ud(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&n.push(Yd(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&n.push(Jd(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&n.push(Wd(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&n.push(Gd(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&n.push(Xd(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),n}getShouldShow(n){var e;const{state:t}=this.view,{selection:r}=t,{ranges:i}=r,s=Math.min(...i.map(a=>a.$from.pos)),o=Math.max(...i.map(a=>a.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:t,oldState:n,from:s,to:o})}updatePosition(){const{selection:n}=this.editor.state,e=hu(this.view,n.from,n.to);Qd({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:i,strategy:s})=>{this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${r}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(n,e){const t=!e?.selection.eq(n.state.selection),r=!e?.doc.eq(n.state.doc);this.updateHandler(n,t,r,e)}show(){var n;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(n=e??this.view.dom.parentElement)==null||n.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)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},cf=n=>new se({key:typeof n.pluginKey=="string"?new le(n.pluginKey):n.pluginKey,view:e=>new Ob({view:e,...n})});ue.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[cf({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}}),m.defineComponent({name:"FloatingMenu",inheritAttrs:!1,props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},options:{type:Object,default:()=>({})},appendTo:{type:Object,default:void 0},shouldShow:{type:Function,default:null}},setup(n,{slots:e,attrs:t}){const r=m.ref(null);return m.onMounted(()=>{const{pluginKey:i,editor:s,options:o,appendTo:l,shouldShow:a}=n;r.value&&(r.value.style.visibility="hidden",r.value.style.position="absolute",r.value.remove(),s.registerPlugin(cf({pluginKey:i,editor:s,element:r.value,options:o,appendTo:l,shouldShow:a})))}),m.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=n;s.unregisterPlugin(i)}),()=>{var i;return m.h(m.Teleport,{to:"body"},m.h("div",{...t,ref:r},(i=e.default)==null?void 0:i.call(e)))}}});const Nb={class:"sus-bubble-menu"},Ab=bn(m.defineComponent({__name:"BubbleMenu",props:{editor:{},showMenu:{type:Boolean}},setup(n){const e=n,t=m.ref(""),r=m.ref(!1);function i(){if(r.value){r.value=!1;return}t.value=e.editor?.getAttributes("link").href,r.value=!0}function s(){if(!t.value){e.editor?.chain().focus().extendMarkRange("link").unsetLink().run(),r.value=!1;return}e.editor?.chain().focus().extendMarkRange("link").setLink({href:t.value}).run(),r.value=!1}function o(){t.value&&window.open(e.editor?.getAttributes("link").href)}return(l,a)=>(m.openBlock(),m.createElementBlock(m.Fragment,null,[m.withDirectives(m.createElementVNode("div",{class:"inset-0 absolute",onClick:a[2]||(a[2]=c=>r.value=!1)},[m.createElementVNode("div",{class:"sus-link",onClick:a[1]||(a[1]=m.withModifiers(()=>{},["stop"]))},[m.withDirectives(m.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=c=>t.value=c),onKeyup:m.withKeys(s,["enter"]),class:"sus-link-input",type:"text",placeholder:"请输入链接"},null,544),[[m.vModelText,t.value]]),(m.openBlock(),m.createElementBlock("svg",{onClick:s,title:"确定",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},[...a[4]||(a[4]=[m.createElementVNode("rect",{width:"24",height:"24",fill:"none"},null,-1),m.createElementVNode("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5"},[m.createElementVNode("path",{"stroke-linejoin":"round",d:"m21 3l-9 9m0 0h5.344M12 12V6.656"}),m.createElementVNode("path",{d:"M2 12c0-4.714 0-7.071 1.464-8.536C4.93 2 7.286 2 12 2m10 10c0 4.714 0 7.071-1.465 8.535C19.072 22 16.714 22 12 22s-7.071 0-8.536-1.465c-.973-.973-1.3-2.342-1.409-4.535"})],-1)])])),(m.openBlock(),m.createElementBlock("svg",{onClick:o,title:"预览",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[...a[5]||(a[5]=[m.createElementVNode("rect",{width:"24",height:"24",fill:"none"},null,-1),m.createElementVNode("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5"},[m.createElementVNode("path",{"stroke-linejoin":"round",d:"m13 11l9-9m0 0h-5.344M22 2v5.344"}),m.createElementVNode("path",{d:"M2 12c0-4.714 0-7.071 1.464-8.536C4.93 2 7.286 2 12 2m10 10c0 4.714 0 7.071-1.465 8.535C19.072 22 16.714 22 12 22s-7.071 0-8.536-1.465c-.973-.973-1.3-2.342-1.409-4.535"})],-1)])]))])],512),[[m.vShow,r.value]]),n.editor&&n.showMenu?(m.openBlock(),m.createBlock(m.unref(Tb),{key:0,editor:n.editor,options:{placement:"bottom",offset:8}},{default:m.withCtx(()=>[m.createElementVNode("div",Nb,[m.createElementVNode("button",{onClick:i,title:"添加链接"}," 链接 "),m.createElementVNode("button",{onClick:a[3]||(a[3]=c=>n.editor.commands.unsetAllMarks()),title:"清除当前选中格式"}," 清除 ")])]),_:1},8,["editor"])):m.createCommentVNode("",!0)],64))}}),[["__scopeId","data-v-3f87b608"]]),Rb=$e.create({name:"emoji",inline:!0,group:"inline",atom:!0,addAttributes(){return{name:{default:null},src:{default:null}}},parseHTML(){return[{tag:"span[data-type='emoji']"}]},renderHTML({HTMLAttributes:n}){return["span",{"data-type":"emoji",class:"emoji",contenteditable:"false"},["img",ce(n,{src:n.src,alt:n.name,draggable:"false",loading:"lazy",align:"absmiddle"})]]}}),Db={class:"sus-comment relative flex flex-row w-full"},Ib={key:0,class:"sus-comment-avatar"},Pb=["src"],Lb={class:"sus-comment__main"},Bb={key:0,class:"sus-comment__info my-1"},_b={key:0,class:"sus-comment__info-input"},Vb=["placeholder"],$b={key:1,class:"sus-comment__info-input"},zb=["placeholder"],Hb={key:2,class:"sus-comment__info-input"},Fb=["placeholder"],jb={class:"relative"},Ub={class:"sus-comment__footer flex justify-between"},Wb={class:"flex flex-row items-center"},Kb={key:0,class:"p-1"},qb={key:1,class:"sus-upload p-1"},Jb={class:"sus-comment__toolbar relative flex"},Gb={class:"sus-comment__toolbar-mask absolute inset-0"},Yb={class:"sus-comment__extend flex"},Xb=["src"],Qb=["onClick"],uf=bn(m.defineComponent({__name:"index",props:{reply:{},toolBar:{},infoBar:{},placeholder:{default:"支持常见的markdown语法,如图片、代码块等"},comment:{}},emits:["on-save","on-cancel","add-image","update-avatar"],setup(n,{expose:e,emit:t}){class r{articleId="";userName="";userEmail="";userWebsite="";userAvatar="";content="";contentText="";replyName="";parentId="";notify=0;privacy=!1}const i=n;e({updateImage:M,updatePreviewImage:T});const s=t,o=m.reactive({emojis:i.toolBar?.emoji?.emojis||[],showPanel:!1}),l=i.reply?.userName,a=m.ref("在此处留下你的足迹吧!(支持markdown语法)"),c=m.reactive(new r),u=m.ref(""),d=m.ref(null),f=m.ref([]),h=m.ref(null),p=i.comment?.privacy||!1,g={enable:i.infoBar?.enable===void 0?!0:i.infoBar.enable,name:{show:i.infoBar?.name?.show===void 0?!0:i.infoBar.name.show,placeholder:i.infoBar?.name?.placeholder||"昵称(必填)"},website:{show:i.infoBar?.website?.show===void 0?!0:i.infoBar.website.show,placeholder:i.infoBar?.website?.placeholder||"网址(https://)",tips:i.infoBar?.website?.tips||"点击昵称时可跳转"},email:{show:i.infoBar?.email?.show===void 0?!0:i.infoBar.email.show,placeholder:i.infoBar?.email?.placeholder||"邮箱(不会公开,仅用于通知回复)",tips:i.infoBar?.email?.tips||"输入QQ邮箱自动获取头像"}},y=Oy({extensions:[u1,h1,l1.configure({placeholder:i.placeholder}),M0.configure({openOnClick:!1,defaultProtocol:"https"}),Rb,C1]});function w(){i.comment&&(c.privacy=i.comment.privacy||!1,c.notify=i.comment.notify||1,c.userName=i.comment.userName||"",c.userEmail=i.comment.userEmail||"",c.userWebsite=i.comment.userWebsite||"",c.userAvatar=i.comment.userAvatar||"",c.content=i.comment.content||"",c.articleId=i.comment.articleId||"")}async function k(){if(!(!y||!y.value)){if(u.value=y.value.getHTML(),c.userWebsite&&(c.userWebsite.concat("http://")||c.userWebsite.concat("https://")||(c.userWebsite="https://"+c.userWebsite)),localStorage.setItem("user",JSON.stringify(c)),localStorage.setItem("comment-content",u.value),i.reply.id!="0"){const K=i.reply.parentId;c.parentId=K==="0"?i.reply.id:K,c.replyName=i.reply.userName,a.value="@"+l+":"}c.content=u.value,c.contentText=y.value.getText(),s("on-save",c,h.value)}}function C(){localStorage.setItem("comment-content",""),s("on-cancel")}function R(){s("add-image",d.value,h.value)}function M(K){h.value||(h.value=[]),!h.value||h.value.length==0?h.value=K:h.value=I(h.value,K[0]),f.value=[];for(let P=0;P<h.value.length;P++)f.value.push(URL.createObjectURL(h.value[P]))}function I(K,P){return[...K,P]}function T(K){f.value=K}function _(){s("update-avatar",c)}function W(){c.notify==1?c.notify=0:c.notify=1}function j(K){try{if(!h.value||!h.value.length||h.value.length<=1){h.value=[],f.value=[];return}h.value?.splice(K,1),f.value.splice(K,1)}catch(P){console.log("remove image error: ",P),h.value=[],f.value=[]}}return m.onMounted(()=>{if(!y||!y.value)return;w();const K=localStorage.getItem("user");if(c.content&&c.content.length>3)y.value.commands.setContent(c.content);else{const P=localStorage.getItem("comment-content");P&&y.value.commands.setContent(P)}if(K){const P=JSON.parse(K);c.userName=P.userName,c.userEmail=P.userEmail,c.userWebsite=P.userWebsite,_()}c.notify=1}),(K,P)=>(m.openBlock(),m.createElementBlock("div",Db,[g.enable?(m.openBlock(),m.createElementBlock("div",Ib,[m.withDirectives(m.createElementVNode("img",{alt:"头像",src:c.userAvatar,class:"sus-avatar",onerror:"this.onerror=null,this.src='/error.webp'"},null,8,Pb),[[m.vShow,!!c.userAvatar]]),m.withDirectives(m.createElementVNode("span",{class:"sus-avatar-text flex w-full h-full items-center justify-center"},m.toDisplayString(c?.userName?.charAt(0)),513),[[m.vShow,!c.userAvatar]])])):m.createCommentVNode("",!0),m.createElementVNode("div",Lb,[g.enable?(m.openBlock(),m.createElementBlock("div",Bb,[g.name.show?(m.openBlock(),m.createElementBlock("div",_b,[m.withDirectives(m.createElementVNode("input",{class:"sus-input sus-username",placeholder:g.name.placeholder,"onUpdate:modelValue":P[0]||(P[0]=Q=>c.userName=Q),maxlength:"23"},null,8,Vb),[[m.vModelText,c.userName]])])):m.createCommentVNode("",!0),g.website.show?(m.openBlock(),m.createElementBlock("div",$b,[m.createVNode(m.unref(qn.OuOToolTip),{content:g.website.tips},{default:m.withCtx(()=>[m.withDirectives(m.createElementVNode("input",{class:"sus-input sus-web",placeholder:g.website.placeholder,"onUpdate:modelValue":P[1]||(P[1]=Q=>c.userWebsite=Q),maxlength:"35"},null,8,zb),[[m.vModelText,c.userWebsite]])]),_:1},8,["content"])])):m.createCommentVNode("",!0),g.email.show?(m.openBlock(),m.createElementBlock("div",Hb,[m.createVNode(m.unref(qn.OuOToolTip),{content:g.email.tips},{default:m.withCtx(()=>[m.withDirectives(m.createElementVNode("input",{onBlur:_,class:"sus-input sus-email",placeholder:g.email.placeholder,"onUpdate:modelValue":P[2]||(P[2]=Q=>c.userEmail=Q),maxlength:"35"},null,40,Fb),[[m.vModelText,c.userEmail]])]),_:1},8,["content"])])):m.createCommentVNode("",!0)])):m.createCommentVNode("",!0),m.createElementVNode("div",jb,[m.createVNode(Ab,{editor:m.unref(y),showMenu:n.toolBar?.bubbleMenu?.show},null,8,["editor","showMenu"]),m.withDirectives(m.createVNode(Dy,{class:"absolute bottom-2 left-1",emoji:o,editor:m.unref(y)},null,8,["emoji","editor"]),[[m.vShow,o.showPanel]]),m.createVNode(m.unref(Ty),{class:"sus-comment-input",editor:m.unref(y)},null,8,["editor"])]),m.createElementVNode("div",Ub,[m.createElementVNode("div",Wb,[o.emojis.length>=0?(m.openBlock(),m.createElementBlock("div",Kb,[(m.openBlock(),m.createElementBlock("svg",{onClick:P[3]||(P[3]=Q=>o.showPanel=!o.showPanel),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[...P[5]||(P[5]=[m.createStaticVNode('<g fill="none" data-v-978fa2fc><path stroke="currentColor" stroke-linecap="round" stroke-width="1.5" d="M9 16c.85.63 1.885 1 3 1s2.15-.37 3-1" data-v-978fa2fc></path><path fill="currentColor" d="M16 10.5c0 .828-.448 1.5-1 1.5s-1-.672-1-1.5s.448-1.5 1-1.5s1 .672 1 1.5" data-v-978fa2fc></path><ellipse cx="9" cy="10.5" fill="currentColor" rx="1" ry="1.5" data-v-978fa2fc></ellipse><path stroke="currentColor" stroke-linecap="round" stroke-width="1.5" d="M7 3.338A9.95 9.95 0 0 1 12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12c0-1.821.487-3.53 1.338-5" data-v-978fa2fc></path></g>',1)])]))])):m.createCommentVNode("",!0),n.toolBar?.image?(m.openBlock(),m.createElementBlock("div",qb,[m.createElementVNode("input",{ref_key:"imgRef",ref:d,onChange:R,type:"file",id:"upload-input",name:"image",accept:"image/*"},null,544),P[6]||(P[6]=m.createStaticVNode('<label for="upload-input" data-v-978fa2fc><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" data-v-978fa2fc><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="1.5" data-v-978fa2fc><path d="m2 12.5l1.752-1.533a2.3 2.3 0 0 1 3.14.105l4.29 4.29a2 2 0 0 0 2.564.222l.299-.21a3 3 0 0 1 3.731.225L21 18.5m-6-13h3.5m0 0H22m-3.5 0V9m0-3.5V2" data-v-978fa2fc></path><path d="M22 12c0 4.714 0 7.071-1.465 8.535C19.072 22 16.714 22 12 22s-7.071 0-8.536-1.465C2 19.072 2 16.714 2 12c0-1.128 0-2.122.02-3M12 2C7.286 2 4.929 2 3.464 3.464c-.424.425-.726.925-.94 1.536" data-v-978fa2fc></path></g></svg></label>',1))])):m.createCommentVNode("",!0),n.toolBar?.notify?(m.openBlock(),m.createElementBlock("div",{key:2,onClick:W,class:"p-1"},[m.withDirectives(m.createVNode(m.unref(qn.OuOToolTip),{content:"收到回复后通知"},{default:m.withCtx(()=>[...P[7]||(P[7]=[m.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[m.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",d:"M12 6v4m-4.5 9c.655 1.748 2.422 3 4.5 3q.367 0 .72-.05M16.5 19a4.5 4.5 0 0 1-1.302 1.84M9.107 2.674A6.5 6.5 0 0 1 12 2c3.727 0 6.75 3.136 6.75 7.005v.705a4.4 4.4 0 0 0 .692 2.375l1.108 1.724c1.011 1.575.239 3.716-1.52 4.214a25.8 25.8 0 0 1-14.06 0c-1.759-.498-2.531-2.639-1.52-4.213l1.108-1.725A4.4 4.4 0 0 0 5.25 9.71v-.705c0-1.074.233-2.092.65-3.002"})],-1)])]),_:1},512),[[m.vShow,c.notify===1]]),m.withDirectives(m.createVNode(m.unref(qn.OuOToolTip),{content:"收到回复后不通知"},{default:m.withCtx(()=>[...P[8]||(P[8]=[m.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[m.createElementVNode("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5"},[m.createElementVNode("path",{"stroke-linejoin":"round",d:"M10 9h4l-4 4h4"}),m.createElementVNode("path",{d:"M7.5 19c.655 1.748 2.422 3 4.5 3q.367 0 .72-.05M16.5 19a4.5 4.5 0 0 1-1.302 1.84M9.107 2.674A6.5 6.5 0 0 1 12 2c3.727 0 6.75 3.136 6.75 7.005v.705a4.4 4.4 0 0 0 .692 2.375l1.108 1.724c1.011 1.575.239 3.716-1.52 4.214a25.8 25.8 0 0 1-14.06 0c-1.759-.498-2.531-2.639-1.52-4.213l1.108-1.725A4.4 4.4 0 0 0 5.25 9.71v-.705c0-1.074.233-2.092.65-3.002"})])],-1)])]),_:1},512),[[m.vShow,c.notify!==1]])])):m.createCommentVNode("",!0)]),m.createElementVNode("div",{class:"sus-comment__footer-send flex justify-end my-2"},[m.createElementVNode("button",{class:"sus-button cancel mx-2",onClick:C},"取消"),m.createElementVNode("button",{class:"sus-button ok",onClick:k},"发送")])]),m.createElementVNode("div",Jb,[m.withDirectives(m.createVNode(m.unref(qn.OuOCheckBox),{modelValue:c.privacy,"onUpdate:modelValue":P[4]||(P[4]=Q=>c.privacy=Q),checked:m.unref(p)},{default:m.withCtx(()=>[...P[9]||(P[9]=[m.createTextVNode(" 仅博主可见 ",-1)])]),_:1},8,["modelValue","checked"]),[[m.vShow,n.toolBar?.privacy?.show]]),m.withDirectives(m.createElementVNode("div",Gb,null,512),[[m.vShow,n.toolBar?.privacy?.disable]])]),m.createElementVNode("div",Yb,[(m.openBlock(!0),m.createElementBlock(m.Fragment,null,m.renderList(f.value,(Q,Z)=>(m.openBlock(),m.createElementBlock("div",{class:"sus-comment__extend-img relative",key:Q},[m.createElementVNode("img",{class:"img-item",src:Q,alt:""},null,8,Xb),m.createElementVNode("div",{onClick:ke=>j(Z),class:"mask"},[...P[10]||(P[10]=[m.createStaticVNode('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" data-v-978fa2fc><g fill="none" stroke="currentColor" stroke-width="1.5" data-v-978fa2fc><path stroke-linecap="round" d="M20.5 6h-17m6 5l.5 5m4.5-5l-.5 5" data-v-978fa2fc></path><path d="M6.5 6h.11a2 2 0 0 0 1.83-1.32l.034-.103l.097-.291c.083-.249.125-.373.18-.479a1.5 1.5 0 0 1 1.094-.788C9.962 3 10.093 3 10.355 3h3.29c.262 0 .393 0 .51.019a1.5 1.5 0 0 1 1.094.788c.055.106.097.23.18.479l.097.291A2 2 0 0 0 17.5 6" data-v-978fa2fc></path><path stroke-linecap="round" d="M18.374 15.4c-.177 2.654-.266 3.981-1.131 4.79s-2.195.81-4.856.81h-.774c-2.66 0-3.99 0-4.856-.81c-.865-.809-.953-2.136-1.13-4.79l-.46-6.9m13.666 0l-.2 3" data-v-978fa2fc></path></g></svg>',1)])],8,Qb)]))),128))])])]))}}),[["__scopeId","data-v-978fa2fc"]]);function Zb(n){const e=new Date(n),t=e.getFullYear(),r=e.getMonth()+1,i=e.getDate(),s=new Date,o=s.getFullYear(),l=s.getMonth()+1,a=s.getDate();if(o===t&&l==r){const c=a-i;if(c===0)return"今天";if(c<7)return c+"天前"}return o===t?`${r}月${i}日`:`${t}年${r}月${i}日`}const ew={class:"sus-item__container relative"},tw={class:"sus-item-svg",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},nw={class:"flex flex-row"},rw={class:"sus-item__operate absolute flex"},iw={class:"sus-comment-aside"},sw={class:"sus-comment-avatar"},ow=["src"],lw={class:"sus-item-floor mt-2"},aw={class:"sus-item__main w-full overflow-hidden"},cw={class:"sus-item__user leading-loose"},uw=["rel","href"],dw={key:0,class:"sus-item-tag mx-1",title:"博主"},fw={key:1,class:"sus-item__content-name mx-1.5"},hw={class:"sus-item__user-date ml-3"},pw={key:0,class:"sus-item__content"},mw=["innerHTML"],gw={key:1,class:"sus-item__content"},yw=["innerHTML"],bw={key:0,class:"sus-item__info flex justify-end mx-1"},ww={class:"sus-item__info-area flex items-center"},kw={class:"sus-item__info-useragent flex items-center"},is=bn(m.defineComponent({__name:"item",props:{comment:{},lineHeight:{},showFooter:{type:Boolean},num:{default:1}},emits:["on-reply","on-remove"],setup(n,{emit:e}){const t=n,r=m.ref(),i=m.ref(),s=m.ref(!1),o=e;function l(){r.value.style.display="block",s.value=!1}function a(){const h=r?.value?.clientHeight||0,p=t.lineHeight*5;h>=p&&(s.value=!0)}function c(){o("on-reply",t.comment)}function u(){o("on-remove",t.comment)}function d(){t.comment.userAvatar||(t.comment.userAvatar="/error.webp")}function f(){const h=new Date(t.comment?.createdDate),p=new Date,g=new Date(p.getFullYear()-1,p.getMonth(),p.getDate());return h>g?"ugc noopener nofollow":"ugc noopener noreferrer nofollow"}return m.onMounted(()=>{d(),a()}),(h,p)=>(m.openBlock(),m.createElementBlock("div",ew,[m.withDirectives((m.openBlock(),m.createElementBlock("svg",tw,[...p[0]||(p[0]=[m.createElementVNode("rect",{width:"24",height:"24",fill:"none"},null,-1),m.createElementVNode("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5"},[m.createElementVNode("path",{d:"M21 7v-.281c0-2.19 0-3.285-.707-3.884c-.707-.6-1.788-.42-3.95-.059l-1.055.176c-1.64.273-2.46.41-3.288.41s-1.648-.137-3.288-.41l-1.054-.176c-2.162-.36-3.243-.54-3.95.059S3 4.529 3 6.719V12c0 5.49 4.239 8.155 6.899 9.286c.721.307 1.082.46 2.101.46c1.02 0 1.38-.153 2.101-.46C16.761 20.155 21 17.49 21 12v-1"}),m.createElementVNode("path",{d:"M6.5 9c.291-.583 1.077-1 2-1s1.709.417 2 1m3 0c.291-.583 1.077-1 2-1s1.709.417 2 1m-9 5s1.05 1 3.5 1s3.5-1 3.5-1"})],-1)])],512)),[[m.vShow,n.comment.band==="privacy"]]),m.createElementVNode("div",nw,[m.createElementVNode("div",rw,[m.withDirectives(m.createElementVNode("span",{onClick:u,class:"sus-item__operate-delete cursor-pointer"}," 删除 ",512),[[m.vShow,!n.comment.privacy&&n.comment.showEdit]]),m.withDirectives(m.createElementVNode("span",{onClick:c,class:"sus-item__operate-edit cursor-pointer"}," 编辑 ",512),[[m.vShow,!n.comment.privacy&&n.comment.showEdit]]),m.withDirectives(m.createElementVNode("span",{onClick:c,class:"sus-item__operate-reply cursor-pointer"}," 回复 ",512),[[m.vShow,!n.comment.privacy]])]),m.createElementVNode("div",iw,[m.createElementVNode("div",sw,[m.withDirectives(m.createElementVNode("img",{alt:"",class:"sus-avatar",src:n.comment.userAvatar,onerror:"this.onerror=null,this.src='/error.webp'"},null,8,ow),[[m.vShow,!!n.comment.userAvatar]]),m.withDirectives(m.createElementVNode("span",{class:"sus-avatar-text flex w-full h-full items-center justify-center"},m.toDisplayString(n.comment.userName.charAt(0)),513),[[m.vShow,!n.comment.userAvatar]])]),m.createElementVNode("p",lw,m.toDisplayString(n.num),1)]),m.createElementVNode("div",aw,[m.createElementVNode("div",cw,[m.createElementVNode("a",{target:"_blank",rel:f(),href:n.comment.userWebsite,class:m.normalizeClass([n.comment.tagName,"sus-item__user-name font-semibold ml-1 cursor-pointer"])},m.toDisplayString(n.comment.userName),11,uw),n.comment.tagName==="owner"?(m.openBlock(),m.createElementBlock("span",dw," 博主 ")):m.createCommentVNode("",!0),n.comment.replyName?(m.openBlock(),m.createElementBlock("span",fw,"@"+m.toDisplayString(n.comment.replyName),1)):m.createCommentVNode("",!0),m.createElementVNode("span",hw,m.toDisplayString(m.unref(Zb)(n.comment.createdDate)),1)]),n.comment.privacy?(m.openBlock(),m.createElementBlock("div",pw,[p[1]||(p[1]=m.createElementVNode("div",{class:"sus-item-privacy"},null,-1)),m.createElementVNode("span",{class:"sus-item-privacy-text",innerHTML:n.comment.content},null,8,mw)])):(m.openBlock(),m.createElementBlock("div",gw,[m.createElementVNode("span",{ref_key:"contentDom",ref:r,class:"sus-item__content-text",innerHTML:n.comment.content+(n.comment.contentExtends||"")},null,8,yw),s.value?(m.openBlock(),m.createElementBlock("a",{key:0,ref_key:"showMoreDom",ref:i,class:"sus-show-detail my-1.5 cursor-pointer",onClick:l},"显示更多>",512)):m.createCommentVNode("",!0)]))])]),n.showFooter&&n.comment.area&&!n.comment.privacy?(m.openBlock(),m.createElementBlock("div",bw,[m.createElementVNode("span",ww,[p[2]||(p[2]=m.createElementVNode("svg",{class:"sus-svg",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[m.createElementVNode("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5"},[m.createElementVNode("path",{d:"M12.5 7.041A3 3 0 1 0 14.959 9.5"}),m.createElementVNode("path",{d:"M5 15.216c-.647-1.654-1-3.415-1-5.073C4 5.646 7.582 2 12 2s8 3.646 8 8.143c0 4.462-2.553 9.67-6.537 11.531a3.45 3.45 0 0 1-2.926 0C9.265 21.08 8.138 20.144 7.194 19"})])],-1)),m.createTextVNode(" "+m.toDisplayString(n.comment.area),1)]),m.createElementVNode("span",kw,[p[3]||(p[3]=m.createElementVNode("svg",{class:"sus-svg",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[m.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",d:"M5 2.252c-.774.169-1.359.45-1.828.92C2 4.343 2 6.229 2 10v1c0 2.828 0 4.243.879 5.121C3.757 17 5.172 17 8 17h8c2.828 0 4.243 0 5.121-.879C22 15.243 22 13.828 22 11v-1c0-3.771 0-5.657-1.172-6.828S17.771 2 14 2H9m7 20H8m4-5v5m10-9h-6M2 13h10"})],-1)),m.createTextVNode(" "+m.toDisplayString(n.comment.userAgent),1)])])):m.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-8ee9ae13"]]),xw={class:"sus-comment__item"},Sw={key:0,class:"sus-comment__item-child"},Cw={key:1},Ew={key:0,class:"sus-comment__item-footer flex justify-center w-full cursor-pointer"},df=bn(m.defineComponent({__name:"index",props:{comment:{},lineHeight:{default:23},showFooter:{type:Boolean,default:!1}},emits:["on-reply"],setup(n,{emit:e}){const t=m.ref(!1),r=e;function i(s){r("on-reply",s)}return(s,o)=>(m.openBlock(),m.createElementBlock("div",xw,[m.createVNode(is,{comment:n.comment,onOnReply:o[0]||(o[0]=l=>i(n.comment)),lineHeight:n.lineHeight,showFooter:n.showFooter},null,8,["comment","lineHeight","showFooter"]),n.comment.child?.length>0?(m.openBlock(),m.createElementBlock("div",Sw,[m.createVNode(is,{onOnReply:o[1]||(o[1]=l=>i(n.comment.child[0])),comment:n.comment.child[0],num:2,showFooter:n.showFooter,lineHeight:n.lineHeight,class:"sus-comment__item-child__item"},null,8,["comment","showFooter","lineHeight"]),n.comment.child?.length>1?(m.openBlock(),m.createBlock(is,{key:0,onOnReply:o[2]||(o[2]=l=>i(n.comment.child[1])),comment:n.comment.child[1],num:3,showFooter:n.showFooter,lineHeight:n.lineHeight,class:"sus-comment__item-child__item"},null,8,["comment","showFooter","lineHeight"])):m.createCommentVNode("",!0),n.comment.child?.length>2?(m.openBlock(),m.createElementBlock("div",Cw,[t.value?m.createCommentVNode("",!0):(m.openBlock(),m.createElementBlock("div",Ew,[m.createElementVNode("p",{class:"sus-load-more",onClick:o[3]||(o[3]=l=>t.value=!0)}," 查看更多回复 > ")])),t.value?(m.openBlock(!0),m.createElementBlock(m.Fragment,{key:1},m.renderList(n.comment.child.slice(2),(l,a)=>(m.openBlock(),m.createBlock(is,{onOnReply:c=>i(l),key:a,comment:l,num:4+a,showFooter:n.showFooter,lineHeight:n.lineHeight,class:"sus-comment__item-child__item"},null,8,["onOnReply","comment","num","showFooter","lineHeight"]))),128)):m.createCommentVNode("",!0)])):m.createCommentVNode("",!0)])):m.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-162930a9"]]),Mw={class:"sus-top-item flex items-start p-1.5 overflow-hidden"},vw={class:"sus-top-item__info flex flex-col mr-1"},Tw={class:"sus-top-item__user whitespace-nowrap"},Ow={key:0,class:"sus-top-item__reply whitespace-nowrap"},Nw=["innerHTML"],ff=bn(m.defineComponent({__name:"simple",props:{comment:{}},setup(n){return(e,t)=>(m.openBlock(),m.createElementBlock("div",Mw,[m.createElementVNode("div",vw,[m.createElementVNode("span",Tw,m.toDisplayString(n.comment.userName)+": ",1),n.comment.replyName?(m.openBlock(),m.createElementBlock("span",Ow,m.toDisplayString("@"+n.comment.replyName),1)):m.createCommentVNode("",!0)]),m.createElementVNode("span",{class:"sus-top-item__content w-full",innerHTML:n.comment.content},null,8,Nw)]))}}),[["__scopeId","data-v-7407d86d"]]),Aw={class:"sus-top-item__user flex items-center"},Rw={key:0,class:"sus-top-item__user-avatar ml-1 mr-2"},Dw=["src"],Iw={class:"sus-top-item__user-owner"},Pw={class:"sus-top-item__user-reply ml-3 opacity-70"},Lw=["innerHTML"],hf=bn(m.defineComponent({__name:"index",props:{comment:{}},emits:["go-local"],setup(n,{emit:e}){const t=e;function r(){t("go-local")}return(i,s)=>(m.openBlock(),m.createElementBlock("div",{class:"sus-top-item p-1.5 cursor-pointer overflow-hidden",onClick:r},[m.createElementVNode("div",Aw,[n.comment.userAvatar?(m.openBlock(),m.createElementBlock("div",Rw,[m.createElementVNode("img",{alt:"",class:"sus-avatar",loading:"lazy",decoding:"async",src:n.comment.userAvatar,onerror:"this.onerror=null,this.src='/error.webp'"},null,8,Dw)])):m.createCommentVNode("",!0),m.createElementVNode("div",Iw,m.toDisplayString(n.comment.userName),1),m.createElementVNode("div",Pw,m.toDisplayString(n.comment.replyName?"@"+n.comment.replyName:""),1)]),m.createElementVNode("div",{class:"sus-top-item__content p-1",innerHTML:n.comment.content},null,8,Lw)]))}}),[["__scopeId","data-v-1e2f9488"]]),Bw=[uf,df,hf,ff],_w={install(n){Bw.forEach(e=>{n.component(e.name,e)})}};je.SuSComment=uf,je.SuSList=df,je.SuSSimpleTop=ff,je.SuSTop=hf,je.default=_w,Object.defineProperties(je,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
104
|
+
3. "-" cannot repeat`);oe.customSchemes.push([n,e])}function y0(){oe.scanner=c0(oe.customSchemes);for(let n=0;n<oe.tokenQueue.length;n++)oe.tokenQueue[n][1]({scanner:oe.scanner});oe.parser=f0(oe.scanner.tokens);for(let n=0;n<oe.pluginQueue.length;n++)oe.pluginQueue[n][1]({scanner:oe.scanner,parser:oe.parser});return oe.initialized=!0,oe}function qo(n){return oe.initialized||y0(),h0(oe.parser.start,n,Hu(oe.scanner.start,n))}qo.scan=Hu;function Ju(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Wo(t),i=qo(n),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}var Jo="[\0- -\u2029 ]",b0=new RegExp(Jo),w0=new RegExp(`${Jo}$`),k0=new RegExp(Jo,"g");function x0(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function S0(n){return new se({key:new le("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=Yc(t.doc,[...e]);if(lu(l).forEach(({newRange:c})=>{const u=Hm(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!w0.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(b0).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],g=d.pos+f.lastIndexOf(p);if(!p)return!1;const y=qo(p).map(w=>w.toObject(n.defaultProtocol));if(!x0(y))return!1;y.filter(w=>w.isLink).map(w=>({...w,from:g+w.start+1,to:g+w.end+1})).filter(w=>r.schema.marks.code?!r.doc.rangeHasMark(w.from,w.to,r.schema.marks.code):!0).filter(w=>n.validate(w.value)).filter(w=>n.shouldAutoLink(w.value)).forEach(w=>{go(w.from,w.to,r.doc).some(k=>k.mark.type===n.type)||o.addMark(w.from,w.to,n.type.create({href:w.href}))})}}),!!o.steps.length)return o}})}function C0(n){return new se({key:new le("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let u=r.target;const d=[];for(;u.nodeName!=="DIV";)d.push(u),u=u.parentNode;o=d.find(f=>f.nodeName==="A")}if(!o)return!1;const l=ou(e.state,n.type.name),a=(i=o?.href)!=null?i:l.href,c=(s=o?.target)!=null?s:l.target;return n.enableClickSelection&&n.editor.commands.extendMarkRange(n.type.name),o&&a?(window.open(a,c),!0):!1}}})}function E0(n){return new se({key:new le("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:i}=e,{selection:s}=i,{empty:o}=s;if(o)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Ju(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}function kn(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(k0,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Gu=gn.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(n=>{if(typeof n=="string"){qu(n);return}qu(n.scheme,n.optionalSlashes)})},onDestroy(){g0()},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:(n,e)=>!!kn(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!kn(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!kn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ce(this.options.HTMLAttributes,n),0]:["a",ce(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!kn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!kn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[yn({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=Ju(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!kn(o,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(s=>e.push({text:s.value,data:{href:s.href},index:s.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(S0({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!kn(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(C0({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(E0({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),M0=Gu,v0=Object.defineProperty,T0=(n,e)=>{for(var t in e)v0(n,t,{get:e[t],enumerable:!0})},O0="listItem",Yu="textStyle",Xu=/^\s*([-+*])\s$/,Qu=ze.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(O0,this.editor.getAttributes(Yu)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Vn({find:Xu,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Vn({find:Xu,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Yu),editor:this.editor})),[n]}}),Zu=ze.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",ce(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),N0={};T0(N0,{findListItemPos:()=>Er,getNextListDepth:()=>Go,handleBackspace:()=>Yo,handleDelete:()=>Xo,hasListBefore:()=>ed,hasListItemAfter:()=>A0,hasListItemBefore:()=>td,listItemHasSubList:()=>nd,nextListIsDeeper:()=>rd,nextListIsHigher:()=>id});var Er=(n,e)=>{const{$from:t}=e.selection,r=be(n,e.schema);let i=null,s=t.depth,o=t.pos,l=null;for(;s>0&&l===null;)i=t.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},Go=(n,e)=>{const t=Er(n,e);if(!t)return!1;const[,r]=Ym(e,n,t.$pos.pos+4);return r},ed=(n,e,t)=>{const{$anchor:r}=n.selection,i=Math.max(0,r.pos-2),s=n.doc.resolve(i).node();return!(!s||!t.includes(s.type.name))},td=(n,e)=>{var t;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((t=i.nodeBefore)==null?void 0:t.type.name)!==n)},nd=(n,e,t)=>{if(!t)return!1;const r=be(n,e.schema);let i=!1;return t.descendants(s=>{s.type===r&&(i=!0)}),i},Yo=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Gt(n.state,e)&&ed(n.state,e,t)){const{$anchor:l}=n.state.selection,a=n.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const u=c.at(-1);if(!u)return!1;const d=n.state.doc.resolve(a.start()+u.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!Gt(n.state,e)||!eg(n.state))return!1;const r=Er(e,n.state);if(!r)return!1;const s=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=nd(e,n.state,s);return td(e,n.state)&&!o?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},rd=(n,e)=>{const t=Go(n,e),r=Er(n,e);return!r||!t?!1:t>r.depth},id=(n,e)=>{const t=Go(n,e),r=Er(n,e);return!r||!t?!1:t<r.depth},Xo=(n,e)=>{if(!Gt(n.state,e)||!Zm(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:i}=t;return!t.empty&&r.sameParent(i)?!1:rd(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():id(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},A0=(n,e)=>{var t;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((t=i.nodeAfter)==null?void 0:t.type.name)!==n)},sd=ue.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Xo(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Xo(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Yo(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Yo(n,t,r)&&(e=!0)}),e}}}}),R0="listItem",od="textStyle",ld=/^(\d+)\.\s$/,ad=ze.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",ce(this.options.HTMLAttributes,t),0]:["ol",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(R0,this.editor.getAttributes(od)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Vn({find:ld,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Vn({find:ld,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(od)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),D0=/^\s*(\[([( |x])?\])\s$/,I0=ze.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:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",ce(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var d,f;l.ariaLabel=((f=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:f.call(d,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(n),s.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}const{checked:d}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const h=t();if(typeof h!="number")return!1;const p=f.doc.nodeAt(h);return f.setNodeMarkup(h,void 0,{...p?.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{i.setAttribute(u,d)}),i.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,s.append(l,o),i.append(s,a),Object.entries(e).forEach(([u,d])=>{i.setAttribute(u,d)}),{dom:i,contentDOM:a,update:u=>u.type!==this.type?!1:(i.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[Vn({find:D0,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),P0=ze.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:n}){return["ul",ce(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ue.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Qu.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(Zu.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(sd.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(ad.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(I0.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(P0.configure(this.options.taskList)),n}});var L0=ze.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),B0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,V0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,$0=gn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Bn({find:B0,type:this.type})]},addPasteRules(){return[yn({find:V0,type:this.type})]}}),z0=ze.create({name:"text",group:"inline"}),_0=gn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function H0(n={}){return new se({view(e){return new F0(e,n)}})}class F0{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),g=d?p.bottom:p.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"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 t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=aa(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class fe extends H{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return fe.valid(r)?new fe(r):H.near(r)}content(){return N.empty}eq(e){return e instanceof fe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new fe(e.resolve(t.pos))}getBookmark(){return new Qo(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!j0(e)||!U0(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&fe.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(fe.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!$.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(fe.valid(l))return l}return null}}}fe.prototype.visible=!1,fe.findFrom=fe.findGapCursorFrom,H.jsonID("gapcursor",fe);class Qo{constructor(e){this.pos=e}map(e){return new Qo(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return fe.valid(t)?new fe(t):H.near(t)}}function j0(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function U0(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function W0(){return new se({props:{decorations:G0,createSelectionBetween(n,e,t){return e.pos==t.pos&&fe.valid(t)?new fe(t):null},handleClick:q0,handleKeyDown:K0,handleDOMEvents:{beforeinput:J0}}})}const K0=to({ArrowLeft:Ui("horiz",-1),ArrowRight:Ui("horiz",1),ArrowUp:Ui("vert",-1),ArrowDown:Ui("vert",1)});function Ui(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof F){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=fe.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new fe(c))),!0):!1}}function q0(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!fe.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&$.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new fe(r))),!0)}function J0(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof fe))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=S.empty;for(let o=r.length-1;o>=0;o--)i=S.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new N(i,0,0));return s.setSelection(F.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function G0(n){if(!(n.selection instanceof fe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ae.create(n.doc,[Ie.widget(n.selection.head,e,{key:"gapcursor"})])}var Wi=200,Ee=function(){};Ee.prototype.append=function(e){return e.length?(e=Ee.from(e),!this.length&&e||e.length<Wi&&this.leafAppend(e)||this.length<Wi&&e.leafPrepend(this)||this.appendInner(e)):this},Ee.prototype.prepend=function(e){return e.length?Ee.from(e).append(this):this},Ee.prototype.appendInner=function(e){return new Y0(this,e)},Ee.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Ee.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ee.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ee.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},Ee.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i},Ee.from=function(e){return e instanceof Ee?e:e&&e.length?new cd(e):Ee.empty};var cd=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Wi)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Wi)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(Ee);Ee.empty=new cd([]);var Y0=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ee);const X0=500;class nt{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,u.push(d);return}if(i){u.push(new dt(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new dt(p,void 0,void 0,c.length+u.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new nt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new dt(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),i||(a=f)}let c=o-r.depth;return c>Z0&&(l=Q0(l,c),o-=c),new nt(l.append(s),o)}remapping(e,t){let r=new Qn;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new nt(this.items.append(e.map(t=>new dt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(s.slice(a+1,h));y&&l++,r.push(new dt(p,g,y))}else r.push(new dt(p))},i);let c=[];for(let f=t;f<o;f++)c.push(new dt(s.maps[f]));let u=this.items.slice(0,i).append(c).append(r),d=new nt(u,l);return d.emptyItemCount()>X0&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.slice(r));u&&s++;let d=new dt(c.invert(),a,u),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new nt(Ee.from(i.reverse()),s)}}nt.empty=new nt(Ee.empty,0);function Q0(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class dt{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new dt(t.getMap().invert(),t,this.selection)}}}class Zt{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const Z0=20;function e1(n,e,t,r){let i=t.getMeta(xn),s;if(i)return i.historyState;t.getMeta(r1)&&(n=new Zt(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(xn))return o.getMeta(xn).redo?new Zt(n.done.addTransform(t,void 0,r,Ki(e)),n.undone,ud(t.mapping.maps),n.prevTime,n.prevComposition):new Zt(n.done,n.undone.addTransform(t,void 0,r,Ki(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!t1(t,n.prevRanges)),c=o?Zo(n.prevRanges,t.mapping):ud(t.mapping.maps);return new Zt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Ki(e)),nt.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Zt(n.done.rebased(t,s),n.undone.rebased(t,s),Zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Zt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function t1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function ud(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,o)=>e.push(s,o));return e}function Zo(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function n1(n,e,t){let r=Ki(e),i=xn.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new Zt(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(xn,{redo:t,historyState:a})}let el=!1,dd=null;function Ki(n){let e=n.plugins;if(dd!=e){el=!1,dd=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){el=!0;break}}return el}const xn=new le("history"),r1=new le("closeHistory");function i1(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new se({key:xn,state:{init(){return new Zt(nt.empty,nt.empty,null,0,-1)},apply(e,t,r){return e1(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?hd:r=="historyRedo"?pd:null;return i?(t.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function fd(n,e){return(t,r)=>{let i=xn.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=n1(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const hd=fd(!1,!0),pd=fd(!0,!0);ue.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new se({key:new le("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const i=this.options.limit;if(i==null||i===0){n=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const o=s-i,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=s-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var s1=ue.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[H0(this.options)]}});ue.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new se({key:new le("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return ae.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(i>=c&&i<=c+a.nodeSize-1))return!1;o+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(Ie.node(c,c+a.nodeSize,{class:this.options.className}))}),ae.create(n,s)}}})]}});var o1=ue.create({name:"gapCursor",addProseMirrorPlugins(){return[W0()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ee(z(n,"allowGapCursor",t)))!=null?e:null}}}),l1=ue.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new se({key:new le("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!t)return null;const s=this.editor.isEmpty;return n.descendants((o,l)=>{const a=r>=l&&r<=l+o.nodeSize,c=!o.isLeaf&&si(o);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];s&&u.push(this.options.emptyEditorClass);const d=Ie.node(l,l+o.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:a}):this.options.placeholder});i.push(d)}return this.options.includeChildren}),ae.create(n,i)}}})]}});ue.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new se({key:new le("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||fu(t.selection)||n.view.dragging?null:ae.create(t.doc,[Ie.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function md({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var a1=ue.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const n=new le(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>(this.options.notAfter||[]).concat(this.options.node).includes(t.name));return[new se({key:n,appendTransaction:(t,r,i)=>{const{doc:s,tr:o,schema:l}=i,a=n.getState(i),c=s.content.size,u=l.nodes[this.options.node];if(a)return o.insert(c,u.create())},state:{init:(t,r)=>{const i=r.tr.doc.lastChild;return!md({node:i,types:e})},apply:(t,r)=>{if(!t.docChanged)return r;const i=t.doc.lastChild;return!md({node:i,types:e})}}})]}}),c1=ue.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>hd(n,e),redo:()=>({state:n,dispatch:e})=>pd(n,e)}},addProseMirrorPlugins(){return[i1(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),u1=ue.create({name:"starterKit",addExtensions(){var n,e,t,r;const i=[];return this.options.bold!==!1&&i.push(zy.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(Py.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Qu.configure(this.options.bulletList)),this.options.code!==!1&&i.push(Fy.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(Du.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(Ky.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(s1.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(o1.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(qy.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(Jy.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(c1.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(Gy.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(e0.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Zu.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(sd.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&i.push(Gu.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(ad.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(L0.configure(this.options.paragraph)),this.options.strike!==!1&&i.push($0.configure(this.options.strike)),this.options.text!==!1&&i.push(z0.configure(this.options.text)),this.options.underline!==!1&&i.push(_0.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&i.push(a1.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),d1=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,f1=ze.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",ce(this.options.HTMLAttributes,n)]},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[Au({find:d1,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),h1=f1;function p1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var tl,gd;function m1(){if(gd)return tl;gd=1;function n(b){return b instanceof Map?b.clear=b.delete=b.set=function(){throw new Error("map is read-only")}:b instanceof Set&&(b.add=b.clear=b.delete=function(){throw new Error("set is read-only")}),Object.freeze(b),Object.getOwnPropertyNames(b).forEach(x=>{const O=b[x],q=typeof O;(q==="object"||q==="function")&&!Object.isFrozen(O)&&n(O)}),b}class e{constructor(x){x.data===void 0&&(x.data={}),this.data=x.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function t(b){return b.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(b,...x){const O=Object.create(null);for(const q in b)O[q]=b[q];return x.forEach(function(q){for(const me in q)O[me]=q[me]}),O}const i="</span>",s=b=>!!b.scope,o=(b,{prefix:x})=>{if(b.startsWith("language:"))return b.replace("language:","language-");if(b.includes(".")){const O=b.split(".");return[`${x}${O.shift()}`,...O.map((q,me)=>`${q}${"_".repeat(me+1)}`)].join(" ")}return`${x}${b}`};class l{constructor(x,O){this.buffer="",this.classPrefix=O.classPrefix,x.walk(this)}addText(x){this.buffer+=t(x)}openNode(x){if(!s(x))return;const O=o(x.scope,{prefix:this.classPrefix});this.span(O)}closeNode(x){s(x)&&(this.buffer+=i)}value(){return this.buffer}span(x){this.buffer+=`<span class="${x}">`}}const a=(b={})=>{const x={children:[]};return Object.assign(x,b),x};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(x){this.top.children.push(x)}openNode(x){const O=a({scope:x});this.add(O),this.stack.push(O)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(x){return this.constructor._walk(x,this.rootNode)}static _walk(x,O){return typeof O=="string"?x.addText(O):O.children&&(x.openNode(O),O.children.forEach(q=>this._walk(x,q)),x.closeNode(O)),x}static _collapse(x){typeof x!="string"&&x.children&&(x.children.every(O=>typeof O=="string")?x.children=[x.children.join("")]:x.children.forEach(O=>{c._collapse(O)}))}}class u extends c{constructor(x){super(),this.options=x}addText(x){x!==""&&this.add(x)}startScope(x){this.openNode(x)}endScope(){this.closeNode()}__addSublanguage(x,O){const q=x.root;O&&(q.scope=`language:${O}`),this.add(q)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(b){return b?typeof b=="string"?b:b.source:null}function f(b){return g("(?=",b,")")}function h(b){return g("(?:",b,")*")}function p(b){return g("(?:",b,")?")}function g(...b){return b.map(O=>d(O)).join("")}function y(b){const x=b[b.length-1];return typeof x=="object"&&x.constructor===Object?(b.splice(b.length-1,1),x):{}}function w(...b){return"("+(y(b).capture?"":"?:")+b.map(q=>d(q)).join("|")+")"}function k(b){return new RegExp(b.toString()+"|").exec("").length-1}function C(b,x){const O=b&&b.exec(x);return O&&O.index===0}const R=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function M(b,{joinWith:x}){let O=0;return b.map(q=>{O+=1;const me=O;let ge=d(q),L="";for(;ge.length>0;){const D=R.exec(ge);if(!D){L+=ge;break}L+=ge.substring(0,D.index),ge=ge.substring(D.index+D[0].length),D[0][0]==="\\"&&D[1]?L+="\\"+String(Number(D[1])+me):(L+=D[0],D[0]==="("&&O++)}return L}).map(q=>`(${q})`).join(x)}const I=/\b\B/,T="[a-zA-Z]\\w*",V="[a-zA-Z_]\\w*",W="\\b\\d+(\\.\\d+)?",j="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",K="\\b(0b[01]+)",P="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Q=(b={})=>{const x=/^#![ ]*\//;return b.binary&&(b.begin=g(x,/.*\b/,b.binary,/\b.*/)),r({scope:"meta",begin:x,end:/$/,relevance:0,"on:begin":(O,q)=>{O.index!==0&&q.ignoreMatch()}},b)},Z={begin:"\\\\[\\s\\S]",relevance:0},ke={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Z]},he={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Z]},pe={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Me=function(b,x,O={}){const q=r({scope:"comment",begin:b,end:x,contains:[]},O);q.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const me=w("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return q.contains.push({begin:g(/[ ]+/,"(",me,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),q},yt=Me("//","$"),pl=Me("/\\*","\\*/"),$w=Me("#","$"),zw={scope:"number",begin:W,relevance:0},_w={scope:"number",begin:j,relevance:0},Hw={scope:"number",begin:K,relevance:0},Fw={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Z,{begin:/\[/,end:/\]/,relevance:0,contains:[Z]}]},jw={scope:"title",begin:T,relevance:0},Uw={scope:"title",begin:V,relevance:0},Ww={begin:"\\.\\s*"+V,relevance:0};var ss=Object.freeze({__proto__:null,APOS_STRING_MODE:ke,BACKSLASH_ESCAPE:Z,BINARY_NUMBER_MODE:Hw,BINARY_NUMBER_RE:K,COMMENT:Me,C_BLOCK_COMMENT_MODE:pl,C_LINE_COMMENT_MODE:yt,C_NUMBER_MODE:_w,C_NUMBER_RE:j,END_SAME_AS_BEGIN:function(b){return Object.assign(b,{"on:begin":(x,O)=>{O.data._beginMatch=x[1]},"on:end":(x,O)=>{O.data._beginMatch!==x[1]&&O.ignoreMatch()}})},HASH_COMMENT_MODE:$w,IDENT_RE:T,MATCH_NOTHING_RE:I,METHOD_GUARD:Ww,NUMBER_MODE:zw,NUMBER_RE:W,PHRASAL_WORDS_MODE:pe,QUOTE_STRING_MODE:he,REGEXP_MODE:Fw,RE_STARTERS_RE:P,SHEBANG:Q,TITLE_MODE:jw,UNDERSCORE_IDENT_RE:V,UNDERSCORE_TITLE_MODE:Uw});function Kw(b,x){b.input[b.index-1]==="."&&x.ignoreMatch()}function qw(b,x){b.className!==void 0&&(b.scope=b.className,delete b.className)}function Jw(b,x){x&&b.beginKeywords&&(b.begin="\\b("+b.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",b.__beforeBegin=Kw,b.keywords=b.keywords||b.beginKeywords,delete b.beginKeywords,b.relevance===void 0&&(b.relevance=0))}function Gw(b,x){Array.isArray(b.illegal)&&(b.illegal=w(...b.illegal))}function Yw(b,x){if(b.match){if(b.begin||b.end)throw new Error("begin & end are not supported with match");b.begin=b.match,delete b.match}}function Xw(b,x){b.relevance===void 0&&(b.relevance=1)}const Qw=(b,x)=>{if(!b.beforeMatch)return;if(b.starts)throw new Error("beforeMatch cannot be used with starts");const O=Object.assign({},b);Object.keys(b).forEach(q=>{delete b[q]}),b.keywords=O.keywords,b.begin=g(O.beforeMatch,f(O.begin)),b.starts={relevance:0,contains:[Object.assign(O,{endsParent:!0})]},b.relevance=0,delete O.beforeMatch},Zw=["of","and","for","in","not","or","if","then","parent","list","value"],ek="keyword";function pf(b,x,O=ek){const q=Object.create(null);return typeof b=="string"?me(O,b.split(" ")):Array.isArray(b)?me(O,b):Object.keys(b).forEach(function(ge){Object.assign(q,pf(b[ge],x,ge))}),q;function me(ge,L){x&&(L=L.map(D=>D.toLowerCase())),L.forEach(function(D){const U=D.split("|");q[U[0]]=[ge,tk(U[0],U[1])]})}}function tk(b,x){return x?Number(x):nk(b)?0:1}function nk(b){return Zw.includes(b.toLowerCase())}const mf={},Sn=b=>{console.error(b)},gf=(b,...x)=>{console.log(`WARN: ${b}`,...x)},Un=(b,x)=>{mf[`${b}/${x}`]||(console.log(`Deprecated as of ${b}. ${x}`),mf[`${b}/${x}`]=!0)},ls=new Error;function yf(b,x,{key:O}){let q=0;const me=b[O],ge={},L={};for(let D=1;D<=x.length;D++)L[D+q]=me[D],ge[D+q]=!0,q+=k(x[D-1]);b[O]=L,b[O]._emit=ge,b[O]._multi=!0}function rk(b){if(Array.isArray(b.begin)){if(b.skip||b.excludeBegin||b.returnBegin)throw Sn("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ls;if(typeof b.beginScope!="object"||b.beginScope===null)throw Sn("beginScope must be object"),ls;yf(b,b.begin,{key:"beginScope"}),b.begin=M(b.begin,{joinWith:""})}}function ik(b){if(Array.isArray(b.end)){if(b.skip||b.excludeEnd||b.returnEnd)throw Sn("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ls;if(typeof b.endScope!="object"||b.endScope===null)throw Sn("endScope must be object"),ls;yf(b,b.end,{key:"endScope"}),b.end=M(b.end,{joinWith:""})}}function sk(b){b.scope&&typeof b.scope=="object"&&b.scope!==null&&(b.beginScope=b.scope,delete b.scope)}function ok(b){sk(b),typeof b.beginScope=="string"&&(b.beginScope={_wrap:b.beginScope}),typeof b.endScope=="string"&&(b.endScope={_wrap:b.endScope}),rk(b),ik(b)}function lk(b){function x(L,D){return new RegExp(d(L),"m"+(b.case_insensitive?"i":"")+(b.unicodeRegex?"u":"")+(D?"g":""))}class O{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(D,U){U.position=this.position++,this.matchIndexes[this.matchAt]=U,this.regexes.push([U,D]),this.matchAt+=k(D)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const D=this.regexes.map(U=>U[1]);this.matcherRe=x(M(D,{joinWith:"|"}),!0),this.lastIndex=0}exec(D){this.matcherRe.lastIndex=this.lastIndex;const U=this.matcherRe.exec(D);if(!U)return null;const ve=U.findIndex((Tr,gl)=>gl>0&&Tr!==void 0),we=this.matchIndexes[ve];return U.splice(0,ve),Object.assign(U,we)}}class q{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(D){if(this.multiRegexes[D])return this.multiRegexes[D];const U=new O;return this.rules.slice(D).forEach(([ve,we])=>U.addRule(ve,we)),U.compile(),this.multiRegexes[D]=U,U}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(D,U){this.rules.push([D,U]),U.type==="begin"&&this.count++}exec(D){const U=this.getMatcher(this.regexIndex);U.lastIndex=this.lastIndex;let ve=U.exec(D);if(this.resumingScanAtSamePosition()&&!(ve&&ve.index===this.lastIndex)){const we=this.getMatcher(0);we.lastIndex=this.lastIndex+1,ve=we.exec(D)}return ve&&(this.regexIndex+=ve.position+1,this.regexIndex===this.count&&this.considerAll()),ve}}function me(L){const D=new q;return L.contains.forEach(U=>D.addRule(U.begin,{rule:U,type:"begin"})),L.terminatorEnd&&D.addRule(L.terminatorEnd,{type:"end"}),L.illegal&&D.addRule(L.illegal,{type:"illegal"}),D}function ge(L,D){const U=L;if(L.isCompiled)return U;[qw,Yw,ok,Qw].forEach(we=>we(L,D)),b.compilerExtensions.forEach(we=>we(L,D)),L.__beforeBegin=null,[Jw,Gw,Xw].forEach(we=>we(L,D)),L.isCompiled=!0;let ve=null;return typeof L.keywords=="object"&&L.keywords.$pattern&&(L.keywords=Object.assign({},L.keywords),ve=L.keywords.$pattern,delete L.keywords.$pattern),ve=ve||/\w+/,L.keywords&&(L.keywords=pf(L.keywords,b.case_insensitive)),U.keywordPatternRe=x(ve,!0),D&&(L.begin||(L.begin=/\B|\b/),U.beginRe=x(U.begin),!L.end&&!L.endsWithParent&&(L.end=/\B|\b/),L.end&&(U.endRe=x(U.end)),U.terminatorEnd=d(U.end)||"",L.endsWithParent&&D.terminatorEnd&&(U.terminatorEnd+=(L.end?"|":"")+D.terminatorEnd)),L.illegal&&(U.illegalRe=x(L.illegal)),L.contains||(L.contains=[]),L.contains=[].concat(...L.contains.map(function(we){return ak(we==="self"?L:we)})),L.contains.forEach(function(we){ge(we,U)}),L.starts&&ge(L.starts,D),U.matcher=me(U),U}if(b.compilerExtensions||(b.compilerExtensions=[]),b.contains&&b.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return b.classNameAliases=r(b.classNameAliases||{}),ge(b)}function bf(b){return b?b.endsWithParent||bf(b.starts):!1}function ak(b){return b.variants&&!b.cachedVariants&&(b.cachedVariants=b.variants.map(function(x){return r(b,{variants:null},x)})),b.cachedVariants?b.cachedVariants:bf(b)?r(b,{starts:b.starts?r(b.starts):null}):Object.isFrozen(b)?r(b):b}var ck="11.11.1";class uk extends Error{constructor(x,O){super(x),this.name="HTMLInjectionError",this.html=O}}const ml=t,wf=r,kf=Symbol("nomatch"),dk=7,xf=function(b){const x=Object.create(null),O=Object.create(null),q=[];let me=!0;const ge="Could not find the language '{}', did you forget to load/include a language module?",L={disableAutodetect:!0,name:"Plain text",contains:[]};let D={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function U(v){return D.noHighlightRe.test(v)}function ve(v){let _=v.className+" ";_+=v.parentNode?v.parentNode.className:"";const X=D.languageDetectRe.exec(_);if(X){const re=tn(X[1]);return re||(gf(ge.replace("{}",X[1])),gf("Falling back to no-highlight mode for this block.",v)),re?X[1]:"no-highlight"}return _.split(/\s+/).find(re=>U(re)||tn(re))}function we(v,_,X){let re="",xe="";typeof _=="object"?(re=v,X=_.ignoreIllegals,xe=_.language):(Un("10.7.0","highlight(lang, code, ...args) has been deprecated."),Un("10.7.0",`Please use highlight(code, options) instead.
|
|
105
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),xe=v,re=_),X===void 0&&(X=!0);const ot={code:re,language:xe};cs("before:highlight",ot);const nn=ot.result?ot.result:Tr(ot.language,ot.code,X);return nn.code=ot.code,cs("after:highlight",nn),nn}function Tr(v,_,X,re){const xe=Object.create(null);function ot(A,B){return A.keywords[B]}function nn(){if(!J.keywords){Ae.addText(ie);return}let A=0;J.keywordPatternRe.lastIndex=0;let B=J.keywordPatternRe.exec(ie),Y="";for(;B;){Y+=ie.substring(A,B.index);const te=wt.case_insensitive?B[0].toLowerCase():B[0],Le=ot(J,te);if(Le){const[It,Ok]=Le;if(Ae.addText(Y),Y="",xe[te]=(xe[te]||0)+1,xe[te]<=dk&&(fs+=Ok),It.startsWith("_"))Y+=B[0];else{const Nk=wt.classNameAliases[It]||It;bt(B[0],Nk)}}else Y+=B[0];A=J.keywordPatternRe.lastIndex,B=J.keywordPatternRe.exec(ie)}Y+=ie.substring(A),Ae.addText(Y)}function us(){if(ie==="")return;let A=null;if(typeof J.subLanguage=="string"){if(!x[J.subLanguage]){Ae.addText(ie);return}A=Tr(J.subLanguage,ie,!0,Nf[J.subLanguage]),Nf[J.subLanguage]=A._top}else A=yl(ie,J.subLanguage.length?J.subLanguage:null);J.relevance>0&&(fs+=A.relevance),Ae.__addSublanguage(A._emitter,A.language)}function qe(){J.subLanguage!=null?us():nn(),ie=""}function bt(A,B){A!==""&&(Ae.startScope(B),Ae.addText(A),Ae.endScope())}function Mf(A,B){let Y=1;const te=B.length-1;for(;Y<=te;){if(!A._emit[Y]){Y++;continue}const Le=wt.classNameAliases[A[Y]]||A[Y],It=B[Y];Le?bt(It,Le):(ie=It,nn(),ie=""),Y++}}function vf(A,B){return A.scope&&typeof A.scope=="string"&&Ae.openNode(wt.classNameAliases[A.scope]||A.scope),A.beginScope&&(A.beginScope._wrap?(bt(ie,wt.classNameAliases[A.beginScope._wrap]||A.beginScope._wrap),ie=""):A.beginScope._multi&&(Mf(A.beginScope,B),ie="")),J=Object.create(A,{parent:{value:J}}),J}function Tf(A,B,Y){let te=C(A.endRe,Y);if(te){if(A["on:end"]){const Le=new e(A);A["on:end"](B,Le),Le.isMatchIgnored&&(te=!1)}if(te){for(;A.endsParent&&A.parent;)A=A.parent;return A}}if(A.endsWithParent)return Tf(A.parent,B,Y)}function Ck(A){return J.matcher.regexIndex===0?(ie+=A[0],1):(xl=!0,0)}function Ek(A){const B=A[0],Y=A.rule,te=new e(Y),Le=[Y.__beforeBegin,Y["on:begin"]];for(const It of Le)if(It&&(It(A,te),te.isMatchIgnored))return Ck(B);return Y.skip?ie+=B:(Y.excludeBegin&&(ie+=B),qe(),!Y.returnBegin&&!Y.excludeBegin&&(ie=B)),vf(Y,A),Y.returnBegin?0:B.length}function Mk(A){const B=A[0],Y=_.substring(A.index),te=Tf(J,A,Y);if(!te)return kf;const Le=J;J.endScope&&J.endScope._wrap?(qe(),bt(B,J.endScope._wrap)):J.endScope&&J.endScope._multi?(qe(),Mf(J.endScope,A)):Le.skip?ie+=B:(Le.returnEnd||Le.excludeEnd||(ie+=B),qe(),Le.excludeEnd&&(ie=B));do J.scope&&Ae.closeNode(),!J.skip&&!J.subLanguage&&(fs+=J.relevance),J=J.parent;while(J!==te.parent);return te.starts&&vf(te.starts,A),Le.returnEnd?0:B.length}function vk(){const A=[];for(let B=J;B!==wt;B=B.parent)B.scope&&A.unshift(B.scope);A.forEach(B=>Ae.openNode(B))}let ds={};function Of(A,B){const Y=B&&B[0];if(ie+=A,Y==null)return qe(),0;if(ds.type==="begin"&&B.type==="end"&&ds.index===B.index&&Y===""){if(ie+=_.slice(B.index,B.index+1),!me){const te=new Error(`0 width match regex (${v})`);throw te.languageName=v,te.badRule=ds.rule,te}return 1}if(ds=B,B.type==="begin")return Ek(B);if(B.type==="illegal"&&!X){const te=new Error('Illegal lexeme "'+Y+'" for mode "'+(J.scope||"<unnamed>")+'"');throw te.mode=J,te}else if(B.type==="end"){const te=Mk(B);if(te!==kf)return te}if(B.type==="illegal"&&Y==="")return ie+=`
|
|
106
|
+
`,1;if(kl>1e5&&kl>B.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ie+=Y,Y.length}const wt=tn(v);if(!wt)throw Sn(ge.replace("{}",v)),new Error('Unknown language: "'+v+'"');const Tk=lk(wt);let wl="",J=re||Tk;const Nf={},Ae=new D.__emitter(D);vk();let ie="",fs=0,Cn=0,kl=0,xl=!1;try{if(wt.__emitTokens)wt.__emitTokens(_,Ae);else{for(J.matcher.considerAll();;){kl++,xl?xl=!1:J.matcher.considerAll(),J.matcher.lastIndex=Cn;const A=J.matcher.exec(_);if(!A)break;const B=_.substring(Cn,A.index),Y=Of(B,A);Cn=A.index+Y}Of(_.substring(Cn))}return Ae.finalize(),wl=Ae.toHTML(),{language:v,value:wl,relevance:fs,illegal:!1,_emitter:Ae,_top:J}}catch(A){if(A.message&&A.message.includes("Illegal"))return{language:v,value:ml(_),illegal:!0,relevance:0,_illegalBy:{message:A.message,index:Cn,context:_.slice(Cn-100,Cn+100),mode:A.mode,resultSoFar:wl},_emitter:Ae};if(me)return{language:v,value:ml(_),illegal:!1,relevance:0,errorRaised:A,_emitter:Ae,_top:J};throw A}}function gl(v){const _={value:ml(v),illegal:!1,relevance:0,_top:L,_emitter:new D.__emitter(D)};return _._emitter.addText(v),_}function yl(v,_){_=_||D.languages||Object.keys(x);const X=gl(v),re=_.filter(tn).filter(Ef).map(qe=>Tr(qe,v,!1));re.unshift(X);const xe=re.sort((qe,bt)=>{if(qe.relevance!==bt.relevance)return bt.relevance-qe.relevance;if(qe.language&&bt.language){if(tn(qe.language).supersetOf===bt.language)return 1;if(tn(bt.language).supersetOf===qe.language)return-1}return 0}),[ot,nn]=xe,us=ot;return us.secondBest=nn,us}function fk(v,_,X){const re=_&&O[_]||X;v.classList.add("hljs"),v.classList.add(`language-${re}`)}function bl(v){let _=null;const X=ve(v);if(U(X))return;if(cs("before:highlightElement",{el:v,language:X}),v.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",v);return}if(v.children.length>0&&(D.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(v)),D.throwUnescapedHTML))throw new uk("One of your code blocks includes unescaped HTML.",v.innerHTML);_=v;const re=_.textContent,xe=X?we(re,{language:X,ignoreIllegals:!0}):yl(re);v.innerHTML=xe.value,v.dataset.highlighted="yes",fk(v,X,xe.language),v.result={language:xe.language,re:xe.relevance,relevance:xe.relevance},xe.secondBest&&(v.secondBest={language:xe.secondBest.language,relevance:xe.secondBest.relevance}),cs("after:highlightElement",{el:v,result:xe,text:re})}function hk(v){D=wf(D,v)}const pk=()=>{as(),Un("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function mk(){as(),Un("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Sf=!1;function as(){function v(){as()}if(document.readyState==="loading"){Sf||window.addEventListener("DOMContentLoaded",v,!1),Sf=!0;return}document.querySelectorAll(D.cssSelector).forEach(bl)}function gk(v,_){let X=null;try{X=_(b)}catch(re){if(Sn("Language definition for '{}' could not be registered.".replace("{}",v)),me)Sn(re);else throw re;X=L}X.name||(X.name=v),x[v]=X,X.rawDefinition=_.bind(null,b),X.aliases&&Cf(X.aliases,{languageName:v})}function yk(v){delete x[v];for(const _ of Object.keys(O))O[_]===v&&delete O[_]}function bk(){return Object.keys(x)}function tn(v){return v=(v||"").toLowerCase(),x[v]||x[O[v]]}function Cf(v,{languageName:_}){typeof v=="string"&&(v=[v]),v.forEach(X=>{O[X.toLowerCase()]=_})}function Ef(v){const _=tn(v);return _&&!_.disableAutodetect}function wk(v){v["before:highlightBlock"]&&!v["before:highlightElement"]&&(v["before:highlightElement"]=_=>{v["before:highlightBlock"](Object.assign({block:_.el},_))}),v["after:highlightBlock"]&&!v["after:highlightElement"]&&(v["after:highlightElement"]=_=>{v["after:highlightBlock"](Object.assign({block:_.el},_))})}function kk(v){wk(v),q.push(v)}function xk(v){const _=q.indexOf(v);_!==-1&&q.splice(_,1)}function cs(v,_){const X=v;q.forEach(function(re){re[X]&&re[X](_)})}function Sk(v){return Un("10.7.0","highlightBlock will be removed entirely in v12.0"),Un("10.7.0","Please use highlightElement now."),bl(v)}Object.assign(b,{highlight:we,highlightAuto:yl,highlightAll:as,highlightElement:bl,highlightBlock:Sk,configure:hk,initHighlighting:pk,initHighlightingOnLoad:mk,registerLanguage:gk,unregisterLanguage:yk,listLanguages:bk,getLanguage:tn,registerAliases:Cf,autoDetection:Ef,inherit:wf,addPlugin:kk,removePlugin:xk}),b.debugMode=function(){me=!1},b.safeMode=function(){me=!0},b.versionString=ck,b.regex={concat:g,lookahead:f,either:w,optional:p,anyNumberOfTimes:h};for(const v in ss)typeof ss[v]=="object"&&n(ss[v]);return Object.assign(b,ss),b},Wn=xf({});return Wn.newInstance=()=>xf({}),tl=Wn,Wn.HighlightJS=Wn,Wn.default=Wn,tl}var g1=m1();const y1=p1(g1);function yd(n,e=[]){return n.flatMap(t=>{const r=[...e,...t.properties?t.properties.className:[]];return t.children?yd(t.children,r):{text:t.value,classes:r}})}function bd(n){return n.value||n.children||[]}function b1(n){return!!y1.getLanguage(n)}function wd({doc:n,name:e,lowlight:t,defaultLanguage:r}){const i=[];return ao(n,s=>s.type.name===e).forEach(s=>{var o;let l=s.pos+1;const a=s.node.attrs.language||r,c=t.listLanguages(),u=a&&(c.includes(a)||b1(a)||(o=t.registered)!=null&&o.call(t,a))?bd(t.highlight(a,s.node.textContent)):bd(t.highlightAuto(s.node.textContent));yd(u).forEach(d=>{const f=l+d.text.length;if(d.classes.length){const h=Ie.inline(l,f,{class:d.classes.join(" ")});i.push(h)}l=f})}),ae.create(n,i)}function w1(n){return typeof n=="function"}function k1({name:n,lowlight:e,defaultLanguage:t}){if(!["highlight","highlightAuto","listLanguages"].every(i=>w1(e[i])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new se({key:new le("lowlight"),state:{init:(i,{doc:s})=>wd({doc:s,name:n,lowlight:e,defaultLanguage:t}),apply:(i,s,o,l)=>{const a=o.selection.$head.parent.type.name,c=l.selection.$head.parent.type.name,u=ao(o.doc,f=>f.type.name===n),d=ao(l.doc,f=>f.type.name===n);return i.docChanged&&([a,c].includes(n)||d.length!==u.length||i.steps.some(f=>f.from!==void 0&&f.to!==void 0&&u.some(h=>h.pos>=f.from&&h.pos+h.node.nodeSize<=f.to)))?wd({doc:i.doc,name:n,lowlight:e,defaultLanguage:t}):s.map(i.mapping,i.doc)}},props:{decorations(i){return r.getState(i)}}});return r}var x1=Wy.extend({addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var n;return[...((n=this.parent)==null?void 0:n.call(this))||[],k1({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});const S1=Lf.createLowlight(),C1=x1.extend({addNodeView(){return({node:n,getPos:e,editor:t})=>{const r=document.createElement("div"),i=document.createElement("pre"),s=document.createElement("code"),o=document.createElement("select");o.setAttribute("class","code-select"),r.setAttribute("class","code-box");const l=["plaintext","java","javascript","html","shell"];return n.attrs.language&&l.lastIndexOf(n.attrs.language)<0&&l.push(n.attrs.language),l.forEach(a=>{const c=document.createElement("option");c.value=a,c.textContent=a,n.attrs.language===a&&(c.selected=!0),o.appendChild(c)}),o.addEventListener("change",a=>{const{value:c}=a.target;t.commands.updateAttributes("codeBlock",{language:c})}),i.appendChild(s),r.appendChild(o),r.appendChild(i),{dom:r,contentDOM:s}}}}).configure({lowlight:S1}),kd=["top","right","bottom","left"],xd=["start","end"],Sd=kd.reduce((n,e)=>n.concat(e,e+"-"+xd[0],e+"-"+xd[1]),[]),ft=Math.min,_e=Math.max,qi=Math.round,ht=n=>({x:n,y:n}),E1={left:"right",right:"left",bottom:"top",top:"bottom"},M1={start:"end",end:"start"};function nl(n,e,t){return _e(n,ft(e,t))}function At(n,e){return typeof n=="function"?n(e):n}function et(n){return n.split("-")[0]}function rt(n){return n.split("-")[1]}function Cd(n){return n==="x"?"y":"x"}function rl(n){return n==="y"?"height":"width"}const v1=new Set(["top","bottom"]);function pt(n){return v1.has(et(n))?"y":"x"}function il(n){return Cd(pt(n))}function Ed(n,e,t){t===void 0&&(t=!1);const r=rt(n),i=il(n),s=rl(i);let o=i==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Gi(o)),[o,Gi(o)]}function T1(n){const e=Gi(n);return[Ji(n),e,Ji(e)]}function Ji(n){return n.replace(/start|end/g,e=>M1[e])}const Md=["left","right"],vd=["right","left"],O1=["top","bottom"],N1=["bottom","top"];function A1(n,e,t){switch(n){case"top":case"bottom":return t?e?vd:Md:e?Md:vd;case"left":case"right":return e?O1:N1;default:return[]}}function R1(n,e,t,r){const i=rt(n);let s=A1(et(n),t==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(Ji)))),s}function Gi(n){return n.replace(/left|right|bottom|top/g,e=>E1[e])}function D1(n){return{top:0,right:0,bottom:0,left:0,...n}}function sl(n){return typeof n!="number"?D1(n):{top:n,right:n,bottom:n,left:n}}function zn(n){const{x:e,y:t,width:r,height:i}=n;return{width:r,height:i,top:t,left:e,right:e+r,bottom:t+i,x:e,y:t}}function Td(n,e,t){let{reference:r,floating:i}=n;const s=pt(e),o=il(e),l=rl(o),a=et(e),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[l]/2-i[l]/2;let h;switch(a){case"top":h={x:u,y:r.y-i.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-i.width,y:d};break;default:h={x:r.x,y:r.y}}switch(rt(e)){case"start":h[o]-=f*(t&&c?-1:1);break;case"end":h[o]+=f*(t&&c?-1:1);break}return h}const I1=async(n,e,t)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=t,l=s.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:n,floating:e,strategy:i}),{x:u,y:d}=Td(c,r,a),f=r,h={},p=0;for(let g=0;g<l.length;g++){const{name:y,fn:w}=l[g],{x:k,y:C,data:R,reset:M}=await w({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:h,rects:c,platform:o,elements:{reference:n,floating:e}});u=k??u,d=C??d,h={...h,[y]:{...h[y],...R}},M&&p<=50&&(p++,typeof M=="object"&&(M.placement&&(f=M.placement),M.rects&&(c=M.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:i}):M.rects),{x:u,y:d}=Td(c,f,a)),g=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:h}};async function _n(n,e){var t;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:a}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=At(e,n),p=sl(h),y=l[f?d==="floating"?"reference":"floating":d],w=zn(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(y)))==null||t?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),k=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),R=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},M=zn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:C,strategy:a}):k);return{top:(w.top-M.top+p.top)/R.y,bottom:(M.bottom-w.bottom+p.bottom)/R.y,left:(w.left-M.left+p.left)/R.x,right:(M.right-w.right+p.right)/R.x}}const P1=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=At(n,e)||{};if(c==null)return{};const d=sl(u),f={x:t,y:r},h=il(i),p=rl(h),g=await o.getDimensions(c),y=h==="y",w=y?"top":"left",k=y?"bottom":"right",C=y?"clientHeight":"clientWidth",R=s.reference[p]+s.reference[h]-f[h]-s.floating[p],M=f[h]-s.reference[h],I=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let T=I?I[C]:0;(!T||!await(o.isElement==null?void 0:o.isElement(I)))&&(T=l.floating[C]||s.floating[p]);const V=R/2-M/2,W=T/2-g[p]/2-1,j=ft(d[w],W),K=ft(d[k],W),P=j,Q=T-g[p]-K,Z=T/2-g[p]/2+V,ke=nl(P,Z,Q),he=!a.arrow&&rt(i)!=null&&Z!==ke&&s.reference[p]/2-(Z<P?j:K)-g[p]/2<0,pe=he?Z<P?Z-P:Z-Q:0;return{[h]:f[h]+pe,data:{[h]:ke,centerOffset:Z-ke-pe,...he&&{alignmentOffset:pe}},reset:he}}});function L1(n,e,t){return(n?[...t.filter(i=>rt(i)===n),...t.filter(i=>rt(i)!==n)]:t.filter(i=>et(i)===i)).filter(i=>n?rt(i)===n||(e?Ji(i)!==i:!1):!0)}const B1=function(n){return n===void 0&&(n={}),{name:"autoPlacement",options:n,async fn(e){var t,r,i;const{rects:s,middlewareData:o,placement:l,platform:a,elements:c}=e,{crossAxis:u=!1,alignment:d,allowedPlacements:f=Sd,autoAlignment:h=!0,...p}=At(n,e),g=d!==void 0||f===Sd?L1(d||null,h,f):f,y=await _n(e,p),w=((t=o.autoPlacement)==null?void 0:t.index)||0,k=g[w];if(k==null)return{};const C=Ed(k,s,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==k)return{reset:{placement:g[0]}};const R=[y[et(k)],y[C[0]],y[C[1]]],M=[...((r=o.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:R}],I=g[w+1];if(I)return{data:{index:w+1,overflows:M},reset:{placement:I}};const T=M.map(j=>{const K=rt(j.placement);return[j.placement,K&&u?j.overflows.slice(0,2).reduce((P,Q)=>P+Q,0):j.overflows[0],j.overflows]}).sort((j,K)=>j[1]-K[1]),W=((i=T.filter(j=>j[2].slice(0,rt(j[0])?2:3).every(K=>K<=0))[0])==null?void 0:i[0])||T[0][0];return W!==l?{data:{index:w+1,overflows:M},reset:{placement:W}}:{}}}},V1=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=At(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const w=et(i),k=pt(l),C=et(l)===l,R=await(a.isRTL==null?void 0:a.isRTL(c.floating)),M=f||(C||!g?[Gi(l)]:T1(l)),I=p!=="none";!f&&I&&M.push(...R1(l,g,p,R));const T=[l,...M],V=await _n(e,y),W=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&W.push(V[w]),d){const Z=Ed(i,o,R);W.push(V[Z[0]],V[Z[1]])}if(j=[...j,{placement:i,overflows:W}],!W.every(Z=>Z<=0)){var K,P;const Z=(((K=s.flip)==null?void 0:K.index)||0)+1,ke=T[Z];if(ke&&(!(d==="alignment"?k!==pt(ke):!1)||j.every(Me=>pt(Me.placement)===k?Me.overflows[0]>0:!0)))return{data:{index:Z,overflows:j},reset:{placement:ke}};let he=(P=j.filter(pe=>pe.overflows[0]<=0).sort((pe,Me)=>pe.overflows[1]-Me.overflows[1])[0])==null?void 0:P.placement;if(!he)switch(h){case"bestFit":{var Q;const pe=(Q=j.filter(Me=>{if(I){const yt=pt(Me.placement);return yt===k||yt==="y"}return!0}).map(Me=>[Me.placement,Me.overflows.filter(yt=>yt>0).reduce((yt,pl)=>yt+pl,0)]).sort((Me,yt)=>Me[1]-yt[1])[0])==null?void 0:Q[0];pe&&(he=pe);break}case"initialPlacement":he=l;break}if(i!==he)return{reset:{placement:he}}}return{}}}};function Od(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function Nd(n){return kd.some(e=>n[e]>=0)}const $1=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:r="referenceHidden",...i}=At(n,e);switch(r){case"referenceHidden":{const s=await _n(e,{...i,elementContext:"reference"}),o=Od(s,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Nd(o)}}}case"escaped":{const s=await _n(e,{...i,altBoundary:!0}),o=Od(s,t.floating);return{data:{escapedOffsets:o,escaped:Nd(o)}}}default:return{}}}}};function Ad(n){const e=ft(...n.map(s=>s.left)),t=ft(...n.map(s=>s.top)),r=_e(...n.map(s=>s.right)),i=_e(...n.map(s=>s.bottom));return{x:e,y:t,width:r-e,height:i-t}}function z1(n){const e=n.slice().sort((i,s)=>i.y-s.y),t=[];let r=null;for(let i=0;i<e.length;i++){const s=e[i];!r||s.y-r.y>r.height/2?t.push([s]):t[t.length-1].push(s),r=s}return t.map(i=>zn(Ad(i)))}const _1=function(n){return n===void 0&&(n={}),{name:"inline",options:n,async fn(e){const{placement:t,elements:r,rects:i,platform:s,strategy:o}=e,{padding:l=2,x:a,y:c}=At(n,e),u=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(r.reference))||[]),d=z1(u),f=zn(Ad(u)),h=sl(l);function p(){if(d.length===2&&d[0].left>d[1].right&&a!=null&&c!=null)return d.find(y=>a>y.left-h.left&&a<y.right+h.right&&c>y.top-h.top&&c<y.bottom+h.bottom)||f;if(d.length>=2){if(pt(t)==="y"){const j=d[0],K=d[d.length-1],P=et(t)==="top",Q=j.top,Z=K.bottom,ke=P?j.left:K.left,he=P?j.right:K.right,pe=he-ke,Me=Z-Q;return{top:Q,bottom:Z,left:ke,right:he,width:pe,height:Me,x:ke,y:Q}}const y=et(t)==="left",w=_e(...d.map(j=>j.right)),k=ft(...d.map(j=>j.left)),C=d.filter(j=>y?j.left===k:j.right===w),R=C[0].top,M=C[C.length-1].bottom,I=k,T=w,V=T-I,W=M-R;return{top:R,bottom:M,left:I,right:T,width:V,height:W,x:I,y:R}}return f}const g=await s.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:o});return i.reference.x!==g.reference.x||i.reference.y!==g.reference.y||i.reference.width!==g.reference.width||i.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},H1=new Set(["left","top"]);async function F1(n,e){const{placement:t,platform:r,elements:i}=n,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=et(t),l=rt(t),a=pt(t)==="y",c=H1.has(o)?-1:1,u=s&&a?-1:1,d=At(e,n);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const j1=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:i,y:s,placement:o,middlewareData:l}=e,a=await F1(e,n);return o===((t=l.offset)==null?void 0:t.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+a.x,y:s+a.y,data:{...a,placement:o}}}}},U1=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:l={fn:y=>{let{x:w,y:k}=y;return{x:w,y:k}}},...a}=At(n,e),c={x:t,y:r},u=await _n(e,a),d=pt(et(i)),f=Cd(d);let h=c[f],p=c[d];if(s){const y=f==="y"?"top":"left",w=f==="y"?"bottom":"right",k=h+u[y],C=h-u[w];h=nl(k,h,C)}if(o){const y=d==="y"?"top":"left",w=d==="y"?"bottom":"right",k=p+u[y],C=p-u[w];p=nl(k,p,C)}const g=l.fn({...e,[f]:h,[d]:p});return{...g,data:{x:g.x-t,y:g.y-r,enabled:{[f]:s,[d]:o}}}}}},W1=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){var t,r;const{placement:i,rects:s,platform:o,elements:l}=e,{apply:a=()=>{},...c}=At(n,e),u=await _n(e,c),d=et(i),f=rt(i),h=pt(i)==="y",{width:p,height:g}=s.floating;let y,w;d==="top"||d==="bottom"?(y=d,w=f===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(w=d,y=f==="end"?"top":"bottom");const k=g-u.top-u.bottom,C=p-u.left-u.right,R=ft(g-u[y],k),M=ft(p-u[w],C),I=!e.middlewareData.shift;let T=R,V=M;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(V=C),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(T=k),I&&!f){const j=_e(u.left,0),K=_e(u.right,0),P=_e(u.top,0),Q=_e(u.bottom,0);h?V=p-2*(j!==0||K!==0?j+K:_e(u.left,u.right)):T=g-2*(P!==0||Q!==0?P+Q:_e(u.top,u.bottom))}await a({...e,availableWidth:V,availableHeight:T});const W=await o.getDimensions(l.floating);return p!==W.width||g!==W.height?{reset:{rects:!0}}:{}}}};function Yi(){return typeof window<"u"}function Hn(n){return Rd(n)?(n.nodeName||"").toLowerCase():"#document"}function Ke(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Rt(n){var e;return(e=(Rd(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Rd(n){return Yi()?n instanceof Node||n instanceof Ke(n).Node:!1}function it(n){return Yi()?n instanceof Element||n instanceof Ke(n).Element:!1}function mt(n){return Yi()?n instanceof HTMLElement||n instanceof Ke(n).HTMLElement:!1}function Dd(n){return!Yi()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Ke(n).ShadowRoot}const K1=new Set(["inline","contents"]);function Mr(n){const{overflow:e,overflowX:t,overflowY:r,display:i}=st(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&!K1.has(i)}const q1=new Set(["table","td","th"]);function J1(n){return q1.has(Hn(n))}const G1=[":popover-open",":modal"];function Xi(n){return G1.some(e=>{try{return n.matches(e)}catch{return!1}})}const Y1=["transform","translate","scale","rotate","perspective"],X1=["transform","translate","scale","rotate","perspective","filter"],Q1=["paint","layout","strict","content"];function ol(n){const e=ll(),t=it(n)?st(n):n;return Y1.some(r=>t[r]?t[r]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||X1.some(r=>(t.willChange||"").includes(r))||Q1.some(r=>(t.contain||"").includes(r))}function Z1(n){let e=en(n);for(;mt(e)&&!Fn(e);){if(ol(e))return e;if(Xi(e))return null;e=en(e)}return null}function ll(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const eb=new Set(["html","body","#document"]);function Fn(n){return eb.has(Hn(n))}function st(n){return Ke(n).getComputedStyle(n)}function Qi(n){return it(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function en(n){if(Hn(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Dd(n)&&n.host||Rt(n);return Dd(e)?e.host:e}function Id(n){const e=en(n);return Fn(e)?n.ownerDocument?n.ownerDocument.body:n.body:mt(e)&&Mr(e)?e:Id(e)}function Pd(n,e,t){var r;e===void 0&&(e=[]);const i=Id(n),s=i===((r=n.ownerDocument)==null?void 0:r.body),o=Ke(i);return s?(al(o),e.concat(o,o.visualViewport||[],Mr(i)?i:[],[])):e.concat(i,Pd(i,[]))}function al(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Ld(n){const e=st(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=mt(n),s=i?n.offsetWidth:t,o=i?n.offsetHeight:r,l=qi(t)!==s||qi(r)!==o;return l&&(t=s,r=o),{width:t,height:r,$:l}}function Bd(n){return it(n)?n:n.contextElement}function jn(n){const e=Bd(n);if(!mt(e))return ht(1);const t=e.getBoundingClientRect(),{width:r,height:i,$:s}=Ld(e);let o=(s?qi(t.width):t.width)/r,l=(s?qi(t.height):t.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const tb=ht(0);function Vd(n){const e=Ke(n);return!ll()||!e.visualViewport?tb:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function nb(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==Ke(n)?!1:e}function vr(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const i=n.getBoundingClientRect(),s=Bd(n);let o=ht(1);e&&(r?it(r)&&(o=jn(r)):o=jn(n));const l=nb(s,t,r)?Vd(s):ht(0);let a=(i.left+l.x)/o.x,c=(i.top+l.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(s){const f=Ke(s),h=r&&it(r)?Ke(r):r;let p=f,g=al(p);for(;g&&r&&h!==p;){const y=jn(g),w=g.getBoundingClientRect(),k=st(g),C=w.left+(g.clientLeft+parseFloat(k.paddingLeft))*y.x,R=w.top+(g.clientTop+parseFloat(k.paddingTop))*y.y;a*=y.x,c*=y.y,u*=y.x,d*=y.y,a+=C,c+=R,p=Ke(g),g=al(p)}}return zn({width:u,height:d,x:a,y:c})}function Zi(n,e){const t=Qi(n).scrollLeft;return e?e.left+t:vr(Rt(n)).left+t}function $d(n,e){const t=n.getBoundingClientRect(),r=t.left+e.scrollLeft-Zi(n,t),i=t.top+e.scrollTop;return{x:r,y:i}}function rb(n){let{elements:e,rect:t,offsetParent:r,strategy:i}=n;const s=i==="fixed",o=Rt(r),l=e?Xi(e.floating):!1;if(r===o||l&&s)return t;let a={scrollLeft:0,scrollTop:0},c=ht(1);const u=ht(0),d=mt(r);if((d||!d&&!s)&&((Hn(r)!=="body"||Mr(o))&&(a=Qi(r)),mt(r))){const h=vr(r);c=jn(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=o&&!d&&!s?$d(o,a):ht(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-a.scrollLeft*c.x+u.x+f.x,y:t.y*c.y-a.scrollTop*c.y+u.y+f.y}}function ib(n){return Array.from(n.getClientRects())}function sb(n){const e=Rt(n),t=Qi(n),r=n.ownerDocument.body,i=_e(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=_e(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-t.scrollLeft+Zi(n);const l=-t.scrollTop;return st(r).direction==="rtl"&&(o+=_e(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}const zd=25;function ob(n,e){const t=Ke(n),r=Rt(n),i=t.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,a=0;if(i){s=i.width,o=i.height;const u=ll();(!u||u&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}const c=Zi(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-h);p<=zd&&(s-=p)}else c<=zd&&(s+=c);return{width:s,height:o,x:l,y:a}}const lb=new Set(["absolute","fixed"]);function ab(n,e){const t=vr(n,!0,e==="fixed"),r=t.top+n.clientTop,i=t.left+n.clientLeft,s=mt(n)?jn(n):ht(1),o=n.clientWidth*s.x,l=n.clientHeight*s.y,a=i*s.x,c=r*s.y;return{width:o,height:l,x:a,y:c}}function _d(n,e,t){let r;if(e==="viewport")r=ob(n,t);else if(e==="document")r=sb(Rt(n));else if(it(e))r=ab(e,t);else{const i=Vd(n);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return zn(r)}function Hd(n,e){const t=en(n);return t===e||!it(t)||Fn(t)?!1:st(t).position==="fixed"||Hd(t,e)}function cb(n,e){const t=e.get(n);if(t)return t;let r=Pd(n,[]).filter(l=>it(l)&&Hn(l)!=="body"),i=null;const s=st(n).position==="fixed";let o=s?en(n):n;for(;it(o)&&!Fn(o);){const l=st(o),a=ol(o);!a&&l.position==="fixed"&&(i=null),(s?!a&&!i:!a&&l.position==="static"&&!!i&&lb.has(i.position)||Mr(o)&&!a&&Hd(n,o))?r=r.filter(u=>u!==o):i=l,o=en(o)}return e.set(n,r),r}function ub(n){let{element:e,boundary:t,rootBoundary:r,strategy:i}=n;const o=[...t==="clippingAncestors"?Xi(e)?[]:cb(e,this._c):[].concat(t),r],l=o[0],a=o.reduce((c,u)=>{const d=_d(e,u,i);return c.top=_e(d.top,c.top),c.right=ft(d.right,c.right),c.bottom=ft(d.bottom,c.bottom),c.left=_e(d.left,c.left),c},_d(e,l,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function db(n){const{width:e,height:t}=Ld(n);return{width:e,height:t}}function fb(n,e,t){const r=mt(e),i=Rt(e),s=t==="fixed",o=vr(n,!0,s,e);let l={scrollLeft:0,scrollTop:0};const a=ht(0);function c(){a.x=Zi(i)}if(r||!r&&!s)if((Hn(e)!=="body"||Mr(i))&&(l=Qi(e)),r){const h=vr(e,!0,s,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else i&&c();s&&!r&&i&&c();const u=i&&!r&&!s?$d(i,l):ht(0),d=o.left+l.scrollLeft-a.x-u.x,f=o.top+l.scrollTop-a.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function cl(n){return st(n).position==="static"}function Fd(n,e){if(!mt(n)||st(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return Rt(n)===t&&(t=t.ownerDocument.body),t}function jd(n,e){const t=Ke(n);if(Xi(n))return t;if(!mt(n)){let i=en(n);for(;i&&!Fn(i);){if(it(i)&&!cl(i))return i;i=en(i)}return t}let r=Fd(n,e);for(;r&&J1(r)&&cl(r);)r=Fd(r,e);return r&&Fn(r)&&cl(r)&&!ol(r)?t:r||Z1(n)||t}const hb=async function(n){const e=this.getOffsetParent||jd,t=this.getDimensions,r=await t(n.floating);return{reference:fb(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function pb(n){return st(n).direction==="rtl"}const mb={convertOffsetParentRelativeRectToViewportRelativeRect:rb,getDocumentElement:Rt,getClippingRect:ub,getOffsetParent:jd,getElementRects:hb,getClientRects:ib,getDimensions:db,getScale:jn,isElement:it,isRTL:pb},Ud=j1,Wd=B1,Kd=U1,qd=V1,Jd=W1,Gd=$1,Yd=P1,Xd=_1,Qd=(n,e,t)=>{const r=new Map,i={platform:mb,...t},s={...i.platform,_c:r};return I1(n,e,{...i,platform:s})};var ul,dl;if(typeof WeakMap<"u"){let n=new WeakMap;ul=e=>n.get(e),dl=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;ul=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},dl=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var Dt=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,i=e/this.width|0;let s=r+1,o=i+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:r,top:i,right:s,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:i,top:s,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?r==0:i==this.width)?null:this.map[s*this.width+(t<0?r-1:i)]:(t<0?s==0:o==this.height)?null:this.map[r+this.width*(t<0?s-1:o)]}rectBetween(n,e){const{left:t,right:r,top:i,bottom:s}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(i,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let i=n.left;i<n.right;i++){const s=r*this.width+i,o=this.map[s];t[o]||(t[o]=!0,!(i==n.left&&i&&this.map[s-1]==o||r==n.top&&r&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let r=0,i=0;;r++){const s=i+t.child(r).nodeSize;if(r==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<i;)o++;return o==l?s-1:this.map[o]}i=s}}static get(n){return ul(n)||dl(n,gb(n))}};function gb(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=yb(n),t=n.childCount,r=[];let i=0,s=null;const o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const d=n.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==d.childCount)break;const g=d.child(p),{colspan:y,rowspan:w,colwidth:k}=g.attrs;for(let C=0;C<w;C++){if(C+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-C});break}const R=i+C*e;for(let M=0;M<y;M++){r[R+M]==0?r[R+M]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:y-M});const I=k&&k[M];if(I){const T=(R+M)%e*2,V=o[T];V==null||V!=I&&o[T+1]==1?(o[T]=I,o[T+1]=1):V==I&&o[T+1]++}}}i+=y,u+=g.nodeSize}const f=(c+1)*e;let h=0;for(;i<f;)r[i++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new Dt(e,t,r,s);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&bb(l,o,n),l}function yb(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const i=n.child(r);let s=0;if(t)for(let o=0;o<r;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){const l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function bb(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;i<n.map.length;i++){const s=n.map[i];if(r[s])continue;r[s]=!0;const o=t.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const u=(i+c)%n.width,d=e[u*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=wb(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function wb(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function fl(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}new le("selectingCells");function kb(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Zd(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function xb(n){const e=n.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;const t=kb(e.$head)||Sb(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Sb(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ef(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function tf(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function nf(n,e,t){const r=n.node(-1),i=Dt.get(r),s=n.start(-1),o=i.nextCell(n.pos-s,e,t);return o==null?null:n.node(0).resolve(s+o)}function rf(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}var gt=class Pt extends H{constructor(e,t=e){const r=e.node(-1),i=Dt.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=s+u+1;return new pa(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(ef(r)&&ef(i)&&tf(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Pt.rowSelection(r,i):s&&this.isColSelection()?Pt.colSelection(r,i):new Pt(r,i)}return F.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=Dt.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let u=a*t.width+i.left,d=i.left;d<i.right;d++,u++){const f=t.map[u];if(s[f])continue;s[f]=!0;const h=t.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const g=i.left-h.left,y=h.right-i.right;if(g>0||y>0){let w=p.attrs;if(g>0&&(w=rf(w,0,g)),y>0&&(w=rf(w,w.colspan-y,y)),h.left<i.left){if(p=p.type.createAndFill(w),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(w)}`)}else p=p.type.create(w,p.content)}if(h.top<i.top||h.bottom>i.bottom){const w={...p.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top<i.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}c.push(p)}o.push(e.child(a).copy(S.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new N(S.from(l),1,1)}replace(e,t=N.empty){const r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){const{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?N.empty:t)}const s=H.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new N(S.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Dt.get(t),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),i+s[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=Dt.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(s+i.map[o.left])),l.bottom<i.height&&(t=a.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+i.map[l.left])),o.bottom<i.height&&(e=a.resolve(s+i.map[i.width*(i.height-1)+o.right-1]))),new Pt(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Dt.get(e),r=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(i,s)>0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof Pt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=Dt.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(s+i.map[o.top*i.width])),l.right<i.width&&(t=a.resolve(s+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+i.map[l.top*i.width])),o.right<i.width&&(e=a.resolve(s+i.map[i.width*(o.top+1)-1]))),new Pt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Pt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Pt(e.resolve(t),e.resolve(r))}getBookmark(){return new Cb(this.$anchorCell.pos,this.$headCell.pos)}};gt.prototype.visible=!1,H.jsonID("cell",gt);var Cb=class Pf{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Pf(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&tf(t,r)?new gt(t,r):H.near(r,1)}};new le("fix-tables");function sf(n){const e=n.selection,t=xb(n),r=t.node(-1),i=t.start(-1),s=Dt.get(r);return{...e instanceof gt?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(t.pos-i),tableStart:i,map:s,table:r}}function Eb(n){return function(e,t){if(!Zd(e))return!1;if(t){const r=fl(e.schema),i=sf(e),s=e.tr,o=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);t(s)}return!0}}function of(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function hl(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Eb(n):function(t,r){if(!Zd(t))return!1;if(r){const i=fl(t.schema),s=sf(t),o=t.tr,l=of("row",s,i),a=of("column",s,i),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?{left:0,top:u,right:1,bottom:s.map.height}:n=="row"?{left:u,top:0,right:s.map.width,bottom:1}:s,f=n=="column"?a?i.cell:i.header_cell:n=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,f,g.attrs)}),r(o)}return!0}}hl("row",{useDeprecatedLogic:!0}),hl("column",{useDeprecatedLogic:!0}),hl("cell",{useDeprecatedLogic:!0});function es(n,e){const t=n.selection;if(!(t instanceof gt))return!1;if(e){const r=n.tr,i=fl(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new N(i,0,0))}),r.docChanged&&e(r)}return!0}to({ArrowLeft:ns("horiz",-1),ArrowRight:ns("horiz",1),ArrowUp:ns("vert",-1),ArrowDown:ns("vert",1),"Shift-ArrowLeft":rs("horiz",-1),"Shift-ArrowRight":rs("horiz",1),"Shift-ArrowUp":rs("vert",-1),"Shift-ArrowDown":rs("vert",1),Backspace:es,"Mod-Backspace":es,Delete:es,"Mod-Delete":es});function ts(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function ns(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;if(s instanceof gt)return ts(t,r,H.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=lf(i,n,e);if(o==null)return!1;if(n=="horiz")return ts(t,r,H.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=nf(l,n,e);let c;return a?c=H.near(a,1):e<0?c=H.near(t.doc.resolve(l.before(-1)),-1):c=H.near(t.doc.resolve(l.after(-1)),1),ts(t,r,c)}}}function rs(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;let o;if(s instanceof gt)o=s;else{const a=lf(i,n,e);if(a==null)return!1;o=new gt(t.doc.resolve(a))}const l=nf(o.$headCell,n,e);return l?ts(t,r,new gt(o.$anchorCell,l)):!1}}function lf(n,e,t){if(!(n.state.selection instanceof F))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}new le("tableColumnResizing");function Mb(n,e){const t=Math.min(n.top,e.top),r=Math.max(n.bottom,e.bottom),i=Math.min(n.left,e.left),o=Math.max(n.right,e.right)-i,l=r-t,a=i,c=t;return new DOMRect(a,c,o,l)}var vb=class{constructor({editor:n,element:e,view:t,updateDelay:r=250,resizeDelay:i=60,shouldShow:s,appendTo:o,getReferencedVirtualElement:l,options:a}){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:d,from:f,to:h})=>{const{doc:p,selection:g}=d,{empty:y}=g,w=!p.textBetween(f,h).length&&wo(d.selection),k=this.element.contains(document.activeElement);return!(!(u.hasFocus()||k)||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 d;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u?.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||u?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,d)=>{const f=!d?.selection.eq(u.state.selection),h=!d?.doc.eq(u.state.doc);!f&&!h||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,f,h,d)},this.updateDelay))},this.updateHandler=(u,d,f,h)=>{const{composing:p}=u;if(p||!d&&!f)return;if(!this.getShouldShow(h)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:u})=>{u.getMeta("bubbleMenu")==="updatePosition"&&this.updatePosition()};var c;this.editor=n,this.element=e,this.view=t,this.updateDelay=r,this.resizeDelay=i,this.appendTo=o,this.scrollTarget=(c=a?.scrollTarget)!=null?c:window,this.getReferencedVirtualElement=l,this.floatingUIOptions={...this.floatingUIOptions,...a},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(t,t.state),this.getShouldShow()&&this.show()}get middlewares(){const n=[];return this.floatingUIOptions.flip&&n.push(qd(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&n.push(Kd(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&n.push(Ud(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&n.push(Yd(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&n.push(Jd(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&n.push(Wd(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&n.push(Gd(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&n.push(Xd(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),n}get virtualElement(){var n;const{selection:e}=this.editor.state,t=(n=this.getReferencedVirtualElement)==null?void 0:n.call(this);if(t)return t;const r=hu(this.view,e.from,e.to);let i={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(e instanceof $){let s=this.view.nodeDOM(e.from);const o=s.dataset.nodeViewWrapper?s:s.querySelector("[data-node-view-wrapper]");o&&(s=o),s&&(i={getBoundingClientRect:()=>s.getBoundingClientRect(),getClientRects:()=>[s.getBoundingClientRect()]})}if(e instanceof gt){const{$anchorCell:s,$headCell:o}=e,l=s?s.pos:o.pos,a=o?o.pos:s.pos,c=this.view.nodeDOM(l),u=this.view.nodeDOM(a);if(!c||!u)return;const d=c===u?c.getBoundingClientRect():Mb(c.getBoundingClientRect(),u.getBoundingClientRect());i={getBoundingClientRect:()=>d,getClientRects:()=>[d]}}return i}updatePosition(){const n=this.virtualElement;n&&Qd(n,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:r})=>{this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(n,e){const{state:t}=n,r=t.selection.from!==t.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(n,e);return}const i=!e?.selection.eq(n.state.selection),s=!e?.doc.eq(n.state.doc);this.updateHandler(n,i,s,e)}getShouldShow(n){var e;const{state:t}=this.view,{selection:r}=t,{ranges:i}=r,s=Math.min(...i.map(a=>a.$from.pos)),o=Math.max(...i.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:t,oldState:n,from:s,to:o})}show(){var n;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(n=e??this.view.dom.parentElement)==null||n.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)}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()}},af=n=>new se({key:typeof n.pluginKey=="string"?new le(n.pluginKey):n.pluginKey,view:e=>new vb({view:e,...n})});ue.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[af({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 Tb=m.defineComponent({name:"BubbleMenu",inheritAttrs:!1,props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:Object,default:void 0},shouldShow:{type:Function,default:null},getReferencedVirtualElement:{type:Function,default:void 0}},setup(n,{slots:e,attrs:t}){const r=m.ref(null);return m.onMounted(()=>{const{editor:i,options:s,pluginKey:o,resizeDelay:l,appendTo:a,shouldShow:c,getReferencedVirtualElement:u,updateDelay:d}=n;r.value&&(r.value.style.visibility="hidden",r.value.style.position="absolute",r.value.remove(),i.registerPlugin(af({editor:i,element:r.value,options:s,pluginKey:o,resizeDelay:l,appendTo:a,shouldShow:c,getReferencedVirtualElement:u,updateDelay:d})))}),m.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=n;s.unregisterPlugin(i)}),()=>{var i;return m.h(m.Teleport,{to:"body"},m.h("div",{...t,ref:r},(i=e.default)==null?void 0:i.call(e)))}}}),Ob=class{constructor({editor:n,element:e,view:t,options:r,appendTo:i,shouldShow:s}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:o,state:l})=>{const{selection:a}=l,{$anchor:c,empty:u}=a,d=c.depth===1,f=c.parent.isTextblock&&!c.parent.type.spec.code&&!c.parent.textContent&&c.parent.childCount===0&&!this.getTextContent(c.parent);return!(!o.hasFocus()||!u||!d||!f||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(o,l,a,c)=>{const{composing:u}=o;if(u||!l&&!a)return;if(!this.getShouldShow(c)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:o})=>{var l;if(this.preventHide){this.preventHide=!1;return}o?.relatedTarget&&((l=this.element.parentNode)!=null&&l.contains(o.relatedTarget))||o?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=n,this.element=e,this.view=t,this.appendTo=i,this.floatingUIOptions={...this.floatingUIOptions,...r},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(t,t.state),this.getShouldShow()&&this.show()}getTextContent(n){return iu(n,{textSerializers:ho(this.editor.schema)})}get middlewares(){const n=[];return this.floatingUIOptions.flip&&n.push(qd(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&n.push(Kd(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&n.push(Ud(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&n.push(Yd(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&n.push(Jd(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&n.push(Wd(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&n.push(Gd(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&n.push(Xd(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),n}getShouldShow(n){var e;const{state:t}=this.view,{selection:r}=t,{ranges:i}=r,s=Math.min(...i.map(a=>a.$from.pos)),o=Math.max(...i.map(a=>a.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:t,oldState:n,from:s,to:o})}updatePosition(){const{selection:n}=this.editor.state,e=hu(this.view,n.from,n.to);Qd({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:i,strategy:s})=>{this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${r}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(n,e){const t=!e?.selection.eq(n.state.selection),r=!e?.doc.eq(n.state.doc);this.updateHandler(n,t,r,e)}show(){var n;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(n=e??this.view.dom.parentElement)==null||n.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)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},cf=n=>new se({key:typeof n.pluginKey=="string"?new le(n.pluginKey):n.pluginKey,view:e=>new Ob({view:e,...n})});ue.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[cf({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}}),m.defineComponent({name:"FloatingMenu",inheritAttrs:!1,props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},options:{type:Object,default:()=>({})},appendTo:{type:Object,default:void 0},shouldShow:{type:Function,default:null}},setup(n,{slots:e,attrs:t}){const r=m.ref(null);return m.onMounted(()=>{const{pluginKey:i,editor:s,options:o,appendTo:l,shouldShow:a}=n;r.value&&(r.value.style.visibility="hidden",r.value.style.position="absolute",r.value.remove(),s.registerPlugin(cf({pluginKey:i,editor:s,element:r.value,options:o,appendTo:l,shouldShow:a})))}),m.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=n;s.unregisterPlugin(i)}),()=>{var i;return m.h(m.Teleport,{to:"body"},m.h("div",{...t,ref:r},(i=e.default)==null?void 0:i.call(e)))}}});const Nb={class:"sus-bubble-menu"},Ab=bn(m.defineComponent({__name:"BubbleMenu",props:{editor:{},showMenu:{type:Boolean}},setup(n){const e=n,t=m.ref(""),r=m.ref(!1);function i(){if(r.value){r.value=!1;return}t.value=e.editor?.getAttributes("link").href,r.value=!0}function s(){if(!t.value){e.editor?.chain().focus().extendMarkRange("link").unsetLink().run(),r.value=!1;return}e.editor?.chain().focus().extendMarkRange("link").setLink({href:t.value}).run(),r.value=!1}function o(){t.value&&window.open(e.editor?.getAttributes("link").href)}return(l,a)=>(m.openBlock(),m.createElementBlock(m.Fragment,null,[m.withDirectives(m.createElementVNode("div",{class:"inset-0 absolute",onClick:a[2]||(a[2]=c=>r.value=!1)},[m.createElementVNode("div",{class:"sus-link",onClick:a[1]||(a[1]=m.withModifiers(()=>{},["stop"]))},[m.withDirectives(m.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=c=>t.value=c),onKeyup:m.withKeys(s,["enter"]),class:"sus-link-input",type:"text",placeholder:"请输入链接"},null,544),[[m.vModelText,t.value]]),(m.openBlock(),m.createElementBlock("svg",{onClick:s,title:"确定",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},[...a[4]||(a[4]=[m.createElementVNode("rect",{width:"24",height:"24",fill:"none"},null,-1),m.createElementVNode("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5"},[m.createElementVNode("path",{"stroke-linejoin":"round",d:"m21 3l-9 9m0 0h5.344M12 12V6.656"}),m.createElementVNode("path",{d:"M2 12c0-4.714 0-7.071 1.464-8.536C4.93 2 7.286 2 12 2m10 10c0 4.714 0 7.071-1.465 8.535C19.072 22 16.714 22 12 22s-7.071 0-8.536-1.465c-.973-.973-1.3-2.342-1.409-4.535"})],-1)])])),(m.openBlock(),m.createElementBlock("svg",{onClick:o,title:"预览",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[...a[5]||(a[5]=[m.createElementVNode("rect",{width:"24",height:"24",fill:"none"},null,-1),m.createElementVNode("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5"},[m.createElementVNode("path",{"stroke-linejoin":"round",d:"m13 11l9-9m0 0h-5.344M22 2v5.344"}),m.createElementVNode("path",{d:"M2 12c0-4.714 0-7.071 1.464-8.536C4.93 2 7.286 2 12 2m10 10c0 4.714 0 7.071-1.465 8.535C19.072 22 16.714 22 12 22s-7.071 0-8.536-1.465c-.973-.973-1.3-2.342-1.409-4.535"})],-1)])]))])],512),[[m.vShow,r.value]]),n.editor&&n.showMenu?(m.openBlock(),m.createBlock(m.unref(Tb),{key:0,editor:n.editor,options:{placement:"bottom",offset:8}},{default:m.withCtx(()=>[m.createElementVNode("div",Nb,[m.createElementVNode("button",{onClick:i,title:"添加链接"}," 链接 "),m.createElementVNode("button",{onClick:a[3]||(a[3]=c=>n.editor.commands.unsetAllMarks()),title:"清除当前选中格式"}," 清除 ")])]),_:1},8,["editor"])):m.createCommentVNode("",!0)],64))}}),[["__scopeId","data-v-3f87b608"]]),Rb=ze.create({name:"emoji",inline:!0,group:"inline",atom:!0,addAttributes(){return{name:{default:null},src:{default:null}}},parseHTML(){return[{tag:"span[data-type='emoji']"}]},renderHTML({HTMLAttributes:n}){return["span",{"data-type":"emoji",class:"emoji",contenteditable:"false"},["img",ce(n,{src:n.src,alt:n.name,draggable:"false",loading:"lazy",align:"absmiddle"})]]}}),Db={class:"sus-comment relative flex flex-row w-full"},Ib={key:0,class:"sus-comment-avatar"},Pb=["src"],Lb={class:"sus-comment__main"},Bb={key:0,class:"sus-comment__info my-1"},Vb={key:0,class:"sus-comment__info-input"},$b=["placeholder"],zb={key:1,class:"sus-comment__info-input"},_b=["placeholder"],Hb={key:2,class:"sus-comment__info-input"},Fb=["placeholder"],jb={class:"relative"},Ub={class:"sus-comment__footer flex justify-between"},Wb={class:"flex flex-row items-center"},Kb={key:0,class:"p-1"},qb={key:1,class:"sus-upload p-1"},Jb={class:"sus-comment__toolbar relative flex"},Gb={class:"sus-comment__toolbar-mask absolute inset-0"},Yb={class:"sus-comment__extend flex"},Xb=["src"],Qb=["onClick"],uf=bn(m.defineComponent({__name:"index",props:{reply:{},toolBar:{},infoBar:{},placeholder:{default:"支持常见的markdown语法,如图片、代码块等"},comment:{}},emits:["on-save","on-cancel","add-image","update-avatar"],setup(n,{expose:e,emit:t}){class r{articleId="";userName="";userEmail="";userWebsite="";userAvatar="";content="";contentText="";replyName="";parentId="";notify=0;privacy=!1}const i=n;e({updateImage:M,updatePreviewImage:T});const s=t,o=m.reactive({emojis:i.toolBar?.emoji?.emojis||[],showPanel:!1}),l=i.reply?.userName,a=m.ref("在此处留下你的足迹吧!(支持markdown语法)"),c=m.reactive(new r),u=m.ref(""),d=m.ref(null),f=m.ref([]),h=m.ref(null),p=i.comment?.privacy||!1,g={enable:i.infoBar?.enable===void 0?!0:i.infoBar.enable,name:{show:i.infoBar?.name?.show===void 0?!0:i.infoBar.name.show,placeholder:i.infoBar?.name?.placeholder||"昵称(必填)"},website:{show:i.infoBar?.website?.show===void 0?!0:i.infoBar.website.show,placeholder:i.infoBar?.website?.placeholder||"网址(https://)",tips:i.infoBar?.website?.tips||"点击昵称时可跳转"},email:{show:i.infoBar?.email?.show===void 0?!0:i.infoBar.email.show,placeholder:i.infoBar?.email?.placeholder||"邮箱(不会公开,仅用于通知回复)",tips:i.infoBar?.email?.tips||"输入QQ邮箱自动获取头像"}},y=Oy({extensions:[u1,h1,l1.configure({placeholder:i.placeholder}),M0.configure({openOnClick:!1,defaultProtocol:"https"}),Rb,C1]});function w(){i.comment&&(c.privacy=i.comment.privacy||!1,c.notify=i.comment.notify||1,c.userName=i.comment.userName||"",c.userEmail=i.comment.userEmail||"",c.userWebsite=i.comment.userWebsite||"",c.userAvatar=i.comment.userAvatar||"",c.content=i.comment.content||"",c.articleId=i.comment.articleId||"")}async function k(){if(!(!y||!y.value)){if(u.value=y.value.getHTML(),c.userWebsite&&(c.userWebsite.concat("http://")||c.userWebsite.concat("https://")||(c.userWebsite="https://"+c.userWebsite)),localStorage.setItem("user",JSON.stringify(c)),localStorage.setItem("comment-content",u.value),i.reply.id!="0"){const K=i.reply.parentId;c.parentId=K==="0"?i.reply.id:K,c.replyName=i.reply.userName,a.value="@"+l+":"}c.content=u.value,c.contentText=y.value.getText(),s("on-save",c,h.value)}}function C(){localStorage.setItem("comment-content",""),s("on-cancel")}function R(){s("add-image",d.value,h.value)}function M(K){h.value||(h.value=[]),!h.value||h.value.length==0?h.value=K:h.value=I(h.value,K[0]),f.value=[];for(let P=0;P<h.value.length;P++)f.value.push(URL.createObjectURL(h.value[P]))}function I(K,P){return[...K,P]}function T(K){f.value=K}function V(){s("update-avatar",c)}function W(){c.notify==1?c.notify=0:c.notify=1}function j(K){try{if(!h.value||!h.value.length||h.value.length<=1){h.value=[],f.value=[];return}h.value?.splice(K,1),f.value.splice(K,1)}catch(P){console.log("remove image error: ",P),h.value=[],f.value=[]}}return m.onMounted(()=>{if(!y||!y.value)return;w();const K=localStorage.getItem("user");if(c.content&&c.content.length>3)y.value.commands.setContent(c.content);else{const P=localStorage.getItem("comment-content");P&&y.value.commands.setContent(P)}if(K){const P=JSON.parse(K);c.userName=P.userName,c.userEmail=P.userEmail,c.userWebsite=P.userWebsite,V()}c.notify=1}),(K,P)=>(m.openBlock(),m.createElementBlock("div",Db,[g.enable?(m.openBlock(),m.createElementBlock("div",Ib,[m.withDirectives(m.createElementVNode("img",{alt:"头像",src:c.userAvatar,class:"sus-avatar",onerror:"this.onerror=null,this.src='/error.webp'"},null,8,Pb),[[m.vShow,!!c.userAvatar]]),m.withDirectives(m.createElementVNode("span",{class:"sus-avatar-text flex w-full h-full items-center justify-center"},m.toDisplayString(c?.userName?.charAt(0)),513),[[m.vShow,!c.userAvatar]])])):m.createCommentVNode("",!0),m.createElementVNode("div",Lb,[g.enable?(m.openBlock(),m.createElementBlock("div",Bb,[g.name.show?(m.openBlock(),m.createElementBlock("div",Vb,[m.withDirectives(m.createElementVNode("input",{class:"sus-input sus-username",placeholder:g.name.placeholder,"onUpdate:modelValue":P[0]||(P[0]=Q=>c.userName=Q),maxlength:"23"},null,8,$b),[[m.vModelText,c.userName]])])):m.createCommentVNode("",!0),g.website.show?(m.openBlock(),m.createElementBlock("div",zb,[m.createVNode(m.unref(qn.OuOToolTip),{content:g.website.tips},{default:m.withCtx(()=>[m.withDirectives(m.createElementVNode("input",{class:"sus-input sus-web",placeholder:g.website.placeholder,"onUpdate:modelValue":P[1]||(P[1]=Q=>c.userWebsite=Q),maxlength:"35"},null,8,_b),[[m.vModelText,c.userWebsite]])]),_:1},8,["content"])])):m.createCommentVNode("",!0),g.email.show?(m.openBlock(),m.createElementBlock("div",Hb,[m.createVNode(m.unref(qn.OuOToolTip),{content:g.email.tips},{default:m.withCtx(()=>[m.withDirectives(m.createElementVNode("input",{onBlur:V,class:"sus-input sus-email",placeholder:g.email.placeholder,"onUpdate:modelValue":P[2]||(P[2]=Q=>c.userEmail=Q),maxlength:"35"},null,40,Fb),[[m.vModelText,c.userEmail]])]),_:1},8,["content"])])):m.createCommentVNode("",!0)])):m.createCommentVNode("",!0),m.createElementVNode("div",jb,[m.createVNode(Ab,{editor:m.unref(y),showMenu:n.toolBar?.bubbleMenu?.show},null,8,["editor","showMenu"]),m.withDirectives(m.createVNode(Dy,{class:"absolute bottom-2 left-1",emoji:o,editor:m.unref(y)},null,8,["emoji","editor"]),[[m.vShow,o.showPanel]]),m.createVNode(m.unref(Ty),{class:"sus-comment-input",editor:m.unref(y)},null,8,["editor"])]),m.createElementVNode("div",Ub,[m.createElementVNode("div",Wb,[o.emojis.length>=0?(m.openBlock(),m.createElementBlock("div",Kb,[(m.openBlock(),m.createElementBlock("svg",{onClick:P[3]||(P[3]=Q=>o.showPanel=!o.showPanel),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[...P[5]||(P[5]=[m.createStaticVNode('<g fill="none" data-v-78541ace><path stroke="currentColor" stroke-linecap="round" stroke-width="1.5" d="M9 16c.85.63 1.885 1 3 1s2.15-.37 3-1" data-v-78541ace></path><path fill="currentColor" d="M16 10.5c0 .828-.448 1.5-1 1.5s-1-.672-1-1.5s.448-1.5 1-1.5s1 .672 1 1.5" data-v-78541ace></path><ellipse cx="9" cy="10.5" fill="currentColor" rx="1" ry="1.5" data-v-78541ace></ellipse><path stroke="currentColor" stroke-linecap="round" stroke-width="1.5" d="M7 3.338A9.95 9.95 0 0 1 12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12c0-1.821.487-3.53 1.338-5" data-v-78541ace></path></g>',1)])]))])):m.createCommentVNode("",!0),n.toolBar?.image?(m.openBlock(),m.createElementBlock("div",qb,[m.createElementVNode("input",{ref_key:"imgRef",ref:d,onChange:R,type:"file",id:"upload-input",name:"image",accept:"image/*"},null,544),P[6]||(P[6]=m.createStaticVNode('<label for="upload-input" data-v-78541ace><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" data-v-78541ace><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="1.5" data-v-78541ace><path d="m2 12.5l1.752-1.533a2.3 2.3 0 0 1 3.14.105l4.29 4.29a2 2 0 0 0 2.564.222l.299-.21a3 3 0 0 1 3.731.225L21 18.5m-6-13h3.5m0 0H22m-3.5 0V9m0-3.5V2" data-v-78541ace></path><path d="M22 12c0 4.714 0 7.071-1.465 8.535C19.072 22 16.714 22 12 22s-7.071 0-8.536-1.465C2 19.072 2 16.714 2 12c0-1.128 0-2.122.02-3M12 2C7.286 2 4.929 2 3.464 3.464c-.424.425-.726.925-.94 1.536" data-v-78541ace></path></g></svg></label>',1))])):m.createCommentVNode("",!0),n.toolBar?.notify?(m.openBlock(),m.createElementBlock("div",{key:2,onClick:W,class:"p-1"},[m.withDirectives(m.createVNode(m.unref(qn.OuOToolTip),{content:"收到回复后通知"},{default:m.withCtx(()=>[...P[7]||(P[7]=[m.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[m.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",d:"M12 6v4m-4.5 9c.655 1.748 2.422 3 4.5 3q.367 0 .72-.05M16.5 19a4.5 4.5 0 0 1-1.302 1.84M9.107 2.674A6.5 6.5 0 0 1 12 2c3.727 0 6.75 3.136 6.75 7.005v.705a4.4 4.4 0 0 0 .692 2.375l1.108 1.724c1.011 1.575.239 3.716-1.52 4.214a25.8 25.8 0 0 1-14.06 0c-1.759-.498-2.531-2.639-1.52-4.213l1.108-1.725A4.4 4.4 0 0 0 5.25 9.71v-.705c0-1.074.233-2.092.65-3.002"})],-1)])]),_:1},512),[[m.vShow,c.notify===1]]),m.withDirectives(m.createVNode(m.unref(qn.OuOToolTip),{content:"收到回复后不通知"},{default:m.withCtx(()=>[...P[8]||(P[8]=[m.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[m.createElementVNode("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5"},[m.createElementVNode("path",{"stroke-linejoin":"round",d:"M10 9h4l-4 4h4"}),m.createElementVNode("path",{d:"M7.5 19c.655 1.748 2.422 3 4.5 3q.367 0 .72-.05M16.5 19a4.5 4.5 0 0 1-1.302 1.84M9.107 2.674A6.5 6.5 0 0 1 12 2c3.727 0 6.75 3.136 6.75 7.005v.705a4.4 4.4 0 0 0 .692 2.375l1.108 1.724c1.011 1.575.239 3.716-1.52 4.214a25.8 25.8 0 0 1-14.06 0c-1.759-.498-2.531-2.639-1.52-4.213l1.108-1.725A4.4 4.4 0 0 0 5.25 9.71v-.705c0-1.074.233-2.092.65-3.002"})])],-1)])]),_:1},512),[[m.vShow,c.notify!==1]])])):m.createCommentVNode("",!0)]),m.createElementVNode("div",{class:"sus-comment__footer-send flex justify-end my-2"},[m.createElementVNode("button",{class:"sus-button cancel mx-2",onClick:C},"取消"),m.createElementVNode("button",{class:"sus-button ok",onClick:k},"发送")])]),m.createElementVNode("div",Jb,[m.withDirectives(m.createVNode(m.unref(qn.OuOCheckBox),{modelValue:c.privacy,"onUpdate:modelValue":P[4]||(P[4]=Q=>c.privacy=Q),checked:m.unref(p)},{default:m.withCtx(()=>[...P[9]||(P[9]=[m.createTextVNode(" 仅博主可见 ",-1)])]),_:1},8,["modelValue","checked"]),[[m.vShow,n.toolBar?.privacy?.show]]),m.withDirectives(m.createElementVNode("div",Gb,null,512),[[m.vShow,n.toolBar?.privacy?.disable]])]),m.createElementVNode("div",Yb,[(m.openBlock(!0),m.createElementBlock(m.Fragment,null,m.renderList(f.value,(Q,Z)=>(m.openBlock(),m.createElementBlock("div",{class:"sus-comment__extend-img relative",key:Q},[m.createElementVNode("img",{class:"img-item",src:Q,alt:""},null,8,Xb),m.createElementVNode("div",{onClick:ke=>j(Z),class:"mask"},[...P[10]||(P[10]=[m.createStaticVNode('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" data-v-78541ace><g fill="none" stroke="currentColor" stroke-width="1.5" data-v-78541ace><path stroke-linecap="round" d="M20.5 6h-17m6 5l.5 5m4.5-5l-.5 5" data-v-78541ace></path><path d="M6.5 6h.11a2 2 0 0 0 1.83-1.32l.034-.103l.097-.291c.083-.249.125-.373.18-.479a1.5 1.5 0 0 1 1.094-.788C9.962 3 10.093 3 10.355 3h3.29c.262 0 .393 0 .51.019a1.5 1.5 0 0 1 1.094.788c.055.106.097.23.18.479l.097.291A2 2 0 0 0 17.5 6" data-v-78541ace></path><path stroke-linecap="round" d="M18.374 15.4c-.177 2.654-.266 3.981-1.131 4.79s-2.195.81-4.856.81h-.774c-2.66 0-3.99 0-4.856-.81c-.865-.809-.953-2.136-1.13-4.79l-.46-6.9m13.666 0l-.2 3" data-v-78541ace></path></g></svg>',1)])],8,Qb)]))),128))])])]))}}),[["__scopeId","data-v-78541ace"]]);function Zb(n){const e=new Date(n),t=e.getFullYear(),r=e.getMonth()+1,i=e.getDate(),s=new Date,o=s.getFullYear(),l=s.getMonth()+1,a=s.getDate();if(o===t&&l==r){const c=a-i;if(c===0)return"今天";if(c<7)return c+"天前"}return o===t?`${r}月${i}日`:`${t}年${r}月${i}日`}const ew={class:"sus-item__container relative"},tw={class:"sus-item-svg",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},nw={class:"flex flex-row"},rw={class:"sus-item__operate absolute flex"},iw={class:"sus-comment-aside"},sw={class:"sus-comment-avatar"},ow=["src"],lw={class:"sus-item-floor mt-2"},aw={class:"sus-item__main w-full overflow-hidden"},cw={class:"sus-item__user leading-loose"},uw=["rel","href"],dw={key:0,class:"sus-item-tag mx-1",title:"博主"},fw={key:1,class:"sus-item__content-name mx-1.5"},hw={class:"sus-item__user-date ml-3"},pw={key:0,class:"sus-item__content"},mw=["innerHTML"],gw={key:1,class:"sus-item__content"},yw=["innerHTML"],bw={key:0,class:"sus-item__info flex justify-end mx-1"},ww={class:"sus-item__info-area flex items-center"},kw={class:"sus-item__info-useragent flex items-center"},is=bn(m.defineComponent({__name:"item",props:{comment:{},lineHeight:{},showFooter:{type:Boolean},num:{default:1}},emits:["on-reply","on-edit","on-remove"],setup(n,{emit:e}){const t=n,r=m.ref(),i=m.ref(),s=m.ref(!1),o=e;function l(){r.value.style.display="block",s.value=!1}function a(){const p=r?.value?.clientHeight||0,g=t.lineHeight*5;p>=g&&(s.value=!0)}function c(){o("on-reply",t.comment)}function u(){o("on-edit",t.comment)}function d(){o("on-remove",t.comment)}function f(){t.comment.userAvatar||(t.comment.userAvatar="/error.webp")}function h(){const p=new Date(t.comment?.createdDate),g=new Date,y=new Date(g.getFullYear()-1,g.getMonth(),g.getDate());return p>y?"ugc noopener nofollow":"ugc noopener noreferrer nofollow"}return m.onMounted(()=>{f(),a()}),(p,g)=>(m.openBlock(),m.createElementBlock("div",ew,[m.withDirectives((m.openBlock(),m.createElementBlock("svg",tw,[...g[0]||(g[0]=[m.createElementVNode("rect",{width:"24",height:"24",fill:"none"},null,-1),m.createElementVNode("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5"},[m.createElementVNode("path",{d:"M21 7v-.281c0-2.19 0-3.285-.707-3.884c-.707-.6-1.788-.42-3.95-.059l-1.055.176c-1.64.273-2.46.41-3.288.41s-1.648-.137-3.288-.41l-1.054-.176c-2.162-.36-3.243-.54-3.95.059S3 4.529 3 6.719V12c0 5.49 4.239 8.155 6.899 9.286c.721.307 1.082.46 2.101.46c1.02 0 1.38-.153 2.101-.46C16.761 20.155 21 17.49 21 12v-1"}),m.createElementVNode("path",{d:"M6.5 9c.291-.583 1.077-1 2-1s1.709.417 2 1m3 0c.291-.583 1.077-1 2-1s1.709.417 2 1m-9 5s1.05 1 3.5 1s3.5-1 3.5-1"})],-1)])],512)),[[m.vShow,n.comment.band==="privacy"]]),m.createElementVNode("div",nw,[m.createElementVNode("div",rw,[m.withDirectives(m.createElementVNode("span",{onClick:d,class:"sus-item__operate-delete cursor-pointer"}," 删除 ",512),[[m.vShow,!n.comment.privacy&&n.comment.showDelete]]),m.withDirectives(m.createElementVNode("span",{onClick:u,class:"sus-item__operate-edit cursor-pointer"}," 编辑 ",512),[[m.vShow,!n.comment.privacy&&n.comment.showEdit]]),m.withDirectives(m.createElementVNode("span",{onClick:c,class:"sus-item__operate-reply cursor-pointer"}," 回复 ",512),[[m.vShow,!n.comment.privacy]])]),m.createElementVNode("div",iw,[m.createElementVNode("div",sw,[m.withDirectives(m.createElementVNode("img",{alt:"",class:"sus-avatar",src:n.comment.userAvatar,onerror:"this.onerror=null,this.src='/error.webp'"},null,8,ow),[[m.vShow,!!n.comment.userAvatar]]),m.withDirectives(m.createElementVNode("span",{class:"sus-avatar-text flex w-full h-full items-center justify-center"},m.toDisplayString(n.comment.userName.charAt(0)),513),[[m.vShow,!n.comment.userAvatar]])]),m.createElementVNode("p",lw,m.toDisplayString(n.num),1)]),m.createElementVNode("div",aw,[m.createElementVNode("div",cw,[m.createElementVNode("a",{target:"_blank",rel:h(),href:n.comment.userWebsite,class:m.normalizeClass([n.comment.tagName,"sus-item__user-name font-semibold ml-1 cursor-pointer"])},m.toDisplayString(n.comment.userName),11,uw),n.comment.tagName==="owner"?(m.openBlock(),m.createElementBlock("span",dw," 博主 ")):m.createCommentVNode("",!0),n.comment.replyName?(m.openBlock(),m.createElementBlock("span",fw,"@"+m.toDisplayString(n.comment.replyName),1)):m.createCommentVNode("",!0),m.createElementVNode("span",hw,m.toDisplayString(m.unref(Zb)(n.comment.createdDate)),1)]),n.comment.privacy?(m.openBlock(),m.createElementBlock("div",pw,[g[1]||(g[1]=m.createElementVNode("div",{class:"sus-item-privacy"},null,-1)),m.createElementVNode("span",{class:"sus-item-privacy-text",innerHTML:n.comment.content},null,8,mw)])):(m.openBlock(),m.createElementBlock("div",gw,[m.createElementVNode("span",{ref_key:"contentDom",ref:r,class:"sus-item__content-text",innerHTML:n.comment.content+(n.comment.contentExtends||"")},null,8,yw),s.value?(m.openBlock(),m.createElementBlock("a",{key:0,ref_key:"showMoreDom",ref:i,class:"sus-show-detail my-1.5 cursor-pointer",onClick:l},"显示更多>",512)):m.createCommentVNode("",!0)]))])]),n.showFooter&&n.comment.area&&!n.comment.privacy?(m.openBlock(),m.createElementBlock("div",bw,[m.createElementVNode("span",ww,[g[2]||(g[2]=m.createElementVNode("svg",{class:"sus-svg",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[m.createElementVNode("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5"},[m.createElementVNode("path",{d:"M12.5 7.041A3 3 0 1 0 14.959 9.5"}),m.createElementVNode("path",{d:"M5 15.216c-.647-1.654-1-3.415-1-5.073C4 5.646 7.582 2 12 2s8 3.646 8 8.143c0 4.462-2.553 9.67-6.537 11.531a3.45 3.45 0 0 1-2.926 0C9.265 21.08 8.138 20.144 7.194 19"})])],-1)),m.createTextVNode(" "+m.toDisplayString(n.comment.area),1)]),m.createElementVNode("span",kw,[g[3]||(g[3]=m.createElementVNode("svg",{class:"sus-svg",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[m.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",d:"M5 2.252c-.774.169-1.359.45-1.828.92C2 4.343 2 6.229 2 10v1c0 2.828 0 4.243.879 5.121C3.757 17 5.172 17 8 17h8c2.828 0 4.243 0 5.121-.879C22 15.243 22 13.828 22 11v-1c0-3.771 0-5.657-1.172-6.828S17.771 2 14 2H9m7 20H8m4-5v5m10-9h-6M2 13h10"})],-1)),m.createTextVNode(" "+m.toDisplayString(n.comment.userAgent),1)])])):m.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-fc3a8ef9"]]),xw={class:"sus-comment__item"},Sw={key:0,class:"sus-comment__item-child"},Cw={key:1},Ew={key:0,class:"sus-comment__item-footer flex justify-center w-full cursor-pointer"},df=bn(m.defineComponent({__name:"index",props:{comment:{},lineHeight:{default:23},showFooter:{type:Boolean,default:!1}},emits:["on-reply","on-edit","on-remove"],setup(n,{emit:e}){const t=m.ref(!1),r=e;function i(l){r("on-reply",l)}function s(l){r("on-edit",l)}function o(l){r("on-remove",l)}return(l,a)=>(m.openBlock(),m.createElementBlock("div",xw,[m.createVNode(is,{comment:n.comment,onOnReply:a[0]||(a[0]=c=>i(n.comment)),onOnEdit:a[1]||(a[1]=c=>s(n.comment)),onOnRemove:a[2]||(a[2]=c=>o(n.comment)),lineHeight:n.lineHeight,showFooter:n.showFooter},null,8,["comment","lineHeight","showFooter"]),n.comment.child?.length>0?(m.openBlock(),m.createElementBlock("div",Sw,[m.createVNode(is,{onOnReply:a[3]||(a[3]=c=>i(n.comment.child[0])),onOnEdit:a[4]||(a[4]=c=>s(n.comment.child[0])),onOnRemove:a[5]||(a[5]=c=>o(n.comment.child[0])),comment:n.comment.child[0],num:2,showFooter:n.showFooter,lineHeight:n.lineHeight,class:"sus-comment__item-child__item"},null,8,["comment","showFooter","lineHeight"]),n.comment.child?.length>1?(m.openBlock(),m.createBlock(is,{key:0,onOnReply:a[6]||(a[6]=c=>i(n.comment.child[1])),onOnEdit:a[7]||(a[7]=c=>s(n.comment.child[1])),onOnRemove:a[8]||(a[8]=c=>o(n.comment.child[1])),comment:n.comment.child[1],num:3,showFooter:n.showFooter,lineHeight:n.lineHeight,class:"sus-comment__item-child__item"},null,8,["comment","showFooter","lineHeight"])):m.createCommentVNode("",!0),n.comment.child?.length>2?(m.openBlock(),m.createElementBlock("div",Cw,[t.value?m.createCommentVNode("",!0):(m.openBlock(),m.createElementBlock("div",Ew,[m.createElementVNode("p",{class:"sus-load-more",onClick:a[9]||(a[9]=c=>t.value=!0)}," 查看更多回复 > ")])),t.value?(m.openBlock(!0),m.createElementBlock(m.Fragment,{key:1},m.renderList(n.comment.child.slice(2),(c,u)=>(m.openBlock(),m.createBlock(is,{onOnReply:d=>i(c),onOnEdit:d=>s(c),onOnRemove:d=>o(c),key:u,comment:c,num:4+u,showFooter:n.showFooter,lineHeight:n.lineHeight,class:"sus-comment__item-child__item"},null,8,["onOnReply","onOnEdit","onOnRemove","comment","num","showFooter","lineHeight"]))),128)):m.createCommentVNode("",!0)])):m.createCommentVNode("",!0)])):m.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-b49dad89"]]),Mw={class:"sus-top-item flex items-start p-1.5 overflow-hidden"},vw={class:"sus-top-item__info flex flex-col mr-1"},Tw={class:"sus-top-item__user whitespace-nowrap"},Ow={key:0,class:"sus-top-item__reply whitespace-nowrap"},Nw=["innerHTML"],ff=bn(m.defineComponent({__name:"simple",props:{comment:{}},setup(n){return(e,t)=>(m.openBlock(),m.createElementBlock("div",Mw,[m.createElementVNode("div",vw,[m.createElementVNode("span",Tw,m.toDisplayString(n.comment.userName)+": ",1),n.comment.replyName?(m.openBlock(),m.createElementBlock("span",Ow,m.toDisplayString("@"+n.comment.replyName),1)):m.createCommentVNode("",!0)]),m.createElementVNode("span",{class:"sus-top-item__content w-full",innerHTML:n.comment.content},null,8,Nw)]))}}),[["__scopeId","data-v-7407d86d"]]),Aw={class:"sus-top-item__user flex items-center"},Rw={key:0,class:"sus-top-item__user-avatar ml-1 mr-2"},Dw=["src"],Iw={class:"sus-top-item__user-owner"},Pw={class:"sus-top-item__user-reply ml-3 opacity-70"},Lw=["innerHTML"],hf=bn(m.defineComponent({__name:"index",props:{comment:{}},emits:["go-local"],setup(n,{emit:e}){const t=e;function r(){t("go-local")}return(i,s)=>(m.openBlock(),m.createElementBlock("div",{class:"sus-top-item p-1.5 cursor-pointer overflow-hidden",onClick:r},[m.createElementVNode("div",Aw,[n.comment.userAvatar?(m.openBlock(),m.createElementBlock("div",Rw,[m.createElementVNode("img",{alt:"",class:"sus-avatar",loading:"lazy",decoding:"async",src:n.comment.userAvatar,onerror:"this.onerror=null,this.src='/error.webp'"},null,8,Dw)])):m.createCommentVNode("",!0),m.createElementVNode("div",Iw,m.toDisplayString(n.comment.userName),1),m.createElementVNode("div",Pw,m.toDisplayString(n.comment.replyName?"@"+n.comment.replyName:""),1)]),m.createElementVNode("div",{class:"sus-top-item__content p-1",innerHTML:n.comment.content},null,8,Lw)]))}}),[["__scopeId","data-v-1e2f9488"]]),Bw=[uf,df,hf,ff],Vw={install(n){Bw.forEach(e=>{n.component(e.name,e)})}};je.SuSComment=uf,je.SuSList=df,je.SuSSimpleTop=ff,je.SuSTop=hf,je.default=Vw,Object.defineProperties(je,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|