"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[712],{528:function(t,e,i){let s;i.d(e,{$f:function(){return iv},AE:function(){return iV},Eu:function(){return sa},Nm:function(){return tF},OO:function(){return tD},ZO:function(){return iW},gB:function(){return iJ},hJ:function(){return iU},l9:function(){return ti},lg:function(){return tE},p:function(){return to},tk:function(){return ia}});var o,n,r,l=i(6693),h=i(5604),a=i(5084);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(i){return!1}}function f(t){return 3==t.nodeType?S(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function p(t,e,i,s){return!!i&&(m(t,e,i,s,-1)||m(t,e,i,s,1))}function g(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function m(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 n=t.parentNode;if(!n||1!=n.nodeType)return!1;e=g(t)+(o<0?0:1),t=n}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}function v(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}class b{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 y=null;function x(t){if(t.setActive)return t.setActive();if(y)return t.focus(y);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==y?{get preventScroll(){return y={preventScroll:!0},!0}}:void 0),!y){y=!1;for(let s=0;s<e.length;){let o=e[s++],n=e[s++],r=e[s++];o.scrollTop!=n&&(o.scrollTop=n),o.scrollLeft!=r&&(o.scrollLeft=r)}}}function S(t,e,i=e){let o=s||(s=document.createRange());return o.setEnd(t,i),o.setStart(t,e),o}function M(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 k(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}class C{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new C(t.parentNode,g(t),e)}static after(t,e){return new C(t.parentNode,g(t)+1,e)}}let D=[];class A{constructor(){this.parent=null,this.dom=null,this.dirty=2}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}sync(t,e){if(2&this.dirty){let i=this.dom,s=null,o;for(let n of this.children){if(n.dirty){if(!n.dom&&(o=s?s.nextSibling:i.firstChild)){let r=A.get(o);(!r||!r.parent&&r.canReuseDOM(n))&&n.reuseDOM(o)}n.sync(t,e),n.dirty=0}if(o=s?s.nextSibling:i.firstChild,e&&!e.written&&e.node==i&&o!=n.dom&&(e.written=!0),n.dom.parentNode==i)for(;o&&o!=n.dom;)o=O(o);else i.insertBefore(n.dom,o);s=n.dom}for((o=s?s.nextSibling:i.firstChild)&&e&&e.node==i&&(e.written=!0);o;)o=O(o)}else if(1&this.dirty)for(let l of this.children)l.dirty&&(l.sync(t,e),l.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 o=t.parentNode;if(o==this.dom)break;0==s&&o.firstChild!=o.lastChild&&(s=t==o.firstChild?-1:1),t=o}i=s<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!A.get(i);)i=i.nextSibling;if(!i)return this.length;for(let n=0,r=0;;n++){let l=this.children[n];if(l.dom==i)return r;r+=l.length+l.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 c=this.children[l],d=h+c.length;if(h<t&&d>e)return c.domBoundsAround(t,e,h);if(d>=t&&-1==s&&(s=l,o=h),h>e&&c.dom.parentNode==this.dom){n=l,r=a;break}a=d,h=d+c.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 s=t;s<e;s++){let o=this.children[s];o.parent==this&&o.destroy()}this.children.splice(t,e-t,...i);for(let n=0;n<i.length;n++)i[n].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new T(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}get isWidget(){return!1}get isHidden(){return!1}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 O(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}A.prototype.breakAfter=0;class T{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 f=a[s];f&&o<f.length?(e==s&&(f=f.split(o),o=0),!u&&d&&f.merge(0,o,d,!0,0,h)?n[n.length-1]=f:(o&&f.merge(0,o,null,!1,0,h),n.push(f))):(null==f?void 0:f.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 R(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 u of s)d+=u.length;t.length+=d,E(t,a,c,l,h,s,0,o,n)}let B="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},L="undefined"!=typeof document?document:{documentElement:{style:{}}},V=/Edge\/(\d+)/.exec(B.userAgent),H=/MSIE \d/.test(B.userAgent),N=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(B.userAgent),P=!!(H||N||V),W=!P&&/gecko\/(\d+)/i.test(B.userAgent),z=!P&&/Chrome\/(\d+)/.exec(B.userAgent),F="webkitFontSmoothing"in L.documentElement.style,I=!P&&/Apple Computer/.test(B.vendor),K=I&&(/Mobile\/\w+/.test(B.userAgent)||B.maxTouchPoints>2);var q={mac:K||/Mac/.test(B.platform),windows:/Win/.test(B.platform),linux:/Linux|X11/.test(B.platform),ie:P,ie_version:H?L.documentMode||6:N?+N[1]:V?+V[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:F,safari:I,webkit_version:F?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=L.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class j extends A{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof j&&!(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 j(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 C(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 G(this.dom,t,e)}}class $ extends A{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(k(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,e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,s,o,n){return(!i||!!(i instanceof $&&i.mark.eq(this.mark))&&(!t||!(o<=0))&&(!(e<this.length)||!(n<=0)))&&(R(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 l=this.length-t;return this.length=t,s>-1&&(this.children.length=s,this.markDirty()),new $(this.mark,e,l)}domAtPos(t){return Z(this,t)}coordsAt(t,e){return J(this,t,e)}}function G(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?!(q.chrome||q.gecko)&&(e?(o--,r=1):n<s&&(n++,r=-1)):i<0?o--:n<s&&n++;let l=S(t,o,n).getClientRects();if(!l.length)return null;let h=l[(r?r<0:i>=0)?0:l.length-1];return q.safari&&!r&&0==h.width&&(h=Array.prototype.find.call(l,t=>t.width)||h),r?v(h,r<0):h||null}class _ extends A{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}static create(t,e,i){return new(t.customView||_)(t,e,i)}split(t){let e=_.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,s,o,n){return(!i||i instanceof _&&!!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 instanceof _&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return l.xv.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):l.xv.empty}domAtPos(t){return(this.length?0==t:this.side>0)?C.before(this.dom):C.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let s=this.dom.getClientRects(),o=null;if(!s.length)return null;for(let n=t>0?s.length-1:0;o=s[n],t>0?0!=n:n!=s.length-1&&!(o.top<o.bottom);n+=t>0?-1:1);return this.length?o:v(o,this.side>0)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class X extends _{domAtPos(t){let{topView:e,text:i}=this.widget;return e?U(t,0,e,i,this.length-e.length,(t,e)=>t.domAtPos(e),(t,e)=>new C(t,Math.min(e,t.nodeValue.length))):new C(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,n){if(s instanceof $){let r=0;for(let l=s.dom.firstChild;l;l=l.nextSibling){let h=A.get(l);if(h){let a=d(l,o);if(d(l,e))return r+(a?t(e,i,h,o,n):h.localPosFromDOM(e,i));r+=h.length+(a?n:0)}else{let c=function t(e,i,s){if(3==s.nodeType)return e==s?{result:i}:{size:s.nodeValue.length};if(1!=s.nodeType||"false"==s.contentEditable)return s.contains(e)?{result:0}:{size:0};{let o=0;for(let n=s.firstChild,r=0;;n=n.nextSibling,r++){if(e==s&&r==i)return{result:o};if(!n)return{size:o};let l=t(e,i,n);if(null!=l.result)return{result:i+l.result};o+=l.size}}}(e,i,l);if(null!=c.result)return r+c.result;r+=c.size}}}else if(s.dom==o)return Math.min(i,o.nodeValue.length);return s.localPosFromDOM(e,i)}(t,e,i,s,this.length-i.length):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:s}=this.widget;return i?U(t,e,i,s,this.length-i.length,(t,e,i)=>t.coordsAt(e,i),(t,e,i)=>G(t,e,i)):G(s,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function U(t,e,i,s,o,n,r){if(i instanceof $){for(let l=i.dom.firstChild;l;l=l.nextSibling){let h=A.get(l);if(h){let a=d(l,s),c=h.length+(a?o:0);if(t<c||t==c&&0>=h.getSide())return a?U(t,e,h,s,o,n,r):n(h,t,e);t-=c}else{let u=function t(e,i,s,o){if(3==s.nodeType){let n=s.nodeValue.length;if(e<=n)return o(s,e,i);e-=n}else if(1==s.nodeType&&"false"!=s.contentEditable)for(let r=s.firstChild;r;r=r.nextSibling){let l=t(e,i,r,o);if("number"!=typeof l)return l;e=l}return e}(t,e,l,r);if("number"!=typeof u)return u;t=u}}return n(i,i.length,-1)}return i.dom==s?r(s,t,e):n(i,t,e)}class Y extends A{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof Y&&t.side==this.side}split(){return new Y(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 this.side>0?C.before(this.dom):C.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return l.xv.empty}get isHidden(){return!0}}function Z(t,e){let i=t.dom,{children:s}=t,o=0;for(let n=0;o<s.length;o++){let r=s[o],l=n+r.length;if(!(l==n&&0>=r.getSide())){if(e>n&&e<l&&r.dom.parentNode==i)return r.domAtPos(e-n);if(e<=n)break;n=l}}for(let h=o;h>0;h--){let a=s[h-1];if(a.dom.parentNode==i)return a.domAtPos(a.length)}for(let c=o;c<s.length;c++){let d=s[c];if(d.dom.parentNode==i)return d.domAtPos(0)}return new C(i,0)}function J(t,e,i){let s=null,o=-1,n=null,r=-1;!function t(e,l){for(let h=0,a=0;h<e.children.length&&a<=l;h++){let c=e.children[h],d=a+c.length;d>=l&&(c.children.length?t(c,l-a):(!n||n.isHidden&&i>0)&&(d>l||a==d&&c.getSide()>0)?(n=c,r=l-a):(a<l||a==d&&0>c.getSide()&&!c.isHidden)&&(s=c,o=l-a)),a=d}}(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 Q(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 tt(t,e){if(t==e)return!0;if(!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 te(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 n in i)e&&e[n]==i[n]||t.setAttribute(s=n,i[n]);return!!s}j.prototype.children=_.prototype.children=Y.prototype.children=D;class ti{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return -1}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get customView(){return null}get isHidden(){return!1}destroy(t){}}var ts=((o=ts||(ts={}))[o.Text=0]="Text",o[o.WidgetBefore=1]="WidgetBefore",o[o.WidgetAfter=2]="WidgetAfter",o[o.WidgetRange=3]="WidgetRange",o);class to extends l.uU{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 tn(t)}static widget(t){let e=t.side||0,i=!!t.block;return e+=i?e>0?3e8:-4e8:e>0?1e8:-1e8,new tl(t,e,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}=th(t,e);i=(o?e?-3e8:-1:5e8)-1,s=(n?e?2e8:1:-6e8)+1}return new tl(t,i,s,e,t.widget||null,!0)}static line(t){return new tr(t)}static set(t,e=!1){return l.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}to.none=l.Xs.empty;class tn extends to{constructor(t){let{start:e,end:i}=th(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 tn&&this.tagName==t.tagName&&this.class==t.class&&tt(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw RangeError("Mark decorations may not be empty");return super.range(t,e)}}tn.prototype.point=!1;class tr extends to{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof tr&&this.spec.class==t.spec.class&&tt(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)}}tr.prototype.mapMode=l.gc.TrackBefore,tr.prototype.point=!0;class tl extends to{constructor(t,e,i,s,o,n){super(e,i,o,t),this.block=s,this.isReplace=n,this.mapMode=s?e<=0?l.gc.TrackBefore:l.gc.TrackAfter:l.gc.TrackDel}get type(){return this.startSide<this.endSide?ts.WidgetRange:this.startSide<=0?ts.WidgetBefore:ts.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}eq(t){var e,i;return t instanceof tl&&((e=this.widget)==(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 th(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 ta(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)}tl.prototype.point=!0;class tc extends A{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 tc))return!1;this.dom||i.transferDOM(this)}return s&&this.setDeco(i?i.attrs:null),R(this,t,e,i?i.children:[],o,n),!0}split(t){let e=new tc;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 o=i;o<this.children.length;o++)e.append(this.children[o],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){tt(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=Q(e,this.attrs||{})),i&&(this.attrs=Q({class:i},this.attrs||{}))}domAtPos(t){return Z(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(k(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&&(te(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let s=this.dom.lastChild;for(;s&&A.get(s) instanceof $;)s=s.lastChild;if(!s||!this.length||"BR"!=s.nodeName&&(null===(i=A.get(s))||void 0===i?void 0:i.isEditable)==!1&&(!q.ios||!this.children.some(t=>t instanceof j))){let o=document.createElement("BR");o.cmIgnore=!0,this.dom.appendChild(o)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t=0,e;for(let i of this.children){if(!(i instanceof j)||/[^ -~]/.test(i.text))return null;let s=f(i.dom);if(1!=s.length)return null;t+=s[0].width,e=s[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(t,e){let i=J(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:s}=this.parent.view.viewState,o=i.bottom-i.top;if(2>Math.abs(o-s.lineHeight)&&s.textHeight<o){let n=(o-s.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}get type(){return ts.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 tc)return o;if(n>e)break}s=n+o.breakAfter}return null}}class td extends A{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 td&&!!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?C.before(this.dom):C.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new td(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return D}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):l.xv.empty}domBoundsAround(){return null}become(t){return t instanceof td&&t.type==this.type&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(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)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class tu{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.bufferMarks=[],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 td&&t.type==ts.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new tc),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(tf(new Y(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(tf(new j(this.text.slice(this.textOff,this.textOff+r)),e),i),this.atCursorPos=!0,this.textOff+=r,t-=r,i=0}}span(t,e,i,s){this.buildText(e-t,i,s),this.pos=e,this.openStart<0&&(this.openStart=s)}point(t,e,i,s,o,n){if(this.disallowBlockEffectsFor[n]&&i instanceof tl){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 tl){if(i.block){let{type:l}=i;l!=ts.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new td(i.widget||new tp("div"),r,l))}else{let h=_.create(i.widget||new tp("span"),r,r?0:i.startSide),a=this.atCursorPos&&!h.isEditable&&o<=s.length&&(t<e||i.startSide>0),c=!h.isEditable&&(t<e||o>s.length||i.startSide<=0),d=this.getLine();2!=this.pendingBuffer||a||h.isEditable||(this.pendingBuffer=0),this.flushBuffer(s),a&&(d.append(tf(new Y(1),s),o),o=s.length+Math.max(0,o-s.length)),d.append(tf(h,s),o),this.atCursorPos=c,this.pendingBuffer=c?t<e||o>s.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}}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 tu(t,e,i,o);return n.openEnd=l.Xs.spans(s,e,i,n),n.openStart<0&&(n.openStart=n.openEnd),n.finish(n.openEnd),n}}function tf(t,e){for(let i of e)t=new $(i,[t],t.length);return t}class tp extends ti{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}get isHidden(){return!0}}let tg=l.r$.define(),tm=l.r$.define(),tw=l.r$.define(),tv=l.r$.define(),tb=l.r$.define(),ty=l.r$.define(),tx=l.r$.define(),tS=l.r$.define({combine:t=>t.some(t=>t)}),tM=l.r$.define({combine:t=>t.some(t=>t)});class tk{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 tk(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}let tC=l.Py.define({map:(t,e)=>t.map(e)});function tD(t,e,i){let s=t.facet(tv);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.r$.define({combine:t=>!t.length||t[0]}),tO=0,tT=l.r$.define();class tE{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 tE(tO++,t,i,t=>{let e=[tT.of(t)];return o&&e.push(tV.of(e=>{let i=e.plugin(t);return i?o(i):to.none})),s&&e.push(s(t)),e})}static fromClass(t,e){return tE.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 e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(s){if(tD(e.state,s,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(i){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(o){tD(t.state,o,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(i){tD(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}let tB=l.r$.define(),tL=l.r$.define(),tV=l.r$.define(),tH=l.r$.define(),tN=l.r$.define(),tP=l.r$.define();class tW{constructor(t,e,i,s){this.fromA=t,this.toA=e,this.fromB=i,this.toB=s}join(t){return new tW(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 c=e[o],d=e[o+1],u=Math.max(r,c),f=Math.min(a,d);if(u<=f&&new tW(u+h,f+h,u,f).addToSet(i),d>a)break;o+=2}if(!l)return i;new tW(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),n=l.toA,r=l.toB}}}class tz{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.as.empty(this.startState.doc.length),i))this.changes=this.changes.compose(s.changes);let o=[];this.changes.iterChangedRanges((t,e,i,s)=>o.push(new tW(t,e,i,s))),this.changedRanges=o}static create(t,e,i){return new tz(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 tF=((n=tF||(tF={}))[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n);let tI=tF.LTR,tK=tF.RTL;function tq(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}let tj=tq("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),t$=tq("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),tG=Object.create(null),t_=[];for(let tX of["()","[]","{}"]){let tU=tX.charCodeAt(0),tY=tX.charCodeAt(1);tG[tU]=tY,tG[tY]=-tU}let tZ=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class tJ{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?tK:tI}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 tQ=[];function t0(t){return[new tJ(0,t,0)]}let t1="";class t2{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(l.yy.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 o=s.nextSibling;if(o==e)break;let n=A.get(s),r=A.get(o);(n&&r?n.breakAfter:(n?n.breakAfter:t8(s))||t8(o)&&("BR"!=s.nodeName||s.cmIgnore))&&this.lineBreak(),s=o}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 s=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let n=-1,r=1,l;if(this.lineSeparator?(n=e.indexOf(this.lineSeparator,s),r=this.lineSeparator.length):(l=o.exec(e))&&(n=l.index,r=l[0].length),this.append(e.slice(s,n<0?e.length:n)),n<0)break;if(this.lineBreak(),r>1)for(let h of this.points)h.node==t&&h.pos>this.text.length&&(h.pos-=r-1);s=n+r}}readNode(t){if(t.cmIgnore)return;let e=A.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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 t8(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class t3{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class t9 extends A{constructor(t){super(),this.view=t,this.compositionDeco=to.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 tc],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new tW(0,0,0,t.state.doc.length)],0)}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=to.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=function(t,e){let i=t4(t);if(!i)return to.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 t2([],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 to.none;l=h-c.length}}else if(a.doc.sliceString(l,h,"￿")!=c)return to.none;let d=A.get(n);return d instanceof X?d=d.widget.topView:d&&(d.parent=null),to.set(to.replace({widget:new t6(n,r,d),inclusive:!0}).range(l,h))}(this.view,t.changes)),(q.ie||q.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 et,l.Xs.compare(e,i,s,o),o.changes);return n=tW.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=q.chrome||q.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,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 o of this.children)o instanceof td&&o.widget instanceof t5&&s.push(o.dom);i.updateGaps(s)}updateChildren(t,e){let i=this.childCursor(e);for(let s=t.length-1;;s--){let o=s>=0?t[s]:null;if(!o)break;let{fromA:n,toA:r,fromB:l,toB:h}=o,{content:a,breakAtStart:c,openStart:d,openEnd:u}=tu.build(this.view.state.doc,l,h,this.decorations,this.dynamicDecorationMap),{i:f,off:p}=i.findPos(r,1),{i:g,off:m}=i.findPos(n,-1);E(this,g,m,f,p,a,c,d,u)}}updateSelection(t=!1,e=!1){var i;(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let s=this.view.root.activeElement,o=s==this.dom,n=!o&&u(this.dom,this.view.observer.selectionRange)&&!(s&&this.dom.contains(s));if(!(o||e||n))return;let r=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,h=this.domAtPos(l.anchor),a=l.empty?h:this.domAtPos(l.head);if(q.gecko&&l.empty&&!this.compositionDeco.size&&1==(i=h).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 d=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(d,h.node.childNodes[h.offset]||null)),h=a=new C(d,0),r=!0}let f=this.view.observer.selectionRange;!r&&f.focusNode&&p(h.node,h.offset,f.anchorNode,f.anchorOffset)&&p(a.node,a.offset,f.focusNode,f.focusOffset)||(this.view.observer.ignore(()=>{q.android&&q.chrome&&this.dom.contains(f.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}(f.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=c(this.view.root);if(t){if(l.empty){if(q.gecko){var e,i;let o=(e=h.node,i=h.offset,1!=e.nodeType?0:(i&&"false"==e.childNodes[i-1].contentEditable?1:0)|(i<e.childNodes.length&&"false"==e.childNodes[i].contentEditable?2:0));if(o&&3!=o){let r=t7(h.node,h.offset,1==o?1:-1);r&&(h=new C(r,1==o?0:r.nodeValue.length))}}t.collapse(h.node,h.offset),null!=l.bidiLevel&&null!=f.cursorBidiLevel&&(f.cursorBidiLevel=l.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(a.node,a.offset)}catch(d){}}else{let u=document.createRange();l.anchor>l.head&&([h,a]=[a,h]),u.setEnd(a.node,a.offset),u.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(u)}}n&&this.view.root.activeElement==this.dom&&(this.dom.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,a)),this.impreciseAnchor=h.precise?null:new C(f.anchorNode,f.anchorOffset),this.impreciseHead=a.precise?null:new C(f.focusNode,f.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=c(t.root),{anchorNode:s,anchorOffset:o}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let n=tc.find(this,e.head);if(!n)return;let r=n.posAtStart;if(e.head==r||e.head==r+n.length)return;let l=this.coordsAt(e.head,-1),h=this.coordsAt(e.head,1);if(!l||!h||l.bottom>h.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let d=t.observer.selectionRange;t.docView.posFromDOM(d.anchorNode,d.anchorOffset)!=e.from&&i.collapse(s,o)}nearest(t){for(let e=t;e;){let i=A.get(e);if(i&&i.rootView==this)return i;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 s=this.children[e];if(i<s.length||s instanceof tc)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!=ts.WidgetBefore&&o.type!=ts.WidgetAfter&&(!s||2==e||this.children[s-1].breakAfter||this.children[s-1].type==ts.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==tF.LTR;for(let h=0,a=0;a<this.children.length;a++){let c=this.children[a],d=h+c.length;if(d>s)break;if(h>=i){let u=c.dom.getBoundingClientRect();if(e.push(u.height),n){let p=c.dom.lastChild,g=p?f(p):[];if(g.length){let m=g[g.length-1],w=l?m.right-u.left:u.right-m.left;w>r&&(r=w,this.minWidth=o,this.minWidthFrom=h,this.minWidthTo=d)}}}h=d+c.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?tF.RTL:tF.LTR}measureTextSize(){for(let t of this.children)if(t instanceof tc){let e=t.measureTextSize();if(e)return e}let i=document.createElement("div"),s,o,n;return i.className="cm-line",i.style.width="99999px",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(i);let t=f(i.firstChild)[0];s=i.getBoundingClientRect().height,o=t?t.width/27:7,n=t?t.height:s,i.remove()}),{lineHeight:s,charWidth:o,textHeight:n}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new T(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 r=e.lineBlockAt(n).bottom-e.lineBlockAt(i).top;t.push(to.replace({widget:new t5(r),block:!0,inclusive:!0,isBlockGap:!0}).range(i,n))}if(!o)break;i=o.to+1}return to.set(t)}updateDeco(){let t=this.view.state.facet(tV).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 h of this.view.state.facet(tN).map(t=>t(this.view)))if(h){let{left:a,right:c,top:d,bottom:u}=h;null!=a&&(o=Math.max(o,a)),null!=c&&(n=Math.max(n,c)),null!=d&&(r=Math.max(r,d)),null!=u&&(l=Math.max(l,u))}let f={left:i.left-o,top:i.top-r,right:i.right+n,bottom:i.bottom+l};!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 d,u=c==h.body;if(u)d={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 f=c.getBoundingClientRect();d={left:f.left,right:f.left+c.clientWidth,top:f.top,bottom:f.top+c.clientHeight}}let p=0,g=0;if("nearest"==o)e.top<d.top?(g=-(d.top-e.top+r),i>0&&e.bottom>d.bottom+g&&(g=e.bottom-d.bottom+g+r)):e.bottom>d.bottom&&(g=e.bottom-d.bottom+r,i<0&&e.top-g<d.top&&(g=-(d.top+g-e.top+r)));else{let m=e.bottom-e.top,w=d.bottom-d.top;g=("center"==o&&m<=w?e.top+m/2-w/2:"start"==o||"center"==o&&i<0?e.top-r:e.bottom-w+r)-d.top}if("nearest"==s?e.left<d.left?(p=-(d.left-e.left+n),i>0&&e.right>d.right+p&&(p=e.right-d.right+p+n)):e.right>d.right&&(p=e.right-d.right+n,i<0&&e.left<d.left+p&&(p=-(d.left+p-e.left+n))):p=("center"==s?e.left+(e.right-e.left)/2-(d.right-d.left)/2:"start"==s==l?e.left-n:e.right-(d.right-d.left)+n)-d.left,p||g){if(u)a.scrollBy(p,g);else{let v=0,b=0;if(g){let y=c.scrollTop;c.scrollTop+=g,b=c.scrollTop-y}if(p){let x=c.scrollLeft;c.scrollLeft+=p,v=c.scrollLeft-x}e={left:e.left-v,top:e.top-b,right:e.right-v,bottom:e.bottom-b},v&&1>Math.abs(v-p)&&(s="nearest"),b&&1>Math.abs(b-g)&&(o="nearest")}}if(u)break;c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,f,e.head<e.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==tF.LTR)}}class t5 extends ti{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 t4(t){let e=t.observer.selectionRange,i=e.focusNode&&t7(e.focusNode,e.focusOffset,0);if(!i)return null;let s=t.docView.nearest(i);if(!s)return null;if(s instanceof tc){let o=i;for(;o.parentNode!=s.dom;)o=o.parentNode;let n=o.previousSibling;for(;n&&!A.get(n);)n=n.previousSibling;let r=n?A.get(n).posAtEnd:s.posAtStart;return{from:r,to:r,node:o,text:i}}{for(;;){let{parent:l}=s;if(!l)return null;if(l instanceof tc)break;s=l}let h=s.posAtStart;return{from:h,to:h+s.length,node:s.dom,text:i}}}class t6 extends ti{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 X}}function t7(t,e,i){if(i<=0)for(let s=t,o=e;;){if(3==s.nodeType)return s;if(1==s.nodeType&&o>0)o=w(s=s.childNodes[o-1]);else break}if(i>=0)for(let n=t,r=e;;){if(3==n.nodeType)return n;if(1==n.nodeType&&r<n.childNodes.length&&i>=0)n=n.childNodes[r],r=0;else break}return null}class et{constructor(){this.changes=[]}compareRange(t,e){ta(t,e,this.changes)}comparePoint(t,e){ta(t,e,this.changes)}}function ee(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function ei(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function es(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function eo(t,e,i){let s=t.nodeValue.length,o=-1,n=1e9,r=0;for(let l=0;l<s;l++){let h=S(t,l,l+1).getClientRects();for(let a=0;a<h.length;a++){let c=h[a];if(c.top==c.bottom)continue;r||(r=e-c.left);let d=(c.top>i?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&d<n){let u=e>=(c.left+c.right)/2,f=u;if((q.chrome||q.gecko)&&S(t,l).getBoundingClientRect().left==c.right&&(f=!u),d<=0)return{node:t,offset:l+(f?1:0)};o=l+(f?1:0),n=d}}}return{node:t,offset:o>-1?o:r>0?t.nodeValue.length:0}}function en(t,e,i,s=-1){var o,n;let r=t.contentDOM.getBoundingClientRect(),l=r.top+t.viewState.paddingTop,h,{docHeight:a}=t.viewState,{x:c,y:d}=e,u=d-l;if(u<0)return 0;if(u>a)return t.state.doc.length;for(let p=t.defaultLineHeight/2,g=!1;(h=t.elementAtHeight(u)).type!=ts.Text;)for(;!((u=s>0?h.bottom+p:h.top-p)>=0)||!(u<=a);){if(g)return i?null:0;g=!0,s=-s}d=l+u;let m=h.from;if(m<t.viewport.from)return 0==t.viewport.from?0:i?null:er(t,r,h,c,d);if(m>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:er(t,r,h,c,d);let w=t.dom.ownerDocument,v=t.root.elementFromPoint?t.root:w,b=v.elementFromPoint(c,d);b&&!t.contentDOM.contains(b)&&(b=null),!b&&(c=Math.max(r.left+1,Math.min(r.right-1,c)),(b=v.elementFromPoint(c,d))&&!t.contentDOM.contains(b)&&(b=null));let y,x=-1;if(b&&(null===(o=t.docView.nearest(b))||void 0===o?void 0:o.isEditable)!=!1){if(w.caretPositionFromPoint){let M=w.caretPositionFromPoint(c,d);M&&({offsetNode:y,offset:x}=M)}else if(w.caretRangeFromPoint){let k=w.caretRangeFromPoint(c,d);k&&({startContainer:y,startOffset:x}=k,(!t.contentDOM.contains(y)||q.safari&&function(t,e,i){let s;if(3!=t.nodeType||e!=(s=t.nodeValue.length))return!1;for(let o=t.nextSibling;o;o=o.nextSibling)if(1!=o.nodeType||"BR"!=o.nodeName)return!1;return S(t,s-1,s).getBoundingClientRect().left>i}(y,x,c)||q.chrome&&function(t,e,i){if(0!=e)return!1;for(let s=t;;){let o=s.parentNode;if(!o||1!=o.nodeType||o.firstChild!=s)return!1;if(o.classList.contains("cm-line"))break;s=o}return i-(1==t.nodeType?t.getBoundingClientRect():S(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}(y,x,c))&&(y=void 0))}}if(!y||!t.docView.dom.contains(y)){let C=tc.find(t.docView,m);if(!C)return u>h.top+h.height/2?h.to:h.from;({node:y,offset:x}=function t(e,i,s){let o,n,r,l,h,a,c,d,u=!1;for(let p=e.firstChild;p;p=p.nextSibling){let g=f(p);for(let m=0;m<g.length;m++){var w,v;let b=g[m];a&&ee(a,b)&&(b=ei(es(b,a.bottom),a.top));let y=(w=b).left>i?w.left-i:Math.max(0,i-w.right),x=(v=b).top>s?v.top-s:Math.max(0,s-v.bottom);if(0==y&&0==x)return 3==p.nodeType?eo(p,i,s):t(p,i,s);if(!h||d>x||d==x&&c>y){h=p,a=b,c=y,d=x;let S=x?s<b.top?-1:1:y?i<b.left?-1:1:0;u=!S||(S>0?m<g.length-1:m>0)}0==y?s>b.bottom&&(!r||r.bottom<b.bottom)?(o=p,r=b):s<b.top&&(!l||l.top>b.top)&&(n=p,l=b):r&&ee(r,b)?r=es(r,b.bottom):l&&ee(l,b)&&(l=ei(l,b.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 M=Math.max(a.left,Math.min(a.right,i));if(3==h.nodeType)return eo(h,M,s);if(u&&"false"!=h.contentEditable)return t(h,M,s);let k=Array.prototype.indexOf.call(e.childNodes,h)+(i>=(a.left+a.right)/2?1:0);return{node:e,offset:k}}(C.dom,c,d))}let D=t.docView.nearest(y);if(!D)return null;if(!D.isWidget||(null===(n=D.dom)||void 0===n?void 0:n.nodeType)!=1)return D.localPosFromDOM(y,x)+D.posAtStart;{let A=D.dom.getBoundingClientRect();return e.y<A.top||e.y<=A.bottom&&e.x<=(A.left+A.right)/2?D.posAtStart:D.posAtEnd}}function er(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.Gz)(r,n,t.state.tabSize)}function el(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 c=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 a=e[e.length-1];a.level!=i&&(r=a.side(!0,i),h=e.length-1)}h<0&&(h=tJ.find(e,r,null!==(n=s.bidiLevel)&&void 0!==n?n:-1,s.assoc));let c=e[h];r==c.side(o,i)&&(r=(c=e[h+=o?1:-1]).side(!o,i));let d=o==(c.dir==i),u=(0,l.cp)(t.text,r,d);if(t1=t.text.slice(Math.min(r,u),Math.max(r,u)),u!=c.side(o,i))return l.jT.cursor(u+t.from,d?-1:1,c.level);let f=h==(o?e.length-1:0)?null:e[h+(o?1:-1)];return f||c.level==i?f&&f.level<c.level?l.jT.cursor(f.side(!o,i)+t.from,o?1:-1,f.level):l.jT.cursor(u+t.from,o?-1:1,c.level):l.jT.cursor(o?t.to:t.from,o?-1:1,i)}(o,n,r,h,i),d=t1;if(!c){if(o.number==(i?t.state.doc.lines:1))return h;d="\n",o=t.state.doc.line(o.number+(i?1:-1)),n=t.bidiSpans(o),c=l.jT.cursor(i?o.from:o.to)}if(a){if(!a(d))return h}else{if(!s)return c;a=s(d)}h=c}}function eh(t,e,i){let s=t.state.facet(tH).map(e=>e(t));for(;;){let o=!1;for(let n of s)n.between(i.from-1,i.from+1,(t,s,n)=>{i.from>t&&i.from<s&&(i=e.head>i.from?l.jT.cursor(t,1):l.jT.cursor(s,-1),o=!0)});if(!o)return i}}class ea{constructor(t){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.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let e=(e,i)=>{!this.ignoreDuringComposition(i)&&("keydown"==i.type&&this.keydown(t,i)||(this.mustFlushObserver(i)&&t.observer.forceFlush(),this.runCustomHandlers(i.type,t,i)?i.preventDefault():e(t,i)))};for(let i in em){let s=em[i];t.contentDOM.addEventListener(i,i=>{eg(t,i)&&e(s,i)},ew[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(em.mousedown,i),!i.defaultPrevented&&2==i.button)){let s=t.contentDOM.style.minHeight;t.contentDOM.style.minHeight="100%",setTimeout(()=>t.contentDOM.style.minHeight=s,200)}}),t.scrollDOM.addEventListener("drop",i=>{i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&e(em.drop,i)}),q.chrome&&102==q.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,q.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?void 0:i.domEventHandlers)for(let n in this.customHandlers.push({plugin:o.value,handlers:s}),s)0>this.registeredEvents.indexOf(n)&&"scroll"!=n&&(this.registeredEvents.push(n),t.contentDOM.addEventListener(n,e=>{eg(t,e)&&this.runCustomHandlers(n,t,e)&&e.preventDefault()}))}runCustomHandlers(t,e,i){for(let s of this.customHandlers){let o=s.handlers[t];if(o)try{if(o.call(s.plugin,i,e)||i.defaultPrevented)return!0}catch(n){tD(e.state,n)}}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(o){tD(t.state,o)}}}keydown(t,e){let i;return this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!!(9==e.keyCode&&Date.now()<this.lastEscPress+2e3)||((27!=e.keyCode&&0>eu.indexOf(e.keyCode)&&(t.inputState.lastEscPress=0),q.android&&q.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))?(t.observer.delayAndroidKey(e.key,e.keyCode),!0):!!(q.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((i=ec.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||ed.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,M(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(q.safari&&!q.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!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 ec=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ed="dthko",eu=[16,17,18,20,91,92,224,225];function ef(t){return .7*Math.max(0,t)+8}class ep{constructor(t,e,i,s){let o,n;this.view=t,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else if(11==i.nodeType)i=i.host;else break;return null}(t.contentDOM);let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(l.yy.allowMultipleSelections)&&((o=t.state.facet(tg)).length?o[0](e):q.mac?e.metaKey:e.ctrlKey),this.dragMove=(n=t.state.facet(tm)).length?n[0](e):q.mac?!e.altKey:!e.ctrlKey,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 n=0;n<o.length;n++){let r=o[n];if(r.left<=e.clientX&&r.right>=e.clientX&&r.top<=e.clientY&&r.bottom>=e.clientY)return!0}return!1}(t,e)&&1==eO(e)&&null}start(t){!1===this.dragging&&(t.preventDefault(),this.select(t))}move(t){var e;if(0==t.buttons)return this.destroy();if(!1!==this.dragging)return;this.select(this.lastEvent=t);let i=0,s=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight};t.clientX<=o.left+6?i=-ef(o.left-t.clientX):t.clientX>=o.right-6&&(i=ef(t.clientX-o.right)),t.clientY<=o.top+6?s=-ef(o.top-t.clientY):t.clientY>=o.bottom-6&&(s=ef(t.clientY-o.bottom)),this.setScrollSpeed(i,s)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}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"}),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 eg(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=A.get(i))&&s.ignoreEvent(e))return!1;return!0}let em=Object.create(null),ew=Object.create(null),ev=q.ie&&q.ie_version<15||q.ios&&q.webkit_version<604;function eb(t,e){let{state:i}=t,s,o=1,n=i.toText(e),r=n.lines==i.selection.ranges.length;if(null!=eE&&i.selection.ranges.every(t=>t.empty)&&eE==n.toString()){let h=-1;s=i.changeByRange(t=>{let s=i.doc.lineAt(t.from);if(s.from==h)return{range:t};h=s.from;let a=i.toText((r?n.line(o++).text:e)+i.lineBreak);return{changes:{from:s.from,insert:a},range:l.jT.cursor(t.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.jT.cursor(t.from+e.length)}}):i.replaceSelection(n);t.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}function ey(t,e,i,s){if(1==s)return l.jT.cursor(e,i);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.jT.cursor(e);0==n?i=1:n==o.length&&(i=-1);let r=n,h=n;i<0?r=(0,l.cp)(o.text,n,!1):h=(0,l.cp)(o.text,n);let a=s(o.text.slice(r,h));for(;r>0;){let c=(0,l.cp)(o.text,r,!1);if(s(o.text.slice(c,r))!=a)break;r=c}for(;h<o.length;){let d=(0,l.cp)(o.text,h);if(s(o.text.slice(h,d))!=a)break;h=d}return l.jT.range(r+o.from,h+o.from)}(t.state,e,i);{let o=tc.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.jT.range(r,h)}}em.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now())},em.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},em.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},ew.touchstart=ew.touchmove={passive:!0},em.mousedown=(t,e)=>{let i,s,o;if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let n=null;for(let r of t.state.facet(tw))if(n=r(t,e))break;if(n||0!=e.button||(i=eM(t,e),s=eO(e),o=t.state.selection,n={update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),o=o.map(t.changes))},get(e,n,r){let h=eM(t,e),a,c=ey(t,h.pos,h.bias,s);if(i.pos!=h.pos&&!n){let d=ey(t,i.pos,i.bias,s),u=Math.min(d.from,c.from),f=Math.max(d.to,c.to);c=u<c.from?l.jT.range(u,f):l.jT.range(f,u)}return n?o.replaceRange(o.main.extend(c.from,c.to)):r&&1==s&&o.ranges.length>1&&(a=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:s,to:o}=t.ranges[i];if(s<=e&&o>=e)return l.jT.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(o,h.pos))?a:r?o.addRange(c):l.jT.create([c])}}),n){let h=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new ep(t,e,n,h)),h&&t.observer.ignore(()=>x(t.contentDOM)),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let ex=(t,e)=>t>=e.top&&t<=e.bottom,eS=(t,e,i)=>ex(e,i)&&t>=i.left&&t<=i.right;function eM(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:function(t,e,i,s){let o=tc.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&&eS(i,s,r))return -1;let l=o.coordsAt(n,1);return l&&eS(i,s,l)?1:r&&ex(s,r)?-1:1}(t,i,e.clientX,e.clientY)}}let ek=q.ie&&q.ie_version<=11,eC=null,eD=0,eA=0;function eO(t){if(!ek)return t.detail;let e=eC,i=eA;return eC=t,eA=Date.now(),eD=!e||i>Date.now()-400&&2>Math.abs(e.clientX-t.clientX)&&2>Math.abs(e.clientY-t.clientY)?(eD+1)%3:1}function eT(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"})}em.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")},em.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&&eT(t,e,s.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let r=0;r<i.length;r++){let l=new FileReader;l.onerror=n,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(s[r]=l.result),n()},l.readAsText(i[r])}}else eT(t,e,e.dataTransfer.getData("Text"),!0)},em.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=ev?null:e.clipboardData;i?(eb(t,i.getData("text/plain")||i.getData("text/uri-text")),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(),eb(t,i.value)},50)}(t)};let eE=null;em.copy=em.cut=(t,e)=>{let{text:i,ranges:s,linewise:o}=function(t){let e=[],i=[],s=!1;for(let o of t.selection.ranges)o.empty||(e.push(t.sliceDoc(o.from,o.to)),i.push(o));if(!e.length){let n=-1;for(let{from:r}of t.selection.ranges){let l=t.doc.lineAt(r);l.number>n&&(e.push(l.text),i.push({from:l.from,to:Math.min(t.doc.length,l.to+1)})),n=l.number}s=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:s}}(t.state);if(!i&&!o)return;eE=o?i:null;let n=ev?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"})};let eR=l.q6.define();function eB(t,e){let i=[];for(let s of t.facet(tx)){let o=s(t,e);o&&i.push(o)}return i?t.update({effects:i,annotations:eR.of(!0)}):null}function eL(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=eB(t.state,e);i?t.dispatch(i):t.update([])}},10)}em.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),eL(t)},em.blur=t=>{t.observer.clearSelectionRange(),eL(t)},em.compositionstart=em.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},em.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,q.chrome&&q.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])},50)},em.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},em.beforeinput=(t,e)=>{var i;let s;if(q.chrome&&q.android&&(s=ec.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.key)){let o=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout(()=>{var e;((null===(e=window.visualViewport)||void 0===e?void 0:e.height)||0)>o+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}};let eV=["pre-wrap","normal","pre-line","break-spaces"];class eH{constructor(t){this.lineWrapping=t,this.doc=l.xv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,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.max(0,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 eV.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,n){let r=eV.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=s,this.lineLength=o,l){this.heightSamples={};for(let h=0;h<n.length;h++){let a=n[h];a<0?h++:this.heightSamples[Math.floor(10*a)]=!0}}return l}}class eN{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class eP{constructor(t,e,i,s,o,n){this.from=t,this.length=e,this.top=i,this.height=s,this.children=o,this.deco=n}get type(){var t,e,i;return null!==(i=null!==(t=this.children)&&void 0!==t?t:null===(e=this.deco)||void 0===e?void 0:e.type)&&void 0!==i?i:ts.Text}get widget(){return this.deco&&this.deco.widget}get to(){return this.from+this.length}get bottom(){return this.top+this.height}join(t){let e=(this.children||[this]).concat(t.children||[t]);return new eP(this.from,this.length+t.length,this.top,this.height+t.height,e,null)}}var eW=((r=eW||(eW={}))[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r);class ez{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=(t?2:0)|-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 ez.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,s){let o=this,n=i.doc;for(let r=s.length-1;r>=0;r--){let{fromA:l,toA:h,fromB:a,toB:c}=s[r],d=o.lineAt(l,eW.ByPosNoHeight,i.setDoc(e),0,0),u=d.to>=h?d:o.lineAt(h,eW.ByPosNoHeight,i,0,0);for(c+=u.to-h,h=u.to;r>0&&d.from<=s[r-1].toA;)l=s[r-1].fromA,a=s[r-1].fromB,r--,l<d.from&&(d=o.lineAt(l,eW.ByPosNoHeight,i,0,0));a+=d.from-l,l=d.from;let f=e$.build(i.setDoc(n),t,a,c);o=o.replace(l,h,f)}return o.updateHeight(i,0)}static empty(){return new eI(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 n=t[e-1];n.break?t.splice(--e,1,n.left,null,n.right):t.splice(--e,1,n.left,n.right),i+=1+n.break,s-=n.size}else if(o>2*s){let r=t[i];r.break?t.splice(i,1,r.left,null,r.right):t.splice(i,1,r.left,r.right),i+=2+r.break,o-=r.size}else break}else if(s<o){let l=t[e++];l&&(s+=l.size)}else{let h=t[--i];h&&(o+=h.size)}let a=0;return null==t[e-1]?(a=1,e--):null==t[e]&&(a=1,i++),new eq(ez.of(t.slice(0,e)),a,ez.of(t.slice(i)))}}ez.prototype.size=1;class eF extends ez{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,s){return new eP(s,this.length,i,this.height,null,this.deco)}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 eI extends eF{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0}replace(t,e,i){let s=i[0];return 1==i.length&&(s instanceof eI||s instanceof eK&&4&s.flags)&&10>Math.abs(this.length-s.length)?(s instanceof eK?s=new eI(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):ez.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 eK extends ez{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,o=s-i+1,n,r=0;if(t.lineWrapping){let l=Math.min(this.height,t.lineHeight*o);n=l/o,this.length>o+1&&(r=(this.height-l)/(this.length-o-1))}else n=this.height/o;return{firstLine:i,lastLine:s,perLine:n,perChar:r}}blockAt(t,e,i,s){let{firstLine:o,lastLine:n,perLine:r,perChar:l}=this.heightMetrics(e,s);if(e.lineWrapping){let h=s+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),a=e.doc.lineAt(h),c=r+a.length*l,d=Math.max(i,t-c/2);return new eP(a.from,a.length,d,c,null,null)}{let u=Math.max(0,Math.min(n-o,Math.floor((t-i)/r))),{from:f,length:p}=e.doc.line(o+u);return new eP(f,p,i+r*u,r,null,null)}}lineAt(t,e,i,s,o){if(e==eW.ByHeight)return this.blockAt(t,i,s,o);if(e==eW.ByPosNoHeight){let{from:n,to:r}=i.doc.lineAt(t);return new eP(n,r-n,0,0,null,null)}let{firstLine:l,perLine:h,perChar:a}=this.heightMetrics(i,o),c=i.doc.lineAt(t),d=h+c.length*a,u=c.number-l,f=s+h*u+a*(c.from-o-u);return new eP(c.from,c.length,Math.max(s,Math.min(f,s+this.height-d)),d,null,null)}forEachLine(t,e,i,s,o,n){t=Math.max(t,o),e=Math.min(e,o+this.length);let{firstLine:r,perLine:l,perChar:h}=this.heightMetrics(i,o);for(let a=t,c=s;a<=e;){let d=i.doc.lineAt(a);if(a==t){let u=d.number-r;c+=l*u+h*(t-o-u)}let f=l+h*d.length;n(new eP(d.from,d.length,c,f,null,null)),c+=f,a=d.to+1}}replace(t,e,i){let s=this.length-e;if(s>0){let o=i[i.length-1];o instanceof eK?i[i.length-1]=new eK(o.length+s):i.push(null,new eK(s-1))}if(t>0){let n=i[0];n instanceof eK?i[0]=new eK(t+n.length):i.unshift(new eK(t-1),null)}return ez.of(i)}decomposeLeft(t,e){e.push(new eK(t-1),null)}decomposeRight(t,e){e.push(null,new eK(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 n=[],r=Math.max(e,s.from),l=-1;for(s.from>e&&n.push(new eK(s.from-e-1).updateHeight(t,e));r<=o&&s.more;){let h=t.doc.lineAt(r).length;n.length&&n.push(null);let a=s.heights[s.index++];-1==l?l=a:Math.abs(a-l)>=.001&&(l=-2);let c=new eI(h,a);c.outdated=!1,n.push(c),r+=h+1}r<=o&&n.push(null,new eK(o-r).updateHeight(t,r));let d=ez.of(n);return(l<0||Math.abs(d.height-this.height)>=.001||Math.abs(l-this.heightMetrics(t,e).perLine)>=.001)&&(t.heightChanged=!0),d}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class eq extends ez{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==eW.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==eW.ByPosNoHeight?eW.ByPosNoHeight:eW.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,eW.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 r of i)o.push(r);if(t>0&&ej(o,n-1),e<this.length){let l=o.length;this.decomposeRight(e,o),ej(o,l)}return ez.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?ez.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 ej(t,e){let i,s;null==t[e]&&(i=t[e-1])instanceof eK&&(s=t[e+1])instanceof eK&&t.splice(e-1,3,new eK(i.length+1+s.length))}class e${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 i=Math.min(e,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof eI?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new eI(i-this.pos,-1)),this.writtenTo=i,e>i&&(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 eF(o,s,i)):(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 eI(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new eK(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 eI)return t;let e=new eI(0,-1);return this.nodes.push(e),e}addBlock(t){var e;this.enterLine();let i=null===(e=t.deco)||void 0===e?void 0:e.type;i!=ts.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,i!=ts.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 eI||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new eI(0,-1));let i=t;for(let s of this.nodes)s instanceof eI&&s.updateHeight(this.oracle,i),i+=s?s.length:1;return this.nodes}static build(t,e,i,s){let o=new e$(i,t);return l.Xs.spans(e,i,s,o,0),o.finish(i)}}class eG{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,s){(t<e||i&&i.heightRelevant||s&&s.heightRelevant)&&ta(t,e,this.changes,5)}}function e_(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 a=t.parentNode;a&&a!=s.body;)if(1==a.nodeType){let c=a,d=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&"visible"!=d.overflow){let u=c.getBoundingClientRect();n=Math.max(n,u.left),r=Math.min(r,u.right),l=Math.max(l,u.top),h=a==t.parentNode?u.bottom:Math.min(h,u.bottom)}a="absolute"==d.position||"fixed"==d.position?c.offsetParent:c.parentNode}else if(11==a.nodeType)a=a.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)}}function eX(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class eU{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 to.replace({widget:new eY(this.size,t)}).range(this.from,this.to)}}class eY extends ti{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 eZ{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.scaler=e1,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=tF.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(tL).some(t=>"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new eH(e),this.stateDeco=t.facet(tV).filter(t=>"function"!=typeof t),this.heightMap=ez.empty().applyChanges(this.stateDeco,l.xv.empty,this.heightOracle.setDoc(t.doc),[new tW(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=to.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:o,to:n}=this.lineBlockAt(s);t.push(new eJ(o,n))}}this.viewports=t.sort((t,e)=>t.from-e.from),this.scaler=this.heightMap.height<=7e6?e1:new e2(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(1==this.scaler.scale?t:e8(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(tV).filter(t=>"function"!=typeof t);let r=t.changedRanges,h=tW.extendWithRanges(r,(i=this.stateDeco,s=t?t.changes:l.as.empty(this.state.doc.length),o=new eG,l.Xs.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&&!t.state.facet(tM)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,o=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?tF.RTL:tF.LTR;let n=this.heightOracle.mustRefreshForWrapping(o),r=e.getBoundingClientRect(),h=n||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let a=0,c=0,d=parseInt(i.paddingTop)||0,u=parseInt(i.paddingBottom)||0;(this.paddingTop!=d||this.paddingBottom!=u)&&(this.paddingTop=d,this.paddingBottom=u,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(s.lineWrapping&&(h=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let f=(this.printing?eX:e_)(e,this.paddingTop),p=f.top-this.pixelViewport.top,g=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let w=r.width;if((this.contentDOMWidth!=w||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=r.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),h){let v=t.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(v)&&(n=!0),n||s.lineWrapping&&Math.abs(w-this.contentDOMWidth)>s.charWidth){let{lineHeight:b,charWidth:y,textHeight:x}=t.docView.measureTextSize();(n=b>0&&s.refresh(o,b,y,x,w/y,v))&&(t.docView.minWidth=0,a|=8)}for(let S of(p>0&&g>0?c=Math.max(p,g):p<0&&g<0&&(c=Math.min(p,g)),s.heightChanged=!1,this.viewports)){let M=S.from==this.viewport.from?v:t.docView.measureVisibleLineHeights(S);this.heightMap=(n?ez.empty().applyChanges(this.stateDeco,l.xv.empty,this.heightOracle,[new tW(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(s,0,n,new eN(S.from,M))}s.heightChanged&&(a|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return k&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&a||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(n?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}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.heightOracle,{visibleTop:n,visibleBottom:r}=this,l=new eJ(s.lineAt(n-1e3*i,eW.ByHeight,o,0,0).from,s.lineAt(r+(1-i)*1e3,eW.ByHeight,o,0,0).to);if(e){let{head:h}=e.range;if(h<l.from||h>l.to){let a=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=s.lineAt(h,eW.ByPos,o,0,0),d;d="center"==e.y?(c.top+c.bottom)/2-a/2:"start"==e.y||"nearest"==e.y&&h<l.from?c.top:c.bottom-a,l=new eJ(s.lineAt(d-500,eW.ByHeight,o,0,0).from,s.lineAt(d+a+500,eW.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 eJ(this.heightMap.lineAt(i,eW.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,eW.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(t,eW.ByPos,this.heightOracle,0,0),{bottom:o}=this.heightMap.lineAt(e,eW.ByPos,this.heightOracle,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 eU(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!=tF.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 f of(d.empty||u.push(d.to),u))if(f>s&&f<n){h(s,f-10,a,c),h(f+10,n,a,c);return}let p=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(!p){if(n<a.to&&e&&i&&e.visibleRanges.some(t=>t.from<=n&&t.to>=n)){let g=e.moveToLineBoundary(l.jT.cursor(n),!1,!0).head;g>s&&(n=g)}p=new eU(s,n,this.gapSize(a,s,n,c))}r.push(p)};for(let a of this.viewportLines){let c,d;if(a.length<n)continue;let u=function(t,e,i){let s=[],o=t,n=0;return l.Xs.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}}(a.from,a.to,this.stateDeco);if(u.total<n)continue;let f=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let p,g,m=s/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=f){let w=e0(u,f),v=((this.visibleBottom-this.visibleTop)/2+m)/a.height;p=w-v,g=w+v}else p=(this.visibleTop-a.top-m)/a.height,g=(this.visibleBottom-a.top+m)/a.height;c=eQ(u,p),d=eQ(u,g)}else{let b,y,x=u.total*this.heightOracle.charWidth,S=s*this.heightOracle.charWidth;if(null!=f){let M=e0(u,f),k=((this.pixelViewport.right-this.pixelViewport.left)/2+S)/x;b=M-k,y=M+k}else b=(this.pixelViewport.left-S)/x,y=(this.pixelViewport.right+S)/x;c=eQ(u,b),d=eQ(u,y)}c>a.from&&h(a.from,c,a,u),d<a.to&&h(d,a.to,a,u)}return r}gapSize(t,e,i,s){let o=e0(s,i)-e0(s,e);return this.heightOracle.lineWrapping?t.height*o:s.total*this.heightOracle.charWidth*o}updateLineGaps(t){eU.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=to.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.Xs.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},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,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||e8(this.heightMap.lineAt(t,eW.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return e8(this.heightMap.lineAt(this.scaler.fromDOM(t),eW.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return e8(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class eJ{constructor(t,e){this.from=t,this.to=e}}function eQ({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 o=0;;o++){let{from:n,to:r}=e[o],l=r-n;if(s<=l)return n+s;s-=l}}function e0(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 e1={toDOM:t=>t,fromDOM:t=>t,scale:1};class e2{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,eW.ByPos,t,0,0).top,r=e.lineAt(o,eW.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 e8(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),s=e.toDOM(t.bottom);return new eP(t.from,t.length,i,s-i,t.children&&t.children.map(t=>e8(t,e)),t.deco)}let e3=l.r$.define({combine:t=>t.join(" ")}),e9=l.r$.define({combine:t=>t.indexOf(!0)>-1}),e5=h.V.newName(),e4=h.V.newName(),e6=h.V.newName(),e7={"&light":"."+e4,"&dark":"."+e6};function it(t,e,i){return new h.V(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 ie=it("."+e5,{"&":{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,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 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .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-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},e7);class ii{constructor(t,e,i,s){this.typeOver=s,this.bounds=null,this.text="";let{impreciseHead:o,impreciseAnchor:n}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let r=o||n?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:n}=t.observer.selectionRange;return i&&(e.push(new t3(i,s)),(o!=i||n!=s)&&e.push(new t3(o,n))),e}(t),h=new t2(r,t.state);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.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.jT.single(i+e,s+e):null}(r,this.bounds.from)}else{let a=t.observer.selectionRange,c=o&&o.node==a.focusNode&&o.offset==a.focusOffset||!d(t.contentDOM,a.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(a.focusNode,a.focusOffset),u=n&&n.node==a.anchorNode&&n.offset==a.anchorOffset||!d(t.contentDOM,a.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(a.anchorNode,a.anchorOffset);this.newSel=l.jT.single(u,c)}}}function is(t,e){let i;let{newSel:s}=e,o=t.state.selection.main;if(e.bounds){let{from:n,to:r}=e.bounds,h=o.from,a=null;(8===t.inputState.lastKeyCode&&t.inputState.lastKeyTime>Date.now()-100||q.android&&e.text.length<r-n)&&(h=o.to,a="end");let c=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 h=Math.max(0,n-Math.min(r,l));i-=r+h-n}if(r<n&&t.length<e.length){let a=i<=n&&i>=r?n-i:0;n-=a,l=n+(l-r),r=n}else if(l<n){let c=i<=n&&i>=l?n-i:0;n-=c,r=n+(r-l),l=n}return{from:n,toA:r,toB:l}}(t.state.doc.sliceString(n,r,"￿"),e.text,h-n,a);c&&(q.chrome&&13==t.inputState.lastKeyCode&&c.toB==c.from+2&&"￿￿"==e.text.slice(c.from,c.toB)&&c.toB--,i={from:n+c.from,to:n+c.toA,insert:l.xv.of(e.text.slice(c.from,c.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))}:(q.mac||q.android)&&i&&i.from==i.to&&i.from==o.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(s&&2==i.insert.length&&(s=l.jT.single(s.main.anchor-1,s.main.head-1)),i={from:o.from,to:o.to,insert:l.xv.of([" "])}):q.chrome&&i&&i.from==i.to&&i.from==o.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(s&&(s=l.jT.single(s.main.anchor-1,s.main.head-1)),i={from:o.from,to:o.to,insert:l.xv.of([" "])}),i){let d,u=t.state;if(q.ios&&t.inputState.flushIOSKey(t)||q.android&&(i.from==o.from&&i.to==o.to&&1==i.insert.length&&2==i.insert.lines&&M(t.contentDOM,"Enter",13)||i.from==o.from-1&&i.to==o.to&&0==i.insert.length&&M(t.contentDOM,"Backspace",8)||i.from==o.from&&i.to==o.to+1&&0==i.insert.length&&M(t.contentDOM,"Delete",46)))return!0;let f=i.insert.toString();if(t.state.facet(ty).some(e=>e(t,i.from,i.to,f)))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 p=o.from<i.from?u.sliceDoc(o.from,i.from):"",g=o.to>i.to?u.sliceDoc(i.to,o.to):"";d=u.replaceSelection(t.state.toText(p+i.insert.sliceString(0,void 0,t.state.lineBreak)+g))}else{let m=u.changes(i),w=s&&s.main.to<=m.newLength?s.main:void 0;if(u.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=o.to&&i.to>=o.to-10){let v=t.state.sliceDoc(i.from,i.to),b=t4(t)||t.state.doc.lineAt(o.head),y=o.to-i.to,x=o.to-o.from;d=u.changeByRange(e=>{if(e.from==o.from&&e.to==o.to)return{changes:m,range:w||e.map(m)};let s=e.to-y,n=s-v.length;if(e.to-e.from!=x||t.state.sliceDoc(n,s)!=v||b&&e.to>=b.from&&e.from<=b.to)return{range:e};let r=u.changes({from:n,to:s,insert:i.insert}),h=e.to-o.to;return{changes:r,range:w?l.jT.range(Math.max(0,w.anchor+h),Math.max(0,w.head+h)):e.map(r)}})}else d={changes:m,selection:w&&u.selection.replaceRange(w)}}let S="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,S+=".compose",t.inputState.compositionFirstChange&&(S+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(d,{scrollIntoView:!0,userEvent:S}),!0}if(!s||s.main.eq(o))return!1;{let k=!1,C="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(k=!0),C=t.inputState.lastSelectionOrigin),t.dispatch({selection:s,scrollIntoView:k,userEvent:C}),!0}}let io={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ir=q.ie&&q.ie_version<=11;class il{constructor(t){this.view=t,this.active=!1,this.selectionRange=new b,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let i of e)this.queue.push(i);(q.ie&&q.ie_version<=11||q.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()}),ir&&(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.resizeScroll=new ResizeObserver(()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM),this.resizeContent=new ResizeObserver(()=>this.view.requestMeasure()),this.resizeContent.observe(t.contentDOM)),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")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(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}(q.ie&&q.ie_version<=11||q.android&&q.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=q.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 o=i.childNodes[s-1];"false"==o.contentEditable?s--:s=w(i=o)}else{if(i==t)return!0;s=g(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 s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);for(let o of this.scrollTargets=e)o.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,io),ir&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),ir&&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 s=()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),!this.flush()&&t.force&&M(this.dom,t.key,t.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,s=!1;for(let o of t){let n=this.readMutation(o);n&&(n.typeOver&&(s=!0),-1==e?{from:e,to:i}=n:(e=Math.min(n.from,e),i=Math.max(n.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 ii(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=is(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=ih(e,t.previousSibling||t.target.previousSibling,-1),s=ih(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,s;for(let o of(this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),null===(s=this.resizeContent)||void 0===s||s.disconnect(),this.scrollTargets))o.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 ih(t,e,i){for(;e;){let s=A.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 ia{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: fixed; 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 eZ(t.state||l.yy.create(t)),this.plugins=this.state.facet(tT).map(t=>new tR(t)),this.plugins))e.update(this);this.observer=new il(this),this.inputState=new ea(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new t9(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}dispatch(...t){this._dispatch(1==t.length&&t[0]instanceof l.YW?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 n of t){if(n.startState!=o)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=n.state}if(this.destroyed){this.viewState.state=o;return}let r=this.hasFocus,h=0,a=null;t.some(t=>t.annotation(eR))?(this.inputState.notifiedFocused=r,h=1):r==this.inputState.notifiedFocused||(this.inputState.notifiedFocused=r,(a=eB(o,r))||(h=1));let c=this.observer.delayedAndroidKey,d=null;if(c?(this.observer.clearDelayedAndroidKey(),((d=this.observer.readChange())&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(d=null)):this.observer.clear(),o.facet(l.yy.phrases)!=this.state.facet(l.yy.phrases))return this.setState(o);s=tz.create(this,o,t),s.flags|=h;let u=this.viewState.scrollTarget;try{for(let f of(this.updateState=2,t)){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:p}=f.state.selection;u=new tk(p.empty?p:l.jT.cursor(p.head,p.head>p.anchor?-1:1))}for(let g of f.effects)g.is(tC)&&(u=g.value)}this.viewState.update(s,u),this.bidiCache=iu.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),e=this.docView.update(s),this.state.facet(tP)!=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(e3)!=s.state.facet(e3)&&(this.viewState.mustMeasureContent=!0),(e||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!s.empty)for(let m of this.state.facet(tb))m(s);(a||d)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),d&&!is(this,d)&&c.force&&M(this.contentDOM,c.key,c.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 i of this.plugins)i.destroy(this);for(let s of(this.viewState=new eZ(t),this.plugins=t.facet(tT).map(t=>new tR(t)),this.pluginMap.clear(),this.plugins))s.update(this);this.docView=new t9(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(tT),i=t.state.facet(tT);if(e!=i){let s=[];for(let o of i){let n=e.indexOf(o);if(n<0)s.push(new tR(o));else{let r=this.plugins[n];r.mustUpdate=t,s.push(r)}}for(let l of this.plugins)l.mustUpdate!=t&&l.destroy(this);this.plugins=s,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let h of this.plugins)h.mustUpdate=t;for(let a=0;a<this.plugins.length;a++)this.plugins[a].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&this.win.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 r=0;;r++){this.updateState=1;let l=this.viewport,h=this.viewState.lineBlockAtHeight(n),a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(r>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];4&a||([this.measureRequests,c]=[c,this.measureRequests]);let d=c.map(t=>{try{return t.read(this)}catch(e){return tD(this.state,e),id}}),u=tz.create(this,this.state,[]),f=!1,p=!1;u.flags|=a,e?e.flags|=a:e=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u));for(let g=0;g<c.length;g++)if(d[g]!=id)try{let m=c[g];m.write&&m.write(d[g],this)}catch(w){tD(this.state,w)}if(this.viewState.editorHeight){if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,p=!0;else{let v=this.viewState.lineBlockAt(h.from).top-h.top;(v>1||v<-1)&&(this.scrollDOM.scrollTop+=v,p=!0)}}if(f&&this.docView.updateSelection(!0),this.viewport.from==l.from&&this.viewport.to==l.to&&!p&&0==this.measureRequests.length)break}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let b of this.state.facet(tb))b(e)}get themeClasses(){return e5+" "+(this.state.facet(e9)?e6:e4)+" "+this.state.facet(e3)}updateAttrs(){let t=ip(this,tB,{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:`${q.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),ip(this,tL,e);let i=this.observer.ignore(()=>{let i=te(this.contentDOM,this.contentAttrs,e),s=te(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 s of i.effects)s.is(ia.announce)&&(e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=s.value)}mountStyles(){this.styleModules=this.state.facet(tP),h.V.mount(this.root,this.styleModules.concat(ie).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&&!(this.measureRequests.indexOf(t)>-1)){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 eh(this,t,el(this,t,e,i))}moveByGroup(t,e){return eh(this,t,el(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.D0.Space&&(o=e),o==e}}))}moveToLineBoundary(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 r=t.dom.getBoundingClientRect(),h=t.textDirectionAt(o.from),a=t.posAtCoords({x:i==(h==tF.LTR)?r.right-1:r.left+1,y:(n.top+n.bottom)/2});if(null!=a)return l.jT.cursor(a,i?-1:1)}let c=tc.find(t.docView,e.head),d=c?i?c.posAtEnd:c.posAtStart:i?o.to:o.from;return l.jT.cursor(d,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return eh(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.jT.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 u=t.viewState.lineBlockAt(o);null==r&&(r=Math.min(a.right-a.left,t.defaultCharacterWidth*(o-u.from))),h=(n<0?u.top:u.bottom)+d}let f=a.left+r,p=null!=s?s:t.defaultLineHeight>>1;for(let g=0;;g+=10){let m=h+(p+g)*n,w=en(t,{x:f,y:m},!1,n);if(m<a.top||m>a.bottom||(n<0?w<o:w>o))return l.jT.cursor(w,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(),en(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 v(i,o[tJ.find(o,t-s.from,-1,e)].dir==tF.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>ic)return t0(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 s=function(t,e){let i=t.length,s=e==tI?1:2,o=e==tI?2:1;if(!t||1==s&&!tZ.test(t))return t0(i);for(let n=0,r=s,l=s;n<i;n++){var h;let a=(h=t.charCodeAt(n))<=247?tj[h]:1424<=h&&h<=1524?2:1536<=h&&h<=1785?t$[h-1536]:1774<=h&&h<=2220?4:8192<=h&&h<=8203?256:64336<=h&&h<=65023?4:8204==h?256:1;512==a?a=r:8==a&&4==l&&(a=16),tQ[n]=4==a?2:a,7&a&&(l=a),r=a}for(let c=0,d=s,u=s;c<i;c++){let f=tQ[c];if(128==f)c<i-1&&d==tQ[c+1]&&24&d?f=tQ[c]=d:tQ[c]=256;else if(64==f){let p=c+1;for(;p<i&&64==tQ[p];)p++;let g=c&&8==d||p<i&&8==tQ[p]?1==u?1:8:256;for(let m=c;m<p;m++)tQ[m]=g;c=p-1}else 8==f&&1==u&&(tQ[c]=1);d=f,7&f&&(u=f)}for(let w=0,v=0,b=0,y,x,S;w<i;w++)if(x=tG[y=t.charCodeAt(w)]){if(x<0){for(let M=v-3;M>=0;M-=3)if(t_[M+1]==-x){let k=t_[M+2],C=2&k?s:4&k?1&k?o:s:0;C&&(tQ[w]=tQ[t_[M]]=C),v=M;break}}else if(189==t_.length)break;else t_[v++]=w,t_[v++]=y,t_[v++]=b}else if(2==(S=tQ[w])||1==S){let D=S==s;b=D?0:1;for(let A=v-3;A>=0;A-=3){let O=t_[A+2];if(2&O)break;if(D)t_[A+2]|=2;else{if(4&O)break;t_[A+2]|=4}}}for(let T=0;T<i;T++)if(256==tQ[T]){let E=T+1;for(;E<i&&256==tQ[E];)E++;let R=(T?tQ[T-1]:s)==1,B=R==((E<i?tQ[E]:s)==1)?R?1:2:s;for(let L=T;L<E;L++)tQ[L]=B;T=E-1}let V=[];if(1==s)for(let H=0;H<i;){let N=H,P=1!=tQ[H++];for(;H<i&&P==(1!=tQ[H]);)H++;if(P)for(let W=H;W>N;){let z=W,F=2!=tQ[--W];for(;W>N&&F==(2!=tQ[W-1]);)W--;V.push(new tJ(W,z,F?2:1))}else V.push(new tJ(N,H,0))}else for(let I=0;I<i;){let K=I,q=2==tQ[I++];for(;I<i&&q==(2==tQ[I]);)I++;V.push(new tJ(K,I,q?1:2))}return V}(t.text,e);return this.bidiCache.push(new iu(t.from,t.to,e,s)),s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||q.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{x(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&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return tC.of(new tk("number"==typeof t?l.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return tE.define(()=>({}),{eventHandlers:t})}static theme(t,e){let i=h.V.newName(),s=[e3.of(i),tP.of(it(`.${i}`,t))];return e&&e.dark&&s.push(e9.of(!0)),s}static baseTheme(t){return l.Wl.lowest(tP.of(it("."+e5,t,e7)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&A.get(i)||A.get(t);return(null===(e=null==s?void 0:s.rootView)||void 0===e?void 0:e.view)||null}}ia.styleModule=tP,ia.inputHandler=ty,ia.focusChangeEffect=tx,ia.perLineTextDirection=tS,ia.exceptionSink=tv,ia.updateListener=tb,ia.editable=tA,ia.mouseSelectionStyle=tw,ia.dragMovesSelection=tm,ia.clickAddsSelectionRange=tg,ia.decorations=tV,ia.atomicRanges=tH,ia.scrollMargins=tN,ia.darkTheme=e9,ia.contentAttributes=tL,ia.editorAttributes=tB,ia.lineWrapping=ia.contentAttributes.of({class:"cm-lineWrapping"}),ia.announce=l.Py.define();let ic=4096,id={};class iu{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:tF.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 iu(e.mapPos(n.from,1),e.mapPos(n.to,-1),n.dir,n.order))}return i}}function ip(t,e,i){for(let s=t.state.facet(e),o=s.length-1;o>=0;o--){let n=s[o],r="function"==typeof n?n(t):n;r&&Q(r,i)}return i}let ig=q.mac?"mac":q.windows?"win":q.linux?"linux":"key";function im(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 iw=l.Wl.default(ia.domEventHandlers({keydown(t,e){let i,s;return function(t,e,i,s){let o=(0,a.YG)(e),n=(0,l.gm)(o,0),r=(0,l.nZ)(n)==o.length&&" "!=o,h="",c=!1;iy&&iy.view==i&&iy.scope==s&&(h=iy.prefix+" ",(c=0>eu.indexOf(e.keyCode))&&(iy=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,g;if(f){if(u(f[h+im(o,e,!r)]))return!0;if(r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(q.windows&&e.ctrlKey&&e.altKey)&&(p=a.ue[e.keyCode])&&p!=o){if(u(f[h+im(p,e,!0)])||e.shiftKey&&(g=a.uY[e.keyCode])!=o&&g!=p&&u(f[h+im(g,e,!1)]))return!0}else if(r&&e.shiftKey&&u(f[h+im(o,e,!0)]))return!0;if(u(f._any))return!0}return c}((i=e.state.facet(iv),(s=ib.get(i))||ib.set(i,s=function(t,e=ig){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;let r=t.split(/-(?!$)/),l=r[r.length-1];"Space"==l&&(l=" ");for(let h=0;h<r.length-1;++h){let a=r[h];if(/^(cmd|meta|m)$/i.test(a))n=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))"mac"==e?n=!0:s=!0;else throw Error("Unrecognized modifier name: "+a)}return i&&(l="Alt-"+l),s&&(l="Ctrl-"+l),n&&(l="Meta-"+l),o&&(l="Shift-"+l),l})(t,e));for(let d=1;d<c.length;d++){let u=c.slice(0,d).join(" ");o(u,!0),a[u]||(a[u]={preventDefault:!0,run:[e=>{let i=iy={view:e,prefix:u,scope:t};return setTimeout(()=>{iy==i&&(iy=null)},4e3),!0}]})}let f=c.join(" ");o(f,!1);let p=a[f]||(a[f]={preventDefault:!1,run:(null===(h=null===(l=a._any)||void 0===l?void 0:l.run)||void 0===h?void 0:h.slice())||[]});n&&p.run.push(n),r&&(p.preventDefault=!0)};for(let r of t){let l=r.scope?r.scope.split(" "):["editor"];if(r.any)for(let h of l){let a=i[h]||(i[h]=Object.create(null));for(let c in a._any||(a._any={preventDefault:!1,run:[]}),a)a[c].run.push(r.any)}let d=r[e]||r.key;if(d)for(let u of l)n(u,d,r.run,r.preventDefault),r.shift&&n(u,"Shift-"+d,r.shift,r.preventDefault)}return i}(i.reduce((t,e)=>t.concat(e),[]))),s),t,e,"editor")}})),iv=l.r$.define({enables:iw}),ib=new WeakMap,iy=null;class ix{constructor(t,e,i,s,o){this.className=t,this.left=e,this.top=i,this.width=s,this.height=o}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(!i.empty)return function(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let s=Math.max(i.from,t.viewport.from),o=Math.min(i.to,t.viewport.to),n=t.textDirection==tF.LTR,r=t.contentDOM,l=r.getBoundingClientRect(),h=iS(t),a=r.querySelector(".cm-line"),c=a&&window.getComputedStyle(a),d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),f=ik(t,s),p=ik(t,o),g=f.type==ts.Text?f:null,m=p.type==ts.Text?p:null;if(t.lineWrapping&&(g&&(g=iM(t,s,g)),m&&(m=iM(t,o,m))),g&&m&&g.from==m.from)return x(S(i.from,i.to,g));{let w=g?S(i.from,null,g):M(f,!1),v=m?S(null,i.to,m):M(p,!0),b=[];return(g||f).to<(m||p).from-1?b.push(y(d,w.bottom,u,v.top)):w.bottom<v.top&&t.elementAtHeight((w.bottom+v.top)/2).type==ts.Text&&(w.bottom=v.top=(w.bottom+v.top)/2),x(w).concat(b).concat(x(v))}function y(t,i,s,o){return new ix(e,t-h.left,i-h.top-.01,s-t,o-i+.01)}function x({top:t,bottom:e,horizontal:i}){let s=[];for(let o=0;o<i.length;o+=2)s.push(y(i[o],t,i[o+1],e));return s}function S(e,i,s){let o=1e9,r=-1e9,l=[];function h(e,i,h,a,c){let f=t.coordsAtPos(e,e==s.to?-2:2),p=t.coordsAtPos(h,h==s.from?2:-2);f&&p&&(o=Math.min(f.top,p.top,o),r=Math.max(f.bottom,p.bottom,r),c==tF.LTR?l.push(n&&i?d:f.left,n&&a?u:p.right):l.push(!n&&a?d:p.left,!n&&i?u:f.right))}let a=null!=e?e:s.from,c=null!=i?i:s.to;for(let f of t.visibleRanges)if(f.to>a&&f.from<c)for(let p=Math.max(f.from,a),g=Math.min(f.to,c);;){let m=t.state.doc.lineAt(p);for(let w of t.bidiSpans(m)){let v=w.from+m.from,b=w.to+m.from;if(v>=g)break;b>p&&h(Math.max(v,p),null==e&&v<=a,Math.min(b,g),null==i&&b>=c,w.dir)}if((p=m.to+1)>=g)break}return 0==l.length&&h(a,null==e,c,null==i,t.textDirection),{top:o,bottom:r,horizontal:l}}function M(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i);{let s=t.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let o=iS(t);return[new ix(e,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}}}function iS(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==tF.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.jT.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:ts.Text}}function ik(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type)){for(let s of i.type)if(s.to>e||s.to==e&&(s.to==i.to||s.type==ts.Text))return s}return i}let iC=!q.ios,iD={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};function iA(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)}iC&&(iD[".cm-line"].caretColor="transparent !important");class iO{constructor(t){let{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.f_,i=e.add.bind(e);for(let{from:s,to:o}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))iA(t.state.doc,this.regexp,s,o,(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 l=t.state.doc.lineAt(n),h=l.to<r?t.state.doc.lineAt(r):l,a=Math.max(o.from,l.from),c=Math.min(o.to,h.to);if(this.boundary){for(;n>l.from;n--)if(this.boundary.test(l.text[n-1-l.from])){a=n;break}for(;r<h.to;r++)if(this.boundary.test(h.text[r-h.from])){c=r;break}}let d=[],u,f=(t,e,i)=>d.push(i.range(t,e));if(l==h)for(this.regexp.lastIndex=a-l.from;(u=this.regexp.exec(l.text))&&u.index<c-l.from;)this.addMatch(u,t,u.index+l.from,f);else iA(t.state.doc,this.regexp,a,c,(e,i)=>this.addMatch(i,t,e,f));e=e.update({filterFrom:a,filterTo:c,filter:(t,e)=>t<a||e>c,add:d})}}return e}}let iT=null!=/x/.unicode?"gu":"g",iE=RegExp("[\0-\b\n-\x1f\x7f-\x9f\xad؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF￹-￼]",iT),iR={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"},iB=null,iL=l.r$.define({combine(t){let e=(0,l.BO)(t,{render:null,specialChars:iE,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==iB&&"undefined"!=typeof document&&document.body){let e=document.body.style;iB=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)!=null}return iB||!1}())&&(e.specialChars=RegExp("	|"+e.specialChars.source,iT)),e.addSpecialChars&&(e.specialChars=RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,iT)),e}});function iV(t={}){return[iL.of(t),iH||(iH=tE.fromClass(class{constructor(t){this.view=t,this.decorations=to.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(iL)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new iO({regexp:t.specialChars,decoration:(e,i,s)=>{let{doc:o}=i.state,n=(0,l.gm)(e[0],0);if(9==n){let r=o.lineAt(s),h=i.state.tabSize,a=(0,l.IS)(r.text,h,s-r.from);return to.replace({widget:new iP((h-a%h)*this.view.defaultCharacterWidth)})}return this.decorationCache[n]||(this.decorationCache[n]=to.replace({widget:new iN(t,n)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(iL);t.startState.facet(iL)!=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 iH=null;class iN extends ti{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")+" "+(iR[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 iP extends ti{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 iW(){return iF}let iz=to.line({class:"cm-activeLine"}),iF=tE.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(iz.range(o.from)),e=o.from)}return to.set(i)}},{decorations:t=>t.decorations}),iI="-10000px";class iK{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 o of this.tooltipViews)o.update&&o.update(t);return!1}let n=[];for(let r=0;r<s.length;r++){let l=s[r],h=-1;if(l){for(let a=0;a<this.tooltips.length;a++){let c=this.tooltips[a];c&&c.create==l.create&&(h=a)}if(h<0)n[r]=this.createTooltipView(l);else{let d=n[r]=this.tooltipViews[h];d.update&&d.update(t)}}}for(let u of this.tooltipViews)0>n.indexOf(u)&&(u.dom.remove(),null===(e=u.destroy)||void 0===e||e.call(u));return this.input=i,this.tooltips=s,this.tooltipViews=n,!0}}function iq(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}let ij=l.r$.define({combine(t){var e,i,s;return{position:q.ios?"absolute":(null===(e=t.find(t=>t.position))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find(t=>t.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(s=t.find(t=>t.tooltipSpace))||void 0===s?void 0:s.tooltipSpace)||iq}}}),i$=new WeakMap,iG=tE.fromClass(class{constructor(t){this.view=t,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(ij);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 iK(t,iU,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(ij);if(s.position!=this.position){for(let o of(this.position=s.position,this.manager.tooltipViews))o.dom.style.position=this.position;i=!0}if(s.parent!=this.parent){for(let n of(this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(n.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 i=document.createElement("div");i.className="cm-tooltip-arrow",e.dom.appendChild(i)}return e.dom.style.position=this.position,e.dom.style.top=iI,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;for(let i of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))i.dom.remove(),null===(t=i.destroy)||void 0===t||t.call(i);null===(e=this.intersectionObserver)||void 0===e||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(ij).tooltipSpace(this.view)}}writeMeasure(t){var e;let{editor:i,space:s}=t,o=[];for(let n=0;n<this.manager.tooltips.length;n++){let r=this.manager.tooltips[n],l=this.manager.tooltipViews[n],{dom:h}=l,a=t.pos[n],c=t.size[n];if(!a||a.bottom<=Math.max(i.top,s.top)||a.top>=Math.min(i.bottom,s.bottom)||a.right<Math.max(i.left,s.left)-.1||a.left>Math.min(i.right,s.right)+.1){h.style.top=iI;continue}let d=r.arrow?l.dom.querySelector(".cm-tooltip-arrow"):null,u=d?7:0,f=c.right-c.left,p=null!==(e=i$.get(l))&&void 0!==e?e:c.bottom-c.top,g=l.offset||iX,m=this.view.textDirection==tF.LTR,w=c.width>s.right-s.left?m?s.left:s.right-c.width:m?Math.min(a.left-(d?14:0)+g.x,s.right-f):Math.max(s.left,a.left-f+(d?14:0)-g.x),v=!!r.above;!r.strictSide&&(v?a.top-(c.bottom-c.top)-g.y<s.top:a.bottom+(c.bottom-c.top)+g.y>s.bottom)&&v==s.bottom-a.bottom>a.top-s.top&&(v=!v);let b=(v?a.top-s.top:s.bottom-a.bottom)-u;if(b<p&&!1!==l.resize){if(b<this.view.defaultLineHeight){h.style.top=iI;continue}i$.set(l,p),h.style.height=(p=b)+"px"}else h.style.height&&(h.style.height="");let y=v?a.top-p-u-g.y:a.bottom+u+g.y,x=w+f;if(!0!==l.overlap)for(let S of o)S.left<x&&S.right>w&&S.top<y+p&&S.bottom>y&&(y=v?S.top-p-2-u:S.bottom+u+2);"absolute"==this.position?(h.style.top=y-t.parent.top+"px",h.style.left=w-t.parent.left+"px"):(h.style.top=y+"px",h.style.left=w+"px"),d&&(d.style.left=`${a.left+(m?g.x:-g.x)-(w+14-7)}px`),!0!==l.overlap&&o.push({left:w,top:y,right:x,bottom:y+p}),h.classList.toggle("cm-tooltip-above",v),h.classList.toggle("cm-tooltip-below",!v),l.positioned&&l.positioned(t.space)}}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=iI}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),i_=ia.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&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"}}}),iX={x:0,y:0},iU=l.r$.define({enables:[iG,i_]}),iY=l.r$.define();class iZ{constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new iK(t,iY,t=>this.createHostedView(t))}static create(t){return new iZ(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(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}}function iJ(t,e){let i=t.plugin(iG);if(!i)return null;let s=i.manager.tooltips.indexOf(e);return s<0?null:i.manager.tooltipViews[s]}let iQ=l.r$.define({combine(t){let e,i;for(let s of t)e=e||s.topContainer,i=i||s.bottomContainer;return{topContainer:e,bottomContainer:i}}}),i0=tE.fromClass(class{constructor(t){this.input=t.state.facet(i8),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet(iQ);for(let i of(this.top=new i1(t,!0,e.topContainer),this.bottom=new i1(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(iQ);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new i1(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new i1(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(i8);if(i!=this.input){let s=i.filter(t=>t),o=[],n=[],r=[],l=[];for(let h of s){let a=this.specs.indexOf(h),c;a<0?(c=h(t.view),l.push(c)):(c=this.panels[a]).update&&c.update(t),o.push(c),(c.top?n:r).push(c)}for(let d of(this.specs=s,this.panels=o,this.top.sync(n),this.bottom.sync(r),l))d.dom.classList.add("cm-panel"),d.mount&&d.mount()}else for(let u of this.panels)u.update&&u.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>ia.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class i1{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 e=this.dom.firstChild;for(let i of this.panels)if(i.dom.parentNode==this.dom){for(;e!=i.dom;)e=i2(e);e=e.nextSibling}else this.dom.insertBefore(i.dom,e);for(;e;)e=i2(e)}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)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function i2(t){let e=t.nextSibling;return t.remove(),e}let i8=l.r$.define({enables:i0});class i3 extends l.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}i3.prototype.elementClass="",i3.prototype.toDOM=void 0,i3.prototype.mapMode=l.gc.TrackBefore,i3.prototype.startSide=i3.prototype.endSide=-1,i3.prototype.point=!0;let i9=l.r$.define(),i5=l.r$.define(),i4=l.r$.define({combine:t=>t.some(t=>t)}),i6=tE.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(i5).map(e=>new si(t,e)),this.gutters))this.dom.appendChild(e.dom);this.fixed=!t.state.facet(i4),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(i4)!=!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.Xs.iter(this.view.state.facet(i9),this.view.viewport.from),s=[],o=this.gutters.map(t=>new se(t,this.view.viewport,-this.view.documentPadding.top));for(let n of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(n.type)){let r=!0;for(let h of n.type)if(h.type==ts.Text&&r){for(let a of(st(i,s,h.from),o))a.line(this.view,h,s);r=!1}else if(h.widget)for(let c of o)c.widget(this.view,h)}else if(n.type==ts.Text)for(let d of(st(i,s,n.from),o))d.line(this.view,n,s);for(let u of o)u.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(i5),i=t.state.facet(i5),s=t.docChanged||t.heightChanged||t.viewportChanged||!l.Xs.eq(t.startState.facet(i9),t.state.facet(i9),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let o of this.gutters)o.update(t)&&(s=!0);else{s=!0;let n=[];for(let r of i){let h=e.indexOf(r);h<0?n.push(new si(this.view,r)):(this.gutters[h].update(t),n.push(this.gutters[h]))}for(let a of this.gutters)a.dom.remove(),0>n.indexOf(a)&&a.destroy();for(let c of n)this.dom.appendChild(c.dom);this.gutters=n}return s}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>ia.scrollMargins.of(e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==tF.LTR?{left:i.dom.offsetWidth}:{right:i.dom.offsetWidth}:null})});function i7(t){return Array.isArray(t)?t:[t]}function st(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class se{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=l.Xs.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:s}=this,o=e.top-this.height;if(this.i==s.elements.length){let n=new ss(t,e.height,o,i);s.elements.push(n),s.dom.appendChild(n.dom)}else s.elements[this.i].update(t,e.height,o,i);this.height=e.bottom,this.i++}line(t,e,i){let s=[];st(this.cursor,s,e.from),i.length&&(s=s.concat(i));let o=this.gutter.config.lineMarker(t,e,s);o&&s.unshift(o);let n=this.gutter;(0!=s.length||n.config.renderEmptyElements)&&this.addElement(t,e,s)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e);i&&this.addElement(t,e,[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 si{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="cm-gutter"+(this.config.class?" "+this.config.class:""),e.domEventHandlers)this.dom.addEventListener(i,s=>{let o=s.target,n;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let r=o.getBoundingClientRect();n=(r.top+r.bottom)/2}else n=s.clientY;let l=t.lineBlockAtHeight(n-t.documentTop);e.domEventHandlers[i](t,l,s)&&s.preventDefault()});this.markers=i7(e.markers(t)),e.initialSpacer&&(this.spacer=new ss(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=i7(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],t);i!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[i])}let s=t.view.viewport;return!l.Xs.eq(this.markers,e,s.from,s.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class ss{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 a=l.elementClass;a&&(i+=" "+a);for(let c=n;c<this.markers.length;c++)if(this.markers[c].compare(l)){r=c,h=!0;break}}else r=this.markers.length;for(;n<r;){let d=this.markers[n++];if(d.toDOM){d.destroy(s);let u=s.nextSibling;s.remove(),s=u}}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 so=l.r$.define(),sn=l.r$.define({combine:t=>(0,l.BO)(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let s in e){let o=i[s],n=e[s];i[s]=o?(t,e,i)=>o(t,e,i)||n(t,e,i):n}return i}})});class sr extends i3{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function sl(t,e){return t.state.facet(sn).formatNumber(e,t.state)}let sh=i5.compute([sn],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(so),lineMarker:(t,e,i)=>i.some(t=>t.toDOM)?null:new sr(sl(t,t.state.doc.lineAt(e.from).number)),widgetMarker:()=>null,lineMarkerChange:t=>t.startState.facet(sn)!=t.state.facet(sn),initialSpacer:t=>new sr(sl(t,sc(t.state.doc.lines))),updateSpacer(t,e){let i=sl(e.view,sc(e.view.state.doc.lines));return i==t.number?t:new sr(i)},domEventHandlers:t.facet(sn).domEventHandlers}));function sa(t={}){var e;let i;return[sn.of(t),(i=[i6],e&&!1===e.fixed&&i.push(i4.of(!0)),i),sh]}function sc(t){let e=9;for(;e<t;)e=10*e+9;return e}}}]);