@mikedown/web-component 0.3.0 → 0.4.0
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/mikedown-editor.ai-ui-QFYFN73D-MK2MJ2BC.js +184 -0
- package/dist/{mikedown-editor.chunk-L7U45VO5.js → mikedown-editor.chunk-MZAFS27D.js} +21 -21
- package/dist/mikedown-editor.standalone.js +139 -139
- package/package.json +3 -3
- package/dist/mikedown-editor.ai-ui-C7ENTWWU-WYTCUH47.js +0 -118
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/*! @mikedown/web-component 0.
|
|
2
|
-
var Jg=Object.create;var Lo=Object.defineProperty;var Ug=Object.getOwnPropertyDescriptor;var Gg=Object.getOwnPropertyNames;var Yg=Object.getPrototypeOf,Xg=Object.prototype.hasOwnProperty;var vc=n=>{throw TypeError(n)};var Fv=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Vv=(n,e)=>{for(var t in e)Lo(n,t,{get:e[t],enumerable:!0})},Qg=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Gg(e))!Xg.call(n,r)&&r!==t&&Lo(n,r,{get:()=>e[r],enumerable:!(i=Ug(e,r))||i.enumerable});return n};var Hv=(n,e,t)=>(t=n!=null?Jg(Yg(n)):{},Qg(e||!n||!n.__esModule?Lo(t,"default",{value:n,enumerable:!0}):t,n));var zo=(n,e,t)=>e.has(n)||vc("Cannot "+t);var Wv=(n,e,t)=>(zo(n,e,"read from private field"),t?t.call(n):e.get(n)),$v=(n,e,t)=>e.has(n)?vc("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),qv=(n,e,t,i)=>(zo(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),Kv=(n,e,t)=>(zo(n,e,"access private method"),t);function ge(n){this.content=n}ge.prototype={constructor:ge,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 i=t&&t!=n?this.remove(t):this,r=i.find(n),s=i.content.slice();return r==-1?s.push(t||n,e):(s[r+1]=e,t&&(s[r]=t)),new ge(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 ge(t)},addToStart:function(n,e){return new ge([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ge(t)},addBefore:function(n,e,t){var i=this.remove(e),r=i.content.slice(),s=i.find(n);return r.splice(s==-1?r.length:s,0,e,t),new ge(r)},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=ge.from(n),n.size?new ge(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ge.from(n),n.size?new ge(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ge.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}};ge.from=function(n){if(n instanceof ge)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ge(e)};var Fo=ge;function Pc(n,e,t){for(let i=0;;i++){if(i==n.childCount||i==e.childCount)return n.childCount==e.childCount?null:t;let r=n.child(i),s=e.child(i);if(r==s){t+=r.nodeSize;continue}if(!r.sameMarkup(s))return t;if(r.isText&&r.text!=s.text){for(let o=0;r.text[o]==s.text[o];o++)t++;return t}if(r.content.size||s.content.size){let o=Pc(r.content,s.content,t+1);if(o!=null)return o}t+=r.nodeSize}}function Bc(n,e,t,i){for(let r=n.childCount,s=e.childCount;;){if(r==0||s==0)return r==s?null:{a:t,b:i};let o=n.child(--r),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,i-=a;continue}if(!o.sameMarkup(l))return{a:t,b:i};if(o.isText&&o.text!=l.text){let h=0,c=Math.min(o.text.length,l.text.length);for(;h<c&&o.text[o.text.length-h-1]==l.text[l.text.length-h-1];)h++,t--,i--;return{a:t,b:i}}if(o.content.size||l.content.size){let h=Bc(o.content,l.content,t-1,i-1);if(h)return h}t-=a,i-=a}}var S=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let i=0;i<e.length;i++)this.size+=e[i].nodeSize}nodesBetween(e,t,i,r=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],h=l+a.nodeSize;if(h>e&&i(a,r+l,s||null,o)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),i,r+c)}l=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,i,r){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let h=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&h||l.isTextblock)&&i&&(o?o=!1:s+=i),s+=h},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,i=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(i)&&(r[r.length-1]=t.withText(t.text+i.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new n(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let i=[],r=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))),i.push(l),r+=l.nodeSize),o=a}return new n(i,r)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let i=this.content[e];if(i==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-i.nodeSize;return r[e]=t,new n(r,s)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(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,i=0;t<this.content.length;t++){let r=this.content[t];e(r,i,t),i+=r.nodeSize}}findDiffStart(e,t=0){return Pc(this,e,t)}findDiffEnd(e,t=this.size,i=e.size){return Bc(this,e,t,i)}findIndex(e){if(e==0)return zr(0,e);if(e==this.size)return zr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,i=0;;t++){let r=this.child(t),s=i+r.nodeSize;if(s>=e)return s==e?zr(t+1,s):zr(t,i);i=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 n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,i=0;for(let r=0;r<e.length;r++){let s=e[r];i+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new n(t||e,i)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([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);var Vo={index:0,offset:0};function zr(n,e){return Vo.index=n,Vo.offset=e,Vo}function Vr(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 i=0;i<n.length;i++)if(!Vr(n[i],e[i]))return!1}else{for(let i in n)if(!(i in e)||!Vr(n[i],e[i]))return!1;for(let i in e)if(!(i in n))return!1}return!0}var _=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,i=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!i&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),i=!0),t&&t.push(s)}}return t||(t=e.slice()),i||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&&Vr(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 i=e.marks[t.type];if(!i)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=i.create(t.attrs);return i.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(t[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((i,r)=>i.type.rank-r.type.rank),t}};_.none=[];var mn=class extends Error{},O=class n{constructor(e,t,i){this.content=e,this.openStart=t,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let i=Lc(this.content,e+this.openStart,t);return i&&new n(i,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Ic(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 i=t.openStart||0,r=t.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(S.fromJSON(e,t.content),i,r)}static maxOpen(e,t=!0){let i=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)i++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new n(e,i,r)}};O.empty=new O(S.empty,0,0);function Ic(n,e,t){let{index:i,offset:r}=n.findIndex(e),s=n.maybeChild(i),{index:o,offset:l}=n.findIndex(t);if(r==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(i!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(i,s.copy(Ic(s.content,e-r-1,t-r-1)))}function Lc(n,e,t,i){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r);if(s==e||o.isText)return i&&!i.canReplace(r,r,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Lc(o.content,e-s-1,t,o);return l&&n.replaceChild(r,o.copy(l))}function Zg(n,e,t){if(t.openStart>n.depth)throw new mn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new mn("Inconsistent open depths");return zc(n,e,t,0)}function zc(n,e,t,i){let r=n.index(i),s=n.node(i);if(r==e.index(i)&&i<n.depth-t.openStart){let o=zc(n,e,t,i+1);return s.copy(s.content.replaceChild(r,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==i&&e.depth==i){let o=n.parent,l=o.content;return pn(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=e0(t,n);return pn(s,Vc(n,o,l,e,i))}else return pn(s,Hr(n,e,i))}function Fc(n,e){if(!e.type.compatibleContent(n.type))throw new mn("Cannot join "+e.type.name+" onto "+n.type.name)}function Wo(n,e,t){let i=n.node(t);return Fc(i,e.node(t)),i}function dn(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 Ri(n,e,t,i){let r=(e||n).node(t),s=0,o=e?e.index(t):r.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(dn(n.nodeAfter,i),s++));for(let l=s;l<o;l++)dn(r.child(l),i);e&&e.depth==t&&e.textOffset&&dn(e.nodeBefore,i)}function pn(n,e){return n.type.checkContent(e),n.copy(e)}function Vc(n,e,t,i,r){let s=n.depth>r&&Wo(n,e,r+1),o=i.depth>r&&Wo(t,i,r+1),l=[];return Ri(null,n,r,l),s&&o&&e.index(r)==t.index(r)?(Fc(s,o),dn(pn(s,Vc(n,e,t,i,r+1)),l)):(s&&dn(pn(s,Hr(n,e,r+1)),l),Ri(e,t,r,l),o&&dn(pn(o,Hr(t,i,r+1)),l)),Ri(i,null,r,l),new S(l)}function Hr(n,e,t){let i=[];if(Ri(null,n,t,i),n.depth>t){let r=Wo(n,e,t+1);dn(pn(r,Hr(n,e,t+1)),i)}return Ri(e,null,t,i),new S(i)}function e0(n,e){let t=e.depth-n.openStart,r=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)r=e.node(s).copy(S.from(r));return{start:r.resolveNoCache(n.openStart+t),end:r.resolveNoCache(r.content.size-n.openEnd-t)}}var Wr=class n{constructor(e,t,i){this.pos=e,this.path=t,this.parentOffset=i,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 i=this.pos-this.path[this.path.length-1],r=e.child(t);return i?e.child(t).cut(i):r}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 i=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)r+=i.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return _.none;if(this.textOffset)return e.child(t).marks;let i=e.maybeChild(t-1),r=e.maybeChild(t);if(!i){let l=i;i=r,r=l}let s=i.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!r||!s[o].isInSet(r.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let i=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!r||!i[s].isInSet(r.marks))&&(i=i[s--].removeFromSet(i));return i}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 i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!t||t(this.node(i))))return new gn(this,e,i);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 i=[],r=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),h=s-a;if(i.push(o,l,r+a),!h||(o=o.child(l),o.isText))break;s=h-1,r+=a+1}return new n(t,i,s)}static resolveCached(e,t){let i=Cc.get(e);if(i)for(let s=0;s<i.elts.length;s++){let o=i.elts[s];if(o.pos==t)return o}else Cc.set(e,i=new $o);let r=i.elts[i.i]=n.resolve(e,t);return i.i=(i.i+1)%t0,r}},$o=class{constructor(){this.elts=[],this.i=0}},t0=12,Cc=new WeakMap,gn=class{constructor(e,t,i){this.$from=e,this.$to=t,this.depth=i}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)}},n0=Object.create(null),Oe=class n{constructor(e,t,i,r=_.none){this.type=e,this.attrs=t,this.marks=r,this.content=i||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,i,r=0){this.content.nodesBetween(e,t,i,r,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,i,r){return this.content.textBetween(e,t,i,r)}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,i){return this.type==e&&Vr(this.attrs,t||e.defaultAttrs||n0)&&_.sameSet(this.marks,i||_.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(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,i=!1){if(e==t)return O.empty;let r=this.resolve(e),s=this.resolve(t),o=i?0:r.sharedDepth(t),l=r.start(o),h=r.node(o).content.cut(r.pos-l,s.pos-l);return new O(h,r.depth-o,s.depth-o)}replace(e,t,i){return Zg(this.resolve(e),this.resolve(t),i)}nodeAt(e){for(let t=this;;){let{index:i,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(i),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:i}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(t),index:t,offset:i};let r=this.content.child(t-1);return{node:r,index:t-1,offset:i-r.nodeSize}}resolve(e){return Wr.resolveCached(this,e)}resolveNoCache(e){return Wr.resolve(this,e)}rangeHasMark(e,t,i){let r=!1;return t>e&&this.nodesBetween(e,t,s=>(i.isInSet(s.marks)&&(r=!0),!r)),r}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()+")"),Hc(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,i=S.empty,r=0,s=i.childCount){let o=this.contentMatchAt(e).matchFragment(i,r,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=r;a<s;a++)if(!this.type.allowsMarks(i.child(a).marks))return!1;return!0}canReplaceWith(e,t,i,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(i),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=_.none;for(let t=0;t<this.marks.length;t++){let i=this.marks[t];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!_.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 i;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=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,i)}let r=S.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,r,i);return s.type.checkAttrs(s.attrs),s}};Oe.prototype.text=void 0;var qo=class n extends Oe{constructor(e,t,i,r){if(super(e,t,null,r),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Hc(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 n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(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 Hc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var yn=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let i=new Ko(e,t);if(i.next==null)return n.empty;let r=Wc(i);i.next&&i.err("Unexpected trailing text");let s=h0(a0(r));return c0(s,i),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,i=e.childCount){let r=this;for(let s=t;r&&s<i;s++)r=r.matchType(e.child(s).type);return r}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 i=0;i<e.next.length;i++)if(this.next[t].type==e.next[i].type)return!0;return!1}fillBefore(e,t=!1,i=0){let r=[this];function s(o,l){let a=o.matchFragment(e,i);if(a&&(!t||a.validEnd))return S.from(l.map(h=>h.createAndFill()));for(let h=0;h<o.next.length;h++){let{type:c,next:f}=o.next[h];if(!(c.isText||c.hasRequiredAttrs())&&r.indexOf(f)==-1){r.push(f);let u=s(f,l.concat(c));if(u)return u}}return null}return s(this,[])}findWrapping(e){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==e)return this.wrapCache[i+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let r=i.shift(),s=r.match;if(s.matchType(e)){let o=[];for(let l=r;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)&&(!r.type||a.validEnd)&&(i.push({match:l.contentMatch,type:l,via:r}),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(i){e.push(i);for(let r=0;r<i.next.length;r++)e.indexOf(i.next[r].next)==-1&&t(i.next[r].next)}return t(this),e.map((i,r)=>{let s=r+(i.validEnd?"*":" ")+" ";for(let o=0;o<i.next.length;o++)s+=(o?", ":"")+i.next[o].type.name+"->"+e.indexOf(i.next[o].next);return s}).join(`
|
|
3
|
-
`)}};yn.empty=new yn(!0);var Ko=class{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 Wc(n){let e=[];do e.push(i0(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function i0(n){let e=[];do e.push(r0(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function r0(n){let e=l0(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=s0(n,e);else break;return e}function Mc(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function s0(n,e){let t=Mc(n),i=t;return n.eat(",")&&(n.next!="}"?i=Mc(n):i=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:i,expr:e}}function o0(n,e){let t=n.nodeTypes,i=t[e];if(i)return[i];let r=[];for(let s in t){let o=t[s];o.isInGroup(e)&&r.push(o)}return r.length==0&&n.err("No node type or group '"+e+"' found"),r}function l0(n){if(n.eat("(")){let e=Wc(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=o0(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 a0(n){let e=[[]];return r(s(n,0),t()),e;function t(){return e.push([])-1}function i(o,l,a){let h={term:a,to:l};return e[o].push(h),h}function r(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,h)=>a.concat(s(h,l)),[]);if(o.type=="seq")for(let a=0;;a++){let h=s(o.exprs[a],l);if(a==o.exprs.length-1)return h;r(h,l=t())}else if(o.type=="star"){let a=t();return i(l,a),r(s(o.expr,a),a),[i(a)]}else if(o.type=="plus"){let a=t();return r(s(o.expr,l),a),r(s(o.expr,a),a),[i(a)]}else{if(o.type=="opt")return[i(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let h=0;h<o.min;h++){let c=t();r(s(o.expr,a),c),a=c}if(o.max==-1)r(s(o.expr,a),a);else for(let h=o.min;h<o.max;h++){let c=t();i(a,c),r(s(o.expr,a),c),a=c}return[i(a)]}else{if(o.type=="name")return[i(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function $c(n,e){return e-n}function Ac(n,e){let t=[];return i(e),t.sort($c);function i(r){let s=n[r];if(s.length==1&&!s[0].term)return i(s[0].to);t.push(r);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&i(a)}}}function h0(n){let e=Object.create(null);return t(Ac(n,0));function t(i){let r=[];i.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let h;for(let c=0;c<r.length;c++)r[c][0]==l&&(h=r[c][1]);Ac(n,a).forEach(c=>{h||r.push([l,h=[]]),h.indexOf(c)==-1&&h.push(c)})})});let s=e[i.join(",")]=new yn(i.indexOf(n.length-1)>-1);for(let o=0;o<r.length;o++){let l=r[o][1].sort($c);s.next.push({type:r[o][0],next:e[l.join(",")]||t(l)})}return s}}function c0(n,e){for(let t=0,i=[n];t<i.length;t++){let r=i[t],s=!r.validEnd,o=[];for(let l=0;l<r.next.length;l++){let{type:a,next:h}=r.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),i.indexOf(h)==-1&&i.push(h)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function qc(n){let e=Object.create(null);for(let t in n){let i=n[t];if(!i.hasDefault)return null;e[t]=i.default}return e}function Kc(n,e){let t=Object.create(null);for(let i in n){let r=e&&e[i];if(r===void 0){let s=n[i];if(s.hasDefault)r=s.default;else throw new RangeError("No value supplied for attribute "+i)}t[i]=r}return t}function jc(n,e,t,i){for(let r in e)if(!(r in n))throw new RangeError(`Unsupported attribute ${r} for ${t} of type ${r}`);for(let r in n){let s=n[r];s.validate&&s.validate(e[r])}}function _c(n,e){let t=Object.create(null);if(e)for(let i in e)t[i]=new jo(n,i,e[i]);return t}var $r=class n{constructor(e,t,i){this.name=e,this.schema=t,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=_c(e,i.attrs),this.defaultAttrs=qc(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==yn.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:Kc(this.attrs,e)}create(e=null,t,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Oe(this,this.computeAttrs(e),S.from(t),_.setFrom(i))}createChecked(e=null,t,i){return t=S.from(t),this.checkContent(t),new Oe(this,this.computeAttrs(e),t,_.setFrom(i))}createAndFill(e=null,t,i){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 r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(S.empty,!0);return s?new Oe(this,e,t.append(s),_.setFrom(i)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).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){jc(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 i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?t&&t.push(e[i]):t||(t=e.slice(0,i));return t?t.length?t:_.none:e}static compile(e,t){let i=Object.create(null);e.forEach((s,o)=>i[s]=new n(s,t,o));let r=t.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let s in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function f0(n,e,t){let i=t.split("|");return r=>{let s=r===null?"null":typeof r;if(i.indexOf(s)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${n}, got ${s}`)}}var jo=class{constructor(e,t,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?f0(e,t,i.validate):i.validate}get isRequired(){return!this.hasDefault}},Bi=class n{constructor(e,t,i,r){this.name=e,this.rank=t,this.schema=i,this.spec=r,this.attrs=_c(e,r.attrs),this.excluded=null;let s=qc(this.attrs);this.instance=s?new _(this,s):null}create(e=null){return!e&&this.instance?this.instance:new _(this,Kc(this.attrs,e))}static compile(e,t){let i=Object.create(null),r=0;return e.forEach((s,o)=>i[s]=new n(s,r++,t,o)),i}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){jc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Gn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=Fo.from(e.nodes),t.marks=Fo.from(e.marks||{}),this.nodes=$r.compile(this.spec.nodes,this),this.marks=Bi.compile(this.spec.marks,this);let i=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=i[o]||(i[o]=yn.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?Tc(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Tc(this,o.split(" "))}this.nodeFromJSON=r=>Oe.fromJSON(this,r),this.markFromJSON=r=>_.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,i,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof $r){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,i,r)}text(e,t){let i=this.nodes.text;return new qo(i,i.defaultAttrs,e,_.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 Tc(n,e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],s=n.marks[r],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(r=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(r)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return t}function u0(n){return n.tag!=null}function d0(n){return n.style!=null}var pt=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let i=this.matchedStyles=[];t.forEach(r=>{if(u0(r))this.tags.push(r);else if(d0(r)){let s=/[^=]*/.exec(r.style)[0];i.indexOf(s)<0&&i.push(s),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let i=new qr(this,t,!1);return i.addAll(e,_.none,t.from,t.to),i.finish()}parseSlice(e,t={}){let i=new qr(this,t,!0);return i.addAll(e,_.none,t.from,t.to),O.maxOpen(i.finish())}matchTag(e,t,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let s=this.tags[r];if(g0(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,i,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!i.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 i(r){let s=r.priority==null?50:r.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,r)}for(let r in e.marks){let s=e.marks[r].spec.parseDOM;s&&s.forEach(o=>{i(o=Ec(o)),o.mark||o.ignore||o.clearMark||(o.mark=r)})}for(let r in e.nodes){let s=e.nodes[r].spec.parseDOM;s&&s.forEach(o=>{i(o=Ec(o)),o.node||o.ignore||o.mark||(o.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Jc={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},p0={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Uc={ol:!0,ul:!0},Ii=1,_o=2,Pi=4;function Oc(n,e,t){return e!=null?(e?Ii:0)|(e==="full"?_o:0):n&&n.whitespace=="pre"?Ii|_o:t&~Pi}var Un=class{constructor(e,t,i,r,s,o){this.type=e,this.attrs=t,this.marks=i,this.solid=r,this.options=o,this.content=[],this.activeMarks=_.none,this.match=s||(o&Pi?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 i=this.type.contentMatch,r;return(r=i.findWrapping(e.type))?(this.match=i,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ii)){let i=this.content[this.content.length-1],r;if(i&&i.isText&&(r=/[ \t\r\n\u000c]+$/.exec(i.text))){let s=i;i.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-r[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&&!Jc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},qr=class{constructor(e,t,i){this.parser=e,this.options=t,this.isOpen=i,this.open=0,this.localPreserveWS=!1;let r=t.topNode,s,o=Oc(null,t.preserveWhitespace,0)|(i?Pi:0);r?s=new Un(r.type,r.attrs,_.none,!0,t.topMatch||r.type.contentMatch,o):i?s=new Un(null,null,_.none,!0,null,o):s=new Un(e.schema.topNodeType,null,_.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 i=e.nodeValue,r=this.top,s=r.options&_o?"full":this.localPreserveWS||(r.options&Ii)>0,{schema:o}=this.parser;if(s==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(s)if(s==="full")i=i.replace(/\r\n?/g,`
|
|
1
|
+
/*! @mikedown/web-component 0.4.0 standalone | MIT | bundles third-party code, see THIRD_PARTY_NOTICES.md */
|
|
2
|
+
var Jg=Object.create;var Lo=Object.defineProperty;var Ug=Object.getOwnPropertyDescriptor;var Gg=Object.getOwnPropertyNames;var Yg=Object.getPrototypeOf,Xg=Object.prototype.hasOwnProperty;var vc=n=>{throw TypeError(n)};var _v=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Kv=(n,e)=>{for(var t in e)Lo(n,t,{get:e[t],enumerable:!0})},Qg=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Gg(e))!Xg.call(n,r)&&r!==t&&Lo(n,r,{get:()=>e[r],enumerable:!(i=Ug(e,r))||i.enumerable});return n};var qv=(n,e,t)=>(t=n!=null?Jg(Yg(n)):{},Qg(e||!n||!n.__esModule?Lo(t,"default",{value:n,enumerable:!0}):t,n));var zo=(n,e,t)=>e.has(n)||vc("Cannot "+t);var jv=(n,e,t)=>(zo(n,e,"read from private field"),t?t.call(n):e.get(n)),Jv=(n,e,t)=>e.has(n)?vc("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Uv=(n,e,t,i)=>(zo(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),Gv=(n,e,t)=>(zo(n,e,"access private method"),t);function ge(n){this.content=n}ge.prototype={constructor:ge,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 i=t&&t!=n?this.remove(t):this,r=i.find(n),s=i.content.slice();return r==-1?s.push(t||n,e):(s[r+1]=e,t&&(s[r]=t)),new ge(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 ge(t)},addToStart:function(n,e){return new ge([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ge(t)},addBefore:function(n,e,t){var i=this.remove(e),r=i.content.slice(),s=i.find(n);return r.splice(s==-1?r.length:s,0,e,t),new ge(r)},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=ge.from(n),n.size?new ge(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ge.from(n),n.size?new ge(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ge.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}};ge.from=function(n){if(n instanceof ge)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ge(e)};var Fo=ge;function Pc(n,e,t){for(let i=0;;i++){if(i==n.childCount||i==e.childCount)return n.childCount==e.childCount?null:t;let r=n.child(i),s=e.child(i);if(r==s){t+=r.nodeSize;continue}if(!r.sameMarkup(s))return t;if(r.isText&&r.text!=s.text){for(let o=0;r.text[o]==s.text[o];o++)t++;return t}if(r.content.size||s.content.size){let o=Pc(r.content,s.content,t+1);if(o!=null)return o}t+=r.nodeSize}}function Ic(n,e,t,i){for(let r=n.childCount,s=e.childCount;;){if(r==0||s==0)return r==s?null:{a:t,b:i};let o=n.child(--r),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,i-=a;continue}if(!o.sameMarkup(l))return{a:t,b:i};if(o.isText&&o.text!=l.text){let h=0,c=Math.min(o.text.length,l.text.length);for(;h<c&&o.text[o.text.length-h-1]==l.text[l.text.length-h-1];)h++,t--,i--;return{a:t,b:i}}if(o.content.size||l.content.size){let h=Ic(o.content,l.content,t-1,i-1);if(h)return h}t-=a,i-=a}}var S=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let i=0;i<e.length;i++)this.size+=e[i].nodeSize}nodesBetween(e,t,i,r=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],h=l+a.nodeSize;if(h>e&&i(a,r+l,s||null,o)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),i,r+c)}l=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,i,r){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let h=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&h||l.isTextblock)&&i&&(o?o=!1:s+=i),s+=h},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,i=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(i)&&(r[r.length-1]=t.withText(t.text+i.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new n(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let i=[],r=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))),i.push(l),r+=l.nodeSize),o=a}return new n(i,r)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let i=this.content[e];if(i==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-i.nodeSize;return r[e]=t,new n(r,s)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(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,i=0;t<this.content.length;t++){let r=this.content[t];e(r,i,t),i+=r.nodeSize}}findDiffStart(e,t=0){return Pc(this,e,t)}findDiffEnd(e,t=this.size,i=e.size){return Ic(this,e,t,i)}findIndex(e){if(e==0)return zr(0,e);if(e==this.size)return zr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,i=0;;t++){let r=this.child(t),s=i+r.nodeSize;if(s>=e)return s==e?zr(t+1,s):zr(t,i);i=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 n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,i=0;for(let r=0;r<e.length;r++){let s=e[r];i+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new n(t||e,i)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([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);var Vo={index:0,offset:0};function zr(n,e){return Vo.index=n,Vo.offset=e,Vo}function Vr(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 i=0;i<n.length;i++)if(!Vr(n[i],e[i]))return!1}else{for(let i in n)if(!(i in e)||!Vr(n[i],e[i]))return!1;for(let i in e)if(!(i in n))return!1}return!0}var j=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,i=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!i&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),i=!0),t&&t.push(s)}}return t||(t=e.slice()),i||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&&Vr(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 i=e.marks[t.type];if(!i)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=i.create(t.attrs);return i.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(t[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((i,r)=>i.type.rank-r.type.rank),t}};j.none=[];var mn=class extends Error{},O=class n{constructor(e,t,i){this.content=e,this.openStart=t,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let i=Lc(this.content,e+this.openStart,t);return i&&new n(i,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Bc(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 i=t.openStart||0,r=t.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(S.fromJSON(e,t.content),i,r)}static maxOpen(e,t=!0){let i=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)i++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new n(e,i,r)}};O.empty=new O(S.empty,0,0);function Bc(n,e,t){let{index:i,offset:r}=n.findIndex(e),s=n.maybeChild(i),{index:o,offset:l}=n.findIndex(t);if(r==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(i!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(i,s.copy(Bc(s.content,e-r-1,t-r-1)))}function Lc(n,e,t,i){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r);if(s==e||o.isText)return i&&!i.canReplace(r,r,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Lc(o.content,e-s-1,t,o);return l&&n.replaceChild(r,o.copy(l))}function Zg(n,e,t){if(t.openStart>n.depth)throw new mn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new mn("Inconsistent open depths");return zc(n,e,t,0)}function zc(n,e,t,i){let r=n.index(i),s=n.node(i);if(r==e.index(i)&&i<n.depth-t.openStart){let o=zc(n,e,t,i+1);return s.copy(s.content.replaceChild(r,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==i&&e.depth==i){let o=n.parent,l=o.content;return pn(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=e0(t,n);return pn(s,Vc(n,o,l,e,i))}else return pn(s,Hr(n,e,i))}function Fc(n,e){if(!e.type.compatibleContent(n.type))throw new mn("Cannot join "+e.type.name+" onto "+n.type.name)}function Wo(n,e,t){let i=n.node(t);return Fc(i,e.node(t)),i}function dn(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 Ri(n,e,t,i){let r=(e||n).node(t),s=0,o=e?e.index(t):r.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(dn(n.nodeAfter,i),s++));for(let l=s;l<o;l++)dn(r.child(l),i);e&&e.depth==t&&e.textOffset&&dn(e.nodeBefore,i)}function pn(n,e){return n.type.checkContent(e),n.copy(e)}function Vc(n,e,t,i,r){let s=n.depth>r&&Wo(n,e,r+1),o=i.depth>r&&Wo(t,i,r+1),l=[];return Ri(null,n,r,l),s&&o&&e.index(r)==t.index(r)?(Fc(s,o),dn(pn(s,Vc(n,e,t,i,r+1)),l)):(s&&dn(pn(s,Hr(n,e,r+1)),l),Ri(e,t,r,l),o&&dn(pn(o,Hr(t,i,r+1)),l)),Ri(i,null,r,l),new S(l)}function Hr(n,e,t){let i=[];if(Ri(null,n,t,i),n.depth>t){let r=Wo(n,e,t+1);dn(pn(r,Hr(n,e,t+1)),i)}return Ri(e,null,t,i),new S(i)}function e0(n,e){let t=e.depth-n.openStart,r=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)r=e.node(s).copy(S.from(r));return{start:r.resolveNoCache(n.openStart+t),end:r.resolveNoCache(r.content.size-n.openEnd-t)}}var Wr=class n{constructor(e,t,i){this.pos=e,this.path=t,this.parentOffset=i,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 i=this.pos-this.path[this.path.length-1],r=e.child(t);return i?e.child(t).cut(i):r}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 i=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)r+=i.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return j.none;if(this.textOffset)return e.child(t).marks;let i=e.maybeChild(t-1),r=e.maybeChild(t);if(!i){let l=i;i=r,r=l}let s=i.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!r||!s[o].isInSet(r.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let i=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!r||!i[s].isInSet(r.marks))&&(i=i[s--].removeFromSet(i));return i}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 i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!t||t(this.node(i))))return new gn(this,e,i);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 i=[],r=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),h=s-a;if(i.push(o,l,r+a),!h||(o=o.child(l),o.isText))break;s=h-1,r+=a+1}return new n(t,i,s)}static resolveCached(e,t){let i=Cc.get(e);if(i)for(let s=0;s<i.elts.length;s++){let o=i.elts[s];if(o.pos==t)return o}else Cc.set(e,i=new $o);let r=i.elts[i.i]=n.resolve(e,t);return i.i=(i.i+1)%t0,r}},$o=class{constructor(){this.elts=[],this.i=0}},t0=12,Cc=new WeakMap,gn=class{constructor(e,t,i){this.$from=e,this.$to=t,this.depth=i}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)}},n0=Object.create(null),Oe=class n{constructor(e,t,i,r=j.none){this.type=e,this.attrs=t,this.marks=r,this.content=i||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,i,r=0){this.content.nodesBetween(e,t,i,r,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,i,r){return this.content.textBetween(e,t,i,r)}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,i){return this.type==e&&Vr(this.attrs,t||e.defaultAttrs||n0)&&j.sameSet(this.marks,i||j.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(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,i=!1){if(e==t)return O.empty;let r=this.resolve(e),s=this.resolve(t),o=i?0:r.sharedDepth(t),l=r.start(o),h=r.node(o).content.cut(r.pos-l,s.pos-l);return new O(h,r.depth-o,s.depth-o)}replace(e,t,i){return Zg(this.resolve(e),this.resolve(t),i)}nodeAt(e){for(let t=this;;){let{index:i,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(i),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:i}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(t),index:t,offset:i};let r=this.content.child(t-1);return{node:r,index:t-1,offset:i-r.nodeSize}}resolve(e){return Wr.resolveCached(this,e)}resolveNoCache(e){return Wr.resolve(this,e)}rangeHasMark(e,t,i){let r=!1;return t>e&&this.nodesBetween(e,t,s=>(i.isInSet(s.marks)&&(r=!0),!r)),r}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()+")"),Hc(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,i=S.empty,r=0,s=i.childCount){let o=this.contentMatchAt(e).matchFragment(i,r,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=r;a<s;a++)if(!this.type.allowsMarks(i.child(a).marks))return!1;return!0}canReplaceWith(e,t,i,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(i),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=j.none;for(let t=0;t<this.marks.length;t++){let i=this.marks[t];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!j.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 i;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=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,i)}let r=S.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,r,i);return s.type.checkAttrs(s.attrs),s}};Oe.prototype.text=void 0;var _o=class n extends Oe{constructor(e,t,i,r){if(super(e,t,null,r),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Hc(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 n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(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 Hc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var yn=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let i=new Ko(e,t);if(i.next==null)return n.empty;let r=Wc(i);i.next&&i.err("Unexpected trailing text");let s=h0(a0(r));return c0(s,i),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,i=e.childCount){let r=this;for(let s=t;r&&s<i;s++)r=r.matchType(e.child(s).type);return r}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 i=0;i<e.next.length;i++)if(this.next[t].type==e.next[i].type)return!0;return!1}fillBefore(e,t=!1,i=0){let r=[this];function s(o,l){let a=o.matchFragment(e,i);if(a&&(!t||a.validEnd))return S.from(l.map(h=>h.createAndFill()));for(let h=0;h<o.next.length;h++){let{type:c,next:f}=o.next[h];if(!(c.isText||c.hasRequiredAttrs())&&r.indexOf(f)==-1){r.push(f);let u=s(f,l.concat(c));if(u)return u}}return null}return s(this,[])}findWrapping(e){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==e)return this.wrapCache[i+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let r=i.shift(),s=r.match;if(s.matchType(e)){let o=[];for(let l=r;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)&&(!r.type||a.validEnd)&&(i.push({match:l.contentMatch,type:l,via:r}),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(i){e.push(i);for(let r=0;r<i.next.length;r++)e.indexOf(i.next[r].next)==-1&&t(i.next[r].next)}return t(this),e.map((i,r)=>{let s=r+(i.validEnd?"*":" ")+" ";for(let o=0;o<i.next.length;o++)s+=(o?", ":"")+i.next[o].type.name+"->"+e.indexOf(i.next[o].next);return s}).join(`
|
|
3
|
+
`)}};yn.empty=new yn(!0);var Ko=class{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 Wc(n){let e=[];do e.push(i0(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function i0(n){let e=[];do e.push(r0(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function r0(n){let e=l0(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=s0(n,e);else break;return e}function Mc(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function s0(n,e){let t=Mc(n),i=t;return n.eat(",")&&(n.next!="}"?i=Mc(n):i=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:i,expr:e}}function o0(n,e){let t=n.nodeTypes,i=t[e];if(i)return[i];let r=[];for(let s in t){let o=t[s];o.isInGroup(e)&&r.push(o)}return r.length==0&&n.err("No node type or group '"+e+"' found"),r}function l0(n){if(n.eat("(")){let e=Wc(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=o0(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 a0(n){let e=[[]];return r(s(n,0),t()),e;function t(){return e.push([])-1}function i(o,l,a){let h={term:a,to:l};return e[o].push(h),h}function r(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,h)=>a.concat(s(h,l)),[]);if(o.type=="seq")for(let a=0;;a++){let h=s(o.exprs[a],l);if(a==o.exprs.length-1)return h;r(h,l=t())}else if(o.type=="star"){let a=t();return i(l,a),r(s(o.expr,a),a),[i(a)]}else if(o.type=="plus"){let a=t();return r(s(o.expr,l),a),r(s(o.expr,a),a),[i(a)]}else{if(o.type=="opt")return[i(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let h=0;h<o.min;h++){let c=t();r(s(o.expr,a),c),a=c}if(o.max==-1)r(s(o.expr,a),a);else for(let h=o.min;h<o.max;h++){let c=t();i(a,c),r(s(o.expr,a),c),a=c}return[i(a)]}else{if(o.type=="name")return[i(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function $c(n,e){return e-n}function Ac(n,e){let t=[];return i(e),t.sort($c);function i(r){let s=n[r];if(s.length==1&&!s[0].term)return i(s[0].to);t.push(r);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&i(a)}}}function h0(n){let e=Object.create(null);return t(Ac(n,0));function t(i){let r=[];i.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let h;for(let c=0;c<r.length;c++)r[c][0]==l&&(h=r[c][1]);Ac(n,a).forEach(c=>{h||r.push([l,h=[]]),h.indexOf(c)==-1&&h.push(c)})})});let s=e[i.join(",")]=new yn(i.indexOf(n.length-1)>-1);for(let o=0;o<r.length;o++){let l=r[o][1].sort($c);s.next.push({type:r[o][0],next:e[l.join(",")]||t(l)})}return s}}function c0(n,e){for(let t=0,i=[n];t<i.length;t++){let r=i[t],s=!r.validEnd,o=[];for(let l=0;l<r.next.length;l++){let{type:a,next:h}=r.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),i.indexOf(h)==-1&&i.push(h)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function _c(n){let e=Object.create(null);for(let t in n){let i=n[t];if(!i.hasDefault)return null;e[t]=i.default}return e}function Kc(n,e){let t=Object.create(null);for(let i in n){let r=e&&e[i];if(r===void 0){let s=n[i];if(s.hasDefault)r=s.default;else throw new RangeError("No value supplied for attribute "+i)}t[i]=r}return t}function qc(n,e,t,i){for(let r in e)if(!(r in n))throw new RangeError(`Unsupported attribute ${r} for ${t} of type ${r}`);for(let r in n){let s=n[r];s.validate&&s.validate(e[r])}}function jc(n,e){let t=Object.create(null);if(e)for(let i in e)t[i]=new qo(n,i,e[i]);return t}var $r=class n{constructor(e,t,i){this.name=e,this.schema=t,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=jc(e,i.attrs),this.defaultAttrs=_c(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==yn.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:Kc(this.attrs,e)}create(e=null,t,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Oe(this,this.computeAttrs(e),S.from(t),j.setFrom(i))}createChecked(e=null,t,i){return t=S.from(t),this.checkContent(t),new Oe(this,this.computeAttrs(e),t,j.setFrom(i))}createAndFill(e=null,t,i){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 r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(S.empty,!0);return s?new Oe(this,e,t.append(s),j.setFrom(i)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).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){qc(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 i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?t&&t.push(e[i]):t||(t=e.slice(0,i));return t?t.length?t:j.none:e}static compile(e,t){let i=Object.create(null);e.forEach((s,o)=>i[s]=new n(s,t,o));let r=t.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let s in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function f0(n,e,t){let i=t.split("|");return r=>{let s=r===null?"null":typeof r;if(i.indexOf(s)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${n}, got ${s}`)}}var qo=class{constructor(e,t,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?f0(e,t,i.validate):i.validate}get isRequired(){return!this.hasDefault}},Ii=class n{constructor(e,t,i,r){this.name=e,this.rank=t,this.schema=i,this.spec=r,this.attrs=jc(e,r.attrs),this.excluded=null;let s=_c(this.attrs);this.instance=s?new j(this,s):null}create(e=null){return!e&&this.instance?this.instance:new j(this,Kc(this.attrs,e))}static compile(e,t){let i=Object.create(null),r=0;return e.forEach((s,o)=>i[s]=new n(s,r++,t,o)),i}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){qc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Gn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=Fo.from(e.nodes),t.marks=Fo.from(e.marks||{}),this.nodes=$r.compile(this.spec.nodes,this),this.marks=Ii.compile(this.spec.marks,this);let i=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=i[o]||(i[o]=yn.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?Tc(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Tc(this,o.split(" "))}this.nodeFromJSON=r=>Oe.fromJSON(this,r),this.markFromJSON=r=>j.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,i,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof $r){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,i,r)}text(e,t){let i=this.nodes.text;return new _o(i,i.defaultAttrs,e,j.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 Tc(n,e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],s=n.marks[r],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(r=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(r)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return t}function u0(n){return n.tag!=null}function d0(n){return n.style!=null}var pt=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let i=this.matchedStyles=[];t.forEach(r=>{if(u0(r))this.tags.push(r);else if(d0(r)){let s=/[^=]*/.exec(r.style)[0];i.indexOf(s)<0&&i.push(s),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let i=new _r(this,t,!1);return i.addAll(e,j.none,t.from,t.to),i.finish()}parseSlice(e,t={}){let i=new _r(this,t,!0);return i.addAll(e,j.none,t.from,t.to),O.maxOpen(i.finish())}matchTag(e,t,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let s=this.tags[r];if(g0(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,i,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!i.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 i(r){let s=r.priority==null?50:r.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,r)}for(let r in e.marks){let s=e.marks[r].spec.parseDOM;s&&s.forEach(o=>{i(o=Ec(o)),o.mark||o.ignore||o.clearMark||(o.mark=r)})}for(let r in e.nodes){let s=e.nodes[r].spec.parseDOM;s&&s.forEach(o=>{i(o=Ec(o)),o.node||o.ignore||o.mark||(o.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Jc={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},p0={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Uc={ol:!0,ul:!0},Bi=1,jo=2,Pi=4;function Oc(n,e,t){return e!=null?(e?Bi:0)|(e==="full"?jo:0):n&&n.whitespace=="pre"?Bi|jo:t&~Pi}var Un=class{constructor(e,t,i,r,s,o){this.type=e,this.attrs=t,this.marks=i,this.solid=r,this.options=o,this.content=[],this.activeMarks=j.none,this.match=s||(o&Pi?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 i=this.type.contentMatch,r;return(r=i.findWrapping(e.type))?(this.match=i,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Bi)){let i=this.content[this.content.length-1],r;if(i&&i.isText&&(r=/[ \t\r\n\u000c]+$/.exec(i.text))){let s=i;i.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-r[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&&!Jc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},_r=class{constructor(e,t,i){this.parser=e,this.options=t,this.isOpen=i,this.open=0,this.localPreserveWS=!1;let r=t.topNode,s,o=Oc(null,t.preserveWhitespace,0)|(i?Pi:0);r?s=new Un(r.type,r.attrs,j.none,!0,t.topMatch||r.type.contentMatch,o):i?s=new Un(null,null,j.none,!0,null,o):s=new Un(e.schema.topNodeType,null,j.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 i=e.nodeValue,r=this.top,s=r.options&jo?"full":this.localPreserveWS||(r.options&Bi)>0,{schema:o}=this.parser;if(s==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(s)if(s==="full")i=i.replace(/\r\n?/g,`
|
|
4
4
|
`);else if(o.linebreakReplacement&&/[\r\n]/.test(i)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=i.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));i=""}else i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let l=r.content[r.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(i=i.slice(1))}i&&this.insertNode(o.text(i),t,!/\S/.test(i)),this.findInText(e)}else this.findInside(e)}addElement(e,t,i){let r=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Uc.hasOwnProperty(o)&&this.parser.normalizeLists&&m0(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,i));e:if(a?a.ignore:p0.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 h,c=this.needsBlock;if(Jc.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),h=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=a&&a.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),h&&this.sync(s),this.needsBlock=c}else{let h=this.readStyles(e,t);h&&this.addElementByRule(e,a,h,a.consuming===!1?l:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
5
|
-
`),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 i=e.style;if(i&&i.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let s=this.parser.matchedStyles[r],o=i.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(h=>!a.clearMark(h)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,i,r){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),i,e.nodeName=="BR")||this.leafFallback(e,i);else{let a=this.enter(o,t.attrs||null,i,t.preserveWhitespace);a&&(s=!0,i=a)}else{let a=this.parser.schema.marks[t.mark];i=i.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,i,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,i,!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,i),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,i,r){let s=i||0;for(let o=i?e.childNodes[i]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,i){let r,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],h=a.findWrapping(e);if(h&&(!r||r.length>h.length+l)&&(r=h,s=a,!h.length))break;if(a.solid){if(i)break;l+=2}}if(!r)return null;this.sync(s);for(let o=0;o<r.length;o++)t=this.enterInner(r[o],null,t,!1);return t}insertNode(e,t,i){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let r=this.findPlace(e,t,i);if(r){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=_.none;for(let l of r.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Dc(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,i,r){let s=this.findPlace(e.create(t),i,!1);return s&&(s=this.enterInner(e,t,i,!0,r)),s}enterInner(e,t,i,r=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Oc(e,s,o.options);o.options&Pi&&o.content.length==0&&(l|=Pi);let a=_.none;return i=i.filter(h=>(o.type?o.type.allowsMarkType(h.type):Dc(h.type,e))?(a=h.addToSet(a),!1):!0),this.nodes.push(new Un(e,t,a,r,null,l)),this.open++,i}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|=Ii)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let i=this.nodes[t].content;for(let r=i.length-1;r>=0;r--)e+=i[r].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==t&&(this.find[i].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,i){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(i?2:4)&&(this.find[r].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("/"),i=this.options.context,r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),s=-(i?i.depth+1:0)+(r?0:1),o=(l,a)=>{for(;l>=0;l--){let h=t[l];if(h==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let c=a>0||a==0&&r?this.nodes[a].type:i&&a>=s?i.node(a-s).type:null;if(!c||c.name!=h&&!c.isInGroup(h))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 i=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let i=this.parser.schema.nodes[t];if(i.isTextblock&&i.defaultAttrs)return i}}};function m0(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&Uc.hasOwnProperty(i)&&t?(t.appendChild(e),e=t):i=="li"?t=e:i&&(t=null)}}function g0(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ec(n){let e={};for(let t in n)e[t]=n[t];return e}function Dc(n,e){let t=e.schema.nodes;for(let i in t){let r=t[i];if(!r.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:h,next:c}=l.edge(a);if(h==e||s.indexOf(c)<0&&o(c))return!0}};if(o(r.contentMatch))return!0}}var Et=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},i){i||(i=Ho(t).createDocumentFragment());let r=i,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 h=o.marks[a];if(!this.marks[h.type.name]){a++;continue}if(!h.eq(s[l][0])||h.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)r=s.pop()[1];for(;a<o.marks.length;){let h=o.marks[a++],c=this.serializeMark(h,o.isInline,t);c&&(s.push([h,r]),r.appendChild(c.dom),r=c.contentDOM||c.dom)}}r.appendChild(this.serializeNodeInner(o,t))}),i}serializeNodeInner(e,t){let{dom:i,contentDOM:r}=Fr(Ho(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return i}serializeNode(e,t={}){let i=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(i),i=s.dom)}return i}serializeMark(e,t,i={}){let r=this.marks[e.type.name];return r&&Fr(Ho(i),r(e,t),null,e.attrs)}static renderSpec(e,t,i=null,r){return Fr(e,t,i,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Nc(e.nodes);return t.text||(t.text=i=>i.text),t}static marksFromSchema(e){return Nc(e.marks)}};function Nc(n){let e={};for(let t in n){let i=n[t].spec.toDOM;i&&(e[t]=i)}return e}function Ho(n){return n.document||window.document}var Rc=new WeakMap;function y0(n){let e=Rc.get(n);return e===void 0&&Rc.set(n,e=b0(n)),e}function b0(n){let e=null;function t(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")e||(e=[]),e.push(i);else for(let r=0;r<i.length;r++)t(i[r]);else for(let r in i)t(i[r])}return t(n),e}function Fr(n,e,t,i){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 r=e[0],s;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(s=y0(i))&&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=r.indexOf(" ");o>0&&(t=r.slice(0,o),r=r.slice(o+1));let l,a=t?n.createElementNS(t,r):n.createElement(r),h=e[1],c=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){c=2;for(let f in h)if(h[f]!=null){let u=f.indexOf(" ");u>0?a.setAttributeNS(f.slice(0,u),f.slice(u+1),h[f]):f=="style"&&a.style?a.style.cssText=h[f]:a.setAttribute(f,h[f])}}for(let f=c;f<e.length;f++){let u=e[f];if(u===0){if(f<e.length-1||f>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:d,contentDOM:p}=Fr(n,u,t,i);if(a.appendChild(d),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var Xc=65535,Qc=Math.pow(2,16);function x0(n,e){return n+e*Qc}function Gc(n){return n&Xc}function k0(n){return(n-(n&Xc))/Qc}var Zc=1,ef=2,Kr=4,tf=8,Fi=class{constructor(e,t,i){this.pos=e,this.delInfo=t,this.recover=i}get deleted(){return(this.delInfo&tf)>0}get deletedBefore(){return(this.delInfo&(Zc|Kr))>0}get deletedAfter(){return(this.delInfo&(ef|Kr))>0}get deletedAcross(){return(this.delInfo&Kr)>0}},Dt=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,i=Gc(e);if(!this.inverted)for(let r=0;r<i;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[i*3]+t+k0(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,i){let r=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?r:0);if(a>e)break;let h=this.ranges[l+s],c=this.ranges[l+o],f=a+h;if(e<=f){let u=h?e==a?-1:e==f?1:t:t,d=a+r+(u<0?0:c);if(i)return d;let p=e==(t<0?a:f)?null:x0(l/3,e-a),m=e==a?ef:e==f?Zc:Kr;return(t<0?e!=a:e!=f)&&(m|=tf),new Fi(d,m,p)}r+=c-h}return i?e+r:new Fi(e+r,0,null)}touches(e,t){let i=0,r=Gc(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?i:0);if(a>e)break;let h=this.ranges[l+s],c=a+h;if(e<=c&&l==r*3)return!0;i+=this.ranges[l+o]-h}return!1}forEach(e){let t=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let o=this.ranges[r],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),h=this.ranges[r+t],c=this.ranges[r+i];e(l,l+h,a,a+c),s+=c-h}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};Dt.empty=new Dt([]);var Vi=class n{constructor(e,t,i=0,r=e?e.length:0){this.mirror=t,this.from=i,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(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,i=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?i+r: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,i=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?i-r-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let i=this.from;i<this.to;i++)e=this._maps[i].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,i){let r=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}}r|=l.delInfo,e=l.pos}return i?e:new Fi(e,r,null)}},Jo=Object.create(null),ae=class{getMap(){return Dt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=Jo[t.stepType];if(!i)throw new RangeError(`No step type ${t.stepType} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in Jo)throw new RangeError("Duplicate use of step JSON ID "+e);return Jo[e]=t,t.prototype.jsonID=e,t}},ue=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,i,r){try{return n.ok(e.replace(t,i,r))}catch(s){if(s instanceof mn)return n.fail(s.message);throw s}}};function Qo(n,e,t){let i=[];for(let r=0;r<n.childCount;r++){let s=n.child(r);s.content.size&&(s=s.copy(Qo(s.content,e,s))),s.isInline&&(s=e(s,t,r)),i.push(s)}return S.fromArray(i)}var Hi=class n extends ae{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=e.resolve(this.from),r=i.node(i.sharedDepth(this.to)),s=new O(Qo(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),r),t.openStart,t.openEnd);return ue.fromReplace(e,this.from,this.to,s)}invert(){return new Nt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new n(t.pos,i.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};ae.jsonID("addMark",Hi);var Nt=class n extends ae{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=new O(Qo(t.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return ue.fromReplace(e,this.from,this.to,i)}invert(){return new Hi(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new n(t.pos,i.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};ae.jsonID("removeMark",Nt);var Wi=class n extends ae{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ue.fromReplace(e,this.pos,this.pos+1,new O(S.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let i=this.mark.addToSet(t.marks);if(i.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(i))return new n(this.pos,t.marks[r]);return new n(this.pos,this.mark)}}return new Yn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};ae.jsonID("addNodeMark",Wi);var Yn=class n extends ae{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ue.fromReplace(e,this.pos,this.pos+1,new O(S.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Wi(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};ae.jsonID("removeNodeMark",Yn);var ye=class n extends ae{constructor(e,t,i,r=!1){super(),this.from=e,this.to=t,this.slice=i,this.structure=r}apply(e){return this.structure&&Yo(e,this.from,this.to)?ue.fail("Structure replace would overwrite content"):ue.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Dt([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deletedAcross&&i.deletedAcross?null:new n(t.pos,Math.max(t.pos,i.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||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?O.empty:new O(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(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?O.empty:new O(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(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 n(t.from,t.to,O.fromJSON(e,t.slice),!!t.structure)}};ae.jsonID("replace",ye);var se=class n extends ae{constructor(e,t,i,r,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=i,this.gapTo=r,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Yo(e,this.from,this.gapFrom)||Yo(e,this.gapTo,this.to)))return ue.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ue.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,t.content);return i?ue.fromReplace(e,this.from,this.to,i):ue.fail("Content does not fit in gap")}getMap(){return new Dt([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 n(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),i=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return t.deletedAcross&&i.deletedAcross||r<t.pos||s>i.pos?null:new n(t.pos,i.pos,r,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 n(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}};ae.jsonID("replaceAround",se);function Yo(n,e,t){let i=n.resolve(e),r=t-e,s=i.depth;for(;r>0&&s>0&&i.indexAfter(s)==i.node(s).childCount;)s--,r--;if(r>0){let o=i.node(s).maybeChild(i.indexAfter(s));for(;r>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,r--}}return!1}function w0(n,e,t,i){let r=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,h,c)=>{if(!a.isInline)return;let f=a.marks;if(!i.isInSet(f)&&c.type.allowsMarkType(i.type)){let u=Math.max(h,e),d=Math.min(h+a.nodeSize,t),p=i.addToSet(f);for(let m=0;m<f.length;m++)f[m].isInSet(p)||(o&&o.to==u&&o.mark.eq(f[m])?o.to=d:r.push(o=new Nt(u,d,f[m])));l&&l.to==u?l.to=d:s.push(l=new Hi(u,d,i))}}),r.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function S0(n,e,t,i){let r=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(i instanceof Bi){let h=o.marks,c;for(;c=i.isInSet(h);)(a||(a=[])).push(c),h=c.removeFromSet(h)}else i?i.isInSet(o.marks)&&(a=[i]):a=o.marks;if(a&&a.length){let h=Math.min(l+o.nodeSize,t);for(let c=0;c<a.length;c++){let f=a[c],u;for(let d=0;d<r.length;d++){let p=r[d];p.step==s-1&&f.eq(r[d].style)&&(u=p)}u?(u.to=h,u.step=s):r.push({style:f,from:Math.max(l,e),to:h,step:s})}}}),r.forEach(o=>n.step(new Nt(o.from,o.to,o.style)))}function Zo(n,e,t,i=t.contentMatch,r=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let h=s.child(a),c=l+h.nodeSize,f=i.matchType(h.type);if(!f)o.push(new ye(l,c,O.empty));else{i=f;for(let u=0;u<h.marks.length;u++)t.allowsMarkType(h.marks[u].type)||n.step(new Nt(l,c,h.marks[u]));if(r&&h.isText&&t.whitespace!="pre"){let u,d=/\r?\n|\r/g,p;for(;u=d.exec(h.text);)p||(p=new O(S.from(t.schema.text(" ",t.allowedMarks(h.marks))),0,0)),o.push(new ye(l+u.index,l+u.index+u[0].length,p))}}l=c}if(!i.validEnd){let a=i.fillBefore(S.empty,!0);n.replace(l,l,new O(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function v0(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Rt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let i=n.depth,r=0,s=0;;--i){let o=n.$from.node(i),l=n.$from.index(i)+r,a=n.$to.indexAfter(i)-s;if(i<n.depth&&o.canReplace(l,a,t))return i;if(i==0||o.type.spec.isolating||!v0(o,l,a))break;l&&(r=1),a<o.childCount&&(s=1)}return null}function C0(n,e,t){let{$from:i,$to:r,depth:s}=e,o=i.before(s+1),l=r.after(s+1),a=o,h=l,c=S.empty,f=0;for(let p=s,m=!1;p>t;p--)m||i.index(p)>0?(m=!0,c=S.from(i.node(p).copy(c)),f++):a--;let u=S.empty,d=0;for(let p=s,m=!1;p>t;p--)m||r.after(p+1)<r.end(p)?(m=!0,u=S.from(r.node(p).copy(u)),d++):h++;n.step(new se(a,h,o,l,new O(c.append(u),f,d),c.size-f,!0))}function Zn(n,e,t=null,i=n){let r=M0(n,e),s=r&&A0(i,e);return s?r.map(Yc).concat({type:e,attrs:t}).concat(s.map(Yc)):null}function Yc(n){return{type:n,attrs:null}}function M0(n,e){let{parent:t,startIndex:i,endIndex:r}=n,s=t.contentMatchAt(i).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(i,r,o)?s:null}function A0(n,e){let{parent:t,startIndex:i,endIndex:r}=n,s=t.child(i),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let h=i;a&&h<r;h++)a=a.matchType(t.child(h).type);return!a||!a.validEnd?null:o}function T0(n,e,t){let i=S.empty;for(let o=t.length-1;o>=0;o--){if(i.size){let l=t[o].type.contentMatch.matchFragment(i);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=S.from(t[o].type.create(t[o].attrs,i))}let r=e.start,s=e.end;n.step(new se(r,s,r,s,new O(i,0,0),t.length,!0))}function O0(n,e,t,i,r){if(!i.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 r=="function"?r(o):r;if(o.isTextblock&&!o.hasMarkup(i,a)&&E0(n.doc,n.mapping.slice(s).map(l),i)){let h=null;if(i.schema.linebreakReplacement){let d=i.whitespace=="pre",p=!!i.contentMatch.matchType(i.schema.linebreakReplacement);d&&!p?h=!1:!d&&p&&(h=!0)}h===!1&&rf(n,o,l,s),Zo(n,n.mapping.slice(s).map(l,1),i,void 0,h===null);let c=n.mapping.slice(s),f=c.map(l,1),u=c.map(l+o.nodeSize,1);return n.step(new se(f,u,f+1,u-1,new O(S.from(i.create(a,null,o.marks)),0,0),1,!0)),h===!0&&nf(n,o,l,s),!1}})}function nf(n,e,t,i){e.forEach((r,s)=>{if(r.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(r.text);){let a=n.mapping.slice(i).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function rf(n,e,t,i){e.forEach((r,s)=>{if(r.type==r.type.schema.linebreakReplacement){let o=n.mapping.slice(i).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
|
|
6
|
-
`))}})}function E0(n,e,t){let i=n.resolve(e),r=i.index();return i.parent.canReplaceWith(r,r+1,t)}function D0(n,e,t,i,r){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(i,null,r||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 se(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new O(S.from(o),0,0),1,!0))}function Le(n,e,t=1,i){let r=n.resolve(e),s=r.depth-t,o=i&&i[i.length-1]||r.parent;if(s<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!o.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let h=r.depth-1,c=t-2;h>s;h--,c--){let f=r.node(h),u=r.index(h);if(f.type.spec.isolating)return!1;let d=f.content.cutByIndex(u,f.childCount),p=i&&i[c+1];p&&(d=d.replaceChild(0,p.type.create(p.attrs)));let m=i&&i[c]||f;if(!f.canReplace(u+1,f.childCount)||!m.type.validContent(d))return!1}let l=r.indexAfter(s),a=i&&i[0];return r.node(s).canReplaceWith(l,l,a?a.type:r.node(s+1).type)}function N0(n,e,t=1,i){let r=n.doc.resolve(e),s=S.empty,o=S.empty;for(let l=r.depth,a=r.depth-t,h=t-1;l>a;l--,h--){s=S.from(r.node(l).copy(s));let c=i&&i[h];o=S.from(c?c.type.create(c.attrs,o):r.node(l).copy(o))}n.step(new ye(e,e,new O(s.append(o),t,t),!0))}function $e(n,e){let t=n.resolve(e),i=t.index();return sf(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(i,i+1)}function R0(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:i}=n.type.schema;for(let r=0;r<e.childCount;r++){let s=e.child(r),o=s.type==i?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function sf(n,e){return!!(n&&e&&!n.isLeaf&&R0(n,e))}function bn(n,e,t=-1){let i=n.resolve(e);for(let r=i.depth;;r--){let s,o,l=i.index(r);if(r==i.depth?(s=i.nodeBefore,o=i.nodeAfter):t>0?(s=i.node(r+1),l++,o=i.node(r).maybeChild(l)):(s=i.node(r).maybeChild(l-1),o=i.node(r+1)),s&&!s.isTextblock&&sf(s,o)&&i.node(r).canReplace(l,l+1))return e;if(r==0)break;e=t<0?i.before(r):i.after(r)}}function P0(n,e,t){let i=null,{linebreakReplacement:r}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(r&&o.inlineContent){let c=o.whitespace=="pre",f=!!o.contentMatch.matchType(r);c&&!f?i=!1:!c&&f&&(i=!0)}let l=n.steps.length;if(i===!1){let c=n.doc.resolve(e+t);rf(n,c.node(),c.before(),l)}o.inlineContent&&Zo(n,e+t-1,o,s.node().contentMatchAt(s.index()),i==null);let a=n.mapping.slice(l),h=a.map(e-t);if(n.step(new ye(h,a.map(e+t,-1),O.empty,!0)),i===!0){let c=n.doc.resolve(h);nf(n,c.node(),c.before(),n.steps.length)}return n}function B0(n,e,t){let i=n.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),t))return e;if(i.parentOffset==0)for(let r=i.depth-1;r>=0;r--){let s=i.index(r);if(i.node(r).canReplaceWith(s,s,t))return i.before(r+1);if(s>0)return null}if(i.parentOffset==i.parent.content.size)for(let r=i.depth-1;r>=0;r--){let s=i.indexAfter(r);if(i.node(r).canReplaceWith(s,s,t))return i.after(r+1);if(s<i.node(r).childCount)return null}return null}function of(n,e,t){let i=n.resolve(e);if(!t.content.size)return e;let r=t.content;for(let s=0;s<t.openStart;s++)r=r.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=i.depth;o>=0;o--){let l=o==i.depth?0:i.pos<=(i.start(o+1)+i.end(o+1))/2?-1:1,a=i.index(o)+(l>0?1:0),h=i.node(o),c=!1;if(s==1)c=h.canReplace(a,a,r);else{let f=h.contentMatchAt(a).findWrapping(r.firstChild.type);c=f&&h.canReplaceWith(a,a,f[0])}if(c)return l==0?i.pos:l<0?i.before(o+1):i.after(o+1)}return null}function $i(n,e,t=e,i=O.empty){if(e==t&&!i.size)return null;let r=n.resolve(e),s=n.resolve(t);return lf(r,s,i)?new ye(e,t,i):new Xo(r,s,i).fit()}function lf(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Xo=class{constructor(e,t,i){this.$from=e,this.$to=t,this.unplaced=i,this.frontier=[],this.placed=S.empty;for(let r=0;r<=e.depth;r++){let s=e.node(r);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=S.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,i=this.$from,r=this.close(e<0?this.$to:i.doc.resolve(e));if(!r)return null;let s=this.placed,o=i.depth,l=r.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new O(s,o,l);return e>-1?new se(i.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||i.pos!=this.$to.pos?new ye(i.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<e;i++){let s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=i){e=i;break}t=s.content}for(let t=1;t<=2;t++)for(let i=t==1?e:this.unplaced.openStart;i>=0;i--){let r,s=null;i?(s=Uo(this.unplaced.content,i-1).firstChild,r=s.content):r=this.unplaced.content;let o=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:h}=this.frontier[l],c,f=null;if(t==1&&(o?h.matchType(o.type)||(f=h.fillBefore(S.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:i,frontierDepth:l,parent:s,inject:f};if(t==2&&o&&(c=h.findWrapping(o.type)))return{sliceDepth:i,frontierDepth:l,parent:s,wrap:c};if(s&&h.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:i}=this.unplaced,r=Uo(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new O(e,t+1,Math.max(i,r.size+t>=e.size-i?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:i}=this.unplaced,r=Uo(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new O(Li(e,t-1,1),t-1,s?t-1:i)}else this.unplaced=new O(Li(e,t,1),t,i)}placeNodes({sliceDepth:e,frontierDepth:t,parent:i,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=i?i.content:o.content,a=o.openStart-e,h=0,c=[],{match:f,type:u}=this.frontier[t];if(r){for(let m=0;m<r.childCount;m++)c.push(r.child(m));f=f.matchFragment(r)}let d=l.size+e-(o.content.size-o.openEnd);for(;h<l.childCount;){let m=l.child(h),g=f.matchType(m.type);if(!g)break;h++,(h>1||a==0||m.content.size)&&(f=g,c.push(af(m.mark(u.allowedMarks(m.marks)),h==1?a:0,h==l.childCount?d:-1)))}let p=h==l.childCount;p||(d=-1),this.placed=zi(this.placed,t,S.from(c)),this.frontier[t].match=f,p&&d<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<d;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?O.empty:new O(Li(o.content,e-1,1),e-1,d<0?o.openEnd:e-1):new O(Li(o.content,e,h),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Go(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:i}=this.$to,r=this.$to.after(i);for(;i>1&&r==this.$to.end(--i);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:i,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Go(e,t,r,i,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:h}=this.frontier[l],c=Go(e,l,h,a,!0);if(!c||c.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=zi(this.placed,t.depth,t.fit)),e=t.move;for(let i=t.depth+1;i<=e.depth;i++){let r=e.node(i),s=r.type.contentMatch.fillBefore(r.content,!0,e.index(i));this.openFrontierNode(r.type,r.attrs,s)}return e}openFrontierNode(e,t=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=zi(this.placed,this.depth,S.from(e.create(t,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=zi(this.placed,this.frontier.length,t))}};function Li(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Li(n.firstChild.content,e-1,t)))}function zi(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(zi(n.lastChild.content,e-1,t)))}function Uo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function af(n,e,t){if(e<=0)return n;let i=n.content;return e>1&&(i=i.replaceChild(0,af(i.firstChild,e-1,i.childCount==1?t-1:0))),e>0&&(i=n.type.contentMatch.fillBefore(i).append(i),t<=0&&(i=i.append(n.type.contentMatch.matchFragment(i).fillBefore(S.empty,!0)))),n.copy(i)}function Go(n,e,t,i,r){let s=n.node(e),o=r?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,o);return l&&!I0(t,s.content,o)?l:null}function I0(n,e,t){for(let i=t;i<e.childCount;i++)if(!n.allowsMarks(e.child(i).marks))return!0;return!1}function L0(n){return n.spec.defining||n.spec.definingForContent}function z0(n,e,t,i){if(!i.size)return n.deleteRange(e,t);let r=n.doc.resolve(e),s=n.doc.resolve(t);if(lf(r,s,i))return n.step(new ye(e,t,i));let o=cf(r,s);o[o.length-1]==0&&o.pop();let l=-(r.depth+1);o.unshift(l);for(let u=r.depth,d=r.pos-1;u>0;u--,d--){let p=r.node(u).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(u)>-1?l=u:r.before(u)==d&&o.splice(1,0,-u)}let a=o.indexOf(l),h=[],c=i.openStart;for(let u=i.content,d=0;;d++){let p=u.firstChild;if(h.push(p),d==i.openStart)break;u=p.content}for(let u=c-1;u>=0;u--){let d=h[u],p=L0(d.type);if(p&&!d.sameMarkup(r.node(Math.abs(l)-1)))c=u;else if(p||!d.type.isTextblock)break}for(let u=i.openStart;u>=0;u--){let d=(u+c+1)%(i.openStart+1),p=h[d];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let b=r.node(g-1),x=r.index(g-1);if(b.canReplaceWith(x,x,p.type,p.marks))return n.replace(r.before(g),y?s.after(g):t,new O(hf(i.content,0,i.openStart,d),d,i.openEnd))}}let f=n.steps.length;for(let u=o.length-1;u>=0&&(n.replace(e,t,i),!(n.steps.length>f));u--){let d=o[u];d<0||(e=r.before(d),t=s.after(d))}}function hf(n,e,t,i,r){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(hf(s.content,e+1,t,i,s)))}if(e>i){let s=r.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(S.empty,!0))}return n}function F0(n,e,t,i){if(!i.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let r=B0(n.doc,e,i.type);r!=null&&(e=t=r)}n.replaceRange(e,t,new O(S.from(i),0,0))}function V0(n,e,t){let i=n.doc.resolve(e),r=n.doc.resolve(t),s=cf(i,r);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||i.node(l).type.contentMatch.validEnd)return n.delete(i.start(l),r.end(l));if(l>0&&(a||i.node(l-1).canReplace(i.index(l-1),r.indexAfter(l-1))))return n.delete(i.before(l),r.after(l))}for(let o=1;o<=i.depth&&o<=r.depth;o++)if(e-i.start(o)==i.depth-o&&t>i.end(o)&&r.end(o)-t!=r.depth-o&&i.start(o-1)==r.start(o-1)&&i.node(o-1).canReplace(i.index(o-1),r.index(o-1)))return n.delete(i.before(o),t);n.delete(e,t)}function cf(n,e){let t=[],i=Math.min(n.depth,e.depth);for(let r=i;r>=0;r--){let s=n.start(r);if(s<n.pos-(n.depth-r)||e.end(r)>e.pos+(e.depth-r)||n.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(s==e.start(r)||r==n.depth&&r==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==s-1)&&t.push(r)}return t}var jr=class n extends ae{constructor(e,t,i){super(),this.pos=e,this.attr=t,this.value=i}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at attribute step's position");let i=Object.create(null);for(let s in t.attrs)i[s]=t.attrs[s];i[this.attr]=this.value;let r=t.type.create(i,null,t.marks);return ue.fromReplace(e,this.pos,this.pos+1,new O(S.from(r),0,t.isLeaf?0:1))}getMap(){return Dt.empty}invert(e){return new n(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 n(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 n(t.pos,t.attr,t.value)}};ae.jsonID("attr",jr);var _r=class n extends ae{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let i=e.type.create(t,e.content,e.marks);return ue.ok(i)}getMap(){return Dt.empty}invert(e){return new n(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 n(t.attr,t.value)}};ae.jsonID("docAttr",_r);var Xn=class extends Error{};Xn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Xn.prototype=Object.create(Error.prototype);Xn.prototype.constructor=Xn;Xn.prototype.name="TransformError";var Qn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Vi}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Xn(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}changedRange(){let e=1e9,t=-1e9;for(let i=0;i<this.mapping.maps.length;i++){let r=this.mapping.maps[i];i&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,i=O.empty){let r=$i(this.doc,e,t,i);return r&&this.step(r),this}replaceWith(e,t,i){return this.replace(e,t,new O(S.from(i),0,0))}delete(e,t){return this.replace(e,t,O.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,i){return z0(this,e,t,i),this}replaceRangeWith(e,t,i){return F0(this,e,t,i),this}deleteRange(e,t){return V0(this,e,t),this}lift(e,t){return C0(this,e,t),this}join(e,t=1){return P0(this,e,t),this}wrap(e,t){return T0(this,e,t),this}setBlockType(e,t=e,i,r=null){return O0(this,e,t,i,r),this}setNodeMarkup(e,t,i=null,r){return D0(this,e,t,i,r),this}setNodeAttribute(e,t,i){return this.step(new jr(e,t,i)),this}setDocAttribute(e,t){return this.step(new _r(e,t)),this}addNodeMark(e,t){return this.step(new Wi(e,t)),this}removeNodeMark(e,t){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(t instanceof _)t.isInSet(i.marks)&&this.step(new Yn(e,t));else{let r=i.marks,s,o=[];for(;s=t.isInSet(r);)o.push(new Yn(e,s)),r=s.removeFromSet(r);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,i){return N0(this,e,t,i),this}addMark(e,t,i){return w0(this,e,t,i),this}removeMark(e,t,i){return S0(this,e,t,i),this}clearIncompatible(e,t,i){return Zo(this,e,t,i),this}};var el=Object.create(null),F=class{constructor(e,t,i){this.$anchor=e,this.$head=t,this.ranges=i||[new Ur(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=O.empty){let i=t.content.lastChild,r=null;for(let l=0;l<t.openEnd;l++)r=i,i=i.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:h}=o[l],c=e.mapping.slice(s);e.replaceRange(c.map(a.pos),c.map(h.pos),l?O.empty:t),l==0&&df(e,s,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let i=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:o,$to:l}=r[s],a=e.mapping.slice(i),h=a.map(o.pos),c=a.map(l.pos);s?e.deleteRange(h,c):(e.replaceRangeWith(h,c,t),df(e,i,t.isInline?-1:1))}}static findFrom(e,t,i=!1){let r=e.parent.inlineContent?new L(e):ei(e.node(0),e.parent,e.pos,e.index(),t,i);if(r)return r;for(let s=e.depth-1;s>=0;s--){let o=t<0?ei(e.node(0),e.node(s),e.before(s+1),e.index(s),t,i):ei(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,i);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Se(e.node(0))}static atStart(e){return ei(e,e,0,0,1)||new Se(e)}static atEnd(e){return ei(e,e,e.content.size,e.childCount,-1)||new Se(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=el[t.type];if(!i)throw new RangeError(`No selection type ${t.type} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in el)throw new RangeError("Duplicate use of selection JSON ID "+e);return el[e]=t,t.prototype.jsonID=e,t}getBookmark(){return L.between(this.$anchor,this.$head).getBookmark()}};F.prototype.visible=!0;var Ur=class{constructor(e,t){this.$from=e,this.$to=t}},ff=!1;function uf(n){!ff&&!n.parent.inlineContent&&(ff=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var L=class n extends F{constructor(e,t=e){uf(e),uf(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let i=e.resolve(t.map(this.head));if(!i.parent.inlineContent)return F.near(i);let r=e.resolve(t.map(this.anchor));return new n(r.parent.inlineContent?r:i,i)}replace(e,t=O.empty){if(super.replace(e,t),t==O.empty){let i=this.$from.marksAcross(this.$to);i&&e.ensureMarks(i)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gr(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 n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){let r=e.resolve(t);return new this(r,i==t?r:e.resolve(i))}static between(e,t,i){let r=e.pos-t.pos;if((!i||r)&&(i=r>=0?1:-1),!t.parent.inlineContent){let s=F.findFrom(t,i,!0)||F.findFrom(t,-i,!0);if(s)t=s.$head;else return F.near(t,i)}return e.parent.inlineContent||(r==0?e=t:(e=(F.findFrom(e,-i,!0)||F.findFrom(e,i,!0)).$anchor,e.pos<t.pos!=r<0&&(e=t))),new n(e,t)}};F.jsonID("text",L);var Gr=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return L.between(e.resolve(this.anchor),e.resolve(this.head))}},B=class n extends F{constructor(e){let t=e.nodeAfter,i=e.node(0).resolve(e.pos+t.nodeSize);super(e,i),this.node=t}map(e,t){let{deleted:i,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);return i?F.near(s):new n(s)}content(){return new O(S.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new nl(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};B.prototype.visible=!1;F.jsonID("node",B);var nl=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:i}=e.mapResult(this.anchor);return t?new Gr(i,i):new n(i)}resolve(e){let t=e.resolve(this.anchor),i=t.nodeAfter;return i&&B.isSelectable(i)?new B(t):F.near(t)}},Se=class n extends F{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=O.empty){if(t==O.empty){e.delete(0,e.doc.content.size);let i=F.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return H0}};F.jsonID("all",Se);var H0={map(){return this},resolve(n){return new Se(n)}};function ei(n,e,t,i,r,s=!1){if(e.inlineContent)return L.create(n,t);for(let o=i-(r>0?0:1);r>0?o<e.childCount:o>=0;o+=r){let l=e.child(o);if(l.isAtom){if(!s&&B.isSelectable(l))return B.create(n,t-(r<0?l.nodeSize:0))}else{let a=ei(n,l,t+r,r<0?l.childCount:0,r,s);if(a)return a}t+=l.nodeSize*r}return null}function df(n,e,t){let i=n.steps.length-1;if(i<e)return;let r=n.steps[i];if(!(r instanceof ye||r instanceof se))return;let s=n.mapping.maps[i],o;s.forEach((l,a,h,c)=>{o==null&&(o=c)}),n.setSelection(F.near(n.doc.resolve(o),t))}var pf=1,Jr=2,mf=4,il=class extends Qn{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|pf)&~Jr,this.storedMarks=null,this}get selectionSet(){return(this.updated&pf)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Jr,this}ensureMarks(e){return _.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&Jr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Jr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let i=this.selection;return t&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||_.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,i){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(i==null&&(i=t),!e)return this.deleteRange(t,i);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=i==t?o.marks():o.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(t,i,r.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(F.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|=mf,this}get scrolledIntoView(){return(this.updated&mf)>0}};function gf(n,e){return!e||!n?n:n.bind(e)}var xn=class{constructor(e,t,i){this.name=e,this.init=gf(t.init,i),this.apply=gf(t.apply,i)}},W0=[new xn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new xn("selection",{init(n,e){return n.selection||F.atStart(e.doc)},apply(n){return n.selection}}),new xn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,i){return i.selection.$cursor?n.storedMarks:null}}),new xn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],qi=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=W0.slice(),t&&t.forEach(i=>{if(this.pluginsByKey[i.key])throw new RangeError("Adding different instances of a keyed plugin ("+i.key+")");this.plugins.push(i),this.pluginsByKey[i.key]=i,i.spec.state&&this.fields.push(new xn(i.key,i.spec.state,i))})}},Yr=class n{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 i=0;i<this.config.plugins.length;i++)if(i!=t){let r=this.config.plugins[i];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],i=this.applyInner(e),r=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=r?r[o].n:0,h=r?r[o].state:this,c=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,h,i);if(c&&i.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let f=0;f<this.config.plugins.length;f++)r.push(f<o?{state:i,n:t.length}:{state:this,n:0})}t.push(c),i=i.applyInner(c),s=!0}r&&(r[o]={state:i,n:t.length})}}if(!s)return{state:i,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let s=i[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new il(this)}static create(e){let t=new qi(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new n(t);for(let r=0;r<t.fields.length;r++)i[t.fields[r].name]=t.fields[r].init(e,i);return i}reconfigure(e){let t=new qi(this.schema,e.plugins),i=t.fields,r=new n(t);for(let s=0;s<i.length;s++){let o=i[s].name;r[o]=this.hasOwnProperty(o)?this[o]:i[s].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(i=>i.toJSON())),e&&typeof e=="object")for(let i in e){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[i],s=r.spec.state;s&&s.toJSON&&(t[i]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,i){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new qi(e.schema,e.plugins),s=new n(r);return r.fields.forEach(o=>{if(o.name=="doc")s.doc=Oe.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=F.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let l in i){let a=i[l],h=a.spec.state;if(a.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=h.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}};function yf(n,e,t){for(let i in n){let r=n[i];r instanceof Function?r=r.bind(e):i=="handleDOMEvents"&&(r=yf(r,e,{})),t[i]=r}return t}var J=class{constructor(e){this.spec=e,this.props={},e.props&&yf(e.props,this,this.props),this.key=e.key?e.key.key:bf("plugin")}getState(e){return e[this.key]}},tl=Object.create(null);function bf(n){return n in tl?n+"$"+ ++tl[n]:(tl[n]=0,n+"$")}var te=class{constructor(e="key"){this.key=bf(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Xr=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function kf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var sl=(n,e,t)=>{let i=kf(n,t);if(!i)return!1;let r=ll(i);if(!r){let o=i.blockRange(),l=o&&Rt(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=r.nodeBefore;if(Ef(n,r,e,-1))return!0;if(i.parent.content.size==0&&(ti(s,"end")||B.isSelectable(s)))for(let o=i.depth;;o--){let l=$i(n.doc,i.before(o),i.after(o),O.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(ti(s,"end")?F.findFrom(a.doc.resolve(a.mapping.map(r.pos,-1)),-1):B.create(a.doc,r.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||i.node(o-1).childCount>1)break}return s.isAtom&&r.depth==i.depth-1?(e&&e(n.tr.delete(r.pos-s.nodeSize,r.pos).scrollIntoView()),!0):!1},wf=(n,e,t)=>{let i=kf(n,t);if(!i)return!1;let r=ll(i);return r?vf(n,r,e):!1},Sf=(n,e,t)=>{let i=Cf(n,t);if(!i)return!1;let r=cl(i);return r?vf(n,r,e):!1};function vf(n,e,t){let i=e.nodeBefore,r=i,s=e.pos-1;for(;!r.isTextblock;s--){if(r.type.spec.isolating)return!1;let c=r.lastChild;if(!c)return!1;r=c}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let c=l.firstChild;if(!c)return!1;l=c}let h=$i(n.doc,s,a,O.empty);if(!h||h.from!=s||h instanceof ye&&h.slice.size>=a-s)return!1;if(t){let c=n.tr.step(h);c.setSelection(L.create(c.doc,s)),t(c.scrollIntoView())}return!0}function ti(n,e,t=!1){for(let i=n;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(t&&i.childCount!=1)return!1}return!1}var ol=(n,e,t)=>{let{$head:i,empty:r}=n.selection,s=i;if(!r)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):i.parentOffset>0)return!1;s=ll(i)}let o=s&&s.nodeBefore;return!o||!B.isSelectable(o)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function ll(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 Cf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var al=(n,e,t)=>{let i=Cf(n,t);if(!i)return!1;let r=cl(i);if(!r)return!1;let s=r.nodeAfter;if(Ef(n,r,e,1))return!0;if(i.parent.content.size==0&&(ti(s,"start")||B.isSelectable(s))){let o=$i(n.doc,i.before(),i.after(),O.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(ti(s,"start")?F.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):B.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&r.depth==i.depth-1?(e&&e(n.tr.delete(r.pos,r.pos+s.nodeSize).scrollIntoView()),!0):!1},hl=(n,e,t)=>{let{$head:i,empty:r}=n.selection,s=i;if(!r)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):i.parentOffset<i.parent.content.size)return!1;s=cl(i)}let o=s&&s.nodeAfter;return!o||!B.isSelectable(o)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,s.pos)).scrollIntoView()),!0)};function cl(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}var Mf=(n,e)=>{let t=n.selection,i=t instanceof B,r;if(i){if(t.node.isTextblock||!$e(n.doc,t.from))return!1;r=t.from}else if(r=bn(n.doc,t.from,-1),r==null)return!1;if(e){let s=n.tr.join(r);i&&s.setSelection(B.create(s.doc,r-n.doc.resolve(r).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Af=(n,e)=>{let t=n.selection,i;if(t instanceof B){if(t.node.isTextblock||!$e(n.doc,t.to))return!1;i=t.to}else if(i=bn(n.doc,t.to,1),i==null)return!1;return e&&e(n.tr.join(i).scrollIntoView()),!0},Tf=(n,e)=>{let{$from:t,$to:i}=n.selection,r=t.blockRange(i),s=r&&Rt(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)},fl=(n,e)=>{let{$head:t,$anchor:i}=n.selection;return!t.parent.type.spec.code||!t.sameParent(i)?!1:(e&&e(n.tr.insertText(`
|
|
7
|
-
`).scrollIntoView()),!0)};function ul(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var dl=(n,e)=>{let{$head:t,$anchor:i}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(i))return!1;let r=t.node(-1),s=t.indexAfter(-1),o=ul(r.contentMatchAt(s));if(!o||!r.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(F.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},pl=(n,e)=>{let t=n.selection,{$from:i,$to:r}=t;if(t instanceof Se||i.parent.inlineContent||r.parent.inlineContent)return!1;let s=ul(r.parent.contentMatchAt(r.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!i.parentOffset&&r.index()<r.parent.childCount?i:r).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(L.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},ml=(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(Le(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let i=t.blockRange(),r=i&&Rt(i);return r==null?!1:(e&&e(n.tr.lift(i,r).scrollIntoView()),!0)};function $0(n){return(e,t)=>{let{$from:i,$to:r}=e.selection;if(e.selection instanceof B&&e.selection.node.isBlock)return!i.parentOffset||!Le(e.doc,i.pos)?!1:(t&&t(e.tr.split(i.pos).scrollIntoView()),!0);if(!i.depth)return!1;let s=[],o,l,a=!1,h=!1;for(let d=i.depth;;d--)if(i.node(d).isBlock){a=i.end(d)==i.pos+(i.depth-d),h=i.start(d)==i.pos-(i.depth-d),l=ul(i.node(d-1).contentMatchAt(i.indexAfter(d-1)));let m=n&&n(r.parent,a,i);s.unshift(m||(a&&l?{type:l}:null)),o=d;break}else{if(d==1)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof L||e.selection instanceof Se)&&c.deleteSelection();let f=c.mapping.map(i.pos),u=Le(c.doc,f,s.length,s);if(u||(s[0]=l?{type:l}:null,u=Le(c.doc,f,s.length,s)),!u)return!1;if(c.split(f,s.length,s),!a&&h&&i.node(o).type!=l){let d=c.mapping.map(i.before(o)),p=c.doc.resolve(d);l&&i.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&c.setNodeMarkup(c.mapping.map(i.before(o)),l)}return t&&t(c.scrollIntoView()),!0}}var q0=$0();var Of=(n,e)=>{let{$from:t,to:i}=n.selection,r,s=t.sharedDepth(i);return s==0?!1:(r=t.before(s),e&&e(n.tr.setSelection(B.create(n.doc,r))),!0)},K0=(n,e)=>(e&&e(n.tr.setSelection(new Se(n.doc))),!0);function j0(n,e,t){let i=e.nodeBefore,r=e.nodeAfter,s=e.index();return!i||!r||!i.type.compatibleContent(r.type)?!1:!i.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(r.isTextblock||$e(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ef(n,e,t,i){let r=e.nodeBefore,s=e.nodeAfter,o,l,a=r.type.spec.isolating||s.type.spec.isolating;if(!a&&j0(n,e,t))return!0;let h=!a&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(l=r.contentMatchAt(r.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let d=e.pos+s.nodeSize,p=S.empty;for(let y=o.length-1;y>=0;y--)p=S.from(o[y].create(null,p));p=S.from(r.copy(p));let m=n.tr.step(new se(e.pos-1,d,e.pos,d,new O(p,1,0),o.length,!0)),g=m.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==r.type&&$e(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let c=s.type.spec.isolating||i>0&&a?null:F.findFrom(e,1),f=c&&c.$from.blockRange(c.$to),u=f&&Rt(f);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(f,u).scrollIntoView()),!0;if(h&&ti(s,"start",!0)&&ti(r,"end")){let d=r,p=[];for(;p.push(d),!d.isTextblock;)d=d.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,m.content)){if(t){let y=S.empty;for(let x=p.length-1;x>=0;x--)y=S.from(p[x].copy(y));let b=n.tr.step(new se(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new O(y,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function Df(n){return function(e,t){let i=e.selection,r=n<0?i.$from:i.$to,s=r.depth;for(;r.node(s).isInline;){if(!s)return!1;s--}return r.node(s).isTextblock?(t&&t(e.tr.setSelection(L.create(e.doc,n<0?r.start(s):r.end(s)))),!0):!1}}var gl=Df(-1),yl=Df(1);function Nf(n,e=null){return function(t,i){let{$from:r,$to:s}=t.selection,o=r.blockRange(s),l=o&&Zn(o,n,e);return l?(i&&i(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function bl(n,e=null){return function(t,i){let r=!1;for(let s=0;s<t.selection.ranges.length&&!r;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,h)=>{if(r)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)r=!0;else{let c=t.doc.resolve(h),f=c.index();r=c.parent.canReplaceWith(f,f+1,n)}})}if(!r)return!1;if(i){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)}i(s.scrollIntoView())}return!0}}function xl(...n){return function(e,t,i){for(let r=0;r<n.length;r++)if(n[r](e,t,i))return!0;return!1}}var rl=xl(Xr,sl,ol),xf=xl(Xr,al,hl),_t={Enter:xl(fl,pl,ml,q0),"Mod-Enter":dl,Backspace:rl,"Mod-Backspace":rl,"Shift-Backspace":rl,Delete:xf,"Mod-Delete":xf,"Mod-a":K0},_0={"Ctrl-h":_t.Backspace,"Alt-Backspace":_t["Mod-Backspace"],"Ctrl-d":_t.Delete,"Ctrl-Alt-Backspace":_t["Mod-Delete"],"Alt-Delete":_t["Mod-Delete"],"Alt-d":_t["Mod-Delete"],"Ctrl-a":gl,"Ctrl-e":yl};for(let n in _t)_0[n]=_t[n];var cC=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function Rf(n,e=null){return function(t,i){let{$from:r,$to:s}=t.selection,o=r.blockRange(s);if(!o)return!1;let l=i?t.tr:null;return J0(l,o,n,e)?(i&&i(l.scrollIntoView()),!0):!1}}function J0(n,e,t,i=null){let r=!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 gn(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new gn(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=Zn(s,t,i,e);return l?(n&&U0(n,e,l,r,t),!0):!1}function U0(n,e,t,i,r){let s=S.empty;for(let c=t.length-1;c>=0;c--)s=S.from(t[c].type.create(t[c].attrs,s));n.step(new se(e.start-(i?2:0),e.end,e.start,e.end,new O(s,0,0),t.length,!0));let o=0;for(let c=0;c<t.length;c++)t[c].type==r&&(o=c+1);let l=t.length-o,a=e.start+t.length-(i?2:0),h=e.parent;for(let c=e.startIndex,f=e.endIndex,u=!0;c<f;c++,u=!1)!u&&Le(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=h.child(c).nodeSize;return n}function Pf(n){return function(e,t){let{$from:i,$to:r}=e.selection,s=i.blockRange(r,o=>o.childCount>0&&o.firstChild.type==n);return s?t?i.node(s.depth-1).type==n?G0(e,t,n,s):Y0(e,t,s):!0:!1}}function G0(n,e,t,i){let r=n.tr,s=i.end,o=i.$to.end(i.depth);s<o&&(r.step(new se(s-1,o,s,o,new O(S.from(t.create(null,i.parent.copy())),1,0),1,!0)),i=new gn(r.doc.resolve(i.$from.pos),r.doc.resolve(o),i.depth));let l=Rt(i);if(l==null)return!1;r.lift(i,l);let a=r.doc.resolve(r.mapping.map(s,-1)-1);return $e(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function Y0(n,e,t){let i=n.tr,r=t.parent;for(let d=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)d-=r.child(p).nodeSize,i.delete(d-1,d+1);let s=i.doc.resolve(t.start),o=s.nodeAfter;if(i.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==r.childCount,h=s.node(-1),c=s.index(-1);if(!h.canReplace(c+(l?0:1),c+1,o.content.append(a?S.empty:S.from(r))))return!1;let f=s.pos,u=f+o.nodeSize;return i.step(new se(f-(l?1:0),u+(a?1:0),f+1,u-1,new O((l?S.empty:S.from(r.copy(S.empty))).append(a?S.empty:S.from(r.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(i.scrollIntoView()),!0}function Bf(n){return function(e,t){let{$from:i,$to:r}=e.selection,s=i.blockRange(r,h=>h.childCount>0&&h.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 h=a.lastChild&&a.lastChild.type==l.type,c=S.from(h?n.create():null),f=new O(S.from(n.create(null,S.from(l.type.create(null,c)))),h?3:1,0),u=s.start,d=s.end;t(e.tr.step(new se(u-(h?3:1),d,u,d,f,1,!0)).scrollIntoView())}return!0}}var de=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},oi=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},Ml=null,Bt=function(n,e,t){let i=Ml||(Ml=document.createRange());return i.setEnd(n,t??n.nodeValue.length),i.setStart(n,e||0),i},X0=function(){Ml=null},An=function(n,e,t,i){return t&&(If(n,e,t,i,-1)||If(n,e,t,i,1))},Q0=/^(img|br|input|textarea|hr)$/i;function If(n,e,t,i,r){for(var s;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Ke(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Xi(n)||Q0.test(n.nodeName)||n.contentEditable=="false")return!1;e=de(n)+(r<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(r<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=r;else return!1;else n=o,e=r<0?Ke(n):0}else return!1}}function Ke(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Z0(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=Ke(n)}else if(n.parentNode&&!Xi(n))e=de(n),n=n.parentNode;else return null}}function ey(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&&!Xi(n))e=de(n)+1,n=n.parentNode;else return null}}function ty(n,e,t){for(let i=e==0,r=e==Ke(n);i||r;){if(n==t)return!0;let s=de(n);if(n=n.parentNode,!n)return!1;i=i&&s==0,r=r&&s==Ke(n)}}function Xi(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)}var hs=function(n){return n.focusNode&&An(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function kn(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function ny(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function iy(n,e,t){if(n.caretPositionFromPoint)try{let i=n.caretPositionFromPoint(e,t);if(i)return{node:i.offsetNode,offset:Math.min(Ke(i.offsetNode),i.offset)}}catch{}if(n.caretRangeFromPoint){let i=n.caretRangeFromPoint(e,t);if(i)return{node:i.startContainer,offset:Math.min(Ke(i.startContainer),i.startOffset)}}}var mt=typeof navigator<"u"?navigator:null,Lf=typeof document<"u"?document:null,Qt=mt&&mt.userAgent||"",Al=/Edge\/(\d+)/.exec(Qt),pu=/MSIE \d/.exec(Qt),Tl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Qt),Ee=!!(pu||Tl||Al),Yt=pu?document.documentMode:Tl?+Tl[1]:Al?+Al[1]:0,je=!Ee&&/gecko\/(\d+)/i.test(Qt);je&&+(/Firefox\/(\d+)/.exec(Qt)||[0,0])[1];var Ol=!Ee&&/Chrome\/(\d+)/.exec(Qt),pe=!!Ol,mu=Ol?+Ol[1]:0,xe=!Ee&&!!mt&&/Apple Computer/.test(mt.vendor),li=xe&&(/Mobile\/\w+/.test(Qt)||!!mt&&mt.maxTouchPoints>2),qe=li||(mt?/Mac/.test(mt.platform):!1),gu=mt?/Win/.test(mt.platform):!1,It=/Android \d/.test(Qt),Qi=!!Lf&&"webkitFontSmoothing"in Lf.documentElement.style,ry=Qi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function sy(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 Pt(n,e){return typeof n=="number"?n:n[e]}function oy(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,i=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*i}}function zf(n,e,t){let i=n.someProp("scrollThreshold")||0,r=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=oi(o);continue}let l=o,a=l==s.body,h=a?sy(s):oy(l),c=0,f=0;if(e.top<h.top+Pt(i,"top")?f=-(h.top-e.top+Pt(r,"top")):e.bottom>h.bottom-Pt(i,"bottom")&&(f=e.bottom-e.top>h.bottom-h.top?e.top+Pt(r,"top")-h.top:e.bottom-h.bottom+Pt(r,"bottom")),e.left<h.left+Pt(i,"left")?c=-(h.left-e.left+Pt(r,"left")):e.right>h.right-Pt(i,"right")&&(c=e.right-h.right+Pt(r,"right")),c||f)if(a)s.defaultView.scrollBy(c,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),c&&(l.scrollLeft+=c);let m=l.scrollLeft-d,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let u=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u=="absolute"?o.offsetParent:oi(o)}}function ly(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),i,r;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){i=l,r=a.top;break}}return{refDOM:i,refTop:r,stack:yu(n.dom)}}function yu(n){let e=[],t=n.ownerDocument;for(let i=n;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),n!=t);i=oi(i));return e}function ay({refDOM:n,refTop:e,stack:t}){let i=n?n.getBoundingClientRect().top:0;bu(t,i==0?0:i-e)}function bu(n,e){for(let t=0;t<n.length;t++){let{dom:i,top:r,left:s}=n[t];i.scrollTop!=r+e&&(i.scrollTop=r+e),i.scrollLeft!=s&&(i.scrollLeft=s)}}var ni=null;function hy(n){if(n.setActive)return n.setActive();if(ni)return n.focus(ni);let e=yu(n);n.focus(ni==null?{get preventScroll(){return ni={preventScroll:!0},!0}}:void 0),ni||(ni=!1,bu(e,0))}function xu(n,e){let t,i=2e8,r,s=0,o=e.top,l=e.top,a,h;for(let c=n.firstChild,f=0;c;c=c.nextSibling,f++){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=Bt(c).getClientRects();else continue;for(let d=0;d<u.length;d++){let p=u[d];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<i){t=c,i=m,r=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,c.nodeType==1&&m&&(s=f+(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=c,h={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=f+1)}}return!t&&a&&(t=a,r=h,i=0),t&&t.nodeType==3?cy(t,r):!t||i&&t.nodeType==1?{node:n,offset:s}:xu(t,r)}function cy(n,e){let t=n.nodeValue.length,i=document.createRange(),r;for(let s=0;s<t;s++){i.setEnd(n,s+1),i.setStart(n,s);let o=Jt(i,1);if(o.top!=o.bottom&&ql(e,o)){r={node:n,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return i.detach(),r||{node:n,offset:0}}function ql(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function fy(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function uy(n,e,t){let{node:i,offset:r}=xu(e,t),s=-1;if(i.nodeType==1&&!i.firstChild){let o=i.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(i,r,s)}function dy(n,e,t,i){let r=-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>i.left||a.top>i.top?r=l.posBefore:(!o&&a.right<i.left||a.bottom<i.top)&&(r=l.posAfter),o=!0),!l.contentDOM&&r<0&&!l.node.isText))return(l.node.isBlock?i.top<(a.top+a.bottom)/2:i.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return r>-1?r:n.docView.posFromDOM(e,t,-1)}function ku(n,e,t){let i=n.childNodes.length;if(i&&t.top<t.bottom)for(let r=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-t.top)/(t.bottom-t.top))-2)),s=r;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let h=l[a];if(ql(e,h))return ku(o,e,h)}}if((s=(s+1)%i)==r)break}return n}function py(n,e){let t=n.dom.ownerDocument,i,r=0,s=iy(t,e.left,e.top);s&&({node:i,offset:r}=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 h=n.dom.getBoundingClientRect();if(!ql(e,h)||(o=ku(n.dom,e,h),!o))return null}if(xe)for(let h=o;i&&h;h=oi(h))h.draggable&&(i=void 0);if(o=fy(o,e),i){if(je&&i.nodeType==1&&(r=Math.min(r,i.childNodes.length),r<i.childNodes.length)){let c=i.childNodes[r],f;c.nodeName=="IMG"&&(f=c.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&r++}let h;Qi&&r&&i.nodeType==1&&(h=i.childNodes[r-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&r--,i==n.dom&&r==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(r==0||i.nodeType!=1||i.childNodes[r-1].nodeName!="BR")&&(l=dy(n,i,r,e))}l==null&&(l=uy(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ff(n){return n.top<n.bottom||n.left<n.right}function Jt(n,e){let t=n.getClientRects();if(t.length){let i=t[e<0?0:t.length-1];if(Ff(i))return i}return Array.prototype.find.call(t,Ff)||n.getBoundingClientRect()}var my=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function wu(n,e,t){let{node:i,offset:r,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=Qi||je;if(i.nodeType==3)if(o&&(my.test(i.nodeValue)||(t<0?!r:r==i.nodeValue.length))){let a=Jt(Bt(i,r,r),t);if(je&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let h=Jt(Bt(i,r-1,r-1),-1);if(h.top==a.top){let c=Jt(Bt(i,r,r+1),-1);if(c.top!=a.top)return Ki(c,c.left<h.left)}}return a}else{let a=r,h=r,c=t<0?1:-1;return t<0&&!r?(h++,c=-1):t>=0&&r==i.nodeValue.length?(a--,c=1):t<0?a--:h++,Ki(Jt(Bt(i,a,h),c),c<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&r&&(t<0||r==Ke(i))){let a=i.childNodes[r-1];if(a.nodeType==1)return kl(a.getBoundingClientRect(),!1)}if(s==null&&r<Ke(i)){let a=i.childNodes[r];if(a.nodeType==1)return kl(a.getBoundingClientRect(),!0)}return kl(i.getBoundingClientRect(),t>=0)}if(s==null&&r&&(t<0||r==Ke(i))){let a=i.childNodes[r-1],h=a.nodeType==3?Bt(a,Ke(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(h)return Ki(Jt(h,1),!1)}if(s==null&&r<Ke(i)){let a=i.childNodes[r];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let h=a?a.nodeType==3?Bt(a,0,o?0:1):a.nodeType==1?a:null:null;if(h)return Ki(Jt(h,-1),!0)}return Ki(Jt(i.nodeType==3?Bt(i):i,-t),t>=0)}function Ki(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 kl(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 Su(n,e,t){let i=n.state,r=n.root.activeElement;i!=e&&n.updateState(e),r!=n.dom&&n.focus();try{return t()}finally{i!=e&&n.updateState(i),r!=n.dom&&r&&r.focus()}}function gy(n,e,t){let i=e.selection,r=t=="up"?i.$from:i.$to;return Su(n,e,()=>{let{node:s}=n.docView.domFromPos(r.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=wu(n,r.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=Bt(l,0,l.nodeValue.length).getClientRects();else continue;for(let h=0;h<a.length;h++){let c=a[h];if(c.bottom>c.top+1&&(t=="up"?o.top-c.top>(c.bottom-o.top)*2:c.bottom-o.bottom>(o.bottom-c.top)*2))return!1}}return!0})}var yy=/[\u0590-\u08ac]/;function by(n,e,t){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,s=!r,o=r==i.parent.content.size,l=n.domSelection();return l?!yy.test(i.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Su(n,e,()=>{let{focusNode:a,focusOffset:h,anchorNode:c,anchorOffset:f}=n.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",t,"character");let d=i.depth?n.docView.domAfterPos(i.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!d.contains(p.nodeType==1?p:p.parentNode)||a==p&&h==m;try{l.collapse(c,f),a&&(a!=c||h!=f)&&l.extend&&l.extend(a,h)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):i.pos==i.start()||i.pos==i.end()}var Vf=null,Hf=null,Wf=!1;function xy(n,e,t){return Vf==e&&Hf==t?Wf:(Vf=e,Hf=t,Wf=t=="up"||t=="down"?gy(n,e,t):by(n,e,t))}var _e=0,$f=1,wn=2,gt=3,Tn=class{constructor(e,t,i,r){this.parent=e,this.children=t,this.dom=i,this.contentDOM=r,this.dirty=_e,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,i){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,i=this.posAtStart;;t++){let r=this.children[t];if(r==e)return i;i+=r.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,i){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(i<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 r;if(e==this.dom&&this.contentDOM)r=t>de(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!1;break}if(s.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!0;break}if(s.nextSibling)break}}return r??i>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let i=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),o;if(s&&(!t||s.node))if(i&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))i=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let i=t;i;i=i.parent)if(i==this)return t}posFromDOM(e,t,i){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,i)}return-1}descAt(e){for(let t=0,i=0;t<this.children.length;t++){let r=this.children[t],s=i+r.size;if(i==e&&s!=i){for(;!r.border&&r.children.length;)for(let o=0;o<r.children.length;o++){let l=r.children[o];if(l.size){r=l;break}}return r}if(e<s)return r.descAt(e-i-r.border);i=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,r=0;for(let s=0;i<this.children.length;i++){let o=this.children[i],l=s+o.size;if(l>e||o instanceof es){r=e-s;break}s=l}if(r)return this.children[i].domFromPos(r-this.children[i].border,t);for(let s;i&&!(s=this.children[i-1]).size&&s instanceof Qr&&s.side>=0;i--);if(t<=0){let s,o=!0;for(;s=i?this.children[i-1]:null,!(!s||s.dom.parentNode==this.contentDOM);i--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?de(s.dom)+1:0}}else{let s,o=!0;for(;s=i<this.children.length?this.children[i]:null,!(!s||s.dom.parentNode==this.contentDOM);i++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?de(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,i=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let o=i,l=0;;l++){let a=this.children[l],h=o+a.size;if(r==-1&&e<=h){let c=o+a.border;if(e>=c&&t<=h-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=o;for(let f=l;f>0;f--){let u=this.children[f-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){r=de(u.dom)+1;break}e-=u.size}r==-1&&(r=0)}if(r>-1&&(h>t||l==this.children.length-1)){t=h;for(let c=l+1;c<this.children.length;c++){let f=this.children[c];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=de(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=h}return{node:this.contentDOM,from:e,to:t,fromOffset:r,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:i}=this.domFromPos(e,0);if(t.nodeType!=1||i==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[i]}setSelection(e,t,i,r=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let d=0,p=0;d<this.children.length;d++){let m=this.children[d],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,i,r);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),h=i.root.getSelection(),c=i.domSelectionRange(),f=!1;if((je||xe)&&e==t){let{node:d,offset:p}=l;if(d.nodeType==3){if(f=!!(p&&d.nodeValue[p-1]==`
|
|
8
|
-
`),f&&p==d.nodeValue.length)for(let m=d,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:de(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=d.childNodes[p-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(je&&c.focusNode&&c.focusNode!=a.node&&c.focusNode.nodeType==1){let d=c.focusNode.childNodes[c.focusOffset];d&&d.contentEditable=="false"&&(r=!0)}if(!(r||f&&xe)&&An(l.node,l.offset,c.anchorNode,c.anchorOffset)&&An(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((h.extend||e==t)&&!(f&&je)){h.collapse(l.node,l.offset);try{e!=t&&h.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let p=l;l=a,a=p}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),h.removeAllRanges(),h.addRange(d)}}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 i=0,r=0;r<this.children.length;r++){let s=this.children[r],o=i+s.size;if(i==o?e<=o&&t>=i:e<o&&t>i){let l=i+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==i||t==o?wn:$f,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=gt:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?wn:gt}i=o}this.dirty=wn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=e==1?wn:$f;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Qr=class extends Tn{constructor(e,t,i,r){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(i,()=>{if(!s)return r;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==_e&&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}},El=class extends Tn{constructor(e,t,i,r){super(e,[],t,null),this.textDOM=i,this.text=r}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}},ai=class n extends Tn{constructor(e,t,i,r,s){super(e,[],i,r),this.mark=t,this.spec=s}static create(e,t,i,r){let s=r.nodeViews[t.type.name],o=s&&s(t,r,i);return(!o||!o.dom)&&(o=Et.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new n(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty>||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=gt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=_e){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=_e}}slice(e,t,i){let r=n.create(this.parent,this.mark,!0,i),s=this.children,o=this.size;t<o&&(s=Pl(s,t,o,i)),e>0&&(s=Pl(s,0,e,i));for(let l=0;l<s.length;l++)s[l].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Xt=class n extends Tn{constructor(e,t,i,r,s,o,l,a,h){super(e,[],s,o),this.node=t,this.outerDeco=i,this.innerDeco=r,this.nodeDOM=l}static create(e,t,i,r,s,o){let l=s.nodeViews[t.type.name],a,h=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},i,r),c=h&&h.dom,f=h&&h.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=Et.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return c=Mu(c,i,t),h?a=new Dl(e,t,i,r,c,f||null,u,h,s,o+1):t.isText?new Zr(e,t,i,r,c,u,s):new n(e,t,i,r,c,f||null,u,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 i=this.children[t];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,i){return this.dirty==_e&&e.eq(this.node)&&ts(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Rl(this,o&&o.node,e);vy(this.node,this.innerDeco,(h,c,f)=>{h.spec.marks?a.syncToMarks(h.spec.marks,i,e,c):h.type.side>=0&&!f&&a.syncToMarks(c==this.node.childCount?_.none:this.node.child(c).marks,i,e,c),a.placeWidget(h,e,r)},(h,c,f,u)=>{a.syncToMarks(h.marks,i,e,u);let d;a.findNodeMatch(h,c,f,u)||l&&e.state.selection.from>r&&e.state.selection.to<r+h.nodeSize&&(d=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(h,c,f,d,e)||a.updateNextNode(h,c,f,e,u,r)||a.addNode(h,c,f,e,r),r+=h.nodeSize}),a.syncToMarks([],i,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==wn)&&(o&&this.protectLocalComposition(e,o),vu(this.contentDOM,this.children,e),li&&Cy(this.dom))}localCompositionInfo(e,t){let{from:i,to:r}=e.state.selection;if(!(e.state.selection instanceof L)||i<t||r>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=My(this.node.content,o,i-t,r-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:r}){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 El(this,s,t,r);e.input.compositionNodes.push(o),this.children=Pl(this.children,i,i+r.length,e,o)}update(e,t,i,r){return this.dirty==gt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,i,r),!0)}updateInner(e,t,i,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=_e}updateOuterDeco(e){if(ts(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=Cu(this.dom,this.nodeDOM,Nl(this.outerDeco,this.node,t),Nl(e,this.node,t)),this.dom!=i&&(i.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 qf(n,e,t,i,r){Mu(i,e,n);let s=new Xt(void 0,n,e,t,i,i,i,r,0);return s.contentDOM&&s.updateChildren(r,0),s}var Zr=class n extends Xt{constructor(e,t,i,r,s,o,l){super(e,t,i,r,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,i,r){return this.dirty==gt||this.dirty!=_e&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=_e||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=_e,!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,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,i){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new n(this.parent,r,this.outerDeco,this.innerDeco,s,s,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=gt)}get domAtom(){return!1}isText(e){return this.node.text==e}},es=class extends Tn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==_e&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Dl=class extends Xt{constructor(e,t,i,r,s,o,l,a,h,c){super(e,t,i,r,s,o,l,h,c),this.spec=a}update(e,t,i,r){if(this.dirty==gt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,i);return s&&this.updateInner(e,t,i,r),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,i,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,r){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,r)}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 vu(n,e,t){let i=n.firstChild,r=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=i;)i=Kf(i),r=!0;i=i.nextSibling}else r=!0,n.insertBefore(l,i);if(o instanceof ai){let a=i?i.previousSibling:n.lastChild;vu(o.contentDOM,o.children,t),i=a?a.nextSibling:n.firstChild}}for(;i;)i=Kf(i),r=!0;r&&t.trackWrites==n&&(t.trackWrites=null)}var ji=function(n){n&&(this.nodeName=n)};ji.prototype=Object.create(null);var Sn=[new ji];function Nl(n,e,t){if(n.length==0)return Sn;let i=t?Sn[0]:new ji,r=[i];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&r.push(i=new ji(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&r.length==1&&r.push(i=new ji(e.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+a:l=="style"?i.style=(i.style?i.style+";":"")+a:l!="nodeName"&&(i[l]=a))}}}return r}function Cu(n,e,t,i){if(t==Sn&&i==Sn)return e;let r=e;for(let s=0;s<i.length;s++){let o=i[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&r!=n&&(a=r.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(r),l=Sn[0]),r=a}ky(r,l||Sn[0],o)}return r}function ky(n,e,t){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in t)&&n.removeAttribute(i);for(let i in t)i!="class"&&i!="style"&&i!="nodeName"&&t[i]!=e[i]&&n.setAttribute(i,t[i]);if(e.class!=t.class){let i=e.class?e.class.split(" ").filter(Boolean):[],r=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.remove(i[s]);for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.add(r[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=i.exec(e.style);)n.style.removeProperty(r[1])}t.style&&(n.style.cssText+=t.style)}}function Mu(n,e,t){return Cu(n,n,Sn,Nl(e,t,n.nodeType!=1))}function ts(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 Kf(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Rl=class{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=wy(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i,r){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=_e,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,h=this.top.children.length;r<this.preMatch.index&&(h=Math.min(this.index+3,h));for(let c=this.index;c<h;c++){let f=this.top.children[c];if(f.matchesMark(e[o])&&!this.isLocked(f.dom)){a=c;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let c=ai.create(this.top,e[o],t,i);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,i,r){let s=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,i))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 h=this.top.children[l];if(h.matchesNode(e,t,i)&&!this.preMatch.matched.has(h)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,i,r,s){let o=this.top.children[r];return o.dirty==gt&&o.dom==o.contentDOM&&(o.dirty=wn),o.update(e,t,i,s)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let i=e.pmViewDesc;if(i){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==i)return r}return-1}e=t}}updateNextNode(e,t,i,r,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Xt){let h=this.preMatch.matched.get(a);if(h!=null&&h!=s)return!1;let c=a.dom,f,u=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=gt&&ts(t,a.outerDeco));if(!u&&a.update(e,t,i,r))return this.destroyBetween(this.index,l),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!u&&(f=this.recreateWrapper(a,e,t,i,r,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=wn,f.updateChildren(r,o+1),f.dirty=_e),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,r,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ts(i,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=Xt.create(this.top,t,i,r,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,i,r,s){let o=Xt.create(this.top,e,t,i,r,s);o.contentDOM&&o.updateChildren(r,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let s=new Qr(this.top,e,t,i);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 ai;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Zr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((xe||pe)&&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 i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let r=new es(this.top,[],i,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function wy(n,e){let t=e,i=t.children.length,r=n.childCount,s=new Map,o=[];e:for(;r>0;){let l;for(;;)if(i){let h=t.children[i-1];if(h instanceof ai)t=h,i=h.children.length;else{l=h,i--;break}}else{if(t==e)break e;i=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(r-1))break;--r,s.set(l,r),o.push(l)}}return{index:r,matched:s,matches:o.reverse()}}function Sy(n,e){return n.type.side-e.type.side}function vy(n,e,t,i){let r=e.locals(n),s=0;if(r.length==0){for(let h=0;h<n.childCount;h++){let c=n.child(h);i(c,r,e.forChild(s,c),h),s+=c.nodeSize}return}let o=0,l=[],a=null;for(let h=0;;){let c,f;for(;o<r.length&&r[o].to==s;){let g=r[o++];g.widget&&(c?(f||(f=[c])).push(g):c=g)}if(c)if(f){f.sort(Sy);for(let g=0;g<f.length;g++)t(f[g],h,!!a)}else t(c,h,!!a);let u,d;if(a)d=-1,u=a,a=null;else if(h<n.childCount)d=h,u=n.child(h++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<r.length&&r[o].from<=s&&r[o].to>s;)l.push(r[o++]);let p=s+u.nodeSize;if(u.isText){let g=p;o<r.length&&r[o].from<g&&(g=r[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=u.cut(g-s),u=u.cut(0,g-s),p=g,d=-1)}else for(;o<r.length&&r[o].to<p;)o++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();i(u,m,e.forChild(s,u),d),s=p}}function Cy(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 My(n,e,t,i){for(let r=0,s=0;r<n.childCount&&s<=i;){let o=n.child(r++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;r<n.childCount;){let h=n.child(r++);if(s+=h.nodeSize,!h.isText)break;a+=h.text}if(s>=t){if(s>=i&&a.slice(i-e.length-l,i-l)==e)return i-e.length;let h=l<i?a.lastIndexOf(e,i-l-1):-1;if(h>=0&&h+e.length+l>=t)return l+h;if(t==i&&a.length>=i+e.length-l&&a.slice(i-l,i-l+e.length)==e)return i}}return-1}function Pl(n,e,t,i,r){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],h=l,c=l+=a.size;h>=t||c<=e?s.push(a):(h<e&&s.push(a.slice(0,e-h,i)),r&&(s.push(r),r=void 0),c>t&&s.push(a.slice(t-h,a.size,i)))}return s}function Kl(n,e=null){let t=n.domSelectionRange(),i=n.state.doc;if(!t.focusNode)return null;let r=n.docView.nearestDesc(t.focusNode),s=r&&r.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=i.resolve(o),a,h;if(hs(t)){for(a=o;r&&!r.node;)r=r.parent;let f=r.node;if(r&&f.isAtom&&B.isSelectable(f)&&r.parent&&!(f.isInline&&ty(t.focusNode,t.focusOffset,r.dom))){let u=r.posBefore;h=new B(o==u?l:i.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=o,u=o;for(let d=0;d<t.rangeCount;d++){let p=t.getRangeAt(d);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,o]=u==n.state.selection.anchor?[u,f]:[f,u],l=i.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let c=i.resolve(a);if(!h){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;h=jl(n,c,l,f)}return h}function Au(n){return n.editable?n.hasFocus():Ou(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Lt(n,e=!1){let t=n.state.selection;if(Tu(n,t),!!Au(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&pe){let i=n.domSelectionRange(),r=n.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&An(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Ty(n);else{let{anchor:i,head:r}=t,s,o;jf&&!(t instanceof L)&&(t.$from.parent.inlineContent||(s=_f(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=_f(n,t.to))),n.docView.setSelection(i,r,n,e),jf&&(s&&Jf(s),o&&Jf(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ay(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}var jf=xe||pe&&mu<63;function _f(n,e){let{node:t,offset:i}=n.docView.domFromPos(e,0),r=i<t.childNodes.length?t.childNodes[i]:null,s=i?t.childNodes[i-1]:null;if(xe&&r&&r.contentEditable=="false")return wl(r);if((!r||r.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(r)return wl(r);if(s)return wl(s)}}function wl(n){return n.contentEditable="true",xe&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Jf(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Ay(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),i=t.anchorNode,r=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=i||t.anchorOffset!=r)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Au(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ty(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,i=t.nodeName=="IMG";i?e.collapse(t.parentNode,de(t)+1):e.collapse(t,0),!i&&!n.state.selection.visible&&Ee&&Yt<=11&&(t.disabled=!0,t.disabled=!1)}function Tu(n,e){if(e instanceof B){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Uf(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Uf(n)}function Uf(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function jl(n,e,t,i){return n.someProp("createSelectionBetween",r=>r(n,e,t))||L.between(e,t,i)}function Gf(n){return n.editable&&!n.hasFocus()?!1:Ou(n)}function Ou(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 Oy(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return An(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Bl(n,e){let{$anchor:t,$head:i}=n.selection,r=e>0?t.max(i):t.min(i),s=r.parent.inlineContent?r.depth?n.doc.resolve(e>0?r.after():r.before()):null:r;return s&&F.findFrom(s,e)}function Ut(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Yf(n,e,t){let i=n.state.selection;if(i instanceof L)if(t.indexOf("s")>-1){let{$head:r}=i,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(r.pos+s.nodeSize*(e<0?-1:1));return Ut(n,new L(i.$anchor,o))}else if(i.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let r=Bl(n.state,e);return r&&r instanceof B?Ut(n,r):!1}else if(!(qe&&t.indexOf("m")>-1)){let r=i.$head,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?r.pos-s.nodeSize:r.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?B.isSelectable(s)?Ut(n,new B(e<0?n.state.doc.resolve(r.pos-s.nodeSize):r)):Qi?Ut(n,new L(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(i instanceof B&&i.node.isInline)return Ut(n,new L(e>0?i.$to:i.$from));{let r=Bl(n.state,e);return r?Ut(n,r):!1}}}function ns(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function _i(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function ii(n,e){return e<0?Ey(n):Dy(n)}function Ey(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let r,s,o=!1;for(je&&t.nodeType==1&&i<ns(t)&&_i(t.childNodes[i],-1)&&(o=!0);;)if(i>0){if(t.nodeType!=1)break;{let l=t.childNodes[i-1];if(_i(l,-1))r=t,s=--i;else if(l.nodeType==3)t=l,i=t.nodeValue.length;else break}}else{if(Eu(t))break;{let l=t.previousSibling;for(;l&&_i(l,-1);)r=t.parentNode,s=de(l),l=l.previousSibling;if(l)t=l,i=ns(t);else{if(t=t.parentNode,t==n.dom)break;i=0}}}o?Il(n,t,i):r&&Il(n,r,s)}function Dy(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let r=ns(t),s,o;for(;;)if(i<r){if(t.nodeType!=1)break;let l=t.childNodes[i];if(_i(l,1))s=t,o=++i;else break}else{if(Eu(t))break;{let l=t.nextSibling;for(;l&&_i(l,1);)s=l.parentNode,o=de(l)+1,l=l.nextSibling;if(l)t=l,i=0,r=ns(t);else{if(t=t.parentNode,t==n.dom)break;i=r=0}}}s&&Il(n,s,o)}function Eu(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ny(n,e){for(;n&&e==n.childNodes.length&&!Xi(n);)e=de(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 Ry(n,e){for(;n&&!e&&!Xi(n);)e=de(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 Il(n,e,t){if(e.nodeType!=3){let s,o;(o=Ny(e,t))?(e=o,t=0):(s=Ry(e,t))&&(e=s,t=s.nodeValue.length)}let i=n.domSelection();if(!i)return;if(hs(i)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),i.removeAllRanges(),i.addRange(s)}else i.extend&&i.extend(e,t);n.domObserver.setCurSelection();let{state:r}=n;setTimeout(()=>{n.state==r&&Lt(n)},50)}function Xf(n,e){let t=n.state.doc.resolve(e);if(!(pe||gu)&&t.parent.inlineContent){let r=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(s.left-r.left)>1)return s.left<r.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(s.left-r.left)>1)return s.left>r.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Qf(n,e,t){let i=n.state.selection;if(i instanceof L&&!i.empty||t.indexOf("s")>-1||qe&&t.indexOf("m")>-1)return!1;let{$from:r,$to:s}=i;if(!r.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Bl(n.state,e);if(o&&o instanceof B)return Ut(n,o)}if(!r.parent.inlineContent){let o=e<0?r:s,l=i instanceof Se?F.near(o,e):F.findFrom(o,e);return l?Ut(n,l):!1}return!1}function Zf(n,e){if(!(n.state.selection instanceof L))return!0;let{$head:t,$anchor:i,empty:r}=n.state.selection;if(!t.sameParent(i))return!0;if(!r)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 eu(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Py(n){if(!xe||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;eu(n,i,"true"),setTimeout(()=>eu(n,i,"false"),20)}return!1}function By(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Iy(n,e){let t=e.keyCode,i=By(e);if(t==8||qe&&t==72&&i=="c")return Zf(n,-1)||ii(n,-1);if(t==46&&!e.shiftKey||qe&&t==68&&i=="c")return Zf(n,1)||ii(n,1);if(t==13||t==27)return!0;if(t==37||qe&&t==66&&i=="c"){let r=t==37?Xf(n,n.state.selection.from)=="ltr"?-1:1:-1;return Yf(n,r,i)||ii(n,r)}else if(t==39||qe&&t==70&&i=="c"){let r=t==39?Xf(n,n.state.selection.from)=="ltr"?1:-1:1;return Yf(n,r,i)||ii(n,r)}else{if(t==38||qe&&t==80&&i=="c")return Qf(n,-1,i)||ii(n,-1);if(t==40||qe&&t==78&&i=="c")return Py(n)||Qf(n,1,i)||ii(n,1);if(i==(qe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function _l(n,e){n.someProp("transformCopied",d=>{e=d(e,n)});let t=[],{content:i,openStart:r,openEnd:s}=e;for(;r>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1;){r--,s--;let d=i.firstChild;t.push(d.type.name,d.attrs!=d.type.defaultAttrs?d.attrs:null),i=d.content}let o=n.someProp("clipboardSerializer")||Et.fromSchema(n.state.schema),l=Iu(),a=l.createElement("div");a.appendChild(o.serializeFragment(i,{document:l}));let h=a.firstChild,c,f=0;for(;h&&h.nodeType==1&&(c=Bu[h.nodeName.toLowerCase()]);){for(let d=c.length-1;d>=0;d--){let p=l.createElement(c[d]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}h=a.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${r} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",d=>d(e,n))||e.content.textBetween(0,e.content.size,`
|
|
5
|
+
`),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 i=e.style;if(i&&i.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let s=this.parser.matchedStyles[r],o=i.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(h=>!a.clearMark(h)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,i,r){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),i,e.nodeName=="BR")||this.leafFallback(e,i);else{let a=this.enter(o,t.attrs||null,i,t.preserveWhitespace);a&&(s=!0,i=a)}else{let a=this.parser.schema.marks[t.mark];i=i.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,i,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,i,!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,i),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,i,r){let s=i||0;for(let o=i?e.childNodes[i]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,i){let r,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],h=a.findWrapping(e);if(h&&(!r||r.length>h.length+l)&&(r=h,s=a,!h.length))break;if(a.solid){if(i)break;l+=2}}if(!r)return null;this.sync(s);for(let o=0;o<r.length;o++)t=this.enterInner(r[o],null,t,!1);return t}insertNode(e,t,i){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let r=this.findPlace(e,t,i);if(r){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=j.none;for(let l of r.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Dc(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,i,r){let s=this.findPlace(e.create(t),i,!1);return s&&(s=this.enterInner(e,t,i,!0,r)),s}enterInner(e,t,i,r=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Oc(e,s,o.options);o.options&Pi&&o.content.length==0&&(l|=Pi);let a=j.none;return i=i.filter(h=>(o.type?o.type.allowsMarkType(h.type):Dc(h.type,e))?(a=h.addToSet(a),!1):!0),this.nodes.push(new Un(e,t,a,r,null,l)),this.open++,i}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|=Bi)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let i=this.nodes[t].content;for(let r=i.length-1;r>=0;r--)e+=i[r].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==t&&(this.find[i].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,i){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(i?2:4)&&(this.find[r].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("/"),i=this.options.context,r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),s=-(i?i.depth+1:0)+(r?0:1),o=(l,a)=>{for(;l>=0;l--){let h=t[l];if(h==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let c=a>0||a==0&&r?this.nodes[a].type:i&&a>=s?i.node(a-s).type:null;if(!c||c.name!=h&&!c.isInGroup(h))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 i=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let i=this.parser.schema.nodes[t];if(i.isTextblock&&i.defaultAttrs)return i}}};function m0(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&Uc.hasOwnProperty(i)&&t?(t.appendChild(e),e=t):i=="li"?t=e:i&&(t=null)}}function g0(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ec(n){let e={};for(let t in n)e[t]=n[t];return e}function Dc(n,e){let t=e.schema.nodes;for(let i in t){let r=t[i];if(!r.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:h,next:c}=l.edge(a);if(h==e||s.indexOf(c)<0&&o(c))return!0}};if(o(r.contentMatch))return!0}}var Et=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},i){i||(i=Ho(t).createDocumentFragment());let r=i,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 h=o.marks[a];if(!this.marks[h.type.name]){a++;continue}if(!h.eq(s[l][0])||h.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)r=s.pop()[1];for(;a<o.marks.length;){let h=o.marks[a++],c=this.serializeMark(h,o.isInline,t);c&&(s.push([h,r]),r.appendChild(c.dom),r=c.contentDOM||c.dom)}}r.appendChild(this.serializeNodeInner(o,t))}),i}serializeNodeInner(e,t){let{dom:i,contentDOM:r}=Fr(Ho(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return i}serializeNode(e,t={}){let i=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(i),i=s.dom)}return i}serializeMark(e,t,i={}){let r=this.marks[e.type.name];return r&&Fr(Ho(i),r(e,t),null,e.attrs)}static renderSpec(e,t,i=null,r){return Fr(e,t,i,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Nc(e.nodes);return t.text||(t.text=i=>i.text),t}static marksFromSchema(e){return Nc(e.marks)}};function Nc(n){let e={};for(let t in n){let i=n[t].spec.toDOM;i&&(e[t]=i)}return e}function Ho(n){return n.document||window.document}var Rc=new WeakMap;function y0(n){let e=Rc.get(n);return e===void 0&&Rc.set(n,e=b0(n)),e}function b0(n){let e=null;function t(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")e||(e=[]),e.push(i);else for(let r=0;r<i.length;r++)t(i[r]);else for(let r in i)t(i[r])}return t(n),e}function Fr(n,e,t,i){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 r=e[0],s;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(s=y0(i))&&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=r.indexOf(" ");o>0&&(t=r.slice(0,o),r=r.slice(o+1));let l,a=t?n.createElementNS(t,r):n.createElement(r),h=e[1],c=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){c=2;for(let f in h)if(h[f]!=null){let u=f.indexOf(" ");u>0?a.setAttributeNS(f.slice(0,u),f.slice(u+1),h[f]):f=="style"&&a.style?a.style.cssText=h[f]:a.setAttribute(f,h[f])}}for(let f=c;f<e.length;f++){let u=e[f];if(u===0){if(f<e.length-1||f>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:d,contentDOM:p}=Fr(n,u,t,i);if(a.appendChild(d),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var Xc=65535,Qc=Math.pow(2,16);function x0(n,e){return n+e*Qc}function Gc(n){return n&Xc}function k0(n){return(n-(n&Xc))/Qc}var Zc=1,ef=2,Kr=4,tf=8,Fi=class{constructor(e,t,i){this.pos=e,this.delInfo=t,this.recover=i}get deleted(){return(this.delInfo&tf)>0}get deletedBefore(){return(this.delInfo&(Zc|Kr))>0}get deletedAfter(){return(this.delInfo&(ef|Kr))>0}get deletedAcross(){return(this.delInfo&Kr)>0}},Dt=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,i=Gc(e);if(!this.inverted)for(let r=0;r<i;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[i*3]+t+k0(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,i){let r=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?r:0);if(a>e)break;let h=this.ranges[l+s],c=this.ranges[l+o],f=a+h;if(e<=f){let u=h?e==a?-1:e==f?1:t:t,d=a+r+(u<0?0:c);if(i)return d;let p=e==(t<0?a:f)?null:x0(l/3,e-a),m=e==a?ef:e==f?Zc:Kr;return(t<0?e!=a:e!=f)&&(m|=tf),new Fi(d,m,p)}r+=c-h}return i?e+r:new Fi(e+r,0,null)}touches(e,t){let i=0,r=Gc(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?i:0);if(a>e)break;let h=this.ranges[l+s],c=a+h;if(e<=c&&l==r*3)return!0;i+=this.ranges[l+o]-h}return!1}forEach(e){let t=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let o=this.ranges[r],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),h=this.ranges[r+t],c=this.ranges[r+i];e(l,l+h,a,a+c),s+=c-h}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};Dt.empty=new Dt([]);var Vi=class n{constructor(e,t,i=0,r=e?e.length:0){this.mirror=t,this.from=i,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(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,i=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?i+r: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,i=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?i-r-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let i=this.from;i<this.to;i++)e=this._maps[i].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,i){let r=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}}r|=l.delInfo,e=l.pos}return i?e:new Fi(e,r,null)}},Jo=Object.create(null),ae=class{getMap(){return Dt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=Jo[t.stepType];if(!i)throw new RangeError(`No step type ${t.stepType} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in Jo)throw new RangeError("Duplicate use of step JSON ID "+e);return Jo[e]=t,t.prototype.jsonID=e,t}},ue=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,i,r){try{return n.ok(e.replace(t,i,r))}catch(s){if(s instanceof mn)return n.fail(s.message);throw s}}};function Qo(n,e,t){let i=[];for(let r=0;r<n.childCount;r++){let s=n.child(r);s.content.size&&(s=s.copy(Qo(s.content,e,s))),s.isInline&&(s=e(s,t,r)),i.push(s)}return S.fromArray(i)}var Hi=class n extends ae{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=e.resolve(this.from),r=i.node(i.sharedDepth(this.to)),s=new O(Qo(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),r),t.openStart,t.openEnd);return ue.fromReplace(e,this.from,this.to,s)}invert(){return new Nt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new n(t.pos,i.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};ae.jsonID("addMark",Hi);var Nt=class n extends ae{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=new O(Qo(t.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return ue.fromReplace(e,this.from,this.to,i)}invert(){return new Hi(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new n(t.pos,i.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};ae.jsonID("removeMark",Nt);var Wi=class n extends ae{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ue.fromReplace(e,this.pos,this.pos+1,new O(S.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let i=this.mark.addToSet(t.marks);if(i.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(i))return new n(this.pos,t.marks[r]);return new n(this.pos,this.mark)}}return new Yn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};ae.jsonID("addNodeMark",Wi);var Yn=class n extends ae{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ue.fromReplace(e,this.pos,this.pos+1,new O(S.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Wi(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};ae.jsonID("removeNodeMark",Yn);var ye=class n extends ae{constructor(e,t,i,r=!1){super(),this.from=e,this.to=t,this.slice=i,this.structure=r}apply(e){return this.structure&&Yo(e,this.from,this.to)?ue.fail("Structure replace would overwrite content"):ue.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Dt([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deletedAcross&&i.deletedAcross?null:new n(t.pos,Math.max(t.pos,i.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||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?O.empty:new O(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(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?O.empty:new O(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(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 n(t.from,t.to,O.fromJSON(e,t.slice),!!t.structure)}};ae.jsonID("replace",ye);var se=class n extends ae{constructor(e,t,i,r,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=i,this.gapTo=r,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Yo(e,this.from,this.gapFrom)||Yo(e,this.gapTo,this.to)))return ue.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ue.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,t.content);return i?ue.fromReplace(e,this.from,this.to,i):ue.fail("Content does not fit in gap")}getMap(){return new Dt([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 n(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),i=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return t.deletedAcross&&i.deletedAcross||r<t.pos||s>i.pos?null:new n(t.pos,i.pos,r,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 n(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}};ae.jsonID("replaceAround",se);function Yo(n,e,t){let i=n.resolve(e),r=t-e,s=i.depth;for(;r>0&&s>0&&i.indexAfter(s)==i.node(s).childCount;)s--,r--;if(r>0){let o=i.node(s).maybeChild(i.indexAfter(s));for(;r>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,r--}}return!1}function w0(n,e,t,i){let r=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,h,c)=>{if(!a.isInline)return;let f=a.marks;if(!i.isInSet(f)&&c.type.allowsMarkType(i.type)){let u=Math.max(h,e),d=Math.min(h+a.nodeSize,t),p=i.addToSet(f);for(let m=0;m<f.length;m++)f[m].isInSet(p)||(o&&o.to==u&&o.mark.eq(f[m])?o.to=d:r.push(o=new Nt(u,d,f[m])));l&&l.to==u?l.to=d:s.push(l=new Hi(u,d,i))}}),r.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function S0(n,e,t,i){let r=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(i instanceof Ii){let h=o.marks,c;for(;c=i.isInSet(h);)(a||(a=[])).push(c),h=c.removeFromSet(h)}else i?i.isInSet(o.marks)&&(a=[i]):a=o.marks;if(a&&a.length){let h=Math.min(l+o.nodeSize,t);for(let c=0;c<a.length;c++){let f=a[c],u;for(let d=0;d<r.length;d++){let p=r[d];p.step==s-1&&f.eq(r[d].style)&&(u=p)}u?(u.to=h,u.step=s):r.push({style:f,from:Math.max(l,e),to:h,step:s})}}}),r.forEach(o=>n.step(new Nt(o.from,o.to,o.style)))}function Zo(n,e,t,i=t.contentMatch,r=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let h=s.child(a),c=l+h.nodeSize,f=i.matchType(h.type);if(!f)o.push(new ye(l,c,O.empty));else{i=f;for(let u=0;u<h.marks.length;u++)t.allowsMarkType(h.marks[u].type)||n.step(new Nt(l,c,h.marks[u]));if(r&&h.isText&&t.whitespace!="pre"){let u,d=/\r?\n|\r/g,p;for(;u=d.exec(h.text);)p||(p=new O(S.from(t.schema.text(" ",t.allowedMarks(h.marks))),0,0)),o.push(new ye(l+u.index,l+u.index+u[0].length,p))}}l=c}if(!i.validEnd){let a=i.fillBefore(S.empty,!0);n.replace(l,l,new O(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function v0(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Rt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let i=n.depth,r=0,s=0;;--i){let o=n.$from.node(i),l=n.$from.index(i)+r,a=n.$to.indexAfter(i)-s;if(i<n.depth&&o.canReplace(l,a,t))return i;if(i==0||o.type.spec.isolating||!v0(o,l,a))break;l&&(r=1),a<o.childCount&&(s=1)}return null}function C0(n,e,t){let{$from:i,$to:r,depth:s}=e,o=i.before(s+1),l=r.after(s+1),a=o,h=l,c=S.empty,f=0;for(let p=s,m=!1;p>t;p--)m||i.index(p)>0?(m=!0,c=S.from(i.node(p).copy(c)),f++):a--;let u=S.empty,d=0;for(let p=s,m=!1;p>t;p--)m||r.after(p+1)<r.end(p)?(m=!0,u=S.from(r.node(p).copy(u)),d++):h++;n.step(new se(a,h,o,l,new O(c.append(u),f,d),c.size-f,!0))}function Zn(n,e,t=null,i=n){let r=M0(n,e),s=r&&A0(i,e);return s?r.map(Yc).concat({type:e,attrs:t}).concat(s.map(Yc)):null}function Yc(n){return{type:n,attrs:null}}function M0(n,e){let{parent:t,startIndex:i,endIndex:r}=n,s=t.contentMatchAt(i).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(i,r,o)?s:null}function A0(n,e){let{parent:t,startIndex:i,endIndex:r}=n,s=t.child(i),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let h=i;a&&h<r;h++)a=a.matchType(t.child(h).type);return!a||!a.validEnd?null:o}function T0(n,e,t){let i=S.empty;for(let o=t.length-1;o>=0;o--){if(i.size){let l=t[o].type.contentMatch.matchFragment(i);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=S.from(t[o].type.create(t[o].attrs,i))}let r=e.start,s=e.end;n.step(new se(r,s,r,s,new O(i,0,0),t.length,!0))}function O0(n,e,t,i,r){if(!i.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 r=="function"?r(o):r;if(o.isTextblock&&!o.hasMarkup(i,a)&&E0(n.doc,n.mapping.slice(s).map(l),i)){let h=null;if(i.schema.linebreakReplacement){let d=i.whitespace=="pre",p=!!i.contentMatch.matchType(i.schema.linebreakReplacement);d&&!p?h=!1:!d&&p&&(h=!0)}h===!1&&rf(n,o,l,s),Zo(n,n.mapping.slice(s).map(l,1),i,void 0,h===null);let c=n.mapping.slice(s),f=c.map(l,1),u=c.map(l+o.nodeSize,1);return n.step(new se(f,u,f+1,u-1,new O(S.from(i.create(a,null,o.marks)),0,0),1,!0)),h===!0&&nf(n,o,l,s),!1}})}function nf(n,e,t,i){e.forEach((r,s)=>{if(r.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(r.text);){let a=n.mapping.slice(i).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function rf(n,e,t,i){e.forEach((r,s)=>{if(r.type==r.type.schema.linebreakReplacement){let o=n.mapping.slice(i).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
|
|
6
|
+
`))}})}function E0(n,e,t){let i=n.resolve(e),r=i.index();return i.parent.canReplaceWith(r,r+1,t)}function D0(n,e,t,i,r){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(i,null,r||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 se(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new O(S.from(o),0,0),1,!0))}function Le(n,e,t=1,i){let r=n.resolve(e),s=r.depth-t,o=i&&i[i.length-1]||r.parent;if(s<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!o.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let h=r.depth-1,c=t-2;h>s;h--,c--){let f=r.node(h),u=r.index(h);if(f.type.spec.isolating)return!1;let d=f.content.cutByIndex(u,f.childCount),p=i&&i[c+1];p&&(d=d.replaceChild(0,p.type.create(p.attrs)));let m=i&&i[c]||f;if(!f.canReplace(u+1,f.childCount)||!m.type.validContent(d))return!1}let l=r.indexAfter(s),a=i&&i[0];return r.node(s).canReplaceWith(l,l,a?a.type:r.node(s+1).type)}function N0(n,e,t=1,i){let r=n.doc.resolve(e),s=S.empty,o=S.empty;for(let l=r.depth,a=r.depth-t,h=t-1;l>a;l--,h--){s=S.from(r.node(l).copy(s));let c=i&&i[h];o=S.from(c?c.type.create(c.attrs,o):r.node(l).copy(o))}n.step(new ye(e,e,new O(s.append(o),t,t),!0))}function $e(n,e){let t=n.resolve(e),i=t.index();return sf(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(i,i+1)}function R0(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:i}=n.type.schema;for(let r=0;r<e.childCount;r++){let s=e.child(r),o=s.type==i?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function sf(n,e){return!!(n&&e&&!n.isLeaf&&R0(n,e))}function bn(n,e,t=-1){let i=n.resolve(e);for(let r=i.depth;;r--){let s,o,l=i.index(r);if(r==i.depth?(s=i.nodeBefore,o=i.nodeAfter):t>0?(s=i.node(r+1),l++,o=i.node(r).maybeChild(l)):(s=i.node(r).maybeChild(l-1),o=i.node(r+1)),s&&!s.isTextblock&&sf(s,o)&&i.node(r).canReplace(l,l+1))return e;if(r==0)break;e=t<0?i.before(r):i.after(r)}}function P0(n,e,t){let i=null,{linebreakReplacement:r}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(r&&o.inlineContent){let c=o.whitespace=="pre",f=!!o.contentMatch.matchType(r);c&&!f?i=!1:!c&&f&&(i=!0)}let l=n.steps.length;if(i===!1){let c=n.doc.resolve(e+t);rf(n,c.node(),c.before(),l)}o.inlineContent&&Zo(n,e+t-1,o,s.node().contentMatchAt(s.index()),i==null);let a=n.mapping.slice(l),h=a.map(e-t);if(n.step(new ye(h,a.map(e+t,-1),O.empty,!0)),i===!0){let c=n.doc.resolve(h);nf(n,c.node(),c.before(),n.steps.length)}return n}function I0(n,e,t){let i=n.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),t))return e;if(i.parentOffset==0)for(let r=i.depth-1;r>=0;r--){let s=i.index(r);if(i.node(r).canReplaceWith(s,s,t))return i.before(r+1);if(s>0)return null}if(i.parentOffset==i.parent.content.size)for(let r=i.depth-1;r>=0;r--){let s=i.indexAfter(r);if(i.node(r).canReplaceWith(s,s,t))return i.after(r+1);if(s<i.node(r).childCount)return null}return null}function of(n,e,t){let i=n.resolve(e);if(!t.content.size)return e;let r=t.content;for(let s=0;s<t.openStart;s++)r=r.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=i.depth;o>=0;o--){let l=o==i.depth?0:i.pos<=(i.start(o+1)+i.end(o+1))/2?-1:1,a=i.index(o)+(l>0?1:0),h=i.node(o),c=!1;if(s==1)c=h.canReplace(a,a,r);else{let f=h.contentMatchAt(a).findWrapping(r.firstChild.type);c=f&&h.canReplaceWith(a,a,f[0])}if(c)return l==0?i.pos:l<0?i.before(o+1):i.after(o+1)}return null}function $i(n,e,t=e,i=O.empty){if(e==t&&!i.size)return null;let r=n.resolve(e),s=n.resolve(t);return lf(r,s,i)?new ye(e,t,i):new Xo(r,s,i).fit()}function lf(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Xo=class{constructor(e,t,i){this.$from=e,this.$to=t,this.unplaced=i,this.frontier=[],this.placed=S.empty;for(let r=0;r<=e.depth;r++){let s=e.node(r);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=S.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,i=this.$from,r=this.close(e<0?this.$to:i.doc.resolve(e));if(!r)return null;let s=this.placed,o=i.depth,l=r.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new O(s,o,l);return e>-1?new se(i.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||i.pos!=this.$to.pos?new ye(i.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<e;i++){let s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=i){e=i;break}t=s.content}for(let t=1;t<=2;t++)for(let i=t==1?e:this.unplaced.openStart;i>=0;i--){let r,s=null;i?(s=Uo(this.unplaced.content,i-1).firstChild,r=s.content):r=this.unplaced.content;let o=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:h}=this.frontier[l],c,f=null;if(t==1&&(o?h.matchType(o.type)||(f=h.fillBefore(S.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:i,frontierDepth:l,parent:s,inject:f};if(t==2&&o&&(c=h.findWrapping(o.type)))return{sliceDepth:i,frontierDepth:l,parent:s,wrap:c};if(s&&h.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:i}=this.unplaced,r=Uo(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new O(e,t+1,Math.max(i,r.size+t>=e.size-i?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:i}=this.unplaced,r=Uo(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new O(Li(e,t-1,1),t-1,s?t-1:i)}else this.unplaced=new O(Li(e,t,1),t,i)}placeNodes({sliceDepth:e,frontierDepth:t,parent:i,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=i?i.content:o.content,a=o.openStart-e,h=0,c=[],{match:f,type:u}=this.frontier[t];if(r){for(let m=0;m<r.childCount;m++)c.push(r.child(m));f=f.matchFragment(r)}let d=l.size+e-(o.content.size-o.openEnd);for(;h<l.childCount;){let m=l.child(h),g=f.matchType(m.type);if(!g)break;h++,(h>1||a==0||m.content.size)&&(f=g,c.push(af(m.mark(u.allowedMarks(m.marks)),h==1?a:0,h==l.childCount?d:-1)))}let p=h==l.childCount;p||(d=-1),this.placed=zi(this.placed,t,S.from(c)),this.frontier[t].match=f,p&&d<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<d;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?O.empty:new O(Li(o.content,e-1,1),e-1,d<0?o.openEnd:e-1):new O(Li(o.content,e,h),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Go(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:i}=this.$to,r=this.$to.after(i);for(;i>1&&r==this.$to.end(--i);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:i,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Go(e,t,r,i,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:h}=this.frontier[l],c=Go(e,l,h,a,!0);if(!c||c.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=zi(this.placed,t.depth,t.fit)),e=t.move;for(let i=t.depth+1;i<=e.depth;i++){let r=e.node(i),s=r.type.contentMatch.fillBefore(r.content,!0,e.index(i));this.openFrontierNode(r.type,r.attrs,s)}return e}openFrontierNode(e,t=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=zi(this.placed,this.depth,S.from(e.create(t,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=zi(this.placed,this.frontier.length,t))}};function Li(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Li(n.firstChild.content,e-1,t)))}function zi(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(zi(n.lastChild.content,e-1,t)))}function Uo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function af(n,e,t){if(e<=0)return n;let i=n.content;return e>1&&(i=i.replaceChild(0,af(i.firstChild,e-1,i.childCount==1?t-1:0))),e>0&&(i=n.type.contentMatch.fillBefore(i).append(i),t<=0&&(i=i.append(n.type.contentMatch.matchFragment(i).fillBefore(S.empty,!0)))),n.copy(i)}function Go(n,e,t,i,r){let s=n.node(e),o=r?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,o);return l&&!B0(t,s.content,o)?l:null}function B0(n,e,t){for(let i=t;i<e.childCount;i++)if(!n.allowsMarks(e.child(i).marks))return!0;return!1}function L0(n){return n.spec.defining||n.spec.definingForContent}function z0(n,e,t,i){if(!i.size)return n.deleteRange(e,t);let r=n.doc.resolve(e),s=n.doc.resolve(t);if(lf(r,s,i))return n.step(new ye(e,t,i));let o=cf(r,s);o[o.length-1]==0&&o.pop();let l=-(r.depth+1);o.unshift(l);for(let u=r.depth,d=r.pos-1;u>0;u--,d--){let p=r.node(u).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(u)>-1?l=u:r.before(u)==d&&o.splice(1,0,-u)}let a=o.indexOf(l),h=[],c=i.openStart;for(let u=i.content,d=0;;d++){let p=u.firstChild;if(h.push(p),d==i.openStart)break;u=p.content}for(let u=c-1;u>=0;u--){let d=h[u],p=L0(d.type);if(p&&!d.sameMarkup(r.node(Math.abs(l)-1)))c=u;else if(p||!d.type.isTextblock)break}for(let u=i.openStart;u>=0;u--){let d=(u+c+1)%(i.openStart+1),p=h[d];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let b=r.node(g-1),x=r.index(g-1);if(b.canReplaceWith(x,x,p.type,p.marks))return n.replace(r.before(g),y?s.after(g):t,new O(hf(i.content,0,i.openStart,d),d,i.openEnd))}}let f=n.steps.length;for(let u=o.length-1;u>=0&&(n.replace(e,t,i),!(n.steps.length>f));u--){let d=o[u];d<0||(e=r.before(d),t=s.after(d))}}function hf(n,e,t,i,r){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(hf(s.content,e+1,t,i,s)))}if(e>i){let s=r.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(S.empty,!0))}return n}function F0(n,e,t,i){if(!i.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let r=I0(n.doc,e,i.type);r!=null&&(e=t=r)}n.replaceRange(e,t,new O(S.from(i),0,0))}function V0(n,e,t){let i=n.doc.resolve(e),r=n.doc.resolve(t),s=cf(i,r);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||i.node(l).type.contentMatch.validEnd)return n.delete(i.start(l),r.end(l));if(l>0&&(a||i.node(l-1).canReplace(i.index(l-1),r.indexAfter(l-1))))return n.delete(i.before(l),r.after(l))}for(let o=1;o<=i.depth&&o<=r.depth;o++)if(e-i.start(o)==i.depth-o&&t>i.end(o)&&r.end(o)-t!=r.depth-o&&i.start(o-1)==r.start(o-1)&&i.node(o-1).canReplace(i.index(o-1),r.index(o-1)))return n.delete(i.before(o),t);n.delete(e,t)}function cf(n,e){let t=[],i=Math.min(n.depth,e.depth);for(let r=i;r>=0;r--){let s=n.start(r);if(s<n.pos-(n.depth-r)||e.end(r)>e.pos+(e.depth-r)||n.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(s==e.start(r)||r==n.depth&&r==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==s-1)&&t.push(r)}return t}var qr=class n extends ae{constructor(e,t,i){super(),this.pos=e,this.attr=t,this.value=i}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at attribute step's position");let i=Object.create(null);for(let s in t.attrs)i[s]=t.attrs[s];i[this.attr]=this.value;let r=t.type.create(i,null,t.marks);return ue.fromReplace(e,this.pos,this.pos+1,new O(S.from(r),0,t.isLeaf?0:1))}getMap(){return Dt.empty}invert(e){return new n(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 n(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 n(t.pos,t.attr,t.value)}};ae.jsonID("attr",qr);var jr=class n extends ae{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let i=e.type.create(t,e.content,e.marks);return ue.ok(i)}getMap(){return Dt.empty}invert(e){return new n(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 n(t.attr,t.value)}};ae.jsonID("docAttr",jr);var Xn=class extends Error{};Xn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Xn.prototype=Object.create(Error.prototype);Xn.prototype.constructor=Xn;Xn.prototype.name="TransformError";var Qn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Vi}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Xn(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}changedRange(){let e=1e9,t=-1e9;for(let i=0;i<this.mapping.maps.length;i++){let r=this.mapping.maps[i];i&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,i=O.empty){let r=$i(this.doc,e,t,i);return r&&this.step(r),this}replaceWith(e,t,i){return this.replace(e,t,new O(S.from(i),0,0))}delete(e,t){return this.replace(e,t,O.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,i){return z0(this,e,t,i),this}replaceRangeWith(e,t,i){return F0(this,e,t,i),this}deleteRange(e,t){return V0(this,e,t),this}lift(e,t){return C0(this,e,t),this}join(e,t=1){return P0(this,e,t),this}wrap(e,t){return T0(this,e,t),this}setBlockType(e,t=e,i,r=null){return O0(this,e,t,i,r),this}setNodeMarkup(e,t,i=null,r){return D0(this,e,t,i,r),this}setNodeAttribute(e,t,i){return this.step(new qr(e,t,i)),this}setDocAttribute(e,t){return this.step(new jr(e,t)),this}addNodeMark(e,t){return this.step(new Wi(e,t)),this}removeNodeMark(e,t){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(t instanceof j)t.isInSet(i.marks)&&this.step(new Yn(e,t));else{let r=i.marks,s,o=[];for(;s=t.isInSet(r);)o.push(new Yn(e,s)),r=s.removeFromSet(r);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,i){return N0(this,e,t,i),this}addMark(e,t,i){return w0(this,e,t,i),this}removeMark(e,t,i){return S0(this,e,t,i),this}clearIncompatible(e,t,i){return Zo(this,e,t,i),this}};var el=Object.create(null),F=class{constructor(e,t,i){this.$anchor=e,this.$head=t,this.ranges=i||[new Ur(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=O.empty){let i=t.content.lastChild,r=null;for(let l=0;l<t.openEnd;l++)r=i,i=i.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:h}=o[l],c=e.mapping.slice(s);e.replaceRange(c.map(a.pos),c.map(h.pos),l?O.empty:t),l==0&&df(e,s,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let i=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:o,$to:l}=r[s],a=e.mapping.slice(i),h=a.map(o.pos),c=a.map(l.pos);s?e.deleteRange(h,c):(e.replaceRangeWith(h,c,t),df(e,i,t.isInline?-1:1))}}static findFrom(e,t,i=!1){let r=e.parent.inlineContent?new L(e):ei(e.node(0),e.parent,e.pos,e.index(),t,i);if(r)return r;for(let s=e.depth-1;s>=0;s--){let o=t<0?ei(e.node(0),e.node(s),e.before(s+1),e.index(s),t,i):ei(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,i);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Se(e.node(0))}static atStart(e){return ei(e,e,0,0,1)||new Se(e)}static atEnd(e){return ei(e,e,e.content.size,e.childCount,-1)||new Se(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=el[t.type];if(!i)throw new RangeError(`No selection type ${t.type} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in el)throw new RangeError("Duplicate use of selection JSON ID "+e);return el[e]=t,t.prototype.jsonID=e,t}getBookmark(){return L.between(this.$anchor,this.$head).getBookmark()}};F.prototype.visible=!0;var Ur=class{constructor(e,t){this.$from=e,this.$to=t}},ff=!1;function uf(n){!ff&&!n.parent.inlineContent&&(ff=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var L=class n extends F{constructor(e,t=e){uf(e),uf(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let i=e.resolve(t.map(this.head));if(!i.parent.inlineContent)return F.near(i);let r=e.resolve(t.map(this.anchor));return new n(r.parent.inlineContent?r:i,i)}replace(e,t=O.empty){if(super.replace(e,t),t==O.empty){let i=this.$from.marksAcross(this.$to);i&&e.ensureMarks(i)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gr(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 n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){let r=e.resolve(t);return new this(r,i==t?r:e.resolve(i))}static between(e,t,i){let r=e.pos-t.pos;if((!i||r)&&(i=r>=0?1:-1),!t.parent.inlineContent){let s=F.findFrom(t,i,!0)||F.findFrom(t,-i,!0);if(s)t=s.$head;else return F.near(t,i)}return e.parent.inlineContent||(r==0?e=t:(e=(F.findFrom(e,-i,!0)||F.findFrom(e,i,!0)).$anchor,e.pos<t.pos!=r<0&&(e=t))),new n(e,t)}};F.jsonID("text",L);var Gr=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return L.between(e.resolve(this.anchor),e.resolve(this.head))}},I=class n extends F{constructor(e){let t=e.nodeAfter,i=e.node(0).resolve(e.pos+t.nodeSize);super(e,i),this.node=t}map(e,t){let{deleted:i,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);return i?F.near(s):new n(s)}content(){return new O(S.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new nl(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};I.prototype.visible=!1;F.jsonID("node",I);var nl=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:i}=e.mapResult(this.anchor);return t?new Gr(i,i):new n(i)}resolve(e){let t=e.resolve(this.anchor),i=t.nodeAfter;return i&&I.isSelectable(i)?new I(t):F.near(t)}},Se=class n extends F{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=O.empty){if(t==O.empty){e.delete(0,e.doc.content.size);let i=F.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return H0}};F.jsonID("all",Se);var H0={map(){return this},resolve(n){return new Se(n)}};function ei(n,e,t,i,r,s=!1){if(e.inlineContent)return L.create(n,t);for(let o=i-(r>0?0:1);r>0?o<e.childCount:o>=0;o+=r){let l=e.child(o);if(l.isAtom){if(!s&&I.isSelectable(l))return I.create(n,t-(r<0?l.nodeSize:0))}else{let a=ei(n,l,t+r,r<0?l.childCount:0,r,s);if(a)return a}t+=l.nodeSize*r}return null}function df(n,e,t){let i=n.steps.length-1;if(i<e)return;let r=n.steps[i];if(!(r instanceof ye||r instanceof se))return;let s=n.mapping.maps[i],o;s.forEach((l,a,h,c)=>{o==null&&(o=c)}),n.setSelection(F.near(n.doc.resolve(o),t))}var pf=1,Jr=2,mf=4,il=class extends Qn{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|pf)&~Jr,this.storedMarks=null,this}get selectionSet(){return(this.updated&pf)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Jr,this}ensureMarks(e){return j.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&Jr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Jr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let i=this.selection;return t&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||j.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,i){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(i==null&&(i=t),!e)return this.deleteRange(t,i);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=i==t?o.marks():o.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(t,i,r.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(F.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|=mf,this}get scrolledIntoView(){return(this.updated&mf)>0}};function gf(n,e){return!e||!n?n:n.bind(e)}var xn=class{constructor(e,t,i){this.name=e,this.init=gf(t.init,i),this.apply=gf(t.apply,i)}},W0=[new xn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new xn("selection",{init(n,e){return n.selection||F.atStart(e.doc)},apply(n){return n.selection}}),new xn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,i){return i.selection.$cursor?n.storedMarks:null}}),new xn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],_i=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=W0.slice(),t&&t.forEach(i=>{if(this.pluginsByKey[i.key])throw new RangeError("Adding different instances of a keyed plugin ("+i.key+")");this.plugins.push(i),this.pluginsByKey[i.key]=i,i.spec.state&&this.fields.push(new xn(i.key,i.spec.state,i))})}},Yr=class n{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 i=0;i<this.config.plugins.length;i++)if(i!=t){let r=this.config.plugins[i];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],i=this.applyInner(e),r=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=r?r[o].n:0,h=r?r[o].state:this,c=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,h,i);if(c&&i.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let f=0;f<this.config.plugins.length;f++)r.push(f<o?{state:i,n:t.length}:{state:this,n:0})}t.push(c),i=i.applyInner(c),s=!0}r&&(r[o]={state:i,n:t.length})}}if(!s)return{state:i,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let s=i[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new il(this)}static create(e){let t=new _i(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new n(t);for(let r=0;r<t.fields.length;r++)i[t.fields[r].name]=t.fields[r].init(e,i);return i}reconfigure(e){let t=new _i(this.schema,e.plugins),i=t.fields,r=new n(t);for(let s=0;s<i.length;s++){let o=i[s].name;r[o]=this.hasOwnProperty(o)?this[o]:i[s].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(i=>i.toJSON())),e&&typeof e=="object")for(let i in e){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[i],s=r.spec.state;s&&s.toJSON&&(t[i]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,i){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new _i(e.schema,e.plugins),s=new n(r);return r.fields.forEach(o=>{if(o.name=="doc")s.doc=Oe.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=F.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let l in i){let a=i[l],h=a.spec.state;if(a.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=h.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}};function yf(n,e,t){for(let i in n){let r=n[i];r instanceof Function?r=r.bind(e):i=="handleDOMEvents"&&(r=yf(r,e,{})),t[i]=r}return t}var J=class{constructor(e){this.spec=e,this.props={},e.props&&yf(e.props,this,this.props),this.key=e.key?e.key.key:bf("plugin")}getState(e){return e[this.key]}},tl=Object.create(null);function bf(n){return n in tl?n+"$"+ ++tl[n]:(tl[n]=0,n+"$")}var te=class{constructor(e="key"){this.key=bf(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var de=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},si=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},hl=null,It=function(n,e,t){let i=hl||(hl=document.createRange());return i.setEnd(n,t??n.nodeValue.length),i.setStart(n,e||0),i},$0=function(){hl=null},An=function(n,e,t,i){return t&&(xf(n,e,t,i,-1)||xf(n,e,t,i,1))},_0=/^(img|br|input|textarea|hr)$/i;function xf(n,e,t,i,r){for(var s;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Ke(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Xi(n)||_0.test(n.nodeName)||n.contentEditable=="false")return!1;e=de(n)+(r<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(r<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=r;else return!1;else n=o,e=r<0?Ke(n):0}else return!1}}function Ke(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function K0(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=Ke(n)}else if(n.parentNode&&!Xi(n))e=de(n),n=n.parentNode;else return null}}function q0(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&&!Xi(n))e=de(n)+1,n=n.parentNode;else return null}}function j0(n,e,t){for(let i=e==0,r=e==Ke(n);i||r;){if(n==t)return!0;let s=de(n);if(n=n.parentNode,!n)return!1;i=i&&s==0,r=r&&s==Ke(n)}}function Xi(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)}var as=function(n){return n.focusNode&&An(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function kn(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function J0(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function U0(n,e,t){if(n.caretPositionFromPoint)try{let i=n.caretPositionFromPoint(e,t);if(i)return{node:i.offsetNode,offset:Math.min(Ke(i.offsetNode),i.offset)}}catch{}if(n.caretRangeFromPoint){let i=n.caretRangeFromPoint(e,t);if(i)return{node:i.startContainer,offset:Math.min(Ke(i.startContainer),i.startOffset)}}}var mt=typeof navigator<"u"?navigator:null,kf=typeof document<"u"?document:null,Qt=mt&&mt.userAgent||"",cl=/Edge\/(\d+)/.exec(Qt),Qf=/MSIE \d/.exec(Qt),fl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Qt),Ee=!!(Qf||fl||cl),Yt=Qf?document.documentMode:fl?+fl[1]:cl?+cl[1]:0,qe=!Ee&&/gecko\/(\d+)/i.test(Qt);qe&&+(/Firefox\/(\d+)/.exec(Qt)||[0,0])[1];var ul=!Ee&&/Chrome\/(\d+)/.exec(Qt),pe=!!ul,Zf=ul?+ul[1]:0,xe=!Ee&&!!mt&&/Apple Computer/.test(mt.vendor),oi=xe&&(/Mobile\/\w+/.test(Qt)||!!mt&&mt.maxTouchPoints>2),_e=oi||(mt?/Mac/.test(mt.platform):!1),eu=mt?/Win/.test(mt.platform):!1,Bt=/Android \d/.test(Qt),Qi=!!kf&&"webkitFontSmoothing"in kf.documentElement.style,G0=Qi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Y0(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 Pt(n,e){return typeof n=="number"?n:n[e]}function X0(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,i=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*i}}function wf(n,e,t){let i=n.someProp("scrollThreshold")||0,r=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=si(o);continue}let l=o,a=l==s.body,h=a?Y0(s):X0(l),c=0,f=0;if(e.top<h.top+Pt(i,"top")?f=-(h.top-e.top+Pt(r,"top")):e.bottom>h.bottom-Pt(i,"bottom")&&(f=e.bottom-e.top>h.bottom-h.top?e.top+Pt(r,"top")-h.top:e.bottom-h.bottom+Pt(r,"bottom")),e.left<h.left+Pt(i,"left")?c=-(h.left-e.left+Pt(r,"left")):e.right>h.right-Pt(i,"right")&&(c=e.right-h.right+Pt(r,"right")),c||f)if(a)s.defaultView.scrollBy(c,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),c&&(l.scrollLeft+=c);let m=l.scrollLeft-d,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let u=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u=="absolute"?o.offsetParent:si(o)}}function Q0(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),i,r;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){i=l,r=a.top;break}}return{refDOM:i,refTop:r,stack:tu(n.dom)}}function tu(n){let e=[],t=n.ownerDocument;for(let i=n;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),n!=t);i=si(i));return e}function Z0({refDOM:n,refTop:e,stack:t}){let i=n?n.getBoundingClientRect().top:0;nu(t,i==0?0:i-e)}function nu(n,e){for(let t=0;t<n.length;t++){let{dom:i,top:r,left:s}=n[t];i.scrollTop!=r+e&&(i.scrollTop=r+e),i.scrollLeft!=s&&(i.scrollLeft=s)}}var ti=null;function ey(n){if(n.setActive)return n.setActive();if(ti)return n.focus(ti);let e=tu(n);n.focus(ti==null?{get preventScroll(){return ti={preventScroll:!0},!0}}:void 0),ti||(ti=!1,nu(e,0))}function iu(n,e){let t,i=2e8,r,s=0,o=e.top,l=e.top,a,h;for(let c=n.firstChild,f=0;c;c=c.nextSibling,f++){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=It(c).getClientRects();else continue;for(let d=0;d<u.length;d++){let p=u[d];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<i){t=c,i=m,r=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,c.nodeType==1&&m&&(s=f+(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=c,h={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=f+1)}}return!t&&a&&(t=a,r=h,i=0),t&&t.nodeType==3?ty(t,r):!t||i&&t.nodeType==1?{node:n,offset:s}:iu(t,r)}function ty(n,e){let t=n.nodeValue.length,i=document.createRange(),r;for(let s=0;s<t;s++){i.setEnd(n,s+1),i.setStart(n,s);let o=Jt(i,1);if(o.top!=o.bottom&&Tl(e,o)){r={node:n,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return i.detach(),r||{node:n,offset:0}}function Tl(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function ny(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function iy(n,e,t){let{node:i,offset:r}=iu(e,t),s=-1;if(i.nodeType==1&&!i.firstChild){let o=i.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(i,r,s)}function ry(n,e,t,i){let r=-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>i.left||a.top>i.top?r=l.posBefore:(!o&&a.right<i.left||a.bottom<i.top)&&(r=l.posAfter),o=!0),!l.contentDOM&&r<0&&!l.node.isText))return(l.node.isBlock?i.top<(a.top+a.bottom)/2:i.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return r>-1?r:n.docView.posFromDOM(e,t,-1)}function ru(n,e,t){let i=n.childNodes.length;if(i&&t.top<t.bottom)for(let r=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-t.top)/(t.bottom-t.top))-2)),s=r;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let h=l[a];if(Tl(e,h))return ru(o,e,h)}}if((s=(s+1)%i)==r)break}return n}function sy(n,e){let t=n.dom.ownerDocument,i,r=0,s=U0(t,e.left,e.top);s&&({node:i,offset:r}=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 h=n.dom.getBoundingClientRect();if(!Tl(e,h)||(o=ru(n.dom,e,h),!o))return null}if(xe)for(let h=o;i&&h;h=si(h))h.draggable&&(i=void 0);if(o=ny(o,e),i){if(qe&&i.nodeType==1&&(r=Math.min(r,i.childNodes.length),r<i.childNodes.length)){let c=i.childNodes[r],f;c.nodeName=="IMG"&&(f=c.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&r++}let h;Qi&&r&&i.nodeType==1&&(h=i.childNodes[r-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&r--,i==n.dom&&r==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(r==0||i.nodeType!=1||i.childNodes[r-1].nodeName!="BR")&&(l=ry(n,i,r,e))}l==null&&(l=iy(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Sf(n){return n.top<n.bottom||n.left<n.right}function Jt(n,e){let t=n.getClientRects();if(t.length){let i=t[e<0?0:t.length-1];if(Sf(i))return i}return Array.prototype.find.call(t,Sf)||n.getBoundingClientRect()}var oy=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function su(n,e,t){let{node:i,offset:r,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=Qi||qe;if(i.nodeType==3)if(o&&(oy.test(i.nodeValue)||(t<0?!r:r==i.nodeValue.length))){let a=Jt(It(i,r,r),t);if(qe&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let h=Jt(It(i,r-1,r-1),-1);if(h.top==a.top){let c=Jt(It(i,r,r+1),-1);if(c.top!=a.top)return Ki(c,c.left<h.left)}}return a}else{let a=r,h=r,c=t<0?1:-1;return t<0&&!r?(h++,c=-1):t>=0&&r==i.nodeValue.length?(a--,c=1):t<0?a--:h++,Ki(Jt(It(i,a,h),c),c<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&r&&(t<0||r==Ke(i))){let a=i.childNodes[r-1];if(a.nodeType==1)return rl(a.getBoundingClientRect(),!1)}if(s==null&&r<Ke(i)){let a=i.childNodes[r];if(a.nodeType==1)return rl(a.getBoundingClientRect(),!0)}return rl(i.getBoundingClientRect(),t>=0)}if(s==null&&r&&(t<0||r==Ke(i))){let a=i.childNodes[r-1],h=a.nodeType==3?It(a,Ke(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(h)return Ki(Jt(h,1),!1)}if(s==null&&r<Ke(i)){let a=i.childNodes[r];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let h=a?a.nodeType==3?It(a,0,o?0:1):a.nodeType==1?a:null:null;if(h)return Ki(Jt(h,-1),!0)}return Ki(Jt(i.nodeType==3?It(i):i,-t),t>=0)}function Ki(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 rl(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 ou(n,e,t){let i=n.state,r=n.root.activeElement;i!=e&&n.updateState(e),r!=n.dom&&n.focus();try{return t()}finally{i!=e&&n.updateState(i),r!=n.dom&&r&&r.focus()}}function ly(n,e,t){let i=e.selection,r=t=="up"?i.$from:i.$to;return ou(n,e,()=>{let{node:s}=n.docView.domFromPos(r.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=su(n,r.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=It(l,0,l.nodeValue.length).getClientRects();else continue;for(let h=0;h<a.length;h++){let c=a[h];if(c.bottom>c.top+1&&(t=="up"?o.top-c.top>(c.bottom-o.top)*2:c.bottom-o.bottom>(o.bottom-c.top)*2))return!1}}return!0})}var ay=/[\u0590-\u08ac]/;function hy(n,e,t){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,s=!r,o=r==i.parent.content.size,l=n.domSelection();return l?!ay.test(i.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:ou(n,e,()=>{let{focusNode:a,focusOffset:h,anchorNode:c,anchorOffset:f}=n.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",t,"character");let d=i.depth?n.docView.domAfterPos(i.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!d.contains(p.nodeType==1?p:p.parentNode)||a==p&&h==m;try{l.collapse(c,f),a&&(a!=c||h!=f)&&l.extend&&l.extend(a,h)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):i.pos==i.start()||i.pos==i.end()}var vf=null,Cf=null,Mf=!1;function cy(n,e,t){return vf==e&&Cf==t?Mf:(vf=e,Cf=t,Mf=t=="up"||t=="down"?ly(n,e,t):hy(n,e,t))}var je=0,Af=1,wn=2,gt=3,Tn=class{constructor(e,t,i,r){this.parent=e,this.children=t,this.dom=i,this.contentDOM=r,this.dirty=je,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,i){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,i=this.posAtStart;;t++){let r=this.children[t];if(r==e)return i;i+=r.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,i){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(i<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 r;if(e==this.dom&&this.contentDOM)r=t>de(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!1;break}if(s.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!0;break}if(s.nextSibling)break}}return r??i>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let i=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),o;if(s&&(!t||s.node))if(i&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))i=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let i=t;i;i=i.parent)if(i==this)return t}posFromDOM(e,t,i){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,i)}return-1}descAt(e){for(let t=0,i=0;t<this.children.length;t++){let r=this.children[t],s=i+r.size;if(i==e&&s!=i){for(;!r.border&&r.children.length;)for(let o=0;o<r.children.length;o++){let l=r.children[o];if(l.size){r=l;break}}return r}if(e<s)return r.descAt(e-i-r.border);i=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,r=0;for(let s=0;i<this.children.length;i++){let o=this.children[i],l=s+o.size;if(l>e||o instanceof Zr){r=e-s;break}s=l}if(r)return this.children[i].domFromPos(r-this.children[i].border,t);for(let s;i&&!(s=this.children[i-1]).size&&s instanceof Xr&&s.side>=0;i--);if(t<=0){let s,o=!0;for(;s=i?this.children[i-1]:null,!(!s||s.dom.parentNode==this.contentDOM);i--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?de(s.dom)+1:0}}else{let s,o=!0;for(;s=i<this.children.length?this.children[i]:null,!(!s||s.dom.parentNode==this.contentDOM);i++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?de(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,i=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let o=i,l=0;;l++){let a=this.children[l],h=o+a.size;if(r==-1&&e<=h){let c=o+a.border;if(e>=c&&t<=h-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=o;for(let f=l;f>0;f--){let u=this.children[f-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){r=de(u.dom)+1;break}e-=u.size}r==-1&&(r=0)}if(r>-1&&(h>t||l==this.children.length-1)){t=h;for(let c=l+1;c<this.children.length;c++){let f=this.children[c];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=de(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=h}return{node:this.contentDOM,from:e,to:t,fromOffset:r,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:i}=this.domFromPos(e,0);if(t.nodeType!=1||i==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[i]}setSelection(e,t,i,r=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let d=0,p=0;d<this.children.length;d++){let m=this.children[d],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,i,r);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),h=i.root.getSelection(),c=i.domSelectionRange(),f=!1;if((qe||xe)&&e==t){let{node:d,offset:p}=l;if(d.nodeType==3){if(f=!!(p&&d.nodeValue[p-1]==`
|
|
7
|
+
`),f&&p==d.nodeValue.length)for(let m=d,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:de(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=d.childNodes[p-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(qe&&c.focusNode&&c.focusNode!=a.node&&c.focusNode.nodeType==1){let d=c.focusNode.childNodes[c.focusOffset];d&&d.contentEditable=="false"&&(r=!0)}if(!(r||f&&xe)&&An(l.node,l.offset,c.anchorNode,c.anchorOffset)&&An(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((h.extend||e==t)&&!(f&&qe)){h.collapse(l.node,l.offset);try{e!=t&&h.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let p=l;l=a,a=p}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),h.removeAllRanges(),h.addRange(d)}}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 i=0,r=0;r<this.children.length;r++){let s=this.children[r],o=i+s.size;if(i==o?e<=o&&t>=i:e<o&&t>i){let l=i+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==i||t==o?wn:Af,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=gt:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?wn:gt}i=o}this.dirty=wn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=e==1?wn:Af;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Xr=class extends Tn{constructor(e,t,i,r){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(i,()=>{if(!s)return r;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==je&&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}},dl=class extends Tn{constructor(e,t,i,r){super(e,[],t,null),this.textDOM=i,this.text=r}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}},li=class n extends Tn{constructor(e,t,i,r,s){super(e,[],i,r),this.mark=t,this.spec=s}static create(e,t,i,r){let s=r.nodeViews[t.type.name],o=s&&s(t,r,i);return(!o||!o.dom)&&(o=Et.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new n(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty>||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=gt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=je){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=je}}slice(e,t,i){let r=n.create(this.parent,this.mark,!0,i),s=this.children,o=this.size;t<o&&(s=yl(s,t,o,i)),e>0&&(s=yl(s,0,e,i));for(let l=0;l<s.length;l++)s[l].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Xt=class n extends Tn{constructor(e,t,i,r,s,o,l,a,h){super(e,[],s,o),this.node=t,this.outerDeco=i,this.innerDeco=r,this.nodeDOM=l}static create(e,t,i,r,s,o){let l=s.nodeViews[t.type.name],a,h=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},i,r),c=h&&h.dom,f=h&&h.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=Et.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return c=hu(c,i,t),h?a=new pl(e,t,i,r,c,f||null,u,h,s,o+1):t.isText?new Qr(e,t,i,r,c,u,s):new n(e,t,i,r,c,f||null,u,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 i=this.children[t];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,i){return this.dirty==je&&e.eq(this.node)&&es(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new gl(this,o&&o.node,e);py(this.node,this.innerDeco,(h,c,f)=>{h.spec.marks?a.syncToMarks(h.spec.marks,i,e,c):h.type.side>=0&&!f&&a.syncToMarks(c==this.node.childCount?j.none:this.node.child(c).marks,i,e,c),a.placeWidget(h,e,r)},(h,c,f,u)=>{a.syncToMarks(h.marks,i,e,u);let d;a.findNodeMatch(h,c,f,u)||l&&e.state.selection.from>r&&e.state.selection.to<r+h.nodeSize&&(d=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(h,c,f,d,e)||a.updateNextNode(h,c,f,e,u,r)||a.addNode(h,c,f,e,r),r+=h.nodeSize}),a.syncToMarks([],i,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==wn)&&(o&&this.protectLocalComposition(e,o),lu(this.contentDOM,this.children,e),oi&&my(this.dom))}localCompositionInfo(e,t){let{from:i,to:r}=e.state.selection;if(!(e.state.selection instanceof L)||i<t||r>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=gy(this.node.content,o,i-t,r-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:r}){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 dl(this,s,t,r);e.input.compositionNodes.push(o),this.children=yl(this.children,i,i+r.length,e,o)}update(e,t,i,r){return this.dirty==gt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,i,r),!0)}updateInner(e,t,i,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=je}updateOuterDeco(e){if(es(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=au(this.dom,this.nodeDOM,ml(this.outerDeco,this.node,t),ml(e,this.node,t)),this.dom!=i&&(i.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 Tf(n,e,t,i,r){hu(i,e,n);let s=new Xt(void 0,n,e,t,i,i,i,r,0);return s.contentDOM&&s.updateChildren(r,0),s}var Qr=class n extends Xt{constructor(e,t,i,r,s,o,l){super(e,t,i,r,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,i,r){return this.dirty==gt||this.dirty!=je&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=je||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=je,!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,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,i){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new n(this.parent,r,this.outerDeco,this.innerDeco,s,s,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=gt)}get domAtom(){return!1}isText(e){return this.node.text==e}},Zr=class extends Tn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==je&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},pl=class extends Xt{constructor(e,t,i,r,s,o,l,a,h,c){super(e,t,i,r,s,o,l,h,c),this.spec=a}update(e,t,i,r){if(this.dirty==gt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,i);return s&&this.updateInner(e,t,i,r),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,i,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,r){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,r)}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 lu(n,e,t){let i=n.firstChild,r=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=i;)i=Of(i),r=!0;i=i.nextSibling}else r=!0,n.insertBefore(l,i);if(o instanceof li){let a=i?i.previousSibling:n.lastChild;lu(o.contentDOM,o.children,t),i=a?a.nextSibling:n.firstChild}}for(;i;)i=Of(i),r=!0;r&&t.trackWrites==n&&(t.trackWrites=null)}var qi=function(n){n&&(this.nodeName=n)};qi.prototype=Object.create(null);var Sn=[new qi];function ml(n,e,t){if(n.length==0)return Sn;let i=t?Sn[0]:new qi,r=[i];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&r.push(i=new qi(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&r.length==1&&r.push(i=new qi(e.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+a:l=="style"?i.style=(i.style?i.style+";":"")+a:l!="nodeName"&&(i[l]=a))}}}return r}function au(n,e,t,i){if(t==Sn&&i==Sn)return e;let r=e;for(let s=0;s<i.length;s++){let o=i[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&r!=n&&(a=r.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(r),l=Sn[0]),r=a}fy(r,l||Sn[0],o)}return r}function fy(n,e,t){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in t)&&n.removeAttribute(i);for(let i in t)i!="class"&&i!="style"&&i!="nodeName"&&t[i]!=e[i]&&n.setAttribute(i,t[i]);if(e.class!=t.class){let i=e.class?e.class.split(" ").filter(Boolean):[],r=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.remove(i[s]);for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.add(r[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=i.exec(e.style);)n.style.removeProperty(r[1])}t.style&&(n.style.cssText+=t.style)}}function hu(n,e,t){return au(n,n,Sn,ml(e,t,n.nodeType!=1))}function es(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 Of(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var gl=class{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=uy(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i,r){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=je,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,h=this.top.children.length;r<this.preMatch.index&&(h=Math.min(this.index+3,h));for(let c=this.index;c<h;c++){let f=this.top.children[c];if(f.matchesMark(e[o])&&!this.isLocked(f.dom)){a=c;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let c=li.create(this.top,e[o],t,i);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,i,r){let s=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,i))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 h=this.top.children[l];if(h.matchesNode(e,t,i)&&!this.preMatch.matched.has(h)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,i,r,s){let o=this.top.children[r];return o.dirty==gt&&o.dom==o.contentDOM&&(o.dirty=wn),o.update(e,t,i,s)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let i=e.pmViewDesc;if(i){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==i)return r}return-1}e=t}}updateNextNode(e,t,i,r,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Xt){let h=this.preMatch.matched.get(a);if(h!=null&&h!=s)return!1;let c=a.dom,f,u=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=gt&&es(t,a.outerDeco));if(!u&&a.update(e,t,i,r))return this.destroyBetween(this.index,l),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!u&&(f=this.recreateWrapper(a,e,t,i,r,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=wn,f.updateChildren(r,o+1),f.dirty=je),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,r,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!es(i,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=Xt.create(this.top,t,i,r,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,i,r,s){let o=Xt.create(this.top,e,t,i,r,s);o.contentDOM&&o.updateChildren(r,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let s=new Xr(this.top,e,t,i);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 li;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Qr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((xe||pe)&&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 i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let r=new Zr(this.top,[],i,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function uy(n,e){let t=e,i=t.children.length,r=n.childCount,s=new Map,o=[];e:for(;r>0;){let l;for(;;)if(i){let h=t.children[i-1];if(h instanceof li)t=h,i=h.children.length;else{l=h,i--;break}}else{if(t==e)break e;i=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(r-1))break;--r,s.set(l,r),o.push(l)}}return{index:r,matched:s,matches:o.reverse()}}function dy(n,e){return n.type.side-e.type.side}function py(n,e,t,i){let r=e.locals(n),s=0;if(r.length==0){for(let h=0;h<n.childCount;h++){let c=n.child(h);i(c,r,e.forChild(s,c),h),s+=c.nodeSize}return}let o=0,l=[],a=null;for(let h=0;;){let c,f;for(;o<r.length&&r[o].to==s;){let g=r[o++];g.widget&&(c?(f||(f=[c])).push(g):c=g)}if(c)if(f){f.sort(dy);for(let g=0;g<f.length;g++)t(f[g],h,!!a)}else t(c,h,!!a);let u,d;if(a)d=-1,u=a,a=null;else if(h<n.childCount)d=h,u=n.child(h++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<r.length&&r[o].from<=s&&r[o].to>s;)l.push(r[o++]);let p=s+u.nodeSize;if(u.isText){let g=p;o<r.length&&r[o].from<g&&(g=r[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=u.cut(g-s),u=u.cut(0,g-s),p=g,d=-1)}else for(;o<r.length&&r[o].to<p;)o++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();i(u,m,e.forChild(s,u),d),s=p}}function my(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 gy(n,e,t,i){for(let r=0,s=0;r<n.childCount&&s<=i;){let o=n.child(r++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;r<n.childCount;){let h=n.child(r++);if(s+=h.nodeSize,!h.isText)break;a+=h.text}if(s>=t){if(s>=i&&a.slice(i-e.length-l,i-l)==e)return i-e.length;let h=l<i?a.lastIndexOf(e,i-l-1):-1;if(h>=0&&h+e.length+l>=t)return l+h;if(t==i&&a.length>=i+e.length-l&&a.slice(i-l,i-l+e.length)==e)return i}}return-1}function yl(n,e,t,i,r){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],h=l,c=l+=a.size;h>=t||c<=e?s.push(a):(h<e&&s.push(a.slice(0,e-h,i)),r&&(s.push(r),r=void 0),c>t&&s.push(a.slice(t-h,a.size,i)))}return s}function Ol(n,e=null){let t=n.domSelectionRange(),i=n.state.doc;if(!t.focusNode)return null;let r=n.docView.nearestDesc(t.focusNode),s=r&&r.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=i.resolve(o),a,h;if(as(t)){for(a=o;r&&!r.node;)r=r.parent;let f=r.node;if(r&&f.isAtom&&I.isSelectable(f)&&r.parent&&!(f.isInline&&j0(t.focusNode,t.focusOffset,r.dom))){let u=r.posBefore;h=new I(o==u?l:i.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=o,u=o;for(let d=0;d<t.rangeCount;d++){let p=t.getRangeAt(d);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,o]=u==n.state.selection.anchor?[u,f]:[f,u],l=i.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let c=i.resolve(a);if(!h){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;h=El(n,c,l,f)}return h}function cu(n){return n.editable?n.hasFocus():uu(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Lt(n,e=!1){let t=n.state.selection;if(fu(n,t),!!cu(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&pe){let i=n.domSelectionRange(),r=n.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&An(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)by(n);else{let{anchor:i,head:r}=t,s,o;Ef&&!(t instanceof L)&&(t.$from.parent.inlineContent||(s=Df(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Df(n,t.to))),n.docView.setSelection(i,r,n,e),Ef&&(s&&Nf(s),o&&Nf(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&yy(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}var Ef=xe||pe&&Zf<63;function Df(n,e){let{node:t,offset:i}=n.docView.domFromPos(e,0),r=i<t.childNodes.length?t.childNodes[i]:null,s=i?t.childNodes[i-1]:null;if(xe&&r&&r.contentEditable=="false")return sl(r);if((!r||r.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(r)return sl(r);if(s)return sl(s)}}function sl(n){return n.contentEditable="true",xe&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Nf(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function yy(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),i=t.anchorNode,r=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=i||t.anchorOffset!=r)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!cu(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function by(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,i=t.nodeName=="IMG";i?e.collapse(t.parentNode,de(t)+1):e.collapse(t,0),!i&&!n.state.selection.visible&&Ee&&Yt<=11&&(t.disabled=!0,t.disabled=!1)}function fu(n,e){if(e instanceof I){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Rf(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Rf(n)}function Rf(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function El(n,e,t,i){return n.someProp("createSelectionBetween",r=>r(n,e,t))||L.between(e,t,i)}function Pf(n){return n.editable&&!n.hasFocus()?!1:uu(n)}function uu(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 xy(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return An(e.node,e.offset,t.anchorNode,t.anchorOffset)}function bl(n,e){let{$anchor:t,$head:i}=n.selection,r=e>0?t.max(i):t.min(i),s=r.parent.inlineContent?r.depth?n.doc.resolve(e>0?r.after():r.before()):null:r;return s&&F.findFrom(s,e)}function Ut(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function If(n,e,t){let i=n.state.selection;if(i instanceof L)if(t.indexOf("s")>-1){let{$head:r}=i,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(r.pos+s.nodeSize*(e<0?-1:1));return Ut(n,new L(i.$anchor,o))}else if(i.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let r=bl(n.state,e);return r&&r instanceof I?Ut(n,r):!1}else if(!(_e&&t.indexOf("m")>-1)){let r=i.$head,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?r.pos-s.nodeSize:r.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?I.isSelectable(s)?Ut(n,new I(e<0?n.state.doc.resolve(r.pos-s.nodeSize):r)):Qi?Ut(n,new L(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(i instanceof I&&i.node.isInline)return Ut(n,new L(e>0?i.$to:i.$from));{let r=bl(n.state,e);return r?Ut(n,r):!1}}}function ts(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ji(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function ni(n,e){return e<0?ky(n):wy(n)}function ky(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let r,s,o=!1;for(qe&&t.nodeType==1&&i<ts(t)&&ji(t.childNodes[i],-1)&&(o=!0);;)if(i>0){if(t.nodeType!=1)break;{let l=t.childNodes[i-1];if(ji(l,-1))r=t,s=--i;else if(l.nodeType==3)t=l,i=t.nodeValue.length;else break}}else{if(du(t))break;{let l=t.previousSibling;for(;l&&ji(l,-1);)r=t.parentNode,s=de(l),l=l.previousSibling;if(l)t=l,i=ts(t);else{if(t=t.parentNode,t==n.dom)break;i=0}}}o?xl(n,t,i):r&&xl(n,r,s)}function wy(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let r=ts(t),s,o;for(;;)if(i<r){if(t.nodeType!=1)break;let l=t.childNodes[i];if(ji(l,1))s=t,o=++i;else break}else{if(du(t))break;{let l=t.nextSibling;for(;l&&ji(l,1);)s=l.parentNode,o=de(l)+1,l=l.nextSibling;if(l)t=l,i=0,r=ts(t);else{if(t=t.parentNode,t==n.dom)break;i=r=0}}}s&&xl(n,s,o)}function du(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Sy(n,e){for(;n&&e==n.childNodes.length&&!Xi(n);)e=de(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 vy(n,e){for(;n&&!e&&!Xi(n);)e=de(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 xl(n,e,t){if(e.nodeType!=3){let s,o;(o=Sy(e,t))?(e=o,t=0):(s=vy(e,t))&&(e=s,t=s.nodeValue.length)}let i=n.domSelection();if(!i)return;if(as(i)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),i.removeAllRanges(),i.addRange(s)}else i.extend&&i.extend(e,t);n.domObserver.setCurSelection();let{state:r}=n;setTimeout(()=>{n.state==r&&Lt(n)},50)}function Bf(n,e){let t=n.state.doc.resolve(e);if(!(pe||eu)&&t.parent.inlineContent){let r=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(s.left-r.left)>1)return s.left<r.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(s.left-r.left)>1)return s.left>r.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Lf(n,e,t){let i=n.state.selection;if(i instanceof L&&!i.empty||t.indexOf("s")>-1||_e&&t.indexOf("m")>-1)return!1;let{$from:r,$to:s}=i;if(!r.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=bl(n.state,e);if(o&&o instanceof I)return Ut(n,o)}if(!r.parent.inlineContent){let o=e<0?r:s,l=i instanceof Se?F.near(o,e):F.findFrom(o,e);return l?Ut(n,l):!1}return!1}function zf(n,e){if(!(n.state.selection instanceof L))return!0;let{$head:t,$anchor:i,empty:r}=n.state.selection;if(!t.sameParent(i))return!0;if(!r)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 Ff(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Cy(n){if(!xe||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;Ff(n,i,"true"),setTimeout(()=>Ff(n,i,"false"),20)}return!1}function My(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Ay(n,e){let t=e.keyCode,i=My(e);if(t==8||_e&&t==72&&i=="c")return zf(n,-1)||ni(n,-1);if(t==46&&!e.shiftKey||_e&&t==68&&i=="c")return zf(n,1)||ni(n,1);if(t==13||t==27)return!0;if(t==37||_e&&t==66&&i=="c"){let r=t==37?Bf(n,n.state.selection.from)=="ltr"?-1:1:-1;return If(n,r,i)||ni(n,r)}else if(t==39||_e&&t==70&&i=="c"){let r=t==39?Bf(n,n.state.selection.from)=="ltr"?1:-1:1;return If(n,r,i)||ni(n,r)}else{if(t==38||_e&&t==80&&i=="c")return Lf(n,-1,i)||ni(n,-1);if(t==40||_e&&t==78&&i=="c")return Cy(n)||Lf(n,1,i)||ni(n,1);if(i==(_e?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Dl(n,e){n.someProp("transformCopied",d=>{e=d(e,n)});let t=[],{content:i,openStart:r,openEnd:s}=e;for(;r>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1;){r--,s--;let d=i.firstChild;t.push(d.type.name,d.attrs!=d.type.defaultAttrs?d.attrs:null),i=d.content}let o=n.someProp("clipboardSerializer")||Et.fromSchema(n.state.schema),l=xu(),a=l.createElement("div");a.appendChild(o.serializeFragment(i,{document:l}));let h=a.firstChild,c,f=0;for(;h&&h.nodeType==1&&(c=bu[h.nodeName.toLowerCase()]);){for(let d=c.length-1;d>=0;d--){let p=l.createElement(c[d]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}h=a.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${r} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",d=>d(e,n))||e.content.textBetween(0,e.content.size,`
|
|
9
8
|
|
|
10
|
-
`);return{dom:a,text:u,slice:e}}function
|
|
11
|
-
`))),0,0),n.someProp("transformPasted",u=>{l=u(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",u=>u(e,r,i,n));if(f)l=f;else{let u=r.marks(),{schema:d}=n.state,p=Et.fromSchema(d);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(d.text(m,u)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),o=Vy(t),Qi&&Hy(o);let h=o&&o.querySelector("[data-pm-slice]"),c=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[3];f>0;f--){let u=o.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;o=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||pt.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:r,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!Ly.test(u.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Wy(tu(l,+c[1],+c[2]),c[4]);else if(l=O.maxOpen(zy(l.content,r),!0),l.openStart||l.openEnd){let f=0,u=0;for(let d=l.content.firstChild;f<l.openStart&&!d.type.spec.isolating;f++,d=d.firstChild);for(let d=l.content.lastChild;u<l.openEnd&&!d.type.spec.isolating;u++,d=d.lastChild);l=tu(l,f,u)}return n.someProp("transformPasted",f=>{l=f(l,n,a)}),l}var Ly=/^(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 zy(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=r.findWrapping(l.type),h;if(!a)return o=null;if(h=o.length&&s.length&&Ru(a,s,l,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=Pu(o[o.length-1],s.length));let c=Nu(l,a);o.push(c),r=r.matchType(c.type),s=a}}),o)return S.from(o)}return n}function Nu(n,e,t=0){for(let i=e.length-1;i>=t;i--)n=e[i].create(null,S.from(n));return n}function Ru(n,e,t,i,r){if(r<n.length&&r<e.length&&n[r]==e[r]){let s=Ru(n,e,t,i.lastChild,r+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(r==n.length-1?t.type:n[r+1]))return i.copy(i.content.append(S.from(Nu(t,n,r+1))))}}function Pu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Pu(n.lastChild,e-1)),i=n.contentMatchAt(n.childCount).fillBefore(S.empty,!0);return n.copy(t.append(i))}function Ll(n,e,t,i,r,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),r<i-1&&(l=Ll(l,e,t,i,r+1,s)),r>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=r).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function tu(n,e,t){return e<n.openStart&&(n=new O(Ll(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new O(Ll(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Bu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},nu=null;function Iu(){return nu||(nu=document.implementation.createHTMLDocument("title"))}var Sl=null;function Fy(n){let e=window.trustedTypes;return e?(Sl||(Sl=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Sl.createHTML(n)):n}function Vy(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Iu().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&Bu[i[1].toLowerCase()])&&(n=r.map(s=>"<"+s+">").join("")+n+r.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Fy(n),r)for(let s=0;s<r.length;s++)t=t.querySelector(r[s])||t;return t}function Hy(n){let e=n.querySelectorAll(pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent=="\xA0"&&i.parentNode&&i.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),i)}}function Wy(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return n}let{content:r,openStart:s,openEnd:o}=n;for(let l=i.length-2;l>=0;l-=2){let a=t.nodes[i[l]];if(!a||a.hasRequiredAttrs())break;r=S.from(a.create(i[l+1],r)),s++,o++}return new O(r,s,o)}var ve={},Ce={},$y={touchstart:!0,touchmove:!0},zl=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function qy(n){for(let e in ve){let t=ve[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=i=>{jy(n,i)&&!Jl(n,i)&&(n.editable||!(i.type in Ce))&&t(n,i)},$y[e]?{passive:!0}:void 0)}xe&&n.dom.addEventListener("input",()=>null),Fl(n)}function Gt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Ky(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 Fl(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=i=>Jl(n,i))})}function Jl(n,e){return n.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(n,e)||e.defaultPrevented:!1})}function jy(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 _y(n,e){!Jl(n,e)&&ve[e.type]&&(n.editable||!(e.type in Ce))&&ve[e.type](n,e)}Ce.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!zu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(It&&pe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),li&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();n.input.lastIOSEnter=i,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==i&&(n.someProp("handleKeyDown",r=>r(n,kn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",i=>i(n,t))||Iy(n,t)?t.preventDefault():Gt(n,"key")};Ce.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Ce.keypress=(n,e)=>{let t=e;if(zu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||qe&&t.metaKey)return;if(n.someProp("handleKeyPress",r=>r(n,t))){t.preventDefault();return}let i=n.state.selection;if(!(i instanceof L)||!i.$from.sameParent(i.$to)){let r=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(r).scrollIntoView();!/[\r\n]/.test(r)&&!n.someProp("handleTextInput",o=>o(n,i.$from.pos,i.$to.pos,r,s))&&n.dispatch(s()),t.preventDefault()}};function cs(n){return{left:n.clientX,top:n.clientY}}function Jy(n,e){let t=e.x-n.clientX,i=e.y-n.clientY;return t*t+i*i<100}function Ul(n,e,t,i,r){if(i==-1)return!1;let s=n.state.doc.resolve(i);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),r,!0):l(n,t,s.node(o),s.before(o),r,!1)))return!0;return!1}function si(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let i=n.state.tr.setSelection(e);t=="pointer"&&i.setMeta("pointer",!0),n.dispatch(i)}function Uy(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&B.isSelectable(i)?(si(n,new B(t),"pointer"),!0):!1}function Gy(n,e){if(e==-1)return!1;let t=n.state.selection,i,r;t instanceof B&&(i=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(B.isSelectable(l)){i&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?r=s.before(t.$from.depth):r=s.before(o);break}}return r!=null?(si(n,B.create(n.state.doc,r),"pointer"),!0):!1}function Yy(n,e,t,i,r){return Ul(n,"handleClickOn",e,t,i)||n.someProp("handleClick",s=>s(n,e,i))||(r?Gy(n,t):Uy(n,t))}function Xy(n,e,t,i){return Ul(n,"handleDoubleClickOn",e,t,i)||n.someProp("handleDoubleClick",r=>r(n,e,i))}function Qy(n,e,t,i){return Ul(n,"handleTripleClickOn",e,t,i)||n.someProp("handleTripleClick",r=>r(n,e,i))||Zy(n,t,i)}function Zy(n,e,t){if(t.button!=0)return!1;let i=n.state.doc;if(e==-1)return i.inlineContent?(si(n,L.create(i,0,i.content.size),"pointer"),!0):!1;let r=i.resolve(e);for(let s=r.depth+1;s>0;s--){let o=s>r.depth?r.nodeAfter:r.node(s),l=r.before(s);if(o.inlineContent)si(n,L.create(i,l+1,l+1+o.content.size),"pointer");else if(B.isSelectable(o))si(n,B.create(i,l),"pointer");else continue;return!0}}function Gl(n){return is(n)}var Lu=qe?"metaKey":"ctrlKey";ve.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let i=Gl(n),r=Date.now(),s="singleClick";r-n.input.lastClick.time<500&&Jy(t,n.input.lastClick)&&!t[Lu]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:s,button:t.button};let o=n.posAtCoords(cs(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Vl(n,o,t,!!i)):(s=="doubleClick"?Xy:Qy)(n,o.pos,o.inside,t)?t.preventDefault():Gt(n,"pointer"))};var Vl=class{constructor(e,t,i,r){this.view=e,this.pos=t,this.event=i,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[Lu],this.allowDefault=i.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let c=e.state.doc.resolve(t.pos);s=c.parent,o=c.depth?c.before():0}let l=r?null:i.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:h}=e.state;(i.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||h instanceof B&&h.from<=o&&h.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&je&&!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)),Gt(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(()=>Lt(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(cs(e))),this.updateAllowDefault(e),this.allowDefault||!t?Gt(this.view,"pointer"):Yy(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||xe&&this.mightDrag&&!this.mightDrag.node.isAtom||pe&&!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)?(si(this.view,F.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Gt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Gt(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(),Gl(n),Gt(n,"pointer")};ve.touchmove=n=>{n.input.lastTouch=Date.now(),Gt(n,"pointer")};ve.contextmenu=n=>Gl(n);function zu(n,e){return n.composing?!0:xe&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var eb=It?5e3:-1;Ce.compositionstart=Ce.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof L&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)||pe&&gu&&tb(n)))n.markCursor=n.state.storedMarks||t.marks(),is(n,!0),n.markCursor=null;else if(is(n,!e.selection.empty),je&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=n.domSelectionRange();for(let r=i.focusNode,s=i.focusOffset;r&&r.nodeType==1&&s!=0;){let o=s<0?r.lastChild:r.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else r=o,s=-1}}n.input.composing=!0}Fu(n,eb)};function tb(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let i=e.childNodes[t];return i.nodeType==1&&i.contentEditable=="false"}Ce.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.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Fu(n,20))};function Fu(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>is(n),e))}function Vu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ib());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function nb(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Z0(e.focusNode,e.focusOffset),i=ey(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let r=i.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||i==s)return s;if(!r||!r.isText(i.nodeValue))return i;if(n.input.compositionNode==i){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return i}}return t||i}function ib(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function is(n,e=!1){if(!(It&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Vu(n),e||n.docView&&n.docView.dirty){let t=Kl(n),i=n.state.selection;return t&&!t.eq(i)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function rb(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 i=getSelection(),r=document.createRange();r.selectNodeContents(e),n.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Ji=Ee&&Yt<15||li&&ry<604;ve.copy=Ce.cut=(n,e)=>{let t=e,i=n.state.selection,r=t.type=="cut";if(i.empty)return;let s=Ji?null:t.clipboardData,o=i.content(),{dom:l,text:a}=_l(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):rb(n,l),r&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function sb(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ob(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,i=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let r=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),i.parentNode&&i.parentNode.removeChild(i),t?Ui(n,i.value,null,r,e):Ui(n,i.textContent,i.innerHTML,r,e)},50)}function Ui(n,e,t,i,r){let s=Du(n,e,t,i,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,r,s||O.empty)))return!0;if(!s)return!1;let o=sb(s),l=o?n.state.tr.replaceSelectionWith(o,i):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Hu(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," "):""}Ce.paste=(n,e)=>{let t=e;if(n.composing&&!It)return;let i=Ji?null:t.clipboardData,r=n.input.shiftKey&&n.input.lastKeyCode!=45;i&&Ui(n,Hu(i),i.getData("text/html"),r,t)?t.preventDefault():ob(n,t)};var rs=class{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}},lb=qe?"altKey":"ctrlKey";function Wu(n,e){let t=n.someProp("dragCopies",i=>!i(e));return t??!e[lb]}ve.dragstart=(n,e)=>{let t=e,i=n.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let r=n.state.selection,s=r.empty?null:n.posAtCoords(cs(t)),o;if(!(s&&s.pos>=r.from&&s.pos<=(r instanceof B?r.to-1:r.to))){if(i&&i.mightDrag)o=B.create(n.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(o=B.create(n.state.doc,f.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:h,slice:c}=_l(n,l);(!t.dataTransfer.files.length||!pe||mu>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ji?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ji||t.dataTransfer.setData("text/plain",h),n.dragging=new rs(c,Wu(n,t),o)};ve.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Ce.dragover=Ce.dragenter=(n,e)=>e.preventDefault();Ce.drop=(n,e)=>{try{ab(n,e,n.dragging)}finally{n.dragging=null}};function ab(n,e,t){if(!e.dataTransfer)return;let i=n.posAtCoords(cs(e));if(!i)return;let r=n.state.doc.resolve(i.pos),s=t&&t.slice;s?n.someProp("transformPasted",d=>{s=d(s,n,!1)}):s=Du(n,Hu(e.dataTransfer),Ji?null:e.dataTransfer.getData("text/html"),!1,r);let o=!!(t&&Wu(n,e));if(n.someProp("handleDrop",d=>d(n,e,s||O.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?of(n.state.doc,r.pos,s):r.pos;l==null&&(l=r.pos);let a=n.state.tr;if(o){let{node:d}=t;d?d.replace(a):a.deleteSelection()}let h=a.mapping.map(l),c=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=a.doc;if(c?a.replaceRangeWith(h,h,s.content.firstChild):a.replaceRange(h,h,s),a.doc.eq(f))return;let u=a.doc.resolve(h);if(c&&B.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new B(u));else{let d=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>d=y),a.setSelection(jl(n,u,a.doc.resolve(d)))}n.focus(),n.dispatch(a.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())&&Lt(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(pe&&It&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:i}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=i||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,kn(8,"Backspace")))))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in Ce)ve[n]=Ce[n];function Gi(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}var ss=class n{constructor(e,t){this.toDOM=e,this.spec=t||Cn,this.side=this.spec.side||0}map(e,t,i,r){let{pos:s,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new yt(s-i,s-i,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Gi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},vn=class n{constructor(e,t){this.attrs=e,this.spec=t||Cn}map(e,t,i,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-i,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-i;return s>=o?null:new yt(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Gi(this.attrs,e.attrs)&&Gi(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Hl=class n{constructor(e,t){this.attrs=e,this.spec=t||Cn}map(e,t,i,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=s.pos?null:new yt(s.pos-i,o.pos-i,this)}valid(e,t){let{index:i,offset:r}=e.content.findIndex(t.from),s;return r==t.from&&!(s=e.child(i)).isText&&r+s.nodeSize==t.to}eq(e){return this==e||e instanceof n&&Gi(this.attrs,e.attrs)&&Gi(this.spec,e.spec)}destroy(){}},yt=class n{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new n(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,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new n(e,e,new ss(t,i))}static inline(e,t,i,r){return new n(e,t,new vn(i,r))}static node(e,t,i,r){return new n(e,t,new Hl(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof vn}get widget(){return this.type instanceof ss}},ri=[],Cn={},De=class n{constructor(e,t){this.local=e.length?e:ri,this.children=t.length?t:ri}static create(e,t){return t.length?as(t,e,0,Cn):be}find(e,t,i){let r=[];return this.findInner(e??0,t??1e9,r,0,i),r}findInner(e,t,i,r,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))&&i.push(l.copy(l.from+r,l.to+r))}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,i,r+l,s)}}map(e,t,i){return this==be||e.maps.length==0?this:this.mapInner(e,t,0,0,i||Cn)}mapInner(e,t,i,r,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,i,r);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?hb(this.children,o||[],e,t,i,r,s):o?new n(o.sort(Mn),ri):be}add(e,t){return t.length?this==be?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let r,s=0;e.forEach((l,a)=>{let h=a+i,c;if(c=qu(t,l,h)){for(r||(r=this.children.slice());s<r.length&&r[s]<a;)s+=3;r[s]==a?r[s+2]=r[s+2].addInner(l,c,h+1):r.splice(s,0,a,a+l.nodeSize,as(c,l,h+1,Cn)),s+=3}});let o=$u(s?Ku(t):t,-i);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new n(o.length?this.local.concat(o).sort(Mn):this.local,r||this.children)}remove(e){return e.length==0||this==be?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,r=this.local;for(let s=0;s<i.length;s+=3){let o,l=i[s]+t,a=i[s+1]+t;for(let c=0,f;c<e.length;c++)(f=e[c])&&f.from>l&&f.to<a&&(e[c]=null,(o||(o=[])).push(f));if(!o)continue;i==this.children&&(i=this.children.slice());let h=i[s+2].removeInner(o,l+1);h!=be?i[s+2]=h:(i.splice(s,3),s-=3)}if(r.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<r.length;l++)r[l].eq(o,t)&&(r==this.local&&(r=this.local.slice()),r.splice(l--,1))}return i==this.children&&r==this.local?this:r.length||i.length?new n(r,i):be}forChild(e,t){if(this==be)return this;if(t.isLeaf)return n.empty;let i,r;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=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 vn){let h=Math.max(s,a.from)-s,c=Math.min(o,a.to)-s;h<c&&(r||(r=[])).push(a.copy(h,c))}}if(r){let l=new n(r.sort(Mn),ri);return i?new ls([l,i]):l}return i||be}eq(e){if(this==e)return!0;if(!(e instanceof n)||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 Yl(this.localsInner(e))}localsInner(e){if(this==be)return ri;if(e.inlineContent||!this.local.some(vn.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof vn||t.push(this.local[i]);return t}forEachSet(e){e(this)}};De.empty=new De([],[]);De.removeOverlap=Yl;var be=De.empty,ls=class n{constructor(e){this.members=e}map(e,t){let i=this.members.map(r=>r.map(e,t,Cn));return n.from(i)}forChild(e,t){if(t.isLeaf)return De.empty;let i=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=be&&(s instanceof n?i=i.concat(s.members):i.push(s))}return n.from(i)}eq(e){if(!(e instanceof n)||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,i=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(!t)t=s;else{i&&(t=t.slice(),i=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Yl(i?t:t.sort(Mn)):ri}static from(e){switch(e.length){case 0:return be;case 1:return e[0];default:return new n(e.every(t=>t instanceof De)?e:e.reduce((t,i)=>t.concat(i instanceof De?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function hb(n,e,t,i,r,s,o){let l=n.slice();for(let h=0,c=s;h<t.maps.length;h++){let f=0;t.maps[h].forEach((u,d,p,m)=>{let g=m-p-(d-u);for(let y=0;y<l.length;y+=3){let b=l[y+1];if(b<0||u>b+c-f)continue;let x=l[y]+c-f;d>=x?l[y+1]=u<=x?-2:-1:u>=c&&g&&(l[y]+=g,l[y+1]+=g)}f+=g}),c=t.maps[h].map(c,-1)}let a=!1;for(let h=0;h<l.length;h+=3)if(l[h+1]<0){if(l[h+1]==-2){a=!0,l[h+1]=-1;continue}let c=t.map(n[h]+s),f=c-r;if(f<0||f>=i.content.size){a=!0;continue}let u=t.map(n[h+1]+s,-1),d=u-r,{index:p,offset:m}=i.content.findIndex(f),g=i.maybeChild(p);if(g&&m==f&&m+g.nodeSize==d){let y=l[h+2].mapInner(t,g,c+1,n[h]+s+1,o);y!=be?(l[h]=f,l[h+1]=d,l[h+2]=y):(l[h+1]=-2,a=!0)}else a=!0}if(a){let h=cb(l,n,e,t,r,s,o),c=as(h,i,0,o);e=c.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,u=0;f<c.children.length;f+=3){let d=c.children[f];for(;u<l.length&&l[u]<d;)u+=3;l.splice(u,0,c.children[f],c.children[f+1],c.children[f+2])}}return new De(e.sort(Mn),l)}function $u(n,e){if(!e||!n.length)return n;let t=[];for(let i=0;i<n.length;i++){let r=n[i];t.push(new yt(r.from+e,r.to+e,r.type))}return t}function cb(n,e,t,i,r,s,o){function l(a,h){for(let c=0;c<a.local.length;c++){let f=a.local[c].map(i,r,h);f?t.push(f):o.onRemove&&o.onRemove(a.local[c].spec)}for(let c=0;c<a.children.length;c+=3)l(a.children[c+2],a.children[c]+h+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 qu(n,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,r=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<i&&((r||(r=[])).push(o),n[s]=null);return r}function Ku(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function as(n,e,t,i){let r=[],s=!1;e.forEach((l,a)=>{let h=qu(n,l,a+t);if(h){s=!0;let c=as(h,l,t+a+1,i);c!=be&&r.push(a,a+l.nodeSize,c)}});let o=$u(s?Ku(n):n,-t).sort(Mn);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(i.onRemove&&i.onRemove(o[l].spec),o.splice(l--,1));return o.length||r.length?new De(o,r):be}function Mn(n,e){return n.from-e.from||n.to-e.to}function Yl(n){let e=n;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let r=t+1;r<e.length;r++){let s=e[r];if(s.from==i.from){s.to!=i.to&&(e==n&&(e=n.slice()),e[r]=s.copy(s.from,i.to),iu(e,r+1,s.copy(i.to,s.to)));continue}else{s.from<i.to&&(e==n&&(e=n.slice()),e[t]=i.copy(i.from,s.from),iu(e,r,i.copy(s.from,i.to)));break}}}return e}function iu(n,e,t){for(;e<n.length&&Mn(t,n[e])>0;)e++;n.splice(e,0,t)}function vl(n){let e=[];return n.someProp("decorations",t=>{let i=t(n.state);i&&i!=be&&e.push(i)}),n.cursorWrapper&&e.push(De.create(n.state.doc,[n.cursorWrapper.deco])),ls.from(e)}var fb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ub=Ee&&Yt<=11,Wl=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},$l=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Wl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let r=0;r<i.length;r++)this.queue.push(i[r]);Ee&&Yt<=11&&i.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():xe&&e.composing&&i.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ub&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,fb)),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(Gf(this.view)){if(this.suppressingSelectionUpdates)return Lt(this.view);if(Ee&&Yt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&An(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,i;for(let s=e.focusNode;s;s=oi(s))t.add(s);for(let s=e.anchorNode;s;s=oi(s))if(t.has(s)){i=s;break}let r=i&&this.view.docView.nearestDesc(i);if(r&&r.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))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 i=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&Gf(e)&&!this.ignoreSelectionChange(i),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let c=0;c<t.length;c++){let f=this.registerMutation(t[c],a);f&&(s=s<0?f.from:Math.min(f.from,s),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(a.some(c=>c.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let c of a)if(c.nodeName=="BR"&&c.parentNode){let f=c.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&c.parentNode.removeChild(c)}}else if(je&&a.length){let c=a.filter(f=>f.nodeName=="BR");if(c.length==2){let[f,u]=c;f.parentNode&&f.parentNode.parentNode==u.parentNode?u.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let u of c){let d=u.parentNode;d&&d.nodeName=="LI"&&(!f||mb(e,f)!=d)&&u.remove()}}}let h=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&hs(i)&&(h=Kl(e))&&h.eq(F.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Lt(e),this.currentSelection.set(i),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,o),db(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,gb(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||Lt(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;c<e.addedNodes.length;c++){let f=e.addedNodes[c];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let r=e.previousSibling,s=e.nextSibling;if(Ee&&Yt<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:f,nextSibling:u}=e.addedNodes[c];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(r=f),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u)}let o=r&&r.parentNode==e.target?de(r)+1:0,l=i.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?de(s):e.target.childNodes.length,h=i.localPosFromDOM(e.target,a,1);return{from:l,to:h}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},ru=new WeakMap,su=!1;function db(n){if(!ru.has(n)&&(ru.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=je,su)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."),su=!0}}function ou(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return An(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function pb(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return ou(n,r)}let t;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",i,!0),t?ou(n,t):null}function mb(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let i=n.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function gb(n,e){var t;let{focusNode:i,focusOffset:r}=n.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),i==s&&n.domSelection().collapse(s,r)}else s.parentNode.removeChild(s)}}function yb(n,e,t){let{node:i,fromOffset:r,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),h,c=a.anchorNode;if(c&&n.dom.contains(c.nodeType==1?c:c.parentNode)&&(h=[{node:c,offset:a.anchorOffset}],hs(a)||h.push({node:a.focusNode,offset:a.focusOffset})),pe&&n.input.lastKeyCode===8)for(let g=s;g>r;g--){let y=i.childNodes[g-1],b=y.pmViewDesc;if(y.nodeName=="BR"&&!b){s=g;break}if(!b||b.size)break}let f=n.state.doc,u=n.someProp("domParser")||pt.fromSchema(n.state.schema),d=f.resolve(o),p=null,m=u.parse(i,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:!0,from:r,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:bb,context:d});if(h&&h[0].pos!=null){let g=h[0].pos,y=h[1]&&h[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:l}}function bb(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(xe&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||xe&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var xb=/^(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 kb(n,e,t,i,r){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let k=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,D=Kl(n,k);if(D&&!n.state.selection.eq(D)){if(pe&&It&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",W=>W(n,kn(13,"Enter"))))return;let R=n.state.tr.setSelection(D);k=="pointer"?R.setMeta("pointer",!0):k=="key"&&R.scrollIntoView(),s&&R.setMeta("composition",s),n.dispatch(R)}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,h=yb(n,e,t),c=n.state.doc,f=c.slice(h.from,h.to),u,d;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,d="end"):(u=n.state.selection.from,d="start"),n.input.lastKeyCode=null;let p=vb(f.content,h.doc.content,h.from,u,d);if(p&&n.input.domChangeCount++,(li&&n.input.lastIOSEnter>Date.now()-225||It)&&r.some(k=>k.nodeType==1&&!xb.test(k.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",k=>k(n,kn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(i&&a instanceof L&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(h.sel){let k=lu(n,n.state.doc,h.sel);if(k&&!k.eq(n.state.selection)){let D=n.state.tr.setSelection(k);s&&D.setMeta("composition",s),n.dispatch(D)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof L&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=h.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=h.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Ee&&Yt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>h.from&&h.doc.textBetween(p.start-h.from-1,p.start-h.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=h.doc.resolveNoCache(p.start-h.from),g=h.doc.resolveNoCache(p.endB-h.from),y=c.resolve(p.start),b=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((li&&n.input.lastIOSEnter>Date.now()-225&&(!b||r.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!b&&m.pos<h.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(h.doc.textBetween(m.pos,g.pos,"","")))&&n.someProp("handleKeyDown",k=>k(n,kn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Sb(c,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",k=>k(n,kn(8,"Backspace")))){It&&pe&&n.domObserver.suppressSelectionUpdates();return}pe&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),It&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==p.endA&&(p.endB-=2,g=h.doc.resolveNoCache(p.endB-h.from),setTimeout(()=>{n.someProp("handleKeyDown",function(k){return k(n,kn(13,"Enter"))})},20));let x=p.start,C=p.endA,w=k=>{let D=k||n.state.tr.replace(x,C,h.doc.slice(p.start-h.from,p.endB-h.from));if(h.sel){let R=lu(n,D.doc,h.sel);R&&!(pe&&n.composing&&R.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(R.head==x||R.head==D.mapping.map(C)-1)||Ee&&R.empty&&R.head==x)&&D.setSelection(R)}return s&&D.setMeta("composition",s),D.scrollIntoView()},T;if(b)if(m.pos==g.pos){Ee&&Yt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Lt(n),20));let k=w(n.state.tr.delete(x,C)),D=c.resolve(p.start).marksAcross(c.resolve(p.endA));D&&k.ensureMarks(D),n.dispatch(k)}else if(p.endA==p.endB&&(T=wb(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let k=w(n.state.tr);T.type=="add"?k.addMark(x,C,T.mark):k.removeMark(x,C,T.mark),n.dispatch(k)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let k=m.parent.textBetween(m.parentOffset,g.parentOffset),D=()=>w(n.state.tr.insertText(k,x,C));n.someProp("handleTextInput",R=>R(n,x,C,k,D))||n.dispatch(D())}else n.dispatch(w());else n.dispatch(w())}function lu(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:jl(n,e.resolve(t.anchor),e.resolve(t.head))}function wb(n,e){let t=n.firstChild.marks,i=e.firstChild.marks,r=t,s=i,o,l,a;for(let c=0;c<i.length;c++)r=i[c].removeFromSet(r);for(let c=0;c<t.length;c++)s=t[c].removeFromSet(s);if(r.length==1&&s.length==0)l=r[0],o="add",a=c=>c.mark(l.addToSet(c.marks));else if(r.length==0&&s.length==1)l=s[0],o="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let h=[];for(let c=0;c<e.childCount;c++)h.push(a(e.child(c)));if(S.from(h).eq(n))return{mark:l,type:o}}function Sb(n,e,t,i,r){if(t-e<=r.pos-i.pos||Cl(i,!0,!1)<r.pos)return!1;let s=n.resolve(e);if(!i.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(Cl(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Cl(o,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(o.parent.content)}function Cl(n,e,t){let i=n.depth,r=e?n.end():n.pos;for(;i>0&&(e||n.indexAfter(i)==n.node(i).childCount);)i--,r++,e=!1;if(t){let s=n.node(i).maybeChild(n.indexAfter(i));for(;s&&!s.isLeaf;)s=s.firstChild,r++}return r}function vb(n,e,t,i,r){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(r=="end"){let a=Math.max(0,s-Math.min(o,l));i-=o+a-s}if(o<s&&n.size<e.size){let a=i<=s&&i>=o?s-i:0;s-=a,s&&s<e.size&&au(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=i<=s&&i>=l?s-i:0;s-=a,s&&s<n.size&&au(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function au(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}var Yi=class{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 zl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(du),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=fu(this),cu(this),this.nodeViews=uu(this),this.docView=qf(this.state.doc,hu(this),vl(this),this.dom,this),this.domObserver=new $l(this,(i,r,s,o)=>kb(this,i,r,s,o)),this.domObserver.start(),qy(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&&Fl(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(du),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let r=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Vu(this),o=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let d=uu(this);Mb(d,this.nodeViews)&&(this.nodeViews=d,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Fl(this),this.editable=fu(this),cu(this);let a=vl(this),h=hu(this),c=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,h,a);(f||!e.selection.eq(r.selection))&&(o=!0);let u=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&ly(this);if(o){this.domObserver.stop();let d=f&&(Ee||pe)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&Cb(r.selection,e.selection);if(f){let p=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=nb(this)),(s||!this.docView.update(e.doc,h,a,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=qf(e.doc,h,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(d=!0)}d||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Oy(this))?Lt(this,d):(Tu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((i=this.dragging)===null||i===void 0)&&i.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():u&&ay(u)}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 B){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&zf(this,t.getBoundingClientRect(),e)}else zf(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 i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,r=-1;if(this.state.doc.nodeAt(i.from)==i.node)r=i.from;else{let s=i.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==i.node&&(r=s)}this.dragging=new rs(e.slice,e.move,r<0?void 0:B.create(this.state.doc,r))}someProp(e,t){let i=this._props&&this._props[e],r;if(i!=null&&(r=t?t(i):i))return r;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(r=t?t(l):l))return r}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(r=t?t(l):l))return r}}hasFocus(){if(Ee){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&&hy(this.dom),Lt(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 py(this,e)}coordsAtPos(e,t=1){return wu(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,i=-1){let r=this.docView.posFromDOM(e,t,i);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return xy(this,t||this.state,e)}pasteHTML(e,t){return Ui(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ui(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return _l(this,e)}destroy(){this.docView&&(Ky(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],vl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,X0())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return _y(this,e)}domSelectionRange(){let e=this.domSelection();return e?xe&&this.root.nodeType===11&&ny(this.dom.ownerDocument)==this.dom&&pb(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Yi.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function hu(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 i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[yt.node(0,n.state.doc.content.size,e)]}function cu(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:yt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function fu(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Cb(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 uu(n){let e=Object.create(null);function t(i){for(let r in i)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=i[r])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Mb(n,e){let t=0,i=0;for(let r in n){if(n[r]!=e[r])return!0;t++}for(let r in e)i++;return t!=i}function du(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var nt={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:"'"},hi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ab=typeof navigator<"u"&&/Mac/.test(navigator.platform),Tb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(oe=0;oe<10;oe++)nt[48+oe]=nt[96+oe]=String(oe);var oe;for(oe=1;oe<=24;oe++)nt[oe+111]="F"+oe;var oe;for(oe=65;oe<=90;oe++)nt[oe]=String.fromCharCode(oe+32),hi[oe]=String.fromCharCode(oe);var oe;for(fs in nt)hi.hasOwnProperty(fs)||(hi[fs]=nt[fs]);var fs;function us(n){var e=Ab&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Tb&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?hi:nt)[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}var Ob=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Eb=typeof navigator<"u"&&/Win/.test(navigator.platform);function Db(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let i,r,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))i=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Ob?o=!0:r=!0;else throw new Error("Unrecognized modifier name: "+a)}return i&&(t="Alt-"+t),r&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Nb(n){let e=Object.create(null);for(let t in n)e[Db(t)]=n[t];return e}function Xl(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 ju(n){return new J({props:{handleKeyDown:Rb(n)}})}function Rb(n){let e=Nb(n);return function(t,i){let r=us(i),s,o=e[Xl(r,i)];if(o&&o(t.state,t.dispatch,t))return!0;if(r.length==1&&r!=" "){if(i.shiftKey){let l=e[Xl(r,i,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((i.altKey||i.metaKey||i.ctrlKey)&&!(Eb&&i.ctrlKey&&i.altKey)&&(s=nt[i.keyCode])&&s!=r){let l=e[Xl(s,i)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Pb=Object.defineProperty,ia=(n,e)=>{for(var t in e)Pb(n,t,{get:e[t],enumerable:!0})};function ws(n){let{state:e,transaction:t}=n,{selection:i}=t,{doc:r}=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 i},get doc(){return r},get tr(){return i=t.selection,r=t.doc,s=t.storedMarks,t}}}var Ss=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(){let{rawCommands:n,editor:e,state:t}=this,{view:i}=e,{tr:r}=t,s=this.buildProps(r);return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...h)=>{let c=l(...h)(s);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(r),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){let{rawCommands:t,editor:i,state:r}=this,{view:s}=i,o=[],l=!!n,a=n||r.tr,h=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(f=>f===!0)),c={...Object.fromEntries(Object.entries(t).map(([f,u])=>[f,(...p)=>{let m=this.buildProps(a,e),g=u(...p)(m);return o.push(g),c}])),run:h};return c}createCan(n){let{rawCommands:e,state:t}=this,i=!1,r=n||t.tr,s=this.buildProps(r,i);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...h)=>a(...h)({...s,dispatch:void 0})])),chain:()=>this.createChain(r,i)}}buildProps(n,e=!0){let{rawCommands:t,editor:i,state:r}=this,{view:s}=i,o={tr:n,editor:i,view:s,state:ws({state:r,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,(...h)=>a(...h)(o)]))}};return o}},td={};ia(td,{blur:()=>Bb,clearContent:()=>Ib,clearNodes:()=>Lb,command:()=>zb,createParagraphNear:()=>Fb,cut:()=>Vb,deleteCurrentNode:()=>Hb,deleteNode:()=>Wb,deleteRange:()=>$b,deleteSelection:()=>qb,enter:()=>Kb,exitCode:()=>jb,extendMarkRange:()=>_b,first:()=>Jb,focus:()=>Gb,forEach:()=>Yb,insertContent:()=>Xb,insertContentAt:()=>ex,joinBackward:()=>ix,joinDown:()=>nx,joinForward:()=>rx,joinItemBackward:()=>sx,joinItemForward:()=>ox,joinTextblockBackward:()=>lx,joinTextblockForward:()=>ax,joinUp:()=>tx,keyboardShortcut:()=>cx,lift:()=>fx,liftEmptyBlock:()=>ux,liftListItem:()=>dx,newlineInCode:()=>px,resetAttributes:()=>mx,scrollIntoView:()=>gx,selectAll:()=>yx,selectNodeBackward:()=>bx,selectNodeForward:()=>xx,selectParentNode:()=>kx,selectTextblockEnd:()=>wx,selectTextblockStart:()=>Sx,setContent:()=>vx,setMark:()=>Kx,setMeta:()=>jx,setNode:()=>_x,setNodeSelection:()=>Jx,setTextDirection:()=>Ux,setTextSelection:()=>Gx,sinkListItem:()=>Yx,splitBlock:()=>Xx,splitListItem:()=>Qx,toggleList:()=>e1,toggleMark:()=>t1,toggleNode:()=>n1,toggleWrap:()=>i1,undoInputRule:()=>r1,unsetAllMarks:()=>s1,unsetMark:()=>o1,unsetTextDirection:()=>l1,updateAttributes:()=>a1,wrapIn:()=>h1,wrapInList:()=>c1});var Bb=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),Ib=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),Lb=()=>({state:n,tr:e,dispatch:t})=>{let{selection:i}=e,{ranges:r}=i;return t&&r.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;let{doc:h,mapping:c}=e,f=h.resolve(c.map(a)),u=h.resolve(c.map(a+l.nodeSize)),d=f.blockRange(u);if(!d)return;let p=Rt(d);if(l.type.isTextblock){let{defaultType:m}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(d.start,m)}(p||p===0)&&e.lift(d,p)})}),!0},zb=n=>e=>n(e),Fb=()=>({state:n,dispatch:e})=>pl(n,e),Vb=(n,e)=>({editor:t,tr:i})=>{let{state:r}=t,s=r.doc.slice(n.from,n.to);i.deleteRange(n.from,n.to);let o=i.mapping.map(e);return i.insert(o,s.content),i.setSelection(new L(i.doc.resolve(Math.max(o-1,0)))),!0},Hb=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,i=t.$anchor.node();if(i.content.size>0)return!1;let r=n.selection.$anchor;for(let s=r.depth;s>0;s-=1)if(r.node(s).type===i.type){if(e){let l=r.before(s),a=r.after(s);n.delete(l,a).scrollIntoView()}return!0}return!1};function he(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}var Wb=n=>({tr:e,state:t,dispatch:i})=>{let r=he(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r){if(i){let a=s.before(o),h=s.after(o);e.delete(a,h).scrollIntoView()}return!0}return!1},$b=n=>({tr:e,dispatch:t})=>{let{from:i,to:r}=n;return t&&e.delete(i,r),!0},qb=()=>({state:n,dispatch:e})=>Xr(n,e),Kb=()=>({commands:n})=>n.keyboardShortcut("Enter"),jb=()=>({state:n,dispatch:e})=>dl(n,e);function ra(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function bs(n,e,t={strict:!0}){let i=Object.keys(e);return i.length?i.every(r=>t.strict?e[r]===n[r]:ra(e[r])?e[r].test(n[r]):e[r]===n[r]):!0}function nd(n,e,t={}){return n.find(i=>i.type===e&&bs(Object.fromEntries(Object.keys(t).map(r=>[r,i.attrs[r]])),t))}function _u(n,e,t={}){return!!nd(n,e,t)}function sa(n,e,t){if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(h=>h.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(h=>h.type===e))return;if(!t){let h=i.node.marks.find(c=>c.type===e);h&&(t=h.attrs)}if(!nd([...i.node.marks],e,t))return;let s=i.index,o=n.start()+i.offset,l=s+1,a=o+i.node.nodeSize;for(;s>0&&_u([...n.parent.child(s-1).marks],e,t);)s-=1,o-=n.parent.child(s).nodeSize;for(;l<n.parent.childCount&&_u([...n.parent.child(l).marks],e,t);)a+=n.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Ft(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}var _b=(n,e)=>({tr:t,state:i,dispatch:r})=>{let s=Ft(n,i.schema),{doc:o,selection:l}=t,{$from:a,from:h,to:c}=l;if(r){let f=sa(a,s,e);if(f&&f.from<=h&&f.to>=c){let u=L.create(o,f.from,f.to);t.setSelection(u)}}return!0},Jb=n=>e=>{let t=typeof n=="function"?n(e):n;for(let i=0;i<t.length;i+=1)if(t[i](e))return!0;return!1};function id(n){return n instanceof L}function zt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function rd(n,e=null){if(!e)return null;let t=F.atStart(n),i=F.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return i;let r=t.from,s=i.to;return e==="all"?L.create(n,zt(0,r,s),zt(n.content.size,r,s)):L.create(n,zt(e,r,s),zt(e,r,s))}function Ju(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function xs(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Ub(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Gb=(n=null,e={})=>({editor:t,view:i,tr:r,dispatch:s})=>{e={scrollIntoView:!0,...e};let o=()=>{(xs()||Ju())&&i.dom.focus(),Ub()&&!xs()&&!Ju()&&i.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(i.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};try{if(i.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(s&&n===null&&!id(t.state.selection))return o(),!0;let l=rd(r.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||r.setSelection(l),a&&r.storedMarks&&r.setStoredMarks(r.storedMarks),o()),!0},Yb=(n,e)=>t=>n.every((i,r)=>e(i,{...t,index:r})),Xb=(n,e)=>({tr:t,commands:i})=>i.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),sd=n=>{let e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){let i=e[t];i.nodeType===3&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)?n.removeChild(i):i.nodeType===1&&sd(i)}return n};function ds(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return sd(t)}function nr(n,e,t){if(n instanceof Oe||n instanceof S)return n;t={slice:!0,parseOptions:{},...t};let i=typeof n=="object"&&n!==null,r=typeof n=="string";if(i)try{if(Array.isArray(n)&&n.length>0)return S.fromArray(n.map(l=>e.nodeFromJSON(l)));let 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),nr("",e,t)}if(r){if(t.errorOnInvalidContent){let o=!1,l="",a=new Gn({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:h=>(o=!0,l=typeof h=="string"?h:h.outerHTML,null)}]}})});if(t.slice?pt.fromSchema(a).parseSlice(ds(n),t.parseOptions):pt.fromSchema(a).parse(ds(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let s=pt.fromSchema(e);return t.slice?s.parseSlice(ds(n),t.parseOptions).content:s.parse(ds(n),t.parseOptions)}return nr("",e,t)}function Qb(n,e,t){let i=n.steps.length-1;if(i<e)return;let r=n.steps[i];if(!(r instanceof ye||r instanceof se))return;let s=n.mapping.maps[i],o=0;s.forEach((l,a,h,c)=>{o===0&&(o=c)}),n.setSelection(F.near(n.doc.resolve(o),t))}var Zb=n=>!("type"in n),ex=(n,e,t)=>({tr:i,dispatch:r,editor:s})=>{var o;if(r){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l,a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{nr(e,s.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=nr(e,s.schema,{parseOptions:h,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:c,to:f}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},u=!0,d=!0;if((Zb(l)?l:[l]).forEach(g=>{g.check(),u=u?g.isText&&g.marks.length===0:!1,d=d?g.isBlock:!1}),c===f&&d){let{parent:g}=i.doc.resolve(c);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(c-=1,f+=1)}let m;if(u){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof S){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;i.insertText(m,c,f)}else{m=l;let g=i.doc.resolve(c),y=g.node(),b=g.parentOffset===0,x=y.isText||y.isTextblock,C=y.content.size>0;b&&x&&C&&d&&(c=Math.max(0,c-1)),i.replaceWith(c,f,m)}t.updateSelection&&Qb(i,i.steps.length-1,-1),t.applyInputRules&&i.setMeta("applyInputRules",{from:c,text:m}),t.applyPasteRules&&i.setMeta("applyPasteRules",{from:c,text:m})}return!0},tx=()=>({state:n,dispatch:e})=>Mf(n,e),nx=()=>({state:n,dispatch:e})=>Af(n,e),ix=()=>({state:n,dispatch:e})=>sl(n,e),rx=()=>({state:n,dispatch:e})=>al(n,e),sx=()=>({state:n,dispatch:e,tr:t})=>{try{let i=bn(n.doc,n.selection.$from.pos,-1);return i==null?!1:(t.join(i,2),e&&e(t),!0)}catch{return!1}},ox=()=>({state:n,dispatch:e,tr:t})=>{try{let i=bn(n.doc,n.selection.$from.pos,1);return i==null?!1:(t.join(i,2),e&&e(t),!0)}catch{return!1}},lx=()=>({state:n,dispatch:e})=>wf(n,e),ax=()=>({state:n,dispatch:e})=>Sf(n,e);function od(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function hx(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t==="Space"&&(t=" ");let i,r,s,o;for(let l=0;l<e.length-1;l+=1){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))xs()||od()?o=!0:r=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return i&&(t=`Alt-${t}`),r&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var cx=n=>({editor:e,view:t,tr:i,dispatch:r})=>{let s=hx(n).split(/-(?!$)/),o=s.find(h=>!["Alt","Ctrl","Meta","Shift"].includes(h)),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",h=>h(t,l))});return a?.steps.forEach(h=>{let c=h.map(i.mapping);c&&r&&i.maybeStep(c)}),!0};function ir(n,e,t={}){let{from:i,to:r,empty:s}=n.selection,o=e?he(e,n.schema):null,l=[];n.doc.nodesBetween(i,r,(f,u)=>{if(f.isText)return;let d=Math.max(i,u),p=Math.min(r,u+f.nodeSize);l.push({node:f,from:d,to:p})});let a=r-i,h=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>bs(f.node.attrs,t,{strict:!1}));return s?!!h.length:h.reduce((f,u)=>f+u.to-u.from,0)>=a}var fx=(n,e={})=>({state:t,dispatch:i})=>{let r=he(n,t.schema);return ir(t,r,e)?Tf(t,i):!1},ux=()=>({state:n,dispatch:e})=>ml(n,e),dx=n=>({state:e,dispatch:t})=>{let i=he(n,e.schema);return Pf(i)(e,t)},px=()=>({state:n,dispatch:e})=>fl(n,e);function vs(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Uu(n,e){let t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((i,r)=>(t.includes(r)||(i[r]=n[r]),i),{})}var mx=(n,e)=>({tr:t,state:i,dispatch:r})=>{let s=null,o=null,l=vs(typeof n=="string"?n:n.name,i.schema);if(!l)return!1;l==="node"&&(s=he(n,i.schema)),l==="mark"&&(o=Ft(n,i.schema));let a=!1;return t.selection.ranges.forEach(h=>{i.doc.nodesBetween(h.$from.pos,h.$to.pos,(c,f)=>{s&&s===c.type&&(a=!0,r&&t.setNodeMarkup(f,void 0,Uu(c.attrs,e))),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&(a=!0,r&&t.addMark(f,f+c.nodeSize,o.create(Uu(u.attrs,e))))})})}),a},gx=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),yx=()=>({tr:n,dispatch:e})=>{if(e){let t=new Se(n.doc);n.setSelection(t)}return!0},bx=()=>({state:n,dispatch:e})=>ol(n,e),xx=()=>({state:n,dispatch:e})=>hl(n,e),kx=()=>({state:n,dispatch:e})=>Of(n,e),wx=()=>({state:n,dispatch:e})=>yl(n,e),Sx=()=>({state:n,dispatch:e})=>gl(n,e);function ta(n,e,t={},i={}){return nr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:i.errorOnInvalidContent})}var vx=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:i={}}={})=>({editor:r,tr:s,dispatch:o,commands:l})=>{let{doc:a}=s;if(i.preserveWhitespace!=="full"){let h=ta(n,r.schema,i,{errorOnInvalidContent:e??r.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,h).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:i,errorOnInvalidContent:e??r.options.enableContentCheck})};function ld(n,e){let t=Ft(e,n.schema),{from:i,to:r,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(i,r,a=>{o.push(...a.marks)});let l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Cx(n,e){let t=new Qn(n);return e.forEach(i=>{i.steps.forEach(r=>{t.step(r)})}),t}function Mx(n){for(let e=0;e<n.edgeCount;e+=1){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function sM(n,e){let t=[];return n.descendants((i,r)=>{e(i)&&t.push({node:i,pos:r})}),t}function oM(n,e,t){let i=[];return n.nodesBetween(e.from,e.to,(r,s)=>{t(r)&&i.push({node:r,pos:s})}),i}function Ax(n,e){for(let t=n.depth;t>0;t-=1){let i=n.node(t);if(e(i))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:i}}}function Cs(n){return e=>Ax(e.$from,n)}function P(n,e,t){return n.config[e]===void 0&&n.parent?P(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?P(n.parent,e,t):null}):n.config[e]}function oa(n){return n.map(e=>{let t={name:e.name,options:e.options,storage:e.storage},i=P(e,"addExtensions",t);return i?[e,...oa(i())]:e}).flat(10)}function la(n,e){let t=Et.fromSchema(e).serializeFragment(n),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(t),r.innerHTML}function ad(n){return typeof n=="function"}function U(n,e=void 0,...t){return ad(n)?e?n.bind(e)(...t):n(...t):n}function Tx(n={}){return Object.keys(n).length===0&&n.constructor===Object}function ci(n){let e=n.filter(r=>r.type==="extension"),t=n.filter(r=>r.type==="node"),i=n.filter(r=>r.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:i}}function hd(n){let e=[],{nodeExtensions:t,markExtensions:i}=ci(n),r=[...t,...i],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=t.filter(h=>h.name!=="text").map(h=>h.name),l=i.map(h=>h.name),a=[...o,...l];return n.forEach(h=>{let c={name:h.name,options:h.options,storage:h.storage,extensions:r},f=P(h,"addGlobalAttributes",c);if(!f)return;f().forEach(d=>{let p;Array.isArray(d.types)?p=d.types:d.types==="*"?p=a:d.types==="nodes"?p=o:d.types==="marks"?p=l:p=[],p.forEach(m=>{Object.entries(d.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...s,...y}})})})})}),r.forEach(h=>{let c={name:h.name,options:h.options,storage:h.storage},f=P(h,"addAttributes",c);if(!f)return;let u=f();Object.entries(u).forEach(([d,p])=>{let m={...s,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:h.name,name:d,attribute:m})})}),e}function Ox(n){let e=[],t="",i=!1,r=!1,s=0,o=n.length;for(let l=0;l<o;l+=1){let a=n[l];if(a==="'"&&!r){i=!i,t+=a;continue}if(a==='"'&&!i){r=!r,t+=a;continue}if(!i&&!r){if(a==="("){s+=1,t+=a;continue}if(a===")"&&s>0){s-=1,t+=a;continue}if(a===";"&&s===0){e.push(t),t="";continue}}t+=a}return t&&e.push(t),e}function Gu(n){let e=[],t=Ox(n||""),i=t.length;for(let r=0;r<i;r+=1){let s=t[r],o=s.indexOf(":");if(o===-1)continue;let l=s.slice(0,o).trim(),a=s.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function Ex(...n){return n.filter(e=>!!e).reduce((e,t)=>{let i={...e};return Object.entries(t).forEach(([r,s])=>{if(!i[r]){i[r]=s;return}if(r==="class"){let l=s?String(s).split(" "):[],a=i[r]?i[r].split(" "):[],h=l.filter(c=>!a.includes(c));i[r]=[...a,...h].join(" ")}else if(r==="style"){let l=new Map([...Gu(i[r]),...Gu(s)]);i[r]=Array.from(l.entries()).map(([a,h])=>`${a}: ${h}`).join("; ")}else i[r]=s}),i},{})}function ks(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,i)=>Ex(t,i),{})}function Dx(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Yu(n,e){return"style"in n?n:{...n,getAttrs:t=>{let i=n.getAttrs?n.getAttrs(t):n.attrs;if(i===!1)return!1;let r=e.reduce((s,o)=>{let l=o.attribute.parseHTML?o.attribute.parseHTML(t):Dx(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...i,...r}}}}function Xu(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Tx(t)?!1:t!=null))}function Qu(n){var e,t;let i={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(i.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(i.validate=n.attribute.validate),[n.name,i]}function Nx(n,e){var t;let i=hd(n),{nodeExtensions:r,markExtensions:s}=ci(n),o=(t=r.find(h=>P(h,"topNode")))==null?void 0:t.name,l=Object.fromEntries(r.map(h=>{let c=i.filter(y=>y.type===h.name),f={name:h.name,options:h.options,storage:h.storage,editor:e},u=n.reduce((y,b)=>{let x=P(b,"extendNodeSchema",f);return{...y,...x?x(h):{}}},{}),d=Xu({...u,content:U(P(h,"content",f)),marks:U(P(h,"marks",f)),group:U(P(h,"group",f)),inline:U(P(h,"inline",f)),atom:U(P(h,"atom",f)),selectable:U(P(h,"selectable",f)),draggable:U(P(h,"draggable",f)),code:U(P(h,"code",f)),whitespace:U(P(h,"whitespace",f)),linebreakReplacement:U(P(h,"linebreakReplacement",f)),defining:U(P(h,"defining",f)),isolating:U(P(h,"isolating",f)),attrs:Object.fromEntries(c.map(Qu))}),p=U(P(h,"parseHTML",f));p&&(d.parseDOM=p.map(y=>Yu(y,c)));let m=P(h,"renderHTML",f);m&&(d.toDOM=y=>m({node:y,HTMLAttributes:ks(y,c)}));let g=P(h,"renderText",f);return g&&(d.toText=g),[h.name,d]})),a=Object.fromEntries(s.map(h=>{let c=i.filter(g=>g.type===h.name),f={name:h.name,options:h.options,storage:h.storage,editor:e},u=n.reduce((g,y)=>{let b=P(y,"extendMarkSchema",f);return{...g,...b?b(h):{}}},{}),d=Xu({...u,inclusive:U(P(h,"inclusive",f)),excludes:U(P(h,"excludes",f)),group:U(P(h,"group",f)),spanning:U(P(h,"spanning",f)),code:U(P(h,"code",f)),attrs:Object.fromEntries(c.map(Qu))}),p=U(P(h,"parseHTML",f));p&&(d.parseDOM=p.map(g=>Yu(g,c)));let m=P(h,"renderHTML",f);return m&&(d.toDOM=g=>m({mark:g,HTMLAttributes:ks(g,c)})),[h.name,d]}));return new Gn({topNode:o,nodes:l,marks:a})}function Rx(n){let e=n.filter((t,i)=>n.indexOf(t)!==i);return Array.from(new Set(e))}function tr(n){return n.sort((t,i)=>{let r=P(t,"priority")||100,s=P(i,"priority")||100;return r>s?-1:r<s?1:0})}function cd(n){let e=tr(oa(n)),t=Rx(e.map(i=>i.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),e}function fd(n,e,t){let{from:i,to:r}=e,{blockSeparator:s=`
|
|
9
|
+
`);return{dom:a,text:u,slice:e}}function pu(n,e,t,i,r){let s=r.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(i||s||!t);if(a){if(n.someProp("transformPastedText",u=>{e=u(e,s||i,n)}),s)return l=new O(S.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
10
|
+
`))),0,0),n.someProp("transformPasted",u=>{l=u(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",u=>u(e,r,i,n));if(f)l=f;else{let u=r.marks(),{schema:d}=n.state,p=Et.fromSchema(d);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(d.text(m,u)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),o=Dy(t),Qi&&Ny(o);let h=o&&o.querySelector("[data-pm-slice]"),c=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[3];f>0;f--){let u=o.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;o=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||pt.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:r,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!Ty.test(u.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Ry(Vf(l,+c[1],+c[2]),c[4]);else if(l=O.maxOpen(Oy(l.content,r),!0),l.openStart||l.openEnd){let f=0,u=0;for(let d=l.content.firstChild;f<l.openStart&&!d.type.spec.isolating;f++,d=d.firstChild);for(let d=l.content.lastChild;u<l.openEnd&&!d.type.spec.isolating;u++,d=d.lastChild);l=Vf(l,f,u)}return n.someProp("transformPasted",f=>{l=f(l,n,a)}),l}var Ty=/^(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 Oy(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=r.findWrapping(l.type),h;if(!a)return o=null;if(h=o.length&&s.length&&gu(a,s,l,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=yu(o[o.length-1],s.length));let c=mu(l,a);o.push(c),r=r.matchType(c.type),s=a}}),o)return S.from(o)}return n}function mu(n,e,t=0){for(let i=e.length-1;i>=t;i--)n=e[i].create(null,S.from(n));return n}function gu(n,e,t,i,r){if(r<n.length&&r<e.length&&n[r]==e[r]){let s=gu(n,e,t,i.lastChild,r+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(r==n.length-1?t.type:n[r+1]))return i.copy(i.content.append(S.from(mu(t,n,r+1))))}}function yu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,yu(n.lastChild,e-1)),i=n.contentMatchAt(n.childCount).fillBefore(S.empty,!0);return n.copy(t.append(i))}function kl(n,e,t,i,r,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),r<i-1&&(l=kl(l,e,t,i,r+1,s)),r>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=r).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Vf(n,e,t){return e<n.openStart&&(n=new O(kl(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new O(kl(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var bu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Hf=null;function xu(){return Hf||(Hf=document.implementation.createHTMLDocument("title"))}var ol=null;function Ey(n){let e=window.trustedTypes;return e?(ol||(ol=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ol.createHTML(n)):n}function Dy(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=xu().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&bu[i[1].toLowerCase()])&&(n=r.map(s=>"<"+s+">").join("")+n+r.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Ey(n),r)for(let s=0;s<r.length;s++)t=t.querySelector(r[s])||t;return t}function Ny(n){let e=n.querySelectorAll(pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent=="\xA0"&&i.parentNode&&i.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),i)}}function Ry(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return n}let{content:r,openStart:s,openEnd:o}=n;for(let l=i.length-2;l>=0;l-=2){let a=t.nodes[i[l]];if(!a||a.hasRequiredAttrs())break;r=S.from(a.create(i[l+1],r)),s++,o++}return new O(r,s,o)}var ve={},Ce={},Py={touchstart:!0,touchmove:!0},wl=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Iy(n){for(let e in ve){let t=ve[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=i=>{Ly(n,i)&&!Nl(n,i)&&(n.editable||!(i.type in Ce))&&t(n,i)},Py[e]?{passive:!0}:void 0)}xe&&n.dom.addEventListener("input",()=>null),Sl(n)}function Gt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function By(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 Sl(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=i=>Nl(n,i))})}function Nl(n,e){return n.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(n,e)||e.defaultPrevented:!1})}function Ly(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 zy(n,e){!Nl(n,e)&&ve[e.type]&&(n.editable||!(e.type in Ce))&&ve[e.type](n,e)}Ce.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!wu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Bt&&pe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),oi&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();n.input.lastIOSEnter=i,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==i&&(n.someProp("handleKeyDown",r=>r(n,kn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",i=>i(n,t))||Ay(n,t)?t.preventDefault():Gt(n,"key")};Ce.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Ce.keypress=(n,e)=>{let t=e;if(wu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||_e&&t.metaKey)return;if(n.someProp("handleKeyPress",r=>r(n,t))){t.preventDefault();return}let i=n.state.selection;if(!(i instanceof L)||!i.$from.sameParent(i.$to)){let r=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(r).scrollIntoView();!/[\r\n]/.test(r)&&!n.someProp("handleTextInput",o=>o(n,i.$from.pos,i.$to.pos,r,s))&&n.dispatch(s()),t.preventDefault()}};function hs(n){return{left:n.clientX,top:n.clientY}}function Fy(n,e){let t=e.x-n.clientX,i=e.y-n.clientY;return t*t+i*i<100}function Rl(n,e,t,i,r){if(i==-1)return!1;let s=n.state.doc.resolve(i);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),r,!0):l(n,t,s.node(o),s.before(o),r,!1)))return!0;return!1}function ri(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let i=n.state.tr.setSelection(e);t=="pointer"&&i.setMeta("pointer",!0),n.dispatch(i)}function Vy(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&I.isSelectable(i)?(ri(n,new I(t),"pointer"),!0):!1}function Hy(n,e){if(e==-1)return!1;let t=n.state.selection,i,r;t instanceof I&&(i=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(I.isSelectable(l)){i&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?r=s.before(t.$from.depth):r=s.before(o);break}}return r!=null?(ri(n,I.create(n.state.doc,r),"pointer"),!0):!1}function Wy(n,e,t,i,r){return Rl(n,"handleClickOn",e,t,i)||n.someProp("handleClick",s=>s(n,e,i))||(r?Hy(n,t):Vy(n,t))}function $y(n,e,t,i){return Rl(n,"handleDoubleClickOn",e,t,i)||n.someProp("handleDoubleClick",r=>r(n,e,i))}function _y(n,e,t,i){return Rl(n,"handleTripleClickOn",e,t,i)||n.someProp("handleTripleClick",r=>r(n,e,i))||Ky(n,t,i)}function Ky(n,e,t){if(t.button!=0)return!1;let i=n.state.doc;if(e==-1)return i.inlineContent?(ri(n,L.create(i,0,i.content.size),"pointer"),!0):!1;let r=i.resolve(e);for(let s=r.depth+1;s>0;s--){let o=s>r.depth?r.nodeAfter:r.node(s),l=r.before(s);if(o.inlineContent)ri(n,L.create(i,l+1,l+1+o.content.size),"pointer");else if(I.isSelectable(o))ri(n,I.create(i,l),"pointer");else continue;return!0}}function Pl(n){return ns(n)}var ku=_e?"metaKey":"ctrlKey";ve.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let i=Pl(n),r=Date.now(),s="singleClick";r-n.input.lastClick.time<500&&Fy(t,n.input.lastClick)&&!t[ku]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:s,button:t.button};let o=n.posAtCoords(hs(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new vl(n,o,t,!!i)):(s=="doubleClick"?$y:_y)(n,o.pos,o.inside,t)?t.preventDefault():Gt(n,"pointer"))};var vl=class{constructor(e,t,i,r){this.view=e,this.pos=t,this.event=i,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[ku],this.allowDefault=i.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let c=e.state.doc.resolve(t.pos);s=c.parent,o=c.depth?c.before():0}let l=r?null:i.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:h}=e.state;(i.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||h instanceof I&&h.from<=o&&h.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&qe&&!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)),Gt(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(()=>Lt(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(hs(e))),this.updateAllowDefault(e),this.allowDefault||!t?Gt(this.view,"pointer"):Wy(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||xe&&this.mightDrag&&!this.mightDrag.node.isAtom||pe&&!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)?(ri(this.view,F.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Gt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Gt(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(),Pl(n),Gt(n,"pointer")};ve.touchmove=n=>{n.input.lastTouch=Date.now(),Gt(n,"pointer")};ve.contextmenu=n=>Pl(n);function wu(n,e){return n.composing?!0:xe&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var qy=Bt?5e3:-1;Ce.compositionstart=Ce.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof L&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)||pe&&eu&&jy(n)))n.markCursor=n.state.storedMarks||t.marks(),ns(n,!0),n.markCursor=null;else if(ns(n,!e.selection.empty),qe&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=n.domSelectionRange();for(let r=i.focusNode,s=i.focusOffset;r&&r.nodeType==1&&s!=0;){let o=s<0?r.lastChild:r.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else r=o,s=-1}}n.input.composing=!0}Su(n,qy)};function jy(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let i=e.childNodes[t];return i.nodeType==1&&i.contentEditable=="false"}Ce.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.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Su(n,20))};function Su(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ns(n),e))}function vu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Uy());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Jy(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=K0(e.focusNode,e.focusOffset),i=q0(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let r=i.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||i==s)return s;if(!r||!r.isText(i.nodeValue))return i;if(n.input.compositionNode==i){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return i}}return t||i}function Uy(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ns(n,e=!1){if(!(Bt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),vu(n),e||n.docView&&n.docView.dirty){let t=Ol(n),i=n.state.selection;return t&&!t.eq(i)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Gy(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 i=getSelection(),r=document.createRange();r.selectNodeContents(e),n.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Ji=Ee&&Yt<15||oi&&G0<604;ve.copy=Ce.cut=(n,e)=>{let t=e,i=n.state.selection,r=t.type=="cut";if(i.empty)return;let s=Ji?null:t.clipboardData,o=i.content(),{dom:l,text:a}=Dl(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Gy(n,l),r&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Yy(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Xy(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,i=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let r=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),i.parentNode&&i.parentNode.removeChild(i),t?Ui(n,i.value,null,r,e):Ui(n,i.textContent,i.innerHTML,r,e)},50)}function Ui(n,e,t,i,r){let s=pu(n,e,t,i,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,r,s||O.empty)))return!0;if(!s)return!1;let o=Yy(s),l=o?n.state.tr.replaceSelectionWith(o,i):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Cu(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," "):""}Ce.paste=(n,e)=>{let t=e;if(n.composing&&!Bt)return;let i=Ji?null:t.clipboardData,r=n.input.shiftKey&&n.input.lastKeyCode!=45;i&&Ui(n,Cu(i),i.getData("text/html"),r,t)?t.preventDefault():Xy(n,t)};var is=class{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}},Qy=_e?"altKey":"ctrlKey";function Mu(n,e){let t=n.someProp("dragCopies",i=>!i(e));return t??!e[Qy]}ve.dragstart=(n,e)=>{let t=e,i=n.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let r=n.state.selection,s=r.empty?null:n.posAtCoords(hs(t)),o;if(!(s&&s.pos>=r.from&&s.pos<=(r instanceof I?r.to-1:r.to))){if(i&&i.mightDrag)o=I.create(n.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(o=I.create(n.state.doc,f.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:h,slice:c}=Dl(n,l);(!t.dataTransfer.files.length||!pe||Zf>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ji?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ji||t.dataTransfer.setData("text/plain",h),n.dragging=new is(c,Mu(n,t),o)};ve.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Ce.dragover=Ce.dragenter=(n,e)=>e.preventDefault();Ce.drop=(n,e)=>{try{Zy(n,e,n.dragging)}finally{n.dragging=null}};function Zy(n,e,t){if(!e.dataTransfer)return;let i=n.posAtCoords(hs(e));if(!i)return;let r=n.state.doc.resolve(i.pos),s=t&&t.slice;s?n.someProp("transformPasted",d=>{s=d(s,n,!1)}):s=pu(n,Cu(e.dataTransfer),Ji?null:e.dataTransfer.getData("text/html"),!1,r);let o=!!(t&&Mu(n,e));if(n.someProp("handleDrop",d=>d(n,e,s||O.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?of(n.state.doc,r.pos,s):r.pos;l==null&&(l=r.pos);let a=n.state.tr;if(o){let{node:d}=t;d?d.replace(a):a.deleteSelection()}let h=a.mapping.map(l),c=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=a.doc;if(c?a.replaceRangeWith(h,h,s.content.firstChild):a.replaceRange(h,h,s),a.doc.eq(f))return;let u=a.doc.resolve(h);if(c&&I.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new I(u));else{let d=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>d=y),a.setSelection(El(n,u,a.doc.resolve(d)))}n.focus(),n.dispatch(a.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())&&Lt(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(pe&&Bt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:i}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=i||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,kn(8,"Backspace")))))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in Ce)ve[n]=Ce[n];function Gi(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}var rs=class n{constructor(e,t){this.toDOM=e,this.spec=t||Cn,this.side=this.spec.side||0}map(e,t,i,r){let{pos:s,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new yt(s-i,s-i,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Gi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},vn=class n{constructor(e,t){this.attrs=e,this.spec=t||Cn}map(e,t,i,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-i,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-i;return s>=o?null:new yt(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Gi(this.attrs,e.attrs)&&Gi(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Cl=class n{constructor(e,t){this.attrs=e,this.spec=t||Cn}map(e,t,i,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=s.pos?null:new yt(s.pos-i,o.pos-i,this)}valid(e,t){let{index:i,offset:r}=e.content.findIndex(t.from),s;return r==t.from&&!(s=e.child(i)).isText&&r+s.nodeSize==t.to}eq(e){return this==e||e instanceof n&&Gi(this.attrs,e.attrs)&&Gi(this.spec,e.spec)}destroy(){}},yt=class n{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new n(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,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new n(e,e,new rs(t,i))}static inline(e,t,i,r){return new n(e,t,new vn(i,r))}static node(e,t,i,r){return new n(e,t,new Cl(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof vn}get widget(){return this.type instanceof rs}},ii=[],Cn={},De=class n{constructor(e,t){this.local=e.length?e:ii,this.children=t.length?t:ii}static create(e,t){return t.length?ls(t,e,0,Cn):be}find(e,t,i){let r=[];return this.findInner(e??0,t??1e9,r,0,i),r}findInner(e,t,i,r,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))&&i.push(l.copy(l.from+r,l.to+r))}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,i,r+l,s)}}map(e,t,i){return this==be||e.maps.length==0?this:this.mapInner(e,t,0,0,i||Cn)}mapInner(e,t,i,r,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,i,r);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?eb(this.children,o||[],e,t,i,r,s):o?new n(o.sort(Mn),ii):be}add(e,t){return t.length?this==be?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let r,s=0;e.forEach((l,a)=>{let h=a+i,c;if(c=Tu(t,l,h)){for(r||(r=this.children.slice());s<r.length&&r[s]<a;)s+=3;r[s]==a?r[s+2]=r[s+2].addInner(l,c,h+1):r.splice(s,0,a,a+l.nodeSize,ls(c,l,h+1,Cn)),s+=3}});let o=Au(s?Ou(t):t,-i);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new n(o.length?this.local.concat(o).sort(Mn):this.local,r||this.children)}remove(e){return e.length==0||this==be?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,r=this.local;for(let s=0;s<i.length;s+=3){let o,l=i[s]+t,a=i[s+1]+t;for(let c=0,f;c<e.length;c++)(f=e[c])&&f.from>l&&f.to<a&&(e[c]=null,(o||(o=[])).push(f));if(!o)continue;i==this.children&&(i=this.children.slice());let h=i[s+2].removeInner(o,l+1);h!=be?i[s+2]=h:(i.splice(s,3),s-=3)}if(r.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<r.length;l++)r[l].eq(o,t)&&(r==this.local&&(r=this.local.slice()),r.splice(l--,1))}return i==this.children&&r==this.local?this:r.length||i.length?new n(r,i):be}forChild(e,t){if(this==be)return this;if(t.isLeaf)return n.empty;let i,r;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=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 vn){let h=Math.max(s,a.from)-s,c=Math.min(o,a.to)-s;h<c&&(r||(r=[])).push(a.copy(h,c))}}if(r){let l=new n(r.sort(Mn),ii);return i?new ss([l,i]):l}return i||be}eq(e){if(this==e)return!0;if(!(e instanceof n)||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 Il(this.localsInner(e))}localsInner(e){if(this==be)return ii;if(e.inlineContent||!this.local.some(vn.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof vn||t.push(this.local[i]);return t}forEachSet(e){e(this)}};De.empty=new De([],[]);De.removeOverlap=Il;var be=De.empty,ss=class n{constructor(e){this.members=e}map(e,t){let i=this.members.map(r=>r.map(e,t,Cn));return n.from(i)}forChild(e,t){if(t.isLeaf)return De.empty;let i=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=be&&(s instanceof n?i=i.concat(s.members):i.push(s))}return n.from(i)}eq(e){if(!(e instanceof n)||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,i=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(!t)t=s;else{i&&(t=t.slice(),i=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Il(i?t:t.sort(Mn)):ii}static from(e){switch(e.length){case 0:return be;case 1:return e[0];default:return new n(e.every(t=>t instanceof De)?e:e.reduce((t,i)=>t.concat(i instanceof De?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function eb(n,e,t,i,r,s,o){let l=n.slice();for(let h=0,c=s;h<t.maps.length;h++){let f=0;t.maps[h].forEach((u,d,p,m)=>{let g=m-p-(d-u);for(let y=0;y<l.length;y+=3){let b=l[y+1];if(b<0||u>b+c-f)continue;let x=l[y]+c-f;d>=x?l[y+1]=u<=x?-2:-1:u>=c&&g&&(l[y]+=g,l[y+1]+=g)}f+=g}),c=t.maps[h].map(c,-1)}let a=!1;for(let h=0;h<l.length;h+=3)if(l[h+1]<0){if(l[h+1]==-2){a=!0,l[h+1]=-1;continue}let c=t.map(n[h]+s),f=c-r;if(f<0||f>=i.content.size){a=!0;continue}let u=t.map(n[h+1]+s,-1),d=u-r,{index:p,offset:m}=i.content.findIndex(f),g=i.maybeChild(p);if(g&&m==f&&m+g.nodeSize==d){let y=l[h+2].mapInner(t,g,c+1,n[h]+s+1,o);y!=be?(l[h]=f,l[h+1]=d,l[h+2]=y):(l[h+1]=-2,a=!0)}else a=!0}if(a){let h=tb(l,n,e,t,r,s,o),c=ls(h,i,0,o);e=c.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,u=0;f<c.children.length;f+=3){let d=c.children[f];for(;u<l.length&&l[u]<d;)u+=3;l.splice(u,0,c.children[f],c.children[f+1],c.children[f+2])}}return new De(e.sort(Mn),l)}function Au(n,e){if(!e||!n.length)return n;let t=[];for(let i=0;i<n.length;i++){let r=n[i];t.push(new yt(r.from+e,r.to+e,r.type))}return t}function tb(n,e,t,i,r,s,o){function l(a,h){for(let c=0;c<a.local.length;c++){let f=a.local[c].map(i,r,h);f?t.push(f):o.onRemove&&o.onRemove(a.local[c].spec)}for(let c=0;c<a.children.length;c+=3)l(a.children[c+2],a.children[c]+h+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 Tu(n,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,r=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<i&&((r||(r=[])).push(o),n[s]=null);return r}function Ou(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function ls(n,e,t,i){let r=[],s=!1;e.forEach((l,a)=>{let h=Tu(n,l,a+t);if(h){s=!0;let c=ls(h,l,t+a+1,i);c!=be&&r.push(a,a+l.nodeSize,c)}});let o=Au(s?Ou(n):n,-t).sort(Mn);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(i.onRemove&&i.onRemove(o[l].spec),o.splice(l--,1));return o.length||r.length?new De(o,r):be}function Mn(n,e){return n.from-e.from||n.to-e.to}function Il(n){let e=n;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let r=t+1;r<e.length;r++){let s=e[r];if(s.from==i.from){s.to!=i.to&&(e==n&&(e=n.slice()),e[r]=s.copy(s.from,i.to),Wf(e,r+1,s.copy(i.to,s.to)));continue}else{s.from<i.to&&(e==n&&(e=n.slice()),e[t]=i.copy(i.from,s.from),Wf(e,r,i.copy(s.from,i.to)));break}}}return e}function Wf(n,e,t){for(;e<n.length&&Mn(t,n[e])>0;)e++;n.splice(e,0,t)}function ll(n){let e=[];return n.someProp("decorations",t=>{let i=t(n.state);i&&i!=be&&e.push(i)}),n.cursorWrapper&&e.push(De.create(n.state.doc,[n.cursorWrapper.deco])),ss.from(e)}var nb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ib=Ee&&Yt<=11,Ml=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Al=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ml,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let r=0;r<i.length;r++)this.queue.push(i[r]);Ee&&Yt<=11&&i.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():xe&&e.composing&&i.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ib&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,nb)),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(Pf(this.view)){if(this.suppressingSelectionUpdates)return Lt(this.view);if(Ee&&Yt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&An(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,i;for(let s=e.focusNode;s;s=si(s))t.add(s);for(let s=e.anchorNode;s;s=si(s))if(t.has(s)){i=s;break}let r=i&&this.view.docView.nearestDesc(i);if(r&&r.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))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 i=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&Pf(e)&&!this.ignoreSelectionChange(i),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let c=0;c<t.length;c++){let f=this.registerMutation(t[c],a);f&&(s=s<0?f.from:Math.min(f.from,s),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(a.some(c=>c.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let c of a)if(c.nodeName=="BR"&&c.parentNode){let f=c.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&c.parentNode.removeChild(c)}}else if(qe&&a.length){let c=a.filter(f=>f.nodeName=="BR");if(c.length==2){let[f,u]=c;f.parentNode&&f.parentNode.parentNode==u.parentNode?u.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let u of c){let d=u.parentNode;d&&d.nodeName=="LI"&&(!f||ob(e,f)!=d)&&u.remove()}}}let h=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&as(i)&&(h=Ol(e))&&h.eq(F.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Lt(e),this.currentSelection.set(i),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,o),rb(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,lb(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||Lt(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;c<e.addedNodes.length;c++){let f=e.addedNodes[c];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let r=e.previousSibling,s=e.nextSibling;if(Ee&&Yt<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:f,nextSibling:u}=e.addedNodes[c];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(r=f),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u)}let o=r&&r.parentNode==e.target?de(r)+1:0,l=i.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?de(s):e.target.childNodes.length,h=i.localPosFromDOM(e.target,a,1);return{from:l,to:h}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},$f=new WeakMap,_f=!1;function rb(n){if(!$f.has(n)&&($f.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=qe,_f)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."),_f=!0}}function Kf(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return An(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function sb(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Kf(n,r)}let t;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",i,!0),t?Kf(n,t):null}function ob(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let i=n.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function lb(n,e){var t;let{focusNode:i,focusOffset:r}=n.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),i==s&&n.domSelection().collapse(s,r)}else s.parentNode.removeChild(s)}}function ab(n,e,t){let{node:i,fromOffset:r,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),h,c=a.anchorNode;if(c&&n.dom.contains(c.nodeType==1?c:c.parentNode)&&(h=[{node:c,offset:a.anchorOffset}],as(a)||h.push({node:a.focusNode,offset:a.focusOffset})),pe&&n.input.lastKeyCode===8)for(let g=s;g>r;g--){let y=i.childNodes[g-1],b=y.pmViewDesc;if(y.nodeName=="BR"&&!b){s=g;break}if(!b||b.size)break}let f=n.state.doc,u=n.someProp("domParser")||pt.fromSchema(n.state.schema),d=f.resolve(o),p=null,m=u.parse(i,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:!0,from:r,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:hb,context:d});if(h&&h[0].pos!=null){let g=h[0].pos,y=h[1]&&h[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:l}}function hb(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(xe&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||xe&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var cb=/^(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 fb(n,e,t,i,r){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let k=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,D=Ol(n,k);if(D&&!n.state.selection.eq(D)){if(pe&&Bt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",W=>W(n,kn(13,"Enter"))))return;let R=n.state.tr.setSelection(D);k=="pointer"?R.setMeta("pointer",!0):k=="key"&&R.scrollIntoView(),s&&R.setMeta("composition",s),n.dispatch(R)}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,h=ab(n,e,t),c=n.state.doc,f=c.slice(h.from,h.to),u,d;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,d="end"):(u=n.state.selection.from,d="start"),n.input.lastKeyCode=null;let p=pb(f.content,h.doc.content,h.from,u,d);if(p&&n.input.domChangeCount++,(oi&&n.input.lastIOSEnter>Date.now()-225||Bt)&&r.some(k=>k.nodeType==1&&!cb.test(k.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",k=>k(n,kn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(i&&a instanceof L&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(h.sel){let k=qf(n,n.state.doc,h.sel);if(k&&!k.eq(n.state.selection)){let D=n.state.tr.setSelection(k);s&&D.setMeta("composition",s),n.dispatch(D)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof L&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=h.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=h.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Ee&&Yt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>h.from&&h.doc.textBetween(p.start-h.from-1,p.start-h.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=h.doc.resolveNoCache(p.start-h.from),g=h.doc.resolveNoCache(p.endB-h.from),y=c.resolve(p.start),b=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((oi&&n.input.lastIOSEnter>Date.now()-225&&(!b||r.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!b&&m.pos<h.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(h.doc.textBetween(m.pos,g.pos,"","")))&&n.someProp("handleKeyDown",k=>k(n,kn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&db(c,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",k=>k(n,kn(8,"Backspace")))){Bt&&pe&&n.domObserver.suppressSelectionUpdates();return}pe&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Bt&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==p.endA&&(p.endB-=2,g=h.doc.resolveNoCache(p.endB-h.from),setTimeout(()=>{n.someProp("handleKeyDown",function(k){return k(n,kn(13,"Enter"))})},20));let x=p.start,C=p.endA,w=k=>{let D=k||n.state.tr.replace(x,C,h.doc.slice(p.start-h.from,p.endB-h.from));if(h.sel){let R=qf(n,D.doc,h.sel);R&&!(pe&&n.composing&&R.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(R.head==x||R.head==D.mapping.map(C)-1)||Ee&&R.empty&&R.head==x)&&D.setSelection(R)}return s&&D.setMeta("composition",s),D.scrollIntoView()},T;if(b)if(m.pos==g.pos){Ee&&Yt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Lt(n),20));let k=w(n.state.tr.delete(x,C)),D=c.resolve(p.start).marksAcross(c.resolve(p.endA));D&&k.ensureMarks(D),n.dispatch(k)}else if(p.endA==p.endB&&(T=ub(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let k=w(n.state.tr);T.type=="add"?k.addMark(x,C,T.mark):k.removeMark(x,C,T.mark),n.dispatch(k)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let k=m.parent.textBetween(m.parentOffset,g.parentOffset),D=()=>w(n.state.tr.insertText(k,x,C));n.someProp("handleTextInput",R=>R(n,x,C,k,D))||n.dispatch(D())}else n.dispatch(w());else n.dispatch(w())}function qf(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:El(n,e.resolve(t.anchor),e.resolve(t.head))}function ub(n,e){let t=n.firstChild.marks,i=e.firstChild.marks,r=t,s=i,o,l,a;for(let c=0;c<i.length;c++)r=i[c].removeFromSet(r);for(let c=0;c<t.length;c++)s=t[c].removeFromSet(s);if(r.length==1&&s.length==0)l=r[0],o="add",a=c=>c.mark(l.addToSet(c.marks));else if(r.length==0&&s.length==1)l=s[0],o="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let h=[];for(let c=0;c<e.childCount;c++)h.push(a(e.child(c)));if(S.from(h).eq(n))return{mark:l,type:o}}function db(n,e,t,i,r){if(t-e<=r.pos-i.pos||al(i,!0,!1)<r.pos)return!1;let s=n.resolve(e);if(!i.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(al(s,!0,!0));return!o.parent.isTextblock||o.pos>t||al(o,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(o.parent.content)}function al(n,e,t){let i=n.depth,r=e?n.end():n.pos;for(;i>0&&(e||n.indexAfter(i)==n.node(i).childCount);)i--,r++,e=!1;if(t){let s=n.node(i).maybeChild(n.indexAfter(i));for(;s&&!s.isLeaf;)s=s.firstChild,r++}return r}function pb(n,e,t,i,r){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(r=="end"){let a=Math.max(0,s-Math.min(o,l));i-=o+a-s}if(o<s&&n.size<e.size){let a=i<=s&&i>=o?s-i:0;s-=a,s&&s<e.size&&jf(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=i<=s&&i>=l?s-i:0;s-=a,s&&s<n.size&&jf(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function jf(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}var Yi=class{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 wl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Xf),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=Gf(this),Uf(this),this.nodeViews=Yf(this),this.docView=Tf(this.state.doc,Jf(this),ll(this),this.dom,this),this.domObserver=new Al(this,(i,r,s,o)=>fb(this,i,r,s,o)),this.domObserver.start(),Iy(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&&Sl(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Xf),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let r=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(vu(this),o=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let d=Yf(this);gb(d,this.nodeViews)&&(this.nodeViews=d,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Sl(this),this.editable=Gf(this),Uf(this);let a=ll(this),h=Jf(this),c=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,h,a);(f||!e.selection.eq(r.selection))&&(o=!0);let u=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Q0(this);if(o){this.domObserver.stop();let d=f&&(Ee||pe)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&mb(r.selection,e.selection);if(f){let p=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Jy(this)),(s||!this.docView.update(e.doc,h,a,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=Tf(e.doc,h,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(d=!0)}d||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&xy(this))?Lt(this,d):(fu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((i=this.dragging)===null||i===void 0)&&i.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():u&&Z0(u)}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 I){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&wf(this,t.getBoundingClientRect(),e)}else wf(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 i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,r=-1;if(this.state.doc.nodeAt(i.from)==i.node)r=i.from;else{let s=i.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==i.node&&(r=s)}this.dragging=new is(e.slice,e.move,r<0?void 0:I.create(this.state.doc,r))}someProp(e,t){let i=this._props&&this._props[e],r;if(i!=null&&(r=t?t(i):i))return r;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(r=t?t(l):l))return r}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(r=t?t(l):l))return r}}hasFocus(){if(Ee){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&&ey(this.dom),Lt(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 sy(this,e)}coordsAtPos(e,t=1){return su(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,i=-1){let r=this.docView.posFromDOM(e,t,i);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return cy(this,t||this.state,e)}pasteHTML(e,t){return Ui(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ui(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Dl(this,e)}destroy(){this.docView&&(By(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ll(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,$0())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return zy(this,e)}domSelectionRange(){let e=this.domSelection();return e?xe&&this.root.nodeType===11&&J0(this.dom.ownerDocument)==this.dom&&sb(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Yi.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Jf(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 i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[yt.node(0,n.state.doc.content.size,e)]}function Uf(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:yt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Gf(n){return!n.someProp("editable",e=>e(n.state)===!1)}function mb(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 Yf(n){let e=Object.create(null);function t(i){for(let r in i)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=i[r])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function gb(n,e){let t=0,i=0;for(let r in n){if(n[r]!=e[r])return!0;t++}for(let r in e)i++;return t!=i}function Xf(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var cs=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Du(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var Ll=(n,e,t)=>{let i=Du(n,t);if(!i)return!1;let r=Fl(i);if(!r){let o=i.blockRange(),l=o&&Rt(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=r.nodeBefore;if(Vu(n,r,e,-1))return!0;if(i.parent.content.size==0&&(ai(s,"end")||I.isSelectable(s)))for(let o=i.depth;;o--){let l=$i(n.doc,i.before(o),i.after(o),O.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(ai(s,"end")?F.findFrom(a.doc.resolve(a.mapping.map(r.pos,-1)),-1):I.create(a.doc,r.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||i.node(o-1).childCount>1)break}return s.isAtom&&r.depth==i.depth-1?(e&&e(n.tr.delete(r.pos-s.nodeSize,r.pos).scrollIntoView()),!0):!1},Nu=(n,e,t)=>{let i=Du(n,t);if(!i)return!1;let r=Fl(i);return r?Pu(n,r,e):!1},Ru=(n,e,t)=>{let i=Iu(n,t);if(!i)return!1;let r=Wl(i);return r?Pu(n,r,e):!1};function Pu(n,e,t){let i=e.nodeBefore,r=i,s=e.pos-1;for(;!r.isTextblock;s--){if(r.type.spec.isolating)return!1;let c=r.lastChild;if(!c)return!1;r=c}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let c=l.firstChild;if(!c)return!1;l=c}let h=$i(n.doc,s,a,O.empty);if(!h||h.from!=s||h instanceof ye&&h.slice.size>=a-s)return!1;if(t){let c=n.tr.step(h);c.setSelection(L.create(c.doc,s)),t(c.scrollIntoView())}return!0}function ai(n,e,t=!1){for(let i=n;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(t&&i.childCount!=1)return!1}return!1}var zl=(n,e,t)=>{let{$head:i,empty:r}=n.selection,s=i;if(!r)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):i.parentOffset>0)return!1;s=Fl(i)}let o=s&&s.nodeBefore;return!o||!I.isSelectable(o)?!1:(e&&e(n.tr.setSelection(I.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Fl(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 Iu(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var Vl=(n,e,t)=>{let i=Iu(n,t);if(!i)return!1;let r=Wl(i);if(!r)return!1;let s=r.nodeAfter;if(Vu(n,r,e,1))return!0;if(i.parent.content.size==0&&(ai(s,"start")||I.isSelectable(s))){let o=$i(n.doc,i.before(),i.after(),O.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(ai(s,"start")?F.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):I.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&r.depth==i.depth-1?(e&&e(n.tr.delete(r.pos,r.pos+s.nodeSize).scrollIntoView()),!0):!1},Hl=(n,e,t)=>{let{$head:i,empty:r}=n.selection,s=i;if(!r)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):i.parentOffset<i.parent.content.size)return!1;s=Wl(i)}let o=s&&s.nodeAfter;return!o||!I.isSelectable(o)?!1:(e&&e(n.tr.setSelection(I.create(n.doc,s.pos)).scrollIntoView()),!0)};function Wl(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}var Bu=(n,e)=>{let t=n.selection,i=t instanceof I,r;if(i){if(t.node.isTextblock||!$e(n.doc,t.from))return!1;r=t.from}else if(r=bn(n.doc,t.from,-1),r==null)return!1;if(e){let s=n.tr.join(r);i&&s.setSelection(I.create(s.doc,r-n.doc.resolve(r).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Lu=(n,e)=>{let t=n.selection,i;if(t instanceof I){if(t.node.isTextblock||!$e(n.doc,t.to))return!1;i=t.to}else if(i=bn(n.doc,t.to,1),i==null)return!1;return e&&e(n.tr.join(i).scrollIntoView()),!0},zu=(n,e)=>{let{$from:t,$to:i}=n.selection,r=t.blockRange(i),s=r&&Rt(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)},$l=(n,e)=>{let{$head:t,$anchor:i}=n.selection;return!t.parent.type.spec.code||!t.sameParent(i)?!1:(e&&e(n.tr.insertText(`
|
|
11
|
+
`).scrollIntoView()),!0)};function _l(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Kl=(n,e)=>{let{$head:t,$anchor:i}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(i))return!1;let r=t.node(-1),s=t.indexAfter(-1),o=_l(r.contentMatchAt(s));if(!o||!r.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(F.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},ql=(n,e)=>{let t=n.selection,{$from:i,$to:r}=t;if(t instanceof Se||i.parent.inlineContent||r.parent.inlineContent)return!1;let s=_l(r.parent.contentMatchAt(r.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!i.parentOffset&&r.index()<r.parent.childCount?i:r).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(L.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},jl=(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(Le(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let i=t.blockRange(),r=i&&Rt(i);return r==null?!1:(e&&e(n.tr.lift(i,r).scrollIntoView()),!0)};function yb(n){return(e,t)=>{let{$from:i,$to:r}=e.selection;if(e.selection instanceof I&&e.selection.node.isBlock)return!i.parentOffset||!Le(e.doc,i.pos)?!1:(t&&t(e.tr.split(i.pos).scrollIntoView()),!0);if(!i.depth)return!1;let s=[],o,l,a=!1,h=!1;for(let d=i.depth;;d--)if(i.node(d).isBlock){a=i.end(d)==i.pos+(i.depth-d),h=i.start(d)==i.pos-(i.depth-d),l=_l(i.node(d-1).contentMatchAt(i.indexAfter(d-1)));let m=n&&n(r.parent,a,i);s.unshift(m||(a&&l?{type:l}:null)),o=d;break}else{if(d==1)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof L||e.selection instanceof Se)&&c.deleteSelection();let f=c.mapping.map(i.pos),u=Le(c.doc,f,s.length,s);if(u||(s[0]=l?{type:l}:null,u=Le(c.doc,f,s.length,s)),!u)return!1;if(c.split(f,s.length,s),!a&&h&&i.node(o).type!=l){let d=c.mapping.map(i.before(o)),p=c.doc.resolve(d);l&&i.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&c.setNodeMarkup(c.mapping.map(i.before(o)),l)}return t&&t(c.scrollIntoView()),!0}}var bb=yb();var Fu=(n,e)=>{let{$from:t,to:i}=n.selection,r,s=t.sharedDepth(i);return s==0?!1:(r=t.before(s),e&&e(n.tr.setSelection(I.create(n.doc,r))),!0)},xb=(n,e)=>(e&&e(n.tr.setSelection(new Se(n.doc))),!0);function kb(n,e,t){let i=e.nodeBefore,r=e.nodeAfter,s=e.index();return!i||!r||!i.type.compatibleContent(r.type)?!1:!i.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(r.isTextblock||$e(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Vu(n,e,t,i){let r=e.nodeBefore,s=e.nodeAfter,o,l,a=r.type.spec.isolating||s.type.spec.isolating;if(!a&&kb(n,e,t))return!0;let h=!a&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(l=r.contentMatchAt(r.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let d=e.pos+s.nodeSize,p=S.empty;for(let y=o.length-1;y>=0;y--)p=S.from(o[y].create(null,p));p=S.from(r.copy(p));let m=n.tr.step(new se(e.pos-1,d,e.pos,d,new O(p,1,0),o.length,!0)),g=m.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==r.type&&$e(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let c=s.type.spec.isolating||i>0&&a?null:F.findFrom(e,1),f=c&&c.$from.blockRange(c.$to),u=f&&Rt(f);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(f,u).scrollIntoView()),!0;if(h&&ai(s,"start",!0)&&ai(r,"end")){let d=r,p=[];for(;p.push(d),!d.isTextblock;)d=d.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,m.content)){if(t){let y=S.empty;for(let x=p.length-1;x>=0;x--)y=S.from(p[x].copy(y));let b=n.tr.step(new se(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new O(y,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function Hu(n){return function(e,t){let i=e.selection,r=n<0?i.$from:i.$to,s=r.depth;for(;r.node(s).isInline;){if(!s)return!1;s--}return r.node(s).isTextblock?(t&&t(e.tr.setSelection(L.create(e.doc,n<0?r.start(s):r.end(s)))),!0):!1}}var Jl=Hu(-1),Ul=Hu(1);function Wu(n,e=null){return function(t,i){let{$from:r,$to:s}=t.selection,o=r.blockRange(s),l=o&&Zn(o,n,e);return l?(i&&i(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Gl(n,e=null){return function(t,i){let r=!1;for(let s=0;s<t.selection.ranges.length&&!r;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,h)=>{if(r)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)r=!0;else{let c=t.doc.resolve(h),f=c.index();r=c.parent.canReplaceWith(f,f+1,n)}})}if(!r)return!1;if(i){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)}i(s.scrollIntoView())}return!0}}function Yl(...n){return function(e,t,i){for(let r=0;r<n.length;r++)if(n[r](e,t,i))return!0;return!1}}var Bl=Yl(cs,Ll,zl),Eu=Yl(cs,Vl,Hl),Zt={Enter:Yl($l,ql,jl,bb),"Mod-Enter":Kl,Backspace:Bl,"Mod-Backspace":Bl,"Shift-Backspace":Bl,Delete:Eu,"Mod-Delete":Eu,"Mod-a":xb},wb={"Ctrl-h":Zt.Backspace,"Alt-Backspace":Zt["Mod-Backspace"],"Ctrl-d":Zt.Delete,"Ctrl-Alt-Backspace":Zt["Mod-Delete"],"Alt-Delete":Zt["Mod-Delete"],"Alt-d":Zt["Mod-Delete"],"Ctrl-a":Jl,"Ctrl-e":Ul};for(let n in Zt)wb[n]=Zt[n];var wC=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function $u(n,e=null){return function(t,i){let{$from:r,$to:s}=t.selection,o=r.blockRange(s);if(!o)return!1;let l=i?t.tr:null;return Sb(l,o,n,e)?(i&&i(l.scrollIntoView()),!0):!1}}function Sb(n,e,t,i=null){let r=!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 gn(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new gn(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=Zn(s,t,i,e);return l?(n&&vb(n,e,l,r,t),!0):!1}function vb(n,e,t,i,r){let s=S.empty;for(let c=t.length-1;c>=0;c--)s=S.from(t[c].type.create(t[c].attrs,s));n.step(new se(e.start-(i?2:0),e.end,e.start,e.end,new O(s,0,0),t.length,!0));let o=0;for(let c=0;c<t.length;c++)t[c].type==r&&(o=c+1);let l=t.length-o,a=e.start+t.length-(i?2:0),h=e.parent;for(let c=e.startIndex,f=e.endIndex,u=!0;c<f;c++,u=!1)!u&&Le(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=h.child(c).nodeSize;return n}function _u(n){return function(e,t){let{$from:i,$to:r}=e.selection,s=i.blockRange(r,o=>o.childCount>0&&o.firstChild.type==n);return s?t?i.node(s.depth-1).type==n?Cb(e,t,n,s):Mb(e,t,s):!0:!1}}function Cb(n,e,t,i){let r=n.tr,s=i.end,o=i.$to.end(i.depth);s<o&&(r.step(new se(s-1,o,s,o,new O(S.from(t.create(null,i.parent.copy())),1,0),1,!0)),i=new gn(r.doc.resolve(i.$from.pos),r.doc.resolve(o),i.depth));let l=Rt(i);if(l==null)return!1;r.lift(i,l);let a=r.doc.resolve(r.mapping.map(s,-1)-1);return $e(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function Mb(n,e,t){let i=n.tr,r=t.parent;for(let d=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)d-=r.child(p).nodeSize,i.delete(d-1,d+1);let s=i.doc.resolve(t.start),o=s.nodeAfter;if(i.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==r.childCount,h=s.node(-1),c=s.index(-1);if(!h.canReplace(c+(l?0:1),c+1,o.content.append(a?S.empty:S.from(r))))return!1;let f=s.pos,u=f+o.nodeSize;return i.step(new se(f-(l?1:0),u+(a?1:0),f+1,u-1,new O((l?S.empty:S.from(r.copy(S.empty))).append(a?S.empty:S.from(r.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(i.scrollIntoView()),!0}function Ku(n){return function(e,t){let{$from:i,$to:r}=e.selection,s=i.blockRange(r,h=>h.childCount>0&&h.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 h=a.lastChild&&a.lastChild.type==l.type,c=S.from(h?n.create():null),f=new O(S.from(n.create(null,S.from(l.type.create(null,c)))),h?3:1,0),u=s.start,d=s.end;t(e.tr.step(new se(u-(h?3:1),d,u,d,f,1,!0)).scrollIntoView())}return!0}}var nt={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:"'"},hi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ab=typeof navigator<"u"&&/Mac/.test(navigator.platform),Tb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(oe=0;oe<10;oe++)nt[48+oe]=nt[96+oe]=String(oe);var oe;for(oe=1;oe<=24;oe++)nt[oe+111]="F"+oe;var oe;for(oe=65;oe<=90;oe++)nt[oe]=String.fromCharCode(oe+32),hi[oe]=String.fromCharCode(oe);var oe;for(fs in nt)hi.hasOwnProperty(fs)||(hi[fs]=nt[fs]);var fs;function us(n){var e=Ab&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Tb&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?hi:nt)[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}var Ob=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Eb=typeof navigator<"u"&&/Win/.test(navigator.platform);function Db(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let i,r,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))i=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Ob?o=!0:r=!0;else throw new Error("Unrecognized modifier name: "+a)}return i&&(t="Alt-"+t),r&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Nb(n){let e=Object.create(null);for(let t in n)e[Db(t)]=n[t];return e}function Xl(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 qu(n){return new J({props:{handleKeyDown:Rb(n)}})}function Rb(n){let e=Nb(n);return function(t,i){let r=us(i),s,o=e[Xl(r,i)];if(o&&o(t.state,t.dispatch,t))return!0;if(r.length==1&&r!=" "){if(i.shiftKey){let l=e[Xl(r,i,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((i.altKey||i.metaKey||i.ctrlKey)&&!(Eb&&i.ctrlKey&&i.altKey)&&(s=nt[i.keyCode])&&s!=r){let l=e[Xl(s,i)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Pb=Object.defineProperty,ia=(n,e)=>{for(var t in e)Pb(n,t,{get:e[t],enumerable:!0})};function ws(n){let{state:e,transaction:t}=n,{selection:i}=t,{doc:r}=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 i},get doc(){return r},get tr(){return i=t.selection,r=t.doc,s=t.storedMarks,t}}}var Ss=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(){let{rawCommands:n,editor:e,state:t}=this,{view:i}=e,{tr:r}=t,s=this.buildProps(r);return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...h)=>{let c=l(...h)(s);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(r),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){let{rawCommands:t,editor:i,state:r}=this,{view:s}=i,o=[],l=!!n,a=n||r.tr,h=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(f=>f===!0)),c={...Object.fromEntries(Object.entries(t).map(([f,u])=>[f,(...p)=>{let m=this.buildProps(a,e),g=u(...p)(m);return o.push(g),c}])),run:h};return c}createCan(n){let{rawCommands:e,state:t}=this,i=!1,r=n||t.tr,s=this.buildProps(r,i);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...h)=>a(...h)({...s,dispatch:void 0})])),chain:()=>this.createChain(r,i)}}buildProps(n,e=!0){let{rawCommands:t,editor:i,state:r}=this,{view:s}=i,o={tr:n,editor:i,view:s,state:ws({state:r,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,(...h)=>a(...h)(o)]))}};return o}},td={};ia(td,{blur:()=>Ib,clearContent:()=>Bb,clearNodes:()=>Lb,command:()=>zb,createParagraphNear:()=>Fb,cut:()=>Vb,deleteCurrentNode:()=>Hb,deleteNode:()=>Wb,deleteRange:()=>$b,deleteSelection:()=>_b,enter:()=>Kb,exitCode:()=>qb,extendMarkRange:()=>jb,first:()=>Jb,focus:()=>Gb,forEach:()=>Yb,insertContent:()=>Xb,insertContentAt:()=>ex,joinBackward:()=>ix,joinDown:()=>nx,joinForward:()=>rx,joinItemBackward:()=>sx,joinItemForward:()=>ox,joinTextblockBackward:()=>lx,joinTextblockForward:()=>ax,joinUp:()=>tx,keyboardShortcut:()=>cx,lift:()=>fx,liftEmptyBlock:()=>ux,liftListItem:()=>dx,newlineInCode:()=>px,resetAttributes:()=>mx,scrollIntoView:()=>gx,selectAll:()=>yx,selectNodeBackward:()=>bx,selectNodeForward:()=>xx,selectParentNode:()=>kx,selectTextblockEnd:()=>wx,selectTextblockStart:()=>Sx,setContent:()=>vx,setMark:()=>Kx,setMeta:()=>qx,setNode:()=>jx,setNodeSelection:()=>Jx,setTextDirection:()=>Ux,setTextSelection:()=>Gx,sinkListItem:()=>Yx,splitBlock:()=>Xx,splitListItem:()=>Qx,toggleList:()=>e1,toggleMark:()=>t1,toggleNode:()=>n1,toggleWrap:()=>i1,undoInputRule:()=>r1,unsetAllMarks:()=>s1,unsetMark:()=>o1,unsetTextDirection:()=>l1,updateAttributes:()=>a1,wrapIn:()=>h1,wrapInList:()=>c1});var Ib=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),Bb=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),Lb=()=>({state:n,tr:e,dispatch:t})=>{let{selection:i}=e,{ranges:r}=i;return t&&r.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;let{doc:h,mapping:c}=e,f=h.resolve(c.map(a)),u=h.resolve(c.map(a+l.nodeSize)),d=f.blockRange(u);if(!d)return;let p=Rt(d);if(l.type.isTextblock){let{defaultType:m}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(d.start,m)}(p||p===0)&&e.lift(d,p)})}),!0},zb=n=>e=>n(e),Fb=()=>({state:n,dispatch:e})=>ql(n,e),Vb=(n,e)=>({editor:t,tr:i})=>{let{state:r}=t,s=r.doc.slice(n.from,n.to);i.deleteRange(n.from,n.to);let o=i.mapping.map(e);return i.insert(o,s.content),i.setSelection(new L(i.doc.resolve(Math.max(o-1,0)))),!0},Hb=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,i=t.$anchor.node();if(i.content.size>0)return!1;let r=n.selection.$anchor;for(let s=r.depth;s>0;s-=1)if(r.node(s).type===i.type){if(e){let l=r.before(s),a=r.after(s);n.delete(l,a).scrollIntoView()}return!0}return!1};function he(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}var Wb=n=>({tr:e,state:t,dispatch:i})=>{let r=he(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r){if(i){let a=s.before(o),h=s.after(o);e.delete(a,h).scrollIntoView()}return!0}return!1},$b=n=>({tr:e,dispatch:t})=>{let{from:i,to:r}=n;return t&&e.delete(i,r),!0},_b=()=>({state:n,dispatch:e})=>cs(n,e),Kb=()=>({commands:n})=>n.keyboardShortcut("Enter"),qb=()=>({state:n,dispatch:e})=>Kl(n,e);function ra(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function bs(n,e,t={strict:!0}){let i=Object.keys(e);return i.length?i.every(r=>t.strict?e[r]===n[r]:ra(e[r])?e[r].test(n[r]):e[r]===n[r]):!0}function nd(n,e,t={}){return n.find(i=>i.type===e&&bs(Object.fromEntries(Object.keys(t).map(r=>[r,i.attrs[r]])),t))}function ju(n,e,t={}){return!!nd(n,e,t)}function sa(n,e,t){if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(h=>h.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(h=>h.type===e))return;if(!t){let h=i.node.marks.find(c=>c.type===e);h&&(t=h.attrs)}if(!nd([...i.node.marks],e,t))return;let s=i.index,o=n.start()+i.offset,l=s+1,a=o+i.node.nodeSize;for(;s>0&&ju([...n.parent.child(s-1).marks],e,t);)s-=1,o-=n.parent.child(s).nodeSize;for(;l<n.parent.childCount&&ju([...n.parent.child(l).marks],e,t);)a+=n.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Ft(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}var jb=(n,e)=>({tr:t,state:i,dispatch:r})=>{let s=Ft(n,i.schema),{doc:o,selection:l}=t,{$from:a,from:h,to:c}=l;if(r){let f=sa(a,s,e);if(f&&f.from<=h&&f.to>=c){let u=L.create(o,f.from,f.to);t.setSelection(u)}}return!0},Jb=n=>e=>{let t=typeof n=="function"?n(e):n;for(let i=0;i<t.length;i+=1)if(t[i](e))return!0;return!1};function id(n){return n instanceof L}function zt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function rd(n,e=null){if(!e)return null;let t=F.atStart(n),i=F.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return i;let r=t.from,s=i.to;return e==="all"?L.create(n,zt(0,r,s),zt(n.content.size,r,s)):L.create(n,zt(e,r,s),zt(e,r,s))}function Ju(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function xs(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Ub(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Gb=(n=null,e={})=>({editor:t,view:i,tr:r,dispatch:s})=>{e={scrollIntoView:!0,...e};let o=()=>{(xs()||Ju())&&i.dom.focus(),Ub()&&!xs()&&!Ju()&&i.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(i.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};try{if(i.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(s&&n===null&&!id(t.state.selection))return o(),!0;let l=rd(r.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||r.setSelection(l),a&&r.storedMarks&&r.setStoredMarks(r.storedMarks),o()),!0},Yb=(n,e)=>t=>n.every((i,r)=>e(i,{...t,index:r})),Xb=(n,e)=>({tr:t,commands:i})=>i.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),sd=n=>{let e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){let i=e[t];i.nodeType===3&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)?n.removeChild(i):i.nodeType===1&&sd(i)}return n};function ds(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return sd(t)}function nr(n,e,t){if(n instanceof Oe||n instanceof S)return n;t={slice:!0,parseOptions:{},...t};let i=typeof n=="object"&&n!==null,r=typeof n=="string";if(i)try{if(Array.isArray(n)&&n.length>0)return S.fromArray(n.map(l=>e.nodeFromJSON(l)));let 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),nr("",e,t)}if(r){if(t.errorOnInvalidContent){let o=!1,l="",a=new Gn({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:h=>(o=!0,l=typeof h=="string"?h:h.outerHTML,null)}]}})});if(t.slice?pt.fromSchema(a).parseSlice(ds(n),t.parseOptions):pt.fromSchema(a).parse(ds(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let s=pt.fromSchema(e);return t.slice?s.parseSlice(ds(n),t.parseOptions).content:s.parse(ds(n),t.parseOptions)}return nr("",e,t)}function Qb(n,e,t){let i=n.steps.length-1;if(i<e)return;let r=n.steps[i];if(!(r instanceof ye||r instanceof se))return;let s=n.mapping.maps[i],o=0;s.forEach((l,a,h,c)=>{o===0&&(o=c)}),n.setSelection(F.near(n.doc.resolve(o),t))}var Zb=n=>!("type"in n),ex=(n,e,t)=>({tr:i,dispatch:r,editor:s})=>{var o;if(r){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l,a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{nr(e,s.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=nr(e,s.schema,{parseOptions:h,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:c,to:f}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},u=!0,d=!0;if((Zb(l)?l:[l]).forEach(g=>{g.check(),u=u?g.isText&&g.marks.length===0:!1,d=d?g.isBlock:!1}),c===f&&d){let{parent:g}=i.doc.resolve(c);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(c-=1,f+=1)}let m;if(u){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof S){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;i.insertText(m,c,f)}else{m=l;let g=i.doc.resolve(c),y=g.node(),b=g.parentOffset===0,x=y.isText||y.isTextblock,C=y.content.size>0;b&&x&&C&&d&&(c=Math.max(0,c-1)),i.replaceWith(c,f,m)}t.updateSelection&&Qb(i,i.steps.length-1,-1),t.applyInputRules&&i.setMeta("applyInputRules",{from:c,text:m}),t.applyPasteRules&&i.setMeta("applyPasteRules",{from:c,text:m})}return!0},tx=()=>({state:n,dispatch:e})=>Bu(n,e),nx=()=>({state:n,dispatch:e})=>Lu(n,e),ix=()=>({state:n,dispatch:e})=>Ll(n,e),rx=()=>({state:n,dispatch:e})=>Vl(n,e),sx=()=>({state:n,dispatch:e,tr:t})=>{try{let i=bn(n.doc,n.selection.$from.pos,-1);return i==null?!1:(t.join(i,2),e&&e(t),!0)}catch{return!1}},ox=()=>({state:n,dispatch:e,tr:t})=>{try{let i=bn(n.doc,n.selection.$from.pos,1);return i==null?!1:(t.join(i,2),e&&e(t),!0)}catch{return!1}},lx=()=>({state:n,dispatch:e})=>Nu(n,e),ax=()=>({state:n,dispatch:e})=>Ru(n,e);function od(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function hx(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t==="Space"&&(t=" ");let i,r,s,o;for(let l=0;l<e.length-1;l+=1){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))xs()||od()?o=!0:r=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return i&&(t=`Alt-${t}`),r&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var cx=n=>({editor:e,view:t,tr:i,dispatch:r})=>{let s=hx(n).split(/-(?!$)/),o=s.find(h=>!["Alt","Ctrl","Meta","Shift"].includes(h)),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",h=>h(t,l))});return a?.steps.forEach(h=>{let c=h.map(i.mapping);c&&r&&i.maybeStep(c)}),!0};function ir(n,e,t={}){let{from:i,to:r,empty:s}=n.selection,o=e?he(e,n.schema):null,l=[];n.doc.nodesBetween(i,r,(f,u)=>{if(f.isText)return;let d=Math.max(i,u),p=Math.min(r,u+f.nodeSize);l.push({node:f,from:d,to:p})});let a=r-i,h=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>bs(f.node.attrs,t,{strict:!1}));return s?!!h.length:h.reduce((f,u)=>f+u.to-u.from,0)>=a}var fx=(n,e={})=>({state:t,dispatch:i})=>{let r=he(n,t.schema);return ir(t,r,e)?zu(t,i):!1},ux=()=>({state:n,dispatch:e})=>jl(n,e),dx=n=>({state:e,dispatch:t})=>{let i=he(n,e.schema);return _u(i)(e,t)},px=()=>({state:n,dispatch:e})=>$l(n,e);function vs(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Uu(n,e){let t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((i,r)=>(t.includes(r)||(i[r]=n[r]),i),{})}var mx=(n,e)=>({tr:t,state:i,dispatch:r})=>{let s=null,o=null,l=vs(typeof n=="string"?n:n.name,i.schema);if(!l)return!1;l==="node"&&(s=he(n,i.schema)),l==="mark"&&(o=Ft(n,i.schema));let a=!1;return t.selection.ranges.forEach(h=>{i.doc.nodesBetween(h.$from.pos,h.$to.pos,(c,f)=>{s&&s===c.type&&(a=!0,r&&t.setNodeMarkup(f,void 0,Uu(c.attrs,e))),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&(a=!0,r&&t.addMark(f,f+c.nodeSize,o.create(Uu(u.attrs,e))))})})}),a},gx=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),yx=()=>({tr:n,dispatch:e})=>{if(e){let t=new Se(n.doc);n.setSelection(t)}return!0},bx=()=>({state:n,dispatch:e})=>zl(n,e),xx=()=>({state:n,dispatch:e})=>Hl(n,e),kx=()=>({state:n,dispatch:e})=>Fu(n,e),wx=()=>({state:n,dispatch:e})=>Ul(n,e),Sx=()=>({state:n,dispatch:e})=>Jl(n,e);function ta(n,e,t={},i={}){return nr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:i.errorOnInvalidContent})}var vx=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:i={}}={})=>({editor:r,tr:s,dispatch:o,commands:l})=>{let{doc:a}=s;if(i.preserveWhitespace!=="full"){let h=ta(n,r.schema,i,{errorOnInvalidContent:e??r.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,h).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:i,errorOnInvalidContent:e??r.options.enableContentCheck})};function ld(n,e){let t=Ft(e,n.schema),{from:i,to:r,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(i,r,a=>{o.push(...a.marks)});let l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Cx(n,e){let t=new Qn(n);return e.forEach(i=>{i.steps.forEach(r=>{t.step(r)})}),t}function Mx(n){for(let e=0;e<n.edgeCount;e+=1){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function cM(n,e){let t=[];return n.descendants((i,r)=>{e(i)&&t.push({node:i,pos:r})}),t}function fM(n,e,t){let i=[];return n.nodesBetween(e.from,e.to,(r,s)=>{t(r)&&i.push({node:r,pos:s})}),i}function Ax(n,e){for(let t=n.depth;t>0;t-=1){let i=n.node(t);if(e(i))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:i}}}function Cs(n){return e=>Ax(e.$from,n)}function P(n,e,t){return n.config[e]===void 0&&n.parent?P(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?P(n.parent,e,t):null}):n.config[e]}function oa(n){return n.map(e=>{let t={name:e.name,options:e.options,storage:e.storage},i=P(e,"addExtensions",t);return i?[e,...oa(i())]:e}).flat(10)}function la(n,e){let t=Et.fromSchema(e).serializeFragment(n),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(t),r.innerHTML}function ad(n){return typeof n=="function"}function U(n,e=void 0,...t){return ad(n)?e?n.bind(e)(...t):n(...t):n}function Tx(n={}){return Object.keys(n).length===0&&n.constructor===Object}function ci(n){let e=n.filter(r=>r.type==="extension"),t=n.filter(r=>r.type==="node"),i=n.filter(r=>r.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:i}}function hd(n){let e=[],{nodeExtensions:t,markExtensions:i}=ci(n),r=[...t,...i],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=t.filter(h=>h.name!=="text").map(h=>h.name),l=i.map(h=>h.name),a=[...o,...l];return n.forEach(h=>{let c={name:h.name,options:h.options,storage:h.storage,extensions:r},f=P(h,"addGlobalAttributes",c);if(!f)return;f().forEach(d=>{let p;Array.isArray(d.types)?p=d.types:d.types==="*"?p=a:d.types==="nodes"?p=o:d.types==="marks"?p=l:p=[],p.forEach(m=>{Object.entries(d.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...s,...y}})})})})}),r.forEach(h=>{let c={name:h.name,options:h.options,storage:h.storage},f=P(h,"addAttributes",c);if(!f)return;let u=f();Object.entries(u).forEach(([d,p])=>{let m={...s,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:h.name,name:d,attribute:m})})}),e}function Ox(n){let e=[],t="",i=!1,r=!1,s=0,o=n.length;for(let l=0;l<o;l+=1){let a=n[l];if(a==="'"&&!r){i=!i,t+=a;continue}if(a==='"'&&!i){r=!r,t+=a;continue}if(!i&&!r){if(a==="("){s+=1,t+=a;continue}if(a===")"&&s>0){s-=1,t+=a;continue}if(a===";"&&s===0){e.push(t),t="";continue}}t+=a}return t&&e.push(t),e}function Gu(n){let e=[],t=Ox(n||""),i=t.length;for(let r=0;r<i;r+=1){let s=t[r],o=s.indexOf(":");if(o===-1)continue;let l=s.slice(0,o).trim(),a=s.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function Ex(...n){return n.filter(e=>!!e).reduce((e,t)=>{let i={...e};return Object.entries(t).forEach(([r,s])=>{if(!i[r]){i[r]=s;return}if(r==="class"){let l=s?String(s).split(" "):[],a=i[r]?i[r].split(" "):[],h=l.filter(c=>!a.includes(c));i[r]=[...a,...h].join(" ")}else if(r==="style"){let l=new Map([...Gu(i[r]),...Gu(s)]);i[r]=Array.from(l.entries()).map(([a,h])=>`${a}: ${h}`).join("; ")}else i[r]=s}),i},{})}function ks(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,i)=>Ex(t,i),{})}function Dx(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Yu(n,e){return"style"in n?n:{...n,getAttrs:t=>{let i=n.getAttrs?n.getAttrs(t):n.attrs;if(i===!1)return!1;let r=e.reduce((s,o)=>{let l=o.attribute.parseHTML?o.attribute.parseHTML(t):Dx(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...i,...r}}}}function Xu(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Tx(t)?!1:t!=null))}function Qu(n){var e,t;let i={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(i.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(i.validate=n.attribute.validate),[n.name,i]}function Nx(n,e){var t;let i=hd(n),{nodeExtensions:r,markExtensions:s}=ci(n),o=(t=r.find(h=>P(h,"topNode")))==null?void 0:t.name,l=Object.fromEntries(r.map(h=>{let c=i.filter(y=>y.type===h.name),f={name:h.name,options:h.options,storage:h.storage,editor:e},u=n.reduce((y,b)=>{let x=P(b,"extendNodeSchema",f);return{...y,...x?x(h):{}}},{}),d=Xu({...u,content:U(P(h,"content",f)),marks:U(P(h,"marks",f)),group:U(P(h,"group",f)),inline:U(P(h,"inline",f)),atom:U(P(h,"atom",f)),selectable:U(P(h,"selectable",f)),draggable:U(P(h,"draggable",f)),code:U(P(h,"code",f)),whitespace:U(P(h,"whitespace",f)),linebreakReplacement:U(P(h,"linebreakReplacement",f)),defining:U(P(h,"defining",f)),isolating:U(P(h,"isolating",f)),attrs:Object.fromEntries(c.map(Qu))}),p=U(P(h,"parseHTML",f));p&&(d.parseDOM=p.map(y=>Yu(y,c)));let m=P(h,"renderHTML",f);m&&(d.toDOM=y=>m({node:y,HTMLAttributes:ks(y,c)}));let g=P(h,"renderText",f);return g&&(d.toText=g),[h.name,d]})),a=Object.fromEntries(s.map(h=>{let c=i.filter(g=>g.type===h.name),f={name:h.name,options:h.options,storage:h.storage,editor:e},u=n.reduce((g,y)=>{let b=P(y,"extendMarkSchema",f);return{...g,...b?b(h):{}}},{}),d=Xu({...u,inclusive:U(P(h,"inclusive",f)),excludes:U(P(h,"excludes",f)),group:U(P(h,"group",f)),spanning:U(P(h,"spanning",f)),code:U(P(h,"code",f)),attrs:Object.fromEntries(c.map(Qu))}),p=U(P(h,"parseHTML",f));p&&(d.parseDOM=p.map(g=>Yu(g,c)));let m=P(h,"renderHTML",f);return m&&(d.toDOM=g=>m({mark:g,HTMLAttributes:ks(g,c)})),[h.name,d]}));return new Gn({topNode:o,nodes:l,marks:a})}function Rx(n){let e=n.filter((t,i)=>n.indexOf(t)!==i);return Array.from(new Set(e))}function tr(n){return n.sort((t,i)=>{let r=P(t,"priority")||100,s=P(i,"priority")||100;return r>s?-1:r<s?1:0})}function cd(n){let e=tr(oa(n)),t=Rx(e.map(i=>i.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),e}function fd(n,e,t){let{from:i,to:r}=e,{blockSeparator:s=`
|
|
12
12
|
|
|
13
|
-
`,textSerializers:o={}}=t||{},l="";return n.nodesBetween(i,r,(a,h,c,f)=>{var u;a.isBlock&&h>i&&(l+=s);let d=o?.[a.type.name];if(d)return c&&(l+=d({node:a,pos:h,parent:c,index:f,range:e})),!1;a.isText&&(l+=(u=a?.text)==null?void 0:u.slice(Math.max(i,h)-h,r-h))}),l}function Px(n,e){let t={from:0,to:n.content.size};return fd(n,t,e)}function ud(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Bx(n,e){let t=he(e,n.schema),{from:i,to:r}=n.selection,s=[];n.doc.nodesBetween(i,r,l=>{s.push(l)});let o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Ix(n,e){let t=vs(typeof e=="string"?e:e.name,n.schema);return t==="node"?Bx(n,e):t==="mark"?ld(n,e):{}}function Lx(n,e=JSON.stringify){let t={};return n.filter(i=>{let r=e(i);return Object.prototype.hasOwnProperty.call(t,r)?!1:t[r]=!0})}function zx(n){let e=Lx(n);return e.length===1?e:e.filter((t,i)=>!e.filter((s,o)=>o!==i).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 Fx(n){let{mapping:e,steps:t}=n,i=[];return e.maps.forEach((r,s)=>{let o=[];if(r.ranges.length)r.forEach((l,a)=>{o.push({from:l,to:a})});else{let{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})=>{let h=e.slice(s).map(l,-1),c=e.slice(s).map(a),f=e.invert().map(h,-1),u=e.invert().map(c);i.push({oldRange:{from:f,to:u},newRange:{from:h,to:c}})})}),zx(i)}function dd(n,e,t){let i=[];return n===e?t.resolve(n).marks().forEach(r=>{let s=t.resolve(n),o=sa(s,r.type);o&&i.push({mark:r,...o})}):t.nodesBetween(n,e,(r,s)=>{!r||r?.nodeSize===void 0||i.push(...r.marks.map(o=>({from:s,to:s+r.nodeSize,mark:o})))}),i}var uM=(n,e,t,i=20)=>{let r=n.doc.resolve(t),s=i,o=null;for(;s>0&&o===null;){let l=r.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function Zi(n,e){return e.nodes[n]||e.marks[n]||null}function ys(n,e,t){return Object.fromEntries(Object.entries(t).filter(([i])=>{let r=n.find(s=>s.type===e&&s.name===i);return r?r.attribute.keepOnSplit:!1}))}var Vx=(n,e=500)=>{let t="",i=n.parentOffset;return n.parent.nodesBetween(Math.max(0,i-e),i,(r,s,o,l)=>{var a,h;let c=((h=(a=r.type.spec).toText)==null?void 0:h.call(a,{node:r,pos:s,parent:o,index:l}))||r.textContent||"%leaf%";t+=r.isAtom&&!r.isText?c:c.slice(0,Math.max(0,i-s))}),t};function na(n,e,t={}){let{empty:i,ranges:r}=n.selection,s=e?Ft(e,n.schema):null;if(i)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>bs(f.attrs,t,{strict:!1}));let o=0,l=[];if(r.forEach(({$from:f,$to:u})=>{let d=f.pos,p=u.pos;n.doc.nodesBetween(d,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;let y=Math.max(d,g),b=Math.min(p,g+m.nodeSize),x=b-y;o+=x,l.push(...m.marks.map(C=>({mark:C,from:y,to:b})))})}),o===0)return!1;let a=l.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>bs(f.mark.attrs,t,{strict:!1})).reduce((f,u)=>f+u.to-u.from,0),h=l.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,u)=>f+u.to-u.from,0);return(a>0?a+h:a)>=o}function Hx(n,e,t={}){if(!e)return ir(n,null,t)||na(n,null,t);let i=vs(e,n.schema);return i==="node"?ir(n,e,t):i==="mark"?na(n,e,t):!1}var dM=(n,e)=>{let{$from:t,$to:i,$anchor:r}=n.selection;if(e){let s=Cs(l=>l.type.name===e)(n.selection);if(!s)return!1;let o=n.doc.resolve(s.pos+1);return r.pos+1===o.end()}return!(i.parentOffset<i.parent.nodeSize-2||t.pos!==i.pos)},pM=n=>{let{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Zu(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Ql(n,e){let{nodeExtensions:t}=ci(e),i=t.find(o=>o.name===n);if(!i)return!1;let r={name:i.name,options:i.options,storage:i.storage},s=U(P(i,"group",r));return typeof s!="string"?!1:s.split(" ").includes("list")}function aa(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var i;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return!/\S/.test((i=n.text)!=null?i:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let r=!0;return n.content.forEach(s=>{r!==!1&&(aa(s,{ignoreWhitespace:t,checkChildren:e})||(r=!1))}),r}return!1}function gM(n){return n instanceof B}var pd=class md{constructor(e){this.position=e}static fromJSON(e){return new md(e.position)}toJSON(){return{position:this.position}}};function Wx(n,e){let t=e.mapping.mapResult(n.position);return{position:new pd(t.pos),mapResult:t}}function $x(n){return new pd(n)}function yM(n,e,t){let r=n.state.doc.content.size,s=zt(e,0,r),o=zt(t,0,r),l=n.coordsAtPos(s),a=n.coordsAtPos(o,-1),h=Math.min(l.top,a.top),c=Math.max(l.bottom,a.bottom),f=Math.min(l.left,a.left),u=Math.max(l.right,a.right),d=u-f,p=c-h,y={top:h,bottom:c,left:f,right:u,width:d,height:p,x:f,y:h};return{...y,toJSON:()=>y}}function qx(n,e,t){var i;let{selection:r}=e,s=null;if(id(r)&&(s=r.$cursor),s){let l=(i=n.storedMarks)!=null?i:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(h=>h.type.excludes(t)))}let{ranges:o}=r;return o.some(({$from:l,$to:a})=>{let h=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(c,f,u)=>{if(h)return!1;if(c.isInline){let d=!u||u.type.allowsMarkType(t),p=!!t.isInSet(c.marks)||!c.marks.some(m=>m.type.excludes(t));h=d&&p}return!h}),h})}var Kx=(n,e={})=>({tr:t,state:i,dispatch:r})=>{let{selection:s}=t,{empty:o,ranges:l}=s,a=Ft(n,i.schema);if(r)if(o){let h=ld(i,a);t.addStoredMark(a.create({...h,...e}))}else l.forEach(h=>{let c=h.$from.pos,f=h.$to.pos;i.doc.nodesBetween(c,f,(u,d)=>{let p=Math.max(d,c),m=Math.min(d+u.nodeSize,f);u.marks.find(y=>y.type===a)?u.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return qx(i,t,a)},jx=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),_x=(n,e={})=>({state:t,dispatch:i,chain:r})=>{let s=he(n,t.schema),o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?r().command(({commands:l})=>bl(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>bl(s,{...o,...e})(l,i)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Jx=n=>({tr:e,dispatch:t})=>{if(t){let{doc:i}=e,r=zt(n,0,i.content.size),s=B.create(i,r);e.setSelection(s)}return!0},Ux=(n,e)=>({tr:t,state:i,dispatch:r})=>{let{selection:s}=i,o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),r&&t.doc.nodesBetween(o,l,(a,h)=>{a.isText||t.setNodeMarkup(h,void 0,{...a.attrs,dir:n})}),!0},Gx=n=>({tr:e,dispatch:t})=>{if(t){let{doc:i}=e,{from:r,to:s}=typeof n=="number"?{from:n,to:n}:n,o=L.atStart(i).from,l=L.atEnd(i).to,a=zt(r,o,l),h=zt(s,o,l),c=L.create(i,a,h);e.setSelection(c)}return!0},Yx=n=>({state:e,dispatch:t})=>{let i=he(n,e.schema);return Bf(i)(e,t)};function ed(n,e){let t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){let i=t.filter(r=>e?.includes(r.type.name));n.tr.ensureMarks(i)}}var Xx=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:i,editor:r})=>{let{selection:s,doc:o}=e,{$from:l,$to:a}=s,h=r.extensionManager.attributes,c=ys(h,l.node().type.name,l.node().attrs);if(s instanceof B&&s.node.isBlock)return!l.parentOffset||!Le(o,l.pos)?!1:(i&&(n&&ed(t,r.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let f=a.parentOffset===a.parent.content.size,u=l.depth===0?void 0:Mx(l.node(-1).contentMatchAt(l.indexAfter(-1))),d=f&&u?[{type:u,attrs:c}]:void 0,p=Le(e.doc,e.mapping.map(l.pos),1,d);if(!d&&!p&&Le(e.doc,e.mapping.map(l.pos),1,u?[{type:u}]:void 0)&&(p=!0,d=u?[{type:u,attrs:c}]:void 0),i){if(p&&(s instanceof L&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,d),u&&!f&&!l.parentOffset&&l.parent.type!==u)){let m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,u)&&e.setNodeMarkup(e.mapping.map(l.before()),u)}n&&ed(t,r.extensionManager.splittableMarks),e.scrollIntoView()}return p},Qx=(n,e={})=>({tr:t,state:i,dispatch:r,editor:s})=>{var o;let l=he(n,i.schema),{$from:a,$to:h}=i.selection,c=i.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(h))return!1;let f=a.node(-1);if(f.type!==l)return!1;let u=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(r){let y=S.empty,b=a.index(-1)?1:a.index(-2)?2:3;for(let D=a.depth-b;D>=a.depth-3;D-=1)y=S.from(a.node(D).copy(y));let x=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,C={...ys(u,a.node().type.name,a.node().attrs),...e},w=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(C))||void 0;y=y.append(S.from(l.createAndFill(null,w)||void 0));let T=a.before(a.depth-(b-1));t.replace(T,a.after(-x),new O(y,4-b,0));let k=-1;t.doc.nodesBetween(T,t.doc.content.size,(D,R)=>{if(k>-1)return!1;D.isTextblock&&D.content.size===0&&(k=R+1)}),k>-1&&t.setSelection(L.near(t.doc.resolve(k))),t.scrollIntoView()}return!0}let d=h.pos===a.end()?f.contentMatchAt(0).defaultType:null,p={...ys(u,f.type.name,f.attrs),...e},m={...ys(u,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,h.pos);let g=d?[{type:l,attrs:p},{type:d,attrs:m}]:[{type:l,attrs:p}];if(!Le(t.doc,a.pos,2))return!1;if(r){let{selection:y,storedMarks:b}=i,{splittableMarks:x}=s.extensionManager,C=b||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!C||!r)return!0;let w=C.filter(T=>x.includes(T.type.name));t.ensureMarks(w)}return!0},Zl=(n,e)=>{let t=Cs(o=>o.type===e)(n.selection);if(!t)return!0;let i=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(i===void 0)return!0;let r=n.doc.nodeAt(i);return t.node.type===r?.type&&$e(n.doc,t.pos)&&n.join(t.pos),!0},ea=(n,e)=>{let t=Cs(o=>o.type===e)(n.selection);if(!t)return!0;let i=n.doc.resolve(t.start).after(t.depth);if(i===void 0)return!0;let r=n.doc.nodeAt(i);return t.node.type===r?.type&&$e(n.doc,i)&&n.join(i),!0};function Zx(n){let e=n.doc,t=e.firstChild;if(!t)return null;let i=e.resolve(1),r=e.resolve(t.nodeSize-1);return L.between(i,r)}var e1=(n,e,t,i={})=>({editor:r,tr:s,state:o,dispatch:l,chain:a,commands:h,can:c})=>{let{extensions:f,splittableMarks:u}=r.extensionManager,d=he(n,o.schema),p=he(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:b}=m,x=y.blockRange(b),C=g||m.$to.parentOffset&&m.$from.marks();if(!x)return!1;let w=Cs($=>Ql($.type.name,f))(m),T=m.from===0&&m.to===o.doc.content.size,k=o.doc.content.content,D=k.length===1?k[0]:null,R=T&&D&&Ql(D.type.name,f)?{node:D,pos:0,depth:0}:null,W=w??R,H=!!w&&x.depth>=1&&x.depth-w.depth<=1,I=!!R;if((H||I)&&W){if(W.node.type===d)return T&&I?a().command(({tr:$,dispatch:q})=>{let j=Zx($);return j?($.setSelection(j),q&&q($),!0):!1}).liftListItem(p).run():h.liftListItem(p);if(Ql(W.node.type.name,f)&&d.validContent(W.node.content))return a().command(()=>(s.setNodeMarkup(W.pos,d),!0)).command(()=>Zl(s,d)).command(()=>ea(s,d)).run()}return!t||!C||!l?a().command(()=>c().wrapInList(d,i)?!0:h.clearNodes()).wrapInList(d,i).command(()=>Zl(s,d)).command(()=>ea(s,d)).run():a().command(()=>{let $=c().wrapInList(d,i),q=C.filter(j=>u.includes(j.type.name));return s.ensureMarks(q),$?!0:h.clearNodes()}).wrapInList(d,i).command(()=>Zl(s,d)).command(()=>ea(s,d)).run()},t1=(n,e={},t={})=>({state:i,commands:r})=>{let{extendEmptyMarkRange:s=!1}=t,o=Ft(n,i.schema);return na(i,o,e)?r.unsetMark(o,{extendEmptyMarkRange:s}):r.setMark(o,e)},n1=(n,e,t={})=>({state:i,commands:r})=>{let s=he(n,i.schema),o=he(e,i.schema),l=ir(i,s,t),a;return i.selection.$anchor.sameParent(i.selection.$head)&&(a=i.selection.$anchor.parent.attrs),l?r.setNode(o,a):r.setNode(s,{...a,...t})},i1=(n,e={})=>({state:t,commands:i})=>{let r=he(n,t.schema);return ir(t,r,e)?i.lift(r):i.wrapIn(r,e)},r1=()=>({state:n,dispatch:e})=>{let t=n.plugins;for(let i=0;i<t.length;i+=1){let r=t[i],s;if(r.spec.isInputRules&&(s=r.getState(n))){if(e){let 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){let 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},s1=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,{empty:i,ranges:r}=t;return i||e&&r.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},o1=(n,e={})=>({tr:t,state:i,dispatch:r})=>{var s;let{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Ft(n,i.schema),{$from:h,empty:c,ranges:f}=l;if(!r)return!0;if(c&&o){let{from:u,to:d}=l,p=(s=h.marks().find(g=>g.type===a))==null?void 0:s.attrs,m=sa(h,a,p);m&&(u=m.from,d=m.to),t.removeMark(u,d,a)}else f.forEach(u=>{t.removeMark(u.$from.pos,u.$to.pos,a)});return t.removeStoredMark(a),!0},l1=n=>({tr:e,state:t,dispatch:i})=>{let{selection:r}=t,s,o;return typeof n=="number"?(s=n,o=n):n&&"from"in n&&"to"in n?(s=n.from,o=n.to):(s=r.from,o=r.to),i&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;let h={...l.attrs};delete h.dir,e.setNodeMarkup(a,void 0,h)}),!0},a1=(n,e={})=>({tr:t,state:i,dispatch:r})=>{let s=null,o=null,l=vs(typeof n=="string"?n:n.name,i.schema);if(!l)return!1;l==="node"&&(s=he(n,i.schema)),l==="mark"&&(o=Ft(n,i.schema));let a=!1;return t.selection.ranges.forEach(h=>{let c=h.$from.pos,f=h.$to.pos,u,d,p,m;t.selection.empty?i.doc.nodesBetween(c,f,(g,y)=>{s&&s===g.type&&(a=!0,p=Math.max(y,c),m=Math.min(y+g.nodeSize,f),u=y,d=g)}):i.doc.nodesBetween(c,f,(g,y)=>{y<c&&s&&s===g.type&&(a=!0,p=Math.max(y,c),m=Math.min(y+g.nodeSize,f),u=y,d=g),y>=c&&y<=f&&(s&&s===g.type&&(a=!0,r&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type&&(a=!0,r)){let x=Math.max(y,c),C=Math.min(y+g.nodeSize,f);t.addMark(x,C,o.create({...b.attrs,...e}))}}))}),d&&(u!==void 0&&r&&t.setNodeMarkup(u,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(g=>{o===g.type&&r&&t.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},h1=(n,e={})=>({state:t,dispatch:i})=>{let r=he(n,t.schema);return Nf(r,e)(t,i)},c1=(n,e={})=>({state:t,dispatch:i})=>{let r=he(n,t.schema);return Rf(r,e)(t,i)},f1=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){let t=this.callbacks[n];return t&&t.forEach(i=>i.apply(this,e)),this}off(n,e){let t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(i=>i!==e):delete this.callbacks[n]),this}once(n,e){let t=(...i)=>{this.off(n,t),e.apply(this,i)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},Ms=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},u1=(n,e)=>{if(ra(e))return e.exec(n);let t=e(n);if(!t)return null;let i=[t.text];return i.index=t.index,i.input=n,i.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(t.replaceWith)),i};function ps(n){var e;let{editor:t,from:i,to:r,text:s,rules:o,plugin:l}=n,{view:a}=t;if(a.composing)return!1;let h=a.state.doc.resolve(i);if(h.parent.type.spec.code||(e=h.nodeBefore||h.nodeAfter)!=null&&e.marks.find(u=>u.type.spec.code))return!1;let c=!1,f=Vx(h)+s;return o.forEach(u=>{if(c)return;let d=u1(f,u.find);if(!d)return;let p=a.state.tr,m=ws({state:a.state,transaction:p}),g={from:i-(d[0].length-s.length),to:r},{commands:y,chain:b,can:x}=new Ss({editor:t,state:m});u.handler({state:m,range:g,match:d,commands:y,chain:b,can:x})===null||!p.steps.length||(u.undoable&&p.setMeta(l,{transform:p,from:i,to:r,text:s}),a.dispatch(p),c=!0)}),c}function d1(n){let{editor:e,rules:t}=n,i=new J({state:{init(){return null},apply(r,s,o){let l=r.getMeta(i);if(l)return l;let a=r.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:c}=a;typeof c=="string"?c=c:c=la(S.from(c),o.schema);let{from:f}=a,u=f+c.length;ps({editor:e,from:f,to:u,text:c,rules:t,plugin:i})}),r.selectionSet||r.docChanged?null:s}},props:{handleTextInput(r,s,o,l){return ps({editor:e,from:s,to:o,text:l,rules:t,plugin:i})},handleDOMEvents:{compositionend:r=>(setTimeout(()=>{let{$cursor:s}=r.state.selection;s&&ps({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:i})}),!1)},handleKeyDown(r,s){if(s.key!=="Enter")return!1;let{$cursor:o}=r.state.selection;return o?ps({editor:e,from:o.pos,to:o.pos,text:`
|
|
14
|
-
`,rules:t,plugin:i}):!1}},isInputRules:!0});return i}function p1(n){return Object.prototype.toString.call(n).slice(8,-1)}function ms(n){return p1(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function gd(n,e){let t={...n};return ms(n)&&ms(e)&&Object.keys(e).forEach(i=>{ms(e[i])&&ms(n[i])?t[i]=gd(n[i],e[i]):t[i]=e[i]}),t}var ha=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{...U(P(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...U(P(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){let e=this.extend({...this.config,addOptions:()=>gd(this.options,n)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(n={}){let 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}},m1=class yd extends ha{constructor(){super(...arguments),this.type="mark"}static create(e={}){let t=typeof e=="function"?e():e;return new yd(t)}static handleExit({editor:e,mark:t}){let{tr:i}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let o=r.marks();if(!!!o.find(h=>h?.type.name===t.name))return!1;let a=o.find(h=>h?.type.name===t.name);return a&&i.removeStoredMark(a),i.insertText(" ",r.pos),e.view.dispatch(i),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}};function g1(n){return typeof n=="number"}var y1=class{constructor(n){this.find=n.find,this.handler=n.handler}},b1=(n,e,t)=>{if(ra(e))return[...n.matchAll(e)];let i=e(n,t);return i?i.map(r=>{let s=[r.text];return s.index=r.index,s.input=n,s.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(r.replaceWith)),s}):[]};function x1(n){let{editor:e,state:t,from:i,to:r,rule:s,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:h,can:c}=new Ss({editor:e,state:t}),f=[];return t.doc.nodesBetween(i,r,(d,p)=>{var m,g,y,b,x;if((g=(m=d.type)==null?void 0:m.spec)!=null&&g.code||!(d.isText||d.isTextblock||d.isInline))return;let C=(x=(b=(y=d.content)==null?void 0:y.size)!=null?b:d.nodeSize)!=null?x:0,w=Math.max(i,p),T=Math.min(r,p+C);if(w>=T)return;let k=d.isText?d.text||"":d.textBetween(w-p,T-p,void 0,"\uFFFC");b1(k,s.find,o).forEach(R=>{if(R.index===void 0)return;let W=w+R.index+1,H=W+R[0].length,I={from:t.tr.mapping.map(W),to:t.tr.mapping.map(H)},$=s.handler({state:t,range:I,match:R,commands:a,chain:h,can:c,pasteEvent:o,dropEvent:l});f.push($)})}),f.every(d=>d!==null)}var gs=null,k1=n=>{var e;let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function w1(n){let{editor:e,rules:t}=n,i=null,r=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:c,from:f,to:u,rule:d,pasteEvt:p})=>{let m=c.tr,g=ws({state:c,transaction:m});if(!(!x1({editor:e,state:g,from:Math.max(f-1,0),to:u.b-1,rule:d,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(c=>new J({view(f){let u=p=>{var m;i=(m=f.dom.parentElement)!=null&&m.contains(p.target)?f.dom.parentElement:null,i&&(gs=e)},d=()=>{gs&&(gs=null)};return window.addEventListener("dragstart",u),window.addEventListener("dragend",d),{destroy(){window.removeEventListener("dragstart",u),window.removeEventListener("dragend",d)}}},props:{handleDOMEvents:{drop:(f,u)=>{if(s=i===f.dom.parentElement,l=u,!s){let d=gs;d?.isEditable&&setTimeout(()=>{let p=d.state.selection;p&&d.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(f,u)=>{var d;let p=(d=u.clipboardData)==null?void 0:d.getData("text/html");return o=u,r=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(f,u,d)=>{let p=f[0],m=p.getMeta("uiEvent")==="paste"&&!r,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),b=!!y;if(!m&&!g&&!b)return;if(b){let{text:w}=y;typeof w=="string"?w=w:w=la(S.from(w),d.schema);let{from:T}=y,k=T+w.length,D=k1(w);return a({rule:c,state:d,from:T,to:{b:k},pasteEvt:D})}let x=u.doc.content.findDiffStart(d.doc.content),C=u.doc.content.findDiffEnd(d.doc.content);if(!(!g1(x)||!C||x===C.b))return a({rule:c,state:d,from:x,to:C,pasteEvt:o})}}))}var As=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=cd(n),this.schema=Nx(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Zi(e.name,this.schema)},i=P(e,"addCommands",t);return i?{...n,...i()}:n},{})}get plugins(){let{editor:n}=this;return tr([...this.extensions].reverse()).flatMap(i=>{let r={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:n,type:Zi(i.name,this.schema)},s=[],o=P(i,"addKeyboardShortcuts",r),l={};if(i.type==="mark"&&P(i,"exitable",r)&&(l.ArrowRight=()=>m1.handleExit({editor:n,mark:i})),o){let u=Object.fromEntries(Object.entries(o()).map(([d,p])=>[d,()=>p({editor:n})]));l={...l,...u}}let a=ju(l);s.push(a);let h=P(i,"addInputRules",r);if(Zu(i,n.options.enableInputRules)&&h){let u=h();if(u&&u.length){let d=d1({editor:n,rules:u}),p=Array.isArray(d)?d:[d];s.push(...p)}}let c=P(i,"addPasteRules",r);if(Zu(i,n.options.enablePasteRules)&&c){let u=c();if(u&&u.length){let d=w1({editor:n,rules:u});s.push(...d)}}let f=P(i,"addProseMirrorPlugins",r);if(f){let u=f();s.push(...u)}return s})}get attributes(){return hd(this.extensions)}get nodeViews(){let{editor:n}=this,{nodeExtensions:e}=ci(this.extensions);return Object.fromEntries(e.filter(t=>!!P(t,"addNodeView")).map(t=>{let i=this.attributes.filter(a=>a.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:he(t.name,this.schema)},s=P(t,"addNodeView",r);if(!s)return[];let o=s();if(!o)return[];let l=(a,h,c,f,u)=>{let d=ks(a,i);return o({node:a,view:h,getPos:c,decorations:f,innerDecorations:u,editor:n,extension:t,HTMLAttributes:d})};return[t.name,l]}))}dispatchTransaction(n){let{editor:e}=this;return tr([...this.extensions].reverse()).reduceRight((i,r)=>{let s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Zi(r.name,this.schema)},o=P(r,"dispatchTransaction",s);return o?l=>{o.call(s,{transaction:l,next:i})}:i},n)}transformPastedHTML(n){let{editor:e}=this;return tr([...this.extensions]).reduce((i,r)=>{let s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Zi(r.name,this.schema)},o=P(r,"transformPastedHTML",s);return o?(l,a)=>{let h=i(l,a);return o.call(s,h)}:i},n||(i=>i))}get markViews(){let{editor:n}=this,{markExtensions:e}=ci(this.extensions);return Object.fromEntries(e.filter(t=>!!P(t,"addMarkView")).map(t=>{let i=this.attributes.filter(l=>l.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:Ft(t.name,this.schema)},s=P(t,"addMarkView",r);if(!s)return[];let o=(l,a,h)=>{let c=ks(l,i);return s()({mark:l,view:a,inline:h,editor:n,extension:t,HTMLAttributes:c,updateAttributes:f=>{I1(l,n,f)}})};return[t.name,o]}))}destroy(){this.extensions.forEach(n=>{let e=n;for(;e.parent;){let t=e.parent;t.child===e&&(t.child=null),e=t}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){let n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;let i={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Zi(e.name,this.schema)};e.type==="mark"&&((t=U(P(e,"keepOnSplit",i)))==null||t)&&this.splittableMarks.push(e.name);let r=P(e,"onBeforeCreate",i),s=P(e,"onCreate",i),o=P(e,"onUpdate",i),l=P(e,"onSelectionUpdate",i),a=P(e,"onTransaction",i),h=P(e,"onFocus",i),c=P(e,"onBlur",i),f=P(e,"onDestroy",i);r&&this.editor.on("beforeCreate",r),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),h&&this.editor.on("focus",h),c&&this.editor.on("blur",c),f&&this.editor.on("destroy",f)})}};As.resolve=cd;As.sort=tr;As.flatten=oa;var S1={};ia(S1,{ClipboardTextSerializer:()=>xd,Commands:()=>kd,Delete:()=>wd,Drop:()=>Sd,Editable:()=>vd,FocusEvents:()=>Md,Keymap:()=>Ad,Paste:()=>Td,Tabindex:()=>Od,TextDirection:()=>Ed,focusEventsPluginKey:()=>Cd});var Je=class bd extends ha{constructor(){super(...arguments),this.type="extension"}static create(e={}){let t=typeof e=="function"?e():e;return new bd(t)}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}},xd=Je.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new J({key:new te("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:e,schema:t}=n,{doc:i,selection:r}=e,{ranges:s}=r,o=Math.min(...s.map(c=>c.$from.pos)),l=Math.max(...s.map(c=>c.$to.pos)),a=ud(t);return fd(i,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),kd=Je.create({name:"commands",addCommands(){return{...td}}}),wd=Je.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,i,r;let s=()=>{var o,l,a,h;if((h=(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?h:n.getMeta("y-sync$"))return;let c=Cx(n.before,[n,...e]);Fx(c).forEach(d=>{c.mapping.mapResult(d.oldRange.from).deletedAfter&&c.mapping.mapResult(d.oldRange.to).deletedBefore&&c.before.nodesBetween(d.oldRange.from,d.oldRange.to,(p,m)=>{let g=m+p.nodeSize-2,y=d.oldRange.from<=m&&g<=d.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:c.mapping.map(m),newTo:c.mapping.map(g),deletedRange:d.oldRange,newRange:d.newRange,partial:!y,editor:this.editor,transaction:n,combinedTransform:c})})});let u=c.mapping;c.steps.forEach((d,p)=>{var m,g;if(d instanceof Nt){let y=u.slice(p).map(d.from,-1),b=u.slice(p).map(d.to),x=u.invert().map(y,-1),C=u.invert().map(b),w=y>0?(m=c.doc.nodeAt(y-1))==null?void 0:m.marks.some(k=>k.eq(d.mark)):!1,T=(g=c.doc.nodeAt(b))==null?void 0:g.marks.some(k=>k.eq(d.mark));this.editor.emit("delete",{type:"mark",mark:d.mark,from:d.from,to:d.to,deletedRange:{from:x,to:C},newRange:{from:y,to:b},partial:!!(T||w),editor:this.editor,transaction:n,combinedTransform:c})}})};(r=(i=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:i.async)==null||r?setTimeout(s,0):s()}}),Sd=Je.create({name:"drop",addProseMirrorPlugins(){return[new J({key:new te("tiptapDrop"),props:{handleDrop:(n,e,t,i)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:i})}}})]}}),vd=Je.create({name:"editable",addProseMirrorPlugins(){return[new J({key:new te("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Cd=new te("focusEvents"),Md=Je.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new J({key:Cd,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;let i=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(i),!1},blur:(e,t)=>{n.isFocused=!1;let i=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(i),!1}}}})]}}),Ad=Je.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{let{selection:a,doc:h}=l,{empty:c,$anchor:f}=a,{pos:u,parent:d}=f,p=f.parent.isTextblock&&u>0?l.doc.resolve(u-1):f,m=p.parent.type.spec.isolating,g=f.pos-f.parentOffset,y=m&&p.parent.childCount===1?g===f.pos:F.atStart(h).from===u;return!c||!d.type.isTextblock||d.textContent.length||!y||y&&f.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()]),i={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()},r={...i},s={...i,"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 xs()||od()?s:r},addProseMirrorPlugins(){return[new J({key:new te("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(m=>m.getMeta("composition")))return;let i=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),r=n.some(m=>m.getMeta("preventClearDocument"));if(!i||r)return;let{empty:s,from:o,to:l}=e.selection,a=F.atStart(e.doc).from,h=F.atEnd(e.doc).to;if(s||!(o===a&&l===h)||!aa(t.doc))return;let u=t.tr,d=ws({state:t,transaction:u}),{commands:p}=new Ss({editor:this.editor,state:d});if(p.clearNodes(),!!u.steps.length)return u}})]}}),Td=Je.create({name:"paste",addProseMirrorPlugins(){return[new J({key:new te("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Od=Je.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new J({key:new te("tabindex"),props:{attributes:()=>{var n;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(n=this.options.value)!=null?n:"0"}}}})]}}),Ed=Je.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:n}=ci(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new J({key:new te("textDirection"),props:{attributes:()=>{let n=this.options.direction;return n?{dir:n}:{}}}})]}}),v1=class er{constructor(e,t,i=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=i,this.resolvedPos=e,this.editor=t,this.currentNode=r}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,i=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,i=this.to-1}this.editor.commands.insertContentAt({from:t,to:i},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new er(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 er(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 er(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,i)=>{let r=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=t.isInline,l=this.pos+i+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!r&&!o&&a.depth<=this.depth)return;let h=new er(a,this.editor,r,r||o?t:null);r&&(h.actualDepth=this.depth+1),e.push(h)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let i=null,r=this.parent;for(;r&&!i;){if(r.node.type.name===e)if(Object.keys(t).length>0){let s=r.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){let a=o[l];if(s[a]!==t[a])break}}else i=r;r=r.parent}return i}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},i=!1){let r=[];if(!this.children||this.children.length===0)return r;let s=Object.keys(t);return this.children.forEach(o=>{i&&r.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&r.push(o),!(i&&r.length>0)&&(r=r.concat(o.querySelectorAll(e,t,i))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},C1=`.ProseMirror {
|
|
13
|
+
`,textSerializers:o={}}=t||{},l="";return n.nodesBetween(i,r,(a,h,c,f)=>{var u;a.isBlock&&h>i&&(l+=s);let d=o?.[a.type.name];if(d)return c&&(l+=d({node:a,pos:h,parent:c,index:f,range:e})),!1;a.isText&&(l+=(u=a?.text)==null?void 0:u.slice(Math.max(i,h)-h,r-h))}),l}function Px(n,e){let t={from:0,to:n.content.size};return fd(n,t,e)}function ud(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Ix(n,e){let t=he(e,n.schema),{from:i,to:r}=n.selection,s=[];n.doc.nodesBetween(i,r,l=>{s.push(l)});let o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Bx(n,e){let t=vs(typeof e=="string"?e:e.name,n.schema);return t==="node"?Ix(n,e):t==="mark"?ld(n,e):{}}function Lx(n,e=JSON.stringify){let t={};return n.filter(i=>{let r=e(i);return Object.prototype.hasOwnProperty.call(t,r)?!1:t[r]=!0})}function zx(n){let e=Lx(n);return e.length===1?e:e.filter((t,i)=>!e.filter((s,o)=>o!==i).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 Fx(n){let{mapping:e,steps:t}=n,i=[];return e.maps.forEach((r,s)=>{let o=[];if(r.ranges.length)r.forEach((l,a)=>{o.push({from:l,to:a})});else{let{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})=>{let h=e.slice(s).map(l,-1),c=e.slice(s).map(a),f=e.invert().map(h,-1),u=e.invert().map(c);i.push({oldRange:{from:f,to:u},newRange:{from:h,to:c}})})}),zx(i)}function dd(n,e,t){let i=[];return n===e?t.resolve(n).marks().forEach(r=>{let s=t.resolve(n),o=sa(s,r.type);o&&i.push({mark:r,...o})}):t.nodesBetween(n,e,(r,s)=>{!r||r?.nodeSize===void 0||i.push(...r.marks.map(o=>({from:s,to:s+r.nodeSize,mark:o})))}),i}var yM=(n,e,t,i=20)=>{let r=n.doc.resolve(t),s=i,o=null;for(;s>0&&o===null;){let l=r.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function Zi(n,e){return e.nodes[n]||e.marks[n]||null}function ys(n,e,t){return Object.fromEntries(Object.entries(t).filter(([i])=>{let r=n.find(s=>s.type===e&&s.name===i);return r?r.attribute.keepOnSplit:!1}))}var Vx=(n,e=500)=>{let t="",i=n.parentOffset;return n.parent.nodesBetween(Math.max(0,i-e),i,(r,s,o,l)=>{var a,h;let c=((h=(a=r.type.spec).toText)==null?void 0:h.call(a,{node:r,pos:s,parent:o,index:l}))||r.textContent||"%leaf%";t+=r.isAtom&&!r.isText?c:c.slice(0,Math.max(0,i-s))}),t};function na(n,e,t={}){let{empty:i,ranges:r}=n.selection,s=e?Ft(e,n.schema):null;if(i)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>bs(f.attrs,t,{strict:!1}));let o=0,l=[];if(r.forEach(({$from:f,$to:u})=>{let d=f.pos,p=u.pos;n.doc.nodesBetween(d,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;let y=Math.max(d,g),b=Math.min(p,g+m.nodeSize),x=b-y;o+=x,l.push(...m.marks.map(C=>({mark:C,from:y,to:b})))})}),o===0)return!1;let a=l.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>bs(f.mark.attrs,t,{strict:!1})).reduce((f,u)=>f+u.to-u.from,0),h=l.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,u)=>f+u.to-u.from,0);return(a>0?a+h:a)>=o}function Hx(n,e,t={}){if(!e)return ir(n,null,t)||na(n,null,t);let i=vs(e,n.schema);return i==="node"?ir(n,e,t):i==="mark"?na(n,e,t):!1}var bM=(n,e)=>{let{$from:t,$to:i,$anchor:r}=n.selection;if(e){let s=Cs(l=>l.type.name===e)(n.selection);if(!s)return!1;let o=n.doc.resolve(s.pos+1);return r.pos+1===o.end()}return!(i.parentOffset<i.parent.nodeSize-2||t.pos!==i.pos)},xM=n=>{let{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Zu(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Ql(n,e){let{nodeExtensions:t}=ci(e),i=t.find(o=>o.name===n);if(!i)return!1;let r={name:i.name,options:i.options,storage:i.storage},s=U(P(i,"group",r));return typeof s!="string"?!1:s.split(" ").includes("list")}function aa(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var i;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return!/\S/.test((i=n.text)!=null?i:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let r=!0;return n.content.forEach(s=>{r!==!1&&(aa(s,{ignoreWhitespace:t,checkChildren:e})||(r=!1))}),r}return!1}function wM(n){return n instanceof I}var pd=class md{constructor(e){this.position=e}static fromJSON(e){return new md(e.position)}toJSON(){return{position:this.position}}};function Wx(n,e){let t=e.mapping.mapResult(n.position);return{position:new pd(t.pos),mapResult:t}}function $x(n){return new pd(n)}function SM(n,e,t){let r=n.state.doc.content.size,s=zt(e,0,r),o=zt(t,0,r),l=n.coordsAtPos(s),a=n.coordsAtPos(o,-1),h=Math.min(l.top,a.top),c=Math.max(l.bottom,a.bottom),f=Math.min(l.left,a.left),u=Math.max(l.right,a.right),d=u-f,p=c-h,y={top:h,bottom:c,left:f,right:u,width:d,height:p,x:f,y:h};return{...y,toJSON:()=>y}}function _x(n,e,t){var i;let{selection:r}=e,s=null;if(id(r)&&(s=r.$cursor),s){let l=(i=n.storedMarks)!=null?i:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(h=>h.type.excludes(t)))}let{ranges:o}=r;return o.some(({$from:l,$to:a})=>{let h=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(c,f,u)=>{if(h)return!1;if(c.isInline){let d=!u||u.type.allowsMarkType(t),p=!!t.isInSet(c.marks)||!c.marks.some(m=>m.type.excludes(t));h=d&&p}return!h}),h})}var Kx=(n,e={})=>({tr:t,state:i,dispatch:r})=>{let{selection:s}=t,{empty:o,ranges:l}=s,a=Ft(n,i.schema);if(r)if(o){let h=ld(i,a);t.addStoredMark(a.create({...h,...e}))}else l.forEach(h=>{let c=h.$from.pos,f=h.$to.pos;i.doc.nodesBetween(c,f,(u,d)=>{let p=Math.max(d,c),m=Math.min(d+u.nodeSize,f);u.marks.find(y=>y.type===a)?u.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return _x(i,t,a)},qx=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),jx=(n,e={})=>({state:t,dispatch:i,chain:r})=>{let s=he(n,t.schema),o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?r().command(({commands:l})=>Gl(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Gl(s,{...o,...e})(l,i)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Jx=n=>({tr:e,dispatch:t})=>{if(t){let{doc:i}=e,r=zt(n,0,i.content.size),s=I.create(i,r);e.setSelection(s)}return!0},Ux=(n,e)=>({tr:t,state:i,dispatch:r})=>{let{selection:s}=i,o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),r&&t.doc.nodesBetween(o,l,(a,h)=>{a.isText||t.setNodeMarkup(h,void 0,{...a.attrs,dir:n})}),!0},Gx=n=>({tr:e,dispatch:t})=>{if(t){let{doc:i}=e,{from:r,to:s}=typeof n=="number"?{from:n,to:n}:n,o=L.atStart(i).from,l=L.atEnd(i).to,a=zt(r,o,l),h=zt(s,o,l),c=L.create(i,a,h);e.setSelection(c)}return!0},Yx=n=>({state:e,dispatch:t})=>{let i=he(n,e.schema);return Ku(i)(e,t)};function ed(n,e){let t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){let i=t.filter(r=>e?.includes(r.type.name));n.tr.ensureMarks(i)}}var Xx=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:i,editor:r})=>{let{selection:s,doc:o}=e,{$from:l,$to:a}=s,h=r.extensionManager.attributes,c=ys(h,l.node().type.name,l.node().attrs);if(s instanceof I&&s.node.isBlock)return!l.parentOffset||!Le(o,l.pos)?!1:(i&&(n&&ed(t,r.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let f=a.parentOffset===a.parent.content.size,u=l.depth===0?void 0:Mx(l.node(-1).contentMatchAt(l.indexAfter(-1))),d=f&&u?[{type:u,attrs:c}]:void 0,p=Le(e.doc,e.mapping.map(l.pos),1,d);if(!d&&!p&&Le(e.doc,e.mapping.map(l.pos),1,u?[{type:u}]:void 0)&&(p=!0,d=u?[{type:u,attrs:c}]:void 0),i){if(p&&(s instanceof L&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,d),u&&!f&&!l.parentOffset&&l.parent.type!==u)){let m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,u)&&e.setNodeMarkup(e.mapping.map(l.before()),u)}n&&ed(t,r.extensionManager.splittableMarks),e.scrollIntoView()}return p},Qx=(n,e={})=>({tr:t,state:i,dispatch:r,editor:s})=>{var o;let l=he(n,i.schema),{$from:a,$to:h}=i.selection,c=i.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(h))return!1;let f=a.node(-1);if(f.type!==l)return!1;let u=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(r){let y=S.empty,b=a.index(-1)?1:a.index(-2)?2:3;for(let D=a.depth-b;D>=a.depth-3;D-=1)y=S.from(a.node(D).copy(y));let x=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,C={...ys(u,a.node().type.name,a.node().attrs),...e},w=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(C))||void 0;y=y.append(S.from(l.createAndFill(null,w)||void 0));let T=a.before(a.depth-(b-1));t.replace(T,a.after(-x),new O(y,4-b,0));let k=-1;t.doc.nodesBetween(T,t.doc.content.size,(D,R)=>{if(k>-1)return!1;D.isTextblock&&D.content.size===0&&(k=R+1)}),k>-1&&t.setSelection(L.near(t.doc.resolve(k))),t.scrollIntoView()}return!0}let d=h.pos===a.end()?f.contentMatchAt(0).defaultType:null,p={...ys(u,f.type.name,f.attrs),...e},m={...ys(u,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,h.pos);let g=d?[{type:l,attrs:p},{type:d,attrs:m}]:[{type:l,attrs:p}];if(!Le(t.doc,a.pos,2))return!1;if(r){let{selection:y,storedMarks:b}=i,{splittableMarks:x}=s.extensionManager,C=b||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!C||!r)return!0;let w=C.filter(T=>x.includes(T.type.name));t.ensureMarks(w)}return!0},Zl=(n,e)=>{let t=Cs(o=>o.type===e)(n.selection);if(!t)return!0;let i=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(i===void 0)return!0;let r=n.doc.nodeAt(i);return t.node.type===r?.type&&$e(n.doc,t.pos)&&n.join(t.pos),!0},ea=(n,e)=>{let t=Cs(o=>o.type===e)(n.selection);if(!t)return!0;let i=n.doc.resolve(t.start).after(t.depth);if(i===void 0)return!0;let r=n.doc.nodeAt(i);return t.node.type===r?.type&&$e(n.doc,i)&&n.join(i),!0};function Zx(n){let e=n.doc,t=e.firstChild;if(!t)return null;let i=e.resolve(1),r=e.resolve(t.nodeSize-1);return L.between(i,r)}var e1=(n,e,t,i={})=>({editor:r,tr:s,state:o,dispatch:l,chain:a,commands:h,can:c})=>{let{extensions:f,splittableMarks:u}=r.extensionManager,d=he(n,o.schema),p=he(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:b}=m,x=y.blockRange(b),C=g||m.$to.parentOffset&&m.$from.marks();if(!x)return!1;let w=Cs($=>Ql($.type.name,f))(m),T=m.from===0&&m.to===o.doc.content.size,k=o.doc.content.content,D=k.length===1?k[0]:null,R=T&&D&&Ql(D.type.name,f)?{node:D,pos:0,depth:0}:null,W=w??R,H=!!w&&x.depth>=1&&x.depth-w.depth<=1,B=!!R;if((H||B)&&W){if(W.node.type===d)return T&&B?a().command(({tr:$,dispatch:_})=>{let q=Zx($);return q?($.setSelection(q),_&&_($),!0):!1}).liftListItem(p).run():h.liftListItem(p);if(Ql(W.node.type.name,f)&&d.validContent(W.node.content))return a().command(()=>(s.setNodeMarkup(W.pos,d),!0)).command(()=>Zl(s,d)).command(()=>ea(s,d)).run()}return!t||!C||!l?a().command(()=>c().wrapInList(d,i)?!0:h.clearNodes()).wrapInList(d,i).command(()=>Zl(s,d)).command(()=>ea(s,d)).run():a().command(()=>{let $=c().wrapInList(d,i),_=C.filter(q=>u.includes(q.type.name));return s.ensureMarks(_),$?!0:h.clearNodes()}).wrapInList(d,i).command(()=>Zl(s,d)).command(()=>ea(s,d)).run()},t1=(n,e={},t={})=>({state:i,commands:r})=>{let{extendEmptyMarkRange:s=!1}=t,o=Ft(n,i.schema);return na(i,o,e)?r.unsetMark(o,{extendEmptyMarkRange:s}):r.setMark(o,e)},n1=(n,e,t={})=>({state:i,commands:r})=>{let s=he(n,i.schema),o=he(e,i.schema),l=ir(i,s,t),a;return i.selection.$anchor.sameParent(i.selection.$head)&&(a=i.selection.$anchor.parent.attrs),l?r.setNode(o,a):r.setNode(s,{...a,...t})},i1=(n,e={})=>({state:t,commands:i})=>{let r=he(n,t.schema);return ir(t,r,e)?i.lift(r):i.wrapIn(r,e)},r1=()=>({state:n,dispatch:e})=>{let t=n.plugins;for(let i=0;i<t.length;i+=1){let r=t[i],s;if(r.spec.isInputRules&&(s=r.getState(n))){if(e){let 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){let 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},s1=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,{empty:i,ranges:r}=t;return i||e&&r.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},o1=(n,e={})=>({tr:t,state:i,dispatch:r})=>{var s;let{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Ft(n,i.schema),{$from:h,empty:c,ranges:f}=l;if(!r)return!0;if(c&&o){let{from:u,to:d}=l,p=(s=h.marks().find(g=>g.type===a))==null?void 0:s.attrs,m=sa(h,a,p);m&&(u=m.from,d=m.to),t.removeMark(u,d,a)}else f.forEach(u=>{t.removeMark(u.$from.pos,u.$to.pos,a)});return t.removeStoredMark(a),!0},l1=n=>({tr:e,state:t,dispatch:i})=>{let{selection:r}=t,s,o;return typeof n=="number"?(s=n,o=n):n&&"from"in n&&"to"in n?(s=n.from,o=n.to):(s=r.from,o=r.to),i&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;let h={...l.attrs};delete h.dir,e.setNodeMarkup(a,void 0,h)}),!0},a1=(n,e={})=>({tr:t,state:i,dispatch:r})=>{let s=null,o=null,l=vs(typeof n=="string"?n:n.name,i.schema);if(!l)return!1;l==="node"&&(s=he(n,i.schema)),l==="mark"&&(o=Ft(n,i.schema));let a=!1;return t.selection.ranges.forEach(h=>{let c=h.$from.pos,f=h.$to.pos,u,d,p,m;t.selection.empty?i.doc.nodesBetween(c,f,(g,y)=>{s&&s===g.type&&(a=!0,p=Math.max(y,c),m=Math.min(y+g.nodeSize,f),u=y,d=g)}):i.doc.nodesBetween(c,f,(g,y)=>{y<c&&s&&s===g.type&&(a=!0,p=Math.max(y,c),m=Math.min(y+g.nodeSize,f),u=y,d=g),y>=c&&y<=f&&(s&&s===g.type&&(a=!0,r&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type&&(a=!0,r)){let x=Math.max(y,c),C=Math.min(y+g.nodeSize,f);t.addMark(x,C,o.create({...b.attrs,...e}))}}))}),d&&(u!==void 0&&r&&t.setNodeMarkup(u,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(g=>{o===g.type&&r&&t.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},h1=(n,e={})=>({state:t,dispatch:i})=>{let r=he(n,t.schema);return Wu(r,e)(t,i)},c1=(n,e={})=>({state:t,dispatch:i})=>{let r=he(n,t.schema);return $u(r,e)(t,i)},f1=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){let t=this.callbacks[n];return t&&t.forEach(i=>i.apply(this,e)),this}off(n,e){let t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(i=>i!==e):delete this.callbacks[n]),this}once(n,e){let t=(...i)=>{this.off(n,t),e.apply(this,i)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},Ms=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},u1=(n,e)=>{if(ra(e))return e.exec(n);let t=e(n);if(!t)return null;let i=[t.text];return i.index=t.index,i.input=n,i.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(t.replaceWith)),i};function ps(n){var e;let{editor:t,from:i,to:r,text:s,rules:o,plugin:l}=n,{view:a}=t;if(a.composing)return!1;let h=a.state.doc.resolve(i);if(h.parent.type.spec.code||(e=h.nodeBefore||h.nodeAfter)!=null&&e.marks.find(u=>u.type.spec.code))return!1;let c=!1,f=Vx(h)+s;return o.forEach(u=>{if(c)return;let d=u1(f,u.find);if(!d)return;let p=a.state.tr,m=ws({state:a.state,transaction:p}),g={from:i-(d[0].length-s.length),to:r},{commands:y,chain:b,can:x}=new Ss({editor:t,state:m});u.handler({state:m,range:g,match:d,commands:y,chain:b,can:x})===null||!p.steps.length||(u.undoable&&p.setMeta(l,{transform:p,from:i,to:r,text:s}),a.dispatch(p),c=!0)}),c}function d1(n){let{editor:e,rules:t}=n,i=new J({state:{init(){return null},apply(r,s,o){let l=r.getMeta(i);if(l)return l;let a=r.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:c}=a;typeof c=="string"?c=c:c=la(S.from(c),o.schema);let{from:f}=a,u=f+c.length;ps({editor:e,from:f,to:u,text:c,rules:t,plugin:i})}),r.selectionSet||r.docChanged?null:s}},props:{handleTextInput(r,s,o,l){return ps({editor:e,from:s,to:o,text:l,rules:t,plugin:i})},handleDOMEvents:{compositionend:r=>(setTimeout(()=>{let{$cursor:s}=r.state.selection;s&&ps({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:i})}),!1)},handleKeyDown(r,s){if(s.key!=="Enter")return!1;let{$cursor:o}=r.state.selection;return o?ps({editor:e,from:o.pos,to:o.pos,text:`
|
|
14
|
+
`,rules:t,plugin:i}):!1}},isInputRules:!0});return i}function p1(n){return Object.prototype.toString.call(n).slice(8,-1)}function ms(n){return p1(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function gd(n,e){let t={...n};return ms(n)&&ms(e)&&Object.keys(e).forEach(i=>{ms(e[i])&&ms(n[i])?t[i]=gd(n[i],e[i]):t[i]=e[i]}),t}var ha=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{...U(P(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...U(P(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){let e=this.extend({...this.config,addOptions:()=>gd(this.options,n)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(n={}){let 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}},m1=class yd extends ha{constructor(){super(...arguments),this.type="mark"}static create(e={}){let t=typeof e=="function"?e():e;return new yd(t)}static handleExit({editor:e,mark:t}){let{tr:i}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let o=r.marks();if(!!!o.find(h=>h?.type.name===t.name))return!1;let a=o.find(h=>h?.type.name===t.name);return a&&i.removeStoredMark(a),i.insertText(" ",r.pos),e.view.dispatch(i),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}};function g1(n){return typeof n=="number"}var y1=class{constructor(n){this.find=n.find,this.handler=n.handler}},b1=(n,e,t)=>{if(ra(e))return[...n.matchAll(e)];let i=e(n,t);return i?i.map(r=>{let s=[r.text];return s.index=r.index,s.input=n,s.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(r.replaceWith)),s}):[]};function x1(n){let{editor:e,state:t,from:i,to:r,rule:s,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:h,can:c}=new Ss({editor:e,state:t}),f=[];return t.doc.nodesBetween(i,r,(d,p)=>{var m,g,y,b,x;if((g=(m=d.type)==null?void 0:m.spec)!=null&&g.code||!(d.isText||d.isTextblock||d.isInline))return;let C=(x=(b=(y=d.content)==null?void 0:y.size)!=null?b:d.nodeSize)!=null?x:0,w=Math.max(i,p),T=Math.min(r,p+C);if(w>=T)return;let k=d.isText?d.text||"":d.textBetween(w-p,T-p,void 0,"\uFFFC");b1(k,s.find,o).forEach(R=>{if(R.index===void 0)return;let W=w+R.index+1,H=W+R[0].length,B={from:t.tr.mapping.map(W),to:t.tr.mapping.map(H)},$=s.handler({state:t,range:B,match:R,commands:a,chain:h,can:c,pasteEvent:o,dropEvent:l});f.push($)})}),f.every(d=>d!==null)}var gs=null,k1=n=>{var e;let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function w1(n){let{editor:e,rules:t}=n,i=null,r=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:c,from:f,to:u,rule:d,pasteEvt:p})=>{let m=c.tr,g=ws({state:c,transaction:m});if(!(!x1({editor:e,state:g,from:Math.max(f-1,0),to:u.b-1,rule:d,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(c=>new J({view(f){let u=p=>{var m;i=(m=f.dom.parentElement)!=null&&m.contains(p.target)?f.dom.parentElement:null,i&&(gs=e)},d=()=>{gs&&(gs=null)};return window.addEventListener("dragstart",u),window.addEventListener("dragend",d),{destroy(){window.removeEventListener("dragstart",u),window.removeEventListener("dragend",d)}}},props:{handleDOMEvents:{drop:(f,u)=>{if(s=i===f.dom.parentElement,l=u,!s){let d=gs;d?.isEditable&&setTimeout(()=>{let p=d.state.selection;p&&d.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(f,u)=>{var d;let p=(d=u.clipboardData)==null?void 0:d.getData("text/html");return o=u,r=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(f,u,d)=>{let p=f[0],m=p.getMeta("uiEvent")==="paste"&&!r,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),b=!!y;if(!m&&!g&&!b)return;if(b){let{text:w}=y;typeof w=="string"?w=w:w=la(S.from(w),d.schema);let{from:T}=y,k=T+w.length,D=k1(w);return a({rule:c,state:d,from:T,to:{b:k},pasteEvt:D})}let x=u.doc.content.findDiffStart(d.doc.content),C=u.doc.content.findDiffEnd(d.doc.content);if(!(!g1(x)||!C||x===C.b))return a({rule:c,state:d,from:x,to:C,pasteEvt:o})}}))}var As=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=cd(n),this.schema=Nx(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Zi(e.name,this.schema)},i=P(e,"addCommands",t);return i?{...n,...i()}:n},{})}get plugins(){let{editor:n}=this;return tr([...this.extensions].reverse()).flatMap(i=>{let r={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:n,type:Zi(i.name,this.schema)},s=[],o=P(i,"addKeyboardShortcuts",r),l={};if(i.type==="mark"&&P(i,"exitable",r)&&(l.ArrowRight=()=>m1.handleExit({editor:n,mark:i})),o){let u=Object.fromEntries(Object.entries(o()).map(([d,p])=>[d,()=>p({editor:n})]));l={...l,...u}}let a=qu(l);s.push(a);let h=P(i,"addInputRules",r);if(Zu(i,n.options.enableInputRules)&&h){let u=h();if(u&&u.length){let d=d1({editor:n,rules:u}),p=Array.isArray(d)?d:[d];s.push(...p)}}let c=P(i,"addPasteRules",r);if(Zu(i,n.options.enablePasteRules)&&c){let u=c();if(u&&u.length){let d=w1({editor:n,rules:u});s.push(...d)}}let f=P(i,"addProseMirrorPlugins",r);if(f){let u=f();s.push(...u)}return s})}get attributes(){return hd(this.extensions)}get nodeViews(){let{editor:n}=this,{nodeExtensions:e}=ci(this.extensions);return Object.fromEntries(e.filter(t=>!!P(t,"addNodeView")).map(t=>{let i=this.attributes.filter(a=>a.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:he(t.name,this.schema)},s=P(t,"addNodeView",r);if(!s)return[];let o=s();if(!o)return[];let l=(a,h,c,f,u)=>{let d=ks(a,i);return o({node:a,view:h,getPos:c,decorations:f,innerDecorations:u,editor:n,extension:t,HTMLAttributes:d})};return[t.name,l]}))}dispatchTransaction(n){let{editor:e}=this;return tr([...this.extensions].reverse()).reduceRight((i,r)=>{let s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Zi(r.name,this.schema)},o=P(r,"dispatchTransaction",s);return o?l=>{o.call(s,{transaction:l,next:i})}:i},n)}transformPastedHTML(n){let{editor:e}=this;return tr([...this.extensions]).reduce((i,r)=>{let s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Zi(r.name,this.schema)},o=P(r,"transformPastedHTML",s);return o?(l,a)=>{let h=i(l,a);return o.call(s,h)}:i},n||(i=>i))}get markViews(){let{editor:n}=this,{markExtensions:e}=ci(this.extensions);return Object.fromEntries(e.filter(t=>!!P(t,"addMarkView")).map(t=>{let i=this.attributes.filter(l=>l.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:Ft(t.name,this.schema)},s=P(t,"addMarkView",r);if(!s)return[];let o=(l,a,h)=>{let c=ks(l,i);return s()({mark:l,view:a,inline:h,editor:n,extension:t,HTMLAttributes:c,updateAttributes:f=>{B1(l,n,f)}})};return[t.name,o]}))}destroy(){this.extensions.forEach(n=>{let e=n;for(;e.parent;){let t=e.parent;t.child===e&&(t.child=null),e=t}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){let n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;let i={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Zi(e.name,this.schema)};e.type==="mark"&&((t=U(P(e,"keepOnSplit",i)))==null||t)&&this.splittableMarks.push(e.name);let r=P(e,"onBeforeCreate",i),s=P(e,"onCreate",i),o=P(e,"onUpdate",i),l=P(e,"onSelectionUpdate",i),a=P(e,"onTransaction",i),h=P(e,"onFocus",i),c=P(e,"onBlur",i),f=P(e,"onDestroy",i);r&&this.editor.on("beforeCreate",r),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),h&&this.editor.on("focus",h),c&&this.editor.on("blur",c),f&&this.editor.on("destroy",f)})}};As.resolve=cd;As.sort=tr;As.flatten=oa;var S1={};ia(S1,{ClipboardTextSerializer:()=>xd,Commands:()=>kd,Delete:()=>wd,Drop:()=>Sd,Editable:()=>vd,FocusEvents:()=>Md,Keymap:()=>Ad,Paste:()=>Td,Tabindex:()=>Od,TextDirection:()=>Ed,focusEventsPluginKey:()=>Cd});var Je=class bd extends ha{constructor(){super(...arguments),this.type="extension"}static create(e={}){let t=typeof e=="function"?e():e;return new bd(t)}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}},xd=Je.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new J({key:new te("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:e,schema:t}=n,{doc:i,selection:r}=e,{ranges:s}=r,o=Math.min(...s.map(c=>c.$from.pos)),l=Math.max(...s.map(c=>c.$to.pos)),a=ud(t);return fd(i,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),kd=Je.create({name:"commands",addCommands(){return{...td}}}),wd=Je.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,i,r;let s=()=>{var o,l,a,h;if((h=(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?h:n.getMeta("y-sync$"))return;let c=Cx(n.before,[n,...e]);Fx(c).forEach(d=>{c.mapping.mapResult(d.oldRange.from).deletedAfter&&c.mapping.mapResult(d.oldRange.to).deletedBefore&&c.before.nodesBetween(d.oldRange.from,d.oldRange.to,(p,m)=>{let g=m+p.nodeSize-2,y=d.oldRange.from<=m&&g<=d.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:c.mapping.map(m),newTo:c.mapping.map(g),deletedRange:d.oldRange,newRange:d.newRange,partial:!y,editor:this.editor,transaction:n,combinedTransform:c})})});let u=c.mapping;c.steps.forEach((d,p)=>{var m,g;if(d instanceof Nt){let y=u.slice(p).map(d.from,-1),b=u.slice(p).map(d.to),x=u.invert().map(y,-1),C=u.invert().map(b),w=y>0?(m=c.doc.nodeAt(y-1))==null?void 0:m.marks.some(k=>k.eq(d.mark)):!1,T=(g=c.doc.nodeAt(b))==null?void 0:g.marks.some(k=>k.eq(d.mark));this.editor.emit("delete",{type:"mark",mark:d.mark,from:d.from,to:d.to,deletedRange:{from:x,to:C},newRange:{from:y,to:b},partial:!!(T||w),editor:this.editor,transaction:n,combinedTransform:c})}})};(r=(i=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:i.async)==null||r?setTimeout(s,0):s()}}),Sd=Je.create({name:"drop",addProseMirrorPlugins(){return[new J({key:new te("tiptapDrop"),props:{handleDrop:(n,e,t,i)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:i})}}})]}}),vd=Je.create({name:"editable",addProseMirrorPlugins(){return[new J({key:new te("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Cd=new te("focusEvents"),Md=Je.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new J({key:Cd,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;let i=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(i),!1},blur:(e,t)=>{n.isFocused=!1;let i=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(i),!1}}}})]}}),Ad=Je.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{let{selection:a,doc:h}=l,{empty:c,$anchor:f}=a,{pos:u,parent:d}=f,p=f.parent.isTextblock&&u>0?l.doc.resolve(u-1):f,m=p.parent.type.spec.isolating,g=f.pos-f.parentOffset,y=m&&p.parent.childCount===1?g===f.pos:F.atStart(h).from===u;return!c||!d.type.isTextblock||d.textContent.length||!y||y&&f.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()]),i={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()},r={...i},s={...i,"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 xs()||od()?s:r},addProseMirrorPlugins(){return[new J({key:new te("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(m=>m.getMeta("composition")))return;let i=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),r=n.some(m=>m.getMeta("preventClearDocument"));if(!i||r)return;let{empty:s,from:o,to:l}=e.selection,a=F.atStart(e.doc).from,h=F.atEnd(e.doc).to;if(s||!(o===a&&l===h)||!aa(t.doc))return;let u=t.tr,d=ws({state:t,transaction:u}),{commands:p}=new Ss({editor:this.editor,state:d});if(p.clearNodes(),!!u.steps.length)return u}})]}}),Td=Je.create({name:"paste",addProseMirrorPlugins(){return[new J({key:new te("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Od=Je.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new J({key:new te("tabindex"),props:{attributes:()=>{var n;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(n=this.options.value)!=null?n:"0"}}}})]}}),Ed=Je.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:n}=ci(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new J({key:new te("textDirection"),props:{attributes:()=>{let n=this.options.direction;return n?{dir:n}:{}}}})]}}),v1=class er{constructor(e,t,i=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=i,this.resolvedPos=e,this.editor=t,this.currentNode=r}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,i=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,i=this.to-1}this.editor.commands.insertContentAt({from:t,to:i},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new er(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 er(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 er(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,i)=>{let r=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=t.isInline,l=this.pos+i+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!r&&!o&&a.depth<=this.depth)return;let h=new er(a,this.editor,r,r||o?t:null);r&&(h.actualDepth=this.depth+1),e.push(h)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let i=null,r=this.parent;for(;r&&!i;){if(r.node.type.name===e)if(Object.keys(t).length>0){let s=r.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){let a=o[l];if(s[a]!==t[a])break}}else i=r;r=r.parent}return i}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},i=!1){let r=[];if(!this.children||this.children.length===0)return r;let s=Object.keys(t);return this.children.forEach(o=>{i&&r.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&r.push(o),!(i&&r.length>0)&&(r=r.concat(o.querySelectorAll(e,t,i))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},C1=`.ProseMirror {
|
|
15
15
|
position: relative;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -81,9 +81,9 @@ img.ProseMirror-separator {
|
|
|
81
81
|
|
|
82
82
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
83
83
|
display: block;
|
|
84
|
-
}`;function M1(n,e,t){let i=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(i!==null)return i;let r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),r.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(r),r}var
|
|
84
|
+
}`;function M1(n,e,t){let i=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(i!==null)return i;let r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),r.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(r),r}var QM=class extends f1{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:i})=>{throw i},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Wx,createMappablePosition:$x},this.setOptions(n),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:r,moved:s})=>this.options.onDrop(i,r,s)),this.on("paste",({event:i,slice:r})=>this.options.onPaste(i,r)),this.on("delete",this.options.onDelete);let e=this.createDoc(),t=rd(e,this.options.autofocus);this.editorState=Yr.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){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(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}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=M1(C1,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){let t=ad(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],i=this.state.reconfigure({plugins:t});return this.view.updateState(i),i}unregisterPlugin(n){if(this.isDestroyed)return;let e=this.state.plugins,t=e;if([].concat(n).forEach(r=>{let s=typeof r=="string"?`${r}$`:r.key;t=t.filter(o=>!o.key.startsWith(s))}),e.length===t.length)return;let i=this.state.reconfigure({plugins:t});return this.view.updateState(i),i}createExtensionManager(){var n,e,t,i;let s=[...this.options.enableCoreExtensions?[vd,xd.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),kd,Md,Ad,Od.configure({value:(i=(t=this.options.coreExtensionOptions)==null?void 0:t.tabindex)==null?void 0:i.value}),Sd,Td,wd,Ed.configure({direction:this.options.textDirection})].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new As(s,this)}createCommandManager(){this.commandManager=new Ss({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=ta(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=ta(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){let{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,i=e.dispatchTransaction||this.dispatchTransaction.bind(this),r=t?this.extensionManager.dispatchTransaction(i):i,s=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new Yi(n,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:r,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(h=>{var c;return(c=this.capturedTransaction)==null?void 0:c.step(h)});return}let{state:e,transactions:t}=this.state.applyTransaction(n),i=!this.state.selection.eq(e.selection),r=t.includes(n),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!r)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),i&&this.emit("selectionUpdate",{editor:this,transaction:n});let o=t.findLast(h=>h.getMeta("focus")||h.getMeta("blur")),l=o?.getMeta("focus"),a=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),a&&this.emit("blur",{editor:this,event:a.event,transaction:o}),!(n.getMeta("preventUpdate")||!t.some(h=>h.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return Bx(this.state,n)}isActive(n,e){let t=typeof n=="string"?n:null,i=typeof n=="string"?e:n;return Hx(this.state,t,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return la(this.state.doc.content,this.schema)}getText(n){let{blockSeparator:e=`
|
|
85
85
|
|
|
86
|
-
`,textSerializers:t={}}=n||{};return Px(this.state.doc,{blockSeparator:e,textSerializers:{...ud(this.schema),...t}})}get isEmpty(){return aa(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){let e=this.state.doc.resolve(n),t=n>0&&e.nodeAfter&&!e.nodeAfter.isText?e.nodeAfter:null;return new v1(e,this,!1,t)}get $doc(){return this.$pos(0)}};function UM(n){return new Ms({find:n.find,handler:({state:e,range:t,match:i})=>{let r=U(n.getAttributes,void 0,i);if(r===!1||r===null)return null;let{tr:s}=e,o=i[i.length-1],l=i[0];if(o){let a=l.search(/\S/),h=t.from+l.indexOf(o),c=h+o.length;if(dd(t.from,t.to,e.doc).filter(d=>d.mark.type.excluded.find(m=>m===n.type&&m!==d.mark.type)).filter(d=>d.to>h).length)return null;c<t.to&&s.delete(c,t.to),h>t.from&&s.delete(t.from+a,h);let u=t.from+a+o.length;s.addMark(t.from+a,u,n.type.create(r||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function GM(n){return new Ms({find:n.find,handler:({state:e,range:t,match:i})=>{let r=U(n.getAttributes,void 0,i)||{},{tr:s}=e,o=t.from,l=t.to,a=n.type.create(r);if(i[1]){let h=i[0].lastIndexOf(i[1]),c=o+h;c>l?c=l:l=c+i[1].length;let f=i[0][i[0].length-1];s.insertText(f,o+i[0].length-1),s.replaceWith(c,l,a)}else if(i[0]){let h=n.type.isInline?o:o-1;s.insert(h,n.type.create(r)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:n.undoable})}function YM(n){return new Ms({find:n.find,handler:({state:e,range:t,match:i})=>{let r=e.doc.resolve(t.from),s=U(n.getAttributes,void 0,i)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.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 QM(n){return new Ms({find:n.find,handler:({state:e,range:t,match:i,chain:r})=>{let s=U(n.getAttributes,void 0,i)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),h=a&&Zn(a,n.type,s);if(!h)return null;if(o.wrap(a,h),n.keepMarks&&n.editor){let{selection:f,storedMarks:u}=e,{splittableMarks:d}=n.editor.extensionManager,p=u||f.$to.parentOffset&&f.$from.marks();if(p){let m=p.filter(g=>d.includes(g.type.name));o.ensureMarks(m)}}if(n.keepAttributes){let f=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";r().updateAttributes(f,s).run()}let c=o.doc.resolve(t.from-1).nodeBefore;c&&c.type===n.type&&$e(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(i,c))&&o.join(t.from-1)},undoable:n.undoable})}var A1=n=>"touches"in n,ZM=class{constructor(n){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,h=l.clientY-this.startY;this.handleResize(a,h)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let h=a.clientX-this.startX,c=a.clientY-this.startY;this.handleResize(h,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,t,i,r,s,o;this.node=n.node,this.editor=n.editor,this.element=n.element,this.contentElement=n.contentElement,this.getPos=n.getPos,this.onResize=n.onResize,this.onCommit=n.onCommit,this.onUpdate=n.onUpdate,(e=n.options)!=null&&e.min&&(this.minSize={...this.minSize,...n.options.min}),(t=n.options)!=null&&t.max&&(this.maxSize=n.options.max),(i=n?.options)!=null&&i.directions&&(this.directions=n.options.directions),(r=n.options)!=null&&r.preserveAspectRatio&&(this.preserveAspectRatio=n.options.preserveAspectRatio),(s=n.options)!=null&&s.className&&(this.classNames={container:n.options.className.container||"",wrapper:n.options.className.wrapper||"",handle:n.options.className.handle||"",resizing:n.options.className.resizing||""}),(o=n.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=n.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var n;return(n=this.contentElement)!=null?n:null}handleEditorUpdate(){let n=this.editor.isEditable;n!==this.lastEditableState&&(this.lastEditableState=n,n?n&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(n,e,t){return n.type!==this.node.type?!1:(this.node=n,this.onUpdate?this.onUpdate(n,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let n=document.createElement("div");return n.dataset.resizeContainer="",n.dataset.node=this.node.type.name,n.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(n.className=this.classNames.container),n.appendChild(this.wrapper),n}createWrapper(){let n=document.createElement("div");return n.style.position="relative",n.style.display="block",n.dataset.resizeWrapper="",this.classNames.wrapper&&(n.className=this.classNames.wrapper),n.appendChild(this.element),n}createHandle(n){let e=document.createElement("div");return e.dataset.resizeHandle=n,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(n,e){let t=e.includes("top"),i=e.includes("bottom"),r=e.includes("left"),s=e.includes("right");t&&(n.style.top="0"),i&&(n.style.bottom="0"),r&&(n.style.left="0"),s&&(n.style.right="0"),(e==="top"||e==="bottom")&&(n.style.left="0",n.style.right="0"),(e==="left"||e==="right")&&(n.style.top="0",n.style.bottom="0")}attachHandles(){this.directions.forEach(n=>{let e;this.createCustomHandle?e=this.createCustomHandle(n):e=this.createHandle(n),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${n}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(n)),this.createCustomHandle||this.positionHandle(e,n),e.addEventListener("mousedown",t=>this.handleResizeStart(t,n)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,n)),this.handleMap.set(n,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(n=>n.remove()),this.handleMap.clear()}applyInitialSize(){let n=this.node.attrs.width,e=this.node.attrs.height;n?(this.element.style.width=`${n}px`,this.initialWidth=n):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(n,e){n.preventDefault(),n.stopPropagation(),this.isResizing=!0,this.activeHandle=e,A1(n)?(this.startX=n.touches[0].clientX,this.startY=n.touches[0].clientY):(this.startX=n.clientX,this.startY=n.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight);let t=this.getPos();this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(n,e){if(!this.activeHandle)return;let t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:i,height:r}=this.calculateNewDimensions(this.activeHandle,n,e),s=this.applyConstraints(i,r,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(n,e,t){let i=this.startWidth,r=this.startHeight,s=n.includes("right"),o=n.includes("left"),l=n.includes("bottom"),a=n.includes("top");return s?i=this.startWidth+e:o&&(i=this.startWidth-e),l?r=this.startHeight+t:a&&(r=this.startHeight-t),(n==="right"||n==="left")&&(i=this.startWidth+(s?e:-e)),(n==="top"||n==="bottom")&&(r=this.startHeight+(l?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(i,r,n):{width:i,height:r}}applyConstraints(n,e,t){var i,r,s,o;if(!t){let h=Math.max(this.minSize.width,n),c=Math.max(this.minSize.height,e);return(i=this.maxSize)!=null&&i.width&&(h=Math.min(this.maxSize.width,h)),(r=this.maxSize)!=null&&r.height&&(c=Math.min(this.maxSize.height,c)),{width:h,height:c}}let l=n,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(n,e,t){let i=t==="left"||t==="right",r=t==="top"||t==="bottom";return i?{width:n,height:n/this.aspectRatio}:r?{width:e*this.aspectRatio,height:e}:{width:n,height:n/this.aspectRatio}}};function tA(n,e){let{selection:t}=n,{$from:i}=t;if(t instanceof B){let s=i.index();return i.parent.canReplaceWith(s,s+1,e)}let r=i.depth;for(;r>=0;){let s=i.index(r);if(i.node(r).contentMatchAt(s).matchType(e))return!0;r-=1}return!1}function nA(n,e){let t=n.getAttribute("style");if(!t)return null;let i=t.split(";").map(s=>s.trim()).filter(Boolean),r=e.toLowerCase();for(let s=i.length-1;s>=0;s-=1){let o=i[s],l=o.indexOf(":");if(l===-1)continue;if(o.slice(0,l).trim().toLowerCase()===r)return o.slice(l+1).trim()}return null}var T1={};ia(T1,{createAtomBlockMarkdownSpec:()=>O1,createBlockMarkdownSpec:()=>E1,createInlineMarkdownSpec:()=>R1,parseAttributes:()=>ca,parseIndentedBlocks:()=>P1,renderNestedMarkdownContent:()=>B1,serializeAttributes:()=>fa});function ca(n){if(!n?.trim())return{};let e={},t=[],i=n.replace(/["']([^"']*)["']/g,h=>(t.push(h),`__QUOTED_${t.length-1}__`)),r=i.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(r){let h=r.map(c=>c.trim().slice(1));e.class=h.join(" ")}let s=i.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);let o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(i.matchAll(o)).forEach(([,h,c])=>{var f;let u=parseInt(((f=c.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),d=t[u];d&&(e[h]=d.slice(1,-1))});let a=i.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(c=>{c.match(/^[a-zA-Z][\w-]*$/)&&(e[c]=!0)}),e}function fa(n){if(!n||Object.keys(n).length===0)return"";let e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(i=>e.push(`.${i}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,i])=>{t==="class"||t==="id"||(i===!0?e.push(t):i!==!1&&i!=null&&e.push(`${t}="${String(i)}"`))}),e.join(" ")}function O1(n){let{nodeName:e,name:t,parseAttributes:i=ca,serializeAttributes:r=fa,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=n,a=t||e,h=c=>{if(!l)return c;let f={};return l.forEach(u=>{u in c&&(f[u]=c[u])}),f};return{parseMarkdown:(c,f)=>{let u={...s,...c.attributes};return f.createNode(e,u,[])},markdownTokenizer:{name:e,level:"block",start(c){var f;let u=new RegExp(`^:::${a}(?:\\s|$)`,"m"),d=(f=c.match(u))==null?void 0:f.index;return d!==void 0?d:-1},tokenize(c,f,u){let d=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=c.match(d);if(!p)return;let m=p[1]||"",g=i(m);if(!o.find(b=>!(b in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:c=>{let f=h(c.attrs||{}),u=r(f),d=u?` {${u}}`:"";return`:::${a}${d} :::`}}}function E1(n){let{nodeName:e,name:t,getContent:i,parseAttributes:r=ca,serializeAttributes:s=fa,defaultAttributes:o={},content:l="block",allowedAttributes:a}=n,h=t||e,c=f=>{if(!a)return f;let u={};return a.forEach(d=>{d in f&&(u[d]=f[d])}),u};return{parseMarkdown:(f,u)=>{let d;if(i){let m=i(f);d=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?d=u.parseChildren(f.tokens||[]):d=u.parseInline(f.tokens||[]);let p={...o,...f.attributes};return u.createNode(e,p,d)},markdownTokenizer:{name:e,level:"block",start(f){var u;let d=new RegExp(`^:::${h}`,"m"),p=(u=f.match(d))==null?void 0:u.index;return p!==void 0?p:-1},tokenize(f,u,d){var p;let m=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=f.match(m);if(!g)return;let[y,b=""]=g,x=r(b),C=1,w=y.length,T="",k=/^:::([\w-]*)(\s.*)?/gm,D=f.slice(w);for(k.lastIndex=0;;){let R=k.exec(D);if(R===null)break;let W=R.index,H=R[1];if(!((p=R[2])!=null&&p.endsWith(":::"))){if(H)C+=1;else if(C-=1,C===0){let I=D.slice(0,W);T=I.trim();let $=f.slice(0,w+W+R[0].length),q=[];if(T)if(l==="block")for(q=d.blockTokens(I),q.forEach(j=>{j.text&&(!j.tokens||j.tokens.length===0)&&(j.tokens=d.inlineTokens(j.text))});q.length>0;){let j=q[q.length-1];if(j.type==="paragraph"&&(!j.text||j.text.trim()===""))q.pop();else break}else q=d.inlineTokens(T);return{type:e,raw:$,attributes:x,content:T,tokens:q}}}}}},renderMarkdown:(f,u)=>{let d=c(f.attrs||{}),p=s(d),m=p?` {${p}}`:"",g=u.renderChildren(f.content||[],`
|
|
86
|
+
`,textSerializers:t={}}=n||{};return Px(this.state.doc,{blockSeparator:e,textSerializers:{...ud(this.schema),...t}})}get isEmpty(){return aa(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){let e=this.state.doc.resolve(n),t=n>0&&e.nodeAfter&&!e.nodeAfter.isText?e.nodeAfter:null;return new v1(e,this,!1,t)}get $doc(){return this.$pos(0)}};function ZM(n){return new Ms({find:n.find,handler:({state:e,range:t,match:i})=>{let r=U(n.getAttributes,void 0,i);if(r===!1||r===null)return null;let{tr:s}=e,o=i[i.length-1],l=i[0];if(o){let a=l.search(/\S/),h=t.from+l.indexOf(o),c=h+o.length;if(dd(t.from,t.to,e.doc).filter(d=>d.mark.type.excluded.find(m=>m===n.type&&m!==d.mark.type)).filter(d=>d.to>h).length)return null;c<t.to&&s.delete(c,t.to),h>t.from&&s.delete(t.from+a,h);let u=t.from+a+o.length;s.addMark(t.from+a,u,n.type.create(r||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function eA(n){return new Ms({find:n.find,handler:({state:e,range:t,match:i})=>{let r=U(n.getAttributes,void 0,i)||{},{tr:s}=e,o=t.from,l=t.to,a=n.type.create(r);if(i[1]){let h=i[0].lastIndexOf(i[1]),c=o+h;c>l?c=l:l=c+i[1].length;let f=i[0][i[0].length-1];s.insertText(f,o+i[0].length-1),s.replaceWith(c,l,a)}else if(i[0]){let h=n.type.isInline?o:o-1;s.insert(h,n.type.create(r)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:n.undoable})}function tA(n){return new Ms({find:n.find,handler:({state:e,range:t,match:i})=>{let r=e.doc.resolve(t.from),s=U(n.getAttributes,void 0,i)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.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 iA(n){return new Ms({find:n.find,handler:({state:e,range:t,match:i,chain:r})=>{let s=U(n.getAttributes,void 0,i)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),h=a&&Zn(a,n.type,s);if(!h)return null;if(o.wrap(a,h),n.keepMarks&&n.editor){let{selection:f,storedMarks:u}=e,{splittableMarks:d}=n.editor.extensionManager,p=u||f.$to.parentOffset&&f.$from.marks();if(p){let m=p.filter(g=>d.includes(g.type.name));o.ensureMarks(m)}}if(n.keepAttributes){let f=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";r().updateAttributes(f,s).run()}let c=o.doc.resolve(t.from-1).nodeBefore;c&&c.type===n.type&&$e(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(i,c))&&o.join(t.from-1)},undoable:n.undoable})}var A1=n=>"touches"in n,rA=class{constructor(n){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,h=l.clientY-this.startY;this.handleResize(a,h)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let h=a.clientX-this.startX,c=a.clientY-this.startY;this.handleResize(h,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,t,i,r,s,o;this.node=n.node,this.editor=n.editor,this.element=n.element,this.contentElement=n.contentElement,this.getPos=n.getPos,this.onResize=n.onResize,this.onCommit=n.onCommit,this.onUpdate=n.onUpdate,(e=n.options)!=null&&e.min&&(this.minSize={...this.minSize,...n.options.min}),(t=n.options)!=null&&t.max&&(this.maxSize=n.options.max),(i=n?.options)!=null&&i.directions&&(this.directions=n.options.directions),(r=n.options)!=null&&r.preserveAspectRatio&&(this.preserveAspectRatio=n.options.preserveAspectRatio),(s=n.options)!=null&&s.className&&(this.classNames={container:n.options.className.container||"",wrapper:n.options.className.wrapper||"",handle:n.options.className.handle||"",resizing:n.options.className.resizing||""}),(o=n.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=n.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var n;return(n=this.contentElement)!=null?n:null}handleEditorUpdate(){let n=this.editor.isEditable;n!==this.lastEditableState&&(this.lastEditableState=n,n?n&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(n,e,t){return n.type!==this.node.type?!1:(this.node=n,this.onUpdate?this.onUpdate(n,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let n=document.createElement("div");return n.dataset.resizeContainer="",n.dataset.node=this.node.type.name,n.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(n.className=this.classNames.container),n.appendChild(this.wrapper),n}createWrapper(){let n=document.createElement("div");return n.style.position="relative",n.style.display="block",n.dataset.resizeWrapper="",this.classNames.wrapper&&(n.className=this.classNames.wrapper),n.appendChild(this.element),n}createHandle(n){let e=document.createElement("div");return e.dataset.resizeHandle=n,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(n,e){let t=e.includes("top"),i=e.includes("bottom"),r=e.includes("left"),s=e.includes("right");t&&(n.style.top="0"),i&&(n.style.bottom="0"),r&&(n.style.left="0"),s&&(n.style.right="0"),(e==="top"||e==="bottom")&&(n.style.left="0",n.style.right="0"),(e==="left"||e==="right")&&(n.style.top="0",n.style.bottom="0")}attachHandles(){this.directions.forEach(n=>{let e;this.createCustomHandle?e=this.createCustomHandle(n):e=this.createHandle(n),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${n}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(n)),this.createCustomHandle||this.positionHandle(e,n),e.addEventListener("mousedown",t=>this.handleResizeStart(t,n)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,n)),this.handleMap.set(n,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(n=>n.remove()),this.handleMap.clear()}applyInitialSize(){let n=this.node.attrs.width,e=this.node.attrs.height;n?(this.element.style.width=`${n}px`,this.initialWidth=n):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(n,e){n.preventDefault(),n.stopPropagation(),this.isResizing=!0,this.activeHandle=e,A1(n)?(this.startX=n.touches[0].clientX,this.startY=n.touches[0].clientY):(this.startX=n.clientX,this.startY=n.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight);let t=this.getPos();this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(n,e){if(!this.activeHandle)return;let t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:i,height:r}=this.calculateNewDimensions(this.activeHandle,n,e),s=this.applyConstraints(i,r,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(n,e,t){let i=this.startWidth,r=this.startHeight,s=n.includes("right"),o=n.includes("left"),l=n.includes("bottom"),a=n.includes("top");return s?i=this.startWidth+e:o&&(i=this.startWidth-e),l?r=this.startHeight+t:a&&(r=this.startHeight-t),(n==="right"||n==="left")&&(i=this.startWidth+(s?e:-e)),(n==="top"||n==="bottom")&&(r=this.startHeight+(l?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(i,r,n):{width:i,height:r}}applyConstraints(n,e,t){var i,r,s,o;if(!t){let h=Math.max(this.minSize.width,n),c=Math.max(this.minSize.height,e);return(i=this.maxSize)!=null&&i.width&&(h=Math.min(this.maxSize.width,h)),(r=this.maxSize)!=null&&r.height&&(c=Math.min(this.maxSize.height,c)),{width:h,height:c}}let l=n,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(n,e,t){let i=t==="left"||t==="right",r=t==="top"||t==="bottom";return i?{width:n,height:n/this.aspectRatio}:r?{width:e*this.aspectRatio,height:e}:{width:n,height:n/this.aspectRatio}}};function oA(n,e){let{selection:t}=n,{$from:i}=t;if(t instanceof I){let s=i.index();return i.parent.canReplaceWith(s,s+1,e)}let r=i.depth;for(;r>=0;){let s=i.index(r);if(i.node(r).contentMatchAt(s).matchType(e))return!0;r-=1}return!1}function lA(n,e){let t=n.getAttribute("style");if(!t)return null;let i=t.split(";").map(s=>s.trim()).filter(Boolean),r=e.toLowerCase();for(let s=i.length-1;s>=0;s-=1){let o=i[s],l=o.indexOf(":");if(l===-1)continue;if(o.slice(0,l).trim().toLowerCase()===r)return o.slice(l+1).trim()}return null}var T1={};ia(T1,{createAtomBlockMarkdownSpec:()=>O1,createBlockMarkdownSpec:()=>E1,createInlineMarkdownSpec:()=>R1,parseAttributes:()=>ca,parseIndentedBlocks:()=>P1,renderNestedMarkdownContent:()=>I1,serializeAttributes:()=>fa});function ca(n){if(!n?.trim())return{};let e={},t=[],i=n.replace(/["']([^"']*)["']/g,h=>(t.push(h),`__QUOTED_${t.length-1}__`)),r=i.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(r){let h=r.map(c=>c.trim().slice(1));e.class=h.join(" ")}let s=i.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);let o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(i.matchAll(o)).forEach(([,h,c])=>{var f;let u=parseInt(((f=c.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),d=t[u];d&&(e[h]=d.slice(1,-1))});let a=i.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(c=>{c.match(/^[a-zA-Z][\w-]*$/)&&(e[c]=!0)}),e}function fa(n){if(!n||Object.keys(n).length===0)return"";let e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(i=>e.push(`.${i}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,i])=>{t==="class"||t==="id"||(i===!0?e.push(t):i!==!1&&i!=null&&e.push(`${t}="${String(i)}"`))}),e.join(" ")}function O1(n){let{nodeName:e,name:t,parseAttributes:i=ca,serializeAttributes:r=fa,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=n,a=t||e,h=c=>{if(!l)return c;let f={};return l.forEach(u=>{u in c&&(f[u]=c[u])}),f};return{parseMarkdown:(c,f)=>{let u={...s,...c.attributes};return f.createNode(e,u,[])},markdownTokenizer:{name:e,level:"block",start(c){var f;let u=new RegExp(`^:::${a}(?:\\s|$)`,"m"),d=(f=c.match(u))==null?void 0:f.index;return d!==void 0?d:-1},tokenize(c,f,u){let d=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=c.match(d);if(!p)return;let m=p[1]||"",g=i(m);if(!o.find(b=>!(b in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:c=>{let f=h(c.attrs||{}),u=r(f),d=u?` {${u}}`:"";return`:::${a}${d} :::`}}}function E1(n){let{nodeName:e,name:t,getContent:i,parseAttributes:r=ca,serializeAttributes:s=fa,defaultAttributes:o={},content:l="block",allowedAttributes:a}=n,h=t||e,c=f=>{if(!a)return f;let u={};return a.forEach(d=>{d in f&&(u[d]=f[d])}),u};return{parseMarkdown:(f,u)=>{let d;if(i){let m=i(f);d=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?d=u.parseChildren(f.tokens||[]):d=u.parseInline(f.tokens||[]);let p={...o,...f.attributes};return u.createNode(e,p,d)},markdownTokenizer:{name:e,level:"block",start(f){var u;let d=new RegExp(`^:::${h}`,"m"),p=(u=f.match(d))==null?void 0:u.index;return p!==void 0?p:-1},tokenize(f,u,d){var p;let m=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=f.match(m);if(!g)return;let[y,b=""]=g,x=r(b),C=1,w=y.length,T="",k=/^:::([\w-]*)(\s.*)?/gm,D=f.slice(w);for(k.lastIndex=0;;){let R=k.exec(D);if(R===null)break;let W=R.index,H=R[1];if(!((p=R[2])!=null&&p.endsWith(":::"))){if(H)C+=1;else if(C-=1,C===0){let B=D.slice(0,W);T=B.trim();let $=f.slice(0,w+W+R[0].length),_=[];if(T)if(l==="block")for(_=d.blockTokens(B),_.forEach(q=>{q.text&&(!q.tokens||q.tokens.length===0)&&(q.tokens=d.inlineTokens(q.text))});_.length>0;){let q=_[_.length-1];if(q.type==="paragraph"&&(!q.text||q.text.trim()===""))_.pop();else break}else _=d.inlineTokens(T);return{type:e,raw:$,attributes:x,content:T,tokens:_}}}}}},renderMarkdown:(f,u)=>{let d=c(f.attrs||{}),p=s(d),m=p?` {${p}}`:"",g=u.renderChildren(f.content||[],`
|
|
87
87
|
|
|
88
88
|
`);return`:::${h}${m}
|
|
89
89
|
|
|
@@ -95,18 +95,18 @@ ${g}
|
|
|
95
95
|
`;let y=[g];for(c+=1;c<l.length;){let w=l[c];if(w.trim()===""){let k=l.slice(c+1).findIndex(W=>W.trim()!=="");if(k===-1)break;if((((r=(i=l[c+1+k].match(/^(\s*)/))==null?void 0:i[1])==null?void 0:r.length)||0)>m){y.push(w),h=`${h}${w}
|
|
96
96
|
`,c+=1;continue}else break}if((((o=(s=w.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>m)y.push(w),h=`${h}${w}
|
|
97
97
|
`,c+=1;else break}let b,x=y.slice(1);if(x.length>0){let w=x.map(T=>T.slice(m+f)).join(`
|
|
98
|
-
`);w.trim()&&(e.customNestedParser?b=e.customNestedParser(w):b=t.blockTokens(w))}let C=e.createToken(p,b);a.push(C)}if(a.length!==0)return{items:a,raw:h}}function
|
|
98
|
+
`);w.trim()&&(e.customNestedParser?b=e.customNestedParser(w):b=t.blockTokens(w))}let C=e.createToken(p,b);a.push(C)}if(a.length!==0)return{items:a,raw:h}}function I1(n,e,t,i){if(!n||!Array.isArray(n.content))return"";let r=typeof t=="function"?t(i):t,[s,...o]=n.content,l=e.renderChildren([s]),a=`${r}${l}`;return o&&o.length>0&&o.forEach((h,c)=>{var f,u;let d=(u=(f=e.renderChild)==null?void 0:f.call(e,h,c+1))!=null?u:e.renderChildren([h]);if(d!=null){let p=d.split(`
|
|
99
99
|
`).map(m=>m?e.indent(m):e.indent("")).join(`
|
|
100
100
|
`);a+=h.type==="paragraph"?`
|
|
101
101
|
|
|
102
102
|
${p}`:`
|
|
103
|
-
${p}`}}),a}function
|
|
103
|
+
${p}`}}),a}function B1(n,e,t={}){let{state:i}=e,{doc:r,tr:s}=i,o=n;r.descendants((l,a)=>{let h=s.mapping.map(a),c=s.mapping.map(a)+l.nodeSize,f=null;if(l.marks.forEach(d=>{if(d!==o)return!1;f=d}),!f)return;let u=!1;if(Object.keys(t).forEach(d=>{t[d]!==f.attrs[d]&&(u=!0)}),u){let d=n.type.create({...n.attrs,...t});s.removeMark(h,c,n.type),s.addMark(h,c,d)}}),s.docChanged&&e.view.dispatch(s)}var aA=class Dd extends ha{constructor(){super(...arguments),this.type="node"}static create(e={}){let t=typeof e=="function"?e():e;return new Dd(t)}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}};function cA(n){return new y1({find:n.find,handler:({state:e,range:t,match:i,pasteEvent:r})=>{let s=U(n.getAttributes,void 0,i,r);if(s===!1||s===null)return null;let{tr:o}=e,l=i[i.length-1],a=i[0],h=t.to;if(l){let c=a.search(/\S/),f=t.from+a.indexOf(l),u=f+l.length;if(dd(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===n.type&&y!==m.mark.type)).filter(m=>m.to>f).length)return null;u<t.to&&o.delete(u,t.to),f>t.from&&o.delete(t.from+c,f),h=t.from+c+l.length,o.addMark(t.from+c,h,n.type.create(s||{})),i.index!==void 0&&i.input!==void 0&&i.index+i[0].length>=i.input.length||o.removeStoredMark(n.type)}}})}var da=[],Id=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?Id:da).push(t=t+n[e])})();function L1(n){if(n<768)return!1;for(let e=0,t=da.length;;){let i=e+t>>1;if(n<da[i])t=i;else if(n>=Id[i])e=i+1;else return!0;if(e==t)return!1}}function Nd(n){return n>=127462&&n<=127487}var Rd=8205;function Bd(n,e,t=!0,i=!0){return(t?Ld:z1)(n,e,i)}function Ld(n,e,t){if(e==n.length)return e;e&&zd(n.charCodeAt(e))&&Fd(n.charCodeAt(e-1))&&e--;let i=ua(n,e);for(e+=Pd(i);e<n.length;){let r=ua(n,e);if(i==Rd||r==Rd||t&&L1(r))e+=Pd(r),i=r;else if(Nd(r)){let s=0,o=e-2;for(;o>=0&&Nd(ua(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function z1(n,e,t){for(;e>0;){let i=Ld(n,e-2,t);if(i<e)return i;e--}return 0}function ua(n,e){let t=n.charCodeAt(e);if(!Fd(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return zd(i)?(t-55296<<10)+(i-56320)+65536:t}function zd(n){return n>=56320&&n<57344}function Fd(n){return n>=55296&&n<56320}function Pd(n){return n<65536?1:2}var K=class n{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=mi(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),ui.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=mi(this,e,t);let i=[];return this.decompose(e,t,i,0),ui.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new Dn(this),s=new Dn(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new Dn(this,e)}iterRange(e,t=this.length){return new Ns(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Rs(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?n.empty:e.length<=32?new ze(e):ui.from(ze.split(e,[]))}},ze=class n extends K{constructor(e,t=F1(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new ma(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new n(Vd(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Ds(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new n(l,o.length+s.length));else{let a=l.length>>1;i.push(new n(l.slice(0,a)),new n(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=mi(this,e,t);let r=Ds(this.text,Ds(i.text,Vd(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new n(r,s):ui.from(n.split(r,[]),s)}sliceString(e,t=this.length,i=`
|
|
104
104
|
`){[e,t]=mi(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new n(i,r)),i=[],r=-1);return r>-1&&t.push(new n(i,r)),t}},ui=class n extends K{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let h=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=mi(this,e,t),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new n(c,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
105
105
|
`){[e,t]=mi(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],h=e.children[s];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new ze(d,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>s&&d instanceof n)for(let m of d.children)f(m);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof ze&&a&&(p=c[c.length-1])instanceof ze&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new ze(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:n.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new n(l,t)}};K.empty=new ze([""],0);function F1(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Ds(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],a=r+l.length;a>=t&&(a>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function Vd(n,e,t){return Ds(n,[""],e,t)}var Dn=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ze?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof ze?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
106
|
-
`,this;e--}else if(r instanceof ze){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ze?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Ns=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Dn(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Rs=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(K.prototype[Symbol.iterator]=function(){return this.iter()},Dn.prototype[Symbol.iterator]=Ns.prototype[Symbol.iterator]=Rs.prototype[Symbol.iterator]=function(){return this});var ma=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function mi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function fe(n,e,t=!0,i=!0){return Id(n,e,t,i)}function V1(n){return n>=56320&&n<57344}function H1(n){return n>=55296&&n<56320}function Kd(n,e){let t=n.charCodeAt(e);if(!H1(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return V1(i)?(t-55296<<10)+(i-56320)+65536:t}function jd(n){return n<65536?1:2}var ga=/\r\n?|\n/,Ne=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Ne||(Ne={})),Vt=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){ya(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new n(e)}composeDesc(e){return this.empty?e:e.empty?this:_d(this,e)}mapDesc(e,t=!1){return e.empty?this:ba(this,e,t)}mapPos(e,t=-1,i=Ne.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(i!=Ne.Simple&&h>=e&&(i==Ne.TrackDel&&r<e&&h>e||i==Ne.TrackBefore&&r<e||i==Ne.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new n(e)}static create(e){return new n(e)}},Me=class n extends Vt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ya(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return ba(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(K.empty);i.push(o?e.slice(s,s+o):K.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:_d(this,e,!0)}map(e,t=!1){return e.empty?this:ba(this,e,t,!0)}iterChanges(e,t=!1){ya(this,e,t)}get desc(){return Vt.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new Nn(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);ke(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;ke(t,c,f),f>0&&Zt(i,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);ke(t,c,-1),ke(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new n(t,i),filtered:Vt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&ke(r,t-o,-1);let f=new n(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof n){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?K.of(d.split(i||ga)):d:K.empty,m=p.length;if(f==u&&m==0)return;f<o&&a(),f>o&&ke(r,f-o,-1),ke(r,u-f,m),Zt(s,r,p),o=u}}return h(e),a(!l),l}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(K.empty);i[r]=K.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new n(t,i)}static createSet(e,t){return new n(e,t)}};function ke(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Zt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(K.empty);n.push(t)}}function ya(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=K.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function ba(n,e,t,i=!1){let r=[],s=i?[]:null,o=new Nn(n),l=new Nn(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);ke(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(ke(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(ke(r,0,o.ins),s&&Zt(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;ke(r,h,a<o.i?o.ins:0),s&&a<o.i&&Zt(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?Me.createSet(r,s):Vt.create(r);throw new Error("Mismatched change set lengths")}}}function _d(n,e,t=!1){let i=[],r=t?[]:null,s=new Nn(n),o=new Nn(e);for(let l=!1;;){if(s.done&&o.done)return r?Me.createSet(i,r):Vt.create(i);if(s.ins==0)ke(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)ke(i,0,o.ins,l),r&&Zt(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;ke(i,a,c,l),r&&c&&Zt(r,i,o.text)}else o.ins==-1?(ke(i,s.off?0:s.len,a,l),r&&Zt(r,i,s.textBit(a))):(ke(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Zt(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}var Nn=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?K.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?K.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},fi=class n{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return v.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return v.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return v.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},v=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new n([this.main],0)}addRange(e,t=!0){return n.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,n.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>fi.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return n.normalized(e.slice(),t);i=s.to}return new n(e,t)}static cursor(e,t=0,i,r){return fi.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r??16777215)<<6)}static range(e,t,i,r){let s=(i??16777215)<<6|(r==null?7:Math.min(6,r));return t<e?fi.create(t,e,48|s):fi.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?n.range(a,l):n.range(l,a))}}return new n(e,t)}};function Jd(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Oa=0,N=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Oa++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Ea),!!e.static,e.enables)}of(e){return new di([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new di(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new di(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Ea(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var di=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Oa++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||xa(f,c)){let d=i(f);if(l?!Hd(d,f.values[o],r):!r(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[s];if(p!=null){let m=Ls(u,p);if(this.dependencies.every(g=>g instanceof N?u.facet(g)===f.facet(g):g instanceof Fe?u.field(g,!1)==f.field(g,!1):!0)||(l?Hd(d=i(f),m,r):r(d=i(f),m)))return f.values[o]=m,0}else d=i(f);return f.values[o]=d,1}}}};function Hd(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function xa(n,e){let t=!1;for(let i of e)sr(n,i)&1&&(t=!0);return t}function W1(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Ls(a,i[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)sr(a,h);return a.values[o]=l(a),1},update(a,h){if(!xa(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=xa(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Ea(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}var Ts=N.define({static:!0}),Fe=class n{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new n(Oa++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Ts).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>{let s=i.facet(Ts),o=r.facet(Ts),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Ts.of({field:this,create:e})]}get extension(){return this}},On={lowest:4,low:3,default:2,high:1,highest:0};function rr(n){return e=>new Ps(e,n)}var hr={highest:rr(On.highest),high:rr(On.high),default:rr(On.default),low:rr(On.low),lowest:rr(On.lowest)},Ps=class{constructor(e,t){this.inner=e,this.prec=t}},Bs=class n{of(e){return new or(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},or=class{constructor(e,t){this.compartment=e,this.inner=t}},Is=class n{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let u of $1(e,t,o))u instanceof Fe?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i?.config.facets;for(let u in s){let d=s[u],p=d[0].facet,m=c&&c[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Ea(m,d))a.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(y=>g.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(g=>W1(g,p,d))}}let f=h.map(u=>u(l));return new n(e,o,f,l,a,s)}};function $1(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof or&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof or){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof Ps)s(o.inner,o.prec);else if(o instanceof Fe)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof di)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,On.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(n,On.default),i.reduce((o,l)=>o.concat(l))}function sr(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function Ls(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var Ud=N.define(),ka=N.define({combine:n=>n.some(e=>e),static:!0}),Gd=N.define({combine:n=>n.length?n[0]:void 0,static:!0}),Yd=N.define(),Xd=N.define(),Qd=N.define(),Zd=N.define({combine:n=>n.length?n[0]:!1}),Ue=class{constructor(e,t){this.type=e,this.value=t}static define(){return new wa}},wa=class{of(e){return new Ue(this,e)}},Sa=class{constructor(e){this.map=e}of(e){return new Z(this,e)}},Z=class n{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new n(this.type,t)}is(e){return this.type==e}static define(e={}){return new Sa(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}};Z.reconfigure=Z.define();Z.appendConfig=Z.define();var ce=class n{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Jd(i,t.newLength),s.some(l=>l.type==n.time)||(this.annotations=s.concat(n.time.of(Date.now())))}static create(e,t,i,r,s,o){return new n(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};ce.time=Ue.define();ce.userEvent=Ue.define();ce.addToHistory=Ue.define();ce.remote=Ue.define();function q1(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function ep(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=Me.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:Z.mapEffects(n.effects,r).concat(Z.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function va(n,e,t){let i=e.selection,r=pi(e.annotations);return e.userEvent&&(r=r.concat(ce.userEvent.of(e.userEvent))),{changes:e.changes instanceof Me?e.changes:Me.of(e.changes||[],t,n.facet(Gd)),selection:i&&(i instanceof v?i:v.single(i.anchor,i.head)),effects:pi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function tp(n,e,t){let i=va(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=ep(i,va(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=ce.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return j1(t?K1(r):r)}function K1(n){let e=n.startState,t=!0;for(let r of e.facet(Yd)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:q1(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=Me.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=ce.create(e,r,n.selection&&n.selection.map(s),Z.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Xd);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof ce?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ce?n=s[0]:n=tp(e,pi(s),!1)}return n}function j1(n){let e=n.startState,t=e.facet(Qd),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=ep(i,va(e,s,n.changes.newLength),!0))}return i==n?n:ce.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var _1=[];function pi(n){return n==null?_1:Array.isArray(n)?n:[n]}var it=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(it||(it={})),J1=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ca;try{Ca=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function U1(n){if(Ca)return Ca.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||J1.test(t)))return!0}return!1}function G1(n){return e=>{if(!/\S/.test(e))return it.Space;if(U1(e))return it.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return it.Word;return it.Other}}var ie=class n{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)sr(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return sr(this,i),Ls(this,i)}update(...e){return tp(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(Bs.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(Z.reconfigure)?(t=null,i=l.value):l.is(Z.appendConfig)&&(t=null,i=pi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=Is.resolve(i,r,this),s=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(ka)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:v.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=pi(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=Z.mapEffects(o,c).concat(Z.mapEffects(pi(a.effects),f))}return{changes:r,selection:v.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Me?e:Me.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return K.of(e.split(this.facet(n.lineSeparator)||ga))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(sr(this,t),Ls(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof Fe&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return n.create({doc:e.doc,selection:v.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Is.resolve(e.extensions||[],new Map),i=e.doc instanceof K?e.doc:K.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||ga)),r=e.selection?e.selection instanceof v?e.selection:v.single(e.selection.anchor,e.selection.head):v.single(0);return Jd(r,i.length),t.staticFacet(ka)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||`
|
|
107
|
-
`}get readOnly(){return this.facet(Zd)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(Ud))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return G1(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=fe(t,o,!1);if(s(t.slice(a,o))!=it.Word)break;o=a}for(;l<r;){let a=fe(t,l);if(s(t.slice(l,a))!=it.Word)break;l=a}return o==l?null:v.range(o+i,l+i)}};ie.allowMultipleSelections=ka;ie.tabSize=N.define({combine:n=>n.length?n[0]:4});ie.lineSeparator=Gd;ie.readOnly=Zd;ie.phrases=N.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});ie.languageData=Ud;ie.changeFilter=Yd;ie.transactionFilter=Xd;ie.transactionExtender=Qd;Bs.reconfigure=Z.define();function cr(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var bt=class{eq(e){return this==e}range(e,t=e){return lr.create(e,t,this)}};bt.prototype.startSide=bt.prototype.endSide=0;bt.prototype.point=!1;bt.prototype.mapMode=Ne.TrackDel;function Da(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}var lr=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function Ma(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var Aa=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,h=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let i=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],c=this.from[a]+e,f=this.to[a]+e,u,d;if(c==f){let p=t.mapPos(c,h.startSide,h.mapMode);if(p==null||(u=d=p,h.startSide!=h.endSide&&(d=t.mapPos(c,h.endSide),d<u)))continue}else if(u=t.mapPos(c,h.startSide),d=t.mapPos(f,h.endSide),u>d||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,d-u)),i.push(h),r.push(u-o),s.push(d-o))}return{mapped:i.length?new n(r,s,i,l):null,pos:o}}},G=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Ma)),this.isEmpty)return t.length?n.of(t):this;let l=new zs(this,null,-1).goto(0),a=0,h=[],c=new Rn;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||h.push(lr.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?n.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(l,l+a.length);if(h===!1)r=Math.max(r,a.maxPoint),t.push(a),i.push(e.mapPos(l));else if(h===!0){let{mapped:c,pos:f}=a.map(l,e);c&&(r=Math.max(r,c.maxPoint),t.push(c),i.push(f))}}let s=this.nextLayer.map(e);return t.length==0?s:new n(i,t,s||n.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return ar.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return ar.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=Wd(o,l,i),h=new En(o,a,s),c=new En(l,a,s);i.iterGaps((f,u,d)=>$d(h,f,c,u,d,r)),i.empty&&i.length==0&&$d(h,0,c,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=Wd(s,o),a=new En(s,l,0).goto(i),h=new En(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Ta(a.active,h.active)||a.point&&(!h.point||!Da(a.point,h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,i,r,s=-1){let o=new En(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<t?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);r.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(r.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Rn;for(let r of e instanceof lr?[e]:t?Y1(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return n.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=n.empty;r=r.nextLayer)t=new n(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};G.empty=new G([],[],null,-1);function Y1(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(Ma(e,i)>0)return n.slice().sort(Ma);e=i}return n}G.empty.nextLayer=G.empty;var Rn=class n{finishChunk(e){this.chunks.push(new Aa(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new n)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(G.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=G.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Wd(n,e,t){let i=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!t?.touchesRange(l,l+s.chunk[o].length)&&r.add(s.chunk[o])}return r}var zs=class{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},ar=class n{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new zs(o,t,i,s));return r.length==1?r[0]:new n(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)pa(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)pa(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),pa(this.heap,0)}}};function pa(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var En=class{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ar.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Os(this.active,e),Os(this.activeTo,e),Os(this.activeRank,e),this.minActive=qd(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Es(this.active,t,i),Es(this.activeTo,t,r),Es(this.activeRank,t,s),e&&Es(e,t,this.cursor.from),this.minActive=qd(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Os(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function $d(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,l=i,a=i-e,h=!!s.boundChange;for(let c=!1;;){let f=n.to+a-t.to,u=f||n.endSide-t.endSide,d=u<0?n.to+a:t.to,p=Math.min(d,o);if(n.point||t.point?(n.point&&t.point&&Da(n.point,t.point)&&Ta(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,p,n.point,t.point),c=!1):(c&&s.boundChange(l),p>l&&!Ta(n.active,t.active)&&s.compareRange(l,p,n.active,t.active),h&&p<o&&(f||n.openEnd(d)!=t.openEnd(d))&&(c=!0)),d>o)break;l=d,u<=0&&n.next(),u>=0&&t.next()}}function Ta(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!Da(n[t],e[t]))return!1;return!0}function Os(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function Es(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function qd(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function Pn(n,e,t=n.length){let i=0;for(let r=0;r<t&&r<n.length;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=fe(n,r));return i}function np(n,e,t,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=fe(n,r)}return i===!0?-1:n.length}var ip=typeof Symbol>"u"?"__\u037C":Symbol.for("\u037C"),Na=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),rp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Ge=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
106
|
+
`,this;e--}else if(r instanceof ze){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ze?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Ns=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Dn(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Rs=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(K.prototype[Symbol.iterator]=function(){return this.iter()},Dn.prototype[Symbol.iterator]=Ns.prototype[Symbol.iterator]=Rs.prototype[Symbol.iterator]=function(){return this});var ma=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function mi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function fe(n,e,t=!0,i=!0){return Bd(n,e,t,i)}function V1(n){return n>=56320&&n<57344}function H1(n){return n>=55296&&n<56320}function Kd(n,e){let t=n.charCodeAt(e);if(!H1(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return V1(i)?(t-55296<<10)+(i-56320)+65536:t}function qd(n){return n<65536?1:2}var ga=/\r\n?|\n/,Ne=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Ne||(Ne={})),Vt=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){ya(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new n(e)}composeDesc(e){return this.empty?e:e.empty?this:jd(this,e)}mapDesc(e,t=!1){return e.empty?this:ba(this,e,t)}mapPos(e,t=-1,i=Ne.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(i!=Ne.Simple&&h>=e&&(i==Ne.TrackDel&&r<e&&h>e||i==Ne.TrackBefore&&r<e||i==Ne.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new n(e)}static create(e){return new n(e)}},Me=class n extends Vt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ya(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return ba(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(K.empty);i.push(o?e.slice(s,s+o):K.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:jd(this,e,!0)}map(e,t=!1){return e.empty?this:ba(this,e,t,!0)}iterChanges(e,t=!1){ya(this,e,t)}get desc(){return Vt.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new Nn(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);ke(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;ke(t,c,f),f>0&&en(i,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);ke(t,c,-1),ke(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new n(t,i),filtered:Vt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&ke(r,t-o,-1);let f=new n(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof n){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?K.of(d.split(i||ga)):d:K.empty,m=p.length;if(f==u&&m==0)return;f<o&&a(),f>o&&ke(r,f-o,-1),ke(r,u-f,m),en(s,r,p),o=u}}return h(e),a(!l),l}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(K.empty);i[r]=K.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new n(t,i)}static createSet(e,t){return new n(e,t)}};function ke(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function en(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(K.empty);n.push(t)}}function ya(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=K.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function ba(n,e,t,i=!1){let r=[],s=i?[]:null,o=new Nn(n),l=new Nn(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);ke(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(ke(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(ke(r,0,o.ins),s&&en(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;ke(r,h,a<o.i?o.ins:0),s&&a<o.i&&en(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?Me.createSet(r,s):Vt.create(r);throw new Error("Mismatched change set lengths")}}}function jd(n,e,t=!1){let i=[],r=t?[]:null,s=new Nn(n),o=new Nn(e);for(let l=!1;;){if(s.done&&o.done)return r?Me.createSet(i,r):Vt.create(i);if(s.ins==0)ke(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)ke(i,0,o.ins,l),r&&en(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;ke(i,a,c,l),r&&c&&en(r,i,o.text)}else o.ins==-1?(ke(i,s.off?0:s.len,a,l),r&&en(r,i,s.textBit(a))):(ke(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&en(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}var Nn=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?K.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?K.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},fi=class n{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return v.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return v.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return v.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},v=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new n([this.main],0)}addRange(e,t=!0){return n.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,n.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>fi.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return n.normalized(e.slice(),t);i=s.to}return new n(e,t)}static cursor(e,t=0,i,r){return fi.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r??16777215)<<6)}static range(e,t,i,r){let s=(i??16777215)<<6|(r==null?7:Math.min(6,r));return t<e?fi.create(t,e,48|s):fi.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?n.range(a,l):n.range(l,a))}}return new n(e,t)}};function Jd(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Oa=0,N=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Oa++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Ea),!!e.static,e.enables)}of(e){return new di([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new di(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new di(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Ea(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var di=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Oa++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||xa(f,c)){let d=i(f);if(l?!Hd(d,f.values[o],r):!r(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[s];if(p!=null){let m=Ls(u,p);if(this.dependencies.every(g=>g instanceof N?u.facet(g)===f.facet(g):g instanceof Fe?u.field(g,!1)==f.field(g,!1):!0)||(l?Hd(d=i(f),m,r):r(d=i(f),m)))return f.values[o]=m,0}else d=i(f);return f.values[o]=d,1}}}};function Hd(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function xa(n,e){let t=!1;for(let i of e)sr(n,i)&1&&(t=!0);return t}function W1(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Ls(a,i[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)sr(a,h);return a.values[o]=l(a),1},update(a,h){if(!xa(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=xa(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Ea(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}var Ts=N.define({static:!0}),Fe=class n{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new n(Oa++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Ts).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>{let s=i.facet(Ts),o=r.facet(Ts),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Ts.of({field:this,create:e})]}get extension(){return this}},On={lowest:4,low:3,default:2,high:1,highest:0};function rr(n){return e=>new Ps(e,n)}var hr={highest:rr(On.highest),high:rr(On.high),default:rr(On.default),low:rr(On.low),lowest:rr(On.lowest)},Ps=class{constructor(e,t){this.inner=e,this.prec=t}},Is=class n{of(e){return new or(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},or=class{constructor(e,t){this.compartment=e,this.inner=t}},Bs=class n{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let u of $1(e,t,o))u instanceof Fe?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i?.config.facets;for(let u in s){let d=s[u],p=d[0].facet,m=c&&c[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Ea(m,d))a.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(y=>g.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(g=>W1(g,p,d))}}let f=h.map(u=>u(l));return new n(e,o,f,l,a,s)}};function $1(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof or&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof or){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof Ps)s(o.inner,o.prec);else if(o instanceof Fe)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof di)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,On.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(n,On.default),i.reduce((o,l)=>o.concat(l))}function sr(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function Ls(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var Ud=N.define(),ka=N.define({combine:n=>n.some(e=>e),static:!0}),Gd=N.define({combine:n=>n.length?n[0]:void 0,static:!0}),Yd=N.define(),Xd=N.define(),Qd=N.define(),Zd=N.define({combine:n=>n.length?n[0]:!1}),Ue=class{constructor(e,t){this.type=e,this.value=t}static define(){return new wa}},wa=class{of(e){return new Ue(this,e)}},Sa=class{constructor(e){this.map=e}of(e){return new Z(this,e)}},Z=class n{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new n(this.type,t)}is(e){return this.type==e}static define(e={}){return new Sa(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}};Z.reconfigure=Z.define();Z.appendConfig=Z.define();var ce=class n{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Jd(i,t.newLength),s.some(l=>l.type==n.time)||(this.annotations=s.concat(n.time.of(Date.now())))}static create(e,t,i,r,s,o){return new n(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};ce.time=Ue.define();ce.userEvent=Ue.define();ce.addToHistory=Ue.define();ce.remote=Ue.define();function _1(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function ep(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=Me.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:Z.mapEffects(n.effects,r).concat(Z.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function va(n,e,t){let i=e.selection,r=pi(e.annotations);return e.userEvent&&(r=r.concat(ce.userEvent.of(e.userEvent))),{changes:e.changes instanceof Me?e.changes:Me.of(e.changes||[],t,n.facet(Gd)),selection:i&&(i instanceof v?i:v.single(i.anchor,i.head)),effects:pi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function tp(n,e,t){let i=va(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=ep(i,va(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=ce.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return q1(t?K1(r):r)}function K1(n){let e=n.startState,t=!0;for(let r of e.facet(Yd)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:_1(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=Me.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=ce.create(e,r,n.selection&&n.selection.map(s),Z.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Xd);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof ce?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ce?n=s[0]:n=tp(e,pi(s),!1)}return n}function q1(n){let e=n.startState,t=e.facet(Qd),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=ep(i,va(e,s,n.changes.newLength),!0))}return i==n?n:ce.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var j1=[];function pi(n){return n==null?j1:Array.isArray(n)?n:[n]}var it=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(it||(it={})),J1=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ca;try{Ca=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function U1(n){if(Ca)return Ca.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||J1.test(t)))return!0}return!1}function G1(n){return e=>{if(!/\S/.test(e))return it.Space;if(U1(e))return it.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return it.Word;return it.Other}}var ie=class n{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)sr(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return sr(this,i),Ls(this,i)}update(...e){return tp(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(Is.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(Z.reconfigure)?(t=null,i=l.value):l.is(Z.appendConfig)&&(t=null,i=pi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=Bs.resolve(i,r,this),s=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(ka)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:v.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=pi(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=Z.mapEffects(o,c).concat(Z.mapEffects(pi(a.effects),f))}return{changes:r,selection:v.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Me?e:Me.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return K.of(e.split(this.facet(n.lineSeparator)||ga))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(sr(this,t),Ls(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof Fe&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return n.create({doc:e.doc,selection:v.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Bs.resolve(e.extensions||[],new Map),i=e.doc instanceof K?e.doc:K.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||ga)),r=e.selection?e.selection instanceof v?e.selection:v.single(e.selection.anchor,e.selection.head):v.single(0);return Jd(r,i.length),t.staticFacet(ka)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||`
|
|
107
|
+
`}get readOnly(){return this.facet(Zd)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(Ud))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return G1(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=fe(t,o,!1);if(s(t.slice(a,o))!=it.Word)break;o=a}for(;l<r;){let a=fe(t,l);if(s(t.slice(l,a))!=it.Word)break;l=a}return o==l?null:v.range(o+i,l+i)}};ie.allowMultipleSelections=ka;ie.tabSize=N.define({combine:n=>n.length?n[0]:4});ie.lineSeparator=Gd;ie.readOnly=Zd;ie.phrases=N.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});ie.languageData=Ud;ie.changeFilter=Yd;ie.transactionFilter=Xd;ie.transactionExtender=Qd;Is.reconfigure=Z.define();function cr(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var bt=class{eq(e){return this==e}range(e,t=e){return lr.create(e,t,this)}};bt.prototype.startSide=bt.prototype.endSide=0;bt.prototype.point=!1;bt.prototype.mapMode=Ne.TrackDel;function Da(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}var lr=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function Ma(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var Aa=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,h=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let i=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],c=this.from[a]+e,f=this.to[a]+e,u,d;if(c==f){let p=t.mapPos(c,h.startSide,h.mapMode);if(p==null||(u=d=p,h.startSide!=h.endSide&&(d=t.mapPos(c,h.endSide),d<u)))continue}else if(u=t.mapPos(c,h.startSide),d=t.mapPos(f,h.endSide),u>d||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,d-u)),i.push(h),r.push(u-o),s.push(d-o))}return{mapped:i.length?new n(r,s,i,l):null,pos:o}}},G=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Ma)),this.isEmpty)return t.length?n.of(t):this;let l=new zs(this,null,-1).goto(0),a=0,h=[],c=new Rn;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||h.push(lr.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?n.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(l,l+a.length);if(h===!1)r=Math.max(r,a.maxPoint),t.push(a),i.push(e.mapPos(l));else if(h===!0){let{mapped:c,pos:f}=a.map(l,e);c&&(r=Math.max(r,c.maxPoint),t.push(c),i.push(f))}}let s=this.nextLayer.map(e);return t.length==0?s:new n(i,t,s||n.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return ar.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return ar.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=Wd(o,l,i),h=new En(o,a,s),c=new En(l,a,s);i.iterGaps((f,u,d)=>$d(h,f,c,u,d,r)),i.empty&&i.length==0&&$d(h,0,c,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=Wd(s,o),a=new En(s,l,0).goto(i),h=new En(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Ta(a.active,h.active)||a.point&&(!h.point||!Da(a.point,h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,i,r,s=-1){let o=new En(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<t?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);r.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(r.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Rn;for(let r of e instanceof lr?[e]:t?Y1(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return n.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=n.empty;r=r.nextLayer)t=new n(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};G.empty=new G([],[],null,-1);function Y1(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(Ma(e,i)>0)return n.slice().sort(Ma);e=i}return n}G.empty.nextLayer=G.empty;var Rn=class n{finishChunk(e){this.chunks.push(new Aa(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new n)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(G.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=G.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Wd(n,e,t){let i=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!t?.touchesRange(l,l+s.chunk[o].length)&&r.add(s.chunk[o])}return r}var zs=class{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},ar=class n{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new zs(o,t,i,s));return r.length==1?r[0]:new n(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)pa(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)pa(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),pa(this.heap,0)}}};function pa(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var En=class{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ar.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Os(this.active,e),Os(this.activeTo,e),Os(this.activeRank,e),this.minActive=_d(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Es(this.active,t,i),Es(this.activeTo,t,r),Es(this.activeRank,t,s),e&&Es(e,t,this.cursor.from),this.minActive=_d(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Os(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function $d(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,l=i,a=i-e,h=!!s.boundChange;for(let c=!1;;){let f=n.to+a-t.to,u=f||n.endSide-t.endSide,d=u<0?n.to+a:t.to,p=Math.min(d,o);if(n.point||t.point?(n.point&&t.point&&Da(n.point,t.point)&&Ta(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,p,n.point,t.point),c=!1):(c&&s.boundChange(l),p>l&&!Ta(n.active,t.active)&&s.compareRange(l,p,n.active,t.active),h&&p<o&&(f||n.openEnd(d)!=t.openEnd(d))&&(c=!0)),d>o)break;l=d,u<=0&&n.next(),u>=0&&t.next()}}function Ta(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!Da(n[t],e[t]))return!1;return!0}function Os(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function Es(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function _d(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function Pn(n,e,t=n.length){let i=0;for(let r=0;r<t&&r<n.length;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=fe(n,r));return i}function np(n,e,t,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=fe(n,r)}return i===!0?-1:n.length}var ip=typeof Symbol>"u"?"__\u037C":Symbol.for("\u037C"),Na=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),rp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Ge=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
108
108
|
`)}static newName(){let e=rp[ip]||1;return rp[ip]=e+1,"\u037C"+e.toString(36)}static mount(e,t,i){let r=e[Na],s=i&&i.nonce;r?s&&r.setNonce(s):r=new Ra(e,s),r.mount(Array.isArray(t)?t:[t],e)}},sp=new Map,Ra=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=sp.get(i);if(s)return e[Na]=s;this.sheet=new r.CSSStyleSheet,sp.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Na]=this}mount(e,t){let i=this.sheet,r=0,s=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<s&&a>-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),i)for(let h=0;h<l.rules.length;h++)i.insertRule(l.rules[h],r++)}else{for(;s<a;)r+=this.modules[s++].rules.length;r+=l.rules.length,s++}}if(i)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
|
|
109
|
-
`;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var Ae=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ha=typeof document<"u"?document:{documentElement:{style:{}}},Wa=/Edge\/(\d+)/.exec(Ae.userAgent),Ip=/MSIE \d/.test(Ae.userAgent),$a=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ae.userAgent),ho=!!(Ip||$a||Wa),op=!ho&&/gecko\/(\d+)/i.test(Ae.userAgent),Pa=!ho&&/Chrome\/(\d+)/.exec(Ae.userAgent),lp="webkitFontSmoothing"in Ha.documentElement.style,qa=!ho&&/Apple Computer/.test(Ae.vendor),ap=qa&&(/Mobile\/\w+/.test(Ae.userAgent)||Ae.maxTouchPoints>2),E={mac:ap||/Mac/.test(Ae.platform),windows:/Win/.test(Ae.platform),linux:/Linux|X11/.test(Ae.platform),ie:ho,ie_version:Ip?Ha.documentMode||6:$a?+$a[1]:Wa?+Wa[1]:0,gecko:op,gecko_version:op?+(/Firefox\/(\d+)/.exec(Ae.userAgent)||[0,0])[1]:0,chrome:!!Pa,chrome_version:Pa?+Pa[1]:0,ios:ap,android:/Android\b/.test(Ae.userAgent),webkit:lp,webkit_version:lp?+(/\bAppleWebKit\/(\d+)/.exec(Ae.userAgent)||[0,0])[1]:0,safari:qa,safari_version:qa?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ae.userAgent)||[0,0])[1]:0,tabSize:Ha.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Th(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var Us=Object.create(null);function Oh(n,e,t){if(n==e)return!0;n||(n=Us),e||(e=Us);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function X1(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function hp(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Q1(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}var Ln=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Pe=(function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n})(Pe||(Pe={})),Y=class extends bt{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Sr(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new zn(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=Lp(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new zn(e,i,r,t,e.widget||null,!0)}static line(e){return new vr(e)}static set(e,t=!1){return G.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Y.none=G.empty;var Sr=class n extends Y{constructor(e){let{start:t,end:i}=Lp(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Th(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Us}eq(e){return this==e||e instanceof n&&this.tagName==e.tagName&&Oh(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};Sr.prototype.point=!1;var vr=class n extends Y{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&Oh(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};vr.prototype.mapMode=Ne.TrackBefore;vr.prototype.point=!0;var zn=class n extends Y{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ne.TrackBefore:Ne.TrackAfter:Ne.TrackDel}get type(){return this.startSide!=this.endSide?Pe.WidgetRange:this.startSide<=0?Pe.WidgetBefore:Pe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&Z1(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};zn.prototype.point=!0;function Lp(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function Z1(n,e){return n==e||!!(n&&e&&n.compare(e))}function xi(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var Gs=class n extends bt{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof n&&this.tagName==e.tagName&&Oh(this.attributes,e.attributes)}static create(e){return new n(e.tagName,e.attributes||Us)}static set(e,t=!1){return G.of(e,t)}};Gs.prototype.startSide=Gs.prototype.endSide=-1;function Cr(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Ka(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function pr(n,e){if(!e.anchorNode)return!1;try{return Ka(n,e.anchorNode)}catch{return!1}}function js(n){return n.nodeType==3?Mr(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function mr(n,e,t,i){return t?cp(n,e,t,i,-1)||cp(n,e,t,i,1):!1}function nn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Ys(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function cp(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:$t(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=nn(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?$t(n):0}else return!1}}function $t(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Xs(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function ek(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function zp(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function tk(n,e,t,i,r,s,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,d=c==a.body,p=1,m=1;if(d)u=ek(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let b=c.getBoundingClientRect();({scaleX:p,scaleY:m}=zp(c,b)),u={left:b.left,right:b.left+c.clientWidth*p,top:b.top,bottom:b.top+c.clientHeight*m}}let g=0,y=0;if(r=="nearest")e.top<u.top?(y=e.top-(u.top+o),t>0&&e.bottom>u.bottom+y&&(y=e.bottom-u.bottom+o)):e.bottom>u.bottom&&(y=e.bottom-u.bottom+o,t<0&&e.top-y<u.top&&(y=e.top-(u.top+o)));else{let b=e.bottom-e.top,x=u.bottom-u.top;y=(r=="center"&&b<=x?e.top+b/2-x/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-x+o)-u.top}if(i=="nearest"?e.left<u.left?(g=e.left-(u.left+s),t>0&&e.right>u.right+g&&(g=e.right-u.right+s)):e.right>u.right&&(g=e.right-u.right+s,t<0&&e.left<u.left+g&&(g=e.left-(u.left+s))):g=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-s:e.right-(u.right-u.left)+s)-u.left,g||y)if(d)h.scrollBy(g,y);else{let b=0,x=0;if(y){let C=c.scrollTop;c.scrollTop+=y/m,x=(c.scrollTop-C)*m}if(g){let C=c.scrollLeft;c.scrollLeft+=g/p,b=(c.scrollLeft-C)*p}e={left:e.left-b,top:e.top-x,right:e.right-b,bottom:e.bottom-x},b&&Math.abs(b-g)<1&&(i="nearest"),x&&Math.abs(x-y)<1&&(r="nearest")}if(d)break;(e.top<u.top||e.bottom>u.bottom||e.left<u.left||e.right>u.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function nk(n){let e=n.ownerDocument,t,i;for(let r=n.parentNode;r&&!(r==e.body||t&&i);)if(r.nodeType==1)!i&&r.scrollHeight>r.clientHeight&&(i=r),!t&&r.scrollWidth>r.clientWidth&&(t=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:t,y:i}}var ja=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?$t(t):0),i,Math.min(e.focusOffset,i?$t(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},Bn=null;E.safari&&E.safari_version>=26&&(Bn=!1);function Fp(n){if(n.setActive)return n.setActive();if(Bn)return n.focus(Bn);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(Bn==null?{get preventScroll(){return Bn={preventScroll:!0},!0}}:void 0),!Bn){Bn=!1;for(let t=0;t<e.length;){let i=e[t++],r=e[t++],s=e[t++];i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=s&&(i.scrollLeft=s)}}}var fp;function Mr(n,e,t=e){let i=fp||(fp=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function ki(n,e,t,i){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,n.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,n.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function ik(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function rk(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,$t(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=$t(t))}else{if(t==n)return!0;i=nn(t),t=t.parentNode}}function Vp(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function Hp(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=$t(t)}else if(t.parentNode&&!Ys(t))i=nn(t),t=t.parentNode;else return null}}function Wp(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!Ys(t))i=nn(t)+1,t=t.parentNode;else return null}}var kt=class n{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new n(e.parentNode,nn(e),t)}static after(e,t){return new n(e.parentNode,nn(e)+1,t)}},ne=(function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n})(ne||(ne={})),Fn=ne.LTR,Eh=ne.RTL;function $p(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var sk=$p("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),ok=$p("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),_a=Object.create(null),xt=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);_a[e]=t,_a[t]=-e}function qp(n){return n<=247?sk[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?ok[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var lk=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Qe=class{get dir(){return this.level%2?Eh:Fn}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function Kp(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Kp(i.inner,r.inner))return!1}return!0}var Q=[];function ak(n,e,t,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,a=s?256:r;for(let h=o,c=a,f=a;h<l;h++){let u=qp(n.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),Q[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=Q[h];if(u==128)h<l-1&&c==Q[h+1]&&c&24?u=Q[h]=c:Q[h]=256;else if(u==64){let d=h+1;for(;d<l&&Q[d]==64;)d++;let p=h&&c==8||d<t&&Q[d]==8?f==1?1:8:256;for(let m=h;m<d;m++)Q[m]=p;h=d-1}else u==8&&f==1&&(Q[h]=1);c=u,u&7&&(f=u)}}}function hk(n,e,t,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:t;for(let f=h,u,d,p;f<c;f++)if(d=_a[u=n.charCodeAt(f)])if(d<0){for(let m=l-3;m>=0;m-=3)if(xt[m+1]==-d){let g=xt[m+2],y=g&2?r:g&4?g&1?s:r:0;y&&(Q[f]=Q[xt[m]]=y),l=m;break}}else{if(xt.length==189)break;xt[l++]=f,xt[l++]=u,xt[l++]=a}else if((p=Q[f])==2||p==1){let m=p==r;a=m?0:1;for(let g=l-3;g>=0;g-=3){let y=xt[g+2];if(y&2)break;if(m)xt[g+2]|=2;else{if(y&4)break;xt[g+2]|=4}}}}}function ck(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let h=Q[a];if(h==256){let c=a+1;for(;;)if(c==l){if(r==t.length)break;c=t[r++].to,l=r<t.length?t[r].from:e}else if(Q[c]==256)c++;else break;let f=s==1,u=(c<e?Q[c]:i)==1,d=f==u?f?1:2:i;for(let p=c,m=r,g=m?t[m-1].to:n;p>a;)p==g&&(p=t[--m].from,g=m?t[m-1].to:n),Q[--p]=d;a=c}else s=h,a++}}}function Ja(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==s.length||a<s[h].from){let m=Q[a];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h<s.length&&p==s[h].from){if(f)break e;let m=s[h];if(!c)for(let g=m.to,y=h+1;;){if(g==t)break e;if(y<s.length&&s[y].from==g)g=s[y++].to;else{if(Q[g]==l)break e;break}}if(h++,u)u.push(m);else{m.from>a&&o.push(new Qe(a,m.from,d));let g=m.direction==Fn!=!(d%2);Ua(n,g?i+1:i,r,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(c?Q[p]!=l:Q[p]==l))break;p++}u?Ja(n,a,p,i+1,r,u,o):a<p&&o.push(new Qe(a,p,d)),a=p}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let m=Q[a-1];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h&&p==s[h-1].to){if(f)break e;let m=s[--h];if(!c)for(let g=m.from,y=h;;){if(g==e)break e;if(y&&s[y-1].to==g)g=s[--y].from;else{if(Q[g-1]==l)break e;break}}if(u)u.push(m);else{m.to<a&&o.push(new Qe(m.to,a,d));let g=m.direction==Fn!=!(d%2);Ua(n,g?i+1:i,r,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(c?Q[p-1]!=l:Q[p-1]==l))break;p--}u?Ja(n,p,a,i+1,r,u,o):p<a&&o.push(new Qe(p,a,d)),a=p}}function Ua(n,e,t,i,r,s,o){let l=e%2?2:1;ak(n,r,s,i,l),hk(n,r,s,i,l),ck(r,s,i,l),Ja(n,r,s,e,t,i,o)}function fk(n,e,t){if(!n)return[new Qe(0,0,e==Eh?1:0)];if(e==Fn&&!t.length&&!lk.test(n))return jp(n.length);if(t.length)for(;n.length>Q.length;)Q[Q.length]=256;let i=[],r=e==Fn?0:1;return Ua(n,r,r,t,0,n.length,i),i}function jp(n){return[new Qe(0,n,0)]}var _p="";function uk(n,e,t,i,r){var s;let o=i.head-n.from,l=Qe.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),a=e[l],h=a.side(r,t);if(o==h){let u=l+=r?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!r,t),h=a.side(r,t)}let c=fe(n.text,o,a.forward(r,t));(c<a.from||c>a.to)&&(c=h),_p=n.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return f&&c==h&&f.level+(r?0:1)<a.level?v.cursor(f.side(!r,t)+n.from,f.forward(r,t)?1:-1,f.level):v.cursor(c+n.from,a.forward(r,t)?-1:1,a.level)}function dk(n,e,t){for(let i=e;i<t;i++){let r=qp(n.charCodeAt(i));if(r==1)return Fn;if(r==2||r==4)return Eh}return Fn}var Jp=N.define(),Up=N.define(),Gp=N.define(),Yp=N.define(),Ga=N.define(),Xp=N.define(),Qp=N.define(),Dh=N.define(),Nh=N.define(),Zp=N.define({combine:n=>n.some(e=>e)}),pk=N.define({combine:n=>n.some(e=>e)}),em=N.define(),gr=class n{constructor(e,t="nearest",i="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new n(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new n(v.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Fs=Z.define({map:(n,e)=>n.map(e)}),tm=Z.define();function st(n,e,t){let i=n.facet(Yp);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}var Ht=N.define({combine:n=>n.length?n[0]:!0}),mk=0,gi=N.define({combine(n){return n.filter((e,t)=>{for(let i=0;i<t;i++)if(n[i].plugin==e.plugin)return!1;return!0})}}),qt=class n{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(gi.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(gi.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new n(mk++,e,i,r,l=>{let a=[];return o&&a.push(co.of(h=>{let c=h.plugin(l);return c?o(c):Y.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define((i,r)=>new e(i,r),t)}},yr=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(st(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){st(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){st(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},nm=N.define(),Rh=N.define(),co=N.define(),im=N.define(),Ph=N.define(),Ar=N.define(),rm=N.define();function up(n,e){let t=n.state.facet(rm);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(n):s),r=[];return G.spans(i,e.from,e.to,{point(){},span(s,o,l,a){let h=s-e.from,c=o-e.from,f=r;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=dk(e.text,h,c)),a>0&&f.length&&(p=f[f.length-1]).to==h&&p.direction==d)p.to=c,f=p.inner;else{let m={from:h,to:c,direction:d,inner:[]};f.push(m),f=m.inner}}}}),r}var sm=N.define();function om(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(sm)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}var fr=N.define(),ot=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,s=0,o=0;;){let l=r<e.length?e[r].fromB:1e9,a=s<t.length?t[s]:1e9,h=Math.min(l,a);if(h==1e9)break;let c=h+o,f=h,u=c;for(;;)if(s<t.length&&t[s]<=f){let d=t[s+1];s+=2,f=Math.max(f,d);for(let p=r;p<e.length&&e[p].fromB<=f;p++)o=e[p].toA-e[p].toB;u=Math.max(u,d+o)}else if(r<e.length&&e[r].fromB<=f){let d=e[r++];f=Math.max(f,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;i.push(new n(c,u,h,f))}return i}},Qs=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=Me.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new ot(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new n(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},gk=[],re=class{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return gk}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&X1(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let i=nn(this.dom),r=this.length?e>0:t>0;return new kt(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Si)return e;return null}static get(e){return e.cmTile}},wi=class extends re{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,r,s=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=i?i.nextSibling:t.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==t)for(;r&&r!=l.dom;)r=dp(r);else t.insertBefore(l.dom,r);i=l.dom}for(r=i?i.nextSibling:t.firstChild,s&&r&&(s.written=!0);r;)r=dp(r);this.length=o}};function dp(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Si=class extends wi{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=re.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&s++,r=t.pop()}else{let o=i.children[r++];if(o instanceof Wt)t.push(r),i=o,r=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,t){let i,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==h&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,r=e-a),(h>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&t<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}},Wt=class n extends wi{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},vi=class n extends wi{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let r=new n(t||document.createElement("div"),e);return(!t||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,i){let r=null,s=-1,o=null,l=-1;function a(c,f){for(let u=0,d=0;u<c.children.length&&d<=f;u++){let p=c.children[u],m=d+p.length;m>=f&&(p.isComposite()?a(p,f-d):(!o||o.isHidden&&(t>0||i&&bk(o,p)))&&(m>f||p.flags&32)?(o=p,l=f-d):(d<f||p.flags&16&&!p.isHidden)&&(r=p,s=f-d)),d=m}}a(this,e);let h=(t<0?r:o)||r||o;return h?{tile:h,offset:h==r?s:l}:null}coordsIn(e,t){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t):yk(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:r,offset:s}=i;if(this.dom.contains(r.dom))return r.isText()?new kt(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new kt(a.dom,0);a==i.tile&&(l=!0)}}return new kt(this.dom,0)}};function yk(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=js(e);return t[t.length-1]||null}function bk(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}var Re=class n extends wi{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},In=class n extends re{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let i=this.dom.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;e==0&&t<0||e==i&&t>=0?E.chrome||E.gecko||(e?(r--,o=1):s<i&&(s++,o=-1)):t<0?r--:s<i&&s++;let l=Mr(this.dom,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return E.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Xs(a,o<0):a||null}static of(e,t){let i=new n(t||document.createTextNode(e),e);return t||(i.flags|=2),i}},Vn=class n extends re{constructor(e,t,i,r){super(e,t,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(i)return Xs(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return Xs(o,!l)}}get overrideDOMText(){if(!this.length)return K.empty;let{root:e}=this;if(!e)return K.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,r,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new n(s,i,e,r)}},Ci=class extends re{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return K.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},Ya=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],h=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,s++,e-=a.length):(l.push({tile:r,index:s}),r=a,s=0,i&&a.isComposite()&&i.enter(a))}else if(s==r.length)o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++;else if(e){let a=Math.min(e,r.length-s);i&&i.skip(r,s,s+a),e-=a,s+=a}else break;return this.tile=r,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},Xa=class{constructor(e,t,i,r){this.from=e,this.to=t,this.wrapper=i,this.rank=r}},Qa=class{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,r){var s;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new In(l.dom,l.text+e);a.parent=o}else o.append(r||In.of(e,(s=this.cache.find(In))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?Ba(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=i;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],h=r.lastChild;if(h instanceof Re&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(Ba(a.dom)),r=h;else{if(this.cache.reused.get(a)){let f=re.get(a.dom);f&&f.setDOM(Ba(a.dom))}let c=Re.of(a.mark,a.dom);r.append(c),r=c}this.cache.reused.set(a,2)}let s=re.get(e.text);s&&this.cache.reused.set(s,2);let o=new In(e.text,e.text.nodeValue);o.flags|=8,r.append(o)}addInlineWidget(e,t,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(t,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=lm);let r=vi.start(e,t||((i=this.cache.find(vi))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(t>0&&(l=r.lastChild)&&l instanceof Re&&l.mark.eq(o))r=l,t--;else{let a=Re.of(o,(i=this.cache.find(Re,h=>h.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(a),r=a,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!pp(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(E.ios&&pp(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Ia,0,32)||new Vn(Ia.toDOM(),0,Ia,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new Xa(e.from,e.to,e.value,e.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-t.rank||this.wrappers[i-1].to-t.to)<0;)i--;this.wrappers.splice(i,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let r=t.lastChild;if(i.from<this.pos&&r instanceof Wt&&r.wrapper.eq(i.wrapper))t=r;else{let s=Wt.of(i.wrapper,(e=this.cache.find(Wt,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Ci,void 0,1);return i&&(i.flags=t),i||new Ci(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Za=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}},Zs=[Vn,vi,In,Re,Ci,Wt,Si];for(let n=0;n<Zs.length;n++)Zs[n].bucket=n;var eh=class{constructor(e){this.view=e,this.buckets=Zs.map(()=>[]),this.index=Zs.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=s.length-1;l>=0;l--){let a=(l+o)%s.length,h=s[a];if((!t||t(h))&&!this.reused.has(h))return s.splice(a,1),a<o&&this.index[r]--,this.reused.set(h,i),h}return null}findWidget(e,t,i){let r=this.buckets[0];if(r.length)for(let s=0,o=0;;s++){if(s==r.length){if(o)return null;o=1,s=0}let l=r[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new Vn(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},th=class{constructor(e,t,i,r,s){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new eh(e),this.text=new Za(e.state.doc),this.builder=new Qa(this.cache,new Si(e,e.contentDOM),G.iter(i)),this.cache.reused.set(t,2),this.old=new Ya(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let r=0,s=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>r){let h=a-r;this.preserve(h,!o,!l),r=a,s+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,r=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let r=wk(this.old),s=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?Vn.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,r,s),s=r.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length?this.builder.addText(o.text,r,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),r,s)),s=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Ci)this.cache.add(o);else if(o instanceof Re)this.builder.ensureLine(null),this.builder.addMark(o,r,s),this.cache.reused.set(o,1),s=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Re&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof Re&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,r=this.builder,s=0,o=G.spans(this.decorations,e,t,{point:(l,a,h,c,f,u)=>{if(h instanceof zn){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)r.continueWidget(a-l);else{let d=h.widget||(h.block?rn.block:rn.inline),p=xk(h),m=this.cache.findWidget(d,a-l,p)||Vn.of(d,this.view,a-l,p);h.block?(h.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(m)):(r.ensureLine(i),r.addInlineWidget(m,c,f))}i=null}else i=kk(i,h);a>l&&this.text.skip(a-l)},span:(l,a,h,c)=>{for(let f=l;f<a;){let u=this.text.next(Math.min(512,a-f));u==null?(r.addLineStartIfNotCovered(i),r.addBreak(),f++):(r.ensureLine(i),r.addText(u,h,f==l?c:h.length),f+=u.length),i=null}}});r.addLineStartIfNotCovered(i),this.openWidget=o>s,this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=re.get(r);if(r==this.view.contentDOM)break;s instanceof Re?t.push(s):s?.isLine()?i=s:s instanceof Wt||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new vi(r,lm):i||t.push(Re.of(new Sr({tagName:r.nodeName.toLowerCase(),attributes:Q1(r)}),r)))}return{line:i,marks:t}}};function pp(n,e){let t=i=>{for(let r of i.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(n)}function xk(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}var lm={class:"cm-line"};function kk(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Th(t,n),i&&(n.class+=" "+i)),n}function wk(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof Re&&e.push(i.mark)}return e}function Ba(n){let e=re.get(n);return e&&e.setDOM(n.cloneNode()),n}var rn=class extends Ln{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};rn.inline=new rn("span");rn.block=new rn("div");var Ia=new class extends Ln{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},eo=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Y.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Si(e,e.contentDOM),this.updateInner([new ot(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:c,toA:f})=>f<this.minWidthFrom||c>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!Ek(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?vk(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;i=new ot(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(E.ie||E.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=Ak(o,this.decorations,e.changes);a.length&&(i=ot.extendWithRanges(i,a));let h=Tk(l,this.blockWrappers,e.changes);return h.length&&(i=ot.extendWithRanges(i,h)),s&&!i.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new th(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=l.run(e,t),nh(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=E.chrome||E.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof br&&r.push(s.dom);i.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(tm)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,r=this.view.root.activeElement,s=r==i,o=!s&&!(this.view.state.facet(Ht)||i.tabIndex>-1)&&pr(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),E.gecko&&a.empty&&!this.hasComposition&&Sk(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=c=new kt(u,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!mr(h.node,h.offset,f.anchorNode,f.anchorOffset)||!mr(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{E.android&&E.chrome&&i.contains(f.focusNode)&&Ok(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=Cr(this.view.root);if(u)if(a.empty){if(E.gecko){let d=Ck(h.node,h.offset);if(d&&d!=3){let p=(d==1?Hp:Wp)(h.node,h.offset);p&&(h=new kt(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),d.setEnd(c.node,c.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new kt(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new kt(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&mr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Cr(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(r,s)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[t];else{let o=$t(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!re.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,l=r;;o++){let a=i.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?r+t:r+(t?i.length:0):r}domAtPos(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(e,t):i.domIn(r,t)}inlineDOMNearPos(e,t){let i,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,c)=>{if(h.isWidget()){if(h.flags&32&&c>=e)return!0;h.flags&16&&(s=!0)}else{let f=c+h.length;if(c<=e&&(i=h,r=e-c,s=f<e),f>=e&&!o&&(o=h,l=e-c,a=c>e),c>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(s&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(r,t):o.domIn(l,t))}coordsAt(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof br?null:i.coordsInWidget(r,t,!0):i.coordsIn(r,t)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=fe(s.text,o);if(l==o)return null;let a=Mr(s.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(h==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return r(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ne.LTR,h=0,c=(f,u,d)=>{for(let p=0;p<f.children.length&&!(u>r);p++){let m=f.children[p],g=u+m.length,y=m.dom.getBoundingClientRect(),{height:b}=y;if(d&&!p&&(h+=y.top-d.top),m instanceof Wt)g>i&&c(m,u,y);else if(u>=i&&(h>0&&t.push(-h),t.push(b+h),h=0,o)){let x=m.dom.lastChild,C=x?js(x):[];if(C.length){let w=C[C.length-1],T=a?w.right-y.left:y.right-w.left;T>l&&(l=T,this.minWidth=s,this.minWidthFrom=u,this.minWidthTo=g)}}d&&p==f.children.length-1&&(h+=d.bottom-y.bottom),u=g+m.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?ne.RTL:ne.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let c=js(h.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,r,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=js(t.firstChild)[0];i=t.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Y.replace({widget:new br(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Y.set(e)}updateDeco(){let e=1,t=this.view.state.facet(co).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(Ph).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,t.push(G.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(im).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(em))try{if(h(this.view,e.range,e))return!0}catch(c){st(this.view.state,c,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=om(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(tk(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==ne.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(t.head,1);h&&h.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){nh(this.tile)}};function nh(n,e){let t=e?.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)nh(i,e)}}function Sk(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function am(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=Hp(t.focusNode,t.focusOffset),r=Wp(t.focusNode,t.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let l=re.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(n.docView.lastCompositionAfterCursor){let a=re.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(s=r)}}if(n.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function vk(n,e,t){let i=am(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new ot(a.mapPos(s),a.mapPos(o),s,o),text:r}}function Ck(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}var Mk=class{constructor(){this.changes=[]}compareRange(e,t){xi(e,t,this.changes)}comparePoint(e,t){xi(e,t,this.changes)}boundChange(e){xi(e,e,this.changes)}};function Ak(n,e,t){let i=new Mk;return G.compare(n,e,t,i),i.changes}var ih=class{constructor(){this.changes=[]}compareRange(e,t){xi(e,t,this.changes)}comparePoint(){}boundChange(e){xi(e,e,this.changes)}};function Tk(n,e,t){let i=new ih;return G.compare(n,e,t,i),i.changes}function Ok(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Ek(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}var br=class extends Ln{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function Dk(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return v.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=fe(r.text,s,!1):l=fe(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let h=fe(r.text,o,!1);if(i(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=fe(r.text,l);if(i(r.text.slice(l,h))!=a)break;l=h}return v.range(o+r.from,l+r.from)}function Nk(n,e,t,i,r){let s=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+np(o,s,n.state.tabSize)}function Rk(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!r||s.type==Pe.Text&&(r.type!=s.type||(t<0?s.from<e:s.to>e)))&&(r=s)}}return r||i}return i}function Pk(n,e,t,i){let r=Rk(n,e.head,e.assoc||-1),s=!i||r.type!=Pe.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(r.from),a=n.posAtCoords({x:t==(l==ne.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return v.cursor(a,t?-1:1)}return v.cursor(t?r.to:r.from,t?-1:1)}function mp(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let h=uk(r,s,o,l,t),c=_p;if(!h){if(r.number==(t?n.state.doc.lines:1))return l;c=`
|
|
110
|
-
`,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),h=n.visualLineSide(r,!t)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function
|
|
111
|
-
`&&n.lineWrapping&&(i&&(i=v.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:K.of([" "])}),t)return Bh(n,t,i,s);if(i&&!no(i,r)){let o=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),l=n.inputState.lastSelectionOrigin,l=="select.pointer"&&(i=hm(n.state.facet(Ar).map(a=>a(n)),i))),n.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function Bh(n,e,t,i=-1){if(E.ios&&n.inputState.flushIOSKey(e))return!0;let r=n.state.selection.main;if(E.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&n.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ki(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&ki(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&ki(n.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=Fk(n,e,t));return n.state.facet(Xp).some(a=>a(n,e.from,e.to,s,l))||n.dispatch(l()),!0}function Fk(n,e,t){let i,r=n.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let a=e.from<s.from?-1:1,h=a<0?s.from:s.to,c=xr(r.facet(Ar).map(f=>f(n)),h,a);e.from==c&&(o=c)}if(o>-1)i={changes:e,selection:v.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let a=s.from<e.from?r.sliceDoc(s.from,e.from):"",h=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(a+e.insert.sliceString(0,void 0,n.state.lineBreak)+h))}else{let a=r.changes(e),h=t&&t.main.to<=a.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=n.state.sliceDoc(e.from,e.to),f,u=t&&am(n,t.main.head);if(u){let p=e.insert.length-(e.to-e.from);f={from:u.from,to:u.to-p}}else f=n.state.doc.lineAt(s.head);let d=s.to-e.to;i=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:h||p.map(a)};let m=p.to-d,g=m-c.length;if(n.state.sliceDoc(g,m)!=c||m>=f.from&&g<=f.to)return{range:p};let y=r.changes({from:g,to:m,insert:e.insert}),b=p.to-s.to;return{changes:y,range:h?v.range(Math.max(0,h.anchor+b),Math.max(0,h.head+b)):p.map(y)}})}else i={changes:a,selection:h&&r.selection.replaceRange(h)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}function um(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&n.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function Vk(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new to(t,i)),(r!=t||s!=i)&&e.push(new to(r,s))),e}function Hk(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?v.single(t+e,i+e):null}function no(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}var ah=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,E.safari&&e.contentDOM.addEventListener("input",()=>null),E.gecko&&ew(e.contentDOM.ownerDocument)}handleEvent(e){!Jk(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Wk(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&pm.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),E.android&&E.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return E.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=dm.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||$k.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,ki(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:E.safari&&!E.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function gp(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){st(t.state,r)}}}function Wk(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&t(l).handlers.push(gp(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(gp(i.value,a))}}for(let i in lt)t(i).handlers.push(lt[i]);for(let i in Ze)t(i).observers.push(Ze[i]);return e}var dm=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],$k="dthko",pm=[16,17,18,20,91,92,224,225],Vs=6;function Hs(n){return Math.max(0,n)*.7+8}function qk(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var hh=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=nk(e.contentDOM),this.atoms=e.state.facet(Ar).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ie.allowMultipleSelections)&&Kk(e,t),this.dragging=_k(e,t)&&ym(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&qk(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=om(this.view);e.clientX-a.left<=r+Vs?t=-Hs(r-e.clientX):e.clientX+a.right>=o-Vs&&(t=Hs(e.clientX-o)),e.clientY-a.top<=s+Vs?i=-Hs(s-e.clientY):e.clientY+a.bottom>=l-Vs&&(i=Hs(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=hm(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function Kk(n,e){let t=n.state.facet(Jp);return t.length?t[0](e):E.mac?e.metaKey:e.ctrlKey}function jk(n,e){let t=n.state.facet(Up);return t.length?t[0](e):E.mac?!e.altKey:!e.ctrlKey}function _k(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Cr(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Jk(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=re.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}var lt=Object.create(null),Ze=Object.create(null),mm=E.ie&&E.ie_version<15||E.ios&&E.webkit_version<604;function Uk(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),gm(n,t.value)},50)}function fo(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function gm(n,e){e=fo(n.state,Dh,e);let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(ch!=null&&t.selection.ranges.every(a=>a.empty)&&ch==s.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:v.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:v.cursor(a.from+h.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Ze.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};lt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);Ze.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};Ze.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};lt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(Gp))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Yk(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new hh(n,e,t,i)),i&&n.observer.ignore(()=>{Fp(n.contentDOM);let s=n.root.activeElement;s&&!s.contains(n.contentDOM)&&s.blur()});let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function yp(n,e,t,i){if(i==1)return v.cursor(e,t);if(i==2)return Dk(n.state,e,t);{let r=n.docView.lineAt(e,t),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<n.state.doc.length&&l==s.to&&l++,v.range(o,l)}}var Gk=E.ie&&E.ie_version<=11,bp=null,xp=0,kp=0;function ym(n){if(!Gk)return n.detail;let e=bp,t=kp;return bp=n,kp=Date.now(),xp=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(xp+1)%3:1}function Yk(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=ym(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=n.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),h,c=yp(n,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let f=yp(n,t.pos,t.assoc,i),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u<c.from?v.range(u,d):v.range(d,u)}return o?r.replaceRange(r.main.extend(c.from,c.to)):l&&i==1&&r.ranges.length>1&&(h=Xk(r,a.pos))?h:l?r.addRange(c):v.create([c])}}}function Xk(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return v.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}lt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=v.range(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",fo(n.state,Nh,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};lt.dragend=n=>(n.inputState.draggedContent=null,!1);function wp(n,e,t,i){if(t=fo(n.state,Dh,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&jk(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}lt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&wp(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return wp(n,e,i,!0),!0}return!1};lt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=mm?null:e.clipboardData;return t?(gm(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Uk(n),!1)};function Qk(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Zk(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:fo(n,Nh,e.join(n.lineBreak)),ranges:t,linewise:i}}var ch=null;lt.copy=lt.cut=(n,e)=>{if(!pr(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=Zk(n.state);if(!t&&!r)return!1;ch=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=mm?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Qk(n,t),!1)};var bm=Ue.define();function xm(n,e){let t=[];for(let i of n.facet(Qp)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:bm.of(!0)}):null}function km(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=xm(n.state,e);t?n.dispatch(t):n.update([])}},10)}Ze.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),km(n)};Ze.blur=n=>{n.observer.clearSelectionRange(),km(n)};Ze.compositionstart=Ze.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};Ze.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,E.chrome&&E.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};Ze.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};lt.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=n.posAtDOM(l.startContainer,l.startOffset),h=n.posAtDOM(l.endContainer,l.endOffset);return Bh(n,{from:a,to:h,insert:n.state.toText(s)},null),!0}}let r;if(E.chrome&&E.android&&(r=dm.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return E.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),E.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>Ze.compositionend(n,e),20),!1};var Sp=new Set;function ew(n){Sp.has(n)||(Sp.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var vp=["pre-wrap","normal","pre-line","break-spaces"],Mi=!1;function Cp(){Mi=!1}var fh=class{constructor(e){this.lineWrapping=e,this.doc=K.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return vp.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let l=vp.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}},uh=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},rt=class n{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Pe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof zn?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ee=(function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n})(ee||(ee={})),_s=.001,Ve=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>_s&&(Mi=!0),this.height=e)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=r[l],u=s.lineAt(a,ee.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:s.lineAt(h,ee.ByPosNoHeight,i,0,0);for(f+=d.to-h,h=d.to;l>0&&u.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,ee.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let p=ph.build(i.setDoc(o),e,c,f);s=io(s,s.replace(a,h,p))}return s.updateHeight(i,0)}static empty(){return new Ye(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new dh(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};function io(n,e){return n==e?n:(n.constructor!=e.constructor&&(Mi=!0),e)}Ve.prototype.size=1;var tw=Y.replace({}),ro=class extends Ve{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new rt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new rt(r,0,i,this.spaceAbove,tw):this.mainBlock(i,r)}lineAt(e,t,i,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,i,r,s).join(o):o}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.lineAt(0,ee.ByPos,i,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},Ye=class n extends ro{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new rt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof tn&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof tn?r=new n(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Ve.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},tn=class n extends Ve{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,e-f/2);return new rt(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:c,length:f}=t.doc.line(s+h);return new rt(c,f,i+l*h,l,0)}}lineAt(e,t,i,r,s){if(t==ee.ByHeight)return this.blockAt(e,i,r,s);if(t==ee.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new rt(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),h=i.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=r+l*f+a*(h.from-s-f);return new rt(h.from,h.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,s);for(let c=e,f=r;c<=t;){let u=i.doc.lineAt(c);if(c==e){let p=u.number-l;f+=a*p+h*(e-s-p)}let d=a+h*u.length;o(new rt(u.from,u.length,f,d,0)),f+=d,c=u.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return Ve.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=r.heights[r.index++],u=0;f<0&&(u=-f,f=r.heights[r.index++]),a==-1?a=f:Math.abs(f-a)>=_s&&(a=-2);let d=new Ye(c,f,u);d.outdated=!1,o.push(d),l+=c+1}l<=s&&o.push(null,new n(s-l).updateHeight(e,l));let h=Ve.of(o);return(a<0||Math.abs(h.height-this.height)>=_s||Math.abs(a-this.heightMetrics(e,t).perLine)>=_s)&&(Mi=!0),io(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},dh=class extends Ve{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==ee.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==ee.ByPosNoHeight?ee.ByPosNoHeight:ee.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,r,s).join(h)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,r,s,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,ee.ByPos,i,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,i,r,s,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&Mp(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),Mp(s,l)}return Ve.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ve.of(this.break?[e,null,t]:[e,t]):(this.left=io(this.left,e),this.right=io(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Mp(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof tn&&(i=n[e+1])instanceof tn&&n.splice(e-1,3,new tn(t.length+1+i.length))}var nw=5,ph=class n{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Ye?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Ye(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new ro(o,r,i)):(o||s||r>=nw)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Ye(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new tn(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ye)return e;let t=new Ye(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ye)&&!this.isCovered?this.nodes.push(new Ye(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof Ye&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new n(i,e);return G.spans(t,i,r,s,0),s.finish(i)}};function iw(n,e,t){let i=new mh;return G.compare(n,e,t,i,0),i.changes}var mh=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&xi(e,t,this.changes,5)}};function rw(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=n.parentNode;h&&h!=i.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();s=Math.max(s,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==n.parentNode?r.innerHeight:a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function sw(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function ow(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var kr=class{constructor(e,t,i,r){this.from=e,this.to=t,this.size=i,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return Y.replace({widget:new gh(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},gh=class extends Ln{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},so=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Ap,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ne.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Rh).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new fh(t),this.stateDeco=Tp(e),this.heightMap=Ve.empty().applyChanges(this.stateDeco,K.empty,this.heightOracle.setDoc(e.doc),[new ot(0,0,0,e.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Y.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new yi(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Ap:new yh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(dr(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Tp(this.state);let r=e.changedRanges,s=ot.extendWithRanges(r,iw(i,this.stateDeco,e?e.changes:Me.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Cp(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Mi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(pk)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ne.RTL:ne.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:C,scaleY:w}=zp(t,l);(C>.005&&Math.abs(this.scaleX-C)>.005||w>.005&&Math.abs(this.scaleY-w)>.005)&&(this.scaleX=C,this.scaleY=w,h|=16,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Vp(e.scrollDOM);let p=(this.printing?ow:rw)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!sw(e.dom))return 0;let b=l.width;if((this.contentDOMWidth!=b||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let C=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(C)&&(o=!0),o||r.lineWrapping&&Math.abs(b-this.contentDOMWidth)>r.charWidth){let{lineHeight:w,charWidth:T,textHeight:k}=e.docView.measureTextSize();o=w>0&&r.refresh(s,w,T,k,Math.max(5,b/T),C),o&&(e.docView.minWidth=0,h|=16)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),Cp();for(let w of this.viewports){let T=w.from==this.viewport.from?C:e.docView.measureVisibleLineHeights(w);this.heightMap=(o?Ve.empty().applyChanges(this.stateDeco,K.empty,this.heightOracle,[new ot(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new uh(w.from,T))}Mi&&(h|=2)}let x=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(h&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new yi(r.lineAt(o-i*1e3,ee.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,ee.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(h,ee.ByPos,s,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new yi(r.lineAt(u-1e3/2,ee.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,ee.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new yi(this.heightMap.lineAt(i,ee.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ee.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ee.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,ee.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new kr(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=ne.LTR&&!i)return[];let l=[],a=(c,f,u,d)=>{if(f-c<s)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let y of m)if(y>c&&y<f){a(c,y-10,u,d),a(y+10,f,u,d);return}let g=aw(e,y=>y.from>=u.from&&y.to<=u.to&&Math.abs(y.from-c)<s&&Math.abs(y.to-f)<s&&!m.some(b=>y.from<b&&y.to>b));if(!g){if(f<u.to&&t&&i&&t.visibleRanges.some(x=>x.from<=f&&x.to>=f)){let x=t.moveToLineBoundary(v.cursor(f),!1,!0).head;x>c&&(f=x)}let y=this.gapSize(u,c,f,d),b=i||y<2e6?y:2e6;g=new kr(c,f,y,b)}l.push(g)},h=c=>{if(c.length<o||c.type!=Pe.Text)return;let f=lw(c.from,c.to,this.stateDeco);if(f.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,y;if(u!=null){let b=$s(f,u),x=((this.visibleBottom-this.visibleTop)/2+m)/c.height;g=b-x,y=b+x}else g=(this.visibleTop-c.top-m)/c.height,y=(this.visibleBottom-c.top+m)/c.height;d=Ws(f,g),p=Ws(f,y)}else{let m=f.total*this.heightOracle.charWidth,g=r*this.heightOracle.charWidth,y=0;if(m>2e6)for(let T of e)T.from>=c.from&&T.from<c.to&&T.size!=T.displaySize&&T.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=T.size-T.displaySize);let b=this.pixelViewport.left+y,x=this.pixelViewport.right+y,C,w;if(u!=null){let T=$s(f,u),k=((x-b)/2+g)/m;C=T-k,w=T+k}else C=(b-g)/m,w=(x+g)/m;d=Ws(f,C),p=Ws(f,w)}d>c.from&&a(c.from,d,c,f),p<c.to&&a(p,c.to,c,f)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(h):h(c);return l}gapSize(e,t,i,r){let s=$s(r,i)-$s(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){kr.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Y.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];G.spans(t,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s<i.length&&!(r&8);s++){let o=this.visibleRanges[s],l=i[s];(o.from!=l.from||o.to!=l.to)&&(r|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||dr(this.heightMap.lineAt(e,ee.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||dr(this.heightMap.lineAt(this.scaler.fromDOM(e),ee.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return dr(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},yi=class{constructor(e,t){this.from=e,this.to=t}};function lw(n,e,t){let i=[],r=n,s=0;return G.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function Ws({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function $s(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function aw(n,e){for(let t of n)if(e(t))return t}var Ap={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function Tp(n){let e=n.facet(co).filter(i=>typeof i!="function"),t=n.facet(Ph).filter(i=>typeof i!="function");return t.length&&e.push(G.join(t)),e}var yh=class n{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,ee.ByPos,e,0,0).top,c=t.lineAt(a,ee.ByPos,e,0,0).bottom;return r+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}eq(e){return e instanceof n?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function dr(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new rt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>dr(r,e)):n._content)}var qs=N.define({combine:n=>n.join(" ")}),bh=N.define({combine:n=>n.indexOf(!0)>-1}),xh=Ge.newName(),wm=Ge.newName(),Sm=Ge.newName(),vm={"&light":"."+wm,"&dark":"."+Sm};function kh(n,e,t){return new Ge(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var hw=kh("."+xh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},vm),cw={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},za=E.ie&&E.ie_version<=11,wh=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new ja,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(E.ie&&E.ie_version<=11||E.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&E.android&&e.constructor.EDIT_CONTEXT!==!1&&!(E.chrome&&E.chrome_version<126)&&(this.editContext=new Sh(e),e.state.facet(Ht)&&(e.contentDOM.editContext=this.editContext.editContext)),za&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Ht)?i.root.activeElement!=this.dom:!pr(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(E.ie&&E.ie_version<=11||E.android&&E.chrome)&&!i.state.selection.main.empty&&r.focusNode&&mr(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Cr(e.root);if(!t)return!1;let i=E.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&fw(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=pr(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&rk(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,cw),za&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),za&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&ki(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&pr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new lh(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=fm(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!no(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Op(t,e.previousSibling||e.target.previousSibling,-1),r=Op(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Ht)!=e.state.facet(Ht)&&(e.view.contentDOM.editContext=e.state.facet(Ht)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Op(n,e,t){for(;e;){let i=re.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Ep(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return mr(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function fw(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Ep(n,r)}let t=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Ep(n,t):null}var Sh=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let c=um(e.state.sliceDoc(l,a),i.text,(h?r.from:r.to)-l,h?"end":null);if(!c){let u=v.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));no(u,r)||e.dispatch({selection:u,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:K.of(i.text.slice(c.from,c.toB).split(`
|
|
112
|
-
`))};if((E.mac||E.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:K.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);Bh(e,f,v.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from<f.to&&!f.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}t.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),h=this.toEditorPos(s.rangeEnd);if(a<h){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(Y.mark({attributes:{style:c}}).range(a,h))}}}e.dispatch({effects:tm.of(Y.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let r=Cr(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,h)=>{if(i)return;let c=h.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(h)){r=this.pendingContextChange=null,t+=c,this.to+=c;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=c}t+=c}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},z=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||ik(e.parent)||document,this.viewState=new so(e.state||ie.create(e)),e.scrollTo&&e.scrollTo.is(Fs)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(gi).map(r=>new yr(r));for(let r of this.plugins)r.update(this);this.observer=new wh(this),this.inputState=new ah(this),this.inputState.ensureHandlers(this.plugins),this.docView=new eo(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof ce?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(bm))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=xm(s,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(ie.phrases)!=this.state.facet(ie.phrases))return this.setState(s);r=Qs.create(this,s,e),r.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;f=new gr(d.empty?d:v.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(Fs)&&(f=d.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=oo.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(fr)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(qs)!=r.state.facet(qs)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let u of this.state.facet(Ga))try{u(r)}catch(d){st(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!fm(this,c)&&h.force&&ki(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new so(e),this.plugins=e.facet(gi).map(i=>new yr(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new eo(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(gi),i=e.state.facet(gi);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new yr(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){st(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,r=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Vp(i))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(d=>{try{return d.read(this)}catch(p){return st(this.state,p),Dp}}),f=Qs.create(this,this.state,[]),u=!1;f.flags|=a,t?t.flags|=a:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f),u&&this.docViewUpdate());for(let d=0;d<h.length;d++)if(c[d]!=Dp)try{let p=h[d];p.write&&p.write(c[d],this)}catch(p){st(this.state,p)}if(u&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(p>1||p<-1){r=r+p,i.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Ga))l(t)}get themeClasses(){return xh+" "+(this.state.facet(bh)?Sm:wm)+" "+this.state.facet(qs)}updateAttrs(){let e=Np(this,nm,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ht)?"true":"false",class:"cm-content",style:`${E.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Np(this,Rh,t);let i=this.observer.ignore(()=>{let r=hp(this.contentDOM,this.contentAttrs,t),s=hp(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(fr);let e=this.state.facet(n.cspNonce);Ge.mount(this.root,this.styleModules.concat(hw).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return La(this,e,mp(this,e,t,i))}moveByGroup(e,t){return La(this,e,mp(this,e,t,i=>Bk(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return v.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return Pk(this,e,t,i)}moveVertically(e,t,i){return La(this,e,Ik(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=rh(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),rh(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Qe.find(s,e-r.from,-1,t)];return Xs(i,o.dir==ne.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Zp)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>uw)return jp(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Kp(s.isolates,i=up(this,e))))return s.order;i||(i=up(this,e));let r=fk(e.text,t,i);return this.bidiCache.push(new oo(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||E.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Fp(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Fs.of(new gr(typeof e=="number"?v.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Fs.of(new gr(v.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return qt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return qt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Ge.newName(),r=[qs.of(i),fr.of(kh(`.${i}`,e))];return t&&t.dark&&r.push(bh.of(!0)),r}static baseTheme(e){return hr.lowest(fr.of(kh("."+xh,e,vm)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&re.get(i)||re.get(e);return((t=r?.root)===null||t===void 0?void 0:t.view)||null}};z.styleModule=fr;z.inputHandler=Xp;z.clipboardInputFilter=Dh;z.clipboardOutputFilter=Nh;z.scrollHandler=em;z.focusChangeEffect=Qp;z.perLineTextDirection=Zp;z.exceptionSink=Yp;z.updateListener=Ga;z.editable=Ht;z.mouseSelectionStyle=Gp;z.dragMovesSelection=Up;z.clickAddsSelectionRange=Jp;z.decorations=co;z.blockWrappers=im;z.outerDecorations=Ph;z.atomicRanges=Ar;z.bidiIsolatedRanges=rm;z.scrollMargins=sm;z.darkTheme=bh;z.cspNonce=N.define({combine:n=>n.length?n[0]:""});z.contentAttributes=Rh;z.editorAttributes=nm;z.lineWrapping=z.contentAttributes.of({class:"cm-lineWrapping"});z.announce=Z.define();var uw=4096,Dp={},oo=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:ne.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new n(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}};function Np(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&Th(o,t)}return t}var dw=E.mac?"mac":E.windows?"win":E.linux?"linux":"key";function pw(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){let h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Ks(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var mw=hr.default(z.domEventHandlers({keydown(n,e){return kw(yw(e.state),n,e,"editor")}})),gw=N.define({enables:mw}),Rp=new WeakMap;function yw(n){let e=n.facet(gw),t=Rp.get(e);return t||Rp.set(e,t=xw(e.reduce((i,r)=>i.concat(r),[]))),t}var en=null,bw=4e3;function xw(n,e=dw){let t=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,h,c)=>{var f,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>pw(y,e));for(let y=1;y<p.length;y++){let b=p.slice(0,y).join(" ");r(b,!0),d[b]||(d[b]={preventDefault:!0,stopPropagation:!1,run:[x=>{let C=en={view:x,prefix:b,scope:o};return setTimeout(()=>{en==C&&(en=null)},bw),!0}]})}let m=p.join(" ");r(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0),c&&(g.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in c)c[u].run.push(d=>f(d,vh))}let a=o[e]||o.key;if(a)for(let h of l)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}var vh=null;function kw(n,e,t,i){vh=e;let r=us(e),s=Kd(r,0),o=jd(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;en&&en.view==t&&en.scope==i&&(l=en.prefix+" ",pm.indexOf(e.keyCode)<0&&(h=!0,en=null));let f=new Set,u=g=>{if(g){for(let y of g.run)if(!f.has(y)&&(f.add(y),y(t)))return g.stopPropagation&&(c=!0),!0;g.preventDefault&&(g.stopPropagation&&(c=!0),h=!0)}return!1},d=n[i],p,m;return d&&(u(d[l+Ks(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(E.windows&&e.ctrlKey&&e.altKey)&&!(E.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=nt[e.keyCode])&&p!=r?(u(d[l+Ks(p,e,!0)])||e.shiftKey&&(m=hi[e.keyCode])!=r&&m!=p&&u(d[l+Ks(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+Ks(r,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),vh=null,a}var AA=/x/.unicode!=null?"gu":"g";function TA(){return Sw}var ww=Y.line({class:"cm-activeLine"}),Sw=qt.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(ww.range(r.from)),e=r.from)}return Y.set(t)}},{decorations:n=>n.decorations});var wt=class extends bt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};wt.prototype.elementClass="";wt.prototype.toDOM=void 0;wt.prototype.mapMode=Ne.TrackBefore;wt.prototype.startSide=wt.prototype.endSide=-1;wt.prototype.point=!0;var Fa=N.define(),vw=N.define();var Js=N.define();var Ch=N.define({combine:n=>n.some(e=>e)});function Cw(n){let e=[Mw];return n&&n.fixed===!1&&e.push(Ch.of(!0)),e}var Mw=qt.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(Js).map(e=>new lo(n,e)),this.fixed=!n.state.facet(Ch);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Ch)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=G.iter(this.view.state.facet(Fa),this.view.viewport.from),i=[],r=this.gutters.map(s=>new Ah(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Pe.Text&&o){Mh(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Pe.Text){Mh(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(Js),t=n.state.facet(Js),i=n.docChanged||n.heightChanged||n.viewportChanged||!G.eq(n.startState.facet(Fa),n.state.facet(Fa),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new lo(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>z.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==ne.LTR?{left:i,right:r}:{right:i,left:r}})});function Pp(n){return Array.isArray(n)?n:[n]}function Mh(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var Ah=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=G.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new ao(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Mh(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),r=i?[i]:null;for(let s of e.state.facet(vw)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},lo=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=Pp(t.markers(e)),t.initialSpacer&&(this.spacer=new ao(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Pp(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!G.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},ao=class{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Aw(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(r);let f=r.nextSibling;r.remove(),r=f}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}};function Aw(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}var Tw=N.define(),Ow=N.define(),bi=N.define({combine(n){return cr(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let s=i[r],o=t[r];i[r]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return i}})}}),wr=class extends wt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Va(n,e){return n.state.facet(bi).formatNumber(e,n.state)}var Ew=Js.compute([bi],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Tw)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new wr(Va(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let r of e.state.facet(Ow)){let s=r(e,t,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(bi)!=e.state.facet(bi),initialSpacer(e){return new wr(Va(e,Bp(e.state.doc.lines)))},updateSpacer(e,t){let i=Va(t.view,Bp(t.view.state.doc.lines));return i==e.number?e:new wr(i)},domEventHandlers:n.facet(bi).domEventHandlers,side:"before"}));function OA(n={}){return[bi.of(n),Cw(),Ew]}function Bp(n){let e=9;for(;e<n;)e=e*10+9;return e}var St=null,Ai=null;function PA(){return(!St||!St.isConnected)&&(St=document.createElement("div"),St.className="mikedown-portal",document.body.appendChild(St),Cm()),St}function BA(n){Ai=n,Cm()}function IA(n){Ai===n&&(Ai=null)}function Cm(){if(!St||!Ai)return;let n=Ai.getAttribute("data-mikedown-theme");n?St.setAttribute("data-mikedown-theme",n):St.removeAttribute("data-mikedown-theme"),St.style.cssText=Ai.style.cssText}var Ih=new te("mikedownAiRewriteHighlight"),WA=Je.create({name:"mikedownAiRewriteHighlight",addProseMirrorPlugins(){return[new J({key:Ih,state:{init:()=>null,apply(n,e){let t=n.getMeta(Ih);if(t)return t.range;if(!e||!n.docChanged)return e;if(e.anchor){let s=n.mapping.map(e.from,-1);return{...e,from:s,to:s}}let i=n.mapping.map(e.from,1),r=n.mapping.map(e.to,-1);return r>i?{from:i,to:r,id:e.id}:null}},props:{decorations(n){let e=Ih.getState(n);return!e||e.to<=e.from?null:De.create(n.doc,[yt.inline(e.from,e.to,{class:"mikedown-ai-rewrite-target"})])}}})]}}),Dw=Z.define(),Nw=Fe.define({create:()=>null,update(n,e){for(let r of e.effects)if(r.is(Dw))return r.value;if(!n||!e.docChanged)return n;if(n.anchor){let r=e.changes.mapPos(n.from,-1);return{...n,from:r,to:r}}let t=e.changes.mapPos(n.from,1),i=e.changes.mapPos(n.to,-1);return i>t?{from:t,to:i,id:n.id}:null},provide:n=>z.decorations.from(n,e=>e&&e.to>e.from?Y.set([Y.mark({class:"mikedown-ai-rewrite-target"}).range(e.from,e.to)]):Y.none)}),$A=[Nw];var Tm=["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"],Rw=["127.0.0.0/8","169.254.0.0/16","0.0.0.0/32"],Pw=[".localhost",".local",".lan",".home.arpa",".internal"];function Bw(n){let e=n.trim();if(!e)return null;let i=(/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,""):e).split(/[/?#]/,1)[0],r=i.includes("@")?i.slice(i.lastIndexOf("@")+1):i;if(!r)return null;if(r.startsWith("[")){let o=r.indexOf("]");return o>1?r.slice(1,o).toLowerCase():null}return(r.match(/:/g)??[]).length>1?r.toLowerCase():r.split(":",1)[0].toLowerCase().replace(/\.$/,"")||null}function Om(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(n);if(!e)return null;let t=e.slice(1).map(Number);return t.some(i=>i>255)?null:(t[0]<<24>>>0)+(t[1]<<16)+(t[2]<<8)+t[3]}function Mm(n,e){let[t,i]=e.split("/"),r=Om(t.trim()),s=i===void 0?32:Number(i);if(r===null||!Number.isInteger(s)||s<0||s>32)return!1;if(s===0)return!0;let o=4294967295<<32-s>>>0;return(n&o)>>>0===(r&o)>>>0}function Iw(n){if(!n.includes(":"))return!1;if(n==="::1"||n==="::")return!0;let e=n.split(":")[0];if(!e)return!1;let t=parseInt(e,16);return Number.isNaN(t)?!1:(t&65472)===65152||(t&65024)===64512}function Em(n,e=Tm){let t=Bw(n);if(!t)return"cloud";if(t==="localhost"||Pw.some(s=>t.endsWith(s)))return"local";let i=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/.exec(t),r=Om(i?i[1]:t);if(r!==null)return Rw.some(s=>Mm(r,s))||e.some(s=>/^\d/.test(s.trim())&&Mm(r,s.trim()))?"local":"cloud";if(Iw(t))return"local";for(let s of e){let o=s.trim().toLowerCase();if(!(!o||/^\d/.test(o))&&(o.startsWith(".")?t.endsWith(o):t===o||t.endsWith(`.${o}`)))return"local"}return"cloud"}function KA(n,e){return n.kind==="vscode-lm"?"cloud":n.locality==="local"||n.locality==="cloud"?n.locality:Em(n.baseUrl,e)}function jA(n,e){return n.locality==="auto"||n.kind==="vscode-lm"?!1:n.locality!==Em(n.baseUrl,e)}function _A(){return{enabled:!1,allowCloud:!1,engines:[],routing:{default:null,fallback:"anyLocal",tasks:{}},features:{},localNetworks:[...Tm],showToolbarButton:!0}}var Am="[A-Za-z0-9_-]+",Lw=`(?<![\\w/#&])#(${Am}(?:/${Am})*)`;function zw(){return new RegExp(Lw,"g")}function Dm(n){return/[A-Za-z]/.test(n)}function JA(n){let e=n.trim().replace(/^#+/,"").toLowerCase();return!e||!Dm(e)?null:e}function Fw(n){return/^[0-9a-f]+$/i.test(n)?/[0-9]/.test(n)||n.length===6||n.length===8:!1}function UA(n){let e=zw(),t=[],i;for(;(i=e.exec(n))!==null;)!Dm(i[1])||Fw(i[1])||t.push({tag:i[1],index:i.index,length:i[0].length});return t}var uo=200,me=function(){};me.prototype.append=function(e){return e.length?(e=me.from(e),!this.length&&e||e.length<uo&&this.leafAppend(e)||this.length<uo&&e.leafPrepend(this)||this.appendInner(e)):this};me.prototype.prepend=function(e){return e.length?me.from(e).append(this):this};me.prototype.appendInner=function(e){return new Vw(this,e)};me.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?me.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};me.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};me.prototype.forEach=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length),t<=i?this.forEachInner(e,t,i,0):this.forEachInvertedInner(e,t,i,0)};me.prototype.map=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length);var r=[];return this.forEach(function(s,o){return r.push(e(s,o))},t,i),r};me.from=function(e){return e instanceof me?e:e&&e.length?new Nm(e):me.empty};var Nm=(function(n){function e(i){n.call(this),this.values=i}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(r,s){return r==0&&s==this.length?this:new e(this.values.slice(r,s))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,s,o,l){for(var a=s;a<o;a++)if(r(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,l){for(var a=s-1;a>=o;a--)if(r(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=uo)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=uo)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(me);me.empty=new Nm([]);var Vw=(function(n){function e(t,i){n.call(this),this.left=t,this.right=i,this.length=t.length+i.length,this.depth=Math.max(t.depth,i.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(i){return i<this.left.length?this.left.get(i):this.right.get(i-this.left.length)},e.prototype.forEachInner=function(i,r,s,o){var l=this.left.length;if(r<l&&this.left.forEachInner(i,r,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(i,Math.max(r-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,s,o){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(i,r-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(i,Math.min(r,l),s,o)===!1)return!1},e.prototype.sliceInner=function(i,r){if(i==0&&r==this.length)return this;var s=this.left.length;return r<=s?this.left.slice(i,r):i>=s?this.right.slice(i-s,r-s):this.left.slice(i,s).append(this.right.slice(0,r-s))},e.prototype.leafAppend=function(i){var r=this.right.leafAppend(i);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(i){var r=this.left.leafPrepend(i);if(r)return new e(r,this.right)},e.prototype.appendInner=function(i){return this.left.depth>=Math.max(this.right.depth,i.depth)+1?new e(this.left,new e(this.right,i)):new e(this,i)},e})(me),Lh=me;var Hw=500,Hn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let r,s;t&&(r=this.remapping(i,this.items.length),s=r.maps.length);let o=e.tr,l,a,h=[],c=[];return this.items.forEach((f,u)=>{if(!f.step){r||(r=this.remapping(i,u+1),s=r.maps.length),s--,c.push(f);return}if(r){c.push(new vt(f.map));let d=f.step.map(r.slice(s)),p;d&&o.maybeStep(d).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],h.push(new vt(p,void 0,void 0,h.length+c.length))),s--,p&&r.appendMap(p,s)}else o.maybeStep(f.step);if(f.selection)return l=r?f.selection.map(r.slice(s)):f.selection,a=new n(this.items.slice(0,i).append(c.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,i,r){let s=[],o=this.eventCount,l=this.items,a=!r&&l.length?l.get(l.length-1):null;for(let c=0;c<e.steps.length;c++){let f=e.steps[c].invert(e.docs[c]),u=new vt(e.mapping.maps[c],f,t),d;(d=a&&a.merge(u))&&(u=d,c?s.pop():l=l.slice(0,l.length-1)),s.push(u),t&&(o++,t=void 0),r||(a=u)}let h=o-i.depth;return h>$w&&(l=Ww(l,h),o-=h),new n(l.append(s),o)}remapping(e,t){let i=new Vi;return this.items.forEach((r,s)=>{let o=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?i.maps.length-r.mirrorOffset:void 0;i.appendMap(r.map,o)},e,t),i}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new vt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},r);let a=t;this.items.forEach(u=>{let d=s.getMirror(--a);if(d==null)return;o=Math.min(o,d);let p=s.maps[d];if(u.step){let m=e.steps[d].invert(e.docs[d]),g=u.selection&&u.selection.map(s.slice(a+1,d));g&&l++,i.push(new vt(p,m,g))}else i.push(new vt(p))},r);let h=[];for(let u=t;u<o;u++)h.push(new vt(s.maps[u]));let c=this.items.slice(0,r).append(h).append(i),f=new n(c,l);return f.emptyItemCount()>Hw&&(f=f.compress(this.items.length-i.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),i=t.maps.length,r=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)r.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(i)),h=a&&a.getMap();if(i--,h&&t.appendMap(h,i),a){let c=o.selection&&o.selection.map(t.slice(i));c&&s++;let f=new vt(h.invert(),a,c),u,d=r.length-1;(u=r.length&&r[d].merge(f))?r[d]=u:r.push(f)}}else o.map&&i--},this.items.length,0),new n(Lh.from(r.reverse()),s)}};Hn.empty=new Hn(Lh.empty,0);function Ww(n,e){let t;return n.forEach((i,r)=>{if(i.selection&&e--==0)return t=r,!1}),n.slice(t)}var vt=class n{constructor(e,t,i,r){this.map=e,this.step=t,this.selection=i,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},Ct=class{constructor(e,t,i,r,s){this.done=e,this.undone=t,this.prevRanges=i,this.prevTime=r,this.prevComposition=s}},$w=20;function qw(n,e,t,i){let r=t.getMeta(sn),s;if(r)return r.historyState;t.getMeta(Bm)&&(n=new Ct(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(sn))return o.getMeta(sn).redo?new Ct(n.done.addTransform(t,void 0,i,po(e)),n.undone,Rm(t.mapping.maps),n.prevTime,n.prevComposition):new Ct(n.done,n.undone.addTransform(t,void 0,i,po(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)-i.newGroupDelay||!Kw(t,n.prevRanges)),h=o?zh(n.prevRanges,t.mapping):Rm(t.mapping.maps);return new Ct(n.done.addTransform(t,a?e.selection.getBookmark():void 0,i,po(e)),Hn.empty,h,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Ct(n.done.rebased(t,s),n.undone.rebased(t,s),zh(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ct(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),zh(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Kw(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((i,r)=>{for(let s=0;s<e.length;s+=2)i<=e[s+1]&&r>=e[s]&&(t=!0)}),t}function Rm(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((i,r,s,o)=>e.push(s,o));return e}function zh(n,e){if(!n)return null;let t=[];for(let i=0;i<n.length;i+=2){let r=e.map(n[i],1),s=e.map(n[i+1],-1);r<=s&&t.push(r,s)}return t}function jw(n,e,t){let i=po(e),r=sn.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,i);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),r,i),a=new Ct(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(sn,{redo:t,historyState:a})}var Fh=!1,Pm=null;function po(n){let e=n.plugins;if(Pm!=e){Fh=!1,Pm=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Fh=!0;break}}return Fh}function eT(n){return n.setMeta(Bm,!0)}var sn=new te("history"),Bm=new te("closeHistory");function tT(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new J({key:sn,state:{init(){return new Ct(Hn.empty,Hn.empty,null,0,-1)},apply(e,t,i){return qw(t,i,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let i=t.inputType,r=i=="historyUndo"?_w:i=="historyRedo"?Jw:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function mo(n,e){return(t,i)=>{let r=sn.getState(t);if(!r||(n?r.undone:r.done).eventCount==0)return!1;if(i){let s=jw(r,t,n);s&&i(e?s.scrollIntoView():s)}return!0}}var _w=mo(!1,!0),Jw=mo(!0,!0),nT=mo(!1,!1),iT=mo(!0,!1);function rT(n){let e=sn.getState(n);return e?e.done.eventCount:0}var Uw=0,Be=class{constructor(e,t){this.from=e,this.to=t}},V=class{constructor(e={}){this.id=Uw++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Te.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};V.closedBy=new V({deserialize:n=>n.split(" ")});V.openedBy=new V({deserialize:n=>n.split(" ")});V.group=new V({deserialize:n=>n.split(" ")});V.isolate=new V({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});V.contextHash=new V({perNode:!0});V.lookAhead=new V({perNode:!0});V.mounted=new V({perNode:!0});var on=class{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[V.mounted.id]}},Gw=Object.create(null),Te=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):Gw,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(V.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(V.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};Te.none=new Te("",Object.create(null),0,8);var Vh=class n{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);if(o){r||(r=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in r&&(l=a.combine(r[a.id],l)),r[a.id]=l}}t.push(r?new Te(i.name,r,i.id,i.flags):i)}return new n(t)}},go=new WeakMap,Im=new WeakMap,X;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(X||(X={}));var le=class n{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=on.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Ti(this.topNode,e)}cursorAt(e,t=0,i=0){let r=go.get(this)||this.topNode,s=new Ti(r);return s.moveTo(e,t),go.set(this,s._tree),s}get topNode(){return new Ie(this,0,0,null)}resolve(e,t=0){let i=Tr(go.get(this)||this.topNode,e,t,!1);return go.set(this,i),i}resolveInner(e,t=0){let i=Tr(Im.get(this)||this.topNode,e,t,!0);return Im.set(this,i),i}resolveStack(e,t=0){return Yw(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&X.IncludeAnonymous)>0;for(let a=this.cursor(o|X.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Yh(Te.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(Te.none,t,i,r)))}static build(e){return Xw(e)}};le.empty=new le(Te.none,[],[],0);var Hh=class n{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new n(this.buffer,this.index)}},ln=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Te.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(qm(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-i;let h=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,h)}return new n(s,o,this.set)}};function qm(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Tr(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof Ie&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:X.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof Ie&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}var bo=class{cursor(e=0){return new Ti(this,e)}getChild(e,t=null,i=null){let r=Lm(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Lm(this,e,t,i)}resolve(e,t=0){return Tr(this,e,t,!1)}resolveInner(e,t=0){return Tr(this,e,t,!0)}matchContext(e){return Wh(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},Ie=class n extends bo{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from,u;if(!(!(s&X.EnterBracketed&&c instanceof le&&(u=on.get(c))&&!u.overlay&&u.bracketed&&i>=f&&i<=f+c.length)&&!qm(r,i,f,f+c.length))){if(c instanceof ln){if(s&X.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,i-f,r);if(d>-1)return new Wn(new $h(o,c,e,f),null,d)}else if(s&X.IncludeAnonymous||!c.type.isAnonymous||Gh(c)){let d;if(!(s&X.IgnoreMounts)&&(d=on.get(c))&&!d.overlay)return new n(d.tree,f,e,o);let p=new n(c,f,e,o);return s&X.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,r,s)}}}if(s&X.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&X.IgnoreOverlays)&&(r=on.get(this._tree))&&r.overlay){let s=e-this.from,o=i&X.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((t>0||o?l<=s:l<s)&&(t<0||o?a>=s:a>s))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Lm(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function Wh(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var $h=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Wn=class n extends bo{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&X.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new le(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Km(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof Ie&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new qh(r,t)}var qh=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Km(this.heads)}};function Yw(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof Ie?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=on.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Ie(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Tr(l,e,t,!1))}}return r?Km(r):i}var Ti=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~X.EnterBracketed,e instanceof Ie)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof Ie?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&X.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&X.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&X.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&X.IncludeAnonymous||l instanceof ln||!l.type.isAnonymous||Gh(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new Wn(this.buffer,t,this.stack[r]);return this.bufferNode=new Wn(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return Wh(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return Wh(this._tree,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function Gh(n){return n.children.some(e=>e instanceof ln||!e.type.isAnonymous||Gh(e))}function Xw(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Hh(t,t.length):t,a=i.types,h=0,c=0;function f(w,T,k,D,R,W){let{id:H,start:I,end:$,size:q}=l,j=c,jt=h;if(q<0)if(l.next(),q==-1){let Ot=s[H];k.push(Ot),D.push(I-w);return}else if(q==-3){h=H;return}else if(q==-4){c=H;return}else throw new RangeError(`Unrecognized record size: ${q}`);let Ni=a[H],Ir,fn,wc=I-w;if($-I<=r&&(fn=g(l.pos-T,R))){let Ot=new Uint16Array(fn.size-fn.skip),We=l.pos-fn.size,dt=Ot.length;for(;l.pos>We;)dt=y(fn.start,Ot,dt);Ir=new ln(Ot,$-fn.start,i),wc=fn.start-w}else{let Ot=l.pos-q;l.next();let We=[],dt=[],un=H>=o?H:-1,Jn=0,Lr=$;for(;l.pos>Ot;)un>=0&&l.id==un&&l.size>=0?(l.end<=Lr-r&&(p(We,dt,I,Jn,l.end,Lr,un,j,jt),Jn=We.length,Lr=l.end),l.next()):W>2500?u(I,Ot,We,dt):f(I,Ot,We,dt,un,W+1);if(un>=0&&Jn>0&&Jn<We.length&&p(We,dt,I,Jn,I,Lr,un,j,jt),We.reverse(),dt.reverse(),un>-1&&Jn>0){let Sc=d(Ni,jt);Ir=Yh(Ni,We,dt,0,We.length,0,$-I,Sc,Sc)}else Ir=m(Ni,We,dt,$-I,j-$,jt)}k.push(Ir),D.push(wc)}function u(w,T,k,D){let R=[],W=0,H=-1;for(;l.pos>T;){let{id:I,start:$,end:q,size:j}=l;if(j>4)l.next();else{if(H>-1&&$<H)break;H<0&&(H=q-r),R.push(I,$,q),W++,l.next()}}if(W){let I=new Uint16Array(W*4),$=R[R.length-2];for(let q=R.length-3,j=0;q>=0;q-=3)I[j++]=R[q],I[j++]=R[q+1]-$,I[j++]=R[q+2]-$,I[j++]=j;k.push(new ln(I,R[2]-$,i)),D.push($-w)}}function d(w,T){return(k,D,R)=>{let W=0,H=k.length-1,I,$;if(H>=0&&(I=k[H])instanceof le){if(!H&&I.type==w&&I.length==R)return I;($=I.prop(V.lookAhead))&&(W=D[H]+I.length+$)}return m(w,k,D,R,W,T)}}function p(w,T,k,D,R,W,H,I,$){let q=[],j=[];for(;w.length>D;)q.push(w.pop()),j.push(T.pop()+k-R);w.push(m(i.types[H],q,j,W-R,I-W,$)),T.push(R-k)}function m(w,T,k,D,R,W,H){if(W){let I=[V.contextHash,W];H=H?[I].concat(H):[I]}if(R>25){let I=[V.lookAhead,R];H=H?[I].concat(H):[I]}return new le(w,T,k,D,H)}function g(w,T){let k=l.fork(),D=0,R=0,W=0,H=k.end-r,I={size:0,start:0,skip:0};e:for(let $=k.pos-w;k.pos>$;){let q=k.size;if(k.id==T&&q>=0){I.size=D,I.start=R,I.skip=W,W+=4,D+=4,k.next();continue}let j=k.pos-q;if(q<0||j<$||k.start<H)break;let jt=k.id>=o?4:0,Ni=k.start;for(k.next();k.pos>j;){if(k.size<0)if(k.size==-3||k.size==-4)jt+=4;else break e;else k.id>=o&&(jt+=4);k.next()}R=Ni,D+=q,W+=jt}return(T<0||D==w)&&(I.size=D,I.start=R,I.skip=W),I.size>4?I:void 0}function y(w,T,k){let{id:D,start:R,end:W,size:H}=l;if(l.next(),H>=0&&D<o){let I=k;if(H>4){let $=l.pos-(H-4);for(;l.pos>$;)k=y(w,T,k)}T[--k]=I,T[--k]=W-w,T[--k]=R-w,T[--k]=D}else H==-3?h=D:H==-4&&(c=D);return k}let b=[],x=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,b,x,-1,0);let C=(e=n.length)!==null&&e!==void 0?e:b.length?x[0]+b[0].length:0;return new le(a[n.topID],b.reverse(),x.reverse(),C)}var zm=new WeakMap;function yo(n,e){if(!n.isAnonymous||e instanceof ln||e.type!=n)return 1;let t=zm.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof le)){t=1;break}t+=yo(n,i)}zm.set(e,t)}return t}function Yh(n,e,t,i,r,s,o,l,a){let h=0;for(let p=i;p<r;p++)h+=yo(n,e[p]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(p,m,g,y,b){for(let x=g;x<y;){let C=x,w=m[x],T=yo(n,p[x]);for(x++;x<y;x++){let k=yo(n,p[x]);if(T+k>=c)break;T+=k}if(x==C+1){if(T>c){let k=p[C];d(k.children,k.positions,0,k.children.length,m[C]+b);continue}f.push(p[C])}else{let k=m[x-1]+p[x-1].length-w;f.push(Yh(n,p,m,C,x,w,k,null,a))}u.push(w+b-s)}}return d(e,t,i,r,0),(l||a)(f,u,o)}var Fm=class{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Wn?this.setBuffer(e.context.buffer,e.index,t):e instanceof Ie&&this.map.set(e.tree,t)}get(e){return e instanceof Wn?this.getBuffer(e.context.buffer,e.index):e instanceof Ie?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},Kt=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new n(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&r.push(u),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return r}},xo=class{startParse(e,t,i){return typeof e=="string"&&(e=new Kh(e)),i=i?i.length?i.map(r=>new Be(r.from,r.to)):[new Be(0,0)]:[new Be(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},Kh=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function aT(n){return(e,t,i,r)=>new Jh(e,n,t,i,r)}var ko=class{constructor(e,t,i,r,s,o){this.parser=e,this.parse=t,this.overlay=i,this.bracketed=r,this.target=s,this.from=o}};function Vm(n){if(!n.length||n.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(n))}var jh=class{constructor(e,t,i,r,s,o,l,a){this.parser=e,this.predicate=t,this.mounts=i,this.index=r,this.start=s,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}},_h=new V({perNode:!0}),Jh=class{constructor(e,t,i,r,s){this.nest=t,this.input=i,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new le(i.type,i.children,i.positions,i.length,i.propValues.concat([[_h,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[V.mounted.id]=new on(t,e.overlay,e.parser,e.bracketed),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new Uh(this.fragments),t=null,i=null,r=new Ti(new Ie(this.baseTree,this.ranges[0].from,0,null),X.IncludeAnonymous|X.IgnoreMounts);e:for(let s,o;;){let l=!0,a;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)l=!1;else if(e.hasNode(r)){if(t){let h=t.mounts.find(c=>c.frag.from<=r.from&&c.frag.to>=r.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let f=c.from+h.pos,u=c.to+h.pos;f>=r.from&&u<=r.to&&!t.ranges.some(d=>d.from<u&&d.to>f)&&t.ranges.push({from:f,to:u})}}l=!1}else if(i&&(o=Qw(i.ranges,r.from,r.to)))l=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.from<r.to||!s.overlay)){r.tree||(Zw(r),t&&t.depth++,i&&i.depth++);let h=e.findMounts(r.from,s.parser);if(typeof s.overlay=="function")t=new jh(s.parser,s.overlay,h,this.inner.length,r.from,!!s.bracketed,r.tree,t);else{let c=Wm(this.ranges,s.overlay||(r.from<r.to?[new Be(r.from,r.to)]:[]));c.length&&Vm(c),(c.length||!s.overlay)&&this.inner.push(new ko(s.parser,c.length?s.parser.startParse(this.input,$m(h,c),c):s.parser.startParse(""),s.overlay?s.overlay.map(f=>new Be(f.from-r.from,f.to-r.from)):null,!!s.bracketed,r.tree,c.length?c[0].from:r.from)),s.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):l=!1}}else if(t&&(a=t.predicate(r))&&(a===!0&&(a=new Be(r.from,r.to)),a.from<a.to)){let h=t.ranges.length-1;h>=0&&t.ranges[h].to==a.from?t.ranges[h]={from:t.ranges[h].from,to:a.to}:t.ranges.push(a)}if(l&&r.firstChild())t&&t.depth++,i&&i.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(t&&!--t.depth){let h=Wm(this.ranges,t.ranges);h.length&&(Vm(h),this.inner.splice(t.index,0,new ko(t.parser,t.parser.startParse(this.input,$m(t.mounts,h),h),t.ranges.map(c=>new Be(c.from-t.start,c.to-t.start)),t.bracketed,t.target,h[0].from))),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}};function Qw(n,e,t){for(let i of n){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function Hm(n,e,t,i,r,s){if(e<t){let o=n.buffer[e+1];i.push(n.slice(e,t,o)),r.push(o-s)}}function Zw(n){let{node:e}=n,t=[],i=e.context.buffer;do t.push(n.index),n.parent();while(!n.tree);let r=n.tree,s=r.children.indexOf(i),o=r.children[s],l=o.buffer,a=[s];function h(c,f,u,d,p,m){let g=t[m],y=[],b=[];Hm(o,c,g,y,b,d);let x=l[g+1],C=l[g+2];a.push(y.length);let w=m?h(g+4,l[g+3],o.set.types[l[g]],x,C-x,m-1):e.toTree();return y.push(w),b.push(x-d),Hm(o,l[g+3],f,y,b,d),new le(u,y,b,p)}r.children[s]=h(0,l.length,Te.none,0,o.length,t.length-1);for(let c of a){let f=n.tree.children[c],u=n.tree.positions[c];n.yield(new Ie(f,u+n.from,c,n._tree))}}var wo=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(X.IncludeAnonymous|X.IgnoreMounts)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)t.to>=e&&t.enter(i,1,X.IgnoreOverlays|X.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof le)t=t.children[0];else break}return!1}},Uh=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(t=i.tree.prop(_h))!==null&&t!==void 0?t:i.to,this.inner=new wo(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(_h))!==null&&e!==void 0?e:t.to,this.inner=new wo(t.tree,-t.offset)}}findMounts(e,t){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(i=s.tree)===null||i===void 0?void 0:i.prop(V.mounted);if(o&&o.parser==t)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=s.to)break;a.tree==this.curFrag.tree&&r.push({frag:a,pos:s.from-a.offset,mount:o})}}}return r}};function Wm(n,e){let t=null,i=e;for(let r=1,s=0;r<n.length;r++){let o=n[r-1].to,l=n[r].from;for(;s<i.length;s++){let a=i[s];if(a.from>=l)break;a.to<=o||(t||(i=t=e.slice()),a.from<o?(t[s]=new Be(a.from,o),a.to>l&&t.splice(s+1,0,new Be(l,a.to))):a.to>l?t[s--]=new Be(l,a.to):t.splice(s--,1))}}return i}function eS(n,e,t,i){let r=0,s=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=r==n.length?1e9:o?n[r].to:n[r].from,f=s==e.length?1e9:l?e[s].to:e[s].from;if(o!=l){let u=Math.max(a,t),d=Math.min(c,f,i);u<d&&h.push(new Be(u,d))}if(a=Math.min(c,f),a==1e9)break;c==a&&(o?(o=!1,r++):o=!0),f==a&&(l?(l=!1,s++):l=!0)}return h}function $m(n,e){let t=[];for(let{pos:i,mount:r,frag:s}of n){let o=i+(r.overlay?r.overlay[0].from:0),l=o+r.tree.length,a=Math.max(s.from,o),h=Math.min(s.to,l);if(r.overlay){let c=r.overlay.map(u=>new Be(u.from+i,u.to+i)),f=eS(e,c,a,h);for(let u=0,d=a;;u++){let p=u==f.length,m=p?h:f[u].from;if(m>d&&t.push(new Kt(d,m,r.tree,-o,s.from>=d||s.openStart,s.to<=m||s.openEnd)),p)break;d=f[u].to}}else t.push(new Kt(a,h,r.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return t}var tS=0,at=class n{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=tS++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof n&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new n(i,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Mo(e);return i=>i.modified.indexOf(t)>-1?i:Mo.get(i.base||i,i.modified.concat(t).sort((r,s)=>r.id-s.id))}},nS=0,Mo=class n{constructor(e){this.name=e,this.instances=[],this.id=nS++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&iS(t,l.modified));if(i)return i;let r=[],s=new at(e.name,r,e,t);for(let l of t)l.instances.push(s);let o=rS(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(n.get(l,a));return s}};function iS(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function rS(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Jm(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let d=r[f++];if(f==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new qn(i,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return Um.add(e)}var Um=new V({combine(n,e){let t,i,r;for(;n||e;){if(!n||e&&n.depth>=e.depth?(r=e,e=e.next):(r=n,n=n.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new qn(r.tags,r.mode,r.context);t?t.next=s:i=s,t=s}return i}}),qn=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};qn.empty=new qn([],2,null);function ec(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function sS(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function Gm(n,e,t,i=0,r=n.length){let s=new Qh(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var Qh=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=r,c=oS(e)||qn.empty,f=sS(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(V.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let b=g<u.overlay.length?u.overlay[g]:null,x=b?b.from+l:a,C=Math.max(t,y),w=Math.min(i,x);if(C<w&&m)for(;e.from<w&&(this.highlightRange(e,C,w,r,s),this.startSpan(Math.min(w,e.to),h),!(e.to>=x||!e.nextSibling())););if(!b||x>i)break;y=b.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,b.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),h))}m&&e.parent()}else if(e.firstChild()){u&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}};function oS(n){let e=n.type.prop(Um);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var M=at.define,So=M(),an=M(),jm=M(an),_m=M(an),hn=M(),vo=M(hn),Xh=M(hn),Tt=M(),$n=M(Tt),Mt=M(),At=M(),Zh=M(),Or=M(Zh),Co=M(),A={comment:So,lineComment:M(So),blockComment:M(So),docComment:M(So),name:an,variableName:M(an),typeName:jm,tagName:M(jm),propertyName:_m,attributeName:M(_m),className:M(an),labelName:M(an),namespace:M(an),macroName:M(an),literal:hn,string:vo,docString:M(vo),character:M(vo),attributeValue:M(vo),number:Xh,integer:M(Xh),float:M(Xh),bool:M(hn),regexp:M(hn),escape:M(hn),color:M(hn),url:M(hn),keyword:Mt,self:M(Mt),null:M(Mt),atom:M(Mt),unit:M(Mt),modifier:M(Mt),operatorKeyword:M(Mt),controlKeyword:M(Mt),definitionKeyword:M(Mt),moduleKeyword:M(Mt),operator:At,derefOperator:M(At),arithmeticOperator:M(At),logicOperator:M(At),bitwiseOperator:M(At),compareOperator:M(At),updateOperator:M(At),definitionOperator:M(At),typeOperator:M(At),controlOperator:M(At),punctuation:Zh,separator:M(Zh),bracket:Or,angleBracket:M(Or),squareBracket:M(Or),paren:M(Or),brace:M(Or),content:Tt,heading:$n,heading1:M($n),heading2:M($n),heading3:M($n),heading4:M($n),heading5:M($n),heading6:M($n),contentSeparator:M(Tt),list:M(Tt),quote:M(Tt),emphasis:M(Tt),strong:M(Tt),link:M(Tt),monospace:M(Tt),strikethrough:M(Tt),inserted:M(),deleted:M(),changed:M(),invalid:M(),meta:Co,documentMeta:M(Co),annotation:M(Co),processingInstruction:M(Co),definition:at.defineModifier("definition"),constant:at.defineModifier("constant"),function:at.defineModifier("function"),standard:at.defineModifier("standard"),local:at.defineModifier("local"),special:at.defineModifier("special")};for(let n in A){let e=A[n];e instanceof at&&(e.name=n)}var fT=ec([{tag:A.link,class:"tok-link"},{tag:A.heading,class:"tok-heading"},{tag:A.emphasis,class:"tok-emphasis"},{tag:A.strong,class:"tok-strong"},{tag:A.keyword,class:"tok-keyword"},{tag:A.atom,class:"tok-atom"},{tag:A.bool,class:"tok-bool"},{tag:A.url,class:"tok-url"},{tag:A.labelName,class:"tok-labelName"},{tag:A.inserted,class:"tok-inserted"},{tag:A.deleted,class:"tok-deleted"},{tag:A.literal,class:"tok-literal"},{tag:A.string,class:"tok-string"},{tag:A.number,class:"tok-number"},{tag:[A.regexp,A.escape,A.special(A.string)],class:"tok-string2"},{tag:A.variableName,class:"tok-variableName"},{tag:A.local(A.variableName),class:"tok-variableName tok-local"},{tag:A.definition(A.variableName),class:"tok-variableName tok-definition"},{tag:A.special(A.variableName),class:"tok-variableName2"},{tag:A.definition(A.propertyName),class:"tok-propertyName tok-definition"},{tag:A.typeName,class:"tok-typeName"},{tag:A.namespace,class:"tok-namespace"},{tag:A.className,class:"tok-className"},{tag:A.macroName,class:"tok-macroName"},{tag:A.propertyName,class:"tok-propertyName"},{tag:A.operator,class:"tok-operator"},{tag:A.comment,class:"tok-comment"},{tag:A.meta,class:"tok-meta"},{tag:A.invalid,class:"tok-invalid"},{tag:A.punctuation,class:"tok-punctuation"}]);var tc,Oi=new V;function lS(n){return N.define({combine:n?e=>e.concat(n):void 0})}var aS=new V,He=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,ie.prototype.hasOwnProperty("tree")||Object.defineProperty(ie.prototype,"tree",{get(){return ht(this)}}),this.parser=t,this.extension=[Ei.of(this),ie.languageData.of((s,o,l)=>{let a=Ym(s,o,l),h=a.type.prop(Oi);if(!h)return[];let c=s.facet(h),f=a.type.prop(aS);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return Ym(e,t,i).type.prop(Oi)==this.data}findRegions(e){let t=e.facet(Ei);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Oi)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(V.mounted);if(l){if(l.tree.prop(Oi)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof le&&r(h,s.positions[a]+o)}};return r(ht(e),0),i}get allowsNesting(){return!0}};He.setState=Z.define();function Ym(n,e,t){let i=n.facet(Ei),r=ht(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,X.ExcludeBuffers|X.EnterBracketed))s.type.isTop&&(r=s);return r}var Xm=class n extends He{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=lS(e.languageData);return new n(t,e.parser.configure({props:[Oi.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new n(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function ht(n){let e=n.field(He.state,!1);return e?e.tree:le.empty}var sc=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Er=null,oc=class n{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],le.empty,0,i,[],null)}startParse(){return this.parser.startParse(new sc(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=le.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(Kt.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Kt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Er;Er=this;try{return e()}finally{Er=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Qm(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=Kt.applyChanges(i,a),r=le.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new n(this.parser,t,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=Qm(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends xo{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=Er;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new le(Te.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Er}};function Qm(n,e,t){return Kt.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var Dr=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=oc.create(e.facet(Ei).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};He.state=Fe.define({create:Dr.init,update(n,e){for(let t of e.effects)if(t.is(He.setState))return t.value;return e.startState.facet(Ei)!=e.state.facet(Ei)?Dr.init(e.state):n.apply(e)}});var rg=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(rg=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var nc=typeof navigator<"u"&&(!((tc=navigator.scheduling)===null||tc===void 0)&&tc.isInputPending)?()=>navigator.scheduling.isInputPending():null,hS=qt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(He.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(He.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=rg(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(He.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!nc?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>nc&&nc()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:He.setState.of(new Dr(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>st(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ei=N.define({combine(n){return n.length?n[0]:null},enables:n=>[He.state,hS,z.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),Zm=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},eg=class n{constructor(e,t,i,r,s,o=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=r,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new n(e.name,(e.alias||[]).concat(e.name).map(r=>r.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let r of e)if(r.filename&&r.filename.test(t))return r;let i=/\.([^.]+)$/.exec(t);if(i){for(let r of e)if(r.extensions.indexOf(i[1])>-1)return r}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let r of e)if(r.alias.some(s=>s==t))return r;if(i)for(let r of e)for(let s of r.alias){let o=t.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+s.length])))return r}return null}},cS=N.define(),To=N.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Nr(n){let e=n.facet(To);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Rr(n,e){let t="",i=n.tabSize,r=n.facet(To)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function uc(n,e){n instanceof ie&&(n=new Kn(n));for(let i of n.state.facet(cS)){let r=i(n,e);if(r!==void 0)return r}let t=ht(n.state);return t.length>=e?uS(n,t,e):null}var Kn=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Nr(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Pn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},fS=new V;function uS(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return sg(i,n,t)}function sg(n,e,t){for(let i=n;i;i=i.next){let r=pS(i.node);if(r)return r(lc.create(e,t,i))}return 0}function dS(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function pS(n){let e=n.type.prop(fS);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(V.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>og(o,!0,1,void 0,s&&!dS(o)?r.from:void 0)}return n.parent==null?mS:null}function mS(){return 0}var lc=class n extends Kn{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(gS(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return sg(this.context.next,this.base,this.pos)}};function gS(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function yS(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function kT({closing:n,align:e=!0,units:t=1}){return i=>og(i,e,t,n)}function og(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?yS(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var wT=n=>n.baseIndent;function ST({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}var vT=N.define(),CT=new V;function MT(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}var Ao=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=Ge.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof He?l=>l.prop(Oi)==o.data:o?l=>l==o:void 0,this.style=ec(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new Ge(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},ac=N.define(),lg=N.define({combine(n){return n.length?[n[0]]:null}});function ic(n){let e=n.facet(ac);return e.length?e:n.facet(lg)}function AT(n,e){let t=[bS],i;return n instanceof Ao&&(n.module&&t.push(z.styleModule.of(n.module)),i=n.themeType),e?.fallback?t.push(lg.of(n)):i?t.push(ac.computeN([z.darkTheme],r=>r.facet(z.darkTheme)==(i=="dark")?[n]:[])):t.push(ac.of(n)),t}var hc=class{constructor(e){this.markCache=Object.create(null),this.tree=ht(e.state),this.decorations=this.buildDeco(e,ic(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ht(e.state),i=ic(e.state),r=i!=ic(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!r&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return Y.none;let i=new Rn;for(let{from:r,to:s}of e.visibleRanges)Gm(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=Y.mark({class:a})))},r,s);return i.finish()}},bS=hr.high(qt.fromClass(hc,{decorations:n=>n.decorations})),TT=Ao.define([{tag:A.meta,color:"#404740"},{tag:A.link,textDecoration:"underline"},{tag:A.heading,textDecoration:"underline",fontWeight:"bold"},{tag:A.emphasis,fontStyle:"italic"},{tag:A.strong,fontWeight:"bold"},{tag:A.strikethrough,textDecoration:"line-through"},{tag:A.keyword,color:"#708"},{tag:[A.atom,A.bool,A.url,A.contentSeparator,A.labelName],color:"#219"},{tag:[A.literal,A.inserted],color:"#164"},{tag:[A.string,A.deleted],color:"#a11"},{tag:[A.regexp,A.escape,A.special(A.string)],color:"#e40"},{tag:A.definition(A.variableName),color:"#00f"},{tag:A.local(A.variableName),color:"#30a"},{tag:[A.typeName,A.namespace],color:"#085"},{tag:A.className,color:"#167"},{tag:[A.special(A.variableName),A.macroName],color:"#256"},{tag:A.definition(A.propertyName),color:"#00c"},{tag:A.comment,color:"#940"},{tag:A.invalid,color:"#f00"}]);var xS=1e4,kS="()[]{}";var wS=new V;function cc(n,e,t){let i=n.prop(e<0?V.openedBy:V.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function fc(n){let e=n.type.prop(wS);return e?e(n.node):n}function jn(n,e,t,i={}){let r=i.maxScanDistance||xS,s=i.brackets||kS,o=ht(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=cc(a.type,t,s);if(h&&a.from<a.to){let c=fc(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return SS(n,e,t,a,c,h,s)}}return vS(n,e,t,o,l.type,r,s)}function SS(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},h=0,c=l?.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let f=fc(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(cc(c.type,t,o))h++;else if(cc(c.type,-t,o)){if(h==0){let f=fc(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function vS(n,e,t,i,r,s,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=s;){let d=c.value;t<0&&(u+=d.length);let p=e+u*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let y=o.indexOf(d[m]);if(!(y<0||i.resolveInner(p+m,1).type!=r))if(y%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}var CS=Object.create(null),tg=[Te.none];var ng=[],ig=Object.create(null),MS=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])MS[n]=AS(CS,e);function rc(n,e){ng.indexOf(n)>-1||(ng.push(n),console.warn(e))}function AS(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||A[h];c?typeof c=="function"?a.length?a=a.map(c):rc(h,`Modifier ${h} used at start of tag`):a.length?rc(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:rc(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=ig[r];if(s)return s.id;let o=ig[r]=Te.define({id:tg.length,name:i,props:[Jm({[i]:t})]});return tg.push(o),o.id}var OT={rtl:Y.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:ne.RTL}),ltr:Y.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:ne.LTR}),auto:Y.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var TS=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=xc(n.state,t.from);return i.line?OS(n):i.block?DS(n):!1};function bc(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var OS=bc(PS,0);var ES=bc(gg,0);var DS=bc((n,e)=>gg(n,e,RS(e)),0);function xc(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var Pr=50;function NS(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-Pr,i),o=n.sliceDoc(r,r+Pr),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,h=s.length-l;if(s.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,f;r-i<=2*Pr?c=f=n.sliceDoc(i,r):(c=n.sliceDoc(i,i+Pr),f=n.sliceDoc(r-Pr,r));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function RS(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function gg(n,e,t=e.selection.ranges){let i=t.map(s=>xc(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>NS(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:h,close:c}=l;s.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function PS(n,e,t=e.selection.ranges){let i=[],r=-1;e:for(let{from:s,to:o}of t){let l=i.length,a=1e9,h;for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(h==null&&(h=xc(e,f.from).line,!h))continue e;if(f.from>r&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:h,indent:u,empty:d,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&s.push({from:l.from+h,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}var pc=Ue.define(),BS=Ue.define(),IS=N.define(),yg=N.define({combine(n){return cr(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),bg=Fe.define({create(){return _n.empty},update(n,e){let t=e.state.facet(yg),i=e.annotation(pc);if(i){let a=ct.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=Eo(c,c.length,t.minDepth,a):c=wg(c,e.startState.selection),new _n(h==0?i.rest:c,h==0?c:i.rest)}let r=e.annotation(BS);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(ce.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=ct.fromTransaction(e),o=e.annotation(ce.time),l=e.annotation(ce.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new _n(n.done.map(ct.fromJSON),n.undone.map(ct.fromJSON))}});function IT(n={}){return[bg,yg.of(n),z.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?xg:e.inputType=="historyRedo"?mc:null;return i?(e.preventDefault(),i(t)):!1}})]}function Do(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(bg,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var xg=Do(0,!1),mc=Do(1,!1),LS=Do(0,!0),zS=Do(1,!0);var ct=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&Me.fromJSON(e.changes),[],e.mapped&&Vt.fromJSON(e.mapped),e.startSelection&&v.fromJSON(e.startSelection),e.selectionsAfter.map(v.fromJSON))}static fromTransaction(e,t){let i=et;for(let r of e.startState.facet(IS)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,et)}static selection(e){return new n(void 0,et,void 0,void 0,e)}};function Eo(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function FS(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function VS(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function kg(n,e){return n.length?e.length?n.concat(e):n:e}var et=[],HS=200;function wg(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-HS));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Eo(n,n.length-1,1e9,t.setSelAfter(i)))}else return[ct.selection([e])]}function WS(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function dc(n,e){if(!n.length)return n;let t=n.length,i=et;for(;t;){let r=$S(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[ct.selection(i)]:et}function $S(n,e,t){let i=kg(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):et,t);if(!n.changes)return ct.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new ct(r,Z.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var qS=/^(input\.type|delete)($|\.)/,_n=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||qS.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,FS(l.changes,e.changes))||i=="input.type.compose")?o=Eo(o,o.length-1,r.minDepth,new ct(e.changes.compose(l.changes),kg(Z.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,et)):o=Eo(o,o.length,r.minDepth,e),new n(o,et,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:et;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&VS(s[s.length-1],e)?this:new n(wg(this.done,e),this.undone,t,i)}addMapping(e){return new n(dc(this.done,e),dc(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:pc.of({side:e,rest:WS(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?et:r.slice(0,r.length-1);return s.mapped&&(l=dc(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:pc.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};_n.empty=new _n(et,et);var LT=[{key:"Mod-z",run:xg,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:mc,preventDefault:!0},{linux:"Ctrl-Shift-z",run:mc,preventDefault:!0},{key:"Mod-u",run:LS,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:zS,preventDefault:!0}];function Di(n,e){return v.create(n.ranges.map(e),n.mainIndex)}function ft(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function ut({state:n,dispatch:e},t){let i=Di(n.selection,t);return i.eq(n.selection,!0)?!1:(e(ft(n,i)),!0)}function No(n,e){return v.cursor(e?n.to:n.from)}function Sg(n,e){return ut(n,t=>t.empty?n.moveByChar(t,e):No(t,e))}function we(n){return n.textDirectionAt(n.state.selection.main.head)==ne.LTR}var vg=n=>Sg(n,!we(n)),Cg=n=>Sg(n,we(n));function Mg(n,e){return ut(n,t=>t.empty?n.moveByGroup(t,e):No(t,e))}var KS=n=>Mg(n,!we(n)),jS=n=>Mg(n,we(n));var zT=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function _S(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Ro(n,e,t){let i=ht(n).resolveInner(e.head),r=t?V.closedBy:V.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;_S(n,h,r)?i=h:a=t?h.to:h.from}let s=i.type.prop(r),o,l;return s&&(o=t?jn(n,i.from,1):jn(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,v.cursor(l,t?-1:1)}var JS=n=>ut(n,e=>Ro(n.state,e,!we(n))),US=n=>ut(n,e=>Ro(n.state,e,we(n)));function Ag(n,e){return ut(n,t=>{if(!t.empty)return No(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var Tg=n=>Ag(n,!1),Og=n=>Ag(n,!0);function Eg(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(z.scrollMargins)){let o=s(n);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(i=Math.max(o?.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function Dg(n,e){let t=Eg(n),{state:i}=n,r=Di(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):No(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(s=z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(ft(i,r),{effects:s}),!0}var ag=n=>Dg(n,!1),gc=n=>Dg(n,!0);function cn(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=v.cursor(i.from+s))}return r}var GS=n=>ut(n,e=>cn(n,e,!0)),YS=n=>ut(n,e=>cn(n,e,!1)),XS=n=>ut(n,e=>cn(n,e,!we(n))),QS=n=>ut(n,e=>cn(n,e,we(n))),ZS=n=>ut(n,e=>v.cursor(n.lineBlockAt(e.head).from,1)),ev=n=>ut(n,e=>v.cursor(n.lineBlockAt(e.head).to,-1));function tv(n,e,t){let i=!1,r=Di(n.selection,s=>{let o=jn(n,s.head,-1)||jn(n,s.head,1)||s.head>0&&jn(n,s.head-1,1)||s.head<n.doc.length&&jn(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return t?v.range(s.anchor,l):v.cursor(l)});return i?(e(ft(n,r)),!0):!1}var nv=({state:n,dispatch:e})=>tv(n,e,!1);function tt(n,e){let t=Di(n.state.selection,i=>{let r=e(i);return v.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(ft(n.state,t)),!0)}function Ng(n,e){return tt(n,t=>n.moveByChar(t,e))}var Rg=n=>Ng(n,!we(n)),Pg=n=>Ng(n,we(n));function Bg(n,e){return tt(n,t=>n.moveByGroup(t,e))}var iv=n=>Bg(n,!we(n)),rv=n=>Bg(n,we(n));var sv=n=>tt(n,e=>Ro(n.state,e,!we(n))),ov=n=>tt(n,e=>Ro(n.state,e,we(n)));function Ig(n,e){return tt(n,t=>n.moveVertically(t,e))}var Lg=n=>Ig(n,!1),zg=n=>Ig(n,!0);function Fg(n,e){return tt(n,t=>n.moveVertically(t,e,Eg(n).height))}var hg=n=>Fg(n,!1),cg=n=>Fg(n,!0),lv=n=>tt(n,e=>cn(n,e,!0)),av=n=>tt(n,e=>cn(n,e,!1)),hv=n=>tt(n,e=>cn(n,e,!we(n))),cv=n=>tt(n,e=>cn(n,e,we(n))),fv=n=>tt(n,e=>v.cursor(n.lineBlockAt(e.head).from)),uv=n=>tt(n,e=>v.cursor(n.lineBlockAt(e.head).to)),fg=({state:n,dispatch:e})=>(e(ft(n,{anchor:0})),!0),ug=({state:n,dispatch:e})=>(e(ft(n,{anchor:n.doc.length})),!0),dg=({state:n,dispatch:e})=>(e(ft(n,{anchor:n.selection.main.anchor,head:0})),!0),pg=({state:n,dispatch:e})=>(e(ft(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),dv=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),pv=({state:n,dispatch:e})=>{let t=Po(n).map(({from:i,to:r})=>v.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:v.create(t),userEvent:"select"})),!0},mv=({state:n,dispatch:e})=>{let t=Di(n.selection,i=>{let r=ht(n),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return v.range(l.to,l.from)}return i});return t.eq(n.selection)?!1:(e(ft(n,t)),!0)};function Vg(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to<n.state.doc.length:o.from>0)for(let l=s;;){let a=n.moveVertically(l,e);if(a.head<o.from||a.head>o.to){r.some(h=>h.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==i.ranges.length?!1:(n.dispatch(ft(t,v.create(r,r.length-1))),!0)}var gv=n=>Vg(n,!1),yv=n=>Vg(n,!0),bv=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=v.create([t.main]):t.main.empty||(i=v.create([v.cursor(t.main.head)])),i?(e(ft(n,i)),!0):!1};function Br(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=Oo(n,a,!1)):a>o&&(t="delete.forward",a=Oo(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Oo(n,o,!1),l=Oo(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:v.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?z.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Oo(n,e,t){if(n instanceof z)for(let i of n.state.facet(z.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var Hg=(n,e,t)=>Br(n,i=>{let r=i.from,{state:s}=n,o=s.doc.lineAt(r),l,a;if(t&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]==" ")return r-1;let h=Pn(l,s.tabSize),c=h%Nr(s)||Nr(s);for(let f=0;f<c&&l[l.length-1-f]==" ";f++)r--;a=r}else a=fe(o.text,r-o.from,e,e)+o.from,a==r&&o.number!=(e?s.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=fe(o.text,a-o.from,!1,!1)+o.from);return a}),yc=n=>Hg(n,!1,!0);var Wg=n=>Hg(n,!0,!1),$g=(n,e)=>Br(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=fe(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),qg=n=>$g(n,!1),xv=n=>$g(n,!0);var kv=n=>Br(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var wv=n=>Br(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Sv=n=>Br(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var vv=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:K.of(["",""])},range:v.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Cv=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:fe(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:fe(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:v.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Po(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Kg(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Po(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(v.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(v.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:v.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var Mv=({state:n,dispatch:e})=>Kg(n,e,!1),Av=({state:n,dispatch:e})=>Kg(n,e,!0);function jg(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of Po(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});let r=n.changes(i);return e(n.update({changes:r,selection:n.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var Tv=({state:n,dispatch:e})=>jg(n,e,!1),Ov=({state:n,dispatch:e})=>jg(n,e,!0),Ev=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Po(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Di(e.selection,r=>{let s;if(n.lineWrapping){let o=n.lineBlockAt(r.head),l=n.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,s)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Dv(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ht(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(V.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var mg=_g(!1),Nv=_g(!0);function _g(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&Dv(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new Kn(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=uc(h,s);for(c==null&&(c=Pn(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",Rr(e,c)];return a&&f.push(Rr(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:K.of(f)},range:v.cursor(s+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function kc(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:v.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var Rv=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Kn(n,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=kc(n,(s,o,l)=>{let a=uc(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=Rr(n,a);(h!=c||l.from<s.from+h.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+h.length,insert:c}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},Pv=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(kc(n,(t,i)=>{i.push({from:t.from,insert:n.facet(To)})}),{userEvent:"input.indent"})),!0),Bv=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(kc(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Pn(r,n.tabSize),o=0,l=Rr(n,Math.max(0,s-Nr(n)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Iv=n=>(n.setTabFocusMode(),!0);var Lv=[{key:"Ctrl-b",run:vg,shift:Rg,preventDefault:!0},{key:"Ctrl-f",run:Cg,shift:Pg},{key:"Ctrl-p",run:Tg,shift:Lg},{key:"Ctrl-n",run:Og,shift:zg},{key:"Ctrl-a",run:ZS,shift:fv},{key:"Ctrl-e",run:ev,shift:uv},{key:"Ctrl-d",run:Wg},{key:"Ctrl-h",run:yc},{key:"Ctrl-k",run:kv},{key:"Ctrl-Alt-h",run:qg},{key:"Ctrl-o",run:vv},{key:"Ctrl-t",run:Cv},{key:"Ctrl-v",run:gc}],zv=[{key:"ArrowLeft",run:vg,shift:Rg,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:KS,shift:iv,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:XS,shift:hv,preventDefault:!0},{key:"ArrowRight",run:Cg,shift:Pg,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:jS,shift:rv,preventDefault:!0},{mac:"Cmd-ArrowRight",run:QS,shift:cv,preventDefault:!0},{key:"ArrowUp",run:Tg,shift:Lg,preventDefault:!0},{mac:"Cmd-ArrowUp",run:fg,shift:dg},{mac:"Ctrl-ArrowUp",run:ag,shift:hg},{key:"ArrowDown",run:Og,shift:zg,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ug,shift:pg},{mac:"Ctrl-ArrowDown",run:gc,shift:cg},{key:"PageUp",run:ag,shift:hg},{key:"PageDown",run:gc,shift:cg},{key:"Home",run:YS,shift:av,preventDefault:!0},{key:"Mod-Home",run:fg,shift:dg},{key:"End",run:GS,shift:lv,preventDefault:!0},{key:"Mod-End",run:ug,shift:pg},{key:"Enter",run:mg,shift:mg},{key:"Mod-a",run:dv},{key:"Backspace",run:yc,shift:yc,preventDefault:!0},{key:"Delete",run:Wg,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:qg,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:xv,preventDefault:!0},{mac:"Mod-Backspace",run:wv,preventDefault:!0},{mac:"Mod-Delete",run:Sv,preventDefault:!0}].concat(Lv.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),FT=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:JS,shift:sv},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:US,shift:ov},{key:"Alt-ArrowUp",run:Mv},{key:"Shift-Alt-ArrowUp",run:Tv},{key:"Alt-ArrowDown",run:Av},{key:"Shift-Alt-ArrowDown",run:Ov},{key:"Mod-Alt-ArrowUp",run:gv},{key:"Mod-Alt-ArrowDown",run:yv},{key:"Escape",run:bv},{key:"Mod-Enter",run:Nv},{key:"Alt-l",mac:"Ctrl-l",run:pv},{key:"Mod-i",run:mv,preventDefault:!0},{key:"Mod-[",run:Bv},{key:"Mod-]",run:Pv},{key:"Mod-Alt-\\",run:Rv},{key:"Shift-Mod-k",run:Ev},{key:"Shift-Mod-\\",run:nv},{key:"Mod-/",run:TS},{key:"Alt-A",run:ES},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Iv}].concat(zv);var Io=null,Bo=null;function HT(){return Io}function WT(){return Io?Promise.resolve(Io):(Bo??(Bo=import("./mikedown-editor.ai-ui-C7ENTWWU-WYTCUH47.js").then(n=>(Io=n,n),n=>{throw Bo=null,n})),Bo)}function $T(n){return typeof n.listEngines=="function"?2:1}function qT(n,e){return!n||!e.showToolbarButton?"hidden":e.enabled?"menu":"firstRun"}export{Fv as a,Vv as b,Hv as c,Wv as d,$v as e,qv as f,Kv as g,S as h,_ as i,O as j,Gn as k,pt as l,Zn as m,of as n,Qn as o,F as p,Ur as q,L as r,B as s,Yr as t,J as u,te as v,yt as w,De as x,Rb as y,he as z,ds as A,ir as B,Cx as C,sM as D,oM as E,Ax as F,P as G,la as H,U as I,Ex as J,ks as K,fd as L,ud as M,Ix as N,Fx as O,dd as P,uM as Q,dM as R,pM as S,aa as T,gM as U,yM as V,Ms as W,m1 as X,S1 as Y,Je as Z,JM as _,UM as $,GM as aa,YM as ba,QM as ca,ZM as da,tA as ea,nA as fa,P1 as ga,B1 as ha,iA as ia,sA as ja,K as ka,Ne as la,v as ma,N as na,Fe as oa,hr as pa,Bs as qa,Ue as ra,Z as sa,ce as ta,ie as ua,bt as va,Pn as wa,Ln as xa,Y as ya,z as za,gw as Aa,TA as Ba,OA as Ca,PA as Da,BA as Ea,IA as Fa,Cm as Ga,Ih as Ha,WA as Ia,Dw as Ja,Nw as Ka,$A as La,Tm as Ma,Bw as Na,Em as Oa,KA as Pa,jA as Qa,_A as Ra,JA as Sa,UA as Ta,eT as Ua,tT as Va,_w as Wa,Jw as Xa,rT as Ya,V as Za,Te as _a,Vh as $a,X as ab,le as bb,Fm as cb,xo as db,aT as eb,at as fb,Jm as gb,A as hb,Oi as ib,lS as jb,aS as kb,He as lb,Xm as mb,ht as nb,oc as ob,Zm as pb,eg as qb,To as rb,fS as sb,kT as tb,wT as ub,ST as vb,vT as wb,CT as xb,MT as yb,Ao as zb,AT as Ab,TT as Bb,wS as Cb,BS as Db,IT as Eb,xg as Fb,mc as Gb,LT as Hb,FT as Ib,HT as Jb,WT as Kb,$T as Lb,qT as Mb};
|
|
109
|
+
`;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var Ae=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ha=typeof document<"u"?document:{documentElement:{style:{}}},Wa=/Edge\/(\d+)/.exec(Ae.userAgent),Bp=/MSIE \d/.test(Ae.userAgent),$a=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ae.userAgent),ho=!!(Bp||$a||Wa),op=!ho&&/gecko\/(\d+)/i.test(Ae.userAgent),Pa=!ho&&/Chrome\/(\d+)/.exec(Ae.userAgent),lp="webkitFontSmoothing"in Ha.documentElement.style,_a=!ho&&/Apple Computer/.test(Ae.vendor),ap=_a&&(/Mobile\/\w+/.test(Ae.userAgent)||Ae.maxTouchPoints>2),E={mac:ap||/Mac/.test(Ae.platform),windows:/Win/.test(Ae.platform),linux:/Linux|X11/.test(Ae.platform),ie:ho,ie_version:Bp?Ha.documentMode||6:$a?+$a[1]:Wa?+Wa[1]:0,gecko:op,gecko_version:op?+(/Firefox\/(\d+)/.exec(Ae.userAgent)||[0,0])[1]:0,chrome:!!Pa,chrome_version:Pa?+Pa[1]:0,ios:ap,android:/Android\b/.test(Ae.userAgent),webkit:lp,webkit_version:lp?+(/\bAppleWebKit\/(\d+)/.exec(Ae.userAgent)||[0,0])[1]:0,safari:_a,safari_version:_a?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ae.userAgent)||[0,0])[1]:0,tabSize:Ha.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Th(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var Us=Object.create(null);function Oh(n,e,t){if(n==e)return!0;n||(n=Us),e||(e=Us);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function X1(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function hp(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Q1(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}var Ln=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Pe=(function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n})(Pe||(Pe={})),Y=class extends bt{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Sr(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new zn(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=Lp(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new zn(e,i,r,t,e.widget||null,!0)}static line(e){return new vr(e)}static set(e,t=!1){return G.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Y.none=G.empty;var Sr=class n extends Y{constructor(e){let{start:t,end:i}=Lp(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Th(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Us}eq(e){return this==e||e instanceof n&&this.tagName==e.tagName&&Oh(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};Sr.prototype.point=!1;var vr=class n extends Y{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&Oh(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};vr.prototype.mapMode=Ne.TrackBefore;vr.prototype.point=!0;var zn=class n extends Y{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ne.TrackBefore:Ne.TrackAfter:Ne.TrackDel}get type(){return this.startSide!=this.endSide?Pe.WidgetRange:this.startSide<=0?Pe.WidgetBefore:Pe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&Z1(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};zn.prototype.point=!0;function Lp(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function Z1(n,e){return n==e||!!(n&&e&&n.compare(e))}function xi(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var Gs=class n extends bt{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof n&&this.tagName==e.tagName&&Oh(this.attributes,e.attributes)}static create(e){return new n(e.tagName,e.attributes||Us)}static set(e,t=!1){return G.of(e,t)}};Gs.prototype.startSide=Gs.prototype.endSide=-1;function Cr(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Ka(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function pr(n,e){if(!e.anchorNode)return!1;try{return Ka(n,e.anchorNode)}catch{return!1}}function qs(n){return n.nodeType==3?Mr(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function mr(n,e,t,i){return t?cp(n,e,t,i,-1)||cp(n,e,t,i,1):!1}function rn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Ys(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function cp(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:$t(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=rn(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?$t(n):0}else return!1}}function $t(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Xs(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function ek(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function zp(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function tk(n,e,t,i,r,s,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,d=c==a.body,p=1,m=1;if(d)u=ek(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let b=c.getBoundingClientRect();({scaleX:p,scaleY:m}=zp(c,b)),u={left:b.left,right:b.left+c.clientWidth*p,top:b.top,bottom:b.top+c.clientHeight*m}}let g=0,y=0;if(r=="nearest")e.top<u.top?(y=e.top-(u.top+o),t>0&&e.bottom>u.bottom+y&&(y=e.bottom-u.bottom+o)):e.bottom>u.bottom&&(y=e.bottom-u.bottom+o,t<0&&e.top-y<u.top&&(y=e.top-(u.top+o)));else{let b=e.bottom-e.top,x=u.bottom-u.top;y=(r=="center"&&b<=x?e.top+b/2-x/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-x+o)-u.top}if(i=="nearest"?e.left<u.left?(g=e.left-(u.left+s),t>0&&e.right>u.right+g&&(g=e.right-u.right+s)):e.right>u.right&&(g=e.right-u.right+s,t<0&&e.left<u.left+g&&(g=e.left-(u.left+s))):g=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-s:e.right-(u.right-u.left)+s)-u.left,g||y)if(d)h.scrollBy(g,y);else{let b=0,x=0;if(y){let C=c.scrollTop;c.scrollTop+=y/m,x=(c.scrollTop-C)*m}if(g){let C=c.scrollLeft;c.scrollLeft+=g/p,b=(c.scrollLeft-C)*p}e={left:e.left-b,top:e.top-x,right:e.right-b,bottom:e.bottom-x},b&&Math.abs(b-g)<1&&(i="nearest"),x&&Math.abs(x-y)<1&&(r="nearest")}if(d)break;(e.top<u.top||e.bottom>u.bottom||e.left<u.left||e.right>u.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function nk(n){let e=n.ownerDocument,t,i;for(let r=n.parentNode;r&&!(r==e.body||t&&i);)if(r.nodeType==1)!i&&r.scrollHeight>r.clientHeight&&(i=r),!t&&r.scrollWidth>r.clientWidth&&(t=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:t,y:i}}var qa=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?$t(t):0),i,Math.min(e.focusOffset,i?$t(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},In=null;E.safari&&E.safari_version>=26&&(In=!1);function Fp(n){if(n.setActive)return n.setActive();if(In)return n.focus(In);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(In==null?{get preventScroll(){return In={preventScroll:!0},!0}}:void 0),!In){In=!1;for(let t=0;t<e.length;){let i=e[t++],r=e[t++],s=e[t++];i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=s&&(i.scrollLeft=s)}}}var fp;function Mr(n,e,t=e){let i=fp||(fp=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function ki(n,e,t,i){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,n.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,n.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function ik(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function rk(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,$t(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=$t(t))}else{if(t==n)return!0;i=rn(t),t=t.parentNode}}function Vp(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function Hp(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=$t(t)}else if(t.parentNode&&!Ys(t))i=rn(t),t=t.parentNode;else return null}}function Wp(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!Ys(t))i=rn(t)+1,t=t.parentNode;else return null}}var kt=class n{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new n(e.parentNode,rn(e),t)}static after(e,t){return new n(e.parentNode,rn(e)+1,t)}},ne=(function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n})(ne||(ne={})),Fn=ne.LTR,Eh=ne.RTL;function $p(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var sk=$p("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),ok=$p("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),ja=Object.create(null),xt=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);ja[e]=t,ja[t]=-e}function _p(n){return n<=247?sk[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?ok[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var lk=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Qe=class{get dir(){return this.level%2?Eh:Fn}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function Kp(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Kp(i.inner,r.inner))return!1}return!0}var Q=[];function ak(n,e,t,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,a=s?256:r;for(let h=o,c=a,f=a;h<l;h++){let u=_p(n.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),Q[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=Q[h];if(u==128)h<l-1&&c==Q[h+1]&&c&24?u=Q[h]=c:Q[h]=256;else if(u==64){let d=h+1;for(;d<l&&Q[d]==64;)d++;let p=h&&c==8||d<t&&Q[d]==8?f==1?1:8:256;for(let m=h;m<d;m++)Q[m]=p;h=d-1}else u==8&&f==1&&(Q[h]=1);c=u,u&7&&(f=u)}}}function hk(n,e,t,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:t;for(let f=h,u,d,p;f<c;f++)if(d=ja[u=n.charCodeAt(f)])if(d<0){for(let m=l-3;m>=0;m-=3)if(xt[m+1]==-d){let g=xt[m+2],y=g&2?r:g&4?g&1?s:r:0;y&&(Q[f]=Q[xt[m]]=y),l=m;break}}else{if(xt.length==189)break;xt[l++]=f,xt[l++]=u,xt[l++]=a}else if((p=Q[f])==2||p==1){let m=p==r;a=m?0:1;for(let g=l-3;g>=0;g-=3){let y=xt[g+2];if(y&2)break;if(m)xt[g+2]|=2;else{if(y&4)break;xt[g+2]|=4}}}}}function ck(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let h=Q[a];if(h==256){let c=a+1;for(;;)if(c==l){if(r==t.length)break;c=t[r++].to,l=r<t.length?t[r].from:e}else if(Q[c]==256)c++;else break;let f=s==1,u=(c<e?Q[c]:i)==1,d=f==u?f?1:2:i;for(let p=c,m=r,g=m?t[m-1].to:n;p>a;)p==g&&(p=t[--m].from,g=m?t[m-1].to:n),Q[--p]=d;a=c}else s=h,a++}}}function Ja(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==s.length||a<s[h].from){let m=Q[a];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h<s.length&&p==s[h].from){if(f)break e;let m=s[h];if(!c)for(let g=m.to,y=h+1;;){if(g==t)break e;if(y<s.length&&s[y].from==g)g=s[y++].to;else{if(Q[g]==l)break e;break}}if(h++,u)u.push(m);else{m.from>a&&o.push(new Qe(a,m.from,d));let g=m.direction==Fn!=!(d%2);Ua(n,g?i+1:i,r,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(c?Q[p]!=l:Q[p]==l))break;p++}u?Ja(n,a,p,i+1,r,u,o):a<p&&o.push(new Qe(a,p,d)),a=p}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let m=Q[a-1];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h&&p==s[h-1].to){if(f)break e;let m=s[--h];if(!c)for(let g=m.from,y=h;;){if(g==e)break e;if(y&&s[y-1].to==g)g=s[--y].from;else{if(Q[g-1]==l)break e;break}}if(u)u.push(m);else{m.to<a&&o.push(new Qe(m.to,a,d));let g=m.direction==Fn!=!(d%2);Ua(n,g?i+1:i,r,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(c?Q[p-1]!=l:Q[p-1]==l))break;p--}u?Ja(n,p,a,i+1,r,u,o):p<a&&o.push(new Qe(p,a,d)),a=p}}function Ua(n,e,t,i,r,s,o){let l=e%2?2:1;ak(n,r,s,i,l),hk(n,r,s,i,l),ck(r,s,i,l),Ja(n,r,s,e,t,i,o)}function fk(n,e,t){if(!n)return[new Qe(0,0,e==Eh?1:0)];if(e==Fn&&!t.length&&!lk.test(n))return qp(n.length);if(t.length)for(;n.length>Q.length;)Q[Q.length]=256;let i=[],r=e==Fn?0:1;return Ua(n,r,r,t,0,n.length,i),i}function qp(n){return[new Qe(0,n,0)]}var jp="";function uk(n,e,t,i,r){var s;let o=i.head-n.from,l=Qe.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),a=e[l],h=a.side(r,t);if(o==h){let u=l+=r?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!r,t),h=a.side(r,t)}let c=fe(n.text,o,a.forward(r,t));(c<a.from||c>a.to)&&(c=h),jp=n.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return f&&c==h&&f.level+(r?0:1)<a.level?v.cursor(f.side(!r,t)+n.from,f.forward(r,t)?1:-1,f.level):v.cursor(c+n.from,a.forward(r,t)?-1:1,a.level)}function dk(n,e,t){for(let i=e;i<t;i++){let r=_p(n.charCodeAt(i));if(r==1)return Fn;if(r==2||r==4)return Eh}return Fn}var Jp=N.define(),Up=N.define(),Gp=N.define(),Yp=N.define(),Ga=N.define(),Xp=N.define(),Qp=N.define(),Dh=N.define(),Nh=N.define(),Zp=N.define({combine:n=>n.some(e=>e)}),pk=N.define({combine:n=>n.some(e=>e)}),em=N.define(),gr=class n{constructor(e,t="nearest",i="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new n(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new n(v.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Fs=Z.define({map:(n,e)=>n.map(e)}),tm=Z.define();function st(n,e,t){let i=n.facet(Yp);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}var Ht=N.define({combine:n=>n.length?n[0]:!0}),mk=0,gi=N.define({combine(n){return n.filter((e,t)=>{for(let i=0;i<t;i++)if(n[i].plugin==e.plugin)return!1;return!0})}}),_t=class n{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(gi.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(gi.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new n(mk++,e,i,r,l=>{let a=[];return o&&a.push(co.of(h=>{let c=h.plugin(l);return c?o(c):Y.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define((i,r)=>new e(i,r),t)}},yr=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(st(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){st(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){st(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},nm=N.define(),Rh=N.define(),co=N.define(),im=N.define(),Ph=N.define(),Ar=N.define(),rm=N.define();function up(n,e){let t=n.state.facet(rm);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(n):s),r=[];return G.spans(i,e.from,e.to,{point(){},span(s,o,l,a){let h=s-e.from,c=o-e.from,f=r;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=dk(e.text,h,c)),a>0&&f.length&&(p=f[f.length-1]).to==h&&p.direction==d)p.to=c,f=p.inner;else{let m={from:h,to:c,direction:d,inner:[]};f.push(m),f=m.inner}}}}),r}var sm=N.define();function om(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(sm)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}var fr=N.define(),ot=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,s=0,o=0;;){let l=r<e.length?e[r].fromB:1e9,a=s<t.length?t[s]:1e9,h=Math.min(l,a);if(h==1e9)break;let c=h+o,f=h,u=c;for(;;)if(s<t.length&&t[s]<=f){let d=t[s+1];s+=2,f=Math.max(f,d);for(let p=r;p<e.length&&e[p].fromB<=f;p++)o=e[p].toA-e[p].toB;u=Math.max(u,d+o)}else if(r<e.length&&e[r].fromB<=f){let d=e[r++];f=Math.max(f,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;i.push(new n(c,u,h,f))}return i}},Qs=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=Me.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new ot(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new n(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},gk=[],re=class{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return gk}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&X1(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let i=rn(this.dom),r=this.length?e>0:t>0;return new kt(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Si)return e;return null}static get(e){return e.cmTile}},wi=class extends re{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,r,s=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=i?i.nextSibling:t.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==t)for(;r&&r!=l.dom;)r=dp(r);else t.insertBefore(l.dom,r);i=l.dom}for(r=i?i.nextSibling:t.firstChild,s&&r&&(s.written=!0);r;)r=dp(r);this.length=o}};function dp(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Si=class extends wi{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=re.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&s++,r=t.pop()}else{let o=i.children[r++];if(o instanceof Wt)t.push(r),i=o,r=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,t){let i,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==h&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,r=e-a),(h>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&t<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}},Wt=class n extends wi{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},vi=class n extends wi{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let r=new n(t||document.createElement("div"),e);return(!t||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,i){let r=null,s=-1,o=null,l=-1;function a(c,f){for(let u=0,d=0;u<c.children.length&&d<=f;u++){let p=c.children[u],m=d+p.length;m>=f&&(p.isComposite()?a(p,f-d):(!o||o.isHidden&&(t>0||i&&bk(o,p)))&&(m>f||p.flags&32)?(o=p,l=f-d):(d<f||p.flags&16&&!p.isHidden)&&(r=p,s=f-d)),d=m}}a(this,e);let h=(t<0?r:o)||r||o;return h?{tile:h,offset:h==r?s:l}:null}coordsIn(e,t){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t):yk(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:r,offset:s}=i;if(this.dom.contains(r.dom))return r.isText()?new kt(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new kt(a.dom,0);a==i.tile&&(l=!0)}}return new kt(this.dom,0)}};function yk(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=qs(e);return t[t.length-1]||null}function bk(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}var Re=class n extends wi{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},Bn=class n extends re{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let i=this.dom.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;e==0&&t<0||e==i&&t>=0?E.chrome||E.gecko||(e?(r--,o=1):s<i&&(s++,o=-1)):t<0?r--:s<i&&s++;let l=Mr(this.dom,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return E.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Xs(a,o<0):a||null}static of(e,t){let i=new n(t||document.createTextNode(e),e);return t||(i.flags|=2),i}},Vn=class n extends re{constructor(e,t,i,r){super(e,t,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(i)return Xs(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return Xs(o,!l)}}get overrideDOMText(){if(!this.length)return K.empty;let{root:e}=this;if(!e)return K.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,r,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new n(s,i,e,r)}},Ci=class extends re{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return K.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},Ya=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],h=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,s++,e-=a.length):(l.push({tile:r,index:s}),r=a,s=0,i&&a.isComposite()&&i.enter(a))}else if(s==r.length)o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++;else if(e){let a=Math.min(e,r.length-s);i&&i.skip(r,s,s+a),e-=a,s+=a}else break;return this.tile=r,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},Xa=class{constructor(e,t,i,r){this.from=e,this.to=t,this.wrapper=i,this.rank=r}},Qa=class{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,r){var s;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new Bn(l.dom,l.text+e);a.parent=o}else o.append(r||Bn.of(e,(s=this.cache.find(Bn))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?Ia(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=i;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],h=r.lastChild;if(h instanceof Re&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(Ia(a.dom)),r=h;else{if(this.cache.reused.get(a)){let f=re.get(a.dom);f&&f.setDOM(Ia(a.dom))}let c=Re.of(a.mark,a.dom);r.append(c),r=c}this.cache.reused.set(a,2)}let s=re.get(e.text);s&&this.cache.reused.set(s,2);let o=new Bn(e.text,e.text.nodeValue);o.flags|=8,r.append(o)}addInlineWidget(e,t,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(t,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=lm);let r=vi.start(e,t||((i=this.cache.find(vi))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(t>0&&(l=r.lastChild)&&l instanceof Re&&l.mark.eq(o))r=l,t--;else{let a=Re.of(o,(i=this.cache.find(Re,h=>h.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(a),r=a,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!pp(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(E.ios&&pp(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Ba,0,32)||new Vn(Ba.toDOM(),0,Ba,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new Xa(e.from,e.to,e.value,e.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-t.rank||this.wrappers[i-1].to-t.to)<0;)i--;this.wrappers.splice(i,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let r=t.lastChild;if(i.from<this.pos&&r instanceof Wt&&r.wrapper.eq(i.wrapper))t=r;else{let s=Wt.of(i.wrapper,(e=this.cache.find(Wt,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Ci,void 0,1);return i&&(i.flags=t),i||new Ci(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Za=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}},Zs=[Vn,vi,Bn,Re,Ci,Wt,Si];for(let n=0;n<Zs.length;n++)Zs[n].bucket=n;var eh=class{constructor(e){this.view=e,this.buckets=Zs.map(()=>[]),this.index=Zs.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=s.length-1;l>=0;l--){let a=(l+o)%s.length,h=s[a];if((!t||t(h))&&!this.reused.has(h))return s.splice(a,1),a<o&&this.index[r]--,this.reused.set(h,i),h}return null}findWidget(e,t,i){let r=this.buckets[0];if(r.length)for(let s=0,o=0;;s++){if(s==r.length){if(o)return null;o=1,s=0}let l=r[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new Vn(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},th=class{constructor(e,t,i,r,s){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new eh(e),this.text=new Za(e.state.doc),this.builder=new Qa(this.cache,new Si(e,e.contentDOM),G.iter(i)),this.cache.reused.set(t,2),this.old=new Ya(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let r=0,s=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>r){let h=a-r;this.preserve(h,!o,!l),r=a,s+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,r=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let r=wk(this.old),s=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?Vn.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,r,s),s=r.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length?this.builder.addText(o.text,r,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),r,s)),s=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Ci)this.cache.add(o);else if(o instanceof Re)this.builder.ensureLine(null),this.builder.addMark(o,r,s),this.cache.reused.set(o,1),s=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Re&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof Re&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,r=this.builder,s=0,o=G.spans(this.decorations,e,t,{point:(l,a,h,c,f,u)=>{if(h instanceof zn){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)r.continueWidget(a-l);else{let d=h.widget||(h.block?sn.block:sn.inline),p=xk(h),m=this.cache.findWidget(d,a-l,p)||Vn.of(d,this.view,a-l,p);h.block?(h.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(m)):(r.ensureLine(i),r.addInlineWidget(m,c,f))}i=null}else i=kk(i,h);a>l&&this.text.skip(a-l)},span:(l,a,h,c)=>{for(let f=l;f<a;){let u=this.text.next(Math.min(512,a-f));u==null?(r.addLineStartIfNotCovered(i),r.addBreak(),f++):(r.ensureLine(i),r.addText(u,h,f==l?c:h.length),f+=u.length),i=null}}});r.addLineStartIfNotCovered(i),this.openWidget=o>s,this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=re.get(r);if(r==this.view.contentDOM)break;s instanceof Re?t.push(s):s?.isLine()?i=s:s instanceof Wt||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new vi(r,lm):i||t.push(Re.of(new Sr({tagName:r.nodeName.toLowerCase(),attributes:Q1(r)}),r)))}return{line:i,marks:t}}};function pp(n,e){let t=i=>{for(let r of i.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(n)}function xk(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}var lm={class:"cm-line"};function kk(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Th(t,n),i&&(n.class+=" "+i)),n}function wk(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof Re&&e.push(i.mark)}return e}function Ia(n){let e=re.get(n);return e&&e.setDOM(n.cloneNode()),n}var sn=class extends Ln{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};sn.inline=new sn("span");sn.block=new sn("div");var Ba=new class extends Ln{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},eo=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Y.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Si(e,e.contentDOM),this.updateInner([new ot(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:c,toA:f})=>f<this.minWidthFrom||c>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!Ek(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?vk(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;i=new ot(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(E.ie||E.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=Ak(o,this.decorations,e.changes);a.length&&(i=ot.extendWithRanges(i,a));let h=Tk(l,this.blockWrappers,e.changes);return h.length&&(i=ot.extendWithRanges(i,h)),s&&!i.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new th(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=l.run(e,t),nh(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=E.chrome||E.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof br&&r.push(s.dom);i.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(tm)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,r=this.view.root.activeElement,s=r==i,o=!s&&!(this.view.state.facet(Ht)||i.tabIndex>-1)&&pr(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),E.gecko&&a.empty&&!this.hasComposition&&Sk(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=c=new kt(u,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!mr(h.node,h.offset,f.anchorNode,f.anchorOffset)||!mr(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{E.android&&E.chrome&&i.contains(f.focusNode)&&Ok(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=Cr(this.view.root);if(u)if(a.empty){if(E.gecko){let d=Ck(h.node,h.offset);if(d&&d!=3){let p=(d==1?Hp:Wp)(h.node,h.offset);p&&(h=new kt(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),d.setEnd(c.node,c.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new kt(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new kt(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&mr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Cr(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(r,s)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[t];else{let o=$t(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!re.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,l=r;;o++){let a=i.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?r+t:r+(t?i.length:0):r}domAtPos(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(e,t):i.domIn(r,t)}inlineDOMNearPos(e,t){let i,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,c)=>{if(h.isWidget()){if(h.flags&32&&c>=e)return!0;h.flags&16&&(s=!0)}else{let f=c+h.length;if(c<=e&&(i=h,r=e-c,s=f<e),f>=e&&!o&&(o=h,l=e-c,a=c>e),c>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(s&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(r,t):o.domIn(l,t))}coordsAt(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof br?null:i.coordsInWidget(r,t,!0):i.coordsIn(r,t)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=fe(s.text,o);if(l==o)return null;let a=Mr(s.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(h==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return r(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ne.LTR,h=0,c=(f,u,d)=>{for(let p=0;p<f.children.length&&!(u>r);p++){let m=f.children[p],g=u+m.length,y=m.dom.getBoundingClientRect(),{height:b}=y;if(d&&!p&&(h+=y.top-d.top),m instanceof Wt)g>i&&c(m,u,y);else if(u>=i&&(h>0&&t.push(-h),t.push(b+h),h=0,o)){let x=m.dom.lastChild,C=x?qs(x):[];if(C.length){let w=C[C.length-1],T=a?w.right-y.left:y.right-w.left;T>l&&(l=T,this.minWidth=s,this.minWidthFrom=u,this.minWidthTo=g)}}d&&p==f.children.length-1&&(h+=d.bottom-y.bottom),u=g+m.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?ne.RTL:ne.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let c=qs(h.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,r,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=qs(t.firstChild)[0];i=t.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Y.replace({widget:new br(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Y.set(e)}updateDeco(){let e=1,t=this.view.state.facet(co).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(Ph).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,t.push(G.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(im).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(em))try{if(h(this.view,e.range,e))return!0}catch(c){st(this.view.state,c,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=om(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(tk(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==ne.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(t.head,1);h&&h.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){nh(this.tile)}};function nh(n,e){let t=e?.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)nh(i,e)}}function Sk(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function am(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=Hp(t.focusNode,t.focusOffset),r=Wp(t.focusNode,t.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let l=re.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(n.docView.lastCompositionAfterCursor){let a=re.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(s=r)}}if(n.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function vk(n,e,t){let i=am(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new ot(a.mapPos(s),a.mapPos(o),s,o),text:r}}function Ck(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}var Mk=class{constructor(){this.changes=[]}compareRange(e,t){xi(e,t,this.changes)}comparePoint(e,t){xi(e,t,this.changes)}boundChange(e){xi(e,e,this.changes)}};function Ak(n,e,t){let i=new Mk;return G.compare(n,e,t,i),i.changes}var ih=class{constructor(){this.changes=[]}compareRange(e,t){xi(e,t,this.changes)}comparePoint(){}boundChange(e){xi(e,e,this.changes)}};function Tk(n,e,t){let i=new ih;return G.compare(n,e,t,i),i.changes}function Ok(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Ek(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}var br=class extends Ln{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function Dk(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return v.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=fe(r.text,s,!1):l=fe(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let h=fe(r.text,o,!1);if(i(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=fe(r.text,l);if(i(r.text.slice(l,h))!=a)break;l=h}return v.range(o+r.from,l+r.from)}function Nk(n,e,t,i,r){let s=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+np(o,s,n.state.tabSize)}function Rk(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!r||s.type==Pe.Text&&(r.type!=s.type||(t<0?s.from<e:s.to>e)))&&(r=s)}}return r||i}return i}function Pk(n,e,t,i){let r=Rk(n,e.head,e.assoc||-1),s=!i||r.type!=Pe.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(r.from),a=n.posAtCoords({x:t==(l==ne.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return v.cursor(a,t?-1:1)}return v.cursor(t?r.to:r.from,t?-1:1)}function mp(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let h=uk(r,s,o,l,t),c=jp;if(!h){if(r.number==(t?n.state.doc.lines:1))return l;c=`
|
|
110
|
+
`,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),h=n.visualLineSide(r,!t)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function Ik(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==it.Space&&(r=o),r==o}}function Bk(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return v.cursor(r,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(r,(e.empty?e.assoc:0)||(t?1:-1)),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,u=i??n.viewState.heightOracle.textHeight>>1,d=rh(n,{x:f,y:l+u*s},!1,s);return v.cursor(d.pos,d.assoc,void 0,o)}function xr(n,e,t){for(;;){let i=0;for(let r of n)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=i||t||(e-s<o-e?-1:1);e=a<0?s:o,i=a}});if(!i)return e}}function hm(n,e){let t=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=xr(n,r.from,0);o!=r.from&&(s=v.cursor(o,-1))}else{let o=xr(n,r.from,-1),l=xr(n,r.to,1);(o!=r.from||l!=r.to)&&(s=v.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?v.create(t,e.mainIndex):e}function La(n,e,t){let i=xr(n.state.facet(Ar).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:v.cursor(i,i<t.from?1:-1)}var Xe=class{constructor(e,t){this.pos=e,this.assoc=t}};function rh(n,e,t,i){let r=n.contentDOM.getBoundingClientRect(),s=r.top+n.viewState.paddingTop,{x:o,y:l}=e,a=l-s,h;for(;;){if(a<0)return new Xe(0,1);if(a>n.viewState.docHeight)return new Xe(n.state.doc.length,-1);if(h=n.elementAtHeight(a),i==null)break;if(h.type==Pe.Text){if(i<0?h.to<n.viewport.from:h.from>n.viewport.to)break;let u=n.docView.coordsAt(i<0?h.from:h.to,i>0?-1:1);if(u&&(i<0?u.top<=a+s:u.bottom>=a+s))break}let f=n.viewState.heightOracle.textHeight/2;a=i>0?h.bottom+f:h.top-f}if(n.viewport.from>=h.to||n.viewport.to<=h.from){if(t)return null;if(h.type==Pe.Text){let f=Nk(n,r,h,o,l);return new Xe(f,f==h.from?1:-1)}}if(h.type!=Pe.Text)return a<(h.top+h.bottom)/2?new Xe(h.from,1):new Xe(h.to,-1);let c=n.docView.lineAt(h.from,2);return(!c||c.length!=h.length)&&(c=n.docView.lineAt(h.from,-2)),new sh(n,o,l,n.textDirectionAt(h.from)).scanTile(c,h.from)}var sh=class{constructor(e,t,i,r){this.view=e,this.x=t,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Qe.find(r,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Qe.find(r,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:r}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from<t)}scan(e,t){let i=0,r=e.length-1,s=new Set,o=this.bidiIn(e[0],e[r]),l,a,h=-1,c=1e9,f;e:for(;i<r;){let d=r-i,p=i+r>>1;t:if(s.has(p)){let g=i+Math.floor(Math.random()*d);for(let y=0;y<d;y++){if(!s.has(g)){p=g;break t}g++,g==r&&(g=i)}break e}s.add(p);let m=t(p);if(m)for(let g=0;g<m.length;g++){let y=m[g],b=0;if(y.bottom<this.y)(!l||l.bottom<y.bottom)&&(l=y),b=1;else if(y.top>this.y)(!a||a.top>y.top)&&(a=y),b=-1;else{let x=y.left>this.x?this.x-y.left:y.right<this.x?this.x-y.right:0,C=Math.abs(x);C<c&&(h=p,c=C,f=y),x&&(b=x<0==(this.baseDir==ne.LTR)?-1:1)}b==-1&&(!o||this.baseDirAt(e[p],1))?r=p:b==1&&(!o||this.baseDirAt(e[p+1],-1))&&(i=p+1)}}if(!f){let d=l&&(!a||this.y-l.bottom<a.top-this.y)?l:a;return this.y=(d.top+d.bottom)/2,this.scan(e,t)}let u=(o?this.dirAt(e[h],1):this.baseDir)==ne.LTR;return{i:h,after:this.x>(f.left+f.right)/2==u}}scanText(e,t){let i=[];for(let s=0;s<e.length;s=fe(e.text,s))i.push(t+s);i.push(t+e.length);let r=this.scan(i,s=>{let o=i[s]-t,l=i[s+1]-t;return Mr(e.dom,o,l).getClientRects()});return r.after?new Xe(i[r.i+1],-1):new Xe(i[r.i],1)}scanTile(e,t){if(!e.length)return new Xe(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,a=t;l<e.children.length;l++)i.push(a+=e.children[l].length);let r=this.scan(i,l=>{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Mr(a.dom,0,a.length)).getClientRects()}),s=e.children[r.i],o=i[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new Xe(i[r.i+1],-1):new Xe(o,1)}},ur="\uFFFF",oh=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(ie.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ur}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=re.get(r),l=r.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=re.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Ys(r))||Ys(l)&&(r.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!zk(l,t)&&this.lineBreak(),r=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(e){let t=re.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Lk(e,i.node,i.offset)?t:0))}};function Lk(n,e,t){for(;;){if(!e||t<$t(e))return!1;if(e==n)return!0;t=rn(e)+1,e=e.parentNode}}function zk(n,e){let t;for(;!(n==e||!n);n=n.nextSibling){let i=re.get(n);if(!i?.isWidget())return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let r=i.overrideDOMText;if(r?.length)return!1}return!0}var to=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},lh=class{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=cm(e.docView.tile,t,i,0))){let l=s||o?[]:Vk(e),a=new oh(l,e);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Hk(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!Ka(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Ka(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),c=e.viewport;if((E.ios||E.chrome)&&e.state.selection.main.empty&&a!=h&&(c.from>0||c.to<e.state.doc.length)){let f=Math.min(a,h),u=Math.max(a,h),d=c.from-f,p=c.to-u;(d==0||d==1||f==0)&&(p==0||p==-1||u==e.state.doc.length)&&(a=0,h=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(v.range(h,a)):this.newSel=v.single(h,a)}}};function cm(n,e,t,i){if(n.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<n.children.length;a++){let f=n.children[a],u=h+f.length;if(h<e&&u>t)return cm(f,e,t,h);if(u>=e&&r==-1&&(r=a,s=h),h>t&&f.dom.parentNode==n.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:s,to:l<0?i+n.length:l,startDOM:(r?n.children[r-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o<n.children.length&&o>=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function fm(n,e){let t,{newSel:i}=e,r=n.state.selection.main,s=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=r.from,h=null;(s===8||E.android&&e.text.length<l-o)&&(a=r.to,h="end");let c=um(n.state.doc.sliceString(o,l,ur),e.text,a-o,h);c&&(E.chrome&&s==13&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==ur+ur&&c.toB--,t={from:o+c.from,to:o+c.toA,insert:K.of(e.text.slice(c.from,c.toB).split(ur))})}else i&&(!n.hasFocus&&n.state.facet(Ht)||no(i,r))&&(i=null);if(!t&&!i)return!1;if(!t&&e.typeOver&&!r.empty&&i&&i.main.empty?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,r.to)}:(E.mac||E.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=v.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:K.of([t.insert.toString().replace("."," ")])}):t&&t.from>=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,r.to))}:n.state.doc.lineAt(r.from).to<r.to&&n.docView.lineHasWidget(r.to)&&n.inputState.insertingTextAt>Date.now()-50?t={from:r.from,to:r.to,insert:n.state.toText(n.inputState.insertingText)}:E.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
|
|
111
|
+
`&&n.lineWrapping&&(i&&(i=v.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:K.of([" "])}),t)return Ih(n,t,i,s);if(i&&!no(i,r)){let o=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),l=n.inputState.lastSelectionOrigin,l=="select.pointer"&&(i=hm(n.state.facet(Ar).map(a=>a(n)),i))),n.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function Ih(n,e,t,i=-1){if(E.ios&&n.inputState.flushIOSKey(e))return!0;let r=n.state.selection.main;if(E.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&n.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ki(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&ki(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&ki(n.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=Fk(n,e,t));return n.state.facet(Xp).some(a=>a(n,e.from,e.to,s,l))||n.dispatch(l()),!0}function Fk(n,e,t){let i,r=n.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let a=e.from<s.from?-1:1,h=a<0?s.from:s.to,c=xr(r.facet(Ar).map(f=>f(n)),h,a);e.from==c&&(o=c)}if(o>-1)i={changes:e,selection:v.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let a=s.from<e.from?r.sliceDoc(s.from,e.from):"",h=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(a+e.insert.sliceString(0,void 0,n.state.lineBreak)+h))}else{let a=r.changes(e),h=t&&t.main.to<=a.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=n.state.sliceDoc(e.from,e.to),f,u=t&&am(n,t.main.head);if(u){let p=e.insert.length-(e.to-e.from);f={from:u.from,to:u.to-p}}else f=n.state.doc.lineAt(s.head);let d=s.to-e.to;i=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:h||p.map(a)};let m=p.to-d,g=m-c.length;if(n.state.sliceDoc(g,m)!=c||m>=f.from&&g<=f.to)return{range:p};let y=r.changes({from:g,to:m,insert:e.insert}),b=p.to-s.to;return{changes:y,range:h?v.range(Math.max(0,h.anchor+b),Math.max(0,h.head+b)):p.map(y)}})}else i={changes:a,selection:h&&r.selection.replaceRange(h)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}function um(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&n.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function Vk(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new to(t,i)),(r!=t||s!=i)&&e.push(new to(r,s))),e}function Hk(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?v.single(t+e,i+e):null}function no(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}var ah=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,E.safari&&e.contentDOM.addEventListener("input",()=>null),E.gecko&&ew(e.contentDOM.ownerDocument)}handleEvent(e){!Jk(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Wk(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&pm.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),E.android&&E.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return E.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=dm.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||$k.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,ki(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:E.safari&&!E.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function gp(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){st(t.state,r)}}}function Wk(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&t(l).handlers.push(gp(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(gp(i.value,a))}}for(let i in lt)t(i).handlers.push(lt[i]);for(let i in Ze)t(i).observers.push(Ze[i]);return e}var dm=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],$k="dthko",pm=[16,17,18,20,91,92,224,225],Vs=6;function Hs(n){return Math.max(0,n)*.7+8}function _k(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var hh=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=nk(e.contentDOM),this.atoms=e.state.facet(Ar).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ie.allowMultipleSelections)&&Kk(e,t),this.dragging=jk(e,t)&&ym(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&_k(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=om(this.view);e.clientX-a.left<=r+Vs?t=-Hs(r-e.clientX):e.clientX+a.right>=o-Vs&&(t=Hs(e.clientX-o)),e.clientY-a.top<=s+Vs?i=-Hs(s-e.clientY):e.clientY+a.bottom>=l-Vs&&(i=Hs(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=hm(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function Kk(n,e){let t=n.state.facet(Jp);return t.length?t[0](e):E.mac?e.metaKey:e.ctrlKey}function qk(n,e){let t=n.state.facet(Up);return t.length?t[0](e):E.mac?!e.altKey:!e.ctrlKey}function jk(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Cr(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Jk(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=re.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}var lt=Object.create(null),Ze=Object.create(null),mm=E.ie&&E.ie_version<15||E.ios&&E.webkit_version<604;function Uk(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),gm(n,t.value)},50)}function fo(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function gm(n,e){e=fo(n.state,Dh,e);let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(ch!=null&&t.selection.ranges.every(a=>a.empty)&&ch==s.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:v.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:v.cursor(a.from+h.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Ze.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};lt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);Ze.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};Ze.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};lt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(Gp))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Yk(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new hh(n,e,t,i)),i&&n.observer.ignore(()=>{Fp(n.contentDOM);let s=n.root.activeElement;s&&!s.contains(n.contentDOM)&&s.blur()});let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function yp(n,e,t,i){if(i==1)return v.cursor(e,t);if(i==2)return Dk(n.state,e,t);{let r=n.docView.lineAt(e,t),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<n.state.doc.length&&l==s.to&&l++,v.range(o,l)}}var Gk=E.ie&&E.ie_version<=11,bp=null,xp=0,kp=0;function ym(n){if(!Gk)return n.detail;let e=bp,t=kp;return bp=n,kp=Date.now(),xp=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(xp+1)%3:1}function Yk(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=ym(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=n.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),h,c=yp(n,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let f=yp(n,t.pos,t.assoc,i),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u<c.from?v.range(u,d):v.range(d,u)}return o?r.replaceRange(r.main.extend(c.from,c.to)):l&&i==1&&r.ranges.length>1&&(h=Xk(r,a.pos))?h:l?r.addRange(c):v.create([c])}}}function Xk(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return v.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}lt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=v.range(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",fo(n.state,Nh,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};lt.dragend=n=>(n.inputState.draggedContent=null,!1);function wp(n,e,t,i){if(t=fo(n.state,Dh,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&qk(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}lt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&wp(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return wp(n,e,i,!0),!0}return!1};lt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=mm?null:e.clipboardData;return t?(gm(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Uk(n),!1)};function Qk(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Zk(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:fo(n,Nh,e.join(n.lineBreak)),ranges:t,linewise:i}}var ch=null;lt.copy=lt.cut=(n,e)=>{if(!pr(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=Zk(n.state);if(!t&&!r)return!1;ch=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=mm?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Qk(n,t),!1)};var bm=Ue.define();function xm(n,e){let t=[];for(let i of n.facet(Qp)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:bm.of(!0)}):null}function km(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=xm(n.state,e);t?n.dispatch(t):n.update([])}},10)}Ze.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),km(n)};Ze.blur=n=>{n.observer.clearSelectionRange(),km(n)};Ze.compositionstart=Ze.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};Ze.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,E.chrome&&E.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};Ze.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};lt.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=n.posAtDOM(l.startContainer,l.startOffset),h=n.posAtDOM(l.endContainer,l.endOffset);return Ih(n,{from:a,to:h,insert:n.state.toText(s)},null),!0}}let r;if(E.chrome&&E.android&&(r=dm.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return E.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),E.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>Ze.compositionend(n,e),20),!1};var Sp=new Set;function ew(n){Sp.has(n)||(Sp.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var vp=["pre-wrap","normal","pre-line","break-spaces"],Mi=!1;function Cp(){Mi=!1}var fh=class{constructor(e){this.lineWrapping=e,this.doc=K.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return vp.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let l=vp.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}},uh=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},rt=class n{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Pe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof zn?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ee=(function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n})(ee||(ee={})),js=.001,Ve=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>js&&(Mi=!0),this.height=e)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=r[l],u=s.lineAt(a,ee.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:s.lineAt(h,ee.ByPosNoHeight,i,0,0);for(f+=d.to-h,h=d.to;l>0&&u.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,ee.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let p=ph.build(i.setDoc(o),e,c,f);s=io(s,s.replace(a,h,p))}return s.updateHeight(i,0)}static empty(){return new Ye(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new dh(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};function io(n,e){return n==e?n:(n.constructor!=e.constructor&&(Mi=!0),e)}Ve.prototype.size=1;var tw=Y.replace({}),ro=class extends Ve{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new rt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new rt(r,0,i,this.spaceAbove,tw):this.mainBlock(i,r)}lineAt(e,t,i,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,i,r,s).join(o):o}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.lineAt(0,ee.ByPos,i,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},Ye=class n extends ro{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new rt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof nn&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof nn?r=new n(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Ve.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},nn=class n extends Ve{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,e-f/2);return new rt(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:c,length:f}=t.doc.line(s+h);return new rt(c,f,i+l*h,l,0)}}lineAt(e,t,i,r,s){if(t==ee.ByHeight)return this.blockAt(e,i,r,s);if(t==ee.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new rt(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),h=i.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=r+l*f+a*(h.from-s-f);return new rt(h.from,h.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,s);for(let c=e,f=r;c<=t;){let u=i.doc.lineAt(c);if(c==e){let p=u.number-l;f+=a*p+h*(e-s-p)}let d=a+h*u.length;o(new rt(u.from,u.length,f,d,0)),f+=d,c=u.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return Ve.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=r.heights[r.index++],u=0;f<0&&(u=-f,f=r.heights[r.index++]),a==-1?a=f:Math.abs(f-a)>=js&&(a=-2);let d=new Ye(c,f,u);d.outdated=!1,o.push(d),l+=c+1}l<=s&&o.push(null,new n(s-l).updateHeight(e,l));let h=Ve.of(o);return(a<0||Math.abs(h.height-this.height)>=js||Math.abs(a-this.heightMetrics(e,t).perLine)>=js)&&(Mi=!0),io(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},dh=class extends Ve{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==ee.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==ee.ByPosNoHeight?ee.ByPosNoHeight:ee.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,r,s).join(h)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,r,s,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,ee.ByPos,i,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,i,r,s,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&Mp(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),Mp(s,l)}return Ve.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ve.of(this.break?[e,null,t]:[e,t]):(this.left=io(this.left,e),this.right=io(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Mp(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof nn&&(i=n[e+1])instanceof nn&&n.splice(e-1,3,new nn(t.length+1+i.length))}var nw=5,ph=class n{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Ye?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Ye(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new ro(o,r,i)):(o||s||r>=nw)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Ye(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new nn(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ye)return e;let t=new Ye(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ye)&&!this.isCovered?this.nodes.push(new Ye(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof Ye&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new n(i,e);return G.spans(t,i,r,s,0),s.finish(i)}};function iw(n,e,t){let i=new mh;return G.compare(n,e,t,i,0),i.changes}var mh=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&xi(e,t,this.changes,5)}};function rw(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=n.parentNode;h&&h!=i.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();s=Math.max(s,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==n.parentNode?r.innerHeight:a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function sw(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function ow(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var kr=class{constructor(e,t,i,r){this.from=e,this.to=t,this.size=i,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return Y.replace({widget:new gh(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},gh=class extends Ln{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},so=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Ap,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ne.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Rh).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new fh(t),this.stateDeco=Tp(e),this.heightMap=Ve.empty().applyChanges(this.stateDeco,K.empty,this.heightOracle.setDoc(e.doc),[new ot(0,0,0,e.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Y.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new yi(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Ap:new yh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(dr(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Tp(this.state);let r=e.changedRanges,s=ot.extendWithRanges(r,iw(i,this.stateDeco,e?e.changes:Me.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Cp(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Mi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(pk)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ne.RTL:ne.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:C,scaleY:w}=zp(t,l);(C>.005&&Math.abs(this.scaleX-C)>.005||w>.005&&Math.abs(this.scaleY-w)>.005)&&(this.scaleX=C,this.scaleY=w,h|=16,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Vp(e.scrollDOM);let p=(this.printing?ow:rw)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!sw(e.dom))return 0;let b=l.width;if((this.contentDOMWidth!=b||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let C=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(C)&&(o=!0),o||r.lineWrapping&&Math.abs(b-this.contentDOMWidth)>r.charWidth){let{lineHeight:w,charWidth:T,textHeight:k}=e.docView.measureTextSize();o=w>0&&r.refresh(s,w,T,k,Math.max(5,b/T),C),o&&(e.docView.minWidth=0,h|=16)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),Cp();for(let w of this.viewports){let T=w.from==this.viewport.from?C:e.docView.measureVisibleLineHeights(w);this.heightMap=(o?Ve.empty().applyChanges(this.stateDeco,K.empty,this.heightOracle,[new ot(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new uh(w.from,T))}Mi&&(h|=2)}let x=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(h&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new yi(r.lineAt(o-i*1e3,ee.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,ee.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(h,ee.ByPos,s,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new yi(r.lineAt(u-1e3/2,ee.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,ee.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new yi(this.heightMap.lineAt(i,ee.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ee.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ee.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,ee.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new kr(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=ne.LTR&&!i)return[];let l=[],a=(c,f,u,d)=>{if(f-c<s)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let y of m)if(y>c&&y<f){a(c,y-10,u,d),a(y+10,f,u,d);return}let g=aw(e,y=>y.from>=u.from&&y.to<=u.to&&Math.abs(y.from-c)<s&&Math.abs(y.to-f)<s&&!m.some(b=>y.from<b&&y.to>b));if(!g){if(f<u.to&&t&&i&&t.visibleRanges.some(x=>x.from<=f&&x.to>=f)){let x=t.moveToLineBoundary(v.cursor(f),!1,!0).head;x>c&&(f=x)}let y=this.gapSize(u,c,f,d),b=i||y<2e6?y:2e6;g=new kr(c,f,y,b)}l.push(g)},h=c=>{if(c.length<o||c.type!=Pe.Text)return;let f=lw(c.from,c.to,this.stateDeco);if(f.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,y;if(u!=null){let b=$s(f,u),x=((this.visibleBottom-this.visibleTop)/2+m)/c.height;g=b-x,y=b+x}else g=(this.visibleTop-c.top-m)/c.height,y=(this.visibleBottom-c.top+m)/c.height;d=Ws(f,g),p=Ws(f,y)}else{let m=f.total*this.heightOracle.charWidth,g=r*this.heightOracle.charWidth,y=0;if(m>2e6)for(let T of e)T.from>=c.from&&T.from<c.to&&T.size!=T.displaySize&&T.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=T.size-T.displaySize);let b=this.pixelViewport.left+y,x=this.pixelViewport.right+y,C,w;if(u!=null){let T=$s(f,u),k=((x-b)/2+g)/m;C=T-k,w=T+k}else C=(b-g)/m,w=(x+g)/m;d=Ws(f,C),p=Ws(f,w)}d>c.from&&a(c.from,d,c,f),p<c.to&&a(p,c.to,c,f)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(h):h(c);return l}gapSize(e,t,i,r){let s=$s(r,i)-$s(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){kr.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Y.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];G.spans(t,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s<i.length&&!(r&8);s++){let o=this.visibleRanges[s],l=i[s];(o.from!=l.from||o.to!=l.to)&&(r|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||dr(this.heightMap.lineAt(e,ee.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||dr(this.heightMap.lineAt(this.scaler.fromDOM(e),ee.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return dr(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},yi=class{constructor(e,t){this.from=e,this.to=t}};function lw(n,e,t){let i=[],r=n,s=0;return G.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function Ws({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function $s(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function aw(n,e){for(let t of n)if(e(t))return t}var Ap={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function Tp(n){let e=n.facet(co).filter(i=>typeof i!="function"),t=n.facet(Ph).filter(i=>typeof i!="function");return t.length&&e.push(G.join(t)),e}var yh=class n{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,ee.ByPos,e,0,0).top,c=t.lineAt(a,ee.ByPos,e,0,0).bottom;return r+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}eq(e){return e instanceof n?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function dr(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new rt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>dr(r,e)):n._content)}var _s=N.define({combine:n=>n.join(" ")}),bh=N.define({combine:n=>n.indexOf(!0)>-1}),xh=Ge.newName(),wm=Ge.newName(),Sm=Ge.newName(),vm={"&light":"."+wm,"&dark":"."+Sm};function kh(n,e,t){return new Ge(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var hw=kh("."+xh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},vm),cw={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},za=E.ie&&E.ie_version<=11,wh=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new qa,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(E.ie&&E.ie_version<=11||E.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&E.android&&e.constructor.EDIT_CONTEXT!==!1&&!(E.chrome&&E.chrome_version<126)&&(this.editContext=new Sh(e),e.state.facet(Ht)&&(e.contentDOM.editContext=this.editContext.editContext)),za&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Ht)?i.root.activeElement!=this.dom:!pr(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(E.ie&&E.ie_version<=11||E.android&&E.chrome)&&!i.state.selection.main.empty&&r.focusNode&&mr(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Cr(e.root);if(!t)return!1;let i=E.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&fw(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=pr(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&rk(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,cw),za&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),za&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&ki(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&pr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new lh(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=fm(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!no(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Op(t,e.previousSibling||e.target.previousSibling,-1),r=Op(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Ht)!=e.state.facet(Ht)&&(e.view.contentDOM.editContext=e.state.facet(Ht)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Op(n,e,t){for(;e;){let i=re.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Ep(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return mr(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function fw(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Ep(n,r)}let t=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Ep(n,t):null}var Sh=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let c=um(e.state.sliceDoc(l,a),i.text,(h?r.from:r.to)-l,h?"end":null);if(!c){let u=v.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));no(u,r)||e.dispatch({selection:u,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:K.of(i.text.slice(c.from,c.toB).split(`
|
|
112
|
+
`))};if((E.mac||E.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:K.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);Ih(e,f,v.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from<f.to&&!f.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}t.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),h=this.toEditorPos(s.rangeEnd);if(a<h){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(Y.mark({attributes:{style:c}}).range(a,h))}}}e.dispatch({effects:tm.of(Y.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let r=Cr(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,h)=>{if(i)return;let c=h.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(h)){r=this.pendingContextChange=null,t+=c,this.to+=c;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=c}t+=c}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},z=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||ik(e.parent)||document,this.viewState=new so(e.state||ie.create(e)),e.scrollTo&&e.scrollTo.is(Fs)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(gi).map(r=>new yr(r));for(let r of this.plugins)r.update(this);this.observer=new wh(this),this.inputState=new ah(this),this.inputState.ensureHandlers(this.plugins),this.docView=new eo(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof ce?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(bm))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=xm(s,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(ie.phrases)!=this.state.facet(ie.phrases))return this.setState(s);r=Qs.create(this,s,e),r.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;f=new gr(d.empty?d:v.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(Fs)&&(f=d.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=oo.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(fr)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(_s)!=r.state.facet(_s)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let u of this.state.facet(Ga))try{u(r)}catch(d){st(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!fm(this,c)&&h.force&&ki(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new so(e),this.plugins=e.facet(gi).map(i=>new yr(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new eo(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(gi),i=e.state.facet(gi);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new yr(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){st(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,r=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Vp(i))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(d=>{try{return d.read(this)}catch(p){return st(this.state,p),Dp}}),f=Qs.create(this,this.state,[]),u=!1;f.flags|=a,t?t.flags|=a:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f),u&&this.docViewUpdate());for(let d=0;d<h.length;d++)if(c[d]!=Dp)try{let p=h[d];p.write&&p.write(c[d],this)}catch(p){st(this.state,p)}if(u&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(p>1||p<-1){r=r+p,i.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Ga))l(t)}get themeClasses(){return xh+" "+(this.state.facet(bh)?Sm:wm)+" "+this.state.facet(_s)}updateAttrs(){let e=Np(this,nm,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ht)?"true":"false",class:"cm-content",style:`${E.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Np(this,Rh,t);let i=this.observer.ignore(()=>{let r=hp(this.contentDOM,this.contentAttrs,t),s=hp(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(fr);let e=this.state.facet(n.cspNonce);Ge.mount(this.root,this.styleModules.concat(hw).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return La(this,e,mp(this,e,t,i))}moveByGroup(e,t){return La(this,e,mp(this,e,t,i=>Ik(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return v.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return Pk(this,e,t,i)}moveVertically(e,t,i){return La(this,e,Bk(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=rh(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),rh(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Qe.find(s,e-r.from,-1,t)];return Xs(i,o.dir==ne.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Zp)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>uw)return qp(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Kp(s.isolates,i=up(this,e))))return s.order;i||(i=up(this,e));let r=fk(e.text,t,i);return this.bidiCache.push(new oo(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||E.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Fp(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Fs.of(new gr(typeof e=="number"?v.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Fs.of(new gr(v.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return _t.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return _t.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Ge.newName(),r=[_s.of(i),fr.of(kh(`.${i}`,e))];return t&&t.dark&&r.push(bh.of(!0)),r}static baseTheme(e){return hr.lowest(fr.of(kh("."+xh,e,vm)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&re.get(i)||re.get(e);return((t=r?.root)===null||t===void 0?void 0:t.view)||null}};z.styleModule=fr;z.inputHandler=Xp;z.clipboardInputFilter=Dh;z.clipboardOutputFilter=Nh;z.scrollHandler=em;z.focusChangeEffect=Qp;z.perLineTextDirection=Zp;z.exceptionSink=Yp;z.updateListener=Ga;z.editable=Ht;z.mouseSelectionStyle=Gp;z.dragMovesSelection=Up;z.clickAddsSelectionRange=Jp;z.decorations=co;z.blockWrappers=im;z.outerDecorations=Ph;z.atomicRanges=Ar;z.bidiIsolatedRanges=rm;z.scrollMargins=sm;z.darkTheme=bh;z.cspNonce=N.define({combine:n=>n.length?n[0]:""});z.contentAttributes=Rh;z.editorAttributes=nm;z.lineWrapping=z.contentAttributes.of({class:"cm-lineWrapping"});z.announce=Z.define();var uw=4096,Dp={},oo=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:ne.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new n(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}};function Np(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&Th(o,t)}return t}var dw=E.mac?"mac":E.windows?"win":E.linux?"linux":"key";function pw(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){let h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Ks(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var mw=hr.default(z.domEventHandlers({keydown(n,e){return kw(yw(e.state),n,e,"editor")}})),gw=N.define({enables:mw}),Rp=new WeakMap;function yw(n){let e=n.facet(gw),t=Rp.get(e);return t||Rp.set(e,t=xw(e.reduce((i,r)=>i.concat(r),[]))),t}var tn=null,bw=4e3;function xw(n,e=dw){let t=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,h,c)=>{var f,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>pw(y,e));for(let y=1;y<p.length;y++){let b=p.slice(0,y).join(" ");r(b,!0),d[b]||(d[b]={preventDefault:!0,stopPropagation:!1,run:[x=>{let C=tn={view:x,prefix:b,scope:o};return setTimeout(()=>{tn==C&&(tn=null)},bw),!0}]})}let m=p.join(" ");r(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0),c&&(g.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in c)c[u].run.push(d=>f(d,vh))}let a=o[e]||o.key;if(a)for(let h of l)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}var vh=null;function kw(n,e,t,i){vh=e;let r=us(e),s=Kd(r,0),o=qd(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;tn&&tn.view==t&&tn.scope==i&&(l=tn.prefix+" ",pm.indexOf(e.keyCode)<0&&(h=!0,tn=null));let f=new Set,u=g=>{if(g){for(let y of g.run)if(!f.has(y)&&(f.add(y),y(t)))return g.stopPropagation&&(c=!0),!0;g.preventDefault&&(g.stopPropagation&&(c=!0),h=!0)}return!1},d=n[i],p,m;return d&&(u(d[l+Ks(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(E.windows&&e.ctrlKey&&e.altKey)&&!(E.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=nt[e.keyCode])&&p!=r?(u(d[l+Ks(p,e,!0)])||e.shiftKey&&(m=hi[e.keyCode])!=r&&m!=p&&u(d[l+Ks(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+Ks(r,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),vh=null,a}var NA=/x/.unicode!=null?"gu":"g";function RA(){return Sw}var ww=Y.line({class:"cm-activeLine"}),Sw=_t.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(ww.range(r.from)),e=r.from)}return Y.set(t)}},{decorations:n=>n.decorations});var wt=class extends bt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};wt.prototype.elementClass="";wt.prototype.toDOM=void 0;wt.prototype.mapMode=Ne.TrackBefore;wt.prototype.startSide=wt.prototype.endSide=-1;wt.prototype.point=!0;var Fa=N.define(),vw=N.define();var Js=N.define();var Ch=N.define({combine:n=>n.some(e=>e)});function Cw(n){let e=[Mw];return n&&n.fixed===!1&&e.push(Ch.of(!0)),e}var Mw=_t.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(Js).map(e=>new lo(n,e)),this.fixed=!n.state.facet(Ch);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Ch)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=G.iter(this.view.state.facet(Fa),this.view.viewport.from),i=[],r=this.gutters.map(s=>new Ah(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Pe.Text&&o){Mh(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Pe.Text){Mh(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(Js),t=n.state.facet(Js),i=n.docChanged||n.heightChanged||n.viewportChanged||!G.eq(n.startState.facet(Fa),n.state.facet(Fa),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new lo(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>z.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==ne.LTR?{left:i,right:r}:{right:i,left:r}})});function Pp(n){return Array.isArray(n)?n:[n]}function Mh(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var Ah=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=G.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new ao(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Mh(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),r=i?[i]:null;for(let s of e.state.facet(vw)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},lo=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=Pp(t.markers(e)),t.initialSpacer&&(this.spacer=new ao(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Pp(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!G.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},ao=class{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Aw(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(r);let f=r.nextSibling;r.remove(),r=f}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}};function Aw(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}var Tw=N.define(),Ow=N.define(),bi=N.define({combine(n){return cr(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let s=i[r],o=t[r];i[r]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return i}})}}),wr=class extends wt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Va(n,e){return n.state.facet(bi).formatNumber(e,n.state)}var Ew=Js.compute([bi],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Tw)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new wr(Va(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let r of e.state.facet(Ow)){let s=r(e,t,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(bi)!=e.state.facet(bi),initialSpacer(e){return new wr(Va(e,Ip(e.state.doc.lines)))},updateSpacer(e,t){let i=Va(t.view,Ip(t.view.state.doc.lines));return i==e.number?e:new wr(i)},domEventHandlers:n.facet(bi).domEventHandlers,side:"before"}));function PA(n={}){return[bi.of(n),Cw(),Ew]}function Ip(n){let e=9;for(;e<n;)e=e*10+9;return e}var St=null,Ai=null;function FA(){return(!St||!St.isConnected)&&(St=document.createElement("div"),St.className="mikedown-portal",document.body.appendChild(St),Cm()),St}function VA(n){Ai=n,Cm()}function HA(n){Ai===n&&(Ai=null)}function Cm(){if(!St||!Ai)return;let n=Ai.getAttribute("data-mikedown-theme");n?St.setAttribute("data-mikedown-theme",n):St.removeAttribute("data-mikedown-theme"),St.style.cssText=Ai.style.cssText}var Bh=new te("mikedownAiRewriteHighlight"),jA=Je.create({name:"mikedownAiRewriteHighlight",addProseMirrorPlugins(){return[new J({key:Bh,state:{init:()=>null,apply(n,e){let t=n.getMeta(Bh);if(t)return t.range;if(!e||!n.docChanged)return e;if(e.anchor){let s=n.mapping.map(e.from,-1);return{...e,from:s,to:s}}let i=n.mapping.map(e.from,1),r=n.mapping.map(e.to,-1);return r>i?{from:i,to:r,id:e.id}:null}},props:{decorations(n){let e=Bh.getState(n);return!e||e.to<=e.from?null:De.create(n.doc,[yt.inline(e.from,e.to,{class:"mikedown-ai-rewrite-target"})])}}})]}}),Dw=Z.define(),Nw=Fe.define({create:()=>null,update(n,e){for(let r of e.effects)if(r.is(Dw))return r.value;if(!n||!e.docChanged)return n;if(n.anchor){let r=e.changes.mapPos(n.from,-1);return{...n,from:r,to:r}}let t=e.changes.mapPos(n.from,1),i=e.changes.mapPos(n.to,-1);return i>t?{from:t,to:i,id:n.id}:null},provide:n=>z.decorations.from(n,e=>e&&e.to>e.from?Y.set([Y.mark({class:"mikedown-ai-rewrite-target"}).range(e.from,e.to)]):Y.none)}),JA=[Nw];var GA=["openai-compatible","lmstudio","ollama","anthropic","openai","vscode-lm"],YA=["vscode-lm"];var XA=8192,QA=["none","default","anyLocal","any"],ZA=["section","page"],eT=1,Rw=5,tT=Rw*2+1,Pw=3,nT=30,iT=80,Iw=60,Bw="section",rT=["unreachable","auth","modelNotFound","modelLoadFailed","contextOverflow","rateLimited","cloudBlocked","consentDenied","cancelled","badOutput","unknown"],Tm=["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"],Lw=["127.0.0.0/8","169.254.0.0/16","0.0.0.0/32"],zw=[".localhost",".local",".lan",".home.arpa",".internal"];function Fw(n){let e=n.trim();if(!e)return null;let i=(/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,""):e).split(/[/?#]/,1)[0],r=i.includes("@")?i.slice(i.lastIndexOf("@")+1):i;if(!r)return null;if(r.startsWith("[")){let o=r.indexOf("]");return o>1?r.slice(1,o).toLowerCase():null}return(r.match(/:/g)??[]).length>1?r.toLowerCase():r.split(":",1)[0].toLowerCase().replace(/\.$/,"")||null}function Om(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(n);if(!e)return null;let t=e.slice(1).map(Number);return t.some(i=>i>255)?null:(t[0]<<24>>>0)+(t[1]<<16)+(t[2]<<8)+t[3]}function Mm(n,e){let[t,i]=e.split("/"),r=Om(t.trim()),s=i===void 0?32:Number(i);if(r===null||!Number.isInteger(s)||s<0||s>32)return!1;if(s===0)return!0;let o=4294967295<<32-s>>>0;return(n&o)>>>0===(r&o)>>>0}function Vw(n){if(!n.includes(":"))return!1;if(n==="::1"||n==="::")return!0;let e=n.split(":")[0];if(!e)return!1;let t=parseInt(e,16);return Number.isNaN(t)?!1:(t&65472)===65152||(t&65024)===64512}function Em(n,e=Tm){let t=Fw(n);if(!t)return"cloud";if(t==="localhost"||zw.some(s=>t.endsWith(s)))return"local";let i=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/.exec(t),r=Om(i?i[1]:t);if(r!==null)return Lw.some(s=>Mm(r,s))||e.some(s=>/^\d/.test(s.trim())&&Mm(r,s.trim()))?"local":"cloud";if(Vw(t))return"local";for(let s of e){let o=s.trim().toLowerCase();if(!(!o||/^\d/.test(o))&&(o.startsWith(".")?t.endsWith(o):t===o||t.endsWith(`.${o}`)))return"local"}return"cloud"}function sT(n,e){return n.kind==="vscode-lm"?"cloud":n.locality==="local"||n.locality==="cloud"?n.locality:Em(n.baseUrl,e)}function oT(n,e){return n.locality==="auto"||n.kind==="vscode-lm"?!1:n.locality!==Em(n.baseUrl,e)}function Hw(){return{maxHops:Pw,sourceShare:Iw,navigateBy:Bw}}function lT(){return{enabled:!1,allowCloud:!1,engines:[],routing:{default:null,fallback:"anyLocal",tasks:{}},features:{},localNetworks:[...Tm],showToolbarButton:!0,activityPanel:!1,docBases:[],docs:Hw()}}var Am="[A-Za-z0-9_-]+",Ww=`(?<![\\w/#&])#(${Am}(?:/${Am})*)`;function $w(){return new RegExp(Ww,"g")}function Dm(n){return/[A-Za-z]/.test(n)}function aT(n){let e=n.trim().replace(/^#+/,"").toLowerCase();return!e||!Dm(e)?null:e}function _w(n){return/^[0-9a-f]+$/i.test(n)?/[0-9]/.test(n)||n.length===6||n.length===8:!1}function hT(n){let e=$w(),t=[],i;for(;(i=e.exec(n))!==null;)!Dm(i[1])||_w(i[1])||t.push({tag:i[1],index:i.index,length:i[0].length});return t}function fT(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s/g,"-")}var uo=200,me=function(){};me.prototype.append=function(e){return e.length?(e=me.from(e),!this.length&&e||e.length<uo&&this.leafAppend(e)||this.length<uo&&e.leafPrepend(this)||this.appendInner(e)):this};me.prototype.prepend=function(e){return e.length?me.from(e).append(this):this};me.prototype.appendInner=function(e){return new Kw(this,e)};me.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?me.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};me.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};me.prototype.forEach=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length),t<=i?this.forEachInner(e,t,i,0):this.forEachInvertedInner(e,t,i,0)};me.prototype.map=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length);var r=[];return this.forEach(function(s,o){return r.push(e(s,o))},t,i),r};me.from=function(e){return e instanceof me?e:e&&e.length?new Nm(e):me.empty};var Nm=(function(n){function e(i){n.call(this),this.values=i}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(r,s){return r==0&&s==this.length?this:new e(this.values.slice(r,s))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,s,o,l){for(var a=s;a<o;a++)if(r(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,l){for(var a=s-1;a>=o;a--)if(r(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=uo)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=uo)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(me);me.empty=new Nm([]);var Kw=(function(n){function e(t,i){n.call(this),this.left=t,this.right=i,this.length=t.length+i.length,this.depth=Math.max(t.depth,i.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(i){return i<this.left.length?this.left.get(i):this.right.get(i-this.left.length)},e.prototype.forEachInner=function(i,r,s,o){var l=this.left.length;if(r<l&&this.left.forEachInner(i,r,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(i,Math.max(r-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,s,o){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(i,r-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(i,Math.min(r,l),s,o)===!1)return!1},e.prototype.sliceInner=function(i,r){if(i==0&&r==this.length)return this;var s=this.left.length;return r<=s?this.left.slice(i,r):i>=s?this.right.slice(i-s,r-s):this.left.slice(i,s).append(this.right.slice(0,r-s))},e.prototype.leafAppend=function(i){var r=this.right.leafAppend(i);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(i){var r=this.left.leafPrepend(i);if(r)return new e(r,this.right)},e.prototype.appendInner=function(i){return this.left.depth>=Math.max(this.right.depth,i.depth)+1?new e(this.left,new e(this.right,i)):new e(this,i)},e})(me),Lh=me;var qw=500,Hn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let r,s;t&&(r=this.remapping(i,this.items.length),s=r.maps.length);let o=e.tr,l,a,h=[],c=[];return this.items.forEach((f,u)=>{if(!f.step){r||(r=this.remapping(i,u+1),s=r.maps.length),s--,c.push(f);return}if(r){c.push(new vt(f.map));let d=f.step.map(r.slice(s)),p;d&&o.maybeStep(d).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],h.push(new vt(p,void 0,void 0,h.length+c.length))),s--,p&&r.appendMap(p,s)}else o.maybeStep(f.step);if(f.selection)return l=r?f.selection.map(r.slice(s)):f.selection,a=new n(this.items.slice(0,i).append(c.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,i,r){let s=[],o=this.eventCount,l=this.items,a=!r&&l.length?l.get(l.length-1):null;for(let c=0;c<e.steps.length;c++){let f=e.steps[c].invert(e.docs[c]),u=new vt(e.mapping.maps[c],f,t),d;(d=a&&a.merge(u))&&(u=d,c?s.pop():l=l.slice(0,l.length-1)),s.push(u),t&&(o++,t=void 0),r||(a=u)}let h=o-i.depth;return h>Jw&&(l=jw(l,h),o-=h),new n(l.append(s),o)}remapping(e,t){let i=new Vi;return this.items.forEach((r,s)=>{let o=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?i.maps.length-r.mirrorOffset:void 0;i.appendMap(r.map,o)},e,t),i}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new vt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},r);let a=t;this.items.forEach(u=>{let d=s.getMirror(--a);if(d==null)return;o=Math.min(o,d);let p=s.maps[d];if(u.step){let m=e.steps[d].invert(e.docs[d]),g=u.selection&&u.selection.map(s.slice(a+1,d));g&&l++,i.push(new vt(p,m,g))}else i.push(new vt(p))},r);let h=[];for(let u=t;u<o;u++)h.push(new vt(s.maps[u]));let c=this.items.slice(0,r).append(h).append(i),f=new n(c,l);return f.emptyItemCount()>qw&&(f=f.compress(this.items.length-i.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),i=t.maps.length,r=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)r.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(i)),h=a&&a.getMap();if(i--,h&&t.appendMap(h,i),a){let c=o.selection&&o.selection.map(t.slice(i));c&&s++;let f=new vt(h.invert(),a,c),u,d=r.length-1;(u=r.length&&r[d].merge(f))?r[d]=u:r.push(f)}}else o.map&&i--},this.items.length,0),new n(Lh.from(r.reverse()),s)}};Hn.empty=new Hn(Lh.empty,0);function jw(n,e){let t;return n.forEach((i,r)=>{if(i.selection&&e--==0)return t=r,!1}),n.slice(t)}var vt=class n{constructor(e,t,i,r){this.map=e,this.step=t,this.selection=i,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},Ct=class{constructor(e,t,i,r,s){this.done=e,this.undone=t,this.prevRanges=i,this.prevTime=r,this.prevComposition=s}},Jw=20;function Uw(n,e,t,i){let r=t.getMeta(Kt),s;if(r)return r.historyState;t.getMeta(Im)&&(n=new Ct(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Kt))return o.getMeta(Kt).redo?new Ct(n.done.addTransform(t,void 0,i,po(e)),n.undone,Rm(t.mapping.maps),n.prevTime,n.prevComposition):new Ct(n.done,n.undone.addTransform(t,void 0,i,po(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)-i.newGroupDelay||!Gw(t,n.prevRanges)),h=o?zh(n.prevRanges,t.mapping):Rm(t.mapping.maps);return new Ct(n.done.addTransform(t,a?e.selection.getBookmark():void 0,i,po(e)),Hn.empty,h,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Ct(n.done.rebased(t,s),n.undone.rebased(t,s),zh(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ct(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),zh(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Gw(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((i,r)=>{for(let s=0;s<e.length;s+=2)i<=e[s+1]&&r>=e[s]&&(t=!0)}),t}function Rm(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((i,r,s,o)=>e.push(s,o));return e}function zh(n,e){if(!n)return null;let t=[];for(let i=0;i<n.length;i+=2){let r=e.map(n[i],1),s=e.map(n[i+1],-1);r<=s&&t.push(r,s)}return t}function Yw(n,e,t){let i=po(e),r=Kt.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,i);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),r,i),a=new Ct(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Kt,{redo:t,historyState:a})}var Fh=!1,Pm=null;function po(n){let e=n.plugins;if(Pm!=e){Fh=!1,Pm=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Fh=!0;break}}return Fh}function yT(n){return n.setMeta(Im,!0)}var Kt=new te("history"),Im=new te("closeHistory");function bT(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new J({key:Kt,state:{init(){return new Ct(Hn.empty,Hn.empty,null,0,-1)},apply(e,t,i){return Uw(t,i,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let i=t.inputType,r=i=="historyUndo"?Xw:i=="historyRedo"?Qw:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function mo(n,e){return(t,i)=>{let r=Kt.getState(t);if(!r||(n?r.undone:r.done).eventCount==0)return!1;if(i){let s=Yw(r,t,n);s&&i(e?s.scrollIntoView():s)}return!0}}var Xw=mo(!1,!0),Qw=mo(!0,!0),xT=mo(!1,!1),kT=mo(!0,!1);function wT(n){let e=Kt.getState(n);return e?e.done.eventCount:0}function ST(n){return n.getMeta(Kt)!=null}var Zw=0,Ie=class{constructor(e,t){this.from=e,this.to=t}},V=class{constructor(e={}){this.id=Zw++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Te.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};V.closedBy=new V({deserialize:n=>n.split(" ")});V.openedBy=new V({deserialize:n=>n.split(" ")});V.group=new V({deserialize:n=>n.split(" ")});V.isolate=new V({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});V.contextHash=new V({perNode:!0});V.lookAhead=new V({perNode:!0});V.mounted=new V({perNode:!0});var on=class{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[V.mounted.id]}},eS=Object.create(null),Te=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):eS,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(V.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(V.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};Te.none=new Te("",Object.create(null),0,8);var Vh=class n{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);if(o){r||(r=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in r&&(l=a.combine(r[a.id],l)),r[a.id]=l}}t.push(r?new Te(i.name,r,i.id,i.flags):i)}return new n(t)}},go=new WeakMap,Bm=new WeakMap,X;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(X||(X={}));var le=class n{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=on.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Ti(this.topNode,e)}cursorAt(e,t=0,i=0){let r=go.get(this)||this.topNode,s=new Ti(r);return s.moveTo(e,t),go.set(this,s._tree),s}get topNode(){return new Be(this,0,0,null)}resolve(e,t=0){let i=Tr(go.get(this)||this.topNode,e,t,!1);return go.set(this,i),i}resolveInner(e,t=0){let i=Tr(Bm.get(this)||this.topNode,e,t,!0);return Bm.set(this,i),i}resolveStack(e,t=0){return tS(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&X.IncludeAnonymous)>0;for(let a=this.cursor(o|X.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Yh(Te.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(Te.none,t,i,r)))}static build(e){return nS(e)}};le.empty=new le(Te.none,[],[],0);var Hh=class n{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new n(this.buffer,this.index)}},ln=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Te.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(_m(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-i;let h=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,h)}return new n(s,o,this.set)}};function _m(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Tr(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof Be&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:X.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof Be&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}var bo=class{cursor(e=0){return new Ti(this,e)}getChild(e,t=null,i=null){let r=Lm(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Lm(this,e,t,i)}resolve(e,t=0){return Tr(this,e,t,!1)}resolveInner(e,t=0){return Tr(this,e,t,!0)}matchContext(e){return Wh(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},Be=class n extends bo{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from,u;if(!(!(s&X.EnterBracketed&&c instanceof le&&(u=on.get(c))&&!u.overlay&&u.bracketed&&i>=f&&i<=f+c.length)&&!_m(r,i,f,f+c.length))){if(c instanceof ln){if(s&X.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,i-f,r);if(d>-1)return new Wn(new $h(o,c,e,f),null,d)}else if(s&X.IncludeAnonymous||!c.type.isAnonymous||Gh(c)){let d;if(!(s&X.IgnoreMounts)&&(d=on.get(c))&&!d.overlay)return new n(d.tree,f,e,o);let p=new n(c,f,e,o);return s&X.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,r,s)}}}if(s&X.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&X.IgnoreOverlays)&&(r=on.get(this._tree))&&r.overlay){let s=e-this.from,o=i&X.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((t>0||o?l<=s:l<s)&&(t<0||o?a>=s:a>s))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Lm(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function Wh(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var $h=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Wn=class n extends bo{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&X.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new le(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Km(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof Be&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new _h(r,t)}var _h=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Km(this.heads)}};function tS(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof Be?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=on.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Be(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Tr(l,e,t,!1))}}return r?Km(r):i}var Ti=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~X.EnterBracketed,e instanceof Be)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof Be?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&X.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&X.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&X.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&X.IncludeAnonymous||l instanceof ln||!l.type.isAnonymous||Gh(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new Wn(this.buffer,t,this.stack[r]);return this.bufferNode=new Wn(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return Wh(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return Wh(this._tree,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function Gh(n){return n.children.some(e=>e instanceof ln||!e.type.isAnonymous||Gh(e))}function nS(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Hh(t,t.length):t,a=i.types,h=0,c=0;function f(w,T,k,D,R,W){let{id:H,start:B,end:$,size:_}=l,q=c,jt=h;if(_<0)if(l.next(),_==-1){let Ot=s[H];k.push(Ot),D.push(B-w);return}else if(_==-3){h=H;return}else if(_==-4){c=H;return}else throw new RangeError(`Unrecognized record size: ${_}`);let Ni=a[H],Br,fn,wc=B-w;if($-B<=r&&(fn=g(l.pos-T,R))){let Ot=new Uint16Array(fn.size-fn.skip),We=l.pos-fn.size,dt=Ot.length;for(;l.pos>We;)dt=y(fn.start,Ot,dt);Br=new ln(Ot,$-fn.start,i),wc=fn.start-w}else{let Ot=l.pos-_;l.next();let We=[],dt=[],un=H>=o?H:-1,Jn=0,Lr=$;for(;l.pos>Ot;)un>=0&&l.id==un&&l.size>=0?(l.end<=Lr-r&&(p(We,dt,B,Jn,l.end,Lr,un,q,jt),Jn=We.length,Lr=l.end),l.next()):W>2500?u(B,Ot,We,dt):f(B,Ot,We,dt,un,W+1);if(un>=0&&Jn>0&&Jn<We.length&&p(We,dt,B,Jn,B,Lr,un,q,jt),We.reverse(),dt.reverse(),un>-1&&Jn>0){let Sc=d(Ni,jt);Br=Yh(Ni,We,dt,0,We.length,0,$-B,Sc,Sc)}else Br=m(Ni,We,dt,$-B,q-$,jt)}k.push(Br),D.push(wc)}function u(w,T,k,D){let R=[],W=0,H=-1;for(;l.pos>T;){let{id:B,start:$,end:_,size:q}=l;if(q>4)l.next();else{if(H>-1&&$<H)break;H<0&&(H=_-r),R.push(B,$,_),W++,l.next()}}if(W){let B=new Uint16Array(W*4),$=R[R.length-2];for(let _=R.length-3,q=0;_>=0;_-=3)B[q++]=R[_],B[q++]=R[_+1]-$,B[q++]=R[_+2]-$,B[q++]=q;k.push(new ln(B,R[2]-$,i)),D.push($-w)}}function d(w,T){return(k,D,R)=>{let W=0,H=k.length-1,B,$;if(H>=0&&(B=k[H])instanceof le){if(!H&&B.type==w&&B.length==R)return B;($=B.prop(V.lookAhead))&&(W=D[H]+B.length+$)}return m(w,k,D,R,W,T)}}function p(w,T,k,D,R,W,H,B,$){let _=[],q=[];for(;w.length>D;)_.push(w.pop()),q.push(T.pop()+k-R);w.push(m(i.types[H],_,q,W-R,B-W,$)),T.push(R-k)}function m(w,T,k,D,R,W,H){if(W){let B=[V.contextHash,W];H=H?[B].concat(H):[B]}if(R>25){let B=[V.lookAhead,R];H=H?[B].concat(H):[B]}return new le(w,T,k,D,H)}function g(w,T){let k=l.fork(),D=0,R=0,W=0,H=k.end-r,B={size:0,start:0,skip:0};e:for(let $=k.pos-w;k.pos>$;){let _=k.size;if(k.id==T&&_>=0){B.size=D,B.start=R,B.skip=W,W+=4,D+=4,k.next();continue}let q=k.pos-_;if(_<0||q<$||k.start<H)break;let jt=k.id>=o?4:0,Ni=k.start;for(k.next();k.pos>q;){if(k.size<0)if(k.size==-3||k.size==-4)jt+=4;else break e;else k.id>=o&&(jt+=4);k.next()}R=Ni,D+=_,W+=jt}return(T<0||D==w)&&(B.size=D,B.start=R,B.skip=W),B.size>4?B:void 0}function y(w,T,k){let{id:D,start:R,end:W,size:H}=l;if(l.next(),H>=0&&D<o){let B=k;if(H>4){let $=l.pos-(H-4);for(;l.pos>$;)k=y(w,T,k)}T[--k]=B,T[--k]=W-w,T[--k]=R-w,T[--k]=D}else H==-3?h=D:H==-4&&(c=D);return k}let b=[],x=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,b,x,-1,0);let C=(e=n.length)!==null&&e!==void 0?e:b.length?x[0]+b[0].length:0;return new le(a[n.topID],b.reverse(),x.reverse(),C)}var zm=new WeakMap;function yo(n,e){if(!n.isAnonymous||e instanceof ln||e.type!=n)return 1;let t=zm.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof le)){t=1;break}t+=yo(n,i)}zm.set(e,t)}return t}function Yh(n,e,t,i,r,s,o,l,a){let h=0;for(let p=i;p<r;p++)h+=yo(n,e[p]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(p,m,g,y,b){for(let x=g;x<y;){let C=x,w=m[x],T=yo(n,p[x]);for(x++;x<y;x++){let k=yo(n,p[x]);if(T+k>=c)break;T+=k}if(x==C+1){if(T>c){let k=p[C];d(k.children,k.positions,0,k.children.length,m[C]+b);continue}f.push(p[C])}else{let k=m[x-1]+p[x-1].length-w;f.push(Yh(n,p,m,C,x,w,k,null,a))}u.push(w+b-s)}}return d(e,t,i,r,0),(l||a)(f,u,o)}var Fm=class{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Wn?this.setBuffer(e.context.buffer,e.index,t):e instanceof Be&&this.map.set(e.tree,t)}get(e){return e instanceof Wn?this.getBuffer(e.context.buffer,e.index):e instanceof Be?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},qt=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new n(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&r.push(u),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return r}},xo=class{startParse(e,t,i){return typeof e=="string"&&(e=new Kh(e)),i=i?i.length?i.map(r=>new Ie(r.from,r.to)):[new Ie(0,0)]:[new Ie(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},Kh=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function AT(n){return(e,t,i,r)=>new Jh(e,n,t,i,r)}var ko=class{constructor(e,t,i,r,s,o){this.parser=e,this.parse=t,this.overlay=i,this.bracketed=r,this.target=s,this.from=o}};function Vm(n){if(!n.length||n.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(n))}var qh=class{constructor(e,t,i,r,s,o,l,a){this.parser=e,this.predicate=t,this.mounts=i,this.index=r,this.start=s,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}},jh=new V({perNode:!0}),Jh=class{constructor(e,t,i,r,s){this.nest=t,this.input=i,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new le(i.type,i.children,i.positions,i.length,i.propValues.concat([[jh,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[V.mounted.id]=new on(t,e.overlay,e.parser,e.bracketed),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new Uh(this.fragments),t=null,i=null,r=new Ti(new Be(this.baseTree,this.ranges[0].from,0,null),X.IncludeAnonymous|X.IgnoreMounts);e:for(let s,o;;){let l=!0,a;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)l=!1;else if(e.hasNode(r)){if(t){let h=t.mounts.find(c=>c.frag.from<=r.from&&c.frag.to>=r.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let f=c.from+h.pos,u=c.to+h.pos;f>=r.from&&u<=r.to&&!t.ranges.some(d=>d.from<u&&d.to>f)&&t.ranges.push({from:f,to:u})}}l=!1}else if(i&&(o=iS(i.ranges,r.from,r.to)))l=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.from<r.to||!s.overlay)){r.tree||(rS(r),t&&t.depth++,i&&i.depth++);let h=e.findMounts(r.from,s.parser);if(typeof s.overlay=="function")t=new qh(s.parser,s.overlay,h,this.inner.length,r.from,!!s.bracketed,r.tree,t);else{let c=Wm(this.ranges,s.overlay||(r.from<r.to?[new Ie(r.from,r.to)]:[]));c.length&&Vm(c),(c.length||!s.overlay)&&this.inner.push(new ko(s.parser,c.length?s.parser.startParse(this.input,$m(h,c),c):s.parser.startParse(""),s.overlay?s.overlay.map(f=>new Ie(f.from-r.from,f.to-r.from)):null,!!s.bracketed,r.tree,c.length?c[0].from:r.from)),s.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):l=!1}}else if(t&&(a=t.predicate(r))&&(a===!0&&(a=new Ie(r.from,r.to)),a.from<a.to)){let h=t.ranges.length-1;h>=0&&t.ranges[h].to==a.from?t.ranges[h]={from:t.ranges[h].from,to:a.to}:t.ranges.push(a)}if(l&&r.firstChild())t&&t.depth++,i&&i.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(t&&!--t.depth){let h=Wm(this.ranges,t.ranges);h.length&&(Vm(h),this.inner.splice(t.index,0,new ko(t.parser,t.parser.startParse(this.input,$m(t.mounts,h),h),t.ranges.map(c=>new Ie(c.from-t.start,c.to-t.start)),t.bracketed,t.target,h[0].from))),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}};function iS(n,e,t){for(let i of n){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function Hm(n,e,t,i,r,s){if(e<t){let o=n.buffer[e+1];i.push(n.slice(e,t,o)),r.push(o-s)}}function rS(n){let{node:e}=n,t=[],i=e.context.buffer;do t.push(n.index),n.parent();while(!n.tree);let r=n.tree,s=r.children.indexOf(i),o=r.children[s],l=o.buffer,a=[s];function h(c,f,u,d,p,m){let g=t[m],y=[],b=[];Hm(o,c,g,y,b,d);let x=l[g+1],C=l[g+2];a.push(y.length);let w=m?h(g+4,l[g+3],o.set.types[l[g]],x,C-x,m-1):e.toTree();return y.push(w),b.push(x-d),Hm(o,l[g+3],f,y,b,d),new le(u,y,b,p)}r.children[s]=h(0,l.length,Te.none,0,o.length,t.length-1);for(let c of a){let f=n.tree.children[c],u=n.tree.positions[c];n.yield(new Be(f,u+n.from,c,n._tree))}}var wo=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(X.IncludeAnonymous|X.IgnoreMounts)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)t.to>=e&&t.enter(i,1,X.IgnoreOverlays|X.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof le)t=t.children[0];else break}return!1}},Uh=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(t=i.tree.prop(jh))!==null&&t!==void 0?t:i.to,this.inner=new wo(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(jh))!==null&&e!==void 0?e:t.to,this.inner=new wo(t.tree,-t.offset)}}findMounts(e,t){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(i=s.tree)===null||i===void 0?void 0:i.prop(V.mounted);if(o&&o.parser==t)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=s.to)break;a.tree==this.curFrag.tree&&r.push({frag:a,pos:s.from-a.offset,mount:o})}}}return r}};function Wm(n,e){let t=null,i=e;for(let r=1,s=0;r<n.length;r++){let o=n[r-1].to,l=n[r].from;for(;s<i.length;s++){let a=i[s];if(a.from>=l)break;a.to<=o||(t||(i=t=e.slice()),a.from<o?(t[s]=new Ie(a.from,o),a.to>l&&t.splice(s+1,0,new Ie(l,a.to))):a.to>l?t[s--]=new Ie(l,a.to):t.splice(s--,1))}}return i}function sS(n,e,t,i){let r=0,s=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=r==n.length?1e9:o?n[r].to:n[r].from,f=s==e.length?1e9:l?e[s].to:e[s].from;if(o!=l){let u=Math.max(a,t),d=Math.min(c,f,i);u<d&&h.push(new Ie(u,d))}if(a=Math.min(c,f),a==1e9)break;c==a&&(o?(o=!1,r++):o=!0),f==a&&(l?(l=!1,s++):l=!0)}return h}function $m(n,e){let t=[];for(let{pos:i,mount:r,frag:s}of n){let o=i+(r.overlay?r.overlay[0].from:0),l=o+r.tree.length,a=Math.max(s.from,o),h=Math.min(s.to,l);if(r.overlay){let c=r.overlay.map(u=>new Ie(u.from+i,u.to+i)),f=sS(e,c,a,h);for(let u=0,d=a;;u++){let p=u==f.length,m=p?h:f[u].from;if(m>d&&t.push(new qt(d,m,r.tree,-o,s.from>=d||s.openStart,s.to<=m||s.openEnd)),p)break;d=f[u].to}}else t.push(new qt(a,h,r.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return t}var oS=0,at=class n{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=oS++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof n&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new n(i,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Mo(e);return i=>i.modified.indexOf(t)>-1?i:Mo.get(i.base||i,i.modified.concat(t).sort((r,s)=>r.id-s.id))}},lS=0,Mo=class n{constructor(e){this.name=e,this.instances=[],this.id=lS++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&aS(t,l.modified));if(i)return i;let r=[],s=new at(e.name,r,e,t);for(let l of t)l.instances.push(s);let o=hS(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(n.get(l,a));return s}};function aS(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function hS(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Jm(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let d=r[f++];if(f==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new _n(i,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return Um.add(e)}var Um=new V({combine(n,e){let t,i,r;for(;n||e;){if(!n||e&&n.depth>=e.depth?(r=e,e=e.next):(r=n,n=n.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new _n(r.tags,r.mode,r.context);t?t.next=s:i=s,t=s}return i}}),_n=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};_n.empty=new _n([],2,null);function ec(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function cS(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function Gm(n,e,t,i=0,r=n.length){let s=new Qh(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var Qh=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=r,c=fS(e)||_n.empty,f=cS(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(V.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let b=g<u.overlay.length?u.overlay[g]:null,x=b?b.from+l:a,C=Math.max(t,y),w=Math.min(i,x);if(C<w&&m)for(;e.from<w&&(this.highlightRange(e,C,w,r,s),this.startSpan(Math.min(w,e.to),h),!(e.to>=x||!e.nextSibling())););if(!b||x>i)break;y=b.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,b.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),h))}m&&e.parent()}else if(e.firstChild()){u&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}};function fS(n){let e=n.type.prop(Um);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var M=at.define,So=M(),an=M(),qm=M(an),jm=M(an),hn=M(),vo=M(hn),Xh=M(hn),Tt=M(),$n=M(Tt),Mt=M(),At=M(),Zh=M(),Or=M(Zh),Co=M(),A={comment:So,lineComment:M(So),blockComment:M(So),docComment:M(So),name:an,variableName:M(an),typeName:qm,tagName:M(qm),propertyName:jm,attributeName:M(jm),className:M(an),labelName:M(an),namespace:M(an),macroName:M(an),literal:hn,string:vo,docString:M(vo),character:M(vo),attributeValue:M(vo),number:Xh,integer:M(Xh),float:M(Xh),bool:M(hn),regexp:M(hn),escape:M(hn),color:M(hn),url:M(hn),keyword:Mt,self:M(Mt),null:M(Mt),atom:M(Mt),unit:M(Mt),modifier:M(Mt),operatorKeyword:M(Mt),controlKeyword:M(Mt),definitionKeyword:M(Mt),moduleKeyword:M(Mt),operator:At,derefOperator:M(At),arithmeticOperator:M(At),logicOperator:M(At),bitwiseOperator:M(At),compareOperator:M(At),updateOperator:M(At),definitionOperator:M(At),typeOperator:M(At),controlOperator:M(At),punctuation:Zh,separator:M(Zh),bracket:Or,angleBracket:M(Or),squareBracket:M(Or),paren:M(Or),brace:M(Or),content:Tt,heading:$n,heading1:M($n),heading2:M($n),heading3:M($n),heading4:M($n),heading5:M($n),heading6:M($n),contentSeparator:M(Tt),list:M(Tt),quote:M(Tt),emphasis:M(Tt),strong:M(Tt),link:M(Tt),monospace:M(Tt),strikethrough:M(Tt),inserted:M(),deleted:M(),changed:M(),invalid:M(),meta:Co,documentMeta:M(Co),annotation:M(Co),processingInstruction:M(Co),definition:at.defineModifier("definition"),constant:at.defineModifier("constant"),function:at.defineModifier("function"),standard:at.defineModifier("standard"),local:at.defineModifier("local"),special:at.defineModifier("special")};for(let n in A){let e=A[n];e instanceof at&&(e.name=n)}var ET=ec([{tag:A.link,class:"tok-link"},{tag:A.heading,class:"tok-heading"},{tag:A.emphasis,class:"tok-emphasis"},{tag:A.strong,class:"tok-strong"},{tag:A.keyword,class:"tok-keyword"},{tag:A.atom,class:"tok-atom"},{tag:A.bool,class:"tok-bool"},{tag:A.url,class:"tok-url"},{tag:A.labelName,class:"tok-labelName"},{tag:A.inserted,class:"tok-inserted"},{tag:A.deleted,class:"tok-deleted"},{tag:A.literal,class:"tok-literal"},{tag:A.string,class:"tok-string"},{tag:A.number,class:"tok-number"},{tag:[A.regexp,A.escape,A.special(A.string)],class:"tok-string2"},{tag:A.variableName,class:"tok-variableName"},{tag:A.local(A.variableName),class:"tok-variableName tok-local"},{tag:A.definition(A.variableName),class:"tok-variableName tok-definition"},{tag:A.special(A.variableName),class:"tok-variableName2"},{tag:A.definition(A.propertyName),class:"tok-propertyName tok-definition"},{tag:A.typeName,class:"tok-typeName"},{tag:A.namespace,class:"tok-namespace"},{tag:A.className,class:"tok-className"},{tag:A.macroName,class:"tok-macroName"},{tag:A.propertyName,class:"tok-propertyName"},{tag:A.operator,class:"tok-operator"},{tag:A.comment,class:"tok-comment"},{tag:A.meta,class:"tok-meta"},{tag:A.invalid,class:"tok-invalid"},{tag:A.punctuation,class:"tok-punctuation"}]);var tc,Oi=new V;function uS(n){return N.define({combine:n?e=>e.concat(n):void 0})}var dS=new V,He=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,ie.prototype.hasOwnProperty("tree")||Object.defineProperty(ie.prototype,"tree",{get(){return ht(this)}}),this.parser=t,this.extension=[Ei.of(this),ie.languageData.of((s,o,l)=>{let a=Ym(s,o,l),h=a.type.prop(Oi);if(!h)return[];let c=s.facet(h),f=a.type.prop(dS);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return Ym(e,t,i).type.prop(Oi)==this.data}findRegions(e){let t=e.facet(Ei);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Oi)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(V.mounted);if(l){if(l.tree.prop(Oi)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof le&&r(h,s.positions[a]+o)}};return r(ht(e),0),i}get allowsNesting(){return!0}};He.setState=Z.define();function Ym(n,e,t){let i=n.facet(Ei),r=ht(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,X.ExcludeBuffers|X.EnterBracketed))s.type.isTop&&(r=s);return r}var Xm=class n extends He{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=uS(e.languageData);return new n(t,e.parser.configure({props:[Oi.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new n(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function ht(n){let e=n.field(He.state,!1);return e?e.tree:le.empty}var sc=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Er=null,oc=class n{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],le.empty,0,i,[],null)}startParse(){return this.parser.startParse(new sc(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=le.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(qt.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(qt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Er;Er=this;try{return e()}finally{Er=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Qm(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=qt.applyChanges(i,a),r=le.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new n(this.parser,t,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=Qm(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends xo{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=Er;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new le(Te.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Er}};function Qm(n,e,t){return qt.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var Dr=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=oc.create(e.facet(Ei).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};He.state=Fe.define({create:Dr.init,update(n,e){for(let t of e.effects)if(t.is(He.setState))return t.value;return e.startState.facet(Ei)!=e.state.facet(Ei)?Dr.init(e.state):n.apply(e)}});var rg=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(rg=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var nc=typeof navigator<"u"&&(!((tc=navigator.scheduling)===null||tc===void 0)&&tc.isInputPending)?()=>navigator.scheduling.isInputPending():null,pS=_t.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(He.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(He.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=rg(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(He.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!nc?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>nc&&nc()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:He.setState.of(new Dr(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>st(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ei=N.define({combine(n){return n.length?n[0]:null},enables:n=>[He.state,pS,z.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),Zm=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},eg=class n{constructor(e,t,i,r,s,o=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=r,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new n(e.name,(e.alias||[]).concat(e.name).map(r=>r.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let r of e)if(r.filename&&r.filename.test(t))return r;let i=/\.([^.]+)$/.exec(t);if(i){for(let r of e)if(r.extensions.indexOf(i[1])>-1)return r}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let r of e)if(r.alias.some(s=>s==t))return r;if(i)for(let r of e)for(let s of r.alias){let o=t.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+s.length])))return r}return null}},mS=N.define(),To=N.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Nr(n){let e=n.facet(To);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Rr(n,e){let t="",i=n.tabSize,r=n.facet(To)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function uc(n,e){n instanceof ie&&(n=new Kn(n));for(let i of n.state.facet(mS)){let r=i(n,e);if(r!==void 0)return r}let t=ht(n.state);return t.length>=e?yS(n,t,e):null}var Kn=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Nr(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Pn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},gS=new V;function yS(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return sg(i,n,t)}function sg(n,e,t){for(let i=n;i;i=i.next){let r=xS(i.node);if(r)return r(lc.create(e,t,i))}return 0}function bS(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function xS(n){let e=n.type.prop(gS);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(V.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>og(o,!0,1,void 0,s&&!bS(o)?r.from:void 0)}return n.parent==null?kS:null}function kS(){return 0}var lc=class n extends Kn{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(wS(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return sg(this.context.next,this.base,this.pos)}};function wS(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function SS(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function FT({closing:n,align:e=!0,units:t=1}){return i=>og(i,e,t,n)}function og(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?SS(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var VT=n=>n.baseIndent;function HT({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}var WT=N.define(),$T=new V;function _T(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}var Ao=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=Ge.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof He?l=>l.prop(Oi)==o.data:o?l=>l==o:void 0,this.style=ec(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new Ge(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},ac=N.define(),lg=N.define({combine(n){return n.length?[n[0]]:null}});function ic(n){let e=n.facet(ac);return e.length?e:n.facet(lg)}function KT(n,e){let t=[vS],i;return n instanceof Ao&&(n.module&&t.push(z.styleModule.of(n.module)),i=n.themeType),e?.fallback?t.push(lg.of(n)):i?t.push(ac.computeN([z.darkTheme],r=>r.facet(z.darkTheme)==(i=="dark")?[n]:[])):t.push(ac.of(n)),t}var hc=class{constructor(e){this.markCache=Object.create(null),this.tree=ht(e.state),this.decorations=this.buildDeco(e,ic(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ht(e.state),i=ic(e.state),r=i!=ic(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!r&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return Y.none;let i=new Rn;for(let{from:r,to:s}of e.visibleRanges)Gm(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=Y.mark({class:a})))},r,s);return i.finish()}},vS=hr.high(_t.fromClass(hc,{decorations:n=>n.decorations})),qT=Ao.define([{tag:A.meta,color:"#404740"},{tag:A.link,textDecoration:"underline"},{tag:A.heading,textDecoration:"underline",fontWeight:"bold"},{tag:A.emphasis,fontStyle:"italic"},{tag:A.strong,fontWeight:"bold"},{tag:A.strikethrough,textDecoration:"line-through"},{tag:A.keyword,color:"#708"},{tag:[A.atom,A.bool,A.url,A.contentSeparator,A.labelName],color:"#219"},{tag:[A.literal,A.inserted],color:"#164"},{tag:[A.string,A.deleted],color:"#a11"},{tag:[A.regexp,A.escape,A.special(A.string)],color:"#e40"},{tag:A.definition(A.variableName),color:"#00f"},{tag:A.local(A.variableName),color:"#30a"},{tag:[A.typeName,A.namespace],color:"#085"},{tag:A.className,color:"#167"},{tag:[A.special(A.variableName),A.macroName],color:"#256"},{tag:A.definition(A.propertyName),color:"#00c"},{tag:A.comment,color:"#940"},{tag:A.invalid,color:"#f00"}]);var CS=1e4,MS="()[]{}";var AS=new V;function cc(n,e,t){let i=n.prop(e<0?V.openedBy:V.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function fc(n){let e=n.type.prop(AS);return e?e(n.node):n}function qn(n,e,t,i={}){let r=i.maxScanDistance||CS,s=i.brackets||MS,o=ht(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=cc(a.type,t,s);if(h&&a.from<a.to){let c=fc(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return TS(n,e,t,a,c,h,s)}}return OS(n,e,t,o,l.type,r,s)}function TS(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},h=0,c=l?.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let f=fc(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(cc(c.type,t,o))h++;else if(cc(c.type,-t,o)){if(h==0){let f=fc(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function OS(n,e,t,i,r,s,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=s;){let d=c.value;t<0&&(u+=d.length);let p=e+u*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let y=o.indexOf(d[m]);if(!(y<0||i.resolveInner(p+m,1).type!=r))if(y%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}var ES=Object.create(null),tg=[Te.none];var ng=[],ig=Object.create(null),DS=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])DS[n]=NS(ES,e);function rc(n,e){ng.indexOf(n)>-1||(ng.push(n),console.warn(e))}function NS(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||A[h];c?typeof c=="function"?a.length?a=a.map(c):rc(h,`Modifier ${h} used at start of tag`):a.length?rc(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:rc(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=ig[r];if(s)return s.id;let o=ig[r]=Te.define({id:tg.length,name:i,props:[Jm({[i]:t})]});return tg.push(o),o.id}var jT={rtl:Y.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:ne.RTL}),ltr:Y.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:ne.LTR}),auto:Y.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var RS=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=xc(n.state,t.from);return i.line?PS(n):i.block?BS(n):!1};function bc(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var PS=bc(FS,0);var IS=bc(gg,0);var BS=bc((n,e)=>gg(n,e,zS(e)),0);function xc(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var Pr=50;function LS(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-Pr,i),o=n.sliceDoc(r,r+Pr),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,h=s.length-l;if(s.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,f;r-i<=2*Pr?c=f=n.sliceDoc(i,r):(c=n.sliceDoc(i,i+Pr),f=n.sliceDoc(r-Pr,r));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function zS(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function gg(n,e,t=e.selection.ranges){let i=t.map(s=>xc(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>LS(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:h,close:c}=l;s.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function FS(n,e,t=e.selection.ranges){let i=[],r=-1;e:for(let{from:s,to:o}of t){let l=i.length,a=1e9,h;for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(h==null&&(h=xc(e,f.from).line,!h))continue e;if(f.from>r&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:h,indent:u,empty:d,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&s.push({from:l.from+h,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}var pc=Ue.define(),VS=Ue.define(),HS=N.define(),yg=N.define({combine(n){return cr(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),bg=Fe.define({create(){return jn.empty},update(n,e){let t=e.state.facet(yg),i=e.annotation(pc);if(i){let a=ct.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=Eo(c,c.length,t.minDepth,a):c=wg(c,e.startState.selection),new jn(h==0?i.rest:c,h==0?c:i.rest)}let r=e.annotation(VS);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(ce.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=ct.fromTransaction(e),o=e.annotation(ce.time),l=e.annotation(ce.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new jn(n.done.map(ct.fromJSON),n.undone.map(ct.fromJSON))}});function ZT(n={}){return[bg,yg.of(n),z.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?xg:e.inputType=="historyRedo"?mc:null;return i?(e.preventDefault(),i(t)):!1}})]}function Do(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(bg,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var xg=Do(0,!1),mc=Do(1,!1),WS=Do(0,!0),$S=Do(1,!0);var ct=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&Me.fromJSON(e.changes),[],e.mapped&&Vt.fromJSON(e.mapped),e.startSelection&&v.fromJSON(e.startSelection),e.selectionsAfter.map(v.fromJSON))}static fromTransaction(e,t){let i=et;for(let r of e.startState.facet(HS)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,et)}static selection(e){return new n(void 0,et,void 0,void 0,e)}};function Eo(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function _S(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function KS(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function kg(n,e){return n.length?e.length?n.concat(e):n:e}var et=[],qS=200;function wg(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-qS));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Eo(n,n.length-1,1e9,t.setSelAfter(i)))}else return[ct.selection([e])]}function jS(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function dc(n,e){if(!n.length)return n;let t=n.length,i=et;for(;t;){let r=JS(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[ct.selection(i)]:et}function JS(n,e,t){let i=kg(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):et,t);if(!n.changes)return ct.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new ct(r,Z.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var US=/^(input\.type|delete)($|\.)/,jn=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||US.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,_S(l.changes,e.changes))||i=="input.type.compose")?o=Eo(o,o.length-1,r.minDepth,new ct(e.changes.compose(l.changes),kg(Z.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,et)):o=Eo(o,o.length,r.minDepth,e),new n(o,et,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:et;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&KS(s[s.length-1],e)?this:new n(wg(this.done,e),this.undone,t,i)}addMapping(e){return new n(dc(this.done,e),dc(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:pc.of({side:e,rest:jS(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?et:r.slice(0,r.length-1);return s.mapped&&(l=dc(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:pc.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};jn.empty=new jn(et,et);var eO=[{key:"Mod-z",run:xg,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:mc,preventDefault:!0},{linux:"Ctrl-Shift-z",run:mc,preventDefault:!0},{key:"Mod-u",run:WS,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:$S,preventDefault:!0}];function Di(n,e){return v.create(n.ranges.map(e),n.mainIndex)}function ft(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function ut({state:n,dispatch:e},t){let i=Di(n.selection,t);return i.eq(n.selection,!0)?!1:(e(ft(n,i)),!0)}function No(n,e){return v.cursor(e?n.to:n.from)}function Sg(n,e){return ut(n,t=>t.empty?n.moveByChar(t,e):No(t,e))}function we(n){return n.textDirectionAt(n.state.selection.main.head)==ne.LTR}var vg=n=>Sg(n,!we(n)),Cg=n=>Sg(n,we(n));function Mg(n,e){return ut(n,t=>t.empty?n.moveByGroup(t,e):No(t,e))}var GS=n=>Mg(n,!we(n)),YS=n=>Mg(n,we(n));var tO=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function XS(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Ro(n,e,t){let i=ht(n).resolveInner(e.head),r=t?V.closedBy:V.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;XS(n,h,r)?i=h:a=t?h.to:h.from}let s=i.type.prop(r),o,l;return s&&(o=t?qn(n,i.from,1):qn(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,v.cursor(l,t?-1:1)}var QS=n=>ut(n,e=>Ro(n.state,e,!we(n))),ZS=n=>ut(n,e=>Ro(n.state,e,we(n)));function Ag(n,e){return ut(n,t=>{if(!t.empty)return No(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var Tg=n=>Ag(n,!1),Og=n=>Ag(n,!0);function Eg(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(z.scrollMargins)){let o=s(n);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(i=Math.max(o?.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function Dg(n,e){let t=Eg(n),{state:i}=n,r=Di(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):No(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(s=z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(ft(i,r),{effects:s}),!0}var ag=n=>Dg(n,!1),gc=n=>Dg(n,!0);function cn(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=v.cursor(i.from+s))}return r}var ev=n=>ut(n,e=>cn(n,e,!0)),tv=n=>ut(n,e=>cn(n,e,!1)),nv=n=>ut(n,e=>cn(n,e,!we(n))),iv=n=>ut(n,e=>cn(n,e,we(n))),rv=n=>ut(n,e=>v.cursor(n.lineBlockAt(e.head).from,1)),sv=n=>ut(n,e=>v.cursor(n.lineBlockAt(e.head).to,-1));function ov(n,e,t){let i=!1,r=Di(n.selection,s=>{let o=qn(n,s.head,-1)||qn(n,s.head,1)||s.head>0&&qn(n,s.head-1,1)||s.head<n.doc.length&&qn(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return t?v.range(s.anchor,l):v.cursor(l)});return i?(e(ft(n,r)),!0):!1}var lv=({state:n,dispatch:e})=>ov(n,e,!1);function tt(n,e){let t=Di(n.state.selection,i=>{let r=e(i);return v.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(ft(n.state,t)),!0)}function Ng(n,e){return tt(n,t=>n.moveByChar(t,e))}var Rg=n=>Ng(n,!we(n)),Pg=n=>Ng(n,we(n));function Ig(n,e){return tt(n,t=>n.moveByGroup(t,e))}var av=n=>Ig(n,!we(n)),hv=n=>Ig(n,we(n));var cv=n=>tt(n,e=>Ro(n.state,e,!we(n))),fv=n=>tt(n,e=>Ro(n.state,e,we(n)));function Bg(n,e){return tt(n,t=>n.moveVertically(t,e))}var Lg=n=>Bg(n,!1),zg=n=>Bg(n,!0);function Fg(n,e){return tt(n,t=>n.moveVertically(t,e,Eg(n).height))}var hg=n=>Fg(n,!1),cg=n=>Fg(n,!0),uv=n=>tt(n,e=>cn(n,e,!0)),dv=n=>tt(n,e=>cn(n,e,!1)),pv=n=>tt(n,e=>cn(n,e,!we(n))),mv=n=>tt(n,e=>cn(n,e,we(n))),gv=n=>tt(n,e=>v.cursor(n.lineBlockAt(e.head).from)),yv=n=>tt(n,e=>v.cursor(n.lineBlockAt(e.head).to)),fg=({state:n,dispatch:e})=>(e(ft(n,{anchor:0})),!0),ug=({state:n,dispatch:e})=>(e(ft(n,{anchor:n.doc.length})),!0),dg=({state:n,dispatch:e})=>(e(ft(n,{anchor:n.selection.main.anchor,head:0})),!0),pg=({state:n,dispatch:e})=>(e(ft(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),bv=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),xv=({state:n,dispatch:e})=>{let t=Po(n).map(({from:i,to:r})=>v.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:v.create(t),userEvent:"select"})),!0},kv=({state:n,dispatch:e})=>{let t=Di(n.selection,i=>{let r=ht(n),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return v.range(l.to,l.from)}return i});return t.eq(n.selection)?!1:(e(ft(n,t)),!0)};function Vg(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to<n.state.doc.length:o.from>0)for(let l=s;;){let a=n.moveVertically(l,e);if(a.head<o.from||a.head>o.to){r.some(h=>h.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==i.ranges.length?!1:(n.dispatch(ft(t,v.create(r,r.length-1))),!0)}var wv=n=>Vg(n,!1),Sv=n=>Vg(n,!0),vv=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=v.create([t.main]):t.main.empty||(i=v.create([v.cursor(t.main.head)])),i?(e(ft(n,i)),!0):!1};function Ir(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=Oo(n,a,!1)):a>o&&(t="delete.forward",a=Oo(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Oo(n,o,!1),l=Oo(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:v.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?z.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Oo(n,e,t){if(n instanceof z)for(let i of n.state.facet(z.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var Hg=(n,e,t)=>Ir(n,i=>{let r=i.from,{state:s}=n,o=s.doc.lineAt(r),l,a;if(t&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]==" ")return r-1;let h=Pn(l,s.tabSize),c=h%Nr(s)||Nr(s);for(let f=0;f<c&&l[l.length-1-f]==" ";f++)r--;a=r}else a=fe(o.text,r-o.from,e,e)+o.from,a==r&&o.number!=(e?s.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=fe(o.text,a-o.from,!1,!1)+o.from);return a}),yc=n=>Hg(n,!1,!0);var Wg=n=>Hg(n,!0,!1),$g=(n,e)=>Ir(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=fe(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),_g=n=>$g(n,!1),Cv=n=>$g(n,!0);var Mv=n=>Ir(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var Av=n=>Ir(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Tv=n=>Ir(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var Ov=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:K.of(["",""])},range:v.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Ev=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:fe(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:fe(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:v.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Po(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Kg(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Po(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(v.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(v.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:v.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var Dv=({state:n,dispatch:e})=>Kg(n,e,!1),Nv=({state:n,dispatch:e})=>Kg(n,e,!0);function qg(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of Po(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});let r=n.changes(i);return e(n.update({changes:r,selection:n.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var Rv=({state:n,dispatch:e})=>qg(n,e,!1),Pv=({state:n,dispatch:e})=>qg(n,e,!0),Iv=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Po(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Di(e.selection,r=>{let s;if(n.lineWrapping){let o=n.lineBlockAt(r.head),l=n.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,s)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Bv(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ht(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(V.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var mg=jg(!1),Lv=jg(!0);function jg(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&Bv(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new Kn(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=uc(h,s);for(c==null&&(c=Pn(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",Rr(e,c)];return a&&f.push(Rr(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:K.of(f)},range:v.cursor(s+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function kc(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:v.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var zv=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Kn(n,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=kc(n,(s,o,l)=>{let a=uc(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=Rr(n,a);(h!=c||l.from<s.from+h.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+h.length,insert:c}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},Fv=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(kc(n,(t,i)=>{i.push({from:t.from,insert:n.facet(To)})}),{userEvent:"input.indent"})),!0),Vv=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(kc(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Pn(r,n.tabSize),o=0,l=Rr(n,Math.max(0,s-Nr(n)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Hv=n=>(n.setTabFocusMode(),!0);var Wv=[{key:"Ctrl-b",run:vg,shift:Rg,preventDefault:!0},{key:"Ctrl-f",run:Cg,shift:Pg},{key:"Ctrl-p",run:Tg,shift:Lg},{key:"Ctrl-n",run:Og,shift:zg},{key:"Ctrl-a",run:rv,shift:gv},{key:"Ctrl-e",run:sv,shift:yv},{key:"Ctrl-d",run:Wg},{key:"Ctrl-h",run:yc},{key:"Ctrl-k",run:Mv},{key:"Ctrl-Alt-h",run:_g},{key:"Ctrl-o",run:Ov},{key:"Ctrl-t",run:Ev},{key:"Ctrl-v",run:gc}],$v=[{key:"ArrowLeft",run:vg,shift:Rg,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:GS,shift:av,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:nv,shift:pv,preventDefault:!0},{key:"ArrowRight",run:Cg,shift:Pg,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:YS,shift:hv,preventDefault:!0},{mac:"Cmd-ArrowRight",run:iv,shift:mv,preventDefault:!0},{key:"ArrowUp",run:Tg,shift:Lg,preventDefault:!0},{mac:"Cmd-ArrowUp",run:fg,shift:dg},{mac:"Ctrl-ArrowUp",run:ag,shift:hg},{key:"ArrowDown",run:Og,shift:zg,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ug,shift:pg},{mac:"Ctrl-ArrowDown",run:gc,shift:cg},{key:"PageUp",run:ag,shift:hg},{key:"PageDown",run:gc,shift:cg},{key:"Home",run:tv,shift:dv,preventDefault:!0},{key:"Mod-Home",run:fg,shift:dg},{key:"End",run:ev,shift:uv,preventDefault:!0},{key:"Mod-End",run:ug,shift:pg},{key:"Enter",run:mg,shift:mg},{key:"Mod-a",run:bv},{key:"Backspace",run:yc,shift:yc,preventDefault:!0},{key:"Delete",run:Wg,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:_g,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Cv,preventDefault:!0},{mac:"Mod-Backspace",run:Av,preventDefault:!0},{mac:"Mod-Delete",run:Tv,preventDefault:!0}].concat(Wv.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),nO=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:QS,shift:cv},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:ZS,shift:fv},{key:"Alt-ArrowUp",run:Dv},{key:"Shift-Alt-ArrowUp",run:Rv},{key:"Alt-ArrowDown",run:Nv},{key:"Shift-Alt-ArrowDown",run:Pv},{key:"Mod-Alt-ArrowUp",run:wv},{key:"Mod-Alt-ArrowDown",run:Sv},{key:"Escape",run:vv},{key:"Mod-Enter",run:Lv},{key:"Alt-l",mac:"Ctrl-l",run:xv},{key:"Mod-i",run:kv,preventDefault:!0},{key:"Mod-[",run:Vv},{key:"Mod-]",run:Fv},{key:"Mod-Alt-\\",run:zv},{key:"Shift-Mod-k",run:Iv},{key:"Shift-Mod-\\",run:lv},{key:"Mod-/",run:RS},{key:"Alt-A",run:IS},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Hv}].concat($v);var Bo=null,Io=null;function rO(){return Bo}function sO(){return Bo?Promise.resolve(Bo):(Io??(Io=import("./mikedown-editor.ai-ui-QFYFN73D-MK2MJ2BC.js").then(n=>(Bo=n,n),n=>{throw Io=null,n})),Io)}function oO(n){return typeof n.listEngines=="function"?2:1}function lO(n,e){return!n||!e.showToolbarButton?"hidden":e.enabled?"menu":"firstRun"}export{_v as a,Kv as b,qv as c,jv as d,Jv as e,Uv as f,Gv as g,S as h,j as i,O as j,Gn as k,pt as l,Zn as m,of as n,Qn as o,F as p,Ur as q,L as r,I as s,Yr as t,J as u,te as v,yt as w,De as x,Rb as y,he as z,ds as A,ir as B,Cx as C,cM as D,fM as E,Ax as F,P as G,la as H,U as I,Ex as J,ks as K,fd as L,ud as M,Bx as N,Fx as O,dd as P,yM as Q,bM as R,xM as S,aa as T,wM as U,SM as V,Ms as W,m1 as X,S1 as Y,Je as Z,QM as _,ZM as $,eA as aa,tA as ba,iA as ca,rA as da,oA as ea,lA as fa,P1 as ga,I1 as ha,aA as ia,cA as ja,K as ka,Ne as la,v as ma,N as na,Fe as oa,hr as pa,Is as qa,Ue as ra,Z as sa,ce as ta,ie as ua,bt as va,Pn as wa,Ln as xa,Y as ya,z as za,gw as Aa,RA as Ba,PA as Ca,FA as Da,VA as Ea,HA as Fa,Cm as Ga,Bh as Ha,jA as Ia,Dw as Ja,Nw as Ka,JA as La,GA as Ma,YA as Na,XA as Oa,QA as Pa,ZA as Qa,eT as Ra,Rw as Sa,Pw as Ta,nT as Ua,iT as Va,Iw as Wa,rT as Xa,Tm as Ya,Fw as Za,Em as _a,sT as $a,oT as ab,Hw as bb,lT as cb,aT as db,hT as eb,fT as fb,yT as gb,bT as hb,Xw as ib,Qw as jb,wT as kb,ST as lb,V as mb,Te as nb,Vh as ob,X as pb,le as qb,Fm as rb,xo as sb,AT as tb,at as ub,Jm as vb,A as wb,Oi as xb,uS as yb,dS as zb,He as Ab,Xm as Bb,ht as Cb,oc as Db,Zm as Eb,eg as Fb,To as Gb,gS as Hb,FT as Ib,VT as Jb,HT as Kb,WT as Lb,$T as Mb,_T as Nb,Ao as Ob,KT as Pb,qT as Qb,AS as Rb,VS as Sb,ZT as Tb,xg as Ub,mc as Vb,eO as Wb,nO as Xb,rO as Yb,sO as Zb,oO as _b,lO as $b};
|