1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6079],{89561:(t,e,i)=>{let s;i.d(e,{$K:()=>sC,A:()=>iO,D4:()=>i_,DK:()=>i8,Eg:()=>i7,HJ:()=>iU,Lz:()=>e7,N$:()=>iN,NZ:()=>tn,OP:()=>tW,S7:()=>sr,TS:()=>id,Ux:()=>i6,VH:()=>iw,Wu:()=>sT,Z9:()=>tT,cU:()=>sd,c_:()=>tC,dz:()=>iz,ld:()=>si,qf:()=>ij,w4:()=>ih,wJ:()=>sl,xO:()=>ts});var o,n,r,l=i(63093),h=i(44015),a=i(84574);function c(t){return(11==t.nodeType?t.getSelection?t:t.ownerDocument:t).getSelection()}function d(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function u(t,e){if(!e.anchorNode)return!1;try{return d(t,e.anchorNode)}catch(t){return!1}}function f(t){return 3==t.nodeType?M(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function p(t,e,i,s){return!!i&&(g(t,e,i,s,-1)||g(t,e,i,s,1))}function m(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function g(t,e,i,s,o){for(;;){if(t==i&&e==s)return!0;if(e==(o<0?0:w(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=m(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType||1==(t=t.childNodes[e+(o<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=o<0?w(t):0}}}function w(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}let v={left:0,right:0,top:0,bottom:0};function b(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}class y{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){this.set(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}set(t,e,i,s){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=s}}let x=null;function S(t){if(t.setActive)return t.setActive();if(x)return t.focus(x);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==x?{get preventScroll(){return x={preventScroll:!0},!0}}:void 0),!x){x=!1;for(let t=0;t<e.length;){let i=e[t++],s=e[t++],o=e[t++];i.scrollTop!=s&&(i.scrollTop=s),i.scrollLeft!=o&&(i.scrollLeft=o)}}}function M(t,e,i=e){let o=s||(s=document.createRange());return o.setEnd(t,i),o.setStart(t,e),o}function k(t,e,i){let s={key:e,code:e,keyCode:i,which:i,cancelable:!0},o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let n=new KeyboardEvent("keyup",s);return n.synthetic=!0,t.dispatchEvent(n),o.defaultPrevented||n.defaultPrevented}function C(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}class A{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new A(t.parentNode,m(t),e)}static after(t,e){return new A(t.parentNode,m(t)+1,e)}}let D=[];class O{constructor(){this.parent=null,this.dom=null,this.dirty=2}get editorView(){if(!this.parent)throw Error("Accessing view in orphan content view");return this.parent.editorView}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}coordsAt(t,e){return null}sync(t){if(2&this.dirty){let e=this.dom,i=null,s;for(let o of this.children){if(o.dirty){if(!o.dom&&(s=i?i.nextSibling:e.firstChild)){let t=O.get(s);(!t||!t.parent&&t.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(t),o.dirty=0}if(s=i?i.nextSibling:e.firstChild,t&&!t.written&&t.node==e&&s!=o.dom&&(t.written=!0),o.dom.parentNode==e)for(;s&&s!=o.dom;)s=T(s);else e.insertBefore(o.dom,s);i=o.dom}for((s=i?i.nextSibling:e.firstChild)&&t&&t.node==e&&(t.written=!0);s;)s=T(s)}else if(1&this.dirty)for(let e of this.children)e.dirty&&(e.sync(t),e.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let s=0==w(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==s&&e.firstChild!=e.lastChild&&(s=t==e.firstChild?-1:1),t=e}i=s<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!O.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let s=this.children[t];if(s.dom==i)return e;e+=s.length+s.breakAfter}}domBoundsAround(t,e,i=0){let s=-1,o=-1,n=-1,r=-1;for(let l=0,h=i,a=i;l<this.children.length;l++){let i=this.children[l],c=h+i.length;if(h<t&&c>e)return i.domBoundsAround(t,e,h);if(c>=t&&-1==s&&(s=l,o=h),h>e&&i.dom.parentNode==this.dom){n=l,r=a;break}a=c,h=c+i.breakAfter}return{from:o,to:r<0?i+this.length:r,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:n<this.children.length&&n>=0?this.children[n].dom:null}}markDirty(t=!1){this.dirty|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.dirty|=2),1&e.dirty)return;e.dirty|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,this.dirty&&this.markParentsDirty(!0))}setDOM(t){this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=D){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new R(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}merge(t,e,i,s,o,n){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}}function T(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}O.prototype.breakAfter=0;class R{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function E(t,e,i,s,o,n,r,l,h){let{children:a}=t,c=a.length?a[e]:null,d=n.length?n[n.length-1]:null,u=d?d.breakAfter:r;if(!(e==s&&c&&!r&&!u&&n.length<2&&c.merge(i,o,n.length?d:null,0==i,l,h))){if(s<a.length){let t=a[s];
1t&&o<t.length?(e==s&&(t=t.split(o),o=0),!u&&d&&t.merge(0,o,d,!0,0,h)?n[n.length-1]=t:(o&&t.merge(0,o,null,!1,0,h),n.push(t))):(null==t?void 0:t.breakAfter)&&(d?d.breakAfter=1:r=1),s++}for(c&&(c.breakAfter=r,i>0&&(!r&&n.length&&c.merge(i,c.length,n[0],!1,l,0)?c.breakAfter=n.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,l,0),e++));e<s&&n.length;)if(a[s-1].become(n[n.length-1]))s--,n.pop(),h=n.length?0:l;else if(a[e].become(n[0]))e++,n.shift(),l=n.length?0:h;else break;!n.length&&e&&s<a.length&&!a[e-1].breakAfter&&a[s].merge(0,0,a[e-1],!1,l,h)&&e--,(e<s||n.length)&&t.replaceChildren(e,s,n)}}function L(t,e,i,s,o,n){let r=t.childCursor(),{i:l,off:h}=r.findPos(i,1),{i:a,off:c}=r.findPos(e,-1),d=e-i;for(let t of s)d+=t.length;t.length+=d,E(t,a,c,l,h,s,0,o,n)}let B="u">typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},V="u">typeof document?document:{documentElement:{style:{}}},H=/Edge\/(\d+)/.exec(B.userAgent),N=/MSIE \d/.test(B.userAgent),P=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(B.userAgent),F=!!(N||P||H),W=!F&&/gecko\/(\d+)/i.test(B.userAgent),z=!F&&/Chrome\/(\d+)/.exec(B.userAgent),q="webkitFontSmoothing"in V.documentElement.style,I=!F&&/Apple Computer/.test(B.vendor),K=I&&(/Mobile\/\w+/.test(B.userAgent)||B.maxTouchPoints>2);var j={mac:K||/Mac/.test(B.platform),windows:/Win/.test(B.platform),linux:/Linux|X11/.test(B.platform),ie:F,ie_version:N?V.documentMode||6:P?+P[1]:H?+H[1]:0,gecko:W,gecko_version:W?+(/Firefox\/(\d+)/.exec(B.userAgent)||[0,0])[1]:0,chrome:!!z,chrome_version:z?+z[1]:0,ios:K,android:/Android\b/.test(B.userAgent),webkit:q,safari:I,webkit_version:q?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=V.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class G extends O{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof G&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new G(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new A(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return $(this.dom,t,e)}}class _ extends O{constructor(t,e=[],i=0){for(let s of(super(),this.mark=t,this.children=e,this.length=i,e))s.setParent(this)}setAttrs(t){if(C(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.dirty|=6)}sync(t){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t)}merge(t,e,i,s,o,n){return(!i||!!(i instanceof _&&i.mark.eq(this.mark))&&(!t||!(o<=0))&&(!(e<this.length)||!(n<=0)))&&(L(this,t,e,i?i.children:[],o-1,n-1),this.markDirty(),!0)}split(t){let e=[],i=0,s=-1,o=0;for(let n of this.children){let r=i+n.length;r>t&&e.push(i<t?n.split(t-i):n),s<0&&i>=t&&(s=o),i=r,o++}let n=this.length-t;return this.length=t,s>-1&&(this.children.length=s,this.markDirty()),new _(this.mark,e,n)}domAtPos(t){return J(this,t)}coordsAt(t,e){return Z(this,t,e)}}function $(t,e,i){let s=t.nodeValue.length;e>s&&(e=s);let o=e,n=e,r=0;0==e&&i<0||e==s&&i>=0?!(j.chrome||j.gecko)&&(e?(o--,r=1):n<s&&(n++,r=-1)):i<0?o--:n<s&&n++;let l=M(t,o,n).getClientRects();if(!l.length)return v;let h=l[(r?r<0:i>=0)?0:l.length-1];return j.safari&&!r&&0==h.width&&(h=Array.prototype.find.call(l,t=>t.width)||h),r?b(h,r<0):h||null}class Y extends O{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}
1static create(t,e,i){return new(t.customView||Y)(t,e,i)}split(t){let e=Y.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,s,o,n){return(!i||i instanceof Y&&!!this.widget.compare(i.widget)&&(!(t>0)||!(o<=0))&&(!(e<this.length)||!(n<=0)))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t.length==this.length&&t instanceof Y&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.eq(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return l.EY.empty;let t=this;for(;t.parent;)t=t.parent;let e=t.editorView,i=e&&e.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):l.EY.empty}domAtPos(t){return 0==t?A.before(this.dom):A.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.dom.getClientRects(),s=null;if(!i.length)return v;for(let e=t>0?i.length-1:0;s=i[e],t>0?0!=e:e!=i.length-1&&!(s.top<s.bottom);e+=t>0?-1:1);return b(s,this.side>0)}get isEditable(){return!1}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class U extends Y{domAtPos(t){let{topView:e,text:i}=this.widget;return e?X(t,0,e,i,(t,e)=>t.domAtPos(e),t=>new A(i,Math.min(t,i.nodeValue.length))):new A(i,Math.min(t,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(t,e){let{topView:i,text:s}=this.widget;return i?function t(e,i,s,o){if(s instanceof _)for(let n of s.children){let s=0,r=d(n.dom,o);if(d(n.dom,e))return s+(r?t(e,i,n,o):n.localPosFromDOM(e,i));s+=r?o.nodeValue.length:n.length}else if(s.dom==o)return Math.min(i,o.nodeValue.length);return s.localPosFromDOM(e,i)}(t,e,i,s):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:s}=this.widget;return i?X(t,e,i,s,(t,e,i)=>t.coordsAt(e,i),(t,e)=>$(s,t,e)):$(s,t,e)}destroy(){var t;super.destroy(),null==(t=this.widget.topView)||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function X(t,e,i,s,o,n){if(i instanceof _){for(let r=i.dom.firstChild;r;r=r.nextSibling){let i=O.get(r);if(!i)return n(t,e);let l=d(r,s),h=i.length+(l?s.nodeValue.length:0);if(t<h||t==h&&0>=i.getSide())return l?X(t,e,i,s,o,n):o(i,t,e);t-=h}return o(i,i.length,-1)}return i.dom==s?n(t,e):o(i,t,e)}class Q extends O{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof Q&&t.side==this.side}split(){return new Q(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return A.before(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){let e=this.dom.getBoundingClientRect(),i=function(t,e){let i=t.parent,s=i?i.children.indexOf(t):-1;for(;i&&s>=0;)if(e<0?s>0:s<i.children.length){let t=i.children[s+e];if(t instanceof G){let i=t.coordsAt(e<0?t.length:0,e);if(i)return i}s+=e}else if(i instanceof _&&i.parent)s=i.parent.children.indexOf(i)+(e<0?0:1),i=i.parent;else{let t=i.dom.lastChild;if(t&&"BR"==t.nodeName)return t.getClientRects()[0];break}}(this,this.side>0?-1:1);return i&&i.top<e.bottom&&i.bottom>e.top?{left:e.left,right:e.right,top:i.top,bottom:i.bottom}:e}get overrideDOMText(){return l.EY.empty}}function J(t,e){let i=t.dom,{children:s}=t,o=0;for(let t=0;o<s.length;o++){let n=s[o],r=t+n.length;if(!(r==t&&0>=n.getSide())){if(e>t&&e<r&&n.dom.parentNode==i)return n.domAtPos(e-t);if(e<=t)break;t=r}}for(let t=o;t>0;t--){let e=s[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=o;t<s.length;t++){let e=s[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new A(i,0)}function Z(t,e,i){let s=null,o=-1,n=null,r=-1;!function t(e,i){for(let l=0,h=0;l<e.children.length&&h<=i;l++){let a=e.children[l],c=h+a.length;c>=i&&(a.children.length?t(a,i-h):!n&&(c>i||h==c&&a.getSide()>0)?(n=a,r=i-h):(h<i||h==c&&0>a.getSide())&&(s=a,o=i-h)),h=c}}(t,e);let l=(i<0?s:n)||s||n;return l?l.coordsAt(Math.max(0,l==s?o:r),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=f(e);return i[i.length-1]||null}(t)}function tt(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}function te(t,e){if(t==e)return!0;
1if(!t||!e)return!1;let i=Object.keys(t),s=Object.keys(e);if(i.length!=s.length)return!1;for(let o of i)if(-1==s.indexOf(o)||t[o]!==e[o])return!1;return!0}function ti(t,e,i){let s=null;if(e)for(let o in e)i&&o in i||t.removeAttribute(s=o);if(i)for(let o in i)e&&e[o]==i[o]||t.setAttribute(s=o,i[o]);return!!s}G.prototype.children=Y.prototype.children=Q.prototype.children=D;class ts{eq(t){return!1}updateDOM(t){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return -1}ignoreEvent(t){return!0}get customView(){return null}destroy(t){}}var to=((o=to||(to={}))[o.Text=0]="Text",o[o.WidgetBefore=1]="WidgetBefore",o[o.WidgetAfter=2]="WidgetAfter",o[o.WidgetRange=3]="WidgetRange",o);class tn extends l.FB{constructor(t,e,i,s){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(t){return new tr(t)}static widget(t){let e=t.side||0,i=!!t.block;return new th(t,e+=i?e>0?3e8:-4e8:e>0?1e8:-1e8,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,s;if(t.isBlockGap)i=-5e8,s=4e8;else{let{start:o,end:n}=ta(t,e);i=(o?e?-3e8:-1:5e8)-1,s=(n?e?2e8:1:-6e8)+1}return new th(t,i,s,e,t.widget||null,!0)}static line(t){return new tl(t)}static set(t,e=!1){return l.om.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}tn.none=l.om.empty;class tr extends tn{constructor(t){let{start:e,end:i}=ta(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){return this==t||t instanceof tr&&this.tagName==t.tagName&&this.class==t.class&&te(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw RangeError("Mark decorations may not be empty");return super.range(t,e)}}tr.prototype.point=!1;class tl extends tn{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof tl&&te(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}tl.prototype.mapMode=l.iR.TrackBefore,tl.prototype.point=!0;class th extends tn{constructor(t,e,i,s,o,n){super(e,i,o,t),this.block=s,this.isReplace=n,this.mapMode=s?e<=0?l.iR.TrackBefore:l.iR.TrackAfter:l.iR.TrackDel}get type(){return this.startSide<this.endSide?to.WidgetRange:this.startSide<=0?to.WidgetBefore:to.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}eq(t){var e,i;return t instanceof th&&(e=this.widget,e==(i=t.widget)||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function ta(t,e=!1){let{inclusiveStart:i,inclusiveEnd:s}=t;return null==i&&(i=t.inclusive),null==s&&(s=t.inclusive),{start:null!=i?i:e,end:null!=s?s:e}}function tc(t,e,i,s=0){let o=i.length-1;o>=0&&i[o]+s>=t?i[o]=Math.max(i[o],e):i.push(t,e)}th.prototype.point=!0;class td extends O{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,s,o,n){if(i){if(!(i instanceof td))return!1;this.dom||i.transferDOM(this)}return s&&this.setDeco(i?i.attrs:null),L(this,t,e,i?i.children:[],o,n),!0}split(t){let e=new td;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:s}=this.childPos(t);s&&(e.append(this.children[i].split(s),0),this.children[i].merge(s,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){te(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){!function t(e,i,s){let o,{children:n}=e;s>0&&i instanceof _&&n.length&&(o=n[n.length-1])instanceof _&&o.mark.eq(i.mark)?t(o,i.children[0],s-1):(n.push(i),i.setParent(e)),e.length+=i.length}(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=tt(e,this.attrs||{})),i&&(this.attrs=tt({class:i},this.attrs||{}))}domAtPos(t){return J(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t){var e;
1this.dom?4&this.dirty&&(C(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(ti(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t);let i=this.dom.lastChild;for(;i&&O.get(i)instanceof _;)i=i.lastChild;if(!i||!this.length||"BR"!=i.nodeName&&(null==(e=O.get(i))?void 0:e.isEditable)==!1&&(!j.ios||!this.children.some(t=>t instanceof G))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t=0;for(let e of this.children){if(!(e instanceof G)||/[^ -~]/.test(e.text))return null;let i=f(e.dom);if(1!=i.length)return null;t+=i[0].width}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length}:null}coordsAt(t,e){return Z(this,t,e)}become(t){return!1}get type(){return to.Text}static find(t,e){for(let i=0,s=0;i<t.children.length;i++){let o=t.children[i],n=s+o.length;if(n>=e){if(o instanceof td)return o;if(n>e)break}s=n+o.breakAfter}return null}}class tu extends O{constructor(t,e,i){super(),this.widget=t,this.length=e,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,s,o,n){return(!i||i instanceof tu&&!!this.widget.compare(i.widget)&&(!(t>0)||!(o<=0))&&(!(e<this.length)||!(n<=0)))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?A.before(this.dom):A.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new tu(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return D}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):l.EY.empty}domBoundsAround(){return null}become(t){return t instanceof tu&&t.type==this.type&&t.widget.constructor==this.widget.constructor&&(t.widget.eq(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class tf{constructor(t,e,i,s){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!t.breakAfter&&!(t instanceof tu&&t.type==to.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new td),this.atCursorPos=!0),this.curLine}flushBuffer(t){this.pendingBuffer&&(this.curLine.append(tp(new Q(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer([]),this.curLine=null,this.content.push(t)}finish(t){t?this.pendingBuffer=0:this.flushBuffer([]),this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:s}=this.cursor.next(this.skip);if(this.skip=0,s)throw Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer([]),this.curLine=null,t--;continue}this.text=e,this.textOff=0}let s=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(0,i)),this.getLine().append(tp(new G(this.text.slice(this.textOff,this.textOff+s)),e),i),this.atCursorPos=!0,this.textOff+=s,t-=s,i=0}}span(t,e,i,s){this.buildText(e-t,i,s),this.pos=e,this.openStart<0&&(this.openStart=s)}
1point(t,e,i,s,o,n){if(this.disallowBlockEffectsFor[n]&&i instanceof th){if(i.block)throw RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof th)if(i.block){let{type:t}=i;t!=to.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new tu(i.widget||new tm("div"),r,t))}else{let n=Y.create(i.widget||new tm("span"),r,r?0:i.startSide),l=this.atCursorPos&&!n.isEditable&&o<=s.length&&(t<e||i.startSide>0),h=!n.isEditable&&(t<e||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||l||(this.pendingBuffer=0),this.flushBuffer(s),l&&(a.append(tp(new Q(1),s),o),o=s.length+Math.max(0,o-s.length)),a.append(tp(n,s),o),this.atCursorPos=h,this.pendingBuffer=h?t<e?1:2:0}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=o)}static build(t,e,i,s,o){let n=new tf(t,e,i,o);return n.openEnd=l.om.spans(s,e,i,n),n.openStart<0&&(n.openStart=n.openEnd),n.finish(n.openEnd),n}}function tp(t,e){for(let i of e)t=new _(i,[t],t.length);return t}class tm extends ts{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}}let tg=l.sj.define(),tw=l.sj.define(),tv=l.sj.define(),tb=l.sj.define(),ty=l.sj.define(),tx=l.sj.define(),tS=l.sj.define({combine:t=>t.some(t=>t)});class tM{constructor(t,e="nearest",i="nearest",s=5,o=5){this.range=t,this.y=e,this.x=i,this.yMargin=s,this.xMargin=o}map(t){return t.empty?this:new tM(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}let tk=l.Pe.define({map:(t,e)=>t.map(e)});function tC(t,e,i){let s=t.facet(tb);s.length?s[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}let tA=l.sj.define({combine:t=>!t.length||t[0]}),tD=0,tO=l.sj.define();class tT{constructor(t,e,i,s){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=s(this)}static define(t,e){let{eventHandlers:i,provide:s,decorations:o}=e||{};return new tT(tD++,t,i,t=>{let e=[tO.of(t)];return o&&e.push(tB.of(e=>{let i=e.plugin(t);return i?o(i):tn.none})),s&&e.push(s(t)),e})}static fromClass(t,e){return tT.define(e=>new t(e),e)}}class tR{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(tC(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){tC(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null==(e=this.value)?void 0:e.destroy)try{this.value.destroy()}catch(e){tC(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}let tE=l.sj.define(),tL=l.sj.define(),tB=l.sj.define(),tV=l.sj.define(),tH=l.sj.define(),tN=l.sj.define();class tP{constructor(t,e,i,s){this.fromA=t,this.toA=e,this.fromB=i,this.toB=s}join(t){return new tP(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let s=t[e-1];if(!(s.fromA>i.toA)){if(s.toA<i.fromA)break;i=i.join(s),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let s=0,o=0,n=0,r=0;;s++){let l=s==t.length?null:t[s],h=n-r,a=l?l.fromB:1e9;for(;o<e.length&&e[o]<a;){let t=e[o],s=e[o+1],n=Math.max(r,t),l=Math.min(a,s);if(n<=l&&new tP(n+h,l+h,n,l).addToSet(i),s>a)break;o+=2}if(!l)return i;new tP(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),n=l.toA,r=l.toB}}}class tF{constructor(t,e,i){for(let s of(this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=l.VR.empty(this.startState.doc.length),i))this.changes=this.changes.compose(s.changes);let s=[];this.changes.iterChangedRanges((t,e,i,o)=>s.push(new tP(t,e,i,o))),this.changedRanges=s;let o=t.hasFocus;o!=t.inputState.notifiedFocused&&(t.inputState.notifiedFocused=o,this.flags|=1)}static create(t,e,i){return new tF(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}var tW=((n=tW||(tW={}))[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n);let tz=tW.LTR,tq=tW.RTL;function tI(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<t[i]);return e}let tK=tI("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),tj=tI("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),tG=Object.create(null),t_=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);tG[e]=i,tG[i]=-e}let t$=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class tY{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?tq:tz}side(t,e){return this.dir==e==t?this.to:this.from}static find(t,e,i,s){let o=-1;for(let n=0;n<t.length;n++){let r=t[n];if(r.from<=e&&r.to>=e){if(r.level==i)return n;(o<0||(0!=s?s<0?r.from<e:r.to>e:t[o].level>r.level))&&(o=n)}}if(o<0)throw RangeError("Index out of range");return o}}let tU=[];function tX(t){return[new tY(0,t,0)]}let tQ="";class tJ{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(l.$t.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+="ï¿¿"}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let s=t;;){this.findPointBefore(i,s),this.readNode(s);let t=s.nextSibling;if(t==e)break;let o=O.get(s),n=O.get(t);(o&&n?o.breakAfter:(o?o.breakAfter:tZ(s))||tZ(t)&&("BR"!=s.nodeName||s.cmIgnore))&&this.lineBreak(),s=t}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,n=1,r;if(this.lineSeparator?(o=e.indexOf(this.lineSeparator,i),n=this.lineSeparator.length):(r=s.exec(e))&&(o=r.index,n=r[0].length),this.append(e.slice(i,o<0?e.length:o)),o<0)break;if(this.lineBreak(),n>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=n-1);i=o+n}}readNode(t){if(t.cmIgnore)return;let e=O.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+Math.min(e,i.offset))}}function tZ(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.no
1deName)}class t0{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class t1 extends O{constructor(t){super(),this.view=t,this.compositionDeco=tn.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new td],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new tP(0,0,0,t.state.doc.length)],0)}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(t){var e,i,s;let o,n=t.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=tn.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=function(t,e){let i=t8(t);if(!i)return tn.none;let{from:s,to:o,node:n,text:r}=i,l=e.mapPos(s,1),h=Math.max(l,e.mapPos(o,-1)),{state:a}=t,c=3==n.nodeType?n.nodeValue:new tJ([],a).readRange(n.firstChild,null).text;if(h-l<c.length)if(a.doc.sliceString(l,Math.min(a.doc.length,l+c.length),"ï¿¿")==c)h=l+c.length;else{if(a.doc.sliceString(Math.max(0,h-c.length),h,"ï¿¿")!=c)return tn.none;l=h-c.length}else if(a.doc.sliceString(l,h,"ï¿¿")!=c)return tn.none;let d=O.get(n);return d instanceof U?d=d.widget.topView:d&&(d.parent=null),tn.set(tn.replace({widget:new t3(n,r,d),inclusive:!0}).range(l,h))}(this.view,t.changes)),(j.ie||j.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=(e=this.decorations,i=this.updateDeco(),s=t.changes,o=new t4,l.om.compare(e,i,s,o),o.changes);return n=tP.extendWithRanges(n,r),(0!=this.dirty||0!=n.length)&&(this.updateInner(n,t.startState.doc.length),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e);let{observer:i}=this.view;i.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=j.chrome||j.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(t),this.dirty=0,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof tu&&t.widget instanceof t2&&s.push(t.dom);i.updateGaps(s)}updateChildren(t,e){let i=this.childCursor(e);for(let e=t.length-1;;e--){let s=e>=0?t[e]:null;if(!s)break;let{fromA:o,toA:n,fromB:r,toB:l}=s,{content:h,breakAtStart:a,openStart:c,openEnd:d}=tf.build(this.view.state.doc,r,l,this.decorations,this.dynamicDecorationMap),{i:u,off:f}=i.findPos(n,1),{i:p,off:m}=i.findPos(o,-1);E(this,p,m,u,f,h,a,c,d)}}updateSelection(t=!1,e=!1){var i;if((t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange(),!(e||this.mayControlSelection()))return;let s=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,n=this.domAtPos(o.anchor),r=o.empty?n:this.domAtPos(o.head);if(j.gecko&&o.empty&&1==(i=n).node.nodeType&&i.node.firstChild&&(0==i.offset||"false"==i.node.childNodes[i.offset-1].contentEditable)&&(i.offset==i.node.childNodes.length||"false"==i.node.childNodes[i.offset].contentEditable)){let t=document.createTextNode("");this.view.observer.ignore(()=>n.node.insertBefore(t,n.node.childNodes[n.offset]||null)),n=r=new A(t,0),s=!0}let l=this.view.observer.selectionRange;!s&&l.focusNode&&p(n.node,n.offset,l.anchorNode,l.anchorOffset)&&p(r.node,r.offset,l.focusNode,l.focusOffset)||(this.view.observer.ignore(()=>{j.android&&j.chrome&&this.dom.contains(l.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(l.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=c(this.view.root);
1if(t)if(o.empty){if(j.gecko){var e,i;let t=(e=n.node,i=n.offset,1!=e.nodeType?0:(i&&"false"==e.childNodes[i-1].contentEditable?1:0)|2*(i<e.childNodes.length&&"false"==e.childNodes[i].contentEditable));if(t&&3!=t){let e=t9(n.node,n.offset,1==t?1:-1);e&&(n=new A(e,1==t?0:e.nodeValue.length))}}t.collapse(n.node,n.offset),null!=o.bidiLevel&&null!=l.cursorBidiLevel&&(l.cursorBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(n.node,n.offset);try{t.extend(r.node,r.offset)}catch(t){}}else{let e=document.createRange();o.anchor>o.head&&([n,r]=[r,n]),e.setEnd(r.node,r.offset),e.setStart(n.node,n.offset),t.removeAllRanges(),t.addRange(e)}}),this.view.observer.setSelectionRange(n,r)),this.impreciseAnchor=n.precise?null:new A(l.anchorNode,l.anchorOffset),this.impreciseHead=r.precise?null:new A(l.focusNode,l.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let t=this.view.state.selection.main,e=c(this.view.root);if(!e||!t.empty||!t.assoc||!e.modify)return;let i=td.find(this,t.head);if(!i)return;let s=i.posAtStart;if(t.head==s||t.head==s+i.length)return;let o=this.coordsAt(t.head,-1),n=this.coordsAt(t.head,1);if(!o||!n||o.bottom>n.top)return;let r=this.domAtPos(t.head+t.assoc);e.collapse(r.node,r.offset),e.modify("move",t.assoc<0?"forward":"backward","lineboundary")}mayControlSelection(){let t=this.view.root.activeElement;return t==this.dom||u(this.dom,this.view.observer.selectionRange)&&!(t&&this.dom.contains(t))}nearest(t){for(let e=t;e;){let t=O.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof td)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){for(let i=this.length,s=this.children.length-1;;s--){let o=this.children[s],n=i-o.breakAfter-o.length;if(t>n||t==n&&o.type!=to.WidgetBefore&&o.type!=to.WidgetAfter&&(!s||2==e||this.children[s-1].breakAfter||this.children[s-1].type==to.WidgetBefore&&e>-2))return o.coordsAt(t-n,e);i=n}}measureVisibleLineHeights(t){let e=[],{from:i,to:s}=t,o=this.view.contentDOM.clientWidth,n=o>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,l=this.view.textDirection==tW.LTR;for(let t=0,h=0;h<this.children.length;h++){let a=this.children[h],c=t+a.length;if(c>s)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),n){let e=a.dom.lastChild,s=e?f(e):[];if(s.length){let e=s[s.length-1],n=l?e.right-i.left:i.right-e.left;n>r&&(r=n,this.minWidth=o,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?tW.RTL:tW.LTR}measureTextSize(){for(let t of this.children)if(t instanceof td){let e=t.measureTextSize();if(e)return e}let t=document.createElement("div"),e,i;return t.className="cm-line",t.style.width="99999px",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(t);let s=f(t.firstChild)[0];e=t.getBoundingClientRect().height,i=s?s.width/27:7,t.remove()}),{lineHeight:e,charWidth:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new R(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,s=0;;s++){let o=s==e.viewports.length?null:e.viewports[s],n=o?o.from-1:this.length;if(n>i){let s=e.lineBlockAt(n).bottom-e.lineBlockAt(i).top;t.push(tn.replace({widget:new t2(s),block:!0,inclusive:!0,isBlockGap:!0}).range(i,n))}if(!o)break;i=o.to+1}return tn.set(t)}updateDeco(){let t=this.view.state.facet(tB).map((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t);for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){let{range:e}=t,i=this.coordsAt(e.head,e.empty?e.assoc:e.head>e.anchor?-1:1),s;if(!i)return;!e.empty&&(s=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let o=0,n=0,r=0,l=0;for(let t of this.view.state.facet(tH).map(t=>t(this.view)))if(t){let{left:e,right:i,top:s,bottom:h}=t;null!=e&&(o=Math.max(o,e)),null!=i&&(n=Math.max(n,i)),null!=s&&(r=Math.max(r,s)),null!=h&&(l=Math.max(l,h))}let h={left:i.left-o,top:i.top-r,right:i.right+n,bottom:i.bottom+l};
1!function(t,e,i,s,o,n,r,l){let h=t.ownerDocument,a=h.defaultView||window;for(let c=t;c;)if(1==c.nodeType){let t,d=c==h.body;if(d)t={left:0,right:a.innerWidth,top:0,bottom:a.innerHeight};else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();t={left:e.left,right:e.left+c.clientWidth,top:e.top,bottom:e.top+c.clientHeight}}let u=0,f=0;if("nearest"==o)e.top<t.top?(f=-(t.top-e.top+r),i>0&&e.bottom>t.bottom+f&&(f=e.bottom-t.bottom+f+r)):e.bottom>t.bottom&&(f=e.bottom-t.bottom+r,i<0&&e.top-f<t.top&&(f=-(t.top+f-e.top+r)));else{let s=e.bottom-e.top,n=t.bottom-t.top;f=("center"==o&&s<=n?e.top+s/2-n/2:"start"==o||"center"==o&&i<0?e.top-r:e.bottom-n+r)-t.top}if("nearest"==s?e.left<t.left?(u=-(t.left-e.left+n),i>0&&e.right>t.right+u&&(u=e.right-t.right+u+n)):e.right>t.right&&(u=e.right-t.right+n,i<0&&e.left<t.left+u&&(u=-(t.left+u-e.left+n))):u=("center"==s?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==s==l?e.left-n:e.right-(t.right-t.left)+n)-t.left,u||f)if(d)a.scrollBy(u,f);else{let t=0,i=0;if(f){let t=c.scrollTop;c.scrollTop+=f,i=c.scrollTop-t}if(u){let e=c.scrollLeft;c.scrollLeft+=u,t=c.scrollLeft-e}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&1>Math.abs(t-u)&&(s="nearest"),i&&1>Math.abs(i-f)&&(o="nearest")}if(d)break;c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,h,e.head<e.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==tW.LTR)}}class t2 extends ts{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}function t8(t){let e=t.observer.selectionRange,i=e.focusNode&&t9(e.focusNode,e.focusOffset,0);if(!i)return null;let s=t.docView.nearest(i);if(!s)return null;if(s instanceof td){let t=i;for(;t.parentNode!=s.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!O.get(e);)e=e.previousSibling;let o=e?O.get(e).posAtEnd:s.posAtStart;return{from:o,to:o,node:t,text:i}}{for(;;){let{parent:t}=s;if(!t)return null;if(t instanceof td)break;s=t}let t=s.posAtStart;return{from:t,to:t+s.length,node:s.dom,text:i}}}class t3 extends ts{constructor(t,e,i){super(),this.top=t,this.text=e,this.topView=i}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return U}}function t9(t,e,i){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0&&i<=0)e=w(t=t.childNodes[e-1]);else{if(1!=t.nodeType||!(e<t.childNodes.length)||!(i>=0))return null;t=t.childNodes[e],e=0}}}class t4{constructor(){this.changes=[]}compareRange(t,e){tc(t,e,this.changes)}comparePoint(t,e){tc(t,e,this.changes)}}function t5(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function t6(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function t7(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function et(t,e,i){let s=t.nodeValue.length,o=-1,n=1e9,r=0;for(let l=0;l<s;l++){let s=M(t,l,l+1).getClientRects();for(let h=0;h<s.length;h++){let a=s[h];if(a.top==a.bottom)continue;r||(r=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<n){let i=e>=(a.left+a.right)/2,s=i;if((j.chrome||j.gecko)&&M(t,l).getBoundingClientRect().left==a.right&&(s=!i),c<=0)return{node:t,offset:l+ +!!s};o=l+ +!!s,n=c}}}return{node:t,offset:o>-1?o:r>0?t.nodeValue.length:0}}function ee(t,{x:e,y:i},s,o=-1){var n;let r=t.contentDOM.getBoundingClientRect(),l=r.top+t.viewState.paddingTop,h,{docHeight:a}=t.viewState,c=i-l;if(c<0)return 0;if(c>a)return t.state.doc.length;for(let e=t.defaultLineHeight/2,i=!1;(h=t.elementAtHeight(c)).type!=to.Text;)for(;!((c=o>0?h.bottom+e:h.top-e)>=0)||!(c<=a);){if(i)return s?null:0;i=!0,o=-o}i=l+c;let d=h.from;if(d<t.viewport.from)return 0==t.viewport.from?0:s?null:ei(t,r,h,e,i);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:s?null:ei(t,r,h,e,i);let u=t.dom.ownerDocument,p=t.root.elementFromPoint?t.root:u,m=p.elementFromPoint(e,i);m&&!t.contentDOM.contains(m)&&(m=null),!m&&(e=Math.max(r.left+1,Math.min(r.right-1,e)),(m=p.elementFromPoint(e,i))&&!t.contentDOM.contains(m)&&(m=null));let g,w=-1;if(m&&(null==(n=t.docView.nearest(m))?void 0:n.isEditable)!=!1){if(u.caretPositionFromPoint){let t=u.caretPositionFromPoint(e,i);t&&({offsetNode:g,offset:w}=t)}else if(u.caretRangeFromPoint){let s=u.caretRangeFromPoint(e,i);s&&({startContainer:g,startOffset:w}
1=s,(!t.contentDOM.contains(g)||j.safari&&function(t,e,i){let s;if(3!=t.nodeType||e!=(s=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return M(t,s-1,s).getBoundingClientRect().left>i}(g,w,e)||j.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}return i-(1==t.nodeType?t.getBoundingClientRect():M(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}(g,w,e))&&(g=void 0))}}if(!g||!t.docView.dom.contains(g)){let s=td.find(t.docView,d);if(!s)return c>h.top+h.height/2?h.to:h.from;({node:g,offset:w}=function t(e,i,s){let o,n,r,l,h,a,c,d,u=!1;for(let g=e.firstChild;g;g=g.nextSibling){let e=f(g);for(let f=0;f<e.length;f++){var p,m;let w=e[f];a&&t5(a,w)&&(w=t6(t7(w,a.bottom),a.top));let v=(p=w).left>i?p.left-i:Math.max(0,i-p.right),b=(m=w).top>s?m.top-s:Math.max(0,s-m.bottom);if(0==v&&0==b)return 3==g.nodeType?et(g,i,s):t(g,i,s);(!h||d>b||d==b&&c>v)&&(h=g,a=w,c=v,d=b,u=!v||(v>0?f<e.length-1:f>0)),0==v?s>w.bottom&&(!r||r.bottom<w.bottom)?(o=g,r=w):s<w.top&&(!l||l.top>w.top)&&(n=g,l=w):r&&t5(r,w)?r=t7(r,w.bottom):l&&t5(l,w)&&(l=t6(l,w.top))}}if(r&&r.bottom>=s?(h=o,a=r):l&&l.top<=s&&(h=n,a=l),!h)return{node:e,offset:0};let g=Math.max(a.left,Math.min(a.right,i));if(3==h.nodeType)return et(h,g,s);if(u&&"false"!=h.contentEditable)return t(h,g,s);let w=Array.prototype.indexOf.call(e.childNodes,h)+ +(i>=(a.left+a.right)/2);return{node:e,offset:w}}(s.dom,e,i))}return t.docView.posFromDOM(g,w)}function ei(t,e,i,s,o){let n=Math.round((s-e.left)*t.defaultCharacterWidth);t.lineWrapping&&i.height>1.5*t.defaultLineHeight&&(n+=Math.floor((o-i.top)/t.defaultLineHeight)*t.viewState.heightOracle.lineLength);let r=t.state.sliceDoc(i.from,i.to);return i.from+(0,l.kn)(r,n,t.state.tabSize)}function es(t,e,i,s){let o=t.state.doc.lineAt(e.head),n=t.bidiSpans(o),r=t.textDirectionAt(o.from);for(let h=e,a=null;;){let e=function(t,e,i,s,o){var n;let r=s.head-t.from,h=-1;if(0==r){if(!o||!t.length)return null;e[0].level!=i&&(r=e[0].side(!1,i),h=0)}else if(r==t.length){if(o)return null;let t=e[e.length-1];t.level!=i&&(r=t.side(!0,i),h=e.length-1)}h<0&&(h=tY.find(e,r,null!=(n=s.bidiLevel)?n:-1,s.assoc));let a=e[h];r==a.side(o,i)&&(r=(a=e[h+=o?1:-1]).side(!o,i));let c=o==(a.dir==i),d=(0,l.zK)(t.text,r,c);if(tQ=t.text.slice(Math.min(r,d),Math.max(r,d)),d!=a.side(o,i))return l.OF.cursor(d+t.from,c?-1:1,a.level);let u=h==(o?e.length-1:0)?null:e[h+(o?1:-1)];return u||a.level==i?u&&u.level<a.level?l.OF.cursor(u.side(!o,i)+t.from,o?1:-1,u.level):l.OF.cursor(d+t.from,o?-1:1,a.level):l.OF.cursor(o?t.to:t.from,o?-1:1,i)}(o,n,r,h,i),c=tQ;if(!e){if(o.number==(i?t.state.doc.lines:1))return h;c="\n",o=t.state.doc.line(o.number+(i?1:-1)),n=t.bidiSpans(o),e=l.OF.cursor(i?o.from:o.to)}if(a){if(!a(c))return h}else{if(!s)return e;a=s(c)}h=e}}function eo(t,e,i){let s=t.state.facet(tV).map(e=>e(t));for(;;){let t=!1;for(let o of s)o.between(i.from-1,i.from+1,(s,o,n)=>{i.from>s&&i.from<o&&(i=e.head>i.from?l.OF.cursor(s,1):l.OF.cursor(o,-1),t=!0)});if(!t)return i}}class en{constructor(t){for(let e in this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.mouseSelection=null,ed){let i=ed[e];t.contentDOM.addEventListener(e,s=>{!ec(t,s)||this.ignoreDuringComposition(s)||"keydown"==e&&this.keydown(t,s)||(this.mustFlushObserver(s)&&t.observer.forceFlush(),this.runCustomHandlers(e,t,s)?s.preventDefault():i(t,s))},eu[e]),this.registeredEvents.push(e)}j.chrome&&102==j.chrome_version&&t.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?t.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,t.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=t.hasFocus,j.safari&&t.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t,e){var i;let s;for(let o of(this.customHandlers=[],e))if(s=null==(i=o.update(t).spec)?void 0:i.domEventHandlers)for(let e in this.customHandlers.push({plugin:o.value,handlers:s}),s)0>this.registeredEvents.indexOf(e)&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,i=>{ec(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()}))}runCustomHandlers(t,e,i){for(let s of this.customHandlers){let o=s.handlers[t];
1if(o)try{if(o.call(s.plugin,i,e)||i.defaultPrevented)return!0}catch(t){tC(e.state,t)}}return!1}runScrollHandlers(t,e){for(let i of(this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft,this.customHandlers)){let s=i.handlers.scroll;if(s)try{s.call(i.plugin,e,t)}catch(e){tC(t.state,e)}}}keydown(t,e){let i;return this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!!(9==e.keyCode&&Date.now()<this.lastEscPress+2e3)||(j.android&&j.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode)?(t.observer.delayAndroidKey(e.key,e.keyCode),!0):!!(j.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((i=er.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||el.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey))&&(this.pendingIOSKey=i||e,setTimeout(()=>this.flushIOSKey(t),250),!0))}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,k(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(j.safari&&!j.ios&&Date.now()-this.compositionEndedAt<100)&&(this.compositionEndedAt=0,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}let er=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],el="dthko",eh=[16,17,18,20,91,92,224,225];class ea{constructor(t,e,i,s){this.view=t,this.style=i,this.mustSelect=s,this.lastEvent=e;let o=t.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(l.$t.allowMultipleSelections)&&function(t,e){let i=t.state.facet(tg);return i.length?i[0](e):j.mac?e.metaKey:e.ctrlKey}(t,e),this.dragMove=function(t,e){let i=t.state.facet(tw);return i.length?i[0](e):j.mac?!e.altKey:!e.ctrlKey}(t,e),this.dragging=!!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let s=c(t.root);if(!s||0==s.rangeCount)return!0;let o=s.getRangeAt(0).getClientRects();for(let t=0;t<o.length;t++){let i=o[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)&&1==eM(e)&&null,!1===this.dragging&&(e.preventDefault(),this.select(e))}move(t){if(0==t.buttons)return this.destroy();!1===this.dragging&&this.select(this.lastEvent=t)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}select(t){let e=this.style.get(t,this.extend,this.multiple);(this.mustSelect||!e.eq(this.view.state.selection)||e.main.assoc!=this.view.state.selection.main.assoc)&&this.view.dispatch({selection:e,userEvent:"select.pointer",scrollIntoView:!0}),this.mustSelect=!1}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function ec(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i=e.target,s;i!=t.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(s=O.get(i))&&s.ignoreEvent(e))return!1;return!0}let ed=Object.create(null),eu=Object.create(null),ef=j.ie&&j.ie_version<15||j.ios&&j.webkit_version<604;function ep(t,e){let{state:i}=t,s,o=1,n=i.toText(e),r=n.lines==i.selection.ranges.length;if(null!=eC&&i.selection.ranges.every(t=>t.empty)&&eC==n.toString()){let t=-1;s=i.changeByRange(s=>{let h=i.doc.lineAt(s.from);if(h.from==t)return{range:s};t=h.from;let a=i.toText((r?n.line(o++).text:e)+i.lineBreak);return{changes:{from:h.from,insert:a},range:l.OF.cursor(s.from+a.length)}})}else s=r?i.changeByRange(t=>{let e=n.line(o++);return{changes:{from:t.from,to:t.to,insert:e.text},range:l.OF.cursor(t.from+e.length)}}):i.replaceSelection(n);t.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}function em(t,e,i,s){if(1==s)return l.OF.cursor(e,i);
1{if(2==s)return function(t,e,i=1){let s=t.charCategorizer(e),o=t.doc.lineAt(e),n=e-o.from;if(0==o.length)return l.OF.cursor(e);0==n?i=1:n==o.length&&(i=-1);let r=n,h=n;i<0?r=(0,l.zK)(o.text,n,!1):h=(0,l.zK)(o.text,n);let a=s(o.text.slice(r,h));for(;r>0;){let t=(0,l.zK)(o.text,r,!1);if(s(o.text.slice(t,r))!=a)break;r=t}for(;h<o.length;){let t=(0,l.zK)(o.text,h);if(s(o.text.slice(h,t))!=a)break;h=t}return l.OF.range(r+o.from,h+o.from)}(t.state,e,i);let o=td.find(t.docView,e),n=t.state.doc.lineAt(o?o.posAtEnd:e),r=o?o.posAtStart:n.from,h=o?o.posAtEnd:n.to;return h<t.state.doc.length&&h==n.to&&h++,l.OF.range(r,h)}}ed.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode?t.inputState.lastEscPress=Date.now():0>eh.indexOf(e.keyCode)&&(t.inputState.lastEscPress=0)},ed.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},ed.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},eu.touchstart=eu.touchmove={passive:!0},ed.mousedown=(t,e)=>{var i,s;let o,n,r,h,a;if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let c=null;for(let i of t.state.facet(tv))if(c=i(t,e))break;if(c||0!=e.button||(o=ev(i=t,s=e),n=eM(s),r=i.state.selection,h=o,a=s,c={update(t){t.docChanged&&(o.pos=t.changes.mapPos(o.pos),r=r.map(t.changes),a=null)},get(t,e,s){let c;a&&t.clientX==a.clientX&&t.clientY==a.clientY?c=h:(c=h=ev(i,t),a=t);let d=em(i,c.pos,c.bias,n);if(o.pos!=c.pos&&!e){let t=em(i,o.pos,o.bias,n),e=Math.min(t.from,d.from),s=Math.max(t.to,d.to);d=e<d.from?l.OF.range(e,s):l.OF.range(s,e)}if(e)return r.replaceRange(r.main.extend(d.from,d.to));if(s&&r.ranges.length>1&&r.ranges.some(t=>t.eq(d))){var u=r,f=d;for(let t=0;;t++)if(u.ranges[t].eq(f))return l.OF.create(u.ranges.slice(0,t).concat(u.ranges.slice(t+1)),u.mainIndex==t?0:u.mainIndex-(u.mainIndex>t));return}return s?r.addRange(d):l.OF.create([d])}}),c){let i=t.root.activeElement!=t.contentDOM;i&&t.observer.ignore(()=>S(t.contentDOM)),t.inputState.startMouseSelection(new ea(t,e,c,i))}};let eg=(t,e)=>t>=e.top&&t<=e.bottom,ew=(t,e,i)=>eg(e,i)&&t>=i.left&&t<=i.right;function ev(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:function(t,e,i,s){let o=td.find(t.docView,e);if(!o)return 1;let n=e-o.posAtStart;if(0==n)return 1;if(n==o.length)return -1;let r=o.coordsAt(n,-1);if(r&&ew(i,s,r))return -1;let l=o.coordsAt(n,1);return l&&ew(i,s,l)?1:r&&eg(s,r)?-1:1}(t,i,e.clientX,e.clientY)}}let eb=j.ie&&j.ie_version<=11,ey=null,ex=0,eS=0;function eM(t){if(!eb)return t.detail;let e=ey,i=eS;return ey=t,eS=Date.now(),ex=!e||i>Date.now()-400&&2>Math.abs(e.clientX-t.clientX)&&2>Math.abs(e.clientY-t.clientY)?(ex+1)%3:1}function ek(t,e,i,s){if(!i)return;let o=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:n}=t.inputState,r=s&&n&&n.dragging&&n.dragMove?{from:n.dragging.from,to:n.dragging.to}:null,l={from:o,insert:i},h=t.state.changes(r?[r,l]:l);t.focus(),t.dispatch({changes:h,selection:{anchor:h.mapPos(o,-1),head:h.mapPos(o,1)},userEvent:r?"move.drop":"input.drop"})}ed.dragstart=(t,e)=>{let{selection:{main:i}}=t.state,{mouseSelection:s}=t.inputState;s&&(s.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},ed.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let i=e.dataTransfer.files;if(i&&i.length){e.preventDefault();let s=Array(i.length),o=0,n=()=>{++o==i.length&&ek(t,e,s.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=n,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(s[t]=e.result),n()},e.readAsText(i[t])}}else ek(t,e,e.dataTransfer.getData("Text"),!0)},ed.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=ef?null:e.clipboardData;i?(ep(t,i.getData("text/plain")),e.preventDefault()):function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),ep(t,i.value)},50)}(t)};let eC=null;function eA(t){setTimeout(()=>{t.hasFocus!=t.inputState.notifiedFocused&&t.update([])},10)}ed.copy=ed.cut=(t,e)=>{let{text:i,ranges:s,linewise:o}=function(t){let e=[],i=[],s=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),i.push(s));if(!e.length){let o=-1;for(let{from:s}
1of t.selection.ranges){let n=t.doc.lineAt(s);n.number>o&&(e.push(n.text),i.push({from:n.from,to:Math.min(t.doc.length,n.to+1)})),o=n.number}s=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:s}}(t.state);if(!i&&!o)return;eC=o?i:null;let n=ef?null:e.clipboardData;n?(e.preventDefault(),n.clearData(),n.setData("text/plain",i)):function(t,e){let i=t.dom.parentNode;if(!i)return;let s=i.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=e,s.focus(),s.selectionEnd=e.length,s.selectionStart=0,setTimeout(()=>{s.remove(),t.focus()},50)}(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"})},ed.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),eA(t)},ed.blur=t=>{t.observer.clearSelectionRange(),eA(t)},ed.compositionstart=ed.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},ed.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionFirstChange=null,j.chrome&&j.android&&t.observer.flushSoon(),setTimeout(()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])},50)},ed.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},ed.beforeinput=(t,e)=>{var i;let s;if(j.chrome&&j.android&&(s=er.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.key)){let e=(null==(i=window.visualViewport)?void 0:i.height)||0;setTimeout(()=>{var i;((null==(i=window.visualViewport)?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}};let eD=["pre-wrap","normal","pre-line","break-spaces"];class eO{constructor(){this.doc=l.EY.empty,this.lineWrapping=!1,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength)),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return eD.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let s=t[i];s<0?i++:this.heightSamples[Math.floor(10*s)]||(e=!0,this.heightSamples[Math.floor(10*s)]=!0)}return e}refresh(t,e,i,s,o){let n=eD.indexOf(t)>-1,r=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=n;if(this.lineWrapping=n,this.lineHeight=e,this.charWidth=i,this.lineLength=s,r){this.heightSamples={};for(let t=0;t<o.length;t++){let e=o[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return r}}class eT{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class eR{constructor(t,e,i,s,o){this.from=t,this.length=e,this.top=i,this.height=s,this.type=o}get to(){return this.from+this.length}get bottom(){return this.top+this.height}join(t){let e=(Array.isArray(this.type)?this.type:[this]).concat(Array.isArray(t.type)?t.type:[t]);return new eR(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var eE=((r=eE||(eE={}))[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r);class eL{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=2*!!t|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>.001&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return eL.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,s){let o=this;for(let n=s.length-1;n>=0;n--){let{fromA:r,toA:l,fromB:h,toB:a}=s[n],c=o.lineAt(r,eE.ByPosNoHeight,e,0,0),d=c.to>=l?c:o.lineAt(l,eE.ByPosNoHeight,e,0,0);for(a+=d.to-l,l=d.to;n>0&&c.from<=s[n-1].toA;)r=s[n-1].fromA,h=s[n-1].fromB,n--,r<c.from&&(c=o.lineAt(r,eE.ByPosNoHeight,e,0,0));h+=c.from-r,r=c.from;let u=eF.build(i,t,h,a);o=o.replace(r,l,u)}return o.updateHeight(i,0)}static empty(){return new eV(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,s=0,o=0;for(;;)if(e==i)if(s>2*o){let o=t[e-1];o.break?t.splice(--e,1,o.left,null,o.right):t.splice(--e,1,o.left,o.right),i+=1+o.break,s-=o.size}else if(o>2*s){let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,o-=e.size}else break;else if(s<o){let i=t[e++];i&&(s+=i.size)}else{let e=t[--i];e&&(o+=e.size)}let n=0;return null==t[e-1]?(n=1,e--):null==t[e]&&(n=1,i++),new eN(eL.of(t.slice(0,e)),n,eL.of(t.slice(i)))}}eL.prototype.size=1;class eB extends eL{constructor(t,e,i){super(t,e),this.type=i}blockAt(t,e,i,s){return new eR(s,this.length,i,this.height,this.type)}lineAt(t,e,i,s,o){return this.blockAt(0,i,s,o)}forEachLine(t,e,i,s,o,n){t<=o+this.length&&e>=o&&n(this.blockAt(0,i,s,o))}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more&&this.setHeight(t,s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class eV extends eB{constructor(t,e){super(t,e,to.Text),this.collapsed=0,this.widgetHeight=0}replace(t,e,i){let s=i[0];return 1==i.length&&(s instanceof eV||s instanceof eH&&4&s.flags)&&10>Math.abs(this.length-s.length)?(s instanceof eH?s=new eV(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):eL.of(i)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more?this.setHeight(t,s.heights[s.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class eH extends eL{constructor(t){super(t,0)}lines(t,e){let i=t.lineAt(e).number,s=t.lineAt(e+this.length).number;return{firstLine:i,lastLine:s,lineHeight:this.height/(s-i+1)}}blockAt(t,e,i,s){let{firstLine:o,lastLine:n,lineHeight:r}
1=this.lines(e,s),l=Math.max(0,Math.min(n-o,Math.floor((t-i)/r))),{from:h,length:a}=e.line(o+l);return new eR(h,a,i+r*l,r,to.Text)}lineAt(t,e,i,s,o){if(e==eE.ByHeight)return this.blockAt(t,i,s,o);if(e==eE.ByPosNoHeight){let{from:e,to:s}=i.lineAt(t);return new eR(e,s-e,0,0,to.Text)}let{firstLine:n,lineHeight:r}=this.lines(i,o),{from:l,length:h,number:a}=i.lineAt(t);return new eR(l,h,s+r*(a-n),r,to.Text)}forEachLine(t,e,i,s,o,n){let{firstLine:r,lineHeight:l}=this.lines(i,o);for(let h=Math.max(t,o),a=Math.min(o+this.length,e);h<=a;){let e=i.lineAt(h);h==t&&(s+=l*(e.number-r)),n(new eR(e.from,e.length,s,l,to.Text)),s+=l,h=e.to+1}}replace(t,e,i){let s=this.length-e;if(s>0){let t=i[i.length-1];t instanceof eH?i[i.length-1]=new eH(t.length+s):i.push(null,new eH(s-1))}if(t>0){let e=i[0];e instanceof eH?i[0]=new eH(t+e.length):i.unshift(new eH(t-1),null)}return eL.of(i)}decomposeLeft(t,e){e.push(new eH(t-1),null)}decomposeRight(t,e){e.push(null,new eH(this.length-t-1))}updateHeight(t,e=0,i=!1,s){let o=e+this.length;if(s&&s.from<=e+this.length&&s.more){let i=[],n=Math.max(e,s.from),r=-1,l=t.heightChanged;for(s.from>e&&i.push(new eH(s.from-e-1).updateHeight(t,e));n<=o&&s.more;){let e=t.doc.lineAt(n).length;i.length&&i.push(null);let o=s.heights[s.index++];-1==r?r=o:Math.abs(o-r)>=.001&&(r=-2);let l=new eV(e,o);l.outdated=!1,i.push(l),n+=e+1}n<=o&&i.push(null,new eH(o-n).updateHeight(t,n));let h=eL.of(i);
vendor: 6,113 bytes, line 1
1return t.heightChanged=l||r<0||Math.abs(h.height-this.height)>=.001||Math.abs(r-this.lines(t.doc,e).lineHeight)>=.001,h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class eN extends eL{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,s){let o=i+this.left.height;return t<o?this.left.blockAt(t,e,i,s):this.right.blockAt(t,e,o,s+this.left.length+this.break)}lineAt(t,e,i,s,o){let n=s+this.left.height,r=o+this.left.length+this.break,l=e==eE.ByHeight?t<n:t<r,h=l?this.left.lineAt(t,e,i,s,o):this.right.lineAt(t,e,i,n,r);if(this.break||(l?h.to<r:h.from>r))return h;let a=e==eE.ByPosNoHeight?eE.ByPosNoHeight:eE.ByPos;return l?h.join(this.right.lineAt(r,a,i,n,r)):this.left.lineAt(r,a,i,s,o).join(h)}forEachLine(t,e,i,s,o,n){let r=s+this.left.height,l=o+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,s,o,n),e>=l&&this.right.forEachLine(t,e,i,r,l,n);else{let h=this.lineAt(l,eE.ByPos,i,s,o);t<h.from&&this.left.forEachLine(t,h.from-1,i,s,o,n),h.to>=t&&h.from<=e&&n(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,r,l,n)}}replace(t,e,i){let s=this.left.length+this.break;if(e<s)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-s,e-s,i));let o=[];t>0&&this.decomposeLeft(t,o);let n=o.length;for(let t of i)o.push(t);if(t>0&&eP(o,n-1),e<this.length){let t=o.length;this.decomposeRight(e,o),eP(o,t)}return eL.of(o)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&t>=++i&&e.push(null),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,s=i+this.break;if(t>=s)return this.right.decomposeRight(t-s,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<s&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?eL.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,s){let{left:o,right:n}=this,r=e+o.length+this.break,l=null;return(s&&s.from<=e+o.length&&s.more?l=o=o.updateHeight(t,e,i,s):o.updateHeight(t,e,i),s&&s.from<=r+n.length&&s.more?l=n=n.updateHeight(t,r,i,s):n.updateHeight(t,r,i),l)?this.balanced(o,n):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function eP(t,e){let i,s;null==t[e]&&(i=t[e-1])instanceof eH&&(s=t[e+1])instanceof eH&&t.splice(e-1,3,new eH(i.length+1+s.length))}class eF{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof eV?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new eV(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let s=i.widget?i.widget.estimatedHeight:0;s<0&&(s=this.oracle.lineHeight);let o=e-t;i.block?this.addBlock(new eB(o,s,i.type)):(o||s>=5)&&this.addLineDeco(s,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new eV(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new eH(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof eV)return t;let e=new eV(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine(),t.type!=to.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=to.WidgetBefore&&(this.covering=t)}addLineDeco(t,e){let i=this.ensureLine();i.length+=e,i.collapsed+=e,i.widgetHeight=Math.max(i.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof eV||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new eV(0,-1));let i=t;for(let t of this.nodes)t instanceof eV&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,s){let o=new eF(i,t);return l.om.spans(e,i,s,o,0),o.finish(i)}}class eW{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,s){(t<e||i&&i.heightRelevant||s&&s.heightRelevant)&&tc(t,e,this.changes,5)}}class ez{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let s=t[i],o=e[i];if(s.from!=o.from||s.to!=o.to||s.size!=o.size)return!1}return!0}draw(t){return tn.replace({widget:new eq(this.size,t)}).range(this.from,this.to)}}class eq extends ts{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class eI{constructor(t){this.state=t,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.heightOracle=ne
1w eO,this.scaler=e_,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=tW.RTL,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1,this.stateDeco=t.facet(tB).filter(t=>"function"!=typeof t),this.heightMap=eL.empty().applyChanges(this.stateDeco,l.EY.empty,this.heightOracle.setDoc(t.doc),[new tP(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=tn.set(this.lineGaps.map(t=>t.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let s=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>s>=t&&s<=e)){let{from:e,to:i}=this.lineBlockAt(s);t.push(new eK(e,i))}}this.viewports=t.sort((t,e)=>t.from-e.from),this.scaler=this.heightMap.height<=7e6?e_:new e$(this.heightOracle.doc,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,t=>{this.viewportLines.push(1==this.scaler.scale?t:eY(t,this.scaler))})}update(t,e=null){var i,s;let o;this.state=t.state;let n=this.stateDeco;this.stateDeco=this.state.facet(tB).filter(t=>"function"!=typeof t);let r=t.changedRanges,h=tP.extendWithRanges(r,(i=this.stateDeco,s=t?t.changes:l.VR.empty(this.state.doc.length),o=new eW,l.om.compare(n,i,s,o,0),o.changes)),a=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),h),this.heightMap.height!=a&&(t.flags|=2);let c=h.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<c.from||e.range.head>c.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,e));let d=!t.changes.empty||2&t.flags||c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,this.updateForViewport(),d&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,o=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?tW.RTL:tW.LTR;let n=this.heightOracle.mustRefreshForWrapping(o),r=n||this.mustMeasureContent||this.contentDOMHeight!=e.clientHeight;this.contentDOMHeight=e.clientHeight,this.mustMeasureContent=!1;let l=0,h=0,a=parseInt(i.paddingTop)||0,c=parseInt(i.paddingBottom)||0;(this.paddingTop!=a||this.paddingBottom!=c)&&(this.paddingTop=a,this.paddingBottom=c,l|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(s.lineWrapping&&(r=!0),this.editorWidth=t.scrollDOM.clientWidth,l|=8);let d=(this.printing?function(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}:function(t,e){let i=t.getBoundingClientRect(),s=t.ownerDocument,o=s.defaultView||window,n=Math.max(0,i.left),r=Math.min(o.innerWidth,i.right),l=Math.max(0,i.top),h=Math.min(o.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=s.body;)if(1==e.nodeType){let i=e,s=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=s.overflow){let s=i.getBoundingClientRect();n=Math.max(n,s.left),r=Math.min(r,s.right),l=Math.max(l,s.top),h=e==t.parentNode?s.bottom:Math.min(h,s.bottom)}e="absolute"==s.position||"fixed"==s.position?i.offsetParent:i.parentNode}else if(11==e.nodeType)e=e.host;else break;return{left:n-i.left,right:Math.max(n,r)-i.left,top:l-(i.top+e),bottom:Math.max(l,h)-(i.top+e)}})(e,this.paddingTop),u=d.top-this.pixelViewport.top,f=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let p=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;
1if(p!=this.inView&&(this.inView=p,p&&(r=!0)),!this.inView&&!this.scrollTarget)return 0;let m=e.clientWidth;if((this.contentDOMWidth!=m||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=m,this.editorHeight=t.scrollDOM.clientHeight,l|=8),r){let e=t.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(e)&&(n=!0),n||s.lineWrapping&&Math.abs(m-this.contentDOMWidth)>s.charWidth){let{lineHeight:i,charWidth:r}=t.docView.measureTextSize();(n=i>0&&s.refresh(o,i,r,m/r,e))&&(t.docView.minWidth=0,l|=8)}for(let i of(u>0&&f>0?h=Math.max(u,f):u<0&&f<0&&(h=Math.min(u,f)),s.heightChanged=!1,this.viewports)){let o=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=this.heightMap.updateHeight(s,0,n,new eT(i.from,o))}s.heightChanged&&(l|=2)}let g=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return g&&(this.viewport=this.getViewport(h,this.scrollTarget)),this.updateForViewport(),(2&l||g)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(n?[]:this.lineGaps,t)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),s=this.heightMap,o=this.state.doc,{visibleTop:n,visibleBottom:r}=this,l=new eK(s.lineAt(n-1e3*i,eE.ByHeight,o,0,0).from,s.lineAt(r+(1-i)*1e3,eE.ByHeight,o,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),n=s.lineAt(t,eE.ByPos,o,0,0),r;r="center"==e.y?(n.top+n.bottom)/2-i/2:"start"==e.y||"nearest"==e.y&&t<l.from?n.top:n.bottom-i,l=new eK(s.lineAt(r-500,eE.ByHeight,o,0,0).from,s.lineAt(r+i+500,eE.ByHeight,o,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),s=e.mapPos(t.to,1);return new eK(this.heightMap.lineAt(i,eE.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(s,eE.ByPos,this.state.doc,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(t,eE.ByPos,this.state.doc,0,0),{bottom:o}=this.heightMap.lineAt(e,eE.ByPos,this.state.doc,0,0),{visibleTop:n,visibleBottom:r}=this;return(0==t||s<=n-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||o>=r+Math.max(10,Math.min(i,250)))&&s>n-2e3&&o<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let s of t)e.touchesRange(s.from,s.to)||i.push(new ez(e.mapPos(s.from),e.mapPos(s.to),s.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,s=i?1e4:2e3,o=s>>1,n=s<<1;if(this.defaultTextDirection!=tW.LTR&&!i)return[];let r=[],h=(s,n,a,c)=>{if(n-s<o)return;let d=this.state.selection.main,u=[d.from];for(let t of(d.empty||u.push(d.to),u))if(t>s&&t<n){h(s,t-10,a,c),h(t+10,n,a,c);return}let f=function(t,e){for(let i of t)if(e(i))return i}(t,t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-s)<o&&Math.abs(t.to-n)<o&&!u.some(e=>t.from<e&&t.to>e));if(!f){if(n<a.to&&e&&i&&e.visibleRanges.some(t=>t.from<=n&&t.to>=n)){let t=e.moveToLineBoundary(l.OF.cursor(n),!1,!0).head;t>s&&(n=t)}f=new ez(s,n,this.gapSize(a,s,n,c))}r.push(f)};for(let t of this.viewportLines){let e,o;if(t.length<n)continue;let r=function(t,e,i){let s=[],o=t,n=0;return l.om.spans(i,t,e,{span(){},point(t,e){t>o&&(s.push({from:o,to:t}),n+=t-o),o=e}},20),o<e&&(s.push({from:o,to:e}),n+=e-o),{total:n,ranges:s}}(t.from,t.to,this.stateDeco);if(r.total<n)continue;let a=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,n,l=s/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=a){let e=eG(r,a),s=((this.visibleBottom-this.visibleTop)/2+l)/t.height;i=e-s,n=e+s}else i=(this.visibleTop-t.top-l)/t.height,n=(this.visibleBottom-t.top+l)/t.height;e=ej(r,i),o=ej(r,n)}else{let t,i,n=r.total*this.heightOracle.charWidth,l=s*this.heightOracle.charWidth;if(null!=a){let e=eG(r,a),s=((this.pixelViewport.right-this.pixelViewport.left)/2+l)/n;t=e-s,i=e+s}else t=(this.pixelViewport.left-l)/n,i=(this.pixelViewport.right+l)/n;e=ej(r,t),o=ej(r,i)}e>t.from&&h(t.from,e,t,r),o<t.to&&h(o,t.to,t,r)}return r}gapSize(t,e,i,s){let o=eG(s,i)-eG(s,e);return this.heightOracle.lineWrapping?t.height*o:s.total*this.heightOracle.charWidth*o}updateLineGaps(t){ez.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=tn.set(t.map(t=>t.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];l.om.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})}
1,point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some((t,i)=>t.from!=e[i].from||t.to!=e[i].to);return this.visibleRanges=e,4*!!i}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||eY(this.heightMap.lineAt(t,eE.ByPos,this.state.doc,0,0),this.scaler)}lineBlockAtHeight(t){return eY(this.heightMap.lineAt(this.scaler.fromDOM(t),eE.ByHeight,this.state.doc,0,0),this.scaler)}elementAtHeight(t){return eY(this.heightMap.blockAt(this.scaler.fromDOM(t),this.state.doc,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class eK{constructor(t,e){this.from=t,this.to=e}}function ej({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let s=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:o}=e[t],n=o-i;if(s<=n)return i+s;s-=n}}function eG(t,e){let i=0;for(let{from:s,to:o}of t.ranges){if(e<=o){i+=e-s;break}i+=o-s}return i/t.total}let e_={toDOM:t=>t,fromDOM:t=>t,scale:1};class e${constructor(t,e,i){let s=0,o=0,n=0;for(let r of(this.viewports=i.map(({from:i,to:o})=>{let n=e.lineAt(i,eE.ByPos,t,0,0).top,r=e.lineAt(o,eE.ByPos,t,0,0).bottom;return s+=r-n,{from:i,to:o,top:n,bottom:r,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(e.height-s),this.viewports))r.domTop=n+(r.top-o)*this.scale,n=r.domBottom=r.domTop+(r.bottom-r.top),o=r.bottom}toDOM(t){for(let e=0,i=0,s=0;;e++){let o=e<this.viewports.length?this.viewports[e]:null;if(!o||t<o.top)return s+(t-i)*this.scale;if(t<=o.bottom)return o.domTop+(t-o.top);i=o.bottom,s=o.domBottom}}fromDOM(t){for(let e=0,i=0,s=0;;e++){let o=e<this.viewports.length?this.viewports[e]:null;if(!o||t<o.domTop)return i+(t-s)/this.scale;if(t<=o.domBottom)return o.top+(t-o.domTop);i=o.bottom,s=o.domBottom}}}function eY(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),s=e.toDOM(t.bottom);return new eR(t.from,t.length,i,s-i,Array.isArray(t.type)?t.type.map(t=>eY(t,e)):t.type)}let eU=l.sj.define({combine:t=>t.join(" ")}),eX=l.sj.define({combine:t=>t.indexOf(!0)>-1}),eQ=h.G.newName(),eJ=h.G.newName(),eZ=h.G.newName(),e0={"&light":"."+eJ,"&dark":"."+eZ};function e1(t,e,i){return new h.G(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!i||!i[e])throw RangeError(`Unsupported selector: ${e}`);return i[e]}):t+" "+e})}let e2=e1("."+eQ,{"&.cm-editor":{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},".cm-content":{margin:0,flexGrow:2,flexShrink:0,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",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 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .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":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&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",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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},"&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-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"},".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"}},e0);class e8{constructor(t,e,i,s){this.typeOver=s,this.bounds=null,this.text="";let{impreciseHead:o,impreciseAnchor:n}=t.docView;if(e>-1&&!t.state.readOnly&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=o||n?[]:function(t){let e=[];
1if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:n}=t.observer.selectionRange;return i&&(e.push(new t0(i,s)),(o!=i||n!=s)&&e.push(new t0(o,n))),e}(t),i=new tJ(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,s=2==t.length?t[1].pos:i;return i>-1&&s>-1?l.OF.single(i+e,s+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=o&&o.node==e.focusNode&&o.offset==e.focusOffset||!d(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),s=n&&n.node==e.anchorNode&&n.offset==e.anchorOffset||!d(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=l.OF.single(s,i)}}}function e3(t,e){let i,{newSel:s}=e,o=t.state.selection.main;if(e.bounds){let{from:s,to:n}=e.bounds,r=o.from,h=null;(8===t.inputState.lastKeyCode&&t.inputState.lastKeyTime>Date.now()-100||j.android&&e.text.length<n-s)&&(r=o.to,h="end");let a=function(t,e,i,s){let o=Math.min(t.length,e.length),n=0;for(;n<o&&t.charCodeAt(n)==e.charCodeAt(n);)n++;if(n==o&&t.length==e.length)return null;let r=t.length,l=e.length;for(;r>0&&l>0&&t.charCodeAt(r-1)==e.charCodeAt(l-1);)r--,l--;if("end"==s){let t=Math.max(0,n-Math.min(r,l));i-=r+t-n}if(r<n&&t.length<e.length){let t=i<=n&&i>=r?n-i:0;n-=t,l=n+(l-r),r=n}else if(l<n){let t=i<=n&&i>=l?n-i:0;n-=t,r=n+(r-l),l=n}return{from:n,toA:r,toB:l}}(t.state.doc.sliceString(s,n,"ï¿¿"),e.text,r-s,h);a&&(j.chrome&&13==t.inputState.lastKeyCode&&a.toB==a.from+2&&"ï¿¿ï¿¿"==e.text.slice(a.from,a.toB)&&a.toB--,i={from:s+a.from,to:s+a.toA,insert:l.EY.of(e.text.slice(a.from,a.toB).split("ï¿¿"))})}else s&&(!t.hasFocus||!t.state.facet(tA)||s.main.eq(o))&&(s=null);if(!i&&!s)return!1;if(!i&&e.typeOver&&!o.empty&&s&&s.main.empty?i={from:o.from,to:o.to,insert:t.state.doc.slice(o.from,o.to)}:i&&i.from>=o.from&&i.to<=o.to&&(i.from!=o.from||i.to!=o.to)&&o.to-o.from-(i.to-i.from)<=4?i={from:o.from,to:o.to,insert:t.state.doc.slice(o.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,o.to))}:(j.mac||j.android)&&i&&i.from==i.to&&i.from==o.head-1&&/^\. ?$/.test(i.insert.toString())?(s&&2==i.insert.length&&(s=l.OF.single(s.main.anchor-1,s.main.head-1)),i={from:o.from,to:o.to,insert:l.EY.of([" "])}):j.chrome&&i&&i.from==i.to&&i.from==o.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(s&&(s=l.OF.single(s.main.anchor-1,s.main.head-1)),i={from:o.from,to:o.to,insert:l.EY.of([" "])}),i){let e,n=t.state;if(j.ios&&t.inputState.flushIOSKey(t)||j.android&&(i.from==o.from&&i.to==o.to&&1==i.insert.length&&2==i.insert.lines&&k(t.contentDOM,"Enter",13)||i.from==o.from-1&&i.to==o.to&&0==i.insert.length&&k(t.contentDOM,"Backspace",8)||i.from==o.from&&i.to==o.to+1&&0==i.insert.length&&k(t.contentDOM,"Delete",46)))return!0;let r=i.insert.toString();if(t.state.facet(tx).some(e=>e(t,i.from,i.to,r)))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=o.from&&i.to<=o.to&&i.to-i.from>=(o.to-o.from)/3&&(!s||s.main.empty&&s.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let s=o.from<i.from?n.sliceDoc(o.from,i.from):"",r=o.to>i.to?n.sliceDoc(i.to,o.to):"";e=n.replaceSelection(t.state.toText(s+i.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=n.changes(i),h=s&&!n.selection.main.eq(s.main)&&s.main.to<=r.newLength?s.main:void 0;if(n.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=o.to&&i.to>=o.to-10){let s=t.state.sliceDoc(i.from,i.to),a=t8(t)||t.state.doc.lineAt(o.head),c=o.to-i.to,d=o.to-o.from;e=n.changeByRange(e=>{if(e.from==o.from&&e.to==o.to)return{changes:r,range:h||e.map(r)};let u=e.to-c,f=u-s.length;if(e.to-e.from!=d||t.state.sliceDoc(f,u)!=s||a&&e.to>=a.from&&e.from<=a.to)return{range:e};let p=n.changes({from:f,to:u,insert:i.insert}),m=e.to-o.to;return{changes:p,range:h?l.OF.range(Math.max(0,h.anchor+m),Math.max(0,h.head+m)):e.map(p)}})}else e={changes:r,selection:h&&n.selection.replaceRange(h)}}let h="input.type";return t.composing&&(h+=".compose",t.inputState.compositionFirstChange&&(h+=".start",t.inputState.compositionFirstChange=!1)),t.dis
1patch(e,{scrollIntoView:!0,userEvent:h}),!0}if(!s||s.main.eq(o))return!1;{let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:s,scrollIntoView:e,userEvent:i}),!0}}let e9={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},e4=j.ie&&j.ie_version<=11;class e5{constructor(t){this.view=t,this.active=!1,this.selectionRange=new y,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.resize=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(j.ie&&j.ie_version<=11||j.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),e4&&(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),"function"==typeof ResizeObserver&&(this.resize=new ResizeObserver(()=>{this.view.docView.lastUpdate<Date.now()-75&&this.onResize()}),this.resize.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(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")))},{}),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(t){this.view.inputState.runScrollHandlers(this.view,t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){for(let e of(this.gapIntersection.disconnect(),t))this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(tA)?i.root.activeElement!=this.dom:!u(i.dom,s))return;let o=s.anchorNode&&i.docView.nearest(s.anchorNode);if(o&&o.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(j.ie&&j.ie_version<=11||j.android&&j.chrome)&&!i.state.selection.main.empty&&s.focusNode&&p(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=j.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let s=e.startContainer,o=e.startOffset,n=e.endContainer,r=e.endOffset,l=t.docView.domAtPos(t.state.selection.main.anchor);return p(l.node,l.offset,n,r)&&([s,o,n,r]=[n,r,s,o]),{anchorNode:s,anchorOffset:o,focusNode:n,focusOffset:r}}(this.view)||c(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=u(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,s=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=s)return!1;for(;;)if(s){if(1!=i.nodeType)return!1;let t=i.childNodes[s-1];"false"==t.contentEditable?s--:s=w(i=t)}else{if(i==t)return!0;s=m(i),i=i.parentNode}}(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else if(11==i.nodeType)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,e9),e4&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),e4&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),!this.flush()&&t.force&&k(this.dom,t.ke
1y,t.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null==(i=this.delayedAndroidKey)?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()}processRecords(){let t=this.queue;for(let e of this.observer.takeRecords())t.push(e);t.length&&(this.queue=[]);let e=-1,i=-1,s=!1;for(let o of t){let t=this.readMutation(o);t&&(t.typeOver&&(s=!0),-1==e?{from:e,to:i}=t:(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:s}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),s=this.selectionChanged&&u(this.dom,this.selectionRange);return t<0&&!s?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new e8(this.view,t,e,i))}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return!1;let i=this.view.state,s=e3(this.view,e);return this.view.state==i&&this.view.update([]),s}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.dirty|=4),"childList"==t.type){let i=e6(e,t.previousSibling||t.target.previousSibling,-1),s=e6(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:s?e.posBefore(s):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i;for(let s of(this.stop(),null==(t=this.intersection)||t.disconnect(),null==(e=this.gapIntersection)||e.disconnect(),null==(i=this.resize)||i.disconnect(),this.scrollTargets))s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function e6(t,e,i){for(;e;){let s=O.get(e);if(s&&s.parent==t)return s;let o=e.parentNode;e=o!=t.dom?o:i>0?e.nextSibling:e.previousSibling}return null}class e7{constructor(t={}){for(let e of(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.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new eI(t.state||l.$t.create(t)),this.plugins=this.state.facet(tO).map(t=>new tR(t)),this.plugins))e.update(this);this.observer=new e5(this),this.inputState=new en(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new t1(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}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.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}
1dispatch(...t){this._dispatch(1==t.length&&t[0]instanceof l.ZX?t[0]:this.state.update(...t))}update(t){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,s,o=this.state;for(let e of t){if(e.startState!=o)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=e.state}if(this.destroyed){this.viewState.state=o;return}let n=this.observer.delayedAndroidKey,r=null;if(n?(this.observer.clearDelayedAndroidKey(),((r=this.observer.readChange())&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(r=null)):this.observer.clear(),o.facet(l.$t.phrases)!=this.state.facet(l.$t.phrases))return this.setState(o);s=tF.create(this,o,t);let h=this.viewState.scrollTarget;try{for(let e of(this.updateState=2,t)){if(h&&(h=h.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;h=new tM(t.empty?t:l.OF.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(tk)&&(h=t.value)}this.viewState.update(s,h),this.bidiCache=ii.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),e=this.docView.update(s),this.state.facet(tN)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(eU)!=s.state.facet(eU)&&(this.viewState.mustMeasureContent=!0),(e||i||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!s.empty)for(let t of this.state.facet(ty))t(s);r&&!e3(this,r)&&n.force&&k(this.contentDOM,n.key,n.keyCode)}setState(t){if(0!=this.updateState)throw Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);for(let e of(this.viewState=new eI(t),this.plugins=t.facet(tO).map(t=>new tR(t)),this.pluginMap.clear(),this.plugins))e.update(this);this.docView=new t1(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(tO),i=t.state.facet(tO);if(e!=i){let s=[];for(let o of i){let i=e.indexOf(o);if(i<0)s.push(new tR(o));else{let e=this.plugins[i];e.mustUpdate=t,s.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=s,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,{scrollHeight:i,scrollTop:s,clientHeight:o}=this.scrollDOM,n=s>i-o-4?i:s;try{for(let t=0;;t++){this.updateState=1;let i=this.viewport,s=this.viewState.lineBlockAtHeight(n),o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let r=[];4&o||([this.measureRequests,r]=[r,this.measureRequests]);let l=r.map(t=>{try{return t.read(this)}catch(t){return tC(this.state,t),ie}}),h=tF.create(this,this.state,[]),a=!1,c=!1;h.flags|=o,e?e.flags|=o:e=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),a=this.docView.update(h));for(let t=0;t<r.length;t++)if(l[t]!=ie)try{let e=r[t];e.write&&e.write(l[t],this)}catch(t){tC(this.state,t)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,c=!0;else{let t=this.viewState.lineBlockAt(s.from).top-s.top;(t>1||t<-1)&&(this.scrollDOM.scrollTop+=t,c=!0)}if(a&&this.docView.updateSelection(!0),this.viewport.from==i.from&&this.viewport.to==i.to&&!c&&0==this.measureRequests.length)break}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(ty))t(e)}get themeClasses(){return eQ+" "+(this.state.facet(eX)?eZ:eJ)+" "+this.state.facet(eU)}updateAttrs(){let t=is(this,tE,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(tA)?"true":"false",class:"cm-content",style:`${j.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),is(this,tL,e);let i=this.observer.ignore(()=>{let i=ti(this.contentDOM,this.contentAttrs,e),s=ti(this.dom,this.editorAttrs,t);return i||s});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)t.is(e7.announce)&&(e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value)}mountStyles(){this.styleModules=this.state.facet(tN),h.G.mount(this.root,this.styleModules.concat(e2).reverse())}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(null!=t.key){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find(e=>e.spec==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return eo(this,t,es(this,t,e,i))}moveByGroup(t,e){return eo(this,t,es(this,t,e,e=>{var i;let s,o;return i=t.head,o=(s=this.state.charCategorizer(i))(e),t=>{let e=s(t);return o==l.Je.Space&&(o=e),o==e}}))}
1moveToLineBoundary(t,e,i=!0){return function(t,e,i,s){let o=t.state.doc.lineAt(e.head),n=s&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>o.from?e.head-1:e.head):null;if(n){let e=t.dom.getBoundingClientRect(),s=t.textDirectionAt(o.from),r=t.posAtCoords({x:i==(s==tW.LTR)?e.right-1:e.left+1,y:(n.top+n.bottom)/2});if(null!=r)return l.OF.cursor(r,i?-1:1)}let r=td.find(t.docView,e.head),h=r?i?r.posAtEnd:r.posAtStart:i?o.to:o.from;return l.OF.cursor(h,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return eo(this,t,function(t,e,i,s){let o=e.head,n=i?1:-1;if(o==(i?t.state.doc.length:0))return l.OF.cursor(o,e.assoc);let r=e.goalColumn,h,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(o),d=t.documentTop;if(c)null==r&&(r=c.left-a.left),h=n<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(o);null==r&&(r=Math.min(a.right-a.left,t.defaultCharacterWidth*(o-e.from))),h=(n<0?e.top:e.bottom)+d}let u=a.left+r,f=null!=s?s:t.defaultLineHeight>>1;for(let i=0;;i+=10){let s=h+(f+i)*n,c=ee(t,{x:u,y:s},!1,n);if(s<a.top||s>a.bottom||(n<0?c<o:c>o))return l.OF.cursor(c,e.assoc,void 0,r)}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),ee(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(t),o=this.bidiSpans(s);return b(i,o[tY.find(o,t-s.from,-1,e)].dir==tW.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(tS)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>it)return tX(t.length);let e=this.textDirectionAt(t.from);for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e)return i.order;let i=function(t,e){let i=t.length,s=e==tz?1:2,o=e==tz?2:1;if(!t||1==s&&!t$.test(t))return tX(i);for(let e=0,o=s,r=s;e<i;e++){var n;let i=(n=t.charCodeAt(e))<=247?tK[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?tj[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8203?256:64336<=n&&n<=65023?4:8204==n?256:1;512==i?i=o:8==i&&4==r&&(i=16),tU[e]=4==i?2:i,7&i&&(r=i),o=i}for(let t=0,e=s,o=s;t<i;t++){let s=tU[t];if(128==s)t<i-1&&e==tU[t+1]&&24&e?s=tU[t]=e:tU[t]=256;else if(64==s){let s=t+1;for(;s<i&&64==tU[s];)s++;let n=t&&8==e||s<i&&8==tU[s]?1==o?1:8:256;for(let e=t;e<s;e++)tU[e]=n;t=s-1}else 8==s&&1==o&&(tU[t]=1);e=s,7&s&&(o=s)}for(let e=0,n=0,r=0,l,h,a;e<i;e++)if(h=tG[l=t.charCodeAt(e)])if(h<0){for(let t=n-3;t>=0;t-=3)if(t_[t+1]==-h){let i=t_[t+2],r=2&i?s:4&i?1&i?o:s:0;r&&(tU[e]=tU[t_[t]]=r),n=t;break}}else if(189==t_.length)break;else t_[n++]=e,t_[n++]=l,t_[n++]=r;else if(2==(a=tU[e])||1==a){let t=a==s;r=+!t;for(let e=n-3;e>=0;e-=3){let i=t_[e+2];if(2&i)break;if(t)t_[e+2]|=2;else{if(4&i)break;t_[e+2]|=4}}}for(let t=0;t<i;t++)if(256==tU[t]){let e=t+1;for(;e<i&&256==tU[e];)e++;let o=(t?tU[t-1]:s)==1,n=o==((e<i?tU[e]:s)==1)?o?1:2:s;for(let i=t;i<e;i++)tU[i]=n;t=e-1}let r=[];if(1==s)for(let t=0;t<i;){let e=t,s=1!=tU[t++];for(;t<i&&s==(1!=tU[t]);)t++;if(s)for(let i=t;i>e;){let t=i,s=2!=tU[--i];for(;i>e&&s==(2!=tU[i-1]);)i--;r.push(new tY(i,t,s?2:1))}else r.push(new tY(e,t,0))}else for(let t=0;t<i;){let e=t,s=2==tU[t++];for(;t<i&&s==(2==tU[t]);)t++;r.push(new tY(e,t,s?1:2))}return r}(t.text,e);return this.bidiCache.push(new ii(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||j.safari&&(null==(t=this.inputState)?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{S(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return tk.of(new tM("number"==typeof t?l.OF.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return tT.define(()=>({}),{eventHandlers:t})}static theme(t,e){let i=h.G.newName(),s=[eU.of(i),tN.of(e1(`.${i}`,t))];return e&&e.dark&&s.push(eX.of(!0)),s}static baseTheme(t){return l.Nb.lowest(tN.of(e1("."+eQ,t,e0)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&O.get(i)||O.get(t);
1return(null==(e=null==s?void 0:s.rootView)?void 0:e.view)||null}}e7.styleModule=tN,e7.inputHandler=tx,e7.perLineTextDirection=tS,e7.exceptionSink=tb,e7.updateListener=ty,e7.editable=tA,e7.mouseSelectionStyle=tv,e7.dragMovesSelection=tw,e7.clickAddsSelectionRange=tg,e7.decorations=tB,e7.atomicRanges=tV,e7.scrollMargins=tH,e7.darkTheme=eX,e7.contentAttributes=tL,e7.editorAttributes=tE,e7.lineWrapping=e7.contentAttributes.of({class:"cm-lineWrapping"}),e7.announce=l.Pe.define();let it=4096,ie={};class ii{constructor(t,e,i,s){this.from=t,this.to=e,this.dir=i,this.order=s}static update(t,e){if(e.empty)return t;let i=[],s=t.length?t[t.length-1].dir:tW.LTR;for(let o=Math.max(0,t.length-10);o<t.length;o++){let n=t[o];n.dir!=s||e.touchesRange(n.from,n.to)||i.push(new ii(e.mapPos(n.from,1),e.mapPos(n.to,-1),n.dir,n.order))}return i}}function is(t,e,i){for(let s=t.state.facet(e),o=s.length-1;o>=0;o--){let e=s[o],n="function"==typeof e?e(t):e;n&&tt(n,i)}return i}let io=j.mac?"mac":j.windows?"win":j.linux?"linux":"key";function ir(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}let il=l.Nb.default(e7.domEventHandlers({keydown:(t,e)=>ip(ic(e.state),t,e,"editor")})),ih=l.sj.define({enables:il}),ia=new WeakMap;function ic(t){let e=t.facet(ih),i=ia.get(e);return i||ia.set(e,i=function(t,e=io){let i=Object.create(null),s=Object.create(null),o=(t,e)=>{let i=s[t];if(null==i)s[t]=e;else if(i!=e)throw Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},n=(t,s,n,r)=>{var l,h;let a=i[t]||(i[t]=Object.create(null)),c=s.split(/ (?!$)/).map(t=>(function(t,e){let i,s,o,n,r=t.split(/-(?!$)/),l=r[r.length-1];"Space"==l&&(l=" ");for(let t=0;t<r.length-1;++t){let l=r[t];if(/^(cmd|meta|m)$/i.test(l))n=!0;else if(/^a(lt)?$/i.test(l))i=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))"mac"==e?n=!0:s=!0;else throw Error("Unrecognized modifier name: "+l)}return i&&(l="Alt-"+l),s&&(l="Ctrl-"+l),n&&(l="Meta-"+l),o&&(l="Shift-"+l),l})(t,e));for(let e=1;e<c.length;e++){let i=c.slice(0,e).join(" ");o(i,!0),a[i]||(a[i]={preventDefault:!0,run:[e=>{let s=iu={view:e,prefix:i,scope:t};return setTimeout(()=>{iu==s&&(iu=null)},4e3),!0}]})}let d=c.join(" ");o(d,!1);let u=a[d]||(a[d]={preventDefault:!1,run:(null==(h=null==(l=a._any)?void 0:l.run)?void 0:h.slice())||[]});n&&u.run.push(n),r&&(u.preventDefault=!0)};for(let s of t){let t=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));for(let e in t._any||(t._any={preventDefault:!1,run:[]}),t)t[e].run.push(s.any)}let o=s[e]||s.key;if(o)for(let e of t)n(e,o,s.run,s.preventDefault),s.shift&&n(e,"Shift-"+o,s.shift,s.preventDefault)}return i}(e.reduce((t,e)=>t.concat(e),[]))),i}function id(t,e,i){return ip(ic(t.state),e,t,i)}let iu=null;function ip(t,e,i,s){let o=(0,a.xT)(e),n=(0,l.vS)(o,0),r=(0,l.Fh)(n)==o.length&&" "!=o,h="",c=!1;iu&&iu.view==i&&iu.scope==s&&(h=iu.prefix+" ",(c=0>eh.indexOf(e.keyCode))&&(iu=null));let d=new Set,u=t=>{if(t){for(let s of t.run)if(!d.has(s)&&(d.add(s),s(i,e)))return!0;t.preventDefault&&(c=!0)}return!1},f=t[s],p,m;if(f){if(u(f[h+ir(o,e,!r)]))return!0;if(r&&(e.shiftKey||e.altKey||e.metaKey||n>127)&&(p=a.E3[e.keyCode])&&p!=o){if(u(f[h+ir(p,e,!0)]))return!0;else if(e.shiftKey&&(m=a.BN[e.keyCode])!=o&&m!=p&&u(f[h+ir(m,e,!1)]))return!0}else if(r&&e.shiftKey&&u(f[h+ir(o,e,!0)]))return!0;if(u(f._any))return!0}return c}let im=!j.ios,ig=l.sj.define({combine:t=>(0,l.QR)(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function iw(t={}){return[ig.of(t),ib,ix]}class iv{constructor(t,e,i,s,o){this.left=t,this.top=e,this.width=i,this.height=s,this.className=o}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width>=0&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}
1eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}}let ib=tT.fromClass(class{constructor(t){this.view=t,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=t.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=t.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),t.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(ig).cursorBlinkRate+"ms"}update(t){let e=t.startState.facet(ig)!=t.state.facet(ig);(e||t.selectionSet||t.geometryChanged||t.viewportChanged)&&this.view.requestMeasure(this.measureReq),t.transactions.some(t=>t.scrollIntoView)&&(this.cursorLayer.style.animationName="cm-blink"==this.cursorLayer.style.animationName?"cm-blink2":"cm-blink"),e&&this.setBlinkRate()}readPos(){let{state:t}=this.view,e=t.facet(ig),i=t.selection.ranges.map(t=>t.empty?[]:function(t,e){if(e.to<=t.viewport.from||e.from>=t.viewport.to)return[];let i=Math.max(e.from,t.viewport.from),s=Math.min(e.to,t.viewport.to),o=t.textDirection==tW.LTR,n=t.contentDOM,r=n.getBoundingClientRect(),l=iS(t),h=window.getComputedStyle(n.firstChild),a=r.left+parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)),c=r.right-parseInt(h.paddingRight),d=ik(t,i),u=ik(t,s),f=d.type==to.Text?d:null,p=u.type==to.Text?u:null;if(t.lineWrapping&&(f&&(f=iM(t,i,f)),p&&(p=iM(t,s,p))),f&&p&&f.from==p.from)return g(w(e.from,e.to,f));{let i=f?w(e.from,null,f):v(d,!1),s=p?w(null,e.to,p):v(u,!0),o=[];return(f||d).to<(p||u).from-1?o.push(m(a,i.bottom,c,s.top)):i.bottom<s.top&&t.elementAtHeight((i.bottom+s.top)/2).type==to.Text&&(i.bottom=s.top=(i.bottom+s.top)/2),g(i).concat(o).concat(g(s))}function m(t,e,i,s){return new iv(t-l.left,e-l.top-.01,i-t,s-e+.01,"cm-selectionBackground")}function g({top:t,bottom:e,horizontal:i}){let s=[];for(let o=0;o<i.length;o+=2)s.push(m(i[o],t,i[o+1],e));return s}function w(e,i,s){let n=1e9,r=-1e9,l=[];function h(e,i,h,d,u){let f=t.coordsAtPos(e,e==s.to?-2:2),p=t.coordsAtPos(h,h==s.from?2:-2);n=Math.min(f.top,p.top,n),r=Math.max(f.bottom,p.bottom,r),u==tW.LTR?l.push(o&&i?a:f.left,o&&d?c:p.right):l.push(!o&&d?a:p.left,!o&&i?c:f.right)}let d=null!=e?e:s.from,u=null!=i?i:s.to;for(let s of t.visibleRanges)if(s.to>d&&s.from<u)for(let o=Math.max(s.from,d),n=Math.min(s.to,u);;){let s=t.state.doc.lineAt(o);for(let r of t.bidiSpans(s)){let t=r.from+s.from,l=r.to+s.from;if(t>=n)break;l>o&&h(Math.max(t,o),null==e&&t<=d,Math.min(l,n),null==i&&l>=u,r.dir)}if((o=s.to+1)>=n)break}return 0==l.length&&h(d,null==e,u,null==i,t.textDirection),{top:n,bottom:r,horizontal:l}}function v(t,e){let i=r.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(this.view,t)).reduce((t,e)=>t.concat(e)),s=[];for(let i of t.selection.ranges){let o=i==t.selection.main;if(i.empty?!o||im:e.drawRangeCursor){let t=function(t,e,i){let s=t.coordsAtPos(e.head,e.assoc||1);if(!s)return null;let o=iS(t);return new iv(s.left-o.left,s.top-o.top,-1,s.bottom-s.top,i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}(this.view,i,o);t&&s.push(t)}}return{rangePieces:i,cursors:s}}drawSel({rangePieces:t,cursors:e}){if(t.length!=this.rangePieces.length||t.some((t,e)=>!t.eq(this.rangePieces[e]))){for(let e of(this.selectionLayer.textContent="",t))this.selectionLayer.appendChild(e.draw());this.rangePieces=t}if(e.length!=this.cursors.length||e.some((t,e)=>!t.eq(this.cursors[e]))){let t=this.cursorLayer.children;if(t.length!==e.length)for(let t of(this.cursorLayer.textContent="",e))this.cursorLayer.appendChild(t.draw());else e.forEach((e,i)=>e.adjust(t[i]));this.cursors=e}}destroy(){this.selectionLayer.remove(),this.cursorLayer.remove()}}),iy={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};im&&(iy[".cm-line"].caretColor="transparent !important");let ix=l.Nb.highest(e7.theme(iy));function iS(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==tW.LTR?e.left:e.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function iM(t,e,i){let s=l.OF.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(s,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(s,!0,!0).from),type:to.Text}}function ik(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type)){for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==to.Text))return t}return i}let iC=l.Pe.define({map:(t,e)=>null==t?null:e.mapPos(t)}),iA=l.sU.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce((t,e)=>e.is(iC)?e.value:t,t))}),iD=tT.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let i=t.state.field(iA);null==i?null!=this.cursor&&(null==(e=this.cursor)||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="
1cm-dropCursor"),(t.startState.field(iA)!=i||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let t=this.view.state.field(iA),e=null!=t&&this.view.coordsAtPos(t);if(!e)return null;let i=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-i.left+this.view.scrollDOM.scrollLeft,top:e.top-i.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}drawCursor(t){this.cursor&&(t?(this.cursor.style.left=t.left+"px",this.cursor.style.top=t.top+"px",this.cursor.style.height=t.height+"px"):this.cursor.style.left="-100000px")}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(iA)!=t&&this.view.dispatch({effects:iC.of(t)})}},{eventHandlers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function iO(){return[iA,iD]}function iT(t,e,i,s,o){e.lastIndex=0;for(let n=t.iterRange(i,s),r=i,l;!n.next().done;r+=n.value.length)if(!n.lineBreak)for(;l=e.exec(n.value);)o(r+l.index,l)}class iR{constructor(t){const{regexp:e,decoration:i,decorate:s,boundary:o,maxLength:n=1e3}=t;if(!e.global)throw RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,s)this.addMatch=(t,e,i,o)=>s(o,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,s,o)=>{let n=i(t,e,s);n&&o(s,s+t[0].length,n)};else if(i)this.addMatch=(t,e,s,o)=>o(s,s+t[0].length,i);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=o,this.maxLength=n}createDeco(t){let e=new l.vB,i=e.add.bind(e);for(let{from:e,to:s}of function(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let s=[];for(let{from:o,to:n}of i)o=Math.max(t.state.doc.lineAt(o).from,o-e),n=Math.min(t.state.doc.lineAt(n).to,n+e),s.length&&s[s.length-1].to>=o?s[s.length-1].to=n:s.push({from:o,to:n});return s}(t,this.maxLength))iT(t.state.doc,this.regexp,e,s,(e,s)=>this.addMatch(s,t,e,i));return e.finish()}updateDeco(t,e){let i=1e9,s=-1;return(t.docChanged&&t.changes.iterChanges((e,o,n,r)=>{r>t.view.viewport.from&&n<t.view.viewport.to&&(i=Math.min(n,i),s=Math.max(r,s))}),t.viewportChanged||s-i>1e3)?this.createDeco(t.view):s>-1?this.updateRange(t.view,e.map(t.changes),i,s):e}updateRange(t,e,i,s){for(let o of t.visibleRanges){let n=Math.max(o.from,i),r=Math.min(o.to,s);if(r>n){let i=t.state.doc.lineAt(n),s=i.to<r?t.state.doc.lineAt(r):i,l=Math.max(o.from,i.from),h=Math.min(o.to,s.to);if(this.boundary){for(;n>i.from;n--)if(this.boundary.test(i.text[n-1-i.from])){l=n;break}for(;r<s.to;r++)if(this.boundary.test(s.text[r-s.from])){h=r;break}}let a=[],c,d=(t,e,i)=>a.push(i.range(t,e));if(i==s)for(this.regexp.lastIndex=l-i.from;(c=this.regexp.exec(i.text))&&c.index<h-i.from;)this.addMatch(c,t,c.index+i.from,d);else iT(t.state.doc,this.regexp,l,h,(e,i)=>this.addMatch(i,t,e,d));e=e.update({filterFrom:l,filterTo:h,filter:(t,e)=>t<l||e>h,add:a})}}return e}}let iE=null!=/x/.unicode?"gu":"g",iL=RegExp("[\0-\b\n-\x1f\x7f-\x9f\xadØâââ\u2028\u2029ââ®â¦â§â©\uFEFF-]",iE),iB={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},iV=null,iH=l.sj.define({combine(t){let e=(0,l.QR)(t,{render:null,specialChars:iL,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==iV&&"u">typeof document&&document.body){let e=document.body.style;iV=(null!=(t=e.tabSize)?t:e.MozTabSize)!=null}return iV||!1}())&&(e.specialChars=RegExp(" |"+e.specialChars.source,iE)),e.addSpecialChars&&(e.specialChars=RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,iE)),e}});function iN(t={}){return[iH.of(t),iP||(iP=tT.fromClass(class{constructor(t){this.view=t,this.decorations=tn.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(iH)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new iR({regexp:t.specialChars,decoration:(e,i,s)=>{let{doc:o}=i.state,n=(0,l.vS)(e[0],0);
1if(9==n){let t=o.lineAt(s),e=i.state.tabSize,n=(0,l.y$)(t.text,e,s-t.from);return tn.replace({widget:new iW((e-n%e)*this.view.defaultCharacterWidth)})}return this.decorationCache[n]||(this.decorationCache[n]=tn.replace({widget:new iF(t,n)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(iH);t.startState.facet(iH)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]}let iP=null;class iF extends ts{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){var e;let i=(e=this.code)>=32?"â¢":10==e?"â¤":String.fromCharCode(9216+e),s=t.state.phrase("Control character")+" "+(iB[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,s,i);if(o)return o;let n=document.createElement("span");return n.textContent=i,n.title=s,n.setAttribute("aria-label",s),n.className="cm-specialChar",n}ignoreEvent(){return!1}}class iW extends ts{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function iz(){return iI}let iq=tn.line({class:"cm-activeLine"}),iI=tT.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let s of t.state.selection.ranges){let o=t.lineBlockAt(s.head);o.from>e&&(i.push(iq.range(o.from)),e=o.from)}return tn.set(i)}},{decorations:t=>t.decorations});class iK extends ts{constructor(t){super(),this.content=t}toDOM(){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):this.content),"string"==typeof this.content?t.setAttribute("aria-label","placeholder "+this.content):t.setAttribute("aria-hidden","true"),t}ignoreEvent(){return!1}}function ij(t){return tT.fromClass(class{constructor(e){this.view=e,this.placeholder=tn.set([tn.widget({widget:new iK(t),side:1}).range(0)])}get decorations(){return this.view.state.doc.length?tn.none:this.placeholder}},{decorations:t=>t.decorations})}function iG(t,e){var i;let s,o=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(o),r=o-n.from,h=r>2e3?-1:r==n.length?(i=e.clientX,(s=t.coordsAtPos(t.viewport.from))?Math.round(Math.abs((s.left-i)/t.defaultCharacterWidth)):-1):(0,l.y$)(n.text,t.state.tabSize,o-n.from);return{line:n.number,col:h,off:r}}function i_(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return e7.mouseSelectionStyle.of((t,i)=>{let s,o;return e(i)?(s=iG(t,i),o=t.state.selection,s?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(s.line).from),i=t.state.doc.lineAt(e);s={line:i.number,col:s.col,off:Math.min(s.off,i.length)},o=o.map(t.changes)}},get(e,i,n){let r=iG(t,e);if(!r)return o;let h=function(t,e,i){let s=Math.min(e.line,i.line),o=Math.max(e.line,i.line),n=[];if(e.off>2e3||i.off>2e3||e.col<0||i.col<0){let r=Math.min(e.off,i.off),h=Math.max(e.off,i.off);for(let e=s;e<=o;e++){let i=t.doc.line(e);i.length<=h&&n.push(l.OF.range(i.from+r,i.to+h))}}else{let r=Math.min(e.col,i.col),h=Math.max(e.col,i.col);for(let e=s;e<=o;e++){let i=t.doc.line(e),s=(0,l.kn)(i.text,r,t.tabSize,!0);if(s<0)n.push(l.OF.cursor(i.to));else{let e=(0,l.kn)(i.text,h,t.tabSize);n.push(l.OF.range(i.from+s,i.from+e))}}}return n}(t.state,s,r);return h.length?n?l.OF.create(h.concat(o.ranges)):l.OF.create(h):o}}:null):null})}let i$={Alt:[18,t=>t.altKey],Control:[17,t=>t.ctrlKey],Shift:[16,t=>t.shiftKey],Meta:[91,t=>t.metaKey]},iY={style:"cursor: crosshair"};function iU(t={}){let[e,i]=i$[t.key||"Alt"],s=tT.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventHandlers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)}}});return[s,e7.contentAttributes.of(t=>{var e;return(null==(e=t.plugin(s))?void 0:e.isDown)?iY:null})]}let iX="-10000px";class iQ{constructor(t,e,i){this.facet=e,this.createTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t),this.tooltipViews=this.tooltips.map(i)}update(t){var e;let i=t.state.facet(this.facet),s=i.filter(t=>t);if(i===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let o=[];for(let e=0;e<s.length;e++){let i=s[e],n=-1;
1if(i){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==i.create&&(n=t)}if(n<0)o[e]=this.createTooltipView(i);else{let i=o[e]=this.tooltipViews[n];i.update&&i.update(t)}}}for(let t of this.tooltipViews)0>o.indexOf(t)&&(t.dom.remove(),null==(e=t.destroy)||e.call(t));return this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function iJ(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}let iZ=l.sj.define({combine:t=>{var e,i,s;return{position:j.ios?"absolute":(null==(e=t.find(t=>t.position))?void 0:e.position)||"fixed",parent:(null==(i=t.find(t=>t.parent))?void 0:i.parent)||null,tooltipSpace:(null==(s=t.find(t=>t.tooltipSpace))?void 0:s.tooltipSpace)||iJ}}}),i0=tT.fromClass(class{constructor(t){this.view=t,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(iZ);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new iQ(t,i8,t=>this.createTooltip(t)),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver)for(let t of(this.intersectionObserver.disconnect(),this.manager.tooltipViews))this.intersectionObserver.observe(t.dom)}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t);e&&this.observeIntersection();let i=e||t.geometryChanged,s=t.state.facet(iZ);if(s.position!=this.position){for(let t of(this.position=s.position,this.manager.tooltipViews))t.dom.style.position=this.position;i=!0}if(s.parent!=this.parent){for(let t of(this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t){let e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=iX,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;for(let e of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))e.dom.remove(),null==(t=e.destroy)||t.call(e);null==(e=this.intersectionObserver)||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect();return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(({dom:t})=>t.getBoundingClientRect()),space:this.view.state.facet(iZ).tooltipSpace(this.view)}}writeMeasure(t){let{editor:e,space:i}=t,s=[];for(let o=0;o<this.manager.tooltips.length;o++){let n=this.manager.tooltips[o],r=this.manager.tooltipViews[o],{dom:l}=r,h=t.pos[o],a=t.size[o];if(!h||h.bottom<=Math.max(e.top,i.top)||h.top>=Math.min(e.bottom,i.bottom)||h.right<Math.max(e.left,i.left)-.1||h.left>Math.min(e.right,i.right)+.1){l.style.top=iX;continue}let c=n.arrow?r.dom.querySelector(".cm-tooltip-arrow"):null,d=7*!!c,u=a.right-a.left,f=a.bottom-a.top,p=r.offset||i2,m=this.view.textDirection==tW.LTR,g=a.width>
1i.right-i.left?m?i.left:i.right-a.width:m?Math.min(h.left-14*!!c+p.x,i.right-u):Math.max(i.left,h.left-u+14*!!c-p.x),w=!!n.above;!n.strictSide&&(w?h.top-(a.bottom-a.top)-p.y<i.top:h.bottom+(a.bottom-a.top)+p.y>i.bottom)&&w==i.bottom-h.bottom>h.top-i.top&&(w=!w);let v=w?h.top-f-d-p.y:h.bottom+d+p.y,b=g+u;if(!0!==r.overlap)for(let t of s)t.left<b&&t.right>g&&t.top<v+f&&t.bottom>v&&(v=w?t.top-f-2-d:t.bottom+d+2);"absolute"==this.position?(l.style.top=v-t.parent.top+"px",l.style.left=g-t.parent.left+"px"):(l.style.top=v+"px",l.style.left=g+"px"),c&&(c.style.left=`${h.left+(m?p.x:-p.x)-(g+14-7)}px`),!0!==r.overlap&&s.push({left:g,top:v,right:b,bottom:v+f}),l.classList.toggle("cm-tooltip-above",w),l.classList.toggle("cm-tooltip-below",!w),r.positioned&&r.positioned()}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView)&&(this.inView=this.view.inView,!this.inView))for(let t of this.manager.tooltipViews)t.dom.style.top=iX}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),i1=e7.baseTheme({".cm-tooltip":{zIndex:100},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),i2={x:0,y:0},i8=l.sj.define({enables:[i0,i1]}),i3=l.sj.define();class i9{constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new iQ(t,i3,t=>this.createHostedView(t))}static create(t){return new i9(t)}createHostedView(t){let e=t.create(this.view);return e.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(e.dom),this.mounted&&e.mount&&e.mount(this.view),e}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned()}update(t){this.manager.update(t)}}let i4=i8.compute([i3],t=>{let e=t.facet(i3).filter(t=>t);return 0===e.length?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.filter(t=>null!=t.end).map(t=>t.end)),create:i9.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class i5{constructor(t,e,i,s,o){this.view=t,this.source=e,this.field=i,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{lastMove:t}=this,e=this.view.contentDOM.contains(t.target)?this.view.posAtCoords(t):null;if(null==e)return;let i=this.view.coordsAtPos(e);if(null==i||t.y<i.top||t.y>i.bottom||t.x<i.left-this.view.defaultCharacterWidth||t.x>i.right+this.view.defaultCharacterWidth)return;let s=this.view.bidiSpans(this.view.state.doc.lineAt(e)).find(t=>t.from<=e&&t.to>=e),o=s&&s.dir==tW.RTL?-1:1,n=this.source(this.view,e,t.x<i.left?-o:o);if(null==n?void 0:n.then){let t=this.pending={pos:e};n.then(e=>{this.pending==t&&(this.pending=null,e&&this.view.dispatch({effects:this.setHover.of(e)}
1))},t=>tC(this.view.state,t,"hover tooltip"))}else n&&this.view.dispatch({effects:this.setHover.of(n)})}mousemove(t){var e;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let i=this.active;if(i&&!function(t){for(let e=t;e;e=e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip"))return!0;return!1}(this.lastMove.target)||this.pending){let{pos:s}=i||this.pending,o=null!=(e=null==i?void 0:i.end)?e:s;(s==o?this.view.posAtCoords(this.lastMove)!=s:!function(t,e,i,s,o){let n=document.createRange(),r=t.domAtPos(e),l=t.domAtPos(i);n.setEnd(l.node,l.offset),n.setStart(r.node,r.offset);let h=n.getClientRects();n.detach();for(let t=0;t<h.length;t++){let e=h[t];if(6>=Math.max(e.top-o,o-e.bottom,e.left-s,s-e.right))return!0}return!1}(this.view,s,o,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function i6(t,e={}){let i=l.Pe.define(),s=l.sU.define({create:()=>null,update(t,s){if(t&&(e.hideOnChange&&(s.docChanged||s.selection)||e.hideOn&&e.hideOn(s,t)))return null;if(t&&s.docChanged){let e=s.changes.mapPos(t.pos,-1,l.iR.TrackDel);if(null==e)return null;let i=Object.assign(Object.create(null),t);i.pos=e,null!=t.end&&(i.end=s.changes.mapPos(t.end)),t=i}for(let e of s.effects)e.is(i)&&(t=e.value),e.is(st)&&(t=null);return t},provide:t=>i3.from(t)});return[s,tT.define(o=>new i5(o,t,s,i,e.hoverTime||300)),i4]}function i7(t,e){let i=t.plugin(i0);if(!i)return null;let s=i.manager.tooltips.indexOf(e);return s<0?null:i.manager.tooltipViews[s]}let st=l.Pe.define(),se=l.sj.define({combine(t){let e,i;for(let s of t)e=e||s.topContainer,i=i||s.bottomContainer;return{topContainer:e,bottomContainer:i}}});function si(t,e){let i=t.plugin(ss),s=i?i.specs.indexOf(e):-1;return s>-1?i.panels[s]:null}let ss=tT.fromClass(class{constructor(t){this.input=t.state.facet(sr),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet(se);for(let i of(this.top=new so(t,!0,e.topContainer),this.bottom=new so(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top)),this.panels))i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(t){let e=t.state.facet(se);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new so(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new so(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(sr);if(i!=this.input){let e=i.filter(t=>t),s=[],o=[],n=[],r=[];for(let i of e){let e=this.specs.indexOf(i),l;e<0?(l=i(t.view),r.push(l)):(l=this.panels[e]).update&&l.update(t),s.push(l),(l.top?o:n).push(l)}for(let t of(this.specs=e,this.panels=s,this.top.sync(o),this.bottom.sync(n),r))t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>e7.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class so{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&0>t.indexOf(e)&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=sn(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=sn(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}
1syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function sn(t){let e=t.nextSibling;return t.remove(),e}let sr=l.sj.define({enables:ss});class sl extends l.FB{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}sl.prototype.elementClass="",sl.prototype.toDOM=void 0,sl.prototype.mapMode=l.iR.TrackBefore,sl.prototype.startSide=sl.prototype.endSide=-1,sl.prototype.point=!0;let sh=l.sj.define(),sa={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>l.om.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},sc=l.sj.define();function sd(t){return[sf(),sc.of(Object.assign(Object.assign({},sa),t))]}let su=l.sj.define({combine:t=>t.some(t=>t)});function sf(t){let e=[sp];return t&&!1===t.fixed&&e.push(su.of(!0)),e}let sp=tT.fromClass(class{constructor(t){for(let e of(this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=t.state.facet(sc).map(e=>new sv(t,e)),this.gutters))this.dom.appendChild(e.dom);this.fixed=!t.state.facet(su),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,s=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(s<(i.to-i.from)*.8)}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(su)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=l.om.iter(this.view.state.facet(sh),this.view.viewport.from),s=[],o=this.gutters.map(t=>new sw(t,this.view.viewport,-this.view.documentPadding.top));for(let t of this.view.viewportLineBlocks){let e;if(Array.isArray(t.type)){for(let i of t.type)if(i.type==to.Text){e=i;break}}else e=t.type==to.Text?t:void 0;if(e)for(let n of(s.length&&(s=[]),sg(i,s,t.from),o))n.line(this.view,e,s)}for(let t of o)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(sc),i=t.state.facet(sc),s=t.docChanged||t.heightChanged||t.viewportChanged||!l.om.eq(t.startState.facet(sh),t.state.facet(sh),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(s=!0);else{s=!0;let o=[];for(let s of i){let i=e.indexOf(s);i<0?o.push(new sv(this.view,s)):(this.gutters[i].update(t),o.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),0>o.indexOf(t)&&t.destroy();for(let t of o)this.dom.appendChild(t.dom);this.gutters=o}return s}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>e7.scrollMargins.of(e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==tW.LTR?{left:i.dom.offsetWidth}:{right:i.dom.offsetWidth}:null})});function sm(t){return Array.isArray(t)?t:[t]}function sg(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class sw{constructor(t,e,i){this.gutter=t,this.height=i,this.localMarkers=[],this.i=0,this.cursor=l.om.iter(t.markers,e.from)}line(t,e,i){this.localMarkers.length&&(this.localMarkers=[]),sg(this.cursor,this.localMarkers,e.from);let s=i.length?this.localMarkers.concat(i):this.localMarkers,o=this.gutter.config.lineMarker(t,e,s);o&&s.unshift(o);let n=this.gutter;if(0==s.length&&!n.config.renderEmptyElements)return;let r=e.top-this.height;if(this.i==n.elements.length){let i=new sb(t,e.height,r,s);n.elements.push(i),n.dom.appendChild(i.dom)}else n.elements[this.i].update(t,e.height,r,s);this.height=e.bottom,this.i++}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class sv{constructor(t,e){for(let i in this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="
1cm-gutter"+(this.config.class?" "+this.config.class:""),e.domEventHandlers)this.dom.addEventListener(i,s=>{let o=t.lineBlockAtHeight(s.clientY-t.documentTop);e.domEventHandlers[i](t,o,s)&&s.preventDefault()});this.markers=sm(e.markers(t)),e.initialSpacer&&(this.spacer=new sb(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=sm(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!l.om.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class sb{constructor(t,e,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,s)}update(t,e,i,s){this.height!=e&&(this.dom.style.height=(this.height=e)+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),!function(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}(this.markers,s)&&this.setMarkers(t,s)}setMarkers(t,e){let i="cm-gutterElement",s=this.dom.firstChild;for(let o=0,n=0;;){let r=n,l=o<e.length?e[o++]:null,h=!1;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let t=n;t<this.markers.length;t++)if(this.markers[t].compare(l)){r=t,h=!0;break}}else r=this.markers.length;for(;n<r;){let t=this.markers[n++];if(t.toDOM){t.destroy(s);let e=s.nextSibling;s.remove(),s=e}}if(!l)break;l.toDOM&&(h?s=s.nextSibling:this.dom.insertBefore(l.toDOM(t),s)),h&&n++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}let sy=l.sj.define(),sx=l.sj.define({combine:t=>(0,l.QR)(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let s=i[t],o=e[t];i[t]=s?(t,e,i)=>s(t,e,i)||o(t,e,i):o}return i}})});class sS extends sl{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function sM(t,e){return t.state.facet(sx).formatNumber(e,t.state)}let sk=sc.compute([sx],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(sy),lineMarker:(t,e,i)=>i.some(t=>t.toDOM)?null:new sS(sM(t,t.state.doc.lineAt(e.from).number)),lineMarkerChange:t=>t.startState.facet(sx)!=t.state.facet(sx),initialSpacer:t=>new sS(sM(t,sA(t.state.doc.lines))),updateSpacer(t,e){let i=sM(e.view,sA(e.view.state.doc.lines));return i==t.number?t:new sS(i)},domEventHandlers:t.facet(sx).domEventHandlers}));function sC(t={}){return[sx.of(t),sf(),sk]}function sA(t){let e=9;for(;e<t;)e=10*e+9;return e}let sD=new class extends sl{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},sO=sh.compute(["selection"],t=>{let e=[],i=-1;for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head).from;o>i&&(i=o,e.push(sD.range(o)))}return l.om.of(e)});function sT(){return sO}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.